For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

source

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

Name
Type
Description

amount

int64

legacy accumulated distribution amount in token base units; v1 accounting normally leaves it at zero unless explicitly set.

source

AccumulatedRewardPerDepositX128

AccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of the reward manager.

Return Values

Name
Type
Description

accumulatedRewardPerDepositX128

*u256.Uint

accumulated reward index per deposited GNS unit in Q128 fixed-point units.

source

AccumulatedTime

AccumulatedTime returns the accumulated time of the reward manager.

Return Values

Name
Type
Description

time

int64

last reward-accumulation timestamp in Unix seconds, or zero before accumulation.

source

ActiveClaimedAmount

ActiveClaimedAmount returns the reward amount claimed by currently active reward states.

Return Values

Name
Type
Description

amount

int64

active claimed reward amount in token base units.

source

ActiveDepositAmount

ActiveDepositAmount returns the principal represented by currently active reward states.

Return Values

Name
Type
Description

amount

int64

active deposited GNS principal in base units.

source

ActivePriceDebtX128

ActivePriceDebtX128 returns the sum of active deposits' initial reward-index debts.

Return Values

Name
Type
Description

debt

*u256.Uint

aggregate active price debt in Q128 fixed-point units.

source

Clone

Clone returns an independent copy of the reward manager, including its reward states and Q128 values.

Return Values

Name
Type
Description

rewardManager

*RewardManager

deep copy with a separate reward tree and mutable numeric values.

source

DistributeAmountPerSecondX128

DistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the reward manager.

Return Values

Name
Type
Description

amountPerSecondX128

*u256.Uint

reward distribution rate in Q128 fixed-point token units per second.

source

DistributeEndTime

DistributeEndTime returns the distribute end time of the reward manager.

Return Values

Name
Type
Description

endTime

int64

reward distribution end timestamp in Unix seconds.

source

DistributeStartTime

DistributeStartTime returns the distribute start time of the reward manager.

Return Values

Name
Type
Description

startTime

int64

reward distribution start timestamp in Unix seconds.

source

RemoveReward

RemoveReward removes the reward state associated with a deposit ID.

Parameters

Name
Type
Description

depositID

string

deposit identifier whose reward state is removed.

source

RewardClaimableDuration

RewardClaimableDuration returns the reward claimable duration of the reward manager.

Return Values

Name
Type
Description

duration

int64

time after a reward becomes claimable during which it remains collectible, in seconds.

source

Rewards

Rewards returns the rewards tree of the reward manager.

Return Values

Name
Type
Description

rewards

*bptree.BPTree

reward-state tree keyed by deposit ID.

source

SetAccumulatedDistributeAmount

SetAccumulatedDistributeAmount sets the legacy reward-manager field. It is not used by v1 reward accounting.

Parameters

Name
Type
Description

amount

int64

legacy accumulated distribution amount in token base units; v1 accounting does not update this field.

source

SetAccumulatedRewardPerDepositX128

SetAccumulatedRewardPerDepositX128 sets the accumulated reward per deposit (Q128) of the reward manager.

Parameters

Name
Type
Description

amount

*u256.Uint

replacement accumulated reward-per-deposit index in Q128 fixed-point units; the value is copied.

source

SetAccumulatedTime

SetAccumulatedTime sets the accumulated time of the reward manager.

Parameters

Name
Type
Description

time

int64

last reward-accumulation timestamp in Unix seconds.

source

SetActiveClaimedAmount

SetActiveClaimedAmount replaces the reward amount claimed by currently active reward states.

Parameters

Name
Type
Description

amount

int64

active claimed reward amount in token base units.

source

SetActiveDepositAmount

SetActiveDepositAmount replaces the principal represented by currently active reward states.

Parameters

Name
Type
Description

amount

int64

active deposited GNS principal in base units.

source

SetActivePriceDebtX128

SetActivePriceDebtX128 replaces the aggregate active price-index debt.

Parameters

Name
Type
Description

debt

*u256.Uint

aggregate active price debt in Q128 fixed-point units; the value is copied.

source

SetDistributeAmountPerSecondX128

SetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the reward manager.

Parameters

Name
Type
Description

amount

*u256.Uint

replacement reward distribution rate in Q128 fixed-point token units per second; the value is copied.

source

SetDistributeEndTime

SetDistributeEndTime sets the distribute end time of the reward manager.

Parameters

Name
Type
Description

time

int64

reward distribution end timestamp in Unix seconds.

source

SetDistributeStartTime

SetDistributeStartTime sets the distribute start time of the reward manager.

Parameters

Name
Type
Description

time

int64

reward distribution start timestamp in Unix seconds.

source

SetReward

SetReward associates a reward state with a deposit ID in the manager's reward tree.

Parameters

Name
Type
Description

depositID

string

deposit identifier used as the reward-tree key.

rewardState

*RewardState

reward state to store for that deposit.

source

SetRewardClaimableDuration

SetRewardClaimableDuration sets the reward claimable duration of the reward manager.

Parameters

Name
Type
Description

duration

int64

claimable reward window in seconds.

source

SetRewards

SetRewards sets the rewards tree of the reward manager.

Parameters

Name
Type
Description

rewards

*bptree.BPTree

reward-state tree to use for this manager.

source

SetTotalClaimedAmount

SetTotalClaimedAmount sets the total claimed amount of the reward manager.

Parameters

Name
Type
Description

amount

int64

total claimed reward amount in token base units.

source

SetTotalDistributeAmount

SetTotalDistributeAmount sets the total distribute amount of the reward manager.

Parameters

Name
Type
Description

amount

int64

total reward allocation for the tier in token base units.

source

TotalClaimedAmount

TotalClaimedAmount returns the total claimed amount of the reward manager.

Return Values

Name
Type
Description

amount

int64

total reward amount claimed from the tier in token base units.

source

TotalDistributeAmount

TotalDistributeAmount returns the total distribute amount of the reward manager.

Return Values

Name
Type
Description

amount

int64

total reward allocation for the tier in token base units.

source

Constructors

  • func GetProjectTierRewardManager(projectTierId string) (*RewardManager, error) (source)

  • func NewRewardManager(totalDistributeAmount int64, distributeStartTime int64, distributeEndTime int64, rewardCollectableDuration int64) *RewardManager (source)

Last updated