GET /v1/shortcuts/route

GET /v1/shortcuts/route

Use this endpoint to calculate an optimal route for entering or exiting any DeFi position or swapping any ERC20 tokens. The API takes into account various DeFi protocols and Exchanges to determine the best path.

The route comes with a transaction object (tx), ready for submission to an Ethereum node. This transaction is a valid, unsigned Ethereum transaction that can be used to execute the recommended route. If tokenIn is not ETH, remember to set your allowances.

Alongside the route and transaction, the API also returns a simulation of the transaction. This simulation gives you a comprehensive quote, detailing expected gas costs, returns, and potential price impact.

Request

Query ParamDescriptionExample
fromAddressEthereum address of the wallet to send the transaction from (It could be an EoA, or a Smart Wallet)fromAddress=0xd8da6bf2...
spenderEthereum address of the receiver of the tokenOutspender=0xd8da6bf2...
receiverEthereum address of the spender of the tokenInreceiver=0xd8da6bf2...
tokenInEthereum address of the token to swap or enter into a position fromtokenIn=0x6b175474e8909...
amountInAmount of tokenIn to swap in weiamountIn=100000000000
tokenOutEthereum address of the token to swap or enter into a position totokenOut= 0x182b723a587...
routingStrategyRouting strategy either router, delegate or ensowalletroutingStrategy=router
toEOA(Deprecated) Flag that indicates if gained tokenOut should be sent to EOA, deprecated in favor of receivertoEOA=true
priceImpactFlag that indicates whether to calculate and return the price impact of the transactionpriceImpact=true
chainId(Optional) The chainId of the network. Default value is 1 for MainnetchainId=1
slippage(Optional) Slippage in basis points. Default value is 300 for 3%slippage=100 (1%)
tokenInAmountToApprove(Optional) If entering with EOA, Amount of tokenIn (ERC20) that needs to be approved to the wallet before the transaction in weitokenInAmountToApprove= 100000000000
tokenInAmountToTransfer(Optional) If entering with EOA, Amount of tokenIn (Ether) that needs to be transfer to the wallet before the transaction in weitokenInAmountToTransfer = 100000000000

Response

It returns an array of objects. The tx objects gives you the transaction to use in ethers. The other fields are a result of a transaction simulation.

FieldDescription
routeAn Array of objects containig:
tokenIn
positionInId
tokenOut
positionOutId
protocol
action
gasEstimated gas used by the transaction
amountOutEstimated amount out received
priceImpactPrice impact in basis points, null if USD price not found
createdAtBlock number the transaction was created on
txThe tx object to use in ethers. Contains sub-parameters:
-data
-to
-from
-value

Examples

Simple ETH to stETH

Spend Ether from the EOA and get stETH in return.

Specify a tokenIn (ETH), tokenOut (stETH) and either a sellAmount to get a route of 1 ETH for WETH. The route endpoint will calculate the best route for you, choosing between all the avilable AMM's and protocols (E.g. depositing directly to Lido).

If depositing directly to LIDO is the best route the tx object will contain the data to call the deposit function on the LIDO contract, otherwise it will contain the data to call the best AMM.

Request:

https://api.enso.finance/api/v1/shortcuts/route?chainId=1&fromAddress=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&receiver=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&spender=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&amountIn=1000000000000000000&slippage=300&tokenIn=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOut=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&routingStrategy=router

Response:

(Response route may differ)

{
  "gas": "399170",
  "amountOut": "1000071289649193663",
  "createdAt": 18684432,
  "tx": {
    "data": "0xb35d7e73000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000619198595a30081ffffffff81def1c0ded9bec7f1a1670819833240f027b25eff9bd3b227018102ffffffff016675a323dedb77822fcf39eaa9d682f6abe72555ddcd52200101ffffffffff017e7d64d987cab6eed08a191c4c2459daf2f8ed0ba9059cbb010301ffffffffffae7ab96520de3a18e5e111b5eaab095312d7fe846e7a43a3010104ffffffff017e7d64d987cab6eed08a191c4c2459daf2f8ed0b241c59120101ffffffffffff7e7d64d987cab6eed08a191c4c2459daf2f8ed0b000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000820000000000000000000000000000000000000000000000000000000000000086000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000006c8415565b0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe840000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d7660c0ce84cddf00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000001437572766500000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000d7660c0ce84cddf00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f670223df021240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000869584cd00000000000000000000000010000000000000000000000000000000000000110000000000000000000000000000000022614e7e3e5a0b1418f1ed151abed9ab000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa9604500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000d7660c0ce84cddd",
    "to": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
    "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "value": "1000000000000000000"
  },
  "route": [
    {
      "action": "apiswap",
      "protocol": "enso",
      "tokenIn": [
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "tokenOut": [
        "0xae7ab96520de3a18e5e111b5eaab095312d7fe84"
      ],
      "positionInId": [
        "1:0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "positionOutId": [
        "1:0xae7ab96520de3a18e5e111b5eaab095312d7fe84:0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ]
    }
  ]
}