# AeraVaultAssetRegistry

## AeraVaultAssetRegistry

**Inherits:** IAssetRegistry, Sweepable, ERC165

Maintains a list of registered assets and their oracles (when applicable).

### State Variables

#### MAX\_ASSETS

Maximum number of assets.

```solidity
uint256 public constant MAX_ASSETS = 50;
```

#### GRACE\_PERIOD\_TIME

Time to pass before accepting answers when sequencer comes back up.

```solidity
uint256 public constant GRACE_PERIOD_TIME = 3600;
```

#### vault

Vault address.

```solidity
address public immutable vault;
```

#### numeraireToken

Numeraire token.

```solidity
IERC20 public immutable numeraireToken;
```

#### feeToken

Fee token.

```solidity
IERC20 public immutable feeToken;
```

#### wrappedNativeToken

Wrapped native token.

```solidity
IERC20 public immutable wrappedNativeToken;
```

#### sequencer

Sequencer Uptime Feed address for L2.

```solidity
AggregatorV2V3Interface public immutable sequencer;
```

#### \_assets

STORAGE ///

List of currently registered assets.

```solidity
AssetInformation[] internal _assets;
```

#### numYieldAssets

Number of ERC4626 assets. Maintained for more efficient calculation of spotPrices.

```solidity
uint256 public numYieldAssets;
```

### Functions

#### constructor

FUNCTIONS ///

```solidity
constructor(
    address owner_,
    address vault_,
    AssetInformation[] memory assets_,
    IERC20 numeraireToken_,
    IERC20 feeToken_,
    IERC20 wrappedNativeToken_,
    AggregatorV2V3Interface sequencer_
) Ownable;
```

**Parameters**

| Name                  | Type                      | Description                           |
| --------------------- | ------------------------- | ------------------------------------- |
| `owner_`              | `address`                 | Initial owner address.                |
| `vault_`              | `address`                 | Vault address.                        |
| `assets_`             | `AssetInformation[]`      | Initial list of registered assets.    |
| `numeraireToken_`     | `IERC20`                  | Numeraire token address.              |
| `feeToken_`           | `IERC20`                  | Fee token address.                    |
| `wrappedNativeToken_` | `IERC20`                  | Wrapped native token address.         |
| `sequencer_`          | `AggregatorV2V3Interface` | Sequencer Uptime Feed address for L2. |

#### addAsset

Add a new asset.

*MUST revert if not called by owner.*

*MUST revert if asset with the same address exists.*

```solidity
function addAsset(AssetInformation calldata asset) external onlyOwner;
```

**Parameters**

| Name    | Type               | Description                      |
| ------- | ------------------ | -------------------------------- |
| `asset` | `AssetInformation` | Asset information for new asset. |

#### removeAsset

Remove an asset.

*MUST revert if not called by owner.*

```solidity
function removeAsset(address asset) external onlyOwner;
```

**Parameters**

| Name    | Type      | Description         |
| ------- | --------- | ------------------- |
| `asset` | `address` | An asset to remove. |

#### assets

Get a list of all registered assets.

*MUST return assets in an order sorted by address.*

```solidity
function assets() external view override returns (AssetInformation[] memory);
```

**Returns**

| Name     | Type                 | Description            |
| -------- | -------------------- | ---------------------- |
| `<none>` | `AssetInformation[]` | assets List of assets. |

#### spotPrices

Calculate spot prices of non-ERC4626 assets.

*MUST return assets in the same order as in assets but with ERC4626 assets filtered out.*

```solidity
function spotPrices()
    external
    view
    override
    returns (AssetPriceReading[] memory);
```

**Returns**

| Name     | Type                  | Description                                                  |
| -------- | --------------------- | ------------------------------------------------------------ |
| `<none>` | `AssetPriceReading[]` | spotPrices Spot prices of non-ERC4626 assets in 18 decimals. |

#### supportsInterface

*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding <https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified\\[EIP> section] to learn more about how these ids are created. This function call must use less than 30 000 gas.*

```solidity
function supportsInterface(bytes4 interfaceId)
    public
    view
    override
    returns (bool);
```

#### \_checkAssetOracle

INTERNAL FUNCTIONS ///

Ensure non-zero oracle address for ERC20 and zero oracle address for ERC4626.

```solidity
function _checkAssetOracle(AssetInformation memory asset) internal view;
```

**Parameters**

| Name    | Type               | Description            |
| ------- | ------------------ | ---------------------- |
| `asset` | `AssetInformation` | Asset details to check |

#### \_checkOraclePrice

Ensure oracle returns valid value and it's up to date.

```solidity
function _checkOraclePrice(AssetInformation memory asset)
    internal
    view
    returns (uint256 price);
```

**Parameters**

| Name    | Type               | Description             |
| ------- | ------------------ | ----------------------- |
| `asset` | `AssetInformation` | Asset details to check. |

**Returns**

| Name    | Type      | Description         |
| ------- | --------- | ------------------- |
| `price` | `uint256` | Valid oracle price. |

#### \_checkUnderlyingAsset

Check whether the underlying asset is listed as an ERC20.

*Will revert if underlying asset is an ERC4626.*

```solidity
function _checkUnderlyingAsset(
    AssetInformation memory asset,
    AssetInformation[] memory assetsToCheck
) internal view;
```

**Parameters**

| Name            | Type                 | Description                              |
| --------------- | -------------------- | ---------------------------------------- |
| `asset`         | `AssetInformation`   | ERC4626 asset to check underlying asset. |
| `assetsToCheck` | `AssetInformation[]` | Array of assets.                         |

