@venusprotocol/oracle 1.6.1 → 1.6.2
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/LICENSE +11 -0
- package/README.md +107 -0
- 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 +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +215 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +183 -0
- 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 +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.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 +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +115 -0
- 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/build-info/a47a69a8f108d3e7113faf89771988ff.json +1 -0
- package/artifacts/contracts/Governance/AccessControlManager.sol/AccessControlManager.dbg.json +4 -0
- package/artifacts/contracts/Governance/AccessControlManager.sol/AccessControlManager.json +369 -0
- package/artifacts/contracts/Governance/AccessControlled.sol/AccessControlled.dbg.json +4 -0
- package/artifacts/contracts/Governance/AccessControlled.sol/AccessControlled.json +181 -0
- package/artifacts/contracts/Governance/IAccessControlManager.sol/IAccessControlManager.dbg.json +4 -0
- package/artifacts/contracts/Governance/IAccessControlManager.sol/IAccessControlManager.json +282 -0
- package/artifacts/contracts/PriceOracle.sol/PriceOracle.dbg.json +1 -1
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +1 -1
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json +130 -2
- package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.dbg.json +1 -1
- 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/ResilientOracleInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/PublicResolverInterface.sol/PublicResolverInterface.dbg.json +4 -0
- package/artifacts/contracts/interfaces/PublicResolverInterface.sol/PublicResolverInterface.json +30 -0
- 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 +4 -0
- package/artifacts/contracts/interfaces/SIDRegistryInterface.sol/SIDRegistryInterface.json +30 -0
- 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 +37 -6
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.dbg.json +1 -1
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.json +131 -2
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.json +122 -6
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.json +130 -2
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.json +132 -3
- package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.dbg.json +1 -1
- 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/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/MockSimpleOracle.dbg.json +1 -1
- 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/Governance/AccessControlManager.sol +99 -0
- package/contracts/Governance/AccessControlled.sol +75 -0
- package/contracts/Governance/IAccessControlManager.sol +22 -0
- package/contracts/ResilientOracle.sol +44 -14
- package/contracts/interfaces/PublicResolverInterface.sol +7 -0
- package/contracts/interfaces/SIDRegistryInterface.sol +7 -0
- package/contracts/oracles/BinanceOracle.sol +35 -7
- package/contracts/oracles/BoundValidator.sol +36 -8
- package/contracts/oracles/ChainlinkOracle.sol +31 -21
- package/contracts/oracles/PythOracle.sol +23 -8
- package/contracts/oracles/TwapOracle.sol +41 -11
- package/deploy/1-deploy-oracles.ts +149 -0
- package/deploy/2-configure-feeds.ts +208 -0
- package/deployments/bsctestnet/AccessControlManager.json +563 -0
- package/deployments/bsctestnet/BinanceOracle.json +66 -40
- package/deployments/bsctestnet/BinanceOracle_Implementation.json +84 -38
- package/deployments/bsctestnet/BinanceOracle_Proxy.json +34 -34
- package/deployments/bsctestnet/BoundValidator.json +177 -39
- package/deployments/bsctestnet/BoundValidator_Implementation.json +248 -40
- package/deployments/bsctestnet/BoundValidator_Proxy.json +51 -37
- package/deployments/bsctestnet/ChainlinkOracle.json +161 -50
- package/deployments/bsctestnet/ChainlinkOracle_Implementation.json +239 -47
- package/deployments/bsctestnet/ChainlinkOracle_Proxy.json +44 -44
- package/deployments/bsctestnet/DefaultProxyAdmin.json +18 -18
- package/deployments/bsctestnet/PythOracle.json +178 -45
- package/deployments/bsctestnet/PythOracle_Implementation.json +246 -43
- package/deployments/bsctestnet/PythOracle_Proxy.json +53 -43
- package/deployments/bsctestnet/ResilientOracle.json +167 -48
- package/deployments/bsctestnet/ResilientOracle_Implementation.json +254 -51
- package/deployments/bsctestnet/ResilientOracle_Proxy.json +42 -46
- package/deployments/bsctestnet/TwapOracle.json +178 -40
- package/deployments/bsctestnet/TwapOracle_Implementation.json +270 -58
- package/deployments/bsctestnet/TwapOracle_Proxy.json +51 -37
- package/deployments/bsctestnet/solcInputs/{6153c675ce838eebb6442d63350712be.json → 30f2cb3e89e183b8669f05bddf9426d9.json} +46 -7
- package/package.json +3 -2
- package/artifacts/build-info/1d7bedd9b14544f287811332b9a539d7.json +0 -1
- package/artifacts/build-info/57da5d39a9f98618d0dcf1f6d4ff6b0d.json +0 -1
- package/artifacts/build-info/f6af69795174616b8b4a6373f9f1c538.json +0 -1
- package/deploy/1-deploy-oracles.d.ts +0 -2
- package/deploy/1-deploy-oracles.d.ts.map +0 -1
- package/deploy/1-deploy-oracles.js +0 -128
- package/deploy/1-deploy-oracles.js.map +0 -1
- package/deploy/2-configure-feeds.d.ts +0 -2
- package/deploy/2-configure-feeds.d.ts.map +0 -1
- package/deploy/2-configure-feeds.js +0 -139
- package/deploy/2-configure-feeds.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
pragma solidity 0.8.13;
|
|
3
|
+
|
|
4
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
5
|
+
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
|
|
6
|
+
|
|
7
|
+
import "./IAccessControlManager.sol";
|
|
8
|
+
|
|
9
|
+
abstract contract AccessControlled is Initializable, Ownable2StepUpgradeable {
|
|
10
|
+
/// @notice Access control manager contract
|
|
11
|
+
IAccessControlManager private _accessControlManager;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @dev This empty reserved space is put in place to allow future versions to add new
|
|
15
|
+
* variables without shifting down storage in the inheritance chain.
|
|
16
|
+
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
17
|
+
*/
|
|
18
|
+
uint256[49] private __gap;
|
|
19
|
+
|
|
20
|
+
/// @notice Emitted when access control manager contract address is changed
|
|
21
|
+
event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);
|
|
22
|
+
|
|
23
|
+
/// @notice Thrown when the action is prohibited by AccessControlManager
|
|
24
|
+
error Unauthorized(address sender, address calledContract, string methodSignature);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @notice Sets the address of AccessControlManager
|
|
28
|
+
* @dev Admin function to set address of AccessControlManager
|
|
29
|
+
* @param accessControlManager_ The new address of the AccessControlManager
|
|
30
|
+
* @custom:event Emits NewAccessControlManager event
|
|
31
|
+
* @custom:access Only Governance
|
|
32
|
+
*/
|
|
33
|
+
function setAccessControlManager(address accessControlManager_) external onlyOwner {
|
|
34
|
+
_setAccessControlManager(accessControlManager_);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @notice Returns the address of the access control manager contract
|
|
39
|
+
*/
|
|
40
|
+
function accessControlManager() external view returns (IAccessControlManager) {
|
|
41
|
+
return _accessControlManager;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {
|
|
45
|
+
__Ownable2Step_init();
|
|
46
|
+
__AccessControlled_init_unchained(accessControlManager_);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {
|
|
50
|
+
_setAccessControlManager(accessControlManager_);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @dev Internal function to set address of AccessControlManager
|
|
55
|
+
* @param accessControlManager_ The new address of the AccessControlManager
|
|
56
|
+
*/
|
|
57
|
+
function _setAccessControlManager(address accessControlManager_) internal {
|
|
58
|
+
require(address(accessControlManager_) != address(0), "invalid acess control manager address");
|
|
59
|
+
address oldAccessControlManager = address(_accessControlManager);
|
|
60
|
+
_accessControlManager = IAccessControlManager(accessControlManager_);
|
|
61
|
+
emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @notice Reverts if the call is not allowed by AccessControlManager
|
|
66
|
+
* @param signature Method signature
|
|
67
|
+
*/
|
|
68
|
+
function _checkAccessAllowed(string memory signature) internal view {
|
|
69
|
+
bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);
|
|
70
|
+
|
|
71
|
+
if (!isAllowedToCall) {
|
|
72
|
+
revert Unauthorized(msg.sender, address(this), signature);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
pragma solidity 0.8.13;
|
|
3
|
+
|
|
4
|
+
import "@openzeppelin/contracts/access/IAccessControl.sol";
|
|
5
|
+
|
|
6
|
+
interface IAccessControlManager is IAccessControl {
|
|
7
|
+
function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;
|
|
8
|
+
|
|
9
|
+
function revokeCallPermission(
|
|
10
|
+
address contractAddress,
|
|
11
|
+
string calldata functionSig,
|
|
12
|
+
address accountToRevoke
|
|
13
|
+
) external;
|
|
14
|
+
|
|
15
|
+
function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);
|
|
16
|
+
|
|
17
|
+
function hasPermission(
|
|
18
|
+
address account,
|
|
19
|
+
address contractAddress,
|
|
20
|
+
string calldata functionSig
|
|
21
|
+
) external view returns (bool);
|
|
22
|
+
}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// SPDX-FileCopyrightText: 2022 Venus
|
|
3
3
|
pragma solidity 0.8.13;
|
|
4
4
|
|
|
5
|
-
import "@openzeppelin/contracts-upgradeable/
|
|
5
|
+
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
|
|
6
6
|
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
|
|
7
7
|
import "./interfaces/VBep20Interface.sol";
|
|
8
8
|
import "./interfaces/OracleInterface.sol";
|
|
9
|
+
import "./Governance/AccessControlled.sol";
|
|
9
10
|
|
|
10
|
-
contract ResilientOracle is
|
|
11
|
+
contract ResilientOracle is PausableUpgradeable, AccessControlled, ResilientOracleInterface {
|
|
11
12
|
/**
|
|
12
13
|
* @dev Oracle roles:
|
|
13
14
|
* **main**: The most trustworthy price source
|
|
@@ -38,6 +39,10 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
38
39
|
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
39
40
|
address public immutable vBnb;
|
|
40
41
|
|
|
42
|
+
/// @notice VAI address
|
|
43
|
+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
44
|
+
address public immutable vai;
|
|
45
|
+
|
|
41
46
|
/// @notice Set this as asset address for BNB. This is the underlying for vBNB
|
|
42
47
|
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
43
48
|
|
|
@@ -78,9 +83,11 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
78
83
|
|
|
79
84
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
80
85
|
/// @param vBnbAddress The address of the vBNB
|
|
86
|
+
/// @param vaiAddress The address of the VAI
|
|
81
87
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
82
|
-
constructor(address vBnbAddress) notNullAddress(vBnbAddress) {
|
|
88
|
+
constructor(address vBnbAddress, address vaiAddress) notNullAddress(vBnbAddress) {
|
|
83
89
|
vBnb = vBnbAddress;
|
|
90
|
+
vai = vaiAddress;
|
|
84
91
|
_disableInitializers();
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -88,7 +95,8 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
88
95
|
* @notice Pauses oracle
|
|
89
96
|
* @custom:access Only Governance
|
|
90
97
|
*/
|
|
91
|
-
function pause() external
|
|
98
|
+
function pause() external {
|
|
99
|
+
_checkAccessAllowed("pause()");
|
|
92
100
|
_pause();
|
|
93
101
|
}
|
|
94
102
|
|
|
@@ -96,7 +104,8 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
96
104
|
* @notice Unpauses oracle
|
|
97
105
|
* @custom:access Only Governance
|
|
98
106
|
*/
|
|
99
|
-
function unpause() external
|
|
107
|
+
function unpause() external {
|
|
108
|
+
_checkAccessAllowed("unpause()");
|
|
100
109
|
_unpause();
|
|
101
110
|
}
|
|
102
111
|
|
|
@@ -106,7 +115,8 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
106
115
|
* @custom:access Only Governance
|
|
107
116
|
* @custom:error Throws a length error if the lenght of the token configs array is 0
|
|
108
117
|
*/
|
|
109
|
-
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external
|
|
118
|
+
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {
|
|
119
|
+
_checkAccessAllowed("setTokenConfigs(TokenConfig[])");
|
|
110
120
|
require(tokenConfigs_.length != 0, "length can't be 0");
|
|
111
121
|
uint256 numTokenConfigs = tokenConfigs_.length;
|
|
112
122
|
for (uint256 i; i < numTokenConfigs; ++i) {
|
|
@@ -130,7 +140,8 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
130
140
|
address asset,
|
|
131
141
|
address oracle,
|
|
132
142
|
OracleRole role
|
|
133
|
-
) external
|
|
143
|
+
) external notNullAddress(asset) checkTokenConfigExistance(asset) {
|
|
144
|
+
_checkAccessAllowed("setOracle(address,address,OracleRole)");
|
|
134
145
|
require(!(oracle == address(0) && role == OracleRole.MAIN), "can't set zero address to main oracle");
|
|
135
146
|
tokenConfigs[asset].oracles[uint256(role)] = oracle;
|
|
136
147
|
emit OracleSet(asset, oracle, uint256(role));
|
|
@@ -149,7 +160,8 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
149
160
|
address asset,
|
|
150
161
|
OracleRole role,
|
|
151
162
|
bool enable
|
|
152
|
-
) external
|
|
163
|
+
) external notNullAddress(asset) checkTokenConfigExistance(asset) {
|
|
164
|
+
_checkAccessAllowed("enableOracle(address,OracleRole,address)");
|
|
153
165
|
tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;
|
|
154
166
|
emit OracleEnabled(asset, uint256(role), enable);
|
|
155
167
|
}
|
|
@@ -173,7 +185,7 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
173
185
|
* @return tokenConfig Config for the vToken
|
|
174
186
|
*/
|
|
175
187
|
function getTokenConfig(address vToken) external view returns (TokenConfig memory) {
|
|
176
|
-
address asset =
|
|
188
|
+
address asset = _getUnderlyingAsset(vToken);
|
|
177
189
|
return tokenConfigs[asset];
|
|
178
190
|
}
|
|
179
191
|
|
|
@@ -231,13 +243,13 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
231
243
|
/**
|
|
232
244
|
* @notice Initializes the contract admin and sets the BoundValidator contract address
|
|
233
245
|
* @param _boundValidator Address of the bound validator contract
|
|
246
|
+
* @param accessControlManager_ Address of the access control manager contract
|
|
234
247
|
*/
|
|
235
|
-
function initialize(BoundValidatorInterface _boundValidator) public initializer {
|
|
248
|
+
function initialize(BoundValidatorInterface _boundValidator, address accessControlManager_) public initializer {
|
|
236
249
|
require(address(_boundValidator) != address(0), "invalid bound validator address");
|
|
237
250
|
boundValidator = _boundValidator;
|
|
238
251
|
|
|
239
|
-
|
|
240
|
-
__Pausable_init();
|
|
252
|
+
__AccessControlled_init_unchained(accessControlManager_);
|
|
241
253
|
}
|
|
242
254
|
|
|
243
255
|
/**
|
|
@@ -251,7 +263,9 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
251
263
|
*/
|
|
252
264
|
function setTokenConfig(
|
|
253
265
|
TokenConfig memory tokenConfig
|
|
254
|
-
) public
|
|
266
|
+
) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {
|
|
267
|
+
_checkAccessAllowed("setTokenConfig(TokenConfig)");
|
|
268
|
+
|
|
255
269
|
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
256
270
|
emit TokenConfigAdded(
|
|
257
271
|
tokenConfig.asset,
|
|
@@ -269,7 +283,8 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
269
283
|
* @return enabled Enabled flag of the oracle based on token config
|
|
270
284
|
*/
|
|
271
285
|
function getOracle(address vToken, OracleRole role) public view returns (address oracle, bool enabled) {
|
|
272
|
-
address asset =
|
|
286
|
+
address asset = _getUnderlyingAsset(vToken);
|
|
287
|
+
|
|
273
288
|
oracle = tokenConfigs[asset].oracles[uint256(role)];
|
|
274
289
|
enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];
|
|
275
290
|
}
|
|
@@ -343,4 +358,19 @@ contract ResilientOracle is OwnableUpgradeable, PausableUpgradeable, ResilientOr
|
|
|
343
358
|
|
|
344
359
|
return (INVALID_PRICE, false);
|
|
345
360
|
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @dev This function returns the underlying asset of a vToken
|
|
364
|
+
* @param vToken vToken address
|
|
365
|
+
* @return asset underlying asset address
|
|
366
|
+
*/
|
|
367
|
+
function _getUnderlyingAsset(address vToken) internal view returns (address asset) {
|
|
368
|
+
if (address(vToken) == vBnb) {
|
|
369
|
+
asset = BNB_ADDR;
|
|
370
|
+
} else if (address(vToken) == vai) {
|
|
371
|
+
asset = vai;
|
|
372
|
+
} else {
|
|
373
|
+
asset = VBep20Interface(vToken).underlying();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
346
376
|
}
|
|
@@ -3,31 +3,54 @@ pragma solidity 0.8.13;
|
|
|
3
3
|
|
|
4
4
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
5
5
|
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
6
|
-
import "../interfaces/FeedRegistryInterface.sol";
|
|
7
6
|
import "../interfaces/VBep20Interface.sol";
|
|
7
|
+
import "../interfaces/SIDRegistryInterface.sol";
|
|
8
|
+
import "../interfaces/FeedRegistryInterface.sol";
|
|
9
|
+
import "../interfaces/PublicResolverInterface.sol";
|
|
8
10
|
|
|
9
11
|
contract BinanceOracle is Initializable {
|
|
10
|
-
|
|
12
|
+
address public sidRegistryAddress;
|
|
11
13
|
|
|
12
14
|
/// @notice vBNB address
|
|
13
15
|
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
14
16
|
address public immutable vBnb;
|
|
15
17
|
|
|
18
|
+
/// @notice VAI address
|
|
19
|
+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
20
|
+
address public immutable vai;
|
|
21
|
+
|
|
16
22
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
17
23
|
/// @param vBnbAddress The address of the vBNB
|
|
24
|
+
/// @param vaiAddress The address of the VAI
|
|
18
25
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
19
|
-
constructor(address vBnbAddress) {
|
|
20
|
-
require(vBnbAddress != address(0), "can't be zero address");
|
|
26
|
+
constructor(address vBnbAddress, address vaiAddress) {
|
|
27
|
+
require(vBnbAddress != address(0), "vBNB can't be zero address");
|
|
28
|
+
require(vaiAddress != address(0), "VAI can't be zero address");
|
|
21
29
|
vBnb = vBnbAddress;
|
|
30
|
+
vai = vaiAddress;
|
|
22
31
|
_disableInitializers();
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
/**
|
|
26
35
|
* @notice Sets the contracts required to fetch prices
|
|
27
|
-
* @param
|
|
36
|
+
* @param _sidRegistryAddress Address of SID registry
|
|
37
|
+
*/
|
|
38
|
+
function initialize(address _sidRegistryAddress) public initializer {
|
|
39
|
+
sidRegistryAddress = _sidRegistryAddress;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @notice Uses Space ID to fetch the feed registry address
|
|
44
|
+
* @return feedRegistryAddress Address of binance oracle feed registry.
|
|
28
45
|
*/
|
|
29
|
-
function
|
|
30
|
-
|
|
46
|
+
function getFeedRegistryAddress() public view returns (address) {
|
|
47
|
+
bytes32 nodeHash = 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff;
|
|
48
|
+
|
|
49
|
+
SIDRegistryInterface sidRegistry = SIDRegistryInterface(sidRegistryAddress);
|
|
50
|
+
address publicResolverAddress = sidRegistry.resolver(nodeHash);
|
|
51
|
+
PublicResolverInterface publicResolver = PublicResolverInterface(publicResolverAddress);
|
|
52
|
+
|
|
53
|
+
return publicResolver.addr(nodeHash);
|
|
31
54
|
}
|
|
32
55
|
|
|
33
56
|
/**
|
|
@@ -43,6 +66,9 @@ contract BinanceOracle is Initializable {
|
|
|
43
66
|
if (address(vToken) == vBnb) {
|
|
44
67
|
symbol = "BNB";
|
|
45
68
|
decimals = 18;
|
|
69
|
+
} else if (address(vToken) == vai) {
|
|
70
|
+
symbol = "VAI";
|
|
71
|
+
decimals = 18;
|
|
46
72
|
} else {
|
|
47
73
|
IERC20Metadata underlyingToken = IERC20Metadata(vToken.underlying());
|
|
48
74
|
symbol = underlyingToken.symbol();
|
|
@@ -53,6 +79,8 @@ contract BinanceOracle is Initializable {
|
|
|
53
79
|
symbol = "BNB";
|
|
54
80
|
}
|
|
55
81
|
|
|
82
|
+
FeedRegistryInterface feedRegistry = FeedRegistryInterface(getFeedRegistryAddress());
|
|
83
|
+
|
|
56
84
|
(, int256 answer, , , ) = feedRegistry.latestRoundDataByName(symbol, "USD");
|
|
57
85
|
|
|
58
86
|
uint256 decimalDelta = feedRegistry.decimalsByName(symbol, "USD");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
2
|
pragma solidity 0.8.13;
|
|
3
3
|
|
|
4
|
-
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
5
4
|
import "../interfaces/VBep20Interface.sol";
|
|
6
5
|
import "../interfaces/OracleInterface.sol";
|
|
6
|
+
import "../Governance/AccessControlled.sol";
|
|
7
7
|
|
|
8
8
|
struct ValidateConfig {
|
|
9
9
|
/// @notice asset address
|
|
@@ -18,7 +18,7 @@ struct ValidateConfig {
|
|
|
18
18
|
|
|
19
19
|
// BoundValidator provides some common functions and can be used
|
|
20
20
|
// to wrap up other contracts to form pivot oracles
|
|
21
|
-
contract BoundValidator is
|
|
21
|
+
contract BoundValidator is AccessControlled, BoundValidatorInterface {
|
|
22
22
|
/// @notice validation configs by asset
|
|
23
23
|
mapping(address => ValidateConfig) public validateConfigs;
|
|
24
24
|
|
|
@@ -26,6 +26,10 @@ contract BoundValidator is OwnableUpgradeable, BoundValidatorInterface {
|
|
|
26
26
|
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
27
27
|
address public immutable vBnb;
|
|
28
28
|
|
|
29
|
+
/// @notice VAI address
|
|
30
|
+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
31
|
+
address public immutable vai;
|
|
32
|
+
|
|
29
33
|
/// @notice Set this as asset address for BNB. This is the underlying for vBNB
|
|
30
34
|
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
31
35
|
|
|
@@ -34,10 +38,13 @@ contract BoundValidator is OwnableUpgradeable, BoundValidatorInterface {
|
|
|
34
38
|
|
|
35
39
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
36
40
|
/// @param vBnbAddress The address of the vBNB
|
|
41
|
+
/// @param vaiAddress The address of the VAI
|
|
37
42
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
38
|
-
constructor(address vBnbAddress) {
|
|
43
|
+
constructor(address vBnbAddress, address vaiAddress) {
|
|
39
44
|
require(vBnbAddress != address(0), "can't be a zero address");
|
|
45
|
+
require(vaiAddress != address(0), "can't be a zero address");
|
|
40
46
|
vBnb = vBnbAddress;
|
|
47
|
+
vai = vaiAddress;
|
|
41
48
|
_disableInitializers();
|
|
42
49
|
}
|
|
43
50
|
|
|
@@ -48,7 +55,9 @@ contract BoundValidator is OwnableUpgradeable, BoundValidatorInterface {
|
|
|
48
55
|
* @custom:error Zero length error is thrown if length of the config array is 0
|
|
49
56
|
* @custom:event Emits ValidateConfigAdded for each validation config that is successfully set
|
|
50
57
|
*/
|
|
51
|
-
function setValidateConfigs(ValidateConfig[] memory configs) external virtual
|
|
58
|
+
function setValidateConfigs(ValidateConfig[] memory configs) external virtual {
|
|
59
|
+
_checkAccessAllowed("setValidateConfigs(ValidateConfig[])");
|
|
60
|
+
|
|
52
61
|
require(configs.length > 0, "invalid validate config length");
|
|
53
62
|
for (uint256 i; i < configs.length; ++i) {
|
|
54
63
|
setValidateConfig(configs[i]);
|
|
@@ -57,9 +66,11 @@ contract BoundValidator is OwnableUpgradeable, BoundValidatorInterface {
|
|
|
57
66
|
|
|
58
67
|
/**
|
|
59
68
|
* @notice Initializes the owner of the contract
|
|
69
|
+
* @param accessControlManager_ Address of the access control manager contract
|
|
60
70
|
*/
|
|
61
|
-
function initialize() public initializer {
|
|
62
|
-
|
|
71
|
+
function initialize(address accessControlManager_) public initializer {
|
|
72
|
+
__Ownable2Step_init();
|
|
73
|
+
__AccessControlled_init_unchained(accessControlManager_);
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
/**
|
|
@@ -71,7 +82,9 @@ contract BoundValidator is OwnableUpgradeable, BoundValidatorInterface {
|
|
|
71
82
|
* @custom:error Range error thrown if lower bound is greater than upper bound
|
|
72
83
|
* @custom:event Emits ValidateConfigAdded when a validation config is successfully set
|
|
73
84
|
*/
|
|
74
|
-
function setValidateConfig(ValidateConfig memory config) public virtual
|
|
85
|
+
function setValidateConfig(ValidateConfig memory config) public virtual {
|
|
86
|
+
_checkAccessAllowed("setValidateConfig(ValidateConfig)");
|
|
87
|
+
|
|
75
88
|
require(config.asset != address(0), "asset can't be zero address");
|
|
76
89
|
require(config.upperBoundRatio > 0 && config.lowerBoundRatio > 0, "bound must be positive");
|
|
77
90
|
require(config.upperBoundRatio > config.lowerBoundRatio, "upper bound must be higher than lowner bound");
|
|
@@ -91,7 +104,7 @@ contract BoundValidator is OwnableUpgradeable, BoundValidatorInterface {
|
|
|
91
104
|
uint256 reportedPrice,
|
|
92
105
|
uint256 anchorPrice
|
|
93
106
|
) public view virtual override returns (bool) {
|
|
94
|
-
address asset =
|
|
107
|
+
address asset = _getUnderlyingAsset(vToken);
|
|
95
108
|
|
|
96
109
|
require(validateConfigs[asset].upperBoundRatio != 0, "validation config not exist");
|
|
97
110
|
require(anchorPrice != 0, "anchor price is not valid");
|
|
@@ -114,6 +127,21 @@ contract BoundValidator is OwnableUpgradeable, BoundValidatorInterface {
|
|
|
114
127
|
return false;
|
|
115
128
|
}
|
|
116
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @dev This function returns the underlying asset of a vToken
|
|
132
|
+
* @param vToken vToken address
|
|
133
|
+
* @return asset underlying asset address
|
|
134
|
+
*/
|
|
135
|
+
function _getUnderlyingAsset(address vToken) internal view returns (address asset) {
|
|
136
|
+
if (address(vToken) == vBnb) {
|
|
137
|
+
asset = BNB_ADDR;
|
|
138
|
+
} else if (address(vToken) == vai) {
|
|
139
|
+
asset = vai;
|
|
140
|
+
} else {
|
|
141
|
+
asset = VBep20Interface(vToken).underlying();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
117
145
|
// BoundValidator is to get inherited, so it's a good practice to add some storage gaps like
|
|
118
146
|
// OpenZepplin proposed in their contracts: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
119
147
|
// solhint-disable-next-line
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
2
|
pragma solidity 0.8.13;
|
|
3
3
|
|
|
4
|
-
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
5
4
|
import "../interfaces/VBep20Interface.sol";
|
|
6
5
|
import "../interfaces/OracleInterface.sol";
|
|
7
6
|
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
|
|
7
|
+
import "../Governance/AccessControlled.sol";
|
|
8
8
|
|
|
9
9
|
struct TokenConfig {
|
|
10
10
|
/// @notice Underlying token address, which can't be a null address and can be used to check if a token is supported
|
|
@@ -16,14 +16,15 @@ struct TokenConfig {
|
|
|
16
16
|
uint256 maxStalePeriod;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
contract ChainlinkOracle is
|
|
20
|
-
/// @notice VAI token is considered $1 constantly in oracle for now
|
|
21
|
-
uint256 public constant VAI_VALUE = 1e18;
|
|
22
|
-
|
|
19
|
+
contract ChainlinkOracle is AccessControlled, OracleInterface {
|
|
23
20
|
/// @notice vBNB address
|
|
24
21
|
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
25
22
|
address public immutable vBnb;
|
|
26
23
|
|
|
24
|
+
/// @notice VAI address
|
|
25
|
+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
26
|
+
address public immutable vai;
|
|
27
|
+
|
|
27
28
|
/// @notice Set this as asset address for BNB. This is the underlying address for vBNB
|
|
28
29
|
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
29
30
|
|
|
@@ -51,9 +52,11 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
51
52
|
|
|
52
53
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
53
54
|
/// @param vBnbAddress The address of the vBNB
|
|
55
|
+
/// @param vaiAddress The address of the VAI
|
|
54
56
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
55
|
-
constructor(address vBnbAddress) notNullAddress(vBnbAddress) {
|
|
57
|
+
constructor(address vBnbAddress, address vaiAddress) notNullAddress(vBnbAddress) notNullAddress(vaiAddress) {
|
|
56
58
|
vBnb = vBnbAddress;
|
|
59
|
+
vai = vaiAddress;
|
|
57
60
|
_disableInitializers();
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -68,7 +71,9 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
68
71
|
function setUnderlyingPrice(
|
|
69
72
|
VBep20Interface vToken,
|
|
70
73
|
uint256 underlyingPriceMantissa
|
|
71
|
-
) external notNullAddress(address(vToken))
|
|
74
|
+
) external notNullAddress(address(vToken)) {
|
|
75
|
+
_checkAccessAllowed("setUnderlyingPrice(VBep20Interface,uint256)");
|
|
76
|
+
|
|
72
77
|
address asset = address(vToken) == vBnb ? BNB_ADDR : address(vToken.underlying());
|
|
73
78
|
emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);
|
|
74
79
|
prices[asset] = underlyingPriceMantissa;
|
|
@@ -81,9 +86,11 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
81
86
|
* @custom:access Only Governance
|
|
82
87
|
* @custom:event Emits PricePosted event on succesfully setup of underlying price
|
|
83
88
|
*/
|
|
84
|
-
function setDirectPrice(address asset, uint256 price) external notNullAddress(asset)
|
|
85
|
-
|
|
89
|
+
function setDirectPrice(address asset, uint256 price) external notNullAddress(asset) {
|
|
90
|
+
_checkAccessAllowed("setDirectPrice(asset,price)");
|
|
91
|
+
|
|
86
92
|
prices[asset] = price;
|
|
93
|
+
emit PricePosted(asset, prices[asset], price, price);
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
/**
|
|
@@ -92,7 +99,8 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
92
99
|
* @custom:access Only Governance
|
|
93
100
|
* @custom:error Zero length error thrown, if length of the array in parameter is 0
|
|
94
101
|
*/
|
|
95
|
-
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external
|
|
102
|
+
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {
|
|
103
|
+
_checkAccessAllowed("setTokenConfigs(TokenConfig[])");
|
|
96
104
|
require(tokenConfigs_.length > 0, "length can't be 0");
|
|
97
105
|
uint256 numTokenConfigs = tokenConfigs_.length;
|
|
98
106
|
for (uint256 i; i < numTokenConfigs; ++i) {
|
|
@@ -100,9 +108,12 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
100
108
|
}
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
/**
|
|
112
|
+
* @notice Initializes the owner of the contract
|
|
113
|
+
* @param accessControlManager_ Address of the access control manager contract
|
|
114
|
+
*/
|
|
115
|
+
function initialize(address accessControlManager_) public initializer {
|
|
116
|
+
__AccessControlled_init_unchained(accessControlManager_);
|
|
106
117
|
}
|
|
107
118
|
|
|
108
119
|
/**
|
|
@@ -116,7 +127,9 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
116
127
|
*/
|
|
117
128
|
function setTokenConfig(
|
|
118
129
|
TokenConfig memory tokenConfig
|
|
119
|
-
) public
|
|
130
|
+
) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.feed) {
|
|
131
|
+
_checkAccessAllowed("setTokenConfig(TokenConfig)");
|
|
132
|
+
|
|
120
133
|
require(tokenConfig.maxStalePeriod > 0, "stale period can't be zero");
|
|
121
134
|
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
122
135
|
emit TokenConfigAdded(tokenConfig.asset, tokenConfig.feed, tokenConfig.maxStalePeriod);
|
|
@@ -128,13 +141,7 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
128
141
|
* @return price Underlying price in USD
|
|
129
142
|
*/
|
|
130
143
|
function getUnderlyingPrice(address vToken) public view override returns (uint256) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (_compareStrings(symbol, "VAI")) {
|
|
134
|
-
return VAI_VALUE;
|
|
135
|
-
} else {
|
|
136
|
-
return _getUnderlyingPriceInternal(VBep20Interface(vToken));
|
|
137
|
-
}
|
|
144
|
+
return _getUnderlyingPriceInternal(VBep20Interface(vToken));
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
/**
|
|
@@ -153,6 +160,9 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
153
160
|
if (address(vToken) == vBnb) {
|
|
154
161
|
token = BNB_ADDR;
|
|
155
162
|
decimals = 18;
|
|
163
|
+
} else if (address(vToken) == vai) {
|
|
164
|
+
token = vai;
|
|
165
|
+
decimals = 18;
|
|
156
166
|
} else {
|
|
157
167
|
token = vToken.underlying();
|
|
158
168
|
decimals = VBep20Interface(token).decimals();
|