router.gno

Searches for the best route for a swap.

SwapRoute

func SwapRoute(
	inputToken string,
	outputToken string,
	_amountSpecified string,
	swapType string,
	strRouteArr string, // []string
	quoteArr string, // []int
	_tokenAmountLimit string,
) (string, string)

Runs a swap through the route that offers the most favorable exchange rate.

Parameters

NameTypeDescription

inputToken

string

The path of the input token.

outputToken

string

The path of the output token.

amountSpecified

string

The amount of the specified token.

swapType

string

The type of the swap. EXACT_IN for specifying an exact amount of inputToken, and EXACT_OUT for specifying an exact amount of outputToken.

strRouteArr

string

The route of the swap.

quoteArr

string

The share of each split of the route.

tokenAmountLimit

string

Limits the number of tokens while routing the swap. The minimum amount of tokens to receive for EXACT_IN, and the maximum amount of tokens to sell for EXACT_OUT.

Return Values

NameTypeDescription

tokenIn

string

The amount sent to the pool from the user (the input of the swap).

tokenOut

string

The amount sent to the user from the pool (the output of the swap).

Last updated