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

AutopoolOracle

Git Source

Inherits: BaseAdapter

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

A price oracle adapter for Autopool ERC4626 vault tokens that validates debt reporting freshness

Handles price conversions between ERC4626 vault shares and their underlying assets. When the vault token is used as the base or quote, the oracle automatically converts between share and asset prices using the vault's convertToAssets/convertToShares functions. The oracle follows the behavior of the ERC4626 vault's implementation of its functions, typically ignoring the maximum amount of shares that can be redeemed or minted. This oracle relies on the convertToAssets/convertToShares functions of the underlying ERC4626 vault. If the dependent ERC4626 contract does not implement sufficient protection against donation attacks, sudden price jumps may occur when large amounts of assets are donated to the vault without a proportional increase in shares. Users should verify the security measures implemented by the underlying vault. Due to this risk, this oracle should only be used when there is no direct price feed available for the vault token. Additionally, this oracle validates that the Autopool's debt reporting is fresh (within 24 hours).

State Variables

name

The name of the oracle.

string public constant override name = "AutopoolOracle";

base

The address of the base asset.

address public immutable base;

quote

The address of the quote asset.

address public immutable quote;

autopool

The Autopool contract for debt reporting validation

IAutopool public immutable autopool;

_MAX_DEBT_REPORTING_AGE

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

uint256 internal constant _MAX_DEBT_REPORTING_AGE = 24 hours;

Functions

constructor

Constructor for the AutopoolOracle contract.

constructor(IERC4626 _vault) payable;

Parameters

NameTypeDescription
_vaultIERC4626The ERC4626 Autopool vault that should be used as the base asset.

_getQuote

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

_validateDebtReporting

Checks last Autopool debt reporting age is <= 24h, reverts if too old

function _validateDebtReporting() internal view;

Errors

StaleDebtReporting

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

error StaleDebtReporting(uint256 oldestTimestamp, uint256 currentTimestamp);