Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

staker source realm

Readme View source

Gov Staker

Governance delegation and xGNS-based voting power management.

Overview

Gov Staker accepts GNS staking, mints and burns xGNS, maintains delegatee balances and timestamped delegation history, tracks undelegation lockups, and settles two reward streams for stakers: GNS emission rewards and protocol-fee rewards in any registered token.

Configuration

  • Undelegation Lockup: configurable; the default is 7 days before undelegated GNS can be collected.
  • Reward Sources: GNS emission (single token) and protocol-fee distribution (one accumulator per fee token).
  • Delegation State: per-delegator/delegatee records, total and user timestamp histories, and reward stake events.

Core Features

Delegation

  • Delegate GNS to any valid address; the delegated amount is mirrored as xGNS voting power.
  • Redelegate between delegatees without a lockup. Redelegation performs an immediate remove-plus-add for reward accounting.
  • Track undelegated balances until the configured lockup expires; collecting then burns the corresponding xGNS and returns GNS.

Rewards

  • CollectReward claims both the emission stream and all known protocol-fee tokens.
  • CollectEmissionReward claims only GNS emission rewards.
  • CollectProtocolFeeReward claims one protocol-fee token; its bucket and stake-event work is bounded per call, so remaining work is collected later.
  • Launchpad can collect the matching emission and protocol-fee rewards for a registered project wallet through launchpad-only entry points.

Protocol-fee rewards are not calculated as a single current-balance share. Each token's fee buckets are divided by the total stake in force during their accrual epochs, accumulated in Q128 fixed point, and settled across each staker's timestamped stake-event segments. Fractional remainders remain in state for later collection.

History and Snapshots

  • Historical delegation snapshots are timestamp lookups used by governance's configured smoothing calculation; they are not block-height snapshots.
  • Cleanup functions preserve history needed by active proposals.

Key Functions

Delegate

Transfers GNS from the caller, mints the same amount of xGNS, and assigns the delegated voting power to a target address. The caller must approve the GNS transfer first.

Undelegate

Removes voting power immediately and creates a withdrawal subject to the configured lockup.

Redelegate

Moves delegated balance from one delegatee to another immediately, without creating a user-facing lockup.

CollectReward

Claims the caller's GNS emission rewards and all known protocol-fee rewards. The all-token path intentionally grows with the number of known fee tokens.

CollectEmissionReward

Claims only the caller's accumulated GNS emission reward.

CollectProtocolFeeReward

Claims one token path's accumulated protocol-fee reward. A later call may be required when pending accrual buckets or stake events exceed the per-call bound.

CollectUndelegatedGns

Collects GNS after the configured undelegation lockup has passed and burns the corresponding xGNS.

CollectRewardFromLaunchPad

Collects both reward streams for a registered launchpad project wallet. This entry point is callable only by the launchpad contract and sends rewards to the supplied project-wallet address.

Delegation Logic

Delegation Flow

  1. Approve GNS spending by the gov/staker realm.
  2. Delegate GNS to a delegatee; xGNS is minted and timestamped history is updated.
  3. Governance reads the delegatee's history at proposal-defined timestamps for vote weight.
  4. Undelegate to start the lockup, or redelegate immediately to another delegatee.
  5. After the lockup expires, collect undelegated GNS.

Usage

These snippets call the public domain proxy from a realm function with a current cur token. Import the proxy package and qualify its function names in integrating code.

 1// Delegate GNS to another address; xGNS voting power is minted 1:1.
 2delegatedAmount := Delegate(cross(cur), delegatee, 1_000_000_000, "g1referrer...")
 3
 4// Redelegate part of the active balance immediately.
 5Redelegate(cross(cur), delegatee, newDelegatee, 500_000_000)
 6
 7// Claim both GNS emission and all known protocol-fee tokens.
 8CollectReward(cross(cur))
 9
10// Or claim only one stream/token.
11CollectEmissionReward(cross(cur))
12CollectProtocolFeeReward(cross(cur), tokenPath)
13
14// Start undelegation. Collect only after the configured lockup (7 days by default).
15Undelegate(cross(cur), delegatee, 250_000_000)
16// ...wait until the lockup has expired...
17CollectUndelegatedGns(cross(cur))

Security

  • Timestamped delegation history and configurable smoothing reduce flash-loan-style voting manipulation; they do not provide a block snapshot.
  • Undelegation removes voting power immediately, while the lockup delays GNS withdrawal.
  • Protocol-fee stake changes must remain independent of the number of fee tokens; only collection folds fee buckets.
  • Launchpad reward entry points are restricted to the launchpad contract and registered project wallets.
  • Snapshot cleanup must preserve data still needed by active proposals.

Constants 3

const StoreKeyUnDelegationLockupPeriod, StoreKeyTotalDelegatedAmount, StoreKeyTotalLockedAmount, StoreKeyDelegationNextID, StoreKeyDelegations, StoreKeyTotalDelegationHistory, StoreKeyUserDelegationHistory, StoreKeyEmissionRewardManager, StoreKeyProtocolFeeRewardManager, StoreKeyDelegationManager, StoreKeyLaunchpadProjectDeposits

 1const (
 2	// Basic configuration
 3	StoreKeyUnDelegationLockupPeriod = "unDelegationLockupPeriod"
 4	StoreKeyTotalDelegatedAmount     = "totalDelegatedAmount"
 5	StoreKeyTotalLockedAmount        = "totalLockedAmount"
 6
 7	// Counters
 8	StoreKeyDelegationNextID = "delegationNextID"
 9
10	// Complex data structures
11	StoreKeyDelegations            = "delegations"            // BPTree of delegations
12	StoreKeyTotalDelegationHistory = "totalDelegationHistory" // UintTree: timestamp -> int64 (cumulative total)
13	StoreKeyUserDelegationHistory  = "userDelegationHistory"  // BPTree: address -> *UintTree[timestamp -> int64]
14
15	// Manager states
16	StoreKeyEmissionRewardManager    = "emissionRewardManager"
17	StoreKeyProtocolFeeRewardManager = "protocolFeeRewardManager"
18	StoreKeyDelegationManager        = "delegationManager"
19	StoreKeyLaunchpadProjectDeposits = "launchpadProjectDeposits"
20)
source

Storage key constants

const ErrSpoofedRealm

1const ErrSpoofedRealm = "rlm does not match the current crossing frame"
source

ErrSpoofedRealm is returned by store Set* methods when the supplied realm token does not match the current crossing frame (rlm.IsCurrent() is false), rejecting spoofed or stale realm tokens before any write is performed.

Functions 57

func CleanStakerDelegationSnapshotByAdmin

crossing Action
1func CleanStakerDelegationSnapshotByAdmin(cur realm, threshold int64, target address)
source

CleanStakerDelegationSnapshotByAdmin removes old delegation snapshots for the total history and the user history of a single target address. Only callable by admin.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • threshold: Unix timestamp cutoff for removing eligible old delegation history
  • target: user address whose delegation history to clean

Halt check: reverts while the GovStaker halt scope is active.

func CollectEmissionReward

crossing Action
1func CollectEmissionReward(cur realm)
source

CollectEmissionReward claims the caller's accumulated GNS emission reward.

The call is subject to the withdrawal halt and transfers GNS when a reward is available.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.

Halt check: reverts while the Withdraw halt scope is active.

func CollectEmissionRewardFromLaunchPad

crossing Action
1func CollectEmissionRewardFromLaunchPad(cur realm, to address)
source

CollectEmissionRewardFromLaunchPad claims only accumulated GNS emission rewards for a registered launchpad project wallet.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • to: registered launchpad project wallet whose emission reward is claimed

Halt check: reverts while the Withdraw halt scope is active.

func CollectProtocolFeeReward

crossing Action
1func CollectProtocolFeeReward(cur realm, tokenPath string)
source

CollectProtocolFeeReward claims accumulated protocol-fee rewards for one registered token path. Folding and settlement are bounded per call; any remaining buckets or stake events are collected by a later call.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • tokenPath: registered token path whose accumulated protocol-fee reward is claimed

Halt check: reverts while the Withdraw halt scope is active.

func CollectProtocolFeeRewardFromLaunchPad

crossing Action
1func CollectProtocolFeeRewardFromLaunchPad(cur realm, to address, tokenPath string)
source

CollectProtocolFeeRewardFromLaunchPad claims one token path of accumulated protocol-fee rewards for a registered launchpad project wallet.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • to: registered launchpad project wallet whose protocol-fee reward is claimed
  • tokenPath: registered token path whose accumulated protocol-fee reward is claimed

Halt check: reverts while the Withdraw halt scope is active.

func CollectReward

crossing Action
1func CollectReward(cur realm)
source

CollectReward claims the caller's GNS emission reward and all known protocol-fee token rewards.

The all-token path folds and settles every known token. It is not a single-current-xGNS-balance formula.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.

Halt check: reverts while the Withdraw halt scope is active.

func CollectRewardFromLaunchPad

crossing Action
1func CollectRewardFromLaunchPad(cur realm, to address)
source

CollectRewardFromLaunchPad claims both GNS emission and protocol-fee rewards for a registered launchpad project wallet. Only the launchpad contract may call this entry point.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • to: registered launchpad project wallet that receives both reward streams

Halt check: reverts while the Withdraw halt scope is active.

func CollectUndelegatedGns

crossing Action
1func CollectUndelegatedGns(cur realm) int64
source

CollectUndelegatedGns collects the amount of the undelegated GNS.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.

Returns:

  • amount: GNS amount released to the caller after eligible undelegation withdrawals are collected

Halt check: reverts while the Withdraw halt scope is active.

func Delegate

crossing Action
1func Delegate(cur realm, to address, amount int64, referrer string) int64
source

Delegate delegates GNS to a delegate.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • to: delegatee address that receives voting power
  • amount: positive GNS amount to delegate and convert to xGNS voting power
  • referrer: optional referral identifier to register for reward tracking

Returns:

  • delegatedAmount: The amount of GNS delegated and mirrored as xGNS.

Halt check: reverts while the GovStaker halt scope is active.

func ExistsDelegation

Action
1func ExistsDelegation(delegationID int64) bool
source

ExistsDelegation checks if a delegation exists. Parameters:

  • delegationID: Numeric identifier of the delegation to look up.

Returns:

  • bool: true when a delegation with delegationID exists, false otherwise.

func GetClaimableRewardByAddress

Action
1func GetClaimableRewardByAddress(addr address) (int64, map[string]int64, error)
source

GetClaimableRewardByAddress returns claimable rewards for an address.

Parameters:

  • addr: Address whose emission and protocol-fee rewards are queried.

Returns:

  • int64: emission reward amount available to addr.
  • map[string]int64: protocol-fee reward amounts keyed by token path.
  • error: nil on success; non-nil when reward state cannot be resolved for addr.

func GetClaimableRewardByLaunchpad

Action
1func GetClaimableRewardByLaunchpad(addr address) (int64, map[string]int64, error)
source

GetClaimableRewardByLaunchpad returns claimable launchpad rewards for an address.

Parameters:

  • addr: Address whose launchpad and protocol-fee rewards are queried.

Returns:

  • int64: emission reward amount available to addr.
  • map[string]int64: protocol-fee reward amounts keyed by token path.
  • error: nil on success; non-nil when reward state cannot be resolved for addr.

func GetClaimableRewardByRewardID

Action
1func GetClaimableRewardByRewardID(rewardID string) (int64, map[string]int64, error)
source

GetClaimableRewardByRewardID returns claimable reward details by reward ID.

Parameters:

  • rewardID: Reward-state identifier whose claimable rewards are queried.

Returns:

  • int64: emission reward amount associated with rewardID.
  • map[string]int64: protocol-fee reward amounts keyed by token path.
  • error: nil on success; non-nil when rewardID cannot be resolved.

func GetCollectableWithdrawAmount

Action
1func GetCollectableWithdrawAmount(delegationID int64) int64
source

GetCollectableWithdrawAmount returns the collectable withdraw amount for a specific delegation. Parameters:

  • delegationID: Identifier of the delegation whose collectable amount is queried.

Returns:

  • int64: amount currently available to collect from delegationID.

func GetDelegationWithdrawCount

Action
1func GetDelegationWithdrawCount(delegationID int64) int
source

