# OracleV1

*Alluvial Finance Inc.*

> Oracle (v1)

This contract handles the input from the allowed oracle members. Highly inspired by Lido's implementation.

## Methods

### acceptAdmin

```solidity
function acceptAdmin() external nonpayable
```

Accept the transfer of ownership

*Only callable by the pending admin. Resets the pending admin if successful.*

### addMember

```solidity
function addMember(address _newOracleMember, uint256 _newQuorum) external nonpayable
```

Adds new address as oracle member, giving the ability to push cl reports.

*Only callable by the administrator. Modifying the quorum clears all the reporting data*

#### Parameters

| Name              | Type    | Description               |
| ----------------- | ------- | ------------------------- |
| \_newOracleMember | address | Address of the new member |
| \_newQuorum       | uint256 | New quorum value          |

### getAdmin

```solidity
function getAdmin() external view returns (address)
```

Retrieves the current admin address

#### Returns

| Name | Type    | Description       |
| ---- | ------- | ----------------- |
| \_0  | address | The admin address |

### getGlobalReportStatus

```solidity
function getGlobalReportStatus() external view returns (uint256)
```

Retrieve member report status

#### Returns

| Name | Type    | Description                 |
| ---- | ------- | --------------------------- |
| \_0  | uint256 | The raw report status value |

### getLastReportedEpochId

```solidity
function getLastReportedEpochId() external view returns (uint256)
```

Retrieve the last reported epoch id

*The Oracle contracts expects reports on an epoch id >= that the returned value*

#### Returns

| Name | Type    | Description                |
| ---- | ------- | -------------------------- |
| \_0  | uint256 | The last reported epoch id |

### getMemberReportStatus

```solidity
function getMemberReportStatus(address _oracleMember) external view returns (bool)
```

Retrieve member report status

#### Parameters

| Name           | Type    | Description                |
| -------------- | ------- | -------------------------- |
| \_oracleMember | address | Address of member to check |

#### Returns

| Name | Type | Description                 |
| ---- | ---- | --------------------------- |
| \_0  | bool | True if member has reported |

### getOracleMembers

```solidity
function getOracleMembers() external view returns (address[])
```

Retrieve the list of oracle members

#### Returns

| Name | Type       | Description        |
| ---- | ---------- | ------------------ |
| \_0  | address\[] | The oracle members |

### getPendingAdmin

```solidity
function getPendingAdmin() external view returns (address)
```

Retrieve the current pending admin address

#### Returns

| Name | Type    | Description               |
| ---- | ------- | ------------------------- |
| \_0  | address | The pending admin address |

### getQuorum

```solidity
function getQuorum() external view returns (uint256)
```

Retrieve the current quorum

#### Returns

| Name | Type    | Description        |
| ---- | ------- | ------------------ |
| \_0  | uint256 | The current quorum |

### getReportVariantDetails

```solidity
function getReportVariantDetails(uint256 _idx) external view returns (struct ReportsVariants.ReportVariantDetails)
```

Retrieve the details of a report variant

#### Parameters

| Name  | Type    | Description                     |
| ----- | ------- | ------------------------------- |
| \_idx | uint256 | The index of the report variant |

#### Returns

| Name | Type                                 | Description                |
| ---- | ------------------------------------ | -------------------------- |
| \_0  | ReportsVariants.ReportVariantDetails | The report variant details |

### getReportVariantsCount

```solidity
function getReportVariantsCount() external view returns (uint256)
```

Retrieve report variants count

#### Returns

| Name | Type    | Description                  |
| ---- | ------- | ---------------------------- |
| \_0  | uint256 | The count of report variants |

### getRiver

```solidity
function getRiver() external view returns (address)
```

Retrieve River address

#### Returns

| Name | Type    | Description          |
| ---- | ------- | -------------------- |
| \_0  | address | The address of River |

### initOracleV1

```solidity
function initOracleV1(address _riverAddress, address _administratorAddress, uint64 _epochsPerFrame, uint64 _slotsPerEpoch, uint64 _secondsPerSlot, uint64 _genesisTime, uint256 _annualAprUpperBound, uint256 _relativeLowerBound) external nonpayable
```

Initializes the oracle

#### Parameters

| Name                   | Type    | Description                                                                                                               |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| \_riverAddress         | address | undefined                                                                                                                 |
| \_administratorAddress | address | Address able to call administrative methods                                                                               |
| \_epochsPerFrame       | uint64  | CL spec parameter. Number of epochs in a frame.                                                                           |
| \_slotsPerEpoch        | uint64  | CL spec parameter. Number of slots in one epoch.                                                                          |
| \_secondsPerSlot       | uint64  | CL spec parameter. Number of seconds between slots.                                                                       |
| \_genesisTime          | uint64  | CL spec parameter. Timestamp of the genesis slot.                                                                         |
| \_annualAprUpperBound  | uint256 | CL bound parameter. Maximum apr allowed for balance increase. Delta between updates is extrapolated on a year time frame. |
| \_relativeLowerBound   | uint256 | CL bound parameter. Maximum relative balance decrease.                                                                    |

