@pendle/core-v2 0.11.11-testnet → 0.12.0-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 (350) hide show
  1. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  2. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
  3. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
  4. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json +199 -30
  5. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.dbg.json +4 -0
  6. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.json +1030 -0
  7. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.dbg.json +4 -0
  8. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.json +1025 -0
  9. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.dbg.json +4 -0
  10. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.json +948 -0
  11. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +4 -0
  12. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +76 -0
  13. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +1 -1
  14. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.json +140 -25
  15. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
  16. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.json +138 -23
  17. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
  18. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.json +138 -23
  19. package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +4 -0
  20. package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +310 -0
  21. package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +4 -0
  22. package/build/artifacts/contracts/core/LiquidityMining/{CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.json → CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.json} +18 -85
  23. package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +4 -0
  24. package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +336 -0
  25. package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +4 -0
  26. package/build/artifacts/contracts/core/LiquidityMining/{CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.json → CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.json} +8 -21
  27. package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +4 -0
  28. package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.json +131 -0
  29. package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +4 -0
  30. package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +297 -0
  31. package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +4 -0
  32. package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +376 -0
  33. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  34. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +11 -0
  35. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  36. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +29 -2
  37. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  38. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +40 -86
  39. package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  40. package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  41. package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +228 -40
  42. package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  43. package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.json +232 -12
  44. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +164 -47
  46. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +25 -93
  48. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  49. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  50. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +222 -9
  51. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  52. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +106 -5
  53. package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +4 -0
  54. package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.json +329 -0
  55. package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.json +13 -2
  57. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  59. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +87 -2
  60. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  61. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +80 -16
  62. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  63. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +164 -2
  64. package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  65. package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +172 -4
  66. package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  67. package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.json +109 -2
  68. package/build/artifacts/contracts/core/actions/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  69. package/build/artifacts/contracts/core/actions/ActionMintRedeem.sol/ActionMintRedeem.json +57 -4
  70. package/build/artifacts/contracts/core/actions/ActionMisc.sol/ActionMisc.dbg.json +1 -1
  71. package/build/artifacts/contracts/core/actions/ActionMisc.sol/ActionMisc.json +7 -2
  72. package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  73. package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.json +199 -4
  74. package/build/artifacts/contracts/core/actions/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
  75. package/build/artifacts/contracts/core/actions/ActionSwapPTYT.sol/ActionSwapPTYT.json +108 -2
  76. package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  77. package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.json +146 -4
  78. package/build/artifacts/contracts/core/actions/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  79. package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +4 -0
  80. package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.json +177 -0
  81. package/build/artifacts/contracts/interfaces/ConvexCurve/ICrvDepositor.sol/ICrvDepositor.dbg.json +4 -0
  82. package/build/artifacts/contracts/interfaces/ConvexCurve/ICrvDepositor.sol/ICrvDepositor.json +78 -0
  83. package/build/artifacts/contracts/interfaces/ConvexCurve/ICvxCrv.sol/ICvxCrv.dbg.json +4 -0
  84. package/build/artifacts/contracts/interfaces/ConvexCurve/ICvxCrv.sol/ICvxCrv.json +24 -0
  85. package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.dbg.json +4 -0
  86. package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.json +264 -0
  87. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +4 -0
  88. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +305 -0
  89. package/build/artifacts/contracts/interfaces/IBoringOwnableUpgradeable.sol/IBoringOwnableUpgradeable.dbg.json +4 -0
  90. package/build/artifacts/contracts/interfaces/IBoringOwnableUpgradeable.sol/IBoringOwnableUpgradeable.json +34 -0
  91. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  92. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +31 -1
  93. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  94. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  95. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +30 -0
  96. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
  97. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.json +10 -0
  98. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  99. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +30 -0
  100. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  101. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +101 -1
  102. package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +4 -0
  103. package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.json +112 -0
  104. package/build/artifacts/contracts/interfaces/IPFeeDistributorFactory.sol/IPFeeDistributorFactory.dbg.json +4 -0
  105. package/build/artifacts/contracts/interfaces/IPFeeDistributorFactory.sol/IPFeeDistributorFactory.json +76 -0
  106. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  107. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +13 -0
  108. package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.dbg.json +4 -0
  109. package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.json +24 -0
  110. package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +4 -0
  111. package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.json +63 -0
  112. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  113. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.json +148 -0
  114. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +4 -0
  115. package/build/artifacts/contracts/interfaces/{IPVotingEscrow.sol/IPVotingEscrow.json → IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.json} +88 -2
  116. package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
  117. package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.json +4 -28
  118. package/build/artifacts/contracts/libraries/Errors.sol/Errors.dbg.json +4 -0
  119. package/build/artifacts/contracts/libraries/Errors.sol/Errors.json +886 -0
  120. package/build/artifacts/contracts/libraries/OracleLib.sol/OracleLib.dbg.json +1 -1
  121. package/build/artifacts/contracts/libraries/OracleLib.sol/OracleLib.json +28 -2
  122. package/build/artifacts/contracts/libraries/RewardManager.sol/RewardManager.dbg.json +1 -1
  123. package/build/artifacts/contracts/libraries/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  124. package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  125. package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  126. package/build/artifacts/contracts/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +4 -0
  127. package/build/artifacts/contracts/libraries/{solmate/SSTORE2.sol/SSTORE2.json → VeHistoryLib.sol/CheckpointHelper.json} +4 -4
  128. package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  129. package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  130. package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.dbg.json +1 -1
  131. package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.json +2 -2
  132. package/build/artifacts/contracts/libraries/helpers/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +4 -0
  133. package/build/artifacts/contracts/libraries/helpers/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +45 -0
  134. package/build/artifacts/contracts/libraries/helpers/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +4 -0
  135. package/build/artifacts/contracts/libraries/helpers/{SSTORE2Deployer.sol/SSTORE2Deployer.json → BaseSplitCodeFactory.sol/CodeDeployer.json} +4 -4
  136. package/build/artifacts/contracts/libraries/helpers/PYIndex.sol/PYIndexLib.dbg.json +1 -1
  137. package/build/artifacts/contracts/libraries/helpers/PYIndex.sol/PYIndexLib.json +2 -2
  138. package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
  139. package/build/artifacts/contracts/libraries/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
  140. package/build/artifacts/contracts/libraries/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -2
  141. package/build/artifacts/contracts/libraries/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
  142. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  143. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  144. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  145. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  146. package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  147. package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.json +2 -2
  148. package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
  149. package/build/artifacts/contracts/libraries/math/Math.sol/Math.json +2 -2
  150. package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.dbg.json +1 -1
  151. package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.json +2 -2
  152. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +4 -0
  153. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +167 -0
  154. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
  155. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +182 -4
  156. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  157. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +126 -79
  158. package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol +3 -1
  159. package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol +19 -16
  160. package/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol +135 -0
  161. package/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol +96 -0
  162. package/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol +215 -0
  163. package/contracts/SuperComposableYield/SCY-implementations/Convex/Pendle3CrvHelper.sol +83 -0
  164. package/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol +10 -15
  165. package/contracts/SuperComposableYield/base-implementations/SCYBase.sol +30 -43
  166. package/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +74 -0
  167. package/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol +38 -0
  168. package/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +83 -0
  169. package/contracts/core/LiquidityMining/{CelerAbstracts/CelerSenderUpg.sol → CrossChainMsg/PendleMsgSenderAppUpg.sol} +12 -13
  170. package/contracts/core/LiquidityMining/FeeDistributor/EpochResultManager.sol +159 -0
  171. package/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol +96 -0
  172. package/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol +68 -0
  173. package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +4 -3
  174. package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol +6 -2
  175. package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol +12 -4
  176. package/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +29 -19
  177. package/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +27 -19
  178. package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +63 -27
  179. package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +6 -5
  180. package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +2 -2
  181. package/contracts/core/Market/PendleMarket.sol +26 -24
  182. package/contracts/core/Market/PendleMarketFactory.sol +41 -20
  183. package/contracts/core/PendleERC20Permit.sol +84 -0
  184. package/contracts/core/PendleRouter.sol +2 -1
  185. package/contracts/core/YieldContracts/PendlePrincipalToken.sol +8 -7
  186. package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +37 -22
  187. package/contracts/core/YieldContracts/PendleYieldToken.sol +106 -35
  188. package/contracts/core/actions/ActionAddRemoveLiq.sol +58 -41
  189. package/contracts/core/actions/ActionCallback.sol +24 -14
  190. package/contracts/core/actions/ActionMintRedeem.sol +11 -5
  191. package/contracts/core/actions/ActionMisc.sol +2 -1
  192. package/contracts/core/actions/ActionSwapPT.sol +38 -19
  193. package/contracts/core/actions/ActionSwapPTYT.sol +7 -6
  194. package/contracts/core/actions/ActionSwapYT.sol +36 -19
  195. package/contracts/core/actions/base/ActionBaseMintRedeem.sol +15 -8
  196. package/contracts/interfaces/ConvexCurve/IBooster.sol +32 -0
  197. package/contracts/interfaces/ConvexCurve/ICrvDepositor.sol +20 -0
  198. package/contracts/interfaces/ConvexCurve/ICvxCrv.sol +6 -0
  199. package/contracts/interfaces/ConvexCurve/IRewards.sol +38 -0
  200. package/contracts/interfaces/Curve/ICrvPool.sol +69 -0
  201. package/contracts/interfaces/IBoringOwnableUpgradeable.sol +10 -0
  202. package/contracts/interfaces/IPActionAddRemoveLiq.sol +7 -7
  203. package/contracts/interfaces/IPActionSwapPT.sol +6 -6
  204. package/contracts/interfaces/IPActionSwapPTYT.sol +2 -2
  205. package/contracts/interfaces/IPActionSwapYT.sol +13 -13
  206. package/contracts/interfaces/IPFeeDistributor.sol +19 -0
  207. package/contracts/interfaces/IPFeeDistributorFactory.sol +14 -0
  208. package/contracts/interfaces/IPMarket.sol +2 -0
  209. package/contracts/interfaces/IPMsgReceiverApp.sol +7 -0
  210. package/contracts/interfaces/IPMsgSendEndpoint.sol +17 -0
  211. package/contracts/interfaces/IPVotingController.sol +22 -0
  212. package/contracts/interfaces/{IPVotingEscrow.sol → IPVotingEscrowMainchain.sol} +11 -1
  213. package/contracts/interfaces/ISuperComposableYield.sol +2 -7
  214. package/contracts/libraries/Errors.sol +121 -0
  215. package/contracts/libraries/OracleLib.sol +6 -3
  216. package/contracts/libraries/VeBalanceLib.sol +5 -1
  217. package/contracts/libraries/VeHistoryLib.sol +20 -31
  218. package/contracts/libraries/helpers/ArrayLib.sol +0 -17
  219. package/contracts/libraries/helpers/BaseSplitCodeFactory.sol +288 -0
  220. package/contracts/libraries/helpers/TokenHelper.sol +4 -0
  221. package/contracts/libraries/kyberswap/AggregationRouterHelper.sol +0 -7
  222. package/contracts/libraries/math/MarketMathCore.sol +29 -25
  223. package/contracts/libraries/math/Math.sol +6 -2
  224. package/contracts/libraries/math/WeekMath.sol +2 -2
  225. package/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol +43 -0
  226. package/contracts/offchain-helpers/MarketMathStatic.sol +36 -36
  227. package/contracts/offchain-helpers/RouterStatic.sol +45 -37
  228. package/deployments/43113-core.json +11 -10
  229. package/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
  230. package/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
  231. package/deployments/43113-testenv.json +9 -9
  232. package/deployments/80001-core.json +10 -9
  233. package/deployments/80001-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
  234. package/deployments/80001-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
  235. package/deployments/80001-testenv.json +16 -16
  236. package/package.json +1 -1
  237. package/typechain-types/ActionAddRemoveLiq.ts +18 -6
  238. package/typechain-types/ActionSwapPT.ts +18 -6
  239. package/typechain-types/ActionSwapPTYT.ts +6 -2
  240. package/typechain-types/ActionSwapYT.ts +18 -6
  241. package/typechain-types/IPActionAddRemoveLiq.ts +19 -7
  242. package/typechain-types/IPActionSwapPT.ts +18 -6
  243. package/typechain-types/IPActionSwapPTYT.ts +6 -2
  244. package/typechain-types/IPActionSwapYT.ts +18 -6
  245. package/typechain-types/IPAllAction.ts +61 -21
  246. package/typechain-types/IPMarket.ts +13 -0
  247. package/typechain-types/IPVotingController.ts +244 -7
  248. package/typechain-types/ISuperComposableYield.ts +7 -46
  249. package/typechain-types/MarketMathStatic.ts +139 -10
  250. package/typechain-types/PendleGaugeControllerSidechainUpg.ts +28 -149
  251. package/typechain-types/PendleMarket.ts +104 -0
  252. package/typechain-types/PendleMarketFactory.ts +76 -13
  253. package/typechain-types/PendlePrincipalToken.ts +104 -0
  254. package/typechain-types/PendleQiTokenSCY.ts +111 -46
  255. package/typechain-types/PendleVotingControllerUpg.ts +133 -77
  256. package/typechain-types/PendleWstEthSCY.ts +111 -46
  257. package/typechain-types/PendleYieldContractFactory.ts +84 -21
  258. package/typechain-types/PendleYieldToken.ts +175 -0
  259. package/typechain-types/RouterStatic.ts +99 -75
  260. package/typechain-types/SCYBase.ts +111 -46
  261. package/typechain-types/SCYBaseWithRewards.ts +111 -46
  262. package/typechain-types/VotingControllerStorageUpg.ts +246 -27
  263. package/typechain-types/VotingEscrowPendleMainchain.ts +81 -93
  264. package/typechain-types/VotingEscrowPendleSidechain.ts +26 -171
  265. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +169 -1
  266. package/typechain-types/factories/ActionCallback__factory.ts +108 -1
  267. package/typechain-types/factories/ActionMintRedeem__factory.ts +54 -1
  268. package/typechain-types/factories/ActionMisc__factory.ts +6 -1
  269. package/typechain-types/factories/ActionSwapPTYT__factory.ts +107 -1
  270. package/typechain-types/factories/ActionSwapPT__factory.ts +196 -1
  271. package/typechain-types/factories/ActionSwapYT__factory.ts +143 -1
  272. package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -1
  273. package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +31 -1
  274. package/typechain-types/factories/IPActionSwapPTYT__factory.ts +10 -0
  275. package/typechain-types/factories/IPActionSwapPT__factory.ts +30 -0
  276. package/typechain-types/factories/IPActionSwapYT__factory.ts +30 -0
  277. package/typechain-types/factories/IPAllAction__factory.ts +101 -1
  278. package/typechain-types/factories/IPMarket__factory.ts +13 -0
  279. package/typechain-types/factories/IPVotingController__factory.ts +148 -0
  280. package/typechain-types/factories/ISuperComposableYield__factory.ts +4 -28
  281. package/typechain-types/factories/MarketMathStatic__factory.ts +181 -3
  282. package/typechain-types/factories/OracleLib__factory.ts +27 -1
  283. package/typechain-types/factories/Pendle3CrvAndTokenSCY__factory.ts +1 -1
  284. package/typechain-types/factories/Pendle3CrvHelper__factory.ts +1 -1
  285. package/typechain-types/factories/PendleConvexCurveLP2PoolSCY__factory.ts +1 -1
  286. package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
  287. package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
  288. package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
  289. package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +11 -0
  290. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +28 -1
  291. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +48 -86
  292. package/typechain-types/factories/PendleMarketFactory__factory.ts +129 -9
  293. package/typechain-types/factories/PendleMarket__factory.ts +214 -1
  294. package/typechain-types/factories/PendlePrincipalToken__factory.ts +86 -1
  295. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  296. package/typechain-types/factories/PendleQiTokenSCY__factory.ts +198 -29
  297. package/typechain-types/factories/PendleRouter__factory.ts +12 -1
  298. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +235 -40
  299. package/typechain-types/factories/PendleWstEthSCY__factory.ts +137 -22
  300. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +103 -20
  301. package/typechain-types/factories/PendleYieldToken__factory.ts +163 -1
  302. package/typechain-types/factories/RouterStatic__factory.ts +67 -20
  303. package/typechain-types/factories/SCYBaseWithRewards__factory.ts +136 -21
  304. package/typechain-types/factories/SCYBase__factory.ts +136 -21
  305. package/typechain-types/factories/VotingControllerStorageUpg__factory.ts +232 -12
  306. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +171 -47
  307. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +31 -93
  308. package/typechain-types/hardhat.d.ts +0 -27
  309. package/typechain-types/index.ts +0 -6
  310. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +0 -4
  311. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.json +0 -810
  312. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +0 -4
  313. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.json +0 -10
  314. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.dbg.json +0 -4
  315. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.json +0 -833
  316. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.dbg.json +0 -4
  317. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.json +0 -723
  318. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.dbg.json +0 -4
  319. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.json +0 -728
  320. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.dbg.json +0 -4
  321. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.json +0 -705
  322. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.dbg.json +0 -4
  323. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.json +0 -864
  324. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultSCY.sol/PendleYearnVaultSCY.dbg.json +0 -4
  325. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultSCY.sol/PendleYearnVaultSCY.json +0 -718
  326. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.dbg.json +0 -4
  327. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.json +0 -784
  328. package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.dbg.json +0 -4
  329. package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.dbg.json +0 -4
  330. package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.dbg.json +0 -4
  331. package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +0 -4
  332. package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.dbg.json +0 -4
  333. package/build/artifacts/contracts/offchain-helpers/SSTORE2DeployerContract.sol/SSTORE2DeployerContract.dbg.json +0 -4
  334. package/build/artifacts/contracts/offchain-helpers/SSTORE2DeployerContract.sol/SSTORE2DeployerContract.json +0 -134
  335. package/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol +0 -161
  336. package/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol +0 -126
  337. package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol +0 -242
  338. package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol +0 -146
  339. package/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol +0 -176
  340. package/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol +0 -129
  341. package/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol +0 -193
  342. package/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultSCY.sol +0 -155
  343. package/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol +0 -182
  344. package/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol +0 -53
  345. package/contracts/libraries/helpers/SSTORE2Deployer.sol +0 -30
  346. package/contracts/libraries/solmate/SSTORE2.sol +0 -99
  347. package/contracts/offchain-helpers/SSTORE2DeployerContract.sol +0 -21
  348. package/deployments/43113-markets/benqi-market-10D931.json +0 -8
  349. package/deployments/43113-markets/benqi-market-9fbD64.json +0 -8
  350. package/deployments/43113-markets/benqi-market-A12361.json +0 -8