GetDelegationWithdrawCount returns the total number of delegation withdraws for a specific delegation. Parameters:

  • delegationID: Identifier of the delegation whose withdrawals are counted.

Returns:

  • int: number of withdrawal records associated with delegationID.

func GetDelegations

Action
1func GetDelegations() *rotree.ReadOnlyTree
source

GetDelegations returns a read-only view of every delegation, keyed by the decimal string form of the delegation ID. Callers paginate it themselves through IterateByOffset. Reading an entry yields a clone, so the view cannot mutate realm state. Returns:

  • *rotree.ReadOnlyTree: read-only delegation view keyed by decimal delegation ID; entry reads return clones.

func GetDelegatorDelegations

Action
1func GetDelegatorDelegations(delegator address) *rotree.ReadOnlyTree
source

GetDelegatorDelegations returns a read-only view of a delegator's delegations, keyed by delegatee address with that pair's delegation IDs as the value. Reading an entry yields a copy of the ID slice, so the view cannot mutate realm state. nil is returned when the delegator has no delegations. Parameters:

  • delegator: Address whose delegations should be listed.

Returns:

  • *rotree.ReadOnlyTree: read-only view keyed by delegatee address, or nil when delegator has no delegations.

func GetEmissionAccumulatedTimestamp

Action
1func GetEmissionAccumulatedTimestamp() int64
source

GetEmissionAccumulatedTimestamp returns the accumulated timestamp for emission rewards. Returns:

  • int64: Unix timestamp at which emission accumulation was last updated.

func GetEmissionAccumulatedX128PerStake

Action
1func GetEmissionAccumulatedX128PerStake() *u256.Uint
source

GetEmissionAccumulatedX128PerStake returns the accumulated emission per stake (Q128). Returns:

  • *u256.Uint: accumulated emission reward per unit stake in Q128 fixed-point form.

func GetEmissionDistributedAmount

Action
1func GetEmissionDistributedAmount() int64
source

GetEmissionDistributedAmount returns the total distributed emission amount. Returns:

  • int64: total emission amount distributed to stakers.

func GetImplementationPackagePath

Action
1func GetImplementationPackagePath() string
source

GetImplementationPackagePath returns the package path of the currently active implementation.

Returns:

  • packagePath: package path of the active implementation

func GetLaunchpadProjectDeposit

Action
1func GetLaunchpadProjectDeposit(projectAddr string) (int64, bool)
source

GetLaunchpadProjectDeposit returns the deposit amount for a launchpad project. Parameters:

  • projectAddr: Launchpad project address whose deposited amount is queried.

Returns:

  • int64: recorded launchpad project deposit amount.
  • bool: true when a deposit record exists for projectAddr; false otherwise.

func GetProtocolFeeAccumulatedTimestamp

Action
1func GetProtocolFeeAccumulatedTimestamp() int64
source

GetProtocolFeeAccumulatedTimestamp returns the accumulated timestamp for protocol fee rewards. Returns:

  • int64: Unix timestamp at which protocol-fee accumulation was last updated.

func GetProtocolFeeAccumulatedX128PerStake

Action
1func GetProtocolFeeAccumulatedX128PerStake(tokenPath string) *u256.Uint
source

GetProtocolFeeAccumulatedX128PerStake returns the accumulated protocol fee per stake (Q128) for a token path. Parameters:

  • tokenPath: Registered token path whose protocol-fee accumulator is queried.

Returns:

  • *u256.Uint: accumulated protocol-fee amount per unit stake in Q128 fixed-point form.

func GetProtocolFeeAmount

Action
1func GetProtocolFeeAmount(tokenPath string) int64
source

GetProtocolFeeAmount returns the protocol fee amounts for a token path. Parameters:

  • tokenPath: Registered token path whose protocol fees are queried.

Returns:

  • int64: accumulated protocol-fee amount for tokenPath in token base units.

func GetTotalDelegated

Action
1func GetTotalDelegated() int64
source

GetTotalDelegated returns the total amount of GNS delegated. Returns:

  • int64: total GNS amount delegated across all delegators.

func GetTotalDelegationAmountAtSnapshot

Action
1func GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool)
source

GetTotalDelegationAmountAtSnapshot returns total delegation at a Unix timestamp, using the latest history entry at or before that timestamp. The lookup is timestamp-based rather than a block-height snapshot. Parameters:

  • snapshotTime: Unix timestamp at or before which to select the latest aggregate delegation history entry.

Returns:

  • int64: aggregate delegated amount recorded at or before snapshotTime.
  • bool: true when a qualifying history entry exists; false when no entry is available.

func GetTotalLockedAmount

Action
1func GetTotalLockedAmount() int64
source

GetTotalLockedAmount returns the total amount of GNS locked in undelegation. Returns:

  • int64: total GNS amount currently locked in undelegation withdrawals.

func GetTotalxGnsSupply

Action
1func GetTotalxGnsSupply() int64
source

GetTotalxGnsSupply returns total xGNS supply, including launchpad-held xGNS. Returns:

  • int64: total xGNS supply, including xGNS held by launchpad projects.

func GetUnDelegationLockupPeriod

Action
1func GetUnDelegationLockupPeriod() int64
source

GetUnDelegationLockupPeriod returns the undelegation lockup period in seconds. Returns:

  • int64: configured undelegation lockup duration in seconds.

func GetUserDelegationAmountAtSnapshot

Action
1func GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool)
source

GetUserDelegationAmountAtSnapshot returns one user's delegation at a Unix timestamp, using that user's latest history entry at or before the timestamp. The bool is false when no qualifying history entry exists. Parameters:

  • userAddr: Delegator address whose historical delegation is queried.
  • snapshotTime: Unix timestamp at or before which to select the user's latest history entry.

Returns:

  • int64: user's delegated amount recorded at or before snapshotTime.
  • bool: true when a qualifying user-history entry exists; false otherwise.

func GetUserDelegationIDs

Action
1func GetUserDelegationIDs(delegator address, delegatee address) []int64
source

GetUserDelegationIDs returns a list of delegation IDs for a specific delegator-delegatee pair. Parameters:

  • delegator: Address that supplied the delegation.
  • delegatee: Address receiving that delegation.

Returns:

  • []int64: delegation IDs for the delegator-delegatee pair; the returned slice is independent of realm state.

func HasDelegationSnapshotsKey

Action
1func HasDelegationSnapshotsKey() bool
source

HasDelegationSnapshotsKey returns true if delegation history exists. Returns:

  • bool: true when delegation history has been initialized in storage.

func NewDelegationTree

Action
1func NewDelegationTree() *bptree.BPTree
source

NewDelegationTree creates an empty tree for delegatee-to-delegation-ID mappings.

Returns:

  • *bptree.BPTree: empty tree configured for delegation lookup entries.

func NewUserDelegationTree

Action
1func NewUserDelegationTree() *bptree.BPTree
source

NewUserDelegationTree creates an empty tree for user delegation mappings. Returns:

  • *bptree.BPTree: empty tree configured for user delegation entries.

func Redelegate

crossing Action
1func Redelegate(cur realm, delegatee, newDelegatee address, amount int64) int64
source

Redelegate redelegates xGNS from the existing delegate to another.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • delegatee: current delegatee address whose voting power is reduced
  • newDelegatee: destination address that receives the redelegated voting power
  • amount: positive xGNS amount to move without a user-facing lockup

Returns:

  • redelegatedAmount: The amount moved from the current delegatee to the new delegatee.

Halt check: reverts while the GovStaker halt scope is active.

func RegisterInitializer

crossing Action
1func RegisterInitializer(cur realm, initializer func(_ int, rlm realm, govStakerStore IGovStakerStore) IGovStaker)
source

RegisterInitializer registers an implementation initializer for this realm. Each implementation version calls it during initialization. The callback receives the current realm context and shared gov/staker store so it can construct the versioned implementation.

Parameters:

  • cur: current realm context; callers use cross(cur) when crossing into this realm
  • initializer: callback invoked with discriminator 0, validated propagated realm context, and IGovStakerStore, returning the implementation

func Render

1func Render(path string) string
source

Render delegates web rendering to the active implementation.

func SetAmountByProjectWallet

crossing Action
1func SetAmountByProjectWallet(cur realm, addr address, amount int64, add bool)
source

SetAmountByProjectWallet adjusts launchpad-backed stake and xGNS accounting for a project wallet. Only callable by launchpad contract.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • addr: registered project wallet whose launchpad-backed stake is adjusted
  • amount: stake amount delta passed to the launchpad reward accounting
  • add: true to add stake and mint xGNS; false to remove stake and burn xGNS

Halt check: reverts while the GovStaker halt scope is active when add is true, or while the Withdraw halt scope is active when add is false.

func SetUnDelegationLockupPeriodByAdmin

crossing Action
1func SetUnDelegationLockupPeriodByAdmin(cur realm, period int64)
source

SetUnDelegationLockupPeriodByAdmin sets the undelegation lockup period. Only callable by admin.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • period: non-negative undelegation lockup duration in seconds

Halt check: reverts while the GovStaker halt scope is active.

func Undelegate

crossing Action
1func Undelegate(cur realm, from address, amount int64) int64
source

Undelegate undelegates xGNS from the existing delegate.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • from: delegatee address from which the caller removes delegation
  • amount: positive xGNS amount to move into undelegation lockup

Returns:

  • amount: The amount of GNS moved into undelegation lockup.

Halt check: reverts while the Withdraw halt scope is active.

func UpgradeImpl

crossing Action
1func UpgradeImpl(cur realm, packagePath string)
source

UpgradeImpl upgrades the active implementation to packagePath. Only admin or governance can call this function.

Parameters:

  • cur: current realm context; callers use cross(cur) when crossing into this realm
  • packagePath: package path of the implementation version to activate

func NewCounter

Action
1func NewCounter() *Counter
source

NewCounter creates a counter initialized before the first allocated identifier.

Returns:

  • *Counter: counter whose current identifier is zero.

func NewDelegation

Action
1func NewDelegation(
2	id int64,
3	delegateFrom, delegateTo address,
4	delegateAmount, createdHeight, createdAt int64,
5) *Delegation
source

NewDelegation creates a delegation record with no undelegated or collected amount.

Parameters:

  • id: unique identifier assigned to this delegation record.
  • delegateFrom: address whose tokens are delegated.
  • delegateTo: address receiving the delegated voting power.
  • delegateAmount: initial delegated token amount in the smallest token unit.
  • createdHeight: block height at which the delegation was created.
  • createdAt: Unix timestamp at which the delegation was created.

Returns:

  • *Delegation: initialized delegation with empty withdrawal history.

func NewDelegationManager

Action
1func NewDelegationManager() *DelegationManager
source

NewDelegationManager creates a new instance of DelegationManager. This factory function initializes the BPTree structure for tracking user delegations.

Returns:

  • *DelegationManager: manager ready to track delegator/delegatee ID lists.

func GetDelegationWithdraws

Action
1func GetDelegationWithdraws(delegationID int64, offset, count int) ([]DelegationWithdraw, error)
source

GetDelegationWithdraws returns a paginated list of delegation withdraws for a specific delegation. Parameters:

  • delegationID: Identifier of the delegation whose withdrawals are requested.
  • offset: Number of matching withdrawal records to skip before collecting results.
  • count: Maximum number of withdrawal records to return.

Returns:

  • []DelegationWithdraw: requested page of withdrawal records, copied before returning.
  • error: nil on success; non-nil when the requested delegation or page cannot be read.

func NewDelegationWithdraw

Action
1func NewDelegationWithdraw(
2	delegationID,
3	unDelegateAmount,
4	createdHeight,
5	createdAt,
6	unDelegationLockupPeriod int64,
7) DelegationWithdraw
source

NewDelegationWithdraw creates a new delegation withdrawal with lockup period. The withdrawal becomes collectable after the lockup period expires.

Parameters:

  • delegationID: Unique identifier of the associated delegation.
  • unDelegateAmount: Amount being withdrawn.
  • createdHeight: Block height at which the undelegation was created.
  • createdAt: Unix timestamp at which the withdrawal was created.
  • unDelegationLockupPeriod: Lockup duration in seconds.

Returns:

  • DelegationWithdraw: new withdrawal instance with its collectable time set after the lockup.

func NewDelegationWithdrawWithoutLockup

