YearnUSDTStrategy

Overview

The YearnUSDTStrategy contract is a strategy that supplies USDT into a Yearn V2 Vault to earn yield. It handles conversions between the underlying asset and USDT through Curve's 3pool and includes safety margins for liquidations.

Constants

ICurveTriPool public constant triPool = ICurveTriPool(CURVE_3POOL_POOL_MAINNET);  // Curve's 3pool
address constant usdt = USDT_MAINNET;                                              // USDT token address

Functions

Initialization Functions

initialize

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

View Functions

previewLiquidate

function previewLiquidate(uint256 requestedAmount) public view override returns (uint256 liquidatedAmount)

Simulates withdrawal with 1% safety margin.

Parameters:

  • requestedAmount: Amount to withdraw

Returns:

  • liquidatedAmount: Expected output amount

previewLiquidateExact

function previewLiquidateExact(uint256 liquidatedAmount) public view virtual override returns (uint256 requestedAmount)

Calculates input needed with 2% buffer.

Parameters:

  • liquidatedAmount: Desired output amount

Returns:

  • requestedAmount: Required input amount

Internal Core Functions

_invest

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

Invests assets by:

  1. Swapping underlying to USDT through Curve

  2. Depositing USDT into Yearn vault

Parameters:

  • amount: Amount to invest

  • minOutputAfterInvestment: Minimum expected shares

Returns:

  • depositedAmount: Amount of tokens received

_divest

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

Withdraws assets by:

  1. Withdrawing USDT from Yearn vault

  2. Swapping USDT to underlying through Curve

Parameters:

  • shares: Amount of shares to withdraw

Returns:

  • withdrawn: Amount of assets received

Internal View Functions

_shareValue

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

Calculates underlying value including Curve conversion.

Parameters:

  • shares: Share amount

Returns:

  • Underlying value

_sharesForAmount

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

Calculates shares needed including Curve conversion.

Parameters:

  • amount: Asset amount

Returns:

  • Required shares

Key Features:

  • Uses Curve's 3pool for token conversions

  • Sets 1M USD maximum trade size

  • Sets minimum trade size to 0.01 token units

  • Includes safety margins for withdrawals

  • Handles conversions between USDT and underlying asset

Last updated