Build Swap Transaction
Last updated
Was this helpful?
Last updated
Was this helpful?
When building transaction, there are 6 additional parameters along with quote input.
receiver
Required
srcSwapProvider
Required when srcSwapDescription is presented in quote result
dstSwapProvider
Required when dstSwapDescription is presented in quote result
bridgeProvider
Required when bridgeDescription is presented in quote result
srcBridgeTokenAddress
Required when bridgeDescription is presented in quote result
dstBridgeTokenAddress
Required when bridgeDescription is presented in quote result
To build transaction, please fill the corresponding fields (srcSwapDescription
, bridgeDescription
and dstSwapDescription
) from quote response's route to buildTx input . If parameters are not filled properly, it may not return the desired routing result. You can review the transaction calldata route by checking route
field in buildTx response.
For example, following response is quote result of Arbitrum USDT to KCC native token.
srcSwapDescription
is null because these is no source chain swap needed in this route, so we don't have to fill srcSwapProvider
when calling buildTx.
We have a non-empty bridgeDescription
because it's a cross-chain quote. We need to fill corresponding bridgeProvider
, srcBridgeTokenAddress
and dstBridgeTokenAddress
when calling buildTx. For single chain quote, we can skip these parameters.
dstSwapDescription
is needed in this route. So we need to fill dstSwapProvider
when calling buildTx.
Therefore, we can create the following buildTx request from above information:
Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
as the address for the native token in your parameter.
If you would like to know more about commissionRate fields and fee collection function, please refer to Monetization / Take Fees
If you would like to know latest supported bridge provider and swap provider, please refer to Supported Blockchains/Bridges/DEXs
This request is asking to bridge 1 ETH from Optimism for ETH on the BNB Chain
IMPORTANT:
Note that the amount parameter should be padded with zeroes. For example, pass
100000000
instead of
100
if the decimals of the token is 6.
The estimatedGas
field in the API response is an estimated value. For now, please use a method similar to RPC, such as , to re-estimate the actual gas limit. You can refer to the following sample code to do that:
Here you can find our full
Source chain ID.
Source chain quote token address.
Source chain quote token amount.
Destination chain ID.
Destination chain quote token address.
Percentage of slippage tolerance.
Destination chain quote token receiver.
Source chain affiliate address.
Commission rate of affiliate, denominator is 1000000. Affiliate must be provided when passing commissionRate.
Provider of bridge operation.
Source chain bridge token address
Destination chain bridge token address
Provider of source chain swap.
Provider of destination chain swap.
Successful Response