@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
@@ -0,0 +1,29 @@
1
+ # PENDLE Curve/Convex SY
2
+
3
+ For the simplicity of the writeup, we will describe only the noticable properties of `PendleCurveUSDD3CrvSY`. `PendleCurveFraxUsdcSY` contract should contain only a subset of those properties compared to USDD one.
4
+
5
+ ## Token in/out flow
6
+
7
+ We support USDD/USDC/DAI/USDT and the two LPs as in and out tokens. Tokens after being deposited to Curve to get back LP USDD/3Crv will be staked into Convex reward system to gain rewards of:
8
+
9
+ - USDD
10
+ - CRV
11
+ - CVX
12
+
13
+ ![](https://i.ibb.co/9rgWfvg/curve.png)
14
+
15
+ ## Exchange Rate
16
+
17
+ Asset type for this SY should be in type of Liquidity. For exchange rate, we use Curve's `pool.get_virtual_price()` as it shows the growth in price of LP token respecting to the swap fees earned by the pool.
18
+
19
+ ## Preview functions
20
+
21
+ Before getting to this, we would like to note that preview functions will play an important role in Pendle's off-chain system. Hence, it is essential for preview function returns the actual outcome that user can get by calling `deposit/redeem`.
22
+
23
+ For preview redeem, Curve provides a view function of `calc_withdraw_one_coin` which accurately returns the amount of token can be redeem by user with a particular amount of LP.
24
+
25
+ For previde deposit, Curve's provided function `calc_token_amount` does not take into account the fee, thus, it does not return the actual amount of lp token user can get.
26
+
27
+ We implemented a workaround for previewDeposit in `CurveUsdd3CrvPoolHelper` and `Curve3CrvPoolHelper` to simulate the calculation happened in Curve's code base.
28
+
29
+ Another thing to note is that `CurveUsdd3CrvPoolHelper`'s preivew deposit result has a dependency on the `3crv.get_virtual_price`. So the simulation should also take into account the case when user deposits with DAI/USDC/USDT, the state of 3Crv pool changes, and thus the `get_virtual_price` of 3crv changes.
@@ -0,0 +1,215 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.17;
3
+
4
+ import "../../../../libraries/math/Math.sol";
5
+ import "../../../../../interfaces/Curve/ITriCrvPool.sol";
6
+ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
7
+
8
+ library Curve3CrvPoolHelper {
9
+ using Math for uint256;
10
+
11
+ uint256 internal constant N_COINS = 3;
12
+ uint256 internal constant PRECISION = 10**18;
13
+ uint256 internal constant RATE_0 = 1000000000000000000;
14
+ uint256 internal constant RATE_1 = 1000000000000000000000000000000;
15
+ uint256 internal constant RATE_2 = 1000000000000000000000000000000;
16
+ uint256 internal constant FEE_DENOMINATOR = 10**10;
17
+
18
+ address internal constant LP = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
19
+ address internal constant POOL = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7;
20
+ address internal constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
21
+ address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
22
+ address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
23
+
24
+ // previewDeposit at the end of the file
25
+
26
+ function preview3CrvRedeem(address tokenOut, uint256 amountSharesToRedeem)
27
+ internal
28
+ view
29
+ returns (uint256)
30
+ {
31
+ return
32
+ ITriCrvPool(POOL).calc_withdraw_one_coin(
33
+ amountSharesToRedeem,
34
+ _get3CrvTokenIndex(tokenOut).Int128()
35
+ );
36
+ }
37
+
38
+ function deposit3Crv(address tokenIn, uint256 amountTokenToDeposit)
39
+ internal
40
+ returns (uint256)
41
+ {
42
+ uint256 balBefore = IERC20(LP).balanceOf(address(this));
43
+ ITriCrvPool(POOL).add_liquidity(_getTokenAmounts(tokenIn, amountTokenToDeposit), 0);
44
+ uint256 balAfter = IERC20(LP).balanceOf(address(this));
45
+ return balAfter - balBefore;
46
+ }
47
+
48
+ function redeem3Crv(address tokenOut, uint256 amountSharesToRedeem)
49
+ internal
50
+ returns (uint256)
51
+ {
52
+ uint256 balBefore = IERC20(tokenOut).balanceOf(address(this));
53
+ ITriCrvPool(POOL).remove_liquidity_one_coin(
54
+ amountSharesToRedeem,
55
+ _get3CrvTokenIndex(tokenOut).Int128(),
56
+ 0
57
+ );
58
+ uint256 balAfter = IERC20(tokenOut).balanceOf(address(this));
59
+ return balAfter - balBefore;
60
+ }
61
+
62
+ function _getTokenAmounts(address token, uint256 amount)
63
+ internal
64
+ pure
65
+ returns (uint256[N_COINS] memory res)
66
+ {
67
+ res[_get3CrvTokenIndex(token)] = amount;
68
+ }
69
+
70
+ function _get3CrvTokenIndex(address token) internal pure returns (uint256) {
71
+ if (token == DAI) return 0;
72
+ if (token == USDC) return 1;
73
+ if (token == USDT) return 2;
74
+ revert("Pendle3CrvHelper: not valid token");
75
+ }
76
+
77
+ function is3CrvToken(address token) internal pure returns (bool) {
78
+ return (token == DAI || token == USDC || token == USDT);
79
+ }
80
+
81
+ function get_virtual_price() internal view returns (uint256) {
82
+ return ITriCrvPool(POOL).get_virtual_price();
83
+ }
84
+
85
+ // ----------------- Forking StableSwap3Pool's calculation -----------------
86
+
87
+ // fork of StableSwap3Pool.vy
88
+ function preview3CrvDeposit(address token, uint256 amount)
89
+ internal
90
+ view
91
+ returns (uint256 netLpOut, uint256 new_virtual_price)
92
+ {
93
+ uint256[N_COINS] memory amounts = _getTokenAmounts(token, amount);
94
+ uint256[N_COINS] memory self_balances = _getBalances();
95
+
96
+ uint256[N_COINS] memory fees;
97
+ uint256 _fee = (ITriCrvPool(POOL).fee() * N_COINS) / (4 * (N_COINS - 1));
98
+ uint256 _admin_fee = ITriCrvPool(POOL).admin_fee();
99
+ uint256 amp = ITriCrvPool(POOL).A();
100
+
101
+ uint256 token_supply = IERC20(LP).totalSupply();
102
+ // Initial invariant
103
+ uint256 D0 = 0;
104
+ uint256[N_COINS] memory old_balances = arrayClone(self_balances);
105
+ D0 = get_D_mem(old_balances, amp);
106
+
107
+ uint256[N_COINS] memory new_balances = arrayClone(old_balances);
108
+
109
+ for (uint256 i = 0; i < N_COINS; ++i) {
110
+ new_balances[i] += amounts[i];
111
+ }
112
+
113
+ uint256 D1 = get_D_mem(new_balances, amp);
114
+ assert(D1 > D0);
115
+
116
+ // We need to recalculate the invariant accounting for fees
117
+ // to calculate fair user's share
118
+ uint256 D2 = D1;
119
+ for (uint256 i = 0; i < N_COINS; ++i) {
120
+ uint256 ideal_balance = (D1 * old_balances[i]) / D0;
121
+ uint256 difference = 0;
122
+ if (ideal_balance > new_balances[i]) {
123
+ difference = ideal_balance - new_balances[i];
124
+ } else {
125
+ difference = new_balances[i] - ideal_balance;
126
+ }
127
+ fees[i] = (_fee * difference) / FEE_DENOMINATOR;
128
+ self_balances[i] = new_balances[i] - ((fees[i] * _admin_fee) / FEE_DENOMINATOR);
129
+ new_balances[i] -= fees[i];
130
+ D2 = get_D_mem(new_balances, amp);
131
+ }
132
+
133
+ netLpOut = (token_supply * (D2 - D0)) / D0;
134
+ new_virtual_price = _get_virtual_price_with_balances(
135
+ self_balances,
136
+ token_supply + netLpOut
137
+ );
138
+ }
139
+
140
+ function _get_virtual_price_with_balances(
141
+ uint256[N_COINS] memory balances,
142
+ uint256 token_supply
143
+ ) internal view returns (uint256) {
144
+ uint256 amp = ITriCrvPool(POOL).A();
145
+ uint256 D = get_D_mem(balances, amp);
146
+ return (D * PRECISION) / token_supply;
147
+ }
148
+
149
+ function get_D_mem(uint256[N_COINS] memory balances, uint256 amp)
150
+ internal
151
+ pure
152
+ returns (uint256)
153
+ {
154
+ return get_D(_xp_mem(balances), amp);
155
+ }
156
+
157
+ function _xp_mem(uint256[N_COINS] memory balances)
158
+ internal
159
+ pure
160
+ returns (uint256[N_COINS] memory)
161
+ {
162
+ uint256[N_COINS] memory result;
163
+ result[0] = (RATE_0 * balances[0]) / PRECISION;
164
+ result[1] = (RATE_1 * balances[1]) / PRECISION;
165
+ result[2] = (RATE_2 * balances[2]) / PRECISION;
166
+
167
+ return result;
168
+ }
169
+
170
+ function get_D(uint256[N_COINS] memory _xp, uint256 _amp) internal pure returns (uint256) {
171
+ uint256 S = 0;
172
+ for (uint256 k = 0; k < N_COINS; ++k) S += _xp[k];
173
+ if (S == 0) return 0;
174
+
175
+ uint256 Dprev = 0;
176
+ uint256 D = S;
177
+ uint256 Ann = _amp * N_COINS;
178
+
179
+ for (uint256 _i = 0; _i < 255; ++_i) {
180
+ uint256 D_P = D;
181
+ for (uint256 k = 0; k < N_COINS; ++k) {
182
+ D_P = (D_P * D) / (_xp[k] * N_COINS);
183
+ }
184
+ Dprev = D;
185
+ D = ((Ann * S + D_P * N_COINS) * D) / (((Ann - 1) * D) + (N_COINS + 1) * D_P);
186
+
187
+ if (D > Dprev) {
188
+ if (D - Dprev <= 1) {
189
+ break;
190
+ }
191
+ } else {
192
+ if (Dprev - D <= 1) {
193
+ break;
194
+ }
195
+ }
196
+ }
197
+ return D;
198
+ }
199
+
200
+ function _getBalances() internal view returns (uint256[N_COINS] memory balances) {
201
+ balances[0] = ITriCrvPool(POOL).balances(0);
202
+ balances[1] = ITriCrvPool(POOL).balances(1);
203
+ balances[2] = ITriCrvPool(POOL).balances(2);
204
+ }
205
+
206
+ function arrayClone(uint256[N_COINS] memory a)
207
+ internal
208
+ pure
209
+ returns (uint256[N_COINS] memory res)
210
+ {
211
+ for (uint256 i = 0; i < N_COINS; ++i) {
212
+ res[i] = a[i];
213
+ }
214
+ }
215
+ }
@@ -6,43 +6,44 @@ import "../../../../../interfaces/Curve/ICrvPool.sol";
6
6
  import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
7
7
 
8
8
  library CurveFraxUsdcPoolHelper {
9
- uint256 public constant N_COINS = 2;
10
- uint256 public constant A_PRECISION = 100;
11
- uint256 public constant PRECISION = 10 ** 18;
12
- uint256 public constant RATE_0 = 1000000000000000000;
13
- uint256 public constant RATE_1 = 1000000000000000000000000000000;
14
- uint256 public constant FEE_DENOMINATOR = 10 ** 10;
9
+ uint256 internal constant N_COINS = 2;
10
+ uint256 internal constant A_PRECISION = 100;
11
+ uint256 internal constant PRECISION = 10**18;
12
+ uint256 internal constant RATE_0 = 1000000000000000000;
13
+ uint256 internal constant RATE_1 = 1000000000000000000000000000000;
14
+ uint256 internal constant FEE_DENOMINATOR = 10**10;
15
+
16
+ address internal constant POOL = 0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2;
17
+ address internal constant LP = 0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC;
18
+ address internal constant FRAX = 0x853d955aCEf822Db058eb8505911ED77F175b99e;
19
+ address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
15
20
 
16
21
  using Math for uint256;
17
22
 
18
- function previewAddLiquidity(address pool, uint256[N_COINS] memory _amounts) internal view returns (uint256) {
19
- uint256 amp = ICrvPool(pool).A_precise();
20
- uint256[N_COINS] memory old_balances;
21
- old_balances[0] = ICrvPool(pool).balances(0);
22
- old_balances[1] = ICrvPool(pool).balances(1);
23
- uint256 D0 = _get_D_mem(old_balances, amp);
24
-
25
- address lp_token = ICrvPool(pool).lp_token();
26
- uint256 total_supply = IERC20(lp_token).totalSupply();
27
-
23
+ function previewAddLiquidity(address token, uint256 amount) internal view returns (uint256) {
24
+ uint256 amp = ICrvPool(POOL).A_precise();
25
+ uint256[N_COINS] memory _amounts = _getTokenAmounts(token, amount);
26
+ uint256[N_COINS] memory old_balances = _getBalances();
28
27
  uint256[N_COINS] memory new_balances;
29
- new_balances[0] = old_balances[0];
30
- new_balances[1] = old_balances[1];
28
+ memcpy(new_balances, old_balances);
29
+
30
+ uint256 D0 = _get_D_mem(old_balances, amp);
31
+ uint256 total_supply = IERC20(LP).totalSupply();
31
32
 
32
- for(uint256 i = 0; i < N_COINS; ++i) {
33
+ for (uint256 i = 0; i < N_COINS; ++i) {
33
34
  // skip totalSupply = 0 check
34
35
  new_balances[i] += _amounts[i];
35
36
  }
36
37
 
37
38
  uint256 D1 = _get_D_mem(new_balances, amp);
38
- assert (D1 > D0);
39
+ assert(D1 > D0);
39
40
 
40
41
  uint256[N_COINS] memory fees;
41
42
 
42
43
  // skip total_supply > 0 check
43
- uint256 fee = ICrvPool(pool).fee() * N_COINS / (4 * (N_COINS - 1));
44
+ uint256 fee = (ICrvPool(POOL).fee() * N_COINS) / (4 * (N_COINS - 1));
44
45
  for (uint256 i = 0; i < N_COINS; ++i) {
45
- uint256 ideal_balance = D1 * old_balances[i] / D0;
46
+ uint256 ideal_balance = (D1 * old_balances[i]) / D0;
46
47
  uint256 difference = 0;
47
48
  uint256 new_balance = new_balances[i];
48
49
 
@@ -51,11 +52,11 @@ library CurveFraxUsdcPoolHelper {
51
52
  } else {
52
53
  difference = new_balance - ideal_balance;
53
54
  }
54
- fees[i] = fee * difference / FEE_DENOMINATOR;
55
+ fees[i] = (fee * difference) / FEE_DENOMINATOR;
55
56
  new_balances[i] -= fees[i];
56
57
  }
57
58
  uint256 D2 = _get_D_mem(new_balances, amp);
58
- return total_supply * (D2 - D0) / D0;
59
+ return (total_supply * (D2 - D0)) / D0;
59
60
  }
60
61
 
61
62
  function _get_D_mem(uint256[N_COINS] memory balances, uint256 _amp)
@@ -64,8 +65,8 @@ library CurveFraxUsdcPoolHelper {
64
65
  returns (uint256)
65
66
  {
66
67
  uint256[N_COINS] memory _xp;
67
- _xp[0] = RATE_0 * balances[0] / PRECISION;
68
- _xp[1] = RATE_1 * balances[1] / PRECISION;
68
+ _xp[0] = (RATE_0 * balances[0]) / PRECISION;
69
+ _xp[1] = (RATE_1 * balances[1]) / PRECISION;
69
70
 
70
71
  return _get_D(_xp, _amp);
71
72
  }
@@ -104,4 +105,23 @@ library CurveFraxUsdcPoolHelper {
104
105
  }
105
106
  assert(false);
106
107
  }
108
+
109
+ function _getBalances() internal view returns (uint256[N_COINS] memory balances) {
110
+ balances[0] = ICrvPool(POOL).balances(0);
111
+ balances[1] = ICrvPool(POOL).balances(1);
112
+ }
113
+
114
+ function memcpy(uint256[N_COINS] memory a, uint256[N_COINS] memory b) internal pure {
115
+ for (uint256 i = 0; i < N_COINS; ++i) {
116
+ a[i] = b[i];
117
+ }
118
+ }
119
+
120
+ function _getTokenAmounts(address token, uint256 amount)
121
+ internal
122
+ pure
123
+ returns (uint256[N_COINS] memory res)
124
+ {
125
+ res[token == FRAX ? 0 : 1] = amount;
126
+ }
107
127
  }
@@ -0,0 +1,152 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.17;
3
+
4
+ import "../../../../libraries/math/Math.sol";
5
+ import "../../../../../interfaces/Curve/ICrvPool.sol";
6
+ import "./Curve3CrvPoolHelper.sol";
7
+ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
8
+
9
+ library CurveUsdd3CrvPoolHelper {
10
+ using Math for uint256;
11
+
12
+ uint256 internal constant N_COINS = 2;
13
+ uint256 internal constant A_PRECISION = 100;
14
+ uint256 internal constant PRECISION = 10**18;
15
+ uint256 internal constant rate_multiplier = 10**18;
16
+ uint256 internal constant FEE_DENOMINATOR = 10**10;
17
+
18
+ // LP == POOL
19
+ address internal constant POOL = 0xe6b5CC1B4b47305c58392CE3D359B10282FC36Ea;
20
+ address internal constant USDD = 0x0C10bF8FcB7Bf5412187A595ab97a3609160b5c6;
21
+ address internal constant LP_3CRV = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
22
+
23
+ function _getBalances() internal view returns (uint256[N_COINS] memory balances) {
24
+ balances[0] = ICrvPool(POOL).balances(0);
25
+ balances[1] = ICrvPool(POOL).balances(1);
26
+ }
27
+
28
+ function _getTokenAmounts(address token, uint256 amount)
29
+ internal
30
+ pure
31
+ returns (uint256[N_COINS] memory res)
32
+ {
33
+ res[token == USDD ? 0 : 1] = amount;
34
+ }
35
+
36
+ // ----------------- Forked from https://etherscan.io/address/0xe6b5CC1B4b47305c58392CE3D359B10282FC36Ea#code -----------------
37
+ function previewAddLiquidity(address token, uint256 amount) internal view returns (uint256) {
38
+ uint256 amp = ICrvPool(POOL).A_precise();
39
+
40
+ uint256[N_COINS] memory rates;
41
+
42
+ rates[0] = rate_multiplier;
43
+
44
+ if (token == USDD || token == LP_3CRV) {
45
+ rates[1] = Curve3CrvPoolHelper.get_virtual_price();
46
+ } else {
47
+ (amount, rates[1]) = Curve3CrvPoolHelper.preview3CrvDeposit(token, amount);
48
+ token = LP_3CRV;
49
+ }
50
+
51
+ uint256[N_COINS] memory amounts = _getTokenAmounts(token, amount);
52
+
53
+ uint256[N_COINS] memory old_balances = _getBalances();
54
+ uint256 D0 = get_D_mem(rates, old_balances, amp);
55
+ uint256[N_COINS] memory new_balances = arrayClone(old_balances);
56
+
57
+ uint256 total_supply = IERC20(POOL).totalSupply();
58
+ for (uint256 i = 0; i < N_COINS; ++i) {
59
+ new_balances[i] += amounts[i];
60
+ }
61
+
62
+ // Invariant after change
63
+ uint256 D1 = get_D_mem(rates, new_balances, amp);
64
+ assert(D1 > D0);
65
+
66
+ // We need to recalculate the invariant accounting for fees
67
+ // to calculate fair user's share
68
+ uint256[N_COINS] memory fees;
69
+ uint256 mint_amount = 0;
70
+
71
+ uint256 base_fee = (ICrvPool(POOL).fee() * N_COINS) / (4 * (N_COINS - 1));
72
+ for (uint256 i = 0; i < N_COINS; ++i) {
73
+ uint256 ideal_balance = (D1 * old_balances[i]) / D0;
74
+ uint256 difference = 0;
75
+ uint256 new_balance = new_balances[i];
76
+ if (ideal_balance > new_balance) {
77
+ difference = ideal_balance - new_balance;
78
+ } else {
79
+ difference = new_balance - ideal_balance;
80
+ }
81
+ fees[i] = (base_fee * difference) / FEE_DENOMINATOR;
82
+ new_balances[i] -= fees[i];
83
+ }
84
+ uint256 D2 = get_D_mem(rates, new_balances, amp);
85
+ mint_amount = (total_supply * (D2 - D0)) / D0;
86
+ return mint_amount;
87
+ }
88
+
89
+ function get_D_mem(
90
+ uint256[N_COINS] memory _rates,
91
+ uint256[N_COINS] memory _balances,
92
+ uint256 _amp
93
+ ) internal pure returns (uint256) {
94
+ uint256[N_COINS] memory xp = _xp_mem(_rates, _balances);
95
+ return get_D(xp, _amp);
96
+ }
97
+
98
+ function _xp_mem(uint256[N_COINS] memory _rates, uint256[N_COINS] memory balances)
99
+ internal
100
+ pure
101
+ returns (uint256[N_COINS] memory)
102
+ {
103
+ uint256[N_COINS] memory result;
104
+ for (uint256 i = 0; i < N_COINS; ++i) {
105
+ result[i] = balances[i] * _rates[i] / PRECISION;
106
+ }
107
+ return result;
108
+ }
109
+
110
+ function get_D(uint256[N_COINS] memory _xp, uint256 _amp) internal pure returns (uint256) {
111
+ uint256 S = 0;
112
+ uint256 Dprev = 0;
113
+ for (uint256 k = 0; k < N_COINS; ++k) {
114
+ S += _xp[k];
115
+ }
116
+ if (S == 0) return 0;
117
+
118
+ uint256 D = S;
119
+ uint256 Ann = _amp * N_COINS;
120
+ for (uint256 _i = 0; _i < 255; ++_i) {
121
+ uint256 D_P = D;
122
+ for (uint256 k = 0; k < N_COINS; ++k) {
123
+ D_P = (D_P * D) / (_xp[k] * N_COINS);
124
+ }
125
+ Dprev = D;
126
+ D =
127
+ (((Ann * S) / A_PRECISION + D_P * N_COINS) * D) /
128
+ (((Ann - A_PRECISION) * D) / A_PRECISION + (N_COINS + 1) * D_P);
129
+
130
+ if (D > Dprev) {
131
+ if (D - Dprev <= 1) {
132
+ return D;
133
+ }
134
+ } else {
135
+ if (Dprev - D <= 1) {
136
+ return D;
137
+ }
138
+ }
139
+ }
140
+ assert(false);
141
+ }
142
+
143
+ function arrayClone(uint256[N_COINS] memory a)
144
+ internal
145
+ pure
146
+ returns (uint256[N_COINS] memory res)
147
+ {
148
+ for (uint256 i = 0; i < N_COINS; ++i) {
149
+ res[i] = a[i];
150
+ }
151
+ }
152
+ }
@@ -0,0 +1,128 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.17;
3
+
4
+ import "../SYBase.sol";
5
+ import "../../../interfaces/ILooksFeeSharing.sol";
6
+ import "../../../interfaces/ILooksStaking.sol";
7
+
8
+ contract PendleLooksStakingSY is SYBase {
9
+ using Math for uint256;
10
+
11
+ address public immutable looks;
12
+ address public immutable stakingContract;
13
+ address public immutable feeSharingContract;
14
+
15
+ constructor(
16
+ string memory _name,
17
+ string memory _symbol,
18
+ address _looks,
19
+ address _stakingContract,
20
+ address _feeSharingContract
21
+ ) SYBase(_name, _symbol, _looks) {
22
+ looks = _looks;
23
+ stakingContract = _stakingContract;
24
+ feeSharingContract = _feeSharingContract;
25
+
26
+ _safeApproveInf(_looks, _stakingContract);
27
+ }
28
+
29
+ /*///////////////////////////////////////////////////////////////
30
+ DEPOSIT/REDEEM USING BASE TOKENS
31
+ //////////////////////////////////////////////////////////////*/
32
+
33
+ function _deposit(address, uint256 amountDeposited)
34
+ internal
35
+ virtual
36
+ override
37
+ returns (uint256 amountSharesOut)
38
+ {
39
+ uint256 previousShare = ILooksStaking(stakingContract).userInfo(address(this));
40
+ ILooksStaking(stakingContract).deposit(amountDeposited);
41
+ amountSharesOut = ILooksStaking(stakingContract).userInfo(address(this)) - previousShare;
42
+ }
43
+
44
+ function _redeem(
45
+ address receiver,
46
+ address,
47
+ uint256 amountSharesToRedeem
48
+ ) internal virtual override returns (uint256 amountTokenOut) {
49
+ uint256 previousBalance = _selfBalance(looks);
50
+ ILooksStaking(stakingContract).withdraw(amountSharesToRedeem);
51
+ amountTokenOut = _selfBalance(looks) - previousBalance;
52
+ _transferOut(looks, receiver, amountTokenOut);
53
+ }
54
+
55
+ /*///////////////////////////////////////////////////////////////
56
+ EXCHANGE-RATE
57
+ //////////////////////////////////////////////////////////////*/
58
+
59
+ function exchangeRate() public view virtual override returns (uint256) {
60
+ (uint256 totalShares, uint256 totalLooks) = _getLooksStakingParams();
61
+ return totalLooks.divDown(totalShares);
62
+ }
63
+
64
+ /*///////////////////////////////////////////////////////////////
65
+ MISC FUNCTIONS FOR METADATA
66
+ //////////////////////////////////////////////////////////////*/
67
+
68
+ function _previewDeposit(address, uint256 amountTokenToDeposit)
69
+ internal
70
+ view
71
+ override
72
+ returns (uint256 amountSharesOut)
73
+ {
74
+ (uint256 totalShares, uint256 totalLooks) = _getLooksStakingParams();
75
+ amountSharesOut = (amountTokenToDeposit * totalShares) / totalLooks;
76
+ }
77
+
78
+ function _previewRedeem(address, uint256 amountSharesToRedeem)
79
+ internal
80
+ view
81
+ override
82
+ returns (uint256 amountTokenOut)
83
+ {
84
+ (uint256 totalShares, uint256 totalLooks) = _getLooksStakingParams();
85
+ amountTokenOut = (amountSharesToRedeem * totalLooks) / totalShares;
86
+ }
87
+
88
+ function _getLooksStakingParams()
89
+ private
90
+ view
91
+ returns (uint256 totalShares, uint256 totalLooks)
92
+ {
93
+ totalShares = ILooksStaking(stakingContract).totalShares();
94
+ totalLooks = ILooksFeeSharing(feeSharingContract).calculateSharesValueInLOOKS(
95
+ stakingContract
96
+ );
97
+ }
98
+
99
+ function getTokensIn() public view virtual override returns (address[] memory res) {
100
+ res = new address[](1);
101
+ res[0] = looks;
102
+ }
103
+
104
+ function getTokensOut() public view virtual override returns (address[] memory res) {
105
+ res = new address[](1);
106
+ res[0] = looks;
107
+ }
108
+
109
+ function isValidTokenIn(address token) public view virtual override returns (bool) {
110
+ return token == looks;
111
+ }
112
+
113
+ function isValidTokenOut(address token) public view virtual override returns (bool) {
114
+ return token == looks;
115
+ }
116
+
117
+ function assetInfo()
118
+ external
119
+ view
120
+ returns (
121
+ AssetType assetType,
122
+ address assetAddress,
123
+ uint8 assetDecimals
124
+ )
125
+ {
126
+ return (AssetType.TOKEN, looks, IERC20Metadata(looks).decimals());
127
+ }
128
+ }
@@ -9,7 +9,7 @@ import "../libraries/Errors.sol";
9
9
 
10
10
  import "../erc20/PendleERC20Permit.sol";
11
11
 
12
- import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
12
+ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
13
13
 
14
14
  contract PendlePrincipalToken is PendleERC20Permit, Initializable, IPPrincipalToken {
15
15
  address public immutable SY;
@@ -22,7 +22,7 @@ contract PendlePrincipalToken is PendleERC20Permit, Initializable, IPPrincipalTo
22
22
  _;
23
23
  }
24
24
 
25
- modifier onlYieldFactory() {
25
+ modifier onlyYieldFactory() {
26
26
  if (msg.sender != factory) revert Errors.OnlyYCFactory();
27
27
  _;
28
28
  }
@@ -39,7 +39,7 @@ contract PendlePrincipalToken is PendleERC20Permit, Initializable, IPPrincipalTo
39
39
  factory = msg.sender;
40
40
  }
41
41
 
42
- function initialize(address _YT) external initializer onlYieldFactory {
42
+ function initialize(address _YT) external initializer onlyYieldFactory {
43
43
  YT = _YT;
44
44
  }
45
45