# For Developers

This section describes the main technical elements required for smart contract integration, if you have any specific questions please don't hesitate to contact us.

### Portfolio Data <a href="#slm1mvhzijp6" id="slm1mvhzijp6"></a>

#### getTokens <a href="#hkuz5pqy2puv" id="hkuz5pqy2puv"></a>

Returns the current list of tokens in the vault.

**Function Signature:** getTokens() external view returns (address\[] memory)

**Returns:**

* An array of addresses representing the tokens in the vault.

**Usage:**

This function provides a list of all tokens currently held in the vault, allowing users to get an overview of the vault's composition. By converting the token balances to USD, the total value of the vault can be calculated. Dividing this total value by the total supply of portfolio tokens results in the price of each portfolio token. Additionally, the weights can be identified by knowing the USD values of each token or having a common value for each token.

#### totalSupply <a href="#pomqxgmqbjkp" id="pomqxgmqbjkp"></a>

Returns the total supply of the portfolio tokens.

**Function Signature:** totalSupply() external view returns (uint256)

**Returns:**

* A uint256 representing the total supply of the portfolio tokens.

**Usage:** This function provides the total supply of the portfolio tokens. It is useful for understanding the overall amount of tokens issued by the portfolio.

### Deposit <a href="#id-2r572le4o66r" id="id-2r572le4o66r"></a>

#### multiTokenDeposit <a href="#id-3a51frjh0kri" id="id-3a51frjh0kri"></a>

Allows the sender to deposit multiple tokens into the fund.

**Function Signature:** multiTokenDeposit(uint256\[] calldata depositAmounts, uint256 \_minMintAmount, IAllowanceTransfer.PermitBatch calldata \_permit, bytes calldata \_signature) external

**Parameters:**

* depositAmounts: Array of amounts for each token to deposit.
* \_minMintAmount: Minimum amount of portfolio tokens expected to mint. This is used to protect against slippage.
* \_permit: Permit batch for tokens. This includes details for each token, spender address, and the signature deadline.
* \_signature: Signature for the permit batch.

#### multiTokenDepositFor <a href="#id-1r4r5h9s7cja" id="id-1r4r5h9s7cja"></a>

Allows a specified depositor to deposit multiple tokens into the fund.

**Function Signature:** multiTokenDepositFor(address \_depositFor, uint256\[] calldata depositAmounts, uint256 \_minMintAmount) external

**Parameters**:

* \_depositFor: Address of the user for whom the deposit is being made.
* depositAmounts: Array of amounts for each token to deposit.
* \_minMintAmount: Minimum amount of portfolio tokens expected to mint. This is used to protect against slippage.

### Withdraw <a href="#yt0e6oe5h9pr" id="yt0e6oe5h9pr"></a>

#### multiTokenWithdrawalFor <a href="#of4mupkw07f4" id="of4mupkw07f4"></a>

Allows an approved user to withdraw portfolio tokens on behalf of another user.

**Function Signature:** multiTokenWithdrawalFor(address \_withdrawFor, address \_tokenReceiver, uint256 \_portfolioTokenAmount) external

**Parameters:**

* \_withdrawFor: Address of the user on whose behalf the withdrawal is being made.
* \_tokenReceiver: Address where the withdrawn portfolio tokens will be sent.
* \_portfolioTokenAmount: Amount of portfolio tokens to withdraw.

**Usage:** This function allows an approved user to withdraw a specified amount of portfolio tokens on behalf of another user. The portfolio tokens are sent to the specified \_tokenReceiver address.

#### multiTokenWithdrawal <a href="#kamfqmjh61q5" id="kamfqmjh61q5"></a>

Allows users to withdraw their deposit from the fund.

**Function Signature:** multiTokenWithdrawal(uint256 \_portfolioTokenAmount) external

**Parameters:**

* \_portfolioTokenAmount: Amount of portfolio tokens to withdraw.

**Usage:** This function allows users to withdraw their deposits from the fund by burning the specified amount of portfolio tokens.

#### emergencyWithdrawal <a href="#arq8uyt7rtz3" id="arq8uyt7rtz3"></a>

Allows users to perform an emergency withdrawal.

**Function Signature:** emergencyWithdrawal(uint256 \_portfolioTokenAmount, address\[] memory \_exemptionTokens) external

**Parameters:**

* \_portfolioTokenAmount: Amount of portfolio tokens to withdraw.
* \_exemptionTokens: Array of token addresses that are exempt from withdrawal restrictions.

**Usage:** This function allows users to perform an emergency withdrawal of their funds. The \_exemptionTokens parameter lets users specify tokens they are willing to lose due to potential transfer issues. These tokens are handled within a try-catch block; if a transfer restriction or any other issue arises with a specified \_exemptionToken, the error is caught, and the withdrawal process continues without withdrawing that underlying portfolio token.

#### emergencyWithdrawalFor <a href="#pty1eufriv7z" id="pty1eufriv7z"></a>

Allows an authorized user to perform an emergency withdrawal on behalf of another user.

**Function Signature:** emergencyWithdrawalFor(address \_withdrawFor, address \_tokenReceiver, uint256 \_portfolioTokenAmount, address\[] memory \_exemptionTokens) external

**Parameters:**

* \_withdrawFor: Address of the user on whose behalf the emergency withdrawal is being made.
* \_tokenReceiver: Address where the withdrawn tokens will be sent.
* \_portfolioTokenAmount: Amount of portfolio tokens to withdraw.
* \_exemptionTokens: Array of token addresses that are exempt from withdrawal restrictions.

**Usage:** This function allows users to perform an emergency withdrawal on behalf of another user. The \_exemptionTokens parameter lets users specify tokens they are willing to lose due to potential transfer issues. These tokens are handled within a try-catch block; if a transfer restriction or any other issue arises with a specified \_exemptionToken, the error is caught, and the withdrawal process continues without withdrawing that underlying portfolio token.

### Claim Removed Portfolio Tokens <a href="#pq1iw0ybqhp6" id="pq1iw0ybqhp6"></a>

#### claimRemovedTokens <a href="#n7253a2022jf" id="n7253a2022jf"></a>

Allows users to claim their share of removed portfolio tokens.

**Function Signature:** claimRemovedTokens(address user, uint256 startId, uint256 endId) external

**Parameters:**

* user: Address of the user claiming the tokens.
* startId: The starting ID from which tokens are being claimed.
* endId: The ending ID up to which tokens are being claimed.

**Usage:** This function allows users to claim their share of removed tokens within a specified range, from startId to endId. It is useful for claiming multiple tokens in one transaction.

#### claimTokenAtId <a href="#uep5gpxfqy4" id="uep5gpxfqy4"></a>

Claims a removed token for a given user at a specific ID.

**Function Signature:** claimTokenAtId(address user, uint256 id) external

**Parameters:**

* user: Address of the user claiming the token.
* id: The ID of the token being claimed.

**Usage:** This function allows a user to claim a removed token at a specific ID. It is useful for claiming a single token without needing to specify a range.

#### getDataAtId <a href="#o976mymyjxxr" id="o976mymyjxxr"></a>

Retrieves the validity and balance of a user's interaction at a given ID.

**Function Signature:** getDataAtId(address user, uint256 id) external view returns (bool, uint256)

**Parameters:**

* user: Address of the user.
* id: The ID for which data is being retrieved.

**Returns:**

* bool: A boolean indicating the validity of the interaction at the given ID.
* uint256: The balance of the user at the given ID.

**Usage:** This function retrieves the validity and balance of a user's interaction at a specific ID. It is useful for verifying the status and amount of tokens before performing a claim.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.velvet.capital/for-developers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