Action
1func NewDelegationWithdrawWithoutLockup(
2	delegationID,
3	unDelegateAmount,
4	createdHeight,
5	createdAt int64,
6) DelegationWithdraw
source

NewDelegationWithdrawWithoutLockup creates a withdrawal that is immediately collectable. This is used for special cases such as redelegation where no lockup is required.

Parameters:

  • delegationID: Unique identifier of the associated delegation.
  • unDelegateAmount: Amount being withdrawn.
  • createdHeight: Block height at which the undelegation was created.
  • createdAt: Unix timestamp at which the withdrawal was created.

Returns:

  • DelegationWithdraw: new withdrawal instance marked collected with collectable time equal to createdAt.

func NewEmissionRewardManager

Action
1func NewEmissionRewardManager() *EmissionRewardManager
source

NewEmissionRewardManager creates and initializes an EmissionRewardManager with empty reward states and zero accounting totals. Returns:

  • *EmissionRewardManager: initialized manager with empty reward states, zero totals, and a zero Q128 accumulator.

func NewEmissionRewardState

Action
1func NewEmissionRewardState(accumulatedRewardX128PerStake *u256.Uint) *EmissionRewardState
source

NewEmissionRewardState creates a new emission reward state for a staker. This factory function initializes the state with the current system reward debt.

Parameters:

  • accumulatedRewardX128PerStake: current system-wide accumulated reward per stake

Returns:

  • *EmissionRewardState: new emission reward state instance

func NewGovStakerStore

Action
1func NewGovStakerStore(kvStore store.KVStore) IGovStakerStore
source

NewGovStakerStore creates a new governance staker store instance backed by kvStore.

Parameters:

  • kvStore: Key-value store used to persist governance staker state.

Returns:

  • IGovStakerStore: store implementation that reads and writes the supplied KV store.

func NewLaunchpadProjectDeposits

Action
1func NewLaunchpadProjectDeposits() *LaunchpadProjectDeposits
source

NewLaunchpadProjectDeposits creates an empty owner-to-deposit tree.

Returns:

  • *LaunchpadProjectDeposits: deposit manager initialized with an empty tree.

func NewProtocolFeeRewardManager

Action
1func NewProtocolFeeRewardManager() *ProtocolFeeRewardManager
source

NewProtocolFeeRewardManager creates a new instance of ProtocolFeeRewardManager.

Returns:

  • *ProtocolFeeRewardManager: new protocol fee reward manager instance

func NewProtocolFeeRewardState

Action
1func NewProtocolFeeRewardState() *ProtocolFeeRewardState
source

NewProtocolFeeRewardState creates an empty state for a staker with no stake.

Returns:

  • *ProtocolFeeRewardState: initialized reward state with empty event and token trees

func NewProtocolFeeTokenAccumulator

Action
1func NewProtocolFeeTokenAccumulator() *ProtocolFeeTokenAccumulator
source

NewProtocolFeeTokenAccumulator creates an empty accumulator with no folded epochs or protocol fees recorded.

Returns:

  • *ProtocolFeeTokenAccumulator: accumulator initialized with zero values and empty epoch history.

func NewProtocolFeeTokenRewardState

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

NewProtocolFeeTokenRewardState creates the settlement state of a token whose open segment starts at the given cursor, stake and accumulator value.

Parameters:

  • eventCursor: number of stake events already folded into this token state
  • segmentStakedAmount: stake amount in force during the open segment
  • segmentStartX128: accumulated fee-per-stake value at the open segment start, scaled by 2^128

Returns:

  • *ProtocolFeeTokenRewardState: token settlement state with zero closed-segment earnings and claimed reward

func NewUintTree

Action
1func NewUintTree() *UintTree
source

NewUintTree creates a new UintTree instance.

Returns:

  • *UintTree: new tree backed by an empty ordered BPTree

Types 20

type Counter

struct
1type Counter struct {
2	id int64
3}
source

Methods on Counter

func Get

method on Counter
1func (c *Counter) Get() int64
source

Get returns the counter's current identifier without incrementing it.

Returns:

  • int64: most recently allocated identifier, or zero for a new counter.

func Next

method on Counter
1func (c *Counter) Next() int64
source

Next increments the counter and returns the newly allocated identifier.

Returns:

  • int64: next identifier after incrementing the counter by one.

type Delegation

struct
 1type Delegation struct {
 2	id               int64
 3	delegateAmount   int64
 4	unDelegateAmount int64
 5	collectedAmount  int64
 6	delegateFrom     address
 7	delegateTo       address
 8	createdHeight    int64
 9	createdAt        int64
10	withdraws        []DelegationWithdraw
11}
source

Delegation represents a delegation between two addresses

Methods on Delegation

func AddWithdraw

method on Delegation
1func (d *Delegation) AddWithdraw(withdraw DelegationWithdraw)
source

AddWithdraw appends a withdrawal record to the delegation history.

Parameters:

  • withdraw: withdrawal record to append, including its amount and unlock timing.

func Clone

method on Delegation
1func (d *Delegation) Clone() *Delegation
source

Clone returns a deep copy of the delegation and its withdrawal slice.

Returns:

  • *Delegation: copied delegation, or nil when the receiver is nil.

func CollectedAmount

method on Delegation
1func (d *Delegation) CollectedAmount() int64
source

CollectedAmount returns the amount already collected from undelegation.

Returns:

  • int64: token amount released from this delegation.

func CreatedAt

method on Delegation
1func (d *Delegation) CreatedAt() int64
source

CreatedAt returns the Unix timestamp recorded when the delegation was created.

Returns:

  • int64: creation timestamp in Unix seconds.

func DelegateFrom

method on Delegation
1func (d *Delegation) DelegateFrom() address
source

DelegateFrom returns the address that supplied the delegated tokens.

Returns:

  • address: delegator address recorded on the delegation.

func DelegateTo

method on Delegation
1func (d *Delegation) DelegateTo() address
source

DelegateTo returns the address receiving the delegated voting power.

Returns:

  • address: delegatee address recorded on the delegation.

func ID

method on Delegation
1func (d *Delegation) ID() int64
source

Basic getters ID returns the unique identifier of the delegation record.

Returns:

  • int64: delegation identifier assigned at creation.

func SetCollectedAmount

method on Delegation
1func (d *Delegation) SetCollectedAmount(amount int64)
source

SetCollectedAmount replaces the amount already collected from this delegation.

Parameters:

  • amount: released token amount in the smallest token unit.

func SetUnDelegateAmount

method on Delegation
1func (d *Delegation) SetUnDelegateAmount(amount int64)
source

Setters SetUnDelegateAmount replaces the amount currently in undelegation lockup.

Parameters:

  • amount: token amount awaiting collection in the smallest token unit.

func SetWithdraw

method on Delegation
1func (d *Delegation) SetWithdraw(index int, withdraw DelegationWithdraw)
source

SetWithdraw replaces one withdrawal record at the supplied slice index.

Parameters:

  • index: zero-based index of the withdrawal entry to replace.
  • withdraw: replacement withdrawal record.

func SetWithdraws

method on Delegation
1func (d *Delegation) SetWithdraws(withdraws []DelegationWithdraw)
source

SetWithdraws replaces the complete withdrawal history.

Parameters:

  • withdraws: withdrawal records to store for this delegation.

func TotalDelegatedAmount

method on Delegation
1func (d *Delegation) TotalDelegatedAmount() int64
source

Amount getters TotalDelegatedAmount returns the current amount still actively delegated.

Returns:

  • int64: active delegated token amount in the smallest token unit.

func UnDelegatedAmount

method on Delegation
1func (d *Delegation) UnDelegatedAmount() int64
source

UnDelegatedAmount returns the amount moved into undelegation lockup.

Returns:

  • int64: token amount awaiting collection after its lockup period.

func Withdraws

method on Delegation
1func (d *Delegation) Withdraws() []DelegationWithdraw
source

Withdraws getters Withdraws returns the delegation's withdrawal records.

Returns:

  • []DelegationWithdraw: withdrawal entries tracked for this delegation.

type DelegationManager

struct
1type DelegationManager struct {
2	// userDelegations maps delegator address -> *bptree.BPTree (delegatee address -> list of delegation IDs)
3	// Using BPTree instead of map to handle unbounded growth of delegators efficiently
4	userDelegations *bptree.BPTree
5}
source

DelegationManager manages the mapping between users and their delegation IDs. It provides efficient lookup and management of user delegations organized by delegator and delegatee addresses.

Methods on DelegationManager

func AddDelegationID

method on DelegationManager
1func (dm *DelegationManager) AddDelegationID(delegator, delegatee string, delegationID int64)
source

AddDelegationID appends a delegation ID to the delegator-delegatee pair, skipping duplicates. The whole get-modify-set runs inside this domain method so the nested BPTree mutation never escapes the owning realm. Performing the lookup in one realm and the write in another (e.g. re-fetching the inner tree across a realm boundary and mutating it) would hit the cross-realm write guard for the persisted leaf slot.

Parameters:

  • delegator: delegator address string used to select the nested tree.
  • delegatee: delegatee address string used as the nested-tree key.
  • delegationID: delegation ID to append when it is not already present.

func GetDelegationIDs

method on DelegationManager
1func (dm *DelegationManager) GetDelegationIDs(delegator, delegatee string) ([]int64, bool)
source

GetDelegationIDs returns IDs recorded for one delegator/delegatee pair.

Parameters:

  • delegator: delegator address string used to select the nested tree.
  • delegatee: delegatee address string used as the nested-tree key.

Returns:

  • []int64: delegation IDs stored for the pair.
  • bool: true when the pair exists with a valid ID slice.

func GetDelegatorDelegations

method on DelegationManager
1func (dm *DelegationManager) GetDelegatorDelegations(delegator string) (*bptree.BPTree, bool)
source

GetDelegatorDelegations returns the delegatee tree for one delegator.

Parameters:

  • delegator: delegator address string used as the root-tree key.

Returns:

  • *bptree.BPTree: delegatee-to-delegation-ID tree when present and correctly typed.
  • bool: true when the delegator entry exists with the expected tree type.

func GetUserDelegations

method on DelegationManager
1func (dm *DelegationManager) GetUserDelegations() *bptree.BPTree
source

GetUserDelegations returns the entire user delegations tree.

Returns:

  • *bptree.BPTree: tree keyed by delegator address string.

func RemoveDelegationID

method on DelegationManager
1func (dm *DelegationManager) RemoveDelegationID(delegator, delegatee string, delegationID int64)
source

RemoveDelegationID removes a delegation ID from the delegator-delegatee pair. Like AddDelegationID, the read-modify-write is kept inside this domain method. RemoveDelegationID removes one ID from a delegator/delegatee pair. Missing pairs and IDs are left unchanged.

Parameters:

  • delegator: delegator address string used to select the nested tree.
  • delegatee: delegatee address string used as the nested-tree key.
  • delegationID: delegation ID to remove when it is present.

func SetDelegationIDs

method on DelegationManager
1func (dm *DelegationManager) SetDelegationIDs(delegator, delegatee string, ids []int64)
source

SetDelegationIDs stores the complete ID slice for a delegator/delegatee pair. A missing delegator entry is initialized with a new nested tree.

Parameters:

  • delegator: delegator address string used to select or create the nested tree.
  • delegatee: delegatee address string used as the nested-tree key.
  • ids: delegation IDs to store for the pair.

func SetUserDelegations

method on DelegationManager
1func (dm *DelegationManager) SetUserDelegations(userDelegations *bptree.BPTree)
source

SetUserDelegations replaces the root delegator-to-delegations tree.

Parameters:

  • userDelegations: tree keyed by delegator address string and containing delegatee trees.

type DelegationType

ident
1type DelegationType string
source

DelegationType represents the type of delegation operation

Methods on DelegationType

func IsDelegate

method on DelegationType
1func (d DelegationType) IsDelegate() bool
source

IsDelegate reports whether the operation type is DelegateType.

Returns:

  • bool: true only when d represents a delegation operation.

func IsUnDelegate

method on DelegationType
1func (d DelegationType) IsUnDelegate() bool
source

IsUnDelegate reports whether the operation type is UnDelegateType.

Returns:

  • bool: true only when d represents an undelegation operation.

func String

method on DelegationType
1func (d DelegationType) String() string
source

