Execute a Swap
Use the response from the previous step to perform a swap
As outlined in the previous page, the /routes
endpoint will return data with the shape of:
For executing a swap, every field that is needed is contained within the details
object.
Here is a breakdown of the details
object:
path
Array of strings
An array containing token addresses in order of the swap route. The final item in the path
should be the outputToken
that was supplied in the previous query.
pairs
Array of strings
An array containing addresses of trade pairs, in order of the swap route.
extras
Array of strings
Extra data needed for each pair.
inputAmount
string
Non decimal-adjusted input amount. Same value as supplied to the endpoint.
expectedOutputAmount
string
Non decimal-adjusted expected output amount. This value should be used, along with some slippage value, to determine the minimum expected output.
deadline
integer
Unix timestamp (seconds) of when the trade must be executed by.
partner
integer
sig
string
Signed message verifying the tenant id along with various other aspects of the trade. If this is modified at all then the user will incur a 1% fee due to the contract not being able to verify the authorizer of the swap.
The details
purposefully details the struct recognized by the Swap router as SwapPayload
. This struct looks like:
Once the transaction has been created, use the user's preferred wallet provider to sign the transaction and send it to be committed on chain.
Last updated