Welcome to the Velvet Intents API documentation! This API provides a efficient way to trade assets within your Velvet vaults programmatically. Designed for flexibility and ease of integration, the API allows you to automate trading activities.
Dive into this documentation to get started on exploring key endpoints, and discovering how to optimize your trading experience on Velvet Vaults.
Trade Steps
There are three steps to trade assets programmatically
In this step, the Rebalance API endpoint is utilized to retrieve essential call data and other necessary inputs required to execute trades within a vault.
rebalanceAddress (string): The rebalancing address of portfolio in which you wish to perform the trade. This address is retrieved from the previous step.
sellToken (string): The token that you intend to sell.
buyToken (string): The token that you wish to buy.
sellAmount (string): The amount of the sell token.
Note: The sellAmount should be specified in a big number format based on the token's decimal. For example: 1 USDC, the value would be "1000000" since USDC is 6 decimal token.
slippage (string): Set this value to "100" (1%)
remainingTokens (string[]): An array of the remaining tokens in the vault after executing the trade. (Tokens can be in any order)
Note: Assuming a fund only has USDC in the vault. After trading 50% amount of USDC to WETH, the fund will now have both USDC and WETH tokens. So in this case the remainingTokens would be array of both of these tokens addresses.
owner (string): The address of vault owner.
Response Schema:
The response will contain a JSON object that includes the trade details necessary for the final step of the process.
Velvet Intents API
Welcome to the Velvet Intents API documentation! This API provides a efficient way to trade assets within your Velvet vaults programmatically. Designed for flexibility and ease of integration, the API allows you to automate trading activities.
Dive into this documentation to get started on exploring key endpoints, and discovering how to optimize your trading experience on Velvet Vaults.
Trade Steps
There are three steps to trade assets programmatically
Fetch All Created Vaults
To retrieve all created vaults associated with a specific owner wallet on Velvet V3, use the following endpoint:
HTTP Request:
Parameters:
Response Schema:
The response will contain a JSON object with the details of all portfolios created by the specified wallet on Velvet V3.
Using Rebalance API Endpoint
In this step, the Rebalance API endpoint is utilized to retrieve essential call data and other necessary inputs required to execute trades within a vault.
HTTP Request:
Parameters:
Note: The
sellAmount
should be specified in a big number format based on the token's decimal. For example:1 USDC
, the value would be"1000000"
since USDC is6
decimal token."100"
(1%)Note: Assuming a fund only has
USDC
in the vault. After trading50%
amount ofUSDC
toWETH
, the fund will now have bothUSDC
andWETH
tokens. So in this case theremainingTokens
would be array of both of these tokens addresses.Response Schema:
The response will contain a JSON object that includes the trade details necessary for the final step of the process.
Executing the trade
In this final step, we will leverage the trade data obtained from the previous step to execute the trade.
To get started, you need to install the Ethers.js library.
Using the contract ABI and rebalancing address, you can create an instance of the Rebalance contract and execute the trade:
That's it! You can follow these steps to execute trade for other vaults. Happy coding! 🎉