1

I created a few bots to pull data from Uniswap. For example, using ETH/DAI. Even though the pairs are the same, the contract ID's are different for pairs and swap. Why is it that the swap price predominantly lower than the pair price?

enter image description here

1 Answer 1

2

The pair price is the price that you will get if you trade an infinitesimally small amount. It is a theoretical equilibrium price that you will never get in practice.

The swap price is the price that you will get if you swap the given amount (1 Eth in your screenshot). The swap price will always be lower than the pair price because of the "price impact" (something referred to as slippage), which is inherent to how AMM work. The bigger the swap in relation to the size of the pool, the worst price you will get. You can learn more about it here. The swap price most likely also include the swap fee that you pay to the liquidity providers (often 0.2% or 0.3%).

4
  • Great response! I also noticed that the % difference changes on the app from small to larger amounts. Now, I noticed v2, methods.getExpectedReturnWithGas(), which would be in Gwei, right? That's different than the Transaction Fee. Is that the 0.2%-0.3% you mentioned? Those fees come out of your wallet though, right?
    – ElHaix
    Commented Dec 12, 2021 at 1:16
  • I don't know about the getExpectedReturnWithGas. However, the gas and the liquidity provider fee of 0.2%-0.3% are two different things. You always pay the gas fee in Eth from your wallet (paid to miners), while the liquidity provider fee will be taken out of the amount you received from the swap and will stay in the pair pool.
    – Undead8
    Commented Dec 12, 2021 at 18:34
  • I see, so the liquidity provider fee, is the Transaction fee, seen in Etherscan? For Flash Loans they can be higher than $400. This comes out of the amount received from the swap? So transaction fees do not come out of your wallet, only gas fees? i.e. etherscan.io/tx/…
    – ElHaix
    Commented Dec 12, 2021 at 20:43
  • 1
    No, the transaction fee on etherscan is the gas fee paid to the miners. It is paid in ETH from the wallet. The fee paid to liquidity provider and slippage is not shown on etherscan and is embedded in the amount you receive from the swap.
    – Undead8
    Commented Dec 13, 2021 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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