IntervalVirtualLockMultiplierFacet
Enables the application of lock multipliers (used for scaling rewards when positions are locked) within staking campaigns according to an interval-based schema.
_Example of an interval-based schema configuration:
If timeLockPeriods = [100, 300]
and timeLockMultipliers = [2, 4]
:
- A position with lock duration less than 100 seconds will receive a lock multiplier of 1 (no multiplier).
- A position with lock duration between 100 and 299 seconds will receive a lock multiplier of 2.
- A position with lock duration 300 seconds or more will receive a lock multiplier of 4.
In addition to lock scaling, staking campaigns may also scale rewards based on the allocated staked amounts (i.e., amount multipliers). This implementation focuses solely on lock periods scaling, ensuring that locked positions receive rewards according to the interval-based lock multiplier schema defined by the associated campaign.
IMPORTANT:
- Multipliers should be scaled by 1e18, allowing for calculations with up to 18 decimal precision.
-
timeLockPeriods
andtimeLockMultipliers
must be in strictly increasing order._
CampaignVirtualLockMultipliersConfigured
Emitted at setCampaignVirtualLockMultipliers()
.
VirtualLockMultiplierApplied
Emitted at applyVirtualLockMultiplier()
and combineVirtualLockMultipliers()
.
setCampaignVirtualLockMultipliers
Setter function for configuring lock 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 multipliers for lock periods.
The lengths of the timeLockPeriods
and timeLockMultipliers
arrays must be equal.
Each threshold defined in timeLockPeriods
should correspond to a multiplier in timeLockMultipliers
.
Emits a {CampaignVirtualLockMultipliersConfigured}
event.
IMPORTANT:
- Values in
timeLockMultipliers
should be scaled by 1e18 at the API level, allowing for 18 decimal precision. -timeLockPeriods
andtimeLockMultipliers
must be in strictly increasing order._
Parameters
Name | Type | Description |
---|---|---|
campaignId | uint256 | The unique identifier of the targeted staking campaign. |
campaignVirtualLockMultipliersData | bytes | The ABI-encoded data containing the following: - timeLockPeriods : A uint256 array of time durations (in seconds) defining lock duration thresholds for lock-based multipliers. - timeLockMultipliers : A uint256 array of respective multiplier values for each threshold (scaled by 1e18). |
applyVirtualLockMultiplier
Applies the respective lock multiplier to the specified position based on the campaign's configuration and the position's lock period.
Lock multipliers are scaled by 1e18, allowing for 18 decimal precision.
Emits a {VirtualLockMultiplierApplied}
event.
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 value of the applied lock multiplier. |
combineVirtualLockMultipliers
Applies to the specified position the calculated combined lock multiplier.
_The combined lock multiplier value is calculated as follows:
Emits a {VirtualLockMultiplierApplied}
event.
IMPORTANT: This adjustment occurs when a position's lock period hasn't elapsed and the position is increased via a restake operation. The combined lock multiplier for calculating rewards is accounted for the period between the position's current unlock timestamp and the restake's unlocktimestamp._
Parameters
Name | Type | Description |
---|---|---|
nftId | uint256 | The unique identifier of the NFT associated with the position. |
currentLockMultiplier | uint256 | The value of the lock multiplier currently applied to the position. |
newLockMultiplier | uint256 | The lock multiplier applicable for the restake's lock period. |
packetsStaked | uint256 | The total amount of staked input packets in the current position. |
packetsRestaked | uint256 | The amount of input packets to be allocated during the restake operation. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The calculated combined lock multiplier value. |
getCurrentLockMultiplier
Retrieves the lock multiplier currently applied to the specified position.
Lock multipliers are scaled by 1e18, allowing for 18 decimal precision. Lock multipliers are only accounted for rewards during positions lock period.
Parameters
Name | Type | Description |
---|---|---|
nftId | uint256 | The unique identifier of the NFT associated with the position. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The lock multiplier value currently applied to the specified position. |
getVirtualBalance
Calculates and retrieves the virtual balance of the specified position. The virtual balance is calculated as the position's actual raw balance (staked input packets) multiplied by the applicable amount and lock multiplier.
Parameters
Name | Type | Description |
---|---|---|
nftId | uint256 | The unique identifier of the NFT associated with the position. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The virtual balance of the position accounting for both any applicable amount and lock multipliers. |
getVirtualBalanceForAmount
Retrieves the virtual amount of packets based on the specified amount of packets and the position's applicable lock multiplier (virtualAmount = amountOfPackets * lockMultiplierApplied).
This function only accounts for any applicable lock multiplier.
Parameters
Name | Type | Description |
---|---|---|
nftId | uint256 | The unique identifier of the NFT associated with the position. |
amountOfPackets | uint256 | The number of packets to account for. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The virtual balance of the specified packets accounting only for any applicable lock multiplier. |