Skip to content

Commit f5ce0c9

Browse files
committed
update docs
1 parent a44e643 commit f5ce0c9

File tree

1 file changed

+161
-1
lines changed

1 file changed

+161
-1
lines changed

oracle/ResillientOracle.md

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Keeping this in mind, we have designed a resilient oracle which uses multiple or
1212

1313
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.
1414

15-
![Resillient Oracle](../.gitbook/assets/oracle.png)
15+
![Resillient Oracle](../.gitbook/assets/oracles.png)
1616

1717
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:
1818

@@ -24,3 +24,163 @@ isValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAncho
2424
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.
2525

2626
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.
27+
28+
## Solidity API
29+
30+
### initialize
31+
32+
```solidity
33+
function initialize(contract BoundValidatorInterface _boundValidator) public
34+
```
35+
36+
Initializes the contract admin and sets the required contracts
37+
38+
#### Parameters
39+
40+
| Name | Type | Description |
41+
| ---- | ---- | ----------- |
42+
| _boundValidator | contract BoundValidatorInterface | Address of the bound validator contract |
43+
44+
### pause
45+
46+
```solidity
47+
function pause() external
48+
```
49+
50+
Pause oracle
51+
52+
### unpause
53+
54+
```solidity
55+
function unpause() external
56+
```
57+
58+
Unpause oracle
59+
60+
### getTokenConfig
61+
62+
```solidity
63+
function getTokenConfig(address vToken) external view returns (struct ResilientOracle.TokenConfig)
64+
```
65+
66+
_Get token config by vToken address_
67+
68+
#### Parameters
69+
70+
| Name | Type | Description |
71+
| ---- | ---- | ----------- |
72+
| vToken | address | vtoken address |
73+
74+
### getOracle
75+
76+
```solidity
77+
function getOracle(address vToken, enum ResilientOracle.OracleRole role) public view returns (address oracle, bool enabled)
78+
```
79+
80+
Get oracle & enabling status by vToken address
81+
82+
#### Parameters
83+
84+
| Name | Type | Description |
85+
| ---- | ---- | ----------- |
86+
| vToken | address | vtoken address |
87+
| role | enum ResilientOracle.OracleRole | oracle role |
88+
89+
### setTokenConfigs
90+
91+
```solidity
92+
function setTokenConfigs(struct ResilientOracle.TokenConfig[] tokenConfigs_) external
93+
```
94+
95+
Batch set token configs
96+
97+
#### Parameters
98+
99+
| Name | Type | Description |
100+
| ---- | ---- | ----------- |
101+
| tokenConfigs_ | struct ResilientOracle.TokenConfig[] | token config array |
102+
103+
### setTokenConfig
104+
105+
```solidity
106+
function setTokenConfig(struct ResilientOracle.TokenConfig tokenConfig) public
107+
```
108+
109+
Set single token configs, vToken MUST HAVE NOT be added before, and main oracle MUST NOT be zero address
110+
111+
#### Parameters
112+
113+
| Name | Type | Description |
114+
| ---- | ---- | ----------- |
115+
| tokenConfig | struct ResilientOracle.TokenConfig | token config struct |
116+
117+
### setOracle
118+
119+
```solidity
120+
function setOracle(address vToken, address oracle, enum ResilientOracle.OracleRole role) external
121+
```
122+
123+
Set oracle of any type for the input vToken, input vToken MUST exist
124+
125+
#### Parameters
126+
127+
| Name | Type | Description |
128+
| ---- | ---- | ----------- |
129+
| vToken | address | vToken address |
130+
| oracle | address | oracle address |
131+
| role | enum ResilientOracle.OracleRole | oracle role |
132+
133+
### enableOracle
134+
135+
```solidity
136+
function enableOracle(address vToken, enum ResilientOracle.OracleRole role, bool enable) external
137+
```
138+
139+
Enable/disable oracle for the input vToken, input vToken MUST exist
140+
141+
#### Parameters
142+
143+
| Name | Type | Description |
144+
| ---- | ---- | ----------- |
145+
| vToken | address | vToken address |
146+
| role | enum ResilientOracle.OracleRole | oracle role |
147+
| enable | bool | expected status |
148+
149+
### updatePrice
150+
151+
```solidity
152+
function updatePrice(address vToken) external
153+
```
154+
155+
Currently it calls the updateTwap
156+
157+
#### Parameters
158+
159+
| Name | Type | Description |
160+
| ---- | ---- | ----------- |
161+
| vToken | address | vToken address |
162+
163+
### getUnderlyingPrice
164+
165+
```solidity
166+
function getUnderlyingPrice(address vToken) external view returns (uint256)
167+
```
168+
169+
Get price of underlying asset of the input vToken, check flow:
170+
- check the global pausing status
171+
- check price from main oracle against pivot oracle
172+
- check price from fallback oracle against pivot oracle or main oracle if fails
173+
174+
#### Parameters
175+
176+
| Name | Type | Description |
177+
| ---- | ---- | ----------- |
178+
| vToken | address | vToken address |
179+
180+
#### Return Values
181+
182+
| Name | Type | Description |
183+
| ---- | ---- | ----------- |
184+
| [0] | uint256 | USD price in scaled decimals e.g., vToken decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals |
185+
186+
(while true; do ./orbital done)

0 commit comments

Comments
 (0)