1

In looking at the Granadanet contract storage, I can see the amount of tzBTC, Tez, and LQT tracked in/by the CPMM.

Here are those values as of writing this:

tokenPool 45805
xtzPool 111379958864916
lqtTotal 51959

Based on these numbers, is it possible to calculate the amount of Tez and tzBTC that a single LQT token is worth?

I ask because I'm currently adding liquidity and removing liquidity on Granadanet, with no way of really understanding how many LQT I should be receiving, or how many Tez and tzBTC I should be getting back when I remove liquidity.

2

When you add tezAmount liquidity you deposit tezAmount * tokenPool / xtzPool tokens (with division rounding up) and receive tezAmount * lqtTotal / xtzPool LQT (with division rounding down). When you remove lqtAmount liquidity you get back lqtAmount * xtzPool / lqtTotal tez and lqtAmount * tokenPool / lqtTotal tokens (with divisions rounding down).

7
  • 1
    Thanks again Sophia. So if the CPMM contract has the following storage values: tokenPool: 45807, xtzPool: 111396486543871, lqtTotal: 51957, then If I add 9740 tez I can expect to get the following amount of tzBTC taken: 9740 * 45807 / 111396329043871 = 0.00000400516 mutzBTC tokens or 4.0516 tzBTC tokens (but 5 will be taken since we round up) and I can expect to receive the following amount of LQT: 9740 * 51957 / 111396486543871 = 0.00000454288 muLQT or 4.54288 LQT (but 4 will be taken since we round down) Is my understanding and math correct?
    – Whirlybird
    Jul 30 at 12:23
  • 1
    @Whirlybird not quite. In this case the tez/token exchange rate is so high (probably my fault if you're looking at granadanet) that that amount of tez equals zero tokens and zero liquidity tokens. If you called addLiquidity with minLqtMinted as 0 the CPMM would just eat your tez. Jul 30 at 16:37
  • 1
    If the CPMM contract has the following storage values: tokenPool: 45807, xtzPool: 111396486543871, lqtTotal: 51957, then If I add 9740 tez I can expect to get the following amount of tzBTC taken: 9740 * 45807 / 111396329043871 = 0.00000400516 mutzBTC tokens or 4.0516 tzBTC tokens (but 5 will be taken since we round up) and I can expect to receive the following amount of LQT: 9740 * 51957 / 111396486543871 = 0.00000454288 muLQT or 4.54288 LQT (but 4 will be taken since we round down)
    – Whirlybird
    Jul 30 at 19:32
  • 2
    @Whirlybird not quite. There's no "muLQT" or "mutzBTC". The tzBTC amount is already in satoshis. In this case you provide zero tzBTC and receive zero LQT. Please note that it's possible for the CPMM to take your tez anyway if you've set minLqtMinted to zero. Aug 2 at 16:19
  • 1
    Thanks for confirming this and bearing with all my tedious questions. 🙂
    – Whirlybird
    Aug 3 at 9:09

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.