> For the complete documentation index, see [llms.txt](https://devs.maxapy.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devs.maxapy.io/maxapy-erc4626/strategies/polygon-usdc.e/convex/convexusdtcrvusdstrategy.md).

# ConvexUSDTCrvUSDStrategy

## Overview

The ConvexUSDTCrvUSDStrategy contract is a strategy that supplies USDT into the crvUSD-USDT pool in Curve on Polygon, then stakes the curve LP tokens in Convex to maximize yield. It manages conversions between USDT and other tokens using Curve's AtriCrypto zapper.

## Constants

```solidity
address public constant crvUsd = CRV_USD_POLYGON;                                 // CRVUSD token address
address public constant wpol = WPOL_POLYGON;                                      // Wrapped MATIC address
address public constant crv = CRV_POLYGON;                                        // CRV token address
address public constant usdt = USDT_POLYGON;                                      // USDT token address
uint256 public constant CRVUSD_USDT_CONVEX_POOL_ID = CRVUSD_USDT_CONVEX_POOL_ID_POLYGON;  // Convex pool ID
IConvexBoosterPolygon public constant convexBooster = IConvexBoosterPolygon(CONVEX_BOOSTER_POLYGON);  // Convex booster
ICurveAtriCryptoZapper constant zapper = ICurveAtriCryptoZapper(CURVE_AAVE_ATRICRYPTO_ZAPPER_POLYGON);  // Curve zapper
```

## State Variables

```solidity
IRouter public router;                           // Router for swaps
ICurveLpPool public curveLpPool;                // Main Curve pool
```

## Functions

### Initialization Functions

#### constructor

```solidity
constructor() initializer
```

Empty constructor marked as initializer.

#### initialize

```solidity
function initialize(
    IMaxApyVault _vault,
    address[] calldata _keepers,
    bytes32 _strategyName,
    address _strategist,
    ICurveLpPool _curveLpPool,
    IRouter _router
) public 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
* `_curveLpPool`: Curve LP pool address
* `_router`: Router address for swaps

### Core Functions

#### \_invest

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

Invests assets through:

1. Converting USDCe to USDT via zapper
2. Adding USDT to crvUSD-USDT pool
3. Staking LP tokens in Convex

Parameters:

* `amount`: Amount to invest
* `minOutputAfterInvestment`: Minimum expected LP tokens

Returns:

* Amount of tokens received

#### \_divest

```solidity
function _divest(uint256 amount) internal override returns (uint256)
```

Withdraws assets through:

1. Withdrawing from Convex
2. Removing liquidity from Curve
3. Converting USDT to USDCe via zapper

Parameters:

* `amount`: LP tokens to divest

Returns:

* Amount received after withdrawals and conversions

#### \_unwindRewards

```solidity
function _unwindRewards(IConvexRewardsPolygon rewardPool) internal override
```

Claims and converts rewards:

1. Claims CRV rewards
2. Swaps CRV through multiple hops
3. Converts crvUSD through Curve pool

Parameters:

* `rewardPool`: Convex rewards pool

### Internal View Functions

#### \_convertUsdtToUsdce

```solidity
function _convertUsdtToUsdce(uint256 usdtAmount) internal view returns (uint256)
```

Converts USDT to USDCe using zapper.

Parameters:

* `usdtAmount`: USDT amount

Returns:

* Equivalent USDCe amount

#### \_convertUsdceToUsdt

```solidity
function _convertUsdceToUsdt(uint256 usdceAmount) internal view returns (uint256)
```

Converts USDCe to USDT using zapper.

Parameters:

* `usdceAmount`: USDCe amount

Returns:

* Equivalent USDT amount

#### \_lpValue

```solidity
function _lpValue(uint256 lp) internal view override returns (uint256)
```

Calculates underlying value of LP tokens.

Parameters:

* `lp`: LP token amount

Returns:

* USDCe value

#### \_lpForAmount

```solidity
function _lpForAmount(uint256 amount) internal view override returns (uint256)
```

Calculates LP tokens needed for amount.

Parameters:

* `amount`: USDCe amount

Returns:

* Required LP tokens

#### \_estimatedTotalAssets

```solidity
function _estimatedTotalAssets() internal view override returns (uint256)
```

Calculates total strategy value including conversions.

Returns:

* Total value in USDCe

#### \_lpPrice

```solidity
function _lpPrice() internal view override returns (uint256)
```

Returns Curve LP token price.

#### \_crv

```solidity
function _crv() internal pure override returns (address)
```

Returns CRV token address.

#### \_crvUsdBalance

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

Returns strategy's crvUSD balance.

#### \_simulateHarvest

```solidity
function _simulateHarvest() public override
```

Simulates harvest operation and reverts with simulation data.
