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.
These bots operate autonomously and are containerized, serving the purpose of submitting prices to the Price Aggregator Smart Contract. Each Bot possesses a unique private key, and the corresponding public key is granted Oracle status on the Price Aggregator Smart Contract whitelist, thereby permitting it to introduce new prices. Each Bot maintains a specific set of price providers that might intersect with those of other Bots. The Oracle Bots carry out two types of scheduled tasks: the "Heartbeat Task" and the "Threshold Task".The Heartbeat Task runs less frequently and operates according to a timeframe set by the round time of the Price Aggregator Smart Contract, ensuring regular price submissions. Conversely, the Threshold Task executes more frequently, retrieving prices from assigned sources (such as Binance, Cryptocompare, HitBTC, Huobi, Kraken, etc..), compares them to the previously submitted price, and resubmits the price if it exceeds a predefined threshold.
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.
Price Aggregator Smart Contract price feeds, which consolidate multiple sources of information to produce a singular price for an asset, drawing from sources such as Binance, Gemini, OKX, HitBTC, Huobi, Kraken, and more.
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.
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.