GET /v1/shortcuts/route

GET /v1/shortcuts/route

Use this endpoint to calculate the optimal route for entering or exiting any DeFi position or swapping any ERC20 tokens. The API analyzes various DeFi protocols and exchanges to determine the most efficient path.

The response includes:

  • A transaction object (tx), ready for submission to blockchain. This is a valid, unsigned Ethereum transaction that executes the recommended route.
  • A simulation of the transaction, providing a detailed quote, including expected gas used, amount out and price impact.
ℹ️

If tokenIn is not native token (ETH), ensure the necessary allowances are set.

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 spender of the tokenInspender=0xd8da6bf2...
receiverEthereum address of the receiver of the tokenOutreceiver=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 50 for 0.5%slippage=100 (1%)
fee(Optional) Fee in basis points. Must be in range 0-100. If specified, this percentage of amountIn value will be sent to feeReceiverfee=100 (1%)
feeReceiver(Optional) Ethereum address that will receive the collected fee amount if fee was provided.feeReceiver=0x220866B1A22...

Response

Returns an object. The tx object contains transaction details to use for transaction execution in Ethers/Viem. The other fields are a result of a transaction simulation.

FieldDescription
routeAn Array of objects containing:
tokenIn
positionInId
tokenOut
positionOutId
protocol
action
gasEstimated gas used by the transaction. Since it's an estimation, it is usually good practice to increase it by 50%
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/Viem. Contains sub-parameters:
-data
-to
-from
-value
feeAmountAn Array containting all the collected fee amounts for each amountIn input
(Only if fee was provided).

Examples

Simple ETH to stETH

Spend Ether from the EOA and get stETH in return.

To initiate a route, specify:

  • tokenIn (ETH)
  • tokenOut (stETH)
  • amountIn (the amount of ETH to swap in wei)

The route endpoint will calculate the best route for you, selecting the best option from all available AMMs and protocols (E.g. depositing directly to Lido).

If depositing directly to Lido is the optimal route, the tx object will contain the necessary data to call Lido’s deposit function. Otherwise, the tx object will include the required data to interact with the best available AMM.

Request:

curl "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&apikey=1e02632d-6feb-4a75-a157-documentation"

Response:

ℹ️

The returned route may vary. As a best practice, increase the estimated gas by approximately 50%.

{
  "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"
      ]
    }
  ]
}

Simple ETH to stETH with a fee

Spend Ether from the EOA and receive stETH, while deducting an ETH fee.

This example works the same way as the Simple ETH to stETH, with one difference:

  • A portion of amountIn, specified in the fee field, is deducted as a fee.
  • The deducted fee is then transferred to the account specified in feeReceiver

Request:

curl "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&fee=100&feeReceiver=0x220866B1A2219f40e72f5c628B65D54268cA3A9D&apikey=1e02632d-6feb-4a75-a157-documentation"

Response:

ℹ️

The returned route may vary. As a best practice, increase the estimated gas by approximately 50%.

{
  "gas": "324023",
  "amountOut": "990357020771139559",
  "feeAmount": ["10000000000000000"],
  "createdAt": 19471563,
  "tx": {
    "data": "0xb35d7e73000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000007a3e76c0f0300ffffffffffff220866b1a2219f40e72f5c628b65d54268ca3a9d19198595a30182ffffffff826352a56caadc4f1e25cd6c75970fa768a3304e649bd3b227018203ffffffff026675a323dedb77822fcf39eaa9d682f6abe72555ddcd52200102ffffffffff027e7d64d987cab6eed08a191c4c2459daf2f8ed0ba9059cbb010402ffffffffffae7ab96520de3a18e5e111b5eaab095312d7fe846e7a43a3010205ffffffff027e7d64d987cab6eed08a191c4c2459daf2f8ed0b241c59120102ffffffffffff7e7d64d987cab6eed08a191c4c2459daf2f8ed0b000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000088000000000000000000000000000000000000000000000000000000000000008c000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000dbd2fc137a30000000000000000000000000000000000000000000000000000000000000000070490411a32000000000000000000000000a9c0cded336699547aac4f9de5a11ada979bc59a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84000000000000000000000000a9c0cded336699547aac4f9de5a11ada979bc59a0000000000000000000000007d585b0e27bbb3d981b7757115ec11f47c4769940000000000000000000000000000000000000000000000000dbd2fc137a300000000000000000000000000000000000000000000000000000d54e7d8dc6d23e80000000000000000000000000000000000000000000000000dbe759d96b5226000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000dc24316b9ae028f1497c275eb9192a3ea0f6702200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dbd2fc137a30000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000843df02124000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000dbd2fc137a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e85000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a00000000000000000000000000000000000000000000000000dbe759d96b5226000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe8400000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe840000000000000000000000007d585b0e27bbb3d981b7757115ec11f47c4769940000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa9604500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000d54e6bab7295dfc",
    "to": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
    "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "value": "1000000000000000000"
  },
  "route": [
    {
      "action": "swap",
      "protocol": "enso",
      "tokenIn": ["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"],
      "tokenOut": ["0xae7ab96520de3a18e5e111b5eaab095312d7fe84"]
    }
  ]
}