### initOracleV1\_1

```solidity
function initOracleV1_1() external nonpayable
```

Initializes the oracle

### isMember

```solidity
function isMember(address _memberAddress) external view returns (bool)
```

Returns true if address is member

*Performs a naive search, do not call this on-chain, used as an off-chain helper*

#### Parameters

| Name            | Type    | Description           |
| --------------- | ------- | --------------------- |
| \_memberAddress | address | Address of the member |

#### Returns

| Name | Type | Description                 |
| ---- | ---- | --------------------------- |
| \_0  | bool | True if address is a member |

### proposeAdmin

```solidity
function proposeAdmin(address _newAdmin) external nonpayable
```

Proposes a new address as admin

*This security prevents setting an invalid address as an admin. The pending admin has to claim its ownership of the contract, and prove that the new address is able to perform regular transactions.*

#### Parameters

| Name       | Type    | Description       |
| ---------- | ------- | ----------------- |
| \_newAdmin | address | New admin address |

### removeMember

```solidity
function removeMember(address _oracleMember, uint256 _newQuorum) external nonpayable
```

Removes an address from the oracle members.

*Only callable by the administrator. Modifying the quorum clears all the reporting dataRemaining members that have already voted should vote again for the same frame.*

#### Parameters

| Name           | Type    | Description       |
| -------------- | ------- | ----------------- |
| \_oracleMember | address | Address to remove |
| \_newQuorum    | uint256 | New quorum value  |

### reportConsensusLayerData

```solidity
function reportConsensusLayerData(IOracleManagerV1.ConsensusLayerReport _report) external nonpayable
```

#### Parameters

| Name     | Type                                  | Description |
| -------- | ------------------------------------- | ----------- |
| \_report | IOracleManagerV1.ConsensusLayerReport | undefined   |

### setMember

```solidity
function setMember(address _oracleMember, address _newAddress) external nonpayable
```

Changes the address of an oracle member

*Only callable by the administrator or the member itselfCannot use an address already in use*

#### Parameters

| Name           | Type    | Description                |
| -------------- | ------- | -------------------------- |
| \_oracleMember | address | Address to change          |
| \_newAddress   | address | New address for the member |

### setQuorum

```solidity
function setQuorum(uint256 _newQuorum) external nonpayable
```

Edits the quorum required to forward cl data to River

*Modifying the quorum clears all the reporting data*

#### Parameters

| Name        | Type    | Description          |
| ----------- | ------- | -------------------- |
| \_newQuorum | uint256 | New quorum parameter |

### version

```solidity
function version() external pure returns (string)
```

Retrieves the version of the contract

#### Returns

| Name | Type   | Description             |
| ---- | ------ | ----------------------- |
| \_0  | string | Version of the contract |

## Events

### AddMember

```solidity
event AddMember(address indexed member)
```

A member has been added to the oracle member list

#### Parameters

| Name             | Type    | Description               |
| ---------------- | ------- | ------------------------- |
| member `indexed` | address | The address of the member |

### ClearedReporting

```solidity
event ClearedReporting()
```

Cleared reporting data

### Initialize

```solidity
event Initialize(uint256 version, bytes cdata)
```

Emitted when the contract is properly initialized

#### Parameters

| Name    | Type    | Description                                               |
| ------- | ------- | --------------------------------------------------------- |
| version | uint256 | New version of the contracts                              |
| cdata   | bytes   | Complete calldata that was used during the initialization |

### RemoveMember

```solidity
event RemoveMember(address indexed member)
```

A member has been removed from the oracle member list

#### Parameters

| Name             | Type    | Description               |
| ---------------- | ------- | ------------------------- |
| member `indexed` | address | The address of the member |

### ReportedConsensusLayerData

```solidity
event ReportedConsensusLayerData(address indexed member, bytes32 indexed variant, IOracleManagerV1.ConsensusLayerReport report, uint256 voteCount, uint256 quorum)
```

An oracle member performed a report

#### Parameters

| Name              | Type                                  | Description               |
| ----------------- | ------------------------------------- | ------------------------- |
| member `indexed`  | address                               | The oracle member         |
| variant `indexed` | bytes32                               | The variant of the report |
| report            | IOracleManagerV1.ConsensusLayerReport | The raw report structure  |
| voteCount         | uint256                               | The vote count            |
| quorum            | uint256                               | undefined                 |

### SetAdmin

```solidity
event SetAdmin(address indexed admin)
```

The admin address changed

#### Parameters

| Name            | Type    | Description       |
| --------------- | ------- | ----------------- |
| admin `indexed` | address | New admin address |

### SetBounds

```solidity
event SetBounds(uint256 annualAprUpperBound, uint256 relativeLowerBound)
```

The report bounds have been changed

#### Parameters

