Would
The
route
(client.getRouteData
) do the job? The
route
API might be the simpler way to route your assets.
Before using the bundle API, check if route
would suffice.To get the up-to date list of available actions and parameters, use GET
To get a list of actions available for a specific protocol, use GET
/integration/actions
.
To get a list of actions available for a specific protocol, use GET
standards/{slug}/
.Chaining Actions
It’s possible to chain actions: using the output of one action as the input for another. To reference outputs from previous actions use theuseOutputOfCallAt
syntax.
For array-outputs such as split
, you can specify the index within that action’s output array
Core Actions
route
The route action determines the optimal path to swap one token for another across multiple DeFi protocols supported by Enso.
This action gets expanded into a combination of swap
, deposit
, and redeem
actions, similar to /route
API.
The /bundle
API will return a route
object that contains a list of all such actions.
When using the
route
action, slippage is automatically calculated and applied.
The action will revert if the received amount is below the expected output after applying slippage.For other actions, make sure to add one of slippage protection actionsParameter | Description | Required |
---|---|---|
tokenIn | Address of the token to send. For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee | Yes |
tokenOut | Address of the token to receive | Yes |
amountIn | Amount of tokenIn to send in wei (with full decimals) | Yes |
slippage | Slippage tolerance in basis points (100 = 1%) | No |
receiver | Address to receive the output tokens if not the caller | No |
primaryAddress | Optional address of the router or primary contract to use | No |
poolFee | Optional pool fee in basis points when using specific pools | No |
swap
Swaps one token for another using a specific pool or exchange protocol.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of token to swap from | Yes |
tokenOut | Address of token to swap to | Yes |
amountIn | Amount of tokenIn to swap in wei (with full decimals) | Yes |
primaryAddress | Address of the router or pool contract | No |
receiver | Address to receive the output tokens | Yes |
slippage | Slippage tolerance in basis points (100 = 1%) | No |
poolFee | Optional pool fee in basis points when using specific pools | No |
poolId | The ID to identify the liquidity pool | No |
deposit
Deposits tokens into a protocol to receive a position token or add liquidity.
- Morpho
- Aave
Use the optional
positionId
to deposit into.Parameter | Description | Required |
---|---|---|
tokenIn | Address of token to deposit. Can be a single address or an array for multiple tokens | Yes |
tokenOut | Address of token to receive. Can be a single address or an array for multiple tokens. Omit if position is not represented by a token. | No |
amountIn | Amount of tokenIn to deposit in wei (with full decimals). Can be a single value or an array for multiple tokens | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the output tokens if not the caller | No |
positionId | Position ID to deposit into (e.g. Morpho Markets’ positions) | No |
redeem
Redeems underlying assets from a protocol by exchanging shares or tokens. Use it to exit a position and retrieve the desired tokens.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of shares/tokens to redeem | No |
tokenOut | Address of token(s) to receive upon redemption. Can be a single address or an array | Yes |
amountIn | Amount of shares/tokens to redeem in wei (with full decimals) | Yes |
primaryAddress | Address of the contract to interact with | Yes |
receiver | Address to receive the output tokens if not the caller | No |
Bridging
Thebridge
action lets you perform transactions spanning multiple chains.
It relies on Stargate and LayerZero to coordinate interactions.
bridge
Facilitates cross-chain token transfers using various bridge protocols with optional callback actions on the destination chain.
When used with callback actions (callback
array), it can automatically execute a series of actions on the destination chain once tokens arrive. Each callback action is executed sequentially on the destination chain.
Important: When using callbacks, the callback bundle MUST start with a balance action to check the bridged token balance on the destination chain.
Parameter | Description | Required |
---|---|---|
primaryAddress | Source bridge pool address | Yes |
destinationChainId | Target blockchain network ID | Yes |
tokenIn | Token address to bridge from source chain | Yes |
amountIn | Amount to bridge (with full decimals) or a reference to a previous action’s output | Yes |
receiver | Address to receive bridged tokens on destination chain | Yes |
callback | Array of actions to execute on the destination chain after bridging (must start with balance action) | No |
callbackValue | Additional value passed to the callback (in addition to bridge token) | No |
Slippage Protection
Whereas theroute
action includes configurable slippage protection by default, but other actions require manual slippage configuration.
Always include slippage protection via the
slippage
or minAmountOut
actions to prevent price impact.slippage
Applies slippage protection specified in basis points (bps
) to ensure the received amount is within the acceptable range of the expected output.
The action calculates the minimum acceptable amount based on the specified slippage tolerance (amountOut * (10000 - bps) / 10000
).
If the actual received amount falls below this threshold, the transaction will revert.
Parameter | Description | Required |
---|---|---|
amountOut | Expected output amount - must be output of one of previous actions useOutputOfCallAt | Yes |
bps | Maximum acceptable slippage in basis points (1 bps = 0.01%, 100 bps = 1%) | Yes |
minAmountOut
Applies slippage protection specified in absolute amount (minAmountOut
) to ensure the received amount is within the acceptable range of the expected output.
Parameter | Description | Required |
---|---|---|
amountOut | Expected output amount - must be output of one of previous actions useOutputOfCallAt | Yes |
minAmountOut | Minimum acceptable amount of out token | Yes |
Deposit & Redeem Actions
depositCLMM
Deposits tokens into a Concentrated Liquidity Market Maker pool (like Uniswap V3).
Parameter | Description | Required |
---|---|---|
tokenIn | Array of addresses of tokens to deposit (usually 2 tokens) | Yes |
tokenOut | Address of the position NFT to receive | Yes |
amountIn | Array of amounts to deposit in wei (with full decimals). Must match the length of tokenIn array | Yes |
ticks | Array containing lower and upper tick bounds defining the price range | Yes |
poolFee | Pool fee tier in basis points (e.g., 3000 for 0.3%) | Yes |
receiver | Address to receive the position NFT if not the caller | No |
tickSpacing | The minimum gap between valid price points for adding liquidity | No |
hook | The hook address for Uniswap V4 pools | No |
redeemCLMM
Redeems tokens from a Concentrated Liquidity Market Maker position (like Uniswap V3).
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the position NFT token | Yes |
tokenOut | Array of addresses of tokens to receive | Yes |
liquidity | Amount of liquidity to withdraw | Yes |
tokenId | ID of the position NFT | Yes |
receiver | Address to receive the underlying tokens if not the caller | No |
singleDeposit
Deposits a single token into a protocol. This is a specialized version of the deposit
action for single token deposits.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the single token to deposit | Yes |
tokenOut | Address of the token to receive (usually a receipt or share token) | No |
amountIn | Amount of tokenIn to deposit in wei (with full decimals) | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the output tokens if not the caller | No |
multiDeposit
Deposits multiple tokens into a protocol (like Curve or Balancer) in a single operation.
Parameter | Description | Required |
---|---|---|
tokenIn | Array of addresses of tokens to deposit | Yes |
tokenOut | Address of the LP token or receipt token to receive | No |
amountIn | Array of amounts to deposit in wei (with full decimals). Must match the length of tokenIn array | Yes |
primaryAddress | Address of the pool or protocol contract to interact with | Yes |
receiver | Address to receive the LP tokens if not the caller | No |
tokenizedSingleDeposit
Deprecation Notice: This action is deprecated in favor of using
singleDeposit
with the appropriate protocol. It will be removed in a future API version.Parameter | Description | Required |
---|---|---|
tokenIn | Address of token to deposit | Yes |
tokenOut | Address of tokenized position to receive | Yes |
amountIn | Amount of tokenIn to deposit in wei (with full decimals) | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the position tokens if not the caller | No |
tokenizedMultiDeposit
Deprecation Notice: This action is deprecated in favor of using
multiDeposit
with the appropriate protocol. It will be removed in a future API version.Parameter | Description | Required |
---|---|---|
tokenIn | Array of addresses of tokens to deposit | Yes |
tokenOut | Address of the tokenized position to receive | Yes |
amountIn | Array of amounts to deposit in wei (with full decimals). Must match the length of tokenIn array | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the position token if not the caller | No |
multiOutSingleDeposit
Deposits a single token and receives multiple output tokens (typically used for certain AMM positions).
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the single token to deposit | Yes |
tokenOut | Array of addresses of tokens to receive | Yes |
amountIn | Amount of tokenIn to deposit in wei (with full decimals) | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the output tokens if not the caller | No |
Lending Actions
borrow
Borrows a token from a lending protocol using a deposited token as collateral.
Parameter | Description | Required |
---|---|---|
collateral | Address of the token used as collateral. Can be an array for multiple collateral tokens | Yes |
tokenOut | Address of the token to borrow | Yes |
amountOut | Amount to borrow in wei (with full decimals) | Yes |
primaryAddress | Address of the lending pool contract | Yes |
repay
Repays a loan on a lending protocol.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of token to repay | Yes |
amountIn | Amount to repay in wei (with full decimals) | Yes |
primaryAddress | Address of the lending pool contract | Yes |
onBehalfOf | Address to repay debt for | Yes |
repay
on Behalf of Another address
Repay parameter onBehalfOf
enables you to repay a loan on behalf of a given address:
Yield Farming Actions
harvest
Harvests rewards from yield-generating positions.
Parameter | Description | Required |
---|---|---|
token | Address of token to harvest rewards for | Yes |
primaryAddress | Address of the contract to interact with (e.g., gauge, farm) | Yes |
Token Management Actions
approve
Approves a spender to use tokens.
Parameter | Description | Required |
---|---|---|
token | Address of the token to approve | Yes |
spender | Address of the spender (protocol or router) | Yes |
amount | Amount to approve in wei (with full decimals) | Yes |
transfer
Transfers tokens to a specified address.
Parameter | Description | Required |
---|---|---|
token | Address of the token to transfer | Yes |
receiver | Address of the recipient | Yes |
amount | Amount to transfer in wei (with full decimals) | Yes |
id | Token ID for ERC721 or ERC1155 tokens | No |
transferFrom
Transfers tokens from a specified address to another address.
Parameter | Description | Required |
---|---|---|
token | Address of the token to transfer | Yes |
sender | Address of the sender | Yes |
receiver | Address of the recipient | Yes |
amount | Amount to transfer in wei (with full decimals) | Yes |
id | Token ID for ERC721 or ERC1155 tokens | No |
permitTransferFrom
Approves and transfers a token that supports permit in a single step using a signature. A permit signature needs to be generated offchain and passed to the API.
Parameter | Description | Required |
---|---|---|
token | Address of the token to transfer. Can be an array for multiple tokens | Yes |
amount | Amount to transfer in wei (with full decimals). Can be an array for multiple tokens | Yes |
sender | Address of the sender | Yes |
receiver | Address of the recipient | Yes |
nonce | Nonce value to prevent signature replay | Yes |
deadline | Timestamp after which the signature is invalid | Yes |
signature | The EIP-2612 permit signature | Yes |
Utility Actions
balance
Gets the balance of a token for the caller’s address.
Parameter | Description | Required |
---|---|---|
token | Address of the token to check balance | Yes |
split
Splits a token into multiple outputs with specified token addresses and amounts.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the token to split | Yes |
tokenOut | Array of token addresses for the split outputs | Yes |
amountIn | Amount to split in wei (with full decimals) | Yes |
receiver | Address to receive the split tokens | No |
merge
Merge multiple token inputs into a single output.
Parameter | Description | Required |
---|---|---|
tokenIn | Array of input token addresses | Yes |
tokenOut | Address of the output token | Yes |
amountIn | Array of amounts to merge (must be in the same denomination) | Yes |
receiver | Address to receive the merged tokens | No |
call
Makes an arbitrary call to any contract, allowing for custom interactions. For example, making a custom contract call when the protocol demands additional arguments.
This is useful for executing complex logic or interacting with contracts that are not directly supported by the Enso API.
To perform arithemtics over return values from previous actions, you can use the PercentageMathHelpers contract:
call
action documentation:
Parameter | Description | Required |
---|---|---|
address | Address of the contract to call | Yes |
method | Name of the method to call | Yes |
abi | ABI signature of the method | Yes |
args | Array of arguments to pass to the method | Yes |
tokenIn | Input token address (when tokens are involved in the call) | No |
tokenOut | Output token address (when tokens are involved in the call) | No |
value | ETH value to send with the transaction in wei | No |
fee
Calculates and deducts a fee from a specified amount, sending the fee to a designated receiver. This action is typically prepended to bridge operations to facilitate fee collection.
The fee
action calculates the fee as amount * (bps/10000)
and sends this amount to the receiver
. It returns amount - fee
, which can be used in subsequent actions via useOutputOfCallAt
.
Parameter | Description | Required |
---|---|---|
token | Token address to apply the fee to | Yes |
amount | Amount to apply the fee to (with full decimals) or a return value from a previous action | Yes |
bps | Fee percentage in basis points (1 bps = 0.01%, 100 bps = 1%) | Yes |
receiver | Address to receive the fee | Yes |
ensofee
Calculates and deducts Enso’s protocol fee from a specified amount.
The fee
action calculates the fee as amount * (bps/10000)
and sends this amount to Enso.
It returns amount - fee
, which can be used in subsequent actions via useOutputOfCallAt
.
Parameter | Description | Required |
---|---|---|
token | Token address to apply the fee to | Yes |
amount | Amount to apply the fee to (with full decimals) or a return value from a previous action | Yes |
bps | Fee percentage in basis points (1 bps = 0.01%, 100 bps = 1%) | Yes |
Protocol Support
The Bundle API supports a wide range of protocols. Some common ones include:aave-v2
,aave-v3
: Aave lending/borrowingbalancer-v2
: Balancer liquidity poolscurve
: Curve Finance stable swaps and gaugescurve-gauge
: Curve gauges for stakingerc20
: Standard token operationserc4626
: ERC4626 vaultsenso
: General Enso operations including route and arbitrary callspermit2
: Uniswap’s Permit2 operationsuniswap-v2
,uniswap-v3
: Uniswap pools and routersyearn
: Yearn Finance vaultscompound-v2
,compound-v3
: Compound lending/borrowingstargate
: Cross-chain bridging
/standards
.
Updated