String returns the textual operation name represented by the delegation type.

Returns:

  • string: "DELEGATE", "UNDELEGATE", or the underlying value for another type.

type DelegationWithdraw

struct
 1type DelegationWithdraw struct {
 2	// delegationID is the unique identifier of the associated delegation
 3	delegationID int64
 4	// unDelegateAmount is the total amount that was undelegated
 5	unDelegateAmount int64
 6	// unDelegatedHeight is the height when the undelegation occurred
 7	unDelegatedHeight int64
 8	// unDelegatedAt is the timestamp when the undelegation occurred
 9	unDelegatedAt int64
10	// collectedAmount is the amount that has already been collected
11	collectedAmount int64
12	// collectableTime is the timestamp when collection becomes available
13	collectableTime int64
14	// collectedAt is the timestamp when collection occurred
15	collectedAt int64
16	// collected indicates whether the withdrawal has been fully collected
17	collected bool
18}
source

DelegationWithdraw represents a pending withdrawal from a delegation. This struct tracks undelegated amounts that are subject to lockup periods and manages the collection process once the lockup period expires.

Methods on DelegationWithdraw

func Clone

method on DelegationWithdraw
1func (d *DelegationWithdraw) Clone() DelegationWithdraw
source

Clone creates a deep copy of the delegation withdraw.

Returns:

  • DelegationWithdraw: independent copy of the withdrawal state.

func CollectableTime

method on DelegationWithdraw
1func (d *DelegationWithdraw) CollectableTime() int64
source

CollectableTime returns the timestamp when collection becomes available.

Returns:

  • int64: collectable time

func CollectedAmount

method on DelegationWithdraw
1func (d *DelegationWithdraw) CollectedAmount() int64
source

CollectedAmount returns the amount that has already been collected.

Returns:

  • int64: collected amount

func CollectedAt

method on DelegationWithdraw
1func (d *DelegationWithdraw) CollectedAt() int64
source

CollectedAt returns the timestamp when collection occurred.

Returns:

  • int64: collection timestamp

func DelegationID

method on DelegationWithdraw
1func (d *DelegationWithdraw) DelegationID() int64
source

DelegationID returns the unique identifier of the associated delegation.

Returns:

  • int64: delegation ID

func IsCollected

method on DelegationWithdraw
1func (d *DelegationWithdraw) IsCollected() bool
source

IsCollected returns whether the withdrawal has been fully collected.

Returns:

  • bool: true if fully collected, false otherwise

func SetCollected

method on DelegationWithdraw
1func (d *DelegationWithdraw) SetCollected(collected bool)
source

SetCollected sets the collected status.

Parameters:

  • collected: new collected status

func SetCollectedAmount

method on DelegationWithdraw
1func (d *DelegationWithdraw) SetCollectedAmount(amount int64)
source

SetCollectedAmount sets the collected amount.

Parameters:

  • amount: collected amount

func SetCollectedAt

method on DelegationWithdraw
1func (d *DelegationWithdraw) SetCollectedAt(collectedAt int64)
source

SetCollectedAt sets the collection timestamp.

Parameters:

  • collectedAt: collection timestamp

func UnDelegateAmount

method on DelegationWithdraw
1func (d *DelegationWithdraw) UnDelegateAmount() int64
source

UnDelegateAmount returns the total amount that was undelegated.

Returns:

  • int64: undelegated amount

func UnDelegatedAt

method on DelegationWithdraw
1func (d *DelegationWithdraw) UnDelegatedAt() int64
source

UnDelegatedAt returns the timestamp when the undelegation occurred.

Returns:

  • int64: undelegation timestamp

func UnDelegatedHeight

method on DelegationWithdraw
1func (d *DelegationWithdraw) UnDelegatedHeight() int64
source

UnDelegatedHeight returns the height when the undelegation occurred.

Returns:

  • int64: undelegation height

type EmissionRewardManager

struct
 1type EmissionRewardManager struct {
 2	// rewardStates maps address to EmissionRewardState for tracking individual staker rewards
 3	rewardStates *bptree.BPTree // address -> EmissionRewardState
 4
 5	// accumulatedRewardX128PerStake tracks the cumulative reward per unit of stake with 128-bit precision
 6	accumulatedRewardX128PerStake *u256.Uint
 7	// distributedAmount tracks the total amount of rewards distributed
 8	distributedAmount int64
 9	// accumulatedTimestamp tracks the last timestamp when rewards were accumulated
10	accumulatedTimestamp int64
11	// totalStakedAmount tracks the total amount of tokens staked in the system
12	totalStakedAmount int64
13}
source

EmissionRewardManager manages the distribution of emission rewards to stakers.

Methods on EmissionRewardManager

func GetAccumulatedRewardX128PerStake

method on EmissionRewardManager
1func (e *EmissionRewardManager) GetAccumulatedRewardX128PerStake() *u256.Uint
source

GetAccumulatedRewardX128PerStake returns the accumulated reward per stake with 128-bit precision. Returns:

  • *u256.Uint: accumulated emission reward per unit of stake in Q128 fixed-point form.

func GetAccumulatedTimestamp

method on EmissionRewardManager
1func (e *EmissionRewardManager) GetAccumulatedTimestamp() int64
source

GetAccumulatedTimestamp returns the last timestamp when rewards were accumulated. Returns:

  • int64: Unix timestamp of the latest emission-reward accumulation.

func GetDistributedAmount

method on EmissionRewardManager
1func (e *EmissionRewardManager) GetDistributedAmount() int64
source

GetDistributedAmount returns the total amount of rewards distributed. Returns:

  • int64: total emission reward amount marked as distributed.

func GetRewardState

method on EmissionRewardManager
1func (e *EmissionRewardManager) GetRewardState(addr string) (*EmissionRewardState, bool, error)
source

GetRewardState retrieves the reward state for addr.

Parameters:

  • addr: Address key identifying the staker's emission reward state.

Returns:

  • *EmissionRewardState: stored state, or nil when addr has no state.
  • bool: true when a reward state exists for addr; false when absent.
  • error: nil on success or absence; non-nil when the stored value has the wrong type.

func GetTotalStakedAmount

method on EmissionRewardManager
1func (e *EmissionRewardManager) GetTotalStakedAmount() int64
source

GetTotalStakedAmount returns the total amount of tokens staked in the system. Returns:

  • int64: total staked token amount tracked by the manager.

func SetAccumulatedRewardX128PerStake

method on EmissionRewardManager
1func (e *EmissionRewardManager) SetAccumulatedRewardX128PerStake(accumulatedRewardX128PerStake *u256.Uint)
source

SetAccumulatedRewardX128PerStake stores the accumulated emission reward per stake.

Parameters:

  • accumulatedRewardX128PerStake: Q128 fixed-point reward-per-stake accumulator to copy into the manager.

func SetAccumulatedTimestamp

method on EmissionRewardManager
1func (e *EmissionRewardManager) SetAccumulatedTimestamp(accumulatedTimestamp int64)
source

SetAccumulatedTimestamp stores the latest emission-reward accumulation timestamp.

Parameters:

  • accumulatedTimestamp: Unix timestamp associated with the current accumulator.

func SetDistributedAmount

method on EmissionRewardManager
1func (e *EmissionRewardManager) SetDistributedAmount(distributedAmount int64)
source

SetDistributedAmount stores the total emission amount marked as distributed.

Parameters:

  • distributedAmount: Total emission reward amount distributed so far.

func SetRewardState

method on EmissionRewardManager
1func (e *EmissionRewardManager) SetRewardState(address string, rewardState *EmissionRewardState)
source

SetRewardState sets the reward state for a specific address SetRewardState stores one staker's emission reward state under address.

Parameters:

  • address: Address key for the staker's reward state.
  • rewardState: Emission reward state to store for address.

func SetRewardStates

method on EmissionRewardManager
1func (e *EmissionRewardManager) SetRewardStates(rewardStates *bptree.BPTree)
source

SetRewardStates replaces the tree containing per-address emission reward states.

Parameters:

  • rewardStates: BPTree mapping staker addresses to emission reward states.

func SetTotalStakedAmount

method on EmissionRewardManager
1func (e *EmissionRewardManager) SetTotalStakedAmount(totalStakedAmount int64)
source

SetTotalStakedAmount stores the total amount currently staked.

Parameters:

  • totalStakedAmount: Aggregate token amount participating in emission rewards.

type EmissionRewardState

struct
 1type EmissionRewardState struct {
 2	// rewardDebtX128 represents the reward debt with 128-bit precision scaling
 3	// Used to calculate rewards earned since the last update
 4	rewardDebtX128 *u256.Uint
 5	// accumulatedRewardAmount is the total rewards accumulated but not yet claimed
 6	accumulatedRewardAmount int64
 7	// accumulatedTimestamp is the last timestamp when rewards were accumulated
 8	accumulatedTimestamp int64
 9	// claimedRewardAmount is the total amount of rewards that have been claimed
10	claimedRewardAmount int64
11	// claimedTimestamp is the last timestamp when rewards were claimed
12	claimedTimestamp int64
13	// stakedAmount is the current amount of tokens staked by this address
14	stakedAmount int64
15}
source

EmissionRewardState tracks emission reward information for an individual staker. This struct maintains reward debt, accumulated rewards, and claiming history to ensure accurate reward calculations and prevent double-claiming.

Methods on EmissionRewardState

func GetAccumulatedRewardAmount

method on EmissionRewardState
1func (e *EmissionRewardState) GetAccumulatedRewardAmount() int64
source

GetAccumulatedRewardAmount returns rewards accrued but not yet claimed.

Returns:

  • int64: accumulated reward amount in the smallest token unit.

func GetAccumulatedTimestamp

method on EmissionRewardState
1func (e *EmissionRewardState) GetAccumulatedTimestamp() int64
source

GetAccumulatedTimestamp returns when accumulated rewards were last updated.

Returns:

  • int64: Unix timestamp in seconds of the last accumulation update.

func GetClaimedRewardAmount

method on EmissionRewardState
1func (e *EmissionRewardState) GetClaimedRewardAmount() int64
source

GetClaimedRewardAmount returns the total rewards already claimed.

Returns:

  • int64: claimed reward amount in the smallest token unit.

func GetClaimedTimestamp

method on EmissionRewardState
1func (e *EmissionRewardState) GetClaimedTimestamp() int64
source

GetClaimedTimestamp returns when rewards were last claimed.

Returns:

  • int64: Unix timestamp in seconds of the last claim.

func GetRewardDebtX128

method on EmissionRewardState
1func (e *EmissionRewardState) GetRewardDebtX128() *u256.Uint
source

GetRewardDebtX128 returns the scaled reward debt used for accrual calculations.

Returns:

  • *u256.Uint: current reward debt in the protocol's 128-bit fixed-point scale.

func GetStakedAmount

method on EmissionRewardState
1func (e *EmissionRewardState) GetStakedAmount() int64
source

GetStakedAmount returns the amount currently staked for this state.

Returns:

  • int64: staked token amount in the smallest token unit.

func SetAccumulatedRewardAmount

method on EmissionRewardState
1func (e *EmissionRewardState) SetAccumulatedRewardAmount(accumulatedRewardAmount int64)
source

SetAccumulatedRewardAmount replaces the unclaimed accumulated reward amount.

Parameters:

  • accumulatedRewardAmount: accumulated reward in the smallest token unit.

func SetAccumulatedTimestamp

method on EmissionRewardState
1func (e *EmissionRewardState) SetAccumulatedTimestamp(accumulatedTimestamp int64)
source

SetAccumulatedTimestamp records the latest reward accumulation timestamp.

Parameters:

  • accumulatedTimestamp: Unix timestamp in seconds for the accumulation update.

func SetClaimedRewardAmount

method on EmissionRewardState
1func (e *EmissionRewardState) SetClaimedRewardAmount(claimedRewardAmount int64)
source

SetClaimedRewardAmount replaces the total claimed reward amount.

Parameters:

  • claimedRewardAmount: claimed reward in the smallest token unit.

func SetClaimedTimestamp

method on EmissionRewardState
1func (e *EmissionRewardState) SetClaimedTimestamp(claimedTimestamp int64)
source

SetClaimedTimestamp records the latest reward claim timestamp.

