Routing Strategy Examples
enso wallet
Enter a position from 1 token

Enter a single position from 1 token

In this example, we will have a user that has 1 WETH (opens in a new tab) in their Ethereum mainnet wallet, and wants to deposit 1 WETH into Beefy Aura wstETH-ETH (opens in a new tab)

💡

Beefy Aura wstETH-ETH token is multihopping over 4 DeFi protocols

Step 1: Approve

The user must approve the WETH first on the contract so that the contract can execute the bundle of transactions.

Approve: Fetch address

Each user has their own respective routing contract which will be deployed, and executed in the same transaction when the execution transaction is submitted. This reduces the risks of approvals with a single-point of failure contract, and the user that is submitting the transaction is the owner of that contract not Enso, further reducing the risk.

Fetch address to approve:

curl -X GET \
  -H "Accept: application/json" \
  "https://api.enso.finance/api/v1/wallet?chainId=1&fromAddress=0x57757E3D981446D585Af0D9Ae4d7DF6D64647806"
chainid: "Chain ID to execute the approval on", // 1 = Ethereum Mainnet, [full networks](../networks)
fromAddress: "EOA address that is executing the approval", // 0x57757E3D981446D585Af0D9Ae4d7DF6D64647806

You will be returned with:

{
  "address": "0xD6A4217CF6A3587B4E33e9a59C52BF57469e713a", // Individual contract owned by the EOA
  "isDeployed": false
}

If the user has already used Enso through another integrator, then isDeployed will be true.

Approve: Approve Transaction

Enso:

curl -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer 1e02632d-6feb-4a75-a157-documentation" \
  "https://api.enso.finance/api/v1/wallet/approve?chainId=1&fromAddress=0x57757E3D981446D585Af0D9Ae4d7DF6D64647806&tokenAddress=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&amount=1000000000000000000000000000"

Ethers:

await ERC20(0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2).approve(address, 5 Ether) // take decimals of the token you're approving into account

Step 2: Execute

Execute: Build actions

We are using the Route endpoint as this it compares the best execution route for token amount out, and gas execution price. For example, it might be better to purchase stEth on a DEX than directly depositing it depending upon the exchange rate of that token on the secondary market.

curl -X 'GET' \
  'https://api.enso.finance/api/v1/shortcuts/route?chainId=1&fromAddress=0x57757E3D981446D585Af0D9Ae4d7DF6D64647806&receiver=0x57757E3D981446D585Af0D9Ae4d7DF6D64647806&spender=0x57757E3D981446D585Af0D9Ae4d7DF6D64647806&amountIn=1000000000000000000&slippage=300&tokenIn=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOut=0xe0d5f9da3613c047003b77caa31270abe3eda6b0' \
  -H 'accept: application/json'

The data value contains the bundle calldata to be submitted to the user.