What is the Bundle API?
The Bundle API is a powerful tool within the ENSO API suite that lets developers pack several DeFi actions into one single transaction. This REST API is designed for simplicity and effectiveness. With just one API call, you can trigger several operations, making your interaction with various DeFi simpler and cheaper.
When first used, it automatically deploys a minimal smart wallet which is then used to execute the bundled transactions. The smart wallet can be controlled only by the user and is the execution context when doing transactions.
Moreover, the Bundle API excels in gas optimization. The more transactions you bundle, the more you can save on gas fees. This makes it an economical choice for users seeking to execute multiple operations efficiently in the DeFi space.
From entering and exiting positions to performing multi-token swaps, the Bundle API can combine any number of these actions into a single transaction. This bundling mechanism works across a multitude of DeFi protocols, such as liquidity pools, lending platforms, automated market makers, yield optimizers, and more.
The Bundle API takes care of optimizing the execution sequence and estimating the gas costs for the bundled actions, providing users with a clear picture of the transaction before execution.
Gas Savings
More transactions bundled together means more gas savings. The Bundle API is designed to optimize the execution sequence of the bundled actions, which can result in significant gas savings:
Try it out:
👉 Run this curl request to see a live route response for entering a Curve Pool AND stEth position with ETH
curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 1e02632d-6feb-4a75-a157-documentation' \
-d '[
{
"protocol": "enso",
"action": "route",
"args": {
"tokenIn": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"tokenOut": "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
"amountIn": "1000000000"
}
},
{
"protocol": "enso",
"action": "route",
"args": {
"tokenIn": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"tokenOut": "0x06325440d014e39736583c165c2963ba99faf14e",
"amountIn": "1000000000"
}
}
]' \
'https://api.enso.finance/api/v1/shortcuts/bundle?chainId=1&fromAddress=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
👉 Or try it out in the Swagger UI (opens in a new tab)
Details: Let's say you want to go from Ether to the steCrv Curve pool. Also, you want to deposit the Curve LP into the Curve Gauge. In the route endpoint you would simply pass a tokenIn (Ether), the amount and the tokenOut (the Curve Gauge).
Enso will take care to swap your token in to the required token (if needed), deposit the LP into the Curve Gauge and stake the LP tokens into the Curve Gauge.