# Fundamental

## Oracles Implementation

### Contracts

The contracts fetch datas from:

| Blockchain         | Contract Address                                                                                                              |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| Base               | [0x05552ab897fd8ae2a0acdfa9275cc189f3832a6f](https://basescan.org/address/0x05552ab897fd8ae2a0acdfa9275cc189f3832a6f#code)    |
| Sonic (Deprecated) | [0x70a58a01c6211ae6b5a1c53b6753f412480bfb44](https://sonicscan.org/address/0x70a58a01c6211ae6b5a1c53b6753f412480bfb44#code)   |
| HyperEVM           | [0x77Fbc522AD920f81799b0c3a71d207d4565c5DA8](https://hyperevmscan.io/address/0x77Fbc522AD920f81799b0c3a71d207d4565c5DA8#code) |
| Avalanche          | [0x94E88fb255FBD0EcEf829098687f5B27f02a12ba](https://snowscan.xyz/address/0x94E88fb255FBD0EcEf829098687f5B27f02a12ba#code)    |

### Gas Wallets

Gas wallets are used to push data to oracle contracts. To ensure uninterrupted oracle operation, Cooper Labs is maintaining sufficient gas in them. Anyone can monitor the wallets below to ensure they remain adequately funded at all times.

| Blockchain         | Contract Address                                                                                                         |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| Base               | [0x8cdc088a6b19f58f7613cb65af03c7496adad893](https://basescan.org/address/0x8cdc088a6b19f58f7613cb65af03c7496adad893)    |
| Sonic (Deprecated) | [0xd35087bb5fa7c4d1a87050cabf73ee4f1649f666](https://sonicscan.org/address/0xd35087bb5fa7c4d1a87050cabf73ee4f1649f666)   |
| HyperEVM           | [0x14566aeb825a3f0605eecd65144dacc52d675b36](https://hyperevmscan.io/address/0x14566aeb825a3f0605eecd65144dacc52d675b36) |
| Avalanche          | [0xe9847Afb5564B221A079f66F3EF9cBa6D4954a4b](https://snowscan.xyz/address/0xe9847Afb5564B221A079f66F3EF9cBa6D4954a4b)    |

### Oracles Configuration

Settings that dictate how the oracle computes and updates data.

|                                   |                                                                                                                                                                                                                              |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Pricing Methodology               | Volume Weighted Average Price with Interquartile Range Filter (more details [here](https://www.diadata.org/docs/nexus/reference/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter)) |
| Deviation (%) & Refresh Frequency | 0.5% & 120 Seconds                                                                                                                                                                                                           |
| Heartbeat                         | 12 Hours                                                                                                                                                                                                                     |

### Assets Data

Available assets on the oracles and the ChainlinkAggregatorV3Interface compatible contracts for each asset feed.

{% tabs %}
{% tab title="Avalanche" %}

| Price Feed   | Contract Address                                                                                                           | Type        | Deviation (%) & Refresh Frequency | Hearbeat |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------- | -------- |
| USDp/USD     | [0x2eEF8970d6dC0fa4f6F86385407439b45DF59e99](https://snowscan.xyz/address/0x2eEF8970d6dC0fa4f6F86385407439b45DF59e99#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| sUSDp/USD    | [0x45FFE3F65C58983dfC8Fb10Ce046fDa6E1EC231a](https://snowscan.xyz/address/0x45FFE3F65C58983dfC8Fb10Ce046fDa6E1EC231a#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| {% endtab %} |                                                                                                                            |             |                                   |          |

{% tab title="HyperEVM" %}

| Price Feed   | Contract Address                                                                                                              | Type        | Deviation (%) & Refresh Frequency | Hearbeat |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------- | -------- |
| USDp/USD     | [0x5975994e5009e2b7fC348dD94a36E7C86958D795](https://hyperevmscan.io/address/0x5975994e5009e2b7fC348dD94a36E7C86958D795#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| sUSDp/USD    | [0xEf06cffeCD2c76762279Fc1b8C37E67bB6d2c18c](https://hyperevmscan.io/address/0xEf06cffeCD2c76762279Fc1b8C37E67bB6d2c18c#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| {% endtab %} |                                                                                                                               |             |                                   |          |

{% tab title="Base" %}

| Price Feed   | Contract Address                                                                                                           | Type        | Deviation (%) & Refresh Frequency | Hearbeat |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------- | -------- |
| USDp/USD     | [0xE2b51a6c951B81499Ca4602d548ff2f701bfdc24](https://basescan.org/address/0xE2b51a6c951B81499Ca4602d548ff2f701bfdc24#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| sUSDp/USD    | [0xB45f03799F26168699c1909f58bE380eAC735B4b](https://basescan.org/address/0xB45f03799F26168699c1909f58bE380eAC735B4b#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| {% endtab %} |                                                                                                                            |             |                                   |          |

{% tab title="Sonic (Deprecated)" %}
{% hint style="warning" %}
USDp & sUSDp price feeds on Sonic are deprecated.
{% endhint %}

| Price Feed    | Contract Address                                                                                                            | Type        | Deviation (%) & Refresh Frequency | Hearbeat |
| ------------- | --------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------- | -------- |
| USDp/USD      | [0xF43dd82a870a176e2Cd392c2d9d51e31D0d694b1](https://sonicscan.org/address/0xF43dd82a870a176e2Cd392c2d9d51e31D0d694b1#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| sUSDp/USD     | [0x026ffC812e12a30658727467246757944F76eB48](https://sonicscan.org/address/0x026ffC812e12a30658727467246757944F76eB48#code) | Fundamental | 0.5% & 120 Seconds                | 12 hours |
| {% endtab %}  |                                                                                                                             |             |                                   |          |
| {% endtabs %} |                                                                                                                             |             |                                   |          |

{% hint style="info" %}
The pricing methodology fetches the fair redemption price of the USDp. In order to maximize security, this pricing methodology is deliberately pessimistic to ensure that no manipulation is possible. This means that the price of the USDp reported by the oracle may be slightly below its actual price.
{% endhint %}

### Data Sources

{% tabs %}
{% tab title="Avalanche" %}

| Data Source  | Contract Address                                                                                                           |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- |
| USDp/USD     | [0x41d58951cbd12d4ef49b0437897677bbf5547c80](https://snowscan.xyz/address/0x41d58951cbd12d4ef49b0437897677bbf5547c80#code) |
| sUSDp/USD    | [0x9d92c21205383651610f90722131655a5b8ed3e0](https://snowscan.xyz/address/0x9d92c21205383651610f90722131655a5b8ed3e0#code) |
| {% endtab %} |                                                                                                                            |

{% tab title="HyperEVM" %}

| Price Feed   | Contract Address                                                                                                              |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| USDp/USD     | [0x1250304f66404cd153fa39388ddcdaec7e0f1707](https://hyperevmscan.io/address/0x1250304f66404cd153fa39388ddcdaec7e0f1707#code) |
| sUSDp/USD    | [0x9b3a8f7cec208e247d97dee13313690977e24459](https://hyperevmscan.io/address/0x9b3a8f7cec208e247d97dee13313690977e24459#code) |
| {% endtab %} |                                                                                                                               |

{% tab title="Base" %}

| Price Feed   | Contract Address                                                                                                           |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- |
| USDp/USD     | [0xc3bef21ea7deb5c34cf33e918c8e28972c8048ed](https://basescan.org/address/0xc3bef21ea7deb5c34cf33e918c8e28972c8048ed#code) |
| sUSDp/USD    | [0x472ed57b376fe400259fb28e5c46eb53f0e3e7e7](https://basescan.org/address/0x472ed57b376fe400259fb28e5c46eb53f0e3e7e7#code) |
| {% endtab %} |                                                                                                                            |

{% tab title="Sonic" %}

| Price Feed    | Contract Address                                                                                                            |
| ------------- | --------------------------------------------------------------------------------------------------------------------------- |
| USDp/USD      | [0xbefbae2330186f031b469e26283acc66bb5f8826](https://sonicscan.org/address/0xbefbae2330186f031b469e26283acc66bb5f8826#code) |
| sUSDp/USD     | [0xe8a3da6f5ed1cf04c58ac7f6a7383641e877517b](https://sonicscan.org/address/0xe8a3da6f5ed1cf04c58ac7f6a7383641e877517b#code) |
| {% endtab %}  |                                                                                                                             |
| {% endtabs %} |                                                                                                                             |

## How the Oracle Works

The fair value oracle aggregates the fair USDp price from where the Parallelizer & Savings Modules are deployed and derives a chain-specific USDp/USD & sUSDp/USD value from it. The detailed data flow looks like this:

1. Each of the chains from which the aggregated USDp feed is comprised is queried for its current fair redemption value based on its backing assets and on the amount of USDp minted on that chain.
2. After collecting the chain-specific USDp redemption values and volumes, the average USDp redemption value (or price) is calculated by weighting the individual data points by the respective on-chain volume.
3. This aggregated USDp/USD value is then written into each deployed oracle and can be retrieved by calling the `getValue()` function with USDp/USD as parameter.
4. The aggregated USDp/USD value can also be retrieved using the chainlink-compatible adapter smart contract for USDp/USD.
5. The chain-local sUSDp/USD price (i.e. the redemption value of sUSDp on the chain where the query happens, based on the aggregated USDp price) can be queried by calling the `getSusdpPrice()` function.

{% hint style="info" %}
The sUSDp/USD value can also be retrieved using the chainlink-compatible adapter [smart contract](#assets-data) for sUSDp/USD.
{% endhint %}

## How to Access Data

### DIAParallelOracle (Solidity)

The following is the list of available methods on the `DIAParallelOracle` contract.

#### getValue()

```
function getValue(string memory key) public view returns (uint128 price, uint128 timestamp)
```

* For USDp/USD: Returns the global USDp price (aggregated fair value from all chains) in USD.
* For sUSDp/USD: Returns the chain-specific sUSDp price in USD using the specific chain's vault exchange rate based on the global USDp price (equivalent to calling `getSusdpPrice()`).

Parameters:

* `key (string)`: the exchange pair identifier (\`USDp/USD\` or \`sUSDp/USD\`)

Return Values:

* `price (uint128)`: The asset price in 18 decimals.
* `timestamp (uint128)`: Unix timestamp of the latest price update.

#### getSusdpPrice()

```
function getSusdpPrice() public view returns (uint256)
```

Calculates the chain-specific sUSDp price using the global USDp price across all chains and the specific chain's vault exchange rate. This is automatically called when using `getValue("sUSDp/USD")`.

`Return Value (uint256)`: The chain-specific sUSDp price in 18 decimals.

### Adapter Contracts

To consume price data from oracles, you can use the adapter [smart contracts.](https://docs.parallel.best/developers-hub/parallel-v3/onchain-tools/oracles/dia) This allows to access the same methods on the AggregatorV3Interface such as `getRoundData` & `latestRoundData`.
