@venusprotocol/oracle 1.6.12-dev.1 → 1.6.12-dev.3
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/contracts/ResilientOracle.sol +84 -55
- package/contracts/interfaces/FeedRegistryInterface.sol +4 -4
- package/contracts/interfaces/OracleInterface.sol +3 -1
- package/contracts/oracles/BinanceOracle.sol +46 -51
- package/contracts/oracles/BoundValidator.sol +22 -51
- package/contracts/oracles/ChainlinkOracle.sol +19 -59
- package/contracts/oracles/PythOracle.sol +27 -47
- package/contracts/oracles/TwapOracle.sol +36 -54
- package/contracts/oracles/mocks/MockBinanceFeedRegistry.sol +6 -6
- package/contracts/test/MockSimpleOracle.sol +14 -2
- package/deployments/bscmainnet/BinanceOracle_Implementation.json +1 -1
- package/deployments/bsctestnet/BinanceOracle_Implementation.json +1 -1
- package/dist/deploy/1-deploy-oracles.js +6 -6
- package/dist/deploy/1-deploy-oracles.js.map +1 -1
- package/package.json +3 -3
|
@@ -227,20 +227,33 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
227
227
|
* @param vToken vToken address
|
|
228
228
|
*/
|
|
229
229
|
function updatePrice(address vToken) external override {
|
|
230
|
-
|
|
230
|
+
address asset = _getUnderlyingAsset(vToken);
|
|
231
|
+
(address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);
|
|
232
|
+
if (pivotOracle != address(0) && pivotOracleEnabled) {
|
|
233
|
+
//if pivot oracle is not TwapOracle it will revert so we need to catch the revert
|
|
234
|
+
try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @notice Updates the pivot oracle price. Currently using TWAP
|
|
240
|
+
* @dev This function should always be called before calling getUnderlyingPrice
|
|
241
|
+
* @param asset asset address
|
|
242
|
+
*/
|
|
243
|
+
function updateAssetPrice(address asset) external {
|
|
244
|
+
(address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);
|
|
231
245
|
if (pivotOracle != address(0) && pivotOracleEnabled) {
|
|
232
246
|
//if pivot oracle is not TwapOracle it will revert so we need to catch the revert
|
|
233
|
-
try TwapInterface(pivotOracle).updateTwap(
|
|
247
|
+
try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}
|
|
234
248
|
}
|
|
235
249
|
}
|
|
236
250
|
|
|
237
251
|
/**
|
|
238
252
|
* @dev Gets token config by vToken address
|
|
239
|
-
* @param
|
|
253
|
+
* @param asset asset address
|
|
240
254
|
* @return tokenConfig Config for the vToken
|
|
241
255
|
*/
|
|
242
|
-
function getTokenConfig(address
|
|
243
|
-
address asset = _getUnderlyingAsset(vToken);
|
|
256
|
+
function getTokenConfig(address asset) external view returns (TokenConfig memory) {
|
|
244
257
|
return tokenConfigs[asset];
|
|
245
258
|
}
|
|
246
259
|
|
|
@@ -259,41 +272,21 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
259
272
|
*/
|
|
260
273
|
function getUnderlyingPrice(address vToken) external view override returns (uint256) {
|
|
261
274
|
if (paused()) revert("resilient oracle is paused");
|
|
262
|
-
uint256 pivotPrice = INVALID_PRICE;
|
|
263
|
-
|
|
264
|
-
// Get pivot oracle price, Invalid price if not available or error
|
|
265
|
-
(address pivotOracle, bool pivotOracleEnabled) = getOracle(vToken, OracleRole.PIVOT);
|
|
266
|
-
if (pivotOracleEnabled && pivotOracle != address(0)) {
|
|
267
|
-
try OracleInterface(pivotOracle).getUnderlyingPrice(vToken) returns (uint256 pricePivot) {
|
|
268
|
-
pivotPrice = pricePivot;
|
|
269
|
-
} catch {}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Compare main price and pivot price, return main price and if validation was successful
|
|
273
|
-
// note: In case pivot oracle is not available but main price is available and
|
|
274
|
-
// validation is successful, the main oracle price is returned.
|
|
275
|
-
(uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(
|
|
276
|
-
vToken,
|
|
277
|
-
pivotPrice,
|
|
278
|
-
pivotOracleEnabled && pivotOracle != address(0)
|
|
279
|
-
);
|
|
280
|
-
if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;
|
|
281
275
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;
|
|
286
|
-
|
|
287
|
-
// Lastly compare main price and fallback price
|
|
288
|
-
if (
|
|
289
|
-
mainPrice != INVALID_PRICE &&
|
|
290
|
-
fallbackPrice != INVALID_PRICE &&
|
|
291
|
-
boundValidator.validatePriceWithAnchorPrice(vToken, mainPrice, fallbackPrice)
|
|
292
|
-
) {
|
|
293
|
-
return mainPrice;
|
|
294
|
-
}
|
|
276
|
+
address asset = _getUnderlyingAsset(vToken);
|
|
277
|
+
return _getPrice(asset);
|
|
278
|
+
}
|
|
295
279
|
|
|
296
|
-
|
|
280
|
+
/**
|
|
281
|
+
* @notice Gets price of the asset
|
|
282
|
+
* @param asset asset address
|
|
283
|
+
* @return price USD price in scaled decimal places.
|
|
284
|
+
* @custom:error Paused error is thrown when resilent oracle is paused
|
|
285
|
+
* @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid
|
|
286
|
+
*/
|
|
287
|
+
function getPrice(address asset) external view override returns (uint256) {
|
|
288
|
+
if (paused()) revert("resilient oracle is paused");
|
|
289
|
+
return _getPrice(asset);
|
|
297
290
|
}
|
|
298
291
|
|
|
299
292
|
/**
|
|
@@ -321,27 +314,63 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
321
314
|
|
|
322
315
|
/**
|
|
323
316
|
* @notice Gets oracle and enabled status by vToken address
|
|
324
|
-
* @param
|
|
317
|
+
* @param asset asset address
|
|
325
318
|
* @param role Oracle role
|
|
326
319
|
* @return oracle Oracle address based on role
|
|
327
320
|
* @return enabled Enabled flag of the oracle based on token config
|
|
328
321
|
*/
|
|
329
|
-
function getOracle(address
|
|
330
|
-
address asset = _getUnderlyingAsset(vToken);
|
|
331
|
-
|
|
322
|
+
function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {
|
|
332
323
|
oracle = tokenConfigs[asset].oracles[uint256(role)];
|
|
333
324
|
enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];
|
|
334
325
|
}
|
|
335
326
|
|
|
327
|
+
function _getPrice(address asset) internal view returns (uint256) {
|
|
328
|
+
uint256 pivotPrice = INVALID_PRICE;
|
|
329
|
+
|
|
330
|
+
// Get pivot oracle price, Invalid price if not available or error
|
|
331
|
+
(address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);
|
|
332
|
+
if (pivotOracleEnabled && pivotOracle != address(0)) {
|
|
333
|
+
try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {
|
|
334
|
+
pivotPrice = pricePivot;
|
|
335
|
+
} catch {}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Compare main price and pivot price, return main price and if validation was successful
|
|
339
|
+
// note: In case pivot oracle is not available but main price is available and
|
|
340
|
+
// validation is successful, the main oracle price is returned.
|
|
341
|
+
(uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(
|
|
342
|
+
asset,
|
|
343
|
+
pivotPrice,
|
|
344
|
+
pivotOracleEnabled && pivotOracle != address(0)
|
|
345
|
+
);
|
|
346
|
+
if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;
|
|
347
|
+
|
|
348
|
+
// Compare fallback and pivot if main oracle comparision fails with pivot
|
|
349
|
+
// Return fallback price when fallback price is validated successfully with pivot oracle
|
|
350
|
+
(uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);
|
|
351
|
+
if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;
|
|
352
|
+
|
|
353
|
+
// Lastly compare main price and fallback price
|
|
354
|
+
if (
|
|
355
|
+
mainPrice != INVALID_PRICE &&
|
|
356
|
+
fallbackPrice != INVALID_PRICE &&
|
|
357
|
+
boundValidator.validatePriceWithAnchorPrice(asset, fallbackPrice, mainPrice)
|
|
358
|
+
) {
|
|
359
|
+
return mainPrice;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
revert("invalid resilient oracle price");
|
|
363
|
+
}
|
|
364
|
+
|
|
336
365
|
/**
|
|
337
|
-
* @notice Gets underlying asset price for the provided
|
|
366
|
+
* @notice Gets underlying asset price for the provided asset
|
|
338
367
|
* @dev This function won't revert when price is 0, because the fallback oracle may still be
|
|
339
368
|
* able to fetch a correct price
|
|
340
|
-
* @param
|
|
369
|
+
* @param asset asset address
|
|
341
370
|
* @param pivotPrice Pivot oracle price
|
|
342
371
|
* @param pivotEnabled If pivot oracle is not empty and enabled
|
|
343
372
|
* @return price USD price in scaled decimals
|
|
344
|
-
* e.g.
|
|
373
|
+
* e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals
|
|
345
374
|
* @return pivotValidated Boolean representing if the validation of main oracle price
|
|
346
375
|
* and pivot oracle price were successful
|
|
347
376
|
* @custom:error Invalid price error is thrown if main oracle fails to fetch price of underlying asset
|
|
@@ -349,13 +378,13 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
349
378
|
* address is null
|
|
350
379
|
*/
|
|
351
380
|
function _getMainOraclePrice(
|
|
352
|
-
address
|
|
381
|
+
address asset,
|
|
353
382
|
uint256 pivotPrice,
|
|
354
383
|
bool pivotEnabled
|
|
355
|
-
)
|
|
356
|
-
(address mainOracle, bool mainOracleEnabled) = getOracle(
|
|
384
|
+
) internal view returns (uint256, bool) {
|
|
385
|
+
(address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);
|
|
357
386
|
if (mainOracleEnabled && mainOracle != address(0)) {
|
|
358
|
-
try OracleInterface(mainOracle).
|
|
387
|
+
try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {
|
|
359
388
|
if (!pivotEnabled) {
|
|
360
389
|
return (mainOraclePrice, true);
|
|
361
390
|
}
|
|
@@ -364,7 +393,7 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
364
393
|
}
|
|
365
394
|
return (
|
|
366
395
|
mainOraclePrice,
|
|
367
|
-
boundValidator.validatePriceWithAnchorPrice(
|
|
396
|
+
boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)
|
|
368
397
|
);
|
|
369
398
|
} catch {
|
|
370
399
|
return (INVALID_PRICE, false);
|
|
@@ -376,7 +405,7 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
376
405
|
|
|
377
406
|
/**
|
|
378
407
|
* @dev This function won't revert when the price is 0 because getUnderlyingPrice checks if price is > 0
|
|
379
|
-
* @param
|
|
408
|
+
* @param asset asset address
|
|
380
409
|
* @return price USD price in 18 decimals
|
|
381
410
|
* @return pivotValidated Boolean representing if the validation of fallback oracle price
|
|
382
411
|
* and pivot oracle price were successfull
|
|
@@ -384,16 +413,16 @@ contract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOr
|
|
|
384
413
|
* @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle
|
|
385
414
|
* address is null
|
|
386
415
|
*/
|
|
387
|
-
function _getFallbackOraclePrice(address
|
|
388
|
-
(address fallbackOracle, bool fallbackEnabled) = getOracle(
|
|
416
|
+
function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {
|
|
417
|
+
(address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);
|
|
389
418
|
if (fallbackEnabled && fallbackOracle != address(0)) {
|
|
390
|
-
try OracleInterface(fallbackOracle).
|
|
419
|
+
try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {
|
|
391
420
|
if (pivotPrice == INVALID_PRICE) {
|
|
392
421
|
return (fallbackOraclePrice, false);
|
|
393
422
|
}
|
|
394
423
|
return (
|
|
395
424
|
fallbackOraclePrice,
|
|
396
|
-
boundValidator.validatePriceWithAnchorPrice(
|
|
425
|
+
boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)
|
|
397
426
|
);
|
|
398
427
|
} catch {
|
|
399
428
|
return (INVALID_PRICE, false);
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
pragma solidity 0.8.13;
|
|
3
3
|
|
|
4
4
|
interface FeedRegistryInterface {
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function latestRoundData(
|
|
6
|
+
address base,
|
|
7
|
+
address quote
|
|
8
8
|
)
|
|
9
9
|
external
|
|
10
10
|
view
|
|
11
11
|
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function decimals(address base, address quote) external view returns (uint8);
|
|
14
14
|
}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
pragma solidity 0.8.13;
|
|
3
3
|
|
|
4
4
|
interface OracleInterface {
|
|
5
|
-
function
|
|
5
|
+
function getPrice(address asset) external view returns (uint256);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
interface ResilientOracleInterface is OracleInterface {
|
|
9
9
|
function updatePrice(address vToken) external;
|
|
10
|
+
|
|
11
|
+
function getUnderlyingPrice(address vToken) external view returns (uint256);
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
interface TwapInterface is OracleInterface {
|
|
@@ -8,6 +8,7 @@ import "../interfaces/FeedRegistryInterface.sol";
|
|
|
8
8
|
import "../interfaces/PublicResolverInterface.sol";
|
|
9
9
|
import "../interfaces/OracleInterface.sol";
|
|
10
10
|
import "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol";
|
|
11
|
+
import "../interfaces/OracleInterface.sol";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @title BinanceOracle
|
|
@@ -17,28 +18,23 @@ import "@venusprotocol/governance-contracts/contracts/Governance/AccessControlle
|
|
|
17
18
|
contract BinanceOracle is AccessControlledV8, OracleInterface {
|
|
18
19
|
address public sidRegistryAddress;
|
|
19
20
|
|
|
20
|
-
/// @notice
|
|
21
|
-
|
|
22
|
-
address public immutable vBnb;
|
|
21
|
+
/// @notice Set this as asset address for BNB. This is the underlying address for vBNB
|
|
22
|
+
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
23
23
|
|
|
24
|
-
/// @notice
|
|
25
|
-
|
|
26
|
-
address public immutable vai;
|
|
24
|
+
/// @notice Quote address for USD
|
|
25
|
+
address public constant USD_ADDR = 0x0000000000000000000000000000000000000348;
|
|
27
26
|
|
|
28
27
|
/// @notice Max stale period configuration for assets
|
|
29
28
|
mapping(string => uint256) public maxStalePeriod;
|
|
30
29
|
|
|
30
|
+
/// @notice Address of WBNB contract
|
|
31
|
+
address public WBNB;
|
|
32
|
+
|
|
31
33
|
event MaxStalePeriodAdded(string indexed asset, uint256 maxStalePeriod);
|
|
32
34
|
|
|
33
|
-
/// @notice Constructor for the implementation contract.
|
|
34
|
-
/// @param vBnbAddress The address of the vBNB
|
|
35
|
-
/// @param vaiAddress The address of the VAI
|
|
35
|
+
/// @notice Constructor for the implementation contract.
|
|
36
36
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
37
|
-
constructor(
|
|
38
|
-
if (vBnbAddress == address(0)) revert("vBNB can't be zero address");
|
|
39
|
-
if (vaiAddress == address(0)) revert("VAI can't be zero address");
|
|
40
|
-
vBnb = vBnbAddress;
|
|
41
|
-
vai = vaiAddress;
|
|
37
|
+
constructor() {
|
|
42
38
|
_disableInitializers();
|
|
43
39
|
}
|
|
44
40
|
|
|
@@ -60,69 +56,68 @@ contract BinanceOracle is AccessControlledV8, OracleInterface {
|
|
|
60
56
|
* @notice Sets the contracts required to fetch prices
|
|
61
57
|
* @param _sidRegistryAddress Address of SID registry
|
|
62
58
|
* @param _accessControlManager Address of the access control manager contract
|
|
59
|
+
* @param _WBNB Address of the access control manager contract
|
|
63
60
|
*/
|
|
64
|
-
function initialize(
|
|
61
|
+
function initialize(
|
|
62
|
+
address _sidRegistryAddress,
|
|
63
|
+
address _accessControlManager,
|
|
64
|
+
address _WBNB
|
|
65
|
+
) external reinitializer(2) {
|
|
65
66
|
sidRegistryAddress = _sidRegistryAddress;
|
|
67
|
+
WBNB = _WBNB;
|
|
66
68
|
__AccessControlled_init(_accessControlManager);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
/**
|
|
70
|
-
* @notice
|
|
71
|
-
* @
|
|
72
|
+
* @notice Uses Space ID to fetch the feed registry address
|
|
73
|
+
* @return feedRegistryAddress Address of binance oracle feed registry.
|
|
74
|
+
*/
|
|
75
|
+
function getFeedRegistryAddress() public view returns (address) {
|
|
76
|
+
bytes32 nodeHash = 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff;
|
|
77
|
+
|
|
78
|
+
SIDRegistryInterface sidRegistry = SIDRegistryInterface(sidRegistryAddress);
|
|
79
|
+
address publicResolverAddress = sidRegistry.resolver(nodeHash);
|
|
80
|
+
PublicResolverInterface publicResolver = PublicResolverInterface(publicResolverAddress);
|
|
81
|
+
|
|
82
|
+
return publicResolver.addr(nodeHash);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @notice Gets the price of a asset from the binance oracle
|
|
87
|
+
* @param asset Address of the address
|
|
72
88
|
* @return Price in USD
|
|
73
89
|
*/
|
|
74
|
-
function
|
|
90
|
+
function getPrice(address asset) public view returns (uint256) {
|
|
75
91
|
string memory symbol;
|
|
76
92
|
uint256 decimals;
|
|
77
93
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
symbol = "BNB";
|
|
81
|
-
decimals = 18;
|
|
82
|
-
} else if (vToken == vai) {
|
|
83
|
-
symbol = "VAI";
|
|
94
|
+
if (asset == BNB_ADDR) {
|
|
95
|
+
symbol = "WBNB";
|
|
84
96
|
decimals = 18;
|
|
97
|
+
asset = WBNB;
|
|
85
98
|
} else {
|
|
86
|
-
IERC20Metadata
|
|
87
|
-
symbol =
|
|
88
|
-
decimals =
|
|
99
|
+
IERC20Metadata token = IERC20Metadata(asset);
|
|
100
|
+
symbol = token.symbol();
|
|
101
|
+
decimals = token.decimals();
|
|
89
102
|
}
|
|
90
103
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
104
|
+
return _getPrice(asset, symbol, decimals);
|
|
105
|
+
}
|
|
94
106
|
|
|
107
|
+
function _getPrice(address asset, string memory symbol, uint256 decimals) internal view returns (uint256) {
|
|
95
108
|
FeedRegistryInterface feedRegistry = FeedRegistryInterface(getFeedRegistryAddress());
|
|
96
109
|
|
|
97
|
-
(, int256 answer, , uint256 updatedAt, ) = feedRegistry.
|
|
110
|
+
(, int256 answer, , uint256 updatedAt, ) = feedRegistry.latestRoundData(asset, USD_ADDR);
|
|
98
111
|
if (answer <= 0) revert("invalid binance oracle price");
|
|
99
112
|
if (block.timestamp < updatedAt) revert("updatedAt exceeds block time");
|
|
100
113
|
|
|
101
|
-
uint256 deltaTime;
|
|
102
|
-
unchecked {
|
|
103
|
-
deltaTime = block.timestamp - updatedAt;
|
|
104
|
-
}
|
|
105
|
-
|
|
114
|
+
uint256 deltaTime = block.timestamp - updatedAt;
|
|
106
115
|
if (deltaTime > maxStalePeriod[symbol]) revert("binance oracle price expired");
|
|
107
116
|
|
|
108
|
-
uint256 decimalDelta = feedRegistry.
|
|
117
|
+
uint256 decimalDelta = feedRegistry.decimals(asset, USD_ADDR);
|
|
109
118
|
return (uint256(answer) * (10 ** (18 - decimalDelta))) * (10 ** (18 - decimals));
|
|
110
119
|
}
|
|
111
120
|
|
|
112
|
-
/**
|
|
113
|
-
* @notice Uses Space ID to fetch the feed registry address
|
|
114
|
-
* @return feedRegistryAddress Address of binance oracle feed registry.
|
|
115
|
-
*/
|
|
116
|
-
function getFeedRegistryAddress() public view returns (address) {
|
|
117
|
-
bytes32 nodeHash = 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff;
|
|
118
|
-
|
|
119
|
-
SIDRegistryInterface sidRegistry = SIDRegistryInterface(sidRegistryAddress);
|
|
120
|
-
address publicResolverAddress = sidRegistry.resolver(nodeHash);
|
|
121
|
-
PublicResolverInterface publicResolver = PublicResolverInterface(publicResolverAddress);
|
|
122
|
-
|
|
123
|
-
return publicResolver.addr(nodeHash);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
121
|
/**
|
|
127
122
|
* @notice Used to compare if two strings are equal or not
|
|
128
123
|
* @param str1 The first string
|
|
@@ -27,29 +27,12 @@ contract BoundValidator is AccessControlledV8, BoundValidatorInterface {
|
|
|
27
27
|
/// @notice validation configs by asset
|
|
28
28
|
mapping(address => ValidateConfig) public validateConfigs;
|
|
29
29
|
|
|
30
|
-
/// @notice vBNB address
|
|
31
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
32
|
-
address public immutable vBnb;
|
|
33
|
-
|
|
34
|
-
/// @notice VAI address
|
|
35
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
36
|
-
address public immutable vai;
|
|
37
|
-
|
|
38
|
-
/// @notice Set this as asset address for BNB. This is the underlying for vBNB
|
|
39
|
-
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
40
|
-
|
|
41
30
|
/// @notice Emit this event when new validation configs are added
|
|
42
31
|
event ValidateConfigAdded(address indexed asset, uint256 indexed upperBound, uint256 indexed lowerBound);
|
|
43
32
|
|
|
44
33
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
45
|
-
/// @param vBnbAddress The address of the vBNB
|
|
46
|
-
/// @param vaiAddress The address of the VAI
|
|
47
34
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
48
|
-
constructor(
|
|
49
|
-
if (vBnbAddress == address(0)) revert("vBNB can't be zero address");
|
|
50
|
-
if (vaiAddress == address(0)) revert("VAI can't be zero address");
|
|
51
|
-
vBnb = vBnbAddress;
|
|
52
|
-
vai = vaiAddress;
|
|
35
|
+
constructor() {
|
|
53
36
|
_disableInitializers();
|
|
54
37
|
}
|
|
55
38
|
|
|
@@ -79,25 +62,6 @@ contract BoundValidator is AccessControlledV8, BoundValidatorInterface {
|
|
|
79
62
|
__AccessControlled_init(accessControlManager_);
|
|
80
63
|
}
|
|
81
64
|
|
|
82
|
-
/**
|
|
83
|
-
* @notice Test reported asset price against anchor price
|
|
84
|
-
* @param vToken vToken address
|
|
85
|
-
* @param reportedPrice The price to be tested
|
|
86
|
-
* @custom:error Missing error thrown if asset config is not set
|
|
87
|
-
* @custom:error Price error thrown if anchor price is not valid
|
|
88
|
-
*/
|
|
89
|
-
function validatePriceWithAnchorPrice(
|
|
90
|
-
address vToken,
|
|
91
|
-
uint256 reportedPrice,
|
|
92
|
-
uint256 anchorPrice
|
|
93
|
-
) external view override returns (bool) {
|
|
94
|
-
address asset = _getUnderlyingAsset(vToken);
|
|
95
|
-
|
|
96
|
-
if (validateConfigs[asset].upperBoundRatio == 0) revert("validation config not exist");
|
|
97
|
-
if (anchorPrice == 0) revert("anchor price is not valid");
|
|
98
|
-
return _isWithinAnchor(asset, reportedPrice, anchorPrice);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
65
|
/**
|
|
102
66
|
* @notice Add a single validation config
|
|
103
67
|
* @param config Validation config struct
|
|
@@ -117,6 +81,23 @@ contract BoundValidator is AccessControlledV8, BoundValidatorInterface {
|
|
|
117
81
|
emit ValidateConfigAdded(config.asset, config.upperBoundRatio, config.lowerBoundRatio);
|
|
118
82
|
}
|
|
119
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @notice Test reported asset price against anchor price
|
|
86
|
+
* @param asset asset address
|
|
87
|
+
* @param reportedPrice The price to be tested
|
|
88
|
+
* @custom:error Missing error thrown if asset config is not set
|
|
89
|
+
* @custom:error Price error thrown if anchor price is not valid
|
|
90
|
+
*/
|
|
91
|
+
function validatePriceWithAnchorPrice(
|
|
92
|
+
address asset,
|
|
93
|
+
uint256 reportedPrice,
|
|
94
|
+
uint256 anchorPrice
|
|
95
|
+
) public view virtual override returns (bool) {
|
|
96
|
+
if (validateConfigs[asset].upperBoundRatio == 0) revert("validation config not exist");
|
|
97
|
+
if (anchorPrice == 0) revert("anchor price is not valid");
|
|
98
|
+
return _isWithinAnchor(asset, reportedPrice, anchorPrice);
|
|
99
|
+
}
|
|
100
|
+
|
|
120
101
|
/**
|
|
121
102
|
* @notice Test whether the reported price is within the valid bounds
|
|
122
103
|
* @param asset Asset address
|
|
@@ -134,18 +115,8 @@ contract BoundValidator is AccessControlledV8, BoundValidatorInterface {
|
|
|
134
115
|
return false;
|
|
135
116
|
}
|
|
136
117
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*/
|
|
142
|
-
function _getUnderlyingAsset(address vToken) private view returns (address asset) {
|
|
143
|
-
if (address(vToken) == vBnb) {
|
|
144
|
-
asset = BNB_ADDR;
|
|
145
|
-
} else if (address(vToken) == vai) {
|
|
146
|
-
asset = vai;
|
|
147
|
-
} else {
|
|
148
|
-
asset = VBep20Interface(vToken).underlying();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
118
|
+
// BoundValidator is to get inherited, so it's a good practice to add some storage gaps like
|
|
119
|
+
// OpenZepplin proposed in their contracts: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
120
|
+
// solhint-disable-next-line
|
|
121
|
+
uint256[49] private __gap;
|
|
151
122
|
}
|
|
@@ -23,14 +23,6 @@ contract ChainlinkOracle is AccessControlledV8, OracleInterface {
|
|
|
23
23
|
uint256 maxStalePeriod;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/// @notice vBNB address
|
|
27
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
28
|
-
address public immutable vBnb;
|
|
29
|
-
|
|
30
|
-
/// @notice VAI address
|
|
31
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
32
|
-
address public immutable vai;
|
|
33
|
-
|
|
34
26
|
/// @notice Set this as asset address for BNB. This is the underlying address for vBNB
|
|
35
27
|
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
36
28
|
|
|
@@ -52,35 +44,11 @@ contract ChainlinkOracle is AccessControlledV8, OracleInterface {
|
|
|
52
44
|
}
|
|
53
45
|
|
|
54
46
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
55
|
-
/// @param vBnbAddress The address of the vBNB
|
|
56
|
-
/// @param vaiAddress The address of the VAI
|
|
57
47
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
58
|
-
constructor(
|
|
59
|
-
vBnb = vBnbAddress;
|
|
60
|
-
vai = vaiAddress;
|
|
48
|
+
constructor() {
|
|
61
49
|
_disableInitializers();
|
|
62
50
|
}
|
|
63
51
|
|
|
64
|
-
/**
|
|
65
|
-
* @notice Set the forced prices of the underlying token of input vToken
|
|
66
|
-
* @param vToken vToken address
|
|
67
|
-
* @param underlyingPriceMantissa price in 18 decimals
|
|
68
|
-
* @custom:access Only Governance
|
|
69
|
-
* @custom:error NotNullAddress thrown if address of vToken is null
|
|
70
|
-
* @custom:event Emits PricePosted event on succesfully setup of underlying price
|
|
71
|
-
*/
|
|
72
|
-
function setUnderlyingPrice(
|
|
73
|
-
VBep20Interface vToken,
|
|
74
|
-
uint256 underlyingPriceMantissa
|
|
75
|
-
) external notNullAddress(address(vToken)) {
|
|
76
|
-
_checkAccessAllowed("setUnderlyingPrice(address,uint256)");
|
|
77
|
-
|
|
78
|
-
address asset = address(vToken) == vBnb ? BNB_ADDR : address(vToken.underlying());
|
|
79
|
-
uint256 previousPriceMantissa = prices[asset];
|
|
80
|
-
prices[asset] = underlyingPriceMantissa;
|
|
81
|
-
emit PricePosted(asset, previousPriceMantissa, prices[asset]);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
52
|
/**
|
|
85
53
|
* @notice Manually set the price of a given asset
|
|
86
54
|
* @param asset Asset address
|
|
@@ -122,16 +90,7 @@ contract ChainlinkOracle is AccessControlledV8, OracleInterface {
|
|
|
122
90
|
}
|
|
123
91
|
|
|
124
92
|
/**
|
|
125
|
-
* @notice
|
|
126
|
-
* @param vToken vToken address
|
|
127
|
-
* @return price Underlying price in USD
|
|
128
|
-
*/
|
|
129
|
-
function getUnderlyingPrice(address vToken) external view override returns (uint256) {
|
|
130
|
-
return _getUnderlyingPriceInternal(VBep20Interface(vToken));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @notice Add single token config. vToken & feed cannot be null addresses and maxStalePeriod must be positive
|
|
93
|
+
* @notice Add single token config. asset & feed cannot be null addresses and maxStalePeriod must be positive
|
|
135
94
|
* @param tokenConfig Token config struct
|
|
136
95
|
* @custom:access Only Governance
|
|
137
96
|
* @custom:error NotNullAddress error is thrown if asset address is null
|
|
@@ -150,29 +109,30 @@ contract ChainlinkOracle is AccessControlledV8, OracleInterface {
|
|
|
150
109
|
}
|
|
151
110
|
|
|
152
111
|
/**
|
|
153
|
-
* @notice Gets the
|
|
154
|
-
*
|
|
155
|
-
* @
|
|
156
|
-
* has 18 decimals of precision
|
|
157
|
-
* @param vToken vToken address
|
|
158
|
-
* @return price Underlying price in USD
|
|
112
|
+
* @notice Gets the price of a asset from the chainlink oracle
|
|
113
|
+
* @param asset Address of the address
|
|
114
|
+
* @return Price in USD
|
|
159
115
|
*/
|
|
160
|
-
function
|
|
161
|
-
address token;
|
|
116
|
+
function getPrice(address asset) public view returns (uint256) {
|
|
162
117
|
uint256 decimals;
|
|
163
118
|
|
|
164
|
-
|
|
165
|
-
if (address(vToken) == vBnb) {
|
|
166
|
-
token = BNB_ADDR;
|
|
167
|
-
decimals = 18;
|
|
168
|
-
} else if (address(vToken) == vai) {
|
|
169
|
-
token = vai;
|
|
119
|
+
if (asset == BNB_ADDR) {
|
|
170
120
|
decimals = 18;
|
|
171
121
|
} else {
|
|
172
|
-
token =
|
|
173
|
-
decimals =
|
|
122
|
+
IERC20Metadata token = IERC20Metadata(asset);
|
|
123
|
+
decimals = token.decimals();
|
|
174
124
|
}
|
|
175
125
|
|
|
126
|
+
return _getPriceInternal(asset, decimals);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @notice Gets the Chainlink price for a given asset
|
|
131
|
+
* @param token address of the asset
|
|
132
|
+
* @param decimals decimals of the asset
|
|
133
|
+
* @return price Underlying price in USD
|
|
134
|
+
*/
|
|
135
|
+
function _getPriceInternal(address token, uint256 decimals) internal view returns (uint256 price) {
|
|
176
136
|
uint256 tokenPrice = prices[token];
|
|
177
137
|
if (tokenPrice != 0) {
|
|
178
138
|
price = tokenPrice;
|
|
@@ -30,14 +30,6 @@ contract PythOracle is AccessControlledV8, OracleInterface {
|
|
|
30
30
|
/// @notice Exponent scale (decimal precision) of prices
|
|
31
31
|
uint256 public constant EXP_SCALE = 1e18;
|
|
32
32
|
|
|
33
|
-
/// @notice vBNB address
|
|
34
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
35
|
-
address public immutable vBnb;
|
|
36
|
-
|
|
37
|
-
/// @notice VAI address
|
|
38
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
39
|
-
address public immutable vai;
|
|
40
|
-
|
|
41
33
|
/// @notice Set this as asset address for BNB. This is the underlying for vBNB
|
|
42
34
|
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
43
35
|
|
|
@@ -58,13 +50,9 @@ contract PythOracle is AccessControlledV8, OracleInterface {
|
|
|
58
50
|
_;
|
|
59
51
|
}
|
|
60
52
|
|
|
61
|
-
/// @notice Constructor for the implementation contract.
|
|
62
|
-
/// @param vBnbAddress The address of the vBNB
|
|
63
|
-
/// @param vaiAddress The address of the VAI
|
|
53
|
+
/// @notice Constructor for the implementation contract.
|
|
64
54
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
65
|
-
constructor(
|
|
66
|
-
vBnb = vBnbAddress;
|
|
67
|
-
vai = vaiAddress;
|
|
55
|
+
constructor() {
|
|
68
56
|
_disableInitializers();
|
|
69
57
|
}
|
|
70
58
|
|
|
@@ -117,32 +105,38 @@ contract PythOracle is AccessControlledV8, OracleInterface {
|
|
|
117
105
|
}
|
|
118
106
|
|
|
119
107
|
/**
|
|
120
|
-
* @notice
|
|
121
|
-
*
|
|
122
|
-
* @
|
|
123
|
-
* @
|
|
124
|
-
* @custom:error
|
|
125
|
-
* @custom:error Zero address error thrown if asset address is null
|
|
126
|
-
* @custom:error Range error thrown if price of Pyth oracle is not greater than zero
|
|
108
|
+
* @notice Set single token config. `maxStalePeriod` cannot be 0 and `vToken` can be a null address
|
|
109
|
+
* @param tokenConfig Token config struct
|
|
110
|
+
* @custom:access Only Governance
|
|
111
|
+
* @custom:error Range error is thrown if max stale period is zero
|
|
112
|
+
* @custom:error NotNullAddress error is thrown if asset address is null
|
|
127
113
|
*/
|
|
128
|
-
function
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
114
|
+
function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {
|
|
115
|
+
_checkAccessAllowed("setTokenConfig(TokenConfig)");
|
|
116
|
+
if (tokenConfig.maxStalePeriod == 0) revert("max stale period cannot be 0");
|
|
117
|
+
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
118
|
+
emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @notice Gets the price of a asset from the pyth oracle
|
|
123
|
+
* @param asset Address of the address
|
|
124
|
+
* @return Price in USD
|
|
125
|
+
*/
|
|
126
|
+
function getPrice(address asset) public view returns (uint256) {
|
|
132
127
|
uint256 decimals;
|
|
133
128
|
|
|
134
|
-
|
|
135
|
-
if (vToken == vBnb) {
|
|
136
|
-
asset = BNB_ADDR;
|
|
137
|
-
decimals = 18;
|
|
138
|
-
} else if (vToken == vai) {
|
|
139
|
-
asset = vai;
|
|
129
|
+
if (asset == BNB_ADDR) {
|
|
140
130
|
decimals = 18;
|
|
141
131
|
} else {
|
|
142
|
-
|
|
143
|
-
decimals =
|
|
132
|
+
IERC20Metadata token = IERC20Metadata(asset);
|
|
133
|
+
decimals = token.decimals();
|
|
144
134
|
}
|
|
145
135
|
|
|
136
|
+
return _getPriceInternal(asset, decimals);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function _getPriceInternal(address asset, uint256 decimals) internal view returns (uint256) {
|
|
146
140
|
TokenConfig storage tokenConfig = tokenConfigs[asset];
|
|
147
141
|
if (tokenConfig.asset == address(0)) revert("asset doesn't exist");
|
|
148
142
|
|
|
@@ -164,18 +158,4 @@ contract PythOracle is AccessControlledV8, OracleInterface {
|
|
|
164
158
|
return ((price * EXP_SCALE) / (10 ** int256(-priceInfo.expo).toUint256())) * (10 ** (18 - decimals));
|
|
165
159
|
}
|
|
166
160
|
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @notice Set single token config. `maxStalePeriod` cannot be 0 and `vToken` can be a null address
|
|
170
|
-
* @param tokenConfig Token config struct
|
|
171
|
-
* @custom:access Only Governance
|
|
172
|
-
* @custom:error Range error is thrown if max stale period is zero
|
|
173
|
-
* @custom:error NotNullAddress error is thrown if asset address is null
|
|
174
|
-
*/
|
|
175
|
-
function setTokenConfig(TokenConfig memory tokenConfig) public notNullAddress(tokenConfig.asset) {
|
|
176
|
-
_checkAccessAllowed("setTokenConfig(TokenConfig)");
|
|
177
|
-
if (tokenConfig.maxStalePeriod == 0) revert("max stale period cannot be 0");
|
|
178
|
-
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
179
|
-
emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);
|
|
180
|
-
}
|
|
181
161
|
}
|
|
@@ -36,18 +36,13 @@ contract TwapOracle is AccessControlledV8, TwapInterface {
|
|
|
36
36
|
uint256 anchorPeriod;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/// @notice Set this as asset address for BNB. This is the underlying for vBNB
|
|
40
|
+
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
41
|
+
|
|
39
42
|
/// @notice WBNB address
|
|
40
43
|
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
41
44
|
address public immutable WBNB;
|
|
42
45
|
|
|
43
|
-
/// @notice vBNB address
|
|
44
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
45
|
-
address public immutable vBnb;
|
|
46
|
-
|
|
47
|
-
/// @notice VAI address
|
|
48
|
-
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
49
|
-
address public immutable vai;
|
|
50
|
-
|
|
51
46
|
/// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets
|
|
52
47
|
uint256 public constant BNB_BASE_UNIT = 1e18;
|
|
53
48
|
uint256 public constant BUSD_BASE_UNIT = 1e18;
|
|
@@ -85,18 +80,10 @@ contract TwapOracle is AccessControlledV8, TwapInterface {
|
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
88
|
-
/// @param vBnbAddress The address of the VBNB
|
|
89
83
|
/// @param wBnbAddress The address of the WBNB
|
|
90
|
-
/// @param vaiAddress The address of the WBNB
|
|
91
84
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
92
|
-
constructor(
|
|
93
|
-
address vBnbAddress,
|
|
94
|
-
address wBnbAddress,
|
|
95
|
-
address vaiAddress
|
|
96
|
-
) notNullAddress(vBnbAddress) notNullAddress(wBnbAddress) notNullAddress(vaiAddress) {
|
|
97
|
-
vBnb = vBnbAddress;
|
|
85
|
+
constructor(address wBnbAddress) notNullAddress(wBnbAddress) {
|
|
98
86
|
WBNB = wBnbAddress;
|
|
99
|
-
vai = vaiAddress;
|
|
100
87
|
_disableInitializers();
|
|
101
88
|
}
|
|
102
89
|
|
|
@@ -125,38 +112,29 @@ contract TwapOracle is AccessControlledV8, TwapInterface {
|
|
|
125
112
|
}
|
|
126
113
|
|
|
127
114
|
/**
|
|
128
|
-
* @notice
|
|
129
|
-
* @
|
|
130
|
-
* @custom:error Missing error is thrown if token config does not exist
|
|
131
|
-
*/
|
|
132
|
-
function updateTwap(address vToken) external returns (uint256) {
|
|
133
|
-
address asset = _getUnderlyingAsset(vToken);
|
|
134
|
-
|
|
135
|
-
if (tokenConfigs[asset].asset == address(0)) revert("asset not exist");
|
|
136
|
-
// Update & fetch WBNB price first, so we can calculate the price of WBNB paired token
|
|
137
|
-
if (asset != WBNB && tokenConfigs[asset].isBnbBased) {
|
|
138
|
-
if (tokenConfigs[WBNB].asset == address(0)) revert("WBNB not exist");
|
|
139
|
-
_updateTwapInternal(tokenConfigs[WBNB]);
|
|
140
|
-
}
|
|
141
|
-
return _updateTwapInternal(tokenConfigs[asset]);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @notice Get the underlying TWAP price for the given vToken
|
|
146
|
-
* @param vToken vToken address
|
|
115
|
+
* @notice Get the underlying TWAP price for the given asset
|
|
116
|
+
* @param asset asset address
|
|
147
117
|
* @return price Underlying price in USD
|
|
148
118
|
* @custom:error Missing error is thrown if the token config does not exist
|
|
149
119
|
* @custom:error Range error is thrown if TWAP price is not greater than zero
|
|
150
120
|
*/
|
|
151
|
-
function
|
|
152
|
-
|
|
121
|
+
function getPrice(address asset) external view override returns (uint256) {
|
|
122
|
+
uint256 decimals;
|
|
123
|
+
|
|
124
|
+
if (asset == BNB_ADDR) {
|
|
125
|
+
decimals = 18;
|
|
126
|
+
asset = WBNB;
|
|
127
|
+
} else {
|
|
128
|
+
IERC20Metadata token = IERC20Metadata(asset);
|
|
129
|
+
decimals = token.decimals();
|
|
130
|
+
}
|
|
153
131
|
|
|
154
132
|
if (tokenConfigs[asset].asset == address(0)) revert("asset not exist");
|
|
155
133
|
uint256 price = prices[asset];
|
|
156
134
|
|
|
157
135
|
// if price is 0, it means the price hasn't been updated yet and it's meaningless, revert
|
|
158
136
|
if (price == 0) revert("TWAP price must be positive");
|
|
159
|
-
return (price * (10 ** (18 -
|
|
137
|
+
return (price * (10 ** (18 - decimals)));
|
|
160
138
|
}
|
|
161
139
|
|
|
162
140
|
/**
|
|
@@ -188,6 +166,25 @@ contract TwapOracle is AccessControlledV8, TwapInterface {
|
|
|
188
166
|
emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);
|
|
189
167
|
}
|
|
190
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.
|
|
171
|
+
* @return anchorPrice anchor price of the underlying asset of the asset
|
|
172
|
+
* @custom:error Missing error is thrown if token config does not exist
|
|
173
|
+
*/
|
|
174
|
+
function updateTwap(address asset) public returns (uint256) {
|
|
175
|
+
if (asset == BNB_ADDR) {
|
|
176
|
+
asset = WBNB;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (tokenConfigs[asset].asset == address(0)) revert("asset not exist");
|
|
180
|
+
// Update & fetch WBNB price first, so we can calculate the price of WBNB paired token
|
|
181
|
+
if (asset != WBNB && tokenConfigs[asset].isBnbBased) {
|
|
182
|
+
if (tokenConfigs[WBNB].asset == address(0)) revert("WBNB not exist");
|
|
183
|
+
_updateTwapInternal(tokenConfigs[WBNB]);
|
|
184
|
+
}
|
|
185
|
+
return _updateTwapInternal(tokenConfigs[asset]);
|
|
186
|
+
}
|
|
187
|
+
|
|
191
188
|
/**
|
|
192
189
|
* @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.
|
|
193
190
|
* @return cumulative price of target token regardless of pair order
|
|
@@ -300,19 +297,4 @@ contract TwapOracle is AccessControlledV8, TwapInterface {
|
|
|
300
297
|
);
|
|
301
298
|
return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);
|
|
302
299
|
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @dev This function returns the underlying asset of a vToken
|
|
306
|
-
* @param vToken vToken address
|
|
307
|
-
* @return asset underlying asset address
|
|
308
|
-
*/
|
|
309
|
-
function _getUnderlyingAsset(address vToken) private view returns (address asset) {
|
|
310
|
-
if (vToken == vBnb) {
|
|
311
|
-
asset = WBNB;
|
|
312
|
-
} else if (vToken == vai) {
|
|
313
|
-
asset = vai;
|
|
314
|
-
} else {
|
|
315
|
-
asset = VBep20Interface(vToken).underlying();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
300
|
}
|
|
@@ -4,15 +4,15 @@ pragma solidity 0.8.13;
|
|
|
4
4
|
import "../../interfaces/FeedRegistryInterface.sol";
|
|
5
5
|
|
|
6
6
|
contract MockBinanceFeedRegistry is FeedRegistryInterface {
|
|
7
|
-
mapping(
|
|
7
|
+
mapping(address => uint256) public assetPrices;
|
|
8
8
|
|
|
9
|
-
function setAssetPrice(
|
|
9
|
+
function setAssetPrice(address base, uint256 price) external {
|
|
10
10
|
assetPrices[base] = price;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
function latestRoundData(
|
|
14
|
+
address base,
|
|
15
|
+
address quote
|
|
16
16
|
)
|
|
17
17
|
external
|
|
18
18
|
view
|
|
@@ -23,7 +23,7 @@ contract MockBinanceFeedRegistry is FeedRegistryInterface {
|
|
|
23
23
|
return (0, int256(assetPrices[base]), 0, block.timestamp - 10, 0);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function decimals(address base, address quote) external view override returns (uint8) {
|
|
27
27
|
return 8;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -14,6 +14,10 @@ contract MockSimpleOracle is OracleInterface {
|
|
|
14
14
|
return prices[vToken];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function getPrice(address asset) external view returns (uint256) {
|
|
18
|
+
return prices[asset];
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
function setPrice(address vToken, uint256 price) public {
|
|
18
22
|
prices[vToken] = price;
|
|
19
23
|
}
|
|
@@ -35,7 +39,15 @@ contract MockBoundValidator is BoundValidatorInterface {
|
|
|
35
39
|
return validateResults[vToken];
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
function
|
|
39
|
-
|
|
42
|
+
function validateAssetPriceWithAnchorPrice(
|
|
43
|
+
address asset,
|
|
44
|
+
uint256 reporterPrice,
|
|
45
|
+
uint256 anchorPrice
|
|
46
|
+
) external view returns (bool) {
|
|
47
|
+
return validateResults[asset];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function setValidateResult(address token, bool pass) public {
|
|
51
|
+
validateResults[token] = pass;
|
|
40
52
|
}
|
|
41
53
|
}
|
|
@@ -60,7 +60,7 @@ const func = function ({ getNamedAccounts, deployments, network }) {
|
|
|
60
60
|
from: deployer,
|
|
61
61
|
log: true,
|
|
62
62
|
deterministicDeployment: false,
|
|
63
|
-
args: [
|
|
63
|
+
args: [],
|
|
64
64
|
proxy: {
|
|
65
65
|
owner: proxyOwnerAddress,
|
|
66
66
|
proxyContract: "OptimizedTransparentProxy",
|
|
@@ -90,7 +90,7 @@ const func = function ({ getNamedAccounts, deployments, network }) {
|
|
|
90
90
|
from: deployer,
|
|
91
91
|
log: true,
|
|
92
92
|
deterministicDeployment: false,
|
|
93
|
-
args:
|
|
93
|
+
args: [],
|
|
94
94
|
proxy: {
|
|
95
95
|
owner: proxyOwnerAddress,
|
|
96
96
|
proxyContract: "OptimizedTransparentProxy",
|
|
@@ -105,7 +105,7 @@ const func = function ({ getNamedAccounts, deployments, network }) {
|
|
|
105
105
|
from: deployer,
|
|
106
106
|
log: true,
|
|
107
107
|
deterministicDeployment: false,
|
|
108
|
-
args: network.live ? [
|
|
108
|
+
args: network.live ? [WBNBAddress] : [],
|
|
109
109
|
proxy: {
|
|
110
110
|
owner: proxyOwnerAddress,
|
|
111
111
|
proxyContract: "OptimizedTransparentProxy",
|
|
@@ -121,7 +121,7 @@ const func = function ({ getNamedAccounts, deployments, network }) {
|
|
|
121
121
|
from: deployer,
|
|
122
122
|
log: true,
|
|
123
123
|
deterministicDeployment: false,
|
|
124
|
-
args:
|
|
124
|
+
args: [],
|
|
125
125
|
proxy: {
|
|
126
126
|
owner: proxyOwnerAddress,
|
|
127
127
|
proxyContract: "OptimizedTransparentProxy",
|
|
@@ -137,13 +137,13 @@ const func = function ({ getNamedAccounts, deployments, network }) {
|
|
|
137
137
|
from: deployer,
|
|
138
138
|
log: true,
|
|
139
139
|
deterministicDeployment: false,
|
|
140
|
-
args:
|
|
140
|
+
args: [],
|
|
141
141
|
proxy: {
|
|
142
142
|
owner: proxyOwnerAddress,
|
|
143
143
|
proxyContract: "OptimizedTransparentProxy",
|
|
144
144
|
execute: {
|
|
145
145
|
methodName: "initialize",
|
|
146
|
-
args: network.live ? [sidRegistryAddress, accessControlManagerAddress] : [],
|
|
146
|
+
args: network.live ? [sidRegistryAddress, accessControlManagerAddress, WBNBAddress] : [],
|
|
147
147
|
},
|
|
148
148
|
},
|
|
149
149
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1-deploy-oracles.js","sourceRoot":"","sources":["../../deploy/1-deploy-oracles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uGAAqF;AACrF,uGAAqF;AACrF,sDAA0B;AAI1B,MAAM,SAAS,GAAG;IAChB,UAAU,EAAE;QACV,WAAW,EAAE,sBAAkB,CAAC,SAAS,CAAC,IAAI;QAC9C,WAAW,EAAE,4CAA4C;QACzD,UAAU,EAAE,sBAAkB,CAAC,S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,CAAC;AACP,QAAA,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venusprotocol/oracle",
|
|
3
3
|
"description": "Venus Protocol Price Oracle",
|
|
4
|
-
"version": "1.6.12-dev.
|
|
5
|
-
"author": "",
|
|
4
|
+
"version": "1.6.12-dev.3",
|
|
5
|
+
"author": "Venus",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=16.x.x"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"artifacts",
|