Skip to content

Commit 1db3d3a

Browse files
authored
Merge pull request #23 from VenusProtocol/oracle
Oracle Docs
2 parents 1953b0f + ec73976 commit 1db3d3a

File tree

6 files changed

+579
-0
lines changed

6 files changed

+579
-0
lines changed

oracle/BinanceOracle.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Binance Oracle
2+
3+
## Introduction
4+
5+
This oracle fetchs prices of assets from Binance oracle.
6+
7+
## Solidity APIs
8+
9+
### initialize
10+
11+
```solidity
12+
function initialize(contract FeedRegistryInterface feed) public
13+
```
14+
15+
Sets the contracts required to fetch price
16+
17+
#### Parameters
18+
19+
| Name | Type | Description |
20+
| ---- | ---- | ----------- |
21+
| feed | contract FeedRegistryInterface | Address of binance oracle feed registry. |
22+
23+
### getUnderlyingPrice
24+
25+
```solidity
26+
function getUnderlyingPrice(contract VBep20Interface vToken) public view returns (uint256)
27+
```
28+
29+
Gets the price of vToken from binance oracle
30+
31+
#### Parameters
32+
33+
| Name | Type | Description |
34+
| ---- | ---- | ----------- |
35+
| vToken | contract VBep20Interface | Address of the vToken |
36+
37+
#### Return Values
38+
39+
| Name | Type | Description |
40+
| ---- | ---- | ----------- |
41+
| [0] | uint256 | price in USD |

oracle/BoundValidator.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Bound Validator
2+
3+
## Introduction
4+
5+
This contracts is used to validate prices from two different sources. We need to set upper and lower bound ratios config for each vToken in this contract.
6+
7+
## Solidity API
8+
9+
10+
### initialize
11+
12+
```solidity
13+
function initialize() public
14+
```
15+
16+
Initializes the owner of the contract
17+
18+
### setValidateConfigs
19+
20+
```solidity
21+
function setValidateConfigs(struct ValidateConfig[] configs) external virtual
22+
```
23+
24+
Add multiple validation configs at the same time
25+
26+
#### Parameters
27+
28+
| Name | Type | Description |
29+
| ---- | ---- | ----------- |
30+
| configs | struct ValidateConfig[] | config array |
31+
32+
### setValidateConfig
33+
34+
```solidity
35+
function setValidateConfig(struct ValidateConfig config) public virtual
36+
```
37+
38+
Add single validation config
39+
40+
#### Parameters
41+
42+
| Name | Type | Description |
43+
| ---- | ---- | ----------- |
44+
| config | struct ValidateConfig | config struct |
45+
46+
### validatePriceWithAnchorPrice
47+
48+
```solidity
49+
function validatePriceWithAnchorPrice(address vToken, uint256 reporterPrice, uint256 anchorPrice) public view virtual returns (bool)
50+
```
51+
52+
Test reported asset price against anchor price
53+
54+
#### Parameters
55+
56+
| Name | Type | Description |
57+
| ---- | ---- | ----------- |
58+
| vToken | address | vToken address |
59+
| reporterPrice | uint256 | the price to be tested |
60+
| anchorPrice | uint256 | |
61+
62+
### _isWithinAnchor
63+
64+
```solidity
65+
function _isWithinAnchor(address asset, uint256 reporterPrice, uint256 anchorPrice) internal view returns (bool)
66+
```
67+
68+
Test whether the reported price is within the predefined bounds
69+
70+
#### Parameters
71+
72+
| Name | Type | Description |
73+
| ---- | ---- | ----------- |
74+
| asset | address | asset address |
75+
| reporterPrice | uint256 | the price to be tested |
76+
| anchorPrice | uint256 | anchor price as testing anchor |

