|
| 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