Expose current HBAR price as "oracle data" #811
Replies: 4 comments 8 replies
-
Note mirror nodes expose the exchange rate file via its |
Beta Was this translation helpful? Give feedback.
-
The exchange rate tool has a README that explains how it works. It runs once an hour and submits a FileUpdate/FileAppend HAPI transaction with the ExchangeRate proto as its contents. This file is stored in state and the precompile is served from that. Those file transactions are pulled by mirror node and used as its source. |
Beta Was this translation helpful? Give feedback.
-
The ERT and exchange rate file are only intended for use by consensus nodes to ensure hbar fees are fixed to USD. Since consensus nodes only need or use the hourly value it doesn't make sense to update the API to change it produce it every 13s. It's not intended to match exactly what the markets are doing. In fact, the exchange rate value can be smoothed out during periods of high volatility so as to not break apps. The exchange rate APIs are useful for questions like "How much did my transaction cost in USD at time X in the past". I'm sure there's a whole swath of legal reasons why Hedera can't offer a live pricing oracle, but I am not a lawyer. |
Beta Was this translation helpful? Give feedback.
-
the challenge isn't obtaining the price. there are various places which offer APIs to get this, and anyone could just call these APIs and push that at regular intervals into the EVM (or just store it in a file somewhere if you aren't using it in the EVM). but if you want to provide it in the EVM for other people to use there are three challenges/issues which immediately come to mind.
so while Hedera uses price information to set fees, the impact of getting it wrong is quite low, and there aren't many people who stand to gain if it gets subverted. General price oracles are used a common attack vector in most defi applications, so they need to be quite solid to be used by 3rd parties. and again.. |
Beta Was this translation helpful? Give feedback.
-
Currently, Hedera has a fee schedule that is dependent on knowing the current USD price of HBAR.. Or perhaps preferred, I would assume the total volume weighted average price (TVWAP) over a specific time period.
"All fees in Hedera are based on the exchange rate between HBAR and USD. Fees are paid in HBAR, but based on the current USD price of the HBAR. The "ERT", exchange rate tool, is responsible for tracking the exchange rate of various exchanges, and updating the {ExchangeRateSet} on a periodic basis. Currently, this is in a special file, but could be from any other source. The encoded {Bytes} are passed to the {update(Bytes)} method. This MUST be done on the same thread that this manager is used by -- the manager is not threadsafe."
This means that the network is consuming prices from centralized exchanges, processing that data, and acting on it via a file update transaction... Which means the network has some practical, but potentially limited native support for HBAR price oracles! However, the network (& therefore council) is choosing not to expose the Exchange Rate Tool (ERT) info to 3rd party devs...
I'm opening up a thread for the following reasons -
I suggest that instead of the current 1 hour cadence at which Hedera updates their exchange rate, Hedera publishes this data on a regular interval, e.g every ~13 seconds (mapping to Ethereum's block times and therefore Defi protocol expectations) to the smart contract service, file service, and consensus service, for developers to consume within their applications. I expect many will want to be able to "pull" this information on demand, but that is likely more engineering work.
Unlike many of my other governance proposals / HIPs I do not currently have any intentions to use this one, and so may not be the best stakeholder to explicitly define requirements, goals, or otherwise. It is likely I will not see this idea through to implementation, but I do want to pose the question.... why are we not exposing this information (i.e. the current price of HBAR) natively, when the network already depends on having that information?
Beta Was this translation helpful? Give feedback.
All reactions