AaveVault

AaveVault: Aave v3 Integration for Yield Generation

πŸ“‹ Overview

The AaveVault is the contract that manages integration with the Aave v3 protocol. It deploys protocol USDC to Aave for yield generation via lending, then distributes revenue to the YieldShift system.


πŸ—οΈ Contract Architecture

Inheritance

contract AaveVault is 
    Initializable,
    ReentrancyGuardUpgradeable,
    AccessControlUpgradeable,
    PausableUpgradeable,
    SecureUpgradeable

Aave Dependencies

Interface
Variable
Role

IERC20

usdc

Underlying USDC token

IERC20

aUSDC

Aave deposit token

IPool

aavePool

Main Aave pool

IPoolAddressesProvider

aaveProvider

Aave address registry

IRewardsController

rewardsController

Aave rewards (if available)

IYieldShift

yieldShift

Yield distribution


πŸ” Roles & Permissions

Role
Responsibilities

DEFAULT_ADMIN_ROLE

General administration

GOVERNANCE_ROLE

Parameters (exposure, fees, thresholds)

VAULT_MANAGER_ROLE

Deploy/withdraw operations

EMERGENCY_ROLE

Emergency mode, pause, emergency withdrawal


βš™οΈ Configuration Parameters

Limits and Thresholds

Parameter
Type
Description
Default Value

maxAaveExposure

uint256

Max Aave exposure (USDC 6 dec)

50,000,000e6 (50M)

harvestThreshold

uint256

Min yield for harvest (USDC)

1,000e6 (1K)

rebalanceThreshold

uint256

Threshold to trigger rebalance (BPS)

500 (5%)

utilizationLimit

uint256

Aave utilization limit (BPS)

9500 (95%)

emergencyExitThreshold

uint256

Emergency exit threshold (BPS)

110 (1.1%)

Fees

Parameter
Type
Description
Default Value

yieldFee

uint256

Fee on harvested yield (BPS)

1000 (10%)


πŸ’° Deployment Operations

Deploy to Aave

Flow

Validations

Check
Error if Failed

!emergencyMode

EmergencyModeActive

newExposure <= maxAaveExposure

MaxExposureExceeded

_isAaveHealthy()

AaveNotHealthy

Withdraw from Aave

Flow


πŸ₯ Health Monitoring

_isAaveHealthy Function

Checks Performed

When to Use

  • Before each deployment (deployToAave)

  • During periodic health checks

  • Before auto-rebalance


πŸ”„ Auto-Rebalancing

autoRebalance Function

When to Trigger a Rebalance

Rebalance Flow

Optimal Allocation Calculation

Factors Considered

Factor
Weight
Description

Aave APY

Primary

Current lending yield

Utilization

Safety

Available liquidity

Protocol Needs

Reserve

Buffer for redemptions

Simplified Formula


🌾 Yield Harvesting

harvestYield Function

Yield Calculation

Tracking

Claim Aave Rewards

If Aave distributes rewards (bonus tokens), this function collects them.


🚨 Emergency Mode

Activation

Emergency Mode Impact

Function
Normal
Emergency Mode

deployToAave

βœ… Allowed

❌ Blocked

withdrawFromAave

βœ… Allowed

βœ… Allowed

harvestYield

βœ… Allowed

⚠️ Limited

emergencyWithdrawAll

❌ Blocked

βœ… Allowed

Emergency Withdraw All

Flow

When to Use

  • Vulnerability detected on Aave

  • Aave liquidity problem

  • Urgent protocol liquidity need

  • Security incident


πŸ“Š View Functions

Main Metrics

Aave Metrics

Risk Metrics


βš™οΈ Configuration

Update Parameters

Update Safety Thresholds


πŸ›‘οΈ Security

Implemented Protections

Protection
Description

Max Exposure

Absolute deployment limit

Utilization Check

Verify available liquidity

Health Monitoring

Checks before each operation

Emergency Mode

Quick exit if necessary

Reentrancy Guard

Reentrancy protection

Role-Based Access

Permission separation

Recovery

Note: Cannot recover active USDC or aUSDC.


πŸ“‹ Events


πŸ“ Calculation Examples

Example 1: Yield Harvest

Example 2: Rebalance


πŸ”— Protocol Integration


Summary: The AaveVault manages integration with Aave v3 to generate yield on protocol USDC. It includes health monitoring, auto-rebalancing, and emergency mode mechanisms to ensure fund security. Yield is harvested periodically and distributed via YieldShift after deducting protocol fees (10%).

Last updated