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

function initialize(
    IMaxApyVault _vault,
    address[] calldata _keepers,
    bytes32 _strategyName,
    address _strategist,
    IYVaultV3 _yVault
) public 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 V3 vault address

Core Functions

liquidateExact

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

Withdraws exact amount and re-stakes remaining shares.

Parameters:

  • amountNeeded: Amount to withdraw

Returns:

  • loss: Amount of realized loss

Internal Core Functions

_beforePrepareReturn

function _beforePrepareReturn() internal override

Claims and processes staking rewards before preparing return.

_adjustPosition

function _adjustPosition(uint256, uint256 minOutputAfterInvestment) internal override

Adjusts strategy positions based on available capital.

Parameters:

  • minOutputAfterInvestment: Minimum expected output

_invest

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

Invests assets and stakes received shares.

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 from staking and vault.

Parameters:

  • shares: Amount of shares to withdraw

Returns:

  • withdrawn: Amount of assets received

_liquidatePosition

function _liquidatePosition(uint256 amountNeeded) internal override returns (uint256 liquidatedAmount, uint256 loss)

Liquidates position up to requested amount.

Parameters:

  • amountNeeded: Amount to liquidate

Returns:

  • liquidatedAmount: Amount actually liquidated

  • loss: Amount of losses incurred

_unwindRewards

function _unwindRewards(IStakingRewardsMulti _yearnStakingRewards) internal

Claims WMATIC rewards and converts to USDC.

Parameters:

  • _yearnStakingRewards: Staking rewards contract

Internal View Functions

_wpolBalance

function _wpolBalance() internal view returns (uint256)

Returns strategy's WMATIC balance.

Returns:

  • Current WMATIC balance

_shareBalance

function _shareBalance() internal view override returns (uint256 _balance)

Returns strategy's staked vault share balance.

Returns:

  • Current staked share balance

Last updated