oracle/ChainlinkOracle.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Chainlink Oracle
2+
3+
## Introduction
4+
5+
This oracle fetchs prices of assets from Chainlink oracle.
6+
7+
## Solidity API
8+
9+
### initialize
10+
11+
```solidity
12+
function initialize() public
13+
```
14+
15+
Initializes the owner of the contract
16+
17+
### getUnderlyingPrice
18+
19+
```solidity
20+
function getUnderlyingPrice(address vToken) public view returns (uint256)
21+
```
22+
23+
Get the Chainlink price of underlying asset of input vToken, revert when vToken is zero address
24+
25+
#### Parameters
26+
27+
| Name | Type | Description |
28+
| ---- | ---- | ----------- |
29+
| vToken | address | vToken address |
30+
31+
#### Return Values
32+
33+
| Name | Type | Description |
34+
| ---- | ---- | ----------- |
35+
| [0] | uint256 | price in USD |
36+
37+
38+
### setUnderlyingPrice
39+
40+
```solidity
41+
function setUnderlyingPrice(contract VBep20Interface vToken, uint256 underlyingPriceMantissa) external
42+
```
43+
44+
Set the forced prices of the underlying token of input vToken
45+
46+
#### Parameters
47+
48+
| Name | Type | Description |
49+
| ---- | ---- | ----------- |
50+
| vToken | contract VBep20Interface | vToken address |
51+
| underlyingPriceMantissa | uint256 | price in 18 decimals |
52+
53+
### setDirectPrice
54+
55+
```solidity
56+
function setDirectPrice(address asset, uint256 price) external
57+
```
58+
59+
Set the forced prices of the input token
60+
61+
#### Parameters
62+
63+
| Name | Type | Description |
64+
| ---- | ---- | ----------- |
65+
| asset | address | asset address |
66+
| price | uint256 | price in 18 decimals |
67+
68+
### setTokenConfigs
69+
70+
```solidity
71+
function setTokenConfigs(struct TokenConfig[] tokenConfigs_) external
72+
```
73+
74+
Add multiple token configs at the same time
75+
76+
#### Parameters
77+
78+
| Name | Type | Description |
79+
| ---- | ---- | ----------- |
80+
| tokenConfigs_ | struct TokenConfig[] | config array |
81+
82+
### setTokenConfig
83+
84+
```solidity
85+
function setTokenConfig(struct TokenConfig tokenConfig) public
86+
```
87+
88+
Add single token config, vToken & feed cannot be zero address, and maxStalePeriod must be positive
89+
90+
#### Parameters
91+
92+
| Name | Type | Description |
93+
| ---- | ---- | ----------- |
94+
| tokenConfig | struct TokenConfig | token config struct |

oracle/PythOracle.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# TWAP Oracle
2+
3+
## Introduction
4+
5+
This oracle fetches price of assets from Pyth oracle
6+
7+
## Solidity API
8+
9+
10+
### initialize
11+
12+
```solidity
13+
function initialize(address underlyingPythOracle_) public
14+
```
15+
16+
Initializes the owner of the contract and sets required contracts
17+
18+
#### Parameters
19+
20+
| Name | Type | Description |
21+
| ---- | ---- | ----------- |
22+
| underlyingPythOracle_ | address | Address of the pyth oracle |
23+
24+
### setTokenConfigs
25+
26+
```solidity
27+
function setTokenConfigs(struct TokenConfig[] tokenConfigs_) external
28+
```
29+
30+
Batch set token configs
31+
32+
#### Parameters
33+
34+
| Name | Type | Description |
35+
| ---- | ---- | ----------- |
36+
| tokenConfigs_ | struct TokenConfig[] | token config array |
37+
38+
### setTokenConfig
39+
40+
```solidity
41+
function setTokenConfig(struct TokenConfig tokenConfig) public
42+
```
43+
44+
Set single token config, `maxStalePeriod` cannot be 0 and `vToken` can be zero address
45+
46+
#### Parameters
47+
48+
| Name | Type | Description |
49+
| ---- | ---- | ----------- |
50+
| tokenConfig | struct TokenConfig | token config struct |
51+
52+
### setUnderlyingPythOracle
53+
54+
```solidity
55+
function setUnderlyingPythOracle(contract IPyth underlyingPythOracle_) external
56+
```
57+
58+
set the underlying pyth oracle contract address
59+
60+
#### Parameters
61+
62+
| Name | Type | Description |
63+
| ---- | ---- | ----------- |
64+
| underlyingPythOracle_ | contract IPyth | pyth oracle contract address |
65+
66+
### getUnderlyingPrice
67+
68+
```solidity
69+
function getUnderlyingPrice(address vToken) public view returns (uint256)
70+
```
71+
72+
Get price of underlying asset of the input vToken, under the hood this function
73+
get price from Pyth contract, the prices of which are updated externally
74+
75+
#### Parameters
76+
77+
| Name | Type | Description |
78+
| ---- | ---- | ----------- |
79+
| vToken | address | vToken address |
80+
81+
#### Return Values
82+
83+
| Name | Type | Description |
84+
| ---- | ---- | ----------- |
85+
| [0] | uint256 | price in 10 decimals |
86+

0 commit comments

Comments
 (0)