# Proof of Reserve Oracle

[DIA oracles](https://www.diadata.org/) helped to deliver Lightning Network node balance data to Ethereum, enabling `strBTC` holders to verify their Bitcoin backing on-chain.

### 1. Oracle Details

#### 1.1. Reserve Feeds

The reserve feeds are consumable via the adapter contract tracking on-chain & off-chain reserves.

| Reserve Query Key | Reserve Oracle Address (Combined Reserves)                                                                            | Adapter Address (Chainlink-Compatible)                                                                                |
| ----------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| STROOM-Reserves   | [0x12DB8fcA6AAA29E922bFAD8a7771aE11F17a1811](https://etherscan.io/address/0x12DB8fcA6AAA29E922bFAD8a7771aE11F17a1811) | [0x1d18b5147B11908B24A247517F606c0705CF8d40](https://etherscan.io/address/0x1d18b5147b11908b24a247517f606c0705cf8d40) |

#### 1.2. Contracts

The DIAOracleV2 contract calculates the off-chain reserves.

<table><thead><tr><th width="233.8570556640625">Blockchain</th><th>Address</th></tr></thead><tbody><tr><td><strong>Ethereum Mainnet</strong></td><td><a href="https://etherscan.io/address/0xFe0593fA61c7Cf3D2CD17b8B53Ef844A33b0463d">0xFe0593fA61c7Cf3D2CD17b8B53Ef844A33b0463d</a></td></tr></tbody></table>

#### 1.3. Oracle Configuration

Settings that dictate how the oracle computes and updates data.

<table><thead><tr><th width="289.28564453125">Setting</th><th>Rate</th></tr></thead><tbody><tr><td><strong>Deviation (%) &#x26; Refresh Frequency</strong></td><td>0.5% and 120 seconds</td></tr><tr><td><strong>Heartbeat</strong></td><td>24h</td></tr></tbody></table>

#### 1.4. Oracle Configuration

**1.4.1. On-chain Sources**

<table><thead><tr><th width="152.42840576171875">Contract</th><th width="272">Asset Address</th><th>Owner Address</th></tr></thead><tbody><tr><td>wBTC &#x3C;-> strBTC converter</td><td><a href="https://etherscan.io/token/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599">0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599</a></td><td><a href="https://etherscan.io/address/0x56192f14c1d84e41db3d5d4c5d407efdb5cb1352">0x56192F14C1d84e41Db3d5d4C5d407EFDB5CB1352</a></td></tr><tr><td>cbBTC &#x3C;-> strBTC converter</td><td><a href="https://etherscan.io/token/0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf">0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf</a></td><td><a href="https://etherscan.io/address/0xe7b4c44adb17147ad877eb8607eeb1e95adf2cd0">0xe7b4c44adB17147Ad877EB8607EEB1e95AdF2cD0</a> </td></tr></tbody></table>

**1.4.2. Off-chain Sources**

<table><thead><tr><th width="197.28564453125">Lightning Service</th><th>Query Endpoints</th><th data-hidden></th></tr></thead><tbody><tr><td><a href="https://api.lightning.community/api/lnd/lightning/wallet-balance/index.html">WalletBalance</a></td><td>Return <code>total_balance</code></td><td></td></tr><tr><td><a href="https://api.lightning.community/api/lnd/lightning/channel-balance/index.html">ChannelBalance</a></td><td>Return the sum of <code>local_balance</code>, <code>unsettled_local_balance</code>,&#x26; <code>pending_open_local_balance</code></td><td></td></tr><tr><td><a href="https://api.lightning.community/api/lnd/lightning/pending-channels/index.html">PendingChannels</a></td><td>Return <code>total_limbo_balance</code></td><td></td></tr></tbody></table>

### 2. How the Oracle Works

The DIA adapter (DIAStroomAdapter) calculates the total BTC reserves by combining two data sources:&#x20;

1. On-chain reserves: the sum of WBTC and cbBTC balances from Stroom converter contract addresses on Ethereum.
2. Off-chain reserves: the sum of WalletBalance API (total\_balance) and ChannelBalance API (local\_balance + unsettled\_local\_balance + pending\_open\_local\_balance) with 8-decimal satoshi precision. The DIA oracle (DIAOracleV2) pushes the aggregated off-chain reserves value on-chain when they deviate by 0.5% or every 24 hours, as configured.

### 3. How to Access Data

#### 3.1. DIAStroomAdapter (Solidity)

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

**3.1.1. getOnchainReserve()**

| function getOnchainReserve() public view returns (uint256) |
| ---------------------------------------------------------- |

Calculates the total on-chain BTC reserves by aggregating WBTC and cbBTC balances from Stroom converter contract addresses on Ethereum.

Return Value (uint256): The total on-chain BTC reserves in 8 decimals.

**3.1.2. getOffchainReserve()**

| function getOffchainReserve() public view returns (uint256) |
| ----------------------------------------------------------- |

Makes a \`getValue()\` call to the DIA oracle, which in turn aggregates off-chain BTC reserves by querying Lightning API services. The DIA oracle's methodology combines \`total\_balance\` from WalletBalance API with the sum of \`local\_balance\`, \`unsettled\_local\_balance\`, and \`pending\_open\_local\_balance\` from ChannelBalance API.

Return Value (uint256): The total off-chain BTC reserves in 8 decimals.

**3.1.3. getCombinedReserveValue()**

| function getCombinedReserveValue() public view returns (uint256) |
| ---------------------------------------------------------------- |

Returns the sum of both on-chain and off-chain BTC reserves.

Return Value (uint256): The total combined BTC reserves in 8 decimals.

#### 3.2. Adapter contracts

To consume price data from the oracle, you can use the adapter smart contract for the [reserve feed](#id-1.1.-reserve-feeds). This will allow you to access the same methods on the \`AggregatorV3Interface\` such as \`latestAnswer\` & \`latestRoundData\`. You can learn more [here](https://www.diadata.org/docs/guides/how-to-guides/migrate-to-dia).

### 4. Glossary

<table><thead><tr><th width="184.71417236328125">Term</th><th>Definition</th></tr></thead><tbody><tr><td>Deviation</td><td>The percentage threshold that triggers a price update when exceeded</td></tr><tr><td>Refresh frequency</td><td>A time interval for checking and updating prices if certain conditions are met</td></tr><tr><td>Heartbeat</td><td>A forced price update at a fixed interval</td></tr></tbody></table>


---

# 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.stroom.network/stroom/smart-contracts/proof-of-reserve-oracle.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.
