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:
Field | Type | Description |
---|---|---|
| Array of strings | An array containing token addresses in order of the swap route. The final item in the |
| Array of strings | An array containing addresses of trade pairs, in order of the swap route. |
| Array of strings | Extra data needed for each pair. |
| string | Non decimal-adjusted input amount. Same value as supplied to the endpoint. |
| string | Non decimal-adjusted expected output amount. This value should be used, along with some slippage value, to determine the minimum expected output. |
| integer | Unix timestamp (seconds) of when the trade must be executed by. |
| integer | The tenant id for the corresponding api key supplied in the request from Query a Swap |
| 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