# Vault

## Types

### ActionType

```solidity
enum ActionType {
    DEPOSIT,
    REBALANCE,
    REDEEM
}
```

### SwapDataExecution

<pre class="language-solidity"><code class="lang-solidity">struct SwapDataExecution {
<strong>    ActionType action;
</strong>    bytes[] swapTxs;
    uint256[] tokenBalancesBefore;
    uint256[] currentPositions;
    uint256 shareOrBaseTokenAmount;
    uint256 totalShareSupply;
}
</code></pre>

| Name                     | Type       | Description                                  |
| ------------------------ | ---------- | -------------------------------------------- |
| `swapTxs`                | bytes\[]   | swap data transaction                        |
| `tokenBalancesBefore`    | uint256\[] | list of vault asset balances before the swap |
| `currentPositions`       | uint256\[] | list of vault positions                      |
| `shareOrBaseTokenAmount` | uint256    | share or base token amount swapped           |
| `totalShareSupply`       | uint256    | total supply of shares                       |

## View Methods

### getConstantProps

```solidity
function getConstantProps() external view virtual returns (VLib.ConstantProps memory)
```

Returns the Constant properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information

### getHistoryProps

```solidity
function getHistoryProps() external view virtual returns (VLib.HistoryProps memory)
```

Returns the History properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information

### getConfigProps

```solidity
function getConfigProps() external view virtual returns (VLib.ConfigProps memory) 
```

Returns the Config properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information

### getFeesProps

```solidity
function getFeesProps() external view virtual returns (VLib.FeesProps memory)
```

Returns the Fees properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information

### getSecurityProps

```solidity
function getSecurityProps() external view virtual returns (VLib.SecurityProps memory)
```

Returns the Security properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information

### tokensLength

```solidity
function tokensLength() public view virtual returns (uint256)
```

Returns the number of different tokens in the vault.

**Return Value:**

| Type    | Description                             |
| ------- | --------------------------------------- |
| uint256 | number of different assets in the vault |

### getLatestPrice

```solidity
function getLatestPrice(address _priceFeed) public view virtual returns (uint256) 
```

Returns the last price of a chainlink price feed.

**Call Parameters:**

| Name         | Type    | Description               |
| ------------ | ------- | ------------------------- |
| `_priceFeed` | address | address of the price feed |

**Return Value:**

| Type    | Description                  |
| ------- | ---------------------------- |
| uint256 | last price of the price feed |

### getVaultBalances

```solidity
function getVaultBalances() public view virtual returns (uint256[] memory balances)
```

Returns the balances of each assets of the vault.

**Return Value:**

| Name       | Type       | Description              |
| ---------- | ---------- | ------------------------ |
| `balances` | uint256\[] | balances of vault assets |

### getVaultStatus

<pre class="language-solidity"><code class="lang-solidity"><strong>function getVaultStatus()
</strong>    public
    view
    returns (
        uint256[] memory positions,
        uint256 vvl,
        uint256 sharePrice
    )
</code></pre>

Returns the status of the vault.

**Return Values:**

| Name         | Type       | Description                 |
| ------------ | ---------- | --------------------------- |
| `positions`  | uint256\[] | vault's position            |
| `vvl`        | uint256    | vault's valorization in USD |
| `sharePrice` | uint256    | price of one vault's share  |

### getManagementFees

```solidity
function getManagementFees() public view returns (uint256 toMint, uint256 sharePrice)
```

Returns the amount of management fees to harvest.

**Return Values:**

| Name         | Type    | Description              |
| ------------ | ------- | ------------------------ |
| `toMint`     | uint256 | amount of shares to mint |
| `sharePrice` | uint256 | share price              |

### getPerformanceFees

```solidity
function getPerformanceFees()
```

Returns the amount of performance fees to harvest.

**Return Values:**

| Name         | Type    | Description              |
| ------------ | ------- | ------------------------ |
| `toMint`     | uint256 | amount of shares to mint |
| `sharePrice` | uint256 | share price              |

