Actions
Actions are interactions with DeFi protocols Enso supports.
The Bundle API supports a variety of actions to build complex DeFi strategies. This reference guide explains all available actions and their parameters.
To get the up-to date list of available actions and parameters, use GET /integration/actions
.
To get a list of actions available for a specific protocol, use GET standards/{slug}/
.
Chaining Actions
Bundle API allows using output of one action as the input for another.
To reference outputs from previous actions use the useOutputOfCallAt
syntax.
For array-outputs such as split
, you can specify the index within that action’s output array
Here’s an example of a more complex chaining sequence that splits WETH into three different
slippage
Applies slippage protection 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. This action should be included manually when not using the route
action, which has built-in slippage protection.
When using the bundler without the route
action, always include slippage protection via the slippage
action to prevent excessive price impact. The route
action includes slippage protection by default, but other actions require manual slippage configuration.
Parameter | Description | Required |
---|---|---|
bps | Maximum acceptable slippage in basis points (1 bps = 0.01%, 100 bps = 1%) | Yes |
amountOut | Expected output amount (with full decimals) or a return value from a previous action via useOutputOfCallAt | Yes |
Core Actions
route
The route action determines the optimal path to swap one token for another across multiple DeFi protocols supported by Enso.
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 slippage
action to the bundle to ensure the transaction doesn’t revert due to price impact.
Parameter | 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 if not the caller | Yes |
slippage | Slippage tolerance in basis points (100 = 1%) | No |
poolFee | Optional pool fee in basis points when using specific pools | No |
call
Makes an arbitrary call to any contract, allowing for custom interactions. This is useful for executing complex logic or interacting with contracts that are not directly supported by the Enso API.
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 |
Deposit Actions
deposit
Deposits tokens into a protocol to receive a position token or add liquidity.
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 | 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 |
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.
Deposits a single token and receives a tokenized position.
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.
Deposits multiple tokens and receives a tokenized position.
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 |
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 |
fee | 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 |
Withdrawal/Redeem Actions
withdraw
Withdraws tokens from a DeFi position.
Parameter | Description | Required |
---|---|---|
primaryAddress | Address of the protocol contract to interact with | Yes |
tokenIn | Address of the token to withdraw from (often a share or receipt token) | Yes |
tokenOut | Address of the underlying token to receive | Yes |
amountOut | Amount of tokenOut to withdraw in wei (with full decimals) | Yes |
receiver | Address to receive the withdrawn tokens if not the caller | 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 |
singleRedeem
Redeems a single token from a protocol.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the share/receipt token to redeem | No |
tokenOut | Address of the underlying token to receive | Yes |
amountIn | Amount of shares to redeem in wei (with full decimals) | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the underlying tokens if not the caller | No |
multiRedeem
Redeems a token from a protocol and receives multiple tokens (like LP token redemption).
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the LP token or share token to redeem | No |
tokenOut | Array of addresses of underlying tokens to receive | Yes |
amountIn | Amount of tokenIn to redeem in wei (with full decimals) | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the underlying tokens if not the caller | No |
tokenizedSingleRedeem
Deprecation Notice: This action is deprecated in favor of using singleRedeem
with the appropriate protocol. It will be removed in a future API version.
Redeems a tokenized position for a single underlying token.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the tokenized position to redeem | Yes |
tokenOut | Address of the underlying token to receive | Yes |
amountIn | Amount of tokenIn to redeem in wei (with full decimals) | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the underlying tokens if not the caller | No |
tokenizedMultiRedeem
Deprecation Notice: This action is deprecated in favor of using multiRedeem
with the appropriate protocol. It will be removed in a future API version.
Redeems a tokenized position for multiple underlying tokens.
Parameter | Description | Required |
---|---|---|
tokenIn | Address of the tokenized position to redeem | Yes |
tokenOut | Array of addresses of underlying tokens to receive | Yes |
amountIn | Amount of tokenIn to redeem in wei (with full decimals) | Yes |
primaryAddress | Address of the protocol contract to interact with | Yes |
receiver | Address to receive the underlying tokens if not the caller | 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 |
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 |
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 |
Bridging
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.
Callbacks can reference outputs from previous callback actions using the useOutputOfCallAt
syntax to create complex cross-chain operations. Each callback action is executed sequentially 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 | 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 |
Utility Actions
split
Splits an amount into multiple parts based on specified percentages.
Parameter | Description | Required |
---|---|---|
amount | Amount to split in wei (with full decimals) | Yes |
percentages | Array of percentages in basis points (must sum to 10000) | Yes |
merge
Merges multiple amounts into a single total.
Parameter | Description | Required |
---|---|---|
amounts | Array of amounts to merge (must be in the same denomination) | Yes |
balance
Gets the balance of a token for a specified account.
Parameter | Description | Required |
---|---|---|
token | Address of the token to check balance | Yes |
account | Address of the account to check | Yes |
minAmountOut
Calculates the minimum amount out based on expected amount and slippage.
Parameter | Description | Required |
---|---|---|
amount | Expected output amount in wei (with full decimals) | Yes |
slippage | Slippage tolerance in basis points (100 = 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/borrowingaxelar
: Cross-chain bridging
For a complete list of supported protocols, use the Projects API endpoint: GET /standards
.
Updated