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

pool package

Functions

Burn

func Burn( cur realm, token0Path string, token1Path string, fee uint32, tickLower int32, tickUpper int32, liquidityAmount string, positionCaller address, ) (string, string)

Burn removes liquidity from a position.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • tickLower: Lower inclusive tick boundary of the position range.
  • tickUpper: Upper exclusive tick boundary of the position range.
  • liquidityAmount: Decimal liquidity amount to remove from the position.
  • positionCaller: Position-contract address whose position is decreased.

Returns:

  • amount0: Token0 principal credited to the position, as a decimal string; the pool operation leaves it owed until a subsequent collection.
  • amount1: Token1 principal credited to the position, as a decimal string; the pool operation leaves it owed until a subsequent collection.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Burn" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Burn" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Collect

func Collect( cur realm, token0Path string, token1Path string, fee uint32, recipient address, tickLower int32, tickUpper int32, amount0Requested string, amount1Requested string, ) (string, string)

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.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • recipient: Non-zero address receiving the owed token amounts.
  • tickLower: Lower inclusive tick boundary of the position range.
  • tickUpper: Upper exclusive tick boundary of the position range.
  • amount0Requested: Decimal token0 amount requested from the position's accrued principal.
  • amount1Requested: Decimal token1 amount requested from the position's accrued principal.

Returns:

  • amount0: Token0 principal transferred to recipient, as a decimal string.
  • amount1: Token1 principal transferred to recipient, as a decimal string.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Collect" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Collect" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

CollectProtocol

func CollectProtocol( cur realm, token0Path string, token1Path string, fee uint32, recipient address, amount0Requested string, amount1Requested string, ) (string, string)

CollectProtocol collects protocol fees from a pool.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • recipient: Address receiving the collected protocol fees.
  • amount0Requested: Decimal token0 protocol-fee amount requested; collection is capped at the available amount.
  • amount1Requested: Decimal token1 protocol-fee amount requested; collection is capped at the available amount.

Returns:

  • amount0: Token0 protocol fee transferred to recipient, as a decimal string.
  • amount1: Token1 protocol fee transferred to recipient, as a decimal string.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "CollectProtocol" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "CollectProtocol" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

CollectSwapFee

func CollectSwapFee( cur realm, token0Path string, token1Path string, fee uint32, recipient address, tickLower int32, tickUpper int32, amount0Requested string, amount1Requested string, ) (amount0, amount1, fee0, fee1 string)

CollectSwapFee pays accrued swap fees for a position out to recipient, net of the withdrawal fee.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • recipient: Non-zero address receiving the collected token amounts after withdrawal-fee deduction.
  • tickLower: Lower inclusive tick boundary of the position range.
  • tickUpper: Upper exclusive tick boundary of the position range.
  • amount0Requested: Decimal token0 amount requested; the configured maximum value requests all token0 fees owed.
  • amount1Requested: Decimal token1 amount requested; the configured maximum value requests all token1 fees owed.

Returns:

  • amount0: Collected token0 amount before withdrawal-fee deduction, as a decimal string.
  • amount1: Collected token1 amount before withdrawal-fee deduction, as a decimal string.
  • fee0: Withdrawal fee withheld from token0, as a decimal string.
  • fee1: Withdrawal fee withheld from token1, as a decimal string.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "CollectSwapFee" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "CollectSwapFee" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

CreatePool

func CreatePool( cur realm, token0Path string, token1Path string, fee uint32, sqrtPriceX96 string, )

CreatePool creates a new liquidity pool for a token pair.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Token contract path supplied for token0; the pool orders the pair canonically rather than preserving the supplied order.
  • token1Path: Token contract path supplied for token1; must form a distinct registered pair with token0Path.
  • fee: Fee tier for the pool; determines its tick spacing and swap fee.
  • sqrtPriceX96: Initial square-root price in Q64.96 fixed-point form; it is inverted when the supplied token order is reversed and must be in bounds.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "CreatePool" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "CreatePool" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

DecodeTickKey

func DecodeTickKey(key string) int32

DecodeTickKey decodes a fixed-width ordered tick key. Parameters:

  • key: fixed-width ordered tick key produced by EncodeTickKey.

Returns:

  • tick: signed tick index decoded from key.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.DecodeTickKey()"

Result

DrySwap

func DrySwap( token0Path string, token1Path string, fee uint32, zeroForOne bool, amountSpecified string, sqrtPriceLimitX96 string, ) (string, string, error)

DrySwap simulates a swap without executing it, returning the expected output.

This is a read-only operation that does not modify pool state. Used by router for multi-hop swap simulations and by clients for price quotes.

Parameters:

  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • zeroForOne: True to sell token0 for token1; false to sell token1 for token0.
  • amountSpecified: Decimal signed amount; positive requests exact input and negative requests exact output.
  • sqrtPriceLimitX96: Price boundary in Q64.96 fixed-point form at which the simulation must stop.

Returns:

  • amount0: Simulated signed token0 delta, as a decimal string; "0" on an unsuccessful simulation.
  • amount1: Simulated signed token1 delta, as a decimal string; "0" on an unsuccessful simulation.
  • error: Nil when the simulation succeeds; non-nil when validation, computation, or pool-balance checks fail.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.DrySwap(,,,,,)"

Result

EncodePositionKey

func EncodePositionKey(tickLower, tickUpper int32) string

EncodePositionKey encodes a position range as two ordered tick keys. Parameters:

  • tickLower: lower signed tick index of the position range.
  • tickUpper: upper signed tick index of the position range.

Returns:

  • key: concatenation of the ordered encodings of tickLower and tickUpper.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.EncodePositionKey(,)"

Result

EncodeTickKey

func EncodeTickKey(tick int32) string

EncodeTickKey encodes a tick as a fixed-width 4-byte key whose lexicographic order matches the signed numeric order. Parameters:

  • tick: signed tick index to encode.

Returns:

  • key: fixed-width ordered key whose lexicographical ordering matches the signed numeric ordering of tick.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.EncodeTickKey()"

Result

ExistsPoolPath

func ExistsPoolPath(poolPath string) bool

ExistsPoolPath checks if a pool exists at the given path. Parameters:

  • poolPath: Canonical pool path identifying the pool to check.

Returns:

  • bool: True when a pool is registered at poolPath; false otherwise.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.ExistsPoolPath()"

Result

GetBalanceToken0

func GetBalanceToken0(poolPath string) (int64, error)

GetBalanceToken0 returns the balance of token0 in the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • int64: Current token0 balance held by the pool, in token base units.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetBalanceToken0()"

Result

GetBalanceToken1

func GetBalanceToken1(poolPath string) (int64, error)

GetBalanceToken1 returns the balance of token1 in the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • int64: Current token1 balance held by the pool, in token base units.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetBalanceToken1()"

Result

GetBalances

func GetBalances(poolPath string) (int64, int64, error)

GetBalances returns the balances of the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool whose balances are read.

Returns:

  • int64: Current token0 balance held by the pool, in token base units.
  • int64: Current token1 balance held by the pool, in token base units.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetBalances()"

Result

GetFee

func GetFee(poolPath string) (uint32, error)

GetFee returns the fee tier of the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool whose fee tier is read.

Returns:

  • uint32: Configured fee tier for the pool.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetFee()"

Result

GetFeeAmountTickSpacing

func GetFeeAmountTickSpacing(fee uint32) (spacing int32, err error)

GetFeeAmountTickSpacing returns the tick spacing for a given fee tier. Parameters:

  • fee: Fee tier whose supported tick spacing is requested.

Returns:

  • spacing: Tick spacing configured for fee.
  • err: Non-nil when fee is not one of the supported fee tiers.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetFeeAmountTickSpacing()"

Result

GetFeeAmountTickSpacings

func GetFeeAmountTickSpacings() map[uint32]int32

GetFeeAmountTickSpacings returns all fee tier to tick spacing mappings. Returns:

  • map[uint32]int32: Copy of the configured fee-tier-to-tick-spacing mapping.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetFeeAmountTickSpacings()"

Result

GetFeeGrowthGlobal0X128

func GetFeeGrowthGlobal0X128(poolPath string) (string, error)

GetFeeGrowthGlobal0X128 returns the global fee growth for token0. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • string: Token0 global fee growth, serialized as a base-10 X128 accumulator.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetFeeGrowthGlobal0X128()"

Result

GetFeeGrowthGlobal1X128

func GetFeeGrowthGlobal1X128(poolPath string) (string, error)

GetFeeGrowthGlobal1X128 returns the global fee growth for token1. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • string: Token1 global fee growth, serialized as a base-10 X128 accumulator.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetFeeGrowthGlobal1X128()"

Result

GetFeeGrowthGlobalX128

func GetFeeGrowthGlobalX128(poolPath string) (string, string, error)

GetFeeGrowthGlobalX128 returns the global fee growth for both tokens. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • string: Token0 global fee growth, serialized as a base-10 X128 accumulator.
  • string: Token1 global fee growth, serialized as a base-10 X128 accumulator.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetFeeGrowthGlobalX128()"

Result

GetImplementationPackagePath

func GetImplementationPackagePath() string

GetImplementationPackagePath returns the package path of the currently active implementation.

Returns:

  • packagePath: Full package path of the active implementation; empty before any version has been registered.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetImplementationPackagePath()"

Result

GetInitializedTicksInRange

func GetInitializedTicksInRange(poolPath string, tickLower, tickUpper int32) ([]int32, error)

GetInitializedTicksInRange returns initialized ticks within the given range. Parameters:

  • poolPath: Canonical pool path whose ticks are enumerated.
  • tickLower: Lower inclusive tick bound for enumeration.
  • tickUpper: Upper bound for enumeration; ticks are selected through the pool's range iterator.

Returns:

  • []int32: Tick indices that are initialized in the requested range.
  • error: Non-nil when poolPath does not identify an existing pool.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetInitializedTicksInRange(,,)"

Result

GetLiquidity

func GetLiquidity(poolPath string) (string, error)

GetLiquidity returns the current liquidity in the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool whose liquidity is read.

Returns:

  • string: Current pool liquidity, serialized as a base-10 unsigned integer.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetLiquidity()"

Result

GetPendingProtocolFees

func GetPendingProtocolFees() map[string]int64

GetPendingProtocolFees returns the pending protocol fee amount per token path. Returns:

  • map[string]int64: Copy of pending protocol fees keyed by token contract path, with amounts in token base units.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPendingProtocolFees()"

Result

GetPoolCreationFee

func GetPoolCreationFee() int64

GetPoolCreationFee returns the current pool creation fee. Returns:

  • int64: Pool creation fee charged when a new pool is created, in configured native-token base units.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPoolCreationFee()"

Result

GetPoolPath

func GetPoolPath(token0Path, token1Path string, fee uint32) string

GetPoolPath generates a unique pool path string based on the token paths and fee tier. Parameters:

  • token0Path: path of the first token contract; it is reordered with token1Path when needed to form canonical pool order.
  • token1Path: path of the second token contract; it is reordered with token0Path when it sorts earlier.
  • fee: pool fee tier encoded as its decimal uint32 value in the path.

Returns:

  • poolPath: canonical token0:token1:fee identifier with token paths in lexicographical order.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPoolPath(,,)"

Result

GetPoolPositions

func GetPoolPositions(poolPath string) *rotree.ReadOnlyTree

GetPoolPositions returns a read-only view of a pool's positions, keyed by position key. nil is returned when the pool does not exist. Parameters:

  • poolPath: Canonical pool path identifying the pool whose positions are read.

Returns:

  • *rotree.ReadOnlyTree: Read-only tree keyed by position key; nil when the pool does not exist.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPoolPositions()"

Result

GetPools

func GetPools() *rotree.ReadOnlyTree

GetPools returns a read-only view of every pool, keyed by pool path. Reading an entry yields a clone, so the view cannot mutate realm state. Returns:

  • *rotree.ReadOnlyTree: Read-only tree keyed by canonical pool path; each entry is cloned before it is exposed.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPools()"

Result

GetPositionFeeGrowthInside0LastX128

func GetPositionFeeGrowthInside0LastX128(poolPath, key string) (string, error)

GetPositionFeeGrowthInside0LastX128 returns the last recorded fee growth inside for token0. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the position.
  • key: Position key identifying the position within the pool.

Returns:

  • string: Position's last token0 fee-growth-inside accumulator, serialized as a base-10 X128 value.
  • error: Non-nil when the pool or position key cannot be found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPositionFeeGrowthInside0LastX128(,)"

Result

GetPositionFeeGrowthInside1LastX128

func GetPositionFeeGrowthInside1LastX128(poolPath, key string) (string, error)

GetPositionFeeGrowthInside1LastX128 returns the last recorded fee growth inside for token1. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the position.
  • key: Position key identifying the position within the pool.

Returns:

  • string: Position's last token1 fee-growth-inside accumulator, serialized as a base-10 X128 value.
  • error: Non-nil when the pool or position key cannot be found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPositionFeeGrowthInside1LastX128(,)"

Result

GetPositionFeeGrowthInsideLastX128

func GetPositionFeeGrowthInsideLastX128(poolPath, key string) (string, string, error)

GetPositionFeeGrowthInsideLastX128 returns the last recorded fee growth inside for both tokens. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the position.
  • key: Position key identifying the position within the pool.

Returns:

  • string: Position's last token0 fee-growth-inside accumulator, serialized as a base-10 X128 value.
  • string: Position's last token1 fee-growth-inside accumulator, serialized as a base-10 X128 value.
  • error: Non-nil when the pool or position key cannot be found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPositionFeeGrowthInsideLastX128(,)"

Result

GetPositionLiquidity

func GetPositionLiquidity(poolPath, key string) (string, error)

GetPositionLiquidity returns the liquidity of a position. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the position.
  • key: Position key identifying the position within the pool.

Returns:

  • string: Position liquidity, serialized as a base-10 unsigned integer.
  • error: Non-nil when the pool or position key cannot be found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPositionLiquidity(,)"

Result

GetPositionTokensOwed

func GetPositionTokensOwed(poolPath, key string) (int64, int64, error)

GetPositionTokensOwedInfos returns the amount of tokens owed for both tokens. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the position.
  • key: Position key identifying the position within the pool.

Returns:

  • int64: Amount of token0 owed to the position, in token base units.
  • int64: Amount of token1 owed to the position, in token base units.
  • error: Non-nil when the pool or position key cannot be found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPositionTokensOwed(,)"

Result

GetPositionTokensOwed0

func GetPositionTokensOwed0(poolPath, key string) (int64, error)

GetPositionTokensOwed0 returns the amount of token0 owed to a position. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the position.
  • key: Position key identifying the position within the pool.

Returns:

  • int64: Amount of token0 owed to the position, in token base units.
  • error: Non-nil when the pool or position key cannot be found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPositionTokensOwed0(,)"

Result

GetPositionTokensOwed1

func GetPositionTokensOwed1(poolPath, key string) (int64, error)

GetPositionTokensOwed1 returns the amount of token1 owed to a position. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the position.
  • key: Position key identifying the position within the pool.

Returns:

  • int64: Amount of token1 owed to the position, in token base units.
  • error: Non-nil when the pool or position key cannot be found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetPositionTokensOwed1(,)"

Result

GetProtocolFeesToken0

func GetProtocolFeesToken0(poolPath string) (int64, error)

GetProtocolFeesToken0 returns accumulated protocol fees for token0. Parameters:

  • poolPath: Canonical pool path identifying the pool whose fees are read.

Returns:

  • int64: Accumulated protocol fee for token0, in token base units.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetProtocolFeesToken0()"

Result

GetProtocolFeesToken1

func GetProtocolFeesToken1(poolPath string) (int64, error)

GetProtocolFeesToken1 returns accumulated protocol fees for token1. Parameters:

  • poolPath: Canonical pool path identifying the pool whose fees are read.

Returns:

  • int64: Accumulated protocol fee for token1, in token base units.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetProtocolFeesToken1()"

Result

GetProtocolFeesTokens

func GetProtocolFeesTokens(poolPath string) (int64, int64, error)

GetProtocolFeesTokens returns the accumulated protocol fees for both tokens. Parameters:

  • poolPath: Canonical pool path identifying the pool whose fees are read.

Returns:

  • int64: Accumulated protocol fee for token0, in token base units.
  • int64: Accumulated protocol fee for token1, in token base units.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetProtocolFeesTokens()"

Result

GetSlot0FeeProtocol

func GetSlot0FeeProtocol(poolPath string) (uint8, error)

GetSlot0FeeProtocol returns the protocol fee rate from slot0. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • uint8: Packed protocol-fee denominator configuration from slot0; token0 occupies the low nibble and token1 the high nibble.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetSlot0FeeProtocol()"

Result

GetSlot0SqrtPriceX96

func GetSlot0SqrtPriceX96(poolPath string) (string, error)

GetSlot0SqrtPriceX96 returns the current sqrt price from slot0. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • string: Current square-root price in Q64.96 fixed-point form, serialized as a base-10 unsigned integer.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetSlot0SqrtPriceX96()"

Result

GetSlot0Tick

func GetSlot0Tick(poolPath string) (int32, error)

GetSlot0Tick returns the current tick from slot0. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • int32: Current active tick index stored in slot0.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetSlot0Tick()"

Result

GetSlot0Unlocked

func GetSlot0Unlocked(poolPath string) (bool, error)

GetSlot0Unlocked reports whether the pool is currently unlocked. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • bool: True when the pool is not holding its reentrancy lock; false when the pool is currently locked.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetSlot0Unlocked()"

Result

GetTickBitmaps

func GetTickBitmaps(poolPath string, wordPos int16) (string, error)

GetTickBitmaps returns the tick bitmap for a given word position. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the bitmap.
  • wordPos: Signed bitmap word position to read.

Returns:

  • string: Bitmap word serialized as a base-10 unsigned integer.
  • error: Non-nil when the pool or bitmap word is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickBitmaps(,)"

Result

GetTickCumulativeOutside

func GetTickCumulativeOutside(poolPath string, tick int32) (int64, error)

GetTickCumulativeOutside returns the tick cumulative value outside a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose outside tick cumulative is requested.

Returns:

  • int64: Tick cumulative recorded outside tick.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickCumulativeOutside(,)"

Result

GetTickFeeGrowthOutside0X128

func GetTickFeeGrowthOutside0X128(poolPath string, tick int32) (string, error)

GetTickFeeGrowthOutside0X128 returns fee growth outside for token0 at a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose outside fee growth is requested.

Returns:

  • string: Token0 fee growth outside tick, serialized as a base-10 X128 accumulator.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickFeeGrowthOutside0X128(,)"

Result

GetTickFeeGrowthOutside1X128

func GetTickFeeGrowthOutside1X128(poolPath string, tick int32) (string, error)

GetTickFeeGrowthOutside1X128 returns fee growth outside for token1 at a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose outside fee growth is requested.

Returns:

  • string: Token1 fee growth outside tick, serialized as a base-10 X128 accumulator.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickFeeGrowthOutside1X128(,)"

Result

GetTickFeeGrowthOutsideX128

func GetTickFeeGrowthOutsideX128(poolPath string, tick int32) (string, string, error)

GetTickFeeGrowthOutsideX128 returns fee growth outside for both tokens at a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose outside fee growth is requested.

Returns:

  • string: Token0 fee growth outside tick, serialized as a base-10 X128 accumulator.
  • string: Token1 fee growth outside tick, serialized as a base-10 X128 accumulator.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickFeeGrowthOutsideX128(,)"

Result

GetTickInitialized

func GetTickInitialized(poolPath string, tick int32) (bool, error)

GetTickInitialized returns whether a tick is initialized. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose initialization flag is requested.

Returns:

  • bool: True when the tick has initialized liquidity and outside accumulators.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickInitialized(,)"

Result

GetTickLiquidityGross

func GetTickLiquidityGross(poolPath string, tick int32) (string, error)

GetTickLiquidityGross returns the total liquidity that references a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose gross liquidity is requested.

Returns:

  • string: Gross liquidity referencing the tick, serialized as a base-10 unsigned integer.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickLiquidityGross(,)"

Result

GetTickLiquidityNet

func GetTickLiquidityNet(poolPath string, tick int32) (string, error)

GetTickLiquidityNet returns the net liquidity change at a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose net liquidity change is requested.

Returns:

  • string: Signed net liquidity change at the tick, serialized as a base-10 integer.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickLiquidityNet(,)"

Result

GetTickSecondsOutside

func GetTickSecondsOutside(poolPath string, tick int32) (uint32, error)

GetTickSecondsOutside returns seconds spent outside a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose outside time is requested.

Returns:

  • uint32: Seconds accumulated outside the tick.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickSecondsOutside(,)"

Result

GetTickSecondsPerLiquidityOutsideX128

func GetTickSecondsPerLiquidityOutsideX128(poolPath string, tick int32) (string, error)

GetTickSecondsPerLiquidityOutsideX128 returns seconds per liquidity outside a tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose outside accumulator is requested.

Returns:

  • string: Seconds-per-liquidity outside tick in X128 precision, serialized as a base-10 unsigned integer.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickSecondsPerLiquidityOutsideX128(,)"

Result

GetTickSpacing

func GetTickSpacing(poolPath string) (int32, error)

GetTickSpacing returns the tick spacing of the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool whose spacing is read.

Returns:

  • int32: Tick spacing associated with the pool's fee tier.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickSpacing()"

Result

GetToken0Path

func GetToken0Path(poolPath string) (string, error)

GetToken0Path returns the path of token0 in the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • string: Canonical token0 contract path stored by the pool.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetToken0Path()"

Result

GetToken1Path

func GetToken1Path(poolPath string) (string, error)

GetToken1Path returns the path of token1 in the pool. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • string: Canonical token1 contract path stored by the pool.
  • error: Non-nil when poolPath does not identify an existing pool.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetToken1Path()"

Result

GetWithdrawalFee

func GetWithdrawalFee() uint64

GetWithdrawalFee returns the current withdrawal fee rate. Returns:

  • uint64: Withdrawal fee rate in basis points; zero means no withdrawal fee is charged.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetWithdrawalFee()"

Result

IncreaseObservationCardinalityNext

func IncreaseObservationCardinalityNext( cur realm, token0Path string, token1Path string, fee uint32, cardinalityNext uint16, )

IncreaseObservationCardinalityNext increases the observation cardinality for a pool.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • cardinalityNext: Requested maximum number of oracle observations retained for the pool.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "IncreaseObservationCardinalityNext" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "IncreaseObservationCardinalityNext" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Mint

func Mint( cur realm, token0Path string, token1Path string, fee uint32, tickLower int32, tickUpper int32, liquidityAmount string, positionCaller address, ) (string, string)

Mint adds liquidity to a position.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • tickLower: Lower inclusive tick boundary of the position range.
  • tickUpper: Upper exclusive tick boundary of the position range.
  • liquidityAmount: Decimal liquidity amount to add to the position.
  • positionCaller: Position-contract address whose position receives the liquidity.

Returns:

  • amount0: Token0 amount required for the liquidity addition, as a decimal string.
  • amount1: Token1 amount required for the liquidity addition, as a decimal string.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Mint" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Mint" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

NewDefaultFeeAmountTickSpacing

func NewDefaultFeeAmountTickSpacing() map[uint32]int32

NewDefaultFeeAmountTickSpacing returns the default tick spacing for each supported fee tier.

Returns:

  • map[uint32]int32: fee-tier to tick-spacing mapping for 100, 500, 3000, and 10000 tiers.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewDefaultFeeAmountTickSpacing()"

Result

NewObservationsTree

func NewObservationsTree() *bptree.BPTree

NewObservationsTree creates the top-level B+tree that indexes pool observation trees by pool path.

Returns:

  • tree: Empty B+tree suitable for storing pool-path observation trees.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewObservationsTree()"

Result

NewPoolPositionsTree

func NewPoolPositionsTree() *bptree.BPTree

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.

Returns:

  • *bptree.BPTree: empty position storage tree with fanout 16.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewPoolPositionsTree()"

Result

NewPoolTicksTree

func NewPoolTicksTree() *bptree.BPTree

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.

Returns:

  • *bptree.BPTree: empty tick storage tree with fanout 32.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewPoolTicksTree()"

Result

NewPoolsTree

func NewPoolsTree() *bptree.BPTree

NewPoolsTree creates the BPTree used to store pools by pool path.

Returns:

  • *bptree.BPTree: empty pool storage tree with fanout 32.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewPoolsTree()"

Result

Observe

func Observe(poolPath string, secondsAgos []uint32) ([]int64, []string, error)

Observe returns the tick and seconds-per-liquidity cumulatives for each requested lookback, matching Uniswap V3's observe(uint32[] secondsAgos). Parameters:

  • poolPath: Canonical pool path whose oracle history is queried.
  • secondsAgos: Lookback intervals in seconds; one cumulative pair is returned for each value, in the same order.

Returns:

  • []int64: Tick cumulative values corresponding to each requested lookback.
  • []string: Seconds-per-liquidity cumulative X128 values, serialized as base-10 strings, corresponding to each lookback.
  • error: Non-nil when pool or observation data cannot be read.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.Observe(,)"

Result

OracleConsult

func OracleConsult(poolPath string, secondsAgo uint32) (int32, string, error)

OracleConsult returns the arithmetic mean tick and harmonic mean liquidity over a lookback, following Uniswap V3 OracleLibrary's consult convention. Parameters:

  • poolPath: Canonical pool path whose oracle data is queried.
  • secondsAgo: Lookback duration in seconds used to compute the time-weighted values.

Returns:

  • int32: Arithmetic mean tick over the requested lookback.
  • string: Harmonic mean liquidity over the lookback, serialized as a base-10 unsigned integer.
  • error: Non-nil when the pool or required observation history is unavailable.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.OracleConsult(,)"

Result

RegisterInitializer

func RegisterInitializer(cur realm, initializer func(_ int, rlm realm, poolStore IPoolStore) IPool)

RegisterInitializer registers a new pool implementation version. This function is called by each version (v1, v2, etc.) during initialization to register their implementation with the proxy system.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • initializer: Version factory receiving the forwarded discriminator, current realm, and shared IPoolStore; it returns the implementation instance to register and later activate.

Security: Only contracts within the domain path can register initializers. Each package path can only register once to prevent duplicate registrations.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "RegisterInitializer" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "RegisterInitializer" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Render

func Render(path string) string

Render delegates web rendering to the active implementation.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.Render()"

Result

SetFeeProtocol

func SetFeeProtocol(cur realm, feeProtocol0, feeProtocol1 uint8)

SetFeeProtocol sets the protocol fee rates for a pool.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • feeProtocol0: Token0 protocol-fee denominator; zero disables it, while non-zero supported values route the corresponding fraction to protocol.
  • feeProtocol1: Token1 protocol-fee denominator; zero disables it, while non-zero supported values route the corresponding fraction to protocol.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetFeeProtocol" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetFeeProtocol" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SetPoolCreationFee

func SetPoolCreationFee(cur realm, fee int64)

SetPoolCreationFee sets the pool creation fee.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • fee: New pool creation fee, in the configured native-token base units.

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

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetPoolCreationFee" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetPoolCreationFee" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SetSwapEndHook

func SetSwapEndHook(cur realm, hook func(cur realm, poolPath string) error)

SetSwapEndHook sets the hook to be called at the end of a swap.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • hook: Callback invoked with the current realm and pool path after swap settlement; its error is propagated to abort the swap.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetSwapEndHook" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetSwapEndHook" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SetSwapStartHook

func SetSwapStartHook(cur realm, hook func(cur realm, poolPath string, timestamp int64))

SetSwapStartHook sets the hook to be called at the start of a swap.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • hook: Callback invoked with the current realm, pool path, and swap timestamp before swap computation.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetSwapStartHook" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetSwapStartHook" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SetTickCrossHook

func SetTickCrossHook(cur realm, hook func(cur realm, poolPath string, tickId int32, zeroForOne bool, timestamp int64))

SetTickCrossHook sets the hook to be called when a tick is crossed during a swap.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • hook: Callback invoked with the current realm, pool path, crossed tick index, swap direction, and block timestamp.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetTickCrossHook" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetTickCrossHook" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SetWithdrawalFee

