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

pool.gno

Types

ExternalIncentive

source

Methods

AccumulatedPenaltyAmount

AccumulatedPenaltyAmount returns the accumulated warmup penalty amount

Return Values

Name
Type
Description

amount

int64

Warm-up penalty accumulated from reward collections for this incentive.

source

Clone

Clone returns an independent ExternalIncentive value with scalar fields copied and its fixed-point rate duplicated.

Return Values

Name
Type
Description

incentive

*ExternalIncentive

Copied external incentive record; its fixed-point rate is cloned when present and otherwise initialized to zero.

source

CreatedHeight

CreatedHeight returns the created height

Return Values

Name
Type
Description

height

int64

Block height at which the incentive record was created.

source

CreatedTimestamp

CreatedTimestamp returns the created timestamp

Return Values

Name
Type
Description

timestamp

int64

Unix timestamp in seconds at which the incentive record was created.

source

Creator

Creator returns the creator address

Return Values

Name
Type
Description

creator

address

Address that created and funded the incentive.

source

DepositGnsAmount

DepositGnsAmount returns the deposit GNS amount

Return Values

Name
Type
Description

amount

int64

GNS amount deposited to back this external incentive.

source

DistributedRewardAmount

DistributedRewardAmount returns the distributed reward amount

Return Values

Name
Type
Description

amount

int64

Reward amount already delivered to positions or refunded at incentive end.

source

EndTimestamp

EndTimestamp returns the end timestamp

Return Values

Name
Type
Description

timestamp

int64

Unix timestamp in seconds at which the incentive window ends.

source

IncentiveId

IncentiveId returns the incentive ID

Return Values

Name
Type
Description

id

string

Identifier assigned to this external incentive.

source

Refunded

Refunded returns the refunded status

Return Values

Name
Type
Description

refunded

bool

True when incentive finalization has marked its refundable balances as returned.

source

RewardAmount

RewardAmount returns the reward amount

Return Values

Name
Type
Description

amount

int64

Mutable reward amount remaining after distributions and refunds.

source

RewardPerSecondX128

RewardPerSecondX128 returns the Q128-scaled reward per second. The underlying value is (rewardAmount << 128) / duration.

Return Values

Name
Type
Description

rate

*u256.Uint

Reward emitted per second, scaled by 2^128 for fixed-point accounting.

source

RewardToken

RewardToken returns the reward token

Return Values

Name
Type
Description

token

string

Reward-token path distributed by this incentive.

source

SetAccumulatedPenaltyAmount

SetAccumulatedPenaltyAmount sets the accumulated warmup penalty amount

Parameters

Name
Type
Description

accumulatedPenaltyAmount

int64

Warm-up penalty amount to store in the incentive's accumulated accounting.

source

SetCreatedHeight

SetCreatedHeight sets the created height

Parameters

Name
Type
Description

createdHeight

int64

Block height to record as the incentive's creation height.

source

SetCreatedTimestamp

SetCreatedTimestamp sets the created timestamp

Parameters

Name
Type
Description

createdTimestamp

int64

Unix timestamp in seconds to record as the incentive creation time.

source

SetCreator

SetCreator sets the creator address

Parameters

Name
Type
Description

creator

address

Address to record as the incentive creator and refund recipient.

source

SetDepositGnsAmount

SetDepositGnsAmount sets the deposit GNS amount

Parameters

Name
Type
Description

depositGnsAmount

int64

GNS amount deposited to back this external incentive.

source

SetDistributedRewardAmount

SetDistributedRewardAmount sets the distributed reward amount

Parameters

Name
Type
Description

distributedRewardAmount

int64

Reward amount delivered to positions or refunded at incentive end.

source

SetEndTimestamp

SetEndTimestamp sets the end timestamp

Parameters

Name
Type
Description

endTimestamp

int64

Unix timestamp in seconds at which the incentive window ends.

source

SetIncentiveId

SetIncentiveId sets the incentive ID

Parameters

Name
Type
Description

incentiveId

string

Identifier to store on the incentive record.

source

SetRefunded

SetRefunded sets the refunded status

Parameters

Name
Type
Description