#### \_insertAsset

Insert asset at the given index in an array of assets.

```solidity
function _insertAsset(AssetInformation memory asset, uint256 index) internal;
```

**Parameters**

| Name    | Type               | Description                                |
| ------- | ------------------ | ------------------------------------------ |
| `asset` | `AssetInformation` | New asset details.                         |
| `index` | `uint256`          | Index of the new asset in the asset array. |

#### \_checkAssetRegistryOwner

Check that owner is not the vault or the guardian.

```solidity
function _checkAssetRegistryOwner(
    address owner_,
    address vault_
) internal view;
```

**Parameters**

| Name     | Type      | Description                   |
| -------- | --------- | ----------------------------- |
| `owner_` | `address` | Asset registry owner address. |
| `vault_` | `address` | Vault address.                |

#### transferOwnership

*Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.*

```solidity
function transferOwnership(address newOwner) public override onlyOwner;
```

### Events

#### AssetAdded

EVENTS ///

Emitted when a new asset is added.

```solidity
event AssetAdded(address indexed asset, AssetInformation assetInfo);
```

#### AssetRemoved

Emitted when an asset is removed.

```solidity
event AssetRemoved(address indexed asset);
```

#### Created

Emitted in constructor.

```solidity
event Created(
    address indexed owner,
    address indexed vault,
    AssetInformation[] assets,
    address indexed numeraireToken,
    address feeToken,
    address wrappedNativeToken,
    address sequencer
);
```

### Errors

#### Aera\_\_NumberOfAssetsExceedsMaximum

ERRORS ///

```solidity
error Aera__NumberOfAssetsExceedsMaximum(uint256 max);
```

#### Aera\_\_NumeraireTokenIsNotRegistered

```solidity
error Aera__NumeraireTokenIsNotRegistered(address numeraireToken);
```

#### Aera\_\_NumeraireTokenIsERC4626

```solidity
error Aera__NumeraireTokenIsERC4626();
```

#### Aera\_\_NumeraireOracleIsNotZeroAddress

```solidity
error Aera__NumeraireOracleIsNotZeroAddress();
```

#### Aera\_\_FeeTokenIsNotRegistered

```solidity
error Aera__FeeTokenIsNotRegistered(address feeToken);
```

#### Aera\_\_FeeTokenIsERC4626

```solidity
error Aera__FeeTokenIsERC4626(address feeToken);
```

#### Aera\_\_WrappedNativeTokenIsNotRegistered

```solidity
error Aera__WrappedNativeTokenIsNotRegistered(address wrappedNativeToken);
```

#### Aera\_\_WrappedNativeTokenIsERC4626

```solidity
error Aera__WrappedNativeTokenIsERC4626(address wrappedNativeToken);
```

#### Aera\_\_AssetOrderIsIncorrect

```solidity
error Aera__AssetOrderIsIncorrect(uint256 index);
```

#### Aera\_\_AssetRegistryInitialOwnerIsZeroAddress

```solidity
error Aera__AssetRegistryInitialOwnerIsZeroAddress();
```

#### Aera\_\_AssetRegistryOwnerIsGuardian

```solidity
error Aera__AssetRegistryOwnerIsGuardian();
```

#### Aera\_\_AssetRegistryOwnerIsVault

```solidity
error Aera__AssetRegistryOwnerIsVault();
```

#### Aera\_\_ERC20OracleIsZeroAddress

```solidity
error Aera__ERC20OracleIsZeroAddress(address asset);
```

#### Aera\_\_ERC4626OracleIsNotZeroAddress

```solidity
error Aera__ERC4626OracleIsNotZeroAddress(address asset);
```

#### Aera\_\_UnderlyingAssetIsNotRegistered

```solidity
error Aera__UnderlyingAssetIsNotRegistered(
    address asset, address underlyingAsset
);
```

#### Aera\_\_UnderlyingAssetIsItselfERC4626

```solidity
error Aera__UnderlyingAssetIsItselfERC4626();
```

#### Aera\_\_AssetIsUnderlyingAssetOfERC4626

```solidity
error Aera__AssetIsUnderlyingAssetOfERC4626(address erc4626Asset);
```

#### Aera\_\_AssetIsAlreadyRegistered

```solidity
error Aera__AssetIsAlreadyRegistered(uint256 index);
```

#### Aera\_\_AssetNotRegistered

```solidity
error Aera__AssetNotRegistered(address asset);
```

#### Aera\_\_CannotRemoveNumeraireToken

```solidity
error Aera__CannotRemoveNumeraireToken(address asset);
```

#### Aera\_\_CannotRemoveFeeToken

```solidity
error Aera__CannotRemoveFeeToken(address feeToken);
```

#### Aera\_\_CannotRemoveWrappedNativeToken

```solidity
error Aera__CannotRemoveWrappedNativeToken(address wrappedNativeToken);
```

#### Aera\_\_VaultIsZeroAddress

```solidity
error Aera__VaultIsZeroAddress();
```

#### Aera\_\_SequencerIsDown

```solidity
error Aera__SequencerIsDown();
```

#### Aera\_\_GracePeriodNotOver

```solidity
error Aera__GracePeriodNotOver();
```

#### Aera\_\_OraclePriceIsInvalid

```solidity
error Aera__OraclePriceIsInvalid(AssetInformation asset, int256 actual);
```

#### Aera\_\_OraclePriceIsTooOld

```solidity
error Aera__OraclePriceIsTooOld(AssetInformation asset, uint256 updatedAt);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aera.finance/v2-archive/contracts/aeravaultassetregistry.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
