Usage
How to interact with the Rest API
The REST API V2 currently has four methods :
GET /swap
Used for getting a quote to swap tokens.
Parameters:
chain
(int) - Chain ID of the desired chainfromToken
(string) - Symbol of token to swap fromtoToken
(string) - Symbol of token to swap toamount
(int) - Amount of fromToken to swap
Example Request:
Returns:
routerAddress
(string) - The address of the router contractmaxAmountOut
(object) - The maximum amount of tokens that can be swapped out. Contains:type
(string) - The data typehex
(string) - The amount encoded in hexidecimal
query
(object) - Parameters for the swap query:0
(string) - Router contract address1
(string) - Address of tokenIn2
(object) - Amount of tokenIn to swap (same structure as maxAmountOut)3
(object) - Minimum amount of tokenOut requested (same structure as maxAmountOut)4
(string) - Encoded params for swap routingswapAdapter
(string) - Address of the swap adapter contracttokenOut
(string) - Address of tokenOutminAmountOut
(object) - Minimum amount of tokenOut required (same structure as maxAmountOut)deadline
(object) - Deadline parameter for the swap (same structure as maxAmountOut)rawParams
(string) - Encoded hex string containing swap parameters
maxAmountOutStr
(string) - The maxAmountOut value formatted as a decimal string
GET /bridge
Used for getting a quote for bridging tokens between chains.
Parameters:
fromChain (int) - Chain ID of origin chain
toChain (int) - Chain ID of destination chain
fromToken (string) - Token symbol to bridge
toToken (string) - Token symbol to bridge to
amount (int) - Amount to bridge
Example:
Returns:
// Each request returns a list of quotes. A quote contains the following:
feeAmount
(object) - The fee amount for the swap. Contains:type
(string) - Data typehex
(string) - Fee amount encoded in hex
feeConfig
(array) - Fee configuration parameters, contains:0
(number) - Gas price1
(object) - Fee percentage denominator (hex encoded BigNumber)2
(object) - Protocol fee percentage numerator (hex encoded BigNumber)
routerAddress
(string) - Address of the router contractmaxAmountOut
(object) - Maximum amount receivable from swap, structure same as aboveoriginQuery
(object) - Original swap query parameters, contains:swapAdapter
(string) - Swap adapter addresstokenOut
(string) - Address of output tokenminAmountOut
(object) - Minimum output token amountdeadline
(object) - Expiry timerawParams
(string) - Encoded hex params
destQuery
(object) - Destination swap query parameters, structure similar to originQuery above.maxAmountOutStr
(string) - maxAmountOut as a decimal string.bridgeModuleName
(string) - the bridge module the transaction will be routed throughgasDropAmount
(BigNumber) - the amount of gas airdropped to the user on the dest chain.
GET /swapTxInfo
Used to get transaction data for executing a swap.
Parameters: (same as /swap
)
Example:
Returns:
data
: The binary data that forms the input to the transaction.to
: The address of the Synapse Router (the synapse bridge contract)
GET /bridgeTxInfo
Used to get transaction data for executing a bridge.
Parameters: (same as /bridge
+ destAddress
)
Example:
Returns:
// This function returns the txInfo for the best (highest expected amount out) quote
data
: The binary data that forms the input to the transaction.to
: The address of the Synapse Router (the synapse bridge contract)
Please read the FAQs and instructions carefully before reaching out to the on Discord for questions.
Last updated