Skip to content

Commit a44e643

Browse files
committed
added details
1 parent c06a64f commit a44e643

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

oracle/ResillientOracle.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Resillient Oracle
2+
3+
## Introduction
4+
5+
Resillient oracle is the price oracle that the protocol interacts with for fetching price of assets.
6+
7+
## Details
8+
9+
DeFi Protocols are usually vulnerable to price oracles reporting incorrect prices. There are various ways in which oracle prices can be manipulated depending on the type of price oracle used which can create a single point of failure and opens several ways for attacking the protocol.
10+
11+
Keeping this in mind, we have designed a resilient oracle which uses multiple oracle sources to validate prices and fallback mechanisms to provide accurate prices and protect from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.
12+
13+
The way the resilient oracle works is for every market (vToken) we configure the main, pivot and fallback oracles. The main oracle oracle is the most trustworthy price source, the pivot oracle is is used as a loose sanity checker and the fallback oracle is used as a backup price source.
14+
15+
![Resillient Oracle](../.gitbook/assets/oracle.png)
16+
17+
To validate the price between two oracles we set an upper and lower bound ratio for every market. The upper bound ratio represents the deviation between reported prices (price from oracle that’s being validated) and anchor price (price from oracle we are validating against) beyond which the reported price will be invalidated. And the lower bound ratio presents the deviation between reported price and anchor price below which the reported price will be invalidated. So for oracle price to be considered valid the below statement should be true:
18+
19+
```
20+
anchorRatio = anchorPrice/reporterPrice
21+
isValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio
22+
```
23+
24+
We usually use Chainlink as the main oracle, TWAP or Pyth oracle as pivot oracle depending on which supports the given market and binance oracle is used as the fallback oracle. For some markets we may use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles.
25+
26+
When fetching an oracle price, for the price to be valid it must be positive and not stagnant. If the price is invalid then we consider the oracle to be stagnant and treat it like it's disabled.

0 commit comments

Comments
 (0)