dAPP
Published on 
9 July, 2021

MOC Decentralized Oracles

Money on Chain is a system that provides a stablecoin platform collateralized with Bitcoin in the RSK blockchain therefore it needs a way to determine the DoC token value in rBTC. Consequently, it needs the price data for BTC/USD pair, among other pairs, inside the blockchain. Since this data cannot be directly accessed from the blockchain, external agents, called Oracles, must provide the necessary prices.

An oracle is a trusted source of data that acts as a bridge between a blockchain and real-world, off-chain, information that can be used by smart contracts.

Oracle services query price pair data from several crypto exchanges and send them into a smart contract on the blockchain being available for other smart contracts to use (call) them.

The Money on Chain Oracle System is a key aspect in the path to decentralization, which creates the possibility for stakeholders to run an oracle and participate in a consensus protocol for price feed publication.

The architecture of Money on Chain’s Oracle System contemplates the following aspects:

  1. Decentralized: Oracles must compete with each other and check other’s price publications forcing them to provide accurate data. This establishes a network of Oracles providing high-quality price feeds that have enough redundancy and provides a fallback mechanism to guarantee that price feeds are always available. It also protects the system against the malicious behavior of a minority group. 
  2. Off-chain Consensus: The consensus amongst the Oracles is achieved off-chain. This greatly reduces costs and allows a high frequency of publishing price feeds.
  3. Economic Incentives: Running and publishing price feeds brings a profit to the Oracle owner since they have to stake a minimum amount of MoC tokens to be able to be selected. Oracles earn MoC tokens for their stake and for being an oracle.

Oracles

Oracles report the chosen price pairs, e.g. rBTC/USD, taken from various crypto exchanges. The same infrastructure can be easily extended to more than one price pair. 

Anyone can become an Oracle, to do so, a stakeholder needs to have a minimum amount of 250,000 MoC tokens staked, being able to compete with other oracles to be selected as a price publisher.  But only N (currently 10) number of oracles are selected to be part of the consensus depending on the amount of their stake. This feature is very important for the community since it helps the system to have honest oracles, because in the case one of them attacking the system will also be destroying the value of its own stake.

Oracles get revenue from the MoC Staking Rewards program for their staked MoC tokens, and in addition to this, they also get rewards for publishing prices. This compensates for the expenses of running an Oracle and pays an additional yield.

Rounds

The Oracle system works in 30 days periods, also called rounds, in which the accounting for the Oracle rewards is determined. 

When a new round starts, the protocol distributes the accumulated rewards in the previous round and sets the global reward counter to zero, from that point onwards the produced rewards are going to be used for the next round. Each round accounts for the locked stake and the price publications for the current month, i.e. in each round, the following data is saved: the list of N (10) Oracles that have more stake are selected to participate, they can publish prices and win rewards for that. When the round is closed the rewards are transferred directly to the account of each Oracle in proportion to the number of publications done during the round.

Registration

Oracles must register as such by publishing their public address and server URL to the RSK network. Oracles must also subscribe for each coin pair they are interested in, to be considered in the selection process for the next publishing round of these prices.

Oracles who want to withdraw their locked stake must first be inactive for one round by unsubscribing from all coin pairs. If there is a withdrawal without the tidy unsubscription the Oracle is punished by losing the points won in the current round so at the end of the round it won't receive rewards. Once successfully unsubscribed, the same withdrawal rules as for stakers apply to the Oracle.  

Consensus for Published Price Feed 

Oracles have to find consensus about the correct price feeds, e.g. the rBTC/USD price pair. This is achieved by an off-chain consensus in which the N (currently 10) Oracles participate which locked the most stake. Oracle’s stake counts for all price pairs, but Oracles must subscribe for each price pair in order to participate. Then, during the round, proposer election and consensus works as follows: 

  1. Election: Price pair proposals are published by one oracle at a time, each time an Oracle is selected among the N oracles with the largest stake to be the publisher. The election of the oracle is done using as a “random seed” the block hash of the block containing the last price published. The probability of being selected as the publisher is weighted by the amount of stake the Oracle has locked. Once a publication is done, there is a new publication in a different block, the seed changes, and a new publisher is selected.
  2. Consensus: The price pair not only has to be published by the chosen oracle but the published data must be co-signed by N/2 (currently 5) other participating Oracles of this round. This “consensus” happens off-chain by sending the price data to other Oracles for signing and then publishing it to the smart contract on the blockchain. The contract verifies that it has the necessary quorum from the remaining Oracles and is signed by the Oracle whose turn it is to publish.

For each publication, only one Oracle can succeed (only one transaction is accepted by the blockchain). After a successful publication, the block hash for the last publication changes, and a new consensus is started.

The Oracle system does have further important properties reflected: 

  • Frequency: Selected Oracles can send the price at any time. The reference implementation does it only when the price change is bigger than a certain variation (delta) which can be configured in the Oracle server. 
  • Fallback Mechanism: If an oracle, for any reason (technical problems, power outages, etc.), is offline and does not appear, there is a fallback mechanism to replace it. Fallback Oracles are elected the same way as the publishing Oracle. The election process sorts the list of selected oracles: [selected, fallback1, fallback2, etc]. Fallback Oracles are authorized to send a number of blocks M after the price change is bigger than delta. The system can be configured with the number of blocks after the price change and the number of Oracles authorized to publish their price pairs. For example, M blocks after the price change, two fallback Oracles are authorized to publish, M+2 blocks after the price change, 4 Oracles are authorized, etc. This way the system can react to failures even faster. 

Incentives

Same way as with stakers, a percentage of the collected MoC tokens from the MOC protocol through fees and from selling data provided by the Oracles to other third parties is distributed among the Oracles. The income stream is accumulated during one month, i.e, one round, and distributed to each coin pair price module. Oracles also receive from the MoC Staking Rewards program for being a staker.

Reward Distribution: Every publication of a price pair yields one point for the publishing Oracle. The frequency to be allowed to publish is proportional to the Oracle stake, i.e. the larger the stake the more often an Oracle is elected to publish. At the end of the round, Oracles receive a payment proportional to their collected points. The profit gets transferred directly to the account of the Oracle owner once a new round starts. Per price pair the Oracle reward is calculated using the following formula: 

Rewards (Points Won Total Points).

If an Oracle withdraws part of its stake in the middle of the round and the new amount is less than the minimum needed or if there is an Oracle with more stake outside the round waiting to participate, then the Oracle loses its place, losing at the same time the accumulated points and the corresponding rewards. On the other hand, if an Oracle that is not selected in the current round adds stake, surpassing an Oracle that is already selected, the Oracle must wait for the next round to participate anyway.

Oracles are pivotal to the Money on Chain protocol, not only they provide accurate pricing information, but they do so in a decentralized manner which allows the platform to be counterparty risk-free.

Do you want to run an oracle? https://docs.moneyonchain.com/omoc/

Copyright © 2018-2024 Money On Chain.
Disclaimer, Privacy Policy and Terms & Conditions
crossmenu