Anyone can provide liquidity to earn passive income. A liquidity provider supplies equal value parts of two different tokens in exchange for LP tokens. Liquidity providers receive a 0.25% fee for every swap that is made in their pair. The 0.25% fee is added back to the pool, increasing the value of ssLP tokens. Liquidity providers can also participate in yield farming with supported pools.
Let us first cover the process of LP creation. Consider a token pair $AAA and $BBB. By creating a pool, a liquidity provider is setting the ratio of tokens, which determines the price of the tokens in the pool. Generally speaking, if a token has an established market price, it makes sense to set the ratio such that the prices of the tokens approximate market prices. If the prices deviate from market prices, arbitrageurs will step in and rebalance the pool to match market prices at the liquidity provider's expense.
Figure 1. Liquidity Pool Creation. Note that rounded numbers were used in the calculations.
In the above example, 2500 $AAA and 100 $BBB are used to create a new liquidity pool. The number of ssLP shares minted is the geometric mean of these token amounts, i.e.,
Applying this, we get sqrt(2500 * 100) = 500 ssLP tokens. The constant product, k, is simply 2500 * 100 = 250,000.
Next, let us cover the process of providing liquidity to an existing pool.
Figure 2. Adding Liquidity to an Existing Liquidity Pool. Note that rounded numbers were used in the calculations.
Figure 2 depicts the pool in Figure 1 after a swap has occured. It now contains 3000 $AAA tokens, 83.38 $BBB tokens, 500 ssLP tokens, and has a k constant of 250,140.
Consider an example in which a user wants to provide 719.60 $AAA tokens to this pool. The protocol mandates that equal value parts of $AAA and $BBB are added, so based on the relative prices of these tokens, 20 $BBB tokens must also be added.
The factory contract first computes accumulated swap fees, and mints new liquidity tokens to the fee beneficiary which, in the case of SaucerSwap, is the DAO Treasury. This is to remain gas efficient. The number of LP tokens minted is based on the equation:
Where s is the number of outstanding ssLP tokens, k2 is the current k value of the LP, and k1 is the k value of the LP at the last deposit / withdraw from the LP, and φ = 1/6. In our example, the number of LP tokens minted and sent to the DAO Treasury is 0.023.
Next, the procotol calculates the number of ssLP tokens minted to the liquidity provider according to the equation:
Where x, deposited is equal to the number of $AAA tokens deposited by the new liquidity provider, s is the number of outstanding ssLP shares (including the newly minted shares for the DAO Treasury), and x is the number of $AAA tokens in the pool. In our case, 719.60 * (500 + 0.023) / 3000 = 119.93 ssLP tokens minted. The new k constant is (3000 + 719.60) * (83.38 + 20) = 384,532.25.
These newly minted LP tokens represent the liquidity provider's share of the $AAA-$BBB LP. In this case, they would own 19.35% of the pool.
Swap fees are automatically put back into the pool and distributed to liquidity providers in proportion to their share of the pool. Put another way, fees are aggregated and distributed to liquidity providers on a pro-rata basis based on the amount of LP tokens they hold.
A liquidity pool's LP Reward APR, which can be found on SaucerSwap's analytics subdomain, is calculated as follows: