Liquidity Mining Contract

1. Introduction

The Liquidity Mining contract is the contract responsible for incentivizing users to allocate capital to where the protocol will need it the most. It pays out a fixed number of tokens each block to all the users across different liquidity pools. Users will receive rewards proportional to the pool's allocation and their relative contribution to the pool.
The contract was derived from the Masterchef contract by Sushiswap with some key changes.
​Contract Source​

2. Module Details

Key Functionalities

deposit - Allow users who have approved liquidity provider (LP) token transfers to the contract to deposit their LP tokens in the contract for reward. Any BLU accrued will be credited to the user as well.
withdraw - Allow users to withdraw their LP token from the contract and collect any accrued BLU rewards.
emergencyWithdraw - Allow users to withdraw their LP token from the contract in any form of emergency without collecting any accrued BLU.
updatePool - Called in withdraw and deposit to update the accrued BLU in different liquidity pools.
setMigrator - Called by admin to set the upgraded liquidity mining contract. The admin will be set to be the timelock/governance contract.
migrate - Called by admin when the migrator is set to upgrade the liquidity mining contract.
withdrawReward - Called by admin to withdraw BLU from the contract. This is required since the contract does not mint new BLU on the fly.

3. Key Mechanism & Concepts

The liquidity mining contract distributes BLU to users adding liquidity to the various pools. The contract allows anyone to stake liquidity provider tokens, which are proofs that the user has contributed to the liquidity, to be eligible for rewards. The rewards are distributed proportionally to the pool's allocation and the user's relative contribution to the pool.
For example:
There are two pools with the following allocation:
    BLU/MATIC - 40%
    MMKT/USDT - 60%
Assuming that 0.00317097919 BLU is distributed every block, 136.986301008 BLU will be distributed in a day across all users.
Assume that a user provides liquidity to 2% on the BLU/MATIC pool and 1% on the MMKT/USDT pool on Quickswap, then he will be eligible for 0.02 * 0.4 * 136.986301008 + 0.01 * 0.06 * 136.986301008which is 1.178 BLU every day.
The user does not need to do anything to receive the reward as long as the LP token is staked in the liquidity mining contract.

4. Gotchas (Potential sources of user error)

Users assume that if they provide liquidity to decentralized exchanges like Quickswap they will be eligible for rewards. This is not the case. Users have to stake their LP token on the liquidity mining contract to be eligible. This can be mitigated by providing resources and support to users who are providing liquidity.

5. Known Risk

    Contract Upgrade Error - The liquidity mining contract can migrate users' funds to another contract through the migrate function. The upgraded contract needs to be implemented correctly to receive the funds and maintain the correct states. While there is no current use case of the migrate function, it is left there to allow the protocol to upgrade in the future. Due to the sensitivity of the function, the liquidity mining contract will be behind a Timelock contract.
Last modified 1mo ago