Skip to main content

ERC4626Oracle

Git Source

Inherits: AggregatorV2V3Interface

SPDX-License-Identifier: MIT

Chainlink-like price oracle wrapping ERC4626 vaults. This oracle exposes the price of one share of the vault it wraps in terms of its underlying asset (the exchange rate).

State Variables

version

The implementation version of this contract.

uint256 public immutable version = 1;

vault

The ERC4626 vault.

IERC4626 public immutable vault;

underlying

The underlying asset of the vault.

IERC20Metadata public immutable underlying;

decimals

The number of decimals of the price returned by this oracle.

uint8 public immutable decimals;

description

The description for this oracle.

string public description;

ONE_SHARE

One unit of the ERC4626 vault.

uint256 public immutable ONE_SHARE;

SCALING_NUMERATOR

Scaling factor numerator used to adjust price to the desired decimals.

uint256 public immutable SCALING_NUMERATOR;

Functions

constructor

Creates a new ERC4626Wrapper for a given ERC4626 vault.

constructor(IERC4626 _vault, uint8 _decimals);

Parameters

NameTypeDescription
_vaultIERC4626The ERC4626 vault.
_decimalsuint8The decimals to use for the price.

getPrice

function getPrice() public view returns (uint256);

latestAnswer

function latestAnswer() external view override returns (int256);

latestTimestamp

function latestTimestamp() external view override returns (uint256);

latestRound

function latestRound() external pure override returns (uint256);

getAnswer

function getAnswer(uint256) external view override returns (int256);

getTimestamp

function getTimestamp(uint256) external view override returns (uint256);

getRoundData

function getRoundData(uint80)
external
view
override
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

latestRoundData

function latestRoundData()
external
view
override
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

_latestRoundData

function _latestRoundData()
internal
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);