| Name                | Type    | Description                                                                                           |
| ------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| annualAprUpperBound | uint256 | The maximum allowed apr. 10% means increases in balance extrapolated to a year should not exceed 10%. |
| relativeLowerBound  | uint256 | The maximum allowed balance decrease as a relative % of the total balance                             |

### SetLastReportedEpoch

```solidity
event SetLastReportedEpoch(uint256 lastReportedEpoch)
```

The last reported epoch has changed

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| lastReportedEpoch | uint256 | undefined   |

### SetMember

```solidity
event SetMember(address indexed oldAddress, address indexed newAddress)
```

A member address has been edited

#### Parameters

| Name                 | Type    | Description                 |
| -------------------- | ------- | --------------------------- |
| oldAddress `indexed` | address | The previous member address |
| newAddress `indexed` | address | The new member address      |

### SetPendingAdmin

```solidity
event SetPendingAdmin(address indexed pendingAdmin)
```

The pending admin address changed

#### Parameters

| Name                   | Type    | Description               |
| ---------------------- | ------- | ------------------------- |
| pendingAdmin `indexed` | address | New pending admin address |

### SetQuorum

```solidity
event SetQuorum(uint256 newQuorum)
```

The storage quorum value has been changed

#### Parameters

| Name      | Type    | Description          |
| --------- | ------- | -------------------- |
| newQuorum | uint256 | The new quorum value |

### SetRiver

```solidity
event SetRiver(address _river)
```

The storage river address value has been changed

#### Parameters

| Name    | Type    | Description           |
| ------- | ------- | --------------------- |
| \_river | address | The new river address |

### SetSpec

```solidity
event SetSpec(uint64 epochsPerFrame, uint64 slotsPerEpoch, uint64 secondsPerSlot, uint64 genesisTime)
```

The consensus layer spec has been changed

#### Parameters

| Name           | Type   | Description                                                  |
| -------------- | ------ | ------------------------------------------------------------ |
| epochsPerFrame | uint64 | The number of epochs inside a frame (225 = 24 hours)         |
| slotsPerEpoch  | uint64 | The number of slots inside an epoch (32 on ethereum mainnet) |
| secondsPerSlot | uint64 | The time between two slots (12 seconds on ethereum mainnet)  |
| genesisTime    | uint64 | The timestamp of block #0                                    |

## Errors

### AddressAlreadyInUse

```solidity
error AddressAlreadyInUse(address newAddress)
```

The address is already in use by an oracle member

#### Parameters

| Name       | Type    | Description                |
| ---------- | ------- | -------------------------- |
| newAddress | address | The address already in use |

### AlreadyReported

```solidity
error AlreadyReported(uint256 epochId, address member)
```

The member already reported on the given epoch id

#### Parameters

| Name    | Type    | Description                    |
| ------- | ------- | ------------------------------ |
| epochId | uint256 | The epoch id provided as input |
| member  | address | The oracle member              |

### EpochTooOld

```solidity
error EpochTooOld(uint256 providedEpochId, uint256 minExpectedEpochId)
```

The provided epoch is too old compared to the expected epoch id

#### Parameters

| Name               | Type    | Description                    |
| ------------------ | ------- | ------------------------------ |
| providedEpochId    | uint256 | The epoch id provided as input |
| minExpectedEpochId | uint256 | The minimum epoch id expected  |

### InvalidArgument

```solidity
error InvalidArgument()
```

The argument was invalid

### InvalidCall

```solidity
error InvalidCall()
```

The call was invalid

### InvalidEpoch

```solidity
error InvalidEpoch(uint256 epoch)
```

Thrown when the reported epoch is invalid

#### Parameters

| Name  | Type    | Description       |
| ----- | ------- | ----------------- |
| epoch | uint256 | The invalid epoch |

### InvalidInitialization

```solidity
error InvalidInitialization(uint256 version, uint256 expectedVersion)
```

An error occurred during the initialization

#### Parameters

| Name            | Type    | Description                                       |
| --------------- | ------- | ------------------------------------------------- |
| version         | uint256 | The version that was attempting to be initialized |
| expectedVersion | uint256 | The version that was expected                     |

### InvalidZeroAddress

```solidity
error InvalidZeroAddress()
```

The address is zero

### ReportIndexOutOfBounds

```solidity
error ReportIndexOutOfBounds(uint256 index, uint256 length)
```

Thrown when the report indexes fetched is out of bounds

#### Parameters

| Name   | Type    | Description               |
| ------ | ------- | ------------------------- |
| index  | uint256 | Requested index           |
| length | uint256 | Size of the variant array |

### Unauthorized

```solidity
error Unauthorized(address caller)
```

The operator is unauthorized for the caller

#### Parameters

| Name   | Type    | Description                 |
| ------ | ------- | --------------------------- |
| caller | address | Address performing the call |


---

# 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.liquidcollective.io/eth/technical-reference/smart-contracts/oraclev1.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.
