Search Apps Documentation Source Content File Folder Download Copy Actions Download

v1 package

Overview

package v1 handles token swaps through GnoSwap liquidity pools. The router provides user-facing swap functions with slippage protection, multi-hop routing, and automatic GNOT wrapping/unwrapping. It supports both exact input and exact output swap modes. All swap functions include deadline checks and minimum output validation to protect users from unfavorable price movements.

Functions

BuildMultiHopRoutePath

func BuildMultiHopRoutePath(hops ...string) string

BuildMultiHopPath creates a multi-hop route path string by connecting multiple single hops. Format: "tokenA:tokenB:fee1\*POOL\*tokenB:tokenC:fee2\*POOL\*tokenC:tokenD:fee3" Parameters: - hops: slice of single-hop path strings Returns: - string: formatted multi-hop route path Example: - hops := \[]string{"tokenA:tokenB:500", "tokenB:tokenC:3000"} returns "tokenA:tokenB:500\*POOL\*tokenB:tokenC:3000"

Param

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.BuildMultiHopRoutePath()"

Result

BuildSingleHopRoutePath

func BuildSingleHopRoutePath(tokenA, tokenB string, fee uint32) string

BuildSingleHopPath creates a single-hop route path string. Format: "tokenA:tokenB:fee" Parameters: - tokenA: input token address - tokenB: output token address - fee: pool fee (e.g., 500, 3000, 10000) Returns: - string: formatted single-hop route path Example: - BuildSingleHopPath("gno.land/r/demo/wugnot", "gno.land/r/demo/usdc", 500) returns "gno.land/r/demo/wugnot:gno.land/r/demo/usdc:500"

Params

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.BuildSingleHopRoutePath(,,)"

Result

NewRouterV1

func NewRouterV1( routerStore router.IRouterStore, ) router.IRouter

Param

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.NewRouterV1()"

Result

NewExactInParams

func NewExactInParams( baseParams BaseSwapParams, amountIn int64, amountOutMin int64, ) ExactInParams

NewExactInParams creates a new ExactInParams instance.

Params

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.NewExactInParams(,,)"

Result

NewExactInSwapOperation

func NewExactInSwapOperation(r *routerV1, pp ExactInParams) *ExactInSwapOperation

Params

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.NewExactInSwapOperation(,)"

Result

NewExactOutParams

func NewExactOutParams( baseParams BaseSwapParams, amountOut int64, amountInMax int64, ) ExactOutParams

NewExactOutParams creates a new ExactOutParams instance.

Params

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.NewExactOutParams(,,)"

Result

NewExactOutSwapOperation

func NewExactOutSwapOperation(r *routerV1, pp ExactOutParams) *ExactOutSwapOperation

NewExactOutSwapOperation creates a new exact-out swap operation.

Params

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.NewExactOutSwapOperation(,)"

Result

NewMultiSwapProcessor

func NewMultiSwapProcessor(r *routerV1, isSimulate bool, direction SwapDirection) *MultiSwapProcessor

NewMultiSwapProcessor creates a new MultiSwapProcessor with the specified configuration.

Params

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.NewMultiSwapProcessor(,,)"

Result

NewRouteParser

func NewRouteParser() *RouteParser

NewRouteParser creates a new route parser instance.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/router/v1.NewRouteParser()"

Result