Withdraw
The withdraw function allows users to partially or fully withdraw their previously staked tokens from a public reward pool. This operation reduces the user’s stake and, consequently, their share of MOR rewards.
Before executing a withdrawal, the contract verifies that the selected rewardPoolIndex
corresponds to a valid and public reward pool. The withdrawal is only permitted if a required delay since the last stake (defined in the pool configuration as withdrawLockPeriodAfterStake
) has passed.
The final withdrawn amount must also respect the minimalStake
rule: the remaining user stake (if any) must not fall below the minimum stake required by the pool unless the user fully exits.
If the pool is public, the contract first calls distributeRewards
to ensure the reward coefficient is up to date. Then, it calculates the user’s current rewards and applies the necessary multipliers to recalculate the virtual deposit. This ensures fair and accurate distribution of future rewards after the withdrawal. Then, the withdrawn tokens are first pulled from the Distributor
using withdraw and then transferred to the user via safeTransfer
The user may continue to interact with the contract or fully exit their stake. Fully exiting resets most of their staking data except reward history.
Last updated
Was this helpful?