> For the complete documentation index, see [llms.txt](https://defivaults.gitbook.io/amphor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://defivaults.gitbook.io/amphor/technical/v1/asyncsynthvault.md).

# AsyncSynthVault

## EpochData

[Git Source](https://github.com/AmphorProtocol/asynchronous-synthetic-private/blob/c4f7a9b8f3d3d9aba0e43eaae38ef9b556023b0e/src/AsyncSynthVault.sol)

*This structure contains all the informations needed to let user claim their request after we processed those. To avoid rounding errors we store the totalSupply and totalAssets at the time of the deposit/redeem for the deposit and the redeem. We also store the amount of assets and shares given by the user.*

```solidity
struct EpochData {
    uint256 totalSupplySnapshotForRedeem;
    uint256 totalAssetsSnapshotForRedeem;
    uint256 totalSupplySnapshotForDeposit;
    uint256 totalAssetsSnapshotForDeposit;
    mapping(address => uint256) depositRequestBalance;
    mapping(address => uint256) redeemRequestBalance;
}
```

## SettleValues

[Git Source](https://github.com/AmphorProtocol/asynchronous-synthetic-private/blob/c4f7a9b8f3d3d9aba0e43eaae38ef9b556023b0e/src/AsyncSynthVault.sol)

*Hold the required values to settle the vault deposit and redeem requests.*

```solidity
struct SettleValues {
    uint256 lastSavedBalance;
    uint256 fees;
    uint256 pendingRedeem;
    uint256 sharesToMint;
    uint256 pendingDeposit;
    uint256 assetsToWithdraw;
    uint256 totalAssetsSnapshotForDeposit;
    uint256 totalSupplySnapshotForDeposit;
    uint256 totalAssetsSnapshotForRedeem;
    uint256 totalSupplySnapshotForRedeem;
}
```

## AsyncSynthVault

[Git Source](https://github.com/AmphorProtocol/asynchronous-synthetic-private/blob/c4f7a9b8f3d3d9aba0e43eaae38ef9b556023b0e/src/AsyncSynthVault.sol)

**Inherits:** IERC7540, SyncSynthVault

### State Variables

#### epochId

The epochId is used to keep track of the deposit and redeem requests. It is incremented every time the owner calls the `settle` function.

```solidity
uint256 public epochId;
```

#### pendingSilo

The lastSavedBalance is used to keep track of the assets in the vault at the time of the last `settle` call.

```solidity
Silo public pendingSilo;
```

#### claimableSilo

The claimableSilo is used to hold the assets/shares of the users that requested a deposit/redeem.

```solidity
Silo public claimableSilo;
```

#### epochs

The epochs mapping is used to store the informations needed to let user claim their request after we processed those. To avoid rounding errors we store the totalSupply and totalAssets at the time of the deposit/redeem for the deposit and the redeem. We also store the amount of assets and shares given by the user.

```solidity
mapping(uint256 epochId => EpochData epoch) public epochs;
```

#### lastDepositRequestId

The lastDepositRequestId is used to keep track of the last deposit request made by the user. It is used to let the user claim their request after we processed those.

```solidity
mapping(address user => uint256 epochId) public lastDepositRequestId;
```

#### lastRedeemRequestId

The lastRedeemRequestId is used to keep track of the last redeem request made by the user. It is used to let the user claim their request after we processed those.

```solidity
mapping(address user => uint256 epochId) public lastRedeemRequestId;
```

### Functions

#### constructor

```solidity
constructor() SyncSynthVault();
```

#### initialize

```solidity
function initialize(
    uint16 fees,
    address owner,
    IERC20 underlying,
    string memory name,
    string memory symbol
)
    public
    virtual
    override
    initializer;
```

#### claimAndRequestDeposit

Since we only allow one claimable request at a time, users must claim their request before making a new one. This function let users claim and request a deposit in one transaction.

*This function is used to claim the pending deposit and request a new one in one transaction.*

```solidity
function claimAndRequestDeposit(
    uint256 assets,
    address receiver,
    bytes memory data
)
    external;
```

**Parameters**

| Name       | Type      | Description                                         |
| ---------- | --------- | --------------------------------------------------- |
| `assets`   | `uint256` | The amount of assets requested by the user.         |
| `receiver` | `address` | The address of the user that requested the deposit. |
| `data`     | `bytes`   | The data to be sent to the receiver.                |

#### claimAndRequestRedeem

Since we only allow one claimable request at a time, users must claim their request before making a new one. This function let users claim and request a redeem in one transaction.

*This function is used to claim the pending redeem and request a new one in one transaction.*

```solidity
function claimAndRequestRedeem(uint256 shares, bytes memory data) external;
```

**Parameters**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `shares` | `uint256` | The amount of shares requested by the user. |
| `data`   | `bytes`   | The data to be sent to the receiver.        |

#### decreaseDepositRequest

*This function is used to decrease the amount of assets requested to deposit by the user. It can only be called by the user who made the request.*

```solidity
function decreaseDepositRequest(uint256 assets)
    external
    whenClosed
    whenNotPaused;
```

**Parameters**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `assets` | `uint256` | The amount of assets requested by the user. |

#### decreaseRedeemRequest

*This function is used to decrease the amount of shares requested to redeem by the user. It can only be called by the user who made the request.*

```solidity
function decreaseRedeemRequest(uint256 shares)
    external
    whenClosed
    whenNotPaused;
```

**Parameters**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `shares` | `uint256` | The amount of shares requested by the user. |

#### close

*The `close` function is used to close the vault. It can only be called by the owner of the contract (`onlyOwner` modifier).*

```solidity
function close() external override onlyOwner;
```

#### open

The `open` function is used to end the lock period of the vault. It can only be called by the owner of the contract (`onlyOwner` modifier) and only when the vault is locked. If there are profits, the performance fees are taken and sent to the owner of the contract.

*The `open` function is used to open the vault.*

```solidity
function open(uint256 assetReturned)
    external
    override
    onlyOwner
    whenNotPaused
    whenClosed;
```

**Parameters**

| Name            | Type      | Description                                                  |
| --------------- | --------- | ------------------------------------------------------------ |
| `assetReturned` | `uint256` | The underlying assets amount to be deposited into the vault. |

#### claimAndRequestDepositWithPermit

*claimAndRequestDepositWithPermit is used to claim the pending deposit and request a new one in one transaction using permit signatures.*

```solidity
function claimAndRequestDepositWithPermit(
    uint256 assets,
    bytes memory data,
    PermitParams calldata permitParams
)
    external;
```

**Parameters**

| Name           | Type           | Description                                 |
| -------------- | -------------- | ------------------------------------------- |
| `assets`       | `uint256`      | The amount of assets requested by the user. |
| `data`         | `bytes`        | The data to be sent to the receiver.        |
| `permitParams` | `PermitParams` | The permit signature.                       |

#### settle

The `settle` function is used to settle the vault. It can only be called by the owner of the contract (`onlyOwner` modifier). If there are profits, the performance fees are taken and sent to the owner of the contract. Since amphor strategies can be time sensitive, we must be able to switch epoch without needing to put all the funds back. Using \_settle we can virtually put back the funds, check how much we owe to users that want to redeem and maybe take the extra funds from the deposit requests.

*The `settle` function is used to settle the vault.*

```solidity
function settle(uint256 newSavedBalance) external;
```

**Parameters**

| Name              | Type      | Description                                                  |
| ----------------- | --------- | ------------------------------------------------------------ |
| `newSavedBalance` | `uint256` | The underlying assets amount to be deposited into the vault. |

#### pendingRedeemRequest

*pendingRedeemRequest is used to know how many shares are currently waiting to be redeemed for the user.*

```solidity
function pendingRedeemRequest(address owner) external view returns (uint256);
```

**Parameters**

| Name    | Type      | Description                                        |
| ------- | --------- | -------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the redeem. |

#### claimableRedeemRequest

*How many shares are virtually waiting for the user to be redeemed via the `claimRedeem` function.*

```solidity
function claimableRedeemRequest(address owner)
    external
    view
    returns (uint256);
```

**Parameters**

| Name    | Type      | Description                                        |
| ------- | --------- | -------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the redeem. |

#### pendingDepositRequest

*How many assets are currently waiting to be deposited for the user.*

```solidity
function pendingDepositRequest(address owner)
    external
    view
    returns (uint256 assets);
```

**Parameters**

| Name    | Type      | Description                                         |
| ------- | --------- | --------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the deposit. |

#### claimableDepositRequest

*How many assets are virtually waiting for the user to be deposit via the `claimDeposit` function.*

```solidity
function claimableDepositRequest(address owner)
    external
    view
    returns (uint256 assets);
```

**Parameters**

| Name    | Type      | Description                                         |
| ------- | --------- | --------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the deposit. |

#### totalPendingDeposits

*How many assets are currently waiting to be deposited for all users.*

```solidity
function totalPendingDeposits() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                   |
| -------- | --------- | --------------------------------------------- |
| `<none>` | `uint256` | The amount of assets waiting to be deposited. |

#### totalPendingRedeems

*How many shares are waiting to be redeemed for all users.*

```solidity
function totalPendingRedeems() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                  |
| -------- | --------- | -------------------------------------------- |
| `<none>` | `uint256` | The amount of shares waiting to be redeemed. |

#### totalClaimableShares

*How many shares are virtually waiting for the user to be redeemed via the `claimRedeem` function.*

```solidity
function totalClaimableShares() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                  |
| -------- | --------- | -------------------------------------------- |
| `<none>` | `uint256` | The amount of shares waiting to be redeemed. |

#### totalClaimableAssets

*How many assets are virtually waiting for the user to be deposit via the `claimDeposit` function.*

```solidity
function totalClaimableAssets() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                   |
| -------- | --------- | --------------------------------------------- |
| `<none>` | `uint256` | The amount of assets waiting to be deposited. |

#### requestDeposit

*when the vault is closed, users can only request to deposit. By doing this funds will be sent and wait in the pendingSilo. When the owner will call the `open` or `settle` function, the funds will be deposited and the minted shares will be sent to the claimableSilo. Waiting for the users to claim them.*

```solidity
function requestDeposit(
    uint256 assets,
    address receiver,
    address owner,
    bytes memory data
)
    public
    whenNotPaused
    whenClosed;
```

**Parameters**

| Name       | Type      | Description                                         |
| ---------- | --------- | --------------------------------------------------- |
| `assets`   | `uint256` | The amount of assets requested by the user.         |
| `receiver` | `address` | The address of the user that requested the deposit. |
| `owner`    | `address` | The address of the user that requested the deposit. |
| `data`     | `bytes`   | The data to be sent to the receiver.                |

#### requestRedeem

*when the vault is closed, users can only request to redeem. By doing this shares will be sent and wait in the pendingSilo. When the owner will call the `open` or `settle` function, the shares will be redeemed and the assets will be sent to the claimableSilo. Waiting for the users to claim them.*

```solidity
function requestRedeem(
    uint256 shares,
    address receiver,
    address owner,
    bytes memory data
)
    public
    whenNotPaused
    whenClosed;
```

**Parameters**

| Name       | Type      | Description                                        |
| ---------- | --------- | -------------------------------------------------- |
| `shares`   | `uint256` | The amount of shares requested by the user.        |
| `receiver` | `address` | The address of the user that requested the redeem. |
| `owner`    | `address` | The address of the user that requested the redeem. |
| `data`     | `bytes`   | The data to be sent to the receiver.               |

#### claimDeposit

*This function let users claim the shares we owe them after we processed their deposit request, in the \_settle function.*

```solidity
function claimDeposit(address receiver)
    public
    whenNotPaused
    returns (uint256 shares);
```

**Parameters**

| Name       | Type      | Description                                         |
| ---------- | --------- | --------------------------------------------------- |
| `receiver` | `address` | The address of the user that requested the deposit. |

#### claimRedeem

*This function let users claim the assets we owe them after we processed their redeem request, in the \_settle function.*

```solidity
function claimRedeem(address receiver)
    public
    whenNotPaused
    returns (uint256 assets);
```

**Parameters**

| Name       | Type      | Description                                        |
| ---------- | --------- | -------------------------------------------------- |
| `receiver` | `address` | The address of the user that requested the redeem. |

#### requestDepositWithPermit

*This funciton let user request a deposit using permit signatures.*

```solidity
function requestDepositWithPermit(
    uint256 assets,
    address receiver,
    bytes memory data,
    PermitParams calldata permitParams
)
    public;
```

**Parameters**

| Name           | Type           | Description                                         |
| -------------- | -------------- | --------------------------------------------------- |
| `assets`       | `uint256`      | The amount of assets requested by the user.         |
| `receiver`     | `address`      | The address of the user that requested the deposit. |
| `data`         | `bytes`        | The data to be sent to the receiver.                |
| `permitParams` | `PermitParams` | The permit signature.                               |

#### maxDepositRequest

*users can request deposit only when the vault is closed and not paused.*

```solidity
function maxDepositRequest(address) public view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                        |
| -------- | --------- | -------------------------------------------------- |
| `<none>` | `uint256` | The maximum amount of assets the user can request. |

#### maxRedeemRequest

*users can request redeem only when the vault is closed and not paused.*

```solidity
function maxRedeemRequest(address owner) public view returns (uint256);
```

**Parameters**

| Name    | Type      | Description                                        |
| ------- | --------- | -------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the redeem. |

**Returns**

| Name     | Type      | Description                                        |
| -------- | --------- | -------------------------------------------------- |
| `<none>` | `uint256` | The maximum amount of shares the user can request. |

#### previewClaimDeposit

This function let users preview how many shares they will get if they claim their deposit request.

*This function let users preview how many shares they will get if they claim their deposit request.*

```solidity
function previewClaimDeposit(address owner) public view returns (uint256);
```

**Parameters**

| Name    | Type      | Description                                         |
| ------- | --------- | --------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the deposit. |

**Returns**

| Name     | Type      | Description                                                                 |
| -------- | --------- | --------------------------------------------------------------------------- |
| `<none>` | `uint256` | The amount of shares the user will get if they claim their deposit request. |

#### previewClaimRedeem

This function let users preview how many assets they will get if they claim their redeem request.

*This function let users preview how many assets they will get if they claim their redeem request.*

```solidity
function previewClaimRedeem(address owner) public view returns (uint256);
```

**Parameters**

| Name    | Type      | Description                                        |
| ------- | --------- | -------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the redeem. |

**Returns**

| Name     | Type      | Description                                                                |
| -------- | --------- | -------------------------------------------------------------------------- |
| `<none>` | `uint256` | The amount of assets the user will get if they claim their redeem request. |

#### convertToShares

*This function convertToShares is used to convert the assets into shares.*

```solidity
function convertToShares(
    uint256 assets,
    uint256 _epochId
)
    public
    view
    returns (uint256);
```

**Parameters**

| Name       | Type      | Description                      |
| ---------- | --------- | -------------------------------- |
| `assets`   | `uint256` | The amount of assets to convert. |
| `_epochId` | `uint256` | The epoch id.                    |

**Returns**

| Name     | Type      | Description           |
| -------- | --------- | --------------------- |
| `<none>` | `uint256` | The amount of shares. |

#### convertToAssets

*This function convertToAssets is used to convert the shares into assets.*

```solidity
function convertToAssets(
    uint256 shares,
    uint256 _epochId
)
    public
    view
    returns (uint256);
```

**Parameters**

| Name       | Type      | Description                      |
| ---------- | --------- | -------------------------------- |
| `shares`   | `uint256` | The amount of shares to convert. |
| `_epochId` | `uint256` | The epoch id.                    |

**Returns**

| Name     | Type      | Description           |
| -------- | --------- | --------------------- |
| `<none>` | `uint256` | The amount of assets. |

#### claimableDepositBalanceInAsset

Utils function to convert the shares claimable into assets. It can be used in the front end to save an rpc call.

Using this the owner can know if he will have to send money to the claimableSilo (for users who want to leave the vault) or if he will receive money from it.

*This function claimableDepositBalanceInAsset is used to know if the owner will have to send money to the claimableSilo (for users who want to leave the vault) or if he will receive money from it.*

```solidity
function claimableDepositBalanceInAsset(address owner)
    public
    view
    returns (uint256);
```

**Parameters**

| Name    | Type      | Description                                         |
| ------- | --------- | --------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the deposit. |

**Returns**

| Name     | Type      | Description                                                                 |
| -------- | --------- | --------------------------------------------------------------------------- |
| `<none>` | `uint256` | The amount of assets the user will get if they claim their deposit request. |

#### previewSettle

Using this the owner can know if he will have to send money to the claimableSilo (for users who want to leave the vault) or if he will receive money from it.

*This function claimableRedeemBalanceInShares is used to know if the owner will have to send money to the claimableSilo (for users who want to leave the vault) or if he will receive money from it.*

```solidity
function previewSettle(uint256 newSavedBalance)
    public
    view
    returns (
        uint256 assetsToOwner,
        uint256 assetsToVault,
        SettleValues memory settleValues
    );
```

**Parameters**

| Name              | Type      | Description                                          |
| ----------------- | --------- | ---------------------------------------------------- |
| `newSavedBalance` | `uint256` | The amount of assets to be deposited into the vault. |

**Returns**

| Name            | Type           | Description                                                                |
| --------------- | -------------- | -------------------------------------------------------------------------- |
| `assetsToOwner` | `uint256`      | The amount of assets the user will get if they claim their redeem request. |
| `assetsToVault` | `uint256`      |                                                                            |
| `settleValues`  | `SettleValues` |                                                                            |

#### supportsInterface

*see EIP*

```solidity
function supportsInterface(bytes4 interfaceId) public pure returns (bool);
```

**Parameters**

| Name          | Type     | Description                    |
| ------------- | -------- | ------------------------------ |
| `interfaceId` | `bytes4` | The interface id to check for. |

**Returns**

| Name     | Type   | Description                                    |
| -------- | ------ | ---------------------------------------------- |
| `<none>` | `bool` | True if the contract implements the interface. |

#### \_createDepositRequest

This function is used to update the balance of the user.

*This function is used to update the balance of the user.*

```solidity
function _createDepositRequest(
    uint256 assets,
    address receiver,
    address owner,
    bytes memory data
)
    internal;
```

**Parameters**

| Name       | Type      | Description |
| ---------- | --------- | ----------- |
| `assets`   | `uint256` |             |
| `receiver` | `address` |             |
| `owner`    | `address` |             |
| `data`     | `bytes`   |             |

#### \_createRedeemRequest

This function is used to update the balance of the user.

*\_createRedeemRequest is used to update the balance of the user in order to create the redeem request.*

```solidity
function _createRedeemRequest(
    uint256 shares,
    address receiver,
    address owner,
    bytes memory data
)
    internal;
```

**Parameters**

| Name       | Type      | Description                                        |
| ---------- | --------- | -------------------------------------------------- |
| `shares`   | `uint256` | The amount of shares requested by the user.        |
| `receiver` | `address` | The address of the user that requested the redeem. |
| `owner`    | `address` | The address of the user that requested the redeem. |
| `data`     | `bytes`   | The data to be sent to the receiver.               |

#### \_claimDeposit

*\_claimDeposit is used to claim the pending deposit and request a new one in one transaction.*

```solidity
function _claimDeposit(
    address owner,
    address receiver
)
    internal
    returns (uint256 shares);
```

**Parameters**

| Name       | Type      | Description                                         |
| ---------- | --------- | --------------------------------------------------- |
| `owner`    | `address` | The address of the user that requested the deposit. |
| `receiver` | `address` | The address of the user that requested the deposit. |

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `shares` | `uint256` | The amount of shares requested by the user. |

#### \_claimRedeem

*\_claimRedeem is used to claim the pending redeem and request a new one in one transaction.*

```solidity
function _claimRedeem(
    address owner,
    address receiver
)
    internal
    whenNotPaused
    returns (uint256 assets);
```

**Parameters**

| Name       | Type      | Description                                        |
| ---------- | --------- | -------------------------------------------------- |
| `owner`    | `address` | The address of the user that requested the redeem. |
| `receiver` | `address` | The address of the user that requested the redeem. |

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `assets` | `uint256` | The amount of shares requested by the user. |

#### \_settle

*\_settle is used to settle the vault.*

```solidity
function _settle(uint256 newSavedBalance)
    internal
    onlyOwner
    whenNotPaused
    whenClosed
    returns (uint256, uint256);
```

**Parameters**

| Name              | Type      | Description                                                  |
| ----------------- | --------- | ------------------------------------------------------------ |
| `newSavedBalance` | `uint256` | The underlying assets amount to be deposited into the vault. |

**Returns**

| Name     | Type      | Description                              |
| -------- | --------- | ---------------------------------------- |
| `<none>` | `uint256` | lastSavedBalance The last saved balance. |
| `<none>` | `uint256` | totalSupply The total supply.            |

#### isCurrentEpoch

*isCurrentEpoch is used to check if the request is the current epoch.*

```solidity
function isCurrentEpoch(uint256 requestId) internal view returns (bool);
```

**Parameters**

| Name        | Type      | Description            |
| ----------- | --------- | ---------------------- |
| `requestId` | `uint256` | The id of the request. |

#### \_convertToShares

*\_convertToShares is used to convert the assets into shares for a specific epoch/request.*

```solidity
function _convertToShares(
    uint256 assets,
    uint256 requestId,
    Math.Rounding rounding
)
    internal
    view
    returns (uint256);
```

**Parameters**

| Name        | Type            | Description                      |
| ----------- | --------------- | -------------------------------- |
| `assets`    | `uint256`       | The amount of assets to convert. |
| `requestId` | `uint256`       | The id of the request.           |
| `rounding`  | `Math.Rounding` | The rounding type.               |

#### \_convertToAssets

*\_convertToAssets is used to convert the shares into assets for a specific epoch/request.*

```solidity
function _convertToAssets(
    uint256 shares,
    uint256 requestId,
    Math.Rounding rounding
)
    internal
    view
    returns (uint256);
```

**Parameters**

| Name        | Type            | Description                      |
| ----------- | --------------- | -------------------------------- |
| `shares`    | `uint256`       | The amount of shares to convert. |
| `requestId` | `uint256`       | The id of the request.           |
| `rounding`  | `Math.Rounding` | The rounding type.               |

#### \_checkMaxDrawdown

*\_checkMaxDrawdown is used to check if the max drawdown is reached.*

```solidity
function _checkMaxDrawdown(
    uint256 _lastSavedBalance,
    uint256 newSavedBalance
)
    internal
    view;
```

**Parameters**

| Name                | Type      | Description             |
| ------------------- | --------- | ----------------------- |
| `_lastSavedBalance` | `uint256` | The last saved balance. |
| `newSavedBalance`   | `uint256` | The new saved balance.  |

#### \_computeFees

```solidity
function _computeFees(
    uint256 _lastSavedBalance,
    uint256 newSavedBalance
)
    internal
    view
    returns (uint256 fees);
```

### Events

#### DecreaseDepositRequest

This event is emitted when a user request a deposit.

```solidity
event DecreaseDepositRequest(
    uint256 indexed requestId,
    address indexed owner,
    uint256 indexed previousRequestedAssets,
    uint256 newRequestedAssets
);
```

**Parameters**

| Name                      | Type      | Description                                                        |
| ------------------------- | --------- | ------------------------------------------------------------------ |
| `requestId`               | `uint256` | The id of the request.                                             |
| `owner`                   | `address` | The address of the user that requested the deposit.                |
| `previousRequestedAssets` | `uint256` | The amount of assets requested by the user before the new request. |
| `newRequestedAssets`      | `uint256` | The amount of assets requested by the user.                        |

#### DecreaseRedeemRequest

This event is emitted when a user request a redeem.

```solidity
event DecreaseRedeemRequest(
    uint256 indexed requestId,
    address indexed owner,
    uint256 indexed previousRequestedShares,
    uint256 newRequestedShares
);
```

**Parameters**

| Name                      | Type      | Description                                                        |
| ------------------------- | --------- | ------------------------------------------------------------------ |
| `requestId`               | `uint256` | The id of the request.                                             |
| `owner`                   | `address` | The address of the user that requested the redeem.                 |
| `previousRequestedShares` | `uint256` | The amount of shares requested by the user before the new request. |
| `newRequestedShares`      | `uint256` | The amount of shares requested by the user.                        |

#### ClaimDeposit

This event is emitted when a user request a redeem.

```solidity
event ClaimDeposit(
    uint256 indexed requestId,
    address indexed owner,
    address indexed receiver,
    uint256 assets,
    uint256 shares
);
```

**Parameters**

| Name        | Type      | Description                                                        |
| ----------- | --------- | ------------------------------------------------------------------ |
| `requestId` | `uint256` | The id of the request.                                             |
| `owner`     | `address` | The address of the user that requested the redeem.                 |
| `receiver`  | `address` | The amount of shares requested by the user before the new request. |
| `assets`    | `uint256` | The amount of shares requested by the user.                        |
| `shares`    | `uint256` | The amount of shares requested by the user.                        |

#### ClaimRedeem

This event is emitted when a user request a redeem.

```solidity
event ClaimRedeem(
    uint256 indexed requestId,
    address indexed owner,
    address indexed receiver,
    uint256 assets,
    uint256 shares
);
```

**Parameters**

| Name        | Type      | Description                                                        |
| ----------- | --------- | ------------------------------------------------------------------ |
| `requestId` | `uint256` | The id of the request.                                             |
| `owner`     | `address` | The address of the user that requested the redeem.                 |
| `receiver`  | `address` | The amount of shares requested by the user before the new request. |
| `assets`    | `uint256` | The amount of shares requested by the user.                        |
| `shares`    | `uint256` | The amount of shares requested by the user.                        |

### Errors

#### ExceededMaxRedeemRequest

This error is emitted when the user request more shares than the maximum allowed.

```solidity
error ExceededMaxRedeemRequest(
    address receiver, uint256 shares, uint256 maxShares
);
```

**Parameters**

| Name        | Type      | Description                                        |
| ----------- | --------- | -------------------------------------------------- |
| `receiver`  | `address` | The address of the user that requested the redeem. |
| `shares`    | `uint256` | The amount of shares requested by the user.        |
| `maxShares` | `uint256` |                                                    |

#### ExceededMaxDepositRequest

This error is emitted when the user request more assets than the maximum allowed.

```solidity
error ExceededMaxDepositRequest(
    address receiver, uint256 assets, uint256 maxDeposit
);
```

**Parameters**

| Name         | Type      | Description                                         |
| ------------ | --------- | --------------------------------------------------- |
| `receiver`   | `address` | The address of the user that requested the deposit. |
| `assets`     | `uint256` | The amount of assets requested by the user.         |
| `maxDeposit` | `uint256` | The maximum amount of assets the user can request.  |

#### MustClaimFirst

This error is emitted when the user try to make a new request without claiming the previous one.

```solidity
error MustClaimFirst(address owner);
```

**Parameters**

| Name    | Type      | Description                                         |
| ------- | --------- | --------------------------------------------------- |
| `owner` | `address` | The address of the user that requested the deposit. |

#### ReceiverFailed

This error is emitted when the user try to make a new request without claiming the previous one.

```solidity
error ReceiverFailed();
```

#### NotOwner

This error is emitted when the user try to make a new request without claiming the previous one.

```solidity
error NotOwner();
```

#### NullRequest

This error is emitted when the user try to make a new request without claiming the previous one.

```solidity
error NullRequest();
```

#### ERC7540CantRequestDepositOnBehalfOf

This error is emitted when the user try to make a new request without claiming the previous one.

```solidity
error ERC7540CantRequestDepositOnBehalfOf();
```
