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

/router package

Overview

Package router provides swap routing and execution across GnoSwap liquidity pools.

The router handles token swaps with multi-hop routing, slippage protection, and automatic GNOT wrapping/unwrapping. It supports both exact input and exact output swap modes with deadline validation.

Key features: - Multi-hop routing across up to 3 pools - Quote distribution for optimal execution - Native GNOT handling with automatic wrap/unwrap - Slippage protection via min/max amounts - Router fee (0.15%) on all swaps - Deadline enforcement to prevent stale transactions

The router acts as a proxy to version-specific implementations, currently routing to v1 for all swap operations.

Function

DrySwapRoute

func DrySwapRoute( inputToken, outputToken string, specifiedAmount string, swapTypeStr string, strRouteArr, quoteArr string, tokenAmountLimit string, ) (string, string, bool)

DrySwapRoute simulates a swap route without executing it.

Parameters:

  • inputToken: path of input token
  • outputToken: path of output token
  • specifiedAmount: specified amount for the swap
  • swapTypeStr: swap type string ("ExactIn" or "ExactOut")
  • strRouteArr: encoded route array
  • quoteArr: encoded quote array
  • tokenAmountLimit: token amount limit

Returns:

  • string: estimated input amount
  • string: estimated output amount
  • bool: success status

Params

Command

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

Result