ChainedERC4626Oracle
Inherits: BaseAdapter
Author: Storm Labs (https://storm-labs.xyz/)
A price oracle adapter for chained ERC4626 vault tokens
Handles price conversions between ERC4626 vault shares through multiple levels until reaching the target underlying asset. The oracle automatically converts between share and asset prices through the entire chain using each vault's convertToAssets/convertToShares functions. This oracle relies on the convertToAssets/convertToShares functions of the underlying ERC4626 vaults. If the dependent ERC4626 contracts do not implement sufficient protection against donation attacks, sudden price jumps may occur when large amounts of assets are donated to the vaults without a proportional increase in shares. Users should verify the security measures implemented by the underlying vaults. Due to this risk, this oracle should only be used when there is no direct price feed available for the vault tokens.
State Variables
name
The name of the oracle
string public constant override name = "ChainedERC4626Oracle";
base
The address of the base asset (first vault in chain)
address public immutable base;
quote
The address of the quote asset (final underlying asset)
address public immutable quote;
vaults
The array of vaults in the chain
address[] public vaults;
_MAX_CHAIN_LENGTH
Maximum allowed length for the vault chain
uint256 private constant _MAX_CHAIN_LENGTH = 10;
Functions
constructor
Constructor for the ChainedERC4626Oracle contract
constructor(IERC4626 _initialVault, address _targetAsset) payable;
Parameters
Name | Type | Description |
---|---|---|
_initialVault | IERC4626 | The starting ERC4626 vault in the chain |
_targetAsset | address | The final underlying asset to reach |
_getQuote
Internal function to get quote through the vault chain
function _getQuote(uint256 inAmount, address _base, address _quote) internal view virtual override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
inAmount | uint256 | The input amount to convert |
_base | address | The base asset address |
_quote | address | The quote asset address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The converted amount |
Errors
InvalidVaultChain
Thrown when a vault in the chain is invalid (zero address)
error InvalidVaultChain();
ChainTooLong
Thrown when the vault chain is either empty or exceeds the maximum allowed length
error ChainTooLong();
TargetAssetNotReached
Thrown when the chain cannot reach the target asset (e.g., invalid vault sequence)
error TargetAssetNotReached();