PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/r/gnoswap/gov/staker/v1

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
v1
Namespace
gnoswap / gov / staker
Files
25 (README)(gnomod.toml)
Exported functions
12
Module
gno.land/r/gnoswap/gov/staker/v1
gno
0.9

Files (25)

  • README.mdmarkdown
  • gnomod.tomltoml
  • assert.gnogno
  • consts.gnogno
  • delegation_manager.gnogno
  • delegation_withdraw.gnogno
  • delegation.gno
gno
  • doc.gnogno
  • emission_reward_manager.gnogno
  • emission_reward_state.gnogno
  • emits.gnogno
  • errors.gnogno
  • getter_utils.gnogno
  • getter.gnogno
  • init.gnogno
  • instance.gnogno
  • launchpad_project_deposits.gnogno
  • protocol_fee_reward_manager.gnogno
  • protocol_fee_reward_state.gnogno
  • render.gnogno
  • staker_delegate.gnogno
  • staker_delegation_snapshot.gnogno
  • staker_reward.gnogno
  • state.gnogno
  • util.gnogno
  • delegation_withdraw.gnogno
    1package staker23import (4	"errors"56	gnsmath "gno.land/p/gnoswap/gnsmath/v1"78

    Functions

    • NewDelegation(id int64, delegateFrom string, delegateTo string, delegateAmount int64, createdHeight int64, createdAt int64) *gno.land/r/gnoswap/gov/staker.Delegation

    • NewDelegationManagerResolver(delegationManager *gno.land/r/gnoswap/gov/staker.DelegationManager) *gno.land/r/gnoswap/gov/staker/v1.DelegationManagerResolver

    • NewDelegationResolver(delegation *gno.land/r/gnoswap/gov/staker.Delegation) *gno.land/r/gnoswap/gov/staker/v1.DelegationResolver

    • NewDelegationWithdraw(delegationID int64, unDelegateAmount int64, createdHeight int64, createdAt int64, unDelegationLockupPeriod int64) struct{delegationID int64; unDelegateAmount int64; unDelegatedHeight int64; unDelegatedAt int64; collectedAmount int64; collectableTime int64; collectedAt int64; collected bool}

    • NewDelegationWithdrawResolver(withdraw *gno.land/r/gnoswap/gov/staker.DelegationWithdraw) *gno.land/r/gnoswap/gov/staker/v1.DelegationWithdrawResolver

    • NewDelegationWithdrawWithoutLockup(delegationID int64, unDelegateAmount int64, createdHeight int64, createdAt int64) struct{delegationID int64; unDelegateAmount int64; unDelegatedHeight int64; unDelegatedAt int64; collectedAmount int64; collectableTime int64; collectedAt int64; collected bool}

    • NewEmissionRewardManagerResolver(emissionRewardManager *gno.land/r/gnoswap/gov/staker.EmissionRewardManager) *gno.land/r/gnoswap/gov/staker/v1.EmissionRewardManagerResolver

    • NewEmissionRewardStateResolver(emissionRewardState *gno.land/r/gnoswap/gov/staker.EmissionRewardState) *gno.land/r/gnoswap/gov/staker/v1.EmissionRewardStateResolver

    • NewGovStakerV1(store interface {GetAllDelegations func() *gno.land/p/nt/bptree/v0.BPTree; GetDelegation func(int64) (*gno.land/r/gnoswap/gov/staker.Delegation, bool); GetDelegationCounter func() *gno.land/r/gnoswap/gov/staker.Counter; GetDelegationManager func() *gno.land/r/gnoswap/gov/staker.DelegationManager; GetEmissionRewardManager func() *gno.land/r/gnoswap/gov/staker.EmissionRewardManager; GetLaunchpadProjectDeposits func() *gno.land/r/gnoswap/gov/staker.LaunchpadProjectDeposits; GetProtocolFeeRewardManager func() *gno.land/r/gnoswap/gov/staker.ProtocolFeeRewardManager; GetTotalDelegatedAmount func() int64; GetTotalDelegationHistory func() *gno.land/r/gnoswap/gov/staker.UintTree; GetTotalLockedAmount func() int64; GetUnDelegationLockupPeriod func() int64; GetUserDelegationHistory func() *gno.land/p/nt/bptree/v0.BPTree; HasDelegation func(int64) bool; HasDelegationCounterStoreKey func() bool; HasDelegationManagerStoreKey func() bool; HasDelegationsStoreKey func() bool; HasEmissionRewardManagerStoreKey func() bool; HasLaunchpadProjectDepositsStoreKey func() bool; HasProtocolFeeRewardManagerStoreKey func() bool; HasTotalDelegatedAmountStoreKey func() bool; HasTotalDelegationHistoryStoreKey func() bool; HasTotalLockedAmountStoreKey func() bool; HasUnDelegationLockupPeriodStoreKey func() bool; HasUserDelegationHistoryStoreKey func() bool; RemoveDelegation func(int, .uverse.realm, int64) .uverse.error; SetDelegation func(int, .uverse.realm, int64, *gno.land/r/gnoswap/gov/staker.Delegation) .uverse.error; SetDelegationCounter func(int, .uverse.realm, *gno.land/r/gnoswap/gov/staker.Counter) .uverse.error; SetDelegationManager func(int, .uverse.realm, *gno.land/r/gnoswap/gov/staker.DelegationManager) .uverse.error; SetDelegations func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetEmissionRewardManager func(int, .uverse.realm, *gno.land/r/gnoswap/gov/staker.EmissionRewardManager) .uverse.error; SetLaunchpadProjectDeposits func(int, .uverse.realm, *gno.land/r/gnoswap/gov/staker.LaunchpadProjectDeposits) .uverse.error; SetProtocolFeeRewardManager func(int, .uverse.realm, *gno.land/r/gnoswap/gov/staker.ProtocolFeeRewardManager) .uverse.error; SetTotalDelegatedAmount func(int, .uverse.realm, int64) .uverse.error; SetTotalDelegationHistory func(int, .uverse.realm, *gno.land/r/gnoswap/gov/staker.UintTree) .uverse.error; SetTotalLockedAmount func(int, .uverse.realm, int64) .uverse.error; SetUnDelegationLockupPeriod func(int, .uverse.realm, int64) .uverse.error; SetUserDelegationHistory func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error}) interface {CleanStakerDelegationSnapshotByAdmin func(int, .uverse.realm, int64, .uverse.address); CollectEmissionReward func(int, .uverse.realm); CollectEmissionRewardFromLaunchPad func(int, .uverse.realm, .uverse.address); CollectProtocolFeeReward func(int, .uverse.realm, string); CollectProtocolFeeRewardFromLaunchPad func(int, .uverse.realm, .uverse.address, string); CollectReward func(int, .uverse.realm); CollectRewardFromLaunchPad func(int, .uverse.realm, .uverse.address); CollectUndelegatedGns func(int, .uverse.realm) int64; Delegate func(int, .uverse.realm, .uverse.address, int64, string) int64; ExistsDelegation func(int64) bool; GetClaimableRewardByAddress func(.uverse.address) (int64, map[string]int64, .uverse.error); GetClaimableRewardByLaunchpad func(.uverse.address) (int64, map[string]int64, .uverse.error); GetClaimableRewardByRewardID func(string) (int64, map[string]int64, .uverse.error); GetCollectableWithdrawAmount func(int64) int64; GetDelegationWithdrawCount func(int64) int; GetDelegationWithdraws func(int64, int, int) ([]gno.land/r/gnoswap/gov/staker.DelegationWithdraw, .uverse.error); GetDelegations func() *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree; GetDelegatorDelegations func(.uverse.address) *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree; GetEmissionAccumulatedTimestamp func() int64; GetEmissionAccumulatedX128PerStake func() *gno.land/p/gnoswap/uint256/v1.Uint; GetEmissionDistributedAmount func() int64; GetLaunchpadProjectDeposit func(string) (int64, bool); GetProtocolFeeAccumulatedTimestamp func() int64; GetProtocolFeeAccumulatedX128PerStake func(string) *gno.land/p/gnoswap/uint256/v1.Uint; GetProtocolFeeAmount func(string) int64; GetTotalDelegated func() int64; GetTotalDelegationAmountAtSnapshot func(int64) (int64, bool); GetTotalLockedAmount func() int64; GetTotalxGnsSupply func() int64; GetUnDelegationLockupPeriod func() int64; GetUserDelegationAmountAtSnapshot func(.uverse.address, int64) (int64, bool); GetUserDelegationIDs func(.uverse.address, .uverse.address) []int64; HasDelegationSnapshotsKey func() bool; Redelegate func(int, .uverse.realm, .uverse.address, .uverse.address, int64) int64; Render func(string) string; SetAmountByProjectWallet func(int, .uverse.realm, .uverse.address, int64, bool); SetUnDelegationLockupPeriodByAdmin func(int, .uverse.realm, int64); Undelegate func(int, .uverse.realm, .uverse.address, int64) int64}

    • NewLaunchpadProjectDepositsResolver(launchpadProjectDeposits *gno.land/r/gnoswap/gov/staker.LaunchpadProjectDeposits) *gno.land/r/gnoswap/gov/staker/v1.LaunchpadProjectDepositsResolver

    • NewProtocolFeeRewardManagerResolver(manager *gno.land/r/gnoswap/gov/staker.ProtocolFeeRewardManager) *gno.land/r/gnoswap/gov/staker/v1.ProtocolFeeRewardManagerResolver

    • NewProtocolFeeRewardStateResolver(protocolFeeRewardState *gno.land/r/gnoswap/gov/staker.ProtocolFeeRewardState) *gno.land/r/gnoswap/gov/staker/v1.ProtocolFeeRewardStateResolver

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.

    Rendered

    RenderedRawgnoweb ↗
    This realm does not provide renderable output (vm/qrender → NoRenderDeclError). View on gnoweb ↗

    vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.

    "gno.land/r/gnoswap/gov/staker"
    9)
    10
    11type DelegationWithdrawResolver struct {
    12 withdraw *staker.DelegationWithdraw
    13}
    14
    15// NewDelegationWithdrawResolver wraps a delegation withdrawal for collection
    16// state and lockup calculations.
    17//
    18// Parameters:
    19// - withdraw: delegation withdrawal state to resolve
    20//
    21// Returns:
    22// - *DelegationWithdrawResolver: resolver retaining the supplied withdrawal pointer
    23func NewDelegationWithdrawResolver(withdraw *staker.DelegationWithdraw) *DelegationWithdrawResolver {
    24 return &DelegationWithdrawResolver{withdraw}
    25}
    26
    27// Get returns the wrapped delegation withdrawal value.
    28//
    29// Returns:
    30// - *staker.DelegationWithdraw: wrapped withdrawal pointer, or nil when the resolver was constructed with nil
    31func (r *DelegationWithdrawResolver) Get() *staker.DelegationWithdraw {
    32 return r.withdraw
    33}
    34
    35// CollectableAmount calculates the amount available for collection at the given time.
    36// Returns zero if the withdrawal is not yet collectable or has been fully collected.
    37//
    38// Parameters:
    39// - currentTime: current timestamp to check collectability against
    40//
    41// Returns:
    42// - int64: amount available for collection
    43func (r *DelegationWithdrawResolver) CollectableAmount(currentTime int64) int64 {
    44 if r.IsCollectable(currentTime) {
    45 return gnsmath.SafeSubInt64(r.withdraw.UnDelegateAmount(), r.withdraw.CollectedAmount())
    46 }
    47
    48 return 0
    49}
    50
    51// IsCollectable determines whether the withdrawal can be collected at the given time.
    52// A withdrawal is collectable if:
    53// - The undelegated amount is positive
    54// - There is remaining uncollected amount
    55// - The current time is at or after the collectable time
    56//
    57// Parameters:
    58// - currentTime: current timestamp to check against
    59//
    60// Returns:
    61// - bool: true if the withdrawal can be collected, false otherwise
    62func (r *DelegationWithdrawResolver) IsCollectable(currentTime int64) bool {
    63 if r.withdraw.UnDelegateAmount() <= 0 {
    64 return false
    65 }
    66
    67 remaining := gnsmath.SafeSubInt64(r.withdraw.UnDelegateAmount(), r.withdraw.CollectedAmount())
    68 if remaining <= 0 {
    69 return false
    70 }
    71
    72 if currentTime < r.withdraw.CollectableTime() {
    73 return false
    74 }
    75
    76 return true
    77}
    78
    79// IsCollected returns whether the withdrawal has been fully collected.
    80//
    81// Returns:
    82// - bool: true if fully collected, false otherwise
    83func (r *DelegationWithdrawResolver) IsCollected() bool {
    84 return r.withdraw.IsCollected()
    85}
    86
    87// collect processes the collection of the specified amount from this withdrawal.
    88// This method validates collectability and updates the collection state.
    89//
    90// Parameters:
    91// - amount: GNS amount to add to this withdrawal's collected amount
    92// - currentTime: Unix timestamp used to check lockup expiry and record collection time
    93//
    94// Returns:
    95// - error: nil after the collection state is updated; errWithdrawNotCollectable when the withdrawal is not collectable
    96func (r *DelegationWithdrawResolver) Collect(amount int64, currentTime int64) error {
    97 if !r.IsCollectable(currentTime) {
    98 return errors.New(errWithdrawNotCollectable)
    99 }
    100
    101 r.withdraw.SetCollectedAmount(gnsmath.SafeAddInt64(r.withdraw.CollectedAmount(), amount))
    102
    103 if r.withdraw.UnDelegateAmount() == r.withdraw.CollectedAmount() {
    104 r.withdraw.SetCollected(true)
    105 r.withdraw.SetCollectedAt(currentTime)
    106 }
    107
    108 return nil
    109}
    110
    111// NewDelegationWithdraw creates a new delegation withdrawal with lockup period.
    112// This is a convenience wrapper around staker.NewDelegationWithdraw.
    113//
    114// Parameters:
    115// - delegationID: unique identifier of the associated delegation
    116// - unDelegateAmount: amount being withdrawn
    117// - createdHeight: height when the withdrawal was created
    118// - createdAt: timestamp when the withdrawal was created
    119// - unDelegationLockupPeriod: duration of the lockup period in seconds
    120//
    121// Returns:
    122// - staker.DelegationWithdraw: new withdrawal instance with lockup
    123func NewDelegationWithdraw(
    124 delegationID,
    125 unDelegateAmount,
    126 createdHeight,
    127 createdAt,
    128 unDelegationLockupPeriod int64,
    129) staker.DelegationWithdraw {
    130 return staker.NewDelegationWithdraw(
    131 delegationID,
    132 unDelegateAmount,
    133 createdHeight,
    134 createdAt,
    135 unDelegationLockupPeriod,
    136 )
    137}
    138
    139// NewDelegationWithdrawWithoutLockup creates a new delegation withdrawal that is immediately collectable.
    140// This is a convenience wrapper around staker.NewDelegationWithdrawWithoutLockup.
    141//
    142// Parameters:
    143// - delegationID: unique identifier of the associated delegation
    144// - unDelegateAmount: amount being withdrawn
    145// - createdHeight: height when the withdrawal was created
    146// - createdAt: timestamp when the withdrawal was created
    147//
    148// Returns:
    149// - staker.DelegationWithdraw: new withdrawal instance that is immediately collectable
    150func NewDelegationWithdrawWithoutLockup(
    151 delegationID,
    152 unDelegateAmount,
    153 createdHeight,
    154 createdAt int64,
    155) staker.DelegationWithdraw {
    156 return staker.NewDelegationWithdrawWithoutLockup(
    157 delegationID,
    158 unDelegateAmount,
    159 createdHeight,
    160 createdAt,
    161 )
    162}
    163