Stake
The stake function allows users to deposit tokens (such as stETH or other depositToken
) into the protocol in exchange for MOR token rewards. Staking is available only for public reward pools, such as the Capital pool.
When a user calls stake, the contract verifies that the reward pool exists and is public. It ensures the provided amount is greater than zero and satisfies the minimalStake
requirement for the selected pool. If a claimLockEnd
is provided, it must be either zero or a future timestamp. If provided, it increases the reward multiplier and updates the user’s lock duration.
The user’s depositToken
is transferred to the DepositPool
contract using transferFrom
. For stETH, due to Lido rebasing, the actual amount received may be slightly less than requested. Immediately after receiving the tokens, the DepositPool
forwards them to the Distributor
contract using the supply method.
If the depositToken
supports external yield (e.g., Aave yield), the Distributor
deposits them into Aave. If the token is stETH, it is not deposited and is held directly by the Distributor
.
Reward multipliers are calculated using two components: the lock period (claimLockEnd
) and a referrer address if one is provided. These multipliers increase the user’s virtual stake, which determines the share of rewards the user is entitled to. If the user passes their own address as referrer, the bonus still applies.
Before updating state, the contract synchronizes the reward coefficient by calling distributeRewards
on the Distributor
. This ensures the latest emission state is considered when updating the user’s reward rate.
Staking resets the withdrawal and claim lock timers. Each new stake requires the user to wait again before being able to withdraw or claim rewards, based on pool-level lock parameters.
To execute this function successfully, the user must have approved the DepositPool
contract to spend their tokens. The staked amount must satisfy the pool’s minimum, and the rewardPoolIndex
must correspond to a valid public pool.
Last updated
Was this helpful?