@venusprotocol/oracle 1.2.0 → 1.2.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/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +2 -2
- 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/math/SafeCast.sol/SafeCast.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.json +2 -2
- package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.json +2 -2
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +2 -2
- 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/AddressUpgradeable.sol/AddressUpgradeable.json +2 -2
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
- package/artifacts/build-info/4d2af5803ee95a57ec9aace7ed32201c.json +1 -0
- package/artifacts/build-info/766f05630947fa6d366a667b66c1141b.json +1 -0
- package/artifacts/contracts/PriceOracle.sol/PriceOracle.dbg.json +4 -0
- package/artifacts/contracts/PriceOracle.sol/PriceOracle.json +62 -0
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +1 -1
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json +35 -3
- package/artifacts/contracts/interfaces/AggregatorV2V3Interface.sol/AggregatorV2V3Interface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/BEP20Interface.sol/BEP20Interface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.dbg.json +4 -0
- package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.json +79 -0
- package/artifacts/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +4 -0
- package/artifacts/contracts/interfaces/OracleInterface.sol/{PivotValidatorInterface.json → BoundValidatorInterface.json} +8 -3
- package/artifacts/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +1 -1
- package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +4 -0
- package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +43 -0
- package/artifacts/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +4 -0
- package/artifacts/contracts/interfaces/OracleInterface.sol/{PivotOracleInterface.json → TwapInterface.json} +5 -10
- 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/PythInterface.sol/PythStructs.json +2 -2
- 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/FixedPoint.json +2 -2
- 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/libraries/PancakeLibrary.sol/PancakeOracleLibrary.json +2 -2
- package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.dbg.json +4 -0
- package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.json +69 -0
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.dbg.json +1 -1
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.json +13 -6
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.json +6 -6
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.json +5 -5
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.json +23 -23
- package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.dbg.json +4 -0
- package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.json +116 -0
- package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.dbg.json +4 -0
- package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.json +144 -0
- 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 +4 -0
- package/artifacts/contracts/oracles/mocks/{MockPivotTwapOracle.sol/MockPivotTwapOracle.json → MockTwapOracle.sol/MockTwapOracle.json} +4 -4
- package/artifacts/contracts/test/BEP20Harness.sol/BEP20Harness.dbg.json +1 -1
- package/artifacts/contracts/test/BEP20Harness.sol/BEP20Harness.json +2 -2
- package/artifacts/contracts/test/MockPyth.sol/MockPyth.dbg.json +1 -1
- package/artifacts/contracts/test/MockPyth.sol/MockPyth.json +2 -2
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.dbg.json +4 -0
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.json +95 -0
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.dbg.json +1 -1
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.json +2 -2
- package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.dbg.json +1 -1
- package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.json +2 -2
- package/artifacts/contracts/test/PancakePairHarness.sol/Math.dbg.json +1 -1
- package/artifacts/contracts/test/PancakePairHarness.sol/Math.json +2 -2
- package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.dbg.json +1 -1
- package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.json +2 -2
- package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.dbg.json +1 -1
- package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.json +2 -2
- package/artifacts/contracts/test/VBEP20Harness.sol/VBEP20Harness.dbg.json +1 -1
- package/artifacts/contracts/test/VBEP20Harness.sol/VBEP20Harness.json +2 -2
- package/deploy/oracles.d.ts +1 -1
- package/deploy/oracles.d.ts.map +1 -1
- package/deploy/oracles.js +43 -29
- package/deploy/oracles.js.map +1 -1
- package/deployments/.gitkeep +0 -0
- package/package.json +4 -5
- package/artifacts/build-info/5759fed659a82870ff637da81e15ba57.json +0 -1
- package/artifacts/build-info/b22018d758b06a50b7c80c494f08be30.json +0 -1
- package/artifacts/contracts/interfaces/OracleInterface.sol/PivotOracleInterface.dbg.json +0 -4
- package/artifacts/contracts/interfaces/OracleInterface.sol/PivotValidatorInterface.dbg.json +0 -4
- package/artifacts/contracts/oracles/PivotPythOracle.sol/PivotPythOracle.dbg.json +0 -4
- package/artifacts/contracts/oracles/PivotPythOracle.sol/PivotPythOracle.json +0 -441
- package/artifacts/contracts/oracles/PivotTwapOracle.sol/PivotTwapOracle.dbg.json +0 -4
- package/artifacts/contracts/oracles/PivotTwapOracle.sol/PivotTwapOracle.json +0 -691
- package/artifacts/contracts/oracles/mocks/MockPivotTwapOracle.sol/MockPivotTwapOracle.dbg.json +0 -4
- package/artifacts/contracts/test/MockBoundValidator.sol/MockBoundValidator.dbg.json +0 -4
- package/artifacts/contracts/test/MockBoundValidator.sol/MockBoundValidator.json +0 -226
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockPivotOracle.dbg.json +0 -4
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockPivotOracle.json +0 -133
- package/contracts/ResilientOracle.sol +0 -220
- package/contracts/interfaces/AggregatorV2V3Interface.sol +0 -60
- package/contracts/interfaces/BEP20Interface.sol +0 -97
- package/contracts/interfaces/OracleInterface.sol +0 -15
- package/contracts/interfaces/PythInterface.sol +0 -160
- package/contracts/interfaces/VBep20Interface.sol +0 -11
- package/contracts/libraries/PancakeLibrary.sol +0 -64
- package/contracts/oracles/BoundValidator.sol +0 -96
- package/contracts/oracles/ChainlinkOracle.sol +0 -178
- package/contracts/oracles/PivotPythOracle.sol +0 -18
- package/contracts/oracles/PivotTwapOracle.sol +0 -18
- package/contracts/oracles/PythOracle.sol +0 -129
- package/contracts/oracles/TwapOracle.sol +0 -234
- package/contracts/oracles/mocks/MockChainlinkOracle.sol +0 -26
- package/contracts/oracles/mocks/MockPivotTwapOracle.sol +0 -31
- package/contracts/oracles/mocks/MockPythOracle.sol +0 -31
- package/contracts/test/BEP20Harness.sol +0 -21
- package/contracts/test/MockBoundValidator.sol +0 -10
- package/contracts/test/MockPyth.sol +0 -78
- package/contracts/test/MockSimpleOracle.sol +0 -37
- package/contracts/test/MockV3Aggregator.sol +0 -91
- package/contracts/test/PancakePairHarness.sol +0 -113
- package/contracts/test/VBEP20Harness.sol +0 -22
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
interface BEP20Interface {
|
|
5
|
-
/**
|
|
6
|
-
* @dev Returns the amount of tokens in existence.
|
|
7
|
-
*/
|
|
8
|
-
function totalSupply() external view returns (uint256);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @dev Returns the token decimals.
|
|
12
|
-
*/
|
|
13
|
-
function decimals() external view returns (uint8);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @dev Returns the token symbol.
|
|
17
|
-
*/
|
|
18
|
-
function symbol() external view returns (string memory);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @dev Returns the token name.
|
|
22
|
-
*/
|
|
23
|
-
function name() external view returns (string memory);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @dev Returns the bep token owner.
|
|
27
|
-
*/
|
|
28
|
-
function getOwner() external view returns (address);
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @dev Returns the amount of tokens owned by `account`.
|
|
32
|
-
*/
|
|
33
|
-
function balanceOf(address account) external view returns (uint256);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @dev Moves `amount` tokens from the caller's account to `recipient`.
|
|
37
|
-
*
|
|
38
|
-
* Returns a boolean value indicating whether the operation succeeded.
|
|
39
|
-
*
|
|
40
|
-
* Emits a {Transfer} event.
|
|
41
|
-
*/
|
|
42
|
-
function transfer(address recipient, uint256 amount) external returns (bool);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @dev Returns the remaining number of tokens that `spender` will be
|
|
46
|
-
* allowed to spend on behalf of `owner` through {transferFrom}. This is
|
|
47
|
-
* zero by default.
|
|
48
|
-
*
|
|
49
|
-
* This value changes when {approve} or {transferFrom} are called.
|
|
50
|
-
*/
|
|
51
|
-
function allowance(address _owner, address spender) external view returns (uint256);
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
|
|
55
|
-
*
|
|
56
|
-
* Returns a boolean value indicating whether the operation succeeded.
|
|
57
|
-
*
|
|
58
|
-
* IMPORTANT: Beware that changing an allowance with this method brings the risk
|
|
59
|
-
* that someone may use both the old and the new allowance by unfortunate
|
|
60
|
-
* transaction ordering. One possible solution to mitigate this race
|
|
61
|
-
* condition is to first reduce the spender's allowance to 0 and set the
|
|
62
|
-
* desired value afterwards:
|
|
63
|
-
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
|
64
|
-
*
|
|
65
|
-
* Emits an {Approval} event.
|
|
66
|
-
*/
|
|
67
|
-
function approve(address spender, uint256 amount) external returns (bool);
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @dev Moves `amount` tokens from `sender` to `recipient` using the
|
|
71
|
-
* allowance mechanism. `amount` is then deducted from the caller's
|
|
72
|
-
* allowance.
|
|
73
|
-
*
|
|
74
|
-
* Returns a boolean value indicating whether the operation succeeded.
|
|
75
|
-
*
|
|
76
|
-
* Emits a {Transfer} event.
|
|
77
|
-
*/
|
|
78
|
-
function transferFrom(
|
|
79
|
-
address sender,
|
|
80
|
-
address recipient,
|
|
81
|
-
uint256 amount
|
|
82
|
-
) external returns (bool);
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @dev Emitted when `value` tokens are moved from one account (`from`) to
|
|
86
|
-
* another (`to`).
|
|
87
|
-
*
|
|
88
|
-
* Note that `value` may be zero.
|
|
89
|
-
*/
|
|
90
|
-
event Transfer(address indexed from, address indexed to, uint256 value);
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
|
|
94
|
-
* a call to {approve}. `value` is the new allowance.
|
|
95
|
-
*/
|
|
96
|
-
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
97
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
pragma experimental ABIEncoderV2;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface OracleInterface {
|
|
7
|
-
function getUnderlyingPrice(address vToken) external view returns (uint256);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface PivotValidatorInterface {
|
|
11
|
-
function validatePrice(address vToken, uint256 price) external view returns (bool);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface PivotOracleInterface is OracleInterface, PivotValidatorInterface {
|
|
15
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
contract PythStructs {
|
|
5
|
-
//
|
|
6
|
-
// The confidence interval roughly corresponds to the standard error of a normal distribution.
|
|
7
|
-
// Both the price and confidence are stored in a fixed-point numeric representation,
|
|
8
|
-
// `x * (10^expo)`, where `expo` is the exponent.
|
|
9
|
-
//
|
|
10
|
-
// Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how
|
|
11
|
-
// to how this price safely.
|
|
12
|
-
struct Price {
|
|
13
|
-
// Price
|
|
14
|
-
int64 price;
|
|
15
|
-
// Confidence interval around the price
|
|
16
|
-
uint64 conf;
|
|
17
|
-
// Price exponent
|
|
18
|
-
int32 expo;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// PriceFeed represents a current aggregate price from pyth publisher feeds.
|
|
22
|
-
struct PriceFeed {
|
|
23
|
-
// The price ID.
|
|
24
|
-
bytes32 id;
|
|
25
|
-
// Product account key.
|
|
26
|
-
bytes32 productId;
|
|
27
|
-
// The current price.
|
|
28
|
-
int64 price;
|
|
29
|
-
// Confidence interval around the price.
|
|
30
|
-
uint64 conf;
|
|
31
|
-
// Price exponent.
|
|
32
|
-
int32 expo;
|
|
33
|
-
// Status of price.
|
|
34
|
-
PriceStatus status;
|
|
35
|
-
// Maximum number of allowed publishers that can contribute to a price.
|
|
36
|
-
uint32 maxNumPublishers;
|
|
37
|
-
// Number of publishers that made up current aggregate.
|
|
38
|
-
uint32 numPublishers;
|
|
39
|
-
// Exponentially moving average price.
|
|
40
|
-
int64 emaPrice;
|
|
41
|
-
// Exponentially moving average confidence interval.
|
|
42
|
-
uint64 emaConf;
|
|
43
|
-
// Unix timestamp describing when the price was published
|
|
44
|
-
uint64 publishTime;
|
|
45
|
-
// Price of previous price with TRADING status
|
|
46
|
-
int64 prevPrice;
|
|
47
|
-
// Confidence interval of previous price with TRADING status
|
|
48
|
-
uint64 prevConf;
|
|
49
|
-
// Unix timestamp describing when the previous price with TRADING status was published
|
|
50
|
-
uint64 prevPublishTime;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* PriceStatus represents the availability status of a price feed.
|
|
54
|
-
UNKNOWN: The price feed is not currently updating for an unknown reason.
|
|
55
|
-
TRADING: The price feed is updating as expected.
|
|
56
|
-
HALTED: The price feed is not currently updating because trading in the product has been halted.
|
|
57
|
-
AUCTION: The price feed is not currently updating because an auction is setting the price.
|
|
58
|
-
*/
|
|
59
|
-
enum PriceStatus {
|
|
60
|
-
UNKNOWN,
|
|
61
|
-
TRADING,
|
|
62
|
-
HALTED,
|
|
63
|
-
AUCTION
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/// @title Consume prices from the Pyth Network (https://pyth.network/).
|
|
69
|
-
/// @author Pyth Data Association
|
|
70
|
-
interface IPyth {
|
|
71
|
-
/// @dev Emitted when an update for price feed with `id` is processed successfully.
|
|
72
|
-
/// @param id The Pyth Price Feed ID.
|
|
73
|
-
/// @param fresh True if the price update is more recent and stored.
|
|
74
|
-
/// @param chainId ID of the source chain that the batch price update containing this price.
|
|
75
|
-
/// This value comes from Wormhole, and you can find the corresponding chains at https://docs.wormholenetwork.com/wormhole/contracts.
|
|
76
|
-
/// @param sequenceNumber Sequence number of the batch price update containing this price.
|
|
77
|
-
/// @param lastPublishTime Publish time of the previously stored price.
|
|
78
|
-
/// @param publishTime Publish time of the given price update.
|
|
79
|
-
/// @param price Current price of the given price update.
|
|
80
|
-
/// @param conf Current confidence interval of the given price update.
|
|
81
|
-
event PriceFeedUpdate(bytes32 indexed id, bool indexed fresh, uint16 chainId, uint64 sequenceNumber, uint64 lastPublishTime, uint64 publishTime, int64 price, uint64 conf);
|
|
82
|
-
|
|
83
|
-
/// @dev Emitted when a batch price update is processed successfully.
|
|
84
|
-
/// @param chainId ID of the source chain that the batch price update comes from.
|
|
85
|
-
/// @param sequenceNumber Sequence number of the batch price update.
|
|
86
|
-
/// @param batchSize Number of prices within the batch price update.
|
|
87
|
-
/// @param freshPricesInBatch Number of prices that were more recent and were stored.
|
|
88
|
-
event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber, uint batchSize, uint freshPricesInBatch);
|
|
89
|
-
|
|
90
|
-
/// @dev Emitted when a call to `updatePriceFeeds` is processed successfully.
|
|
91
|
-
/// @param sender Sender of the call (`msg.sender`).
|
|
92
|
-
/// @param batchCount Number of batches that this function processed.
|
|
93
|
-
/// @param fee Amount of paid fee for updating the prices.
|
|
94
|
-
event UpdatePriceFeeds(address indexed sender, uint batchCount, uint fee);
|
|
95
|
-
|
|
96
|
-
/// @notice Returns the current price and confidence interval.
|
|
97
|
-
/// @dev Reverts if the current price is not available.
|
|
98
|
-
/// @param id The Pyth Price Feed ID of which to fetch the current price and confidence interval.
|
|
99
|
-
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
|
|
100
|
-
function getCurrentPrice(bytes32 id) external view returns (PythStructs.Price memory price);
|
|
101
|
-
|
|
102
|
-
/// @notice Returns the exponential moving average price and confidence interval.
|
|
103
|
-
/// @dev Reverts if the current exponential moving average price is not available.
|
|
104
|
-
/// @param id The Pyth Price Feed ID of which to fetch the current price and confidence interval.
|
|
105
|
-
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
|
|
106
|
-
function getEmaPrice(bytes32 id) external view returns (PythStructs.Price memory price);
|
|
107
|
-
|
|
108
|
-
/// @notice Returns the latest available price, along with the timestamp when it was generated.
|
|
109
|
-
/// @dev This function returns the same price as `getCurrentPrice` in the case where a price was available
|
|
110
|
-
/// at the time this `PriceFeed` was published (`publish_time`). However, if a price was not available
|
|
111
|
-
/// at that time, this function returns the price from the latest time at which the price was available.
|
|
112
|
-
///
|
|
113
|
-
/// The returned price can be from arbitrarily far in the past; this function makes no guarantees that
|
|
114
|
-
/// the returned price is recent or useful for any particular application.
|
|
115
|
-
///
|
|
116
|
-
/// Users of this function should check the returned timestamp to ensure that the returned price is
|
|
117
|
-
/// sufficiently recent for their application. If you are considering using this function, it may be
|
|
118
|
-
/// safer / easier to use either `getCurrentPrice` or `getLatestAvailablePriceWithinDuration`.
|
|
119
|
-
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
|
|
120
|
-
/// @return publishTime - the UNIX timestamp of when this price was computed.
|
|
121
|
-
function getLatestAvailablePriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price, uint64 publishTime);
|
|
122
|
-
|
|
123
|
-
/// @notice Returns the latest price as long as it was updated within `duration` seconds of the current time.
|
|
124
|
-
/// @dev This function is a sanity-checked version of `getLatestAvailablePriceUnchecked` which is useful in
|
|
125
|
-
/// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
|
|
126
|
-
/// recently.
|
|
127
|
-
function getLatestAvailablePriceWithinDuration(bytes32 id, uint64 duration) external view returns (PythStructs.Price memory price);
|
|
128
|
-
|
|
129
|
-
/// @notice Update price feeds with given update messages.
|
|
130
|
-
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
|
|
131
|
-
/// `getUpdateFee` with the length of the `updateData` array.
|
|
132
|
-
/// Prices will be updated if they are more recent than the current stored prices.
|
|
133
|
-
/// The call will succeed even if the update is not the most recent.
|
|
134
|
-
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
|
|
135
|
-
/// @param updateData Array of price update data.
|
|
136
|
-
function updatePriceFeeds(bytes[] memory updateData) external payable;
|
|
137
|
-
|
|
138
|
-
/// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is
|
|
139
|
-
/// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the
|
|
140
|
-
/// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`.
|
|
141
|
-
///
|
|
142
|
-
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
|
|
143
|
-
/// `getUpdateFee` with the length of the `updateData` array.
|
|
144
|
-
///
|
|
145
|
-
/// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime
|
|
146
|
-
/// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have
|
|
147
|
-
/// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.
|
|
148
|
-
/// Otherwise, it calls updatePriceFeeds method to update the prices.
|
|
149
|
-
///
|
|
150
|
-
/// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.
|
|
151
|
-
/// @param updateData Array of price update data.
|
|
152
|
-
/// @param priceIds Array of price ids.
|
|
153
|
-
/// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`
|
|
154
|
-
function updatePriceFeedsIfNecessary(bytes[] memory updateData, bytes32[] memory priceIds, uint64[] memory publishTimes) external payable;
|
|
155
|
-
|
|
156
|
-
/// @notice Returns the required fee to update an array of price updates.
|
|
157
|
-
/// @param updateDataSize Number of price updates.
|
|
158
|
-
/// @return feeAmount The required fee in Wei.
|
|
159
|
-
function getUpdateFee(uint updateDataSize) external view returns (uint feeAmount);
|
|
160
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
import "./BEP20Interface.sol";
|
|
5
|
-
|
|
6
|
-
interface VBep20Interface is BEP20Interface {
|
|
7
|
-
/**
|
|
8
|
-
* @notice Underlying asset for this VToken
|
|
9
|
-
*/
|
|
10
|
-
function underlying() external view returns (address);
|
|
11
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
library FixedPoint {
|
|
5
|
-
// range: [0, 2**112 - 1]
|
|
6
|
-
// resolution: 1 / 2**112
|
|
7
|
-
struct uq112x112 {
|
|
8
|
-
uint224 _x;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// returns a uq112x112 which represents the ratio of the numerator to the denominator
|
|
12
|
-
// equivalent to encode(numerator).div(denominator)
|
|
13
|
-
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
|
|
14
|
-
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
|
|
15
|
-
return uq112x112((uint224(numerator) << 112) / denominator);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// decode a uq112x112 into a uint with 18 decimals of precision
|
|
19
|
-
function decode112with18(uq112x112 memory self) internal pure returns (uint) {
|
|
20
|
-
// we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous
|
|
21
|
-
// instead, get close to:
|
|
22
|
-
// (x * 1e18) >> 112
|
|
23
|
-
// without risk of overflowing, e.g.:
|
|
24
|
-
// (x) / 2 ** (112 - lg(1e18))
|
|
25
|
-
return uint(self._x) / 5192296858534827;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// library with helper methods for oracles that are concerned with computing average prices
|
|
30
|
-
library PancakeOracleLibrary {
|
|
31
|
-
using FixedPoint for *;
|
|
32
|
-
|
|
33
|
-
// helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]
|
|
34
|
-
function currentBlockTimestamp() internal view returns (uint32) {
|
|
35
|
-
return uint32(block.timestamp % 2 ** 32);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// produces the cumulative price using counterfactuals to save gas and avoid a call to sync.
|
|
39
|
-
function currentCumulativePrices(
|
|
40
|
-
address pair
|
|
41
|
-
) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {
|
|
42
|
-
blockTimestamp = currentBlockTimestamp();
|
|
43
|
-
price0Cumulative = IPancakePair(pair).price0CumulativeLast();
|
|
44
|
-
price1Cumulative = IPancakePair(pair).price1CumulativeLast();
|
|
45
|
-
|
|
46
|
-
// if time has elapsed since the last update on the pair, mock the accumulated price values
|
|
47
|
-
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves();
|
|
48
|
-
if (blockTimestampLast != blockTimestamp) {
|
|
49
|
-
// subtraction overflow is desired
|
|
50
|
-
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
|
|
51
|
-
// addition overflow is desired
|
|
52
|
-
// counterfactual
|
|
53
|
-
price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
|
|
54
|
-
// counterfactual
|
|
55
|
-
price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface IPancakePair {
|
|
61
|
-
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
|
|
62
|
-
function price0CumulativeLast() external view returns (uint);
|
|
63
|
-
function price1CumulativeLast() external view returns (uint);
|
|
64
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
pragma experimental ABIEncoderV2;
|
|
4
|
-
|
|
5
|
-
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
6
|
-
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
|
|
7
|
-
|
|
8
|
-
struct ValidateConfig {
|
|
9
|
-
/// @notice vToken address
|
|
10
|
-
address vToken;
|
|
11
|
-
/// @notice upper bound of deviation between reported price and anchor price,
|
|
12
|
-
/// beyond which the reported price will be invalidated
|
|
13
|
-
uint256 upperBoundRatio;
|
|
14
|
-
/// @notice lower bound of deviation between reported price and anchor price,
|
|
15
|
-
/// below which the reported price will be invalidated
|
|
16
|
-
uint256 lowerBoundRatio;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// BoundValidator provides some common functions and can be used
|
|
20
|
-
// to wrap up other contracts to form pivot oracles
|
|
21
|
-
contract BoundValidator is OwnableUpgradeable {
|
|
22
|
-
using SafeMath for uint256;
|
|
23
|
-
|
|
24
|
-
/// @notice validation configs by token
|
|
25
|
-
mapping(address => ValidateConfig) public validateConfigs;
|
|
26
|
-
|
|
27
|
-
/// @notice Emit this event when new validate configs are added
|
|
28
|
-
event ValidateConfigAdded(
|
|
29
|
-
address indexed vToken,
|
|
30
|
-
uint256 indexed upperBound,
|
|
31
|
-
uint256 indexed lowerBound
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @notice Add multiple validation configs at the same time
|
|
36
|
-
* @param configs config array
|
|
37
|
-
*/
|
|
38
|
-
function setValidateConfigs(ValidateConfig[] memory configs) external virtual onlyOwner() {
|
|
39
|
-
require(configs.length > 0, "invalid validate config length");
|
|
40
|
-
for (uint8 i = 0; i < configs.length; i++) {
|
|
41
|
-
setValidateConfig(configs[i]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @notice Add single validation config
|
|
47
|
-
* @param config config struct
|
|
48
|
-
*/
|
|
49
|
-
function setValidateConfig(ValidateConfig memory config) public virtual onlyOwner()
|
|
50
|
-
{
|
|
51
|
-
require(config.vToken != address(0), "vToken can't be zero address");
|
|
52
|
-
require(config.upperBoundRatio > 0 && config.lowerBoundRatio > 0, "bound must be positive");
|
|
53
|
-
require(config.upperBoundRatio > config.lowerBoundRatio, "upper bound must be higher than lowner bound");
|
|
54
|
-
validateConfigs[config.vToken] = config;
|
|
55
|
-
emit ValidateConfigAdded(
|
|
56
|
-
config.vToken,
|
|
57
|
-
config.upperBoundRatio,
|
|
58
|
-
config.lowerBoundRatio
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @notice Test reported vToken underlying price against anchor price
|
|
64
|
-
* @param vToken vToken address
|
|
65
|
-
* @param reporterPrice the price to be tested
|
|
66
|
-
*/
|
|
67
|
-
function validatePriceWithAnchorPrice(
|
|
68
|
-
address vToken,
|
|
69
|
-
uint256 reporterPrice,
|
|
70
|
-
uint256 anchorPrice) public view virtual returns (bool)
|
|
71
|
-
{
|
|
72
|
-
require(validateConfigs[vToken].upperBoundRatio != 0, "validation config not exist");
|
|
73
|
-
require(anchorPrice != 0, "anchor price is not valid");
|
|
74
|
-
return _isWithinAnchor(vToken, reporterPrice, anchorPrice);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @notice Test whether the reported price is within the predefined bounds
|
|
79
|
-
* @param vToken vToken address
|
|
80
|
-
* @param reporterPrice the price to be tested
|
|
81
|
-
* @param anchorPrice anchor price as testing anchor
|
|
82
|
-
*/
|
|
83
|
-
function _isWithinAnchor(address vToken, uint256 reporterPrice, uint256 anchorPrice) internal view returns (bool) {
|
|
84
|
-
if (reporterPrice > 0) {
|
|
85
|
-
uint256 anchorRatio = anchorPrice.mul(100e16).div(reporterPrice);
|
|
86
|
-
uint256 upperBoundAnchorRatio = validateConfigs[vToken].upperBoundRatio;
|
|
87
|
-
uint256 lowerBoundAnchorRatio = validateConfigs[vToken].lowerBoundRatio;
|
|
88
|
-
return anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio;
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// BoundValidator is to get inherited, so it's a good practice to add some storage gaps like
|
|
94
|
-
// OpenZepplin proposed in their contracts: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
95
|
-
uint256[49] private __gap;
|
|
96
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
pragma experimental ABIEncoderV2;
|
|
4
|
-
|
|
5
|
-
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
6
|
-
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
|
|
7
|
-
import "../interfaces/VBep20Interface.sol";
|
|
8
|
-
import "../interfaces/AggregatorV2V3Interface.sol";
|
|
9
|
-
import "../interfaces/OracleInterface.sol";
|
|
10
|
-
|
|
11
|
-
struct TokenConfig {
|
|
12
|
-
/// @notice vToken address, which can't be zero address and can be used for existance check
|
|
13
|
-
address vToken;
|
|
14
|
-
/// @notice chainlink feed address
|
|
15
|
-
address feed;
|
|
16
|
-
/// @notice expiration period of this asset
|
|
17
|
-
uint256 maxStalePeriod;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
21
|
-
using SafeMath for uint256;
|
|
22
|
-
|
|
23
|
-
/// @notice VAI token is considered $1 constantly in oracle for now
|
|
24
|
-
uint256 public constant VAI_VALUE = 1e18;
|
|
25
|
-
|
|
26
|
-
/// @notice TODO: might be removed some day, it's for enabling us to force set the prices to
|
|
27
|
-
/// certain values in some urgent conditions
|
|
28
|
-
mapping(address => uint256) public prices;
|
|
29
|
-
|
|
30
|
-
/// @notice token config by assets
|
|
31
|
-
mapping(address => TokenConfig) public tokenConfigs;
|
|
32
|
-
|
|
33
|
-
/// @notice emit when forced price is set
|
|
34
|
-
event PricePosted(
|
|
35
|
-
address asset,
|
|
36
|
-
uint256 previousPriceMantissa,
|
|
37
|
-
uint256 requestedPriceMantissa,
|
|
38
|
-
uint256 newPriceMantissa
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
/// @notice emit when token config is added
|
|
42
|
-
event TokenConfigAdded(address vToken, address feed, uint256 maxStalePeriod);
|
|
43
|
-
|
|
44
|
-
modifier notNullAddress(address someone) {
|
|
45
|
-
require(someone != address(0), "can't be zero address");
|
|
46
|
-
_;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function initialize() public initializer {
|
|
50
|
-
__Ownable_init();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @notice Get the Chainlink price of underlying asset of input vToken, revert when vToken is zero address
|
|
55
|
-
* @param vToken vToken address
|
|
56
|
-
* @return price in USD, with 18 decimals
|
|
57
|
-
*/
|
|
58
|
-
function getUnderlyingPrice(address vToken) public view override
|
|
59
|
-
returns (uint256)
|
|
60
|
-
{
|
|
61
|
-
string memory symbol = VBep20Interface(vToken).symbol();
|
|
62
|
-
// VBNB token doesn't have `underlying` method, so it has to skip `_getUnderlyingPriceInternal
|
|
63
|
-
// method and directly goes into `_getChainlinkPrice`
|
|
64
|
-
if (_compareStrings(symbol, "vBNB")) {
|
|
65
|
-
return _getChainlinkPrice(vToken);
|
|
66
|
-
// VAI price is constantly 1 at the moment, but not guarantee in the future
|
|
67
|
-
} else if (_compareStrings(symbol, "VAI")) {
|
|
68
|
-
return VAI_VALUE;
|
|
69
|
-
// @TODO: This is some history code, keep it here in case of messing up
|
|
70
|
-
} else if (_compareStrings(symbol, "XVS")) {
|
|
71
|
-
return prices[address(vToken)];
|
|
72
|
-
} else {
|
|
73
|
-
return _getUnderlyingPriceInternal(VBep20Interface(vToken));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @notice Get the Chainlink price of underlying asset of input vToken or cached price when it's been set
|
|
79
|
-
* @dev The decimals of underlying tokens is considered to ensure the returned prices are in 18 decimals
|
|
80
|
-
* @param vToken vToken address
|
|
81
|
-
* @return price in USD, with 18 decimals
|
|
82
|
-
*/
|
|
83
|
-
function _getUnderlyingPriceInternal(VBep20Interface vToken) internal view returns (uint256 price) {
|
|
84
|
-
VBep20Interface token = VBep20Interface(vToken.underlying());
|
|
85
|
-
|
|
86
|
-
if (prices[address(token)] != 0) {
|
|
87
|
-
price = prices[address(token)];
|
|
88
|
-
} else {
|
|
89
|
-
price = _getChainlinkPrice(address(vToken));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
uint256 decimalDelta = uint256(18).sub(uint256(token.decimals()));
|
|
93
|
-
return price.mul(10**decimalDelta);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @notice Get the Chainlink price of underlying asset of input vToken, revert if token config doesn't exit
|
|
98
|
-
* @dev The decimals of feeds are considered
|
|
99
|
-
* @param vToken vToken address
|
|
100
|
-
* @return price in USD, with 18 decimals
|
|
101
|
-
*/
|
|
102
|
-
function _getChainlinkPrice(address vToken)
|
|
103
|
-
internal view
|
|
104
|
-
notNullAddress(tokenConfigs[address(vToken)].vToken)
|
|
105
|
-
returns (uint256)
|
|
106
|
-
{
|
|
107
|
-
TokenConfig storage tokenConfig = tokenConfigs[vToken];
|
|
108
|
-
AggregatorV2V3Interface feed = AggregatorV2V3Interface(tokenConfig.feed);
|
|
109
|
-
|
|
110
|
-
// note: maxStalePeriod cannot be 0
|
|
111
|
-
uint256 maxStalePeriod = tokenConfig.maxStalePeriod;
|
|
112
|
-
|
|
113
|
-
// Chainlink USD-denominated feeds store answers at 8 decimals, mostly
|
|
114
|
-
uint256 decimalDelta = uint256(18).sub(feed.decimals());
|
|
115
|
-
|
|
116
|
-
(, int256 answer, , uint256 updatedAt, ) = feed.latestRoundData();
|
|
117
|
-
require(answer > 0, "chainlink price must be positive");
|
|
118
|
-
|
|
119
|
-
uint256 deltaTime = block.timestamp.sub(updatedAt, "updatedAt exceeds block time");
|
|
120
|
-
require(deltaTime <= maxStalePeriod, "chainlink price expired");
|
|
121
|
-
|
|
122
|
-
return uint256(answer).mul(10**decimalDelta);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @notice Set the forced prices of the underlying token of input vToken
|
|
127
|
-
* @param vToken vToken address
|
|
128
|
-
* @param underlyingPriceMantissa price in 18 decimals
|
|
129
|
-
*/
|
|
130
|
-
function setUnderlyingPrice(VBep20Interface vToken, uint256 underlyingPriceMantissa) external onlyOwner() {
|
|
131
|
-
address asset = address(vToken.underlying());
|
|
132
|
-
emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);
|
|
133
|
-
prices[asset] = underlyingPriceMantissa;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @notice Set the forced prices of the input token
|
|
138
|
-
* @param asset asset address
|
|
139
|
-
* @param price price in 18 decimals
|
|
140
|
-
*/
|
|
141
|
-
function setDirectPrice(address asset, uint256 price) external onlyOwner() {
|
|
142
|
-
emit PricePosted(asset, prices[asset], price, price);
|
|
143
|
-
prices[asset] = price;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @notice Add multiple token configs at the same time
|
|
148
|
-
* @param tokenConfigs_ config array
|
|
149
|
-
*/
|
|
150
|
-
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external onlyOwner() {
|
|
151
|
-
require(tokenConfigs_.length > 0, "length can't be 0");
|
|
152
|
-
for (uint256 i = 0; i < tokenConfigs_.length; i++) {
|
|
153
|
-
setTokenConfig(tokenConfigs_[i]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @notice Add single token config, vToken & feed cannot be zero address, and maxStalePeriod must be positive
|
|
159
|
-
* @param tokenConfig token config struct
|
|
160
|
-
*/
|
|
161
|
-
function setTokenConfig(TokenConfig memory tokenConfig) public
|
|
162
|
-
onlyOwner()
|
|
163
|
-
notNullAddress(tokenConfig.vToken)
|
|
164
|
-
notNullAddress(tokenConfig.feed)
|
|
165
|
-
{
|
|
166
|
-
require(tokenConfig.maxStalePeriod > 0, "stale period can't be zero");
|
|
167
|
-
tokenConfigs[tokenConfig.vToken] = tokenConfig;
|
|
168
|
-
emit TokenConfigAdded(
|
|
169
|
-
tokenConfig.vToken,
|
|
170
|
-
tokenConfig.feed,
|
|
171
|
-
tokenConfig.maxStalePeriod
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function _compareStrings(string memory a, string memory b) internal pure returns (bool) {
|
|
176
|
-
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
pragma experimental ABIEncoderV2;
|
|
4
|
-
|
|
5
|
-
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
|
|
6
|
-
import "./BoundValidator.sol";
|
|
7
|
-
import "./PythOracle.sol";
|
|
8
|
-
|
|
9
|
-
contract PivotPythOracle is PythOracle, BoundValidator, PivotOracleInterface {
|
|
10
|
-
/**
|
|
11
|
-
* @notice Test reported vToken underlying price against stored TWAP
|
|
12
|
-
* @param vToken vToken address
|
|
13
|
-
* @param reporterPrice the price to be tested
|
|
14
|
-
*/
|
|
15
|
-
function validatePrice(address vToken, uint256 reporterPrice) external view override returns (bool) {
|
|
16
|
-
return validatePriceWithAnchorPrice(vToken, reporterPrice, getUnderlyingPrice(vToken));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
pragma experimental ABIEncoderV2;
|
|
4
|
-
|
|
5
|
-
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
|
|
6
|
-
import "./BoundValidator.sol";
|
|
7
|
-
import "./TwapOracle.sol";
|
|
8
|
-
|
|
9
|
-
contract PivotTwapOracle is TwapOracle, BoundValidator, PivotOracleInterface {
|
|
10
|
-
/**
|
|
11
|
-
* @notice Test reported vToken underlying price against stored TWAP
|
|
12
|
-
* @param vToken vToken address
|
|
13
|
-
* @param reporterPrice the price to be tested
|
|
14
|
-
*/
|
|
15
|
-
function validatePrice(address vToken, uint256 reporterPrice) external view override returns (bool) {
|
|
16
|
-
return validatePriceWithAnchorPrice(vToken, reporterPrice, prices[vToken]);
|
|
17
|
-
}
|
|
18
|
-
}
|