pool.gno
Burn
Burn removes liquidity from a position.
Halt check: reverts while the Withdraw halt scope is active.
Parameters
cur
realm
Current realm context; callers use cross(cur) when crossing into this realm.
token0Path
string
Path of the first token in the pool pair.
token1Path
string
Path of the second token in the pool pair.
fee
uint32
Fee tier identifying the pool.
tickLower
int32
Lower inclusive tick boundary of the position range.
tickUpper
int32
Upper exclusive tick boundary of the position range.
liquidityAmount
string
Decimal liquidity amount to remove from the position.
positionCaller
address
Position-contract address whose position is decreased.
Return Values
amount0
string
Token0 principal credited to the position, as a decimal string; the pool operation leaves it owed until a subsequent collection.
amount1
string
Token1 principal credited to the position, as a decimal string; the pool operation leaves it owed until a subsequent collection.
Collect
Collect pays tokens owed to a position out to recipient in full. No withdrawal fee is charged on this path; see CollectSwapFee for the fee-bearing path.
Halt check: reverts while the Withdraw halt scope is active.
Parameters
cur
realm
Current realm context; callers use cross(cur) when crossing into this realm.
token0Path
string
Path of the first token in the pool pair.
token1Path
string
Path of the second token in the pool pair.
fee
uint32
Fee tier identifying the pool.
recipient
address
Non-zero address receiving the owed token amounts.
tickLower
int32
Lower inclusive tick boundary of the position range.
tickUpper
int32
Upper exclusive tick boundary of the position range.
amount0Requested
string
Decimal token0 amount requested from the position's accrued principal.
amount1Requested
string
Decimal token1 amount requested from the position's accrued principal.
Return Values
amount0
string
Token0 principal transferred to recipient, as a decimal string.
amount1
string
Token1 principal transferred to recipient, as a decimal string.
CollectProtocol
CollectProtocol collects protocol fees from a pool.
Halt check: reverts while the Withdraw halt scope is active.
Parameters
cur
realm
Current realm context; callers use cross(cur) when crossing into this realm.
token0Path
string
Path of the first token in the pool pair.
token1Path
string
Path of the second token in the pool pair.
fee
uint32
Fee tier identifying the pool.
recipient
address
Address receiving the collected protocol fees.
amount0Requested
string
Decimal token0 protocol-fee amount requested; collection is capped at the available amount.
amount1Requested
string
Decimal token1 protocol-fee amount requested; collection is capped at the available amount.
Return Values
amount0
string
Token0 protocol fee transferred to recipient, as a decimal string.
amount1
string
Token1 protocol fee transferred to recipient, as a decimal string.
CollectSwapFee
CollectSwapFee pays accrued swap fees for a position out to recipient, net of the withdrawal fee.
Halt check: reverts while the Withdraw halt scope is active.
Parameters
cur
realm
Current realm context; callers use cross(cur) when crossing into this realm.
token0Path
string
Path of the first token in the pool pair.
token1Path
string
Path of the second token in the pool pair.
fee
uint32
Fee tier identifying the pool.
recipient
address
Non-zero address receiving the collected token amounts after withdrawal-fee deduction.
tickLower
int32
Lower inclusive tick boundary of the position range.
tickUpper
int32
Upper exclusive tick boundary of the position range.
amount0Requested
string
Decimal token0 amount requested; the configured maximum value requests all token0 fees owed.
amount1Requested
string
Decimal token1 amount requested; the configured maximum value requests all token1 fees owed.
Return Values
amount0
string
Collected token0 amount before withdrawal-fee deduction, as a decimal string.
amount1
string
Collected token1 amount before withdrawal-fee deduction, as a decimal string.
fee0
string
Withdrawal fee withheld from token0, as a decimal string.
fee1
string
Withdrawal fee withheld from token1, as a decimal string.
IncreaseObservationCardinalityNext
IncreaseObservationCardinalityNext increases the observation cardinality for a pool.
Halt check: reverts while the Pool halt scope is active.
Parameters
cur
realm
Current realm context; callers use cross(cur) when crossing into this realm.
token0Path
string
Path of the first token in the pool pair.
token1Path
string
Path of the second token in the pool pair.
fee
uint32
Fee tier identifying the pool.
cardinalityNext
uint16
Requested maximum number of oracle observations retained for the pool.
Mint
Mint adds liquidity to a position.
Halt check: reverts while the Pool halt scope is active.
Parameters
cur
realm
Current realm context; callers use cross(cur) when crossing into this realm.
token0Path
string
Path of the first token in the pool pair.
token1Path
string
Path of the second token in the pool pair.
fee
uint32
Fee tier identifying the pool.
tickLower
int32
Lower inclusive tick boundary of the position range.
tickUpper
int32
Upper exclusive tick boundary of the position range.
liquidityAmount
string
Decimal liquidity amount to add to the position.
positionCaller
address
Position-contract address whose position receives the liquidity.
Return Values
amount0
string
Token0 amount required for the liquidity addition, as a decimal string.
amount1
string
Token1 amount required for the liquidity addition, as a decimal string.
NewDefaultFeeAmountTickSpacing
NewDefaultFeeAmountTickSpacing returns the default tick spacing for each supported fee tier.
Return Values
map[uint32]int32
map[uint32]int32
fee-tier to tick-spacing mapping for 100, 500, 3000, and 10000 tiers.
NewPoolPositionsTree
NewPoolPositionsTree creates a BPTree for storing pool position info (fanout 16), owned by the pool domain realm so leaf-slot writes are not readonly tainted.
Return Values
*bptree.BPTree
*bptree.BPTree
empty position storage tree with fanout 16.
NewPoolTicksTree
NewPoolTicksTree creates a BPTree for storing pool tick info (fanout 32), owned by the pool domain realm so leaf-slot writes are not readonly tainted.
Return Values
*bptree.BPTree
*bptree.BPTree
empty tick storage tree with fanout 32.
NewPoolsTree
NewPoolsTree creates the BPTree used to store pools by pool path.
Return Values
*bptree.BPTree
*bptree.BPTree
empty pool storage tree with fanout 32.
Types
Pool
Pool describes a single pool's state. A pool is identified with a unique key (token0, token1, fee), where token0 < token1.
Methods
BalanceToken0
BalanceToken0 returns the pool's current token0 balance.
Return Values
int64
int64
token0 balance available in the pool.
BalanceToken1
BalanceToken1 returns the pool's current token1 balance.
Return Values
int64
int64
token1 balance available in the pool.
Balances
Balances returns the pool's current token balances.
Return Values
TokenPair
TokenPair
token0 and token1 balances tracked by the pool.
Clone
Clone copies a pool's own fields and leaves its collections nil: ticks, tickBitmaps, and positions are not copied. Oracle observations are stored separately from Pool.
The copy is shallow because the read-only pool view clones every entry a caller reads, so copying the collections would walk the whole tick tree for each entry on a page. Read them through their own lookups instead: GetTickInfo / GetInitializedTicksInRange for ticks, GetTickBitmaps for the bitmaps, GetPoolPositions for positions, and GetSlot0 / GetObservationAt for oracle metadata and entries. A caller that needs a working copy of a collection -- DrySwap is the only one -- assembles it from those getters.
Return Values
*Pool
*Pool
shallow pool copy with scalar state and cloned numeric values; nil when the receiver is nil.
DeleteTick
DeleteTick removes the tick state for the given tick index.
Parameters
tick
int32
tick index to remove.
DeleteTickBitmap
DeleteTickBitmap deletes the tick bitmap for the given word position.
Parameters
wordPos
int16
signed bitmap word position to remove.
Fee
Fee returns the pool's fee tier.
Return Values
uint32
uint32
fee tier used by swaps in this pool.
FeeGrowthGlobal0X128
FeeGrowthGlobal0X128 returns cumulative token0 fee growth per unit of liquidity.
Return Values
*u256.Uint
*u256.Uint
token0 fee-growth accumulator scaled by 2^128.
FeeGrowthGlobal1X128
FeeGrowthGlobal1X128 returns cumulative token1 fee growth per unit of liquidity.
Return Values
*u256.Uint
*u256.Uint
token1 fee-growth accumulator scaled by 2^128.
GetPosition
GetPosition returns the position information for key.
Parameters
key
string
encoded lower/upper tick-range key to look up.
Return Values
PositionInfo
PositionInfo
stored aggregate position for the key.
error
error
non-nil when the key is absent or contains a value of the wrong type.
GetTick
GetTick returns the state stored for a tick.
Parameters
tick
int32
tick index to look up.
Return Values
TickInfo
TickInfo
stored tick state.
error
error
non-nil when the tick is absent; a present value of the wrong type causes a panic.
HasTick
HasTick reports whether a tick entry exists in the pool's tick tree.
Parameters
tick
int32
tick index to check.
Return Values
bool
bool
true when the encoded tick is present; false otherwise.
IterateTicks
IterateTicks visits pool ticks in the inclusive range [startTick, endTick]. Iteration stops when the callback returns true.
Parameters
startTick
int32
first tick index in the inclusive range.
endTick
int32
last tick index in the inclusive range.
fn
func(int32, TickInfo) bool
callback receiving each decoded tick and its state; return true to stop iteration.
Liquidity
Liquidity returns the pool's active liquidity for the current tick range.
Return Values
*u256.Uint
*u256.Uint
active liquidity amount.
PoolPath
Pool Getters methods PoolPath returns the canonical pool path derived from token0, token1, and the fee tier.
Return Values
string
string
pool identifier assembled from the pool's token paths and fee.
Positions
Positions returns the tree containing aggregate position state by range key.
Return Values
*bptree.BPTree
*bptree.BPTree
pool position storage tree.
ProtocolFees
ProtocolFees returns protocol fees accrued in both pool tokens.
Return Values
TokenPair
TokenPair
token0 and token1 protocol-fee balances.
ProtocolFeesToken0
ProtocolFeesToken0 returns protocol fees accrued in token0.
Return Values
int64
int64
token0 amount reserved as protocol fees.
ProtocolFeesToken1
ProtocolFeesToken1 returns protocol fees accrued in token1.
Return Values
int64
int64
token1 amount reserved as protocol fees.
SetBalanceToken0
SetBalanceToken0 updates the pool's tracked token0 balance.
Parameters
token0
int64
new token0 balance.
SetBalanceToken1
SetBalanceToken1 updates the pool's tracked token1 balance.
Parameters
token1
int64
new token1 balance.
SetBalances
SetBalances replaces the pool's tracked balances for both tokens.
Parameters
balances
TokenPair
token0 and token1 balances to store.
SetFee
SetFee stores the pool's fee tier.
Parameters
fee
uint32
fee tier to use for swaps in this pool.
SetFeeGrowthGlobal0X128
SetFeeGrowthGlobal0X128 stores the token0 fee-growth accumulator.
Parameters
feeGrowthGlobal0X128
*u256.Uint
token0 fee growth per liquidity unit, scaled by 2^128.
SetFeeGrowthGlobal1X128
SetFeeGrowthGlobal1X128 stores the token1 fee-growth accumulator.
Parameters
feeGrowthGlobal1X128
*u256.Uint
token1 fee growth per liquidity unit, scaled by 2^128.
SetLiquidity
SetLiquidity stores the pool's active liquidity for the current tick range.
Parameters
liquidity
*u256.Uint
active liquidity amount to store.
SetPosition
SetPosition stores position information under an encoded range key.
Parameters
posKey
string
encoded lower/upper tick-range key.
positionInfo
PositionInfo
aggregate position state to store.
SetPositions
SetPositions replaces the tree containing aggregate position state.
Parameters
positions
*bptree.BPTree
position storage tree to use.
SetProtocolFees
SetProtocolFees replaces the pool's accrued protocol fees for both tokens.
Parameters
protocolFees
TokenPair
token0 and token1 protocol-fee balances to store.
SetProtocolFeesToken0
SetProtocolFeesToken0 updates the pool's accrued token0 protocol fees.
Parameters
token0
int64
new token0 protocol-fee balance.
SetProtocolFeesToken1
SetProtocolFeesToken1 updates the pool's accrued token1 protocol fees.
Parameters
token1
int64
new token1 protocol-fee balance.
SetSlot0
SetSlot0 replaces the pool's current price, tick, lock, and oracle cursor state.
Parameters
slot0
Slot0
slot0 state to store.
SetTick
SetTick stores tick state under its encoded tick key.
Parameters
tick
int32
tick index to store.
tickInfo
TickInfo
tick state associated with the index.
SetTickBitmap
SetTickBitmap stores one initialized-tick bitmap word.
Parameters
wordPos
int16
signed bitmap word position.
tickBitmap
string
encoded bitmap bits for that word.
SetTickBitmaps
SetTickBitmaps replaces the map of initialized-tick bitmap words.
Parameters
tickBitmaps
map[int16]string
bitmap words keyed by signed word position.
SetTickSpacing
SetTickSpacing stores the permitted spacing between initialized ticks.
Parameters
tickSpacing
int32
tick spacing to configure for the pool.
SetTicks
SetTicks replaces the tree containing pool tick state.
Parameters
ticks
*bptree.BPTree
tick storage tree to use.
SetToken0Path
Pool Setters methods SetToken0Path stores the path of the pool's token0 asset.
Parameters
token0Path
string
token0 asset path to store.
SetToken1Path
SetToken1Path stores the path of the pool's token1 asset.
Parameters
token1Path
string
token1 asset path to store.
Slot0
Slot0 returns the pool's current price, tick, lock, and oracle cursor state.
Return Values
Slot0
Slot0
current slot0 state, including the price and observation metadata.
Slot0FeeProtocol
Slot0FeeProtocol returns the packed protocol-fee denominators from slot0.
Return Values
uint8
uint8
packed token0/token1 protocol-fee denominator configuration.
Slot0SqrtPriceX96
Slot0SqrtPriceX96 returns the current square-root price in Q96 fixed-point form.
Return Values
*u256.Uint
*u256.Uint
stored sqrt(token1/token0) price scaled by 2^96.
Slot0Tick
Slot0Tick returns the current pool tick.
Return Values
int32
int32
tick corresponding to the current pool price.
Slot0Unlocked
Slot0Unlocked reports whether the pool is currently available for reentrant operations.
Return Values
bool
bool
true when the pool is unlocked; false while its swap lock is held.
TickBitmaps
TickBitmaps returns the map of initialized-tick bitmap words.
Return Values
map[int16]string
map[int16]string
bitmap words keyed by signed word position.
TickSpacing
TickSpacing returns the permitted spacing between initialized ticks.
Return Values
int32
int32
tick spacing configured for the pool.
Ticks
Ticks returns the tree containing tick state keyed by encoded tick.
Return Values
*bptree.BPTree
*bptree.BPTree
pool tick storage tree.
Token0Path
Token0Path returns the path of the pool's token0 asset.
Return Values
string
string
token0 path stored in the pool.
Token1Path
Token1Path returns the path of the pool's token1 asset.
Return Values
string
string
token1 path stored in the pool.
Constructors
func NewPool(token0Path string, token1Path string, fee uint32, sqrtPriceX96 *u256.Uint, tickSpacing int32, tick int32, slot0FeeProtocol uint8) *Pool(source)
PositionInfo
PositionInfo stores aggregate liquidity, fee-growth checkpoints, and tokens owed for one pool-scoped lower/upper tick key.
Methods
FeeGrowthInside0LastX128
FeeGrowthInside0LastX128 returns the token0 fee-growth checkpoint for this position.
Return Values
string
string
token0 inside fee-growth checkpoint scaled by 2^128.
FeeGrowthInside1LastX128
FeeGrowthInside1LastX128 returns the token1 fee-growth checkpoint for this position.
Return Values
string
string
token1 inside fee-growth checkpoint scaled by 2^128.
Liquidity
Liquidity returns aggregate liquidity for this position range.
Return Values
string
string
position liquidity encoded as a decimal string.
SetFeeGrowthInside0LastX128
SetFeeGrowthInside0LastX128 updates the token0 fee-growth checkpoint.
Parameters
feeGrowthInside0LastX128
string
token0 inside fee-growth checkpoint scaled by 2^128, encoded as a decimal string.
SetFeeGrowthInside1LastX128
SetFeeGrowthInside1LastX128 updates the token1 fee-growth checkpoint.
Parameters
feeGrowthInside1LastX128
string
token1 inside fee-growth checkpoint scaled by 2^128, encoded as a decimal string.
SetLiquidity
SetLiquidity updates aggregate liquidity for this position range.
Parameters
liquidity
string
position liquidity encoded as a decimal string.
SetTokensOwed0
SetTokensOwed0 updates token0 accumulated for this position.
Parameters
tokensOwed0
int64
token0 principal or fee amount awaiting collection.
SetTokensOwed1
SetTokensOwed1 updates token1 accumulated for this position.
Parameters
tokensOwed1
int64
token1 principal or fee amount awaiting collection.
TokensOwed0
TokensOwed0 returns token0 accumulated for this position.
Return Values
int64
int64
token0 principal or fee amount awaiting collection.
TokensOwed1
TokensOwed1 returns token1 accumulated for this position.
Return Values
int64
int64
token1 principal or fee amount awaiting collection.
Constructors
Slot0
Slot0 mirrors Uniswap V3's slot0(): current price/tick/protocol-fee/lock state and the oracle cursor/capacity metadata.
Methods
Clone
Clone returns a value-type copy of Slot0 that shares no mutable state with the original, so callers cannot reach back into pool internals through the returned sqrtPriceX96 pointer.
Return Values
Slot0
Slot0
value copy with a cloned sqrt-price pointer.
FeeProtocol
FeeProtocol returns the packed protocol-fee denominators in slot0.
Return Values
uint8
uint8
packed token0/token1 protocol-fee denominator configuration.
ObservationCardinality
ObservationCardinality returns the number of observation slots currently available.
Return Values
uint16
uint16
current observation capacity.
ObservationCardinalityNext
ObservationCardinalityNext returns the requested future observation capacity.
Return Values
uint16
uint16
next observation capacity to use when the ring grows.
ObservationIndex
ObservationIndex returns the index of the most recently written observation.
Return Values
uint16
uint16
current observation ring-buffer index.
SetFeeProtocol
SetFeeProtocol updates the packed slot0 protocol-fee denominators.
Parameters
feeProtocol
uint8
packed token0/token1 protocol-fee denominator configuration.
SetObservationCardinality
SetObservationCardinality updates the current observation capacity.
Parameters
observationCardinality
uint16
current number of observation slots available.
SetObservationCardinalityNext
SetObservationCardinalityNext updates the requested future observation capacity.
Parameters
observationCardinalityNext
uint16
next capacity to use when the ring grows.
SetObservationIndex
SetObservationIndex updates the index of the most recently written observation.
Parameters
observationIndex
uint16
observation ring-buffer index to store.
SetSqrtPriceX96
SetSqrtPriceX96 updates the slot0 sqrt price.
Parameters
sqrtPriceX96
*u256.Uint
sqrt(token1/token0) price scaled by 2^96; it is cloned before storage.
SetTick
SetTick updates the current slot0 tick.
Parameters
tick
int32
current pool tick to store.
SetUnlocked
SetUnlocked updates the slot0 reentrancy-lock state.
Parameters
unlocked
bool
true to mark the pool unlocked, false to mark it locked.
SqrtPriceX96
SqrtPriceX96 returns a copy of the current sqrt price in Q96 fixed-point form.
Return Values
*u256.Uint
*u256.Uint
cloned sqrt(token1/token0) price scaled by 2^96.
Tick
Tick returns the current pool tick recorded in slot0.
Return Values
int32
int32
current tick.
Unlocked
Unlocked reports whether the pool's reentrancy lock is open.
Return Values
bool
bool
true when unlocked and false while the pool is locked.
Constructors
func GetSlot0(poolPath string) Slot0(source)func NewSlot0(sqrtPriceX96 *u256.Uint, tick int32, feeProtocol uint8, unlocked bool) Slot0(source)
TickInfo
TickInfo stores information about a specific tick in the pool. TIcks represent discrete price points that can be used as boundaries for positions.
Methods
Clone
Clone returns an independent value copy of this tick's stored state.
Return Values
TickInfo
TickInfo
copied liquidity, fee-growth, time, and initialization fields.
FeeGrowthOutside0X128
FeeGrowthOutside0X128 returns token0 fee growth on the side of this tick opposite the current tick.
Return Values
string
string
token0 outside fee-growth accumulator scaled by 2^128.
FeeGrowthOutside1X128
FeeGrowthOutside1X128 returns token1 fee growth on the side of this tick opposite the current tick.
Return Values
string
string
token1 outside fee-growth accumulator scaled by 2^128.
Initialized
Initialized reports whether this tick has active initialized state.
Return Values
bool
bool
true when the tick is initialized; false otherwise.
LiquidityGross
TickInfo Getters methods LiquidityGross returns total position liquidity referencing this tick.
Return Values
string
string
gross liquidity encoded as a decimal string.
LiquidityNet
LiquidityNet returns net liquidity applied when this tick is crossed.
Return Values
string
string
signed net liquidity encoded as a decimal string.
SecondsOutside
SecondsOutside returns the time spent on the side of this tick opposite the current tick.
Return Values
uint32
uint32
seconds accumulated outside the tick.
SecondsPerLiquidityOutsideX128
SecondsPerLiquidityOutsideX128 returns seconds per liquidity outside this tick.
Return Values
string
string
outside seconds-per-liquidity accumulator scaled by 2^128.
SetFeeGrowthOutside0X128
SetFeeGrowthOutside0X128 stores token0 outside fee growth for this tick.
Parameters
feeGrowthOutside0X128
string
token0 outside fee growth scaled by 2^128, encoded as a decimal string.
SetFeeGrowthOutside1X128
SetFeeGrowthOutside1X128 stores token1 outside fee growth for this tick.
Parameters
feeGrowthOutside1X128
string
token1 outside fee growth scaled by 2^128, encoded as a decimal string.
SetInitialized
SetInitialized updates whether this tick is initialized.
Parameters
initialized
bool
true to mark the tick initialized, false otherwise.
SetLiquidityGross
TickInfo Setters methods SetLiquidityGross stores total position liquidity referencing this tick.
Parameters
liquidityGross
string
gross liquidity encoded as a decimal string.
SetLiquidityNet
SetLiquidityNet stores the net liquidity change applied when crossing this tick.
Parameters
liquidityNet
string
signed net liquidity encoded as a decimal string.
SetSecondsOutside
SetSecondsOutside stores the seconds accumulated outside this tick.
Parameters
secondsOutside
uint32
elapsed seconds outside the tick.
SetSecondsPerLiquidityOutsideX128
SetSecondsPerLiquidityOutsideX128 stores outside seconds-per-liquidity growth.
Parameters
secondsPerLiquidityOutsideX128
string
outside seconds per liquidity scaled by 2^128, encoded as a decimal string.
SetTickCumulativeOutside
SetTickCumulativeOutside stores cumulative tick value outside this tick.
Parameters
tickCumulativeOutside
int64
cumulative tick value on the opposite side.
TickCumulativeOutside
TickCumulativeOutside returns cumulative tick value on the side opposite the current tick.
Return Values
int64
int64
outside cumulative tick value.
Constructors
func GetTickInfo(poolPath string, tick int32) (TickInfo, error)(source)func NewTickInfo() TickInfo(source)
TokenPair
Methods
SetToken0
SetToken0 updates the token0 amount in the pair.
Parameters
token0
int64
token0 amount to store.
SetToken1
SetToken1 updates the token1 amount in the pair.
Parameters
token1
int64
token1 amount to store.
Token0
Token0 returns the token0 amount in the pair.
Return Values
int64
int64
stored token0 amount.
Token1
Token1 returns the token1 amount in the pair.
Return Values
int64
int64
stored token1 amount.
Constructors
func NewTokenPair() TokenPair(source)
Last updated