@pendle/core-v2 0.11.9-testnet → 0.11.11-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 (147) hide show
  1. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +1 -1
  2. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +1 -1
  3. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.dbg.json +1 -1
  4. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  5. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
  6. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.dbg.json +1 -1
  7. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.dbg.json +1 -1
  8. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.dbg.json +1 -1
  9. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.dbg.json +1 -1
  10. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +1 -1
  11. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultSCY.sol/PendleYearnVaultSCY.dbg.json +1 -1
  12. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.dbg.json +1 -1
  13. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
  14. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
  15. package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.dbg.json +1 -1
  16. package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.dbg.json +1 -1
  17. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  18. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  19. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  20. package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  21. package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  22. package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  23. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  24. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
  25. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  26. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  27. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  28. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  29. package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  30. package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.json +2 -2
  31. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  32. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  33. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  34. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  35. package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  36. package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +4 -4
  37. package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  38. package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.json +2 -2
  39. package/build/artifacts/contracts/core/actions/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  40. package/build/artifacts/contracts/core/actions/ActionMintRedeem.sol/ActionMintRedeem.json +9 -4
  41. package/build/artifacts/contracts/core/actions/ActionMisc.sol/ActionMisc.dbg.json +1 -1
  42. package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  43. package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.json +2 -2
  44. package/build/artifacts/contracts/core/actions/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/actions/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
  46. package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.json +2 -2
  48. package/build/artifacts/contracts/core/actions/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  49. package/build/artifacts/contracts/core/actions/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
  50. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  51. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  52. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +5 -0
  53. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  54. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
  55. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  56. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  57. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +5 -0
  58. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  59. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  60. package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.dbg.json +1 -1
  61. package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.json +93 -0
  62. package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
  63. package/build/artifacts/contracts/libraries/OracleLib.sol/OracleLib.dbg.json +1 -1
  64. package/build/artifacts/contracts/libraries/RewardManager.sol/RewardManager.dbg.json +1 -1
  65. package/build/artifacts/contracts/libraries/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  66. package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  67. package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  68. package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.dbg.json +1 -1
  69. package/build/artifacts/contracts/libraries/helpers/PYIndex.sol/PYIndexLib.dbg.json +1 -1
  70. package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +1 -1
  71. package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
  72. package/build/artifacts/contracts/libraries/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
  73. package/build/artifacts/contracts/libraries/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
  74. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  75. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  76. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  77. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  78. package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  79. package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
  80. package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.dbg.json +1 -1
  81. package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.dbg.json +1 -1
  82. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
  83. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -2
  84. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  85. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +120 -60
  86. package/build/artifacts/contracts/offchain-helpers/SSTORE2DeployerContract.sol/SSTORE2DeployerContract.dbg.json +1 -1
  87. package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +6 -1
  88. package/contracts/core/PendleRouter.sol +2 -1
  89. package/contracts/core/actions/ActionAddRemoveLiq.sol +23 -2
  90. package/contracts/core/actions/ActionMintRedeem.sol +4 -0
  91. package/contracts/interfaces/IPActionMintRedeem.sol +1 -0
  92. package/contracts/interfaces/IPVotingEscrow.sol +1 -1
  93. package/contracts/libraries/math/MarketApproxLib.sol +1 -0
  94. package/contracts/offchain-helpers/MarketMathStatic.sol +16 -8
  95. package/contracts/offchain-helpers/RouterStatic.sol +52 -3
  96. package/package.json +1 -1
  97. package/typechain-types/ActionMintRedeem.ts +9 -2
  98. package/typechain-types/Errors.ts +57 -0
  99. package/typechain-types/ICrvPool.ts +137 -22
  100. package/typechain-types/IPActionMintRedeem.ts +9 -2
  101. package/typechain-types/IPAllAction.ts +9 -2
  102. package/typechain-types/IPBatchSeller.ts +252 -0
  103. package/typechain-types/IPVotingEscrow.ts +131 -0
  104. package/typechain-types/IPVotingEscrowMainchain.ts +461 -0
  105. package/typechain-types/IRewards.ts +25 -10
  106. package/typechain-types/Pendle3CrvAndTokenSCY.ts +1215 -0
  107. package/typechain-types/Pendle3CrvTokenSCY.ts +85 -185
  108. package/typechain-types/PendleBatchSeller.ts +626 -0
  109. package/typechain-types/PendleConvexCurveLP2PoolSCY.ts +185 -220
  110. package/typechain-types/PendleConvexCurveLPSCY.ts +159 -182
  111. package/typechain-types/PendleCvxCRVSCY.ts +0 -34
  112. package/typechain-types/PendleFeeDistributorFactory.ts +97 -8
  113. package/typechain-types/PtAMMArb.ts +587 -0
  114. package/typechain-types/RouterStatic.ts +82 -0
  115. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
  116. package/typechain-types/factories/ActionCallback__factory.ts +1 -1
  117. package/typechain-types/factories/ActionMintRedeem__factory.ts +6 -1
  118. package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
  119. package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
  120. package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
  121. package/typechain-types/factories/Errors__factory.ts +933 -0
  122. package/typechain-types/factories/ICrvPool__factory.ts +85 -12
  123. package/typechain-types/factories/IPActionMintRedeem__factory.ts +5 -0
  124. package/typechain-types/factories/IPAllAction__factory.ts +5 -0
  125. package/typechain-types/factories/IPBatchSeller__factory.ts +138 -0
  126. package/typechain-types/factories/IPVotingEscrowMainchain__factory.ts +340 -0
  127. package/typechain-types/factories/IPVotingEscrow__factory.ts +93 -0
  128. package/typechain-types/factories/IRewards__factory.ts +14 -1
  129. package/typechain-types/factories/MarketMathStatic__factory.ts +1 -1
  130. package/typechain-types/factories/Pendle3CrvAndTokenSCY__factory.ts +1130 -0
  131. package/typechain-types/factories/Pendle3CrvHelper__factory.ts +1 -1
  132. package/typechain-types/factories/Pendle3CrvTokenSCY__factory.ts +74 -128
  133. package/typechain-types/factories/PendleBatchSeller__factory.ts +558 -0
  134. package/typechain-types/factories/PendleConvexCurveLP2PoolSCY__factory.ts +207 -136
  135. package/typechain-types/factories/PendleConvexCurveLPSCY__factory.ts +170 -95
  136. package/typechain-types/factories/PendleCvxCRVSCY__factory.ts +1 -29
  137. package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +97 -8
  138. package/typechain-types/factories/PendleFeeDistributor__factory.ts +6 -1
  139. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +17 -1
  140. package/typechain-types/factories/PendleMsgReceiverAppUpg__factory.ts +11 -0
  141. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +6 -1
  142. package/typechain-types/factories/PendleRouter__factory.ts +1 -1
  143. package/typechain-types/factories/PtAMMArb__factory.ts +525 -0
  144. package/typechain-types/factories/RouterStatic__factory.ts +65 -1
  145. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
  146. package/typechain-types/hardhat.d.ts +261 -0
  147. package/typechain-types/index.ts +58 -0
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/20ebeca750412294184becd43b05ac5c.json"
3
+ "buildInfo": "../../../build-info/a07e513bae360be1bd8f008a37b5e555.json"
4
4
  }
@@ -119,7 +119,12 @@ contract VotingEscrowPendleMainchain is IPVotingEscrow, VotingEscrowTokenBase, C
119
119
  * @dev state changes expected:
120
120
  - _totalSupply & lastSlopeChangeAppliedAt is updated
121
121
  */
122
- function totalSupplyCurrent() public virtual override returns (uint128) {
122
+ function totalSupplyCurrent()
123
+ public
124
+ virtual
125
+ override(IPVeToken, VotingEscrowTokenBase)
126
+ returns (uint128)
127
+ {
123
128
  (VeBalance memory supply, ) = _applySlopeChange();
124
129
  return supply.getCurrentValue();
125
130
  }
@@ -51,7 +51,8 @@ contract PendleRouter is Proxy, Initializable, UUPSUpgradeable, BoringOwnableUpg
51
51
  sig == IPActionMintRedeem.redeemPyToToken.selector ||
52
52
  sig == IPActionMintRedeem.mintPyFromScy.selector ||
53
53
  sig == IPActionMintRedeem.redeemPyToScy.selector ||
54
- sig == IPActionMintRedeem.redeemDueInterestAndRewards.selector
54
+ sig == IPActionMintRedeem.redeemDueInterestAndRewards.selector ||
55
+ sig == IPActionMintRedeem.redeemDueInterestAndRewardsThenSwapAll.selector
55
56
  ) {
56
57
  return ACTION_MINT_REDEEM;
57
58
  } else if (
@@ -369,6 +369,29 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
369
369
  address market,
370
370
  uint256 netLpToRemove,
371
371
  uint256 minScyOut
372
+ ) internal returns (uint256 netScyOut) {
373
+ if (IPMarket(market).isExpired()) {
374
+ netScyOut = __removeLpToScyAfterExpiry(receiver, market, netLpToRemove);
375
+ } else {
376
+ netScyOut = __removeLpToScyBeforeExpiry(receiver, market, netLpToRemove);
377
+ }
378
+ require(netScyOut >= minScyOut, "insufficient lp out");
379
+ }
380
+
381
+ function __removeLpToScyAfterExpiry(
382
+ address receiver,
383
+ address market,
384
+ uint256 netLpToRemove
385
+ ) internal returns (uint256 netScyOut) {
386
+ (, , IPYieldToken YT) = IPMarket(market).readTokens();
387
+ (uint256 scyFromBurn, ) = IPMarket(market).burn(receiver, address(YT), netLpToRemove);
388
+ netScyOut = scyFromBurn + IPYieldToken(YT).redeemPY(receiver);
389
+ }
390
+
391
+ function __removeLpToScyBeforeExpiry(
392
+ address receiver,
393
+ address market,
394
+ uint256 netLpToRemove
372
395
  ) internal returns (uint256 netScyOut) {
373
396
  (uint256 scyFromBurn, uint256 ptFromBurn) = IPMarket(market).burn(
374
397
  receiver,
@@ -380,8 +403,6 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
380
403
  ptFromBurn,
381
404
  EMPTY_BYTES
382
405
  );
383
-
384
- require(scyFromBurn + scyFromSwap >= minScyOut, "insufficient lp out");
385
406
  netScyOut = scyFromBurn + scyFromSwap;
386
407
  }
