@venusprotocol/oracle 1.6.12-dev.2 → 1.6.12-dev.4
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.
- package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol/AggregatorInterface.dbg.json +1 -1
- package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol/AggregatorV2V3Interface.dbg.json +1 -1
- package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol/AggregatorV3Interface.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol/AccessControlManager.dbg.json +1 -1
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +1 -1
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +1 -1
- package/artifacts/build-info/{fc01a49cbd804e304740a46d676189d0.json → e6185827013b85f715ee874203b21fc8.json} +1 -1
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +1 -1
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json +36 -4
- package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.json +10 -10
- package/artifacts/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/OracleInterface.sol/OracleInterface.json +2 -2
- package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +19 -0
- package/artifacts/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/OracleInterface.sol/TwapInterface.json +2 -2
- package/artifacts/contracts/interfaces/PublicResolverInterface.sol/PublicResolverInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/PythInterface.sol/AbstractPyth.dbg.json +1 -1
- package/artifacts/contracts/interfaces/PythInterface.sol/IPyth.dbg.json +1 -1
- package/artifacts/contracts/interfaces/PythInterface.sol/PythStructs.dbg.json +1 -1
- package/artifacts/contracts/interfaces/SIDRegistryInterface.sol/SIDRegistryInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/VBep20Interface.sol/VBep20Interface.dbg.json +1 -1
- package/artifacts/contracts/libraries/PancakeLibrary.sol/FixedPoint.dbg.json +1 -1
- package/artifacts/contracts/libraries/PancakeLibrary.sol/IPancakePair.dbg.json +1 -1
- package/artifacts/contracts/libraries/PancakeLibrary.sol/PancakeOracleLibrary.dbg.json +1 -1
- package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.json +49 -42
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.dbg.json +1 -1
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.json +4 -54
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.json +5 -60
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.json +6 -43
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.json +18 -41
- package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.json +16 -16
- package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.json +2 -2
- package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.json +2 -2
- package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.dbg.json +1 -1
- package/artifacts/contracts/test/AccessControlManager.sol/AccessControlManagerScenario.dbg.json +1 -1
- package/artifacts/contracts/test/BEP20Harness.sol/BEP20Harness.dbg.json +1 -1
- package/artifacts/contracts/test/MockPyth.sol/MockPyth.dbg.json +1 -1
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.dbg.json +1 -1
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.json +32 -3
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.dbg.json +1 -1
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.json +21 -2
- package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.dbg.json +1 -1
- package/artifacts/contracts/test/PancakePairHarness.sol/Math.dbg.json +1 -1
- package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.dbg.json +1 -1
- package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.dbg.json +1 -1
- package/artifacts/contracts/test/VBEP20Harness.sol/VBEP20Harness.dbg.json +1 -1
- package/contracts/ResilientOracle.sol +100 -70
- package/contracts/interfaces/FeedRegistryInterface.sol +4 -4
- package/contracts/interfaces/OracleInterface.sol +3 -1
- package/contracts/oracles/BinanceOracle.sol +53 -61
- package/contracts/oracles/BoundValidator.sol +22 -51
- package/contracts/oracles/ChainlinkOracle.sol +25 -65
- package/contracts/oracles/PythOracle.sol +28 -48
- package/contracts/oracles/TwapOracle.sol +39 -57
- package/contracts/oracles/mocks/MockBinanceFeedRegistry.sol +6 -6
- package/contracts/test/MockSimpleOracle.sol +14 -2
- package/dist/deploy/1-deploy-oracles.js +6 -6
- package/dist/deploy/1-deploy-oracles.js.map +1 -1
- package/package.json +2 -2
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
"type": "function"
|
|
138
138
|
}
|
|
139
139
|
],
|
|
140
|
-
"bytecode": "
|
|
141
|
-
"deployedBytecode": "
|
|
140
|
+
"bytecode": "0x608060405234801561001057600080fd5b5061064c806100206000396000f3fe608060405234801561001057600080fd5b506004361061007c5760003560e01c80638129fc1c1161005b5780638129fc1c146100eb5780638da5cb5b146100f3578063f2fde38b1461010c578063fc57d4df1461011f57600080fd5b8062e4768b146100815780635e9a523c146100ad578063715018a6146100e3575b600080fd5b6100ab61008f3660046103f2565b6001600160a01b03909116600090815260656020526040902055565b005b6100cd6100bb36600461042f565b60656020526000908152604090205481565b6040516100da9190610460565b60405180910390f35b6100ab610132565b6100ab610146565b6033546001600160a01b03166040516100da9190610477565b6100ab61011a36600461042f565b61021e565b6100cd61012d36600461042f565b610255565b61013a6102d9565b6101446000610303565b565b600054610100900460ff16158080156101665750600054600160ff909116105b806101805750303b158015610180575060005460ff166001145b6101a55760405162461bcd60e51b815260040161019c906104d3565b60405180910390fd5b6000805460ff1916600117905580156101c8576000805461ff0019166101001790555b6101d0610355565b801561021b576000805461ff00191690556040517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890610212906001906104f7565b60405180910390a15b50565b6102266102d9565b6001600160a01b03811661024c5760405162461bcd60e51b815260040161019c90610548565b61021b81610303565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610296573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ba9190610563565b6001600160a01b03166000908152606560205260409020549392505050565b6033546001600160a01b031633146101445760405162461bcd60e51b815260040161019c90610584565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661037c5760405162461bcd60e51b815260040161019c90610606565b610144600054610100900460ff166103a65760405162461bcd60e51b815260040161019c90610606565b61014433610303565b60006001600160a01b0382165b92915050565b6103cb816103af565b811461021b57600080fd5b80356103bc816103c2565b806103cb565b80356103bc816103e1565b6000806040838503121561040857610408600080fd5b600061041485856103d6565b9250506020610425858286016103e7565b9150509250929050565b60006020828403121561044457610444600080fd5b600061045084846103d6565b949350505050565b805b82525050565b602081016103bc8284610458565b61045a816103af565b602081016103bc828461046e565b602e81526000602082017f496e697469616c697a61626c653a20636f6e747261637420697320616c72656181526d191e481a5b9a5d1a585b1a5e995960921b602082015291505b5060400190565b602080825281016103bc81610485565b600060ff82166103bc565b61045a816104e3565b602081016103bc82846104ee565b602681526000602082017f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b602082015291506104cc565b602080825281016103bc81610505565b80516103bc816103c2565b60006020828403121561057857610578600080fd5b60006104508484610558565b60208082528181019081527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726040830152606082016103bc565b602b81526000602082017f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206981526a6e697469616c697a696e6760a81b602082015291506104cc565b602080825281016103bc816105be56fea2646970667358221220a2b6bb3475321b0cec42ebbd8115720c002ca210cfadffe400fadb57f3bd3f2764736f6c634300080d0033",
|
|
141
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007c5760003560e01c80638129fc1c1161005b5780638129fc1c146100eb5780638da5cb5b146100f3578063f2fde38b1461010c578063fc57d4df1461011f57600080fd5b8062e4768b146100815780635e9a523c146100ad578063715018a6146100e3575b600080fd5b6100ab61008f3660046103f2565b6001600160a01b03909116600090815260656020526040902055565b005b6100cd6100bb36600461042f565b60656020526000908152604090205481565b6040516100da9190610460565b60405180910390f35b6100ab610132565b6100ab610146565b6033546001600160a01b03166040516100da9190610477565b6100ab61011a36600461042f565b61021e565b6100cd61012d36600461042f565b610255565b61013a6102d9565b6101446000610303565b565b600054610100900460ff16158080156101665750600054600160ff909116105b806101805750303b158015610180575060005460ff166001145b6101a55760405162461bcd60e51b815260040161019c906104d3565b60405180910390fd5b6000805460ff1916600117905580156101c8576000805461ff0019166101001790555b6101d0610355565b801561021b576000805461ff00191690556040517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890610212906001906104f7565b60405180910390a15b50565b6102266102d9565b6001600160a01b03811661024c5760405162461bcd60e51b815260040161019c90610548565b61021b81610303565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610296573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ba9190610563565b6001600160a01b03166000908152606560205260409020549392505050565b6033546001600160a01b031633146101445760405162461bcd60e51b815260040161019c90610584565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661037c5760405162461bcd60e51b815260040161019c90610606565b610144600054610100900460ff166103a65760405162461bcd60e51b815260040161019c90610606565b61014433610303565b60006001600160a01b0382165b92915050565b6103cb816103af565b811461021b57600080fd5b80356103bc816103c2565b806103cb565b80356103bc816103e1565b6000806040838503121561040857610408600080fd5b600061041485856103d6565b9250506020610425858286016103e7565b9150509250929050565b60006020828403121561044457610444600080fd5b600061045084846103d6565b949350505050565b805b82525050565b602081016103bc8284610458565b61045a816103af565b602081016103bc828461046e565b602e81526000602082017f496e697469616c697a61626c653a20636f6e747261637420697320616c72656181526d191e481a5b9a5d1a585b1a5e995960921b602082015291505b5060400190565b602080825281016103bc81610485565b600060ff82166103bc565b61045a816104e3565b602081016103bc82846104ee565b602681526000602082017f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b602082015291506104cc565b602080825281016103bc81610505565b80516103bc816103c2565b60006020828403121561057857610578600080fd5b60006104508484610558565b60208082528181019081527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726040830152606082016103bc565b602b81526000602082017f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206981526a6e697469616c697a696e6760a81b602082015291506104cc565b602080825281016103bc816105be56fea2646970667358221220a2b6bb3475321b0cec42ebbd8115720c002ca210cfadffe400fadb57f3bd3f2764736f6c634300080d0033",
|
|
142
142
|
"linkReferences": {},
|
|
143
143
|
"deployedLinkReferences": {}
|
|
144
144
|
}
|
|
@@ -156,8 +156,8 @@
|
|
|
156
156
|
"type": "function"
|
|
157
157
|
}
|
|
158
158
|
],
|
|
159
|
-
"bytecode": "
|
|
160
|
-
"deployedBytecode": "
|
|
159
|
+
"bytecode": "0x608060405234801561001057600080fd5b50610758806100206000396000f3fe608060405234801561001057600080fd5b50600436106100875760003560e01c80638da5cb5b1161005b5780638da5cb5b14610116578063c4d66de81461012f578063f2fde38b14610142578063fc57d4df1461015557600080fd5b8062e4768b1461008c57806356fa5a56146100b85780635e9a523c146100e1578063715018a61461010e575b600080fd5b6100b661009a36600461046d565b6001600160a01b03909116600090815260656020526040902055565b005b6066546100cb906001600160a01b031681565b6040516100d891906104e0565b60405180910390f35b6101016100ef3660046104ee565b60656020526000908152604090205481565b6040516100d8919061051d565b6100b6610168565b6033546001600160a01b03166040516100d89190610534565b6100b661013d3660046104ee565b61017c565b6100b66101503660046104ee565b610296565b6101016101633660046104ee565b6102d0565b610170610354565b61017a600061037e565b565b600054610100900460ff161580801561019c5750600054600160ff909116105b806101b65750303b1580156101b6575060005460ff166001145b6101db5760405162461bcd60e51b81526004016101d290610590565b60405180910390fd5b6000805460ff1916600117905580156101fe576000805461ff0019166101001790555b6102066103d0565b6001600160a01b03821661022c5760405162461bcd60e51b81526004016101d2906105df565b606680546001600160a01b0319166001600160a01b0384161790558015610292576000805461ff00191690556040517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989061028990600190610603565b60405180910390a15b5050565b61029e610354565b6001600160a01b0381166102c45760405162461bcd60e51b81526004016101d290610654565b6102cd8161037e565b50565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610311573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610335919061066f565b6001600160a01b03166000908152606560205260409020549392505050565b6033546001600160a01b0316331461017a5760405162461bcd60e51b81526004016101d290610690565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166103f75760405162461bcd60e51b81526004016101d290610712565b61017a600054610100900460ff166104215760405162461bcd60e51b81526004016101d290610712565b61017a3361037e565b60006001600160a01b0382165b92915050565b6104468161042a565b81146102cd57600080fd5b80356104378161043d565b80610446565b80356104378161045c565b6000806040838503121561048357610483600080fd5b600061048f8585610451565b92505060206104a085828601610462565b9150509250929050565b60006001600160a01b038216610437565b6000610437826104aa565b6000610437826104bb565b6104da816104c6565b82525050565b6020810161043782846104d1565b60006020828403121561050357610503600080fd5b600061050f8484610451565b949350505050565b806104da565b602081016104378284610517565b6104da8161042a565b60208101610437828461052b565b602e81526000602082017f496e697469616c697a61626c653a20636f6e747261637420697320616c72656181526d191e481a5b9a5d1a585b1a5e995960921b602082015291505b5060400190565b6020808252810161043781610542565b602281526000602082017f70797468206f7261636c652063616e6e6f74206265207a65726f206164647265815261737360f01b60208201529150610589565b60208082528101610437816105a0565b600060ff8216610437565b6104da816105ef565b6020810161043782846105fa565b602681526000602082017f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b60208201529150610589565b6020808252810161043781610611565b80516104378161043d565b60006020828403121561068457610684600080fd5b600061050f8484610664565b60208082528181019081527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604083015260608201610437565b602b81526000602082017f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206981526a6e697469616c697a696e6760a81b60208201529150610589565b60208082528101610437816106ca56fea264697066735822122034cc05da4376bf87f477375a7344a418c6791e13535cf516963fa5a24e88c28d64736f6c634300080d0033",
|
|
160
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100875760003560e01c80638da5cb5b1161005b5780638da5cb5b14610116578063c4d66de81461012f578063f2fde38b14610142578063fc57d4df1461015557600080fd5b8062e4768b1461008c57806356fa5a56146100b85780635e9a523c146100e1578063715018a61461010e575b600080fd5b6100b661009a36600461046d565b6001600160a01b03909116600090815260656020526040902055565b005b6066546100cb906001600160a01b031681565b6040516100d891906104e0565b60405180910390f35b6101016100ef3660046104ee565b60656020526000908152604090205481565b6040516100d8919061051d565b6100b6610168565b6033546001600160a01b03166040516100d89190610534565b6100b661013d3660046104ee565b61017c565b6100b66101503660046104ee565b610296565b6101016101633660046104ee565b6102d0565b610170610354565b61017a600061037e565b565b600054610100900460ff161580801561019c5750600054600160ff909116105b806101b65750303b1580156101b6575060005460ff166001145b6101db5760405162461bcd60e51b81526004016101d290610590565b60405180910390fd5b6000805460ff1916600117905580156101fe576000805461ff0019166101001790555b6102066103d0565b6001600160a01b03821661022c5760405162461bcd60e51b81526004016101d2906105df565b606680546001600160a01b0319166001600160a01b0384161790558015610292576000805461ff00191690556040517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989061028990600190610603565b60405180910390a15b5050565b61029e610354565b6001600160a01b0381166102c45760405162461bcd60e51b81526004016101d290610654565b6102cd8161037e565b50565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610311573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610335919061066f565b6001600160a01b03166000908152606560205260409020549392505050565b6033546001600160a01b0316331461017a5760405162461bcd60e51b81526004016101d290610690565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166103f75760405162461bcd60e51b81526004016101d290610712565b61017a600054610100900460ff166104215760405162461bcd60e51b81526004016101d290610712565b61017a3361037e565b60006001600160a01b0382165b92915050565b6104468161042a565b81146102cd57600080fd5b80356104378161043d565b80610446565b80356104378161045c565b6000806040838503121561048357610483600080fd5b600061048f8585610451565b92505060206104a085828601610462565b9150509250929050565b60006001600160a01b038216610437565b6000610437826104aa565b6000610437826104bb565b6104da816104c6565b82525050565b6020810161043782846104d1565b60006020828403121561050357610503600080fd5b600061050f8484610451565b949350505050565b806104da565b602081016104378284610517565b6104da8161042a565b60208101610437828461052b565b602e81526000602082017f496e697469616c697a61626c653a20636f6e747261637420697320616c72656181526d191e481a5b9a5d1a585b1a5e995960921b602082015291505b5060400190565b6020808252810161043781610542565b602281526000602082017f70797468206f7261636c652063616e6e6f74206265207a65726f206164647265815261737360f01b60208201529150610589565b60208082528101610437816105a0565b600060ff8216610437565b6104da816105ef565b6020810161043782846105fa565b602681526000602082017f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b60208201529150610589565b6020808252810161043781610611565b80516104378161043d565b60006020828403121561068457610684600080fd5b600061050f8484610664565b60208082528181019081527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604083015260608201610437565b602b81526000602082017f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206981526a6e697469616c697a696e6760a81b60208201529150610589565b60208082528101610437816106ca56fea264697066735822122034cc05da4376bf87f477375a7344a418c6791e13535cf516963fa5a24e88c28d64736f6c634300080d0033",
|
|
161
161
|
"linkReferences": {},
|
|
162
162
|
"deployedLinkReferences": {}
|
|
163
163
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"inputs": [
|
|
13
13
|
{
|
|
14
14
|
"internalType": "address",
|
|
15
|
-
"name": "
|
|
15
|
+
"name": "token",
|
|
16
16
|
"type": "address"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
@@ -39,6 +39,35 @@
|
|
|
39
39
|
"stateMutability": "view",
|
|
40
40
|
"type": "function"
|
|
41
41
|
},
|
|
42
|
+
{
|
|
43
|
+
"inputs": [
|
|
44
|
+
{
|
|
45
|
+
"internalType": "address",
|
|
46
|
+
"name": "asset",
|
|
47
|
+
"type": "address"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"internalType": "uint256",
|
|
51
|
+
"name": "reporterPrice",
|
|
52
|
+
"type": "uint256"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"internalType": "uint256",
|
|
56
|
+
"name": "anchorPrice",
|
|
57
|
+
"type": "uint256"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"name": "validateAssetPriceWithAnchorPrice",
|
|
61
|
+
"outputs": [
|
|
62
|
+
{
|
|
63
|
+
"internalType": "bool",
|
|
64
|
+
"name": "",
|
|
65
|
+
"type": "bool"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"stateMutability": "view",
|
|
69
|
+
"type": "function"
|
|
70
|
+
},
|
|
42
71
|
{
|
|
43
72
|
"inputs": [
|
|
44
73
|
{
|
|
@@ -88,8 +117,8 @@
|
|
|
88
117
|
"type": "function"
|
|
89
118
|
}
|
|
90
119
|
],
|
|
91
|
-
"bytecode": "
|
|
92
|
-
"deployedBytecode": "
|
|
120
|
+
"bytecode": "0x608060405234801561001057600080fd5b5061025e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806328d0ef671461005c57806379c5e512146100a05780638146bf7f146100db57806397c7033e1461005c578063a050bcb3146100e8575b600080fd5b61008a61006a366004610151565b50506001600160a01b031660009081526020819052604090205460ff1690565b60405161009791906101a1565b60405180910390f35b6100d96100ae3660046101c2565b6001600160a01b03919091166000908152602081905260409020805460ff1916911515919091179055565b005b60015461008a9060ff1681565b61008a6100f63660046101ff565b60006020819052908152604090205460ff1681565b60006001600160a01b0382165b92915050565b6101278161010b565b811461013257600080fd5b50565b80356101188161011e565b80610127565b803561011881610140565b60008060006060848603121561016957610169600080fd5b60006101758686610135565b935050602061018686828701610146565b925050604061019786828701610146565b9150509250925092565b811515815260208101610118565b801515610127565b8035610118816101af565b600080604083850312156101d8576101d8600080fd5b60006101e48585610135565b92505060206101f5858286016101b7565b9150509250929050565b60006020828403121561021457610214600080fd5b60006102208484610135565b94935050505056fea2646970667358221220eb324a5f7de5fac855ef5ac3cfaf6bd5d789514c7e369d027e48f6088f4dbeff64736f6c634300080d0033",
|
|
121
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c806328d0ef671461005c57806379c5e512146100a05780638146bf7f146100db57806397c7033e1461005c578063a050bcb3146100e8575b600080fd5b61008a61006a366004610151565b50506001600160a01b031660009081526020819052604090205460ff1690565b60405161009791906101a1565b60405180910390f35b6100d96100ae3660046101c2565b6001600160a01b03919091166000908152602081905260409020805460ff1916911515919091179055565b005b60015461008a9060ff1681565b61008a6100f63660046101ff565b60006020819052908152604090205460ff1681565b60006001600160a01b0382165b92915050565b6101278161010b565b811461013257600080fd5b50565b80356101188161011e565b80610127565b803561011881610140565b60008060006060848603121561016957610169600080fd5b60006101758686610135565b935050602061018686828701610146565b925050604061019786828701610146565b9150509250925092565b811515815260208101610118565b801515610127565b8035610118816101af565b600080604083850312156101d8576101d8600080fd5b60006101e48585610135565b92505060206101f5858286016101b7565b9150509250929050565b60006020828403121561021457610214600080fd5b60006102208484610135565b94935050505056fea2646970667358221220eb324a5f7de5fac855ef5ac3cfaf6bd5d789514c7e369d027e48f6088f4dbeff64736f6c634300080d0033",
|
|
93
122
|
"linkReferences": {},
|
|
94
123
|
"deployedLinkReferences": {}
|
|
95
124
|
}
|
|
@@ -8,6 +8,25 @@
|
|
|
8
8
|
"stateMutability": "nonpayable",
|
|
9
9
|
"type": "constructor"
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
"inputs": [
|
|
13
|
+
{
|
|
14
|
+
"internalType": "address",
|
|
15
|
+
"name": "asset",
|
|
16
|
+
"type": "address"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"name": "getPrice",
|
|
20
|
+
"outputs": [
|
|
21
|
+
{
|
|
22
|
+
"internalType": "uint256",
|
|
23
|
+
"name": "",
|
|
24
|
+
"type": "uint256"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"stateMutability": "view",
|
|
28
|
+
"type": "function"
|
|
29
|
+
},
|
|
11
30
|
{
|
|
12
31
|
"inputs": [
|
|
13
32
|
{
|
|
@@ -65,8 +84,8 @@
|
|
|
65
84
|
"type": "function"
|
|
66
85
|
}
|
|
67
86
|
],
|
|
68
|
-
"bytecode": "
|
|
69
|
-
"deployedBytecode": "
|
|
87
|
+
"bytecode": "0x608060405234801561001057600080fd5b506101c9806100206000396000f3fe608060405234801561001057600080fd5b506004361061004b5760003560e01c8062e4768b1461005057806341976e091461007c578063cfed246b146100bb578063fc57d4df1461007c575b600080fd5b61007a61005e366004610121565b6001600160a01b03909116600090815260208190526040902055565b005b6100a561008a36600461015e565b6001600160a01b031660009081526020819052604090205490565b6040516100b29190610187565b60405180910390f35b6100a56100c936600461015e565b60006020819052908152604090205481565b60006001600160a01b0382165b92915050565b6100f7816100db565b811461010257600080fd5b50565b80356100e8816100ee565b806100f7565b80356100e881610110565b6000806040838503121561013757610137600080fd5b60006101438585610105565b925050602061015485828601610116565b9150509250929050565b60006020828403121561017357610173600080fd5b600061017f8484610105565b949350505050565b818152602081016100e856fea2646970667358221220d9ff4fcce9cdcb7d0ebd9e889def8385cc4cc5bc93ced5bec82592b0eb9eb7dc64736f6c634300080d0033",
|
|
88
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004b5760003560e01c8062e4768b1461005057806341976e091461007c578063cfed246b146100bb578063fc57d4df1461007c575b600080fd5b61007a61005e366004610121565b6001600160a01b03909116600090815260208190526040902055565b005b6100a561008a36600461015e565b6001600160a01b031660009081526020819052604090205490565b6040516100b29190610187565b60405180910390f35b6100a56100c936600461015e565b60006020819052908152604090205481565b60006001600160a01b0382165b92915050565b6100f7816100db565b811461010257600080fd5b50565b80356100e8816100ee565b806100f7565b80356100e881610110565b6000806040838503121561013757610137600080fd5b60006101438585610105565b925050602061015485828601610116565b9150509250929050565b60006020828403121561017357610173600080fd5b600061017f8484610105565b949350505050565b818152602081016100e856fea2646970667358221220d9ff4fcce9cdcb7d0ebd9e889def8385cc4cc5bc93ced5bec82592b0eb9eb7dc64736f6c634300080d0033",
|
|
70
89
|
"linkReferences": {},
|
|
71
90
|
"deployedLinkReferences": {}
|
|
72
91
|
}
|
|
@@ -20,9 +20,9 @@ import "@venusprotocol/governance-contracts/contracts/Governance/AccessControlle
|
|
|
20
20
|
* the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle
|
|
21
21
|
* and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.
|
|
22
22
|
*
|
|
23
|
-
* For every market (vToken) we configure the main, pivot and fallback oracles. The
|
|
24
|
-
*
|
|
25
|
-
* is used as a backup price source.
|
|
23
|
+
* For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per
|
|
24
|
+
* vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot
|
|
25
|
+
* oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source.
|
|
26
26
|
*
|
|
27
27
|
* To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every
|
|
28
28
|
* market. The upper bound ratio represents the deviation between reported price (the price that’s being
|
|
@@ -109,8 +109,8 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* @notice Checks whether token config exists by checking whether
|
|
113
|
-
* @dev
|
|
112
|
+
* @notice Checks whether token config exists by checking whether asset is null address
|
|
113
|
+
* @dev address can't be null, so it's suitable to be used to check the validity of the config
|
|
114
114
|
* @param asset asset address
|
|
115
115
|
*/
|
|
116
116
|
modifier checkTokenConfigExistence(address asset) {
|
|
@@ -180,8 +180,8 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
* @notice Sets oracle for a given
|
|
184
|
-
* @dev Supplied
|
|
183
|
+
* @notice Sets oracle for a given asset and role.
|
|
184
|
+
* @dev Supplied asset **must** exist and main oracle may not be null
|
|
185
185
|
* @param asset Asset address
|
|
186
186
|
* @param oracle Oracle address
|
|
187
187
|
* @param role Oracle role
|
|
@@ -203,7 +203,8 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
|
-
* @notice Enables/ disables oracle for the input
|
|
206
|
+
* @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist
|
|
207
|
+
* @dev Configuration for the asset **must** already exist and the asset cannot be 0 address
|
|
207
208
|
* @param asset Asset address
|
|
208
209
|
* @param role Oracle role
|
|
209
210
|
* @param enable Enabled boolean of the oracle
|
|
@@ -227,20 +228,33 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
227
228
|
* @param vToken vToken address
|
|
228
229
|
*/
|
|
229
230
|
function updatePrice(address vToken) external override {
|
|
230
|
-
|
|
231
|
+
address asset = _getUnderlyingAsset(vToken);
|
|
232
|
+
(address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);
|
|
231
233
|
if (pivotOracle != address(0) && pivotOracleEnabled) {
|
|
232
234
|
//if pivot oracle is not TwapOracle it will revert so we need to catch the revert
|
|
233
|
-
try TwapInterface(pivotOracle).updateTwap(
|
|
235
|
+
try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}
|
|
234
236
|
}
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
/**
|
|
238
|
-
* @
|
|
239
|
-
* @
|
|
240
|
-
* @
|
|
240
|
+
* @notice Updates the pivot oracle price. Currently using TWAP
|
|
241
|
+
* @dev This function should always be called before calling getPrice
|
|
242
|
+
* @param asset asset address
|
|
241
243
|
*/
|
|
242
|
-
function
|
|
243
|
-
address
|
|
244
|
+
function updateAssetPrice(address asset) external {
|
|
245
|
+
(address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);
|
|
246
|
+
if (pivotOracle != address(0) && pivotOracleEnabled) {
|
|
247
|
+
//if pivot oracle is not TwapOracle it will revert so we need to catch the revert
|
|
248
|
+
try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @dev Gets token config by asset address
|
|
254
|
+
* @param asset asset address
|
|
255
|
+
* @return tokenConfig Config for the asset
|
|
256
|
+
*/
|
|
257
|
+
function getTokenConfig(address asset) external view returns (TokenConfig memory) {
|
|
244
258
|
return tokenConfigs[asset];
|
|
245
259
|
}
|
|
246
260
|
|
|
@@ -259,41 +273,21 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
259
273
|
*/
|
|
260
274
|
function getUnderlyingPrice(address vToken) external view override returns (uint256) {
|
|
261
275
|
if (paused()) revert("resilient oracle is paused");
|
|
262
|
-
uint256 pivotPrice = INVALID_PRICE;
|
|
263
276
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
try OracleInterface(pivotOracle).getUnderlyingPrice(vToken) returns (uint256 pricePivot) {
|
|
268
|
-
pivotPrice = pricePivot;
|
|
269
|
-
} catch {}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Compare main price and pivot price, return main price and if validation was successful
|
|
273
|
-
// note: In case pivot oracle is not available but main price is available and
|
|
274
|
-
// validation is successful, the main oracle price is returned.
|
|
275
|
-
(uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(
|
|
276
|
-
vToken,
|
|
277
|
-
pivotPrice,
|
|
278
|
-
pivotOracleEnabled && pivotOracle != address(0)
|
|
279
|
-
);
|
|
280
|
-
if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;
|
|
281
|
-
|
|
282
|
-
// Compare fallback and pivot if main oracle comparision fails with pivot
|
|
283
|
-
// Return fallback price when fallback price is validated successfully with pivot oracle
|
|
284
|
-
(uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(vToken, pivotPrice);
|
|
285
|
-
if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;
|
|
286
|
-
|
|
287
|
-
// Lastly compare main price and fallback price
|
|
288
|
-
if (
|
|
289
|
-
mainPrice != INVALID_PRICE &&
|
|
290
|
-
fallbackPrice != INVALID_PRICE &&
|
|
291
|
-
boundValidator.validatePriceWithAnchorPrice(vToken, mainPrice, fallbackPrice)
|
|
292
|
-
) {
|
|
293
|
-
return mainPrice;
|
|
294
|
-
}
|
|
277
|
+
address asset = _getUnderlyingAsset(vToken);
|
|
278
|
+
return _getPrice(asset);
|
|
279
|
+
}
|
|
295
280
|
|
|
296
|
-
|
|
281
|
+
/**
|
|
282
|
+
* @notice Gets price of the asset
|
|
283
|
+
* @param asset asset address
|
|
284
|
+
* @return price USD price in scaled decimal places.
|
|
285
|
+
* @custom:error Paused error is thrown when resilent oracle is paused
|
|
286
|
+
* @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid
|
|
287
|
+
*/
|
|
288
|
+
function getPrice(address asset) external view override returns (uint256) {
|
|
289
|
+
if (paused()) revert("resilient oracle is paused");
|
|
290
|
+
return _getPrice(asset);
|
|
297
291
|
}
|
|
298
292
|
|
|
299
293
|
/**
|
|
@@ -303,7 +297,7 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
303
297
|
* @custom:access Only Governance
|
|
304
298
|
* @custom:error NotNullAddress is thrown if asset address is null
|
|
305
299
|
* @custom:error NotNullAddress is thrown if main-role oracle address for asset is null
|
|
306
|
-
* @custom:event Emits TokenConfigAdded event when
|
|
300
|
+
* @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account
|
|
307
301
|
*/
|
|
308
302
|
function setTokenConfig(
|
|
309
303
|
TokenConfig memory tokenConfig
|
|
@@ -320,42 +314,78 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
320
314
|
}
|
|
321
315
|
|
|
322
316
|
/**
|
|
323
|
-
* @notice Gets oracle and enabled status by
|
|
324
|
-
* @param
|
|
317
|
+
* @notice Gets oracle and enabled status by asset address
|
|
318
|
+
* @param asset asset address
|
|
325
319
|
* @param role Oracle role
|
|
326
320
|
* @return oracle Oracle address based on role
|
|
327
321
|
* @return enabled Enabled flag of the oracle based on token config
|
|
328
322
|
*/
|
|
329
|
-
function getOracle(address
|
|
330
|
-
address asset = _getUnderlyingAsset(vToken);
|
|
331
|
-
|
|
323
|
+
function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {
|
|
332
324
|
oracle = tokenConfigs[asset].oracles[uint256(role)];
|
|
333
325
|
enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];
|
|
334
326
|
}
|
|
335
327
|
|
|
328
|
+
function _getPrice(address asset) internal view returns (uint256) {
|
|
329
|
+
uint256 pivotPrice = INVALID_PRICE;
|
|
330
|
+
|
|
331
|
+
// Get pivot oracle price, Invalid price if not available or error
|
|
332
|
+
(address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);
|
|
333
|
+
if (pivotOracleEnabled && pivotOracle != address(0)) {
|
|
334
|
+
try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {
|
|
335
|
+
pivotPrice = pricePivot;
|
|
336
|
+
} catch {}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Compare main price and pivot price, return main price and if validation was successful
|
|
340
|
+
// note: In case pivot oracle is not available but main price is available and
|
|
341
|
+
// validation is successful, the main oracle price is returned.
|
|
342
|
+
(uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(
|
|
343
|
+
asset,
|
|
344
|
+
pivotPrice,
|
|
345
|
+
pivotOracleEnabled && pivotOracle != address(0)
|
|
346
|
+
);
|
|
347
|
+
if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;
|
|
348
|
+
|
|
349
|
+
// Compare fallback and pivot if main oracle comparision fails with pivot
|
|
350
|
+
// Return fallback price when fallback price is validated successfully with pivot oracle
|
|
351
|
+
(uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);
|
|
352
|
+
if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;
|
|
353
|
+
|
|
354
|
+
// Lastly compare main price and fallback price
|
|
355
|
+
if (
|
|
356
|
+
mainPrice != INVALID_PRICE &&
|
|
357
|
+
fallbackPrice != INVALID_PRICE &&
|
|
358
|
+
boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)
|
|
359
|
+
) {
|
|
360
|
+
return mainPrice;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
revert("invalid resilient oracle price");
|
|
364
|
+
}
|
|
365
|
+
|
|
336
366
|
/**
|
|
337
|
-
* @notice Gets
|
|
367
|
+
* @notice Gets a price for the provided asset
|
|
338
368
|
* @dev This function won't revert when price is 0, because the fallback oracle may still be
|
|
339
369
|
* able to fetch a correct price
|
|
340
|
-
* @param
|
|
370
|
+
* @param asset asset address
|
|
341
371
|
* @param pivotPrice Pivot oracle price
|
|
342
372
|
* @param pivotEnabled If pivot oracle is not empty and enabled
|
|
343
373
|
* @return price USD price in scaled decimals
|
|
344
|
-
* e.g.
|
|
374
|
+
* e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals
|
|
345
375
|
* @return pivotValidated Boolean representing if the validation of main oracle price
|
|
346
376
|
* and pivot oracle price were successful
|
|
347
|
-
* @custom:error Invalid price error is thrown if main oracle fails to fetch price of
|
|
377
|
+
* @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset
|
|
348
378
|
* @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle
|
|
349
379
|
* address is null
|
|
350
380
|
*/
|
|
351
381
|
function _getMainOraclePrice(
|
|
352
|
-
address
|
|
382
|
+
address asset,
|
|
353
383
|
uint256 pivotPrice,
|
|
354
384
|
bool pivotEnabled
|
|
355
|
-
)
|
|
356
|
-
(address mainOracle, bool mainOracleEnabled) = getOracle(
|
|
385
|
+
) internal view returns (uint256, bool) {
|
|
386
|
+
(address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);
|
|
357
387
|
if (mainOracleEnabled && mainOracle != address(0)) {
|
|
358
|
-
try OracleInterface(mainOracle).
|
|
388
|
+
try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {
|
|
359
389
|
if (!pivotEnabled) {
|
|
360
390
|
return (mainOraclePrice, true);
|
|
361
391
|
}
|
|
@@ -364,7 +394,7 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
364
394
|
}
|
|
365
395
|
return (
|
|
366
396
|
mainOraclePrice,
|
|
367
|
-
boundValidator.validatePriceWithAnchorPrice(
|
|
397
|
+
boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)
|
|
368
398
|
);
|
|
369
399
|
} catch {
|
|
370
400
|
return (INVALID_PRICE, false);
|
|
@@ -375,25 +405,25 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
375
405
|
}
|
|
376
406
|
|
|
377
407
|
/**
|
|
378
|
-
* @dev This function won't revert when the price is 0 because
|
|
379
|
-
* @param
|
|
408
|
+
* @dev This function won't revert when the price is 0 because getPrice checks if price is > 0
|
|
409
|
+
* @param asset asset address
|
|
380
410
|
* @return price USD price in 18 decimals
|
|
381
411
|
* @return pivotValidated Boolean representing if the validation of fallback oracle price
|
|
382
412
|
* and pivot oracle price were successfull
|
|
383
|
-
* @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of
|
|
413
|
+
* @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset
|
|
384
414
|
* @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle
|
|
385
415
|
* address is null
|
|
386
416
|
*/
|
|
387
|
-
function _getFallbackOraclePrice(address
|
|
388
|
-
(address fallbackOracle, bool fallbackEnabled) = getOracle(
|
|
417
|
+
function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {
|
|
418
|
+
(address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);
|
|
389
419
|
if (fallbackEnabled && fallbackOracle != address(0)) {
|
|
390
|
-
try OracleInterface(fallbackOracle).
|
|
420
|
+
try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {
|
|
391
421
|
if (pivotPrice == INVALID_PRICE) {
|
|
392
422
|
return (fallbackOraclePrice, false);
|
|
393
423
|
}
|
|
394
424
|
return (
|
|
395
425
|
fallbackOraclePrice,
|
|
396
|
-
boundValidator.validatePriceWithAnchorPrice(
|
|
426
|
+
boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)
|
|
397
427
|
);
|
|
398
428
|
} catch {
|
|
399
429
|
return (INVALID_PRICE, false);
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
pragma solidity 0.8.13;
|
|
3
3
|
|
|
4
4
|
interface FeedRegistryInterface {
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function latestRoundData(
|
|
6
|
+
address base,
|
|
7
|
+
address quote
|
|
8
8
|
)
|
|
9
9
|
external
|
|
10
10
|
view
|
|
11
11
|
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function decimals(address base, address quote) external view returns (uint8);
|
|
14
14
|
}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
pragma solidity 0.8.13;
|
|
3
3
|
|
|
4
4
|
interface OracleInterface {
|
|
5
|
-
function
|
|
5
|
+
function getPrice(address asset) external view returns (uint256);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
interface ResilientOracleInterface is OracleInterface {
|
|
9
9
|
function updatePrice(address vToken) external;
|
|
10
|
+
|
|
11
|
+
function getUnderlyingPrice(address vToken) external view returns (uint256);
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
interface TwapInterface is OracleInterface {
|