Parameters:

  • claimedTimestamp: Unix timestamp in seconds for the claim.

func SetRewardDebtX128

method on EmissionRewardState
1func (e *EmissionRewardState) SetRewardDebtX128(rewardDebtX128 *u256.Uint)
source
Example
1Setters

SetRewardDebtX128 replaces the reward debt with a copied fixed-point value.

Parameters:

  • rewardDebtX128: reward debt in the protocol's 128-bit fixed-point scale.

func SetStakedAmount

method on EmissionRewardState
1func (e *EmissionRewardState) SetStakedAmount(stakedAmount int64)
source

SetStakedAmount replaces the current staked amount. Parameters:

  • stakedAmount: staked token amount in the smallest token unit.

type IGovStaker

interface
1type IGovStaker interface {
2	IGovStakerDelegation
3	IGovStakerReward
4	IGovStakerGetter
5	IGovStakerAdmin
6	Render(path string) string
7}
source

Main interface that combines all sub-interfaces

type IGovStakerAdmin

interface
 1type IGovStakerAdmin interface {
 2	// CleanStakerDelegationSnapshotByAdmin removes delegation-history entries
 3	// older than a validated timestamp cutoff.
 4	//
 5	// Parameters:
 6	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
 7	//   - rlm: propagated current realm context validated before administrative state updates
 8	//   - snapshotTime: Unix timestamp cutoff before which eligible history entries are removed
 9	//   - target: address whose user delegation history is cleaned
10	CleanStakerDelegationSnapshotByAdmin(_ int, rlm realm, snapshotTime int64, target address)
11	// SetUnDelegationLockupPeriodByAdmin updates the duration used by future
12	// undelegation withdrawals.
13	//
14	// Parameters:
15	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
16	//   - rlm: propagated current realm context validated before the administrative store write
17	//   - period: non-negative undelegation lockup duration in seconds
18	SetUnDelegationLockupPeriodByAdmin(_ int, rlm realm, period int64)
19}
source

Admin interface for administrative functions

type IGovStakerDelegation

interface
 1type IGovStakerDelegation interface {
 2	// Main delegation operations
 3	// Delegate moves GNS into delegation and assigns the corresponding xGNS voting power.
 4	//
 5	// Parameters:
 6	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
 7	//   - rlm: propagated current realm context validated before token transfers and state updates
 8	//   - to: address that receives the delegated voting power
 9	//   - amount: positive GNS amount to delegate
10	//   - referrer: optional referral identifier associated with the delegation
11	//
12	// Returns:
13	//   - int64: amount delegated and represented as xGNS
14	Delegate(_ int, rlm realm, to address, amount int64, referrer string) int64
15	// Undelegate removes voting power from an existing delegatee and starts the
16	// undelegation lockup for the returned GNS.
17	//
18	// Parameters:
19	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
20	//   - rlm: propagated current realm context validated before token and state updates
21	//   - from: delegatee address from which the caller removes delegation
22	//   - amount: positive xGNS amount to undelegate
23	//
24	// Returns:
25	//   - int64: amount moved from active delegation into undelegation lockup
26	Undelegate(_ int, rlm realm, from address, amount int64) int64
27	// Redelegate moves voting power from one delegatee to another without a
28	// user-facing undelegation lockup.
29	//
30	// Parameters:
31	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
32	//   - rlm: propagated current realm context validated before token and state updates
33	//   - delegatee: current delegatee address whose delegation is reduced
34	//   - newDelegatee: destination address that receives the redelegated amount
35	//   - amount: positive xGNS amount to move between delegatees
36	//
37	// Returns:
38	//   - int64: amount moved from the current delegatee to the new delegatee
39	Redelegate(_ int, rlm realm, delegatee, newDelegatee address, amount int64) int64
40	// CollectUndelegatedGns releases GNS whose undelegation lockup has expired.
41	//
42	// Parameters:
43	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
44	//   - rlm: propagated current realm context validated before token and state updates
45	//
46	// Returns:
47	//   - int64: amount of unlocked GNS collected by the caller
48	CollectUndelegatedGns(_ int, rlm realm) int64
49}
source

Delegation operations interface

Mutating methods take `_ int, rlm realm` so the realm token is threaded from the proxy entry points down to the cross-realm token transfers and store writes performed inside each implementation. The `_ int` sentinel surfaces at every call site as a literal `0`, making the realm threading visible to readers.

type IGovStakerGetter

interface
  1type IGovStakerGetter interface {
  2	// Store data getters
  3	// GetUnDelegationLockupPeriod returns the configured undelegation cooldown.
  4	//
  5	// Returns:
  6	//   - int64: undelegation lockup duration in seconds
  7	GetUnDelegationLockupPeriod() int64
  8
  9	// Delegation getters
 10	// GetTotalxGnsSupply returns total xGNS supply, including xGNS held by the
 11	// launchpad.
 12	//
 13	// Returns:
 14	//   - int64: total xGNS supply used as the governance quorum base
 15	GetTotalxGnsSupply() int64
 16	// GetTotalDelegated returns the amount currently delegated for governance
 17	// voting power.
 18	//
 19	// Returns:
 20	//   - int64: total active delegated xGNS amount
 21	GetTotalDelegated() int64
 22	// GetTotalLockedAmount returns GNS held by the staker contract for active
 23	// delegations and not-yet-collected undelegations.
 24	//
 25	// Returns:
 26	//   - int64: total locked GNS amount
 27	GetTotalLockedAmount() int64
 28	// GetDelegations returns a read-only tree of all delegations keyed by their
 29	// decimal-string IDs.
 30	//
 31	// Returns:
 32	//   - *rotree.ReadOnlyTree: read-only delegation index whose entries are cloned for callers
 33	GetDelegations() *rotree.ReadOnlyTree
 34	// ExistsDelegation checks whether a delegation record exists.
 35	//
 36	// Parameters:
 37	//   - delegationID: unique delegation identifier to look up
 38	//
 39	// Returns:
 40	//   - bool: true when delegationID has a stored record; false otherwise
 41	ExistsDelegation(delegationID int64) bool
 42	// GetDelegatorDelegations returns a read-only tree for one delegator, keyed
 43	// by delegatee address.
 44	//
 45	// Parameters:
 46	//   - delegator: address whose delegatee mappings are requested
 47	//
 48	// Returns:
 49	//   - *rotree.ReadOnlyTree: delegatee-to-delegation-ID tree, or nil when the delegator has no delegations
 50	GetDelegatorDelegations(delegator address) *rotree.ReadOnlyTree
 51	// GetUserDelegationIDs returns delegation IDs for one delegator-delegatee
 52	// pair.
 53	//
 54	// Parameters:
 55	//   - delegator: address that owns the delegation
 56	//   - delegatee: address receiving the delegation
 57	//
 58	// Returns:
 59	//   - []int64: stored delegation IDs for the pair, or an empty list when none exist
 60	GetUserDelegationIDs(delegator address, delegatee address) []int64
 61	// HasDelegationSnapshotsKey reports whether total delegation history has
 62	// been initialized in storage.
 63	//
 64	// Returns:
 65	//   - bool: true when the total delegation history store key exists; false otherwise
 66	HasDelegationSnapshotsKey() bool
 67	// GetTotalDelegationAmountAtSnapshot finds the latest total delegation
 68	// history value at or before a Unix timestamp.
 69	//
 70	// Parameters:
 71	//   - snapshotTime: Unix timestamp at which to resolve historical total delegation
 72	//
 73	// Returns:
 74	//   - int64: total delegated amount from the latest qualifying history entry
 75	//   - bool: true when a qualifying history entry exists; false when history has no such entry
 76	GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool)
 77	// GetUserDelegationAmountAtSnapshot finds one user's latest delegation
 78	// history value at or before a Unix timestamp.
 79	//
 80	// Parameters:
 81	//   - userAddr: user's address whose delegation history is searched
 82	//   - snapshotTime: Unix timestamp at which to resolve the user's historical delegation
 83	//
 84	// Returns:
 85	//   - int64: user's delegated amount from the latest qualifying history entry
 86	//   - bool: true when a qualifying history entry exists; false otherwise
 87	GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool)
 88
 89	// Reward getters
 90	// GetClaimableRewardByAddress computes current claimable emission and
 91	// protocol-fee rewards for an address reward ID.
 92	//
 93	// Parameters:
 94	//   - addr: staker address whose reward ID is queried
 95	//
 96	// Returns:
 97	//   - int64: claimable GNS emission reward amount
 98	//   - map[string]int64: claimable protocol-fee amounts keyed by token path
 99	//   - error: nil when both reward streams are computed; otherwise the reward-accounting error
100	GetClaimableRewardByAddress(addr address) (int64, map[string]int64, error)
101	// GetClaimableRewardByLaunchpad computes rewards for a launchpad project
102	// wallet's launchpad-specific reward ID.
103	//
104	// Parameters:
105	//   - addr: registered launchpad project wallet address
106	//
107	// Returns:
108	//   - int64: claimable GNS emission reward amount
109	//   - map[string]int64: claimable protocol-fee amounts keyed by token path
110	//   - error: nil when both reward streams are computed; otherwise the reward-accounting error
111	GetClaimableRewardByLaunchpad(addr address) (int64, map[string]int64, error)
112	// GetClaimableRewardByRewardID computes current rewards for an explicit
113	// reward identifier.
114	//
115	// Parameters:
116	//   - rewardID: staker or launchpad reward-state identifier
117	//
118	// Returns:
119	//   - int64: claimable GNS emission reward amount
120	//   - map[string]int64: claimable protocol-fee amounts keyed by token path
121	//   - error: nil when both reward streams are computed; otherwise the reward-accounting error
122	GetClaimableRewardByRewardID(rewardID string) (int64, map[string]int64, error)
123
124	// Launchpad getters
125	// GetLaunchpadProjectDeposit returns a project's recorded launchpad deposit.
126	//
127	// Parameters:
128	//   - projectAddr: project address identifier used to derive the launchpad reward key
129	//
130	// Returns:
131	//   - int64: stored project deposit amount
132	//   - bool: true when a deposit record exists for projectAddr; false otherwise
133	GetLaunchpadProjectDeposit(projectAddr string) (int64, bool)
134
135	// Withdraw getters
136	// GetDelegationWithdrawCount returns the number of pending withdrawal
137	// records attached to a delegation.
138	//
139	// Parameters:
140	//   - delegationID: delegation whose withdrawal list is counted
141	//
142	// Returns:
143	//   - int: number of withdrawal records, or 0 when the delegation is absent
144	GetDelegationWithdrawCount(delegationID int64) int
145	// GetDelegationWithdraws returns a slice of a delegation's withdrawal list.
146	//
147	// Parameters:
148	//   - delegationID: delegation whose withdrawals are requested
149	//   - offset: non-negative zero-based starting index in the withdrawal list
150	//   - count: non-negative maximum number of withdrawals to include
151	//
152	// Returns:
153	//   - []DelegationWithdraw: withdrawals in the requested range, or an empty slice when the delegation or range is absent
154	//   - error: nil when the lookup completes; an unknown delegation yields an empty slice
155	GetDelegationWithdraws(delegationID int64, offset, count int) ([]DelegationWithdraw, error)
156	// GetCollectableWithdrawAmount sums all withdrawal amounts currently
157	// collectable for a delegation.
158	//
159	// Parameters:
160	//   - delegationID: delegation whose expired withdrawals are summed
161	//
162	// Returns:
163	//   - int64: total GNS amount collectable now, or 0 when none is collectable
164	GetCollectableWithdrawAmount(delegationID int64) int64
165
166	// Protocol fee reward getters
167	// GetProtocolFeeAccumulatedX128PerStake returns the per-stake protocol-fee
168	// accumulator for a token path, scaled by 2^128.
169	//
170	// Parameters:
171	//   - tokenPath: registered token path whose accumulator is queried
172	//
173	// Returns:
174	//   - *uint256.Uint: Q128-scaled accumulated fee per stake, zero when the token has no folded fee
175	GetProtocolFeeAccumulatedX128PerStake(tokenPath string) *uint256.Uint
176	// GetProtocolFeeAmount returns the total protocol fee folded for a token
177	// path.
178	//
179	// Parameters:
180	//   - tokenPath: registered token path whose folded fee amount is queried
181	//
182	// Returns:
183	//   - int64: total folded protocol-fee amount, or 0 when the token has no accumulator
184	GetProtocolFeeAmount(tokenPath string) int64
185	// GetProtocolFeeAccumulatedTimestamp returns the last timestamp at which
186	// protocol-fee accrual state advanced.
187	//
188	// Returns:
189	//   - int64: Unix timestamp of the latest protocol-fee accumulation update
190	GetProtocolFeeAccumulatedTimestamp() int64
191
192	// Emission reward getters
193	// GetEmissionAccumulatedX128PerStake returns the accumulated GNS emission
194	// reward per stake, scaled by 2^128.
195	//
196	// Returns:
197	//   - *uint256.Uint: Q128-scaled accumulated emission per stake
198	GetEmissionAccumulatedX128PerStake() *uint256.Uint
199	// GetEmissionDistributedAmount returns the total GNS emission distributed
200	// through the staker reward manager.
201	//
202	// Returns:
203	//   - int64: cumulative distributed GNS emission amount
204	GetEmissionDistributedAmount() int64
205	// GetEmissionAccumulatedTimestamp returns the last timestamp at which
206	// emission reward accrual state advanced.
207	//
208	// Returns:
209	//   - int64: Unix timestamp of the latest emission accumulation update
210	GetEmissionAccumulatedTimestamp() int64
211}
source

