Oracles on Tezos

What Can We Learn From Oracles on Ethereum?

What kind of oracle solution would support the Tezos ecosystem in the best way? Currently there are multiple options available on Ethereum. On Tezos the development is still limited, but I believe having more oracle solutions on Tezos could stimulate DeFi development.

So what is available on Ethereum right now?

Maker

MakerDAO uses a custom oracle managed by a group of 14 pseudonymous individuals and public organizations to determine asset prices and exchange rates for supported assets. The group of 14 participating feeds are determined by a DAO governance vote, and is subject to change.

The oracle itself consists of two modules, a broadcaster and relayer. Each feed runs a broadcaster which pulls asset prices, signs them with their private key, and broadcasts them through a secure network. A relayer monitors the broadcaster messages, ensures they are within a predetermined spread (1%), aggregates the data, and submits it to Ethereum as a single transaction. Before the Maker system updates with the new price, however, a time period enforced by the Oracle Security Module (OSM) must be waited. This ensures that new price values propagated by the system are not taken up until a specified time in the future.

Maker does not have an incentive structure for relayers or feeds, but has proposed one such model which would compensate feeds, relayers, and other participants for their contributions to the system. The current design also maintains a whitelist of specific addresses who can access the oracleā€™s data.

Source: http://oracles.club/maker.html

Chainlink

ChainLinkā€™s reference price feeds rely on a set of trusted parties to provide asset prices to the Ethereum blockchain. ChainLink also offers a service that allows users to request alternate off-chain price data from trusted oracle providers or, alternatively, set up a network of oracles themselves. ChainLink provides free access to reference price feeds for the ETH/USD and BTC/USD pairs (as well as many others). These feeds rely on a set of 21 trusted parties to submit reference price data. The ETH/USD pair updates every 0.5% deviation in price and has a heartbeat of 2 hours. The BTC/USD pair updates every 1% deviation in price and also has a heartbeat of 2 hours. Unlike MakerDAO, ChainLink does not have a decentralized governance process to determine participating parties in its reference price feeds. ChainLink itself is responsible for adding/removing parties from the system, centralizing control of the reference oracles.

ChainLink allows application developers to run their own ChainLink node or request other off-chain data, but requires payment in the LINK token. LINK is an ERC-667 token that implements a custom function that allows for the transfer of data along with token transfers. This mechanism is used to query and transfer resulting data from ChainLink nodes to on-chain smart contracts. If an application developer wishes to query non-reference data using Chainlink, they can either run their own ChainLink node, or query one of ChainLinkā€™s trusted nodes. Each node that is queried charges the requester a predetermined amount of LINK. Requesters can call multiple nodes to achieve the desired degree of decentralization, but are charged for each query they make.

ChainLink gives developers the option to run their own ChainLink node that responds to requests, but requires these developers to buy and send the LINK token to themselves for each request they make. ChainLink will also be establishing a whitelist for all on-chain reference price data (although it is currently free). The ChainLink organization will control all changes (additions/deletions) to this list.

Source: http://oracles.club/chainlink.html

Compound

The decentralized lending platform Compound uses a custom application-specific price oracle.

Compoundā€™s oracle relies on a single, centralized poster (price gathering script) to pull the price of a basket of assets relative to Ether from many different exchange sources. This trusted party then posts price updates to the blockchain each time it detects a 1% deviation in price. The newly reported price must be within a 10% bound of an anchor price that is updated every hour. Large price movements (>10%) must be set manually using a corresponding, specific hardware key. This key is currently controlled by the Compound team.

Compound has also developed a second oracle design they call the Compound Open Oracle System. Using the Open Oracle system, anyone wishing to report a price can do so. This report is then propagated via a p2p network to all other nodes in the system. Anyone with gas and a connection to the Ethereum network can then post the signed price data on-chain. A single on-chain contract, known as the Data Contract, is responsible for holding and validating all price data. This contract sorts the reported information by price reporter. Any on-chain application can request to view price data by selecting a subset of the reported price feeds. While Compound expects to productionize this oracle in the near future (still completing audits), it has yet to be launched on the Ethereum mainnet.

Source: http://oracles.club/compound.html

Uniswap

Uniswap is a constant-product automated market maker (or constant-product AMM), that allows users to exchange asset pairs on the Ethereum blockchain as long as a predetermined product of the reserves remains constant. Uniswap exists entirely on the Ethereum blockchain, and is completely decentralized, with no single party having control of the asset pool or prices. Uniswapā€™s reserve balances are public and viewable by any party at any time, thus Uniswap can be used as a price oracle to determine the marginal price of an asset.

