@venusprotocol/oracle 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/build-info/1d7bedd9b14544f287811332b9a539d7.json +1 -0
- package/artifacts/build-info/f6af69795174616b8b4a6373f9f1c538.json +1 -0
- package/artifacts/contracts/PriceOracle.sol/PriceOracle.dbg.json +1 -1
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +1 -1
- package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json +2 -2
- 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 +1 -1
- package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.json +2 -2
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.dbg.json +1 -1
- package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.json +3 -3
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.json +2 -2
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.json +2 -2
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.json +2 -2
- package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.json +2 -2
- package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.json +2 -2
- package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.json +2 -2
- package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.dbg.json +1 -1
- package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.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 +1 -1
- package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.json +2 -2
- 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/contracts/PriceOracle.sol +2 -2
- package/contracts/ResilientOracle.sol +127 -114
- package/contracts/libraries/PancakeLibrary.sol +8 -8
- package/contracts/oracles/BinanceOracle.sol +4 -4
- package/contracts/oracles/BoundValidator.sol +31 -29
- package/contracts/oracles/ChainlinkOracle.sol +85 -83
- package/contracts/oracles/PythOracle.sol +41 -41
- package/contracts/oracles/TwapOracle.sol +67 -67
- package/contracts/oracles/mocks/MockBinanceOracle.sol +4 -4
- package/contracts/oracles/mocks/MockChainlinkOracle.sol +4 -4
- package/contracts/oracles/mocks/MockPythOracle.sol +4 -4
- package/contracts/oracles/mocks/MockTwapOracle.sol +4 -4
- package/contracts/test/MockPyth.sol +13 -13
- package/contracts/test/MockSimpleOracle.sol +8 -8
- package/contracts/test/MockV3Aggregator.sol +18 -18
- package/contracts/test/PancakePairHarness.sol +10 -10
- package/deploy/1-deploy-oracles.d.ts +1 -3
- package/deploy/1-deploy-oracles.d.ts.map +1 -1
- package/deploy/1-deploy-oracles.js +2 -1
- package/deploy/1-deploy-oracles.js.map +1 -1
- package/deploy/2-configure-feeds.d.ts +1 -3
- package/deploy/2-configure-feeds.d.ts.map +1 -1
- package/deploy/2-configure-feeds.js +101 -87
- package/deploy/2-configure-feeds.js.map +1 -1
- package/deployments/bsctestnet/BinanceOracle.json +42 -29
- package/deployments/bsctestnet/BinanceOracle_Implementation.json +96 -23
- package/deployments/bsctestnet/BinanceOracle_Proxy.json +28 -28
- package/deployments/bsctestnet/BoundValidator.json +65 -39
- package/deployments/bsctestnet/BoundValidator_Implementation.json +113 -35
- package/deployments/bsctestnet/BoundValidator_Proxy.json +37 -37
- package/deployments/bsctestnet/ChainlinkOracle.json +64 -38
- package/deployments/bsctestnet/ChainlinkOracle_Implementation.json +122 -41
- package/deployments/bsctestnet/ChainlinkOracle_Proxy.json +37 -37
- package/deployments/bsctestnet/DefaultProxyAdmin.json +15 -15
- package/deployments/bsctestnet/PythOracle.json +71 -45
- package/deployments/bsctestnet/PythOracle_Implementation.json +128 -44
- package/deployments/bsctestnet/PythOracle_Proxy.json +44 -44
- package/deployments/bsctestnet/ResilientOracle.json +67 -54
- package/deployments/bsctestnet/ResilientOracle_Implementation.json +161 -63
- package/deployments/bsctestnet/ResilientOracle_Proxy.json +39 -39
- package/deployments/bsctestnet/TwapOracle.json +74 -71
- package/deployments/bsctestnet/TwapOracle_Implementation.json +163 -93
- package/deployments/bsctestnet/TwapOracle_Proxy.json +37 -41
- package/deployments/bsctestnet/solcInputs/6153c675ce838eebb6442d63350712be.json +144 -0
- package/package.json +4 -2
- package/artifacts/build-info/4f6308532d612c9477fab05b03e221e5.json +0 -1
- package/deployments/bsctestnet/solcInputs/09bc2981019c6dcce653b90bac585fe0.json +0 -81
- package/deployments/bsctestnet/solcInputs/5dedb37ab8105f1f71e53a3f865859c5.json +0 -57
- package/deployments/bsctestnet/solcInputs/bb71c6049f6b7b21a6581f40daf802bc.json +0 -138
|
@@ -7,12 +7,12 @@ import "../interfaces/OracleInterface.sol";
|
|
|
7
7
|
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
|
|
8
8
|
|
|
9
9
|
struct TokenConfig {
|
|
10
|
-
/// @notice
|
|
10
|
+
/// @notice Underlying token address, which can't be a null address and can be used to check if a token is supported
|
|
11
11
|
/// @notice 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB for BNB
|
|
12
12
|
address asset;
|
|
13
|
-
/// @notice
|
|
13
|
+
/// @notice Chainlink feed address
|
|
14
14
|
address feed;
|
|
15
|
-
/// @notice expiration period of this asset
|
|
15
|
+
/// @notice Price expiration period of this asset
|
|
16
16
|
uint256 maxStalePeriod;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -24,16 +24,16 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
24
24
|
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
25
25
|
address public immutable vBnb;
|
|
26
26
|
|
|
27
|
-
/// @notice Set this as asset address for BNB. This is the underlying for vBNB
|
|
27
|
+
/// @notice Set this as asset address for BNB. This is the underlying address for vBNB
|
|
28
28
|
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
29
29
|
|
|
30
|
-
/// @notice
|
|
30
|
+
/// @notice Manually set an override price, useful under extenuating conditions such as price feed failure
|
|
31
31
|
mapping(address => uint256) public prices;
|
|
32
32
|
|
|
33
|
-
/// @notice
|
|
33
|
+
/// @notice Token config by assets
|
|
34
34
|
mapping(address => TokenConfig) public tokenConfigs;
|
|
35
35
|
|
|
36
|
-
/// @notice
|
|
36
|
+
/// @notice Emit when a price is manually set
|
|
37
37
|
event PricePosted(
|
|
38
38
|
address asset,
|
|
39
39
|
uint256 previousPriceMantissa,
|
|
@@ -41,7 +41,7 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
41
41
|
uint256 newPriceMantissa
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
/// @notice
|
|
44
|
+
/// @notice Emit when a token config is added
|
|
45
45
|
event TokenConfigAdded(address asset, address feed, uint256 maxStalePeriod);
|
|
46
46
|
|
|
47
47
|
modifier notNullAddress(address someone) {
|
|
@@ -50,22 +50,82 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
53
|
-
/// @param vBnbAddress The address of the
|
|
53
|
+
/// @param vBnbAddress The address of the vBNB
|
|
54
54
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
55
55
|
constructor(address vBnbAddress) notNullAddress(vBnbAddress) {
|
|
56
56
|
vBnb = vBnbAddress;
|
|
57
57
|
_disableInitializers();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @notice Set the forced prices of the underlying token of input vToken
|
|
62
|
+
* @param vToken vToken address
|
|
63
|
+
* @param underlyingPriceMantissa price in 18 decimals
|
|
64
|
+
* @custom:access Only Governance
|
|
65
|
+
* @custom:error NotNullAddress thrown if address of vToken is null
|
|
66
|
+
* @custom:event Emits PricePosted event on succesfully setup of underlying price
|
|
67
|
+
*/
|
|
68
|
+
function setUnderlyingPrice(
|
|
69
|
+
VBep20Interface vToken,
|
|
70
|
+
uint256 underlyingPriceMantissa
|
|
71
|
+
) external notNullAddress(address(vToken)) onlyOwner {
|
|
72
|
+
address asset = address(vToken) == vBnb ? BNB_ADDR : address(vToken.underlying());
|
|
73
|
+
emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);
|
|
74
|
+
prices[asset] = underlyingPriceMantissa;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @notice Manually set the price of a given asset
|
|
79
|
+
* @param asset Asset address
|
|
80
|
+
* @param price Underlying price in 18 decimals
|
|
81
|
+
* @custom:access Only Governance
|
|
82
|
+
* @custom:event Emits PricePosted event on succesfully setup of underlying price
|
|
83
|
+
*/
|
|
84
|
+
function setDirectPrice(address asset, uint256 price) external notNullAddress(asset) onlyOwner {
|
|
85
|
+
emit PricePosted(asset, prices[asset], price, price);
|
|
86
|
+
prices[asset] = price;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @notice Add multiple token configs at the same time
|
|
91
|
+
* @param tokenConfigs_ config array
|
|
92
|
+
* @custom:access Only Governance
|
|
93
|
+
* @custom:error Zero length error thrown, if length of the array in parameter is 0
|
|
94
|
+
*/
|
|
95
|
+
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external onlyOwner {
|
|
96
|
+
require(tokenConfigs_.length > 0, "length can't be 0");
|
|
97
|
+
uint256 numTokenConfigs = tokenConfigs_.length;
|
|
98
|
+
for (uint256 i; i < numTokenConfigs; ++i) {
|
|
99
|
+
setTokenConfig(tokenConfigs_[i]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
60
103
|
/// @notice Initializes the owner of the contract
|
|
61
104
|
function initialize() public initializer {
|
|
62
105
|
__Ownable_init();
|
|
63
106
|
}
|
|
64
107
|
|
|
65
108
|
/**
|
|
66
|
-
* @notice
|
|
109
|
+
* @notice Add single token config. vToken & feed cannot be null addresses and maxStalePeriod must be positive
|
|
110
|
+
* @param tokenConfig Token config struct
|
|
111
|
+
* @custom:access Only Governance
|
|
112
|
+
* @custom:error NotNullAddress error is thrown if asset address is null
|
|
113
|
+
* @custom:error NotNullAddress error is thrown if token feed address is null
|
|
114
|
+
* @custom:error Range error is thrown if maxStale period of token is not greater than zero
|
|
115
|
+
* @custom:event Emits TokenConfigAdded event on succesfully setting of the token config
|
|
116
|
+
*/
|
|
117
|
+
function setTokenConfig(
|
|
118
|
+
TokenConfig memory tokenConfig
|
|
119
|
+
) public onlyOwner notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.feed) {
|
|
120
|
+
require(tokenConfig.maxStalePeriod > 0, "stale period can't be zero");
|
|
121
|
+
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
122
|
+
emit TokenConfigAdded(tokenConfig.asset, tokenConfig.feed, tokenConfig.maxStalePeriod);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @notice Gets the Chainlink price for the underlying asset of a given vToken, revert when vToken is a null address
|
|
67
127
|
* @param vToken vToken address
|
|
68
|
-
* @return price in USD
|
|
128
|
+
* @return price Underlying price in USD
|
|
69
129
|
*/
|
|
70
130
|
function getUnderlyingPrice(address vToken) public view override returns (uint256) {
|
|
71
131
|
string memory symbol = address(vToken) != vBnb ? VBep20Interface(vToken).symbol() : "BNB";
|
|
@@ -78,16 +138,18 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
78
138
|
}
|
|
79
139
|
|
|
80
140
|
/**
|
|
81
|
-
* @notice
|
|
82
|
-
*
|
|
141
|
+
* @notice Gets the Chainlink price for the underlying asset of a given vToken
|
|
142
|
+
* or the manually set price if it's been set
|
|
143
|
+
* @dev The decimals of the underlying token are considered to ensure the returned price
|
|
144
|
+
* has 18 decimals of precision
|
|
83
145
|
* @param vToken vToken address
|
|
84
|
-
* @return price in USD
|
|
146
|
+
* @return price Underlying price in USD
|
|
85
147
|
*/
|
|
86
148
|
function _getUnderlyingPriceInternal(VBep20Interface vToken) internal view returns (uint256 price) {
|
|
87
149
|
address token;
|
|
88
150
|
uint256 decimals;
|
|
89
151
|
|
|
90
|
-
//
|
|
152
|
+
// vBNB token doesn't have `underlying` method
|
|
91
153
|
if (address(vToken) == vBnb) {
|
|
92
154
|
token = BNB_ADDR;
|
|
93
155
|
decimals = 18;
|
|
@@ -108,14 +170,14 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
108
170
|
}
|
|
109
171
|
|
|
110
172
|
/**
|
|
111
|
-
* @notice Get the Chainlink price
|
|
112
|
-
* @dev The
|
|
113
|
-
* @param asset
|
|
114
|
-
* @return price in USD, with 18 decimals
|
|
115
|
-
* @custom:error NotNullAddress error thrown if asset address is
|
|
116
|
-
* @custom:error Price error if
|
|
117
|
-
* @custom:error Timing error if current timestamp is less than last
|
|
118
|
-
* @custom:error Timing error if time difference between current time and last
|
|
173
|
+
* @notice Get the Chainlink price for the underlying asset of a given vToken, revert if token config doesn't exit
|
|
174
|
+
* @dev The precision of the price feed is used to ensure the returned price has 18 decimals of precision
|
|
175
|
+
* @param asset Underlying asset address
|
|
176
|
+
* @return price Underlying price in USD, with 18 decimals of precision
|
|
177
|
+
* @custom:error NotNullAddress error is thrown if the asset address is null
|
|
178
|
+
* @custom:error Price error is thrown if the Chainlink price of asset is not greater than zero
|
|
179
|
+
* @custom:error Timing error is thrown if current timestamp is less than the last updatedAt timestamp
|
|
180
|
+
* @custom:error Timing error is thrown if time difference between current time and last updated time
|
|
119
181
|
* is greater than maxStalePeriod
|
|
120
182
|
*/
|
|
121
183
|
function _getChainlinkPrice(
|
|
@@ -140,66 +202,6 @@ contract ChainlinkOracle is OwnableUpgradeable, OracleInterface {
|
|
|
140
202
|
return uint256(answer) * (10 ** decimalDelta);
|
|
141
203
|
}
|
|
142
204
|
|
|
143
|
-
/**
|
|
144
|
-
* @notice Set the forced prices of the underlying token of input vToken
|
|
145
|
-
* @param vToken vToken address
|
|
146
|
-
* @param underlyingPriceMantissa price in 18 decimals
|
|
147
|
-
* @custom:access Only Governance
|
|
148
|
-
* @custom:error NotNullAddress thrown if address of vToken is zero
|
|
149
|
-
* @custom:event Emits PricePosted event on succesfully setup of underlying price
|
|
150
|
-
*/
|
|
151
|
-
function setUnderlyingPrice(
|
|
152
|
-
VBep20Interface vToken,
|
|
153
|
-
uint256 underlyingPriceMantissa
|
|
154
|
-
) external notNullAddress(address(vToken)) onlyOwner {
|
|
155
|
-
address asset = address(vToken) == vBnb ? BNB_ADDR : address(vToken.underlying());
|
|
156
|
-
emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);
|
|
157
|
-
prices[asset] = underlyingPriceMantissa;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @notice Set the forced prices of the input token
|
|
162
|
-
* @param asset asset address
|
|
163
|
-
* @param price price in 18 decimals
|
|
164
|
-
* @custom:access Only GOvernance
|
|
165
|
-
* @custom:event Emits PricePosted event on succesfully setup of underlying price
|
|
166
|
-
*/
|
|
167
|
-
function setDirectPrice(address asset, uint256 price) external notNullAddress(asset) onlyOwner {
|
|
168
|
-
emit PricePosted(asset, prices[asset], price, price);
|
|
169
|
-
prices[asset] = price;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @notice Add multiple token configs at the same time
|
|
174
|
-
* @param tokenConfigs_ config array
|
|
175
|
-
* @custom:access Only Governance
|
|
176
|
-
* @custom:error Zero length error thrown, if length of the array in parameter is 0
|
|
177
|
-
*/
|
|
178
|
-
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external onlyOwner {
|
|
179
|
-
require(tokenConfigs_.length > 0, "length can't be 0");
|
|
180
|
-
uint256 numTokenConfigs = tokenConfigs_.length;
|
|
181
|
-
for (uint256 i; i < numTokenConfigs; ++i) {
|
|
182
|
-
setTokenConfig(tokenConfigs_[i]);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @notice Add single token config, vToken & feed cannot be zero address, and maxStalePeriod must be positive
|
|
188
|
-
* @param tokenConfig token config struct
|
|
189
|
-
* @custom:access Only Governance
|
|
190
|
-
* @custom:error NotNullAddress error thrown if asset address is zero
|
|
191
|
-
* @custom:error NotNullAddress error thrown if token feed address is zero
|
|
192
|
-
* @custom:error Range error if maxStale period of token is not greater than zero
|
|
193
|
-
* @custom:event Emits TokenConfigAdded event on succesfully setting up token config
|
|
194
|
-
*/
|
|
195
|
-
function setTokenConfig(
|
|
196
|
-
TokenConfig memory tokenConfig
|
|
197
|
-
) public onlyOwner notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.feed) {
|
|
198
|
-
require(tokenConfig.maxStalePeriod > 0, "stale period can't be zero");
|
|
199
|
-
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
200
|
-
emit TokenConfigAdded(tokenConfig.asset, tokenConfig.feed, tokenConfig.maxStalePeriod);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
205
|
function _compareStrings(string memory a, string memory b) internal pure returns (bool) {
|
|
204
206
|
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
|
|
205
207
|
}
|
|
@@ -16,7 +16,7 @@ struct TokenConfig {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* PythOracle contract reads prices from actual Pyth oracle contract which accepts
|
|
19
|
+
* PythOracle contract reads prices from actual Pyth oracle contract which accepts, verifies and stores the
|
|
20
20
|
* updated prices from external sources
|
|
21
21
|
*/
|
|
22
22
|
contract PythOracle is OwnableUpgradeable, OracleInterface {
|
|
@@ -28,7 +28,7 @@ contract PythOracle is OwnableUpgradeable, OracleInterface {
|
|
|
28
28
|
// To cast int64/int8 types from Pyth to unsigned types
|
|
29
29
|
using SafeCast for int256;
|
|
30
30
|
|
|
31
|
-
/// @notice
|
|
31
|
+
/// @notice Exponent scale (decimal precision) of prices
|
|
32
32
|
uint256 public constant EXP_SCALE = 1e18;
|
|
33
33
|
|
|
34
34
|
/// @notice vBNB address
|
|
@@ -38,47 +38,36 @@ contract PythOracle is OwnableUpgradeable, OracleInterface {
|
|
|
38
38
|
/// @notice Set this as asset address for BNB. This is the underlying for vBNB
|
|
39
39
|
address public constant BNB_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;
|
|
40
40
|
|
|
41
|
-
/// @notice
|
|
41
|
+
/// @notice The actual pyth oracle address fetch & store the prices
|
|
42
42
|
IPyth public underlyingPythOracle;
|
|
43
43
|
|
|
44
|
-
/// @notice
|
|
44
|
+
/// @notice Token configs by asset address
|
|
45
|
+
mapping(address => TokenConfig) public tokenConfigs;
|
|
46
|
+
|
|
47
|
+
/// @notice Emit when setting a new pyth oracle address
|
|
45
48
|
event PythOracleSet(address indexed newPythOracle);
|
|
46
49
|
|
|
47
|
-
/// @notice
|
|
50
|
+
/// @notice Emit when a token config is added
|
|
48
51
|
event TokenConfigAdded(address indexed vToken, bytes32 indexed pythId, uint64 indexed maxStalePeriod);
|
|
49
52
|
|
|
50
|
-
/// @notice token configs by asset address
|
|
51
|
-
mapping(address => TokenConfig) public tokenConfigs;
|
|
52
|
-
|
|
53
53
|
modifier notNullAddress(address someone) {
|
|
54
54
|
require(someone != address(0), "can't be zero address");
|
|
55
55
|
_;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/// @notice Constructor for the implementation contract. Sets immutable variables.
|
|
59
|
-
/// @param vBnbAddress The address of the
|
|
59
|
+
/// @param vBnbAddress The address of the vBNB
|
|
60
60
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
61
61
|
constructor(address vBnbAddress) notNullAddress(vBnbAddress) {
|
|
62
62
|
vBnb = vBnbAddress;
|
|
63
63
|
_disableInitializers();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* @notice Initializes the owner of the contract and sets required contracts
|
|
68
|
-
* @param underlyingPythOracle_ Address of the pyth oracle
|
|
69
|
-
*/
|
|
70
|
-
function initialize(address underlyingPythOracle_) public initializer {
|
|
71
|
-
__Ownable_init();
|
|
72
|
-
require(underlyingPythOracle_ != address(0), "pyth oracle cannot be zero address");
|
|
73
|
-
underlyingPythOracle = IPyth(underlyingPythOracle_);
|
|
74
|
-
emit PythOracleSet(underlyingPythOracle_);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
66
|
/**
|
|
78
67
|
* @notice Batch set token configs
|
|
79
|
-
* @param tokenConfigs_
|
|
68
|
+
* @param tokenConfigs_ Token config array
|
|
80
69
|
* @custom:access Only Governance
|
|
81
|
-
* @custom:error Zero length error thrown
|
|
70
|
+
* @custom:error Zero length error is thrown if length of the array in parameter is 0
|
|
82
71
|
*/
|
|
83
72
|
function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external onlyOwner {
|
|
84
73
|
require(tokenConfigs_.length != 0, "length can't be 0");
|
|
@@ -89,21 +78,8 @@ contract PythOracle is OwnableUpgradeable, OracleInterface {
|
|
|
89
78
|
}
|
|
90
79
|
|
|
91
80
|
/**
|
|
92
|
-
* @notice Set
|
|
93
|
-
* @param
|
|
94
|
-
* @custom:access Only Governance
|
|
95
|
-
* @custom:error Range error thrown if max stale period is zero
|
|
96
|
-
* @custom:error NotNullAddress error thrown if asset address is zero
|
|
97
|
-
*/
|
|
98
|
-
function setTokenConfig(TokenConfig memory tokenConfig) public onlyOwner notNullAddress(tokenConfig.asset) {
|
|
99
|
-
require(tokenConfig.maxStalePeriod != 0, "max stale period cannot be 0");
|
|
100
|
-
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
101
|
-
emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @notice set the underlying pyth oracle contract address
|
|
106
|
-
* @param underlyingPythOracle_ pyth oracle contract address
|
|
81
|
+
* @notice Set the underlying Pyth oracle contract address
|
|
82
|
+
* @param underlyingPythOracle_ Pyth oracle contract address
|
|
107
83
|
* @custom:access Only Governance
|
|
108
84
|
* @custom:error NotNullAddress error thrown if underlyingPythOracle_ address is zero
|
|
109
85
|
* @custom:event Emits PythOracleSet event with address of Pyth oracle.
|
|
@@ -115,14 +91,38 @@ contract PythOracle is OwnableUpgradeable, OracleInterface {
|
|
|
115
91
|
emit PythOracleSet(address(underlyingPythOracle_));
|
|
116
92
|
}
|
|
117
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @notice Initializes the owner of the contract and sets required contracts
|
|
96
|
+
* @param underlyingPythOracle_ Address of the Pyth oracle
|
|
97
|
+
*/
|
|
98
|
+
function initialize(address underlyingPythOracle_) public initializer {
|
|
99
|
+
__Ownable_init();
|
|
100
|
+
require(underlyingPythOracle_ != address(0), "pyth oracle cannot be zero address");
|
|
101
|
+
underlyingPythOracle = IPyth(underlyingPythOracle_);
|
|
102
|
+
emit PythOracleSet(underlyingPythOracle_);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @notice Set single token config. `maxStalePeriod` cannot be 0 and `vToken` can be a null address
|
|
107
|
+
* @param tokenConfig Token config struct
|
|
108
|
+
* @custom:access Only Governance
|
|
109
|
+
* @custom:error Range error is thrown if max stale period is zero
|
|
110
|
+
* @custom:error NotNullAddress error is thrown if asset address is null
|
|
111
|
+
*/
|
|
112
|
+
function setTokenConfig(TokenConfig memory tokenConfig) public onlyOwner notNullAddress(tokenConfig.asset) {
|
|
113
|
+
require(tokenConfig.maxStalePeriod != 0, "max stale period cannot be 0");
|
|
114
|
+
tokenConfigs[tokenConfig.asset] = tokenConfig;
|
|
115
|
+
emit TokenConfigAdded(tokenConfig.asset, tokenConfig.pythId, tokenConfig.maxStalePeriod);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
118
|
/**
|
|
119
119
|
* @notice Get price of underlying asset of the input vToken, under the hood this function
|
|
120
120
|
* get price from Pyth contract, the prices of which are updated externally
|
|
121
121
|
* @param vToken vToken address
|
|
122
|
-
* @return price
|
|
123
|
-
* @custom:error Zero address error thrown if underlyingPythOracle address is
|
|
124
|
-
* @custom:error Zero address error thrown if asset address is
|
|
125
|
-
* @custom:error Range error thrown if price of
|
|
122
|
+
* @return price Underlying price with a precision of 10 decimals
|
|
123
|
+
* @custom:error Zero address error thrown if underlyingPythOracle address is null
|
|
124
|
+
* @custom:error Zero address error thrown if asset address is null
|
|
125
|
+
* @custom:error Range error thrown if price of Pyth oracle is not greater than zero
|
|
126
126
|
*/
|
|
127
127
|
function getUnderlyingPrice(address vToken) public view override returns (uint256) {
|
|
128
128
|
require(address(underlyingPythOracle) != address(0), "Pyth oracle is zero address");
|
|
@@ -13,19 +13,18 @@ struct Observation {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
struct TokenConfig {
|
|
16
|
-
/// @notice
|
|
16
|
+
/// @notice Asset address, which can't be zero address and can be used for existance check
|
|
17
17
|
address asset;
|
|
18
18
|
/// @notice Decimals of underlying asset
|
|
19
19
|
uint256 baseUnit;
|
|
20
|
-
/// @notice The address of
|
|
20
|
+
/// @notice The address of Pancake pair
|
|
21
21
|
address pancakePool;
|
|
22
22
|
/// @notice Whether the token is paired with WBNB
|
|
23
23
|
bool isBnbBased;
|
|
24
|
-
/// @notice A flag identifies whether the
|
|
24
|
+
/// @notice A flag identifies whether the Pancake pair is reversed
|
|
25
25
|
/// e.g. XVS-WBNB is not reversed, while WBNB-XVS is.
|
|
26
26
|
bool isReversedPool;
|
|
27
|
-
/// @notice
|
|
28
|
-
/// required to update **twap** window
|
|
27
|
+
/// @notice The minimum window in seconds required between TWAP updates
|
|
29
28
|
uint256 anchorPeriod;
|
|
30
29
|
}
|
|
31
30
|
|
|
@@ -52,7 +51,13 @@ contract TwapOracle is OwnableUpgradeable, TwapInterface {
|
|
|
52
51
|
/// @notice Stored price by token
|
|
53
52
|
mapping(address => uint256) public prices;
|
|
54
53
|
|
|
55
|
-
/// @notice
|
|
54
|
+
/// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.
|
|
55
|
+
mapping(address => Observation[]) public observations;
|
|
56
|
+
|
|
57
|
+
/// @notice Observation array index which probably falls in current anchor period mapped by asset address
|
|
58
|
+
mapping(address => uint256) public windowStart;
|
|
59
|
+
|
|
60
|
+
/// @notice Emit this event when TWAP window is updated
|
|
56
61
|
event TwapWindowUpdated(
|
|
57
62
|
address indexed asset,
|
|
58
63
|
uint256 oldTimestamp,
|
|
@@ -61,12 +66,6 @@ contract TwapOracle is OwnableUpgradeable, TwapInterface {
|
|
|
61
66
|
uint256 newAcc
|
|
62
67
|
);
|
|
63
68
|
|
|
64
|
-
/// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.
|
|
65
|
-
mapping(address => Observation[]) public observations;
|
|
66
|
-
|
|
67
|
-
/// @notice index of array which probably falls in current anchor period mapped with asset address
|
|
68
|
-
mapping(address => uint256) public windowStart;
|
|
69
|
-
|
|
70
69
|
/// @notice Emit this event when TWAP price is updated
|
|
71
70
|
event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);
|
|
72
71
|
|
|
@@ -89,16 +88,9 @@ contract TwapOracle is OwnableUpgradeable, TwapInterface {
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
/**
|
|
92
|
-
* @notice
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
__Ownable_init();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @notice Add multiple token configs at the same time
|
|
100
|
-
* @param configs config array
|
|
101
|
-
* @custom:error ZSero length error thrown, if length of the array in parameter is 0
|
|
91
|
+
* @notice Adds multiple token configs at the same time
|
|
92
|
+
* @param configs Config array
|
|
93
|
+
* @custom:error Zero length error thrown, if length of the config array is 0
|
|
102
94
|
*/
|
|
103
95
|
function setTokenConfigs(TokenConfig[] memory configs) external onlyOwner {
|
|
104
96
|
require(configs.length > 0, "length can't be 0");
|
|
@@ -109,16 +101,41 @@ contract TwapOracle is OwnableUpgradeable, TwapInterface {
|
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
/**
|
|
112
|
-
* @notice
|
|
104
|
+
* @notice Get the underlying TWAP price for the given vToken
|
|
105
|
+
* @param vToken vToken address
|
|
106
|
+
* @return price Underlying price in USD
|
|
107
|
+
* @custom:error Missing error is thrown if the token config does not exist
|
|
108
|
+
* @custom:error Range error is thrown if TWAP price is not greater than zero
|
|
109
|
+
*/
|
|
110
|
+
function getUnderlyingPrice(address vToken) external view override returns (uint256) {
|
|
111
|
+
// VBNB token doesn't have `underlying` method, vBNB's underlying token is wBNB
|
|
112
|
+
address asset = address(vToken) == vBnb ? WBNB : VBep20Interface(vToken).underlying();
|
|
113
|
+
require(tokenConfigs[asset].asset != address(0), "asset not exist");
|
|
114
|
+
uint256 price = prices[asset];
|
|
115
|
+
|
|
116
|
+
// if price is 0, it means the price hasn't been updated yet and it's meaningless, revert
|
|
117
|
+
require(price > 0, "TWAP price must be positive");
|
|
118
|
+
return (price * (10 ** (18 - IERC20Metadata(asset).decimals())));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @notice Initializes the owner of the contract and sets the contracts required
|
|
123
|
+
*/
|
|
124
|
+
function initialize() public initializer {
|
|
125
|
+
__Ownable_init();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @notice Adds a single token config
|
|
113
130
|
* @param config token config struct
|
|
114
131
|
* @custom:access Only Governance
|
|
115
|
-
* @custom:error Range error thrown if anchor period is not greater than zero
|
|
116
|
-
* @custom:error Range error thrown if base unit is not greater than zero
|
|
117
|
-
* @custom:error Value error thrown if base unit decimals not same as asset decimals
|
|
118
|
-
* @custom:error NotNullAddress if address of asset is
|
|
119
|
-
* @custom:error NotNullAddress if
|
|
132
|
+
* @custom:error Range error is thrown if anchor period is not greater than zero
|
|
133
|
+
* @custom:error Range error is thrown if base unit is not greater than zero
|
|
134
|
+
* @custom:error Value error is thrown if base unit decimals is not the same as asset decimals
|
|
135
|
+
* @custom:error NotNullAddress error is thrown if address of asset is null
|
|
136
|
+
* @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null
|
|
120
137
|
* @custom:event Emits TokenConfigAdded event if new token config are added with
|
|
121
|
-
* asset address,
|
|
138
|
+
* asset address, PancakePool address, anchor period address
|
|
122
139
|
*/
|
|
123
140
|
function setTokenConfig(
|
|
124
141
|
TokenConfig memory config
|
|
@@ -139,25 +156,24 @@ contract TwapOracle is OwnableUpgradeable, TwapInterface {
|
|
|
139
156
|
}
|
|
140
157
|
|
|
141
158
|
/**
|
|
142
|
-
* @notice
|
|
143
|
-
* @
|
|
144
|
-
* @
|
|
145
|
-
* @custom:error Missing error thrown if token config is not exist
|
|
146
|
-
* @custom:error Range error thrown if **twap** price is not greater than zero
|
|
159
|
+
* @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.
|
|
160
|
+
* @return anchorPrice anchor price of the underlying asset of the vToken
|
|
161
|
+
* @custom:error Missing error is thrown if token config does not exist
|
|
147
162
|
*/
|
|
148
|
-
function
|
|
163
|
+
function updateTwap(address vToken) public returns (uint256) {
|
|
149
164
|
// VBNB token doesn't have `underlying` method, vBNB's underlying token is wBNB
|
|
150
165
|
address asset = address(vToken) == vBnb ? WBNB : VBep20Interface(vToken).underlying();
|
|
151
166
|
require(tokenConfigs[asset].asset != address(0), "asset not exist");
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
// Update & fetch WBNB price first, so we can calculate the price of WBNB paired token
|
|
168
|
+
if (asset != WBNB && tokenConfigs[asset].isBnbBased) {
|
|
169
|
+
require(tokenConfigs[WBNB].asset != address(0), "WBNB not exist");
|
|
170
|
+
_updateTwapInternal(tokenConfigs[WBNB]);
|
|
171
|
+
}
|
|
172
|
+
return _updateTwapInternal(tokenConfigs[asset]);
|
|
157
173
|
}
|
|
158
174
|
|
|
159
175
|
/**
|
|
160
|
-
* @notice Fetches the current token/WBNB and token/BUSD price accumulator from
|
|
176
|
+
* @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.
|
|
161
177
|
* @return cumulative price of target token regardless of pair order
|
|
162
178
|
*/
|
|
163
179
|
function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {
|
|
@@ -169,30 +185,13 @@ contract TwapOracle is OwnableUpgradeable, TwapInterface {
|
|
|
169
185
|
}
|
|
170
186
|
}
|
|
171
187
|
|
|
172
|
-
/**
|
|
173
|
-
* @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.
|
|
174
|
-
* @return vToken Address of vToken
|
|
175
|
-
* @custom:error Missing error thrown if token config is not exist
|
|
176
|
-
*/
|
|
177
|
-
function updateTwap(address vToken) public returns (uint256) {
|
|
178
|
-
// VBNB token doesn't have `underlying` method, vBNB's underlying token is wBNB
|
|
179
|
-
address asset = address(vToken) == vBnb ? WBNB : VBep20Interface(vToken).underlying();
|
|
180
|
-
require(tokenConfigs[asset].asset != address(0), "asset not exist");
|
|
181
|
-
// Update & fetch WBNB price first, so we can calculate the price of WBNB paired token
|
|
182
|
-
if (asset != WBNB && tokenConfigs[asset].isBnbBased) {
|
|
183
|
-
require(tokenConfigs[WBNB].asset != address(0), "WBNB not exist");
|
|
184
|
-
_updateTwapInternal(tokenConfigs[WBNB]);
|
|
185
|
-
}
|
|
186
|
-
return _updateTwapInternal(tokenConfigs[asset]);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
188
|
/**
|
|
190
189
|
* @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.
|
|
191
|
-
* @return price in USD, with 18 decimals
|
|
192
|
-
* @custom:error Timing error thrown if current time is not greater than old observation timestamp
|
|
193
|
-
* @custom:error Zero price error thrown if token is BNB based and price is zero
|
|
194
|
-
* @custom:error Zero price error thrown if fetched anchorPriceMantissa is zero
|
|
195
|
-
* @custom:event Emits AnchorPriceUpdated event on
|
|
190
|
+
* @return price Underlying price in USD, with 18 decimals
|
|
191
|
+
* @custom:error Timing error is thrown if current time is not greater than old observation timestamp
|
|
192
|
+
* @custom:error Zero price error is thrown if token is BNB based and price is zero
|
|
193
|
+
* @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero
|
|
194
|
+
* @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,
|
|
196
195
|
* AnchorPrice, old observation timestamp and current timestamp
|
|
197
196
|
*/
|
|
198
197
|
function _updateTwapInternal(TokenConfig memory config) internal virtual returns (uint256) {
|
|
@@ -234,11 +233,12 @@ contract TwapOracle is OwnableUpgradeable, TwapInterface {
|
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
/**
|
|
237
|
-
* @notice
|
|
238
|
-
*
|
|
236
|
+
* @notice Appends current observation and pick an observation with a timestamp equal
|
|
237
|
+
* or just greater than the window start timestamp. If one is not available,
|
|
238
|
+
* then pick the last availableobservation. The window start index is updated in both the cases.
|
|
239
239
|
* Only the current observation is saved, prior observations are deleted during this operation.
|
|
240
|
-
* @return cumulative price
|
|
241
|
-
* @custom:event
|
|
240
|
+
* @return Tuple of cumulative price, old observation and timestamp
|
|
241
|
+
* @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,
|
|
242
242
|
* new observation timestamp, current timestamp, new observation price and cumulative price
|
|
243
243
|
*/
|
|
244
244
|
function pokeWindowValues(
|
|
@@ -12,15 +12,15 @@ contract MockBinanceOracle is OwnableUpgradeable {
|
|
|
12
12
|
|
|
13
13
|
constructor() {}
|
|
14
14
|
|
|
15
|
+
function setPrice(address asset, uint256 price) external {
|
|
16
|
+
assetPrices[asset] = price;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
function initialize(FeedRegistryInterface feed) public initializer {
|
|
16
20
|
__Ownable_init();
|
|
17
21
|
feedRegistry = feed;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
function setPrice(address asset, uint256 price) external {
|
|
21
|
-
assetPrices[asset] = price;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
24
|
function getUnderlyingPrice(address vToken) public view returns (uint256) {
|
|
25
25
|
return assetPrices[vToken];
|
|
26
26
|
}
|
|
@@ -11,14 +11,14 @@ contract MockChainlinkOracle is OwnableUpgradeable {
|
|
|
11
11
|
//set price in 6 decimal precision
|
|
12
12
|
constructor() {}
|
|
13
13
|
|
|
14
|
-
function initialize() public initializer {
|
|
15
|
-
__Ownable_init();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
function setPrice(address asset, uint256 price) external {
|
|
19
15
|
assetPrices[asset] = price;
|
|
20
16
|
}
|
|
21
17
|
|
|
18
|
+
function initialize() public initializer {
|
|
19
|
+
__Ownable_init();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
22
|
//https://compound.finance/docs/prices
|
|
23
23
|
function getUnderlyingPrice(address vToken) public view returns (uint256) {
|
|
24
24
|
address token = VBep20Interface(vToken).underlying();
|
|
@@ -14,16 +14,16 @@ contract MockPythOracle is OwnableUpgradeable {
|
|
|
14
14
|
//set price in 6 decimal precision
|
|
15
15
|
constructor() {}
|
|
16
16
|
|
|
17
|
+
function setPrice(address asset, uint256 price) external {
|
|
18
|
+
assetPrices[asset] = price;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
function initialize(address underlyingPythOracle_) public initializer {
|
|
18
22
|
__Ownable_init();
|
|
19
23
|
require(underlyingPythOracle_ != address(0), "pyth oracle cannot be zero address");
|
|
20
24
|
underlyingPythOracle = IPyth(underlyingPythOracle_);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
function setPrice(address asset, uint256 price) external {
|
|
24
|
-
assetPrices[asset] = price;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
27
|
//https://compound.finance/docs/prices
|
|
28
28
|
function getUnderlyingPrice(address vToken) public view returns (uint256) {
|
|
29
29
|
address token = VBep20Interface(vToken).underlying();
|