Safety Module
The Nexus Market Safety Module serves as a safeguard for the Protocol against potential shortfall events. By staking ZBU, participants contribute to the security of the protocol and earn incentives in return. The staked tokens may be slashed in the event of a shortfall to cover any protocol deficits.
The Safety Module operates by allowing users to stake their ERC-20 tokens into StakeZeebuV3 contracts, which are also ERC-20 tokens. These StakeZeebuV3 contracts handle the distribution of rewards and manage the slashing mechanism.
Staking
Users stake tokens by calling the stake function on the StakeZeebuV3 contract with the amount they wish to stake. In exchange, they receive staked tokens adjusted by the current exchange rate, representing their share in the Safety Module.
Unstaking
Before withdrawing their staked tokens, users must initiate a cooldown period by invoking the cooldown() function. After the cooldown period, defined by _cooldownSeconds
, has elapsed, there is a limited window (UNSTAKE_WINDOW
) during which users can redeem their staked tokens by calling the redeem function. If this window is missed, the cooldown process must be restarted.
Actions involving staked tokens can affect the cooldown period:
Staking More Tokens: Adding more tokens to your stake during an active cooldown doesn't impact the existing cooldown. The new tokens will require a separate cooldown period before they can be unstaked.
Unstaking Tokens: Once the cooldown period has passed, only the tokens that were in cooldown can be unstaked. Unstaking resets the cooldown for the withdrawn amount, and any remaining staked tokens will need a new cooldown period for future withdrawals.
Claiming Rewards: Collecting earned incentives doesn't affect the cooldown period. Users can claim rewards at any time without influencing their cooldown status.
Transferring Staked Tokens: Sending staked tokens to another address doesn't alter the sender's cooldown. The recipient must initiate their own cooldown period to unstake those tokens, as the cooldown is not transferred along with the tokens.
After the cooldown period concludes, users have a two-day window to unstake their tokens. Failing to do so within this timeframe means they must initiate the cooldown process again, waiting the full duration before being able to unstake.
Exchange Rate Mechanism
The exchange rate determines how staked tokens convert back to the underlying assets. Initially set to a 1:1 ratio (1e18
), the exchange rate adjusts in response to slashing events or when additional funds are added to the module. This mechanism determines the value of staked tokens to reflect the total assets within the Safety Module after such events. The exchange rate is calculated using the formula:
Rewards
Participants earn rewards over time based on emission rates set by Nexus Market. The DistributionManager contract manages the calculation and distribution of these incentives. Rewards are proportional to the amount staked and the duration of staking.
The formula for calculating accrued rewards is:
Asset Index: A cumulative value representing the total rewards per unit staked, updated regularly based on the emission rate and total staked tokens.
User Index: The index value recorded during the user's last interaction with the staking contract.
Claiming Rewards
Users can claim their accumulated rewards at any time by calling the claimRewards function:
Claimed rewards are transferred to the user's wallet. This action does not affect the staking status or the cooldown period. Users with the appropriate permissions can also claim rewards on behalf of others using claimRewardsOnBehalf. Additionally, there's an option to claim rewards and immediately restake them in one transaction using claimRewardsAndStake, allowing users to compound rewards.
Slashing
Slashing is a mechanism designed to cover losses in the event of a protocol shortfall by utilizing a portion of the staked funds. Only addresses with the SLASH_ADMIN_ROLE
can initiate a slashing event by calling the slash function:
The maximum slashing amount is determined per-asset by _maxSlashablePercentage
, a predefined limit set by the SLASH_ADMIN_ROLE
.
After a slashing event, the exchange rate is updated to reflect the reduced total assets, proportionally affecting all stakers. The module then enters a post-slashing period during which:
New staking is temporarily disabled to prevent dilution of existing stakers' shares.
Stakers can redeem their tokens without waiting for a cooldown period, allowing them to exit the module promptly.
No further slashing events can occur until the current one is settled.
To conclude the post-slashing period and resume normal operations, the SLASH_ADMIN_ROLE
must call:
Last updated
Was this helpful?