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.
Methods
AppendStakeEvent
AppendStakeEvent records that stakedAmount is staked from epoch on.
Parameters
epoch
int64
accrual epoch at which this stake amount becomes effective
stakedAmount
int64
stake amount in force from epoch onward
GetClaimedReward
GetClaimedReward returns the total reward of tokenPath collected so far.
Parameters
tokenPath
string
token path whose accumulated claimed reward is requested
Return Values
int64
int64
total reward collected for tokenPath, or zero when no token state exists
GetClaimedTimestamp
GetClaimedTimestamp returns the last timestamp at which all token rewards were collected.
Return Values
int64
int64
Unix timestamp recorded for the most recent all-token collection
GetStakeEvent
GetStakeEvent returns the indexed stake event.
Parameters
index
int64
zero-based stake-event index
Return Values
*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
GetStakeEventCount
GetStakeEventCount returns the number of stake-change events recorded.
Return Values
int64
int64
count of indexed stake events
GetStakedAmount
GetStakedAmount returns the current stake amount tracked for the staker.
Return Values
int64
int64
current staked amount
GetTokenPaths
GetTokenPaths returns every token path settled for this staker, in key order.
Return Values
[]string
[]string
token paths with stored settlement state, ordered by the underlying tree keys
GetTokenState
GetTokenState returns the settlement state of tokenPath, or false when the token was never settled for this staker.
Parameters
tokenPath
string
registered token path whose per-staker settlement state is requested
Return Values
*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
SetClaimedTimestamp
SetClaimedTimestamp records the timestamp at which all token rewards were collected.
Parameters
claimedTimestamp
int64
Unix timestamp of the all-token collection
SetStakedAmount
SetStakedAmount updates the current stake amount tracked for the staker.
Parameters
stakedAmount
int64
new current staked amount
SetTokenState
SetTokenState stores the settlement state for a token path.
Parameters
tokenPath
string
token path used as the settlement-state key
tokenState
*ProtocolFeeTokenRewardState
per-token settlement state to store
Constructors
func NewProtocolFeeRewardState() *ProtocolFeeRewardState(source)
ProtocolFeeStakeEvent
ProtocolFeeStakeEvent is one stake change: from epoch on, stakedAmount was staked.
Methods
GetEpoch
GetEpoch returns the accrual epoch from which this stake event applies.
Return Values
int64
int64
epoch at which the stake amount became effective
GetStakedAmount
GetStakedAmount returns the stake amount in force for this event.
Return Values
int64
int64
staked amount associated with the event
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.
Methods
GetClaimedReward
GetClaimedReward returns the total reward collected for this token state.
Return Values
int64
int64
cumulative collected reward amount
GetEarnedX128
GetEarnedX128 returns closed-segment earnings awaiting collection.
Return Values
*u256.Uint
*u256.Uint
unclaimed reward accumulator scaled by 2^128
GetEventCursor
GetEventCursor returns the number of stake events already folded for this token.
Return Values
int64
int64
count of folded stake events
GetSegmentStakedAmount
GetSegmentStakedAmount returns the stake amount in the open segment.
Return Values
int64
int64
stake amount used while settling the open segment
GetSegmentStartX128
GetSegmentStartX128 returns the accumulator value at the open segment start.
Return Values
*u256.Uint
*u256.Uint
fee-per-stake accumulator at segment start, scaled by 2^128
SetClaimedReward
SetClaimedReward replaces the cumulative collected reward amount.
Parameters
claimedReward
int64
total reward collected for this token state
SetEarnedX128
SetEarnedX128 replaces the closed-segment earnings accumulator.
Parameters
earnedX128
*u256.Uint
unclaimed earnings accumulator scaled by 2^128
SetSegment
SetSegment moves the open segment: events up to eventCursor are folded, and the segment starts at segmentStartX128 with segmentStakedAmount staked.
Parameters
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
Constructors
func NewProtocolFeeTokenRewardState(eventCursor int64, segmentStakedAmount int64, segmentStartX128 *u256.Uint) *ProtocolFeeTokenRewardState(source)
Last updated