@venusprotocol/oracle 1.5.0 → 1.6.0

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 (118) hide show
  1. package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol/AggregatorInterface.dbg.json +1 -1
  2. package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol/AggregatorV2V3Interface.dbg.json +1 -1
  3. package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol/AggregatorV3Interface.dbg.json +1 -1
  4. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
  5. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
  6. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
  7. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
  8. package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +1 -1
  9. package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.dbg.json +1 -1
  10. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +1 -1
  11. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
  12. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
  13. package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +1 -1
  14. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
  15. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
  16. package/artifacts/build-info/1d7bedd9b14544f287811332b9a539d7.json +1 -0
  17. package/artifacts/build-info/{96c10bfc915caedc90a237abc802c96d.json → 57da5d39a9f98618d0dcf1f6d4ff6b0d.json} +1 -1
  18. package/artifacts/build-info/f6af69795174616b8b4a6373f9f1c538.json +1 -0
  19. package/artifacts/contracts/PriceOracle.sol/PriceOracle.dbg.json +1 -1
  20. package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +1 -1
  21. package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json +2 -2
  22. package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.dbg.json +1 -1
  23. package/artifacts/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +1 -1
  24. package/artifacts/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +1 -1
  25. package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +1 -1
  26. package/artifacts/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +1 -1
  27. package/artifacts/contracts/interfaces/PythInterface.sol/AbstractPyth.dbg.json +1 -1
  28. package/artifacts/contracts/interfaces/PythInterface.sol/IPyth.dbg.json +1 -1
  29. package/artifacts/contracts/interfaces/PythInterface.sol/PythStructs.dbg.json +1 -1
  30. package/artifacts/contracts/interfaces/VBep20Interface.sol/VBep20Interface.dbg.json +1 -1
  31. package/artifacts/contracts/libraries/PancakeLibrary.sol/FixedPoint.dbg.json +1 -1
  32. package/artifacts/contracts/libraries/PancakeLibrary.sol/FixedPoint.json +2 -2
  33. package/artifacts/contracts/libraries/PancakeLibrary.sol/IPancakePair.dbg.json +1 -1
  34. package/artifacts/contracts/libraries/PancakeLibrary.sol/PancakeOracleLibrary.dbg.json +1 -1
  35. package/artifacts/contracts/libraries/PancakeLibrary.sol/PancakeOracleLibrary.json +2 -2
  36. package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.dbg.json +1 -1
  37. package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.json +2 -2
  38. package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.dbg.json +1 -1
  39. package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.json +3 -3
  40. package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.dbg.json +1 -1
  41. package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.json +2 -2
  42. package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.dbg.json +1 -1
  43. package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.json +2 -2
  44. package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.dbg.json +1 -1
  45. package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.json +2 -2
  46. package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.dbg.json +1 -1
  47. package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.dbg.json +1 -1
  48. package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.json +2 -2
  49. package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.dbg.json +1 -1
  50. package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.json +2 -2
  51. package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.dbg.json +1 -1
  52. package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.json +2 -2
  53. package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.dbg.json +1 -1
  54. package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.json +2 -2
  55. package/artifacts/contracts/test/BEP20Harness.sol/BEP20Harness.dbg.json +1 -1
  56. package/artifacts/contracts/test/MockPyth.sol/MockPyth.dbg.json +1 -1
  57. package/artifacts/contracts/test/MockPyth.sol/MockPyth.json +2 -2
  58. package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.dbg.json +1 -1
  59. package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.json +2 -2
  60. package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.dbg.json +1 -1
  61. package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.json +2 -2
  62. package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.dbg.json +1 -1
  63. package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.json +2 -2
  64. package/artifacts/contracts/test/PancakePairHarness.sol/Math.dbg.json +1 -1
  65. package/artifacts/contracts/test/PancakePairHarness.sol/Math.json +2 -2
  66. package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.dbg.json +1 -1
  67. package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.json +2 -2
  68. package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.dbg.json +1 -1
  69. package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.json +2 -2
  70. package/artifacts/contracts/test/VBEP20Harness.sol/VBEP20Harness.dbg.json +1 -1
  71. package/contracts/PriceOracle.sol +2 -2
  72. package/contracts/ResilientOracle.sol +127 -114
  73. package/contracts/libraries/PancakeLibrary.sol +8 -8
  74. package/contracts/oracles/BinanceOracle.sol +4 -4
  75. package/contracts/oracles/BoundValidator.sol +31 -29
  76. package/contracts/oracles/ChainlinkOracle.sol +85 -83
  77. package/contracts/oracles/PythOracle.sol +41 -41
  78. package/contracts/oracles/TwapOracle.sol +67 -67
  79. package/contracts/oracles/mocks/MockBinanceOracle.sol +4 -4
  80. package/contracts/oracles/mocks/MockChainlinkOracle.sol +4 -4
  81. package/contracts/oracles/mocks/MockPythOracle.sol +4 -4
  82. package/contracts/oracles/mocks/MockTwapOracle.sol +4 -4
  83. package/contracts/test/MockPyth.sol +13 -13
  84. package/contracts/test/MockSimpleOracle.sol +8 -8
  85. package/contracts/test/MockV3Aggregator.sol +18 -18
  86. package/contracts/test/PancakePairHarness.sol +10 -10
  87. package/deploy/1-deploy-oracles.d.ts +1 -3
  88. package/deploy/1-deploy-oracles.d.ts.map +1 -1
  89. package/deploy/1-deploy-oracles.js +13 -3
  90. package/deploy/1-deploy-oracles.js.map +1 -1
  91. package/deploy/2-configure-feeds.d.ts +1 -3
  92. package/deploy/2-configure-feeds.d.ts.map +1 -1
  93. package/deploy/2-configure-feeds.js +101 -87
  94. package/deploy/2-configure-feeds.js.map +1 -1
  95. package/deployments/bsctestnet/BinanceOracle.json +42 -29
  96. package/deployments/bsctestnet/BinanceOracle_Implementation.json +96 -23
  97. package/deployments/bsctestnet/BinanceOracle_Proxy.json +28 -28
  98. package/deployments/bsctestnet/BoundValidator.json +65 -39
  99. package/deployments/bsctestnet/BoundValidator_Implementation.json +113 -35
  100. package/deployments/bsctestnet/BoundValidator_Proxy.json +37 -37
  101. package/deployments/bsctestnet/ChainlinkOracle.json +64 -38
  102. package/deployments/bsctestnet/ChainlinkOracle_Implementation.json +122 -41
  103. package/deployments/bsctestnet/ChainlinkOracle_Proxy.json +37 -37
  104. package/deployments/bsctestnet/DefaultProxyAdmin.json +15 -15
  105. package/deployments/bsctestnet/PythOracle.json +71 -45
  106. package/deployments/bsctestnet/PythOracle_Implementation.json +128 -44
  107. package/deployments/bsctestnet/PythOracle_Proxy.json +44 -44
  108. package/deployments/bsctestnet/ResilientOracle.json +67 -54
  109. package/deployments/bsctestnet/ResilientOracle_Implementation.json +161 -63
  110. package/deployments/bsctestnet/ResilientOracle_Proxy.json +39 -39
  111. package/deployments/bsctestnet/TwapOracle.json +74 -71
  112. package/deployments/bsctestnet/TwapOracle_Implementation.json +163 -93
  113. package/deployments/bsctestnet/TwapOracle_Proxy.json +37 -41
  114. package/deployments/bsctestnet/solcInputs/6153c675ce838eebb6442d63350712be.json +144 -0
  115. package/package.json +4 -2
  116. package/deployments/bsctestnet/solcInputs/09bc2981019c6dcce653b90bac585fe0.json +0 -81
  117. package/deployments/bsctestnet/solcInputs/5dedb37ab8105f1f71e53a3f865859c5.json +0 -57
  118. package/deployments/bsctestnet/solcInputs/bb71c6049f6b7b21a6581f40daf802bc.json +0 -138