Getter interface for read operations

type IGovStakerReward

interface
 1type IGovStakerReward interface {
 2	// Reward collection
 3	// CollectReward settles the caller's GNS emission and all known protocol-fee
 4	// token rewards.
 5	//
 6	// Parameters:
 7	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
 8	//   - rlm: propagated current realm context validated before reward transfers and state updates
 9	CollectReward(_ int, rlm realm)
10	// CollectEmissionReward settles only the caller's accumulated GNS emission reward.
11	//
12	// Parameters:
13	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
14	//   - rlm: propagated current realm context validated before reward transfer and state updates
15	CollectEmissionReward(_ int, rlm realm)
16	// CollectProtocolFeeReward settles one registered protocol-fee token reward
17	// for the caller.
18	//
19	// Parameters:
20	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
21	//   - rlm: propagated current realm context validated before reward transfer and state updates
22	//   - tokenPath: registered token path whose accumulated reward is settled
23	CollectProtocolFeeReward(_ int, rlm realm, tokenPath string)
24	// CollectRewardFromLaunchPad settles both reward streams for a registered
25	// launchpad project wallet.
26	//
27	// Parameters:
28	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
29	//   - rlm: propagated current realm context validated before launchpad authorization and reward transfers
30	//   - to: registered launchpad project wallet that receives the rewards
31	CollectRewardFromLaunchPad(_ int, rlm realm, to address)
32	// CollectEmissionRewardFromLaunchPad settles only the emission reward for a
33	// registered launchpad project wallet.
34	//
35	// Parameters:
36	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
37	//   - rlm: propagated current realm context validated before launchpad authorization and reward transfer
38	//   - to: registered launchpad project wallet that receives the emission reward
39	CollectEmissionRewardFromLaunchPad(_ int, rlm realm, to address)
40	// CollectProtocolFeeRewardFromLaunchPad settles one protocol-fee token reward
41	// for a registered launchpad project wallet.
42	//
43	// Parameters:
44	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
45	//   - rlm: propagated current realm context validated before launchpad authorization and reward transfer
46	//   - to: registered launchpad project wallet that receives the token reward
47	//   - tokenPath: registered token path whose accumulated reward is settled
48	CollectProtocolFeeRewardFromLaunchPad(_ int, rlm realm, to address, tokenPath string)
49	// SetAmountByProjectWallet adjusts the launchpad-backed stake amount and
50	// corresponding xGNS balance for a project wallet.
51	//
52	// Parameters:
53	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded implementation call
54	//   - rlm: propagated current realm context validated before launchpad authorization and state updates
55	//   - addr: project wallet address whose launchpad-backed stake is adjusted
56	//   - amount: stake amount delta passed to the launchpad reward accounting
57	//   - add: true to add stake and mint xGNS; false to remove stake and burn xGNS
58	SetAmountByProjectWallet(_ int, rlm realm, addr address, amount int64, add bool)
59}
source

Reward management interface

type IGovStakerStore

interface
  1type IGovStakerStore interface {
  2	// Basic configuration
  3	// HasUnDelegationLockupPeriodStoreKey reports whether the lockup duration is initialized.
  4	//
  5	// Returns:
  6	//   - bool: true when the undelegation lockup period store key exists
  7	HasUnDelegationLockupPeriodStoreKey() bool
  8	// GetUnDelegationLockupPeriod returns the persisted undelegation lockup duration.
  9	//
 10	// Returns:
 11	//   - int64: configured lockup duration in seconds
 12	GetUnDelegationLockupPeriod() int64
 13	// SetUnDelegationLockupPeriod persists the undelegation lockup duration.
 14	//
 15	// Parameters:
 16	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
 17	//   - rlm: propagated current realm context required by the KV store
 18	//   - period: lockup duration in seconds
 19	//
 20	// Returns:
 21	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
 22	SetUnDelegationLockupPeriod(_ int, rlm realm, period int64) error
 23
 24	// HasTotalDelegatedAmountStoreKey reports whether total active delegation is initialized.
 25	//
 26	// Returns:
 27	//   - bool: true when the total delegated amount store key exists
 28	HasTotalDelegatedAmountStoreKey() bool
 29	// GetTotalDelegatedAmount returns the persisted total active delegation amount.
 30	//
 31	// Returns:
 32	//   - int64: total delegated xGNS amount
 33	GetTotalDelegatedAmount() int64
 34	// SetTotalDelegatedAmount persists the total active delegation amount.
 35	//
 36	// Parameters:
 37	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
 38	//   - rlm: propagated current realm context required by the KV store
 39	//   - amount: total active delegated xGNS amount to store
 40	//
 41	// Returns:
 42	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
 43	SetTotalDelegatedAmount(_ int, rlm realm, amount int64) error
 44
 45	// HasTotalLockedAmountStoreKey reports whether total locked GNS is initialized.
 46	//
 47	// Returns:
 48	//   - bool: true when the total locked amount store key exists
 49	HasTotalLockedAmountStoreKey() bool
 50	// GetTotalLockedAmount returns the persisted total GNS held by the staker.
 51	//
 52	// Returns:
 53	//   - int64: total locked GNS amount
 54	GetTotalLockedAmount() int64
 55	// SetTotalLockedAmount persists the total locked GNS amount.
 56	//
 57	// Parameters:
 58	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
 59	//   - rlm: propagated current realm context required by the KV store
 60	//   - amount: total locked GNS amount to store
 61	//
 62	// Returns:
 63	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
 64	SetTotalLockedAmount(_ int, rlm realm, amount int64) error
 65
 66	// Delegation management
 67	// HasDelegation reports whether a delegation record exists for an ID.
 68	//
 69	// Parameters:
 70	//   - id: delegation identifier to look up
 71	//
 72	// Returns:
 73	//   - bool: true when a delegation is stored under id; false otherwise
 74	HasDelegation(id int64) bool
 75	// GetDelegation retrieves one delegation record.
 76	//
 77	// Parameters:
 78	//   - id: delegation identifier to look up
 79	//
 80	// Returns:
 81	//   - *Delegation: stored delegation pointer, or nil when id is absent
 82	//   - bool: true when a delegation record exists and has the expected type; false otherwise
 83	GetDelegation(id int64) (*Delegation, bool)
 84	// SetDelegation stores a delegation under its identifier.
 85	//
 86	// Parameters:
 87	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
 88	//   - rlm: propagated current realm context required by the KV store
 89	//   - id: delegation identifier used as the storage key
 90	//   - delegation: delegation record to store
 91	//
 92	// Returns:
 93	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
 94	SetDelegation(_ int, rlm realm, id int64, delegation *Delegation) error
 95	// RemoveDelegation deletes a delegation record and its storage entry.
 96	//
 97	// Parameters:
 98	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
 99	//   - rlm: propagated current realm context required by the KV store
100	//   - id: delegation identifier to remove
101	//
102	// Returns:
103	//   - error: nil when the store write succeeds; otherwise the KV-store error, including a spoofed realm context
104	RemoveDelegation(_ int, rlm realm, id int64) error
105
106	// HasDelegationsStoreKey reports whether the all-delegations tree is initialized.
107	//
108	// Returns:
109	//   - bool: true when the delegations store key exists
110	HasDelegationsStoreKey() bool
111	// SetDelegations replaces the persisted all-delegations tree.
112	//
113	// Parameters:
114	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
115	//   - rlm: propagated current realm context required by the KV store
116	//   - delegations: BPTree containing delegation records keyed by delegation ID
117	//
118	// Returns:
119	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
120	SetDelegations(_ int, rlm realm, delegations *bptree.BPTree) error
121	// GetAllDelegations returns the persisted tree containing every delegation.
122	//
123	// Returns:
124	//   - *bptree.BPTree: all-delegations tree keyed by decimal-string delegation ID
125	GetAllDelegations() *bptree.BPTree
126
127	// HasDelegationCounterStoreKey reports whether the next-delegation-ID counter is initialized.
128	//
129	// Returns:
130	//   - bool: true when the delegation counter store key exists
131	HasDelegationCounterStoreKey() bool
132	// GetDelegationCounter returns the persisted counter used to allocate delegation IDs.
133	//
134	// Returns:
135	//   - *Counter: mutable delegation-ID counter
136	GetDelegationCounter() *Counter
137	// SetDelegationCounter persists the delegation-ID counter.
138	//
139	// Parameters:
140	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
141	//   - rlm: propagated current realm context required by the KV store
142	//   - counter: delegation-ID counter to store
143	//
144	// Returns:
145	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
146	SetDelegationCounter(_ int, rlm realm, counter *Counter) error
147
148	// Total delegation history (timestamp -> int64)
149	// HasTotalDelegationHistoryStoreKey reports whether cumulative total delegation history is initialized.
150	//
151	// Returns:
152	//   - bool: true when the total-delegation-history store key exists
153	HasTotalDelegationHistoryStoreKey() bool
154	// GetTotalDelegationHistory returns timestamp-keyed cumulative total delegation history.
155	//
156	// Returns:
157	//   - *UintTree: total delegation history tree mapping Unix timestamps to int64 amounts
158	GetTotalDelegationHistory() *UintTree
159	// SetTotalDelegationHistory persists timestamp-keyed cumulative total delegation history.
160	//
161	// Parameters:
162	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
163	//   - rlm: propagated current realm context required by the KV store
164	//   - history: timestamp-to-total-delegation tree to store
165	//
166	// Returns:
167	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
168	SetTotalDelegationHistory(_ int, rlm realm, history *UintTree) error
169
170	// User delegation history (address -> *UintTree[timestamp -> int64])
171	// HasUserDelegationHistoryStoreKey reports whether per-user delegation history is initialized.
172	//
173	// Returns:
174	//   - bool: true when the user-delegation-history store key exists
175	HasUserDelegationHistoryStoreKey() bool
176	// GetUserDelegationHistory returns the composite-keyed per-user delegation history tree.
177	//
178	// Returns:
179	//   - *bptree.BPTree: history tree keyed by address and timestamp
180	GetUserDelegationHistory() *bptree.BPTree
181	// SetUserDelegationHistory persists the composite-keyed per-user delegation history tree.
182	//
183	// Parameters:
184	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
185	//   - rlm: propagated current realm context required by the KV store
186	//   - history: address-and-timestamp delegation history tree to store
187	//
188	// Returns:
189	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
190	SetUserDelegationHistory(_ int, rlm realm, history *bptree.BPTree) error
191
192	// Manager states
193	// HasEmissionRewardManagerStoreKey reports whether the emission reward manager is initialized.
194	//
195	// Returns:
196	//   - bool: true when the emission reward manager store key exists
197	HasEmissionRewardManagerStoreKey() bool
198	// GetEmissionRewardManager returns the persisted emission reward manager.
199	//
200	// Returns:
201	//   - *EmissionRewardManager: emission reward accounting manager
202	GetEmissionRewardManager() *EmissionRewardManager
203	// SetEmissionRewardManager persists the emission reward manager.
204	//
205	// Parameters:
206	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
207	//   - rlm: propagated current realm context required by the KV store
208	//   - manager: emission reward manager state to store
209	//
210	// Returns:
211	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
212	SetEmissionRewardManager(_ int, rlm realm, manager *EmissionRewardManager) error
213
214	// HasProtocolFeeRewardManagerStoreKey reports whether protocol-fee reward state is initialized.
215	//
216	// Returns:
217	//   - bool: true when the protocol-fee reward manager store key exists
218	HasProtocolFeeRewardManagerStoreKey() bool
219	// GetProtocolFeeRewardManager returns the persisted protocol-fee reward manager.
220	//
221	// Returns:
222	//   - *ProtocolFeeRewardManager: protocol-fee reward accounting manager
223	GetProtocolFeeRewardManager() *ProtocolFeeRewardManager
224	// SetProtocolFeeRewardManager persists the protocol-fee reward manager.
225	//
226	// Parameters:
227	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
228	//   - rlm: propagated current realm context required by the KV store
229	//   - manager: protocol-fee reward manager state to store
230	//
231	// Returns:
232	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
233	SetProtocolFeeRewardManager(_ int, rlm realm, manager *ProtocolFeeRewardManager) error
234
235	// HasDelegationManagerStoreKey reports whether delegation-manager state is initialized.
236	//
237	// Returns:
238	//   - bool: true when the delegation manager store key exists
239	HasDelegationManagerStoreKey() bool
240	// GetDelegationManager returns the persisted delegation manager.
241	//
242	// Returns:
243	//   - *DelegationManager: delegation-to-address index manager
244	GetDelegationManager() *DelegationManager
245	// SetDelegationManager persists the delegation manager.
246	//
247	// Parameters:
248	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
249	//   - rlm: propagated current realm context required by the KV store
250	//   - manager: delegation manager state to store
251	//
252	// Returns:
253	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
254	SetDelegationManager(_ int, rlm realm, manager *DelegationManager) error
255
256	// HasLaunchpadProjectDepositsStoreKey reports whether launchpad project deposits are initialized.
257	//
258	// Returns:
259	//   - bool: true when the launchpad-project-deposits store key exists
260	HasLaunchpadProjectDepositsStoreKey() bool
261	// GetLaunchpadProjectDeposits returns the persisted launchpad project deposit state.
262	//
263	// Returns:
264	//   - *LaunchpadProjectDeposits: project-address-to-deposit state
265	GetLaunchpadProjectDeposits() *LaunchpadProjectDeposits
266	// SetLaunchpadProjectDeposits persists launchpad project deposit state.
267	//
268	// Parameters:
269	//   - _: leading realm-call discriminator; callers pass 0 for the forwarded store write
270	//   - rlm: propagated current realm context required by the KV store
271	//   - deposits: launchpad project deposit state to store
272	//
273	// Returns:
274	//   - error: nil when stored; otherwise the KV-store error, including a spoofed realm context
275	SetLaunchpadProjectDeposits(_ int, rlm realm, deposits *LaunchpadProjectDeposits) error
276}
source

