RateBasedLockRewardDistributionFacet
This facet manages the logic and storage for the Rate-Based Lock Reward Distribution algorithm. The functions in this facet handle operations such as creating staking positions, calculating staking rewards based on lock periods and multipliers, as well as calculating claimable rewards for stakeholders. This contract is designed to support instant staking rewards distribution by default while maintaining flexibility for future updates and features (e.g., restake after unlock timestamp).
_It operates using the Layout struct defined in RateBasedLockRewardDistributionFacetStorage
,
which contains essential data for managing staking campaigns within the context of the
Rate-Based rewards distribution schedule.
IMPORTANT:
-
Rate-Based Reward Distribution Facets should only be used in conjuction with RewardMinter Facets for configuring reward assets in staking campaigns.
-
This implementation is intended to be leveraged by campaigns where locking positions is a fundamental requirement for participation and instant staking rewards are featured. It does not cater to scenarios where stakeholders can freely unstake their positions at any time.
-
Reward rates should be scaled by 1e18 at the API level, allowing for calculations with up to 18 decimal precision._
RestakeDisabledDueToInstantStakeRewards
Thrown due to restaking being disabled due to instant staking rewards featured.
CampaignRewardsDistributionConfigured
Emitted at setCampaignRewardsDistribution()
.
RewardRateChanged
Emitted at changeCampaignRate()
.
InstaStakeRewardsReceived
Emitted at applyStake()
setCampaignRewardsDistribution
Sets the rewards distribution schedule for a specified campaign.
_This function can only be called during the campaign's creation
(see CampaignCreationSkeleton.createCampaign()
).
The reward rate must be scaled by 1e18 (18 decimal precision support).
Emits a {CampaignRewardsDistributionConfigured}
event.
IMPORTANT: Reward Rate value should be scaled by 1e18 at the API level, allowing for 18 decimal precision._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignRewardsDistributionData | bytes | Should contain an ABI-encoded uint256 for the reward rate and a boolean indicating whether lock multipliers are supported. |
changeCampaignRate
Changes the rate of rewards for a specified campaign.
This function can only be called by the creator of the targeted campaign.
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
newRate | uint256 | The new reward rate to be applied for the campaign (must be scaled with 1e18). |
applyStake
Creates a new staking position in the specified campaign.
_Staking rewards are transferred instantly to the position's creator.
If no amount multiplier is applied, virtualPacketsStaked
will be equal to packetsStaked
.
Emits a {InstaStakeRewardsReceived}
event._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
nftId | uint256 | The unique identifier of the NFT associated with the position. |
virtualPacketsStaked | uint256 | The number of staked (input) packets adjusted by the applicable amount multiplier (if any). |
packetsStaked | uint256 | The raw number of staked packets, before applying any multipliers. |
account | address | The address of the user creating and owning the position. |
applyRestake
Reverts because restaking is not supported when instant staking rewards are featured.
This function always reverts with a custom message explaining that restaking is disabled due to the instant rewards feature.
Parameters
Name | Type | Description |
---|---|---|
uint256 | ||
uint256 |
applyUnstake
Called when a position's owner partially or fully unstakes.
Decreasing or closing a position (partially or fully unstaking) is only allowed after the position's lock period has expired.
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
nftId | uint256 | The unique identifier of the NFT associated with the position. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The current claimable amount of reward packets for the position. |
getReward
Returns the claimable rewards for a specific position.
The claimable rewards are calculated without accounting for lock multipliers. Claimable rewards begin to accrue after the position's lock period expires when instant staking rewards are featured.
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
nftId | uint256 | The unique identifier of the NFT associated with the position. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The amount of reward packets that can be claimed by the specified position. |
getRestakeReward
Reverts because restaking is not supported when instant staking rewards are featured.
This function alwayss revert with a custom message explaining that restaking is disabled due to the instant rewards feature.
Parameters
Name | Type | Description |
---|---|---|
uint256 | ||
uint256 |