refunded

bool

Finalization status to store for the incentive.

source

SetRewardAmount

SetRewardAmount sets the reward amount

Parameters

Name
Type
Description

rewardAmount

int64

Remaining reward amount to store after accounting adjustments.

source

SetRewardPerSecondX128

SetRewardPerSecondX128 sets the Q128-scaled reward per second.

Parameters

Name
Type
Description

rewardPerSecondX128

*u256.Uint

Q128-scaled per-second reward rate; the value is copied before storage.

source

SetRewardToken

SetRewardToken sets the reward token

Parameters

Name
Type
Description

rewardToken

string

Token path of the reward asset distributed by this incentive.

source

SetTargetPoolPath

SetTargetPoolPath sets the target pool path

Parameters

Name
Type
Description

targetPoolPath

string

Pool path to target with this external incentive.

source

SetTotalRewardAmount

SetTotalRewardAmount sets the total reward amount

Parameters

Name
Type
Description

totalRewardAmount

int64

Total reward amount to record for the incentive.

source

SetUnclaimableSeconds

SetUnclaimableSeconds sets the accumulated unclaimable seconds.

Parameters

Name
Type
Description

unclaimableSeconds

int64

Overlapping unclaimable duration in seconds to store.

source

StartTimestamp

StartTimestamp returns the start timestamp.

It keys the byStartTime discovery index and must stay immutable after the incentive is registered, so no setter is exposed.

Return Values

Name
Type
Description

timestamp

int64

Unix timestamp in seconds at which reward distribution starts.

source

TargetPoolPath

TargetPoolPath returns the target pool path

Return Values

Name
Type
Description

path

string

Pool path targeted by this external incentive.

source

TotalRewardAmount

TotalRewardAmount returns the total reward amount

Return Values

Name
Type
Description

amount

int64

Total reward amount configured when the incentive was created.

source

UnclaimableSeconds

UnclaimableSeconds returns the accumulated seconds of unclaimable periods that overlap the incentive window. It is updated whenever an unclaimable period closes and is backfilled once from the historical unclaimable periods tree after an upgrade.

Return Values

Name
Type
Description

seconds

int64

Accumulated seconds of unclaimable periods overlapping the incentive window.

source

Constructors

  • func GetExternalIncentiveByPoolPath(poolPath string) ([]ExternalIncentive, error) (source)

  • func NewExternalIncentive(incentiveId string, targetPoolPath string, rewardToken string, rewardAmount int64, startTimestamp int64, endTimestamp int64, creator address, depositGnsAmount int64, createdHeight int64, currentTime int64) *ExternalIncentive (source)

Incentives

Incentives 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

  • byStartTime: Per-pool start-time index mapping an incentive's start timestamp (key) to the incentive IDs that start at that timestamp (value). This mirrors the lazy-discovery lookup previously served by a global creation-time index, but scoped to this pool's own incentives, so discovery cost is bounded by this pool's incentives instead of growing with the total number of incentives system-wide.

source

Methods

AddIncentiveByStartTime

AddIncentiveByStartTime registers an incentive ID under its start timestamp in the per-pool start-time index. Multiple incentives starting at the same timestamp are accumulated as a list.

Parameters

Name
Type
Description

startTimestamp

int64

Nonnegative Unix timestamp in seconds used as the start-time index key.

incentiveId

string

Incentive identifier to append to that timestamp's bucket.

source

Incentive

Incentive returns an incentive by ID

Parameters

Name
Type
Description

incentiveId

string

Identifier used to look up the external incentive record.

Return Values

Name
Type
Description

incentive

*ExternalIncentive

Matching ExternalIncentive pointer, or nil when no value is stored for incentiveId.

found

bool

True only when the stored value has ExternalIncentive type; false for a missing or mismatched value.

source

IncentiveTrees

Incentives returns the incentives tree

Return Values

Name
Type
Description

tree

*bptree.BPTree

Mutable B+ tree mapping incentive IDs to ExternalIncentive records.

source

IterateIncentiveIdsByTime