Uniswap relies on arbitrageurs to ensure its quoted asset prices are close to the reference market price. If the price quoted by Uniswap differs from the true market price of the traded pair, arbitrageurs can always make a profit from executing a trade with this oracle. Thus, it is always likely to trade close to a reference market price.

Using Uniswap as an oracle does have downsides, however, as low liquidity asset pools are vulnerable to relatively inexpensive manipulation as was demonstrated in the bZx attack. Thus, Uniswap should only be used as an oracle if the service using it does not depend on relatively small changes in market price, or over a very short period of time.

Uniswap v2 will incorporate price feeds focused on solving both of the above problems. Each traded pair measures the current Uniswap market price at the beginning of each block. This price iis set by the last transaction in a previous block, and is thus expensive to manipulate. Uniswap V2 adds this end-of-block price to a cumulative-price variable in the contract that is weighted by the time this price has existed. This variable represents a sum of the Uniswap price for every second in the entire history of the contract. External contracts seeking a manipulation resistant price from Uniswap can read this variable and calculate their required price.

Source: http://oracles.club/uniswap.html

Dfusion

Dfusion is a decentralized exchange that uses batch auctions and a multi-dimensional order book to set prices for asset pairs. Unlike Constant-Function Market Makers or traditional exchanges that maintain separate liquidity pools/order books for individual asset pairs, Dfusion aggregates all orders into a single multi-dimensional order book that consists of multiple different token pairs. It then uses a time-based batch auction to set cleaning prices for each token exchanged in a batch. Batch auction settlement prices can be used as an oracle service by projects seeking access to an on-chain oracle service.

Dfusionā€™s settlement times occur approximately every 5 minutes. All orders submitted before a batch is settled can be included in the final settlement. The auction accepts settlement proposals from anyone. Solutions are simply checked for validity and if they are ā€˜betterā€™ than existing solutions. If a solutions is judged to be ā€˜betterā€™ than another, it replaces the previous solution. All trades are finalized after 5 minutes.

Source: http://oracles.club/dfusion.html

Coinbase

The Coinbase Oracle is a verifiable price feed for the BTC/USD and ETH/USD markets that anyone can publish on-chain. The price feed is accessible through a centralized API, and is updated every minute with data sourced from Coinbase Pro.

All posted prices are signed using the Oracleā€™s public key. This allows anyone to post price data on-chain, without trusting the poster of the data. The Oracle implements a filtering mechanism that automatically rejects price points that significantly deviate from the reported assetā€™s expected volatility. The result is a trusted, but reliable feed that any DeFi protocol can integrate easily.

Source: http://oracles.club/coinbase.html

What do you want to see on Tezos?

While the Tezos defi ecosystem evolves, I think current and upcoming projects could benefit from an oracle solution that has a novel architecture and works in a semi-trustless manner.

A decentralized oracle network could be a goal to achieve as more DeFi projects start and volume increases in Tezos, but there are some obstacles such as incentivising node operators (without a seperate token distribution), accuracy and validation of feed, resistance from various social and technical attacks etc. At Tezsure we would love to have a trusted and verified oracle system to build on.

I would really like to see an open discussion in regards to oracles on Tezos. It is still early, so it is still pretty much an open canvas. Letā€™s paint together!

18 Likes

Itā€™s true. A stable oracle system can help pave the way for DeFi projects in Tezos. That will encourage or kickstart DeFi activities. I think an a set of oracles governed by multiple actors in the Tezos ecosystem could be a way (maybe core research group, development projects, community orgs. and active contributors ). This could evolve into a network as the defi on Tezos grows, eventually enabling a broader governance and multiple oracle nodes.

1 Like

I donā€™t know much about Oracles but I think the more (if they are quality ones) the better. In a DeFi world itā€™s always better to have more sources of information because we canā€™t 100% trust them on their own.

And this just came out. SmartPy will bring Chainlink oracles to Tezos.

3 Likes

Definitely interesting, but I hope to see other oracle solutions as well.

  • Something that doesnā€™t require another token to function.
  • The fact that only 35% of tokens are publicly available is also not a pretty sight.
1 Like

Sounds a bit like protocol design :slight_smile: . Some interesting roperties:

  • payable in xtz
  • decentralised: Maker model sounds clever. But how to know if the price feed is incorrect(compare deviation?)? And how to punish bad behaviour (slash stake?)?
  • should have some reputation mechanism or forbid anonymity: coinbase is far less likely to manipulate price than a long term good behaving anonymous quote supplier.

Many questions remain:

  • how to determine fee?
  • is quote an average of all feeds, or median, orā€¦
  • should the quote also include a confidence level?
  • if confidence level is too low, should quote even be published?
  • ā€¦
