节点
petgraph
套利流程
[] 获取所有交易对信息常驻内存,提供模拟引擎接口,完整的各个uniswap clone版本的clone版本
[] 通过add/remove/swap sync event更新对应交易对信息
[] 监视pending交易,通过模拟引擎接口,simulate用户交易,更新模拟信息
[] 选取更新交易对的五级hops和常用待监视交易对,查询cycles,使用图算法寻找最优套利路径
[] 计算是否盈利
[] backrunning用户交易,使用多个bot同时发送交易,提高成功率
[] 更新合约,一个成功,其他失败,失败的确保GAS费耗费最少
[] 多线程方式,同步信息或者协程方式,mpmc
Ref
frontrun
1 | 0|start | 2022-11-23T04:12:47.612879Z INFO fetch_tx_1: block_bot::util::transaction: https://bscscan.com/tx/0x7976930b8f1d29645532c8962b09bbe6d777e452b809c3560a96d2198995374d GasPrice: 5000000000, GasLimit: 1470804, nonce: 819, from: 0xa15bcf6695aa600bd19deafbda74a0e02b225b96, to: Some(0x9d3a168cf3a54bae225471fc061a77e49c741751) |
winnner: 监测到4个pending
1 ok, 1 error
sender: 0xb99bcff726fe908c72aad3edced34414da2ff6eb
winner
position: 4
other’s failed tx:
sender: 0xc1403efe15c651a32a11e0fdb469edc8c47d2b07,监测到2个pending
failed
position: 12
my failed tx: 7个交易,替换3个(842,843,844),失败4个(842,843,844,845),期望成功1个(842),其他都替换为成功的。
4 errors
failed1
position: 6
failed2
position: 7
exploit1
[MEV contract] 0xee85d50607ed2d1413eabf789eca6f138a9c362f
为可升级合约,实现地址为:0x037f09d32E1e3AC52a295aE856C17C42d7DEFE83
调用了另一个0x83EF20c2eA6BEd52a62b34BfB3f559DDE4441E65合约
msg.sender: 0xa1d2b3c7c64b2746370cd8f6e81af7d4cb3fbb1c
input:
0xb11ad16900000000000000000000000000000000000000000000000000000000000000600000000000000000000000001610bc33319e9398de5f57b33a5b184c806ad21700000000000000000000000000000000000000000000000045963237b717b40000000000000000000000000000000000000000000000000000000000000000010000000000000000000000009abfe8921d32eac9fea6669e25344e2c97182757
0xb11ad169
0000000000000000000000000000000000000000000000000000000000000060 address[], borrowers
0000000000000000000000001610bc33319e9398de5f57b33a5b184c806ad217 # vDot
00000000000000000000000000000000000000000000000045963237b717b400 # dot price
0000000000000000000000000000000000000000000000000000000000000001 # borrowers.length
0000000000000000000000009abfe8921d32eac9fea6669e25344e2c97182757 # borrower
borrower: 0x9abfe8921d32eac9fea6669e25344e2c97182757
vDot: 0x1610bc33319e9398de5f57b33a5b184c806ad217 不再使用
1 | // SPDX-License-Identifier: MIT |
mev-analyzer
poc1
flashswap: WBNB -> BTCB -> vCake -> BUSD
input
0xa5bb9219
00000000000000000000000086ac3974e2bd0d60825230fa6f355ff11409df5c # vCollateral: vCake
000000000000000000000000882c173bc7ff3b7786ca16dfed3dfffb9ee7847b # vDebt: vBTC
0000000000000000000000009c2323b8a57da0bd3cbe325c7f4db05cbb896dbd # borrower
0000000000000000000000000000000000000000000000000004c8b3c57ccfc5 # borrow amount
000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56 # token repay