@pendle/core-v2 4.5.2 → 4.7.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/build/artifacts/contracts/core/StandardizedYield/implementations/Ethena/PendleSUSDESY.sol/PendleSUSDESY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ethena/PendleSUSDESY.sol/PendleSUSDESY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultERC20SY.sol/PendleKarakVaultERC20SY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultERC20SY.sol/PendleKarakVaultERC20SY.json +1070 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultEzETHSY.sol/PendleKarakVaultEzETHSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultEzETHSY.sol/PendleKarakVaultEzETHSY.json +1144 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultSUSDESY.sol/PendleKarakVaultSUSDESY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultSUSDESY.sol/PendleKarakVaultSUSDESY.json +1111 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultSYBaseUpg.sol/PendleKarakVaultSYBaseUpg.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultSYBaseUpg.sol/PendleKarakVaultSYBaseUpg.json +1036 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultUSDESY.sol/PendleKarakVaultUSDESY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultUSDESY.sol/PendleKarakVaultUSDESY.json +1096 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultWEETHSY.sol/PendleKarakVaultWEETHSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultWEETHSY.sol/PendleKarakVaultWEETHSY.json +1116 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC4626SY.sol/PendleERC4626SY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC4626SY.sol/PendleERC4626SY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC4626UpgSY.sol/PendleERC4626SYUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC4626UpgSY.sol/PendleERC4626SYUpg.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol/PendleGDaiSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol/PendleGDaiSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol/PendleSfrxEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol/PendleSfrxEthSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PirexETH/PendleApxETHSY.sol/PendleApxETHSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PirexETH/PendleApxETHSY.sol/PendleApxETHSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Puffer/PendlePufStETHSY.sol/PendlePufStETHSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Puffer/PendlePufStETHSY.sol/PendlePufStETHSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Puffer/PendlePufWETHSY.sol/PendlePufWETHSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Puffer/PendlePufWETHSY.sol/PendlePufWETHSY.json +2 -2
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.json +19 -0
- package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.json +1200 -34
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.json +1228 -62
- 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/IPReflector.sol/IPReflector.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPReflector.sol/IPReflector.json +30 -0
- package/build/artifacts/contracts/interfaces/IPTokenWithSupplyCap.sol/IPTokenWithSupplyCap.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPTokenWithSupplyCap.sol/IPTokenWithSupplyCap.json +37 -0
- package/build/artifacts/contracts/interfaces/Karak/IKarakVault.sol/IKarakVault.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Karak/IKarakVault.sol/IKarakVault.json +24 -0
- package/build/artifacts/contracts/interfaces/Karak/IKarakVaultSupervisor.sol/IKarakVaultSupervisor.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Karak/IKarakVaultSupervisor.sol/IKarakVaultSupervisor.json +76 -0
- package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.json +25 -2
- package/build/artifacts/contracts/offchain-helpers/SupplyCapReader.sol/IPossibleSupplyCapInterface.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/SupplyCapReader.sol/SupplyCapReader.dbg.json +1 -1
- 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 +1202 -36
- 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/Reflector.sol/Reflector.dbg.json +4 -0
- package/build/artifacts/contracts/router/Reflector.sol/Reflector.json +34 -0
- package/build/artifacts/contracts/router/base/ActionBase.sol/ActionBase.dbg.json +1 -1
- package/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultERC20SY.sol +32 -0
- package/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultEzETHSY.sol +80 -0
- package/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultSUSDESY.sol +73 -0
- package/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultSYBaseUpg.sol +141 -0
- package/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultUSDESY.sol +18 -0
- package/contracts/core/StandardizedYield/implementations/Karak/PendleKarakVaultWEETHSY.sol +71 -0
- package/contracts/interfaces/IERC4626.sol +2 -0
- package/contracts/interfaces/IPActionMiscV3.sol +99 -0
- package/contracts/interfaces/{IPPtLpOracle.sol → IPPYLpOracle.sol} +5 -1
- package/contracts/interfaces/IPReflector.sol +6 -0
- package/contracts/interfaces/IPTokenWithSupplyCap.sol +9 -0
- package/contracts/interfaces/Karak/IKarakVault.sol +6 -0
- package/contracts/interfaces/Karak/IKarakVaultSupervisor.sol +8 -0
- package/contracts/offchain-helpers/PendlePoolDeployHelper.sol +5 -0
- package/contracts/oracles/PendleLpOracleLib.sol +4 -4
- package/contracts/oracles/{PendlePtLpOracle.sol → PendlePYLpOracle.sol} +51 -21
- 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 +182 -34
- package/contracts/router/ActionSwapYTV3.sol +0 -85
- package/contracts/router/Reflector.sol +70 -0
- package/contracts/router/base/ActionBase.sol +90 -1
- package/deployments/1-core.json +11 -2
- package/deployments/1-markets/KARAK-SUSDE-MAINNET-SEP2024.json +14 -0
- package/deployments/1-markets/KARAK-USDE-MAINNET-SEP2024.json +14 -0
- package/deployments/1-markets/KARAK-WEETH-MAINNET-SEP2024.json +14 -0
- package/deployments/10-core.json +11 -2
- package/deployments/42161-core.json +11 -2
- package/deployments/42161-markets/CAMELOT-PEP-ARBITRUM-JUNE2025.json +14 -0
- package/deployments/42161-markets/RSETH-ARBITRUM-SEP2024-NEW.json +11 -0
- package/deployments/5000-core.json +11 -2
- package/deployments/56-core.json +11 -2
- package/package.json +1 -1
- package/typechain-types/ActionMiscV3.ts +628 -16
- package/typechain-types/IERC4626.ts +34 -0
- package/typechain-types/IKarakVault.ts +84 -0
- package/typechain-types/IKarakVaultSupervisor.ts +190 -0
- package/typechain-types/IPActionMiscV3.ts +628 -16
- package/typechain-types/IPAllActionV3.ts +535 -0
- package/typechain-types/IPReflector.ts +95 -0
- package/typechain-types/IPTokenWithSupplyCap.ts +110 -0
- package/typechain-types/PendleKarakVaultERC20SY.ts +1324 -0
- package/typechain-types/PendleKarakVaultEzETHSY.ts +1400 -0
- package/typechain-types/PendleKarakVaultSUSDESY.ts +1380 -0
- package/typechain-types/PendleKarakVaultSYBaseUpg.ts +1312 -0
- package/typechain-types/PendleKarakVaultUSDESY.ts +1366 -0
- package/typechain-types/PendleKarakVaultWEETHSY.ts +1370 -0
- package/typechain-types/PendlePYLpOracle.ts +10 -3
- package/typechain-types/PendlePoolDeployHelper.ts +44 -0
- package/typechain-types/Reflector.ts +95 -0
- package/typechain-types/factories/ActionAddRemoveLiqV3__factory.ts +1 -1
- package/typechain-types/factories/ActionMiscV3__factory.ts +1201 -35
- 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/IERC4626__factory.ts +19 -0
- package/typechain-types/factories/IKarakVaultSupervisor__factory.ts +95 -0
- package/typechain-types/factories/IKarakVault__factory.ts +36 -0
- package/typechain-types/factories/IPActionMiscV3__factory.ts +1200 -34
- package/typechain-types/factories/IPAllActionV3__factory.ts +1228 -62
- package/typechain-types/factories/IPReflector__factory.ts +42 -0
- package/typechain-types/factories/IPTokenWithSupplyCap__factory.ts +56 -0
- package/typechain-types/factories/PendleApxETHSY__factory.ts +1 -1
- package/typechain-types/factories/PendleERC4626SYUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleERC4626SY__factory.ts +1 -1
- package/typechain-types/factories/PendleGDaiSY__factory.ts +1 -1
- package/typechain-types/factories/PendleKarakVaultERC20SY__factory.ts +1139 -0
- package/typechain-types/factories/PendleKarakVaultEzETHSY__factory.ts +1236 -0
- package/typechain-types/factories/PendleKarakVaultSUSDESY__factory.ts +1180 -0
- package/typechain-types/factories/PendleKarakVaultSYBaseUpg__factory.ts +1055 -0
- package/typechain-types/factories/PendleKarakVaultUSDESY__factory.ts +1165 -0
- package/typechain-types/factories/PendleKarakVaultWEETHSY__factory.ts +1189 -0
- package/typechain-types/factories/PendlePYLpOracle__factory.ts +12 -24
- package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +24 -1
- package/typechain-types/factories/PendlePufStETHSY__factory.ts +1 -1
- package/typechain-types/factories/PendlePufWETHSY__factory.ts +1 -1
- package/typechain-types/factories/PendleSUSDESY__factory.ts +1 -1
- package/typechain-types/factories/PendleSfrxEthSY__factory.ts +1 -1
- package/typechain-types/factories/Reflector__factory.ts +84 -0
- package/typechain-types/hardhat.d.ts +99 -0
- package/typechain-types/index.ts +22 -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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../../../interfaces/IPTokenWithSupplyCap.sol";
|
|
5
|
+
import "./PendleKarakVaultSYBaseUpg.sol";
|
|
6
|
+
|
|
7
|
+
contract PendleKarakVaultSUSDESY is PendleKarakVaultSYBaseUpg, IPTokenWithSupplyCap {
|
|
8
|
+
// solhint-disable immutable-vars-naming
|
|
9
|
+
address public immutable usde;
|
|
10
|
+
address public immutable susde;
|
|
11
|
+
|
|
12
|
+
constructor(address _vault, address _vaultSupervisor) PendleKarakVaultSYBaseUpg(_vault, _vaultSupervisor) {
|
|
13
|
+
susde = IERC4626(_vault).asset();
|
|
14
|
+
usde = IERC4626(susde).asset();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getAbsoluteSupplyCap() external view returns (uint256) {
|
|
18
|
+
uint256 assetLimit = IKarakVault(vault).assetLimit();
|
|
19
|
+
return IERC4626(vault).convertToShares(assetLimit);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getAbsoluteTotalSupply() external view returns (uint256) {
|
|
23
|
+
return IERC20(vault).totalSupply();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function initialize() external initializer {
|
|
27
|
+
__SYBaseUpg_init("SY Karak sUSDe", "SY-Karak-sUSDe");
|
|
28
|
+
__KarakVaultSY_init();
|
|
29
|
+
_safeApproveInf(usde, susde);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*///////////////////////////////////////////////////////////////
|
|
33
|
+
EXCHANGE-RATE
|
|
34
|
+
//////////////////////////////////////////////////////////////*/
|
|
35
|
+
|
|
36
|
+
function _getStakeTokenExchangeRate() internal view virtual override returns (uint256) {
|
|
37
|
+
return IERC4626(susde).previewRedeem(PMath.ONE);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/*///////////////////////////////////////////////////////////////
|
|
41
|
+
ADDITIONAL TOKEN IN FUNCTIONS
|
|
42
|
+
//////////////////////////////////////////////////////////////*/
|
|
43
|
+
|
|
44
|
+
function _getAdditionalTokens() internal view virtual override returns (address[] memory) {
|
|
45
|
+
return ArrayLib.create(usde);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _previewToStakeToken(
|
|
49
|
+
address tokenIn,
|
|
50
|
+
uint256 amountTokenToDeposit
|
|
51
|
+
) internal view virtual override returns (uint256) {
|
|
52
|
+
assert(tokenIn == usde);
|
|
53
|
+
|
|
54
|
+
return IERC4626(susde).previewDeposit(amountTokenToDeposit);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _wrapToStakeToken(
|
|
58
|
+
address tokenIn,
|
|
59
|
+
uint256 amountDeposited
|
|
60
|
+
) internal virtual override returns (uint256) {
|
|
61
|
+
assert(tokenIn == usde);
|
|
62
|
+
|
|
63
|
+
return IERC4626(susde).deposit(amountDeposited, address(this));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _canWrapToStakeToken(address tokenIn) internal view virtual override returns (bool) {
|
|
67
|
+
return tokenIn == usde;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function assetInfo() external view override returns (AssetType, address, uint8) {
|
|
71
|
+
return (AssetType.TOKEN, usde, 18);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../SYBaseUpg.sol";
|
|
5
|
+
import "../../../../interfaces/IERC4626.sol";
|
|
6
|
+
import "../../../../interfaces/Karak/IKarakVault.sol";
|
|
7
|
+
import "../../../../interfaces/Karak/IKarakVaultSupervisor.sol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pendle SY should take either the stake token or the vault token from user to deposit back into Karak.
|
|
11
|
+
* At any point of time, all holding under SY.totalSupply() should always be deposited inside Karak rather than holding the vault token.
|
|
12
|
+
*/
|
|
13
|
+
abstract contract PendleKarakVaultSYBaseUpg is SYBaseUpg {
|
|
14
|
+
using ArrayLib for address[];
|
|
15
|
+
|
|
16
|
+
error KarakVaultAssetLimitExceeded(uint256 assetLimit, uint256 totalAsset, uint256 amountAssetToDeposit);
|
|
17
|
+
|
|
18
|
+
// solhint-disable immutable-vars-naming
|
|
19
|
+
address public immutable vault; // vault is also share token
|
|
20
|
+
address public immutable stakeToken;
|
|
21
|
+
address public immutable vaultSupervisor;
|
|
22
|
+
|
|
23
|
+
// address public immutable shareToken;
|
|
24
|
+
|
|
25
|
+
constructor(address _vault, address _vaultSupervisor) SYBaseUpg(_vault) {
|
|
26
|
+
vault = _vault;
|
|
27
|
+
stakeToken = IERC4626(_vault).asset();
|
|
28
|
+
vaultSupervisor = _vaultSupervisor;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*///////////////////////////////////////////////////////////////
|
|
32
|
+
Karak Vault Specilization
|
|
33
|
+
//////////////////////////////////////////////////////////////*/
|
|
34
|
+
|
|
35
|
+
function __KarakVaultSY_init() internal onlyInitializing {
|
|
36
|
+
_safeApproveInf(stakeToken, vault);
|
|
37
|
+
_safeApproveInf(vault, vaultSupervisor);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function exchangeRate() public view override returns (uint256) {
|
|
41
|
+
uint256 stakeTokenRate = _getStakeTokenExchangeRate();
|
|
42
|
+
// There should be no decimal offset on normal ERC20 tokens
|
|
43
|
+
// Could not be use for stakeToken without a properly configured ERC20 interface
|
|
44
|
+
uint256 shareToAssetRate = IERC4626(vault).convertToAssets(PMath.ONE);
|
|
45
|
+
return (stakeTokenRate * shareToAssetRate) / PMath.ONE;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _getStakeTokenExchangeRate() internal view virtual returns (uint256);
|
|
49
|
+
|
|
50
|
+
/*///////////////////////////////////////////////////////////////
|
|
51
|
+
DEPOSIT/REDEEM USING BASE TOKENS
|
|
52
|
+
//////////////////////////////////////////////////////////////*/
|
|
53
|
+
|
|
54
|
+
function _deposit(
|
|
55
|
+
address tokenIn,
|
|
56
|
+
uint256 amountDeposited
|
|
57
|
+
) internal virtual override returns (uint256 /*amountSharesOut*/) {
|
|
58
|
+
if (tokenIn != stakeToken && tokenIn != vault) {
|
|
59
|
+
(tokenIn, amountDeposited) = (stakeToken, _wrapToStakeToken(tokenIn, amountDeposited));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (tokenIn == stakeToken) {
|
|
63
|
+
return IKarakVaultSupervisor(vaultSupervisor).deposit(vault, amountDeposited, 0);
|
|
64
|
+
} else {
|
|
65
|
+
IKarakVaultSupervisor(vaultSupervisor).returnShares(vault, amountDeposited);
|
|
66
|
+
return amountDeposited;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _redeem(
|
|
71
|
+
address receiver,
|
|
72
|
+
address /*tokenOut*/,
|
|
73
|
+
uint256 amountSharesToRedeem
|
|
74
|
+
) internal virtual override returns (uint256 /*amountTokenOut*/) {
|
|
75
|
+
IKarakVaultSupervisor(vaultSupervisor).gimmieShares(vault, amountSharesToRedeem);
|
|
76
|
+
_transferOut(vault, receiver, amountSharesToRedeem);
|
|
77
|
+
return amountSharesToRedeem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/*///////////////////////////////////////////////////////////////
|
|
81
|
+
MISC FUNCTIONS FOR METADATA
|
|
82
|
+
//////////////////////////////////////////////////////////////*/
|
|
83
|
+
|
|
84
|
+
function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit) internal view override returns (uint256) {
|
|
85
|
+
if (tokenIn != stakeToken && tokenIn != vault) {
|
|
86
|
+
(tokenIn, amountTokenToDeposit) = (stakeToken, _previewToStakeToken(tokenIn, amountTokenToDeposit));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (tokenIn == stakeToken) {
|
|
90
|
+
uint256 totalAsset = IERC4626(vault).totalAssets();
|
|
91
|
+
uint256 totalSupply = IERC4626(vault).totalSupply();
|
|
92
|
+
uint256 assetLimit = IKarakVault(vault).assetLimit();
|
|
93
|
+
if (totalAsset + amountTokenToDeposit > assetLimit) {
|
|
94
|
+
revert KarakVaultAssetLimitExceeded(assetLimit, totalAsset, amountTokenToDeposit);
|
|
95
|
+
}
|
|
96
|
+
return (amountTokenToDeposit * totalSupply) / totalAsset;
|
|
97
|
+
}
|
|
98
|
+
return amountTokenToDeposit;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function _previewRedeem(
|
|
102
|
+
address /*tokenOut*/,
|
|
103
|
+
uint256 amountSharesToRedeem
|
|
104
|
+
) internal pure override returns (uint256 /*amountTokenOut*/) {
|
|
105
|
+
return amountSharesToRedeem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function getTokensIn() public view virtual override returns (address[] memory) {
|
|
109
|
+
return ArrayLib.create(vault, stakeToken).merge(_getAdditionalTokens());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function getTokensOut() public view virtual override returns (address[] memory) {
|
|
113
|
+
return ArrayLib.create(vault);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isValidTokenIn(address token) public view virtual override returns (bool) {
|
|
117
|
+
return token == vault || token == stakeToken || _canWrapToStakeToken(token);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function isValidTokenOut(address token) public view virtual override returns (bool) {
|
|
121
|
+
return token == vault;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/*///////////////////////////////////////////////////////////////
|
|
125
|
+
ADDITIONAL TOKEN IN FUNCTIONS
|
|
126
|
+
//////////////////////////////////////////////////////////////*/
|
|
127
|
+
|
|
128
|
+
function _getAdditionalTokens() internal view virtual returns (address[] memory) {}
|
|
129
|
+
|
|
130
|
+
function _previewToStakeToken(address, uint256) internal view virtual returns (uint256) {
|
|
131
|
+
assert(false);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function _wrapToStakeToken(address, uint256) internal virtual returns (uint256) {
|
|
135
|
+
assert(false);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function _canWrapToStakeToken(address) internal view virtual returns (bool) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../../../interfaces/IPTokenWithSupplyCap.sol";
|
|
5
|
+
import "./PendleKarakVaultERC20SY.sol";
|
|
6
|
+
|
|
7
|
+
contract PendleKarakVaultUSDESY is PendleKarakVaultERC20SY, IPTokenWithSupplyCap {
|
|
8
|
+
constructor(address _vault, address _vaultSupervisor) PendleKarakVaultERC20SY(_vault, _vaultSupervisor) {}
|
|
9
|
+
|
|
10
|
+
function getAbsoluteSupplyCap() external view returns (uint256) {
|
|
11
|
+
uint256 assetLimit = IKarakVault(vault).assetLimit();
|
|
12
|
+
return IERC4626(vault).convertToShares(assetLimit);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getAbsoluteTotalSupply() external view returns (uint256) {
|
|
16
|
+
return IERC20(vault).totalSupply();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
|
|
4
|
+
import "./PendleKarakVaultSYBaseUpg.sol";
|
|
5
|
+
import "../../../../interfaces/EtherFi/IEtherFiLiquidityPool.sol";
|
|
6
|
+
import "../../../../interfaces/EtherFi/IEtherFiWEEth.sol";
|
|
7
|
+
|
|
8
|
+
contract PendleKarakVaultWEETHSY is PendleKarakVaultSYBaseUpg {
|
|
9
|
+
// solhint-disable immutable-vars-naming
|
|
10
|
+
address public immutable weETH;
|
|
11
|
+
address public immutable liquidityPool;
|
|
12
|
+
address public immutable eETH;
|
|
13
|
+
address public immutable referee;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
address _vault,
|
|
17
|
+
address _vaultSupervisor,
|
|
18
|
+
address _referee
|
|
19
|
+
) PendleKarakVaultSYBaseUpg(_vault, _vaultSupervisor) {
|
|
20
|
+
weETH = IERC4626(_vault).asset();
|
|
21
|
+
liquidityPool = IEtherFiWEEth(weETH).liquidityPool();
|
|
22
|
+
eETH = IEtherFiWEEth(weETH).eETH();
|
|
23
|
+
referee = _referee;
|
|
24
|
+
|
|
25
|
+
_disableInitializers();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function initialize() external initializer {
|
|
29
|
+
__SYBaseUpg_init("SY Karak WEETH", "SY-Karak-WEETH");
|
|
30
|
+
__KarakVaultSY_init();
|
|
31
|
+
_safeApproveInf(eETH, weETH);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*///////////////////////////////////////////////////////////////
|
|
35
|
+
EXCHANGE-RATE
|
|
36
|
+
//////////////////////////////////////////////////////////////*/
|
|
37
|
+
|
|
38
|
+
function _getStakeTokenExchangeRate() internal view virtual override returns (uint256) {
|
|
39
|
+
return IEtherFiLiquidityPool(liquidityPool).amountForShare(1 ether);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*///////////////////////////////////////////////////////////////
|
|
43
|
+
ADDITIONAL TOKEN IN FUNCTIONS
|
|
44
|
+
//////////////////////////////////////////////////////////////*/
|
|
45
|
+
|
|
46
|
+
function _getAdditionalTokens() internal view virtual override returns (address[] memory) {
|
|
47
|
+
return ArrayLib.create(eETH, NATIVE);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _previewToStakeToken(
|
|
51
|
+
address,
|
|
52
|
+
uint256 amountTokenToDeposit
|
|
53
|
+
) internal view virtual override returns (uint256) {
|
|
54
|
+
return IEtherFiLiquidityPool(liquidityPool).sharesForAmount(amountTokenToDeposit);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _wrapToStakeToken(address tokenIn, uint256 amountDeposited) internal virtual override returns (uint256) {
|
|
58
|
+
if (tokenIn == NATIVE) {
|
|
59
|
+
IEtherFiLiquidityPool(liquidityPool).deposit{value: amountDeposited}(referee);
|
|
60
|
+
}
|
|
61
|
+
return IEtherFiWEEth(weETH).wrap(_selfBalance(eETH));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _canWrapToStakeToken(address tokenIn) internal view virtual override returns (bool) {
|
|
65
|
+
return tokenIn == eETH || tokenIn == NATIVE;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function assetInfo() external view override returns (AssetType, address, uint8) {
|
|
69
|
+
return (AssetType.TOKEN, eETH, 18);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -33,6 +33,8 @@ interface IERC4626 is IERC20Metadata {
|
|
|
33
33
|
|
|
34
34
|
function convertToAssets(uint256 shares) external view returns (uint256);
|
|
35
35
|
|
|
36
|
+
function convertToShares(uint256 assets) external view returns (uint256);
|
|
37
|
+
|
|
36
38
|
function previewDeposit(uint256 assets) external view returns (uint256);
|
|
37
39
|
|
|
38
40
|
function previewRedeem(uint256 shares) external view returns (uint256);
|
|
@@ -26,6 +26,26 @@ interface IPActionMiscV3 {
|
|
|
26
26
|
bytes returnData;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
struct ExitPreExpReturnParams {
|
|
30
|
+
uint256 netPtFromRemove;
|
|
31
|
+
uint256 netSyFromRemove;
|
|
32
|
+
uint256 netPyRedeem;
|
|
33
|
+
uint256 netSyFromRedeem;
|
|
34
|
+
uint256 netPtSwap;
|
|
35
|
+
uint256 netYtSwap;
|
|
36
|
+
uint256 netSyFromSwap;
|
|
37
|
+
uint256 netSyFee;
|
|
38
|
+
uint256 totalSyOut;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
struct ExitPostExpReturnParams {
|
|
42
|
+
uint256 netPtFromRemove;
|
|
43
|
+
uint256 netSyFromRemove;
|
|
44
|
+
uint256 netPtRedeem;
|
|
45
|
+
uint256 netSyFromRedeem;
|
|
46
|
+
uint256 totalSyOut;
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
event MintSyFromToken(
|
|
30
50
|
address indexed caller,
|
|
31
51
|
address indexed tokenIn,
|
|
@@ -80,6 +100,42 @@ interface IPActionMiscV3 {
|
|
|
80
100
|
uint256 netSyInterm
|
|
81
101
|
);
|
|
82
102
|
|
|
103
|
+
event ExitPreExpToToken(
|
|
104
|
+
address indexed caller,
|
|
105
|
+
address indexed market,
|
|
106
|
+
address indexed token,
|
|
107
|
+
address receiver,
|
|
108
|
+
uint256 netLpIn,
|
|
109
|
+
uint256 totalTokenOut,
|
|
110
|
+
ExitPreExpReturnParams params
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
event ExitPreExpToSy(
|
|
114
|
+
address indexed caller,
|
|
115
|
+
address indexed market,
|
|
116
|
+
address indexed receiver,
|
|
117
|
+
uint256 netLpIn,
|
|
118
|
+
ExitPreExpReturnParams params
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
event ExitPostExpToToken(
|
|
122
|
+
address indexed caller,
|
|
123
|
+
address indexed market,
|
|
124
|
+
address indexed token,
|
|
125
|
+
address receiver,
|
|
126
|
+
uint256 netLpIn,
|
|
127
|
+
uint256 totalTokenOut,
|
|
128
|
+
ExitPostExpReturnParams params
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
event ExitPostExpToSy(
|
|
132
|
+
address indexed caller,
|
|
133
|
+
address indexed market,
|
|
134
|
+
address indexed receiver,
|
|
135
|
+
uint256 netLpIn,
|
|
136
|
+
ExitPostExpReturnParams params
|
|
137
|
+
);
|
|
138
|
+
|
|
83
139
|
function mintSyFromToken(
|
|
84
140
|
address receiver,
|
|
85
141
|
address SY,
|
|
@@ -143,6 +199,49 @@ interface IPActionMiscV3 {
|
|
|
143
199
|
uint256 minTokenOut
|
|
144
200
|
) external payable returns (uint256 netTokenOut, uint256 netSyInterm);
|
|
145
201
|
|
|
202
|
+
function exitPreExpToToken(
|
|
203
|
+
address receiver,
|
|
204
|
+
address market,
|
|
205
|
+
uint256 netPtIn,
|
|
206
|
+
uint256 netYtIn,
|
|
207
|
+
uint256 netLpIn,
|
|
208
|
+
TokenOutput calldata output,
|
|
209
|
+
LimitOrderData calldata limit
|
|
210
|
+
) external returns (uint256 netTokenOut, ExitPreExpReturnParams memory params);
|
|
211
|
+
|
|
212
|
+
function exitPreExpToSy(
|
|
213
|
+
address receiver,
|
|
214
|
+
address market,
|
|
215
|
+
uint256 netPtIn,
|
|
216
|
+
uint256 netYtIn,
|
|
217
|
+
uint256 netLpIn,
|
|
218
|
+
uint256 minSyOut,
|
|
219
|
+
LimitOrderData calldata limit
|
|
220
|
+
) external returns (ExitPreExpReturnParams memory params);
|
|
221
|
+
|
|
222
|
+
function exitPostExpToToken(
|
|
223
|
+
address receiver,
|
|
224
|
+
address market,
|
|
225
|
+
uint256 netPtIn,
|
|
226
|
+
uint256 netLpIn,
|
|
227
|
+
TokenOutput calldata output
|
|
228
|
+
) external returns (uint256 netTokenOut, ExitPostExpReturnParams memory params);
|
|
229
|
+
|
|
230
|
+
function exitPostExpToSy(
|
|
231
|
+
address receiver,
|
|
232
|
+
address market,
|
|
233
|
+
uint256 netPtIn,
|
|
234
|
+
uint256 netLpIn,
|
|
235
|
+
uint256 minSyOut
|
|
236
|
+
) external returns (ExitPostExpReturnParams memory params);
|
|
237
|
+
|
|
238
|
+
function callAndReflect(
|
|
239
|
+
address payable reflector,
|
|
240
|
+
bytes calldata selfCall1,
|
|
241
|
+
bytes calldata selfCall2,
|
|
242
|
+
bytes calldata reflectCall
|
|
243
|
+
) external payable returns (bytes memory selfRes1, bytes memory selfRes2, bytes memory reflectRes);
|
|
244
|
+
|
|
146
245
|
function boostMarkets(address[] memory markets) external;
|
|
147
246
|
|
|
148
247
|
function multicall(Call3[] calldata calls) external payable returns (Result[] memory res);
|
|
@@ -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,8 @@
|
|
|
1
|
+
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
interface IKarakVaultSupervisor {
|
|
5
|
+
function deposit(address vault, uint256 amount, uint256 minSharesOut) external returns (uint256 shares);
|
|
6
|
+
function gimmieShares(address vault, uint256 shares) external;
|
|
7
|
+
function returnShares(address vault, uint256 shares) external;
|
|
8
|
+
}
|
|
@@ -39,6 +39,11 @@ contract PendlePoolDeployHelper is TokenHelper {
|
|
|
39
39
|
_seedLiquidity(market, SY, PT, YT, tokenToSeedLiqudity, amountToSeed);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function seedLiquidity(address market, address tokenToSeedLiqudity, uint256 amountToSeed) external payable {
|
|
43
|
+
(IStandardizedYield SY, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
|
|
44
|
+
_seedLiquidity(market, address(SY), address(PT), address(YT), tokenToSeedLiqudity, amountToSeed);
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
function _deployPYAndMarket(
|
|
43
48
|
address SY,
|
|
44
49
|
PoolDeploymentParams memory params
|
|
@@ -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,54 @@ contract PendlePtLpOracle is BoringOwnableUpgradeable, IPPtLpOracle {
|
|
|
26
26
|
uint16 public blockCycleNumerator;
|
|
27
27
|
uint16 public constant BLOCK_CYCLE_DENOMINATOR = 1000;
|
|
28
28
|
|
|
29
|
-
constructor(
|
|
29
|
+
constructor() {
|
|
30
|
+
_disableInitializers();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function initialize(uint16 _blockCycleNumerator) external initializer {
|
|
30
34
|
__BoringOwnable_init();
|
|
31
|
-
|
|
35
|
+
_setBlockCycleNumerator(_blockCycleNumerator);
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
if (newBlockCycleNumerator < BLOCK_CYCLE_DENOMINATOR) {
|
|
36
|
-
revert InvalidBlockRate(newBlockCycleNumerator);
|
|
37
|
-
}
|
|
38
|
+
// Refer to https://docs.pendle.finance/Home on how to use the oracle
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
/*///////////////////////////////////////////////////////////////
|
|
41
|
+
PT, YT, LP to SY
|
|
42
|
+
//////////////////////////////////////////////////////////////*/
|
|
43
|
+
|
|
44
|
+
function getPtToSyRate(address market, uint32 duration) external view returns (uint256) {
|
|
45
|
+
return IPMarket(market).getPtToSyRate(duration);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
function
|
|
44
|
-
return IPMarket(market).
|
|
48
|
+
function getYtToSyRate(address market, uint32 duration) external view returns (uint256) {
|
|
49
|
+
return IPMarket(market).getYtToSyRate(duration);
|
|
45
50
|
}
|
|
46
51
|
|
|
52
|
+
function getLpToSyRate(address market, uint32 duration) external view returns (uint256) {
|
|
53
|
+
return IPMarket(market).getLpToSyRate(duration);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/*///////////////////////////////////////////////////////////////
|
|
57
|
+
PT, YT, LP to Asset
|
|
58
|
+
//////////////////////////////////////////////////////////////*/
|
|
59
|
+
|
|
47
60
|
/// @notice make sure you have taken into account the risk of not being able to withdraw from SY to Asset
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return IPMarket(market).getLpToAssetRate(duration);
|
|
61
|
+
function getPtToAssetRate(address market, uint32 duration) external view returns (uint256) {
|
|
62
|
+
return IPMarket(market).getPtToAssetRate(duration);
|
|
51
63
|
}
|
|
52
64
|
|
|
53
|
-
function
|
|
54
|
-
return IPMarket(market).
|
|
65
|
+
function getYtToAssetRate(address market, uint32 duration) external view returns (uint256) {
|
|
66
|
+
return IPMarket(market).getYtToAssetRate(duration);
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
function
|
|
58
|
-
return IPMarket(market).
|
|
69
|
+
function getLpToAssetRate(address market, uint32 duration) external view returns (uint256) {
|
|
70
|
+
return IPMarket(market).getLpToAssetRate(duration);
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
/*///////////////////////////////////////////////////////////////
|
|
74
|
+
Utility functions
|
|
75
|
+
//////////////////////////////////////////////////////////////*/
|
|
76
|
+
|
|
61
77
|
/**
|
|
62
78
|
* A check function for the cardinality status of the market
|
|
63
79
|
* @param market PendleMarket address
|
|
@@ -99,4 +115,18 @@ contract PendlePtLpOracle is BoringOwnableUpgradeable, IPPtLpOracle {
|
|
|
99
115
|
}
|
|
100
116
|
return uint16(cardinalityRequired);
|
|
101
117
|
}
|
|
118
|
+
|
|
119
|
+
// --- Owner-Only Functions ---
|
|
120
|
+
function setBlockCycleNumerator(uint16 newBlockCycleNumerator) external onlyOwner {
|
|
121
|
+
_setBlockCycleNumerator(newBlockCycleNumerator);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _setBlockCycleNumerator(uint16 newBlockCycleNumerator) internal {
|
|
125
|
+
if (newBlockCycleNumerator < BLOCK_CYCLE_DENOMINATOR) {
|
|
126
|
+
revert InvalidBlockRate(newBlockCycleNumerator);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
blockCycleNumerator = newBlockCycleNumerator;
|
|
130
|
+
emit SetBlockCycleNumerator(newBlockCycleNumerator);
|
|
131
|
+
}
|
|
102
132
|
}
|