IterateIncentiveIdsByTime iterates over the incentive IDs that start within the inclusive [startTime, endTime] range, visiting only the buckets that fall in the range. ReverseIterate is used because it is inclusive on both ends, matching the discovery semantics previously implemented as (startTimestamp >= startTime && startTimestamp <= endTime).

Parameters

Name
Type
Description

startTime

int64

Inclusive lower Unix timestamp bound for incentive starts.

endTime

int64

Inclusive upper Unix timestamp bound for incentive starts.

fn

func(string) bool

Callback receiving each matching incentive ID; returning true requests that iteration stop.

source

IterateIncentives

IterateIncentives iterates over all incentives

Parameters

Name
Type
Description

fn

func(string, *ExternalIncentive) bool

Callback receiving each incentive ID and record; returning true requests that iteration stop.

source

RemoveIncentive

RemoveIncentive deletes an incentive by ID.

Only an incentive that never started may be removed: once rewards begin accruing, deposits and the refund accounting reference the record, so an ended incentive is marked refunded instead of removed.

Parameters

Name
Type
Description

incentiveId

string

Identifier of the external incentive record to remove.

source

RemoveIncentiveByStartTime

RemoveIncentiveByStartTime unregisters an incentive ID from the per-pool start-time index. The bucket itself is dropped once its last ID is removed, so the index never keeps an empty entry that discovery would still visit.

Parameters

Name
Type
Description

startTimestamp

int64

Nonnegative Unix timestamp in seconds identifying the start-time bucket.

incentiveId

string

Incentive identifier to remove from that bucket; all matching entries are omitted.

source

RemoveUnclaimablePeriod

RemoveUnclaimablePeriod removes the interval keyed by its start timestamp.

Parameters

Name
Type
Description

startTimestamp

int64

Nonnegative Unix timestamp in seconds identifying the interval to remove.

source

SetIncentive

SetIncentive sets an incentive by ID

Parameters

Name
Type
Description

incentiveId

string

Identifier under which to store the incentive.

incentive

*ExternalIncentive

ExternalIncentive record to store for incentiveId.

source

SetIncentives

SetIncentives sets the incentives tree

Parameters

Name
Type
Description

incentives

*bptree.BPTree

B+ tree to use for incentive ID lookups and storage.

source

SetTargetPoolPath

SetTargetPoolPath sets the target pool path

Parameters

Name
Type
Description

targetPoolPath

string

Pool path to associate with this incentive collection.

source

SetUnclaimablePeriod

SetUnclaimablePeriod records an interval during which staking rewards cannot be claimed.

Parameters

Name
Type
Description

startTimestamp

int64

Nonnegative Unix timestamp in seconds at which the interval begins.

endTimestamp

int64

Unix timestamp in seconds at which the interval ends; 0 records an ongoing interval.

source

SetUnclaimablePeriods

SetUnclaimablePeriods sets the unclaimable periods tree

Parameters

Name
Type
Description

unclaimablePeriods

*UintTree

Tree of reward-unclaimable intervals keyed by their start timestamps.

source

TargetPoolPath

TargetPoolPath returns the target pool path

Return Values

Name
Type
Description

path

string

Pool path to which this incentive collection belongs.

source

UnclaimablePeriods

UnclaimablePeriods returns the unclaimable periods tree

Return Values

Name
Type
Description

periods

*UintTree

Tree mapping unclaimable-period start timestamps to end timestamps; end 0 denotes an open period.

source

Constructors

  • func NewIncentives(targetPoolPath string) *Incentives (source)

Pool

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.

    • stakedLiquidity: 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 undistributed 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.

source

Methods

Clone

Clone returns a pool copy of the scalar state with a fresh tick container.

Return Values

Name
Type
Description

pool

*Pool

Pool copy carrying scalar state and a fresh tick container; backing trees and incentives are nil, and nil receiver yields nil.

source

GlobalRewardRatioAccumulation

GlobalRewardRatioAccumulation returns the global reward ratio accumulation tree

Return Values

Name
Type
Description

tree

*UintTree

Historical global time-per-total-stake accumulation keyed by Unix timestamp.

source

HistoricalTick

HistoricalTick returns the historical tick tree

Return Values

Name
Type
Description