@@ -65,8 +65,8 @@
65
65
  "type": "function"
66
66
  }
67
67
  ],
68
- "bytecode": "0x608060405234801561001057600080fd5b5061016a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100405760003560e01c8062e4768b14610045578063cfed246b14610071578063fc57d4df146100a3575b600080fd5b61006f6100533660046100e8565b6001600160a01b03909116600090815260208190526040902055565b005b61009161007f366004610112565b60006020819052908152604090205481565b60405190815260200160405180910390f35b6100916100b1366004610112565b6001600160a01b031660009081526020819052604090205490565b80356001600160a01b03811681146100e357600080fd5b919050565b600080604083850312156100fb57600080fd5b610104836100cc565b946020939093013593505050565b60006020828403121561012457600080fd5b61012d826100cc565b939250505056fea2646970667358221220006f828e75718402a1b489565d3326c818ca6a96b4dcdca912d2f548e13cd80564736f6c634300080d0033",
69
- "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100405760003560e01c8062e4768b14610045578063cfed246b14610071578063fc57d4df146100a3575b600080fd5b61006f6100533660046100e8565b6001600160a01b03909116600090815260208190526040902055565b005b61009161007f366004610112565b60006020819052908152604090205481565b60405190815260200160405180910390f35b6100916100b1366004610112565b6001600160a01b031660009081526020819052604090205490565b80356001600160a01b03811681146100e357600080fd5b919050565b600080604083850312156100fb57600080fd5b610104836100cc565b946020939093013593505050565b60006020828403121561012457600080fd5b61012d826100cc565b939250505056fea2646970667358221220006f828e75718402a1b489565d3326c818ca6a96b4dcdca912d2f548e13cd80564736f6c634300080d0033",
68
+ "bytecode": "0x608060405234801561001057600080fd5b5061016a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100405760003560e01c8062e4768b14610045578063cfed246b14610071578063fc57d4df146100a3575b600080fd5b61006f6100533660046100e8565b6001600160a01b03909116600090815260208190526040902055565b005b61009161007f366004610112565b60006020819052908152604090205481565b60405190815260200160405180910390f35b6100916100b1366004610112565b6001600160a01b031660009081526020819052604090205490565b80356001600160a01b03811681146100e357600080fd5b919050565b600080604083850312156100fb57600080fd5b610104836100cc565b946020939093013593505050565b60006020828403121561012457600080fd5b61012d826100cc565b939250505056fea264697066735822122079729389e19976118c5af11cb5a9c34538b0860f1f7a58cc91b2d72ab611f23f64736f6c634300080d0033",
69
+ "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100405760003560e01c8062e4768b14610045578063cfed246b14610071578063fc57d4df146100a3575b600080fd5b61006f6100533660046100e8565b6001600160a01b03909116600090815260208190526040902055565b005b61009161007f366004610112565b60006020819052908152604090205481565b60405190815260200160405180910390f35b6100916100b1366004610112565b6001600160a01b031660009081526020819052604090205490565b80356001600160a01b03811681146100e357600080fd5b919050565b600080604083850312156100fb57600080fd5b610104836100cc565b946020939093013593505050565b60006020828403121561012457600080fd5b61012d826100cc565b939250505056fea264697066735822122079729389e19976118c5af11cb5a9c34538b0860f1f7a58cc91b2d72ab611f23f64736f6c634300080d0033",
70
70
  "linkReferences": {},
71
71
  "deployedLinkReferences": {}
72
72
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/96c10bfc915caedc90a237abc802c96d.json"
3
+ "buildInfo": "../../../build-info/1d7bedd9b14544f287811332b9a539d7.json"
4
4
  }
@@ -299,8 +299,8 @@
299
299
  "type": "function"
300
300
  }
301
301
  ],
