> For the complete documentation index, see [llms.txt](https://docs.mellow.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mellow.finance/resources/mellow-lrt-depreciated/utils/depositwrapper.md).

# DepositWrapper

### Overview

`DepositWrapper` contract is a utility that wraps deposits of various tokens into a specific vault asset. It allows for deposits in ETH, WETH, stETH and wstETH.

### Key Features

* **Token Conversion**: Converts between ETH, WETH, stETH, and wstETH for deposits.
* **Direct Deposit**: Supports direct deposits into the vault with security checks.
* **Allowance Management**: Adjusts ERC20 allowances securely before deposit.

### Core Methods

1. **Deposit Function**
   * `deposit(address, address, uint256, uint256, uint256)`: Facilitates deposits into the vault after converting tokens.
     * **to**: The address receiving LP tokens after the deposit.
     * **token**: The address of the input token (WETH, stETH, wstETH, or native ETH).
     * **amount**: The amount of the input token.
     * **minLpAmount**: Minimum acceptable amount of LP tokens to be minted.
     * **deadline**: Time before which the deposit must be completed.
     * **Returns**: The amount of LP tokens minted.
     * **Errors**:
       * `InvalidTokenList`: If the vault does not exclusively accept wstETH.
       * `InvalidAmount`: If the input amount is zero or doesn't match `msg.value` for ETH.
       * `InvalidToken`: If the input token is not recognized.
     * **Event**:
       * `DepositWrapperDeposit(address, address, uint256, uint256, uint256)`: Emitted after a successful deposit.
         * **sender**: Address of the sender.
         * **token**: Address of the input token.
         * **amount**: Amount deposited.
         * **lpAmount**: Amount of LP tokens minted.
         * **deadline**: Deadline of the deposit operation.
2. **Conversion Helpers**
   * `_wethToWsteth(uint256)`: Converts WETH to wstETH through stETH.
   * `_ethToSteth(uint256)`: Converts native ETH to stETH.
   * `_stethToWsteth(uint256)`: Converts stETH to wstETH.
3. **Fallback Method**
   * `receive()`: Allows receiving ETH only from the WETH contract.
     * **Error**:
       * `InvalidSender`: Raised if ETH is received from an address other than WETH.


---

# 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.mellow.finance/resources/mellow-lrt-depreciated/utils/depositwrapper.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.
