Skip to content

🌴 Bots for the Mangrove ecosystem

Notifications You must be signed in to change notification settings

mangrovedao/mangrove-bots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CI

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.

Documentation

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.

Prerequisites

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.

  1. 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
  2. Yarn 2, with Node.js >= 16.10:

    $ corepack enable
  3. Foundry:

    $ curl -L https://foundry.paradigm.xyz | bash
    # Reopen shell
    $ foundryup
  4. 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

Usage

The following sections describe the most common use cases in this repo.

Initial setup

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.

Build

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

Test

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.

Usage details and how to add packages

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.

Structure and contents of this monorepo

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

Git hooks and Husky

We use Husky to manage our Git hooks.

The Git hook scripts are in the .husky/ folder.

Husky and Heroku

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.