IGovStakerStore mirrors the mutating-method realm-threading convention used by the public IGovStaker* interfaces above. Setters take `_ int, rlm realm` so KV-store writes execute under the proxy realm — the only address with write access to the shared store.

type LaunchpadProjectDeposits

struct
1type LaunchpadProjectDeposits struct {
2	// deposits maps owner address to deposit amount
3	deposits *bptree.BPTree // string -> int64
4}
source

LaunchpadProjectDeposits manages deposit amounts for launchpad projects. It tracks the total staked amount for each project identified by owner address.

Methods on LaunchpadProjectDeposits

func GetDeposit

method on LaunchpadProjectDeposits
1func (lpd *LaunchpadProjectDeposits) GetDeposit(ownerAddress string) (int64, bool)
source

GetDeposit looks up a project's deposit by owner address.

Parameters:

  • ownerAddress: owner address string used as the deposit key.

Returns:

  • int64: stored deposit amount in the smallest token unit, or zero when absent.
  • bool: true when an int64 deposit is stored for the owner.

func GetDeposits

method on LaunchpadProjectDeposits
1func (lpd *LaunchpadProjectDeposits) GetDeposits() *bptree.BPTree
source

GetDeposits returns the owner-to-deposit tree managed by this instance.

Returns:

  • *bptree.BPTree: tree keyed by owner address string and storing int64 amounts.

func RemoveDeposit

method on LaunchpadProjectDeposits
1func (lpd *LaunchpadProjectDeposits) RemoveDeposit(ownerAddress string) bool
source

RemoveDeposit removes an owner's deposit entry.

Parameters:

  • ownerAddress: owner address string whose deposit entry should be removed.

Returns:

  • bool: true when an entry was removed; false when no entry existed.

func SetDeposit

method on LaunchpadProjectDeposits
1func (lpd *LaunchpadProjectDeposits) SetDeposit(ownerAddress string, amount int64)
source

SetDeposit stores or replaces an owner's deposit amount.

Parameters:

  • ownerAddress: owner address string used as the deposit key.
  • amount: deposit amount in the smallest token unit.

func SetDeposits

method on LaunchpadProjectDeposits
1func (lpd *LaunchpadProjectDeposits) SetDeposits(deposits *bptree.BPTree)
source

SetDeposits replaces the owner-to-deposit tree.

Parameters:

  • deposits: tree keyed by owner address string and storing int64 amounts.

type ProtocolFeeRewardManager

struct
 1type ProtocolFeeRewardManager struct {
 2	// rewardStates maps a reward ID to the ProtocolFeeRewardState tracking that staker
 3	rewardStates *bptree.BPTree // rewardID -> *ProtocolFeeRewardState
 4	// tokenAccumulators maps a token path to its ProtocolFeeTokenAccumulator
 5	tokenAccumulators *bptree.BPTree // tokenPath -> *ProtocolFeeTokenAccumulator
 6	// currentEpoch is the accrual epoch in force, mirrored from protocol_fee
 7	currentEpoch int64
 8	// totalStakedAmount is the total amount currently staked
 9	totalStakedAmount int64
10	// totalStakedHistory records the total staked amount in force from each epoch
11	totalStakedHistory *UintTree // epoch -> int64
12	// accumulatedTimestamp is the last timestamp at which the accrual state moved: a fold or a stake change
13	accumulatedTimestamp int64
14}
source

ProtocolFeeRewardManager distributes protocol fees to stakers.

Protocol fees arrive in many tokens, so the manager keeps one accumulator per token instead of a single one. A stake change never touches those accumulators: it advances the accrual epoch, records the total stake in force from that epoch, and appends one event for an ordinary add/remove. Redelegate performs a remove plus an add and therefore appends two events. The per-token work happens when a token is collected, so stake-change cost does not depend on how many tokens ever collected a fee.

Methods on ProtocolFeeRewardManager

func GetAccumulatedProtocolFeeX128PerStake

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetAccumulatedProtocolFeeX128PerStake(tokenPath string) *u256.Uint
source

GetAccumulatedProtocolFeeX128PerStake returns the accumulated fee per stake of tokenPath (scaled by 2^128), or nil when the token never had a fee folded in.

Parameters:

  • tokenPath: token package path whose accumulated per-stake fee is requested

Returns:

  • *u256.Uint: accumulated fee per stake scaled by 2^128, or nil when tokenPath has no accumulator

func GetAccumulatedTimestamp

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetAccumulatedTimestamp() int64
source

GetAccumulatedTimestamp returns the last timestamp at which fee accrual state moved through a fold or stake change.

Returns:

  • int64: last accumulated-state update timestamp

func GetCurrentEpoch

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetCurrentEpoch() int64
source

GetCurrentEpoch returns the accrual epoch currently in force.

Returns:

  • int64: current protocol-fee accrual epoch

func GetProtocolFeeAmount

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetProtocolFeeAmount(tokenPath string) int64
source

GetProtocolFeeAmount returns the total fee amount folded in for tokenPath.

Parameters:

  • tokenPath: token package path whose folded protocol-fee amount is requested

Returns:

  • int64: total fee amount folded for tokenPath, or zero when no accumulator exists

func GetRewardState

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetRewardState(rewardID string) (*ProtocolFeeRewardState, bool, error)
source

GetRewardState retrieves the reward state identified by rewardID. Missing IDs return nil and false; a stored value of the wrong type returns an error.

Parameters:

  • rewardID: identifier of the staker reward state to retrieve

Returns:

  • *ProtocolFeeRewardState: stored reward state, or nil when rewardID is absent or invalid
  • bool: true when a correctly typed reward state was found
  • error: nil when absent or found; a cast error when the stored value has the wrong type

func GetTokenAccumulator

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetTokenAccumulator(tokenPath string) (*ProtocolFeeTokenAccumulator, bool)
source

GetTokenAccumulator returns the accumulator of tokenPath, or false when the token never had a fee folded in.

Parameters:

  • tokenPath: token package path whose protocol-fee accumulator is requested

Returns:

  • *ProtocolFeeTokenAccumulator: accumulator for tokenPath, or nil when none exists
  • bool: true when tokenPath has a folded-fee accumulator

func GetTokenPaths

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetTokenPaths() []string
source

GetTokenPaths returns every token path that had a fee folded in, in key order.

Returns:

  • []string: token paths present in the accumulator tree, ordered by tree key

func GetTotalStakedAmount

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetTotalStakedAmount() int64
source

GetTotalStakedAmount returns the total amount currently staked.

Returns:

  • int64: current total staked amount

func GetTotalStakedAmountAt

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) GetTotalStakedAmountAt(epoch int64) int64
source

GetTotalStakedAmountAt returns the total staked amount in force during epoch, using the latest recorded stake amount at or before that epoch.

Parameters:

  • epoch: accrual epoch whose effective total stake is requested

Returns:

  • int64: total stake recorded at or before epoch, or zero for a negative epoch

func SetAccumulatedTimestamp

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) SetAccumulatedTimestamp(accumulatedTimestamp int64)
source

SetAccumulatedTimestamp records the timestamp at which accrual state last moved.

Parameters:

  • accumulatedTimestamp: timestamp to record for the latest fold or stake change

func SetCurrentEpoch

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) SetCurrentEpoch(epoch int64)
source

SetCurrentEpoch records the accrual epoch currently in force.

Parameters:

  • epoch: new current protocol-fee accrual epoch

func SetRewardState

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) SetRewardState(rewardID string, rewardState *ProtocolFeeRewardState)
source

SetRewardState stores rewardState under rewardID.

Parameters:

  • rewardID: identifier under which the staker reward state is stored
  • rewardState: reward state to associate with rewardID

func SetTokenAccumulator

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) SetTokenAccumulator(tokenPath string, accumulator *ProtocolFeeTokenAccumulator)
source

SetTokenAccumulator stores accumulator under tokenPath.

Parameters:

  • tokenPath: token package path used as the accumulator key
  • accumulator: protocol-fee accumulator to store for tokenPath

func SetTotalStakedAmount

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) SetTotalStakedAmount(totalStakedAmount int64)
source

SetTotalStakedAmount records the total amount currently staked.

Parameters:

  • totalStakedAmount: new total staked amount

func SetTotalStakedAmountAt

method on ProtocolFeeRewardManager
1func (p *ProtocolFeeRewardManager) SetTotalStakedAmountAt(epoch int64, totalStakedAmount int64)
source

SetTotalStakedAmountAt records the total staked amount in force from epoch on.

Parameters:

  • epoch: first accrual epoch at which totalStakedAmount is in force
  • totalStakedAmount: total stake amount to record from epoch onward

type ProtocolFeeRewardState

struct
 1type ProtocolFeeRewardState struct {
 2	// stakedAmount is the current amount staked
 3	stakedAmount int64
 4	// stakeEvents records the staked amount in force from each stake change, by index
 5	stakeEvents *UintTree // index -> *ProtocolFeeStakeEvent
 6	// stakeEventCount is the number of recorded stake events
 7	stakeEventCount int64
 8	// tokenStates maps a token path to the settlement state of that token
 9	tokenStates *bptree.BPTree // tokenPath -> *ProtocolFeeTokenRewardState
10	// claimedTimestamp is the last timestamp at which every token was collected
11	claimedTimestamp int64
12}
source

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 on ProtocolFeeRewardState

