Staking ProtocolrewardsDistributioncomplexRewardDistribution

ComplexRewardDistributionFacet

This implementation manages the storage and logic for the Complex Reward Distribution algorithm which is inspired by the Synthetix algorithm. https://github.com/Synthetixio/synthetix/blob/develop/contracts/RewardsDistribution.sol

This implementation is designed exclusively for campaigns with no locks that provide perpetual rewards.

CampaignRewardsDistributionConfigured

event CampaignRewardsDistributionConfigured(uint256 campaignId, uint256 duration, address rewardDistributor)

Emitted at setCampaignRewardsDistribution().

RewardsNotifiedForCampaign

event RewardsNotifiedForCampaign(uint256 campaignId, uint256 rewardAmount)

Emitted at notifyRewardAmount().

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()).

Sets the duration and the designated reward distributor.

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, uint256) external view returns (uint256)

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

Return Values

NameTypeDescription
[0]uint2560 because rewards at restake are provided by getRestakeReward().

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 campaignId, uint256 nftId) external returns (uint256)

Returns the claimable rewards for a specific position when it is increased.

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.

notifyRewardAmount

function notifyRewardAmount(uint256 campaignId, uint256 rewardAmount) external

This function is called by the reward distributor of the specified campaign to provide additional rewards

This function can only be called by the reward distributor of the campaign.

Parameters

NameTypeDescription
campaignIduint256The unique identifier of the targeted staking campaign.
rewardAmountuint256The amount of reward packets.

On this page