Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquidity pool questions #155

Open
zamrokk opened this issue Jun 8, 2022 · 8 comments
Open

Liquidity pool questions #155

zamrokk opened this issue Jun 8, 2022 · 8 comments

Comments

@zamrokk
Copy link

zamrokk commented Jun 8, 2022

Q1 : It is said : "By adding liquidity you'll earn 0.05% of all trades on this pair proportional to your share of the pool."
How can I get this reward ?
Is it a global reward of the pool ? But when i convert back the LQ tokens to XTZ and CTez, is it including the reward too or not ? How can I see the formula of it to verify it ?

Q2 : When I get some LQ tokens from the Liquidity pool, what happens to my XTZ on it and its delegation ? Who get my delegation rewards out of it ? As XTZ are deflationists, it means that user is losing some inflation value here

@DeFiPrince
Copy link

  1. The reward is automatically added to the pool whenever a swap happens, so the returns get compounded for the Liquidity Providers. So, Whenever someone removes liquidity, they are also getting the trading fees accumulated over the period of time.

@DeFiPrince
Copy link

  1. As the per the economic model of the ctez, this AMM is not delegated to any baker. There are other Automated Market Makers on Plenty (stable Swap) , Quipuswap which offer baking rewards and have a higher percentage of fee on trades executed.

@zamrokk
Copy link
Author

zamrokk commented Jun 21, 2022

  1. Here the allocation is nominal = # LP tokens. If the pool grows, how fees are added to the pool ? fees are XTZ, not LP tokens. Then, if the allocation was in % of fees, the I can understand how the withdraw can happen, but in our case, the allocation is on nominal, I have not seen that this can be increased by the contract , is it the case ?

@zamrokk
Copy link
Author

zamrokk commented Jun 21, 2022

If I simply :

  • I have x LP token over y total of LP token. This formula x / y gives me my % of the LP fund.
  • Some fees (in XTZ or CTEZ) have to be sent to the LP fund in provinding a Swap service for XTZ/Ctez pair
  • On a withdraw of LP token, the amount of currency (XTZ or Ctez depending how you take the fees) should have increased
  • How is calculated the amount of XTZ or Ctez at withdraw time == i.e what is the valuation of LP token ?

@DeFiPrince
Copy link

  1. Here the allocation is nominal = # LP tokens. If the pool grows, how fees are added to the pool ? fees are XTZ, not LP tokens. Then, if the allocation was in % of fees, the I can understand how the withdraw can happen, but in our case, the allocation is on nominal, I have not seen that this can be increased by the contract , is it the case ?

Whenever a swap occurs, the tokenPool and cashPool values change, depending upon the direction of swap, trading fee is calculated and added to the respective variable.

Let's take an example:

Automated Market Liquidity ( 1000 Tez and 1000 ctez) and you are the sole liquidity provider with 2000 Lp Tokens of the Pool.
Assuming the price of 1 tez = 1 ctez ( which was at the start of economic model)

If someone swapped 1 tez to ctez at that time.

Trading Fee = 0.05/100 * 1 tez = 500 mutez ( 0.000050 tez )

Since, the user is swapping around 0.1 % of liquidity, there are facing slippage in the trade.
After the swap is executed

In the smart contract, tokenPool value is the ctez balance of the Automated Market Maker and cashPool is the xtz balance.
cashPool = 1000 tez + 1 tez = 1001 tez
tokenPool = 999.001498 ctez

Upon Remove Liquidity, following calculation would be executed:

xtz_amount = (user_lp_balance * cashPool ) / total_lp_supply = 1001 tez
ctez_amount = (user_lp_balance * tokenPool ) / total_lp_supply = 999.001498 ctez

Note - This is an extremely basic example to explain the working of the AMM. There are other things to consider while providing liquidity to the pairs.

@zamrokk
Copy link
Author

zamrokk commented Jun 21, 2022

Are the fees always taken in XTZ ? Does it mean that the cashPool will always grow ?

@DeFiPrince
Copy link

The fees are taken in ctez and xtz, depending upon the input of the swap. If the swap is from ctez to tez, then fee is taken in the form of ctez and vice-versa.

@zamrokk
Copy link
Author

zamrokk commented Jun 21, 2022 via email

@Tezsure Tezsure locked as resolved and limited conversation to collaborators Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants