@pendle/core-v2 2.23.1 → 2.23.3-mantle

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 (289) hide show
  1. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
  2. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
  3. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
  4. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
  5. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.dbg.json +1 -1
  6. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  7. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  8. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  9. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
  10. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +2 -2
  11. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol/PendleFeeDistributorV2.dbg.json +1 -1
  12. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  13. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  14. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  15. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  16. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  17. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  18. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  19. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  20. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
  21. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
  22. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
  23. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  24. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  25. package/build/artifacts/contracts/core/Market/PendleExternalRewardDistributor.sol/PendleExternalRewardDistributor.dbg.json +4 -0
  26. package/build/artifacts/contracts/core/Market/PendleExternalRewardDistributor.sol/PendleExternalRewardDistributor.json +373 -0
  27. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  28. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  29. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
  30. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  31. package/build/artifacts/contracts/core/Market/v2/PendleGaugeV2.sol/PendleGaugeV2.dbg.json +4 -0
  32. package/build/artifacts/contracts/core/Market/v2/PendleGaugeV2.sol/PendleGaugeV2.json +128 -0
  33. package/build/artifacts/contracts/core/Market/v2/PendleMarketFactoryV2.sol/PendleMarketFactoryV2.dbg.json +4 -0
  34. package/build/artifacts/contracts/core/Market/v2/PendleMarketFactoryV2.sol/PendleMarketFactoryV2.json +682 -0
  35. package/build/artifacts/contracts/core/Market/v2/PendleMarketV2.sol/PendleMarketV2.dbg.json +4 -0
  36. package/build/artifacts/contracts/core/Market/v2/PendleMarketV2.sol/PendleMarketV2.json +1219 -0
  37. package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
  38. package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  39. package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +1 -1
  40. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  41. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  42. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ankr/PendleAnkrBNBSY.sol/PendleAnkrBNBSY.dbg.json +1 -1
  43. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +1 -1
  44. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/AuraEthxBbAWethSY.sol/AuraEthxBbAWethSY.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/AuraEthxBbAWethSY.sol/AuraEthxBbAWethSY.json +2 -2
  46. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol/PendleAuraBbAWethSwethSY.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol/PendleAuraBbAWethSwethSY.json +2 -2
  48. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol/PendleAuraWethAnkrethSYV2.dbg.json +1 -1
  49. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol/PendleAuraWethAnkrethSYV2.json +2 -2
  50. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol/PendleAuraWethRocketEthSYV2.dbg.json +1 -1
  51. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol/PendleAuraWethRocketEthSYV2.json +2 -2
  52. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol/PendleAuraWethStafiEthSY.dbg.json +1 -1
  53. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol/PendleAuraWethStafiEthSY.json +2 -2
  54. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethVethSY.sol/PendleAuraWethVethSY.dbg.json +1 -1
  55. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethVethSY.sol/PendleAuraWethVethSY.json +2 -2
  56. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol/PendleAuraWethWstethSYV2.dbg.json +1 -1
  57. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol/PendleAuraWethWstethSYV2.json +2 -2
  58. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol/PendleAuraWstethAnkreth.dbg.json +1 -1
  59. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol/PendleAuraWstethAnkreth.json +2 -2
  60. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol/ComposableStableMath.dbg.json +1 -1
  61. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreview.sol/ComposableStablePreview.dbg.json +1 -1
  62. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/FixedPoint.sol/FixedPoint.dbg.json +1 -1
  63. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol/BbAPoolHelper.dbg.json +1 -1
  64. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol/BbAWethHelper.dbg.json +1 -1
  65. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol/LinearMath.dbg.json +1 -1
  66. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearPreview.sol/LinearPreview.dbg.json +1 -1
  67. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol/MetaStableMath.dbg.json +1 -1
  68. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol/MetaStablePreview.dbg.json +1 -1
  69. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol/PendleAuraBalancerStableLPSYV2.dbg.json +1 -1
  70. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  71. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  72. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
  73. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotRewardHelper.sol/CamelotRewardHelper.dbg.json +1 -1
  74. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileCommon.sol/CamelotV1VolatileCommon.dbg.json +1 -1
  75. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileLpHelper.sol/CamelotV1VolatileLpHelper.dbg.json +1 -1
  76. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatilePreview.sol/CamelotV1VolatilePreview.dbg.json +1 -1
  77. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol/PendleCamelotV1VolatileSY.dbg.json +1 -1
  78. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol/PendleCamelotV1VolatileSY.json +2 -2
  79. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
  80. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +2 -2
  81. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
  82. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +2 -2
  83. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +1 -1
  84. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +1 -1
  85. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +1 -1
  86. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
  87. package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.dbg.json +1 -1
  88. package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.json +2 -2
  89. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleArbitrumStakedEthSY.sol/PendleArbitrumStakedEthSY.dbg.json +1 -1
  90. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol/PendleGDaiSY.dbg.json +1 -1
  91. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
  92. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol/PendleSfrxEthSY.dbg.json +1 -1
  93. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol/PendleStargateLPSY.dbg.json +1 -1
  94. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol/PendleStargateLPSY.json +2 -2
  95. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWbEthSY.sol/PendleWbEthSY.dbg.json +1 -1
  96. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  97. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwETH.sol/SwETHSY.dbg.json +1 -1
  98. package/build/artifacts/contracts/core/StandardizedYield/implementations/Thena/PendleThenaSY.sol/PendleThenaSY.dbg.json +1 -1
  99. package/build/artifacts/contracts/core/StandardizedYield/implementations/Thena/PendleThenaSY.sol/PendleThenaSY.json +2 -2
  100. package/build/artifacts/contracts/core/StandardizedYield/implementations/Thena/ThenaLpHelper.sol/ThenaLpHelper.dbg.json +1 -1
  101. package/build/artifacts/contracts/core/StandardizedYield/implementations/Thena/ThenaMath.sol/ThenaMath.dbg.json +1 -1
  102. package/build/artifacts/contracts/core/StandardizedYield/implementations/Thena/ThenaPreview.sol/IThenaSY.dbg.json +1 -1
  103. package/build/artifacts/contracts/core/StandardizedYield/implementations/Thena/ThenaPreview.sol/ThenaPreview.dbg.json +1 -1
  104. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  105. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  106. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  107. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
  108. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  109. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
  110. package/build/artifacts/contracts/core/YieldContractsV2/InterestManagerYTV2.sol/InterestManagerYTV2.dbg.json +1 -1
  111. package/build/artifacts/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol/PendlePrincipalTokenV2.dbg.json +1 -1
  112. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.dbg.json +1 -1
  113. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.json +2 -2
  114. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.dbg.json +1 -1
  115. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.json +2 -2
  116. package/build/artifacts/contracts/core/libraries/ArrayLib.sol/ArrayLib.dbg.json +1 -1
  117. package/build/artifacts/contracts/core/libraries/ArrayLib.sol/ArrayLib.json +2 -2
  118. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  119. package/build/artifacts/contracts/core/libraries/math/Math.sol/Math.dbg.json +1 -1
  120. package/build/artifacts/contracts/interfaces/Ankr/IAnkrBNB.sol/IAnkrBNB.dbg.json +1 -1
  121. package/build/artifacts/contracts/interfaces/Ankr/IAnkrLiquidStaking.sol/IAnkrLiquidStaking.dbg.json +1 -1
  122. package/build/artifacts/contracts/interfaces/BinanceEth/IWBETH.sol/IWBETH.dbg.json +1 -1
  123. package/build/artifacts/contracts/interfaces/Camelot/ICamelotNFTPool.sol/ICamelotNFTPool.dbg.json +1 -1
  124. package/build/artifacts/contracts/interfaces/Camelot/ICamelotNitroPool.sol/ICamelotNitroPool.dbg.json +1 -1
  125. package/build/artifacts/contracts/interfaces/Camelot/ICamelotPair.sol/ICamelotPair.dbg.json +1 -1
  126. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  127. package/build/artifacts/contracts/interfaces/IPActionInfoStatic.sol/IPActionInfoStatic.dbg.json +1 -1
  128. package/build/artifacts/contracts/interfaces/IPActionMarketAuxStatic.sol/IPActionMarketAuxStatic.dbg.json +1 -1
  129. package/build/artifacts/contracts/interfaces/IPActionMarketCoreStatic.sol/IPActionMarketCoreStatic.dbg.json +1 -1
  130. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  131. package/build/artifacts/contracts/interfaces/IPActionMintRedeemStatic.sol/IPActionMintRedeemStatic.dbg.json +1 -1
  132. package/build/artifacts/contracts/interfaces/IPActionStorageStatic.sol/IPActionStorageStatic.dbg.json +1 -1
  133. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  134. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  135. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  136. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
  137. package/build/artifacts/contracts/interfaces/IPExternalRewardDistributor.sol/IPExternalRewardDistributor.dbg.json +4 -0
  138. package/build/artifacts/contracts/interfaces/IPExternalRewardDistributor.sol/IPExternalRewardDistributor.json +109 -0
  139. package/build/artifacts/contracts/interfaces/IPGauge.sol/IPGauge.dbg.json +1 -1
  140. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  141. package/build/artifacts/contracts/interfaces/IPMarketFactoryV2.sol/IPMarketFactoryV2.dbg.json +4 -0
  142. package/build/artifacts/contracts/interfaces/IPMarketFactoryV2.sol/IPMarketFactoryV2.json +166 -0
  143. package/build/artifacts/contracts/interfaces/IPRouterHelper.sol/IPRouterHelper.dbg.json +1 -1
  144. package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
  145. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  146. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  147. package/build/artifacts/contracts/interfaces/IPendlePreviewHelper.sol/IPendlePreviewHelper.dbg.json +1 -1
  148. package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
  149. package/build/artifacts/contracts/interfaces/ISwETH.sol/ISwETH.dbg.json +1 -1
  150. package/build/artifacts/contracts/interfaces/Thena/IThenaFactory.sol/IThenaFactory.dbg.json +1 -1
  151. package/build/artifacts/contracts/interfaces/Thena/IThenaGaugeV2.sol/IThenaGaugeV2.dbg.json +1 -1
  152. package/build/artifacts/contracts/interfaces/Thena/IThenaPair.sol/IThenaPair.dbg.json +1 -1
  153. package/build/artifacts/contracts/interfaces/Thena/IThenaRouter.sol/IThenaRouter.dbg.json +1 -1
  154. package/build/artifacts/contracts/offchain-helpers/BoringLpSeller.sol/BoringLpSeller.dbg.json +1 -1
  155. package/build/artifacts/contracts/offchain-helpers/BoringPtSeller.sol/BoringPtSeller.dbg.json +1 -1
  156. package/build/artifacts/contracts/offchain-helpers/Broadcaster.sol/Broadcaster.dbg.json +1 -1
  157. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
  158. package/build/artifacts/contracts/offchain-helpers/LegacyNFTHelper.sol/LegacyNFTHelper.dbg.json +1 -1
  159. package/build/artifacts/contracts/offchain-helpers/LegacyNFTHelper.sol/StarNFTV1.dbg.json +1 -1
  160. package/build/artifacts/contracts/offchain-helpers/MarketExchangeRateLib.sol/MarketExchangeRateLib.dbg.json +1 -1
  161. package/build/artifacts/contracts/offchain-helpers/PtAndLpToAsset.sol/PtAndLpToAsset.dbg.json +1 -1
  162. package/build/artifacts/contracts/offchain-helpers/router-static/PendleRouterStatic.sol/PendleRouterStatic.dbg.json +1 -1
  163. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol/ActionInfoStatic.dbg.json +1 -1
  164. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
  165. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol/ActionMarketCoreStatic.dbg.json +1 -1
  166. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol/ActionMintRedeemStatic.dbg.json +1 -1
  167. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol/ActionStorageStatic.dbg.json +1 -1
  168. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol/ActionVePendleStatic.dbg.json +1 -1
  169. package/build/artifacts/contracts/offchain-helpers/router-static/base/StorageLayout.sol/StorageLayout.dbg.json +1 -1
  170. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
  171. package/build/artifacts/contracts/oracles/PendlePtOracle.sol/PendlePtOracle.dbg.json +1 -1
  172. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
  173. package/build/artifacts/contracts/oracles/samples/PendleLpGlpOracle.sol/PendleLpGlpOracle.dbg.json +1 -1
  174. package/build/artifacts/contracts/oracles/samples/PendlePtGlpOracle.sol/PendlePtGlpOracle.dbg.json +1 -1
  175. package/build/artifacts/contracts/oracles/samples/PendlePtUsdChainlinkOracle.sol/PendlePtUsdChainlinkOracle.dbg.json +1 -1
  176. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  177. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  178. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  179. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  180. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  181. package/build/artifacts/contracts/router/PendleRouterHelper.sol/PendleRouterHelper.dbg.json +1 -1
  182. package/build/artifacts/contracts/router/base/ActionBaseCallback.sol/ActionBaseCallback.dbg.json +1 -1
  183. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  184. package/build/artifacts/contracts/router/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
  185. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  186. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  187. package/build/artifacts/contracts/router/swap-aggregator/1inch/I1inchAggregationRouterV5.sol/I1inchAggregationRouterV5.dbg.json +1 -1
  188. package/build/artifacts/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol/OneInchAggregationRouterHelper.dbg.json +1 -1
  189. package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/PendleSwap.dbg.json +1 -1
  190. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol/IExecutorHelper.dbg.json +1 -1
  191. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/KyberInputScalingHelper.sol/KyberInputScalingHelper.dbg.json +1 -1
  192. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ScalingDataLib.sol/ScalingDataLib.dbg.json +1 -1
  193. package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +4 -0
  194. package/contracts/core/Market/PendleExternalRewardDistributor.sol +135 -0
  195. package/contracts/core/Market/v2/PendleGaugeV2.sol +142 -0
  196. package/contracts/core/Market/v2/PendleMarketFactoryV2.sol +177 -0
  197. package/contracts/core/Market/v2/PendleMarketV2.sol +379 -0
  198. package/contracts/core/RewardManager/RewardManager.sol +0 -1
  199. package/contracts/core/RewardManager/RewardManagerAbstract.sol +3 -2
  200. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreview.sol +1 -607
  201. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewProxy.sol +53 -0
  202. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV4.sol +600 -0
  203. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV5.sol +621 -0
  204. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/FixedPoint.sol +8 -0
  205. package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkReceiver.sol +46 -0
  206. package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkRelayer.sol +43 -0
  207. package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleMantleStakedEthSY.sol +120 -0
  208. package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleOracleForSyProxy.sol +23 -0
  209. package/contracts/core/libraries/ArrayLib.sol +32 -0
  210. package/contracts/core/libraries/Errors.sol +2 -0
  211. package/contracts/interfaces/Balancer/IPComposableStablePreview.sol +23 -0
  212. package/contracts/interfaces/Balancer/IVersion.sol +13 -0
  213. package/contracts/interfaces/IPExternalRewardDistributor.sol +19 -0
  214. package/contracts/interfaces/IPMarketFactoryV2.sol +8 -0
  215. package/contracts/interfaces/IPOracleForSy.sol +7 -0
  216. package/contracts/offchain-helpers/AutomateReady.sol +111 -0
  217. package/contracts/offchain-helpers/ChainlinkRelayerAutomation.sol +52 -0
  218. package/contracts/offchain-helpers/ChainlinkRelayerGelato.sol +36 -0
  219. package/contracts/offchain-helpers/errors/SDKErrorsDirectory.sol +149 -0
  220. package/contracts/router/swap-aggregator/PendleSwap.sol +7 -2
  221. package/deployments/5000-core.json +29 -0
  222. package/deployments/5000-markets/WSTETH-MANTLE-MARCH2024.json +10 -0
  223. package/package.json +7 -7
  224. package/typechain-types/AuraSwEthBbAWethSYV2.ts +1532 -0
  225. package/typechain-types/BotActionCallback.ts +1093 -0
  226. package/typechain-types/ComposableStablePreviewProxy.ts +352 -0
  227. package/typechain-types/ComposableStablePreviewV4.ts +217 -0
  228. package/typechain-types/ComposableStablePreviewV5.ts +217 -0
  229. package/typechain-types/IPComposableStablePreview.ts +217 -0
  230. package/typechain-types/IPOracleForSy.ts +87 -0
  231. package/typechain-types/IVersion.ts +81 -0
  232. package/typechain-types/LiquiditySeedingHelper.ts +128 -0
  233. package/typechain-types/LongYieldActionHelper.ts +1093 -0
  234. package/typechain-types/LongYieldTradingBot.ts +1093 -0
  235. package/typechain-types/PendleChainlinkReceiver.ts +239 -0
  236. package/typechain-types/PendleChainlinkRelayer.ts +158 -0
  237. package/typechain-types/PendleExternalRewardDistributor.ts +49 -0
  238. package/typechain-types/PendleMantleStakedEthSY.ts +1222 -0
  239. package/typechain-types/PendleMarketFactoryV2.ts +26 -24
  240. package/typechain-types/PendleOracleForSyProxy.ts +275 -0
  241. package/typechain-types/ShortYieldActionHelper.ts +1093 -0
  242. package/typechain-types/ShortYieldTradingBot.ts +1093 -0
  243. package/typechain-types/TradingBotBase.ts +1093 -0
  244. package/typechain-types/factories/AuraEthxBbAWethSY__factory.ts +1 -1
  245. package/typechain-types/factories/AuraSwEthBbAWethSYV2__factory.ts +1244 -0
  246. package/typechain-types/factories/BotActionCallback__factory.ts +899 -9
  247. package/typechain-types/factories/ComposableStablePreviewProxy__factory.ts +288 -0
  248. package/typechain-types/factories/ComposableStablePreviewV4__factory.ts +190 -0
  249. package/typechain-types/factories/ComposableStablePreviewV5__factory.ts +190 -0
  250. package/typechain-types/factories/IPComposableStablePreview__factory.ts +152 -0
  251. package/typechain-types/factories/IPOracleForSy__factory.ts +36 -0
  252. package/typechain-types/factories/IVersion__factory.ts +36 -0
  253. package/typechain-types/factories/LiquiditySeedingHelper__factory.ts +124 -0
  254. package/typechain-types/factories/LongYieldActionHelper__factory.ts +899 -9
  255. package/typechain-types/factories/LongYieldTradingBot__factory.ts +923 -33
  256. package/typechain-types/factories/PendleAuraBbAWethSwethSY__factory.ts +1 -1
  257. package/typechain-types/factories/PendleAuraWethAnkrethSYV2__factory.ts +1 -1
  258. package/typechain-types/factories/PendleAuraWethRocketEthSYV2__factory.ts +1 -1
  259. package/typechain-types/factories/PendleAuraWethStafiEthSY__factory.ts +1 -1
  260. package/typechain-types/factories/PendleAuraWethVethSY__factory.ts +1 -1
  261. package/typechain-types/factories/PendleAuraWethWstethSYV2__factory.ts +1 -1
  262. package/typechain-types/factories/PendleAuraWstethAnkreth__factory.ts +1 -1
  263. package/typechain-types/factories/PendleCamelotV1VolatileSY__factory.ts +1 -1
  264. package/typechain-types/factories/PendleChainlinkReceiver__factory.ts +216 -0
  265. package/typechain-types/factories/PendleChainlinkRelayer__factory.ts +180 -0
  266. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -1
  267. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -1
  268. package/typechain-types/factories/PendleExternalRewardDistributor__factory.ts +29 -1
  269. package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
  270. package/typechain-types/factories/PendleGlpSY__factory.ts +1 -1
  271. package/typechain-types/factories/PendleMantleStakedEthSY__factory.ts +1068 -0
  272. package/typechain-types/factories/PendleMarketFactoryV2__factory.ts +15 -15
  273. package/typechain-types/factories/PendleMarketV2__factory.ts +10 -1
  274. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  275. package/typechain-types/factories/PendleOracleForSyProxy__factory.ts +211 -0
  276. package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
  277. package/typechain-types/factories/PendleStargateLPSY__factory.ts +1 -1
  278. package/typechain-types/factories/PendleThenaSY__factory.ts +1 -1
  279. package/typechain-types/factories/PendleYieldContractFactoryV2__factory.ts +1 -1
  280. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
  281. package/typechain-types/factories/PendleYieldTokenV2__factory.ts +1 -1
  282. package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
  283. package/typechain-types/factories/ShortYieldActionHelper__factory.ts +899 -9
  284. package/typechain-types/factories/ShortYieldTradingBot__factory.ts +939 -49
  285. package/typechain-types/factories/TradingBotBase__factory.ts +899 -9
  286. package/typechain-types/hardhat.d.ts +162 -9
  287. package/typechain-types/index.ts +34 -2
  288. /package/contracts/router/swap-aggregator/{1inch → oneinch}/I1inchAggregationRouterV5.sol +0 -0
  289. /package/contracts/router/swap-aggregator/{1inch → oneinch}/OneInchAggregationRouterHelper.sol +0 -0
