Usage

How to interact with the Rest API

The REST API V2 currently has six methods :

GET /swap

Used for getting a quote to swap tokens.

Parameters:

  • chain (int) - Chain ID of the desired chain

  • fromToken (string) - Symbol of token to swap from

  • toToken (string) - Symbol of token to swap to

  • amount (int) - Amount of fromToken to swap

Example Request:

/swap?chain=1&fromToken=USDC&toToken=DAI&amount=100

Returns:

  • routerAddress (string) - The address of the router contract

  • maxAmountOut (object) - The maximum amount of tokens that can be swapped out. Contains:

    • type (string) - The data type

    • hex (string) - The amount encoded in hexidecimal

  • query (object) - Parameters for the swap query:

    • 0 (string) - Router contract address

    • 1 (string) - Address of tokenIn

    • 2 (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 routing

    • swapAdapter (string) - Address of the swap adapter contract

    • tokenOut (string) - Address of tokenOut

    • minAmountOut (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:

/bridge?fromChain=1&toChain=42161&fromToken=USDC&toToken=USDC&amount=1000000

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 type

    • hex (string) - Fee amount encoded in hex

  • feeConfig (array) - Fee configuration parameters, contains:

    • 0 (number) - Gas price

    • 1 (object) - Fee percentage denominator (hex encoded BigNumber)

    • 2 (object) - Protocol fee percentage numerator (hex encoded BigNumber)

  • routerAddress (string) - Address of the router contract

  • maxAmountOut (object) - Maximum amount receivable from swap, structure same as above

  • originQuery (object) - Original swap query parameters, contains:

    • swapAdapter (string) - Swap adapter address

    • tokenOut (string) - Address of output token

    • minAmountOut (object) - Minimum output token amount

    • deadline (object) - Expiry time

    • rawParams (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 through

  • gasDropAmount (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) and

  • address : the address attempting to swap assets

Example:

/swapTxInfo?chain=1&fromToken=USDC&toToken=DAI&amount=100&address=0x22858d74Fdb1b9007Bee4e0396531FD806a66eF4

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:

/bridgeTxInfo?fromChain=1&toChain=42161&fromToken=USDC&toToken=USDC&amount=1000000&destAddress=0xcc78d2f004c9de9694ff6a9bbdee4793d30f3842

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)

GET /getSynapseTxId

Used to get the unique Synapse Tx Id data for executing a bridge.

Parameters:

  • originChainId (int) - Chain ID of the origin chain

  • bridgeModule (string) - string of the bridge module used (e.g. "SynapseRFQ")

  • txHash (string) - Transaction hash of the bridge transaction on the origin chain

Example:

/getSynapseTxId?originChainId=8453&bridgeModule=SynapseRFQ&txHash=0x4acd82091b54cf584d50adcad9f57c61055beaca130016ecc3798d3d61f5487a

Returns:

// This function returns the Synapse Transaction Id for the given transaction

  • synapseTxId: The unique Synapse Tx Id (Kappa)

GET /getBridgeTxStatus

Used to get the status of a bridge transaction, and the destination transaction information if the transaction is finalized

Parameters:

  • destChainId (int) - Chain ID of the destination chain

  • bridgeModule (string) - String of the bridge module used (e.g. "SynapseRFQ")

  • synapseTxId (string) - The unique Synapse Tx Id (Kappa)

Example:

/getBridgeTxStatus?destChainId=534352&bridgeModule=SynapseRFQ&synapseTxId=0xf4315cb818ad76305dc5fbd55181263688ffeb3fb3e1c6abc2b849a48b3a7c78

Returns:

// This function returns the status of a bridge transaction, and optionally information on the completed destination transaction.

  • status: A boolean flag, returning true if the transaction is completed

  • toInfo : A data type filled with information about the completed destination transaction (returns null if the transaction isnt complete)

GET /getDestinationTx

Used to get the status of a bridge transaction, and the destination transaction information if the transaction is finalized. This method is a SIMPLE implementation of the above two methods.

Parameters:

  • originChainId (int) - Chain ID of the origin chain

  • txHash (string) - Transaction hash of the bridge transaction on the origin chain

Example:

/getDestinationTx?originChainId=1&txHash=0x93f9d78516ee5fbce2595519ec97e03ff03778af600acb1769d0ce6def32b804

Returns:

// This function returns the status of a bridge transaction, and optionally information on the completed destination transaction.

  • status: A string response, returning "completed" if the transaction is completed

  • toInfo : A data type filled with information about the completed destination transaction (returns null if the transaction isnt complete)

Please read the FAQs and instructions carefully before reaching out to the on Discord for questions.

Last updated