Actions

Summary

Actions are standardized interactions related to contract calls, allowing for quick development integration than requiring to handle each individual function signature for each protocol, you can simply use these actions for interacting which associates the function calls of a protocol.

Example of Abstraction

Depositing into a position is applicable to many protocols, and each protocol has different function signatures for example:

Before

balancer: joinPool(bytes32 poolId, address sender, address recipient, (address[] assets, uint256[] maxAmountsIn, bytes userData, bool fromInternalBalance)
uniswap: addLiquidity(address tokenA,address tokenB,uint amountADesired,uint amountBDesired,uint amountAMin,uint amountBMin,address to,uint deadline) external returns (uint amountA, uint amountB, uint liquidity)
beefy: deposit(uint256)
morpho: supply(address poolToken, address user, uint256 amount)

After

With Enso you can simply use Deposit for all protocols resulting in quick, and easy integration with all the logic for each particular protocol deposit logic abstracted away.

You can use the deposit action inside of the bundle endpoint.

{
    protocol: "morpho",
    args: {
        tokenIn: weth,
        tokenOut: b80bal20weth,
        amountIn: wethAmount
        primaryAddress: morphoVault
    },
    action: "deposit",
},
tokenIn: 'Address of token to send' // You can define many tokens in by [inToken1, inToken2]
  ? tokenOut
  : 'Address of token to receive' // Optional - protocols that have isolated contracts per each deposit(for example Yearn), then you do not need to define tokenOut.  For protocols that have a shared contract for all of their vaults/deposits such as balancer and univ4 then you should define tokenOut
amountIn: 'Raw amount to send' // You can define many tokens out by [outToken1, outToken2]
primaryAddress: 'Address of smart contract to interact with' // Address of smart contract to interact with

Endpoints

GET /api/v1/actions (opens in a new tab)

The actions endpoint returns all actions that are applicable to be used within the Enso API for convenience, however you can still do arbitrary calls if there are standards missing for the actions you'd like to complete which can be seen here.

💡

Try it out!

curl -X 'GET' \
  -H "Content-Type: application/json" \
  'https://api.enso.finance/api/v1/actions' \

You will receive a response that looks like this:

[
  {
    "inputs": {
      "tokenIn": "Address of token to send",
      "tokenOut": "Address of token to receive",
      "amountIn": "Raw amount to send",
      "primaryAddress": "Address of smart contract to interact with"
    },
    "name": "deposit"
  }
]

Which returns the list of actions, and inputs required for each action.

As of actions that Enso API currently supports is:

  1. Route
  2. Deposit
  3. Harvest
  4. Borrow
  5. Repay
  6. Redeem
  7. Swap
  8. Transfer
  9. Withdraw
  10. Approve
  11. PermitTransferFrom

If you require an action to be supported, please open up an issue on github (opens in a new tab)