tree

*UintTree

Historical tick-ID ordering snapshots keyed by Unix timestamp.

source

Incentives

Incentives returns the incentives

Return Values

Name
Type
Description

incentives

*Incentives

External-incentive collection associated with this pool.

source

LastUnclaimableTime

LastUnclaimableTime returns the last unclaimable time

Return Values

Name
Type
Description

timestamp

int64

Unix timestamp in seconds at which the pool entered its current unclaimable period, or 0 when tracking has not started.

source

PoolPath

PoolPath returns the pool path

Return Values

Name
Type
Description

path

string

Pool identifier used to associate this state with a liquidity pool.

source

RewardCache

RewardCache returns the reward cache tree

Return Values

Name
Type
Description

tree

*UintTree

Historical per-second GNS reward cache keyed by Unix timestamp.

source

SetGlobalRewardRatioAccumulation

SetGlobalRewardRatioAccumulation sets the global reward ratio accumulation tree

Parameters

Name
Type
Description

globalRewardRatioAccumulation

*UintTree

Tree of serialized Q128-scaled reward-ratio accumulation snapshots.

source

SetGlobalRewardRatioAccumulationAt

SetGlobalRewardRatioAccumulationAt records a serialized global reward-ratio accumulation snapshot.

Parameters

Name
Type
Description

currentTime

int64

Nonnegative Unix timestamp in seconds used as the snapshot key.

acc

string

Serialized Q128-scaled global reward-ratio accumulation value.

source

SetHistoricalTick

SetHistoricalTick sets the historical tick tree

Parameters

Name
Type
Description

historicalTick

*UintTree

Tree of tick IDs representing the ordering history of staked positions.

source

SetHistoricalTickAt

SetHistoricalTickAt records the tick ordering snapshot for a timestamp.

Parameters

Name
Type
Description

currentTime

int64

Nonnegative Unix timestamp in seconds used as the snapshot key.

tick

int32

Tick ID representing the pool's historical ordering at currentTime.

source

SetIncentives

SetIncentives sets the incentives

Parameters

Name
Type
Description

incentives

*Incentives

External-incentive collection to associate with the pool.

source

SetLastUnclaimableTime

SetLastUnclaimableTime sets the last unclaimable time

Parameters

Name
Type
Description

lastUnclaimableTime

int64

Unix timestamp in seconds marking the start of the current unclaimable period; use 0 when no period is active.

source

SetPoolPath

SetPoolPath sets the pool path

Parameters

Name
Type
Description

poolPath

string

Pool identifier to store.

source

SetRewardCache

SetRewardCache sets the reward cache tree

Parameters

Name
Type
Description

rewardCache

*UintTree

Tree containing the pool's per-second GNS reward snapshots.

source

SetRewardCacheAt

SetRewardCacheAt records the per-second reward rate for a timestamp.

Parameters

Name
Type
Description

currentTime

int64

Nonnegative Unix timestamp in seconds used as the cache key.

reward

int64

GNS reward emitted per second from currentTime until the next cached change.

source

SetStakedLiquidity

SetStakedLiquidity sets the staked liquidity tree

Parameters

Name
Type
Description

stakedLiquidity

*UintTree

Tree of historical total staked liquidity snapshots.

source

SetStakedLiquidityAt

SetStakedLiquidityAt records the current total staked liquidity at a timestamp.

Parameters

Name
Type
Description

currentTime

int64

Nonnegative Unix timestamp in seconds used as the snapshot key.

delta

*u256.Uint

Total staked liquidity at currentTime, stored as a copied Q128-scaled uint value.

source

SetTicks

SetTicks sets the ticks

Parameters

Name
Type
Description

ticks

Ticks

Tick mapping value to store in the pool.

source

SetUnclaimableAcc

SetUnclaimableAcc sets the unclaimable accumulation

Parameters

Name
Type
Description

unclaimableAcc

int64

Accumulated undistributed unclaimable reward amount in the pool's int64 reward units.

source

StakedLiquidity

StakedLiquidity returns the staked liquidity tree

Return Values

Name
Type
Description

tree

*UintTree