3 Likes

Personally Iā€™m against the use of Chainlink for a few reasons, though of course anyone is free to use it if thatā€™s what they feel is best for them:

  1. I donā€™t want to use a platform that is not only built on another chain, but forces you to purchase ETH/LINK for API requests. Also on this topic, ETH gas is too expensive and as far as Iā€™m aware, Chainlink doesnā€™t currently make sense at scale, monetarily. And Ethereum 2.0 wonā€™t be ready to support Chainlink for years.

  2. I feel that any platform like Chainlink should utilize the native coin, and correct me if Iā€™m wrong, but is there any necessity for LINK aside from doing their fundraising? Why not use ETH for everything?

Iā€™d prefer oracles on Tezos that use XTZ.

2 Likes

A standard deviation could be set for price feed. A large amount of stake could be enabled for people to run node with slashing. A reputation mechanism and a data validation mechnaism also has to be there. Sort of like baker and endorser. (And anonymity should be forbid, it then also put a minor pressure from community to stay active and honest)

All the questions are good and I think Oracle network design comes close to protocol design. Incentivisation in XTZ could be a task and a very interesting point imo for people to run nodes.

2 Likes

Yeah, there are mutilple barriers to use Chainlink. They say they are blockchain agnostic but evetually it doesnā€™t help the network effect of Tezos. Using a component which is built on Ethereum and transacting w the same for building on Tezos is not the most friendliest way imo.

4 Likes

I have nothing against Chainlink. Itā€™s a great addition to Tezos. But a project like Tezos should have its own oracles, that are payable with native XTZ.

4 Likes

I am not against Chainlink, but I just donā€™t understand their token model. The heavy centralization of the token and ecosystem are red flags to me. From a technical standpoint the functionalities can easily be recreated using Tez.

We can definitely learn from them, but I think other oracle solutions are also interesting to study.

4 Likes

Great points, to figure these questions out we have to iterate and test a lot. I donā€™t think writing a whitepaper is the right course here. Just trying different models in a test environment seems the best way forward in my opinion.

2 Likes

Would really like to know the opinion of user-facing projects on Tezos.

Asking all developers, startups and companies to join the discussion, what kind of oracles would you use in your project?

1 Like

Dear friends, as there is already a topic here about Oracles on Tezos, I would like to ask you guys for help on this subject.

I want to better understand oracles. A developer friend of mine told me that an oracle is just an off-chain software that saves (updates) data into a smart contractā€™s storage from time to timeā€¦ I understand that price oracles should have a high number of known, trusted participants, so the data can be considered safe to use. Thatā€™s not my worries here.

Regarding off-chain software that consumes data from some API from time to time and saves it on a blockchain smart contractā€™s storage, I could do this very easily as I have years of experience on this kind of programming.

My doubt isā€¦ Isnā€™t harmfull for blockchain (regarding storage space usage) saving so much data? Wonā€™t this break the blockchain at some point in the future? I mean, saving excessive data on-chain? As far as I know, things donā€™t really get ā€œupdatedā€ on chain. Actually blockchain keeps all previous saved data as history.

I donā€™t know. Maybe Iā€™m being too conservative?

I have worked once (for example) in a system that saved buses gps position every minute and it stored 5GB of data per period.

Letā€™s imagine a decentralized facebook where all posts, replies and likes got persisted on Tezos blockchain. Or a real estate app like Zillow or Truliaā€¦ Could all the real estate sell and rent offers be stored on chain? Is this viable at all?

Also, besides price oracles, which kind of information do you guys think that could be useful for Tezos blockchain? Weather forecasts? I imagine a decentralized smart-phone that could function based entirely on blockchain. It should use many smart-contracts to grab data for the decentralized apps. So, each of these apps would have to get data provided by some oracle.

So, in summaryā€¦ Two main doubts: About storage space usage and about which data would be useful.

Thanks in advance.

Hi, Iā€™ve been running a bakery for a while and just starting my journey into tez development. Iā€™ve been thinking alot about non-financial data oracles, just like youā€™re suggesting. Hopefully I can shed some light on some of your ideas.

On storage size, I think we have to look at it a little differently on-chain, because it is true that storing all that data will cost alot. I think there are clever solutions that could be implemented to keep storage size down tho, like using a system like IPFS for cheaper storage of large data, and then just storing the hash on chain.

Also, a great thing about Tezos is that we can spin up nodes in 3 different modes: full, rolling, archive. Full and rolling do not store the whole chain, and are far lighter than the archive node. Most folks arenā€™t running archive nodes. Rolling mode offers a super fast way to access the absolute latest blockchain data. This kinda makes oracles a great fit for Tezos, because old data we donā€™t need gets pruned to save space.

