Staking ProtocolinternalFacetsrewardsDistributionpreStakeRewardDistribution

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:

  1. 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.
  2. 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._

CampaignRewardsDistributionConfigured

event CampaignRewardsDistributionConfigured(uint256 campaignId, address rewardProvider, uint256 totalReward, bool isInstaReward)

Emitted at setCampaignRewardsDistribution().

setCampaignRewardsDistribution

function setCampaignRewardsDistribution(uint256 campaignId, bytes campaignRewardsDistributionData) external

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

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
campaignRewardsDistributionDatabytesThe ABI-encoded data for the reward distribution schedule.

applyStake

function applyStake(uint256 campaignId, uint256 nftId, uint256 virtualPacketsStaked, uint256 packetsStaked, address) external

Creates a new staking position in the specified campaign.

If no amount multiplier is applied, virtualPacketsStaked will be equal to packetsStaked.

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
nftIduint256The unique identifier of the NFT associated with the position.
virtualPacketsStakeduint256The number of staked (input) packets adjusted by the applicable amount multiplier.
packetsStakeduint256The raw number of staked packets, without accounting for amount multipliers.
address

applyRestake

function applyRestake(uint256 campaignId, uint256 nftId) external returns (uint256)

Called when a specified position in the given campaign is increased.

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
nftIduint256

Return Values

NameTypeDescription
[0]uint2560 because rewards are provided after ending timestamp of campaign.

applyUnstake

function applyUnstake(uint256 campaignId, uint256 nftId) external returns (uint256)

Returns the claimable rewards for a position being unstaked.

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
nftIduint256The unique identifier of the NFT associated with the position.

Return Values

NameTypeDescription
[0]uint256The calculated claimable rewards.

getReward

function getReward(uint256 campaignId, uint256 nftId) external returns (uint256)

Returns the claimable rewards for a specific position.

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
nftIduint256The unique identifier of the NFT associated with the position.

Return Values

NameTypeDescription
[0]uint256The rewards that can be claimed by the specified position.

getRestakeReward

function getRestakeReward(uint256, uint256) external view returns (uint256)

Called when a position in a campaign is increased.

Return Values

NameTypeDescription
[0]uint2560 because rewards are provided after ending timestamp of campaign.

On this page