Introduction

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 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' \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer 1e02632d-6feb-4a75-a157-documentation" \
  "https://api.enso.finance/api/v1/shortcuts/route?chainId=1&fromAddress=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&priceImpact=false&toEoa=true&amountIn=1000000000000000000&slippage=300&tokenIn=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOut=0x06325440d014e39736583c165c2963ba99faf14e"

👉 Or try it out in the Swagger UI (opens in a new tab)

Will return a response like this:

{
  "createdAt": 17692827,
 
  "gas": 625417,
  "amountOut": "1949890251706461962125",
  "tx": {
    "to": "0x7fEA6786D291A87fC4C98aFCCc5A5d3cFC36bc7b",
    "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "value": "1000000000000000000",
    "data": "0xffa2ca3b273...."
  ...
  }}
 

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:

  1. Swap Ether for one of the triCrypto underlying, in this case, USDC
  2. Deposit USDC into the triCrypto (opens in a new tab) Curve pool, receiving triCrypto LP tokens (opens in a new tab)
  3. Stake the received LP token into the Curve Gauge (opens in a new tab)