reward_manager.gno
Types
RewardManager
RewardManager manages the distribution of rewards for a project tier.
This struct contains the necessary data and methods to calculate and track rewards for deposits associated with a project tier.
Fields:
rewards (bptree.BPTree): A map of deposit IDs to their associated reward states.
distributeAmountPerSecondX128 (u256.Uint): The amount of tokens to be distributed per second, represented as a Q128 fixed-point number.
accumulatedRewardPerDepositX128 (u256.Uint): The accumulated reward per GNS stake, represented as a Q128 fixed-point number.
totalDistributeAmount (int64): The total token allocation for this tier.
totalClaimedAmount (int64): The total amount of tokens claimed.
distributeStartTime (int64): The start time of the reward calculation.
distributeEndTime (int64): The end time of the reward calculation.
accumulatedDistributeAmount (int64): A legacy field not maintained by v1 reward accounting; normally zero unless explicitly set.
rewardClaimableDuration (int64): The duration of reward claimable.
Methods
AccumulatedDistributeAmount
AccumulatedDistributeAmount returns the legacy reward-manager field. v1 reward paths do not maintain it, so normal reads return zero unless it was explicitly set.
Return Values
amount
int64
legacy accumulated distribution amount in token base units; v1 accounting normally leaves it at zero unless explicitly set.
AccumulatedRewardPerDepositX128
AccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of the reward manager.
Return Values
accumulatedRewardPerDepositX128
*u256.Uint
accumulated reward index per deposited GNS unit in Q128 fixed-point units.
AccumulatedTime
AccumulatedTime returns the accumulated time of the reward manager.
Return Values
time
int64
last reward-accumulation timestamp in Unix seconds, or zero before accumulation.
ActiveClaimedAmount
ActiveClaimedAmount returns the reward amount claimed by currently active reward states.
Return Values
amount
int64
active claimed reward amount in token base units.
ActiveDepositAmount
ActiveDepositAmount returns the principal represented by currently active reward states.
Return Values
amount
int64
active deposited GNS principal in base units.
ActivePriceDebtX128
ActivePriceDebtX128 returns the sum of active deposits' initial reward-index debts.
Return Values
debt
*u256.Uint
aggregate active price debt in Q128 fixed-point units.
Clone
Clone returns an independent copy of the reward manager, including its reward states and Q128 values.
Return Values
rewardManager
*RewardManager
deep copy with a separate reward tree and mutable numeric values.
DistributeAmountPerSecondX128
DistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the reward manager.
Return Values
amountPerSecondX128
*u256.Uint
reward distribution rate in Q128 fixed-point token units per second.
DistributeEndTime
DistributeEndTime returns the distribute end time of the reward manager.
Return Values
endTime
int64
reward distribution end timestamp in Unix seconds.
DistributeStartTime
DistributeStartTime returns the distribute start time of the reward manager.
Return Values
startTime
int64
reward distribution start timestamp in Unix seconds.
RemoveReward
RemoveReward removes the reward state associated with a deposit ID.
Parameters
depositID
string
deposit identifier whose reward state is removed.
RewardClaimableDuration
RewardClaimableDuration returns the reward claimable duration of the reward manager.
Return Values
duration
int64
time after a reward becomes claimable during which it remains collectible, in seconds.
Rewards
Rewards returns the rewards tree of the reward manager.
Return Values
rewards
*bptree.BPTree
reward-state tree keyed by deposit ID.
SetAccumulatedDistributeAmount
SetAccumulatedDistributeAmount sets the legacy reward-manager field. It is not used by v1 reward accounting.
Parameters
amount
int64
legacy accumulated distribution amount in token base units; v1 accounting does not update this field.
SetAccumulatedRewardPerDepositX128
SetAccumulatedRewardPerDepositX128 sets the accumulated reward per deposit (Q128) of the reward manager.
Parameters
amount
*u256.Uint
replacement accumulated reward-per-deposit index in Q128 fixed-point units; the value is copied.
SetAccumulatedTime
SetAccumulatedTime sets the accumulated time of the reward manager.
Parameters
time
int64
last reward-accumulation timestamp in Unix seconds.
SetActiveClaimedAmount
SetActiveClaimedAmount replaces the reward amount claimed by currently active reward states.
Parameters
amount
int64
active claimed reward amount in token base units.
SetActiveDepositAmount
SetActiveDepositAmount replaces the principal represented by currently active reward states.
Parameters
amount
int64
active deposited GNS principal in base units.
SetActivePriceDebtX128
SetActivePriceDebtX128 replaces the aggregate active price-index debt.
Parameters
debt
*u256.Uint
aggregate active price debt in Q128 fixed-point units; the value is copied.
SetDistributeAmountPerSecondX128
SetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the reward manager.
Parameters
amount
*u256.Uint
replacement reward distribution rate in Q128 fixed-point token units per second; the value is copied.
SetDistributeEndTime
SetDistributeEndTime sets the distribute end time of the reward manager.
Parameters
time
int64
reward distribution end timestamp in Unix seconds.
SetDistributeStartTime
SetDistributeStartTime sets the distribute start time of the reward manager.
Parameters
time
int64
reward distribution start timestamp in Unix seconds.
SetReward
SetReward associates a reward state with a deposit ID in the manager's reward tree.
Parameters
depositID
string
deposit identifier used as the reward-tree key.
rewardState
*RewardState
reward state to store for that deposit.
SetRewardClaimableDuration
SetRewardClaimableDuration sets the reward claimable duration of the reward manager.
Parameters
duration
int64
claimable reward window in seconds.
SetRewards
SetRewards sets the rewards tree of the reward manager.
Parameters
rewards
*bptree.BPTree
reward-state tree to use for this manager.
SetTotalClaimedAmount
SetTotalClaimedAmount sets the total claimed amount of the reward manager.
Parameters
amount
int64
total claimed reward amount in token base units.
SetTotalDistributeAmount
SetTotalDistributeAmount sets the total distribute amount of the reward manager.
Parameters
amount
int64
total reward allocation for the tier in token base units.
TotalClaimedAmount
TotalClaimedAmount returns the total claimed amount of the reward manager.
Return Values
amount
int64
total reward amount claimed from the tier in token base units.
TotalDistributeAmount
TotalDistributeAmount returns the total distribute amount of the reward manager.
Return Values
amount
int64
total reward allocation for the tier in token base units.
Constructors
Last updated