MCPcopy Index your code
hub / github.com/Py-Ec/solana-arbitrage-bot

github.com/Py-Ec/solana-arbitrage-bot @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
304 symbols 612 edges 58 files 60 documented · 20%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

solana arbitrage bot

happy searching :)

layout

  • client/: off-chain arbitrage bot code
  • program/: on-chain swap program
  • pools/: dex pool metadata
  • onchain-data/: analysis of other arbitrage swaps
  • mainnet-fork/: fork mainnet account states to test swap input/output estimates

each folder contains a corresponding README.md which explains how it works

dexs supported

  • serum
  • aldrin
  • saber
  • mercurial
  • orca

other notes

  • we use rust unit tests (with mainnet forking) to ensure our swap quotes are correct (quoted swap amount = actual swap amount)
  • to figure out how to interface with each dex (most dont have rust sdks or even public ts sdks) we reverse engineer how to interact with them through the jupiter-swap sdk (analyzing the npm package folder bc its also not public)
  • in the client we use a brute-force approach to find arb opportunities instead of negative cycle algos bc its much faster and can find all opportunities
  • we also dont calculate the optimal swap input amount for each arb bc its faster to spam multiple decreasing amounts and let the largest one land (this is what the winner of the arbitrage opportunities was doing - eg, send tx with input size N, N/2, N/4, ...)
  • why do we need an on-chain swap program? checkout this post out -- if you swap from A -> B -> C you might get more/less of B than expected which effects the swap instruction to C

why share this alpha

the life of a lone searcher is a lonely one where you cant share what you find or share your code - while working on this project i realized this is not what im about and thus i open source

Extension points exported contracts — how you extend this code

DynPack (Interface)
Trait for packing of trait objects, required because structs that implement `Pack` cannot be used as trait objects (as ` [4 …
client/src/pool_utils/calculator.rs
RawAccount (Interface)
(no doc)
mainnet-fork/check_ata_balances.ts
CurveCalculator (Interface)
Trait representing operations required on a swap curve [4 implementers]
client/src/pool_utils/calculator.rs
PoolOperations (Interface)
(no doc) [5 implementers]
client/src/pool.rs

Core symbols most depended-on inside this repo

clone
called by 55
client/src/serialize/token.rs
derive_token_address
called by 17
client/src/utils.rs
clone
called by 14
client/src/pool_utils/base.rs
unpack_token_account
called by 10
client/src/serialize/token.rs
floor
called by 9
client/src/pool_utils/serum.rs
fee_tenth_of_bps
called by 9
client/src/pool_utils/serum.rs
swap_without_fees
called by 9
client/src/pool_utils/constant_price.rs
compute_d
called by 7
client/src/pool_utils/stable.rs

Shape

Method 134
Function 107
Class 48
Enum 11
Interface 4

Languages

Rust94%
TypeScript6%

Modules by API surface

client/src/pool_utils/constant_product.rs22 symbols
client/src/pool_utils/stable.rs18 symbols
program/programs/tmp/src/swaps/serum.rs17 symbols
client/src/pool_utils/offset.rs17 symbols
client/src/pool_utils/serum.rs16 symbols
client/src/pool_utils/constant_price.rs16 symbols
client/src/pool_utils/calculator.rs16 symbols
client/src/pool_utils/base.rs16 symbols
program/programs/tmp/src/lib.rs14 symbols
client/src/serialize/token.rs14 symbols
client/src/pools/serum.rs14 symbols
client/src/pool_utils/fees.rs12 symbols

For agents

$ claude mcp add solana-arbitrage-bot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact