Search Apps Documentation Source Content File Folder Download Copy Actions Download

position package

Functions

CollectFee

func CollectFee( cur realm, positionId uint64, ) (uint64, string, string, string, string, string)

CollectFee collects accumulated fees from a position.

Parameters:

  • positionId: ID of the position

Returns:

  • uint64: position ID
  • string: amount of token0 collected
  • string: amount of token1 collected
  • string: pool path
  • string: token0 path
  • string: token1 path

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/position" -func "CollectFee" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -func "CollectFee" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

DecreaseLiquidity

func DecreaseLiquidity( cur realm, positionId uint64, liquidityStr string, amount0MinStr string, amount1MinStr string, deadline int64, ) (uint64, string, string, string, string, string, string)

DecreaseLiquidity removes liquidity from a position.

Parameters:

  • positionId: ID of the position
  • liquidityStr: amount of liquidity to remove
  • amount0MinStr: minimum amount of token0
  • amount1MinStr: minimum amount of token1
  • deadline: transaction deadline

Returns:

  • uint64: position ID
  • string: removed liquidity amount
  • string: amount of token0 removed
  • string: amount of token1 removed
  • string: pool path
  • string: net amount of token0 after fees
  • string: net amount of token1 after fees

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/position" -func "DecreaseLiquidity" -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -func "DecreaseLiquidity" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

GetImplementationPackagePath

func GetImplementationPackagePath() string

GetImplementationPackagePath returns the package path of the currently active implementation.

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetImplementationPackagePath()"

Result

GetPositionCount

func GetPositionCount() int

GetPositionCount returns the total number of positions.

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionCount()"

Result

GetPositionFeeGrowthInside0LastX128

func GetPositionFeeGrowthInside0LastX128(positionId uint64) string

GetPositionFeeGrowthInside0LastX128 returns the last recorded fee growth inside for token0.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionFeeGrowthInside0LastX128()"

Result

GetPositionFeeGrowthInside1LastX128

func GetPositionFeeGrowthInside1LastX128(positionId uint64) string

GetPositionFeeGrowthInside1LastX128 returns the last recorded fee growth inside for token1.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionFeeGrowthInside1LastX128()"

Result

GetPositionFeeGrowthInsideLastX128

func GetPositionFeeGrowthInsideLastX128(positionId uint64) (string, string)

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

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionFeeGrowthInsideLastX128()"

Result

GetPositionIDs

func GetPositionIDs(offset, count int) []uint64

GetPositionIDs returns a paginated list of position IDs.

Params

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionIDs(,)"

Result

GetPositionLiquidity

func GetPositionLiquidity(positionId uint64) string

GetPositionLiquidity returns the liquidity amount of a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionLiquidity()"

Result

GetPositionPoolKey

func GetPositionPoolKey(positionId uint64) string

GetPositionPoolKey returns the pool key of a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionPoolKey()"

Result

GetPositionTickLower

func GetPositionTickLower(positionId uint64) int32

GetPositionTickLower returns the lower tick of a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionTickLower()"

Result

GetPositionTickUpper

func GetPositionTickUpper(positionId uint64) int32

GetPositionTickUpper returns the upper tick of a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionTickUpper()"

Result

GetPositionTicks

func GetPositionTicks(positionId uint64) (int32, int32)

GetPositionTicks returns the lower and upper ticks of a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionTicks()"

Result

GetPositionToken0Balance

func GetPositionToken0Balance(positionId uint64) int64

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionToken0Balance()"

Result

GetPositionToken1Balance

func GetPositionToken1Balance(positionId uint64) int64

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionToken1Balance()"

Result

GetPositionTokenBalances

func GetPositionTokenBalances(positionId uint64) (int64, int64)

GetPositionTokenBalances returns the token0 balance of a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionTokenBalances()"

Result

GetPositionTokensOwed

func GetPositionTokensOwed(positionId uint64) (int64, int64)

GetPositionTokensOwed returns the amount of tokens owed to a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionTokensOwed()"

Result

GetPositionTokensOwed0

func GetPositionTokensOwed0(positionId uint64) int64

GetPositionTokensOwed0 returns the amount of token0 owed to a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionTokensOwed0()"

Result

GetPositionTokensOwed1

func GetPositionTokensOwed1(positionId uint64) int64

GetPositionTokensOwed1 returns the amount of token1 owed to a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPositionTokensOwed1()"

Result

GetUnclaimedFee

func GetUnclaimedFee(positionId uint64) (string, string)

GetUnclaimedFee returns the unclaimed fees for both tokens of a position.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetUnclaimedFee()"

Result

IncreaseLiquidity

func IncreaseLiquidity( cur realm, positionId uint64, amount0DesiredStr string, amount1DesiredStr string, amount0MinStr string, amount1MinStr string, deadline int64, ) (uint64, string, string, string, string)

IncreaseLiquidity adds liquidity to an existing position.

Parameters:

  • positionId: ID of the position
  • amount0DesiredStr: desired amount of token0
  • amount1DesiredStr: desired amount of token1
  • amount0MinStr: minimum amount of token0
  • amount1MinStr: minimum amount of token1
  • deadline: transaction deadline

Returns:

  • uint64: position ID
  • string: new liquidity amount
  • string: amount of token0 added
  • string: amount of token1 added
  • string: pool path

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/position" -func "IncreaseLiquidity" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -func "IncreaseLiquidity" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

IsBurned

func IsBurned(positionId uint64) bool

IsBurned returns whether a position has been burned.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.IsBurned()"

Result

IsInRange

func IsInRange(positionId uint64) bool

IsInRange returns whether a position's ticks are within the current price range.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.IsInRange()"

Result

Mint

func Mint( cur realm, token0 string, token1 string, fee uint32, tickLower int32, tickUpper int32, amount0Desired string, amount1Desired string, amount0Min string, amount1Min string, deadline int64, mintTo address, referrer string, ) (uint64, string, string, string)

Mint creates a new liquidity position NFT.

Parameters:

  • token0: path of the first token
  • token1: path of the second token
  • fee: pool fee tier
  • tickLower: lower tick boundary
  • tickUpper: upper tick boundary
  • amount0Desired: desired amount of token0
  • amount1Desired: desired amount of token1
  • amount0Min: minimum amount of token0
  • amount1Min: minimum amount of token1
  • deadline: transaction deadline
  • mintTo: recipient of the position NFT
  • referrer: referrer address for reward tracking

Returns:

  • uint64: position ID
  • string: liquidity amount
  • string: amount of token0 added
  • string: amount of token1 added

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/position" -func "Mint" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -func "Mint" -args $'' -args $'' -args $'' -args $'' -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

NewPositionsTree

func NewPositionsTree() *bptree.BPTree

NewPositionsTree allocates the positions BP-tree under /r/gnoswap/position's realm context (the realm that declares Position).

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.NewPositionsTree()"

Result

RegisterInitializer

func RegisterInitializer(cur realm, initializer func(_ int, rlm realm, positionStore IPositionStore) IPosition)

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

The initializer function creates a new instance of the implementation using the provided positionStore interface.

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/position" -func "RegisterInitializer" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

Reposition

func Reposition( cur realm, positionId uint64, tickLower int32, tickUpper int32, amount0DesiredStr string, amount1DesiredStr string, amount0MinStr string, amount1MinStr string, deadline int64, ) (uint64, string, int32, int32, string, string)

Reposition changes the tick range of a position.

Parameters:

  • positionId: ID of the position
  • tickLower: new lower tick boundary
  • tickUpper: new upper tick boundary
  • amount0DesiredStr: desired amount of token0
  • amount1DesiredStr: desired amount of token1
  • amount0MinStr: minimum amount of token0
  • amount1MinStr: minimum amount of token1
  • deadline: transaction deadline

Returns:

  • uint64: position ID
  • string: new liquidity amount
  • int32: new lower tick
  • int32: new upper tick
  • string: amount of token0 used
  • string: amount of token1 used

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/position" -func "Reposition" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -func "Reposition" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

SetPositionOperator

func SetPositionOperator( cur realm, positionId uint64, operator address, )

SetPositionOperator sets an operator for a position.

Parameters:

  • positionId: ID of the position
  • operator: address of the operator

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/position" -func "SetPositionOperator" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -func "SetPositionOperator" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

UpgradeImpl

func UpgradeImpl(cur realm, packagePath string)

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

Security: Only admin or governance can perform upgrades. The new implementation must have been previously registered via RegisterInitializer.

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/position" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/position" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

NewPositionStore

func NewPositionStore(kvStore store.KVStore) IPositionStore

NewPositionStore creates a new protocol fee store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.NewPositionStore()"

Result

GetPosition

func GetPosition(positionId uint64) (Position, error)

GetPosition returns the position data for a given position ID.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.GetPosition()"

Result

NewPosition

func NewPosition( poolKey string, tickLower int32, tickUpper int32, liquidity string, feeGrowthInside0LastX128, feeGrowthInside1LastX128 string, tokensOwed0, tokensOwed1 int64, burned bool, operator address, ) *Position

Params

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/gnoswap/position.NewPosition(,,,,,,,,,)"

Result