Comment on page
Provide liquidity for rToken and maintain the value of rToken.
1.Completely decentralized and independent
2.Support to provide liquidity asymmetrically, but encourage to provide liquidity symmetrically
3.Make up for LP’s impermanent losses through shared trading fees and mining incentives
The overall structure is shown in the following figure:
When the user swaps tokens on rDEX, the trading fee based on slippage will be charged. If the slippage is too high, the corresponding trading fee will also increase hugely, limiting some large transactions and also compensating the liquidity provider.
The module mainly provides mining program incentives for Liquidity Provider:
1.Deposit Function: Liquidity provider stakes the LP token to participate in mining program
2.Withdraw Function: The user withdraws LP token and stops mining, and the corresponding mining reward will be issued at this time
3.Claim Function: Withdraw the mining rewards
This module deals with the functions like minting, burning and transferring LP tokens, etc.
Product formula in Uniswap:
When the number of inputs is
xand the number of outputs is
If the exchange is made at the exchange price, the output is
y'/Y = x/X
We can further get slippage slip:
We can see that when
xis closer to
X, the slippage is greater.
The trading fee rate in Uniswap is fixed at 0.3%, and rDEX will use a slippage based fee model instead.
If we take slip as the transaction fee rate here:
y''in the hands of the end user after deducting the handling fee:
Pool after exchange:
Price after exchange:
Calculation formulas for transaction fee, exchange amount, etc.:
x=Sent Asset Amount
X=Sent Asset Pool Balance
Y=Received Asset Pool Balance
Liquidity provider liquidity pool share calculation formula:
f=Native amount added
r=rToken amount added
F=Native Balance (before)
R=rToken Balance (before)
P=existing Pool Units
It is an independent service whose main responsibility is to maintain the balance between the rToken trading price on rDEX and the rToken exchange rate on the StaFi chain.