func AppendStakeEvent

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) AppendStakeEvent(epoch int64, stakedAmount int64)
source

AppendStakeEvent records that stakedAmount is staked from epoch on.

Parameters:

  • epoch: accrual epoch at which this stake amount becomes effective
  • stakedAmount: stake amount in force from epoch onward

func GetClaimedReward

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) GetClaimedReward(tokenPath string) int64
source

GetClaimedReward returns the total reward of tokenPath collected so far.

Parameters:

  • tokenPath: token path whose accumulated claimed reward is requested

Returns:

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

func GetClaimedTimestamp

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) GetClaimedTimestamp() int64
source

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

Returns:

  • int64: Unix timestamp recorded for the most recent all-token collection

func GetStakeEvent

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) GetStakeEvent(index int64) (*ProtocolFeeStakeEvent, bool)
source

GetStakeEvent returns the indexed stake event.

Parameters:

  • index: zero-based stake-event index

Returns:

  • *ProtocolFeeStakeEvent: event at index, or nil when no event is stored there
  • bool: true when an event exists at index; false when the index is absent

func GetStakeEventCount

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) GetStakeEventCount() int64
source

GetStakeEventCount returns the number of stake-change events recorded.

Returns:

  • int64: count of indexed stake events

func GetStakedAmount

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) GetStakedAmount() int64
source

GetStakedAmount returns the current stake amount tracked for the staker.

Returns:

  • int64: current staked amount

func GetTokenPaths

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) GetTokenPaths() []string
source

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

Returns:

  • []string: token paths with stored settlement state, ordered by the underlying tree keys

func GetTokenState

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) GetTokenState(tokenPath string) (*ProtocolFeeTokenRewardState, bool)
source

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

Parameters:

  • tokenPath: registered token path whose per-staker settlement state is requested

Returns:

  • *ProtocolFeeTokenRewardState: token settlement state, or nil when it has not been initialized
  • bool: true when tokenPath has a stored settlement state, otherwise false

func SetClaimedTimestamp

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) SetClaimedTimestamp(claimedTimestamp int64)
source

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

Parameters:

  • claimedTimestamp: Unix timestamp of the all-token collection

func SetStakedAmount

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) SetStakedAmount(stakedAmount int64)
source

SetStakedAmount updates the current stake amount tracked for the staker.

Parameters:

  • stakedAmount: new current staked amount

func SetTokenState

method on ProtocolFeeRewardState
1func (p *ProtocolFeeRewardState) SetTokenState(tokenPath string, tokenState *ProtocolFeeTokenRewardState)
source

SetTokenState stores the settlement state for a token path.

Parameters:

  • tokenPath: token path used as the settlement-state key
  • tokenState: per-token settlement state to store

type ProtocolFeeStakeEvent

struct
1type ProtocolFeeStakeEvent struct {
2	epoch        int64
3	stakedAmount int64
4}
source

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

Methods on ProtocolFeeStakeEvent

func GetEpoch

method on ProtocolFeeStakeEvent
1func (e *ProtocolFeeStakeEvent) GetEpoch() int64
source

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

Returns:

  • int64: epoch at which the stake amount became effective

func GetStakedAmount

method on ProtocolFeeStakeEvent
1func (e *ProtocolFeeStakeEvent) GetStakedAmount() int64
source

GetStakedAmount returns the stake amount in force for this event.

Returns:

  • int64: staked amount associated with the event

type ProtocolFeeTokenAccumulator

struct
 1type ProtocolFeeTokenAccumulator struct {
 2	// accumulatedX128PerStake is the latest accumulated fee per stake, scaled by 2^128
 3	accumulatedX128PerStake *u256.Uint
 4	// history maps an epoch to the accumulated value after that epoch's fees were folded
 5	history *UintTree // epoch -> *u256.Uint
 6	// firstEpoch is the first epoch a fee was folded for, or -1 when none was
 7	firstEpoch int64
 8	// foldedEpoch is the last epoch whose fees are known to be fully folded, or -1
 9	foldedEpoch int64
10	// protocolFeeAmount is the total fee amount folded in
11	protocolFeeAmount int64
12}
source

ProtocolFeeTokenAccumulator tracks the accumulated protocol fee per stake of one token.

Fees are folded in per accrual epoch, each against the total stake in force during that epoch. The value after folding each epoch is kept in history so that a staker's reward can be settled later against the accumulator as it stood at any epoch.

Methods on ProtocolFeeTokenAccumulator

func GetAccumulatedX128PerStake

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) GetAccumulatedX128PerStake() *u256.Uint
source

GetAccumulatedX128PerStake returns the latest accumulated protocol fee per stake, scaled by 2^128.

Returns:

  • *u256.Uint: latest accumulated fee-per-stake value in Q128 fixed-point form.

func GetAccumulatedX128PerStakeAt

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) GetAccumulatedX128PerStakeAt(epoch int64) *u256.Uint
source

GetAccumulatedX128PerStakeAt returns the accumulated value after the fees of the latest folded epoch at or before epoch, or zero when no fee was folded by then.

Parameters:

  • epoch: accrual epoch whose latest post-fold value is requested.

Returns:

  • *u256.Uint: accumulated fee per stake in Q128 fixed-point form, or zero when no fee was folded by epoch.

func GetFirstEpoch

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) GetFirstEpoch() int64
source

GetFirstEpoch returns the first epoch for which a fee was folded.

Returns:

  • int64: first folded epoch, or -1 when no fee has been folded.

func GetFoldedEpoch

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) GetFoldedEpoch() int64
source

GetFoldedEpoch returns the last epoch known to be fully folded.

Returns:

  • int64: last fully folded epoch, or -1 when no epoch is fully folded.

func GetProtocolFeeAmount

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) GetProtocolFeeAmount() int64
source

GetProtocolFeeAmount returns the total protocol fee amount folded into the accumulator.

Returns:

  • int64: total fee amount folded for this token.

func SetAccumulatedX128PerStakeAt

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) SetAccumulatedX128PerStakeAt(epoch int64, value *u256.Uint)
source

SetAccumulatedX128PerStakeAt stores value as the accumulated amount after epoch's fees and makes it the latest value.

Parameters:

  • epoch: epoch whose post-fold accumulator value is being stored.
  • value: accumulated fee-per-stake value in Q128 fixed-point form.

func SetFoldedEpoch

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) SetFoldedEpoch(epoch int64)
source

SetFoldedEpoch records the last epoch whose protocol fees are fully folded.

Parameters:

  • epoch: latest fully folded accrual epoch.

func SetProtocolFeeAmount

method on ProtocolFeeTokenAccumulator
1func (a *ProtocolFeeTokenAccumulator) SetProtocolFeeAmount(amount int64)
source

SetProtocolFeeAmount records the total protocol fee amount folded so far.

Parameters:

  • amount: total folded protocol fee amount for this token.

type ProtocolFeeTokenRewardState

struct
 1type ProtocolFeeTokenRewardState struct {
 2	// eventCursor is the number of stake events already folded in
 3	eventCursor int64
 4	// segmentStakedAmount is the amount staked during the open segment
 5	segmentStakedAmount int64
 6	// segmentStartX128 is the accumulated fee per stake at the start of the open segment
 7	segmentStartX128 *u256.Uint
 8	// earnedX128 is the reward earned by closed segments and not yet collected, scaled by 2^128
 9	earnedX128 *u256.Uint
10	// claimedReward is the total reward collected so far
11	claimedReward int64
12}
source

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 on ProtocolFeeTokenRewardState

func GetClaimedReward

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) GetClaimedReward() int64
source

GetClaimedReward returns the total reward collected for this token state.

Returns:

  • int64: cumulative collected reward amount

func GetEarnedX128

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) GetEarnedX128() *u256.Uint
source

GetEarnedX128 returns closed-segment earnings awaiting collection.

Returns:

  • *u256.Uint: unclaimed reward accumulator scaled by 2^128

func GetEventCursor

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) GetEventCursor() int64
source

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

Returns:

  • int64: count of folded stake events

func GetSegmentStakedAmount

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) GetSegmentStakedAmount() int64
source

GetSegmentStakedAmount returns the stake amount in the open segment.

Returns:

  • int64: stake amount used while settling the open segment

func GetSegmentStartX128

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) GetSegmentStartX128() *u256.Uint
source

GetSegmentStartX128 returns the accumulator value at the open segment start.

Returns:

  • *u256.Uint: fee-per-stake accumulator at segment start, scaled by 2^128

func SetClaimedReward

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) SetClaimedReward(claimedReward int64)
source

SetClaimedReward replaces the cumulative collected reward amount.

Parameters:

  • claimedReward: total reward collected for this token state

func SetEarnedX128

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) SetEarnedX128(earnedX128 *u256.Uint)
source

SetEarnedX128 replaces the closed-segment earnings accumulator.

Parameters:

  • earnedX128: unclaimed earnings accumulator scaled by 2^128

func SetSegment

method on ProtocolFeeTokenRewardState
1func (t *ProtocolFeeTokenRewardState) SetSegment(eventCursor int64, segmentStakedAmount int64, segmentStartX128 *u256.Uint)
source

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

Parameters:

  • eventCursor: number of stake events folded into the new segment
  • segmentStakedAmount: stake amount in force for the new open segment
  • segmentStartX128: fee-per-stake accumulator at the new segment start, scaled by 2^128

type UintTree

struct
1type UintTree struct {
2	tree *bptree.BPTree // non-negative int64 key -> any
3}
source

UintTree is a wrapper around a BPTree for storing non-negative int64 keys as ordered strings. Depending on the caller, keys represent Unix timestamps, accrual epochs, or stake-event indexes.

Since keys are int64 values, they are converted to uint64-compatible strings.

Methods: - Get: Retrieves a value associated with a non-negative int64 key. - set: Stores a value with a non-negative int64 key. - Has: Checks if a non-negative int64 key exists in the tree. - remove: Removes a non-negative int64 key and its associated value. - Iterate: Iterates over keys and values in a range. - ReverseIterate: Iterates in reverse order over keys and values in a range.

Methods on UintTree

func Get

method on UintTree
1func (self *UintTree) Get(key int64) (any, bool)
source

Get looks up a value by its non-negative int64 key.

Parameters:

  • key: non-negative int64 key encoded for the ordered tree lookup; a negative key panics

Returns:

  • any: value stored at key, or nil when no entry exists
  • bool: true when key has an entry; false when absent

func Has

method on UintTree
1func (self *UintTree) Has(key int64) bool
source

Has checks whether a non-negative int64 key is present in the tree.

Parameters:

  • key: non-negative int64 key to encode and test; a negative key panics

Returns:

  • bool: true when key is present; false when no entry is stored at key

func Iterate

method on UintTree
1func (self *UintTree) Iterate(start, end int64, fn func(key int64, value any) bool)
source

Iterate visits entries in the half-open [start, end) key range in ascending order.

Parameters:

  • start: non-negative lower-bound key for the iteration range; a negative bound panics
  • end: non-negative upper-bound key for the iteration range; a negative bound panics
  • fn: callback receiving each decoded key and value; return true to stop iteration, or false to continue

func Remove

method on UintTree
1func (self *UintTree) Remove(key int64)
source

Remove deletes the entry associated with a non-negative int64 key, if one exists.

Parameters:

  • key: non-negative int64 key to encode and remove; a negative key panics

func ReverseIterate

method on UintTree
1func (self *UintTree) ReverseIterate(start, end int64, fn func(key int64, value any) bool)
source

ReverseIterate visits entries in descending order over the half-open [start, end) key range.

Parameters:

  • start: non-negative lower-bound key for the iteration range; a negative bound panics
  • end: non-negative upper-bound key for the iteration range; a negative bound panics
  • fn: callback receiving each decoded key and value; return true to stop iteration, or false to continue

func Set

method on UintTree
1func (self *UintTree) Set(key int64, value any)
source

Set associates a value with a non-negative int64 key, replacing any existing value at that key.

Parameters:

  • key: non-negative int64 key to encode and store; a negative key panics
  • value: value to associate with key

func Size

method on UintTree
1func (self *UintTree) Size() int
source

Size returns the number of entries in the tree.

Returns:

  • int: number of key-value entries currently stored in the tree

Imports 11

Source Files 24

Directories 1