Fordefi has integrated leading platforms to facilitate intent-based swaps or aggregated trading across decentralized finance (DeFi) from within Fordefi's web console and REST API.
- For instructions in performing swaps using the web console, see Swap Assets.
- For programmatic leverage of the swap aggregator API, you must call two endpoints:
- See a complete example showcasing our swap API and how to use it to manage quotes from multiple providers.
If you want to use UniswapX as a quote provider, please contact Fordefi support to have this feature activated for your organization.
First, you must receive a quote for the specific trade you wish to make. Pass the swap parameters, that is, the origin vault
, the input asset
, the output asset
, and the amount
of the input asset. Optionally, you can also specify the maximum slippage tolerance or ask for quotes from a subset of secific providers. To get the full list of supported providers, you can call the Get Providers endpoint.
{
"vault_id": "432b199b-1f71-42bf-ba0b-33d512afa9de",
"input_asset_identifier": {
"type": "evm",
"details": {
"type": "native",
"chain": "ethereum_mainnet"
}
},
"output_asset_identifier": {
"type":"evm",
"details":{
"type":"erc20",
"token":{
"chain":"ethereum_mainnet",
"hex_repr":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
}
}
},
"amount": "1000000000000000000",
"slippage_bps": "1000000000000000000"
"requested_provider_ids": []
}
Once you have received a quote from at least one provider, you can submit the swap transaction by submitting the same swap parameters as in the quote request and the quote_id
that you chose from the response.
Note that if the swap transaction requires token approvals to make the swap, several transactions will be created on Fordefi according to the required approvals to make the swap.
{
"quote_id": "3c071a1d-db86-46a7-9dc8-72ba3fbca992",
"vault_id": "432b199b-1f71-42bf-ba0b-33d512afa9de",
"input_asset_identifier": {
"type": "evm",
"details": {
"type": "native",
"chain": "ethereum_mainnet"
}
},
"output_asset_identifier": {
"type":"evm",
"details":{
"type":"erc20",
"token":{
"chain":"ethereum_mainnet",
"hex_repr":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
}
}
},
"amount": "1000000000000000000",
"slippage_bps": "1000000000000000000"
}