# SommelierMorphoEthMaximizerStrategy

## Overview

The SommelierMorphoEthMaximizerStrategy contract is a specialized strategy that supplies an underlying token into a Sommelier Vault to earn yield. This strategy is adapted from the yearn-steth-acc repository and optimizes ETH returns through Morpho integration.

## Constants

```solidity
address constant wstEth = WSTETH_MAINNET;                                      // Wrapped stETH token address
IUniswapV3Router constant router = IUniswapV3Router(UNISWAP_V3_ROUTER_MAINNET); // Uniswap V3 router
```

## State Variables

No additional state variables beyond those inherited from BaseSommelierStrategy.

## Functions

### Initialization Functions

### initialize

```solidity
function initialize(
    IMaxApyVault _vault,
    address[] calldata _keepers,
    bytes32 _strategyName,
    address _strategist,
    ICellar _cellar
) public override initializer
```

Initializes the strategy with Sommelier components.

Parameters:

* `_vault`: MaxApy vault address
* `_keepers`: Array of keeper addresses
* `_strategyName`: Name of the strategy
* `_strategist`: Strategist address
* `_cellar`: Sommelier Turbo-stETH cellar address

### Core Functions

### liquidateExact

```solidity
function liquidateExact(uint256 amountNeeded) external virtual override checkRoles(VAULT_ROLE) returns (uint256 loss)
```

Withdraws exactly amountNeeded to vault. Can only be called by vault.

Parameters:

* `amountNeeded`: Amount of underlying asset to withdraw

Returns:

* `loss`: Amount of loss realized during withdrawal

### Internal Core Functions

### \_divest

```solidity
function _divest(uint256 shares) internal override returns (uint256 withdrawn)
```

Withdraws assets from Cellar Vault, handling potential losses.

Parameters:

* `shares`: Amount of cellar shares to divest

Returns:

* `withdrawn`: Amount of assets received after withdrawal

### \_swapWstEth

```solidity
function _swapWstEth(uint256 amountIn) internal returns (uint256)
```

Swaps wstETH to underlying WETH using Uniswap V3.

Parameters:

* `amountIn`: Amount of wstETH to swap

Returns:

* Amount of WETH received

### Internal View Functions

### \_wstEthBalance

```solidity
function _wstEthBalance() internal view returns (uint256)
```

Retrieves the contract's wstETH balance.

Returns:

* Current wstETH balance

### Key Features

1. Integrates with Sommelier's Turbo-stETH cellar for yield optimization
2. Handles wstETH/ETH conversions through Uniswap V3
3. Implements safety checks for pause conditions and minimum trade sizes
4. Manages exact liquidations for vault withdrawals
5. Monitors and handles potential losses during withdrawals


---

# 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://devs.maxapy.io/maxapy-erc4626/strategies/ethereum-weth/sommelier/sommeliermorphoethmaximizerstrategy.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.
