本程序用于演示如何使用magic-math服务以实现CLMM套利。
使用的是CLMM类型的SOL-TRUMP pool
This program demonstrates how to use the magic-math service to implement CLMM arbitrage.
The SOL-TRUMP pools of type CLMM are used
SOL So11111111111111111111111111111111111111112
TRUMP 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN
-
确保已安装 Node.js, ts-node 和 yarn。Make sure Node.js, ts-node and yarn are installed.
-
环境变量说明 Environment variable
钱包路径 / private key path
SENDER_WALLET_PATH='~/wallets/wallet.json'
#solana 主网 rpc / Mainnet RPC
MAIN_NET_RPC=''
MAGIC_MATH_RPC=' https://clmm.mathminer.space'
#PAID JUPITER API
JUPITER_API_ENDPOINT='https://public.jupiterapi.com'-
使用以下命令安装依赖:
yarn
-
运行程序:
ts-node src/client.ts
pools是clmm类型sol-usdc池子的集合,magic-math会计算它们之中是否存在套利机会。
pools is a collection of CLMM-type SOL-USDC pools. Magic-Math will analyze whether arbitrage opportunities exist among them and identify the maximum arbitrage opportunity.
curl --tlsv1.2 -X POST http://ip:port/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "ReqClmmTwoSwapPath",
"params": {
"baseToken":"sol",
"pools":[
{
"poolAddress": "FTZXgbCYGnVEVMHCTWg6w9YqFiNdjd4wpmEuydf1d7f1",
"mmType": "clmm",
"token1": "sol",
"token2":"usdc",
"sqrtPrice": "9000752841835098010",
"liquidity": "573110189269850",
"feeRate": "1600"
},
{
"poolAddress": "J9GqLeSbhfyhXZjjTZyvJkP4t5nvAmVCbzqnRG4ebVZA",
"mmType": "clmm",
"token1": "sol",
"token2":"usdc",
"sqrtPrice": "9010752841835098010",
"liquidity": "573110189269850",
"feeRate": "20000"
},
{
"poolAddress": "J2XyxHqQEVjzUdrp1feyA7Cbg9QLoQYpoj5oyed276oJ",
"mmType": "clmm",
"token1": "sol",
"token2":"usdc",
"sqrtPrice": "9020752841835098010",
"liquidity": "573110189269850",
"feeRate": "500"
},
{
"poolAddress": "9byT27JF1YcZNbdfYgrhb3ZKQTjidjb9eTd3EFX4muRZ",
"mmType": "clmm",
"token1": "sol",
"token2":"usdc",
"sqrtPrice": "9030752841835098010",
"liquidity": "573110189269850",
"feeRate": "10000"
},
{
"poolAddress": "ARoW2byayvBviouHVymJyVTjHM5SzaYCjvQQeZCFSbDb",
"mmType": "clmm",
"token1": "sol",
"token2":"usdc",
"sqrtPrice": "9030752841835098810",
"liquidity": "573110189269850",
"feeRate": "10000"
}
]
}
}'benefit_point表示本次套利最优输入值值(也就是request中baseToken的输入值)
enefit表示理论收益
benefit_point represents the optimal input value for this arbitrage opportunity (i.e., the input amount of baseToken in the request).
benefit represents the theoretical profit.
{
"jsonrpc": "2.0",
"result": [{
"benefit": 534515338,
"benefit_point": 457025916626,
"pool_a_adress": "J2XyxHqQEVjzUdrp1feyA7Cbg9QLoQYpoj5oyed276oJ",
"pool_b_adress": "FTZXgbCYGnVEVMHCTWg6w9YqFiNdjd4wpmEuydf1d7f1"
}],
"error": null,
"id": 1
}