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.
BuildMultiHopRoutePath
func BuildMultiHopRoutePath(hops ...string) string
Link
Execute
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"
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.BuildMultiHopRoutePath( )"
BuildSingleHopRoutePath
func BuildSingleHopRoutePath(tokenA, tokenB string, fee uint32) string
Link
Execute
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"
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.BuildSingleHopRoutePath( , , )"
NewRouterV1
func NewRouterV1(
routerStore router.IRouterStore,
) router.IRouter
Link
Execute
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.NewRouterV1( )"
NewExactInParams
func NewExactInParams(
baseParams BaseSwapParams,
amountIn int64,
amountOutMin int64,
) ExactInParams
Link
Execute
NewExactInParams creates a new ExactInParams instance.
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.NewExactInParams( , , )"
NewExactInSwapOperation
func NewExactInSwapOperation(r *routerV1, pp ExactInParams) *ExactInSwapOperation
Link
Execute
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.NewExactInSwapOperation( , )"
NewExactOutParams
func NewExactOutParams(
baseParams BaseSwapParams,
amountOut int64,
amountInMax int64,
) ExactOutParams
Link
Execute
NewExactOutParams creates a new ExactOutParams instance.
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.NewExactOutParams( , , )"
NewExactOutSwapOperation
func NewExactOutSwapOperation(r *routerV1, pp ExactOutParams) *ExactOutSwapOperation
Link
Execute
NewExactOutSwapOperation creates a new exact-out swap operation.
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.NewExactOutSwapOperation( , )"
NewMultiSwapProcessor
func NewMultiSwapProcessor(r *routerV1, isSimulate bool, direction SwapDirection) *MultiSwapProcessor
Link
Execute
NewMultiSwapProcessor creates a new MultiSwapProcessor with the specified configuration.
Command
gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land " -data "gno.land/r/gnoswap/router/v1.NewMultiSwapProcessor( , , )"
NewRouteParser
func NewRouteParser() *RouteParser
Link
Execute
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()"