Hatom Price Oracle Infrastructure
as of 17/06/2023
The Hatom Price Oracle is a sophisticated infrastructure comprising of Oracle Bots that push prices to a Price Aggregator Smart Contract (akin to the Chainlink oracle system). This contract subsequently renders these prices accessible on-chain, facilitating their usage by the Lending Price Oracle Smart Contract to ensure reliable pricing when users interact with the Lending Protocol.
Oracle Bots
Price Aggregator Smart Contract
Its primary role is to compile price submissions from whitelisted Oracles. These Oracles are tasked with extracting prices from external sources like well-established exchanges and forwarding this data to the Price Aggregator. Upon reaching a certain number of submissions (which is fewer than the total number of Oracles), the Price Aggregator calculates a new median price and announces it. In a manner similar to Chainlink's price feeds, Oracles contribute prices in "rounds," which generally take place every half hour to one hour. However, if a sudden price change surpasses a predetermined "Threshold", Oracles are expected to resubmit a price, irrespective of the duration since the last submission.
Price Oracle Smart Contract
The Hatom Oracle Smart Contract is responsible for supplying prices to the Controller Smart Contract, ensuring all assets can be represented in a common unit or currency (in this case, EGLD). To achieve this, the Oracle Smart Contract employs the following sources of information:
xExchange DEX Price Feeds, comprising the current price and the time-weighted average price (also known as the Safe Price) of the specific asset.
When a price is requested from the Hatom Oracle Smart Contract, it fetches the safe price from the xExchange DEX Price Feeds, and compares it to the price offered by the Price Aggregator Smart Contract. If the price difference falls within an acceptable range, the price from the Price Aggregator Smart Contract is deemed valid and relayed to the Controller Smart Contract. If the price difference exceeds a certain limit, the following occurs:
If the initial tolerance is Surpassed: The price is deemed invalid and the Hatom Oracle Smart Contract issues an event to alert the community that the first anchor tolerance has been exceeded. It then sends the most recent valid price to the Controller Smart Contract. A subsequent call to the Hatom Oracle Smart Contract will Fail unless the prices return within the tolerance range.
If the final tolerance is Surpassed: The price is deemed invalid and the Hatom Oracle Smart Contract issues an event to alert the community that the last anchor tolerance has been exceeded. It then sends the most recent valid price to the Controller Smart Contract. The Oracle is suspended, and all subsequent price requests will Fail unless there's a manual intervention by the Guardian to Unpause the Oracle.
Guardian bot
The Guardian Bot has been specifically designed to closely monitor the Lending Protocol. Its role is to track price feeds from the Price Aggregator and the Safe Price, compare them, and identify any irregularities or discrepancies in the prices of the integrated assets. The Bot will also autonomously pause the Protocol in such occurrences and notify us for additional monitoring and necessary action.
Last updated