Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

router/v2 package

Overview

package router handles token swaps through GnoSwap liquidity pools.

The router provides user-facing swap functions with slippage protection, multi-hop routing, and both exact-input and exact-output swap modes.

Live exact-input calls enforce a minimum output and deadline. Live exact-output calls enforce a maximum input and deadline. DrySwapRoute is read-only and has no deadline or transfer.

Functions

BuildSingleHopRoutePath

func BuildSingleHopRoutePath(tokenA, tokenB string, fee uint32) string
Ask AI Claude ChatGPT

BuildSingleHopRoutePath formats one route-direction single-hop path.

Parameters:

  • tokenA: input token contract path
  • tokenB: output token contract path
  • fee: pool fee tier appended as a decimal value

Returns:

  • routePath: tokenA:tokenB:fee formatted route string; panics for empty or identical tokens

Params

Command

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

Result

NewRouterV1

func NewRouterV1( routerStore router.IRouterStore, ) router.IRouter
Ask AI Claude ChatGPT

NewRouterV1 creates a router v1 implementation backed by routerStore.

Parameters:

  • routerStore: storage implementation used for swap-fee and pending protocol-fee state

Returns:

  • router: initialized IRouter implementation backed by routerStore

Param

Command

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

Result

NewExactInParams

func NewExactInParams( baseParams BaseSwapParams, amountIn int64, amountOutMin int64, ) ExactInParams
Ask AI Claude ChatGPT

NewExactInParams creates parameters for an exact-input swap.

Parameters:

  • baseParams: shared token, route, quote, price-limit, and deadline settings
  • amountIn: exact input amount in token units; must be positive before execution
  • amountOutMin: minimum acceptable output amount in token units

Returns:

  • params: exact-input parameters combining baseParams and amount limits

Params

Command

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

Result

NewExactInSwapOperation

func NewExactInSwapOperation(r *routerV1, pp ExactInParams) *ExactInSwapOperation
Ask AI Claude ChatGPT

NewExactInSwapOperation creates an exact-input operation for router execution.

Parameters:

  • r: router implementation used to execute pool swaps
  • pp: exact-input amount and route settings

Returns:

  • operation: initialized ExactInSwapOperation

Params

Command

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

Result

NewExactOutParams

func NewExactOutParams( baseParams BaseSwapParams, amountOut int64, amountInMax int64, ) ExactOutParams
Ask AI Claude ChatGPT

NewExactOutParams creates parameters for an exact-output swap.

Parameters:

  • baseParams: shared token, route, quote, price-limit, and deadline settings
  • amountOut: requested output amount in token units; must be positive before execution
  • amountInMax: maximum acceptable input amount in token units

Returns:

  • params: exact-output parameters combining baseParams and amount limits

Params

Command

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

Result

NewExactOutSwapOperation

func NewExactOutSwapOperation(r *routerV1, pp ExactOutParams) *ExactOutSwapOperation
Ask AI Claude ChatGPT

NewExactOutSwapOperation creates an exact-output operation for router execution.

Parameters:

  • r: router implementation used to execute pool swaps
  • pp: exact-output amount and route settings

Returns:

  • operation: initialized ExactOutSwapOperation

Params

Command

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

Result

NewRouteParser

func NewRouteParser() *RouteParser
Ask AI Claude ChatGPT

NewRouteParser creates a parser for comma-separated route and quote strings.

Returns:

  • parser: new RouteParser instance

Command

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

Result

Gno Expression Evaluator

Evaluate any read-only Gno expression against gno.land/r/gnoswap/router/v2, for example a function call with arguments.