YearnMaticUSDCStakingStrategy

Overview

The YearnMaticUSDCStakingStrategy contract is a strategy that supplies USDC into a Yearn V3 Vault and stakes the vault shares to earn additional WMATIC rewards. It manages reward claiming and conversion through Uniswap V3.

Constants

address public constant wpol = WPOL_POLYGON;                                      // WMATIC token address
IRouter public constant router = IRouter(UNISWAP_V3_ROUTER_POLYGON);             // Uniswap V3 router
IStakingRewardsMulti public constant yearnStakingRewards =                       // Yearn staking rewards
    IStakingRewardsMulti(0x602920E7e0a335137E02DF139CdF8D1381DAdBfD);

State Variables

uint256 public minSwapMatic;    // Minimum amount of WMATIC to swap

Functions

Initialization Functions

constructor

constructor() initializer

Empty constructor marked as initializer.

initialize

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 V3 vault address

Core Functions

liquidateExact

Withdraws exact amount and re-stakes remaining shares.

Parameters:

  • amountNeeded: Amount to withdraw

Returns:

  • loss: Amount of realized loss

Internal Core Functions

_beforePrepareReturn

Claims and processes staking rewards before preparing return.

_adjustPosition

Adjusts strategy positions based on available capital.

Parameters:

  • minOutputAfterInvestment: Minimum expected output

_invest

Invests assets and stakes received shares.

Parameters:

  • amount: Amount to invest

  • minOutputAfterInvestment: Minimum expected shares

Returns:

  • depositedAmount: Amount of tokens received

_divest

Withdraws assets from staking and vault.

Parameters:

  • shares: Amount of shares to withdraw

Returns:

  • withdrawn: Amount of assets received

_liquidatePosition

Liquidates position up to requested amount.

Parameters:

  • amountNeeded: Amount to liquidate

Returns:

  • liquidatedAmount: Amount actually liquidated

  • loss: Amount of losses incurred

_unwindRewards

Claims WMATIC rewards and converts to USDC.

Parameters:

  • _yearnStakingRewards: Staking rewards contract

Internal View Functions

_wpolBalance

Returns strategy's WMATIC balance.

Returns:

  • Current WMATIC balance

_shareBalance

Returns strategy's staked vault share balance.

Returns:

  • Current staked share balance

Last updated