# 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

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

### wrap

Deposits vault shares into the wrapper.

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

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>vaultShares</code></td><td>uint256</td><td>The amount of vault shares to deposit</td></tr><tr><td><code>receiver</code></td><td>address</td><td>The address to receive the wrapper shares</td></tr></tbody></table>

<table><thead><tr><th width="189.33333333333331">Return Parameter</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>wrapperShares</code></td><td>uint256</td><td>The amount of minted wrapper shares</td></tr></tbody></table>

### wrap

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

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

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>vaultShares</code></td><td>uint256</td><td>The amount of vault shares to deposit</td></tr><tr><td><code>receiver</code></td><td>address</td><td>The address to receive the wrapper shares</td></tr><tr><td><code>minShares</code></td><td>uint256</td><td>The minimum allowed wrapper shares from this deposit</td></tr></tbody></table>

<table><thead><tr><th width="189.33333333333331">Return Parameter</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>shares</code></td><td>uint256</td><td>The amount of minted wrapper shares</td></tr></tbody></table>

### unwrap

Withdraws vault shares from the wrapper.

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

{% hint style="warning" %}
`msg.sender` must approve the relevant allowance of the vault token before calling this method.
{% endhint %}

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>shares</code></td><td>uint256</td><td>The amount of wrapper shares to redeem</td></tr><tr><td><code>receiver</code></td><td>address</td><td>The address to receive the vault shares</td></tr><tr><td><code>owner</code></td><td>address</td><td>The address of the owner of the wrapper shares</td></tr></tbody></table>

<table><thead><tr><th width="189.33333333333331">Return Parameter</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>vaultShares</code></td><td>uint256</td><td>The amount of withdrawn vault shares</td></tr></tbody></table>

### unwrap

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)
```

<table><thead><tr><th width="192.33333333333331">Input Parameter</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>shares</code></td><td>uint256</td><td>The amount of wrapper shares to redeem</td></tr><tr><td><code>receiver</code></td><td>address</td><td>The address to receive the vault shares</td></tr><tr><td><code>owner</code></td><td>address</td><td>The address of the owner of the wrapper shares</td></tr><tr><td><code>minVaultShares</code></td><td>uint256</td><td>The minimum vault shares that should be returned</td></tr></tbody></table>

<table><thead><tr><th width="189.33333333333331">Return Parameter</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>vaultShares</code></td><td>uint256</td><td>The amount of withdrawn vault shares</td></tr></tbody></table>

## View Methods

### 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

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

Returns the address of the wrapped vault.

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

### totalVaultShares

Returns the vault balance of the wrapper.

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


---

# 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://dev.spectra.finance/technical-reference/contract-functions/spectra4626wrapper.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.
