@pendle/core-v2 0.16.6-testnet → 0.17.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 (321) hide show
  1. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
  2. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
  3. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
  4. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
  5. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +2 -2
  6. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
  7. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
  8. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
  9. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +2 -2
  10. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
  11. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +2 -2
  12. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  13. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  14. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
  15. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  16. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
  17. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  18. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
  19. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  20. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  21. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
  22. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  23. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +16 -5
  24. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  25. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.json +0 -13
  26. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  27. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  28. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  29. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
  30. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  31. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  32. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
  33. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +2 -15
  34. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
  35. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +2 -2
  36. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
  37. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
  38. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  39. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
  40. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  41. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
  42. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  43. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  44. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +25 -13
  45. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  46. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +221 -50
  47. package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +1 -1
  48. package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.json +2 -2
  49. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  50. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.json +141 -0
  51. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  52. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.json +141 -0
  53. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  54. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
  55. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +143 -2
  57. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +4 -0
  58. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +1144 -0
  59. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +4 -0
  60. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +1209 -0
  61. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +4 -0
  62. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.json +10 -0
  63. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +1 -1
  64. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.json +3 -82
  65. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +4 -0
  66. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.json +10 -0
  67. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +4 -0
  68. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol/PendleConvexLPSY.json +142 -1
  69. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +4 -0
  70. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +997 -0
  71. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  72. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +143 -2
  73. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  74. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  75. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +2 -2
  76. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  77. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +83 -10
  78. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  79. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +35 -4
  80. package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
  81. package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.json +2 -2
  82. package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
  83. package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
  84. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
  85. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +3 -38
  86. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +1 -1
  87. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.json +2 -2
  88. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
  89. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
  90. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.json +2 -2
  91. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  92. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +105 -31
  93. package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
  94. package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.json +1 -1
  95. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
  96. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +14 -7
  97. package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.dbg.json +4 -0
  98. package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.json +213 -0
  99. package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
  100. package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.json +1 -1
  101. package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.dbg.json +4 -0
  102. package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.json +30 -0
  103. package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.dbg.json +4 -0
  104. package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.json +76 -0
  105. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  106. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +8 -8
  107. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  108. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +18 -18
  109. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  110. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
  111. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  112. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +2 -2
  113. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  114. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +28 -28
  115. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
  116. package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +1 -1
  117. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  118. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +17 -5
  119. package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
  120. package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.json +50 -19
  121. package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +1 -1
  122. package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.json +1 -1
  123. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  124. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  125. package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
  126. package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.json +7 -7
  127. package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
  128. package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.json +13 -0
  129. package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
  130. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
  131. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +2 -2
  132. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
  133. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +58 -2
  134. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
  135. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -46
  136. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  137. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +62 -62
  138. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  139. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +11 -11
  140. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  141. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
  142. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  143. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +20 -20
  144. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
  145. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
  146. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  147. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +2 -2
  148. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
  149. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +3 -3
  150. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  151. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +4 -4
  152. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  153. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -186
  154. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  155. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  156. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  157. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  158. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  159. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
  160. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -2
  161. package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
  162. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +1 -1
  163. package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +3 -6
  164. package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +7 -4
  165. package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +10 -5
  166. package/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +1 -4
  167. package/contracts/LiquidityMining/libraries/VeHistoryLib.sol +0 -5
  168. package/contracts/core/BulkSeller/BulkSeller.sol +0 -5
  169. package/contracts/core/BulkSeller/BulkSellerFactory.sol +7 -6
  170. package/contracts/core/Market/MarketMathCore.sol +52 -11
  171. package/contracts/core/Market/PendleMarket.sol +35 -22
  172. package/contracts/core/Market/PendleMarketFactory.sol +67 -35
  173. package/contracts/core/StandardizedYield/SYBase.sol +26 -3
  174. package/contracts/core/StandardizedYield/SYBaseWithRewards.sol +3 -1
  175. package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +102 -0
  176. package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +160 -0
  177. package/contracts/core/StandardizedYield/implementations/Convex/README.md +29 -0
  178. package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +215 -0
  179. package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +46 -26
  180. package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +152 -0
  181. package/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol +0 -0
  182. package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +128 -0
  183. package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
  184. package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +30 -12
  185. package/contracts/core/YieldContracts/PendleYieldToken.sol +79 -22
  186. package/contracts/core/erc20/PendleERC20.sol +4 -7
  187. package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -1
  188. package/contracts/core/libraries/BoringOwnableUpgradeable.sol +1 -1
  189. package/contracts/core/libraries/Errors.sol +12 -2
  190. package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -1
  191. package/contracts/interfaces/Curve/ICrvPool.sol +3 -4
  192. package/contracts/interfaces/Curve/ITriCrvPool.sol +41 -0
  193. package/contracts/interfaces/IERC4626.sol +1 -1
  194. package/contracts/interfaces/ILooksFeeSharing.sol +5 -0
  195. package/contracts/interfaces/ILooksStaking.sol +13 -0
  196. package/contracts/interfaces/IPActionAddRemoveLiq.sol +4 -4
  197. package/contracts/interfaces/IPActionMintRedeem.sol +8 -8
  198. package/contracts/interfaces/IPActionSwapYT.sol +2 -2
  199. package/contracts/interfaces/IPMarket.sol +20 -4
  200. package/contracts/interfaces/IPMarketFactory.sol +15 -5
  201. package/contracts/interfaces/IPMsgSendEndpoint.sol +1 -1
  202. package/contracts/interfaces/IPYieldContractFactory.sol +2 -2
  203. package/contracts/interfaces/IPYieldToken.sol +2 -0
  204. package/contracts/interfaces/IStandardizedYield.sol +15 -10
  205. package/contracts/offchain-helpers/BulkSellerOffchain.sol +17 -8
  206. package/contracts/offchain-helpers/MarketMathStatic.sol +35 -96
  207. package/contracts/offchain-helpers/RouterStatic.sol +8 -6
  208. package/contracts/router/ActionAddRemoveLiq.sol +102 -10
  209. package/contracts/router/ActionMintRedeem.sol +44 -4
  210. package/contracts/router/ActionSwapPT.sol +41 -11
  211. package/contracts/router/ActionSwapPTYT.sol +32 -7
  212. package/contracts/router/ActionSwapYT.sol +49 -33
  213. package/contracts/router/PendleRouter.sol +3 -11
  214. package/contracts/router/base/MarketApproxLib.sol +52 -18
  215. package/deployments/43113-core.json +18 -14
  216. package/deployments/43113-markets/USDC-FEB-2ND.json +10 -0
  217. package/deployments/43113-markets/WETH-FEB-2ND.json +10 -0
  218. package/deployments/43113-testenv.json +1 -2
  219. package/package.json +5 -5
  220. package/typechain-types/ActionAddRemoveLiq.ts +18 -18
  221. package/typechain-types/ActionMintRedeem.ts +30 -30
  222. package/typechain-types/ActionSwapPTYT.ts +5 -5
  223. package/typechain-types/ActionSwapYT.ts +5 -5
  224. package/typechain-types/BulkSeller.ts +0 -19
  225. package/typechain-types/BulkSellerOffchain.ts +74 -0
  226. package/typechain-types/IBooster.ts +9 -3
  227. package/typechain-types/ICrvPool.ts +4 -9
  228. package/typechain-types/IERC4626.ts +5 -5
  229. package/typechain-types/IPActionAddRemoveLiq.ts +13 -13
  230. package/typechain-types/IPActionMintRedeem.ts +30 -30
  231. package/typechain-types/IPActionSwapYT.ts +5 -5
  232. package/typechain-types/IPAllAction.ts +48 -48
  233. package/typechain-types/IPMarket.ts +26 -16
  234. package/typechain-types/IPMarketFactory.ts +70 -37
  235. package/typechain-types/IPMsgSendEndpoint.ts +1 -1
  236. package/typechain-types/IPYieldContractFactory.ts +11 -11
  237. package/typechain-types/IPYieldToken.ts +21 -0
  238. package/typechain-types/MarketMathStatic.ts +0 -67
  239. package/typechain-types/PendleConvexLPSY.ts +204 -0
  240. package/typechain-types/PendleMarket.ts +26 -16
  241. package/typechain-types/PendleMarketFactory.ts +316 -92
  242. package/typechain-types/PendleQiTokenSY.ts +204 -0
  243. package/typechain-types/PendleRouter.ts +3 -287
  244. package/typechain-types/PendleWstEthSY.ts +204 -0
  245. package/typechain-types/PendleYieldContractFactory.ts +63 -18
  246. package/typechain-types/PendleYieldToken.ts +42 -0
  247. package/typechain-types/RouterStatic.ts +2 -2
  248. package/typechain-types/SYBase.ts +204 -0
  249. package/typechain-types/SYBaseWithRewards.ts +204 -0
  250. package/typechain-types/VotingEscrowPendleSidechain.ts +8 -8
  251. package/typechain-types/VotingEscrowTokenBase.ts +0 -21
  252. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +10 -10
  253. package/typechain-types/factories/ActionCallback__factory.ts +1 -1
  254. package/typechain-types/factories/ActionMintRedeem__factory.ts +19 -19
  255. package/typechain-types/factories/ActionMisc__factory.ts +1 -1
  256. package/typechain-types/factories/ActionSwapPTYT__factory.ts +2 -2
  257. package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
  258. package/typechain-types/factories/ActionSwapYT__factory.ts +3 -3
  259. package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -1
  260. package/typechain-types/factories/BaseSplitCodeFactoryContract__factory.ts +1 -1
  261. package/typechain-types/factories/BoringOwnableUpgradeableData__factory.ts +1 -1
  262. package/typechain-types/factories/BulkSellerFactory__factory.ts +1 -1
  263. package/typechain-types/factories/BulkSellerOffchain__factory.ts +57 -1
  264. package/typechain-types/factories/BulkSeller__factory.ts +1 -14
  265. package/typechain-types/factories/Errors__factory.ts +104 -30
  266. package/typechain-types/factories/IBooster__factory.ts +1 -1
  267. package/typechain-types/factories/ICrvPool__factory.ts +14 -7
  268. package/typechain-types/factories/IERC4626__factory.ts +1 -1
  269. package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +8 -8
  270. package/typechain-types/factories/IPActionMintRedeem__factory.ts +18 -18
  271. package/typechain-types/factories/IPActionSwapYT__factory.ts +2 -2
  272. package/typechain-types/factories/IPAllAction__factory.ts +28 -28
  273. package/typechain-types/factories/IPMarketFactory__factory.ts +50 -19
  274. package/typechain-types/factories/IPMarket__factory.ts +17 -5
  275. package/typechain-types/factories/IPMsgSendEndpoint__factory.ts +1 -1
  276. package/typechain-types/factories/IPYieldContractFactory__factory.ts +7 -7
  277. package/typechain-types/factories/IPYieldToken__factory.ts +13 -0
  278. package/typechain-types/factories/MarketMathStatic__factory.ts +1 -45
  279. package/typechain-types/factories/OracleLib__factory.ts +1 -1
  280. package/typechain-types/factories/PendleConvexLPSY__factory.ts +141 -0
  281. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -1
  282. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -1
  283. package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
  284. package/typechain-types/factories/PendleERC20__factory.ts +1 -1
  285. package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +1 -1
  286. package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
  287. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
  288. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
  289. package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1 -1
  290. package/typechain-types/factories/PendleMarketFactory__factory.ts +220 -49
  291. package/typechain-types/factories/PendleMarket__factory.ts +18 -6
  292. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
  293. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
  294. package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
  295. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  296. package/typechain-types/factories/PendleQiTokenSY__factory.ts +142 -1
  297. package/typechain-types/factories/PendleRouter__factory.ts +1 -185
  298. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
  299. package/typechain-types/factories/PendleWstEthSY__factory.ts +142 -1
  300. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +82 -9
  301. package/typechain-types/factories/PendleYieldToken__factory.ts +38 -3
  302. package/typechain-types/factories/RouterStatic__factory.ts +3 -3
  303. package/typechain-types/factories/SYBaseWithRewards__factory.ts +141 -0
  304. package/typechain-types/factories/SYBase__factory.ts +141 -0
  305. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
  306. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +15 -4
  307. package/typechain-types/factories/VotingEscrowTokenBase__factory.ts +0 -13
  308. package/typechain-types/hardhat.d.ts +0 -36
  309. package/typechain-types/index.ts +0 -6
  310. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +0 -4
  311. package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.dbg.json +0 -4
  312. package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.json +0 -182
  313. package/contracts/offchain-helpers/ImplicitSwapfeeContract.sol +0 -30
  314. package/deployments/43113-markets/QIWBTC-3RD-FEB.json +0 -11
  315. package/deployments/43113-markets/benqi-market-QI-AVAX-FEB-2ND.json +0 -9
  316. package/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
  317. package/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -9
  318. package/deployments/80001-core.json +0 -16
  319. package/deployments/80001-markets/benqi-market-QI-USDC-FEB-2ND.json +0 -8
  320. package/deployments/80001-markets/benqi-market-QI-WETH-DEC-1ST.json +0 -8
  321. package/deployments/80001-testenv.json +0 -22
