@venusprotocol/oracle 1.2.0 → 1.2.1
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/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/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/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/c88e3d40dfcb048309cae1c803479ead.json +1 -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/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 +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/MockPythOracle.sol/MockPythOracle.dbg.json +1 -1
- 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} +2 -2
- 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 +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/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/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,113 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
// a library for performing various math operations
|
|
5
|
-
|
|
6
|
-
library Math {
|
|
7
|
-
function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
|
|
8
|
-
z = x < y ? x : y;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
|
|
12
|
-
function sqrt(uint256 y) internal pure returns (uint256 z) {
|
|
13
|
-
if (y > 3) {
|
|
14
|
-
z = y;
|
|
15
|
-
uint256 x = y / 2 + 1;
|
|
16
|
-
while (x < z) {
|
|
17
|
-
z = x;
|
|
18
|
-
x = (y / x + x) / 2;
|
|
19
|
-
}
|
|
20
|
-
} else if (y != 0) {
|
|
21
|
-
z = 1;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// range: [0, 2**112 - 1]
|
|
28
|
-
// resolution: 1 / 2**112
|
|
29
|
-
|
|
30
|
-
library UQ112x112 {
|
|
31
|
-
//solhint-disable-next-line state-visibility
|
|
32
|
-
uint224 constant Q112 = 2**112;
|
|
33
|
-
|
|
34
|
-
// encode a uint112 as a UQ112x112
|
|
35
|
-
function encode(uint112 y) internal pure returns (uint224 z) {
|
|
36
|
-
z = uint224(y) * Q112; // never overflows
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// divide a UQ112x112 by a uint112, returning a UQ112x112
|
|
40
|
-
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
|
|
41
|
-
z = x / uint224(y);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
contract PancakePairHarness {
|
|
47
|
-
using UQ112x112 for uint224;
|
|
48
|
-
|
|
49
|
-
address public token0;
|
|
50
|
-
address public token1;
|
|
51
|
-
|
|
52
|
-
uint112 private reserve0; // uses single storage slot, accessible via getReserves
|
|
53
|
-
uint112 private reserve1; // uses single storage slot, accessible via getReserves
|
|
54
|
-
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
|
|
55
|
-
|
|
56
|
-
uint256 public price0CumulativeLast;
|
|
57
|
-
uint256 public price1CumulativeLast;
|
|
58
|
-
uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
|
|
59
|
-
|
|
60
|
-
function currentBlockTimestamp() external view returns (uint32) {
|
|
61
|
-
return uint32(block.timestamp % 2 ** 32);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function getReserves()
|
|
65
|
-
public
|
|
66
|
-
view
|
|
67
|
-
returns (
|
|
68
|
-
uint112 _reserve0,
|
|
69
|
-
uint112 _reserve1,
|
|
70
|
-
uint32 _blockTimestampLast
|
|
71
|
-
)
|
|
72
|
-
{
|
|
73
|
-
_reserve0 = reserve0;
|
|
74
|
-
_reserve1 = reserve1;
|
|
75
|
-
_blockTimestampLast = blockTimestampLast;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// called once by the factory at time of deployment
|
|
80
|
-
function initialize(address _token0, address _token1) external {
|
|
81
|
-
token0 = _token0;
|
|
82
|
-
token1 = _token1;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// update reserves and, on the first call per block, price accumulators
|
|
86
|
-
function update(
|
|
87
|
-
uint256 balance0,
|
|
88
|
-
uint256 balance1,
|
|
89
|
-
uint112 _reserve0,
|
|
90
|
-
uint112 _reserve1
|
|
91
|
-
) external {
|
|
92
|
-
require(
|
|
93
|
-
balance0 <= type(uint112).max && balance1 <= type(uint112).max,
|
|
94
|
-
"PancakeV2: OVERFLOW"
|
|
95
|
-
);
|
|
96
|
-
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
|
|
97
|
-
unchecked {
|
|
98
|
-
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
|
|
99
|
-
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
|
|
100
|
-
// * never overflows, and + overflow is desired
|
|
101
|
-
price0CumulativeLast +=
|
|
102
|
-
uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) *
|
|
103
|
-
timeElapsed;
|
|
104
|
-
price1CumulativeLast +=
|
|
105
|
-
uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) *
|
|
106
|
-
timeElapsed;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
reserve0 = uint112(balance0);
|
|
110
|
-
reserve1 = uint112(balance1);
|
|
111
|
-
blockTimestampLast = blockTimestamp;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,22 +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 "./BEP20Harness.sol";
|
|
7
|
-
|
|
8
|
-
contract VBEP20Harness is BEP20Harness {
|
|
9
|
-
/**
|
|
10
|
-
* @notice Underlying asset for this VToken
|
|
11
|
-
*/
|
|
12
|
-
address public underlying;
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
string memory name_,
|
|
16
|
-
string memory symbol_,
|
|
17
|
-
uint8 decimals,
|
|
18
|
-
address underlying_
|
|
19
|
-
) BEP20Harness(name_, symbol_, decimals) {
|
|
20
|
-
underlying = underlying_;
|
|
21
|
-
}
|
|
22
|
-
}
|