Historical staked-liquidity tree keyed by Unix timestamp, with Q128-scaled liquidity values.

source

Ticks

Ticks returns the ticks

Return Values

Name
Type
Description

ticks

*Ticks

Addressable tick mapping for this pool's staked positions.

source

UnclaimableAcc

UnclaimableAcc returns the unclaimable accumulation

Return Values

Name
Type
Description

amount

int64

Accumulated undistributed unclaimable reward amount in the pool's int64 reward units.

source

Constructors

  • func GetPool(poolPath string) (*Pool, error) (source)

  • func NewPool(poolPath string, currentTime int64) *Pool (source)

SwapBatchProcessor

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

source

Methods

AddCross

AddCross appends a tick-cross record to the batch sequence.

Parameters

Name
Type
Description

tickCross

*SwapTickCross

Tick-cross record to append.

source

Crosses

Crosses returns the tick crosses accumulated by this batch.

Return Values

Name
Type
Description

crosses

[]*SwapTickCross

Slice of tick-cross records in the order they were added.

source

IsActive

IsActive reports the processor's stored active flag.

Return Values

Name
Type
Description

active

bool

True when the batch is marked active for the swap lifecycle.

source

LastCross

LastCross returns the most recently appended tick cross.

Return Values

Name
Type
Description

cross

*SwapTickCross

Last tick-cross record, or nil when no crosses have been added.

source

Pool

Pool returns the pool referenced by this swap batch.

Return Values

Name
Type
Description

pool

*Pool

Pool state used to process the accumulated tick crosses.

source

PoolPath

PoolPath returns the pool path associated with this swap batch.

Return Values

Name
Type
Description

path

string

Pool identifier for the swap being processed.

source

SetCrosses

SetCrosses replaces the batch's accumulated tick-cross sequence.

Parameters

Name
Type
Description

crosses

[]*SwapTickCross

Tick-cross records to store as the batch's accumulated sequence.

source

SetIsActive

SetIsActive stores the processor's active lifecycle flag.

Parameters

Name
Type
Description

isActive

bool

Active flag to store for the swap lifecycle.

source

SetPool

SetPool replaces the pool reference used by this swap batch.

Parameters

Name
Type
Description

pool

*Pool

Pool state to reference while processing tick crosses.

source

SetPoolPath

SetPoolPath stores the pool identifier associated with this swap batch.

Parameters

Name
Type
Description

poolPath

string

Pool identifier to associate with the swap batch.

source

SetTimestamp

SetTimestamp stores the swap-start timestamp for this batch.

Parameters

Name
Type
Description

timestamp

int64

Unix timestamp in seconds to record for the swap batch.

source

Timestamp

Timestamp returns the Unix timestamp in seconds recorded when the swap started.

Return Values

Name
Type
Description

timestamp

int64

Swap-start timestamp in Unix seconds.

source

Constructors

  • func NewSwapBatchProcessor(poolPath string, pool *Pool, timestamp int64) *SwapBatchProcessor (source)

SwapTickCross

SwapTickCross 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

source

Methods

Delta

Delta returns the precomputed net staked-liquidity change for the crossed tick.

Return Values

Name
Type
Description

delta

*i256.Int

Signed liquidity delta to apply at the crossed tick.

source

TickID

TickID returns the index of the crossed tick.

Return Values

Name
Type
Description

tickID

int32

Tick index represented by this cross.

source

ZeroForOne

ZeroForOne reports the swap direction represented by this cross.

Return Values

Name
Type
Description

zeroForOne

bool

True for token0-to-token1 swaps; false for token1-to-token0 swaps.

source

Constructors

  • func NewSwapTickCross(tickID int32, zeroForOne bool, delta *i256.Int) *SwapTickCross (source)

Tick

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.

source

Methods

Clone

Clone returns a deep copy of the tick.

Return Values

Name
Type
Description

tick

*Tick

Deep copy of the tick and its outside-accumulation tree, or nil when the receiver is nil.

source

Id

Id returns the tick ID

Return Values

Name
Type
Description

id

int32

Tick index represented by this record.

source

OutsideAccumulation

OutsideAccumulation returns the outside accumulation tree

