ContinuousVirtualAmountMultiplierFacetStorage
This library manages the storage and logic for the application of amount multipliers (used for scaling rewards) within staking campaigns according to a continuous-based schema.
_Example of a continuous-based schema configuration:
If amountsStaked = [100, 200, 300]
and amountStakedMultipliers = [2, 3, 4]
:
-
A position with less than 100 staked packets will receive an amount multiplier of 1 (no multiplier).
-
A position with staked packets X, where X is between 100 (inclusive) and 200 (exclusive), will receive an amount multiplier calculated as follows:
amountMultiplierForX = 2 + ((X - 100) / (200 - 100)) * (3 - 2)
-
A position with staked packets Y, where Y is between 200 (inclusive) and 300 (exclusive), will receive an amount multiplier calculated as follows:
amountMultiplierForY = 3 + ((Y - 200) / (300 - 200)) * (4 - 3)
-
A position with 300 or more staked packets will receive an amount multiplier of 4.
IMPORTANT:
- Multipliers should be scaled by 1e18, allowing for calculations with up to 18 decimal precision.
-
amountsStaked
andamountStakedMultipliers
must be in strictly increasing order._
CampaignNotOnCreationStateForSetting
Thrown when a targeted campaign is not "On Creation" state, which is required at configurations.
NoAmountMultiplierDataProvided
Thrown at setter when no data provided for either amountsStaked
or amountStakedMultipliers
InvalidAmountMultiplierDataLengths
Thrown at setter when the lengths of amountsStaked
and amountStakedMultipliers
do not match.
InvalidZeroFirstAmountMultiplierData
Thrown at setter when the first element of amountsStaked
or amountStakedMultipliers
is zero.
InvalidAmountMultiplierDataOrder
Thrown at setter when the amountsStaked
or amountStakedMultipliers
are not in strictly increasing order.
STORAGE_SLOT
Unique identifier for the storage slot where the Layout struct is stored.
DIVIDER
Used to normalize values (e.g., multipliers) for calculations with up to 18 decimal precision.
Layout
Struct for managing information related to amount-wise multipliers.
CampaignInfo
Struct containing the configuration information for amount-wise multipliers in a staking campaign.
layout
Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT
unique identifier.
setCampaignVirtualAmountMultipliers
Setter function for configuring amount multipliers for the specified staking campaign.
_Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol
).
This function allows for the configuration of thresholds and their respective base multipliers for staked amounts.
The lengths of the amountsStaked
and amountStakedMultipliers
arrays must be equal.
Each threshold defined in amountsStaked
should correspond to a base multiplier in amountStakedMultipliers
._
Parameters
Name | Type | Description |
---|---|---|
l | struct ContinuousVirtualAmountMultiplierFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignVirtualAmountMultipliersData | bytes | The ABI-encoded data containing the following: - amountsStaked : A uint256 array of input packet amounts defining amount thresholds for amount-based multipliers. - amountStakedMultipliers : A uint256 array of respective base multiplier values for each threshold (scaled by 1e18). |
applyVirtualAmountMultiplier
Calculates and applies the respective amount multiplier to the specified position based on the campaign's configuration and the position's total staked amount of input packets.
This function returns the virtual balance of the specified position, calculated as the position's actual raw balance multiplied by the applicable amount multiplier.
Parameters
Name | Type | Description |
---|---|---|
l | struct ContinuousVirtualAmountMultiplierFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
nftId | uint256 | The unique identifier of the NFT associated with the position. |
totalAmountStaked | uint256 | The actual raw balance (in staked input packets) of the position. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The calculated virtual balance of the position. |