I am using Python and web3.py.
I have to swap eth to tokens using swapExactEthforTokens in Uniswap. And then I have to tokens to eth using swapExactTokensforEth in Uniswap.
How do get calculate profit?
I have to predict the profit.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityThis is a case of an Arbitrage. In summary, an Arbitrage is the transferring of goods from market to market while buying at a lower price in one and selling for higher in the other market. The practice is enabled by the fact that markets are not that fast to know exactly the price of a certain good in all other markets in order to fix its pricing.
The arbitrage is a product of that issue and is the best way to fixing it. The prediction is an exercise of "The shortest route" algorithms.
here is a more elaborate post on that : Finance And money StackExchange
Call
function.geth
to add this custom modification of running the transaction on latest StateDB , and then this transaction will produce Event logs, you check the event log for the amount of tokens you would receive if the transaction is successful