302
- "bytecode": "0x608060405234801561001057600080fd5b5060405161054f38038061054f83398101604081905261002f916100a4565b6000805460ff191660ff84161790556100478161004e565b50506100ff565b60018190554260025560038054906000610067836100d8565b9091555050600380546000908152600460209081526040808320949094558254825260058152838220429081905592548252600690529190912055565b600080604083850312156100b757600080fd5b825160ff811681146100c857600080fd5b6020939093015192949293505050565b6000600182016100f857634e487b7160e01b600052601160045260246000fd5b5060010190565b6104418061010e6000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80638205bf6a116100715780638205bf6a146101a15780639a6fc8f5146101aa578063a87a20ce14610228578063b5ab58dc1461023b578063b633620c1461025b578063feaf968c1461027b57600080fd5b8063313ce567146100b95780634aa2011f146100dd57806350d25bcd1461013a57806354fd4d5014610151578063668a0f02146101595780637284e41614610162575b600080fd5b6000546100c69060ff1681565b60405160ff90911681526020015b60405180910390f35b6101386100eb36600461031b565b69ffffffffffffffffffff90931660038181556001849055600283905560009182526004602090815260408084209590955581548352600581528483209390935554815260069091522055565b005b61014360015481565b6040519081526020016100d4565b610143600081565b61014360035481565b604080518082018252601f81527f76302e362f74657374732f4d6f636b563341676772656761746f722e736f6c00602082015290516100d49190610354565b61014360025481565b6101f16101b83660046103a9565b69ffffffffffffffffffff8116600090815260046020908152604080832054600683528184205460059093529220549293919290918490565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100d4565b6101386102363660046103cb565b6102a6565b6101436102493660046103cb565b60046020526000908152604090205481565b6101436102693660046103cb565b60056020526000908152604090205481565b60035460008181526004602090815260408083205460068352818420546005909352922054836101f1565b600181905542600255600380549060006102bf836103e4565b9091555050600380546000908152600460209081526040808320949094558254825260058152838220429081905592548252600690529190912055565b803569ffffffffffffffffffff8116811461031657600080fd5b919050565b6000806000806080858703121561033157600080fd5b61033a856102fc565b966020860135965060408601359560600135945092505050565b600060208083528351808285015260005b8181101561038157858101830151858201604001528201610365565b81811115610393576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156103bb57600080fd5b6103c4826102fc565b9392505050565b6000602082840312156103dd57600080fd5b5035919050565b60006001820161040457634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220c4931ac7ff097b3484785670c8666f1afe46147271868984da85770c9f227bdf64736f6c634300080d0033",
303
- "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638205bf6a116100715780638205bf6a146101a15780639a6fc8f5146101aa578063a87a20ce14610228578063b5ab58dc1461023b578063b633620c1461025b578063feaf968c1461027b57600080fd5b8063313ce567146100b95780634aa2011f146100dd57806350d25bcd1461013a57806354fd4d5014610151578063668a0f02146101595780637284e41614610162575b600080fd5b6000546100c69060ff1681565b60405160ff90911681526020015b60405180910390f35b6101386100eb36600461031b565b69ffffffffffffffffffff90931660038181556001849055600283905560009182526004602090815260408084209590955581548352600581528483209390935554815260069091522055565b005b61014360015481565b6040519081526020016100d4565b610143600081565b61014360035481565b604080518082018252601f81527f76302e362f74657374732f4d6f636b563341676772656761746f722e736f6c00602082015290516100d49190610354565b61014360025481565b6101f16101b83660046103a9565b69ffffffffffffffffffff8116600090815260046020908152604080832054600683528184205460059093529220549293919290918490565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100d4565b6101386102363660046103cb565b6102a6565b6101436102493660046103cb565b60046020526000908152604090205481565b6101436102693660046103cb565b60056020526000908152604090205481565b60035460008181526004602090815260408083205460068352818420546005909352922054836101f1565b600181905542600255600380549060006102bf836103e4565b9091555050600380546000908152600460209081526040808320949094558254825260058152838220429081905592548252600690529190912055565b803569ffffffffffffffffffff8116811461031657600080fd5b919050565b6000806000806080858703121561033157600080fd5b61033a856102fc565b966020860135965060408601359560600135945092505050565b600060208083528351808285015260005b8181101561038157858101830151858201604001528201610365565b81811115610393576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156103bb57600080fd5b6103c4826102fc565b9392505050565b6000602082840312156103dd57600080fd5b5035919050565b60006001820161040457634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220c4931ac7ff097b3484785670c8666f1afe46147271868984da85770c9f227bdf64736f6c634300080d0033",
302
+ "bytecode": "0x608060405234801561001057600080fd5b5060405161054f38038061054f83398101604081905261002f916100a4565b6000805460ff191660ff84161790556100478161004e565b50506100ff565b60018190554260025560038054906000610067836100d8565b9091555050600380546000908152600460209081526040808320949094558254825260058152838220429081905592548252600690529190912055565b600080604083850312156100b757600080fd5b825160ff811681146100c857600080fd5b6020939093015192949293505050565b6000600182016100f857634e487b7160e01b600052601160045260246000fd5b5060010190565b6104418061010e6000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80638205bf6a116100715780638205bf6a146101a15780639a6fc8f5146101aa578063a87a20ce14610228578063b5ab58dc1461023b578063b633620c1461025b578063feaf968c1461027b57600080fd5b8063313ce567146100b95780634aa2011f146100dd57806350d25bcd1461013a57806354fd4d5014610151578063668a0f02146101595780637284e41614610162575b600080fd5b6000546100c69060ff1681565b60405160ff90911681526020015b60405180910390f35b6101386100eb36600461031b565b69ffffffffffffffffffff90931660038181556001849055600283905560009182526004602090815260408084209590955581548352600581528483209390935554815260069091522055565b005b61014360015481565b6040519081526020016100d4565b610143600081565b61014360035481565b604080518082018252601f81527f76302e362f74657374732f4d6f636b563341676772656761746f722e736f6c00602082015290516100d49190610354565b61014360025481565b6101f16101b83660046103a9565b69ffffffffffffffffffff8116600090815260046020908152604080832054600683528184205460059093529220549293919290918490565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100d4565b6101386102363660046103cb565b6102a6565b6101436102493660046103cb565b60046020526000908152604090205481565b6101436102693660046103cb565b60056020526000908152604090205481565b60035460008181526004602090815260408083205460068352818420546005909352922054836101f1565b600181905542600255600380549060006102bf836103e4565b9091555050600380546000908152600460209081526040808320949094558254825260058152838220429081905592548252600690529190912055565b803569ffffffffffffffffffff8116811461031657600080fd5b919050565b6000806000806080858703121561033157600080fd5b61033a856102fc565b966020860135965060408601359560600135945092505050565b600060208083528351808285015260005b8181101561038157858101830151858201604001528201610365565b81811115610393576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156103bb57600080fd5b6103c4826102fc565b9392505050565b6000602082840312156103dd57600080fd5b5035919050565b60006001820161040457634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122096c3091245664199860a20761528ca5dd19410fde7d776e43eaba08a8a7f513e64736f6c634300080d0033",
303
+ "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638205bf6a116100715780638205bf6a146101a15780639a6fc8f5146101aa578063a87a20ce14610228578063b5ab58dc1461023b578063b633620c1461025b578063feaf968c1461027b57600080fd5b8063313ce567146100b95780634aa2011f146100dd57806350d25bcd1461013a57806354fd4d5014610151578063668a0f02146101595780637284e41614610162575b600080fd5b6000546100c69060ff1681565b60405160ff90911681526020015b60405180910390f35b6101386100eb36600461031b565b69ffffffffffffffffffff90931660038181556001849055600283905560009182526004602090815260408084209590955581548352600581528483209390935554815260069091522055565b005b61014360015481565b6040519081526020016100d4565b610143600081565b61014360035481565b604080518082018252601f81527f76302e362f74657374732f4d6f636b563341676772656761746f722e736f6c00602082015290516100d49190610354565b61014360025481565b6101f16101b83660046103a9565b69ffffffffffffffffffff8116600090815260046020908152604080832054600683528184205460059093529220549293919290918490565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100d4565b6101386102363660046103cb565b6102a6565b6101436102493660046103cb565b60046020526000908152604090205481565b6101436102693660046103cb565b60056020526000908152604090205481565b60035460008181526004602090815260408083205460068352818420546005909352922054836101f1565b600181905542600255600380549060006102bf836103e4565b9091555050600380546000908152600460209081526040808320949094558254825260058152838220429081905592548252600690529190912055565b803569ffffffffffffffffffff8116811461031657600080fd5b919050565b6000806000806080858703121561033157600080fd5b61033a856102fc565b966020860135965060408601359560600135945092505050565b600060208083528351808285015260005b8181101561038157858101830151858201604001528201610365565b81811115610393576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156103bb57600080fd5b6103c4826102fc565b9392505050565b6000602082840312156103dd57600080fd5b5035919050565b60006001820161040457634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122096c3091245664199860a20761528ca5dd19410fde7d776e43eaba08a8a7f513e64736f6c634300080d0033",
304
304
  "linkReferences": {},
305
305
  "deployedLinkReferences": {}
306
306
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/96c10bfc915caedc90a237abc802c96d.json"
3
+ "buildInfo": "../../../build-info/1d7bedd9b14544f287811332b9a539d7.json"
4
4
  }
@@ -3,8 +3,8 @@
3
3
  "contractName": "Math",
4
4
  "sourceName": "contracts/test/PancakePairHarness.sol",
5
5
  "abi": [],
6
- "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122089bd95e6319d32931f7d89dfe0d9a275ab7b2442948927a50f691f6544eee7ff64736f6c634300080d0033",
7
- "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122089bd95e6319d32931f7d89dfe0d9a275ab7b2442948927a50f691f6544eee7ff64736f6c634300080d0033",
6
+ "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220fdd1ee70439705f44b55a9066b0079fa67d8e91973de6e95c24782e5130cdd9464736f6c634300080d0033",
7
+ "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220fdd1ee70439705f44b55a9066b0079fa67d8e91973de6e95c24782e5130cdd9464736f6c634300080d0033",
8
8
  "linkReferences": {},
9
9
  "deployedLinkReferences": {}
10
10
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/96c10bfc915caedc90a237abc802c96d.json"
3
+ "buildInfo": "../../../build-info/1d7bedd9b14544f287811332b9a539d7.json"
4
4
  }
@@ -151,8 +151,8 @@
151
151
  "type": "function"
152
152
  }
153
153
  ],