func SetWithdrawalFee(cur realm, fee uint64)

SetWithdrawalFee sets the withdrawal fee rate.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • fee: Withdrawal fee in basis points; zero disables the fee.

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

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetWithdrawalFee" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "SetWithdrawalFee" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SnapshotCumulativesInside

func SnapshotCumulativesInside( poolPath string, tickLower int32, tickUpper int32, ) (int64, string, uint32, error)

SnapshotCumulativesInside returns the tick, seconds-per-liquidity, and seconds cumulatives accrued while the pool price was inside [tickLower, tickUpper). Both boundary ticks must be initialized.

Snapshots are only comparable across an interval during which a position in the range existed, matching Uniswap V3's snapshotCumulativesInside. Parameters:

  • poolPath: Canonical pool path whose oracle snapshot is queried.
  • tickLower: Lower inclusive tick boundary of the position range.
  • tickUpper: Upper exclusive tick boundary of the position range; both boundary ticks must be initialized.

Returns:

  • int64: Tick cumulative accrued while the price was inside the range.
  • string: Seconds-per-liquidity-inside X128 accumulator, serialized as a base-10 string.
  • uint32: Seconds accrued while the price was inside the range.
  • error: Non-nil when the pool, observations, or initialized boundaries are unavailable.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.SnapshotCumulativesInside(,,)"

Result

Swap

func Swap( cur realm, token0Path string, token1Path string, fee uint32, recipient address, zeroForOne bool, amountSpecified string, sqrtPriceLimitX96 string, swapCallback func(cur realm, amount0Delta, amount1Delta int64, callbackMarker *CallbackMarker) error, ) (string, string)

Swap executes a token swap in the pool.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • token0Path: Path of the first token in the pool pair.
  • token1Path: Path of the second token in the pool pair.
  • fee: Fee tier identifying the pool.
  • recipient: Address receiving output tokens.
  • zeroForOne: True to sell token0 for token1; false to sell token1 for token0.
  • amountSpecified: Decimal signed amount; positive requests exact input and negative requests exact output.
  • sqrtPriceLimitX96: Price boundary in Q64.96 fixed-point form at which the swap must stop.
  • swapCallback: Callback invoked with the current realm, signed token deltas, and a callback marker; it must settle the input token and return a non-nil error to abort settlement.

Returns:

  • amount0: Signed token0 delta for the swap, as a decimal string.
  • amount1: Signed token1 delta for the swap, as a decimal string.

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Swap" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "Swap" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

UpgradeImpl

func UpgradeImpl(cur realm, packagePath string)

UpgradeImpl switches the active pool implementation to a different version. This function allows seamless upgrades from one version to another without data migration or downtime.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • packagePath: Full package path of a version previously registered for this pool domain.

Security: Only admin or governance can perform upgrades. The new implementation must have been previously registered via RegisterInitializer. The pool must not be locked (see assertPoolUnlocked).

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/pool" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

NewCallbackMarker

func NewCallbackMarker() *CallbackMarker

NewCallbackMarker allocates a CallbackMarker in the pool realm. Construction must happen here because /r/-declared types can only be allocated in their owning realm (interrealm v2 checkConstructionTime). Callers in other realms (e.g. pool/v1 impl) borrow into pool via borrow rule #1 (function defined in /r/ package). Returns:

  • marker: New marker value allocated in the pool realm for swap-callback validation.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewCallbackMarker()"

Result

NewPoolStore

func NewPoolStore(kvStore store.KVStore) IPoolStore

NewPoolStore creates a new pool store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation. Parameters:

  • kvStore: KV store used to persist and retrieve pool-domain state.

Returns:

  • poolStore: an IPoolStore implementation backed by kvStore.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewPoolStore()"

Result

DefaultObservation

func DefaultObservation() Observation

DefaultObservation returns the zero, uninitialized observation used for an empty slot.

Returns:

  • observation: Observation with zero timestamp and accumulators and Initialized false.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.DefaultObservation()"

Result

GetObservationAt

func GetObservationAt(poolPath string, index uint16) (Observation, error)

GetObservationAt returns a safe copy of the observation stored at index. An in-range but uninitialized slot returns the zero observation, matching Uniswap V3's fixed observation-array getter.

ref: uniswap v3 IUniswapV3PoolState.observations(uint256 index) Parameters:

  • poolPath: Canonical pool path identifying the pool containing the observation.
  • index: Zero-based observation-array index; values at or above the fixed cardinality bound return an error.

Returns:

  • Observation: Observation at index, or the zero observation when the slot is in range but has never been written.
  • error: Non-nil when the pool is missing or index is out of range.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetObservationAt(,)"

Result

MakeObservation

func MakeObservation( blockTimestamp int64, tickCumulative int64, secondsPerLiquidityCumulativeX128 string, initialized bool, ) Observation