@@ -6,6 +6,14 @@ import "../interfaces/IPActionAddRemoveLiq.sol";
6
6
  import "../interfaces/IPMarket.sol";
7
7
  import "../core/libraries/Errors.sol";
8
8
 
9
+ /**
10
+ * @dev If market is expired, all actions will revert, except for the following:
11
+ * - removeLiquidityDualSyAndPt()
12
+ * - removeLiquidityDualTokenAndPt()
13
+ * - removeLiquiditySingleSy()
14
+ * - removeLiquiditySingleToken()
15
+ * This is because swapping and adding liquidity are not allowed on an expired market.
16
+ */
9
17
  contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
10
18
  using Math for uint256;
11
19
  using Math for int256;
@@ -20,6 +28,13 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
20
28
  ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
21
29
  {}
22
30
 
31
+ /**
32
+ * @notice Adds liquidity to the SY/PT market, granting LP tokens in return
33
+ * @dev Will mint as much LP as possible given no more than `netSyDesired` and `netPtDesired`,
34
+ * while not changing the market's price
35
+ * @dev Only the necessary SY/PT amount will be transferred
36
+ * @dev Reverts if market is expired
37
+ */
23
38
  function addLiquidityDualSyAndPt(
24
39
  address receiver,
25
40
  address market,
@@ -37,7 +52,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
37
52
  (IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
38
53
 
39
54
  // calculate the amount of SY and PT to be used
40
- MarketState memory state = IPMarket(market).readState();
55
+ MarketState memory state = IPMarket(market).readState(address(this));
41
56
  (, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
42
57
  netSyDesired,
43
58
  netPtDesired,
@@ -60,7 +75,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
60
75
  }
61
76
 
62
77
  /**
63
- * @dev this function assumes that netTokenDesired = netTokenUsed, and fails if this does not hold
78
+ * @notice Adds liquidity to SY/PT market using PT + any token.
79
+ * @dev Input token is first swapped to SY-mintable token using Kyber, then SY is minted from
80
+ * such. Finally the SY/PT pair is added to the market
81
+ * @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
82
+ * @param netPtDesired maximum PT to be used
83
+ * @dev Only the necessary PT amount will be transferred
84
+ * @dev All SY minted must be used, otherwise the call will revert. Therefore it is recommended
85
+ * that `netPtDesired` is slightly higher than actual expected.
86
+ * @dev Reverts if market is expired
64
87
  */
65
88
  function addLiquidityDualTokenAndPt(
66
89
  address receiver,
@@ -84,7 +107,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
84
107
 
85
108
  {
86
109
  // calc the amount of SY and PT to be used
87
- MarketState memory state = IPMarket(market).readState();
110
+ MarketState memory state = IPMarket(market).readState(address(this));
88
111
  (, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
89
112
  netSyDesired,
90
113
  netPtDesired,
@@ -108,14 +131,22 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
108
131
  emit AddLiquidityDualTokenAndPt(
109
132
  msg.sender,
110
133
  market,
111
- receiver,
112
134
  input.tokenIn,
135
+ receiver,
113
136
  netTokenUsed,
114
137
  netPtUsed,
115
138
  netLpOut
116
139
  );
117
140
  }
118
141
 
142
+ /**
143
+ * @notice Swaps partial PT to SY, then use them to add liquidity to SY/PT pair
144
+ * @param netPtIn amount of PT to be transferred in from caller
145
+ * @param guessPtSwapToSy approximate info for the swap
146
+ * @return netLpOut actual LP output, will not be lower than `minLpOut`
147
+ * @return netSyFee amount of SY fee incurred from the swap
148
+ * @dev Reverts if market is expired
149
+ */
119
150
  function addLiquiditySinglePt(
120
151
  address receiver,
121
152
  address market,
@@ -126,7 +157,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
126
157
  (, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
127
158
 
128
159
  // calculate the amount of PT to swap
129
- MarketState memory state = IPMarket(market).readState();
160
+ MarketState memory state = IPMarket(market).readState(address(this));
130
161
 
131
162
  (uint256 netPtSwap, , ) = state.approxSwapPtToAddLiquidity(
132
163
  YT.newIndex(),
@@ -153,6 +184,14 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
153
184
  emit AddLiquiditySinglePt(msg.sender, market, receiver, netPtIn, netLpOut);
154
185
  }
155
186
 
187
+ /**
188
+ * @notice Swaps partial SY to PT, then use them to add liquidity to SY/PT pair
189
+ * @param netSyIn amount of SY to be transferred in from caller
190
+ * @param guessPtReceivedFromSy approx. output PT from the swap
191
+ * @return netLpOut actual LP output, will not be lower than `minLpOut`
192
+ * @return netSyFee amount of SY fee incurred from the swap
193
+ * @dev Reverts if market is expired
194
+ */
156
195
  function addLiquiditySingleSy(
157
196
  address receiver,
158
197
  address market,
@@ -178,6 +217,15 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
178
217
  emit AddLiquiditySingleSy(msg.sender, market, receiver, netSyIn, netLpOut);
179
218
  }
180
219
 
220
+ /**
221
+ * @notice Adds liquidity using a single token input. The input token is first swapped through
222
+ * Kyberswap to a SY-mintable token, the rest is the same as `addLiquiditySingleSy()`
223
+ * @param guessPtReceivedFromSy approximate PT output for the SY-to-PT swap
224
+ * @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
225
+ * @return netLpOut actual LP output, will not be lower than `minLpOut`
226
+ * @return netSyFee amount of SY fee incurred from the swap
227
+ * @dev Reverts if market is expired
228
+ */
181
229
  function addLiquiditySingleToken(
182
230
  address receiver,
183
231
  address market,
@@ -210,6 +258,11 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
210
258
  );
211
259
  }
212
260
 
261
+ /**
262
+ * @notice Burns LP token to remove SY/PT liquidity
263
+ * @param netLpToRemove amount of LP to be burned from caller
264
+ * @dev Will work even if market is expired
265
+ */
213
266
  function removeLiquidityDualSyAndPt(
214
267
  address receiver,
215
268
  address market,
@@ -234,6 +287,13 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
234
287
  );
235
288
  }
236
289
 
290
+ /**
291
+ * @notice Burns LP token to remove SY/PT liquidity, then redeems SY, finally (if needed)
292
+ * swaps SY redeemings through Kyberswap to desired output token.
293
+ * @param netLpToRemove amount of LP to be burned from caller
294
+ * @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
295
+ * @dev Will work even if market is expired
296
+ */
237
297
  function removeLiquidityDualTokenAndPt(
238
298
  address receiver,
239
299
  address market,
@@ -261,31 +321,39 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
261
321
  emit RemoveLiquidityDualTokenAndPt(
262
322
  msg.sender,
263
323
  market,
324
+ output.tokenOut,
264
325
  receiver,
265
326
  netLpToRemove,
266
327
  netPtOut,
267
- output.tokenOut,
268
328
  netTokenOut
269
329
  );
270
330
  }
271
331
 
332
+ /**
333
+ * @notice Removes SY/PT liquidity, then swaps all resulting SY to return only PT
334
+ * @param netLpToRemove amount of LP to be burned from caller
335
+ * @param guessPtReceivedFromSy approximate info for the swap
336
+ * @return netPtOut total PT output, will not be lower than `minPtOut`
337
+ * @return netSyFee amount of SY fee incurred from the swap
338
+ * @dev Reverts if market is expired
339
+ */
272
340
  function removeLiquiditySinglePt(
273
341
  address receiver,
274
342
  address market,
275
343
  uint256 netLpToRemove,
276
344
  uint256 minPtOut,
277
- ApproxParams calldata guessPtOut
345
+ ApproxParams calldata guessPtReceivedFromSy
278
346
  ) external returns (uint256 netPtOut, uint256 netSyFee) {
279
347
  (, , IPYieldToken YT) = IPMarket(market).readTokens();
280
348
 
281
349
  // calculate the total amount of PT received from burning & selling SY
282
- MarketState memory state = IPMarket(market).readState();
350
+ MarketState memory state = IPMarket(market).readState(address(this));
283
351
  (uint256 syFromBurn, uint256 ptFromBurn) = state.removeLiquidity(netLpToRemove);
284
352
  (uint256 ptFromSwap, ) = state.approxSwapExactSyForPt(
285
353
  YT.newIndex(),
286
354
  syFromBurn,
287
355
  block.timestamp,
288
- guessPtOut
356
+ guessPtReceivedFromSy
289
357
  );
290
358
 
291
359
  if (ptFromBurn + ptFromSwap < minPtOut)
@@ -305,6 +373,14 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
305
373
  emit RemoveLiquiditySinglePt(msg.sender, market, receiver, netLpToRemove, netPtOut);
306
374
  }
307
375
 
376
+ /**
377
+ * @notice Removes SY/PT liquidity, then converts all resulting PT to return only SY
378
+ * @dev Conversion is done with market swap if not expired, or with PT redeeming if expired
379
+ * @param netLpToRemove amount of LP to be burned from caller
380
+ * @return netSyOut total SY output, will not be lower than `minSyOut`
381
+ * @return netSyFee amount of SY fee incurred from the swap
382
+ * @dev Will work even if market is expired
383
+ */
308
384
  function removeLiquiditySingleSy(
309
385
  address receiver,
310
386
  address market,
@@ -320,6 +396,18 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
320
396
  emit RemoveLiquiditySingleSy(msg.sender, market, receiver, netLpToRemove, netSyOut);
321
397
  }
322
398
 
399
+ /**
400
+ * @notice Removes SY/PT liquidity, then converts all to desired output token.
401
+ * @dev inner workings of this function:
402
+ - Removes SY/PT liquidity to only SY (see `removeLiquiditySingleSy()`)
403
+ - Burns SY to redeem SY-mintable tokens
404
+ - (If needed) swaps resulting tokens to desired output token using Kyberswap
405
+ * @param netLpToRemove amount of LP to be burned from caller
406
+ * @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
407
+ * @return netTokenOut total token output, will not be lower than `output.minTokenOut`
408
+ * @return netSyFee amount of SY fee incurred from the swap
409
+ * @dev Will work even if market is expired
410
+ */
323
411
  function removeLiquiditySingleToken(
324
412
  address receiver,
325
413
  address market,
@@ -353,6 +441,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
353
441
  );
354
442
  }
355
443
 
444
+ /// @dev swaps SY to PT, then adds liquidity
356
445
  function _addLiquiditySingleSy(
357
446
  address receiver,
358
447
  address market,
@@ -361,7 +450,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
361
450
  uint256 minLpOut,
362
451
  ApproxParams calldata guessPtReceivedFromSy
363
452
  ) internal returns (uint256 netLpOut, uint256 netSyFee) {
364
- MarketState memory state = IPMarket(market).readState();
453
+ MarketState memory state = IPMarket(market).readState(address(this));
365
454
 
366
455
  // calculate the PT amount needed to add liquidity
367
456
  (uint256 netPtFromSwap, , ) = state.approxSwapSyToAddLiquidity(
@@ -384,6 +473,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
384
473
  if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
385
474
  }
386
475
 
476
+ /// @dev removes SY/PT liquidity, then converts PT to SY
387
477
  function _removeLiquiditySingleSy(
388
478
  address receiver,
389
479
  address market,
@@ -399,6 +489,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
399
489
  if (netSyOut < minSyOut) revert Errors.RouterInsufficientSyOut(netSyOut, minSyOut);
400
490
  }
401
491
 
492
+ /// @dev converts PT to SY post-expiry
402
493
  function __removeLpToSyAfterExpiry(
403
494
  address receiver,
404
495
  address market,
@@ -409,6 +500,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
409
500
  netSyOut = syFromBurn + IPYieldToken(YT).redeemPY(receiver);
410
501
  }
411
502
 
503
+ /// @dev swaps PT to SY pre-expiry
412
504
  function __removeLpToSyBeforeExpiry(
413
505
  address receiver,
414
506
  address market,
@@ -16,6 +16,10 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
16
16
  ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
17
17
  {}
18
18
 
19
+ /**
20
+ * @notice swaps input token for SY-mintable tokens (if needed), then mints SY from such
21
+ * @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
22
+ */
19
23
  function mintSyFromToken(
20
24
  address receiver,
21
25
  address SY,
@@ -23,9 +27,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
23
27
  TokenInput calldata input
24
28
  ) external payable returns (uint256 netSyOut) {
25
29
  netSyOut = _mintSyFromToken(receiver, SY, minSyOut, input);
26
- emit MintSyFromToken(msg.sender, receiver, SY, input.tokenIn, input.netTokenIn, netSyOut);
30
+ emit MintSyFromToken(msg.sender, input.tokenIn, SY, receiver, input.netTokenIn, netSyOut);
27
31
  }
28
32
 
33
+ /**
34
+ * @notice redeems SY for SY-mintable tokens, then (if needed) swaps resulting tokens for
35
+ * desired output token through Kyberswap
36
+ * @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
37
+ */
29
38
  function redeemSyToToken(
30
39
  address receiver,
31
40
  address SY,
@@ -33,9 +42,16 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
33
42
  TokenOutput calldata output
34
43
  ) external returns (uint256 netTokenOut) {
35
44
  netTokenOut = _redeemSyToToken(receiver, SY, netSyIn, output, true);
36
- emit RedeemSyToToken(msg.sender, receiver, SY, netSyIn, output.tokenOut, netTokenOut);
45
+ emit RedeemSyToToken(msg.sender, output.tokenOut, SY, receiver, netSyIn, netTokenOut);
37
46
  }
38
47
 
48
+ /**
49
+ * @notice mints PY from any input token
50
+ * @dev swaps input token through Kyberswap to SY-mintable tokens first, then mints SY, finally
51
+ * mints PY from SY
52
+ * @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
53
+ * @dev reverts if PY is expired
54
+ */
39
55
  function mintPyFromToken(
40
56
  address receiver,
41
57
  address YT,
@@ -47,9 +63,15 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
47
63
  uint256 netSyToMint = _mintSyFromToken(YT, SY, 0, input);
48
64
  netPyOut = _mintPyFromSy(receiver, YT, netSyToMint, minPyOut, false);
49
65
 
50
- emit MintPyFromToken(msg.sender, receiver, YT, input.tokenIn, input.netTokenIn, netPyOut);
66
+ emit MintPyFromToken(msg.sender, input.tokenIn, YT, receiver, input.netTokenIn, netPyOut);
51
67
  }
52
68
 
69
+ /**
70
+ * @notice redeems PY for token
71
+ * @dev redeems PT(+YT) for SY first, then redeems SY, finally swaps resulting tokens to output
72
+ * token through Kyberswap (if needed)
73
+ * @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
74
+ */
53
75
  function redeemPyToToken(
54
76
  address receiver,
55
77
  address YT,
@@ -61,9 +83,13 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
61
83
  uint256 netSyToRedeem = _redeemPyToSy(_syOrBulk(SY, output), YT, netPyIn, 1);
62
84
  netTokenOut = _redeemSyToToken(receiver, SY, netSyToRedeem, output, false);
63
85
 
64
- emit RedeemPyToToken(msg.sender, receiver, YT, netPyIn, output.tokenOut, netTokenOut);
86
+ emit RedeemPyToToken(msg.sender, output.tokenOut, YT, receiver, netPyIn, netTokenOut);
65
87
  }
66
88
 
89
+ /**
90
+ * @notice mints PT+YT from input SY
91
+ * @dev reverts if the PY pair is expired
92
+ */
67
93
  function mintPyFromSy(
68
94
  address receiver,
69
95
  address YT,
@@ -74,6 +100,7 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
74
100
  emit MintPyFromSy(msg.sender, receiver, YT, netSyIn, netPyOut);
75
101
  }
76
102
 
103
+ /// @notice redeems PT(+YT) for its corresponding SY
77
104
  function redeemPyToSy(
78
105
  address receiver,
79
106
  address YT,
@@ -84,6 +111,11 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
84
111
  emit RedeemPyToSy(msg.sender, receiver, YT, netPyIn, netSyOut);
85
112
  }
86
113
 
114
+ /**
115
+ * @notice A unified interface for redeeming rewards and interests for any SYs,
116
+ * YTs, and markets alike for `user`.
117
+ * @dev returns arrays of amounts claimed for each asset.
118
+ */
87
119
  function redeemDueInterestAndRewards(
88
120
  address user,
89
121
  address[] calldata sys,
@@ -134,6 +166,14 @@ contract ActionMintRedeem is IPActionMintRedeem, ActionBaseMintRedeem {
134
166
  uint256[] amounts;
135
167
  }
136
168
 
169
+ /**
170
+ * @notice A function to:
171
+ - Redeem all of caller's due interest and rewards in SYs, YTs, and markets
172
+ - Redeem SYs themselves
173
+ - Finally swaps all resulting tokens to `dataSwap.outputToken`
174
+ * @return netTokenOut total token output amount, will not be lower than `dataSwap.minTokenOut`
175
+ * @return amountsSwapped the amounts swapped for each token defined in `dataSwap.tokens`
176
+ */
137
177
  function redeemDueInterestAndRewardsThenSwapAll(
138
178
  address[] calldata sys,
139
179
  RouterYtRedeemStruct calldata dataYT,
@@ -6,6 +6,7 @@ import "../interfaces/IPActionSwapPT.sol";
6
6
  import "../interfaces/IPMarket.sol";
7
7
  import "../core/libraries/Errors.sol";
8
8
 
9
+ /// @dev All swap actions will revert if market is expired
9
10
  contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
10
11
  using MarketMathCore for MarketState;
11
12
  using MarketApproxPtInLib for MarketState;
@@ -19,6 +20,12 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
19
20
  ActionBaseMintRedeem(_kyberScalingLib) //solhint-disable-next-line no-empty-blocks
20
21
  {}
21
22
 
23
+ /**
24
+ * @notice swaps exact amount of PT for SY
25
+ * @param exactPtIn will always consume this exact amount of PT for as much SY as possible
26
+ * @return netSyOut amount SY output, will not be less than `minSyOut`
27
+ * @return netSyFee amount SY fee incurred
28
+ */
22
29
  function swapExactPtForSy(
23
30
  address receiver,
24
31
  address market,
@@ -36,8 +43,13 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
36
43
  }
37
44
 
38
45
  /**
39
- * @notice Note that the amount of SY out will be a bit more than `exactSyOut`, since an approximation is used. It's
40
- guaranteed that the `netSyOut` is at least `exactSyOut`
46
+ * @notice swaps some amount of PT for the desired SY amount
47
+ * @param guessPtIn approximation data for input PT amount
48
+ * @param exactSyOut will consume as little PT as possible for this much SY amount
49
+ * @return netPtIn amount of PT used, will not be more than `maxPtIn`
50
+ * @return netSyFee amount SY fee incurred
51
+ * @dev the SY output might be slightly more than `exactSyOut` since an approximation is used.
52
+ * It is guaranteed that exactSyOut <= actualSyOut <= exactSyOut*(100% + guessPtIn.eps)
41
53
  */
42
54
  function swapPtForExactSy(
43
55
  address receiver,
@@ -46,7 +58,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
46
58
  uint256 maxPtIn,
47
59
  ApproxParams calldata guessPtIn
48
60
  ) external returns (uint256 netPtIn, uint256 netSyFee) {
49
- MarketState memory state = IPMarket(market).readState();
61
+ MarketState memory state = IPMarket(market).readState(address(this));
50
62
  (, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
51
63
 
52
64
  (netPtIn, , ) = state.approxSwapPtForExactSy(
@@ -69,16 +81,23 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
69
81
  emit SwapPtAndSy(msg.sender, market, receiver, netPtIn.neg(), exactSyOut.Int());
70
82
  }
71
83
 
84
+ /**
85
+ * @notice swaps SY for exact amount of PT
86
+ * @param exactPtOut will always consume as little SY as possible for this much amount of PT
87
+ * @return netSyIn amount SY used, will not be more than `maxSyIn`
88
+ * @return netSyFee amount SY fee incurred
89
+ * @dev the output amount of PT here is exact, no approximation is used
90
+ */
72
91
  function swapSyForExactPt(
73
92
  address receiver,
74
93
  address market,
75
94
  uint256 exactPtOut,
76
95
  uint256 maxSyIn
77
96
  ) external returns (uint256 netSyIn, uint256 netSyFee) {
78
- MarketState memory state = IPMarket(market).readState();
97
+ MarketState memory state = IPMarket(market).readState(address(this));
79
98
  (IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
80
99
 
81
- (netSyIn, ) = state.swapSyForExactPt(YT.newIndex(), exactPtOut, block.timestamp);
100
+ (netSyIn, , ) = state.swapSyForExactPt(YT.newIndex(), exactPtOut, block.timestamp);
82
101
 
83
102
  if (netSyIn > maxSyIn) revert Errors.RouterExceededLimitSyIn(netSyIn, maxSyIn);
84
103
 
@@ -90,6 +109,13 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
90
109
  emit SwapPtAndSy(msg.sender, market, receiver, exactPtOut.Int(), netSyIn.neg());
91
110
  }
92
111
 
112
+ /**
113
+ * @notice swaps exact amount of SY for as much PT as possible
114
+ * @param exactSyIn will always consume this much amount of SY
115
+ * @param guessPtOut approximation data for output PT amount
116
+ * @return netPtOut amount of PT output, will not be less than `minPtOut`
117
+ * @return netSyFee amount SY fee incurred
118
+ */
93
119
  function swapExactSyForPt(
94
120
  address receiver,
95
121
  address market,
@@ -114,9 +140,10 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
114
140
  }
115
141
 
116
142
  /**
117
- * @notice swap from any ERC20 tokens, through Uniswap's forks, to get baseTokens to make SY, then swap
118
- from SY to PT
119
- * @dev simply a combination of _mintSyFromToken & _swapExactSyForPt
143
+ * @notice swap (through Kyberswap) from any input token for SY-mintable tokens, then mints SY
144
+ * and swaps said SY for PT
145
+ * @param input data for input token, see {`./kyberswap/KyberSwapHelper.sol`}
146
+ * @dev is a combination of `_mintSyFromToken()` and `_swapExactSyForPt()`
120
147
  */
121
148
  function swapExactTokenForPt(
122
149
  address receiver,
@@ -151,8 +178,11 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
151
178
  }
152
179
 
153
180
  /**
154
- * @notice swap from PT to SY, then redeem SY to baseToken & swap through Uniswap's forks to get tokenOut
155
- * @dev simply a combination of _swapExactPtForSy & _redeemSyToToken
181
+ * @notice swap from exact amount of PT to SY, then redeem SY for assets, finally swaps
182
+ * resulting assets through Kyberswap to get desired output token
183
+ * @param exactPtIn will always consume this much PT for as much SY as possible
184
+ * @param output data for desired output token, see {`./kyberswap/KyberSwapHelper.sol`}
185
+ * @dev is a combination of `_swapExactPtForSy()` and `_redeemSyToToken()`
156
186
  */
157
187
  function swapExactPtForToken(
158
188
  address receiver,
@@ -193,7 +223,7 @@ contract ActionSwapPT is IPActionSwapPT, ActionBaseMintRedeem {
193
223
  uint256 minPtOut,
194
224
  ApproxParams calldata guessPtOut
195
225
  ) internal returns (uint256 netPtOut, uint256 netSyFee) {
196
- MarketState memory state = IPMarket(market).readState();
226
+ MarketState memory state = IPMarket(market).readState(address(this));
197
227
 
198
228
  (netPtOut, ) = state.approxSwapExactSyForPt(
199
229
  YT.newIndex(),
@@ -5,6 +5,7 @@ import "../interfaces/IPActionSwapPTYT.sol";
5
5
  import "../interfaces/IPMarket.sol";
6
6
  import "./base/CallbackHelper.sol";
7
7
 
8
+ /// @dev All swap actions will revert if market is expired
8
9
  contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper, TokenHelper {
9
10
  using MarketMathCore for MarketState;
10
11
  using MarketApproxPtInLib for MarketState;
@@ -19,6 +20,18 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper, TokenHelper {
19
20
 
20
21
  }
21
22
 
23
+ /**
24
+ * @notice swap exact PT to YT with the help of flashswaps & YT tokenization / redemption
25
+ * @dev inner working of this function:
26
+ - `exactPtIn` PT is transferred to market contract
27
+ - `market.swapExactPtForSy` is called, which will transfer SY directly to YT contract & callback is invoked.
28
+ Note that we will owe PT, the amount before is not sufficient
29
+ - in callback, all SY in YT contract is used to mint PT + YT, with PT used to pay the rest of the loan, and YT
30
+ transferred to the receiver
31
+ * @param exactPtIn will always consume this amount of PT for as much YT as possible
32
+ * @param guessTotalPtToSwap approximation data for PT used for the PT-to-SY flashswap
33
+ * @dev this function works in conjunction with ActionCallback
34
+ */
22
35
  function swapExactPtForYt(
23
36
  address receiver,
24
37
  address market,
@@ -27,7 +40,7 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper, TokenHelper {
27
40
  ApproxParams calldata guessTotalPtToSwap
28
41
  ) external returns (uint256 netYtOut, uint256 netSyFee) {
29
42
  (, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
30
- MarketState memory state = IPMarket(market).readState();
43
+ MarketState memory state = IPMarket(market).readState(address(this));
31
44
 
32
45
  _transferFrom(IERC20(PT), msg.sender, market, exactPtIn);
33
46
 
@@ -50,31 +63,43 @@ contract ActionSwapPTYT is IPActionSwapPTYT, CallbackHelper, TokenHelper {
50
63
  emit SwapPtAndYt(msg.sender, market, receiver, exactPtIn.neg(), netYtOut.Int());
51
64
  }
52
65
 
66
+ /**
67
+ * @notice swap exact YT to PT with the help of flashswaps & YT tokenization / redemption
68
+ * @dev inner working of this function:
69
+ - `exactYtIn` YT is transferred to yield contract
70
+ - `market.swapSyForExactPt` is called, which will transfer PT directly to this contract & callback is invoked.
71
+ Note that we now owe SY
72
+ - in callback, a portion of PT + YT is used to redeem SY, which is then used to payback the loan. The rest of
73
+ of the PT is transferred to `receiver`
74
+ * @param exactYtIn will always consume this amount of YT for as much PT as possible
75
+ * @param guessTotalPtFromSwap approximation data for PT output of the SY-to-PT flashswap
76
+ * @dev this function works in conjunction with ActionCallback
77
+ */
53
78
  function swapExactYtForPt(
54
79
  address receiver,
55
80
  address market,
56
81
  uint256 exactYtIn,
57
82
  uint256 minPtOut,
58
- ApproxParams calldata guessTotalPtSwapped
83
+ ApproxParams calldata guessTotalPtFromSwap
59
84
  ) external returns (uint256 netPtOut, uint256 netSyFee) {
60
85
  (, , IPYieldToken YT) = IPMarket(market).readTokens();
61
- MarketState memory state = IPMarket(market).readState();
86
+ MarketState memory state = IPMarket(market).readState(address(this));
62
87
 
63
88
  _transferFrom(IERC20(YT), msg.sender, address(YT), exactYtIn);
64
89
 
65
- uint256 totalPtSwapped;
66
- (netPtOut, totalPtSwapped, netSyFee) = state.approxSwapExactYtForPt(
90
+ uint256 totalPtFromSwap;
91
+ (netPtOut, totalPtFromSwap, netSyFee) = state.approxSwapExactYtForPt(
67
92
  YT.newIndex(),
68
93
  exactYtIn,
69
94
  block.timestamp,
70
- guessTotalPtSwapped
95
+ guessTotalPtFromSwap
71
96
  );
72
97
 
73
98
  if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
74
99
 
75
100
  IPMarket(market).swapSyForExactPt(
76
101
  address(this),
77
- totalPtSwapped,
102
+ totalPtFromSwap,
78
103
  _encodeSwapExactYtForPt(receiver, exactYtIn, minPtOut)
79
104
  );
80
105