154
- "bytecode": "0x608060405234801561001057600080fd5b506104e4806100206000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80635a3d5493116100665780635a3d5493146101585780637464fc3d14610161578063abf812721461016a578063d21220a714610187578063d9fc83c61461019a57600080fd5b80630902f1ac146100985780630dfe1681146100d8578063485cc955146101035780635909c0d514610141575b600080fd5b600254604080516001600160701b038084168252600160701b8404166020820152600160e01b90920463ffffffff16908201526060015b60405180910390f35b6000546100eb906001600160a01b031681565b6040516001600160a01b0390911681526020016100cf565b61013f610111366004610391565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b005b61014a60035481565b6040519081526020016100cf565b61014a60045481565b61014a60055481565b6101726101ad565b60405163ffffffff90911681526020016100cf565b6001546100eb906001600160a01b031681565b61013f6101a83660046103db565b6101c3565b60006101be64010000000042610437565b905090565b6001600160701b0384118015906101e157506001600160701b038311155b6102275760405162461bcd60e51b815260206004820152601360248201527250616e63616b6556323a204f564552464c4f5760681b604482015260640160405180910390fd5b600061023864010000000042610437565b60025490915063ffffffff600160e01b909104811682039081161580159061026857506001600160701b03841615155b801561027c57506001600160701b03831615155b156102e7578063ffffffff166102a4856102958661033a565b6001600160e01b031690610359565b600380546001600160e01b03929092169290920201905563ffffffff81166102cf846102958761033a565b600480546001600160e01b0392909216929092020190555b506002805463ffffffff909216600160e01b026001600160e01b036001600160701b03968716600160701b026001600160e01b031990941696909716959095179190911794909416929092179092555050565b6000610353600160701b6001600160701b03841661044b565b92915050565b600061036e6001600160701b03831684610488565b9392505050565b80356001600160a01b038116811461038c57600080fd5b919050565b600080604083850312156103a457600080fd5b6103ad83610375565b91506103bb60208401610375565b90509250929050565b80356001600160701b038116811461038c57600080fd5b600080600080608085870312156103f157600080fd5b8435935060208501359250610408604086016103c4565b9150610416606086016103c4565b905092959194509250565b634e487b7160e01b600052601260045260246000fd5b60008261044657610446610421565b500690565b60006001600160e01b038281168482168115158284048211161561047f57634e487b7160e01b600052601160045260246000fd5b02949350505050565b60006001600160e01b03838116806104a2576104a2610421565b9216919091049291505056fea2646970667358221220f32c12ae07331f7e2e84a64aee6ca6fe8c22215e01b560954f2ec1fdea6cc4ff64736f6c634300080d0033",
155
- "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c80635a3d5493116100665780635a3d5493146101585780637464fc3d14610161578063abf812721461016a578063d21220a714610187578063d9fc83c61461019a57600080fd5b80630902f1ac146100985780630dfe1681146100d8578063485cc955146101035780635909c0d514610141575b600080fd5b600254604080516001600160701b038084168252600160701b8404166020820152600160e01b90920463ffffffff16908201526060015b60405180910390f35b6000546100eb906001600160a01b031681565b6040516001600160a01b0390911681526020016100cf565b61013f610111366004610391565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b005b61014a60035481565b6040519081526020016100cf565b61014a60045481565b61014a60055481565b6101726101ad565b60405163ffffffff90911681526020016100cf565b6001546100eb906001600160a01b031681565b61013f6101a83660046103db565b6101c3565b60006101be64010000000042610437565b905090565b6001600160701b0384118015906101e157506001600160701b038311155b6102275760405162461bcd60e51b815260206004820152601360248201527250616e63616b6556323a204f564552464c4f5760681b604482015260640160405180910390fd5b600061023864010000000042610437565b60025490915063ffffffff600160e01b909104811682039081161580159061026857506001600160701b03841615155b801561027c57506001600160701b03831615155b156102e7578063ffffffff166102a4856102958661033a565b6001600160e01b031690610359565b600380546001600160e01b03929092169290920201905563ffffffff81166102cf846102958761033a565b600480546001600160e01b0392909216929092020190555b506002805463ffffffff909216600160e01b026001600160e01b036001600160701b03968716600160701b026001600160e01b031990941696909716959095179190911794909416929092179092555050565b6000610353600160701b6001600160701b03841661044b565b92915050565b600061036e6001600160701b03831684610488565b9392505050565b80356001600160a01b038116811461038c57600080fd5b919050565b600080604083850312156103a457600080fd5b6103ad83610375565b91506103bb60208401610375565b90509250929050565b80356001600160701b038116811461038c57600080fd5b600080600080608085870312156103f157600080fd5b8435935060208501359250610408604086016103c4565b9150610416606086016103c4565b905092959194509250565b634e487b7160e01b600052601260045260246000fd5b60008261044657610446610421565b500690565b60006001600160e01b038281168482168115158284048211161561047f57634e487b7160e01b600052601160045260246000fd5b02949350505050565b60006001600160e01b03838116806104a2576104a2610421565b9216919091049291505056fea2646970667358221220f32c12ae07331f7e2e84a64aee6ca6fe8c22215e01b560954f2ec1fdea6cc4ff64736f6c634300080d0033",
154
+ "bytecode": "0x608060405234801561001057600080fd5b506104e4806100206000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80635a3d5493116100665780635a3d5493146101585780637464fc3d14610161578063abf812721461016a578063d21220a714610187578063d9fc83c61461019a57600080fd5b80630902f1ac146100985780630dfe1681146100d8578063485cc955146101035780635909c0d514610141575b600080fd5b600254604080516001600160701b038084168252600160701b8404166020820152600160e01b90920463ffffffff16908201526060015b60405180910390f35b6000546100eb906001600160a01b031681565b6040516001600160a01b0390911681526020016100cf565b61013f610111366004610391565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b005b61014a60035481565b6040519081526020016100cf565b61014a60045481565b61014a60055481565b6101726101ad565b60405163ffffffff90911681526020016100cf565b6001546100eb906001600160a01b031681565b61013f6101a83660046103db565b6101c3565b60006101be64010000000042610437565b905090565b6001600160701b0384118015906101e157506001600160701b038311155b6102275760405162461bcd60e51b815260206004820152601360248201527250616e63616b6556323a204f564552464c4f5760681b604482015260640160405180910390fd5b600061023864010000000042610437565b60025490915063ffffffff600160e01b909104811682039081161580159061026857506001600160701b03841615155b801561027c57506001600160701b03831615155b156102e7578063ffffffff166102a4856102958661033a565b6001600160e01b031690610359565b600380546001600160e01b03929092169290920201905563ffffffff81166102cf846102958761033a565b600480546001600160e01b0392909216929092020190555b506002805463ffffffff909216600160e01b026001600160e01b036001600160701b03968716600160701b026001600160e01b031990941696909716959095179190911794909416929092179092555050565b6000610353600160701b6001600160701b03841661044b565b92915050565b600061036e6001600160701b03831684610488565b9392505050565b80356001600160a01b038116811461038c57600080fd5b919050565b600080604083850312156103a457600080fd5b6103ad83610375565b91506103bb60208401610375565b90509250929050565b80356001600160701b038116811461038c57600080fd5b600080600080608085870312156103f157600080fd5b8435935060208501359250610408604086016103c4565b9150610416606086016103c4565b905092959194509250565b634e487b7160e01b600052601260045260246000fd5b60008261044657610446610421565b500690565b60006001600160e01b038281168482168115158284048211161561047f57634e487b7160e01b600052601160045260246000fd5b02949350505050565b60006001600160e01b03838116806104a2576104a2610421565b9216919091049291505056fea2646970667358221220f004ca14fe33dd19fbd8c35a6fb88523d1e18a170538bdd7d6cb8410862c876364736f6c634300080d0033",
155
+ "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c80635a3d5493116100665780635a3d5493146101585780637464fc3d14610161578063abf812721461016a578063d21220a714610187578063d9fc83c61461019a57600080fd5b80630902f1ac146100985780630dfe1681146100d8578063485cc955146101035780635909c0d514610141575b600080fd5b600254604080516001600160701b038084168252600160701b8404166020820152600160e01b90920463ffffffff16908201526060015b60405180910390f35b6000546100eb906001600160a01b031681565b6040516001600160a01b0390911681526020016100cf565b61013f610111366004610391565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b005b61014a60035481565b6040519081526020016100cf565b61014a60045481565b61014a60055481565b6101726101ad565b60405163ffffffff90911681526020016100cf565b6001546100eb906001600160a01b031681565b61013f6101a83660046103db565b6101c3565b60006101be64010000000042610437565b905090565b6001600160701b0384118015906101e157506001600160701b038311155b6102275760405162461bcd60e51b815260206004820152601360248201527250616e63616b6556323a204f564552464c4f5760681b604482015260640160405180910390fd5b600061023864010000000042610437565b60025490915063ffffffff600160e01b909104811682039081161580159061026857506001600160701b03841615155b801561027c57506001600160701b03831615155b156102e7578063ffffffff166102a4856102958661033a565b6001600160e01b031690610359565b600380546001600160e01b03929092169290920201905563ffffffff81166102cf846102958761033a565b600480546001600160e01b0392909216929092020190555b506002805463ffffffff909216600160e01b026001600160e01b036001600160701b03968716600160701b026001600160e01b031990941696909716959095179190911794909416929092179092555050565b6000610353600160701b6001600160701b03841661044b565b92915050565b600061036e6001600160701b03831684610488565b9392505050565b80356001600160a01b038116811461038c57600080fd5b919050565b600080604083850312156103a457600080fd5b6103ad83610375565b91506103bb60208401610375565b90509250929050565b80356001600160701b038116811461038c57600080fd5b600080600080608085870312156103f157600080fd5b8435935060208501359250610408604086016103c4565b9150610416606086016103c4565b905092959194509250565b634e487b7160e01b600052601260045260246000fd5b60008261044657610446610421565b500690565b60006001600160e01b038281168482168115158284048211161561047f57634e487b7160e01b600052601160045260246000fd5b02949350505050565b60006001600160e01b03838116806104a2576104a2610421565b9216919091049291505056fea2646970667358221220f004ca14fe33dd19fbd8c35a6fb88523d1e18a170538bdd7d6cb8410862c876364736f6c634300080d0033",
156
156
  "linkReferences": {},
157
157
  "deployedLinkReferences": {}
158
158
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/96c10bfc915caedc90a237abc802c96d.json"
3
+ "buildInfo": "../../../build-info/1d7bedd9b14544f287811332b9a539d7.json"
4
4
  }
@@ -3,8 +3,8 @@
3
3
  "contractName": "UQ112x112",