I would agree that storing all real estate listings like Zillow would definitely be tough, and costly. But by cleverly storing a hash of a listing and keeping the data elsewhere, you could create an ā€œdecentralized MLSā€ system where the buyer/seller pays the network to host the listing data. They could get the data signed by a reputable source to verify the details of the property as well. So I think storage has to be carefully designed, but shouldnā€™t be a complete blocker for future use-cases.

ā€“

Second, on non-financial oracles, this is something Iā€™m very interested in exploring. Stuff like weather forecasts, sports scores, even news articles. I think that if reputable sources can be convinced to sign data and send it to the chain, some crazy use-cases could evolve. Like fanduel signing sports scores and sending to a Tezos oracle, then decentralized sports betting contracts could be created using automated escrow. Fanduel would advertise their public key, and folks would verify the data before using it.

Also, hereā€™s something a little different that I was thinking of: reverse oracles. Rather than a trusted third-party sending out data to users and contracts, imagine an oracle where users send data for use by a third-party.

The use-case I have for this is ā€œproof-of-locationā€, something difficult to imagine in classic blockchain sense. What we do is flip the price oracle idea around, and think of it like: users sign their location data, and upload it to the oracle. A third-party contract can then query the oracle and get the information when necessary. The user would also control the permissions of their location data, being able to allow and revoke access to their updated location at any time.

Example: A regulated US bank (BigBank) wants to offer classic checking/savings accounts held in smart contracts on tezos blockchain. US regulations require that only people in the US can use this service. So BigBankā€™s smart contract would have an ā€œapplicationā€ feature where a user takes their tz address and requests a 1% interest savings account. How do we prove that an arbitrary tz_xxx account actually exists in the US, without invasive KYC controls?

Use the (hypothetical) proof of location oracle.

  1. BigBankā€™s contract gets application from tz123.
  2. BigBankā€™s contract requests access to tz123 on location oracle.
  3. BigBankā€™s contract queries tz123 on location oracle.
  4. BigBankā€™s contract verifies location is within USA and verifies signature.
  5. BigBank opens the account.

Now the hardest part is deciding the constraints on the proof-of-location oracle. Since itā€™s accepting data in reverse, from untrusted anonymous users rather than trusted sources, it cant be a free for all. Hereā€™s where it would have to get clever. Iā€™m thinking a system where users get paid for providing good data, and must pay for providing bad data. With location data, we want to optimize for freshness and accuracy.

So there could be a rule where data provided within 15min of the last update is incentivized with a tez reward, but if itā€™s been 30min since a users last update, they have to pay to get it updated. What they pay would go back into the reserves for rewarding good data.

A second rule could be related to the distance from the last location update. Meaning data provided within 30 meters gets rewarded, and data provided thatā€™s farther than 30 meters has to pay in the same way as the minutes restriction. These constraints on updates would instill more trust in the data.

The final problem is spoofers and botting, because this system really only assigns a location to a tez wallet, not an actual identity. I propose an IRL system of onboarding to the reverse oracle. What I mean is that someone would have to go to a trusted location in real life like a walmart, bank, mall, govt office, etc and get their initial location data signed in-person, proving that the owner of the wallet was at the location. Then the constraints defined above will keep the spoofing to a minimum, and if people want to spoof it will cost them alot of money to do.

(We could even keep a delta of the latest N updates, not storing the actual location data but the deviation of the latest N locations to make a decision of trustworthiness)

Obviously the parameters I chose are arbitrary, and the data wouldnā€™t be amazingly trustworthy, but I think the availability of even a rough proof-of-location could offer major value for regulations, and it would be refined over time. Sorry I started rambling up there somewhere :slight_smile:

Dear Arrijabba,

Thanks a lot for your kind reply. It certainly makes things more clear to me. I had already imagined once something that stores a hash instead of the whole data, and uses a cross-chain solution. Maybe something hybrid with another blockchain like IPFS or even with current Google or Amazon storage tools (although less appealing)ā€¦

I particularly enjoyed your comments that I quote below:

This matches with the theory that Iā€™ve explained in my most recent topic here on Tezos Agora " Customer Review Platform on Blockchain". And I really think that it makes more sense than all other proposed Oracles. Many sources of information to the Oracle, instead of one ā€œtrustedā€ source. ā€œTrustedā€ centralized source seems we are using old world concepts. So, this is really brilliant to me.

It is what I suggest in my proposed project of people reviewing items with stars from 1-5 or like/dislike.

We could start a whole new kind of multi-sourced oracles. with this concept. One example would be some kind of contract/oracle to reward people that stay home in times of pandemics.

1 Like