Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AutoPoolCompounderOracle

Git Source

Inherits: ChainedERC4626Oracle

Author: Storm Labs (https://storm-labs.xyz/)

A price oracle adapter for Autopool Compounder tokens that provides pricing relative to the base asset

*Extends ChainedERC4626Oracle to handle the AutopoolCompounder -> Autopool -> BaseAsset chain with additional validation for the Autopool's debt reporting staleness. The oracle validates that the Autopool's oldestDebtReporting timestamp is within 24 hours to ensure accurate pricing. If the debt reporting is stale, the oracle will revert. Chain structure:

  1. AutopoolCompounder (Yearn V3 Strategy, ERC4626) holds Autopool tokens
  2. Autopool (Tokemak Vault, ERC4626) holds base asset (e.g., USDC)
  3. Base Asset (e.g., USDC)*

State Variables

MAX_DEBT_REPORTING_AGE

Maximum allowed age for debt reporting (24 hours in seconds)

uint256 public constant MAX_DEBT_REPORTING_AGE = 24 hours;

autopool

The Autopool contract for debt reporting validation

IAutopool public immutable autopool;

Functions

constructor

Constructor for the AutoPoolCompounderOracle contract

The constructor automatically discovers the chain from compounder to base asset and validates that the autopool's debt reporting is fresh

constructor(IERC4626 _compounder) payable ChainedERC4626Oracle(_compounder, _getBaseAsset(_compounder));

Parameters

NameTypeDescription
_compounderIERC4626The AutopoolCompounder (Yearn V3 Strategy) contract

_getQuote

Internal function to get quote with debt reporting validation

function _getQuote(uint256 inAmount, address _base, address _quote) internal view virtual override returns (uint256);

Parameters

NameTypeDescription
inAmountuint256The input amount to convert
_baseaddressThe base asset address
_quoteaddressThe quote asset address

Returns

NameTypeDescription
<none>uint256The converted amount

_validateDebtReporting

Validates that the Autopool's debt reporting is not stale

Reverts if the oldest debt reporting timestamp is more than 24 hours old

function _validateDebtReporting() internal view;

_getBaseAsset

Helper function to extract the base asset from the compounder chain

function _getBaseAsset(IERC4626 _compounder) private view returns (address);

Parameters

NameTypeDescription
_compounderIERC4626The AutopoolCompounder contract

Returns

NameTypeDescription
<none>addressThe base asset address (e.g., USDC)

Errors

StaleDebtReporting

Thrown when the Autopool's debt reporting is stale (older than 24 hours)

error StaleDebtReporting(uint256 oldestTimestamp, uint256 currentTimestamp);

InvalidChainLength

Thrown when the vault chain length is invalid

error InvalidChainLength();