@@ -11,9 +11,10 @@ import "../../libraries/math/Math.sol";
11
11
  import "../../libraries/helpers/ArrayLib.sol";
12
12
  import "../../interfaces/IPYieldContractFactory.sol";
13
13
  import "../../libraries/SCY/SCYUtils.sol";
14
+ import "../../libraries/Errors.sol";
14
15
  import "../../libraries/helpers/MiniHelpers.sol";
15
16
  import "../../libraries/RewardManagerAbstract.sol";
16
- import "../PendleERC20.sol";
17
+ import "../PendleERC20Permit.sol";
17
18
  import "./InterestManagerYT.sol";
18
19
 
19
20
  /**
@@ -21,7 +22,12 @@ Invariance to maintain:
21
22
  - address(0) & address(this) should never have any rewards & activeBalance accounting done. This is
22
23
  guaranteed by address(0) & address(this) check in each updateForTwo function
23
24
  */
24
- contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, InterestManagerYT {
25
+ contract PendleYieldToken is
26
+ IPYieldToken,
27
+ PendleERC20Permit,
28
+ RewardManagerAbstract,
29
+ InterestManagerYT
30
+ {
25
31
  using Math for uint256;
26
32
  using SafeERC20 for IERC20;
27
33
  using ArrayLib for uint256[];
@@ -49,6 +55,11 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
49
55
  _updateScyReserve();
50
56
  }
51
57
 
58
+ modifier notExpired() {
59
+ if (isExpired()) revert Errors.YCExpired();
60
+ _;
61
+ }
62
+
52
63
  constructor(
53
64
  address _SCY,
54
65
  address _PT,
@@ -56,7 +67,7 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
56
67
  string memory _symbol,
57
68
  uint8 __decimals,
58
69
  uint256 _expiry
59
- ) PendleERC20(_name, _symbol, __decimals) {
70
+ ) PendleERC20Permit(_name, _symbol, __decimals) {
60
71
  SCY = _SCY;
61
72
  PT = _PT;
62
73
  expiry = _expiry;
@@ -67,20 +78,41 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
67
78
  function mintPY(address receiverPT, address receiverYT)
68
79
  external
69
80
  nonReentrant
81
+ notExpired
70
82
  updateData
71
83
  returns (uint256 amountPYOut)
72
84
  {
73
- require(!isExpired(), "yield contract expired");
74
-
75
- uint256 amountScyToMint = _getFloatingScyAmount();
76
-
77
- amountPYOut = _calcPYToMint(amountScyToMint);
78
-
79
- _mint(receiverYT, amountPYOut);
80
-
81
- IPPrincipalToken(PT).mintByYT(receiverPT, amountPYOut);
85
+ address[] memory receiverPTs = new address[](1);
86
+ address[] memory receiverYTs = new address[](1);
87
+ uint256[] memory amountScyToMints = new uint256[](1);
88
+
89
+ (receiverPTs[0], receiverYTs[0], amountScyToMints[0]) = (
90
+ receiverPT,
91
+ receiverYT,
92
+ _getFloatingScyAmount()
93
+ );
94
+
95
+ uint256[] memory amountPYOuts = _mintPY(receiverPTs, receiverYTs, amountScyToMints);
96
+ amountPYOut = amountPYOuts[0];
97
+ }
82
98
 
83
- emit Mint(msg.sender, receiverPT, receiverYT, amountScyToMint, amountPYOut);
99
+ /// @notice Tokenize SCY into PT + YT of equal qty. Every unit of underlying of SCY will create 1 PT + 1 YT
100
+ function mintPYMulti(
101
+ address[] calldata receiverPTs,
102
+ address[] calldata receiverYTs,
103
+ uint256[] calldata amountScyToMints
104
+ ) external nonReentrant notExpired updateData returns (uint256[] memory amountPYOuts) {
105
+ uint256 length = receiverPTs.length;
106
+
107
+ if (receiverYTs.length != length && amountScyToMints.length == length)
108
+ revert Errors.ArrayLengthMismatch();
109
+ if (length == 0) revert Errors.ArrayEmpty();
110
+
111
+ uint256 totalScyToMint = amountScyToMints.sum();
112
+ if (totalScyToMint > _getFloatingScyAmount())
113
+ revert Errors.YieldContractInsufficientScy(totalScyToMint, _getFloatingScyAmount());
114
+
115
+ amountPYOuts = _mintPY(receiverPTs, receiverYTs, amountScyToMints);
84
116
  }
85
117
 
86
118
  /// @dev this function converts PY tokens into scy, but interests & rewards are not redeemed at the same time
@@ -109,8 +141,8 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
109
141
  updateData
110
142
  returns (uint256[] memory amountScyOuts)
111
143
  {
112
- require(receivers.length == amountPYToRedeems.length, "not same length");
113
- require(receivers.length != 0, "empty array");
144
+ if (receivers.length != amountPYToRedeems.length) revert Errors.ArrayLengthMismatch();
145
+ if (receivers.length == 0) revert Errors.ArrayEmpty();
114
146
  amountScyOuts = _redeemPY(receivers, amountPYToRedeems);
115
147
  }
116
148
 
@@ -126,7 +158,7 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
126
158
  bool redeemInterest,
127
159
  bool redeemRewards
128
160
  ) external nonReentrant updateData returns (uint256 interestOut, uint256[] memory rewardsOut) {
129
- require(redeemInterest || redeemRewards, "nothing to redeem");
161
+ if (!redeemInterest && !redeemRewards) revert Errors.YCNothingToRedeem();
130
162
 
131
163
  // if redeemRewards == true, this line must be here for obvious reason
132
164
  // if redeemInterest == true, this line must be here because of the reason above
@@ -155,7 +187,7 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
155
187
  updateData
156
188
  returns (uint256 interestOut, uint256[] memory rewardsOut)
157
189
  {
158
- require(isExpired(), "not expired");
190
+ if (!isExpired()) revert Errors.YCNotExpired();
159
191
 
160
192
  address treasury = IPYieldContractFactory(factory).treasury();
161
193
 
@@ -175,23 +207,19 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
175
207
  _transferOut(SCY, treasury, interestOut);
176
208
  }
177
209
 
178
- function rewardIndexesCurrent() external override returns (uint256[] memory) {
210
+ function rewardIndexesCurrent() external override nonReentrant returns (uint256[] memory) {
179
211
  return ISuperComposableYield(SCY).rewardIndexesCurrent();
180
212
  }
181
213
 
182
214
  /// @dev maximize the current rate with the previous rate to guarantee non-decreasing rate
183
- function pyIndexCurrent() public returns (uint256 currentIndex) {
184
- currentIndex = Math.max(ISuperComposableYield(SCY).exchangeRate(), _pyIndexStored);
185
- _pyIndexStored = currentIndex.Uint128();
186
- emit NewInterestIndex(currentIndex);
187
- }
188
-
189
- function pyIndexStored() public view returns (uint256) {
190
- return _pyIndexStored;
215
+ function pyIndexCurrent() public nonReentrant returns (uint256 currentIndex) {
216
+ currentIndex = _pyIndexCurrent();
191
217
  }
192
218
 
193
- function isExpired() public view returns (bool) {
194
- return MiniHelpers.isCurrentlyExpired(expiry);
219
+ function setPostExpiryData() external nonReentrant {
220
+ if (isExpired()) {
221
+ _setPostExpiryData();
222
+ }
195
223
  }
196
224
 
197
225
  function getPostExpiryData()
@@ -204,7 +232,7 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
204
232
  uint256[] memory userRewardOwed
205
233
  )
206
234
  {
207
- require(postExpiry.firstPYIndex != 0, "PostExpiry data not set");
235
+ if (postExpiry.firstPYIndex == 0) revert Errors.YCPostExpiryDataNotSet();
208
236
 
209
237
  firstPYIndex = postExpiry.firstPYIndex;
210
238
  totalScyInterestForTreasury = postExpiry.totalScyInterestForTreasury;
@@ -219,6 +247,39 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
219
247
  }
220
248
  }
221
249
 
250
+ function _mintPY(
251
+ address[] memory receiverPTs,
252
+ address[] memory receiverYTs,
253
+ uint256[] memory amountScyToMints
254
+ ) internal returns (uint256[] memory amountPYOuts) {
255
+ amountPYOuts = new uint256[](amountScyToMints.length);
256
+
257
+ uint256 index = _pyIndexCurrent();
258
+
259
+ for (uint256 i = 0; i < amountScyToMints.length; i++) {
260
+ amountPYOuts[i] = _calcPYToMint(amountScyToMints[i], index);
261
+
262
+ _mint(receiverYTs[i], amountPYOuts[i]);
263
+ IPPrincipalToken(PT).mintByYT(receiverPTs[i], amountPYOuts[i]);
264
+
265
+ emit Mint(
266
+ msg.sender,
267
+ receiverPTs[i],
268
+ receiverYTs[i],
269
+ amountScyToMints[i],
270
+ amountPYOuts[i]
271
+ );
272
+ }
273
+ }
274
+
275
+ function pyIndexStored() public view returns (uint256) {
276
+ return _pyIndexStored;
277
+ }
278
+
279
+ function isExpired() public view returns (bool) {
280
+ return MiniHelpers.isCurrentlyExpired(expiry);
281
+ }
282
+
222
283
  function _redeemPY(address[] memory receivers, uint256[] memory amountPYToRedeems)
223
284
  internal
224
285
  returns (uint256[] memory amountScyOuts)
@@ -227,7 +288,7 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
227
288
  IPPrincipalToken(PT).burnByYT(address(this), totalAmountPYToRedeem);
228
289
  if (!isExpired()) _burn(address(this), totalAmountPYToRedeem);
229
290
 
230
- uint256 index = pyIndexCurrent();
291
+ uint256 index = _pyIndexCurrent();
231
292
  uint256 totalScyInterestPostExpiry;
232
293
  amountScyOuts = new uint256[](receivers.length);
233
294
 
@@ -247,9 +308,13 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
247
308
  }
248
309
  }
249
310
 
250
- function _calcPYToMint(uint256 amountScy) internal returns (uint256 amountPY) {
311
+ function _calcPYToMint(uint256 amountScy, uint256 indexCurrent)
312
+ internal
313
+ pure
314
+ returns (uint256 amountPY)
315
+ {
251
316
  // doesn't matter before or after expiry, since mintPY is only allowed before expiry
252
- return SCYUtils.scyToAsset(pyIndexCurrent(), amountScy);
317
+ return SCYUtils.scyToAsset(indexCurrent, amountScy);
253
318
  }
254
319
 
255
320
  function _calcScyRedeemableFromPY(uint256 amountPY, uint256 indexCurrent)
@@ -275,7 +340,7 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
275
340
 
276
341
  function _getFloatingScyAmount() internal view returns (uint256 amount) {
277
342
  amount = _selfBalance(SCY) - scyReserve;
278
- require(amount > 0, "RECEIVE_ZERO");
343
+ if (amount == 0) revert Errors.YCNoFloatingScy();
279
344
  }
280
345
 
281
346
  function _setPostExpiryData() internal {
@@ -284,7 +349,7 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
284
349
 
285
350
  _redeemExternalReward(); // do a final redeem. All the future reward income will belong to the treasury
286
351
 
287
- local.firstPYIndex = pyIndexCurrent().Uint128();
352
+ local.firstPYIndex = _pyIndexCurrent().Uint128();
288
353
  address[] memory rewardTokens = ISuperComposableYield(SCY).getRewardTokens();
289
354
  uint256[] memory rewardIndexes = ISuperComposableYield(SCY).rewardIndexesCurrent();
290
355
  for (uint256 i = 0; i < rewardTokens.length; i++) {
@@ -299,7 +364,13 @@ contract PendleYieldToken is IPYieldToken, PendleERC20, RewardManagerAbstract, I
299
364
 
300
365
  function _getInterestIndex() internal virtual override returns (uint256 index) {
301
366
  if (isExpired()) index = postExpiry.firstPYIndex;
302
- else index = pyIndexCurrent();
367
+ else index = _pyIndexCurrent();
368
+ }
369
+
370
+ function _pyIndexCurrent() internal returns (uint256 currentIndex) {
371
+ currentIndex = Math.max(ISuperComposableYield(SCY).exchangeRate(), _pyIndexStored);
372
+ _pyIndexStored = currentIndex.Uint128();
373
+ emit NewInterestIndex(currentIndex);
303
374
  }
304
375
 
305
376
  function _YTbalance(address user) internal view override returns (uint256) {
@@ -4,6 +4,7 @@ pragma solidity 0.8.15;
4
4
  import "./base/ActionBaseMintRedeem.sol";
5
5
  import "../../interfaces/IPActionAddRemoveLiq.sol";
6
6
  import "../../interfaces/IPMarket.sol";
7
+ import "../../libraries/Errors.sol";
7
8
 
8
9
  contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
9
10
  using Math for uint256;
@@ -33,19 +34,17 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
33
34
  uint256 netPtUsed
34
35
  )
35
36
  {
36
- (ISuperComposableYield SCY, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market)
37
- .readTokens();
37
+ (ISuperComposableYield SCY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
38
38
 
39
39
  MarketState memory state = IPMarket(market).readState();
40
40
  (, netLpOut, netScyUsed, netPtUsed) = state.addLiquidity(
41
- YT.newIndex(),
42
41
  netScyDesired,
43
42
  netPtDesired,
44
43
  block.timestamp
45
44
  );
46
45
 
47
46
  // early-check
48
- require(netLpOut >= minLpOut, "insufficient lp out");
47
+ if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
49
48
 
50
49
  IERC20(SCY).safeTransferFrom(msg.sender, market, netScyUsed);
51
50
  IERC20(PT).safeTransferFrom(msg.sender, market, netPtUsed);
@@ -53,7 +52,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
53
52
  (netLpOut, , ) = IPMarket(market).mint(receiver, netScyUsed, netPtUsed);
54
53
 
55
54
  // fail-safe
56
- require(netLpOut >= minLpOut, "FS insufficient lp out");
55
+ if (netLpOut < minLpOut) assert(false);
56
+
57
57
  emit AddLiquidityDualScyAndPt(
58
58
  msg.sender,
59
59
  market,
@@ -80,8 +80,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
80
80
  uint256 netPtUsed
81
81
  )
82
82
  {
83
- (ISuperComposableYield SCY, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market)
84
- .readTokens();
83
+ (ISuperComposableYield SCY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
85
84
 
86
85
  uint256 netScyDesired = SCY.previewDeposit(tokenIn, netTokenDesired);
87
86
  uint256 netScyUsed;
@@ -89,15 +88,13 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
89
88
  {
90
89
  MarketState memory state = IPMarket(market).readState();
91
90
  (, netLpOut, netScyUsed, netPtUsed) = state.addLiquidity(
92
- YT.newIndex(),
93
91
  netScyDesired,
94
92
  netPtDesired,
95
93
  block.timestamp
96
94
  );
97
95
  }
98
96
 
99
- // early-check
100
- require(netLpOut >= minLpOut, "insufficient lp out");
97
+ if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
101
98
 
102
99
  IERC20(PT).safeTransferFrom(msg.sender, market, netPtUsed);
103
100
 
@@ -115,8 +112,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
115
112
  }
116
113
 
117
114
  (netLpOut, , ) = IPMarket(market).mint(receiver, netScyUsed, netPtUsed);
118
- // fail-safe
119
- require(netLpOut >= minLpOut, "FS insufficient lp out");
115
+
116
+ if (netLpOut < minLpOut) assert(false);
120
117
 
121
118
  emit AddLiquidityDualTokenAndPt(
122
119
  msg.sender,
@@ -135,7 +132,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
135
132
  uint256 netPtIn,
136
133
  uint256 minLpOut,
137
134
  ApproxParams calldata guessPtSwapToScy
138
- ) external returns (uint256 netLpOut) {
135
+ ) external returns (uint256 netLpOut, uint256 netScyFee) {
139
136
  (, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
140
137
 
141
138
  MarketState memory state = IPMarket(market).readState();
@@ -149,14 +146,16 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
149
146
 
150
147
  IERC20(PT).safeTransferFrom(msg.sender, market, netPtIn);
151
148
 
152
- (uint256 netScyReceived, ) = IPMarket(market).swapExactPtForScy(
149
+ uint256 netScyReceived;
150
+ (netScyReceived, netScyFee) = IPMarket(market).swapExactPtForScy(
153
151
  market,
154
152
  netPtSwap,
155
153
  EMPTY_BYTES
156
154
  ); // ignore return, receiver = market
155
+
157
156
  (netLpOut, , ) = IPMarket(market).mint(receiver, netScyReceived, netPtIn - netPtSwap);
158
157
 
159
- require(netLpOut >= minLpOut, "insufficient lp out");
158
+ if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
160
159
 
161
160
  emit AddLiquiditySinglePt(msg.sender, market, receiver, netPtIn, netLpOut);
162
161
  }
@@ -167,11 +166,11 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
167
166
  uint256 netScyIn,
168
167
  uint256 minLpOut,
169
168
  ApproxParams calldata guessPtReceivedFromScy
170
- ) external returns (uint256 netLpOut) {
169
+ ) external returns (uint256 netLpOut, uint256 netScyFee) {
171
170
  (ISuperComposableYield SCY, , IPYieldToken YT) = IPMarket(market).readTokens();
172
171
  IERC20(SCY).safeTransferFrom(msg.sender, market, netScyIn);
173
172
 
174
- netLpOut = _addLiquiditySingleScy(
173
+ (netLpOut, netScyFee) = _addLiquiditySingleScy(
175
174
  receiver,
176
175
  market,
177
176
  YT,
@@ -189,13 +188,13 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
189
188
  uint256 minLpOut,
190
189
  ApproxParams calldata guessPtReceivedFromScy,
191
190
  TokenInput calldata input
192
- ) external payable returns (uint256 netLpOut) {
191
+ ) external payable returns (uint256 netLpOut, uint256 netScyFee) {
193
192
  (ISuperComposableYield SCY, , IPYieldToken YT) = IPMarket(market).readTokens();
194
193
 
195
194
  // all output SCY is transferred directly to the market
196
195
  uint256 netScyUsed = _mintScyFromToken(address(market), address(SCY), 1, input);
197
196
 
198
- netLpOut = _addLiquiditySingleScy(
197
+ (netLpOut, netScyFee) = _addLiquiditySingleScy(
199
198
  receiver,
200
199
  market,
201
200
  YT,
@@ -225,8 +224,8 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
225
224
 
226
225
  (netScyOut, netPtOut) = IPMarket(market).burn(receiver, receiver, netLpToRemove);
227
226
 
228
- require(netScyOut >= minScyOut, "insufficient SCY out");
229
- require(netPtOut >= minPtOut, "insufficient PT out");
227
+ if (netScyOut < minScyOut) revert Errors.RouterInsufficientScyOut(netScyOut, minScyOut);
228
+ if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
230
229
 
231
230
  emit RemoveLiquidityDualScyAndPt(
232
231
  msg.sender,
@@ -250,11 +249,12 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
250
249
 
251
250
  IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
252
251
 
253
- (, netPtOut) = IPMarket(market).burn(address(SCY), receiver, netLpToRemove);
252
+ uint256 netScyOut;
253
+ (netScyOut, netPtOut) = IPMarket(market).burn(address(SCY), receiver, netLpToRemove);
254
254
 
255
- netTokenOut = SCY.redeemAfterTransfer(receiver, tokenOut, minTokenOut);
255
+ netTokenOut = SCY.redeem(receiver, netScyOut, tokenOut, minTokenOut, true);
256
256
 
257
- require(netPtOut >= minPtOut, "insufficient PT out");
257
+ if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
258
258
 
259
259
  emit RemoveLiquidityDualTokenAndPt(
260
260
  msg.sender,
@@ -273,7 +273,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
273
273
  uint256 netLpToRemove,
274
274
  uint256 minPtOut,
275
275
  ApproxParams calldata guessPtOut
276
- ) external returns (uint256 netPtOut) {
276
+ ) external returns (uint256 netPtOut, uint256 netScyFee) {
277
277
  (, , IPYieldToken YT) = IPMarket(market).readTokens();
278
278
 
279
279
  IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
@@ -287,14 +287,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
287
287
  guessPtOut
288
288
  );
289
289
 
290
- // early-check
291
- require(ptFromBurn + ptFromSwap >= minPtOut, "insufficient lp out");
290
+ if (ptFromBurn + ptFromSwap < minPtOut)
291
+ revert Errors.RouterInsufficientPtOut(ptFromBurn + ptFromSwap, minPtOut);
292
292
 
293
293
  (, ptFromBurn) = IPMarket(market).burn(market, receiver, netLpToRemove);
294
- IPMarket(market).swapScyForExactPt(receiver, ptFromSwap, EMPTY_BYTES); // ignore return
294
+ (, netScyFee) = IPMarket(market).swapScyForExactPt(receiver, ptFromSwap, EMPTY_BYTES);
295
295
 
296
296
  // fail-safe
297
- require(ptFromBurn + ptFromSwap >= minPtOut, "FS insufficient lp out");
297
+ if (ptFromBurn + ptFromSwap < minPtOut) assert(false);
298
+
298
299
  netPtOut = ptFromBurn + ptFromSwap;
299
300
 
300
301
  emit RemoveLiquiditySinglePt(msg.sender, market, receiver, netLpToRemove, netPtOut);
@@ -305,9 +306,14 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
305
306
  address market,
306
307
  uint256 netLpToRemove,
307
308
  uint256 minScyOut
308
- ) external returns (uint256 netScyOut) {
309
+ ) external returns (uint256 netScyOut, uint256 netScyFee) {
309
310
  IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
310
- netScyOut = _removeLiquiditySingleScy(receiver, market, netLpToRemove, minScyOut);
311
+ (netScyOut, netScyFee) = _removeLiquiditySingleScy(
312
+ receiver,
313
+ market,
314
+ netLpToRemove,
315
+ minScyOut
316
+ );
311
317
  emit RemoveLiquiditySingleScy(msg.sender, market, receiver, netLpToRemove, netScyOut);
312
318
  }
313
319
 
@@ -316,13 +322,20 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
316
322
  address market,
317
323
  uint256 netLpToRemove,
318
324
  TokenOutput calldata output
319
- ) external returns (uint256 netTokenOut) {
325
+ ) external returns (uint256 netTokenOut, uint256 netScyFee) {
320
326
  (ISuperComposableYield SCY, , ) = IPMarket(market).readTokens();
321
327
 
322
328
  IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
323
329
 
324
330
  // all output SCY is directly transferred to the SCY contract
325
- uint256 netScyReceived = _removeLiquiditySingleScy(address(SCY), market, netLpToRemove, 1);
331
+ uint256 netScyReceived;
332
+
333
+ (netScyReceived, netScyFee) = _removeLiquiditySingleScy(
334
+ address(SCY),
335
+ market,
336
+ netLpToRemove,
337
+ 1
338
+ );
326
339
 
327
340
  // since all SCY is already at the SCY contract, doPull = false
328
341
  netTokenOut = _redeemScyToToken(receiver, address(SCY), netScyReceived, output, false);
@@ -344,7 +357,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
344
357
  uint256 netScyIn,
345
358
  uint256 minLpOut,
346
359
  ApproxParams calldata guessPtReceivedFromScy
347
- ) internal returns (uint256 netLpOut) {
360
+ ) internal returns (uint256 netLpOut, uint256 netScyFee) {
348
361
  MarketState memory state = IPMarket(market).readState();
349
362
 
350
363
  (uint256 netPtReceived, , ) = state.approxSwapScyToAddLiquidity(
@@ -354,14 +367,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
354
367
  guessPtReceivedFromScy
355
368
  );
356
369
 
357
- (uint256 netScySwapped, ) = IPMarket(market).swapScyForExactPt(
370
+ uint256 netScySwapped;
371
+ (netScySwapped, netScyFee) = IPMarket(market).swapScyForExactPt(
358
372
  market,
359
373
  netPtReceived,
360
374
  EMPTY_BYTES
361
375
  ); // ignore return, receiver = market
362
376
  (netLpOut, , ) = IPMarket(market).mint(receiver, netScyIn - netScySwapped, netPtReceived);
363
377
 
364
- require(netLpOut >= minLpOut, "insufficient lp out");
378
+ if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
365
379
  }
366
380
 
367
381
  function _removeLiquiditySingleScy(
@@ -369,13 +383,14 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
369
383
  address market,
370
384
  uint256 netLpToRemove,
371
385
  uint256 minScyOut
372
- ) internal returns (uint256 netScyOut) {
386
+ ) internal returns (uint256 netScyOut, uint256 netScyFee) {
373
387
  if (IPMarket(market).isExpired()) {
374
388
  netScyOut = __removeLpToScyAfterExpiry(receiver, market, netLpToRemove);
375
389
  } else {
376
- netScyOut = __removeLpToScyBeforeExpiry(receiver, market, netLpToRemove);
390
+ (netScyOut, netScyFee) = __removeLpToScyBeforeExpiry(receiver, market, netLpToRemove);
377
391
  }
378
- require(netScyOut >= minScyOut, "insufficient lp out");
392
+
393
+ if (netScyOut < minScyOut) revert Errors.RouterInsufficientScyOut(netScyOut, minScyOut);
379
394
  }
380
395
 
381
396
  function __removeLpToScyAfterExpiry(
@@ -392,13 +407,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
392
407
  address receiver,
393
408
  address market,
394
409
  uint256 netLpToRemove
395
- ) internal returns (uint256 netScyOut) {
410
+ ) internal returns (uint256 netScyOut, uint256 netScyFee) {
396
411
  (uint256 scyFromBurn, uint256 ptFromBurn) = IPMarket(market).burn(
397
412
  receiver,
398
413
  market,
399
414
  netLpToRemove
400
415
  );
401
- (uint256 scyFromSwap, ) = IPMarket(market).swapExactPtForScy(
416
+
417
+ uint256 scyFromSwap;
418
+ (scyFromSwap, netScyFee) = IPMarket(market).swapExactPtForScy(
402
419
  receiver,
403
420
  ptFromBurn,
404
421
  EMPTY_BYTES
@@ -6,6 +6,8 @@ import "../../interfaces/IPMarket.sol";
6
6
  import "../../interfaces/IPMarketSwapCallback.sol";
7
7
  import "../../libraries/SCY/SCYUtils.sol";
8
8
  import "../../libraries/math/MarketApproxLib.sol";
9
+ import "../../libraries/Errors.sol";
10
+
9
11
  import "./base/ActionBaseMintRedeem.sol";
10
12
  import "./base/CallbackHelper.sol";
11
13
  import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
@@ -22,14 +24,14 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
22
24
 
23
25
  address public immutable marketFactory;
24
26
 
25
- modifier onlyPendleMarket(address market) {
26
- require(IPMarketFactory(marketFactory).isValidMarket(market), "INVALID_MARKET");
27
+ modifier onlyPendleMarket(address caller) {
28
+ if (!IPMarketFactory(marketFactory).isValidMarket(caller))
29
+ revert Errors.RouterCallbackNotPendleMarket(caller);
27
30
  _;
28
31
  }
29
32
 
30
33
  /// @dev since this contract will be proxied, it must not contains non-immutable variables
31
34
  constructor(address _marketFactory) {
32
- require(_marketFactory != address(0), "zero address");
33
35
  marketFactory = _marketFactory;
34
36
  }
35
37
 
@@ -54,7 +56,7 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
54
56
  } else if (swapType == ActionType.SwapExactPtForYt) {
55
57
  _callbackSwapExactPtForYt(market, ptToAccount, scyToAccount, data);
56
58
  } else {
57
- require(false, "unknown swapType");
59
+ assert(false);
58
60
  }
59
61
  }
60
62
 
@@ -71,8 +73,8 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
71
73
  uint256 ptOwed = ptToAccount.abs();
72
74
  uint256 netPyOut = YT.mintPY(market, receiver);
73
75
 
74
- require(netPyOut >= ptOwed, "insufficient PT to pay");
75
- require(netPyOut >= minYtOut, "insufficient YT out");
76
+ if (netPyOut < ptOwed) revert Errors.RouterInsufficientPtRepay(netPyOut, ptOwed);
77
+ if (netPyOut < minYtOut) revert Errors.RouterInsufficientYtOut(netPyOut, minYtOut);
76
78
  }
77
79
 
78
80
  struct VarsSwapScyForExactYt {
@@ -104,7 +106,9 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
104
106
  /// ------------------------------------------------------------
105
107
  uint256 scyReceived = scyToAccount.Uint();
106
108
  uint256 netScyToPull = totalScyNeed.subMax0(scyReceived);
107
- require(netScyToPull <= vars.maxScyToPull, "exceed SCY in limit");
109
+
110
+ if (netScyToPull > vars.maxScyToPull)
111
+ revert Errors.RouterExceededLimitScyIn(netScyToPull, vars.maxScyToPull);
108
112
 
109
113
  /// ------------------------------------------------------------
110
114
  /// mint & transfer
@@ -114,7 +118,7 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
114
118
  }
115
119
 
116
120
  uint256 netPyOut = YT.mintPY(market, vars.receiver);
117
- require(netPyOut >= ptOwed, "insufficient pt to pay");
121
+ if (netPyOut < ptOwed) revert Errors.RouterInsufficientPtRepay(netPyOut, ptOwed);
118
122
  }
119
123
 
120
124
  /// @dev refer to _swapExactYtForScy or _swapYtForExactScy
@@ -140,7 +144,8 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
140
144
  );
141
145
 
142
146
  uint256[] memory amountScyOuts = YT.redeemPYMulti(receivers, amountPYToRedeems);
143
- require(amountScyOuts[1] >= minScyOut, "insufficient SCY out");
147
+ if (amountScyOuts[1] < minScyOut)
148
+ revert Errors.RouterInsufficientScyOut(amountScyOuts[1], minScyOut);
144
149
  }
145
150
 
146
151
  function _callbackSwapExactPtForYt(
@@ -154,8 +159,9 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
154
159
  (, , IPYieldToken YT) = IPMarket(market).readTokens();
155
160
 
156
161
  uint256 netPyOut = YT.mintPY(market, receiver);
157
- require(netPyOut >= minYtOut, "insufficient YT out");
158
- require(exactPtIn + netPyOut >= netPtOwed, "insufficient PT to pay");
162
+ if (netPyOut < minYtOut) revert Errors.RouterInsufficientYtOut(netPyOut, minYtOut);
163
+ if (exactPtIn + netPyOut < netPtOwed)
164
+ revert Errors.RouterInsufficientPtRepay(exactPtIn + netPyOut, netPtOwed);
159
165
  }
160
166
 
161
167
  function _callbackSwapExactYtForPt(
@@ -172,8 +178,12 @@ contract ActionCallback is IPMarketSwapCallback, CallbackHelper {
172
178
  PT.safeTransfer(address(YT), exactYtIn);
173
179
  uint256 netScyToMarket = YT.redeemPY(market);
174
180
 
175
- require(netScyToMarket >= netScyOwed, "insufficient SCY to pay");
176
- require(ptToAccount.Uint() - exactYtIn >= minPtOut, "insufficient PT out");
177
- PT.safeTransfer(receiver, ptToAccount.Uint() - exactYtIn);
181
+ if (netScyToMarket < netScyOwed)
182
+ revert Errors.RouterInsufficientScyRepay(netScyToMarket, netScyOwed);
183
+
184
+ uint256 netPtOut = ptToAccount.Uint() - exactYtIn;
185
+ if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
186
+
187
+ PT.safeTransfer(receiver, netPtOut);
178
188
  }
179
189
  }