> For the complete documentation index, see [llms.txt](https://docs.hatom.com/getting-started/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hatom.com/getting-started/hatoms-ecosystem/lending-protocol/hatom-price-oracle-infrastructure.md).

# Hatom Price Oracle Infrastructure

### Introduction

The Hatom Price Oracle is a robust infrastructure composed of [**Oracle Bots** ](#oracle-bots)that feed prices into a [**Price Aggregator Smart Contract**](#price-aggregator-smart-contract), similar to the Chainlink Oracle system. This smart contract makes prices available on-chain, enabling the Lending [**Price Oracle Smart Contract**](#price-aggregator-smart-contract) to provide reliable pricing when users interact with the[ **Lending Protocol**](/getting-started/hatoms-ecosystem/lending-protocol.md)**.**

### Oracle Bots

Oracle Bots are autonomous, containerized entities responsible for submitting prices to the [**Price Aggregator Smart Contract**](#price-aggregator-smart-contract). Each bot has a unique private key, and the corresponding public key is granted Oracle status on the [**Price Aggregator**](#price-aggregator-smart-contract) whitelist, allowing it to introduce new prices. Each bot is linked to a specific set of price providers, which may overlap with others.

The Oracle Bots execute two key tasks:

1. **Heartbeat Task:** Runs less frequently, according to the round time of the [**Price Aggregator**](#price-aggregator-smart-contract), to ensure regular price submissions.
2. **Threshold Task:** Runs more frequently, fetching prices from sources like [**Binance**](https://www.binance.com/), [**Cryptocompare**](https://www.cryptocompare.com/), [**HitBTC**](https://hitbtc.com/), [**Huobi**](https://www.huobi.com/), and [**Kraken**](https://www.kraken.com/). It compares new prices to previously submitted prices and resubmits them if they exceed a predefined threshold.

### Price Aggregator Smart Contract

The Price Aggregator compiles price submissions from whitelisted [**Oracles**](#oracle-bots) that pull data from reputable exchanges. Once a certain number of submissions are received (fewer than the total number of [**Oracles**](#oracle-bots)), the [**Price Aggregator**](#price-aggregator-smart-contract) calculates a new median price and announces it. Similar to Chainlink’s price feeds, these [**Oracles** ](#oracle-bots)submit prices in "rounds," typically occurring every 30 minutes to an hour. However, if a price change surpasses a set Threshold, oracles must resubmit a price, regardless of the last submission time.

### Price Oracle Smart Contract

The [**Hatom Price Oracle Smart Contract**](#price-oracle-smart-contract) supplies prices to the **Controller Smart Contract** to ensure all assets are represented in a common unit (typically EGLD). It sources information from:

* [**xExchange DEX**](http://xexchange.com) **Price Feeds** and[ **AshSwap Aggregator**](http://ashswap.io) **Price Feeds**, which include current and time-weighted average prices (the Safe Price) of specific assets.
* [**Price Aggregator Smart Contract**](#price-aggregator-smart-contract) **Feeds**, which aggregate data from multiple sources such as [**Binance**](https://www.binance.com/fr), [**Gemini**](https://www.gemini.com/eu), [**OKX**](https://www.okx.com/), [**HitBTC**](https://hitbtc.com/), [**Huobi**](https://www.huobi.com/), and [**Kraken**](https://www.kraken.com/).

When the [**Hatom Oracle Smart Contract**](#price-oracle-smart-contract) receives a price request, it compares the Safe Price from [**xExchange DEX**](http://xexchange.com) with the price from the [**Price Aggregator**](#price-aggregator-smart-contract). If the difference is within an acceptable range, the[ **Price Aggregator’s**](#price-aggregator-smart-contract) value is deemed valid and sent to the **Controller Smart Contract**. If the difference exceeds a predefined limit:

* **If the initial tolerance is surpassed:** The price is marked invalid, and the [**Oracle** ](#price-oracle-smart-contract)issues an alert to the community. The most recent valid price is sent to the **Controller Smart Contract**. Future calls to [**Oracle** ](#price-oracle-smart-contract)will revert unless the prices fall within the tolerance range.
* **If the final tolerance is surpassed:** The price is marked invalid, an alert is issued, and [**Oracle** ](#price-oracle-smart-contract)sends the most recent valid price to the **Controller Smart Contract**. The [**Oracle** ](#price-oracle-smart-contract)is then suspended, and subsequent price requests will fail until a Guardian manually intervenes to unpause the [**Oracle**](#price-oracle-smart-contract).
