0

this is from IUniswapV2Router01.sol:

function addLiquidity(
    address tokenA,
    address tokenB,
    uint amountADesired,
    uint amountBDesired,
    uint amountAMin,
    uint amountBMin,
    address to,
    uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);

What does the return value uint liquidity represents?

1 Answer 1

1

Represents how much LP token you will received after you provided liquidity to the pool.

Uniswap v2 checks the ratio of token A and token B in the pool and only lets you add liquidity according to that ratio.

So those 3 values you get in return of calling addLiquidity() are the amount of token A the protocol allows you to stake, the amount of token B, and the number of LP token you get to represent the liquidity you just provided.

You can later use those LP token to get your liquidity back from the pool.

Hope this helps!

3
  • so every pool has its own LP token and is it generated when the pool is created?
    – Yilmaz
    Commented Dec 11, 2022 at 21:10
  • Exactly. The pool is generated from the 2 token addresses and every LP is unique to its pool, and therefore unique to the pair of tokens. If my answer helps, feel free to mark it as valid! Commented Dec 11, 2022 at 21:50
  • yes, ty. I have some other unanswered questions, you can also feel free to go over them :)
    – Yilmaz
    Commented Dec 11, 2022 at 22:28

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.