getProfit = 0

Now that we have studied the principle, it is still necessary to write a code to test it.
First, write the function, and then call the API of the pair, instantiate the contract, and pass in the corresponding ABI.
Get Reserves, and then pass it in directly.
Calculate delta a, use A of delta a to trade, prepare the transaction path, and ensure that the entire transaction process is in one block, otherwise, during the transaction process, other people's transactions will be interspersed, affecting the final result.
At present, there are very few arbitrage opportunities, but this method can still be used to prevent others from arbitrage when the project party pulls orders.

from web3 import Web3
from web3.middleware import geth_poa_middleware
import math
from json import loads

r = 997/1000
def 

Guess you like

Origin blog.csdn.net/wjl__ai__/article/details/121701733