im pretty new to solidity, and i was wondering how you can 1 ERC token by another across different liquidity pools.


I have 1 DAI and I change it for eth in the ETH-DAI Uniswap pool then I swap ETH by SUSHI in the SUHSI-ETH Sushiswap pool

so the tx looks like this swap 1 dai for x eth swap x eth for y sushi

I guess you cant do it directly and you need to deploy a smart contract that interacts with both contracts (Uniswap ETH-DAI and Sushiswap SUSHI-ETH) and then you interact with your deployed smart contract. Does this have a particular name? I saw that it exist something called atomic swaps but I guess its not the same

  • I don't think the question makes any reference to different chains/side-chains/layers. It just concerns different liquidity pools in different AMMs on the same chain. May 28 '21 at 14:06
  • As @RichardHorrocks pointed, i was talking about the same chain. here is a sample transaction of what I want to achieve: bscscan.com/tx/…
    – user71155
    May 30 '21 at 16:41
  • @user71155 tx was constructed in the smart contract. Jun 2 '21 at 2:12
  • @VladimirKovalchuk exactly! Thats what i want to achieve, from a smart contract create a function that takes an input amount, a path and talks to all the different liquidity pools in that path. For example, I input 1 BNB and I give two addresses, the BNB-CAKE LP address and the CAKE - BUSD LP address (it can be from another DEX, so I cant use their native router SC), the contract then needs to swap in a single transaction (really important) BNB for CAKE and then CAKE for BUSD.
    – user71155
    Jun 3 '21 at 7:08
  • @user71155, so, do that, what kind of issue do you have:) Jun 3 '21 at 9:00

Here you can find an example of such a smart contract. https://blog.infura.io/build-a-flash-loan-arbitrage-bot-on-infura-part-ii/

Nothing unusual here. Just do a call to different smart contracts in a single transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.