PreStakeRewardDistributionFacet
This face manages the storage and logic for the PreStake Reward Distribution algorithm.
_This implementation is designed exclusively for campaigns that expect users to stake (or restake) within a predefined time window, specifically between the campaign's starting and ending timestamps. Rewards are distributed only after the campaign's ending timestamp and up until a predefined rewards ending timestamp.
Key Design Features:
- Fixed Lock Period: All users should be locked for the same duration, eliminating the need for lock multipliers.
- Restaking is permitted only within the campaign's staking window (
startingTimestamp <= t_stake <= endingTimestamp
). - Delayed Rewards: Rewards are not distributed instantly upon staking but are available after the campaign's ending timestamp.
- InstaRewards Option:
- If enabled, users can claim all their designated rewards immediately after the campaign's ending timestamp, though they remain locked until the rewards ending timestamp.
- If disabled, users receive rewards proportionally based on the time elapsed since the campaign's ending timestamp. Full rewards are only claimable after the rewards ending timestamp.
Integration Considerations:
-
Using
ERC__RewardTransferFacet
:- Rewards are transferred from the distributor to the
RewardAssetHandler
. - The reward distributor must approve the diamond for reward transfers before the PreStake configuration is executed.
- The diamond contract will initiate
transferFrom
to retrieve the rewards.
- Rewards are transferred from the distributor to the
-
Using
ERC__RewardMinterFacet
:- Rewards are minted by the campaign's
RewardAssetHandler
, not the diamond itself. - The minter role must be assigned to the campaign's
RewardAssetHandler
._
- Rewards are minted by the campaign's
CampaignRewardsDistributionConfigured
Emitted at setCampaignRewardsDistribution()
.
setCampaignRewardsDistribution
Sets the rewards distribution schedule for a specified campaign.
_This function can only be called during the campaign's creation
(see CampaignCreationSkeleton.createCampaign()
).
Emits a {CampaignRewardsDistributionConfigured}
event._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignRewardsDistributionData | bytes | The ABI-encoded data for the reward distribution schedule. |
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 amount multiplier. |
packetsStaked | uint256 | The raw number of staked packets, without accounting for amount multipliers. |
address |
applyRestake
Called when a specified position in the given campaign is increased.
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
nftId | uint256 |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | 0 because rewards are provided after ending timestamp of campaign. |
applyUnstake
Returns the claimable rewards for a position being unstaked.
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 calculated claimable rewards. |
getReward
Returns the claimable rewards for a specific position.
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 rewards that can be claimed by the specified position. |
getRestakeReward
Called when a position in a campaign is increased.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | 0 because rewards are provided after ending timestamp of campaign. |