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

protocol_fee_reward_state.gno

Types

ProtocolFeeRewardState

ProtocolFeeRewardState tracks the protocol fee rewards of one staker.

Ordinary stake changes append one ProtocolFeeStakeEvent; Redelegate performs a remove plus an add and appends two events. Each token is settled on its own from those events, so the state keeps a per-token cursor into the event history rather than a reward debt for every token at once.

source

Methods

AppendStakeEvent

AppendStakeEvent records that stakedAmount is staked from epoch on.

Parameters

Name
Type
Description

epoch

int64

accrual epoch at which this stake amount becomes effective

stakedAmount

int64

stake amount in force from epoch onward

source

GetClaimedReward

GetClaimedReward returns the total reward of tokenPath collected so far.

Parameters

Name
Type
Description

tokenPath

string

token path whose accumulated claimed reward is requested

Return Values

Name
Type
Description

int64

int64

total reward collected for tokenPath, or zero when no token state exists

source

GetClaimedTimestamp

GetClaimedTimestamp returns the last timestamp at which all token rewards were collected.

Return Values

Name
Type
Description

int64

int64

Unix timestamp recorded for the most recent all-token collection

source

GetStakeEvent

GetStakeEvent returns the indexed stake event.

Parameters

Name
Type
Description

index

int64

zero-based stake-event index

Return Values

Name
Type
Description

*ProtocolFeeStakeEvent

*ProtocolFeeStakeEvent

event at index, or nil when no event is stored there

bool

bool

true when an event exists at index; false when the index is absent

source

GetStakeEventCount

GetStakeEventCount returns the number of stake-change events recorded.

Return Values

Name
Type
Description

int64

int64

count of indexed stake events

source

GetStakedAmount

GetStakedAmount returns the current stake amount tracked for the staker.

Return Values

Name
Type
Description

int64

int64

current staked amount

source

GetTokenPaths

GetTokenPaths returns every token path settled for this staker, in key order.

Return Values

Name
Type
Description

[]string

[]string

token paths with stored settlement state, ordered by the underlying tree keys

source

GetTokenState

GetTokenState returns the settlement state of tokenPath, or false when the token was never settled for this staker.

Parameters

Name
Type
Description

tokenPath

string

registered token path whose per-staker settlement state is requested

Return Values

Name
Type
Description

*ProtocolFeeTokenRewardState

*ProtocolFeeTokenRewardState

token settlement state, or nil when it has not been initialized

bool

bool

true when tokenPath has a stored settlement state, otherwise false

source

SetClaimedTimestamp

SetClaimedTimestamp records the timestamp at which all token rewards were collected.

Parameters

Name
Type
Description

claimedTimestamp

int64

Unix timestamp of the all-token collection

source

SetStakedAmount

SetStakedAmount updates the current stake amount tracked for the staker.

Parameters

Name
Type
Description

stakedAmount

int64

new current staked amount

source

SetTokenState

SetTokenState stores the settlement state for a token path.

Parameters

Name
Type
Description

tokenPath

string

token path used as the settlement-state key

tokenState

*ProtocolFeeTokenRewardState

per-token settlement state to store

source

Constructors

  • func NewProtocolFeeRewardState() *ProtocolFeeRewardState (source)

ProtocolFeeStakeEvent

ProtocolFeeStakeEvent is one stake change: from epoch on, stakedAmount was staked.

source

Methods

GetEpoch

GetEpoch returns the accrual epoch from which this stake event applies.

Return Values

Name
Type
Description

int64

int64

epoch at which the stake amount became effective

source

GetStakedAmount

GetStakedAmount returns the stake amount in force for this event.

Return Values

Name
Type
Description

int64

int64

staked amount associated with the event

source

ProtocolFeeTokenRewardState

ProtocolFeeTokenRewardState is the settlement state of one token for one staker.

Stake events up to eventCursor are folded into earnedX128. The open segment starts where the last folded event left the accumulator (segmentStartX128) with segmentStakedAmount staked.

source

Methods

GetClaimedReward

GetClaimedReward returns the total reward collected for this token state.

Return Values

Name
Type
Description

int64

int64

cumulative collected reward amount

source

GetEarnedX128

GetEarnedX128 returns closed-segment earnings awaiting collection.

Return Values

Name
Type
Description

*u256.Uint

*u256.Uint

unclaimed reward accumulator scaled by 2^128

source

GetEventCursor

GetEventCursor returns the number of stake events already folded for this token.

Return Values

Name
Type
Description

int64

int64

count of folded stake events

source

GetSegmentStakedAmount

GetSegmentStakedAmount returns the stake amount in the open segment.

Return Values

Name
Type
Description

int64

int64

stake amount used while settling the open segment

source

GetSegmentStartX128

GetSegmentStartX128 returns the accumulator value at the open segment start.

Return Values

Name
Type
Description

*u256.Uint

*u256.Uint

fee-per-stake accumulator at segment start, scaled by 2^128

source

SetClaimedReward

SetClaimedReward replaces the cumulative collected reward amount.

Parameters

Name
Type
Description

claimedReward

int64

total reward collected for this token state

source

SetEarnedX128

SetEarnedX128 replaces the closed-segment earnings accumulator.

Parameters

Name
Type
Description

earnedX128

*u256.Uint

unclaimed earnings accumulator scaled by 2^128

source

SetSegment

SetSegment moves the open segment: events up to eventCursor are folded, and the segment starts at segmentStartX128 with segmentStakedAmount staked.

Parameters

Name
Type
Description

eventCursor

int64

number of stake events folded into the new segment

segmentStakedAmount

int64

stake amount in force for the new open segment

segmentStartX128

*u256.Uint

fee-per-stake accumulator at the new segment start, scaled by 2^128

source

Constructors

  • func NewProtocolFeeTokenRewardState(eventCursor int64, segmentStakedAmount int64, segmentStartX128 *u256.Uint) *ProtocolFeeTokenRewardState (source)

Last updated