NEST is a stochastic computer that enables the generation and programming of stochastic assets. It provides the blockchain world with a whole new range of development tools and assets. In this article, we will discuss how the NEST offers the world a new creative paradigm through its core component - the NEST oracle.
What is an oracle?
Oracle, from the definition by Oxford Learner's Dictionaries, is a word originating from ancient Greece that means advice or information from god. This explanation is akin to a blockchain's oracle – an entity that provides off-chain information (information about the world outside the blockchain). In general, oracle is blockchain middleware, a bridge between the two worlds.
Why do we need oracles?
Blockchain was designed with decentralization as one of its core features, i.e., transactions will produce the same result every time they are executed regardless of the address that executes it. Additionally, after a transaction is verified, the state of the blockchain is updated irreversibly. That eliminates the need for a central authority and enhances its integrity and liveliness since corruption or tampering will be either corrected or rejected by the entire network.
However, this mechanism hinders the system's ability to exploit off-chain resources such as APIs, functions, or data required to build complex decentralized systems.
For easier understanding, consider the example below:
Bob and Alice want to transfer assets on the Ethereum blockchain. Normally, when Bob sends Alice 5 ETH, we can easily subtract 5 ETH from Bob's balance and add 5 ETH to Alice's. Then every node on the network will reproduce this information and end up in the same state, which allows us to get the same result about both Bob and Alice's balance every time.
But if Bob wants to send an amount of ETH based on the price of USD? That means the amount of ETH sent is not a constant but a random number based on ETH/USD covert ratio. One solution for that could be an API to get the value of ETH that equals the USD value Bob wants to send, which means all nodes on the Ethereum network will have to call this API. Unfortunately, that led to a problem when the value returned from the API, a non-deterministic entity, changes and makes the transaction between Bob and Alice impossible to be verified.
Additionally, the state of the blockchain is updated irreversibly when a transaction is verified. That makes the allowing of inputs from outside the blockchain a risk for the network as the miners can't confirm all these external inputs and will allow the execution of anything that matches the predefined criteria of the smart contract.
In other words, allowing external inputs creates an element of trust in the blockchain. Consider an example of a crypto sports betting site that accepts Ethereum: Someone deposits 1 ETH in a smart contract representing the betting pool of a soccer match between teams A and B. The player gets 2 ETH if team A wins and 1 ETH if two teams draw, or/else he/she will lose the 1 ETH deposited. That means there must be a way to ensure that only the correct result of the match is reported to the smart contract, especially since the outcome of the bet is irreversible.
The above two examples show that the demand for off-chain information is immense: Defi applications need information about tokens' price, decentralized betting sites need information about matches' results, decentralized trustless insurance needs information about accidents or natural disasters, etc. As a result, oracles are introduced to meet these massive demands.
The existing problems
However, an oracle still has problems, as the blockchain cannot access real-world data but relies heavily on what the oracle offers instead. As a result, if the oracle is centralized (the data comes from only one source) and imports corrupted data to the network, it can cause irreparable damage. Moreover, the oracle itself can be attacked by hackers. To summarize, an oracle must meet the following key requirements:
- Accuracy: simply means the data offered on-chain must reflect that of the real world. That can be considered a fundamental requirement of not only an oracle but also any system/entity providing data to the blockchain since we invented such complex systems to offer the blockchain flawless data.
- Sensitivity: is an addition to accuracy, as the data in the real world can change with an interval of just a few seconds. For example, imagine that we use an oracle to provide information about the price ratio of 2 tokens. At 11:00 am, the ratio is 1:1, but at 11:01, this figure change to 1:1.1. As a result, an oracle needs to be "sensitive" enough and update the price on time because if at 11:01 the ratio reported is still 1:1 then the accuracy requirement is no longer met. Basically, at its core, accuracy comes with sensitivity.
- Attack resistance: is the basic requirement for most, if not all, digital systems, especially blockchain networks, where any changes made are irreversible. Furthermore, Defi platforms are not just blockchain, but they are also about people's assets. Therefore, if an oracle is vulnerable to attacks, the consequence might be disastrous.
- Direct verification: is the first unique requirement of a decentralized oracle compared to traditional data porters. The data offered to the network might be flawed, so there must be entities in charge to verify and choose valid data. What makes the difference is while a centralized data porter has to trust a single or a group of designated verifiers, which can easily get corrupted, the decentralized oracle with direct verification allows anyone with access to the system the right to verify data. That makes decentralized oracle a "trustless network."
- Distributed quotation system: means anyone can freely join or leave the system at any time. That creates great complexity as there are no constraints in such systems.
Solution for decentralization blockchain
Obviously, a centralized oracle makes the decentralization idea of blockchain purposeless since there is no point in maintaining a decentralized system with centralized input sources. Therefore, the oracles themselves must also be decentralized. A decentralized oracle network, as the name indicates, is a collection of multiple independent oracles that provide data to a blockchain. Each component in this group will get data from different off-chain sources and bring it on-chain. After that, the aggregation process of these data will result in a single trustworthy for that specific data point.
In the next section, we will dig deeper into how a decentralized oracle can solve problems steamed from its centralized counterpart. For easy understanding, we take NEST Oracles, which is a truly decentralized oracle in today's market for example.
NEST Protocol
The diagram below briefly explains how the protocol works, which will be examined in detail later.
Participants
There are five main participants in the NEST oracle.
- Price maker: includes participants who submit price quotations to the protocol.
- Miner: Provide quotations, pay a commission fee (quotation fee) in ETH and receive NEST tokens (the protocol's ERC-20 token). Anyone can become a miner. In the example below, we denote them as O.
- Verifier: If the price quoted by the miner is different from the market price, the verifier can trade the asset quoted with the price the miner offered and earn a benefit. After the trade, verifiers also need to provide a new quotation but don't have to pay the commission fee because the miner will pay that extra quotation fee for the new quotation. Anyone can become a verifier. In the example below, we will denote them as A.
- Price caller: consists of contracts and accounts that pay the fee to get the protocol quotation, which literally means pay to use the NEST protocol. In other words, most price callers are other Defi protocols or institutions. In the example below, we will denote them as C.
- Channel opener: provides the information required for a quote channel and owns the maintenance right for the opened channel.
Quote channel
The Quote channel is the foundation of the NEST oracle and contains all information that constitutes the price mechanism. A channel opener, as mentioned above, can easily open a channel by setting the components required for a channel.
You can check for more information about quote channels by accessing the NEST protocol's official page.
Quotation for mining
To participate in the quotation, the maker needs to provide quotation fees, collateral assets, and a sufficient quotation asset with the same value as the valuation asset.
Consider an example where a miner O quotes a price of 1 ETH equals 100 USDT (1 ETH = 100 USDT). That miner will have to input in the quoted contract the collateral y (currently, all quotations use NEST as collateral), ETH, and USDT. Additionally, miner O receives some NEST tokens as he pays the commission fee. Moreover, he or she will also set a particular variable called "quotation scale," which will be denoted as "x." We will explain the quotation scale in the following few sections. All these processes are completely open and transparent. After miner O submits the collateral, the price verification period begins.
Price Verification
The price verification period is where makers try to validate the quotation (price) provided by the miner in a closed loop. After this period, the NEST protocol will be offered at an accurate price.
Continuing with the above example, assume that the quotation 1 ETH = 100 USDT differs from the "real" price, and verifier A sees the arbitrage opportunity. Now, the quotation scale is x, meaning x ETH has a corresponding value quantity of 100 * x USDT. Therefore, if the verifier uses the price p, he can trade p * x * ETH to get 100 * p * x USDT. Note that the verifier can trade either ETH or USDT, called the "Price verification period."
After a period, denoted as T0 (currently 25 blocks, which is 5 minutes), if there is no trade made with the quotation price the miner offered, then the quotation will be called "effective quotation." An effective quotation contains two variables: the price p and the quotation scale x (p, x). In other cases, when there is a verifier chooses to trade with the price p, that verifier will have to quote a new price p1 and new quotation scale x1, which means the verifier must transfer x1 ETH, x1 * p1 USDT, and y1 NEST (as collateral) into the transaction. Then the interval goes on, creating a continuous price chain.
$$p_0 -> p_1 -> p_2 . . .$$
$$x_0 -> x_1 -> x_2 . . .$$
As mentioned in the "effective quotation" above, these quotations correspond to a block, with each block recording a price. Assume that the "effective quotation" of a block is: $$(p_1, x_1), (p_2, x_2), (p_3, x_3),...$$The block price is calculated by dividing the sum of all products between prices and its scales by the sum of all scales:
$$\frac{\displaystyle\sum_{i=1}^{M} P_i * x_i}{\displaystyle\sum_{i=1}^{M} x_i}$$
Notes: M represents the number of effective quotations in the block.
It is essential to note that the longer the price verification period takes, the higher the quotation fee will be. However, since the verifiers do not have to pay the quotation fee, the miners might want to minimize the quotation fees by reducing the time the price verification period takes. That means if miners want to minimize their costs, they must report the price that is least likely to be traded during the price verification period. Therefore, the quotation offered by the miner has a certain ability to predict future prices.
After the price verification period, the maker's assets will be made available to withdraw at any time.
Price taking effect
With the price calculated in the block, it is now available for price callers to retrieve and use that price in their products.
Attack-resistant
Attackers can attack the protocol by making it not apply the right price by tampering with the normal price, p, and changing it to p1. Or they can paralyze the entire system by continuously trading every quotation to prevent the price from being updated (if all quotations are traded, there will be no effective quotation. That means the price cannot be updated). However, by increasing the cost of such actions, the NEST protocol can effectively resist attempts to corrupt the system.
First, the price chain itself is attack resistant. When an attacker wants to tamper with the normal price, he/she will have to provide the "correct" price so that the price takes effect or pay corresponding assets to continue the price chain.
Second, to amplify the attackers, the developers of NEST arrange the quotation scale as follows: the scale and collateral of the first verifier are x1 and y1, then the scale of the second verifier is $$x_2 = B * x_1$$ and $$y_2 = B * y_1$$ with B > 1. Notice that with quotation scale, the above rule only applies four times since the first verification, but with collateral, there is no limit to it.
For example, with B = 2, we have the following price chain:
$$x_0 -> B x_0 -> B^2 x_0 -> B^3 x_0 -> B_4 x_0 -> B^4 x_0 -> . . . -> B^4 x_0 -> . . .$$
$$y_0 -> B y_0 -> B^2 y_0 -> B^3 y_0 -> B^4 y_0 -> B^5 y_0 -> . . . -> B^n x_0 -> . . .$$
Assume that the verification period is 5 minutes and there is a miner O to make a quotation. To prevent this quotation from taking effect in one hour, the attacker needs at least 6144 * y0 collateral asset and 32 * x0 for each quoted asset. With the quotation channel zero set y0 = 100,000 NEST, this mechanic makes attacking methods nearly impossible.
Why NEST is a revolution
NEST is far more than a data porter
Some can argue that an oracle is simply a data porter, a "pipeline" that allows data from different sources to be verified before publishing on the blockchain. However, NEST's mechanics do not choose any "reliable sources", but encourages different sources to provide it with accurate data instead. Clearly, we can see how a miner is incentivized to provide the real price and rewarded with NEST tokens for the useful price they offer.
One other misconception with decentralized oracle is that the verifying process can be prone to errors and therefore the corrupted data is published on the network. Nevertheless, that is not the case with NEST, as its verifiers are encouraged to prevent wrong information from reaching the blockchain. Indeed, if a quotation got traded, it will not be published, and trades on NEST oracle only happen when the price quoted is not the actual world price.
These two key points makes NEST stand out. It is not a system of import, correct, aggregate, and publish but a system that generates the accurate data at its core.
NEST is a truly decentralized oracle
Decentralization has always been blockchain's core value because of its security benefits. With NEST, it is also designed to be decentralized and, therefore can be safely and efficiently integrated with any blockchain network. The decentralization of NEST is built by its characteristics, as anyone can assign any role, at any time and of course, can opt-out freely.
NEST ensures the integrity of data and is tamper-proof
The data in NEST is verified based on its integrity. As we have discussed, if the price is not the "real" price, it will be traded by a verifier and will not be published on the blockchain. Furthermore, the verification period only ends when there are no more arbitrage opportunities. That helps the data provided by NEST is guaranteed to be the actual data.
The data provider (miner) is discouraged from providing flawed data, as the full quotation fee (commission fee) is paid by them, and this fee increases each time the verifier trades with the quoted price. That ensures the input data of NEST is as close to the off-chain data as possible. Also, since the incentivized miners report the information about the outer world through their quotations, this perfectly synchronizes the off-chain data on-chain and greatly increases the accuracy and sensitivity of the data.
Finally, NEST is invulnerable to attacks. With the collateral increase after any invalid verification (trade), the price of providing flawed data could be gigantic. That discourages attackers from tampering with the system.
Conclusions
With the requirements for off-chain data increasing for blockchain networks, NEST compensates for the demand and does it in a very creative and "decentralized" way. With that being said, NEST has many applications and is already integrated with numerous Defi projects. It definitely has the potential to become the leading oracle in the market.
References
[1] NEST Decentralized Probabilistic Virtual Machine Mode , nestprotocol.org, accessed 31th August, 2022.
[2] Decentralized Oracles: a comprehensive overview, medium.com, accessed 31th August, 2022.
[3] What Is a Blockchain Oracle?, medium.com, accessed 31th August, 2022.
[4] Comprehensive comparison of Chainlink, NEST, MakerDao oracles, blocking.net, accessed 31th August, 2022