> For the complete documentation index, see [llms.txt](https://docs.indexcoop.com/index-coop-community-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.indexcoop.com/index-coop-community-handbook/protocol/index-protocol/modules/wrap-module.md).

# Wrap Module

The **WrapModuleV2** ([Etherscan](https://etherscan.io/address/0xbfe0f7b4f9537a25d7c498161d6f24b38699a075)) is a smart contract that enables the wrapping of ERC20 and Ether positions via third-party protocols. The WrapModule works in conjunction with WrapAdapters, in which the `wrapAdapterID` / `integrationNames` are stored on the [integration registry](/index-coop-community-handbook/protocol/index-protocol/core-contracts/integration-registry.md). Examples of wrap actions include wrapping DAI to cDAI (Compound) or DAI to aDAI (Aave).

## Select Methods

### wrap()

`function wrap(ISetToken _setToken, address _underlyingToken, address _wrappedToken, uint256 _underlyingUnits, string calldata _integrationName)`      &#x20;

**Manager only**. Instructs the SetToken to wrap an underlying asset into a wrappedToken via a specified adapter.

| Parameter Name    | Type      | Description                                                       |
| ----------------- | --------- | ----------------------------------------------------------------- |
| \_setToken        | ISetToken | Instance of the SetToken                                          |
| \_underlyingToken | address   | Address of the component to be wrapped                            |
| \_wrappedToken    | address   | Address of the desired wrapped token                              |
| \_underlyingUnits | uint256   | Quantity of underlying units in Position units                    |
| \_integrationName | string    | Name of wrap module integration (mapping on integration registry) |

### wrapWithEther()

`function wrapWithEther(ISetToken _setToken, address _wrappedToken, uint256 _underlyingUnits, string calldata _integrationName)`      &#x20;

**Manager only**. Instructs the SetToken to wrap Ether into a wrappedToken via a specified adapter. Since SetTokens only hold WETH, in order to support protocols that collateralize with Ether the SetToken's WETH must be unwrapped first before sending to the external protocol.

| Parameter Name    | Type      | Description                                                       |
| ----------------- | --------- | ----------------------------------------------------------------- |
| \_setToken        | ISetToken | Instance of the SetToken                                          |
| \_wrappedToken    | address   | Address of the desired wrapped token                              |
| \_underlyingUnits | uint256   | Quantity of underlying units in Position units                    |
| \_integrationName | string    | Name of wrap module integration (mapping on integration registry) |

### unwrap()

`function unwrap(ISetToken _setToken, address _underlyingToken, address _wrappedToken, uint256 _wrappedUnits, string calldata _integrationName)`      &#x20;

**Manager only**. Instructs the SetToken to wrap an underlying asset into a wrappedToken via a specified adapter.

| Parameter Name    | Type      | Description                                                       |
| ----------------- | --------- | ----------------------------------------------------------------- |
| \_setToken        | ISetToken | Instance of the SetToken                                          |
| \_underlyingToken | address   | Address of the component to be wrapped                            |
| \_wrappedToken    | address   | Address of the desired wrapped token                              |
| \_wrappedUnits    | uint256   | Quantity of wrapped units in Position units                       |
| \_integrationName | string    | Name of wrap module integration (mapping on integration registry) |

### unwrapWithEther()

`function unwrapWithEther(ISetToken _setToken, address _wrappedToken, uint256 _wrappedUnits, string calldata _integrationName)`      &#x20;

**Manager only**. Instructs the SetToken to wrap an underlying asset into a wrappedToken via a specified adapter.

| Parameter Name    | Type      | Description                                                       |
| ----------------- | --------- | ----------------------------------------------------------------- |
| \_setToken        | ISetToken | Instance of the SetToken                                          |
| \_wrappedToken    | address   | Address of the desired wrapped token                              |
| \_wrappedUnits    | uint256   | Quantity of wrapped units in Position units                       |
| \_integrationName | string    | Name of wrap module integration (mapping on integration registry) |

### initialize()

`function initialize(ISetToken _setToken)`

**Manager only.** Initializes this module to the SetToken.

| Parameter Name | Type      | Description             |
| -------------- | --------- | ----------------------- |
| \_setToken     | ISetToken | Address of the SetToken |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.indexcoop.com/index-coop-community-handbook/protocol/index-protocol/modules/wrap-module.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
