RateBasedOpenRewardDistributionFacet
This facet manages the logic and storage for the Rate-Based Open Reward Distribution algorithm. The functions in this facet handle operations such as creating and increasing staking positions, and calculating claimable rewards based on amount multipliers.
This facet is designed exclusively for no-lock campaigns and does not support instant stake rewards, while maintaining flexibility for future updates and features.
_It operates using the Layout struct defined in RateBasedOpenRewardDistributionFacetStorage
,
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 designed for campaigns where positions are always unlockable and instant staking rewards are not featured. It does not support scenarios where stakeholders can lock their positions.
-
Reward rates should be scaled by 1e18 at the API level, allowing for calculations with up to 18 decimal precision._
CampaignRewardsDistributionConfigured
Emitted at setCampaignRewardsDistribution()
.
RewardRateChanged
Emitted at changeCampaignRate()
.
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 | The ABI-encoded uint256 for the reward rate value to set. |
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.
If no amount multiplier is applied, virtualPacketsStaked
will be equal to packetsStaked
.
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 multiplier (if any). |
packetsStaked | uint256 | The raw number of staked packets, before applying any amount multiplier. |
address |
applyRestake
Increases the given staking position in the specified campaign.
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign (unused in this implementation). |
nftId | uint256 | The unique identifier of the NFT associated with the position (unused in this implementation). |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | 0 since unclaimed rewards (till restake) should be provided by getRestakeReward() |
applyUnstake
Called when a position's owner partially or fully unstakes.
Decreasing or closing a position (partially or fully unstaking) should be allowed at any time.
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 position's accured claimable rewards (output packets). |
getReward
Returns the accrued claimable rewards for a specific position.
Claimable rewards begin to accrue at the moment a position is created based on the campaign's reward distribution settings.
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
Returns the accured claimable rewards for a specific position.
This function is called when a position is increased (see StakingSkeleton.sol
).
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. |