Return Values

Name
Type
Description

tree

*UintTree

Historical reward-ratio accumulation observed outside this tick.

source

SetId

SetId sets the tick ID

Parameters

Name
Type
Description

id

int32

Tick index to store in the record.

source

SetOutsideAccumulation

SetOutsideAccumulation sets the outside accumulation tree

Parameters

Name
Type
Description

outsideAccumulation

*UintTree

UintTree of outside-accumulation snapshots keyed by Unix timestamp.

source

SetOutsideAccumulationAt

SetOutsideAccumulationAt sets the outside accumulation at the timestamp. SetOutsideAccumulationAt records the Q128-scaled outside accumulation at a timestamp.

Parameters

Name
Type
Description

timestamp

int64

Nonnegative Unix timestamp in seconds used as the snapshot key.

acc

*u256.Uint

Q128-scaled accumulation value encoded into the tree.

source

SetStakedLiquidityDelta

SetStakedLiquidityDelta sets the staked liquidity delta

Parameters

Name
Type
Description

stakedLiquidityDelta

*i256.Int

New net staked liquidity delta; the value is copied before storage.

source

SetStakedLiquidityGross

SetStakedLiquidityGross sets the staked liquidity gross

Parameters

Name
Type
Description

stakedLiquidityGross

*u256.Uint

New total gross staked liquidity; the value is copied before storage.

source

StakedLiquidityDelta

StakedLiquidityDelta returns the staked liquidity delta

Return Values

Name
Type
Description

delta

*i256.Int

Net staked liquidity change associated with this tick.

source

StakedLiquidityGross

StakedLiquidityGross returns the staked liquidity gross

Return Values

Name
Type
Description

liquidity

*u256.Uint

Total gross staked liquidity currently associated with this tick.

source

Constructors

  • func NewTick(tickId int32) *Tick (source)

Ticks

Tick mapping for each pool

source

Methods

Clone

Clone returns a deep copy of ticks.

Return Values

Name
Type
Description

ticks

Ticks

New Ticks value with cloned Tick records in a fresh fanout-16 tree.

source

Get

Get returns the tick for the given tickId, or nil if it does not exist.

Parameters

Name
Type
Description

tickId

int32

Tick index to look up.

Return Values

Name
Type
Description

tick

*Tick

Matching Tick record, or nil when the encoded ID is absent; panics if a stored value has the wrong type.

source

Has

Has reports whether a tick ID is present in the underlying tree.

Parameters

Name
Type
Description

tickId

int32

Tick index whose encoded key is tested.

Return Values

Name
Type
Description

present

bool

True when the encoded tick ID exists in the underlying tree.

source

IterateTicks

IterateTicks iterates over all ticks

Parameters

Name
Type
Description

fn

func(int32, *Tick) bool

Callback receiving each stored Tick and decoded tick ID; returning true requests that iteration stop.

source

SetTick

SetTick sets a tick by ID

Parameters

Name
Type
Description

tickId

int32

Tick index under which to store the record.

tick

*Tick

Non-nil Tick record to store; a zero gross staked liquidity removes the tick instead, while nil input panics during the gross-liquidity check.

source

SetTree

SetTree sets the ticks tree

Parameters

Name
Type
Description

tree

*bptree.BPTree

B+ tree to use for tick storage.

source

Tree

Tree returns the ticks tree

Return Values

Name
Type
Description

tree

*bptree.BPTree

Mutable B+ tree mapping encoded int32 tick IDs to Tick records.

source

Constructors

  • func NewTicks() Ticks (source)

TierRatio

100%, 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

source

Fields

Methods

Get

Get returns the ratio(scaled up by 100) for the given tier.

Parameters

Name
Type
Description

tier

uint64

Tier number to query; only tiers 1, 2, and 3 are supported.

Return Values

Name
Type
Description

ratio

uint64

Requested tier share scaled by 100.

err

error

Non-nil when tier is not 1, 2, or 3; nil for a supported tier.

source

Constructors

  • func NewTierRatio(tier1 uint64, tier2 uint64, tier3 uint64) TierRatio (source)

Last updated