@@ -0,0 +1,379 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.17;
3
+
4
+ import "../../../interfaces/IPMarket.sol";
5
+ import "../../../interfaces/IPMarketFactory.sol";
6
+ import "../../../interfaces/IPMarketSwapCallback.sol";
7
+
8
+ import "../../erc20/PendleERC20Permit.sol";
9
+ import "./PendleGaugeV2.sol";
10
+ import "../OracleLib.sol";
11
+
12
+ /**
13
+ Invariance to maintain:
14
+ - Internal balances totalPt & totalSy not interfered by people transferring tokens in directly
15
+ - address(0) & address(this) should never have any rewards & activeBalance accounting done. This is
16
+ guaranteed by address(0) & address(this) check in each updateForTwo function
17
+ */
18
+ contract PendleMarketV2 is PendleERC20Permit, PendleGaugeV2, IPMarket {
19
+ using Math for uint256;
20
+ using Math for int256;
21
+ using MarketMathCore for MarketState;
22
+ using SafeERC20 for IERC20;
23
+ using PYIndexLib for IPYieldToken;
24
+ using OracleLib for OracleLib.Observation[65535];
25
+
26
+ struct MarketStorage {
27
+ int128 totalPt;
28
+ int128 totalSy;
29
+ // 1 SLOT = 256 bits
30
+ uint96 lastLnImpliedRate;
31
+ uint16 observationIndex;
32
+ uint16 observationCardinality;
33
+ uint16 observationCardinalityNext;
34
+ // 1 SLOT = 144 bits
35
+ }
36
+
37
+ string private constant NAME = "Pendle Market";
38
+ string private constant SYMBOL = "PENDLE-LPT";
39
+
40
+ IPPrincipalToken internal immutable PT;
41
+ IStandardizedYield internal immutable SY;
42
+ IPYieldToken internal immutable YT;
43
+
44
+ address public immutable factory;
45
+ uint256 public immutable expiry;
46
+ int256 public immutable scalarRoot;
47
+ int256 public immutable initialAnchor;
48
+
49
+ MarketStorage public _storage;
50
+
51
+ OracleLib.Observation[65535] public observations;
52
+
53
+ modifier notExpired() {
54
+ if (isExpired()) revert Errors.MarketExpired();
55
+ _;
56
+ }
57
+
58
+ constructor(
59
+ address _PT,
60
+ int256 _scalarRoot,
61
+ int256 _initialAnchor,
62
+ address _vePendle,
63
+ address _gaugeController,
64
+ address _externalRewardDistributor
65
+ )
66
+ PendleERC20Permit(NAME, SYMBOL, 18)
67
+ PendleGaugeV2(
68
+ IPPrincipalToken(_PT).SY(),
69
+ _vePendle,
70
+ _gaugeController,
71
+ _externalRewardDistributor
72
+ )
73
+ {
74
+ PT = IPPrincipalToken(_PT);
75
+ SY = IStandardizedYield(PT.SY());
76
+ YT = IPYieldToken(PT.YT());
77
+
78
+ (_storage.observationCardinality, _storage.observationCardinalityNext) = observations
79
+ .initialize(uint32(block.timestamp));
80
+
81
+ if (_scalarRoot <= 0) revert Errors.MarketScalarRootBelowZero(_scalarRoot);
82
+
83
+ scalarRoot = _scalarRoot;
84
+ initialAnchor = _initialAnchor;
85
+ expiry = IPPrincipalToken(_PT).expiry();
86
+ factory = msg.sender;
87
+ }
88
+
89
+ /**
90
+ * @notice PendleMarket allows users to provide in PT & SY in exchange for LPs, which
91
+ * will grant LP holders more exchange fee over time
92
+ * @dev will mint as much LP as possible such that the corresponding SY and PT used do
93
+ * not exceed `netSyDesired` and `netPtDesired`, respectively
94
+ * @dev PT and SY should be transferred to this contract prior to calling
95
+ * @dev will revert if PT is expired
96
+ */
97
+ function mint(
98
+ address receiver,
99
+ uint256 netSyDesired,
100
+ uint256 netPtDesired
101
+ )
102
+ external
103
+ nonReentrant
104
+ notExpired
105
+ returns (uint256 netLpOut, uint256 netSyUsed, uint256 netPtUsed)
106
+ {
107
+ MarketState memory market = readState(msg.sender);
108
+ PYIndex index = YT.newIndex();
109
+
110
+ uint256 lpToReserve;
111
+
112
+ (lpToReserve, netLpOut, netSyUsed, netPtUsed) = market.addLiquidity(
113
+ netSyDesired,
114
+ netPtDesired,
115
+ block.timestamp
116
+ );
117
+
118
+ // initializing the market
119
+ if (lpToReserve != 0) {
120
+ market.setInitialLnImpliedRate(index, initialAnchor, block.timestamp);
121
+ _mint(address(1), lpToReserve);
122
+ }
123
+
124
+ _mint(receiver, netLpOut);
125
+
126
+ _writeState(market);
127
+
128
+ if (_selfBalance(SY) < market.totalSy.Uint())
129
+ revert Errors.MarketInsufficientSyReceived(_selfBalance(SY), market.totalSy.Uint());
130
+ if (_selfBalance(PT) < market.totalPt.Uint())
131
+ revert Errors.MarketInsufficientPtReceived(_selfBalance(PT), market.totalPt.Uint());
132
+
133
+ emit Mint(receiver, netLpOut, netSyUsed, netPtUsed);
134
+ }
135
+
136
+ /**
137
+ * @notice LP Holders can burn their LP to receive back SY & PT proportionally
138
+ * to their share of the market
139
+ */
140
+ function burn(
141
+ address receiverSy,
142
+ address receiverPt,
143
+ uint256 netLpToBurn
144
+ ) external nonReentrant returns (uint256 netSyOut, uint256 netPtOut) {
145
+ MarketState memory market = readState(msg.sender);
146
+
147
+ _burn(address(this), netLpToBurn);
148
+
149
+ (netSyOut, netPtOut) = market.removeLiquidity(netLpToBurn);
150
+
151
+ if (receiverSy != address(this)) IERC20(SY).safeTransfer(receiverSy, netSyOut);
152
+ if (receiverPt != address(this)) IERC20(PT).safeTransfer(receiverPt, netPtOut);
153
+
154
+ _writeState(market);
155
+
156
+ emit Burn(receiverSy, receiverPt, netLpToBurn, netSyOut, netPtOut);
157
+ }
158
+
159
+ /**
160
+ * @notice Pendle Market allows swaps between PT & SY it is holding. This function
161
+ * aims to swap an exact amount of PT to SY.
162
+ * @dev steps working of this contract
163
+ - The outcome amount of SY will be precomputed by MarketMathLib
164
+ - Release the calculated amount of SY to receiver
165
+ - Callback to msg.sender if data.length > 0
166
+ - Ensure exactPtIn amount of PT has been transferred to this address
167
+ * @dev will revert if PT is expired
168
+ * @param data bytes data to be sent in the callback (if any)
169
+ */
170
+ function swapExactPtForSy(
171
+ address receiver,
172
+ uint256 exactPtIn,
173
+ bytes calldata data
174
+ ) external nonReentrant notExpired returns (uint256 netSyOut, uint256 netSyFee) {
175
+ MarketState memory market = readState(msg.sender);
176
+
177
+ uint256 netSyToReserve;
178
+ (netSyOut, netSyFee, netSyToReserve) = market.swapExactPtForSy(
179
+ YT.newIndex(),
180
+ exactPtIn,
181
+ block.timestamp
182
+ );
183
+
184
+ if (receiver != address(this)) IERC20(SY).safeTransfer(receiver, netSyOut);
185
+ IERC20(SY).safeTransfer(market.treasury, netSyToReserve);
186
+
187
+ _writeState(market);
188
+
189
+ if (data.length > 0) {
190
+ IPMarketSwapCallback(msg.sender).swapCallback(exactPtIn.neg(), netSyOut.Int(), data);
191
+ }
192
+
193
+ if (_selfBalance(PT) < market.totalPt.Uint())
194
+ revert Errors.MarketInsufficientPtReceived(_selfBalance(PT), market.totalPt.Uint());
195
+
196
+ emit Swap(msg.sender, receiver, exactPtIn.neg(), netSyOut.Int(), netSyFee, netSyToReserve);
197
+ }
198
+
199
+ /**
200
+ * @notice Pendle Market allows swaps between PT & SY it is holding. This function
201
+ * aims to swap SY for an exact amount of PT.
202
+ * @dev steps working of this function
203
+ - The exact outcome amount of PT will be transferred to receiver
204
+ - Callback to msg.sender if data.length > 0
205
+ - Ensure the calculated required amount of SY is transferred to this address
206
+ * @dev will revert if PT is expired
207
+ * @param data bytes data to be sent in the callback (if any)
208
+ */
209
+ function swapSyForExactPt(
210
+ address receiver,
211
+ uint256 exactPtOut,
212
+ bytes calldata data
213
+ ) external nonReentrant notExpired returns (uint256 netSyIn, uint256 netSyFee) {
214
+ MarketState memory market = readState(msg.sender);
215
+
216
+ uint256 netSyToReserve;
217
+ (netSyIn, netSyFee, netSyToReserve) = market.swapSyForExactPt(
218
+ YT.newIndex(),
219
+ exactPtOut,
220
+ block.timestamp
221
+ );
222
+
223
+ if (receiver != address(this)) IERC20(PT).safeTransfer(receiver, exactPtOut);
224
+ IERC20(SY).safeTransfer(market.treasury, netSyToReserve);
225
+
226
+ _writeState(market);
227
+
228
+ if (data.length > 0) {
229
+ IPMarketSwapCallback(msg.sender).swapCallback(exactPtOut.Int(), netSyIn.neg(), data);
230
+ }
231
+
232
+ // have received enough SY
233
+ if (_selfBalance(SY) < market.totalSy.Uint())
234
+ revert Errors.MarketInsufficientSyReceived(_selfBalance(SY), market.totalSy.Uint());
235
+
236
+ emit Swap(msg.sender, receiver, exactPtOut.Int(), netSyIn.neg(), netSyFee, netSyToReserve);
237
+ }
238
+
239
+ /// @notice forces balances to match reserves
240
+ function skim() external nonReentrant {
241
+ MarketState memory market = readState(msg.sender);
242
+ uint256 excessPt = _selfBalance(PT) - market.totalPt.Uint();
243
+ uint256 excessSy = _selfBalance(SY) - market.totalSy.Uint();
244
+ if (excessPt != 0) IERC20(PT).safeTransfer(market.treasury, excessPt);
245
+ if (excessSy != 0) IERC20(SY).safeTransfer(market.treasury, excessSy);
246
+ }
247
+
248
+ /**
249
+ * @notice redeems the user's reward
250
+ * @return amount of reward token redeemed, in the same order as `getRewardTokens()`
251
+ */
252
+ function redeemRewards(address user) external nonReentrant returns (uint256[] memory) {
253
+ return _redeemRewards(user);
254
+ }
255
+
256
+ /// @notice returns the list of reward tokens
257
+ function getRewardTokens() external view returns (address[] memory) {
258
+ return _getRewardTokens();
259
+ }
260
+
261
+ /*///////////////////////////////////////////////////////////////
262
+ ORACLE
263
+ //////////////////////////////////////////////////////////////*/
264
+
265
+ function observe(
266
+ uint32[] memory secondsAgos
267
+ ) external view returns (uint216[] memory lnImpliedRateCumulative) {
268
+ return
269
+ observations.observe(
270
+ uint32(block.timestamp),
271
+ secondsAgos,
272
+ _storage.lastLnImpliedRate,
273
+ _storage.observationIndex,
274
+ _storage.observationCardinality
275
+ );
276
+ }
277
+
278
+ function increaseObservationsCardinalityNext(uint16 cardinalityNext) external nonReentrant {
279
+ uint16 cardinalityNextOld = _storage.observationCardinalityNext;
280
+ uint16 cardinalityNextNew = observations.grow(cardinalityNextOld, cardinalityNext);
281
+ if (cardinalityNextOld != cardinalityNextNew) {
282
+ _storage.observationCardinalityNext = cardinalityNextNew;
283
+ emit IncreaseObservationCardinalityNext(cardinalityNextOld, cardinalityNextNew);
284
+ }
285
+ }
286
+
287
+ /*///////////////////////////////////////////////////////////////
288
+ READ/WRITE STATES
289
+ //////////////////////////////////////////////////////////////*/
290
+
291
+ /**
292
+ * @notice read the state of the market from storage into memory for gas-efficient manipulation
293
+ */
294
+ function readState(address router) public view returns (MarketState memory market) {
295
+ market.totalPt = _storage.totalPt;
296
+ market.totalSy = _storage.totalSy;
297
+ market.totalLp = totalSupply().Int();
298
+
299
+ (market.treasury, market.lnFeeRateRoot, market.reserveFeePercent) = IPMarketFactory(
300
+ factory
301
+ ).getMarketConfig(router);
302
+
303
+ market.scalarRoot = scalarRoot;
304
+ market.expiry = expiry;
305
+
306
+ market.lastLnImpliedRate = _storage.lastLnImpliedRate;
307
+ }
308
+
309
+ /// @notice write back the state of the market from memory to storage
310
+ function _writeState(MarketState memory market) internal {
311
+ uint96 lastLnImpliedRate96 = market.lastLnImpliedRate.Uint96();
312
+ int128 totalPt128 = market.totalPt.Int128();
313
+ int128 totalSy128 = market.totalSy.Int128();
314
+
315
+ (uint16 observationIndex, uint16 observationCardinality) = observations.write(
316
+ _storage.observationIndex,
317
+ uint32(block.timestamp),
318
+ _storage.lastLnImpliedRate,
319
+ _storage.observationCardinality,
320
+ _storage.observationCardinalityNext
321
+ );
322
+
323
+ _storage.totalPt = totalPt128;
324
+ _storage.totalSy = totalSy128;
325
+ _storage.lastLnImpliedRate = lastLnImpliedRate96;
326
+ _storage.observationIndex = observationIndex;
327
+ _storage.observationCardinality = observationCardinality;
328
+
329
+ emit UpdateImpliedRate(block.timestamp, market.lastLnImpliedRate);
330
+ }
331
+
332
+ /*///////////////////////////////////////////////////////////////
333
+ TRIVIAL FUNCTIONS
334
+ //////////////////////////////////////////////////////////////*/
335
+
336
+ function readTokens()
337
+ external
338
+ view
339
+ returns (IStandardizedYield _SY, IPPrincipalToken _PT, IPYieldToken _YT)
340
+ {
341
+ _SY = SY;
342
+ _PT = PT;
343
+ _YT = YT;
344
+ }
345
+
346
+ function isExpired() public view returns (bool) {
347
+ return MiniHelpers.isCurrentlyExpired(expiry);
348
+ }
349
+
350
+ /*///////////////////////////////////////////////////////////////
351
+ PENDLE GAUGE - RELATED
352
+ //////////////////////////////////////////////////////////////*/
353
+
354
+ function _stakedBalance(address user) internal view override returns (uint256) {
355
+ return balanceOf(user);
356
+ }
357
+
358
+ function _totalStaked() internal view override returns (uint256) {
359
+ return totalSupply();
360
+ }
361
+
362
+ // solhint-disable-next-line ordering
363
+ function _beforeTokenTransfer(
364
+ address from,
365
+ address to,
366
+ uint256 amount
367
+ ) internal override(PendleERC20, PendleGaugeV2) {
368
+ PendleGaugeV2._beforeTokenTransfer(from, to, amount);
369
+ }
370
+
371
+ // solhint-disable-next-line ordering
372
+ function _afterTokenTransfer(
373
+ address from,
374
+ address to,
375
+ uint256 amount
376
+ ) internal override(PendleERC20, PendleGaugeV2) {
377
+ PendleGaugeV2._afterTokenTransfer(from, to, amount);
378
+ }
379
+ }
@@ -13,7 +13,6 @@ abstract contract RewardManager is RewardManagerAbstract {
13
13
 
14
14
  mapping(address => RewardState) public rewardState;
15
15
 
16
- uint256 internal constant INITIAL_REWARD_INDEX = 1;
17
16
 
18
17
  function _updateRewardIndex()
19
18
  internal
@@ -13,6 +13,8 @@ import "./RewardManagerAbstract.sol";
13
13
  abstract contract RewardManagerAbstract is IRewardManager, TokenHelper {
14
14
  using Math for uint256;
15
15
 
16
+ uint256 internal constant INITIAL_REWARD_INDEX = 1;
17
+
16
18
  struct RewardState {
17
19
  uint128 index;
18
20
  uint128 lastBalance;
@@ -56,8 +58,7 @@ abstract contract RewardManagerAbstract is IRewardManager, TokenHelper {
56
58
  uint256 userIndex = userReward[token][user].index;
57
59
 
58
60
  if (userIndex == 0) {
59
- userReward[token][user].index = index.Uint128();
60
- continue;
61
+ userIndex = INITIAL_REWARD_INDEX.Uint128();
61
62
  }
62
63
 
63
64
  if (userIndex == index) continue;