ghConnectHub

Price manipulation using Oracles

analyticagh |
Education & Learning

Oracles act as a data layer providing and verifying real-time data to smart contracts residing Block Chain network. Decentralized Exchanges (DEx) operating in the decentralized finance spherical on the blockchain, rely on Oracles to enable smart contracts have access to reliable information mostly on pricing to making them intelligent.

The need for Oracles arises because blockchains do not have data on-chain to provide smart contracts. As a result, some price oracles in Defi source information from credible crypto exchanges such as Binance, Coinbase. Some Oracles also exist on-chain whereby they make use of mathematical algorithms to determine the pricing of their liquidity. On-chain price oracles are called software oracles and an example is the Uniswap's time-weighted average price oracles integrated into the protocol.
These price oracles reside on notable blockchains such as Ethereum, Binance smart chain, Polygon (matic) network.

The total value of locked up funds (TVL) in Defi stands at around $92.36 billion as at January 21, 2022. The growing value of locked up funds shows the degree of acceptance and adoption that is eminent if the blockchain ecosystem is secured.

Types of Price Oracles

Off-chain price oracles or hardware oracles compute information and store off-chain before sending data to the blockchain. For example, Aave, Compound Finance, Synthetix and other protocols rely on the off-chain price oracles for asset pricing. Open price feed (Price oracle of compound finance) and Chainlink are some price oracles worth mentioning. Defi projects can use a mix of price oracles to better secured pricing data

Each price oracle chosen has its own inherent advantages or disadvantages. The project deliverables will determine whether to integrate an off-chain, on-chain or a hybrid chain price oracle as the case may be.

The design architecture of Oracles can be Centralized or decentralized. Centralized Oracles function as a single entity providing data to smart contracts using a single node as a data source. This centralized design is similar to the traditional financial model. This presents a risk where there is a single point of failure, this is less secure and data residing therein become subject to security breaches. Since other sources are not available to corroborate the data.


Decentralized Oracles have the advantage of relying on multiple external sources of information to increase their credibility. They normally make use of Shelling points game theory whereby all participants provide data and inputs are evaluated from all nodes without collusion and expect same from other providers.

How Price Manipulation Occurs

An attacker who wishes to benefit from price differences on assets, Can initiate an attack on an off-chain price oracle's data feed to prevent updates or manipulate the price to a level that makes the asset cheap to buy. The attacker can then take a huge amount of un-collaterized loan, buy the asset, then restore the oracle feed data then sell on a different exchange. The huge value of funds available on liquidity pool can magnify the effects of even the slightest price difference.

This attack is often encountered by price oracles using the centralized design since there is only a single node providing data to smart contracts on the blockchain without relying on other data sources for verification and computation of the best price possible. This presents a risk anytime there is a single point of failure and data residing therein become subject to security breaches. Since other sources are not available to corroborate the validity of the data.

Using an on-chain price oracles (as in the case of Automated Market) , if proper pricing determinants or fail safe pause mechanisms is not put in place, asset prices can be manipulated. This is because of the use of the constant product function formula. With this formula, the prices of a pair of assets are computed based on the amount of liquidity available in the pool and must be held in a constant proportion thus remain unchanged.

A reduction in the price of one asset will lead to an increase in the price of the other, and an increase in one asset will lead to fall in the other, in other to maintain a constant equilibrium between the pair. With this in mind, a flash loan can be used to target poorly designed systems to make the price of one asset very cheap, while another transaction can be used to buy the cheap asset and profit from it.

Use cases of Price Oracles

Derivative platforms need the availability of price oracles to value of assets. For example, Perpetual contracts are being traded, the protocol requests for the spot price of each asset at a predetermined time. Then, if the market price becomes bigger than the indexed price, long position holders will have to pay a funding payment to short position holders, the reverse holds true.

A similar principle applies to the stabilization of crypto-backed stable coins like DAI. DAI's peg to USD is maintained by using collateralized debt denominated in Ethereum. Price oracles are utilized to report the value of ETH and determine the moment when DAI is insufficiently collateralized.

Lending protocols rely on price oracles to avoid under-collateralized of the value of assets used to secure loans. Using price oracles the value of an underlying assets can be known, a downward movement of value will lead to the liquidation of the position.

Trading platforms rely on price oracles to value their assets. Valuing their assets is crucial to ensuring that traders who use their platforms are not being exploited.

The Future of Oracles

Despite the challenges that Oracles encounter, Oracles are set to prepare the stage for Defi’s adoption and acceptance. As Oracles are being subjected to manipulations, more robust designs need to be implemented and used to mitigate the risk exposures and strengthen their functionalities. Majority of Oracles are being setup as decentralized in the Defi space and also implementing inbuilt safety mechanisms to guard against price manipulations.