Data computation
Last updated
Last updated
DIA Lumina employs a flexible and trustless system for processing data into final outputs. After Feeders collect data, it is stored in Pods—smart contracts on the Lasernet rollup. Finally, the Aggregator is the smart contract that selects data from Pods using customizable rules and produces a final value.
As the backbone of the system, Lasernet is an optimistic Ethereum Layer-2 rollup. It serves as an open data repository that handles the full lifecycle of data trustlessly. The Lasernet chain is built for scalability using the OP Stack and using Celestia as the data availability layer, to handle large oracle transactions at a low cost.
The DIA Lumina oracle consists of a two major components:
A collection of key/value smart contract that collect price data from each feeder.
The DIA metacontract that collates these prices from the key/value contracts and provides an automatically refreshed reading of the latest market price.
An exemplary Lumina data flow can be seen here. Oracle feeders scrape trades from exchanges and submit these as last prices into their respective oracle contracts. From there, a threshold of 5 in 1 hour is required for the meta contract to assume consensus on the median value of this set of trades.
These are smart contracts that securely store on-chain data. Each Pod receives regular updates from its assigned Feeders, ensuring that asset prices are accurate and up-to-date. The Pods make price data openly available for all users on the network.
Each decentralized Lumina feeder writes data into its own oracle contract. This feeder contract is a vasic key/value store which stores oracle updates accessible by a key, such as BTC/USD
. The data stored for each entry is the last price of the asset and the timestamp of that price.
Each feeder has their own feeder contract, so that it is always clear who made which update.
In order to pack the data efficiently, the entries (price and timestamp) are packed into the same uint256
when an update is written to the key/value store.
It is not necessary to interface with the feeder contract directly. However, for debugging and transparency purposes it is possible to call getValue()
in a feeder contract. This will retrieve the latest price update that is stored for the requested asset.
Call getValue(pairName)
with pairName
being the full pair name such as BTC/USD.
The response of the call contains two values:
The current asset price in USD with a fix-comma notation of 8 decimals.
The UNIX timestamp of the last oracle update.
A smart contract that picks data from multiple Pods and creates a final median value. Multiple Aggregator smart contracts can be deployed, creating a flexible framework for users. Aggregators operate with customizable rulesets (custom sources, aggregation windows, and more), allowing them to cater to different use cases. Aggregators also have the option to benchmark data against external sources for additional security.
The metacontract exposed a simple Read
function called getValue()
. It has one parameter pairKey
, which consists of the symbol of the queried asset and /USD
to denominate its price in US Dollars. For instance, the latest Bitcoin price is queried by calling getValue("BTC/USD")
.
The function then returns two values:
The value of the asset in US Dollars, with 8 decimals.
The timestamp of the block with the latest calculation result.
The oracle has several safeguards against becoming stale or having not enough feeders providing updates.
The current version of the metacontract supports the median methodology. Later iterations of the metacontract will allow selecting different methodologies for each price evaluation.
Each metacontract has an admin
address that can setup the metacontract for its specific usage. The admin is able to add and remove feeders, set a threshold of required feeders, and set a timeout duration after which a feeder update is considered stale.
The metacontract needs to learn about available feeder key/value storage smart contracts. The admin can add as many feeders as they wish to the price evaluation using the addOracle()
method. The required parameter of that method is the address (on DIA chain) of the key/value smart contract belonging to that feeder. After an oracle is added, its latest prices are immediately part of the price evaluation.
If needed, oracle feeders can also be removed by the admin. The required parameter of that method is the address (on DIA chain) of the key/value smart contract belonging to that feeder. Removal is immediate, so any call made to getValue()
from the removal block onwards will not include data from the removed feeder any more.
To make price discovery more robust, a threshold needs to be set by the admin. This threshold corresponds to the number of feeders that need to have submitted a price to reach a valid consensus.
Here's the Aggregator Smart Contract on DIA Lasernet Testnet:
0x7Dd70B4B76130Bc29E33635d2d1F88e088dF84A6
To find queryable assets visit the following page: