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 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 300 for 3%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...
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 containing:
tokenIn
positionInId
tokenOut
positionOutId
protocol
action
gasEstimated gas used by the transaction. Being an estimation, 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. 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.

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, good practice is to increase the estimated gas by approx. 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 get stETH in return extracting an ETH fee.

This example is the same as the one before, only that it extracts the correspondent ETH amount specified in the fee field from amountIn and transfers it to the ethereum account specified in the feeReceiver parameter.

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&fee=100&feeReceiver=0x220866B1A2219f40e72f5c628B65D54268cA3A9D

Response:

(Response route may differ)

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