# Spectra4626Wrapper



The `Spectra4626Wrapper` contract implements a wrapper to facilitate compliance of an interest-bearing vault with the ERC-4626 standard, making it compatible for deploying a Spectra Principal Token.

## ERC-4626 [#erc-4626]

This contract is compatible with the [ERC-4626 standard](https://eips.ethereum.org/EIPS/eip-4626) and implements its interface. However, depending on the functionalities supported by the wrapped vault, some functions may revert by default (e.g. redeem() / withdraw()).

## Methods [#methods]

### wrap [#wrap]

Deposits vault shares into the wrapper.

```solidity
function wrap(uint256 vaultShares, address receiver) external returns (uint256)
```

| Input Parameter | Type    | Description                               |
| --------------- | ------- | ----------------------------------------- |
| `vaultShares`   | uint256 | The amount of vault shares to deposit     |
| `receiver`      | address | The address to receive the wrapper shares |

| Return Parameter | Type    | Description                         |
| ---------------- | ------- | ----------------------------------- |
| `wrapperShares`  | uint256 | The amount of minted wrapper shares |

### wrap [#wrap-1]

Deposits vault shares into the wrapper, with support for slippage protection.

```solidity
function wrap(
    uint256 vaultShares,
    address receiver,
    uint256 minShares
) external returns (uint256)
```

| Input Parameter | Type    | Description                                          |
| --------------- | ------- | ---------------------------------------------------- |
| `vaultShares`   | uint256 | The amount of vault shares to deposit                |
| `receiver`      | address | The address to receive the wrapper shares            |
| `minShares`     | uint256 | The minimum allowed wrapper shares from this deposit |

| Return Parameter | Type    | Description                         |
| ---------------- | ------- | ----------------------------------- |
| `shares`         | uint256 | The amount of minted wrapper shares |

### unwrap [#unwrap]

Withdraws vault shares from the wrapper.

```solidity
function unwrap(uint256 shares, address receiver, address owner) external returns (uint256)
```

<Callout type="warn">
  `msg.sender` must approve the relevant allowance of the vault token before calling this method.
</Callout>

| Input Parameter | Type    | Description                                    |
| --------------- | ------- | ---------------------------------------------- |
| `shares`        | uint256 | The amount of wrapper shares to redeem         |
| `receiver`      | address | The address to receive the vault shares        |
| `owner`         | address | The address of the owner of the wrapper shares |

| Return Parameter | Type    | Description                          |
| ---------------- | ------- | ------------------------------------ |
| `vaultShares`    | uint256 | The amount of withdrawn vault shares |

### unwrap [#unwrap-1]

Withdraws vault shares from the wrapper, with support for slippage protection.

```solidity
function unwrap(
    uint256 shares,
    address receiver,
    address owner,
    uint256 minVaultShares
) external returns (uint256)
```

| Input Parameter  | Type    | Description                                      |
| ---------------- | ------- | ------------------------------------------------ |
| `shares`         | uint256 | The amount of wrapper shares to redeem           |
| `receiver`       | address | The address to receive the vault shares          |
| `owner`          | address | The address of the owner of the wrapper shares   |
| `minVaultShares` | uint256 | The minimum vault shares that should be returned |

| Return Parameter | Type    | Description                          |
| ---------------- | ------- | ------------------------------------ |
| `vaultShares`    | uint256 | The amount of withdrawn vault shares |

## View Methods [#view-methods]

### previewWrap [#previewwrap]

Calculates the amount of minted wrapper shares for a given amount of deposited vault shares.

```solidity
function previewWrap(uint256 vaultShares) external view returns (uint256)
```

### previewUnwrap [#previewunwrap]

Calculates the amount of withdrawn vault shares for a given amount of redeemed wrapper shares.

```solidity
function previewUnwrap(uint256 shares) external view returns (uint256)
```

### vault [#vault]

Returns the address of the wrapped vault.

```solidity
function vault() external view returns (address)
```

### totalVaultShares [#totalvaultshares]

Returns the vault balance of the wrapper.

```solidity
function totalVaultShares() external view returns (uint256)
```
