0

Let's say I add liquidity to the ETH-USDT pool, then I remove liquidity some time later.

In between that time, trades have happened and people have added and removed liquidity too.

I only have what's inside the Pair contract, so:

  • reserve0
  • reserse1
  • price as a ratio reserve0/reserve1

I don't have access to:

  • History of swaps that have occurred
  • History of other people adding/removing liquidity

Is it possible to figure out how much I've earned in fees?

1 Answer 1

1

Assuming you are asking about Uniswap V3 - You can call positions:

    function positions(bytes32 key)
        external
        view
        returns (
            uint128 _liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

This returns the token fees due to a position in both token0 and token1.

1
  • Sorry I should've prefaced - I meant V2!
    – doctopus
    May 28, 2021 at 3:04

Your Answer

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

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