staker source realm
Package staker manages liquidity mining rewards for GnoSwap positions.
View source
Staker
Liquidity mining and reward distribution for LP positions.
Overview
Staker manages distribution of internal (GNS emission) and external (user-provided) rewards to staked LP positions, with time-weighted rewards and warmup periods.
Configuration
- Deposit GNS Amount: 1,000 GNS for external incentives (default)
- Minimum Reward Amount: 1,000 tokens (default)
- Unstaking Fee: 1% (default)
- Pool Tiers: 1, 2, or 3 (assigned per pool)
- Warmup Schedule: 30/50/70/100% over 30/60/90 days
- External Token Whitelist: Approved reward tokens
Core Features
Internal Rewards (GNS Emission)
- Allocated to tiered pools (tiers 1, 2, 3)
- Split across tiers by TierRatio
- Distributed proportionally to in-range liquidity
- Unclaimed rewards go to community pool
External Rewards (User Incentives)
- Created for specific pools
- Constant reward per block
- Proportional to staked liquidity
- Unclaimed rewards returned to creator
Warmup Periods
Every staked position progresses through warmup periods:
- 0-30 days: 30% rewards (70% to community/creator)
- 30-60 days: 50% rewards (50% to community/creator)
- 60-90 days: 70% rewards (30% to community/creator)
- 90+ days: 100% rewards
Key Functions
StakeToken
Stakes LP position NFT to earn rewards.
UnStakeToken
Unstakes position and collects all rewards.
CollectReward
Collects accumulated rewards without unstaking.
CreateExternalIncentive
Creates external reward program for specific pool.
EndExternalIncentive
Ends incentive program and returns unused rewards.
Reward Calculation Logic
Tier Ratio Distribution
Emission split across tiers based on active pools:
If only tier 1 has pools: [100%, 0%, 0%]
If tiers 1 & 3 have pools: [80%, 0%, 20%]
If tiers 1 & 2 have pools: [70%, 30%, 0%]
If all tiers have pools: [50%, 30%, 20%]
Mathematical representation:
TierRatio(t) =
[1, 0, 0] if Count(2) = 0 ∧ Count(3) = 0
[0.8, 0, 0.2] if Count(2) = 0
[0.7, 0.3, 0] if Count(3) = 0
[0.5, 0.3, 0.2] otherwise
Pool Reward Formula
poolReward(pool) = (emission × TierRatio[tier(pool)]) / Count(tier(pool))
Where emission is calculated as:
emission = GNSEmissionPerSecond × (avgMsPerBlock/1000) × StakerEmissionRatio
Position Reward Calculation
The reward for each position is calculated through:
- Cache pool rewards up to current block
- Retrieve position state from deposit records
- Calculate internal rewards if pool is tiered
- Calculate external rewards for active incentives
- Apply warmup penalties based on stake duration
Mathematical formula for total reward ratio:
TotalRewardRatio(s,e) = Σ[i=0 to m-1] ΔRaw(αᵢ, βᵢ) × rᵢ
where:
αᵢ = max(s, Hᵢ₋₁)
βᵢ = min(e, Hᵢ)
ΔRaw(a, b) = CalcRaw(b) - CalcRaw(a)
CalcRaw(h) =
L(h) - U(h) if tick(h) < ℓ
U(h) - L(h) if tick(h) ≥ u
G(h) - (L(h) + U(h)) otherwise
where:
L(h) = tickLower.OutsideAccumulation(h)
U(h) = tickUpper.OutsideAccumulation(h)
G(h) = globalRewardRatioAccumulation(h)
ℓ = tickLower.id
u = tickUpper.id
Final position reward:
finalReward = TotalRewardRatio × poolReward × positionLiquidity
= ∫[s to e] (poolReward × positionLiquidity) / TotalStakedLiquidity(h) dh
Tick Cross Hook
When price crosses an initialized tick with staked positions:
- Updates staked liquidity - Adjusts total staked liquidity
- Updates reward accumulation - Recalculates
globalRewardRatioAccumulation - Manages unclaimable periods - Starts/ends periods with no in-range liquidity
- Updates tick accumulation - Adjusts
CurrentOutsideAccumulation
The globalRewardRatioAccumulation tracks the integral:
globalRewardRatioAccumulation = ∫ 1/TotalStakedLiquidity(h) dh
This integral is only computed when TotalStakedLiquidity(h) ≠ 0, enabling precise reward calculation even as liquidity changes.
Reward State Tracking
The system maintains:
- Global accumulation: Tracks reward ratio across all positions
- Tick accumulation: Tracks rewards "outside" each tick
- Position state: Individual reward calculation parameters
Usage
1// Stake existing position
2StakeToken(123, "g1referrer...")
3
4// Create external incentive
5CreateExternalIncentive(
6 "gno.land/r/demo/bar:gno.land/r/demo/baz:3000",
7 "gno.land/r/demo/reward",
8 "1000000000", // 1000 tokens
9 startTime,
10 endTime,
11)
12
13// Collect rewards without unstaking
14CollectReward(123)
15
16// Unstake and collect all rewards
17UnStakeToken(123)
Security
- Positions locked during staking
- External incentives require GNS deposit
- Warmup periods prevent gaming
- Unclaimed rewards properly redirected
- Hook integration ensures accurate tracking
Package staker manages liquidity mining rewards for GnoSwap positions.
The staker distributes GNS emissions and external incentives to liquidity providers based on their position size, price range, and staking duration. It supports both internal GNS rewards and external token incentives.
Rewards are calculated per-tick and accumulate over time, with automatic compounding and fee collection integration.
4
const AllTierCount
const ErrSpoofedRealm
const StoreKeyDepositGnsAmount, StoreKeyMinimumRewardAmount, StoreKeyDeposits, StoreKeyExternalIncentives, StoreKeyTotalEmissionSent, StoreKeyAllowedTokens, StoreKeyIncentiveCounter, StoreKeyTokenSpecificMinimumRewards, StoreKeyUnstakingFee, StoreKeyPendingProtocolFees, StoreKeyPools, StoreKeyPoolTierMemberships, StoreKeyPoolTierRatio, StoreKeyPoolTierCounts, StoreKeyPoolTierLastRewardCacheTimestamp, StoreKeyPoolTierCurrentEmission, StoreKeyPoolTierGetEmission, StoreKeyPoolTierGetHalvingBlocksInRange, StoreKeyWarmupTemplate, StoreKeyCurrentSwapBatch, StoreKeyExternalIncentivesByCreationTime
1const (
2 StoreKeyDepositGnsAmount StoreKey = "depositGnsAmount"
3 StoreKeyMinimumRewardAmount StoreKey = "minimumRewardAmount"
4 StoreKeyDeposits StoreKey = "deposits"
5 StoreKeyExternalIncentives StoreKey = "externalIncentives"
6 StoreKeyTotalEmissionSent StoreKey = "totalEmissionSent"
7 StoreKeyAllowedTokens StoreKey = "allowedTokens"
8 StoreKeyIncentiveCounter StoreKey = "incentiveCounter"
9 StoreKeyTokenSpecificMinimumRewards StoreKey = "tokenSpecificMinimumRewards"
10 StoreKeyUnstakingFee StoreKey = "unstakingFee"
11 StoreKeyPendingProtocolFees StoreKey = "pendingProtocolFees"
12 StoreKeyPools StoreKey = "pools"
13 StoreKeyPoolTierMemberships StoreKey = "poolTierMemberships"
14 StoreKeyPoolTierRatio StoreKey = "poolTierRatio"
15 StoreKeyPoolTierCounts StoreKey = "poolTierCounts"
16 StoreKeyPoolTierLastRewardCacheTimestamp StoreKey = "poolTierLastRewardCacheTimestamp"
17 StoreKeyPoolTierCurrentEmission StoreKey = "poolTierCurrentEmission"
18 StoreKeyPoolTierGetEmission StoreKey = "poolTierGetEmission"
19 StoreKeyPoolTierGetHalvingBlocksInRange StoreKey = "poolTierGetHalvingBlocksInRange"
20 StoreKeyWarmupTemplate StoreKey = "warmupTemplate"
21 StoreKeyCurrentSwapBatch StoreKey = "currentSwapBatch"
22 StoreKeyExternalIncentivesByCreationTime StoreKey = "externalIncentivesByCreationTime"
23)102
func AddToken
crossing ActionAddToken adds a token to the reward token whitelist.
func ChangePoolTier
crossing ActionChangePoolTier changes the reward tier of a pool.
func CollectExternalIncentivePenalty
crossing Action1func CollectExternalIncentivePenalty(cur realm, targetPoolPath, incentiveId string, refundAddress address) int64CollectExternalIncentivePenalty collects accumulated warmup penalties for an ended incentive.
func CollectReward
crossing Action1func CollectReward(cur realm, positionId uint64) (string, string, map[string]int64, map[string]int64)CollectReward collects accumulated rewards from a staked position.
Parameters:
- positionId: ID of the staked position
Returns:
- string: pool path
- string: staking details
- map[string]int64: internal rewards
- map[string]int64: external rewards
func CollectableEmissionReward
ActionCollectableEmissionReward returns the claimable internal reward amount.
func CollectableExternalIncentiveReward
ActionCollectableExternalIncentiveReward returns the claimable external reward amount.
func CreateExternalIncentive
crossing ActionCreateExternalIncentive creates an external reward incentive for a pool.
Parameters:
- targetPoolPath: pool to incentivize
- rewardToken: token to use as reward
- rewardAmount: total reward amount
- startTimestamp: incentive start time
- endTimestamp: incentive end time
func DecodeInt64
Actionfunc DecodeUint
ActionDecodeUint converts a zero-padded string back into a uint64 number.
Parameters: - s (string): The zero-padded string.
Returns: - uint64: The decoded number.
Panics: - If the string cannot be parsed into a uint64.
Example: Input: "00000000000000012345" Output: 12345
func DefaultAllowedTokens
Actionfunc EncodeInt
ActionEncodeInt takes an int32 and returns a zero-padded decimal string with up to 10 digits for the absolute value. If the number is negative, the '-' sign comes first, followed by zeros, then digits.
func EncodeInt64
Actionfunc EncodeUint
ActionEncodeUint converts a uint64 number into a zero-padded 20-character string.
Parameters: - num (uint64): The number to encode.
Returns: - string: A zero-padded string representation of the number.
Example: Input: 12345 Output: "00000000000000012345"
func EndExternalIncentive
crossing Action1func EndExternalIncentive(cur realm, targetPoolPath, incentiveId string, refundAddress address)EndExternalIncentive terminates an external incentive early.
func GetAllowedTokens
ActionGetAllowedTokens returns the allowed external incentive tokens.
func GetCreatedHeightOfIncentive
ActionGetCreatedHeightOfIncentive returns the block height when an incentive was created.
func GetDepositCollectedExternalReward
ActionGetDepositCollectedExternalReward returns the collected external reward amount of a position.
func GetDepositCollectedInternalReward
ActionGetDepositCollectedInternalReward returns the collected internal reward amount of a position.
func GetDepositExternalIncentiveIdList
ActionGetDepositExternalIncentiveIdList returns external incentive IDs for a deposit.
func GetDepositExternalRewardLastCollectTimestamp
Action1func GetDepositExternalRewardLastCollectTimestamp(lpTokenId uint64, incentiveId string) int64GetDepositExternalRewardLastCollectTimestamp returns the last external reward collection time for a position.
func GetDepositGnsAmount
ActionGetDepositGnsAmount returns the required GNS deposit amount for staking.
func GetDepositInternalRewardLastCollectTimestamp
ActionGetDepositInternalRewardLastCollectTimestamp returns the last internal reward collection time for a position.
func GetDepositLiquidity
ActionGetDepositLiquidity returns the liquidity amount of a staked position.
func GetDepositLiquidityAsString
ActionGetDepositLiquidityAsString returns the liquidity amount of a staked position as string.
func GetDepositStakeTime
ActionGetDepositStakeTime returns the staking duration of a position.
func GetDepositTargetPoolPath
ActionGetDepositTargetPoolPath returns the pool path of a staked position.
func GetDepositTickLower
ActionGetDepositTickLower returns the lower tick of a staked position.
func GetDepositTickUpper
ActionGetDepositTickUpper returns the upper tick of a staked position.
func GetImplementationPackagePath
ActionGetImplementationPackagePath returns the package path of the currently active implementation.
func GetIncentiveAccumulatedPenaltyAmount
ActionGetIncentiveAccumulatedPenaltyAmount returns the accumulated warmup penalty amount of an incentive.
func GetIncentiveCreatedTimestamp
ActionGetIncentiveCreatedTimestamp returns the creation timestamp of an incentive.
func GetIncentiveDepositGnsAmount
ActionGetIncentiveDepositGnsAmount returns the deposited GNS amount of an incentive.
func GetIncentiveDistributedRewardAmount
ActionGetIncentiveDistributedRewardAmount returns the distributed reward amount of an incentive.
func GetIncentiveEndTimestamp
ActionGetIncentiveEndTimestamp returns the end timestamp of an incentive.
func GetIncentiveRefunded
ActionGetIncentiveRefunded returns whether an incentive has been refunded.
func GetIncentiveRemainingRewardAmount
ActionGetIncentiveRemainingRewardAmount returns the remaining reward amount of an incentive.
func GetIncentiveRewardAmount
ActionGetIncentiveRewardAmount returns the total reward amount of an incentive.
func GetIncentiveRewardAmountAsString
ActionGetIncentiveRewardAmountAsString returns the total reward amount of an incentive as string.
func GetIncentiveRewardPerSecondX128
ActionGetIncentiveRewardPerSecondX128 returns the reward rate per second of an incentive, expressed as a Q128 fixed-point number (i.e. actual rate = value / 2^128). Callers needing an integer rate can right-shift the result by 128.
func GetIncentiveRewardToken
ActionGetIncentiveRewardToken returns the reward token of an incentive.
func GetIncentiveStartTimestamp
ActionGetIncentiveStartTimestamp returns the start timestamp of an incentive.
func GetIncentiveTotalRewardAmount
ActionGetIncentiveTotalRewardAmount returns the total reward amount of an incentive.
func GetMinimumRewardAmount
ActionGetMinimumRewardAmount returns the minimum reward amount to distribute.
func GetMinimumRewardAmountForToken
ActionGetMinimumRewardAmountForToken returns the minimum reward amount for a specific token.
func GetPoolGlobalRewardRatioAccumulation
ActionGetPoolGlobalRewardRatioAccumulation returns the global reward ratio accumulation at a specific timestamp for a pool.
func GetPoolGlobalRewardRatioAccumulationCount
ActionGetPoolGlobalRewardRatioAccumulationCount returns the number of global reward ratio accumulation entries for a pool.
func GetPoolGlobalRewardRatioAccumulationIDs
ActionGetPoolGlobalRewardRatioAccumulationIDs returns a paginated list of timestamps for global reward ratio accumulation entries.
func GetPoolHistoricalTick
ActionGetPoolHistoricalTick returns the historical tick at a specific timestamp for a pool.
func GetPoolHistoricalTickCount
ActionGetPoolHistoricalTickCount returns the number of historical tick entries for a pool.
func GetPoolHistoricalTickIDs
ActionGetPoolHistoricalTickIDs returns a paginated list of historical tick values for a pool.
func GetPoolIncentiveCount
ActionGetPoolIncentiveCount returns the number of incentives for a pool.
func GetPoolIncentiveIDs
ActionGetPoolIncentiveIDs returns a paginated list of incentive IDs for a pool.
func GetPoolIncentiveIdList
ActionGetPoolIncentiveIdList returns all incentive IDs for a pool.
func GetPoolReward
ActionGetPoolReward returns the reward amount for a tier.
func GetPoolRewardCache
ActionGetPoolRewardCache returns the reward cache value at a specific timestamp for a pool.
func GetPoolRewardCacheCount
ActionGetPoolRewardCacheCount returns the number of reward cache entries for a pool.
func GetPoolRewardCacheIDs
ActionGetPoolRewardCacheIDs returns a paginated list of reward cache timestamps for a pool.
func GetPoolStakedLiquidity
ActionGetPoolStakedLiquidity returns the current total staked liquidity of a pool.
func GetPoolTier
ActionGetPoolTier returns the tier of a pool.
func GetPoolTierCount
ActionGetPoolTierCount returns the number of pools in a tier.
func GetPoolTierRatio
ActionGetPoolTierRatio returns the reward ratio of a pool.
func GetPoolsByTier
ActionGetPoolsByTier returns the pool list for a tier.
func GetSpecificTokenMinimumRewardAmount
ActionGetSpecificTokenMinimumRewardAmount returns the minimum reward amount for a specific token.
func GetTargetPoolPathByIncentiveId
ActionGetTargetPoolPathByIncentiveId returns the pool path for an incentive ID.
func GetTotalEmissionSent
ActionGetTotalEmissionSent returns the total GNS emission sent.
func GetUnstakingFee
ActionGetUnstakingFee returns the unstaking fee percentage.
func IsIncentiveActive
ActionIsIncentiveActive returns whether an incentive is active.
func IsStaked
ActionIsStaked returns whether a position is staked.
func NewBPTreeN
ActionNewBPTreeN allocates a raw BP-tree under /r/gnoswap/staker's realm context (the realm that declares Pool/Deposit/ExternalIncentive). The tree's PkgID is therefore /r/gnoswap/staker, matching the domain values it stores, so tree.Set leaf-slot writes clear the readonly-taint gate regardless of which realm (staker/v1, mock) calls Set (borrow rule #2 borrows m.Realm to the tree's owning realm). Implementations and mocks must allocate trees that hold /r/gnoswap/staker-declared values through here rather than calling bptree.NewBPTreeN directly in their own realm.
func RegisterInitializer
crossing Action1func RegisterInitializer(cur realm, initializer func(_ int, rlm realm, stakerStore IStakerStore, poolAccessor PoolAccessor, emissionAccessor EmissionAccessor, nftAccessor NFTAccessor) IStaker)RegisterInitializer registers a new staker implementation version. This function is called by each version (v1, v2, etc.) during initialization to register their implementation with the proxy system.
The initializer function creates a new instance of the implementation using the provided stakerStore interface.
Security: Only contracts within the domain path can register initializers. Each package path can only register once to prevent duplicate registrations.
func RemovePoolTier
crossing ActionRemovePoolTier removes a pool from the tier system.
func RemoveToken
crossing ActionRemoveToken removes a token from the reward token whitelist.
func SetDepositGnsAmount
crossing ActionSetDepositGnsAmount sets the required GNS deposit amount for staking.
func SetMinimumRewardAmount
crossing ActionSetMinimumRewardAmount sets the minimum reward amount to distribute.
func SetPoolTier
crossing ActionSetPoolTier sets the reward tier for a pool.
func SetTokenMinimumRewardAmount
crossing ActionSetTokenMinimumRewardAmount sets minimum reward amounts per token.
func SetUnStakingFee
crossing ActionSetUnStakingFee sets the unstaking fee percentage.
func SetWarmUp
crossing ActionSetWarmUp sets the warm-up period parameters for staking.
func StakeToken
crossing ActionStakeToken stakes a position NFT to earn rewards.
Parameters:
- positionId: ID of the position to stake
- referrer: referrer address for reward tracking
Returns:
- string: deposit ID
func UnStakeToken
crossing ActionUnStakeToken unstakes a position NFT and collects rewards.
Parameters:
- positionId: ID of the position to unstake
Returns:
- string: collected reward details
func UpgradeImpl
crossing ActionUpgradeImpl switches the active staker implementation to a different version. This function allows seamless upgrades from one version to another without data migration or downtime.
Security: Only admin or governance can perform upgrades. The new implementation must have been previously registered via RegisterInitializer.
func NewCounter
Actionfunc GetDeposit
ActionGetDeposit returns a copy of the deposit for the given position ID.
func NewDeposit
Actionfunc GetExternalIncentiveByPoolPath
ActionGetExternalIncentiveByPoolPath returns all external incentives for a pool.
func GetIncentive
ActionGetIncentive returns a copy of the incentive for the given pool and ID.
func NewExternalIncentive
ActionNewExternalIncentive creates a new external incentive
func NewStakerStore
ActionNewStakerStore creates a new staker store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation.
func NewIncentives
Actionfunc GetPool
ActionGetPool returns a copy of the pool for the given path.
func NewPool
ActionNewPool creates a new pool with the given poolPath and currentHeight.
func NewSwapBatchProcessor
Actionfunc NewSwapTickCross
Actionfunc NewTick
Actionfunc NewTicks
Actionfunc NewTierRatio
Actionfunc NewUintTree
ActionNewUintTree creates a new UintTree instance with default fanout 64.
func NewUintTreeN
ActionNewUintTreeN creates a new UintTree instance with the specified fanout.
func DefaultWarmupTemplate
Actionfunc GetDepositWarmUp
ActionGetDepositWarmUp returns the warmup records of a staked position.
func GetWarmupTemplate
ActionGetWarmupTemplate returns the current warmup template.
func NewWarmup
Action20
type Counter
structtype Deposit
struct 1type Deposit struct {
2 warmups []Warmup // warmup information
3 liquidity *u256.Uint // liquidity
4 targetPoolPath string // staked position's pool path
5 owner address // owner address
6 stakeTime int64 // staked time
7 internalRewardLastCollectTime int64 // last collect time for internal reward
8 collectedInternalReward int64 // collected internal reward
9 collectedExternalRewards map[string]int64 // collected external reward by incentive id (incentiveID -> int64)
10 externalRewardLastCollectTimes map[string]int64 // last collect time for external rewards by incentive id (incentiveID -> int64)
11 externalIncentiveIds map[string]bool // external incentive ids for this deposit (incentiveID -> bool)
12 lastExternalIncentiveUpdatedAt int64 // last time when external incentive ids were synced
13 tickLower int32 // tick lower
14 tickUpper int32 // tick upper
15}Methods on Deposit
func AddExternalIncentiveId
method on DepositAddExternalIncentiveId adds an external incentive id to the deposit.
func Clone
method on DepositClone returns a deep copy of the deposit.
func CollectedExternalRewards
method on Depositfunc CollectedInternalReward
method on Depositfunc ExternalIncentiveIds
method on Depositfunc ExternalRewardLastCollectTimes
method on Depositfunc GetCollectedExternalReward
method on DepositGetCollectedExternalReward returns the collected external reward for the given incentive ID. Returns 0 if the incentive ID does not exist.
func GetExternalIncentiveIdList
method on DepositGetExternalIncentiveIdList returns a list of external incentive ids for the deposit.
func GetExternalRewardLastCollectTime
method on DepositGetExternalRewardLastCollectTime returns the last collect time for the given incentive ID. Returns 0 if the incentive ID does not exist.
func HasExternalIncentiveId
method on DepositHasExternalIncentiveId checks if the deposit has the given external incentive id.
func InternalRewardLastCollectTime
method on Depositfunc IterateExternalIncentiveIds
method on DepositIterateExternalIncentiveIds iterates over external incentive IDs without allocating a slice. The callback function receives each incentive ID and should return false to continue iteration, or true to stop early. This method is more memory-efficient than GetExternalIncentiveIdList for cases where you only need to process IDs sequentially.
func LastExternalIncentiveUpdatedAt
method on Depositfunc Liquidity
method on Depositfunc Owner
method on Depositfunc RemoveExternalIncentiveId
method on DepositRemoveExternalIncentiveId removes an external incentive id from the deposit.
func SetCollectedExternalReward
method on Depositfunc SetCollectedExternalRewards
method on Depositfunc SetCollectedInternalReward
method on Depositfunc SetExternalIncentiveIds
method on Depositfunc SetExternalRewardLastCollectTime
method on Depositfunc SetExternalRewardLastCollectTimes
method on Depositfunc SetInternalRewardLastCollectTime
method on Depositfunc SetLastExternalIncentiveUpdatedAt
method on Depositfunc SetLiquidity
method on Depositfunc SetOwner
method on Depositfunc SetStakeTime
method on Depositfunc SetTargetPoolPath
method on Depositfunc SetTickLower
method on Depositfunc SetTickUpper
method on Depositfunc SetWarmups
method on Depositfunc StakeTime
method on Depositfunc TargetPoolPath
method on Depositfunc TickLower
method on Depositfunc TickUpper
method on Depositfunc Warmups
method on Deposittype EmissionAccessor
interface1type EmissionAccessor interface {
2 MintAndDistributeGns(_ int, rlm realm) (int64, bool)
3 GetStakerEmissionAmountPerSecond() int64
4 GetStakerEmissionAmountPerSecondInRange(start, end int64) ([]int64, []int64)
5 SetOnDistributionPctChangeCallback(_ int, rlm realm, callback func(_ int, rlm realm, emissionAmountPerSecond int64))
6}type ExternalIncentive
struct 1type ExternalIncentive struct {
2 incentiveId string // incentive id
3 startTimestamp int64 // start time for external reward
4 endTimestamp int64 // end time for external reward
5 createdHeight int64 // block height when the incentive was created
6 createdTimestamp int64 // timestamp when the incentive was created
7 depositGnsAmount int64 // deposited gns amount
8 targetPoolPath string // external reward target pool path
9 rewardToken string // external reward token path
10 totalRewardAmount int64 // total reward amount
11 rewardAmount int64 // to be distributed reward amount
12 rewardPerSecondX128 *u256.Uint // reward per second, scaled by 2^128 to preserve sub-second precision
13 distributedRewardAmount int64 // distributed reward amount, when un-staked and refunded
14 accumulatedPenaltyAmount int64 // accumulated warmup penalty from CollectReward
15 creator address // creator address
16
17 refunded bool // whether incentive has been refunded (includes GNS deposit and unclaimed rewards)
18}Methods on ExternalIncentive
func AccumulatedPenaltyAmount
method on ExternalIncentiveAccumulatedPenaltyAmount returns the accumulated warmup penalty amount
func Clone
method on ExternalIncentivefunc CreatedHeight
method on ExternalIncentiveCreatedHeight returns the created height
func CreatedTimestamp
method on ExternalIncentiveCreatedTimestamp returns the created timestamp
func Creator
method on ExternalIncentiveCreator returns the creator address
func DepositGnsAmount
method on ExternalIncentiveDepositGnsAmount returns the deposit GNS amount
func DistributedRewardAmount
method on ExternalIncentiveDistributedRewardAmount returns the distributed reward amount
func EndTimestamp
method on ExternalIncentiveEndTimestamp returns the end timestamp
func IncentiveId
method on ExternalIncentiveIncentiveId returns the incentive ID
func Refunded
method on ExternalIncentiveRefunded returns the refunded status
func RewardAmount
method on ExternalIncentiveRewardAmount returns the reward amount
func RewardPerSecondX128
method on ExternalIncentiveRewardPerSecondX128 returns the Q128-scaled reward per second. The underlying value is (rewardAmount << 128) / duration.
func RewardToken
method on ExternalIncentiveRewardToken returns the reward token
func SetAccumulatedPenaltyAmount
method on ExternalIncentiveSetAccumulatedPenaltyAmount sets the accumulated warmup penalty amount
func SetCreatedHeight
method on ExternalIncentiveSetCreatedHeight sets the created height
func SetCreatedTimestamp
method on ExternalIncentiveSetCreatedTimestamp sets the created timestamp
func SetCreator
method on ExternalIncentiveSetCreator sets the creator address
func SetDepositGnsAmount
method on ExternalIncentiveSetDepositGnsAmount sets the deposit GNS amount
func SetDistributedRewardAmount
method on ExternalIncentiveSetDistributedRewardAmount sets the distributed reward amount
func SetEndTimestamp
method on ExternalIncentiveSetEndTimestamp sets the end timestamp
func SetIncentiveId
method on ExternalIncentiveSetIncentiveId sets the incentive ID
func SetRefunded
method on ExternalIncentiveSetRefunded sets the refunded status
func SetRewardAmount
method on ExternalIncentiveSetRewardAmount sets the reward amount
func SetRewardPerSecondX128
method on ExternalIncentiveSetRewardPerSecondX128 sets the Q128-scaled reward per second.
func SetRewardToken
method on ExternalIncentiveSetRewardToken sets the reward token
func SetStartTimestamp
method on ExternalIncentiveSetStartTimestamp sets the start timestamp
func SetTargetPoolPath
method on ExternalIncentiveSetTargetPoolPath sets the target pool path
func SetTotalRewardAmount
method on ExternalIncentiveSetTotalRewardAmount sets the total reward amount
func StartTimestamp
method on ExternalIncentiveStartTimestamp returns the start timestamp
func TargetPoolPath
method on ExternalIncentiveTargetPoolPath returns the target pool path
func TotalRewardAmount
method on ExternalIncentiveTotalRewardAmount returns the total reward amount
type IStaker
interfacetype IStakerGetter
interface 1type IStakerGetter interface {
2 GetPool(poolPath string) *Pool
3 GetPoolRewardCacheCount(poolPath string) uint64
4 GetPoolRewardCacheIDs(poolPath string, offset, count int) []int64
5 GetPoolRewardCache(poolPath string, timestamp uint64) int64
6 GetPoolIncentiveCount(poolPath string) uint64
7 GetPoolIncentiveIDs(poolPath string, offset, count int) []string
8 GetPoolGlobalRewardRatioAccumulationCount(poolPath string) uint64
9 GetPoolGlobalRewardRatioAccumulationIDs(poolPath string, offset, count int) []uint64
10 GetPoolGlobalRewardRatioAccumulation(poolPath string, timestamp uint64) string
11 GetPoolHistoricalTickCount(poolPath string) uint64
12 GetPoolHistoricalTickIDs(poolPath string, offset, count int) []int32
13 GetPoolHistoricalTick(poolPath string, tick uint64) int32
14 GetIncentive(poolPath string, incentiveId string) *ExternalIncentive
15 GetDeposit(lpTokenId uint64) *Deposit
16 CollectableEmissionReward(positionId uint64) int64
17 CollectableExternalIncentiveReward(positionId uint64, incentiveId string) int64
18 GetCreatedHeightOfIncentive(poolPath string, incentiveId string) int64
19 GetIncentiveCreatedTimestamp(poolPath string, incentiveId string) int64
20 GetIncentiveTotalRewardAmount(poolPath string, incentiveId string) int64
21 GetIncentiveDistributedRewardAmount(poolPath string, incentiveId string) int64
22 GetIncentiveRemainingRewardAmount(poolPath string, incentiveId string) int64
23 GetIncentiveAccumulatedPenaltyAmount(poolPath string, incentiveId string) int64
24 GetIncentiveDepositGnsAmount(poolPath string, incentiveId string) int64
25 GetIncentiveRefunded(poolPath string, incentiveId string) bool
26 IsIncentiveActive(poolPath string, incentiveId string) bool
27 GetDepositExternalRewardLastCollectTimestamp(lpTokenId uint64, incentiveId string) int64
28 GetDepositGnsAmount() int64
29 GetDepositInternalRewardLastCollectTimestamp(lpTokenId uint64) int64
30 GetDepositCollectedInternalReward(lpTokenId uint64) int64
31 GetDepositCollectedExternalReward(lpTokenId uint64, incentiveId string) int64
32 GetDepositLiquidity(lpTokenId uint64) *u256.Uint
33 GetDepositLiquidityAsString(lpTokenId uint64) string
34 GetDepositOwner(lpTokenId uint64) address
35 GetDepositStakeTime(lpTokenId uint64) int64
36 GetDepositTargetPoolPath(lpTokenId uint64) string
37 GetDepositTickLower(lpTokenId uint64) int32
38 GetDepositTickUpper(lpTokenId uint64) int32
39 GetDepositWarmUp(lpTokenId uint64) []Warmup
40 GetDepositExternalIncentiveIdList(lpTokenId uint64) []string
41 GetExternalIncentiveByPoolPath(poolPath string) []ExternalIncentive
42 GetIncentiveEndTimestamp(poolPath string, incentiveId string) int64
43 GetIncentiveCreator(poolPath string, incentiveId string) address
44 GetIncentiveRewardAmount(poolPath string, incentiveId string) *u256.Uint
45 GetIncentiveRewardAmountAsString(poolPath string, incentiveId string) string
46 GetIncentiveRewardPerSecondX128(poolPath string, incentiveId string) *u256.Uint
47 GetIncentiveRewardToken(poolPath string, incentiveId string) string
48 GetIncentiveStartTimestamp(poolPath string, incentiveId string) int64
49 GetMinimumRewardAmount() int64
50 GetMinimumRewardAmountForToken(tokenPath string) int64
51 GetPoolIncentiveIdList(poolPath string) []string
52 GetPoolStakedLiquidity(poolPath string) string
53 GetPoolsByTier(tier uint64) []string
54 GetPoolReward(tier uint64) int64
55 GetPoolTier(poolPath string) uint64
56 GetPoolTierCount(tier uint64) uint64
57 GetPoolTierRatio(poolPath string) uint64
58 GetSpecificTokenMinimumRewardAmount(tokenPath string) (int64, bool)
59 GetTargetPoolPathByIncentiveId(poolPath string, incentiveId string) string
60 GetUnstakingFee() uint64
61 IsStaked(positionId uint64) bool
62 GetTotalEmissionSent() int64
63 GetAllowedTokens() []string
64 GetWarmupTemplate() []Warmup
65}type IStakerManager
interface 1type IStakerManager interface {
2 StakeToken(_ int, rlm realm, positionId uint64, referrer string) string
3 UnStakeToken(_ int, rlm realm, positionId uint64) string
4 CollectReward(_ int, rlm realm, positionId uint64) (string, string, map[string]int64, map[string]int64)
5
6 SetPoolTier(_ int, rlm realm, poolPath string, tier uint64)
7 ChangePoolTier(_ int, rlm realm, poolPath string, tier uint64)
8 RemovePoolTier(_ int, rlm realm, poolPath string)
9
10 CreateExternalIncentive(
11 _ int,
12 rlm realm,
13 targetPoolPath string,
14 rewardToken string,
15 rewardAmount int64,
16 startTimestamp int64,
17 endTimestamp int64,
18 )
19 EndExternalIncentive(_ int, rlm realm, targetPoolPath, incentiveId string, refundAddress address)
20 CollectExternalIncentivePenalty(_ int, rlm realm, targetPoolPath, incentiveId string, refundAddress address) int64
21 AddToken(_ int, rlm realm, tokenPath string)
22 RemoveToken(_ int, rlm realm, tokenPath string)
23
24 SetWarmUp(_ int, rlm realm, pct, timeDuration int64)
25 SetDepositGnsAmount(_ int, rlm realm, amount int64)
26 SetMinimumRewardAmount(_ int, rlm realm, amount int64)
27 SetTokenMinimumRewardAmount(_ int, rlm realm, paramsStr string)
28 SetUnStakingFee(_ int, rlm realm, fee uint64)
29}type IStakerStore
interface 1type IStakerStore interface {
2 // DepositGnsAmount
3 HasDepositGnsAmountStoreKey() bool
4 GetDepositGnsAmount() int64
5 SetDepositGnsAmount(_ int, rlm realm, amount int64) error
6
7 // MinimumRewardAmount
8 HasMinimumRewardAmountStoreKey() bool
9 GetMinimumRewardAmount() int64
10 SetMinimumRewardAmount(_ int, rlm realm, amount int64) error
11
12 // Deposits
13 HasDepositsStoreKey() bool
14 GetDeposits() *bptree.BPTree
15 SetDeposits(_ int, rlm realm, deposits *bptree.BPTree) error
16
17 // ExternalIncentives
18 HasExternalIncentivesStoreKey() bool
19 GetExternalIncentives() *bptree.BPTree
20 SetExternalIncentives(_ int, rlm realm, incentives *bptree.BPTree) error
21
22 // TotalEmissionSent
23 HasTotalEmissionSentStoreKey() bool
24 GetTotalEmissionSent() int64
25 SetTotalEmissionSent(_ int, rlm realm, amount int64) error
26
27 // AllowedTokens
28 HasAllowedTokensStoreKey() bool
29 GetAllowedTokens() []string
30 SetAllowedTokens(_ int, rlm realm, tokens []string) error
31 AddAllowedToken(_ int, rlm realm, tokenPath string) error
32 RemoveAllowedToken(_ int, rlm realm, tokenPath string) error
33
34 // IncentiveCounter
35 HasIncentiveCounterStoreKey() bool
36 GetIncentiveCounter() *Counter
37 SetIncentiveCounter(_ int, rlm realm, counter *Counter) error
38 NextIncentiveID(creator address, timestamp int64) string
39
40 // TokenSpecificMinimumRewards
41 HasTokenSpecificMinimumRewardsStoreKey() bool
42 GetTokenSpecificMinimumRewards() map[string]int64
43 SetTokenSpecificMinimumRewards(_ int, rlm realm, rewards map[string]int64) error
44 SetTokenSpecificMinimumRewardItem(_ int, rlm realm, tokenPath string, amount int64) error
45 RemoveTokenSpecificMinimumRewardItem(_ int, rlm realm, tokenPath string) error
46
47 // UnstakingFee
48 HasUnstakingFeeStoreKey() bool
49 GetUnstakingFee() uint64
50 SetUnstakingFee(_ int, rlm realm, fee uint64) error
51
52 HasPendingProtocolFeesStoreKey() bool
53 GetPendingProtocolFees() map[string]int64
54 SetPendingProtocolFees(_ int, rlm realm, fees map[string]int64) error
55
56 // Pools
57 HasPoolsStoreKey() bool
58 GetPools() *bptree.BPTree
59 SetPools(_ int, rlm realm, pools *bptree.BPTree) error
60
61 // PoolTierMemberships
62 HasPoolTierMembershipsStoreKey() bool
63 GetPoolTierMemberships() *bptree.BPTree
64 SetPoolTierMemberships(_ int, rlm realm, memberships *bptree.BPTree) error
65
66 // PoolTierRatio
67 HasPoolTierRatioStoreKey() bool
68 GetPoolTierRatio() TierRatio
69 SetPoolTierRatio(_ int, rlm realm, ratio TierRatio) error
70
71 // PoolTierCounts
72 HasPoolTierCountsStoreKey() bool
73 GetPoolTierCounts() [AllTierCount]uint64
74 SetPoolTierCounts(_ int, rlm realm, counts [AllTierCount]uint64) error
75
76 // PoolTierLastRewardCacheTimestamp
77 HasPoolTierLastRewardCacheTimestampStoreKey() bool
78 GetPoolTierLastRewardCacheTimestamp() int64
79 SetPoolTierLastRewardCacheTimestamp(_ int, rlm realm, timestamp int64) error
80
81 // PoolTierCurrentEmission
82 HasPoolTierCurrentEmissionStoreKey() bool
83 GetPoolTierCurrentEmission() int64
84 SetPoolTierCurrentEmission(_ int, rlm realm, emission int64) error
85
86 // PoolTierGetEmission
87 HasPoolTierGetEmissionStoreKey() bool
88 GetPoolTierGetEmission() func() int64
89 SetPoolTierGetEmission(_ int, rlm realm, fn func() int64) error
90
91 // PoolTierGetHalvingBlocksInRange
92 HasPoolTierGetHalvingBlocksInRangeStoreKey() bool
93 GetPoolTierGetHalvingBlocksInRange() func(start, end int64) ([]int64, []int64)
94 SetPoolTierGetHalvingBlocksInRange(_ int, rlm realm, fn func(start, end int64) ([]int64, []int64)) error
95
96 HasWarmupTemplateStoreKey() bool
97 GetWarmupTemplate() []Warmup
98 SetWarmupTemplate(_ int, rlm realm, warmups []Warmup) error
99
100 // CurrentSwapBatch
101 HasCurrentSwapBatchStoreKey() bool
102 GetCurrentSwapBatch() *SwapBatchProcessor
103 SetCurrentSwapBatch(_ int, rlm realm, batch *SwapBatchProcessor) error
104
105 // ExternalIncentivesByCreationTime
106 HasExternalIncentivesByCreationTimeStoreKey() bool
107 GetExternalIncentivesByCreationTime() *UintTree
108 SetExternalIncentivesByCreationTime(_ int, rlm realm, tree *UintTree) error
109}type Incentives
structIncentives represents a collection of external incentives for a specific pool.
Fields:
-
incentives: BPTree storing ExternalIncentive objects indexed by incentiveId The incentiveId serves as the key to efficiently lookup incentive details
-
targetPoolPath: String identifier for the pool this incentive collection belongs to Used to associate incentives with their corresponding liquidity pool
-
unclaimablePeriods: Tree storing periods when rewards cannot be claimed Maps start timestamp (key) to end timestamp (value) An end timestamp of 0 indicates an ongoing unclaimable period Used to track intervals when staking rewards are not claimable
Methods on Incentives
func Incentive
method on IncentivesIncentive returns an incentive by ID
func IncentiveTrees
method on IncentivesIncentives returns the incentives tree
func IterateIncentives
method on Incentives1func (i *Incentives) IterateIncentives(fn func(incentiveId string, incentive *ExternalIncentive) bool)IterateIncentives iterates over all incentives
func RemoveUnclaimablePeriod
method on Incentivesfunc SetIncentive
method on IncentivesSetIncentive sets an incentive by ID
func SetIncentives
method on IncentivesSetIncentives sets the incentives tree
func SetTargetPoolPath
method on IncentivesSetTargetPoolPath sets the target pool path
func SetUnclaimablePeriod
method on Incentivesfunc SetUnclaimablePeriods
method on IncentivesSetUnclaimablePeriods sets the unclaimable periods tree
func TargetPoolPath
method on IncentivesTargetPoolPath returns the target pool path
func UnclaimablePeriods
method on IncentivesUnclaimablePeriods returns the unclaimable periods tree
type NFTAccessor
interface 1type NFTAccessor interface {
2 Approve(_ int, rlm realm, approved address, tid grc721.TokenID) error
3 Mint(_ int, rlm realm, to address, tid grc721.TokenID) grc721.TokenID
4 Burn(_ int, rlm realm, tid grc721.TokenID)
5 TransferFrom(_ int, rlm realm, from, to address, tid grc721.TokenID) error
6 TotalSupply() int64
7 Exists(tid grc721.TokenID) bool
8 MustOwnerOf(tid grc721.TokenID) address
9 OwnerOf(tid grc721.TokenID) (address, error)
10}type Pool
struct 1type Pool struct {
2 poolPath string
3
4 stakedLiquidity *UintTree // uint64 timestamp -> *u256.Uint(Q128)
5
6 lastUnclaimableTime int64
7 unclaimableAcc int64
8
9 rewardCache *UintTree // uint64 timestamp -> int64 gnsReward
10
11 incentives *Incentives
12
13 ticks Ticks // int32 tickId -> Tick tick
14
15 globalRewardRatioAccumulation *UintTree // uint64 timestamp -> *u256.Uint(Q128) rewardRatioAccumulation
16
17 historicalTick *UintTree // uint64 timestamp -> int32 tickId
18}Pool is a struct for storing an incentivized pool information Each pool stores Incentives and Ticks associated with it.
Fields: - poolPath: The path of the pool.
-
currentStakedLiquidity: The current total staked liquidity of the in-range positions for the pool. Updated when tick cross happens or stake/unstake happens. Used to calculate the global reward ratio accumulation or decide whether to enter/exit unclaimable period.
-
lastUnclaimableTime: The time at which the unclaimable period started. Set to 0 when the pool is not in an unclaimable period.
-
unclaimableAcc: The accumulated undisributed unclaimable reward. Reset to 0 when processUnclaimableReward is called and sent to community pool.
-
rewardCache: The cached per-second reward emitted for this pool. Stores new entry only when the reward is changed. PoolTier.cacheReward() updates this.
- incentives: The external incentives associated with the pool.
- ticks: The Ticks associated with the pool.
-
globalRewardRatioAccumulation: Global ratio of Time / TotalStake accumulation(since the pool creation) Stores new entry only when tick cross or stake/unstake happens. It is used to calculate the reward for a staked position at certain time.
-
historicalTick: The historical tick for the pool at a given time. It does not reflect the exact tick at the timestamp, but it provides correct ordering for the staked position's ticks. Therefore, you should not compare it for equality, only for ordering. Set when tick cross happens or a new position is created.
Methods on Pool
func Clone
method on PoolClone returns a deep copy of the pool.
func GlobalRewardRatioAccumulation
method on PoolGlobalRewardRatioAccumulation returns the global reward ratio accumulation tree
func HistoricalTick
method on PoolHistoricalTick returns the historical tick tree
func Incentives
method on PoolIncentives returns the incentives
func LastUnclaimableTime
method on PoolLastUnclaimableTime returns the last unclaimable time
func PoolPath
method on PoolPoolPath returns the pool path
func RewardCache
method on PoolRewardCache returns the reward cache tree
func SetGlobalRewardRatioAccumulation
method on PoolSetGlobalRewardRatioAccumulation sets the global reward ratio accumulation tree
func SetGlobalRewardRatioAccumulationAt
method on Poolfunc SetHistoricalTick
method on PoolSetHistoricalTick sets the historical tick tree
func SetHistoricalTickAt
method on Poolfunc SetIncentives
method on PoolSetIncentives sets the incentives
func SetLastUnclaimableTime
method on PoolSetLastUnclaimableTime sets the last unclaimable time
func SetPoolPath
method on PoolSetPoolPath sets the pool path
func SetRewardCache
method on PoolSetRewardCache sets the reward cache tree
func SetRewardCacheAt
method on Poolfunc SetStakedLiquidity
method on PoolSetStakedLiquidity sets the staked liquidity tree
func SetStakedLiquidityAt
method on Poolfunc SetTicks
method on PoolSetTicks sets the ticks
func SetUnclaimableAcc
method on PoolSetUnclaimableAcc sets the unclaimable accumulation
func StakedLiquidity
method on PoolStakedLiquidity returns the staked liquidity tree
func Ticks
method on PoolTicks returns the ticks
func UnclaimableAcc
method on PoolUnclaimableAcc returns the unclaimable accumulation
type PoolAccessor
interface1type PoolAccessor interface {
2 ExistsPoolPath(poolPath string) bool
3 GetSlot0Tick(poolPath string) int32
4 GetSlot0SqrtPriceX96(poolPath string) string
5
6 SetTickCrossHook(_ int, rlm realm, hook func(_ int, rlm realm, poolPath string, tickId int32, zeroForOne bool, timestamp int64))
7 SetSwapStartHook(_ int, rlm realm, hook func(_ int, rlm realm, poolPath string, timestamp int64))
8 SetSwapEndHook(_ int, rlm realm, hook func(_ int, rlm realm, poolPath string) error)
9}type StoreKey
identtype SwapBatchProcessor
struct1type SwapBatchProcessor struct {
2 poolPath string // The pool path identifier for this swap
3 pool *Pool // Reference to the pool being swapped in
4 crosses []*SwapTickCross // Accumulated tick crosses during the swap
5 timestamp int64 // Timestamp when the swap started
6 isActive bool // Flag to prevent accumulation after swap ends
7}SwapBatchProcessor processes tick crosses in batch for a swap This processor accumulates all tick crosses that occur during a single swap and processes them together at the end, reducing redundant calculations and state updates that would occur with individual tick processing
Methods on SwapBatchProcessor
func AddCross
method on SwapBatchProcessorfunc Crosses
method on SwapBatchProcessorfunc IsActive
method on SwapBatchProcessorfunc LastCross
method on SwapBatchProcessorfunc Pool
method on SwapBatchProcessorfunc PoolPath
method on SwapBatchProcessorfunc SetCrosses
method on SwapBatchProcessorfunc SetIsActive
method on SwapBatchProcessorfunc SetPool
method on SwapBatchProcessorfunc SetPoolPath
method on SwapBatchProcessorfunc SetTimestamp
method on SwapBatchProcessorfunc Timestamp
method on SwapBatchProcessortype SwapTickCross
structSwapTickCross stores information about a tick cross during a swap This struct is used to accumulate tick cross events during a single swap transaction for batch processing to optimize gas usage and computational efficiency
type Tick
struct 1type Tick struct {
2 id int32
3
4 // conceptually equal with Pool.liquidityGross but only for the staked positions
5 stakedLiquidityGross *u256.Uint
6
7 // conceptually equal with Pool.liquidityNet but only for the staked positions
8 stakedLiquidityDelta *i256.Int
9
10 // currentOutsideAccumulation is the accumulation of the time / TotalStake outside the tick.
11 // It is calculated by subtracting the current tick's currentOutsideAccumulation from the global reward ratio accumulation.
12 outsideAccumulation *UintTree // timestamp -> *u256.Uint
13}Tick represents the state of a specific tick in a pool.
Fields: - id (int32): The ID of the tick. - stakedLiquidityGross (*u256.Uint): Total gross staked liquidity at this tick. - stakedLiquidityDelta (*i256.Int): Net change in staked liquidity at this tick. - outsideAccumulation (*UintTree): RewardRatioAccumulation outside the tick.
Methods on Tick
func Clone
method on TickClone returns a deep copy of the tick.
func Id
method on TickId returns the tick ID
func OutsideAccumulation
method on TickOutsideAccumulation returns the outside accumulation tree
func SetId
method on TickSetId sets the tick ID
func SetOutsideAccumulation
method on TickSetOutsideAccumulation sets the outside accumulation tree
func SetOutsideAccumulationAt
method on TickSetOutsideAccumulationAt sets the outside accumulation at the timestamp.
func SetStakedLiquidityDelta
method on TickSetStakedLiquidityDelta sets the staked liquidity delta
func SetStakedLiquidityGross
method on TickSetStakedLiquidityGross sets the staked liquidity gross
func StakedLiquidityDelta
method on TickStakedLiquidityDelta returns the staked liquidity delta
func StakedLiquidityGross
method on TickStakedLiquidityGross returns the staked liquidity gross
type Ticks
structTick mapping for each pool
Methods on Ticks
func Clone
method on TicksClone returns a deep copy of ticks.
func Get
method on Ticksfunc Has
method on Ticksfunc IterateTicks
method on TicksIterateTicks iterates over all ticks
func SetTick
method on TicksSetTick sets a tick by ID
func SetTree
method on TicksSetTree sets the ticks tree
func Tree
method on TicksTree returns the ticks tree
type TierRatio
struct100%, 0%, 0% if no tier2 and tier3 80%, 0%, 20% if no tier2 70%, 30%, 0% if no tier3 50%, 30%, 20% if has tier2 and tier3
type UintTree
structUintTree is a wrapper around a B+ tree for storing block timestamps as strings. Since block timestamps are defined as int64, we take int64 and convert it to uint64 for the tree.
Methods: - Get: Retrieves a value associated with a uint64 key. - Set: Stores a value with a uint64 key. - Has: Checks if a uint64 key exists in the tree. - Remove: Removes a uint64 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 Clone
method on UintTreefunc Get
method on UintTreefunc Has
method on UintTreefunc Iterate
method on UintTreefunc IterateByOffset
method on UintTreefunc Remove
method on UintTreefunc ReverseIterate
method on UintTreefunc Set
method on UintTreefunc Size
method on UintTreetype Warmup
structMethods on Warmup
func SetNextWarmupTime
method on Warmupfunc SetTimeDuration
method on Warmupfunc SetWarmupRatio
method on Warmup19
- errors stdlib
- gno.land/p/gnoswap/consts package
- gno.land/p/gnoswap/deps/grc721 package
- gno.land/p/gnoswap/int256 package
- gno.land/p/gnoswap/rbac package
- gno.land/p/gnoswap/store package
- gno.land/p/gnoswap/uint256 package
- gno.land/p/gnoswap/version_manager package
- gno.land/p/nt/bptree/v0 package
- gno.land/p/nt/ufmt/v0 package
- gno.land/r/gnoswap/access realm
- gno.land/r/gnoswap/emission realm
- gno.land/r/gnoswap/gnft realm
- gno.land/r/gnoswap/pool realm
- gno.land/r/gnoswap/rbac realm
- math stdlib
- strconv stdlib
- strings stdlib
- time stdlib