387
408
  }
@@ -187,6 +187,10 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
187
187
 
188
188
  // now swap all to outputToken
189
189
  netTokenOut = _swapAllToOutputToken(tokensOut, dataSwap);
190
+
191
+ if (netTokenOut < dataSwap.minTokenOut)
192
+ require(netTokenOut < dataSwap.minTokenOut, "Insufficient Token Out");
193
+
190
194
  amountsSwapped = tokensOut.amounts;
191
195
 
192
196
  emit RedeemDueInterestAndRewardsThenSwapAll(
@@ -147,6 +147,7 @@ interface IPActionMintRedeem {
147
147
  bytes[] kybercalls;
148
148
  //
149
149
  address outputToken;
150
+ uint256 minTokenOut;
150
151
  }
151
152
 
152
153
  function redeemDueInterestAndRewardsThenSwapAll(
@@ -5,7 +5,7 @@ pragma solidity 0.8.15;
5
5
  import "./IPVeToken.sol";
6
6
  import "../libraries/VeBalanceLib.sol";
7
7
 
8
- interface IPVotingEscrow {
8
+ interface IPVotingEscrow is IPVeToken {
9
9
  event NewLockPosition(address indexed user, uint128 amount, uint128 expiry);
10
10
 
11
11
  event Withdraw(address indexed user, uint128 amount);
@@ -318,6 +318,7 @@ library MarketApproxPtInLib {
318
318
 
319
319
  uint256 netPtPayable = netAssetOut + arg.maxPtIn;
320
320
  if (guess <= netPtPayable) {
321
+ p.guessMin = guess;
321
322
  uint256 netPtIn = guess - netAssetOut; // guess >= netAssetOut (market invariant)
322
323
  if (Math.isASmallerApproxB(netPtIn, arg.maxPtIn, p.eps)) {
323
324
  return (netAssetOut, netPtIn, guess, arg.index.assetToScy(netAssetToReserve));
@@ -233,15 +233,22 @@ library MarketMathStatic {
233
233
  MarketState memory state = IPMarket(market).readState();
234
234
 
235
235
  (uint256 scyFromBurn, uint256 ptFromBurn) = state.removeLiquidity(lpToRemove);
236
- uint256 scyFromSwap;
237
- (scyFromSwap, netScyFee) = state.swapExactPtForScy(
238
- pyIndex(market),
239
- ptFromBurn,
240
- block.timestamp
241
- );
242
236
 
243
- netScyOut = scyFromBurn + scyFromSwap;
244
- priceImpact = calcPriceImpact(market, ptFromBurn.neg());
237
+ if (IPMarket(market).isExpired()) {
238
+ (,, IPYieldToken YT) = IPMarket(market).readTokens();
239
+ PYIndex index = PYIndex.wrap(YT.pyIndexCurrent());
240
+ netScyOut = scyFromBurn + index.assetToScy(ptFromBurn);
241
+ } else {
242
+ uint256 scyFromSwap;
243
+ (scyFromSwap, netScyFee) = state.swapExactPtForScy(
244
+ pyIndex(market),
245
+ ptFromBurn,
246
+ block.timestamp
247
+ );
248
+
249
+ netScyOut = scyFromBurn + scyFromSwap;
250
+ priceImpact = calcPriceImpact(market, ptFromBurn.neg());
251
+ }
245
252
  }
246
253
 
247
254
  function removeLiquiditySingleBaseTokenStatic(
@@ -596,6 +603,7 @@ library MarketMathStatic {
596
603
  public
597
604
  returns (uint256)
598
605
  {
606
+ if (IPMarket(market).isExpired()) return Math.ONE;
599
607
  int256 netPtToAccount = netPtOut;
600
608
  MarketState memory state = IPMarket(market).readState();
601
609
  MarketPreCompute memory comp = state.getMarketPreCompute(pyIndex(market), block.timestamp);
@@ -3,14 +3,22 @@ pragma solidity 0.8.15;
3
3
 
4
4
  import "../interfaces/IPYieldContractFactory.sol";
5
5
  import "../interfaces/IPMarketFactory.sol";
6
+ import "../interfaces/IPVotingEscrow.sol";
7
+ import "../periphery/BoringOwnableUpgradeable.sol";
6
8
  import "./MarketMathStatic.sol";
7
9
  import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
8
10
  import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
9
11
  import "../periphery/BoringOwnableUpgradeable.sol";
12
+ import "../libraries/math/WeekMath.sol";
10
13
 
11
14
  /// EXCLUDED FROM ALL AUDITS, TO BE CALLED ONLY BY PENDLE's SDK
12
15
  contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeable {
13
16
  using Math for uint256;
17
+ using VeBalanceLib for VeBalance;
18
+ using VeBalanceLib for LockedPosition;
19
+
20
+ uint128 public constant MAX_LOCK_TIME = 104 weeks;
21
+ uint128 public constant MIN_LOCK_TIME = 1 weeks;
14
22
 
15
23
  struct TokenAmount {
16
24
  address token;
@@ -47,12 +55,16 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
47
55
 
48
56
  IPYieldContractFactory internal immutable yieldContractFactory;
49
57
  IPMarketFactory internal immutable marketFactory;
58
+ IPVotingEscrow internal immutable vePENDLE;
50
59
 
51
- constructor(IPYieldContractFactory _yieldContractFactory, IPMarketFactory _marketFactory)
52
- initializer
53
- {
60
+ constructor(
61
+ IPYieldContractFactory _yieldContractFactory,
62
+ IPMarketFactory _marketFactory,
63
+ IPVotingEscrow _vePENDLE
64
+ ) initializer {
54
65
  yieldContractFactory = _yieldContractFactory;
55
66
  marketFactory = _marketFactory;
67
+ vePENDLE = _vePENDLE;
56
68
  }
57
69
 
58
70
  function initialize() external initializer {
@@ -594,6 +606,43 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
594
606
  return MarketMathStatic.swapExactYtForPt(market, exactYtIn, getDefaultApproxParams());
595
607
  }
596
608
 
609
+ // ============= vePENDLE =============
610
+
611
+ function increaseLockPositionStatic(
612
+ address user,
613
+ uint128 additionalAmountToLock,
614
+ uint128 newExpiry
615
+ ) external view returns (uint128 newVeBalance) {
616
+ require(
617
+ WeekMath.isValidWTime(newExpiry) && !MiniHelpers.isTimeInThePast(newExpiry),
618
+ "invalid newExpiry"
619
+ );
620
+
621
+ require(newExpiry <= block.timestamp + MAX_LOCK_TIME, "max lock time exceeded");
622
+ require(newExpiry >= block.timestamp + MIN_LOCK_TIME, "insufficient lock time");
623
+
624
+ LockedPosition memory oldPosition;
625
+
626
+ {
627
+ (uint128 amount, uint128 expiry) = vePENDLE.positionData(user);
628
+ oldPosition = LockedPosition(amount, expiry);
629
+ }
630
+
631
+ require(oldPosition.expiry <= newExpiry, "new expiry must be after current expiry");
632
+ uint128 newTotalAmountLocked = additionalAmountToLock + oldPosition.amount;
633
+ require(newTotalAmountLocked > 0, "zero total amount locked");
634
+
635
+ uint128 additionalDurationToLock = newExpiry - oldPosition.expiry;
636
+
637
+ LockedPosition memory newPosition = LockedPosition(
638
+ oldPosition.amount + additionalAmountToLock,
639
+ oldPosition.expiry + additionalDurationToLock
640
+ );
641
+
642
+ VeBalance memory newBalance = newPosition.convertToVeBalance();
643
+ return newBalance.getCurrentValue();
644
+ }
645
+
597
646
  // ============= OTHER HELPERS =============
598
647
 
599
648
  function mintPYFromScyStatic(address YT, uint256 amountScyToMint)
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.11.9-testnet",
5
+ "version": "0.11.11-testnet",
6
6
  "homepage": "https://pendle.finance",
7
7
  "keywords": [
8
8
  "pendle",
@@ -68,12 +68,19 @@ export declare namespace IPActionMintRedeem {
68
68
  tokens: string[];
69
69
  kybercalls: BytesLike[];
70
70
  outputToken: string;
71
+ minTokenOut: BigNumberish;
71
72
  };
72
73
 
73
- export type RouterSwapAllStructStructOutput = [string[], string[], string] & {
74
+ export type RouterSwapAllStructStructOutput = [
75
+ string[],
76
+ string[],
77
+ string,
78
+ BigNumber
79
+ ] & {
74
80
  tokens: string[];
75
81
  kybercalls: string[];
76
82
  outputToken: string;
83
+ minTokenOut: BigNumber;
77
84
  };
78
85
  }
79
86
 
@@ -85,7 +92,7 @@ export interface ActionMintRedeemInterface extends utils.Interface {
85
92
  "mintPyFromToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;
86
93
  "mintScyFromToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;
87
94
  "redeemDueInterestAndRewards(address,address[],address[],address[])": FunctionFragment;
88
- "redeemDueInterestAndRewardsThenSwapAll(address[],(address[],address[],address[]),address[],(address[],bytes[],address))": FunctionFragment;
95
+ "redeemDueInterestAndRewardsThenSwapAll(address[],(address[],address[],address[]),address[],(address[],bytes[],address,uint256))": FunctionFragment;
89
96
  "redeemPyToScy(address,address,uint256,uint256)": FunctionFragment;
90
97
  "redeemPyToToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;
91
98
  "redeemScyToToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;
@@ -0,0 +1,57 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ import { BaseContract, Signer, utils } from "ethers";
5
+
6
+ import { Listener, Provider } from "@ethersproject/providers";
7
+ import type {
8
+ TypedEventFilter,
9
+ TypedEvent,
10
+ TypedListener,
11
+ OnEvent,
12
+ } from "./common";
13
+
14
+ export interface ErrorsInterface extends utils.Interface {
15
+ contractName: "Errors";
16
+ functions: {};
17
+
18
+ events: {};
19
+ }
20
+
21
+ export interface Errors extends BaseContract {
22
+ contractName: "Errors";
23
+ connect(signerOrProvider: Signer | Provider | string): this;
24
+ attach(addressOrName: string): this;
25
+ deployed(): Promise<this>;
26
+
27
+ interface: ErrorsInterface;
28
+
29
+ queryFilter<TEvent extends TypedEvent>(
30
+ event: TypedEventFilter<TEvent>,
31
+ fromBlockOrBlockhash?: string | number | undefined,
32
+ toBlock?: string | number | undefined
33
+ ): Promise<Array<TEvent>>;
34
+
35
+ listeners<TEvent extends TypedEvent>(
36
+ eventFilter?: TypedEventFilter<TEvent>
37
+ ): Array<TypedListener<TEvent>>;
38
+ listeners(eventName?: string): Array<Listener>;
39
+ removeAllListeners<TEvent extends TypedEvent>(
40
+ eventFilter: TypedEventFilter<TEvent>
41
+ ): this;
42
+ removeAllListeners(eventName?: string): this;
43
+ off: OnEvent<this>;
44
+ on: OnEvent<this>;
45
+ once: OnEvent<this>;
46
+ removeListener: OnEvent<this>;
47
+
48
+ functions: {};
49
+
50
+ callStatic: {};
51
+
52
+ filters: {};
53
+
54
+ estimateGas: {};
55
+
56
+ populateTransaction: {};
57
+ }
@@ -25,23 +25,23 @@ import type {
25
25
  export interface ICrvPoolInterface extends utils.Interface {
26
26
  contractName: "ICrvPool";
27
27
  functions: {
28
- "add_liquidity(uint256[],uint256,address)": FunctionFragment;
29
- "calc_token_amount(uint256[],bool)": FunctionFragment;
28
+ "add_liquidity(uint256[2],uint256)": FunctionFragment;
29
+ "calc_token_amount(uint256[3],bool)": FunctionFragment;
30
30
  "calc_withdraw_one_coin(uint256,int128)": FunctionFragment;
31
31
  "exchange(int128,int128,uint256,uint256,address)": FunctionFragment;
32
32
  "get_dy(int128,int128,uint256)": FunctionFragment;
33
33
  "get_virtual_price()": FunctionFragment;
34
34
  "remove_liquidity(uint256,uint256[],address)": FunctionFragment;
35
- "remove_liquidity_one_coin(uint256,int128,uint256,address)": FunctionFragment;
35
+ "remove_liquidity_one_coin(uint256,int128,uint256)": FunctionFragment;
36
36
  };
37
37
 
38
38
  encodeFunctionData(
39
39
  functionFragment: "add_liquidity",
40
- values: [BigNumberish[], BigNumberish, string]
40
+ values: [[BigNumberish, BigNumberish], BigNumberish]
41
41
  ): string;
42
42
  encodeFunctionData(
43
43
  functionFragment: "calc_token_amount",
44
- values: [BigNumberish[], boolean]
44
+ values: [[BigNumberish, BigNumberish, BigNumberish], boolean]
45
45
  ): string;
46
46
  encodeFunctionData(
47
47
  functionFragment: "calc_withdraw_one_coin",
@@ -65,7 +65,7 @@ export interface ICrvPoolInterface extends utils.Interface {
65
65
  ): string;
66
66
  encodeFunctionData(
67
67
  functionFragment: "remove_liquidity_one_coin",
68
- values: [BigNumberish, BigNumberish, BigNumberish, string]
68
+ values: [BigNumberish, BigNumberish, BigNumberish]
69
69
  ): string;
70
70
 
71
71
  decodeFunctionResult(
@@ -126,19 +126,43 @@ export interface ICrvPool extends BaseContract {
126
126
  removeListener: OnEvent<this>;
127
127
 
128
128
  functions: {
129
- add_liquidity(
129
+ "add_liquidity(uint256[2],uint256)"(
130
+ _deposit_amount: [BigNumberish, BigNumberish],
131
+ _min_amount: BigNumberish,
132
+ overrides?: Overrides & { from?: string | Promise<string> }
133
+ ): Promise<ContractTransaction>;
134
+
135
+ "add_liquidity(uint256[3],uint256)"(
136
+ _deposit_amount: [BigNumberish, BigNumberish, BigNumberish],
137
+ _min_amount: BigNumberish,
138
+ overrides?: Overrides & { from?: string | Promise<string> }
139
+ ): Promise<ContractTransaction>;
140
+
141
+ "add_liquidity(uint256[],uint256,address)"(
130
142
  _deposit_amount: BigNumberish[],
131
143
  _min_amount: BigNumberish,
132
144
  _receiver: string,
133
145
  overrides?: Overrides & { from?: string | Promise<string> }
134
146
  ): Promise<ContractTransaction>;
135
147
 
136
- calc_token_amount(
148
+ "calc_token_amount(uint256[3],bool)"(
149
+ _amounts: [BigNumberish, BigNumberish, BigNumberish],
150
+ _is_deposit: boolean,
151
+ overrides?: CallOverrides
152
+ ): Promise<[BigNumber]>;
153
+
154
+ "calc_token_amount(uint256[],bool)"(
137
155
  _amounts: BigNumberish[],
138
156
  _is_deposit: boolean,
139
157
  overrides?: CallOverrides
140
158
  ): Promise<[BigNumber]>;
141
159
 
160
+ "calc_token_amount(uint256[2],bool)"(
161
+ _amounts: [BigNumberish, BigNumberish],
162
+ _is_deposit: boolean,
163
+ overrides?: CallOverrides
164
+ ): Promise<[BigNumber]>;
165
+
142
166
  calc_withdraw_one_coin(
143
167
  _burn_amount: BigNumberish,
144
168
  i: BigNumberish,
@@ -174,24 +198,47 @@ export interface ICrvPool extends BaseContract {
174
198
  _burn_amount: BigNumberish,
175
199
  i: BigNumberish,
176
200
  _min_amount: BigNumberish,
177
- _receiver: string,
178
201
  overrides?: Overrides & { from?: string | Promise<string> }
179
202
  ): Promise<ContractTransaction>;
180
203
  };
181
204
 
182
- add_liquidity(
205
+ "add_liquidity(uint256[2],uint256)"(
206
+ _deposit_amount: [BigNumberish, BigNumberish],
207
+ _min_amount: BigNumberish,
208
+ overrides?: Overrides & { from?: string | Promise<string> }
209
+ ): Promise<ContractTransaction>;
210
+
211
+ "add_liquidity(uint256[3],uint256)"(
212
+ _deposit_amount: [BigNumberish, BigNumberish, BigNumberish],
213
+ _min_amount: BigNumberish,
214
+ overrides?: Overrides & { from?: string | Promise<string> }
215
+ ): Promise<ContractTransaction>;
216
+
217
+ "add_liquidity(uint256[],uint256,address)"(
183
218
  _deposit_amount: BigNumberish[],
184
219
  _min_amount: BigNumberish,
185
220
  _receiver: string,
186
221
  overrides?: Overrides & { from?: string | Promise<string> }
187
222
  ): Promise<ContractTransaction>;
188
223
 
189
- calc_token_amount(
224
+ "calc_token_amount(uint256[3],bool)"(
225
+ _amounts: [BigNumberish, BigNumberish, BigNumberish],
226
+ _is_deposit: boolean,
227
+ overrides?: CallOverrides
228
+ ): Promise<BigNumber>;
229
+
230
+ "calc_token_amount(uint256[],bool)"(
190
231
  _amounts: BigNumberish[],
191
232
  _is_deposit: boolean,
192
233
  overrides?: CallOverrides
193
234
  ): Promise<BigNumber>;
194
235
 
236
+ "calc_token_amount(uint256[2],bool)"(
237
+ _amounts: [BigNumberish, BigNumberish],
238
+ _is_deposit: boolean,
239
+ overrides?: CallOverrides
240
+ ): Promise<BigNumber>;
241
+
195
242
  calc_withdraw_one_coin(
196
243
  _burn_amount: BigNumberish,
197
244
  i: BigNumberish,
@@ -227,24 +274,47 @@ export interface ICrvPool extends BaseContract {
227
274
  _burn_amount: BigNumberish,
228
275
  i: BigNumberish,
229
276
  _min_amount: BigNumberish,
230
- _receiver: string,
231
277
  overrides?: Overrides & { from?: string | Promise<string> }
232
278
  ): Promise<ContractTransaction>;
233
279
 
234
280
  callStatic: {
235
- add_liquidity(
281
+ "add_liquidity(uint256[2],uint256)"(
282
+ _deposit_amount: [BigNumberish, BigNumberish],
283
+ _min_amount: BigNumberish,
284
+ overrides?: CallOverrides
285
+ ): Promise<void>;
286
+
287
+ "add_liquidity(uint256[3],uint256)"(
288
+ _deposit_amount: [BigNumberish, BigNumberish, BigNumberish],
289
+ _min_amount: BigNumberish,
290
+ overrides?: CallOverrides
291
+ ): Promise<void>;
292
+
293
+ "add_liquidity(uint256[],uint256,address)"(
236
294
  _deposit_amount: BigNumberish[],
237
295
  _min_amount: BigNumberish,
238
296
  _receiver: string,
239
297
  overrides?: CallOverrides
240
298
  ): Promise<BigNumber>;
241
299
 
242
- calc_token_amount(
300
+ "calc_token_amount(uint256[3],bool)"(
301
+ _amounts: [BigNumberish, BigNumberish, BigNumberish],
302
+ _is_deposit: boolean,
303
+ overrides?: CallOverrides
304
+ ): Promise<BigNumber>;
305
+
306
+ "calc_token_amount(uint256[],bool)"(
243
307
  _amounts: BigNumberish[],
244
308
  _is_deposit: boolean,
245
309
  overrides?: CallOverrides
246
310
  ): Promise<BigNumber>;
247
311
 
312
+ "calc_token_amount(uint256[2],bool)"(
313
+ _amounts: [BigNumberish, BigNumberish],
314
+ _is_deposit: boolean,
315
+ overrides?: CallOverrides
316
+ ): Promise<BigNumber>;
317
+
248
318
  calc_withdraw_one_coin(
249
319
  _burn_amount: BigNumberish,
250
320
  i: BigNumberish,
@@ -280,27 +350,50 @@ export interface ICrvPool extends BaseContract {
280
350
  _burn_amount: BigNumberish,
281
351
  i: BigNumberish,
282
352
  _min_amount: BigNumberish,
283
- _receiver: string,
284
353
  overrides?: CallOverrides
285
- ): Promise<BigNumber>;
354
+ ): Promise<void>;
286
355
  };
287
356
 
288
357
  filters: {};
289
358
 
290
359
  estimateGas: {
291
- add_liquidity(
360
+ "add_liquidity(uint256[2],uint256)"(
361
+ _deposit_amount: [BigNumberish, BigNumberish],
362
+ _min_amount: BigNumberish,
363
+ overrides?: Overrides & { from?: string | Promise<string> }
364
+ ): Promise<BigNumber>;
365
+
366
+ "add_liquidity(uint256[3],uint256)"(
367
+ _deposit_amount: [BigNumberish, BigNumberish, BigNumberish],
368
+ _min_amount: BigNumberish,
369
+ overrides?: Overrides & { from?: string | Promise<string> }
370
+ ): Promise<BigNumber>;
371
+
372
+ "add_liquidity(uint256[],uint256,address)"(
292
373
  _deposit_amount: BigNumberish[],
293
374
  _min_amount: BigNumberish,
294
375
  _receiver: string,
295
376
  overrides?: Overrides & { from?: string | Promise<string> }
296
377
  ): Promise<BigNumber>;
297
378
 
298
- calc_token_amount(
379
+ "calc_token_amount(uint256[3],bool)"(
380
+ _amounts: [BigNumberish, BigNumberish, BigNumberish],
381
+ _is_deposit: boolean,
382
+ overrides?: CallOverrides
383
+ ): Promise<BigNumber>;
384
+
385
+ "calc_token_amount(uint256[],bool)"(
299
386
  _amounts: BigNumberish[],
300
387
  _is_deposit: boolean,
301
388
  overrides?: CallOverrides
302
389
  ): Promise<BigNumber>;
303
390
 
391
+ "calc_token_amount(uint256[2],bool)"(
392
+ _amounts: [BigNumberish, BigNumberish],
393
+ _is_deposit: boolean,
394
+ overrides?: CallOverrides
395
+ ): Promise<BigNumber>;
396
+
304
397
  calc_withdraw_one_coin(
305
398
  _burn_amount: BigNumberish,
306
399
  i: BigNumberish,
@@ -336,25 +429,48 @@ export interface ICrvPool extends BaseContract {
336
429
  _burn_amount: BigNumberish,
337
430
  i: BigNumberish,
338
431
  _min_amount: BigNumberish,
339
- _receiver: string,
340
432
  overrides?: Overrides & { from?: string | Promise<string> }
341
433
  ): Promise<BigNumber>;
342
434
  };
343
435
 
344
436
  populateTransaction: {
345
- add_liquidity(
437
+ "add_liquidity(uint256[2],uint256)"(
438
+ _deposit_amount: [BigNumberish, BigNumberish],
439
+ _min_amount: BigNumberish,
440
+ overrides?: Overrides & { from?: string | Promise<string> }
441
+ ): Promise<PopulatedTransaction>;
442
+
443
+ "add_liquidity(uint256[3],uint256)"(
444
+ _deposit_amount: [BigNumberish, BigNumberish, BigNumberish],
445
+ _min_amount: BigNumberish,
446
+ overrides?: Overrides & { from?: string | Promise<string> }
447
+ ): Promise<PopulatedTransaction>;
448
+
449
+ "add_liquidity(uint256[],uint256,address)"(
346
450
  _deposit_amount: BigNumberish[],
347
451
  _min_amount: BigNumberish,
348
452
  _receiver: string,
349
453
  overrides?: Overrides & { from?: string | Promise<string> }
350
454
  ): Promise<PopulatedTransaction>;
351
455
 
352
- calc_token_amount(
456
+ "calc_token_amount(uint256[3],bool)"(
457
+ _amounts: [BigNumberish, BigNumberish, BigNumberish],
458
+ _is_deposit: boolean,
459
+ overrides?: CallOverrides
460
+ ): Promise<PopulatedTransaction>;
461
+
462
+ "calc_token_amount(uint256[],bool)"(
353
463
  _amounts: BigNumberish[],
354
464
  _is_deposit: boolean,
355
465
  overrides?: CallOverrides
356
466
  ): Promise<PopulatedTransaction>;
357
467
 
468
+ "calc_token_amount(uint256[2],bool)"(
469
+ _amounts: [BigNumberish, BigNumberish],
470
+ _is_deposit: boolean,
471
+ overrides?: CallOverrides
472
+ ): Promise<PopulatedTransaction>;
473
+
358
474
  calc_withdraw_one_coin(
359
475
  _burn_amount: BigNumberish,
360
476
  i: BigNumberish,
@@ -390,7 +506,6 @@ export interface ICrvPool extends BaseContract {
390
506
  _burn_amount: BigNumberish,
391
507
  i: BigNumberish,
392
508
  _min_amount: BigNumberish,
393
- _receiver: string,
394
509
  overrides?: Overrides & { from?: string | Promise<string> }
395
510
  ): Promise<PopulatedTransaction>;
396
511
  };
@@ -68,12 +68,19 @@ export declare namespace IPActionMintRedeem {
68
68
  tokens: string[];
69
69
  kybercalls: BytesLike[];
70
70
  outputToken: string;
71
+ minTokenOut: BigNumberish;
71
72
  };
72
73
 
73
- export type RouterSwapAllStructStructOutput = [string[], string[], string] & {
74
+ export type RouterSwapAllStructStructOutput = [
75
+ string[],
76
+ string[],
77
+ string,
78
+ BigNumber
79
+ ] & {
74
80
  tokens: string[];
75
81
  kybercalls: string[];
76
82
  outputToken: string;
83
+ minTokenOut: BigNumber;
77
84
  };
78
85
  }
79
86
 
@@ -84,7 +91,7 @@ export interface IPActionMintRedeemInterface extends utils.Interface {
84
91
  "mintPyFromToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;
85
92
  "mintScyFromToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;
86
93
  "redeemDueInterestAndRewards(address,address[],address[],address[])": FunctionFragment;
87
- "redeemDueInterestAndRewardsThenSwapAll(address[],(address[],address[],address[]),address[],(address[],bytes[],address))": FunctionFragment;
94
+ "redeemDueInterestAndRewardsThenSwapAll(address[],(address[],address[],address[]),address[],(address[],bytes[],address,uint256))": FunctionFragment;
88
95
  "redeemPyToScy(address,address,uint256,uint256)": FunctionFragment;
89
96
  "redeemPyToToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;
90
97
  "redeemScyToToken(address,address,uint256,(address,uint256,address,bytes))": FunctionFragment;