This repo contains a number of bots for the Mangrove ecosystem - each provided as a separate package.
The core contracts for Mangrove with example Solidity offer logics live in the mangrove-core repo.
The SDK for Mangrove lives in the mangrove.js repo.
If you are looking for the Mangrove developer documentation, the main site to go to is docs.mangrove.exchange.
Each package also contains a README.md with package-specific documentation.
For Linux or macOS everything should work out of the box, if you are using Windows, then we recommend installing everything from within WSL2 and expect some quirks.
-
Node.js 14.14+, we recommend installation through nvm, e.g.:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash # Reopen shell $ nvm install --lts
-
Yarn 2, with Node.js >= 16.10:
$ corepack enable
-
$ curl -L https://foundry.paradigm.xyz | bash # Reopen shell $ foundryup
-
Clone the git repo with sub-modules
$ git clone --recurse-submodules https://github.com/mangrovedao/mangrove-bots.git # Or set the global git config once: git config --global submodule.recurse true
The following sections describe the most common use cases in this repo.
After first cloning the repo, you should run yarn install
in the root folder.
$ yarn install
The you need to setup the local environment (still in the root folder) - here we configure all packages identically, but they can also be configured individually:
$ cp .env.local.example .env.test.local
$ find ./packages/ -name '.env.local.example' | while read line ; do ln -s $(readlink -f ./.env.test.local) $(dirname $line) ; done
Then open .env.test.local
in your favorite editor and put in settings for, e.g., node urls, for instance pointing to Alchemy.
To build, run
$ yarn build
This can also be done from a specific package in ./packages/<somePackage>
and only builds that package and its dependencies.
If you encounter issues with JavaScript memory consumption, then try increasing the max available space for heap, and try again:
$ export NODE_OPTIONS="$NODE_OPTIONS --max_old_space_size=4096"
$ yarn build
To run tests, run
$ yarn test
This can also be done from a specific package in ./packages/<somePackage>
to run tests for that specific package.
For more details on how to use Yarn and Yarn workspaces, see the Yarn 2 CLI documentation and for more details on our usage of yarn, see yarn details.
The repo root contains the following folders and files:
.
├── .github/ # GitHub related files, in particular CI configurations for GitHub Actions
├── .husky/ # Husky Git hooks, e.g. for auto formatting
├── .yarn/ # Yarn files
├── packages/ # The actual bot packages
├── .gitattributes # Git attributes for the whole monorepo
├── .gitignore # Git ignore for the whole monorepo
├── .yarnrc.yml # Yarn 2 configuration
├── LICENSES # Overview of the licenses that apply to this repo
├── README.md # This README file
├── package.json # Package file with dependencies and scripts for the monorepo
└── yarn.lock # Yarn lock file ensuring consistent installs across machines
We use Husky to manage our Git hooks.
The Git hook scripts are in the .husky/
folder.
We currently deploy several bot packages to Heroku. To disable Husky from running on a Heroku deploy, we use pinst package and two heroku-specific scripts
in the top-level package.json
:
{
...
"heroku-postbuild": "pinst --disable && yarn build",
"heroku-cleanup": "pinst --enable",
...
}
Note that when Heroku detects a heroku-postbuild
it does not run the build
script, so we need to invoke that specifically.