MaxApyHarvester
Overview
The MaxApyHarvester contract serves as an internal mechanism to execute harvests atomically. It manages strategy allocations and harvests for the MaxApy protocol, handling batch operations for multiple strategies.
Constants
Errors
State Variables
Structs
Functions
Constructor
Initializes the contract with admin and keeper roles.
Parameters:
admin
: Address of the adminkeepers
: Array of keeper addresses to be granted roles
Fallback Functions
fallback
Reverts any direct calls to the contract.
receive
Reverts any ETH transfers to the contract.
Core Functions
batchAllocate
Executes batch strategy allocation for the MaxApy protocol.
Parameters:
vault
: MaxApyVault contract instancestrategies
: Array of strategy allocation data
batchHarvest
Executes batch harvesting operations for multiple strategies.
Parameters:
vault
: MaxApyVault contract instanceharvests
: Array of harvest data for strategies
batchAllocateAndHarvest
Combines batch allocation and harvesting in a single transaction.
Parameters:
vault
: MaxApyVault contract instanceallocations
: Array of strategy allocation dataharvests
: Array of harvest data
Returns:
Boolean indicating success
Simulation Functions
_simulateBatchAllocateAndHarvest
Internal function that performs a dry-run of batch allocation and harvest operations. It simulates the entire process of adding new strategies and harvesting, capturing the state changes without permanently altering the blockchain state.
This function works by:
Recording initial total assets
Simulating strategy allocations
Simulating harvests for each strategy
Collecting detailed simulation results
Reverting with encoded data containing all simulation outcomes
Parameters:
vault
: MaxApyVault contract instanceallocations
: Array of strategy allocation dataharvests
: Array of harvest data
simulateBatchAllocateAndHarvest
An external function that provides a safe way to preview the outcomes of strategy changes and harvests before actually executing them. This function is crucial for risk management and optimization of strategy allocations.
Key benefits:
Allows analysis of potential returns before committing funds
It helps in comparing different strategy combinations
Provides insights into expected asset value changes
Enables validation of allocation decisions before execution
Assists in optimizing harvest parameters
Parameters:
vault
: MaxApyVault contract instanceallocations
: Array of strategy allocation dataharvests
: Array of harvest data
Returns:
totalAssetsBefore
: Total vault assets before simulated operationstotalAssetsAfter
: Projected total assets after operationssimulationResults
: Detailed results for each strategy, including:Expected balances
Investment outputs
Intended vs actual invest/divest amounts
Strategy-specific performance metrics
Usage: This simulation mechanism is essential for protocol management, allowing operators to:
Test new strategy combinations safely
Validate allocation ratios
Preview harvest outcomes
Optimize timing and parameters of operations
Minimize risks when adjusting strategy allocations
Modifiers
checkRoles
Ensures caller has required roles.
Parameters:
roles
: Required role permissions
Last updated