Deposit
Depositing is the action for taking funds from the callers wallet into a particular protocol.
- For many cases you can directly use the route endpoint to enter into a position than directly using the deposit action. The route endpoint will determine the best price and gas router for either depositing directly into the protocol, or buying the position token on a secondary market.
- If you are depositing into a protocol you must have the underlying token required for the deposit action. For example if you are attempting to deposit into a Yearn vault that requires WETH and you define DAI as the tokenIn then the transaction will fail. This is a perfect use case for using the route endpoint.
NOTE: Direct deposit actions doesn't have slippage protection. If you are interacting with a protocol that needs slippage protection use the route endpoint
Argument | Description | Example |
---|---|---|
tokenIn | Address of token to send. You can define many tokens in by [inToken1, inToken2] | tokenIn=0x3b175474e8909... |
amountIn | Raw amount to send. You can define many tokens out by [outToken1, outToken2] | amountIn=100000000000 |
tokenOut | Address of token to receive | tokenOut=0x6b175474e8909... |
primaryAddress | Address of smart contract to interact with e.g. Balancer Vault | primaryAddress=0x7b175474e8909.. |
recipient | Address of the receiver. Optional - if you want to send the tokens to a different address than the smart wallet | recipient=0x8b175474e8909... |
Example
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: "balancer-v2",
args: {
tokenIn: weth,
tokenOut: b80bal20weth,
amountIn: wethAmount
primaryAddress: balancerVault
},
action: "deposit",
},
Endpoints
POST /api/v1/shortcuts/bundle (opens in a new tab)
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 1e02632d-6feb-4a75-a157-documentation" \
--data '[
{
"action": "deposit",
"args": {
"tokenIn": "0xba100000625a3754423978a60c9317c58a424e3d",
"tokenOut": "0x5c6Ee304399DBdB9C8Ef030aB642B10820DB8F56",
"amountIn": "1000000000000000000",
"primaryAddress": "0xba12222222228d8ba445958a75a0704d566bf2c8",
},
"protocol": "balancer-v2"
}]' \
"https://api.enso.finance/api/v1/shortcuts/bundle?chainId=1&fromAddress=0xd8da6bf26964af9d7eed9e03e53415d37aa96045"