What is the Router API?
The Route API is a highly-efficient DeFi aggregation and smart order routing REST API. With it, developers can easily tap into optimized routes for DeFi tokens/positions and multi-token swaps across various chains.
With a single API integration, unlock a host of DeFi strategies in your application. The Route API finds the optimal execution path across a multitude of DeFi protocols such as liquidity pools, lending platforms, automated market makers, yield optimizers, and more.
This allows for maximized capital efficiency and yield optimization, taking into account return rates, gas costs, and slippage. The Route API is your key to navigating the intricate DeFi landscape with ease and efficiency.
Try it out:
👉 Run this curl request to see a live route response for entering a Curve position with ETH.
curl -X 'GET' \
'https://api.enso.finance/api/v1/shortcuts/route?chainId=1&fromAddress=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&receiver=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&spender=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&amountIn=1000000000000000000&slippage=300&tokenIn=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOut=0x06325440d014e39736583c165c2963ba99faf14e&routingStrategy=router' \
-H 'accept: application/json'
👉 Or try it out in the Swagger UI (opens in a new tab)
Will return a response like this:
{
"gas": "243255",
"amountOut": "922135437013688654",
"createdAt": 18684443,
"tx": {
"data": "0xb35d7e73...",
"to": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
"from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"value": "1000000000000000000"
},
"route": [...]
}
The response will contain a valid transaction that you can broadcast to the network and a simulation of the transaction itself.
What's happening?
Let's say you want to go from ETH to a Curve pool. Also, to get additional yield, you want to deposit the LP token into a Curve Gauge. In the route endpoint, like in the above example, you would pass a tokenIn (ETH), the amount and the tokenOut, for example the tricrypto Curve Gauge.
Under the hood, Enso will take care of the following steps:
- Swap Ether for one of the triCrypto underlying, in this case, USDC
- Deposit USDC into the triCrypto (opens in a new tab) Curve pool, receiving triCrypto LP tokens (opens in a new tab)
- Stake the received LP token into the Curve Gauge (opens in a new tab)
For more informations about what's happening behind the scenes, check out this section
Routing Options
There are 3 options for routing strategies depending upon your usecase of EOA, Smart Account, or new Smart Account.
router
- single contract, which can be seen as the universal routerdelegate
- returns calldata in the form of delegateCalls for smart accountsensowallet
- returns calldata for deploying a Enso smart account, and executing all the logic inside of the smart account in the same transaction