# YearnDAIStrategy

## Overview

The YearnDAIStrategy contract is a strategy that supplies DAI into a Yearn V2 Vault to earn yield. It handles conversions between the underlying asset and DAI through Curve's 3pool.

## Constants

```solidity
ICurveTriPool public constant triPool = ICurveTriPool(CURVE_3POOL_POOL_MAINNET);  // Curve's 3pool
address constant dai = DAI_MAINNET;                                                // DAI token address
```

## Functions

### Initialization Functions

#### initialize

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

Initializes the strategy with required components.

Parameters:

* `_vault`: MaxApy vault address
* `_keepers`: Array of keeper addresses
* `_strategyName`: Name of the strategy
* `_strategist`: Strategist address
* `_yVault`: Yearn V2 vault address

### Internal Core Functions

#### \_invest

```solidity
function _invest(uint256 amount, uint256 minOutputAfterInvestment) internal override returns (uint256 depositedAmount)
```

Invests assets by:

1. Swapping underlying to DAI through Curve
2. Depositing DAI into Yearn vault

Parameters:

* `amount`: Amount to invest
* `minOutputAfterInvestment`: Minimum expected shares

Returns:

* `depositedAmount`: Amount of tokens received

#### \_divest

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

Withdraws assets by:

1. Withdrawing DAI from Yearn vault
2. Swapping DAI to underlying through Curve

Parameters:

* `shares`: Amount of shares to withdraw

Returns:

* `withdrawn`: Amount of assets received

### Internal View Functions

#### \_shareValue

```solidity
function _shareValue(uint256 shares) internal view override returns (uint256)
```

Calculates underlying value of shares including Curve conversion rate.

Parameters:

* `shares`: Share amount

Returns:

* Underlying value

#### \_sharesForAmount

```solidity
function _sharesForAmount(uint256 amount) internal view override returns (uint256 shares)
```

Calculates shares needed for amount including Curve conversion rate.

Parameters:

* `amount`: Asset amount

Returns:

* Required shares

Key Features:

* Uses Curve's 3pool for token conversions
* Sets 1M DAI maximum trade size
* Sets minimum trade size to 0.01 token units
* Handles token conversions during deposits and withdrawals
