AutopoolCompounder
Inherits: BaseStrategy
A Yearn V3 strategy that compounds Tokemak Autopool rewards
Accepts any Tokemak Autopool ERC4626 vault as the asset, stakes it, and compounds rewards. Deployers should seed the underlying Autopool immediately after deployment to avoid the standard first-depositor inflation risk.
Using private RPCs to call report() is recommended to avoid any frontrunning activities when
depositing rewards back into the autopool.
State Variables
baseAsset
CONSTANTS ///
The base asset of the autopool (e.g., USDC for autoUSD)
IERC20 public immutable baseAsset;
rewarder
The Tokemak AutopoolMainRewarder for staking
IAutopoolMainRewarder public immutable rewarder;
milkman
The Milkman contract for async swaps
IMilkman public immutable milkman;
priceCheckerByToken
STATE VARIABLES ///
Mapping from reward token to its price checker
mapping(address => address) public priceCheckerByToken;
_configuredRewardTokens
Set of configured reward tokens
EnumerableSet.AddressSet private _configuredRewardTokens;
maxPriceDeviationBps
Maximum deviation allowed for price checks (in basis points)
uint256 public maxPriceDeviationBps = 500;
Functions
constructor
CONSTRUCTOR ///
Initialize the strategy
constructor(
address _autopool,
address _rewarder,
address _milkman
)
payable
BaseStrategy(_autopool, "AutopoolCompounder");
Parameters
Name | Type | Description |
---|---|---|
_autopool | address | The Tokemak Autopool vault to manage |
_rewarder | address | The AutopoolMainRewarder contract |
_milkman | address | The Milkman contract for swaps |
updatePriceChecker
MANAGEMENT FUNCTIONS ///
Update the price checker for a reward token
function updatePriceChecker(address rewardToken, address priceChecker) external onlyManagement;
Parameters
Name | Type | Description |
---|---|---|
rewardToken | address | The reward token address |
priceChecker | address | The price checker contract address |
setMaxPriceDeviation
Set the maximum price deviation for swaps
function setMaxPriceDeviation(uint256 maxDeviationBps_) external onlyManagement;
Parameters
Name | Type | Description |
---|---|---|
maxDeviationBps_ | uint256 | The max deviation in basis points |
cancelSwap
KEEPER FUNCTIONS ///
Cancel a stuck swap and recover tokens
Only callable by management to recover stuck swaps
function cancelSwap(
uint256 amountIn,
address fromToken,
address toToken,
address priceChecker,
bytes calldata priceCheckerData
)
external
onlyKeepers;
Parameters
Name | Type | Description |
---|---|---|
amountIn | uint256 | The amount of tokens in the swap |
fromToken | address | The token being swapped from |
toToken | address | The token being swapped to |
priceChecker | address | The price checker used in the swap |
priceCheckerData | bytes | The data passed to the price checker |
claimRewardsAndSwap
Claim rewards and initiate swaps via Milkman
Initiates async swaps. In-flight assets don't affect reported share balance.
function claimRewardsAndSwap() external onlyKeepers;
_processRewardToken
Process a single reward token for swapping
function _processRewardToken(address token) internal;
_deployFunds
YEARN V3 STRATEGY HOOKS ///
Deploy funds by staking autopool tokens
function _deployFunds(uint256 amount) internal override;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount to deploy |
_freeFunds
Free funds by unstaking autopool tokens
function _freeFunds(uint256 amount) internal override;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount to free |
_harvestAndReport
Harvest and report strategy performance
Strategy accounts for autopool shares, not base assets. In-flight Milkman swaps do not affect share
balance. Gains are realized in the next report() after swaps settle.
function _harvestAndReport() internal override returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total assets under management (in autopool shares) |
_emergencyWithdraw
Emergency withdraw function for shutdown scenarios
Allows management to withdraw staked autopool shares when strategy is shutdown
function _emergencyWithdraw(uint256 _amount) internal override;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | The amount of autopool shares to withdraw |
recoverBaseAssets
Recover base assets stuck in the contract
Can only be called when strategy is shutdown to prevent griefing
function recoverBaseAssets() external onlyManagement;
getConfiguredRewardTokens
VIEW FUNCTIONS ///
Get all configured reward tokens
function getConfiguredRewardTokens() external view returns (address[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | address[] | An array of configured reward token addresses |
stakedBalance
Get the total staked balance
function stakedBalance() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount staked in the rewarder |
pendingRewards
Get pending rewards
function pendingRewards() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of pending main rewards (TOKE) |
Events
PriceCheckerUpdated
EVENTS ///
event PriceCheckerUpdated(address indexed rewardToken, address indexed priceChecker);
MaxPriceDeviationUpdated
event MaxPriceDeviationUpdated(uint256 maxDeviationBps);
Errors
ZeroAddress
ERRORS ///
error ZeroAddress();
InvalidAsset
error InvalidAsset();
CannotSetCheckerForAsset
error CannotSetCheckerForAsset();
InvalidPriceChecker
error InvalidPriceChecker();
InvalidMaxDeviation
error InvalidMaxDeviation();
StrategyNotShutdown
error StrategyNotShutdown();