MakeObservation constructs an observation from its stored oracle accumulators.

Parameters:

  • blockTimestamp: Timestamp associated with the observation.
  • tickCumulative: Signed cumulative tick at blockTimestamp.
  • secondsPerLiquidityCumulativeX128: Decimal Q128-scaled cumulative seconds-per-liquidity value.
  • initialized: Whether this observation slot is initialized and usable.

Returns:

  • observation: Observation containing the supplied timestamp, accumulators, and initialization flag.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.MakeObservation(,,,)"

Result

NewObservationTree

func NewObservationTree() *ObservationTree

NewObservationTree creates an empty pool-local observation tree keyed by uint16 index.

Returns:

  • tree: Initialized observation tree ready for Get, Set, and Has operations.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewObservationTree()"

Result

NewPoolObservationsTree

func NewPoolObservationsTree(currentTime int64) *ObservationTree

NewPoolObservationsTree creates a circular observation buffer with slot zero initialized.

Parameters:

  • currentTime: Timestamp assigned to the initial observation at index zero.

Returns:

  • tree: Observation tree containing an initialized zero-index observation with zero cumulative values.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewPoolObservationsTree()"

Result

NewPool

func NewPool( token0Path string, token1Path string, fee uint32, sqrtPriceX96 *u256.Uint, tickSpacing int32, tick int32, slot0FeeProtocol uint8, ) *Pool

NewPool constructs a pool with the supplied token pair, fee, price, and tick configuration.

Parameters:

  • token0Path: path of the pool's token0 asset.
  • token1Path: path of the pool's token1 asset.
  • fee: fee tier used by swaps.
  • sqrtPriceX96: initial sqrt(token1/token0) price scaled by 2^96.
  • tickSpacing: spacing between initialized ticks.
  • tick: initial current tick.
  • slot0FeeProtocol: packed protocol-fee denominator configuration for slot0.

Returns:

  • *Pool: initialized pool with empty balances, fee growth, ticks, bitmaps, and positions.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewPool(,,,,,,)"

Result

NewDefaultPositionInfo

func NewDefaultPositionInfo() PositionInfo

NewDefaultPositionInfo returns the zero-accounting position state used for a new pool position.

Returns:

  • info: Position info with zero liquidity, zero fee-growth checkpoints, and no tokens owed.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewDefaultPositionInfo()"

Result

NewPositionInfo

func NewPositionInfo() PositionInfo

NewPositionInfo creates a zeroed position state for a tick range.

Returns:

  • PositionInfo: position with zero liquidity, fee-growth checkpoints, and owed tokens.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewPositionInfo()"

Result

GetSlot0

func GetSlot0(poolPath string) Slot0

GetSlot0 returns a safe copy of the pool's slot0 (sqrt price, tick, protocol fee, lock state, and oracle cursor/capacity metadata). The clone happens here, at the proxy boundary, so every implementation version can return its internal Slot0 by value without each one having to remember to defend against callers mutating the shared sqrtPriceX96. Parameters:

  • poolPath: Canonical pool path identifying the pool to query.

Returns:

  • Slot0: Copy of the pool's slot0 state, including price, tick, protocol fee, lock, and observation metadata; panics if the pool is missing.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetSlot0()"

Result

NewSlot0

func NewSlot0( sqrtPriceX96 *u256.Uint, tick int32, feeProtocol uint8, unlocked bool, ) Slot0

NewSlot0 constructs slot0 with the supplied price, tick, protocol fee, and lock state. Observation metadata starts with index zero and cardinality one.

Parameters:

  • sqrtPriceX96: initial sqrt(token1/token0) price scaled by 2^96.
  • tick: initial current pool tick.
  • feeProtocol: packed token0/token1 protocol-fee denominator configuration.
  • unlocked: initial reentrancy-lock state.

Returns:

  • Slot0: initialized slot0 value with one observation slot.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewSlot0(,,,)"

Result

GetTickInfo

func GetTickInfo(poolPath string, tick int32) (TickInfo, error)

GetTickInfo returns the tick info for a given tick. Parameters:

  • poolPath: Canonical pool path identifying the pool containing the tick.
  • tick: Tick index whose complete state is requested.

Returns:

  • TickInfo: Safe copy of the requested tick's liquidity and oracle/fee accumulator fields.
  • error: Non-nil when the pool or tick is not found.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.GetTickInfo(,)"

Result

NewTickInfo

func NewTickInfo() TickInfo

NewTickInfo creates an uninitialized tick state with zero accumulators.

Returns:

  • TickInfo: default tick state with all numeric fields zero and Initialized false.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewTickInfo()"

Result

NewTokenPair

func NewTokenPair() TokenPair

NewTokenPair creates a token-pair balance value initialized to zero.

Returns:

  • TokenPair: zero token0 and token1 balances.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/pool.NewTokenPair()"

Result