Skip to content

waterquarks/mangomaker

Repository files navigation

Mangomaker

About

This is a very simple market maker for https://trade.mango.markets, built in anticipation to the SRM trading competitions. It quotes perps and hedges in spot. With thoroughly descriptive code, it is intended to serve as a hands-on technical introduction to Mango Markets and as a starting point for your own bot.

Happy to help you out with any questions - join the Discord at discord.gg/mangomarkets and ask away in #dev-marketmaker.

Quickstart

You will need node and yarn installed.

git clone https://github.com/waterquarks/mangomaker && cd mangomaker # Clone this repo
yarn install # Install dependencies

On devnet

Setting up a Solana account

To get a devnet wallet with SOL, first create the wallet by installing the Solana CLI tools as per https://docs.solana.com/cli/install-solana-cli-tools and then generating a keypair using solana-keygen new --outfile keypair.json.

Now airdrop some SOL to it using solana airdrop 2 --verbose --url devnet --keypair ./keypair.json, and some USDC as well with

Creating a Mango account with collateral

Import keypair.json (you can use cat keypair.json to print these from within the shell) into your Phantom app and switch the network to devnet. Then go to https://devnet.mango.markets and deposit the collateral - video instructions here:

guide.mp4

Initializing the market maker

With the 2 previous steps covered, execute the following command:

KEYPAIR=./keypair.json MANGO_GROUP=devnet.2 MANGO_ACCOUNT=YOUR_MANGO_ACCOUNT SYMBOL=SOL npx ts-node app.ts

Replacing YOUR_MANGO_ACCOUNT with your own Mango account pubkey - you can fetch it from https://devnet.mango.markets/account, as per the following picture:

Screen Shot 2022-07-12 at 04 14 05

You should now see the orders quoted by the bot highlighted in the UI's orderbook.

image

On mainnet

Assuming you've got a Mango account with some collateral and your keypair stored in a JSON file (see the devnet quickstart for reference):

KEYPAIR=PATH_TO_YOUR_KEYPAIR MANGO_GROUP=mainnet.1 MANGO_ACCOUNT=YOUR_MANGO_ACCOUNT SYMBOL=SOL npx ts-node app.ts

Meta learning resources

More example bots

Releases

No releases published

Packages

No packages published