🔒Locking
To lock an “amount” of pool LPs to earn locked LP fees, a user needs to approve this “amount” for a corresponding pool TokenLocker contract and call TokenLocker.lock(user, amount, days). This lock will be created with expiry in specified “days” number of days with LP “amount” for a “user”.
For each day until expiry, TokenLocker assigns a daily weight to each user lock as userLockWeight = lockDaysUntilExpiry * lockedAmount. It linearly declines until a lock expires. It happens on lock creation or lock update operations.
User can extend a lock by calling TokenLocker.extendLock(amount, days, newDays), where “amount” is by how much user wants to increase a lock, “days” corresponds to a lock with “days” left until expiry and “newDays” is new number of days until expiry for this lock and “newDays” must be > “days”.
To withdraw a lock, the user needs to first call TokenLocker.initiateExitSteam(), which will kick start the withdrawal streaming process of locked LP tokens linearly. The number of tokens being withdrawn is TokenLocker.streamableBalance(user), which is a total number of locked LPs that expired, but not withdrawn. User can track a number of tokens he can fully withdraw by calling TokenLocker.claimableExitStreamBalance(user) and call TokenLocker.withdrawExitStream() to withdraw this amount.
Locked LP fees distribution
If a pool has lockerFeesP > 0%, then this % of non-locked LPs fees will be accrued by pool FeeDistributor contract besides full locked LP fees that are being locked at the corresponding TokenLocker contract. It does it by subtracting this % from fees on each LP fees accrual and on each LP balances update to correctly track earned fees. FeeDistributor contract, which is immutably set in pool (Pair) contract and distributes locked LP pool fees, has immutably set corresponding pool address and claimFees() method, which can call pool claimFees() function (can be called by anyone) to get its corresponding accumulated TokenLocker fees after previous claiming.
User lock daily fees share is roughly equal to dailyFees * TokenLocker.dailyWeightOf(user, day) / TokenLocker.dailyTotalWeight() (it varies a little between timing when claiming daily locked fees).
Locked LP fees claiming
User needs to call the FeeDistributor.claim(user, tokens) function where tokens is a specified token or both pool tokens, which he wants to claim. How much tokens can be claimed by a user is calculated with a FeeDistributor.claimable(user) function, which returns current amounts for both pool tokens.
Last updated