4
4
  "sourceName": "contracts/test/PancakePairHarness.sol",
5
5
  "abi": [],
6
- "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220117741be2359bd8706edcdd40faaf9073f3381189c35f762e7bee14c2afc53a264736f6c634300080d0033",
7
- "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220117741be2359bd8706edcdd40faaf9073f3381189c35f762e7bee14c2afc53a264736f6c634300080d0033",
6
+ "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122065dd1aba8b49cec425c48656322d3b21fbfb833a258afc914ec218340bb70b9464736f6c634300080d0033",
7
+ "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122065dd1aba8b49cec425c48656322d3b21fbfb833a258afc914ec218340bb70b9464736f6c634300080d0033",
8
8
  "linkReferences": {},
9
9
  "deployedLinkReferences": {}
10
10
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/96c10bfc915caedc90a237abc802c96d.json"
3
+ "buildInfo": "../../../build-info/57da5d39a9f98618d0dcf1f6d4ff6b0d.json"
4
4
  }
@@ -4,6 +4,8 @@
4
4
  pragma solidity 0.8.13;
5
5
 
6
6
  abstract contract PriceOracle {
7
+ function updatePrice(address vToken) external virtual;
8
+
7
9
  /**
8
10
  * @notice Get the underlying price of a vToken asset
9
11
  * @param vToken The vToken address to get the underlying price of
@@ -11,6 +13,4 @@ abstract contract PriceOracle {
11
13
  * Zero means the price is unavailable.
12
14
  */
13
15
  function getUnderlyingPrice(address vToken) external view virtual returns (uint256);
14
-
15
- function updatePrice(address vToken) external virtual;
16
16
  }
@@ -8,21 +8,10 @@ import "./interfaces/VBep20Interface.sol";
8
8
  import "./interfaces/OracleInterface.sol";
9
9
 
10
10
  contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOracleInterface {
11
- uint256 public constant INVALID_PRICE = 0;
12
-
13
- /// @notice vBNB address
14
- /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
15
- address public immutable vBnb;
16
-
17
- /// @notice Set this as asset address for BNB. This is the underlying for vBNB
18
- address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
19
-
20
- BoundValidatorInterface public boundValidator;
21
-
22
11
  /**
23
- * @dev oracle role, we have 3 roles at the moment
12
+ * @dev Oracle roles:
24
13
  * **main**: The most trustworthy price source
25
- * **pivot**: Not so trustworthy price source, used as a loose sanity checker
14
+ * **pivot**: Price oracle used as a loose sanity checker
26
15
  * **fallback**: The backup source when main oracle price is invalidated
27
16
  */
28
17
  enum OracleRole {
@@ -34,14 +23,26 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
34
23
  struct TokenConfig {
35
24
  /// @notice asset address
36
25
  address asset;
37
- /// @notice `oracles` stores the oracles in the order of: [main, pivot, fallback],
38
- /// it can be indexed with enum OracleRole value
26
+ /// @notice `oracles` stores the oracles based on their role in the following order:
27
+ /// [main, pivot, fallback],
28
+ /// It can be indexed with the corresponding enum OracleRole value
39
29
  address[3] oracles;
40
- /// @notice `enableFlagsForOracles` stores the oracle enable statuses
30
+ /// @notice `enableFlagsForOracles` stores the enabled state
41
31
  /// for each oracle in the same order as `oracles`
42
32
  bool[3] enableFlagsForOracles;
43
33
  }
44
34
 
35
+ uint256 public constant INVALID_PRICE = 0;
36
+
37
+ /// @notice vBNB address
38
+ /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
39
+ address public immutable vBnb;
40
+
41
+ /// @notice Set this as asset address for BNB. This is the underlying for vBNB
42
+ address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
43
+
44
+ BoundValidatorInterface public boundValidator;
45
+
45
46
  mapping(address => TokenConfig) private tokenConfigs;
46
47
 
47
48
  event TokenConfigAdded(
@@ -50,17 +51,24 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
50
51
  address indexed pivotOracle,
51
52
  address fallbackOracle
52
53
  );
54
+
55
+ /// Event emitted when an oracle is set
53
56
  event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);
57
+
58
+ /// Event emitted when an oracle is enabled or disabled
54
59
  event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);
55
60
 
61
+ /**
62
+ * @notice Checks whether an address is null or not
63
+ */
56
64
  modifier notNullAddress(address someone) {
57
65
  require(someone != address(0), "can't be zero address");
58
66
  _;
59
67
  }
60
68
 
61
69
  /**
62
- * @notice Check whether token config exist by checking whether vToken is zero address
63
- * @dev vToken can't be set to zero, so it's suitable to be used to check
70
+ * @notice Checks whether token config exists by checking whether vToken is null address
71
+ * @dev vToken can't be null, so it's suitable to be used to check the validity of the config
64
72
  * @param asset asset address
65
73
  */
66
74
  modifier checkTokenConfigExistance(address asset) {
@@ -69,7 +77,7 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
69
77
  }
70
78
 
71
79
  /// @notice Constructor for the implementation contract. Sets immutable variables.
72
- /// @param vBnbAddress The address of the VBNB
80
+ /// @param vBnbAddress The address of the vBNB
73
81
  /// @custom:oz-upgrades-unsafe-allow constructor
74
82
  constructor(address vBnbAddress) notNullAddress(vBnbAddress) {
75
83
  vBnb = vBnbAddress;
@@ -77,59 +85,26 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
77
85
  }
78
86
 
79
87
  /**
80
- * @notice Initializes the contract admin and sets the BoundValidator contract address
81
- * @param _boundValidator Address of the bound validator contract
82
- */
83
- function initialize(BoundValidatorInterface _boundValidator) public initializer {
84
- require(address(_boundValidator) != address(0), "invalid bound validator address");
85
- boundValidator = _boundValidator;
86
-
87
- __Ownable_init();
88
- __Pausable_init();
89
- }
90
-
91
- /**
92
- * @notice Pause oracle
88
+ * @notice Pauses oracle
89
+ * @custom:access Only Governance
93
90
  */
94
91
  function pause() external onlyOwner {
95
92
  _pause();
96
93
  }
97
94
 
98
95
  /**
99
- * @notice Unpause oracle
96
+ * @notice Unpauses oracle
97
+ * @custom:access Only Governance
100
98
  */
101
99
  function unpause() external onlyOwner {
102
100
  _unpause();
103
101
  }
104
102
 
