MCPcopy Index your code
hub / github.com/blockworks-foundation/mango

github.com/blockworks-foundation/mango @v2.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.2.1 ↗ · + Follow
190 symbols 481 edges 15 files 7 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Mango Markets - Decentralized Margin Trading

⚠️ Warning

Any content produced by Blockworks, or developer resources that Blockworks provides, are for educational and inspiration purposes only. Blockworks does not encourage, induce or sanction the deployment of any such applications in violation of applicable laws or regulations.

Contribute

Significant contributions to the source code may be compensated with a grant from the Blockworks Foundation.

Security

Mango is currently unaudited software. Use at your own risk.

You may be eligible for a substantial reward if you find a vulnerability and report it privately to hello@blockworks.foundation

Setup

This setup assumes you're familiar with the basics of Solana development. If you're not, you might find it useful to follow the instructions here: https://github.com/solana-labs/example-helloworld and/or here: https://docs.solana.com/cli to get set up with node and rust as well

get rust

sudo apt-get install -y pkg-config build-essential python3-pip jq
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup override set 1.58
rustup component add rustfmt
rustup component add rust-src

Note that currently rust version at least 1.50 is needed. Check rust version and upgrade if necessary with

rustc --version
rustup update

get mango

VERSION=v1.9.1
sh -c "$(curl -sSfL https://release.solana.com/$VERSION/install)"
sudo apt-get install -y libssl-dev libudev-dev
cargo install spl-token-cli

git clone git@github.com:blockworks-foundation/mango.git
git clone git@github.com:blockworks-foundation/mango-client-ts.git

get devnet coins

  • Go to mango-client-ts/src/ids.json and create a token account in sollet.io for each of the symbols under devnet
  • Go to https://spl-token-ui.netlify.app/#/token-faucets,
  • switch to devnet cluster in top right and Token airdrop tab
  • then copy paste the faucet id for the token you want from ids.json.devnet.faucets
  • paste in your corresponding token account address
  • hit Airdrop tokens and check your sollet.io to see if you've received tokens

deploy devnet

Note: Make sure the IDS_PATH and KEYPAIR are correct in mango/cli/devnet.env

Then set the devnet keys and URL

source cli/devnet.env
solana config set --url $CLUSTER_URL

Then compile program and deploy using devnet_deploy.sh in mango/cli

cd cli
. devnet_deploy.sh

deploy mainnet

Rework devnet_deploy.sh and use cli/mainnet.env to deploy to mainnet

run tests

Regression and integration tests are in progress. To run them

cd program
cargo test  # run non-solana VM tests (none at the moment but would include simple unit tests in the future)
cargo test-bpf  # run tests that use the solana VM (ie the smart contract tests)

Extension points exported contracts — how you extend this code

SignerNonce (Interface)
(no doc) [1 implementers]
common/src/lib.rs
AddPacked (Interface)
(no doc) [1 implementers]
program/tests/helpers/mod.rs
Loadable (Interface)
(no doc)
program/src/state.rs

Core symbols most depended-on inside this repo

pack
called by 24
program/src/instruction.rs
update_indexes
called by 11
program/src/state.rs
load_open_orders
called by 10
program/src/state.rs
read_keypair_file
called by 9
common/src/lib.rs
gen_signer_seeds
called by 9
program/src/utils.rs
checked_sub_deposit
called by 9
program/src/processor.rs
name
called by 8
common/src/lib.rs
send_instructions
called by 8
common/src/lib.rs

Shape

Function 102
Method 64
Class 14
Enum 7
Interface 3

Languages

Rust100%

Modules by API surface

program/src/state.rs49 symbols
program/src/processor.rs34 symbols
common/src/lib.rs28 symbols
program/src/instruction.rs23 symbols
program/tests/helpers/mod.rs20 symbols
cli/src/main.rs16 symbols
program/src/error.rs6 symbols
program/src/utils.rs4 symbols
program/tests/test_srm.rs2 symbols
program/tests/test_init.rs2 symbols
program/tests/test_deposit.rs2 symbols
program/tests/test_borrow.rs2 symbols

For agents

$ claude mcp add mango \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact