@pendle/core-v2 0.17.6-testnet → 0.17.8-testnet

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.
Files changed (171) hide show
  1. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
  2. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
  3. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
  4. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
  5. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +2 -2
  6. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
  7. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
  8. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
  9. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +2 -2
  10. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
  11. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +2 -2
  12. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  13. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  14. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
  15. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  16. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
  17. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  18. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
  19. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  20. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  21. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
  22. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  23. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
  24. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  25. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  26. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  27. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  28. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
  29. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  30. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  31. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
  32. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +2 -2
  33. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
  34. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +2 -2
  35. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
  36. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
  37. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  38. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
  39. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  40. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
  41. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  42. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
  43. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  44. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +2 -2
  45. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  46. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.json +0 -141
  47. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  48. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json +0 -141
  49. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/PendleApeStakingSY.sol/PendleApeStakingSY.dbg.json +4 -0
  50. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/PendleApeStakingSY.sol/PendleApeStakingSY.json +908 -0
  51. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  52. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
  53. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  54. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -143
  55. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +2 -143
  57. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +2 -143
  59. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
  60. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.json +0 -141
  61. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
  62. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +2 -143
  63. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  64. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -143
  65. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  66. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +2 -2
  67. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  68. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
  69. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  70. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
  71. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  72. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +13 -2
  73. package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.dbg.json +4 -0
  74. package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.json +149 -0
  75. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  76. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  77. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  78. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
  79. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  80. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  81. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
  82. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  83. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  84. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  85. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
  86. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +2 -2
  87. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
  88. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -2
  89. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  90. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +2 -2
  91. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  92. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +2 -2
  93. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  94. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
  95. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  96. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +2 -2
  97. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
  98. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
  99. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  100. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +2 -2
  101. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
  102. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
  103. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  104. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +2 -2
  105. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  106. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -2
  107. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  108. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  109. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  110. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  111. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  112. package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
  113. package/contracts/core/StandardizedYield/SYBase.sol +5 -23
  114. package/contracts/core/StandardizedYield/SYBaseWithRewards.sol +1 -3
  115. package/contracts/core/StandardizedYield/implementations/Ape/PendleApeStakingSY.sol +184 -0
  116. package/contracts/core/libraries/Errors.sol +2 -0
  117. package/contracts/interfaces/IApeStaking.sol +30 -0
  118. package/deployments/43113-markets/APE-30-MARCH.json +10 -0
  119. package/package.json +1 -1
  120. package/typechain-types/IApeStaking.ts +31 -0
  121. package/typechain-types/PendleApeStakingSY.ts +88 -204
  122. package/typechain-types/PendleConvexLPSY.ts +0 -204
  123. package/typechain-types/PendleCurveFraxUsdcSY.ts +0 -204
  124. package/typechain-types/PendleCurveUsdd3CrvSY.ts +0 -204
  125. package/typechain-types/PendleLooksStakingSY.ts +0 -204
  126. package/typechain-types/PendleQiTokenSY.ts +0 -204
  127. package/typechain-types/PendleWstEthSY.ts +0 -204
  128. package/typechain-types/SYBase.ts +0 -204
  129. package/typechain-types/SYBaseWithRewards.ts +0 -204
  130. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
  131. package/typechain-types/factories/ActionCallback__factory.ts +1 -1
  132. package/typechain-types/factories/ActionMintRedeem__factory.ts +1 -1
  133. package/typechain-types/factories/ActionMisc__factory.ts +1 -1
  134. package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
  135. package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
  136. package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
  137. package/typechain-types/factories/BulkSellerFactory__factory.ts +1 -1
  138. package/typechain-types/factories/BulkSellerOffchain__factory.ts +1 -1
  139. package/typechain-types/factories/BulkSeller__factory.ts +1 -1
  140. package/typechain-types/factories/Errors__factory.ts +12 -1
  141. package/typechain-types/factories/IApeStaking__factory.ts +34 -0
  142. package/typechain-types/factories/MarketMathStatic__factory.ts +1 -1
  143. package/typechain-types/factories/OracleLib__factory.ts +1 -1
  144. package/typechain-types/factories/PendleApeStakingSY__factory.ts +57 -141
  145. package/typechain-types/factories/PendleConvexLPSY__factory.ts +0 -141
  146. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -142
  147. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -142
  148. package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
  149. package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
  150. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
  151. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
  152. package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1 -142
  153. package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
  154. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  155. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
  156. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
  157. package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
  158. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  159. package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -142
  160. package/typechain-types/factories/PendleRouter__factory.ts +1 -1
  161. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
  162. package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -142
  163. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
  164. package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
  165. package/typechain-types/factories/RouterStatic__factory.ts +1 -1
  166. package/typechain-types/factories/SYBaseWithRewards__factory.ts +0 -141
  167. package/typechain-types/factories/SYBase__factory.ts +0 -141
  168. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
  169. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
  170. package/typechain-types/hardhat.d.ts +18 -0
  171. package/typechain-types/index.ts +4 -0
@@ -1,22 +1,13 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
  pragma solidity 0.8.17;
3
- import "../../interfaces/IStandardizedYield.sol";
4
3
 
4
+ import "../../interfaces/IStandardizedYield.sol";
5
5
  import "../erc20/PendleERC20Permit.sol";
6
-
7
6
  import "../libraries/math/Math.sol";
8
7
  import "../libraries/TokenHelper.sol";
9
8
  import "../libraries/Errors.sol";
10
- import "../libraries/BoringOwnableUpgradeable.sol";
11
- import "@openzeppelin/contracts/security/Pausable.sol";
12
-
13
- abstract contract SYBase is
14
- IStandardizedYield,
15
- PendleERC20Permit,
16
- TokenHelper,
17
- BoringOwnableUpgradeable,
18
- Pausable
19
- {
9
+
10
+ abstract contract SYBase is IStandardizedYield, PendleERC20Permit, TokenHelper {
20
11
  using Math for uint256;
21
12
 
22
13
  address public immutable yieldToken;
@@ -25,9 +16,8 @@ abstract contract SYBase is
25
16
  string memory _name,
26
17
  string memory _symbol,
27
18
  address _yieldToken
28
- ) PendleERC20Permit(_name, _symbol, IERC20Metadata(_yieldToken).decimals()) initializer {
19
+ ) PendleERC20Permit(_name, _symbol, IERC20Metadata(_yieldToken).decimals()) {
29
20
  yieldToken = _yieldToken;
30
- __BoringOwnable_init();
31
21
  }
32
22
 
33
23
  // solhint-disable no-empty-blocks
@@ -189,19 +179,11 @@ abstract contract SYBase is
189
179
  return _previewRedeem(tokenOut, amountSharesToRedeem);
190
180
  }
191
181
 
192
- function pause() external onlyOwner {
193
- _pause();
194
- }
195
-
196
- function unpause() external onlyOwner {
197
- _unpause();
198
- }
199
-
200
182
  function _beforeTokenTransfer(
201
183
  address,
202
184
  address,
203
185
  uint256
204
- ) internal virtual override whenNotPaused {}
186
+ ) internal virtual override {}
205
187
 
206
188
  function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit)
207
189
  internal
@@ -29,7 +29,6 @@ abstract contract SYBaseWithRewards is SYBase, RewardManager {
29
29
  virtual
30
30
  override
31
31
  nonReentrant
32
- whenNotPaused
33
32
  returns (uint256[] memory rewardAmounts)
34
33
  {
35
34
  _updateAndDistributeRewards(user);
@@ -74,7 +73,6 @@ abstract contract SYBaseWithRewards is SYBase, RewardManager {
74
73
  function rewardIndexesCurrent()
75
74
  external
76
75
  override
77
- whenNotPaused
78
76
  nonReentrant
79
77
  returns (uint256[] memory indexes)
80
78
  {
@@ -122,7 +120,7 @@ abstract contract SYBaseWithRewards is SYBase, RewardManager {
122
120
  address from,
123
121
  address to,
124
122
  uint256
125
- ) internal virtual override whenNotPaused {
123
+ ) internal virtual override {
126
124
  _updateAndDistributeRewardsForTwo(from, to);
127
125
  }
128
126
  }
@@ -0,0 +1,184 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.17;
3
+
4
+ import "../../SYBase.sol";
5
+ import "../../../../interfaces/IApeStaking.sol";
6
+
7
+ contract PendleApeStakingSY is SYBase {
8
+ using Math for uint256;
9
+
10
+ uint256 public constant APE_COIN_POOL_ID = 0;
11
+ uint256 public constant MIN_APE_DEPOSIT = 10**18;
12
+ uint256 public constant EPOCH_LENGTH = 1 hours;
13
+
14
+ address public immutable apeStaking;
15
+ address public immutable apeCoin;
16
+
17
+ uint256 private lastRewardClaimedEpoch;
18
+
19
+ constructor(
20
+ string memory _name,
21
+ string memory _symbol,
22
+ address _apeCoin,
23
+ address _apeStaking
24
+ )
25
+ SYBase(_name, _symbol, _apeCoin)
26
+ {
27
+ apeStaking = _apeStaking;
28
+ apeCoin = _apeCoin;
29
+ lastRewardClaimedEpoch = _getCurrentEpochId();
30
+ _safeApproveInf(apeCoin, apeStaking);
31
+ }
32
+
33
+ function _deposit(address, uint256 amountDeposited)
34
+ internal
35
+ virtual
36
+ override
37
+ returns (uint256 amountSharesOut)
38
+ {
39
+ // Respecting APE's deposit invariant & prevent frontrunning on deployment
40
+ if (amountDeposited < MIN_APE_DEPOSIT) {
41
+ revert Errors.SYApeDepositAmountTooSmall(amountDeposited);
42
+ }
43
+
44
+ _harvestAndCompound();
45
+
46
+ // As SY Base is pulling the tokenIn first, the totalAsset should exclude user's deposit
47
+ uint256 priorTotalAssetOwned = getTotalAssetOwned() - amountDeposited;
48
+
49
+ if (totalSupply() == 0) {
50
+ amountSharesOut = amountDeposited;
51
+ } else {
52
+ // The upcoming calculation can be reduced to amountDeposited.divDown(exchangeRate())
53
+ // The following calculation is choosen instead to minimize precision error
54
+ amountSharesOut = (amountDeposited * totalSupply()) / priorTotalAssetOwned;
55
+ }
56
+ }
57
+
58
+ function _redeem(
59
+ address receiver,
60
+ address,
61
+ uint256 amountSharesToRedeem
62
+ ) internal virtual override returns (uint256 amountTokenOut) {
63
+ _harvestAndCompound();
64
+
65
+ // As SY is burned before calling _redeem(), we should account for priorSupply
66
+ uint256 priorTotalSupply = totalSupply() + amountSharesToRedeem;
67
+
68
+ if (amountSharesToRedeem == priorTotalSupply) {
69
+ amountTokenOut = getTotalAssetOwned();
70
+ } else {
71
+ // The upcoming calculation can be reduced to amountSharesToRedeem.mulDown(exchangeRate())
72
+ // The following calculation is choosen instead to minimize precision error
73
+ amountTokenOut = (amountSharesToRedeem * getTotalAssetOwned()) / priorTotalSupply;
74
+ }
75
+
76
+ // There might be case when the contract is holding < 1 APE reward and user is withdrawing everything out of it
77
+ if (amountTokenOut > _selfBalance(apeCoin)) {
78
+ IApeStaking(apeStaking).withdrawApeCoin(
79
+ amountTokenOut - _selfBalance(apeCoin),
80
+ address(this)
81
+ );
82
+ }
83
+ _transferOut(apeCoin, receiver, amountTokenOut);
84
+ }
85
+
86
+ function exchangeRate() public view virtual override returns (uint256) {
87
+ return getTotalAssetOwned().divDown(totalSupply());
88
+ }
89
+
90
+ /*///////////////////////////////////////////////////////////////
91
+ AUTOCOMPOUND FEATURE
92
+ //////////////////////////////////////////////////////////////*/
93
+
94
+ function harvestAndCompound() external {
95
+ _harvestAndCompound();
96
+ }
97
+
98
+ function getTotalAssetOwned() public view returns (uint256 totalAssetOwned) {
99
+ (uint256 stakedAmount, ) = IApeStaking(apeStaking).addressPosition(address(this));
100
+ uint256 unclaimedAmount = IApeStaking(apeStaking).pendingRewards(
101
+ APE_COIN_POOL_ID,
102
+ address(this),
103
+ 0
104
+ );
105
+ uint256 floatingAmount = _selfBalance(apeCoin);
106
+ totalAssetOwned = stakedAmount + unclaimedAmount + floatingAmount;
107
+ }
108
+
109
+ function _harvestAndCompound() internal {
110
+ // Claim reward
111
+ uint256 currentEpochId = _getCurrentEpochId();
112
+ if (currentEpochId != lastRewardClaimedEpoch) {
113
+ IApeStaking(apeStaking).claimSelfApeCoin();
114
+ lastRewardClaimedEpoch = currentEpochId;
115
+ }
116
+
117
+ // Deposit APE
118
+ uint256 amountAssetToCompound = _selfBalance(apeCoin);
119
+ if (amountAssetToCompound >= MIN_APE_DEPOSIT) {
120
+ IApeStaking(apeStaking).depositSelfApeCoin(amountAssetToCompound);
121
+ }
122
+ }
123
+
124
+ /*///////////////////////////////////////////////////////////////
125
+ MISC FUNCTIONS FOR METADATA
126
+ //////////////////////////////////////////////////////////////*/
127
+
128
+ function _previewDeposit(address, uint256 amountTokenToDeposit)
129
+ internal
130
+ view
131
+ override
132
+ returns (uint256 amountSharesOut)
133
+ {
134
+ if (totalSupply() == 0) {
135
+ amountSharesOut = amountTokenToDeposit;
136
+ } else {
137
+ amountSharesOut = (amountTokenToDeposit * totalSupply()) / getTotalAssetOwned();
138
+ }
139
+ }
140
+
141
+ function _previewRedeem(address, uint256 amountSharesToRedeem)
142
+ internal
143
+ view
144
+ override
145
+ returns (uint256 amountTokenOut)
146
+ {
147
+ amountTokenOut = (amountSharesToRedeem * getTotalAssetOwned()) / totalSupply();
148
+ }
149
+
150
+
151
+ function _getCurrentEpochId() private view returns (uint256) {
152
+ return block.timestamp / EPOCH_LENGTH;
153
+ }
154
+
155
+ function getTokensIn() public view virtual override returns (address[] memory res) {
156
+ res = new address[](1);
157
+ res[0] = apeCoin;
158
+ }
159
+
160
+ function getTokensOut() public view virtual override returns (address[] memory res) {
161
+ res = new address[](1);
162
+ res[0] = apeCoin;
163
+ }
164
+
165
+ function isValidTokenIn(address token) public view virtual override returns (bool) {
166
+ return token == apeCoin;
167
+ }
168
+
169
+ function isValidTokenOut(address token) public view virtual override returns (bool) {
170
+ return token == apeCoin;
171
+ }
172
+
173
+ function assetInfo()
174
+ external
175
+ view
176
+ returns (
177
+ AssetType assetType,
178
+ address assetAddress,
179
+ uint8 assetDecimals
180
+ )
181
+ {
182
+ return (AssetType.TOKEN, apeCoin, IERC20Metadata(apeCoin).decimals());
183
+ }
184
+ }
@@ -111,6 +111,8 @@ library Errors {
111
111
  error SYCurveInvalidPid();
112
112
  error SYCurve3crvPoolNotFound();
113
113
 
114
+ error SYApeDepositAmountTooSmall(uint256 amountDeposited);
115
+
114
116
  // Liquidity Mining
115
117
  error VCInactivePool(address pool);
116
118
  error VCPoolAlreadyActive(address pool);
@@ -0,0 +1,30 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+
3
+ pragma solidity 0.8.17;
4
+
5
+ interface IApeStaking {
6
+ function apeCoin() external view returns (address);
7
+
8
+ function depositSelfApeCoin(uint256 _amount) external;
9
+
10
+ function withdrawApeCoin(uint256 _amount, address _recipient) external;
11
+
12
+ function claimSelfApeCoin() external;
13
+
14
+ /**
15
+ * @notice when poolId is set to 0, tokenId's value does not matter
16
+ */
17
+ function pendingRewards(
18
+ uint256 _poolId,
19
+ address _address,
20
+ uint256 _tokenId
21
+ ) external view returns (uint256);
22
+
23
+ function addressPosition(address addr)
24
+ external
25
+ view
26
+ returns (uint256 stakedAmount, int256 rewardsDebt);
27
+
28
+ // for SDK
29
+ function pools(uint256 id) external view returns (uint48, uint16, uint96 totalStaked, uint96);
30
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "sAPE",
3
+ "SY": "0xDE080bEeB90e62F61936C113Fb46E62aa766cF1f",
4
+ "YT": "0x6537939Ec3e9da193D234A36bC5664B3cA570bc8",
5
+ "PT": "0x1432364a6a56d30810087fbD2ed197e609451299",
6
+ "market": "0x94B81B4cF70849E994f17b872C0e8E448443aE9b",
7
+ "expiry": 1680134400,
8
+ "scalarRoot": "2200000000000000000",
9
+ "initAnchor": "1151500000000000000"
10
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pendle/core-v2",
3
3
  "description": "Core smart contracts of Pendle Protocol.",
4
4
  "license": "BUSL-1.1",
5
- "version": "0.17.6-testnet",
5
+ "version": "0.17.8-testnet",
6
6
  "homepage": "https://pendle.finance",
7
7
  "keywords": [
8
8
  "pendle",
@@ -30,6 +30,7 @@ export interface IApeStakingInterface extends utils.Interface {
30
30
  "claimSelfApeCoin()": FunctionFragment;
31
31
  "depositSelfApeCoin(uint256)": FunctionFragment;
32
32
  "pendingRewards(uint256,address,uint256)": FunctionFragment;
33
+ "pools(uint256)": FunctionFragment;
33
34
  "withdrawApeCoin(uint256,address)": FunctionFragment;
34
35
  };
35
36
 
@@ -50,6 +51,7 @@ export interface IApeStakingInterface extends utils.Interface {
50
51
  functionFragment: "pendingRewards",
51
52
  values: [BigNumberish, string, BigNumberish]
52
53
  ): string;
54
+ encodeFunctionData(functionFragment: "pools", values: [BigNumberish]): string;
53
55
  encodeFunctionData(
54
56
  functionFragment: "withdrawApeCoin",
55
57
  values: [BigNumberish, string]
@@ -72,6 +74,7 @@ export interface IApeStakingInterface extends utils.Interface {
72
74
  functionFragment: "pendingRewards",
73
75
  data: BytesLike
74
76
  ): Result;
77
+ decodeFunctionResult(functionFragment: "pools", data: BytesLike): Result;
75
78
  decodeFunctionResult(
76
79
  functionFragment: "withdrawApeCoin",
77
80
  data: BytesLike
@@ -136,6 +139,13 @@ export interface IApeStaking extends BaseContract {
136
139
  overrides?: CallOverrides
137
140
  ): Promise<[BigNumber]>;
138
141
 
142
+ pools(
143
+ id: BigNumberish,
144
+ overrides?: CallOverrides
145
+ ): Promise<
146
+ [number, number, BigNumber, BigNumber] & { totalStaked: BigNumber }
147
+ >;
148
+
139
149
  withdrawApeCoin(
140
150
  _amount: BigNumberish,
141
151
  _recipient: string,
@@ -168,6 +178,13 @@ export interface IApeStaking extends BaseContract {
168
178
  overrides?: CallOverrides
169
179
  ): Promise<BigNumber>;
170
180
 
181
+ pools(
182
+ id: BigNumberish,
183
+ overrides?: CallOverrides
184
+ ): Promise<
185
+ [number, number, BigNumber, BigNumber] & { totalStaked: BigNumber }
186
+ >;
187
+
171
188
  withdrawApeCoin(
172
189
  _amount: BigNumberish,
173
190
  _recipient: string,
@@ -201,6 +218,13 @@ export interface IApeStaking extends BaseContract {
201
218
  overrides?: CallOverrides
202
219
  ): Promise<BigNumber>;
203
220
 
221
+ pools(
222
+ id: BigNumberish,
223
+ overrides?: CallOverrides
224
+ ): Promise<
225
+ [number, number, BigNumber, BigNumber] & { totalStaked: BigNumber }
226
+ >;
227
+
204
228
  withdrawApeCoin(
205
229
  _amount: BigNumberish,
206
230
  _recipient: string,
@@ -234,6 +258,8 @@ export interface IApeStaking extends BaseContract {
234
258
  overrides?: CallOverrides
235
259
  ): Promise<BigNumber>;
236
260
 
261
+ pools(id: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>;
262
+
237
263
  withdrawApeCoin(
238
264
  _amount: BigNumberish,
239
265
  _recipient: string,
@@ -265,6 +291,11 @@ export interface IApeStaking extends BaseContract {
265
291
  overrides?: CallOverrides
266
292
  ): Promise<PopulatedTransaction>;
267
293
 
294
+ pools(
295
+ id: BigNumberish,
296
+ overrides?: CallOverrides
297
+ ): Promise<PopulatedTransaction>;
298
+
268
299
  withdrawApeCoin(
269
300
  _amount: BigNumberish,
270
301
  _recipient: string,