105
103
  /**
106
- * @dev Get token config by vToken address
107
- * @param vToken vtoken address
108
- * @return tokenConfig config of the vToken
109
- */
110
- function getTokenConfig(address vToken) external view returns (TokenConfig memory) {
111
- address asset = address(vToken) == vBnb ? BNB_ADDR : VBep20Interface(vToken).underlying();
112
- return tokenConfigs[asset];
113
- }
114
-
115
- /**
116
- * @notice Get oracle & enabling status by vToken address
117
- * @param vToken vtoken address
118
- * @param role oracle role
119
- * @return oracle oracle address based on role
120
- * @return enabled enabled flag of the oracle based on token config
121
- */
122
- function getOracle(address vToken, OracleRole role) public view returns (address oracle, bool enabled) {
123
- address asset = address(vToken) == vBnb ? BNB_ADDR : VBep20Interface(vToken).underlying();
124
- oracle = tokenConfigs[asset].oracles[uint256(role)];
125
- enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];
126
- }
127
-
128
- /**
129
- * @notice Batch set token configs
130
- * @param tokenConfigs_ token config array
104
+ * @notice Batch sets token configs
105
+ * @param tokenConfigs_ Token config array
131
106
  * @custom:access Only Governance
132
- * @custom:error Length error if the lenght of the array is 0, passed in parameter
107
+ * @custom:error Throws a length error if the lenght of the token configs array is 0
133
108
  */
134
109
  function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external onlyOwner {
135
110
  require(tokenConfigs_.length != 0, "length can't be 0");
@@ -140,34 +115,15 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
140
115
  }
141
116
 
142
117
  /**
143
- * @notice Set/reset single token configs and main oracle **must not** be zero address
144
- * @param tokenConfig token config struct
145
- * @custom:access Only Governance
146
- * @custom:error NotNullAddress thrown if asset address is zero
147
- * @custom:error NotNullAddress thrown if main-role oracle address for asset is zero
148
- * @custom:event Emits TokenConfigAdded event when vToken config are set by governnace
149
- */
150
- function setTokenConfig(
151
- TokenConfig memory tokenConfig
152
- ) public onlyOwner notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {
153
- tokenConfigs[tokenConfig.asset] = tokenConfig;
154
- emit TokenConfigAdded(
155
- tokenConfig.asset,
156
- tokenConfig.oracles[uint256(OracleRole.MAIN)],
157
- tokenConfig.oracles[uint256(OracleRole.PIVOT)],
158
- tokenConfig.oracles[uint256(OracleRole.FALLBACK)]
159
- );
160
- }
161
-
162
- /**
163
- * @notice Set oracle of any type for the input vToken, input vToken **must** exist
164
- * @param asset asset address
165
- * @param oracle oracle address
166
- * @param role oracle role
118
+ * @notice Sets oracle for a given vToken and role.
119
+ * @dev Supplied vToken **must** exist and main oracle may not be null
120
+ * @param asset Asset address
121
+ * @param oracle Oracle address
122
+ * @param role Oracle role
167
123
  * @custom:access Only Governance
168
- * @custom:error Zero address error if main-role oracle password is set to zero
169
- * @custom:error NotNullAddress error thrown if asset address is zero
170
- * @custom:error TokenConfigExistance error thrown if token config is not set
124
+ * @custom:error Null address error if main-role oracle address is null
125
+ * @custom:error NotNullAddress error is thrown if asset address is null
126
+ * @custom:error TokenConfigExistance error is thrown if token config is not set
171
127
  * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset
172
128
  */
173
129
  function setOracle(
@@ -181,13 +137,13 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
181
137
  }
182
138
 
183
139
  /**
184
- * @notice Enable/disable oracle for the input vToken, input vToken **must** exist
185
- * @param asset asset address
186
- * @param role oracle role
187
- * @param enable expected status
140
+ * @notice Enables/ disables oracle for the input vToken, input vToken **must** exist
141
+ * @param asset Asset address
142
+ * @param role Oracle role
143
+ * @param enable Enabled boolean of the oracle
188
144
  * @custom:access Only Governance
189
- * @custom:error NotNullAddress error thrown if asset address is zero
190
- * @custom:error TokenConfigExistance error thrown if token config is not set
145
+ * @custom:error NotNullAddress error is thrown if asset address is null
146
+ * @custom:error TokenConfigExistance error is thrown if token config is not set
191
147
  */
192
148
  function enableOracle(
193
149
  address asset,
@@ -199,8 +155,8 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
199
155
  }
200
156
 
201
157
  /**
202
- * @notice Update the pivot oracle price. Currently using **twap**
203
- * @dev This function should be called every time before calling getUnderlyingPrice
158
+ * @notice Updates the pivot oracle price. Currently using TWAP
159
+ * @dev This function should always be called before calling getUnderlyingPrice
204
160
  * @param vToken vToken address
205
161
  */
206
162
  function updatePrice(address vToken) external override {
@@ -212,15 +168,26 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
212
168
  }
213
169
 
214
170
  /**
215
- * @notice Get price of underlying asset of the input vToken, check flow:
216
- * - check the global pausing status
217
- * - check price from main oracle against pivot oracle
218
- * - check price from fallback oracle against pivot oracle or main oracle if fails
171
+ * @dev Gets token config by vToken address
219
172
  * @param vToken vToken address
220
- * @return price USD price in scaled decimal places, In case pivot oracle is not available
221
- * but main price is available and validation is successful, main oracle price is returned.
222
- * @custom:error paused error thrown when resilent oracle is paused
223
- * @custom:error Invalid resilient oracle price error thrown if fetched prices from oracle is invalid
173
+ * @return tokenConfig Config for the vToken
174
+ */
175
+ function getTokenConfig(address vToken) external view returns (TokenConfig memory) {
176
+ address asset = address(vToken) == vBnb ? BNB_ADDR : VBep20Interface(vToken).underlying();
177
+ return tokenConfigs[asset];
178
+ }
179
+
180
+ /**
181
+ * @notice Gets price of the underlying asset for a given vToken. Validation flow:
182
+ * - Check if the oracle is paused globally
183
+ * - Validate price from main oracle against pivot oracle
184
+ * - Validate price from fallback oracle against pivot oracle or main oracle if the first validation failed
185
+ * In the case that the pivot oracle is not available but main price is available and validation is successful,
186
+ * main oracle price is returned.
187
+ * @param vToken vToken address
188
+ * @return price USD price in scaled decimal places.
189
+ * @custom:error Paused error is thrown when resilent oracle is paused
190
+ * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid
224
191
  */
225
192
  function getUnderlyingPrice(address vToken) external view override returns (uint256) {
226
193
  require(!paused(), "resilient oracle is paused");
@@ -262,19 +229,65 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
262
229
  }
263
230
 
