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
Emitted at setCampaignRewardsDistribution()
.
RewardsNotifiedForCampaign
Emitted at notifyRewardAmount()
.
setCampaignRewardsDistribution
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
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.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | 0 because rewards at restake are provided by getRestakeReward() . |
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
Returns the claimable rewards for a specific position when it is increased.
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. |
notifyRewardAmount
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
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
rewardAmount | uint256 | The amount of reward packets. |