@pendle/core-v2 4.5.1-beta-1 → 4.5.1-oracle-beta
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/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.json +1049 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.json +1039 -0
- package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.json +0 -431
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.json +0 -431
- package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.json +60 -0
- package/build/artifacts/contracts/interfaces/IPPYLpOracle.sol/IPPYLpOracle.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/{IPPtLpOracle.sol/IPPtLpOracle.json → IPPYLpOracle.sol/IPPYLpOracle.json} +50 -2
- package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.json +25 -0
- package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.json +207 -0
- package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.json +401 -0
- package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.json +2 -2
- package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.json +2 -2
- package/build/artifacts/contracts/oracles/PendlePYLpOracle.sol/PendlePYLpOracle.dbg.json +4 -0
- package/build/artifacts/contracts/oracles/PendlePYLpOracle.sol/PendlePYLpOracle.json +422 -0
- package/build/artifacts/contracts/oracles/PendlePYOracleLib.sol/PendlePYOracleLib.dbg.json +4 -0
- package/build/artifacts/contracts/oracles/{PendlePtOracleLib.sol/PendlePtOracleLib.json → PendlePYOracleLib.sol/PendlePYOracleLib.json} +4 -4
- package/build/artifacts/contracts/oracles/samples/BoringLpGlpOracle.sol/BoringLpGlpOracle.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/samples/BoringLpGlpOracle.sol/BoringLpGlpOracle.json +2 -2
- package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkAssetOracle.sol/BoringPYUsdChainlinkAssetOracle.dbg.json +4 -0
- package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkAssetOracle.sol/BoringPYUsdChainlinkAssetOracle.json +183 -0
- package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkSYOracle.sol/BoringPYUsdChainlinkSYOracle.dbg.json +4 -0
- package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkSYOracle.sol/BoringPYUsdChainlinkSYOracle.json +183 -0
- package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.json +2 -2
- package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.json +2 -591
- package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.json +2 -2
- package/build/artifacts/contracts/router/base/ActionBase.sol/ActionBase.dbg.json +1 -1
- package/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol +6 -1
- package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol +56 -0
- package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol +111 -0
- package/contracts/interfaces/IPActionMiscV3.sol +0 -38
- package/contracts/interfaces/IPGovernanceProxy.sol +14 -0
- package/contracts/interfaces/{IPPtLpOracle.sol → IPPYLpOracle.sol} +5 -1
- package/contracts/interfaces/IPPausingInterface.sol +8 -0
- package/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol +66 -0
- package/contracts/offchain-helpers/PendleGovernanceProxy.sol +84 -0
- package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +12 -4
- package/contracts/oracles/PendleLpOracleLib.sol +4 -4
- package/contracts/oracles/{PendlePtLpOracle.sol → PendlePYLpOracle.sol} +44 -16
- package/contracts/oracles/{PendlePtOracleLib.sol → PendlePYOracleLib.sol} +31 -1
- package/contracts/oracles/samples/BoringLpGlpOracle.sol +2 -2
- package/contracts/oracles/samples/{BoringPtUsdChainlinkOracle.sol → BoringPYUsdChainlinkAssetOracle.sol} +36 -12
- package/contracts/oracles/samples/BoringPYUsdChainlinkSYOracle.sol +102 -0
- package/contracts/router/ActionMiscV3.sol +36 -216
- package/contracts/router/ActionSwapYTV3.sol +85 -0
- package/contracts/router/base/ActionBase.sol +1 -106
- package/deployments/1-markets/EZETH-MAINNET-SEP2024.json +11 -0
- package/deployments/1-markets/PUFETH-MAINNET-SEP2024.json +11 -0
- package/deployments/1-markets/RSETH-MAINNET-SEP2024.json +11 -0
- package/deployments/1-markets/RSWETH-SWELL-STAKING-MAINNET-JUL2024.json +11 -0
- package/deployments/1-markets/SUSDE-MAINNET-SEP2024.json +13 -0
- package/deployments/1-markets/WEETH-MAINNET-SEP2024.json +11 -0
- package/deployments/42161-markets/EZETH-ARB-SEP2024.json +11 -0
- package/deployments/42161-markets/RSETH-ARBITRUM-SEP2024.json +11 -0
- package/deployments/42161-markets/SILO-PTEETH-ARBITRUM-JUNE2024.json +11 -0
- package/deployments/42161-markets/SILO-PTEZETH-ARBITRUM-JUNE2024.json +11 -0
- package/deployments/42161-markets/WEETH-ARB-SEP2024.json +11 -0
- package/deployments/56-markets/WEETH-BSC-SEP2024.json +11 -0
- package/package.json +1 -1
- package/typechain-types/ActionMiscV3.ts +16 -379
- package/typechain-types/BoringPYUsdChainlinkAssetOracle.ts +244 -0
- package/typechain-types/BoringPYUsdChainlinkSYOracle.ts +243 -0
- package/typechain-types/IPActionMiscV3.ts +16 -249
- package/typechain-types/IPAllActionV3.ts +0 -156
- package/typechain-types/IPGovernanceProxy.ts +142 -0
- package/typechain-types/IPPYLpOracle.ts +379 -0
- package/typechain-types/IPPausingInterface.ts +112 -0
- package/typechain-types/PendleGovernanceProxy.ts +603 -0
- package/typechain-types/PendlePYLpOracle.ts +612 -0
- package/typechain-types/factories/ActionAddRemoveLiqV3__factory.ts +1 -1
- package/typechain-types/factories/ActionMarketAuxStatic__factory.ts +1 -1
- package/typechain-types/factories/ActionMiscV3__factory.ts +1 -590
- package/typechain-types/factories/ActionSwapPTV3__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapYTV3__factory.ts +1 -1
- package/typechain-types/factories/BoringLpGlpOracle__factory.ts +1 -1
- package/typechain-types/factories/BoringPYUsdChainlinkAssetOracle__factory.ts +269 -0
- package/typechain-types/factories/BoringPYUsdChainlinkSYOracle__factory.ts +267 -0
- package/typechain-types/factories/IPActionMiscV3__factory.ts +0 -431
- package/typechain-types/factories/IPAllActionV3__factory.ts +0 -431
- package/typechain-types/factories/IPGovernanceProxy__factory.ts +75 -0
- package/typechain-types/factories/IPPYLpOracle__factory.ts +214 -0
- package/typechain-types/factories/IPPausingInterface__factory.ts +40 -0
- package/typechain-types/factories/PendleERC20WithSupplyCapSY__factory.ts +1 -1
- package/typechain-types/factories/PendleGovernanceProxy__factory.ts +458 -0
- package/typechain-types/factories/PendlePYLpOracle__factory.ts +487 -0
- package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleSwellRswETHStakingSY__factory.ts +1 -1
- package/typechain-types/hardhat.d.ts +63 -0
- package/typechain-types/index.ts +14 -0
- package/build/artifacts/contracts/interfaces/IPPtLpOracle.sol/IPPtLpOracle.dbg.json +0 -4
- package/build/artifacts/contracts/oracles/PendlePtLpOracle.sol/PendlePtLpOracle.dbg.json +0 -4
- package/build/artifacts/contracts/oracles/PendlePtLpOracle.sol/PendlePtLpOracle.json +0 -367
- package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +0 -4
- package/build/artifacts/contracts/oracles/samples/BoringPtUsdChainlinkOracle.sol/BoringPtUsdChainlinkOracle.dbg.json +0 -4
- package/build/artifacts/contracts/oracles/samples/BoringPtUsdChainlinkOracle.sol/BoringPtUsdChainlinkOracle.json +0 -157
- /package/deployments/1-markets/{EZETH-JUNE2024.json → EZETH-APR2024.json} +0 -0
- /package/deployments/42161-markets/{RSETH-MAY2024.json → RSETH-JUNE2024.json} +0 -0
- /package/deployments/42161-markets/{WEETH-MAY2024.json → WEETH-JUNE2024.json} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
interface IPGovernanceProxy {
|
|
5
|
+
struct Call {
|
|
6
|
+
address target;
|
|
7
|
+
uint256 value;
|
|
8
|
+
bytes callData;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function pause(address[] calldata addrs) external;
|
|
12
|
+
|
|
13
|
+
function aggregate(Call[] calldata calls) external payable returns (bytes[] memory rtnData);
|
|
14
|
+
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
interface IPPYLpOracle {
|
|
5
5
|
event SetBlockCycleNumerator(uint16 newBlockCycleNumerator);
|
|
6
6
|
|
|
7
7
|
function getPtToAssetRate(address market, uint32 duration) external view returns (uint256);
|
|
8
8
|
|
|
9
|
+
function getYtToAssetRate(address market, uint32 duration) external view returns (uint256);
|
|
10
|
+
|
|
9
11
|
function getLpToAssetRate(address market, uint32 duration) external view returns (uint256);
|
|
10
12
|
|
|
11
13
|
function getPtToSyRate(address market, uint32 duration) external view returns (uint256);
|
|
12
14
|
|
|
15
|
+
function getYtToSyRate(address market, uint32 duration) external view returns (uint256);
|
|
16
|
+
|
|
13
17
|
function getLpToSyRate(address market, uint32 duration) external view returns (uint256);
|
|
14
18
|
|
|
15
19
|
function getOracleState(
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
interface ISwellSimpleStakingERC20 {
|
|
5
|
+
/// @notice Struct to hold the supported booleans
|
|
6
|
+
/// @param deposit true if deposit is supported
|
|
7
|
+
/// @param withdraw true if withdraw is supported
|
|
8
|
+
struct Supported {
|
|
9
|
+
bool deposit;
|
|
10
|
+
bool withdraw;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/// @notice Error emitted when the amount is null
|
|
14
|
+
error AMOUNT_NULL();
|
|
15
|
+
|
|
16
|
+
/// @notice Error emitted when the address is null
|
|
17
|
+
error ADDRESS_NULL();
|
|
18
|
+
|
|
19
|
+
/// @notice Error emitted when the balance is insufficient
|
|
20
|
+
error INSUFFICIENT_BALANCE();
|
|
21
|
+
|
|
22
|
+
/// @notice Error emitted when the token is not allowed
|
|
23
|
+
error TOKEN_NOT_ALLOWED(address token);
|
|
24
|
+
|
|
25
|
+
/// @notice Event emitted when a token is added or removed
|
|
26
|
+
/// @param token address of the token
|
|
27
|
+
/// @param supported struct with deposit and withdraw booleans
|
|
28
|
+
event SupportedToken(address indexed token, Supported supported);
|
|
29
|
+
|
|
30
|
+
/// @notice Event emitted when a deposit is made
|
|
31
|
+
/// @param token address of the token
|
|
32
|
+
/// @param staker address of the staker
|
|
33
|
+
/// @param amount amount of the deposit
|
|
34
|
+
event Deposit(address indexed token, address indexed staker, uint256 amount);
|
|
35
|
+
|
|
36
|
+
/// @notice Event emitted when a withdrawal is made
|
|
37
|
+
/// @param token address of the token
|
|
38
|
+
/// @param staker address of the staker
|
|
39
|
+
/// @param amount amount of the withdrawal
|
|
40
|
+
event Withdraw(address indexed token, address indexed staker, uint256 amount);
|
|
41
|
+
|
|
42
|
+
/// @notice Method to deposit tokens
|
|
43
|
+
/// @dev token are transferred from the sender, and the receiver is credited
|
|
44
|
+
/// @param _token address of the token
|
|
45
|
+
/// @param _amount amount to deposit
|
|
46
|
+
/// @param _receiver address of the receiver
|
|
47
|
+
function deposit(address _token, uint256 _amount, address _receiver) external;
|
|
48
|
+
|
|
49
|
+
/// @notice Method to rescue tokens, only callable by the owner
|
|
50
|
+
/// @dev difference between balance and internal balance is transferred to the owner
|
|
51
|
+
/// @param _token address of the token
|
|
52
|
+
function rescueERC20(address _token) external;
|
|
53
|
+
|
|
54
|
+
/// @notice Method to add or remove a token
|
|
55
|
+
/// @dev only callable by the owner
|
|
56
|
+
/// @param _token address of the token
|
|
57
|
+
/// @param _supported struct with deposit and withdraw booleans
|
|
58
|
+
function supportToken(address _token, Supported calldata _supported) external;
|
|
59
|
+
|
|
60
|
+
/// @notice Method to rescue tokens, only callable by the owner
|
|
61
|
+
/// @dev token are transferred to the receiver and sender is credited
|
|
62
|
+
/// @param _token address of the token
|
|
63
|
+
/// @param _amount amount to withdraw
|
|
64
|
+
/// @param _receiver address of the receiver
|
|
65
|
+
function withdraw(address _token, uint256 _amount, address _receiver) external;
|
|
66
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
import "../interfaces/IPPausingInterface.sol";
|
|
5
|
+
import "../interfaces/IPGovernanceProxy.sol";
|
|
6
|
+
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
|
|
7
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
8
|
+
|
|
9
|
+
// solhint-disable custom-errors
|
|
10
|
+
// solhint-disable no-inline-assembly
|
|
11
|
+
// solhint-disable no-empty-blocks
|
|
12
|
+
|
|
13
|
+
contract PendleGovernanceProxy is AccessControlUpgradeable, UUPSUpgradeable, IPGovernanceProxy {
|
|
14
|
+
bytes32 public constant GUARDIAN = keccak256("GUARDIAN");
|
|
15
|
+
|
|
16
|
+
modifier onlyGuardian() {
|
|
17
|
+
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(GUARDIAN, msg.sender), "not authorized");
|
|
18
|
+
_;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
modifier onlyAdmin() {
|
|
22
|
+
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "not authorized");
|
|
23
|
+
_;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
_disableInitializers();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*///////////////////////////////////////////////////////////////
|
|
31
|
+
PAUSING
|
|
32
|
+
//////////////////////////////////////////////////////////////*/
|
|
33
|
+
|
|
34
|
+
function pause(address[] calldata addrs) external onlyGuardian {
|
|
35
|
+
uint256 length = addrs.length;
|
|
36
|
+
for (uint256 i = 0; i < length; ) {
|
|
37
|
+
IPPausingInterface(addrs[i]).pause();
|
|
38
|
+
unchecked {
|
|
39
|
+
++i;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*///////////////////////////////////////////////////////////////
|
|
45
|
+
ADMIN CALL
|
|
46
|
+
//////////////////////////////////////////////////////////////*/
|
|
47
|
+
|
|
48
|
+
function aggregate(
|
|
49
|
+
IPGovernanceProxy.Call[] calldata calls
|
|
50
|
+
) external payable onlyAdmin returns (bytes[] memory rtnData) {
|
|
51
|
+
uint256 length = calls.length;
|
|
52
|
+
rtnData = new bytes[](length);
|
|
53
|
+
|
|
54
|
+
Call calldata call;
|
|
55
|
+
for (uint256 i = 0; i < length; ) {
|
|
56
|
+
call = calls[i];
|
|
57
|
+
|
|
58
|
+
(bool success, bytes memory resp) = call.target.call{value: call.value}(call.callData);
|
|
59
|
+
if (!success) {
|
|
60
|
+
assembly {
|
|
61
|
+
revert(add(32, resp), mload(resp))
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
rtnData[i] = resp;
|
|
66
|
+
|
|
67
|
+
unchecked {
|
|
68
|
+
++i;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
receive() external payable {}
|
|
74
|
+
|
|
75
|
+
/*///////////////////////////////////////////////////////////////
|
|
76
|
+
UPGRADABLE RELATED
|
|
77
|
+
//////////////////////////////////////////////////////////////*/
|
|
78
|
+
|
|
79
|
+
function initialize(address governance) external initializer {
|
|
80
|
+
_grantRole(DEFAULT_ADMIN_ROLE, governance);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _authorizeUpgrade(address) internal view override onlyAdmin {}
|
|
84
|
+
}
|
|
@@ -114,12 +114,20 @@ contract ActionMarketAuxStatic is IPActionMarketAuxStatic {
|
|
|
114
114
|
function getLpToAssetRate(address market) public view returns (uint256) {
|
|
115
115
|
MarketState memory state = _readState(market);
|
|
116
116
|
PYIndex pyIndexCurrent = _pyIndex(market);
|
|
117
|
-
MarketPreCompute memory comp = state.getMarketPreCompute(pyIndexCurrent, block.timestamp);
|
|
118
117
|
|
|
119
|
-
int256 totalHypotheticalAsset
|
|
120
|
-
|
|
118
|
+
int256 totalHypotheticalAsset;
|
|
119
|
+
if (state.expiry <= block.timestamp) {
|
|
120
|
+
// 1 PT = 1 Asset post-expiry
|
|
121
|
+
totalHypotheticalAsset = state.totalPt + pyIndexCurrent.syToAsset(state.totalSy);
|
|
122
|
+
} else {
|
|
123
|
+
MarketPreCompute memory comp = state.getMarketPreCompute(pyIndexCurrent, block.timestamp);
|
|
124
|
+
|
|
125
|
+
totalHypotheticalAsset =
|
|
126
|
+
comp.totalAsset +
|
|
127
|
+
state.totalPt.mulDown(int256(_getPtToAssetRate(market, state, pyIndexCurrent)));
|
|
128
|
+
}
|
|
121
129
|
|
|
122
|
-
return
|
|
130
|
+
return totalHypotheticalAsset.divDown(state.totalLp).Uint();
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
function getPtToAssetRate(address market) public view returns (uint256) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
import "./
|
|
4
|
+
import "./PendlePYOracleLib.sol";
|
|
5
5
|
|
|
6
6
|
library PendleLpOracleLib {
|
|
7
|
-
using
|
|
7
|
+
using PendlePYOracleLib for IPMarket;
|
|
8
8
|
using PMath for uint256;
|
|
9
9
|
using PMath for int256;
|
|
10
10
|
using MarketMathCore for MarketState;
|
|
@@ -16,7 +16,7 @@ library PendleLpOracleLib {
|
|
|
16
16
|
* @param duration twap duration
|
|
17
17
|
*/
|
|
18
18
|
function getLpToAssetRate(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
19
|
-
(uint256 syIndex, uint256 pyIndex) =
|
|
19
|
+
(uint256 syIndex, uint256 pyIndex) = PendlePYOracleLib.getSYandPYIndexCurrent(market);
|
|
20
20
|
uint256 lpToAssetRateRaw = _getLpToAssetRateRaw(market, duration, pyIndex);
|
|
21
21
|
if (syIndex >= pyIndex) {
|
|
22
22
|
return lpToAssetRateRaw;
|
|
@@ -32,7 +32,7 @@ library PendleLpOracleLib {
|
|
|
32
32
|
* @param duration twap duration
|
|
33
33
|
*/
|
|
34
34
|
function getLpToSyRate(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
35
|
-
(uint256 syIndex, uint256 pyIndex) =
|
|
35
|
+
(uint256 syIndex, uint256 pyIndex) = PendlePYOracleLib.getSYandPYIndexCurrent(market);
|
|
36
36
|
uint256 lpToAssetRateRaw = _getLpToAssetRateRaw(market, duration, pyIndex);
|
|
37
37
|
if (syIndex >= pyIndex) {
|
|
38
38
|
return lpToAssetRateRaw.divDown(syIndex);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
|
-
import "./
|
|
4
|
+
import "./PendlePYOracleLib.sol";
|
|
5
5
|
import "./PendleLpOracleLib.sol";
|
|
6
|
-
import "../interfaces/
|
|
6
|
+
import "../interfaces/IPPYLpOracle.sol";
|
|
7
7
|
import "../core/libraries/BoringOwnableUpgradeable.sol";
|
|
8
8
|
|
|
9
9
|
// This is a pre-deployed version of PendlePtOracleLib & PendleLpOracleLib with additional utility functions.
|
|
10
10
|
// Use of this contract rather than direct library integration resulting in a smaller bytecode size and simpler structure
|
|
11
11
|
// but slightly higher gas usage (~ 4000 gas, 2 external calls & 1 cold code load)
|
|
12
|
-
contract
|
|
13
|
-
using
|
|
12
|
+
contract PendlePYLpOracle is BoringOwnableUpgradeable, IPPYLpOracle {
|
|
13
|
+
using PendlePYOracleLib for IPMarket;
|
|
14
14
|
using PendleLpOracleLib for IPMarket;
|
|
15
15
|
|
|
16
16
|
error InvalidBlockRate(uint256 blockCycleNumerator);
|
|
@@ -26,38 +26,52 @@ contract PendlePtLpOracle is BoringOwnableUpgradeable, IPPtLpOracle {
|
|
|
26
26
|
uint16 public blockCycleNumerator;
|
|
27
27
|
uint16 public constant BLOCK_CYCLE_DENOMINATOR = 1000;
|
|
28
28
|
|
|
29
|
-
constructor(uint16 _blockCycleNumerator)
|
|
30
|
-
|
|
31
|
-
setBlockCycleNumerator(_blockCycleNumerator);
|
|
29
|
+
constructor(uint16 _blockCycleNumerator) {
|
|
30
|
+
_setBlockCycleNumerator(_blockCycleNumerator);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
revert InvalidBlockRate(newBlockCycleNumerator);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
blockCycleNumerator = newBlockCycleNumerator;
|
|
40
|
-
emit SetBlockCycleNumerator(newBlockCycleNumerator);
|
|
33
|
+
function initialize() external initializer {
|
|
34
|
+
__BoringOwnable_init();
|
|
41
35
|
}
|
|
42
36
|
|
|
37
|
+
/*///////////////////////////////////////////////////////////////
|
|
38
|
+
PT, YT, LP to Asset (see EIP-5115)
|
|
39
|
+
//////////////////////////////////////////////////////////////*/
|
|
40
|
+
|
|
41
|
+
/// @notice make sure you have taken into account the risk of not being able to withdraw from SY to Asset
|
|
42
|
+
/// More info in StandardizedYield
|
|
43
43
|
function getPtToAssetRate(address market, uint32 duration) external view returns (uint256) {
|
|
44
44
|
return IPMarket(market).getPtToAssetRate(duration);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
function getYtToAssetRate(address market, uint32 duration) external view returns (uint256) {
|
|
48
|
+
return IPMarket(market).getYtToAssetRate(duration);
|
|
49
|
+
}
|
|
50
|
+
|
|
49
51
|
function getLpToAssetRate(address market, uint32 duration) external view returns (uint256) {
|
|
50
52
|
return IPMarket(market).getLpToAssetRate(duration);
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
/*///////////////////////////////////////////////////////////////
|
|
56
|
+
PT, YT, LP to SY (repricing token)
|
|
57
|
+
//////////////////////////////////////////////////////////////*/
|
|
58
|
+
|
|
53
59
|
function getPtToSyRate(address market, uint32 duration) external view returns (uint256) {
|
|
54
60
|
return IPMarket(market).getPtToSyRate(duration);
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
function getYtToSyRate(address market, uint32 duration) external view returns (uint256) {
|
|
64
|
+
return IPMarket(market).getYtToSyRate(duration);
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
function getLpToSyRate(address market, uint32 duration) external view returns (uint256) {
|
|
58
68
|
return IPMarket(market).getLpToSyRate(duration);
|
|
59
69
|
}
|
|
60
70
|
|
|
71
|
+
/*///////////////////////////////////////////////////////////////
|
|
72
|
+
Utility functions
|
|
73
|
+
//////////////////////////////////////////////////////////////*/
|
|
74
|
+
|
|
61
75
|
/**
|
|
62
76
|
* A check function for the cardinality status of the market
|
|
63
77
|
* @param market PendleMarket address
|
|
@@ -99,4 +113,18 @@ contract PendlePtLpOracle is BoringOwnableUpgradeable, IPPtLpOracle {
|
|
|
99
113
|
}
|
|
100
114
|
return uint16(cardinalityRequired);
|
|
101
115
|
}
|
|
116
|
+
|
|
117
|
+
// --- Owner-Only Functions ---
|
|
118
|
+
function setBlockCycleNumerator(uint16 newBlockCycleNumerator) external onlyOwner {
|
|
119
|
+
_setBlockCycleNumerator(newBlockCycleNumerator);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function _setBlockCycleNumerator(uint16 newBlockCycleNumerator) internal {
|
|
123
|
+
if (newBlockCycleNumerator < BLOCK_CYCLE_DENOMINATOR) {
|
|
124
|
+
revert InvalidBlockRate(newBlockCycleNumerator);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
blockCycleNumerator = newBlockCycleNumerator;
|
|
128
|
+
emit SetBlockCycleNumerator(newBlockCycleNumerator);
|
|
129
|
+
}
|
|
102
130
|
}
|
|
@@ -6,7 +6,7 @@ import "../core/libraries/math/PMath.sol";
|
|
|
6
6
|
|
|
7
7
|
// This library can & should be integrated directly for optimal gas usage.
|
|
8
8
|
// If you prefer not to integrate it directly, the PendlePtOracle contract (a pre-deployed version of this contract) can be used.
|
|
9
|
-
library
|
|
9
|
+
library PendlePYOracleLib {
|
|
10
10
|
using PMath for uint256;
|
|
11
11
|
using PMath for int256;
|
|
12
12
|
|
|
@@ -25,6 +25,21 @@ library PendlePtOracleLib {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* This function returns the twap rate YT/Asset on market, but take into account the current rate of SY
|
|
30
|
+
This is to account for special cases where underlying asset becomes insolvent and has decreasing exchangeRate
|
|
31
|
+
* @param market market to get rate from
|
|
32
|
+
* @param duration twap duration
|
|
33
|
+
*/
|
|
34
|
+
function getYtToAssetRate(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
35
|
+
(uint256 syIndex, uint256 pyIndex) = getSYandPYIndexCurrent(market);
|
|
36
|
+
if (syIndex >= pyIndex) {
|
|
37
|
+
return getYtToAssetRateRaw(market, duration);
|
|
38
|
+
} else {
|
|
39
|
+
return (getYtToAssetRateRaw(market, duration) * syIndex) / pyIndex;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
28
43
|
/// @notice Similar to getPtToAsset but returns the rate in SY instead
|
|
29
44
|
function getPtToSyRate(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
30
45
|
(uint256 syIndex, uint256 pyIndex) = getSYandPYIndexCurrent(market);
|
|
@@ -35,6 +50,16 @@ library PendlePtOracleLib {
|
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
52
|
|
|
53
|
+
/// @notice Similar to getPtToAsset but returns the rate in SY instead
|
|
54
|
+
function getYtToSyRate(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
55
|
+
(uint256 syIndex, uint256 pyIndex) = getSYandPYIndexCurrent(market);
|
|
56
|
+
if (syIndex >= pyIndex) {
|
|
57
|
+
return getYtToAssetRateRaw(market, duration).divDown(syIndex);
|
|
58
|
+
} else {
|
|
59
|
+
return getYtToAssetRateRaw(market, duration).divDown(pyIndex);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
38
63
|
/// @notice returns the raw rate without taking into account whether SY is solvent
|
|
39
64
|
function getPtToAssetRateRaw(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
40
65
|
uint256 expiry = market.expiry();
|
|
@@ -49,6 +74,11 @@ library PendlePtOracleLib {
|
|
|
49
74
|
}
|
|
50
75
|
}
|
|
51
76
|
|
|
77
|
+
/// @notice returns the raw rate without taking into account whether SY is solvent
|
|
78
|
+
function getYtToAssetRateRaw(IPMarket market, uint32 duration) internal view returns (uint256) {
|
|
79
|
+
return PMath.ONE - getPtToAssetRateRaw(market, duration);
|
|
80
|
+
}
|
|
81
|
+
|
|
52
82
|
function getSYandPYIndexCurrent(IPMarket market) internal view returns (uint256 syIndex, uint256 pyIndex) {
|
|
53
83
|
(IStandardizedYield SY, , IPYieldToken YT) = market.readTokens();
|
|
54
84
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "../PendleLpOracleLib.sol";
|
|
5
|
-
import "../../interfaces/
|
|
5
|
+
import "../../interfaces/IPPYLpOracle.sol";
|
|
6
6
|
import "../../interfaces/GMX/IGlpManager.sol";
|
|
7
7
|
import "../../core/libraries/math/PMath.sol";
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ contract BoringLpGlpOracle {
|
|
|
23
23
|
market = _market;
|
|
24
24
|
glpManager = _glpManager;
|
|
25
25
|
|
|
26
|
-
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) =
|
|
26
|
+
(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPYLpOracle(_ptOracle).getOracleState(
|
|
27
27
|
market,
|
|
28
28
|
twapDuration
|
|
29
29
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
|
-
import "../../interfaces/
|
|
4
|
+
import "../../interfaces/IPPYLpOracle.sol";
|
|
5
5
|
import "../../interfaces/IPMarket.sol";
|
|
6
6
|
import "../../core/libraries/math/PMath.sol";
|
|
7
7
|
import "../PendleLpOracleLib.sol";
|
|
@@ -9,29 +9,41 @@ import "../PendleLpOracleLib.sol";
|
|
|
9
9
|
import {AggregatorV2V3Interface as IChainlinkAggregator} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @notice The returned price from this contract is multiplied by the default USD price of the
|
|
13
|
-
*
|
|
12
|
+
* @notice The returned price from this contract is multiplied by the default USD price of the
|
|
13
|
+
* underlying asset, as read from a Chainlink-interface oracle.
|
|
14
|
+
*
|
|
15
|
+
* Example of this usage:
|
|
16
|
+
* - PT-wstETH = ptToAssetRate * stETH price
|
|
17
|
+
* - PT-silo-crvUSD = ptToAssetRate * crvUSD price
|
|
18
|
+
*
|
|
19
|
+
* For more details into how the oracle is implemented, refer to PendlePYLpOracle & PendlePYOracleLib.
|
|
14
20
|
*/
|
|
15
|
-
contract
|
|
16
|
-
using
|
|
21
|
+
contract BoringPYUsdChainlinkAssetOracle {
|
|
22
|
+
using PendlePYOracleLib for IPMarket;
|
|
17
23
|
|
|
18
24
|
uint32 public immutable twapDuration;
|
|
19
25
|
address public immutable market;
|
|
20
26
|
address public immutable feed;
|
|
21
27
|
uint8 public immutable feedDecimals;
|
|
22
|
-
address public immutable
|
|
28
|
+
address public immutable pyLpOracle;
|
|
23
29
|
|
|
24
|
-
constructor(uint32 _twapDuration, address _market, address _feed, address
|
|
30
|
+
constructor(uint32 _twapDuration, address _market, address _feed, address _pyLpOracle) {
|
|
25
31
|
twapDuration = _twapDuration;
|
|
26
32
|
market = _market;
|
|
27
33
|
feed = _feed;
|
|
28
34
|
feedDecimals = IChainlinkAggregator(feed).decimals();
|
|
29
35
|
|
|
30
36
|
// required only for sample2
|
|
31
|
-
|
|
37
|
+
pyLpOracle = _pyLpOracle;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @notice All pricing functions in this contract should only be used after checkOracleState() is ran successfully without reverting.
|
|
41
|
+
* This equals to calling checkOracleState() in your oracle constructor.
|
|
42
|
+
*/
|
|
43
|
+
// checkOracleState();
|
|
32
44
|
}
|
|
33
45
|
|
|
34
|
-
/// @notice direct integration with
|
|
46
|
+
/// @notice direct integration with PendlePYOracleLib, which optimizes gas efficiency.
|
|
35
47
|
/// @notice please checkOracleState() before use
|
|
36
48
|
function getPtPriceSample1() external view virtual returns (uint256) {
|
|
37
49
|
uint256 ptRate = IPMarket(market).getPtToAssetRate(twapDuration);
|
|
@@ -43,11 +55,23 @@ contract BoringPtUsdChainlinkOracle {
|
|
|
43
55
|
/// but slightly higher gas usage (~ 4000 gas, 2 external calls & 1 cold code load)
|
|
44
56
|
/// @notice please checkOracleState() before use
|
|
45
57
|
function getPtPriceSample2() external view virtual returns (uint256) {
|
|
46
|
-
uint256 ptRate =
|
|
58
|
+
uint256 ptRate = IPPYLpOracle(pyLpOracle).getPtToAssetRate(market, twapDuration);
|
|
47
59
|
uint256 assetPrice = _getUnderlyingAssetPrice();
|
|
48
60
|
return (assetPrice * ptRate) / PMath.ONE;
|
|
49
61
|
}
|
|
50
62
|
|
|
63
|
+
function getYtPriceSample1() external view virtual returns (uint256) {
|
|
64
|
+
uint256 ytRate = IPMarket(market).getYtToAssetRate(twapDuration);
|
|
65
|
+
uint256 assetPrice = _getUnderlyingAssetPrice();
|
|
66
|
+
return (assetPrice * ytRate) / PMath.ONE;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getYtPriceSample2() external view virtual returns (uint256) {
|
|
70
|
+
uint256 ytRate = IPPYLpOracle(pyLpOracle).getYtToAssetRate(market, twapDuration);
|
|
71
|
+
uint256 assetPrice = _getUnderlyingAssetPrice();
|
|
72
|
+
return (assetPrice * ytRate) / PMath.ONE;
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
function _getUnderlyingAssetPrice() internal view virtual returns (uint256) {
|
|
52
76
|
uint256 rawPrice = uint256(IChainlinkAggregator(feed).latestAnswer());
|
|
53
77
|
return feedDecimals < 18 ? rawPrice * 10 ** (18 - feedDecimals) : rawPrice / 10 ** (feedDecimals - 18);
|
|
@@ -60,8 +84,8 @@ contract BoringPtUsdChainlinkOracle {
|
|
|
60
84
|
|
|
61
85
|
/// @notice Call only once for each (market, duration). Once successful, it's permanently valid (also for any shorter duration).
|
|
62
86
|
function checkOracleState() external view {
|
|
63
|
-
(bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied) =
|
|
64
|
-
|
|
87
|
+
(bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied) = IPPYLpOracle(
|
|
88
|
+
pyLpOracle
|
|
65
89
|
).getOracleState(market, twapDuration);
|
|
66
90
|
|
|
67
91
|
if (increaseCardinalityRequired) {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../interfaces/IPPYLpOracle.sol";
|
|
5
|
+
import "../../interfaces/IPMarket.sol";
|
|
6
|
+
import "../../core/libraries/math/PMath.sol";
|
|
7
|
+
import "../PendleLpOracleLib.sol";
|
|
8
|
+
|
|
9
|
+
import {AggregatorV2V3Interface as IChainlinkAggregator} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @notice The returned price from this contract is multiplied by the default USD price of the
|
|
13
|
+
* SY-equivalent token, as read from a Chainlink-interface oracle.
|
|
14
|
+
*
|
|
15
|
+
* Example of this usage:
|
|
16
|
+
* - PT-weETH = ptToSyRate * weETH price
|
|
17
|
+
* - PT-ezETH = ptToSyRate * ezETH price
|
|
18
|
+
*
|
|
19
|
+
* For more details into how the oracle is implemented, refer to PendlePYLpOracle & PendlePYOracleLib.
|
|
20
|
+
*/
|
|
21
|
+
contract BoringPYUsdChainlinkSYOracle {
|
|
22
|
+
using PendlePYOracleLib for IPMarket;
|
|
23
|
+
|
|
24
|
+
uint32 public immutable twapDuration;
|
|
25
|
+
address public immutable market;
|
|
26
|
+
address public immutable feed;
|
|
27
|
+
uint8 public immutable feedDecimals;
|
|
28
|
+
address public immutable pyLpOracle;
|
|
29
|
+
|
|
30
|
+
constructor(uint32 _twapDuration, address _market, address _feed, address _pyLpOracle) {
|
|
31
|
+
twapDuration = _twapDuration;
|
|
32
|
+
market = _market;
|
|
33
|
+
feed = _feed;
|
|
34
|
+
feedDecimals = IChainlinkAggregator(feed).decimals();
|
|
35
|
+
|
|
36
|
+
// required only for sample2
|
|
37
|
+
pyLpOracle = _pyLpOracle;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @notice All pricing functions in this contract should only be used after checkOracleState() is ran successfully without reverting.
|
|
41
|
+
* This equals to calling checkOracleState() in your oracle constructor.
|
|
42
|
+
*/
|
|
43
|
+
// checkOracleState();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// @notice direct integration with PendlePYOracleLib, which optimizes gas efficiency.
|
|
47
|
+
/// @notice please checkOracleState() before use
|
|
48
|
+
function getPtPriceSample1() external view virtual returns (uint256) {
|
|
49
|
+
uint256 ptRate = IPMarket(market).getPtToSyRate(twapDuration);
|
|
50
|
+
uint256 syEquivalentTokenPrice = _getSYEquivalentTokenPrice();
|
|
51
|
+
return (syEquivalentTokenPrice * ptRate) / PMath.ONE;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// @notice integration with the PendlePtOracle contract, resulting in a smaller bytecode size and simpler structure
|
|
55
|
+
/// but slightly higher gas usage (~ 4000 gas, 2 external calls & 1 cold code load)
|
|
56
|
+
/// @notice please checkOracleState() before use
|
|
57
|
+
function getPtPriceSample2() external view virtual returns (uint256) {
|
|
58
|
+
uint256 ptRate = IPPYLpOracle(pyLpOracle).getPtToSyRate(market, twapDuration);
|
|
59
|
+
uint256 syEquivalentTokenPrice = _getSYEquivalentTokenPrice();
|
|
60
|
+
return (syEquivalentTokenPrice * ptRate) / PMath.ONE;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getYtPriceSample1() external view virtual returns (uint256) {
|
|
64
|
+
uint256 ytRate = IPMarket(market).getYtToSyRate(twapDuration);
|
|
65
|
+
uint256 syEquivalentTokenPrice = _getSYEquivalentTokenPrice();
|
|
66
|
+
return (syEquivalentTokenPrice * ytRate) / PMath.ONE;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getYtPriceSample2() external view virtual returns (uint256) {
|
|
70
|
+
uint256 ytRate = IPPYLpOracle(pyLpOracle).getYtToSyRate(market, twapDuration);
|
|
71
|
+
uint256 syEquivalentTokenPrice = _getSYEquivalentTokenPrice();
|
|
72
|
+
return (syEquivalentTokenPrice * ytRate) / PMath.ONE;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _getSYEquivalentTokenPrice() internal view virtual returns (uint256) {
|
|
76
|
+
uint256 rawPrice = uint256(IChainlinkAggregator(feed).latestAnswer());
|
|
77
|
+
return feedDecimals < 18 ? rawPrice * 10 ** (18 - feedDecimals) : rawPrice / 10 ** (feedDecimals - 18);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ------------------ NOT TO INCLUDE IN PRODUCTION CODE ------------------
|
|
81
|
+
|
|
82
|
+
error IncreaseCardinalityRequired(uint16 cardinalityRequired);
|
|
83
|
+
error AdditionalWaitRequired(uint32 duration);
|
|
84
|
+
|
|
85
|
+
/// @notice Call only once for each (market, duration). Once successful, it's permanently valid (also for any shorter duration).
|
|
86
|
+
function checkOracleState() external view {
|
|
87
|
+
(bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied) = IPPYLpOracle(
|
|
88
|
+
pyLpOracle
|
|
89
|
+
).getOracleState(market, twapDuration);
|
|
90
|
+
|
|
91
|
+
if (increaseCardinalityRequired) {
|
|
92
|
+
// It's required to call IPMarket(market).increaseObservationsCardinalityNext(cardinalityRequired) and wait for
|
|
93
|
+
// at least the twapDuration, to allow data population.
|
|
94
|
+
revert IncreaseCardinalityRequired(cardinalityRequired);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!oldestObservationSatisfied) {
|
|
98
|
+
// It's necessary to wait for at least the twapDuration, to allow data population.
|
|
99
|
+
revert AdditionalWaitRequired(twapDuration);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|