@venusprotocol/oracle 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
  2. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
  3. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
  4. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
  5. package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +1 -1
  6. package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.dbg.json +1 -1
  7. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +1 -1
  8. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
  9. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
  10. package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +1 -1
  11. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
  12. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
  13. package/artifacts/build-info/c88e3d40dfcb048309cae1c803479ead.json +1 -0
  14. package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +1 -1
  15. package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json +35 -3
  16. package/artifacts/contracts/interfaces/AggregatorV2V3Interface.sol/AggregatorV2V3Interface.dbg.json +1 -1
  17. package/artifacts/contracts/interfaces/BEP20Interface.sol/BEP20Interface.dbg.json +1 -1
  18. package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.dbg.json +4 -0
  19. package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.json +79 -0
  20. package/artifacts/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +4 -0
  21. package/artifacts/contracts/interfaces/OracleInterface.sol/{PivotValidatorInterface.json → BoundValidatorInterface.json} +8 -3
  22. package/artifacts/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +1 -1
  23. package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +4 -0
  24. package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +43 -0
  25. package/artifacts/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +4 -0
  26. package/artifacts/contracts/interfaces/OracleInterface.sol/{PivotOracleInterface.json → TwapInterface.json} +5 -10
  27. package/artifacts/contracts/interfaces/PythInterface.sol/IPyth.dbg.json +1 -1
  28. package/artifacts/contracts/interfaces/PythInterface.sol/PythStructs.dbg.json +1 -1
  29. package/artifacts/contracts/interfaces/VBep20Interface.sol/VBep20Interface.dbg.json +1 -1
  30. package/artifacts/contracts/libraries/PancakeLibrary.sol/FixedPoint.dbg.json +1 -1
  31. package/artifacts/contracts/libraries/PancakeLibrary.sol/IPancakePair.dbg.json +1 -1
  32. package/artifacts/contracts/libraries/PancakeLibrary.sol/PancakeOracleLibrary.dbg.json +1 -1
  33. package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.dbg.json +4 -0
  34. package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.json +69 -0
  35. package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.dbg.json +1 -1
  36. package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.json +13 -6
  37. package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.dbg.json +1 -1
  38. package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.json +6 -6
  39. package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.dbg.json +1 -1
  40. package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.json +5 -5
  41. package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.dbg.json +1 -1
  42. package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.json +23 -23
  43. package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.dbg.json +4 -0
  44. package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.json +116 -0
  45. package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.dbg.json +4 -0
  46. package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.json +144 -0
  47. package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.dbg.json +1 -1
  48. package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.dbg.json +1 -1
  49. package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.dbg.json +4 -0
  50. package/artifacts/contracts/oracles/mocks/{MockPivotTwapOracle.sol/MockPivotTwapOracle.json → MockTwapOracle.sol/MockTwapOracle.json} +2 -2
  51. package/artifacts/contracts/test/BEP20Harness.sol/BEP20Harness.dbg.json +1 -1
  52. package/artifacts/contracts/test/MockPyth.sol/MockPyth.dbg.json +1 -1
  53. package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.dbg.json +4 -0
  54. package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.json +95 -0
  55. package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.dbg.json +1 -1
  56. package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.dbg.json +1 -1
  57. package/artifacts/contracts/test/PancakePairHarness.sol/Math.dbg.json +1 -1
  58. package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.dbg.json +1 -1
  59. package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.dbg.json +1 -1
  60. package/artifacts/contracts/test/VBEP20Harness.sol/VBEP20Harness.dbg.json +1 -1
  61. package/deploy/oracles.d.ts +1 -1
  62. package/deploy/oracles.d.ts.map +1 -1
  63. package/deploy/oracles.js +43 -29
  64. package/deploy/oracles.js.map +1 -1
  65. package/deployments/.gitkeep +0 -0
  66. package/package.json +4 -5
  67. package/artifacts/build-info/5759fed659a82870ff637da81e15ba57.json +0 -1
  68. package/artifacts/build-info/b22018d758b06a50b7c80c494f08be30.json +0 -1
  69. package/artifacts/contracts/interfaces/OracleInterface.sol/PivotOracleInterface.dbg.json +0 -4
  70. package/artifacts/contracts/interfaces/OracleInterface.sol/PivotValidatorInterface.dbg.json +0 -4
  71. package/artifacts/contracts/oracles/PivotPythOracle.sol/PivotPythOracle.dbg.json +0 -4
  72. package/artifacts/contracts/oracles/PivotPythOracle.sol/PivotPythOracle.json +0 -441
  73. package/artifacts/contracts/oracles/PivotTwapOracle.sol/PivotTwapOracle.dbg.json +0 -4
  74. package/artifacts/contracts/oracles/PivotTwapOracle.sol/PivotTwapOracle.json +0 -691
  75. package/artifacts/contracts/oracles/mocks/MockPivotTwapOracle.sol/MockPivotTwapOracle.dbg.json +0 -4
  76. package/artifacts/contracts/test/MockBoundValidator.sol/MockBoundValidator.dbg.json +0 -4
  77. package/artifacts/contracts/test/MockBoundValidator.sol/MockBoundValidator.json +0 -226
  78. package/artifacts/contracts/test/MockSimpleOracle.sol/MockPivotOracle.dbg.json +0 -4
  79. package/artifacts/contracts/test/MockSimpleOracle.sol/MockPivotOracle.json +0 -133
  80. package/contracts/ResilientOracle.sol +0 -220
  81. package/contracts/interfaces/AggregatorV2V3Interface.sol +0 -60
  82. package/contracts/interfaces/BEP20Interface.sol +0 -97
  83. package/contracts/interfaces/OracleInterface.sol +0 -15
  84. package/contracts/interfaces/PythInterface.sol +0 -160
  85. package/contracts/interfaces/VBep20Interface.sol +0 -11
  86. package/contracts/libraries/PancakeLibrary.sol +0 -64
  87. package/contracts/oracles/BoundValidator.sol +0 -96
  88. package/contracts/oracles/ChainlinkOracle.sol +0 -178
  89. package/contracts/oracles/PivotPythOracle.sol +0 -18
  90. package/contracts/oracles/PivotTwapOracle.sol +0 -18
  91. package/contracts/oracles/PythOracle.sol +0 -129
  92. package/contracts/oracles/TwapOracle.sol +0 -234
  93. package/contracts/oracles/mocks/MockChainlinkOracle.sol +0 -26
  94. package/contracts/oracles/mocks/MockPivotTwapOracle.sol +0 -31
  95. package/contracts/oracles/mocks/MockPythOracle.sol +0 -31
  96. package/contracts/test/BEP20Harness.sol +0 -21
  97. package/contracts/test/MockBoundValidator.sol +0 -10
  98. package/contracts/test/MockPyth.sol +0 -78
  99. package/contracts/test/MockSimpleOracle.sol +0 -37
  100. package/contracts/test/MockV3Aggregator.sol +0 -91
  101. package/contracts/test/PancakePairHarness.sol +0 -113
  102. package/contracts/test/VBEP20Harness.sol +0 -22
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5759fed659a82870ff637da81e15ba57.json"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b22018d758b06a50b7c80c494f08be30.json"
4
- }
@@ -1,226 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "MockBoundValidator",
4
- "sourceName": "contracts/test/MockBoundValidator.sol",
5
- "abi": [
6
- {
7
- "anonymous": false,
8
- "inputs": [
9
- {
10
- "indexed": false,
11
- "internalType": "uint8",
12
- "name": "version",
13
- "type": "uint8"
14
- }
15
- ],
16
- "name": "Initialized",
17
- "type": "event"
18
- },
19
- {
20
- "anonymous": false,
21
- "inputs": [
22
- {
23
- "indexed": true,
24
- "internalType": "address",
25
- "name": "previousOwner",
26
- "type": "address"
27
- },
28
- {
29
- "indexed": true,
30
- "internalType": "address",
31
- "name": "newOwner",
32
- "type": "address"
33
- }
34
- ],
35
- "name": "OwnershipTransferred",
36
- "type": "event"
37
- },
38
- {
39
- "anonymous": false,
40
- "inputs": [
41
- {
42
- "indexed": true,
43
- "internalType": "address",
44
- "name": "vToken",
45
- "type": "address"
46
- },
47
- {
48
- "indexed": true,
49
- "internalType": "uint256",
50
- "name": "upperBound",
51
- "type": "uint256"
52
- },
53
- {
54
- "indexed": true,
55
- "internalType": "uint256",
56
- "name": "lowerBound",
57
- "type": "uint256"
58
- }
59
- ],
60
- "name": "ValidateConfigAdded",
61
- "type": "event"
62
- },
63
- {
64
- "inputs": [],
65
- "name": "initialize",
66
- "outputs": [],
67
- "stateMutability": "nonpayable",
68
- "type": "function"
69
- },
70
- {
71
- "inputs": [],
72
- "name": "owner",
73
- "outputs": [
74
- {
75
- "internalType": "address",
76
- "name": "",
77
- "type": "address"
78
- }
79
- ],
80
- "stateMutability": "view",
81
- "type": "function"
82
- },
83
- {
84
- "inputs": [],
85
- "name": "renounceOwnership",
86
- "outputs": [],
87
- "stateMutability": "nonpayable",
88
- "type": "function"
89
- },
90
- {
91
- "inputs": [
92
- {
93
- "components": [
94
- {
95
- "internalType": "address",
96
- "name": "vToken",
97
- "type": "address"
98
- },
99
- {
100
- "internalType": "uint256",
101
- "name": "upperBoundRatio",
102
- "type": "uint256"
103
- },
104
- {
105
- "internalType": "uint256",
106
- "name": "lowerBoundRatio",
107
- "type": "uint256"
108
- }
109
- ],
110
- "internalType": "struct ValidateConfig",
111
- "name": "config",
112
- "type": "tuple"
113
- }
114
- ],
115
- "name": "setValidateConfig",
116
- "outputs": [],
117
- "stateMutability": "nonpayable",
118
- "type": "function"
119
- },
120
- {
121
- "inputs": [
122
- {
123
- "components": [
124
- {
125
- "internalType": "address",
126
- "name": "vToken",
127
- "type": "address"
128
- },
129
- {
130
- "internalType": "uint256",
131
- "name": "upperBoundRatio",
132
- "type": "uint256"
133
- },
134
- {
135
- "internalType": "uint256",
136
- "name": "lowerBoundRatio",
137
- "type": "uint256"
138
- }
139
- ],
140
- "internalType": "struct ValidateConfig[]",
141
- "name": "configs",
142
- "type": "tuple[]"
143
- }
144
- ],
145
- "name": "setValidateConfigs",
146
- "outputs": [],
147
- "stateMutability": "nonpayable",
148
- "type": "function"
149
- },
150
- {
151
- "inputs": [
152
- {
153
- "internalType": "address",
154
- "name": "newOwner",
155
- "type": "address"
156
- }
157
- ],
158
- "name": "transferOwnership",
159
- "outputs": [],
160
- "stateMutability": "nonpayable",
161
- "type": "function"
162
- },
163
- {
164
- "inputs": [
165
- {
166
- "internalType": "address",
167
- "name": "",
168
- "type": "address"
169
- }
170
- ],
171
- "name": "validateConfigs",
172
- "outputs": [
173
- {
174
- "internalType": "address",
175
- "name": "vToken",
176
- "type": "address"
177
- },
178
- {
179
- "internalType": "uint256",
180
- "name": "upperBoundRatio",
181
- "type": "uint256"
182
- },
183
- {
184
- "internalType": "uint256",
185
- "name": "lowerBoundRatio",
186
- "type": "uint256"
187
- }
188
- ],
189
- "stateMutability": "view",
190
- "type": "function"
191
- },
192
- {
193
- "inputs": [
194
- {
195
- "internalType": "address",
196
- "name": "vToken",
197
- "type": "address"
198
- },
199
- {
200
- "internalType": "uint256",
201
- "name": "reporterPrice",
202
- "type": "uint256"
203
- },
204
- {
205
- "internalType": "uint256",
206
- "name": "anchorPrice",
207
- "type": "uint256"
208
- }
209
- ],
210
- "name": "validatePriceWithAnchorPrice",
211
- "outputs": [
212
- {
213
- "internalType": "bool",
214
- "name": "",
215
- "type": "bool"
216
- }
217
- ],
218
- "stateMutability": "view",
219
- "type": "function"
220
- }
221
- ],
222
- "bytecode": "0x608060405234801561001057600080fd5b50610a82806100206000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80639c3576151161005b5780639c357615146100e2578063af9e6c5b146100f5578063bca9e11614610108578063f2fde38b1461016657600080fd5b8063715018a61461008d5780638129fc1c146100975780638da5cb5b1461009f57806397c7033e146100bf575b600080fd5b610095610179565b005b61009561018d565b6033546040516001600160a01b0390911681526020015b60405180910390f35b6100d26100cd3660046107dc565b6102a3565b60405190151581526020016100b6565b6100956100f03660046108b7565b610372565b610095610103366004610967565b610415565b610141610116366004610983565b6065602052600090815260409020805460018201546002909201546001600160a01b03909116919083565b604080516001600160a01b0390941684526020840192909252908201526060016100b6565b610095610174366004610983565b6105b6565b61018161062c565b61018b6000610686565b565b600054610100900460ff16158080156101ad5750600054600160ff909116105b806101c75750303b1580156101c7575060005460ff166001145b61022f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610252576000805461ff0019166101001790555b61025a6106d8565b80156102a0576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6001600160a01b038316600090815260656020526040812060010154810361030d5760405162461bcd60e51b815260206004820152601b60248201527f76616c69646174696f6e20636f6e666967206e6f7420657869737400000000006044820152606401610226565b8160000361035d5760405162461bcd60e51b815260206004820152601960248201527f616e63686f72207072696365206973206e6f742076616c6964000000000000006044820152606401610226565b610368848484610707565b90505b9392505050565b61037a61062c565b60008151116103cb5760405162461bcd60e51b815260206004820152601e60248201527f696e76616c69642076616c696461746520636f6e666967206c656e67746800006044820152606401610226565b60005b81518160ff161015610411576103ff828260ff16815181106103f2576103f261099e565b6020026020010151610415565b80610409816109ca565b9150506103ce565b5050565b61041d61062c565b80516001600160a01b03166104745760405162461bcd60e51b815260206004820152601c60248201527f76546f6b656e2063616e2774206265207a65726f2061646472657373000000006044820152606401610226565b6000816020015111801561048c575060008160400151115b6104d15760405162461bcd60e51b8152602060048201526016602482015275626f756e64206d75737420626520706f73697469766560501b6044820152606401610226565b806040015181602001511161053d5760405162461bcd60e51b815260206004820152602c60248201527f757070657220626f756e64206d75737420626520686967686572207468616e2060448201526b1b1bdddb995c88189bdd5b9960a21b6064820152608401610226565b80516001600160a01b039081166000908152606560209081526040808320855181546001600160a01b03191695169485178155918501516001830181905581860151600290930183905590519193909290917f28e2d96bdcf74fe6203e40d159d27ec2e15230239c0aee4a0a914196c550e6d19190a450565b6105be61062c565b6001600160a01b0381166106235760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610226565b6102a081610686565b6033546001600160a01b0316331461018b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610226565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166106ff5760405162461bcd60e51b8152600401610226906109e9565b61018b610778565b6000821561076e57600061072d8461072785670de0b6b3a76400006107a8565b906107b4565b6001600160a01b03861660009081526065602052604090206001810154600290910154919250908183118015906107645750808310155b935050505061036b565b5060009392505050565b600054610100900460ff1661079f5760405162461bcd60e51b8152600401610226906109e9565b61018b33610686565b600061036b8284610a34565b600061036b8284610a53565b80356001600160a01b03811681146107d757600080fd5b919050565b6000806000606084860312156107f157600080fd5b6107fa846107c0565b95602085013595506040909401359392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561084e5761084e61080f565b604052919050565b60006060828403121561086857600080fd5b6040516060810181811067ffffffffffffffff8211171561088b5761088b61080f565b60405290508061089a836107c0565b815260208301356020820152604083013560408201525092915050565b600060208083850312156108ca57600080fd5b823567ffffffffffffffff808211156108e257600080fd5b818501915085601f8301126108f657600080fd5b8135818111156109085761090861080f565b610916848260051b01610825565b8181528481019250606091820284018501918883111561093557600080fd5b938501935b8285101561095b5761094c8986610856565b8452938401939285019261093a565b50979650505050505050565b60006060828403121561097957600080fd5b61036b8383610856565b60006020828403121561099557600080fd5b61036b826107c0565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff81036109e0576109e06109b4565b60010192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000816000190483118215151615610a4e57610a4e6109b4565b500290565b600082610a7057634e487b7160e01b600052601260045260246000fd5b50049056fea164736f6c634300080d000a",
223
- "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c80639c3576151161005b5780639c357615146100e2578063af9e6c5b146100f5578063bca9e11614610108578063f2fde38b1461016657600080fd5b8063715018a61461008d5780638129fc1c146100975780638da5cb5b1461009f57806397c7033e146100bf575b600080fd5b610095610179565b005b61009561018d565b6033546040516001600160a01b0390911681526020015b60405180910390f35b6100d26100cd3660046107dc565b6102a3565b60405190151581526020016100b6565b6100956100f03660046108b7565b610372565b610095610103366004610967565b610415565b610141610116366004610983565b6065602052600090815260409020805460018201546002909201546001600160a01b03909116919083565b604080516001600160a01b0390941684526020840192909252908201526060016100b6565b610095610174366004610983565b6105b6565b61018161062c565b61018b6000610686565b565b600054610100900460ff16158080156101ad5750600054600160ff909116105b806101c75750303b1580156101c7575060005460ff166001145b61022f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610252576000805461ff0019166101001790555b61025a6106d8565b80156102a0576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6001600160a01b038316600090815260656020526040812060010154810361030d5760405162461bcd60e51b815260206004820152601b60248201527f76616c69646174696f6e20636f6e666967206e6f7420657869737400000000006044820152606401610226565b8160000361035d5760405162461bcd60e51b815260206004820152601960248201527f616e63686f72207072696365206973206e6f742076616c6964000000000000006044820152606401610226565b610368848484610707565b90505b9392505050565b61037a61062c565b60008151116103cb5760405162461bcd60e51b815260206004820152601e60248201527f696e76616c69642076616c696461746520636f6e666967206c656e67746800006044820152606401610226565b60005b81518160ff161015610411576103ff828260ff16815181106103f2576103f261099e565b6020026020010151610415565b80610409816109ca565b9150506103ce565b5050565b61041d61062c565b80516001600160a01b03166104745760405162461bcd60e51b815260206004820152601c60248201527f76546f6b656e2063616e2774206265207a65726f2061646472657373000000006044820152606401610226565b6000816020015111801561048c575060008160400151115b6104d15760405162461bcd60e51b8152602060048201526016602482015275626f756e64206d75737420626520706f73697469766560501b6044820152606401610226565b806040015181602001511161053d5760405162461bcd60e51b815260206004820152602c60248201527f757070657220626f756e64206d75737420626520686967686572207468616e2060448201526b1b1bdddb995c88189bdd5b9960a21b6064820152608401610226565b80516001600160a01b039081166000908152606560209081526040808320855181546001600160a01b03191695169485178155918501516001830181905581860151600290930183905590519193909290917f28e2d96bdcf74fe6203e40d159d27ec2e15230239c0aee4a0a914196c550e6d19190a450565b6105be61062c565b6001600160a01b0381166106235760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610226565b6102a081610686565b6033546001600160a01b0316331461018b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610226565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166106ff5760405162461bcd60e51b8152600401610226906109e9565b61018b610778565b6000821561076e57600061072d8461072785670de0b6b3a76400006107a8565b906107b4565b6001600160a01b03861660009081526065602052604090206001810154600290910154919250908183118015906107645750808310155b935050505061036b565b5060009392505050565b600054610100900460ff1661079f5760405162461bcd60e51b8152600401610226906109e9565b61018b33610686565b600061036b8284610a34565b600061036b8284610a53565b80356001600160a01b03811681146107d757600080fd5b919050565b6000806000606084860312156107f157600080fd5b6107fa846107c0565b95602085013595506040909401359392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561084e5761084e61080f565b604052919050565b60006060828403121561086857600080fd5b6040516060810181811067ffffffffffffffff8211171561088b5761088b61080f565b60405290508061089a836107c0565b815260208301356020820152604083013560408201525092915050565b600060208083850312156108ca57600080fd5b823567ffffffffffffffff808211156108e257600080fd5b818501915085601f8301126108f657600080fd5b8135818111156109085761090861080f565b610916848260051b01610825565b8181528481019250606091820284018501918883111561093557600080fd5b938501935b8285101561095b5761094c8986610856565b8452938401939285019261093a565b50979650505050505050565b60006060828403121561097957600080fd5b61036b8383610856565b60006020828403121561099557600080fd5b61036b826107c0565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff81036109e0576109e06109b4565b60010192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000816000190483118215151615610a4e57610a4e6109b4565b500290565b600082610a7057634e487b7160e01b600052601260045260246000fd5b50049056fea164736f6c634300080d000a",
224
- "linkReferences": {},
225
- "deployedLinkReferences": {}
226
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b22018d758b06a50b7c80c494f08be30.json"
4
- }
@@ -1,133 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "MockPivotOracle",
4
- "sourceName": "contracts/test/MockSimpleOracle.sol",
5
- "abi": [
6
- {
7
- "inputs": [],
8
- "stateMutability": "nonpayable",
9
- "type": "constructor"
10
- },
11
- {
12
- "inputs": [
13
- {
14
- "internalType": "address",
15
- "name": "vToken",
16
- "type": "address"
17
- }
18
- ],
19
- "name": "getUnderlyingPrice",
20
- "outputs": [
21
- {
22
- "internalType": "uint256",
23
- "name": "",
24
- "type": "uint256"
25
- }
26
- ],
27
- "stateMutability": "view",
28
- "type": "function"
29
- },
30
- {
31
- "inputs": [
32
- {
33
- "internalType": "address",
34
- "name": "",
35
- "type": "address"
36
- }
37
- ],
38
- "name": "prices",
39
- "outputs": [
40
- {
41
- "internalType": "uint256",
42
- "name": "",
43
- "type": "uint256"
44
- }
45
- ],
46
- "stateMutability": "view",
47
- "type": "function"
48
- },
49
- {
50
- "inputs": [
51
- {
52
- "internalType": "address",
53
- "name": "vToken",
54
- "type": "address"
55
- },
56
- {
57
- "internalType": "uint256",
58
- "name": "price",
59
- "type": "uint256"
60
- }
61
- ],
62
- "name": "setPrice",
63
- "outputs": [],
64
- "stateMutability": "nonpayable",
65
- "type": "function"
66
- },
67
- {
68
- "inputs": [
69
- {
70
- "internalType": "address",
71
- "name": "vToken",
72
- "type": "address"
73
- },
74
- {
75
- "internalType": "bool",
76
- "name": "pass",
77
- "type": "bool"
78
- }
79
- ],
80
- "name": "setValidateResult",
81
- "outputs": [],
82
- "stateMutability": "nonpayable",
83
- "type": "function"
84
- },
85
- {
86
- "inputs": [
87
- {
88
- "internalType": "address",
89
- "name": "vToken",
90
- "type": "address"
91
- },
92
- {
93
- "internalType": "uint256",
94
- "name": "price",
95
- "type": "uint256"
96
- }
97
- ],
98
- "name": "validatePrice",
99
- "outputs": [
100
- {
101
- "internalType": "bool",
102
- "name": "",
103
- "type": "bool"
104
- }
105
- ],
106
- "stateMutability": "view",
107
- "type": "function"
108
- },
109
- {
110
- "inputs": [
111
- {
112
- "internalType": "address",
113
- "name": "",
114
- "type": "address"
115
- }
116
- ],
117
- "name": "validateResults",
118
- "outputs": [
119
- {
120
- "internalType": "bool",
121
- "name": "",
122
- "type": "bool"
123
- }
124
- ],
125
- "stateMutability": "view",
126
- "type": "function"
127
- }
128
- ],
129
- "bytecode": "0x608060405234801561001057600080fd5b50610238806100206000396000f3fe608060405234801561001057600080fd5b50600436106100615760003560e01c8062e4768b1461006657806379c5e51214610092578063a050bcb3146100cb578063cfed246b14610103578063fc57d4df14610131578063fd45a4331461015a575b600080fd5b6100906100743660046101a3565b6001600160a01b03909116600090815260208190526040902055565b005b6100906100a03660046101cd565b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b6100ee6100d9366004610209565b60016020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b610123610111366004610209565b60006020819052908152604090205481565b6040519081526020016100fa565b61012361013f366004610209565b6001600160a01b031660009081526020819052604090205490565b6100ee6101683660046101a3565b506001600160a01b031660009081526001602052604090205460ff1690565b80356001600160a01b038116811461019e57600080fd5b919050565b600080604083850312156101b657600080fd5b6101bf83610187565b946020939093013593505050565b600080604083850312156101e057600080fd5b6101e983610187565b9150602083013580151581146101fe57600080fd5b809150509250929050565b60006020828403121561021b57600080fd5b61022482610187565b939250505056fea164736f6c634300080d000a",
130
- "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100615760003560e01c8062e4768b1461006657806379c5e51214610092578063a050bcb3146100cb578063cfed246b14610103578063fc57d4df14610131578063fd45a4331461015a575b600080fd5b6100906100743660046101a3565b6001600160a01b03909116600090815260208190526040902055565b005b6100906100a03660046101cd565b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b6100ee6100d9366004610209565b60016020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b610123610111366004610209565b60006020819052908152604090205481565b6040519081526020016100fa565b61012361013f366004610209565b6001600160a01b031660009081526020819052604090205490565b6100ee6101683660046101a3565b506001600160a01b031660009081526001602052604090205460ff1690565b80356001600160a01b038116811461019e57600080fd5b919050565b600080604083850312156101b657600080fd5b6101bf83610187565b946020939093013593505050565b600080604083850312156101e057600080fd5b6101e983610187565b9150602083013580151581146101fe57600080fd5b809150509250929050565b60006020828403121561021b57600080fd5b61022482610187565b939250505056fea164736f6c634300080d000a",
131
- "linkReferences": {},
132
- "deployedLinkReferences": {}
133
- }
@@ -1,220 +0,0 @@
1
- // SPDX-License-Identifier: UNLICENSED
2
- pragma solidity ^0.8.0;
3
- pragma experimental ABIEncoderV2;
4
-
5
- import "@openzeppelin/contracts/utils/math/SafeMath.sol";
6
- import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
7
- import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
8
- import "./interfaces/OracleInterface.sol";
9
-
10
-
11
- contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable {
12
- using SafeMath for uint256;
13
-
14
- uint256 public constant INVALID_PRICE = 0;
15
-
16
- /**
17
- * @dev oracle role, we have 3 roles at the moment
18
- * MAIN: The most trustworthy price source
19
- * PIVOT: Not so trustworthy price source, used as a loose sanity checker
20
- * FALLBACK: The backup source when main oracle price is invalidated
21
- */
22
- enum OracleRole {
23
- MAIN,
24
- PIVOT,
25
- FALLBACK
26
- }
27
-
28
- struct TokenConfig {
29
- /// @notice vToken address
30
- address vToken;
31
- /// @notice `oracles` stores the oracles in the order of: [main, pivot, fallback],
32
- /// it can be indexed with enum OracleRole value
33
- address[3] oracles;
34
- /// @notice `enableFlagsForOracles` stores the oracle enable statuses
35
- /// for each oracle in the same order as `oracles`
36
- bool[3] enableFlagsForOracles;
37
- }
38
-
39
- mapping(address => TokenConfig) private tokenConfigs;
40
-
41
- event GlobalEnable(bool indexed isEnable);
42
- event TokenConfigAdded(
43
- address indexed token,
44
- address indexed mainOracle,
45
- address indexed pivotOracle,
46
- address fallbackOracle
47
- );
48
- event OracleSet(address indexed vToken, address indexed oracle, uint indexed role);
49
- event OracleEnabled(address indexed vToken, uint indexed role, bool indexed enable);
50
-
51
- modifier notNullAddress(address someone) {
52
- require(someone != address(0), "can't be zero address");
53
- _;
54
- }
55
-
56
- /**
57
- * @notice Check whether token config exist by checking whether vToken is zero address
58
- * @dev vToken can't be set to zero, so it's suitable to be used to check
59
- * @param vToken vtoken address
60
- */
61
- modifier checkTokenConfigExistance(address vToken) {
62
- require(tokenConfigs[vToken].vToken != address(0), "token config must exist");
63
- _;
64
- }
65
-
66
- function initialize() public initializer {
67
- __Ownable_init();
68
- __Pausable_init();
69
- }
70
-
71
- /**
72
- * @notice Pause protocol
73
- */
74
- function pause() external onlyOwner() {
75
- _pause();
76
- }
77
-
78
- /**
79
- * @notice Unpause protocol
80
- */
81
- function unpause() external onlyOwner() {
82
- _unpause();
83
- }
84
-
85
- /**
86
- * @dev Get token config by vToken address
87
- * @param vToken vtoken address
88
- */
89
- function getTokenConfig(address vToken) external view returns (TokenConfig memory) {
90
- return tokenConfigs[vToken];
91
- }
92
-
93
- /**
94
- * @notice Get oracle & enabling status by vToken address
95
- * @param vToken vtoken address
96
- * @param role oracle role
97
- */
98
- function getOracle(address vToken, OracleRole role) public view returns (address oracle, bool enabled) {
99
- oracle = tokenConfigs[vToken].oracles[uint(role)];
100
- enabled = tokenConfigs[vToken].enableFlagsForOracles[uint(role)];
101
- }
102
-
103
- /**
104
- * @notice Batch set token configs
105
- * @param tokenConfigs_ token config array
106
- */
107
- function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external onlyOwner() {
108
- require(tokenConfigs_.length != 0, "length can't be 0");
109
- for (uint256 i = 0; i < tokenConfigs_.length; i++) {
110
- setTokenConfig(tokenConfigs_[i]);
111
- }
112
- }
113
-
114
- /**
115
- * @notice Set single token configs, vToken MUST HAVE NOT be added before, and main oracle MUST NOT be zero address
116
- * @param tokenConfig token config struct
117
- */
118
- function setTokenConfig(TokenConfig memory tokenConfig) public
119
- onlyOwner()
120
- notNullAddress(tokenConfig.vToken)
121
- notNullAddress(tokenConfig.oracles[uint(OracleRole.MAIN)])
122
- {
123
- tokenConfigs[tokenConfig.vToken] = tokenConfig;
124
- emit TokenConfigAdded(
125
- tokenConfig.vToken,
126
- tokenConfig.oracles[uint(OracleRole.MAIN)],
127
- tokenConfig.oracles[uint(OracleRole.PIVOT)],
128
- tokenConfig.oracles[uint(OracleRole.FALLBACK)]
129
- );
130
- }
131
-
132
- /**
133
- * @notice Set oracle of any type for the input vToken, input vToken MUST exist
134
- * @param vToken vToken address
135
- * @param oracle oracle address
136
- * @param role oracle role
137
- */
138
- function setOracle(address vToken, address oracle, OracleRole role) external
139
- onlyOwner()
140
- notNullAddress(vToken)
141
- checkTokenConfigExistance(vToken)
142
- {
143
- require(!(oracle == address(0) && role == OracleRole.MAIN), "can't set zero address to main oracle");
144
- tokenConfigs[vToken].oracles[uint(role)] = oracle;
145
- emit OracleSet(vToken, oracle, uint(role));
146
- }
147
-
148
- /**
149
- * @notice Enable/disable oracle for the input vToken, input vToken MUST exist
150
- * @param vToken vToken address
151
- * @param role oracle role
152
- * @param enable expected status
153
- */
154
- function enableOracle(address vToken, OracleRole role, bool enable) external
155
- onlyOwner()
156
- notNullAddress(vToken)
157
- checkTokenConfigExistance(vToken)
158
- {
159
- tokenConfigs[vToken].enableFlagsForOracles[uint(role)] = enable;
160
- emit OracleEnabled(vToken, uint(role), enable);
161
- }
162
-
163
- /**
164
- * @notice Get price of underlying asset of the input vToken, check flow:
165
- * - check the global pausing status
166
- * - check price from main oracle
167
- * - check price against pivot oracle, if any
168
- * - if fallback flag is enabled and price is invalidated, fallback
169
- * @param vToken vToken address
170
- * @return price USD price in 18 decimals
171
- */
172
- function getUnderlyingPrice(address vToken) external view returns (uint256) {
173
- uint256 price = _getUnderlyingPriceInternal(vToken);
174
- (address fallbackOracle, bool fallbackEnabled) = getOracle(vToken, OracleRole.FALLBACK);
175
- if (price == INVALID_PRICE && fallbackEnabled && fallbackOracle != address(0)) {
176
- uint256 fallbackPrice = OracleInterface(fallbackOracle).getUnderlyingPrice(vToken);
177
- require(fallbackPrice != INVALID_PRICE, "fallback oracle price must be positive");
178
- return fallbackPrice;
179
- }
180
- // if price is 0 here, it means main oracle price is 0 or got invalidated by pivot oracle
181
- // and fallback oracle is not active, we revert it
182
- require(price != INVALID_PRICE, "invalid resilient oracle price");
183
- return price;
184
- }
185
-
186
- /**
187
- * @notice This function won't revert when price is 0, because the fallback oracle may come to play later
188
- * @param vToken vToken address
189
- * @return price USD price in 18 decimals
190
- */
191
- function _getUnderlyingPriceInternal(address vToken) internal view returns (uint256) {
192
- // Global emergency switch
193
- require(!paused(), "resilient oracle is paused");
194
-
195
- (address mainOracle, bool mainOracleEnabled) = getOracle(vToken, OracleRole.MAIN);
196
-
197
- uint price = INVALID_PRICE;
198
-
199
- if (!mainOracleEnabled) {
200
- return price;
201
- }
202
-
203
- price = OracleInterface(mainOracle).getUnderlyingPrice(vToken);
204
-
205
- (address pivotOracle, bool pivotOracleEnabled) = getOracle(vToken, OracleRole.PIVOT);
206
-
207
- // Price oracle is not mandantory
208
- if (pivotOracle == address(0) || !pivotOracleEnabled) {
209
- return price;
210
- }
211
-
212
- // Check the price with pivot oracle
213
- bool pass = PivotOracleInterface(pivotOracle).validatePrice(vToken, price);
214
- if (!pass) {
215
- return INVALID_PRICE;
216
- }
217
-
218
- return price;
219
- }
220
- }
@@ -1,60 +0,0 @@
1
- // SPDX-License-Identifier: UNLICENSED
2
- pragma solidity ^0.8.0;
3
-
4
- /**
5
- * @title The V2 & V3 Aggregator Interface
6
- * @notice Solidity V0.5 does not allow interfaces to inherit from other
7
- * interfaces so this contract is a combination of v0.5 AggregatorInterface.sol
8
- * and v0.5 AggregatorV3Interface.sol.
9
- */
10
- interface AggregatorV2V3Interface {
11
- //
12
- // V2 Interface:
13
- //
14
- function latestAnswer() external view returns (int256);
15
-
16
- function latestTimestamp() external view returns (uint256);
17
-
18
- function latestRound() external view returns (uint256);
19
-
20
- function getAnswer(uint256 roundId) external view returns (int256);
21
-
22
- function getTimestamp(uint256 roundId) external view returns (uint256);
23
-
24
- event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
25
- event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
26
-
27
- //
28
- // V3 Interface:
29
- //
30
- function decimals() external view returns (uint8);
31
-
32
- function description() external view returns (string memory);
33
-
34
- function version() external view returns (uint256);
35
-
36
- // getRoundData and latestRoundData should both raise "No data present"
37
- // if they do not have data to report, instead of returning unset values
38
- // which could be misinterpreted as actual reported values.
39
- function getRoundData(uint80 _roundId)
40
- external
41
- view
42
- returns (
43
- uint80 roundId,
44
- int256 answer,
45
- uint256 startedAt,
46
- uint256 updatedAt,
47
- uint80 answeredInRound
48
- );
49
-
50
- function latestRoundData()
51
- external
52
- view
53
- returns (
54
- uint80 roundId,
55
- int256 answer,
56
- uint256 startedAt,
57
- uint256 updatedAt,
58
- uint80 answeredInRound
59
- );
60
- }