## Write Methods

### deposit

```solidity
function deposit(uint256 _baseTokenAmountIn, bytes[] calldata _swapTxs) external
```

Deposits an amount of base token in the vault.

**Call Parameters:**

| Name                 | Type     | Description                                   |
| -------------------- | -------- | --------------------------------------------- |
| `_baseTokenAmountIn` | uint256  | amount to deposit                             |
| `_swapTxs`           | bytes\[] | payload to interact with paraswap's contracts |

### redeem

```solidity
function redeem(uint256 _amountIn, bytes[] calldata _swapTxs) external
```

Redeems an amount from the vault and receive in the same currency as deposit.

**Call Parameters:**

| Name        | Type     | Description                                   |
| ----------- | -------- | --------------------------------------------- |
| `_amountIn` | uint256  | amount to redeem                              |
| `_swapTxs`  | bytes\[] | payload to interact with paraswap's contracts |

### redeemEach

```solidity
function redeemEach(uint256 _amountIn) external
```

Redeems each parts of the assets in proportion to the shares burned.

**Call Parameters:**

| Name        | Type    | Description             |
| ----------- | ------- | ----------------------- |
| `_amountIn` | uint256 | shares amount to redeem |

### redeemForced

```solidity
function redeemForced(address _user, uint256 _amountIn) external
```

Redeems each parts of the assets in proportion to the shares burned to a user.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name        | Type    | Description             |
| ----------- | ------- | ----------------------- |
| `_user`     | address | address of the user     |
| `_amountIn` | uint256 | shares amount to redeem |

### rebalance

```solidity
function rebalance(uint256[] memory _signals, bytes[] calldata _swapTxs) external
```

Rebalances the vault.

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

**Call Parameters:**

|            | Type     | Description                                                 |
| ---------- | -------- | ----------------------------------------------------------- |
| `_signals` | uint256  | <p>vault in \[BTC ETH]<br>signal in bps : \[3000, 7000]</p> |
| `_swapTxs` | bytes\[] | payload to interact with paraswap's contracts               |

### harvestManagementFees

```solidity
function harvestManagementFees() external
```

Mints share in proportion of management fees, based on current fees ratio and last withdraw timestamp.&#x20;

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

### harvestPerformanceFees

```solidity
function harvestPerformanceFees() external
```

Mints share in proportion of performance fees, based on current fees ratio and last withdraw timestamp.&#x20;

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

### approveForSwap

<pre class="language-solidity"><code class="lang-solidity"><strong>function approveForSwap(uint256[] memory _amounts) public
</strong></code></pre>

Modifies approvals for assets managed by the vault.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name       | Type       | Description        |
| ---------- | ---------- | ------------------ |
| `_amounts` | uint256\[] | amounts to approve |

### addVaultAsset

```solidity
function addVaultAsset(address _token) external
```

Adds a new asset to the vault.&#x20;

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name     | Type    | Description                 |
| -------- | ------- | --------------------------- |
| `_token` | address | address of the token to add |

### setShareTransferability

```solidity
function setShareTransferability(bool _status) external
```

Settles the new share transferability status.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name      | Type | Description                       |
| --------- | ---- | --------------------------------- |
| `_status` | bool | true if the share is transferable |

### setConfigProps

```solidity
function setConfigProps(VLib.ConfigProps memory _configProps) public
```

Settles ConfigProps.&#x20;

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information. Only callable by the admin.

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

### setSecurityProps

```solidity
function setSecurityProps(VLib.SecurityProps memory _securityProps) public
```

Settles SecurityProps.

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information.

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

### setFeesProps

```solidity
function setFeesProps(VLib.FeesProps memory _feesProps) public
```

Settles FeesProps.

Refer to the [VLib](/technical-reference/core-contracts/vlib.md)'s data structure for more information

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}


---

# 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.shprd.finance/technical-reference/core-contracts/vault.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.