264
231
  /**
265
- * @notice Get asset underlying vToken asset price
232
+ * @notice Initializes the contract admin and sets the BoundValidator contract address
233
+ * @param _boundValidator Address of the bound validator contract
234
+ */
235
+ function initialize(BoundValidatorInterface _boundValidator) public initializer {
236
+ require(address(_boundValidator) != address(0), "invalid bound validator address");
237
+ boundValidator = _boundValidator;
238
+
239
+ __Ownable_init();
240
+ __Pausable_init();
241
+ }
242
+
243
+ /**
244
+ * @notice Sets/resets single token configs.
245
+ * @dev main oracle **must not** be a null address
246
+ * @param tokenConfig Token config struct
247
+ * @custom:access Only Governance
248
+ * @custom:error NotNullAddress is thrown if asset address is null
249
+ * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null
250
+ * @custom:event Emits TokenConfigAdded event when vToken config is set successfully by governnace
251
+ */
252
+ function setTokenConfig(
253
+ TokenConfig memory tokenConfig
254
+ ) public onlyOwner notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {
255
+ tokenConfigs[tokenConfig.asset] = tokenConfig;
256
+ emit TokenConfigAdded(
257
+ tokenConfig.asset,
258
+ tokenConfig.oracles[uint256(OracleRole.MAIN)],
259
+ tokenConfig.oracles[uint256(OracleRole.PIVOT)],
260
+ tokenConfig.oracles[uint256(OracleRole.FALLBACK)]
261
+ );
262
+ }
263
+
264
+ /**
265
+ * @notice Gets oracle and enabled status by vToken address
266
+ * @param vToken vToken address
267
+ * @param role Oracle role
268
+ * @return oracle Oracle address based on role
269
+ * @return enabled Enabled flag of the oracle based on token config
270
+ */
271
+ function getOracle(address vToken, OracleRole role) public view returns (address oracle, bool enabled) {
272
+ address asset = address(vToken) == vBnb ? BNB_ADDR : VBep20Interface(vToken).underlying();
273
+ oracle = tokenConfigs[asset].oracles[uint256(role)];
274
+ enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];
275
+ }
276
+
277
+ /**
278
+ * @notice Gets underlying asset price for the provided vToken
266
279
  * @dev This function won't revert when price is 0, because the fallback oracle may still be
267
280
  * able to fetch a correct price
268
281
  * @param vToken vToken address
269
- * @param pivotPrice pivot oracle price
270
- * @param pivotEnabled if pivot oracle is not empty and enabled
282
+ * @param pivotPrice Pivot oracle price
283
+ * @param pivotEnabled If pivot oracle is not empty and enabled
271
284
  * @return price USD price in scaled decimals
272
285
  * e.g. vToken decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals
273
286
  * @return pivotValidated Boolean representing if the validation of main oracle price
274
- * and pivot oracle price was successful
275
- * @custom:error Invalid price error thrown if main oracle fails to fetch price of underlying asset
276
- * @custom:error Invalid price error thrown if main oracle is not enabled or main oracle
277
- * address is zero
287
+ * and pivot oracle price were successful
288
+ * @custom:error Invalid price error is thrown if main oracle fails to fetch price of underlying asset
289
+ * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle
290
+ * address is null
278
291
  */
279
292
  function _getMainOraclePrice(
280
293
  address vToken,
@@ -303,14 +316,14 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
303
316
  }
304
317
 
305
318
  /**
306
- * @notice This function won't revert when price is 0, because the getUnderlyingPrice checks if pirce is > 0
319
+ * @dev This function won't revert when the price is 0 because getUnderlyingPrice checks if price is > 0
307
320
  * @param vToken vToken address
308
321
  * @return price USD price in 18 decimals
309
322
  * @return pivotValidated Boolean representing if the validation of fallback oracle price
310
- * and pivot oracle price was successfull
311
- * @custom:error Invalid price error thrown if fallback oracle fails to fetch price of underlying asset
312
- * @custom:error Invalid price error thrown if fallback oracle is not enabled or fallback oracle
313
- * address is zero
323
+ * and pivot oracle price were successfull
324
+ * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of underlying asset
325
+ * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle
326
+ * address is null
314
327
  */
315
328
  function _getFallbackOraclePrice(address vToken, uint256 pivotPrice) internal view returns (uint256, bool) {
316
329
  (address fallbackOracle, bool fallbackEnabled) = getOracle(vToken, OracleRole.FALLBACK);
@@ -1,6 +1,14 @@
1
1
  // SPDX-License-Identifier: BSD-3-Clause
2
2
  pragma solidity 0.8.13;
3
3
 
4
+ interface IPancakePair {
5
+ function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
6
+
7
+ function price0CumulativeLast() external view returns (uint256);
8
+
9
+ function price1CumulativeLast() external view returns (uint256);
10
+ }
11
+
4
12
  library FixedPoint {
5
13
  // range: [0, 2**112 - 1]
6
14
  // resolution: 1 / 2**112
@@ -58,11 +66,3 @@ library PancakeOracleLibrary {
58
66
  }
59
67
  }
60
68
  }
61
-
62
- interface IPancakePair {
63
- function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
64
-
65
- function price0CumulativeLast() external view returns (uint256);
66
-
67
- function price1CumulativeLast() external view returns (uint256);
68
- }
@@ -14,7 +14,7 @@ contract BinanceOracle is Initializable {
14
14
  address public immutable vBnb;
15
15
 
16
16
  /// @notice Constructor for the implementation contract. Sets immutable variables.
17
- /// @param vBnbAddress The address of the VBNB
17
+ /// @param vBnbAddress The address of the vBNB
18
18
  /// @custom:oz-upgrades-unsafe-allow constructor
19
19
  constructor(address vBnbAddress) {
20
20
  require(vBnbAddress != address(0), "can't be zero address");
@@ -23,7 +23,7 @@ contract BinanceOracle is Initializable {
23
23
  }
24
24
 
25
25
  /**
26
- * @notice Sets the contracts required to fetch price
26
+ * @notice Sets the contracts required to fetch prices
27
27
  * @param feed Address of binance oracle feed registry.
28
28
  */
29
29
  function initialize(FeedRegistryInterface feed) public initializer {
@@ -31,9 +31,9 @@ contract BinanceOracle is Initializable {
31
31
  }
32
32
 
33
33
  /**
34
- * @notice Gets the price of vToken from binance oracle
34
+ * @notice Gets the price of a vToken from the binance oracle
35
35
  * @param vToken Address of the vToken
36
- * @return price in USD
36
+ * @return Price in USD
37
37
  */
38
38
  function getUnderlyingPrice(VBep20Interface vToken) public view returns (uint256) {
39
39
  string memory symbol;