@pendle/core-v2 0.16.2-testnet → 0.16.3-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 (319) 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 +15 -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 +15 -2
  6. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
  7. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.json +13 -0
  8. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
  9. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
  10. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +15 -2
  11. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
  12. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +15 -2
  13. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  14. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +13 -0
  15. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  16. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +15 -2
  17. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  18. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +15 -2
  19. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  20. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +15 -2
  21. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  22. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  23. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +15 -2
  24. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  25. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +15 -2
  26. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  27. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  28. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  29. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  30. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
  31. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  32. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  33. package/build/artifacts/contracts/LiquidityMining/libraries/WeekMath.sol/WeekMath.dbg.json +1 -1
  34. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +4 -0
  35. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +695 -0
  36. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +4 -0
  37. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +531 -0
  38. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +4 -0
  39. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +10 -0
  40. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  41. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
  42. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  43. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
  44. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  46. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
  47. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  48. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +15 -2
  49. package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
  50. package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  51. package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +1 -1
  52. package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.json +2 -2
  53. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  54. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  55. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
  57. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
  59. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
  60. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +4 -0
  61. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.json +89 -0
  62. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  63. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -2
  64. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  65. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  66. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +15 -2
  67. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  68. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +15 -2
  69. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  70. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
  71. package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
  72. package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.json +2 -2
  73. package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
  74. package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
  75. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
  76. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +2 -2
  77. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +1 -1
  78. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.json +2 -2
  79. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
  80. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.json +13 -0
  81. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
  82. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.json +2 -2
  83. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  84. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +208 -2
  85. package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
  86. package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
  87. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
  88. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +30 -83
  89. package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
  90. package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
  91. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  92. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +91 -17
  93. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  94. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +50 -0
  95. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  96. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +20 -0
  97. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
  98. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  99. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +20 -0
  100. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  101. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +181 -17
  102. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +4 -0
  103. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.json +173 -0
  104. package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +4 -0
  105. package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.json +86 -0
  106. package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.dbg.json +4 -0
  107. package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.json +34 -0
  108. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  109. package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
  110. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  111. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  112. package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
  113. package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
  114. package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
  115. package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
  116. package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
  117. package/build/artifacts/contracts/interfaces/ISJoe.sol/ISJoe.dbg.json +1 -1
  118. package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
  119. package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.json +45 -0
  120. package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
  121. package/build/artifacts/contracts/interfaces/IWAvax.sol/IWAvax.dbg.json +1 -1
  122. package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
  123. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
  124. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +15 -2
  125. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +4 -0
  126. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +67 -0
  127. package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.dbg.json +1 -1
  128. package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.json +2 -2
  129. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
  130. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -36
  131. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  132. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +237 -61
  133. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  134. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +120 -41
  135. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  136. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
  137. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  138. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +79 -24
  139. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
  140. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
  141. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  142. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +49 -24
  143. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
  144. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
  145. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  146. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +49 -24
  147. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  148. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +15 -2
  149. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  150. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.json +14 -1
  151. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  152. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  153. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  154. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  155. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
  156. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +191 -2
  157. package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.dbg.json +4 -0
  158. package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.json +35 -0
  159. package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
  160. package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.json +1 -1
  161. package/contracts/core/BulkSeller/BulkSeller.sol +250 -0
  162. package/contracts/core/BulkSeller/BulkSellerFactory.sol +89 -0
  163. package/contracts/core/BulkSeller/BulkSellerMathCore.sol +143 -0
  164. package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol +2 -4
  165. package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +107 -0
  166. package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +19 -4
  167. package/contracts/core/libraries/Errors.sol +17 -0
  168. package/contracts/interfaces/Curve/ICrvPool.sol +9 -27
  169. package/contracts/interfaces/IPActionAddRemoveLiq.sol +3 -5
  170. package/contracts/interfaces/IPActionMintRedeem.sol +2 -0
  171. package/contracts/interfaces/IPBulkSeller.sol +28 -0
  172. package/contracts/interfaces/IPBulkSellerFactory.sol +12 -0
  173. package/contracts/interfaces/IPBulkSellerSYCallback.sol +10 -0
  174. package/contracts/interfaces/IStETH.sol +6 -0
  175. package/contracts/offchain-helpers/BulkSellerOffchain.sol +43 -0
  176. package/contracts/offchain-helpers/MarketMathStatic.sol +0 -144
  177. package/contracts/offchain-helpers/RouterStatic.sol +167 -51
  178. package/contracts/router/ActionAddRemoveLiq.sol +60 -44
  179. package/contracts/router/ActionMintRedeem.sol +19 -15
  180. package/contracts/router/ActionSwapPT.sol +3 -3
  181. package/contracts/router/ActionSwapYT.sol +11 -4
  182. package/contracts/router/base/ActionBaseMintRedeem.sol +73 -74
  183. package/contracts/router/kyberswap/AggregationRouterHelper.sol +17 -1
  184. package/contracts/router/kyberswap/IAggregatorRouterHelper.sol +10 -0
  185. package/contracts/router/kyberswap/KyberSwapHelper.sol +17 -8
  186. package/deployments/43113-core.json +3 -2
  187. package/deployments/43113-markets/benqi-market-QI-AVAX-FEB-2ND.json +9 -0
  188. package/deployments/80001-core.json +3 -2
  189. package/package.json +3 -2
  190. package/typechain-types/AccessControl.ts +360 -0
  191. package/typechain-types/ActionAddRemoveLiq.ts +83 -52
  192. package/typechain-types/ActionBaseMintRedeem.ts +27 -8
  193. package/typechain-types/ActionMintRedeem.ts +68 -17
  194. package/typechain-types/ActionSwapPT.ts +53 -12
  195. package/typechain-types/ActionSwapYT.ts +53 -12
  196. package/typechain-types/AggregationRouterHelper.ts +287 -3
  197. package/typechain-types/BaseSplitCodeFactoryContract.ts +9 -0
  198. package/typechain-types/BeaconProxy.ts +97 -0
  199. package/typechain-types/BoringOwnableUpgradeable.ts +9 -0
  200. package/typechain-types/BulkSeller.ts +776 -0
  201. package/typechain-types/BulkSellerFactory.ts +707 -0
  202. package/typechain-types/BulkSellerOffchain.ts +117 -0
  203. package/typechain-types/Curve3CrvPoolHelper.ts +236 -0
  204. package/typechain-types/CurveFraxUsdcPoolHelper.ts +158 -0
  205. package/typechain-types/CurveUsdd3CrvPoolHelper.ts +184 -0
  206. package/typechain-types/ERC165.ts +102 -0
  207. package/typechain-types/IAccessControl.ts +305 -0
  208. package/typechain-types/IAggregationRouterHelper.ts +108 -0
  209. package/typechain-types/ICrvPool.ts +66 -164
  210. package/typechain-types/IERC165.ts +102 -0
  211. package/typechain-types/IPActionAddRemoveLiq.ts +56 -44
  212. package/typechain-types/IPActionMintRedeem.ts +41 -9
  213. package/typechain-types/IPActionSwapPT.ts +26 -4
  214. package/typechain-types/IPActionSwapYT.ts +26 -4
  215. package/typechain-types/IPAllAction.ts +77 -55
  216. package/typechain-types/IPBulkSeller.ts +290 -0
  217. package/typechain-types/IPBulkSellerCallback.ts +115 -0
  218. package/typechain-types/IPBulkSellerFactory.ts +147 -0
  219. package/typechain-types/IStETH.ts +56 -0
  220. package/typechain-types/ITriCrvPool.ts +345 -0
  221. package/typechain-types/Initializable.ts +68 -0
  222. package/typechain-types/KyberSwapHelper.ts +8 -8
  223. package/typechain-types/MarketMathStatic.ts +0 -50
  224. package/typechain-types/PendleCurveFraxUsdcSY.ts +1228 -0
  225. package/typechain-types/PendleCurveUsdd3CrvSY.ts +1299 -0
  226. package/typechain-types/PendleFeeDistributor.ts +9 -0
  227. package/typechain-types/PendleFeeDistributorFactory.ts +9 -0
  228. package/typechain-types/PendleGaugeControllerBaseUpg.ts +9 -0
  229. package/typechain-types/PendleGaugeControllerMainchainUpg.ts +9 -0
  230. package/typechain-types/PendleGaugeControllerSidechainUpg.ts +9 -0
  231. package/typechain-types/PendleMarketFactory.ts +9 -0
  232. package/typechain-types/PendleMsgReceiveEndpointUpg.ts +9 -0
  233. package/typechain-types/PendleMsgSendEndpointUpg.ts +9 -0
  234. package/typechain-types/PendleMsgSenderAppUpg.ts +9 -0
  235. package/typechain-types/PendlePrincipalToken.ts +9 -0
  236. package/typechain-types/PendleRouter.ts +9 -0
  237. package/typechain-types/PendleVotingControllerUpg.ts +9 -0
  238. package/typechain-types/PendleYieldContractFactory.ts +9 -0
  239. package/typechain-types/ReentrancyGuardUpgradeable.ts +68 -0
  240. package/typechain-types/RouterStatic.ts +203 -22
  241. package/typechain-types/VotingEscrowPendleMainchain.ts +9 -0
  242. package/typechain-types/VotingEscrowPendleSidechain.ts +9 -0
  243. package/typechain-types/factories/AccessControl__factory.ts +227 -0
  244. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +131 -59
  245. package/typechain-types/factories/ActionBaseMintRedeem__factory.ts +14 -1
  246. package/typechain-types/factories/ActionCallback__factory.ts +1 -1
  247. package/typechain-types/factories/ActionMintRedeem__factory.ts +90 -42
  248. package/typechain-types/factories/ActionMisc__factory.ts +1 -1
  249. package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
  250. package/typechain-types/factories/ActionSwapPT__factory.ts +60 -42
  251. package/typechain-types/factories/ActionSwapYT__factory.ts +60 -42
  252. package/typechain-types/factories/AggregationRouterHelper__factory.ts +190 -1
  253. package/typechain-types/factories/BaseSplitCodeFactoryContract__factory.ts +14 -1
  254. package/typechain-types/factories/BaseSplitCodeFactory__factory.ts +1 -1
  255. package/typechain-types/factories/BeaconProxy__factory.ts +141 -0
  256. package/typechain-types/factories/BoringOwnableUpgradeableData__factory.ts +1 -1
  257. package/typechain-types/factories/BoringOwnableUpgradeable__factory.ts +13 -0
  258. package/typechain-types/factories/BulkSellerFactory__factory.ts +584 -0
  259. package/typechain-types/factories/BulkSellerOffchain__factory.ts +120 -0
  260. package/typechain-types/factories/BulkSeller__factory.ts +745 -0
  261. package/typechain-types/factories/Curve3CrvPoolHelper__factory.ts +220 -0
  262. package/typechain-types/factories/CurveFraxUsdcPoolHelper__factory.ts +146 -0
  263. package/typechain-types/factories/CurveUsdd3CrvPoolHelper__factory.ts +172 -0
  264. package/typechain-types/factories/ERC165__factory.ts +39 -0
  265. package/typechain-types/factories/ERC20__factory.ts +1 -1
  266. package/typechain-types/factories/Errors__factory.ts +207 -1
  267. package/typechain-types/factories/IAccessControl__factory.ts +198 -0
  268. package/typechain-types/factories/IAggregationRouterHelper__factory.ts +54 -0
  269. package/typechain-types/factories/ICrvPool__factory.ts +30 -83
  270. package/typechain-types/factories/IERC165__factory.ts +42 -0
  271. package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +91 -17
  272. package/typechain-types/factories/IPActionMintRedeem__factory.ts +50 -0
  273. package/typechain-types/factories/IPActionSwapPT__factory.ts +20 -0
  274. package/typechain-types/factories/IPActionSwapYT__factory.ts +20 -0
  275. package/typechain-types/factories/IPAllAction__factory.ts +181 -17
  276. package/typechain-types/factories/IPBulkSellerCallback__factory.ts +53 -0
  277. package/typechain-types/factories/IPBulkSellerFactory__factory.ts +101 -0
  278. package/typechain-types/factories/IPBulkSeller__factory.ts +185 -0
  279. package/typechain-types/factories/IStETH__factory.ts +45 -0
  280. package/typechain-types/factories/ITriCrvPool__factory.ts +225 -0
  281. package/typechain-types/factories/ImplicitSwapfeeContract__factory.ts +1 -1
  282. package/typechain-types/factories/Initializable__factory.ts +36 -0
  283. package/typechain-types/factories/KyberSwapHelper__factory.ts +1 -1
  284. package/typechain-types/factories/MarketMathStatic__factory.ts +1 -35
  285. package/typechain-types/factories/OracleLib__factory.ts +1 -1
  286. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1068 -0
  287. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1168 -0
  288. package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
  289. package/typechain-types/factories/PendleERC20__factory.ts +1 -1
  290. package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +14 -1
  291. package/typechain-types/factories/PendleFeeDistributor__factory.ts +14 -1
  292. package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +13 -0
  293. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +14 -1
  294. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +14 -1
  295. package/typechain-types/factories/PendleMarketFactory__factory.ts +14 -1
  296. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  297. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +14 -1
  298. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +14 -1
  299. package/typechain-types/factories/PendleMsgSenderAppUpg__factory.ts +13 -0
  300. package/typechain-types/factories/PendlePrincipalToken__factory.ts +14 -1
  301. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  302. package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
  303. package/typechain-types/factories/PendleRouter__factory.ts +14 -1
  304. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +14 -1
  305. package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
  306. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +14 -1
  307. package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
  308. package/typechain-types/factories/ReentrancyGuardUpgradeable__factory.ts +43 -0
  309. package/typechain-types/factories/RouterStatic__factory.ts +182 -2
  310. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +14 -1
  311. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +14 -1
  312. package/typechain-types/hardhat.d.ts +139 -13
  313. package/typechain-types/index.ts +30 -4
  314. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.dbg.json +0 -4
  315. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.json +0 -1018
  316. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +0 -4
  317. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +0 -76
  318. package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol +0 -167
  319. package/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol +0 -83
@@ -4,6 +4,8 @@ pragma solidity 0.8.17;
4
4
  import "../interfaces/IPYieldContractFactory.sol";
5
5
  import "../interfaces/IPMarketFactory.sol";
6
6
  import "../interfaces/IPVotingEscrowMainchain.sol";
7
+ import "../interfaces/IPBulkSellerFactory.sol";
8
+ import "../interfaces/IPBulkSeller.sol";
7
9
 
8
10
  import "./MarketMathStatic.sol";
9
11
 
@@ -58,15 +60,18 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
58
60
  IPYieldContractFactory internal immutable yieldContractFactory;
59
61
  IPMarketFactory internal immutable marketFactory;
60
62
  IPVotingEscrowMainchain internal immutable vePENDLE;
63
+ IPBulkSellerFactory internal immutable bulkFactory;
61
64
 
62
65
  constructor(
63
66
  IPYieldContractFactory _yieldContractFactory,
64
67
  IPMarketFactory _marketFactory,
65
- IPVotingEscrowMainchain _vePENDLE
68
+ IPVotingEscrowMainchain _vePENDLE,
69
+ IPBulkSellerFactory _bulkFactory
66
70
  ) initializer {
67
71
  yieldContractFactory = _yieldContractFactory;
68
72
  marketFactory = _marketFactory;
69
73
  vePENDLE = _vePENDLE;
74
+ bulkFactory = _bulkFactory;
70
75
  }
71
76
 
72
77
  function initialize() external initializer {
@@ -283,6 +288,7 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
283
288
  address market,
284
289
  address tokenIn,
285
290
  uint256 netTokenDesired,
291
+ bool useBulk,
286
292
  uint256 netPtDesired
287
293
  )
288
294
  external
@@ -293,13 +299,23 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
293
299
  uint256 netPtUsed
294
300
  )
295
301
  {
296
- return
297
- MarketMathStatic.addLiquidityDualTokenAndPtStatic(
298
- market,
299
- tokenIn,
300
- netTokenDesired,
301
- netPtDesired
302
- );
302
+ uint256 netSyDesired = previewDepositStatic(
303
+ getSyMarket(market),
304
+ tokenIn,
305
+ netTokenDesired,
306
+ useBulk
307
+ );
308
+
309
+ uint256 netSyUsed;
310
+ (netLpOut, netSyUsed, netPtUsed) = MarketMathStatic.addLiquidityDualSyAndPtStatic(
311
+ market,
312
+ netSyDesired,
313
+ netPtDesired
314
+ );
315
+
316
+ if (netSyUsed != netSyDesired) revert Errors.RouterNotAllSyUsed(netSyDesired, netSyUsed);
317
+
318
+ netTokenUsed = netTokenDesired;
303
319
  }
304
320
 
305
321
  function addLiquiditySinglePtStatic(address market, uint256 netPtIn)
@@ -331,7 +347,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
331
347
  function addLiquiditySingleBaseTokenStatic(
332
348
  address market,
333
349
  address baseToken,
334
- uint256 netBaseTokenIn
350
+ uint256 netBaseTokenIn,
351
+ bool useBulk
335
352
  )
336
353
  external
337
354
  returns (
@@ -341,13 +358,15 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
341
358
  uint256 priceImpact
342
359
  )
343
360
  {
361
+ uint256 netSyIn = previewDepositStatic(
362
+ getSyMarket(market),
363
+ baseToken,
364
+ netBaseTokenIn,
365
+ useBulk
366
+ );
367
+
344
368
  return
345
- MarketMathStatic.addLiquiditySingleBaseTokenStatic(
346
- market,
347
- baseToken,
348
- netBaseTokenIn,
349
- getDefaultApproxParams()
350
- );
369
+ MarketMathStatic.addLiquiditySingleSyStatic(market, netSyIn, getDefaultApproxParams());
351
370
  }
352
371
 
353
372
  function removeLiquidityDualSyAndPtStatic(address market, uint256 netLpToRemove)
@@ -361,10 +380,17 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
361
380
  function removeLiquidityDualTokenAndPtStatic(
362
381
  address market,
363
382
  uint256 netLpToRemove,
364
- address tokenOut
383
+ address tokenOut,
384
+ bool useBulk
365
385
  ) external view returns (uint256 netTokenOut, uint256 netPtOut) {
366
- return
367
- MarketMathStatic.removeLiquidityDualTokenAndPtStatic(market, netLpToRemove, tokenOut);
386
+ uint256 netSyOut;
387
+
388
+ (netSyOut, netPtOut) = MarketMathStatic.removeLiquidityDualSyAndPtStatic(
389
+ market,
390
+ netLpToRemove
391
+ );
392
+
393
+ netTokenOut = previewRedeemStatic(getSyMarket(market), tokenOut, netSyOut, useBulk);
368
394
  }
369
395
 
370
396
  function removeLiquiditySinglePtStatic(address market, uint256 netLpToRemove)
@@ -398,7 +424,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
398
424
  function removeLiquiditySingleBaseTokenStatic(
399
425
  address market,
400
426
  uint256 netLpToRemove,
401
- address baseToken
427
+ address baseToken,
428
+ bool useBulk
402
429
  )
403
430
  external
404
431
  returns (
@@ -407,12 +434,14 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
407
434
  uint256 priceImpact
408
435
  )
409
436
  {
410
- return
411
- MarketMathStatic.removeLiquiditySingleBaseTokenStatic(
412
- market,
413
- netLpToRemove,
414
- baseToken
415
- );
437
+ uint256 netSyOut;
438
+
439
+ (netSyOut, netSyFee, priceImpact) = MarketMathStatic.removeLiquiditySingleSyStatic(
440
+ market,
441
+ netLpToRemove
442
+ );
443
+
444
+ netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, useBulk);
416
445
  }
417
446
 
418
447
  function swapExactPtForSyStatic(address market, uint256 exactPtIn)
@@ -464,7 +493,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
464
493
  function swapExactBaseTokenForPtStatic(
465
494
  address market,
466
495
  address baseToken,
467
- uint256 amountBaseToken
496
+ uint256 amountBaseToken,
497
+ bool useBulk
468
498
  )
469
499
  external
470
500
  returns (
@@ -473,19 +503,20 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
473
503
  uint256 priceImpact
474
504
  )
475
505
  {
476
- return
477
- MarketMathStatic.swapExactBaseTokenForPtStatic(
478
- market,
479
- baseToken,
480
- amountBaseToken,
481
- getDefaultApproxParams()
482
- );
506
+ uint256 netSyIn = previewDepositStatic(
507
+ getSyMarket(market),
508
+ baseToken,
509
+ amountBaseToken,
510
+ useBulk
511
+ );
512
+ return MarketMathStatic.swapExactSyForPtStatic(market, netSyIn, getDefaultApproxParams());
483
513
  }
484
514
 
485
515
  function swapExactPtForBaseTokenStatic(
486
516
  address market,
487
517
  uint256 exactPtIn,
488
- address baseToken
518
+ address baseToken,
519
+ bool useBulk
489
520
  )
490
521
  external
491
522
  returns (
@@ -494,7 +525,13 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
494
525
  uint256 priceImpact
495
526
  )
496
527
  {
497
- return MarketMathStatic.swapExactPtForBaseTokenStatic(market, exactPtIn, baseToken);
528
+ uint256 netSyOut;
529
+ (netSyOut, netSyFee, priceImpact) = MarketMathStatic.swapExactPtForSyStatic(
530
+ market,
531
+ exactPtIn
532
+ );
533
+
534
+ netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, useBulk);
498
535
  }
499
536
 
500
537
  function swapSyForExactYtStatic(address market, uint256 exactYtOut)
@@ -546,7 +583,8 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
546
583
  function swapExactYtForBaseTokenStatic(
547
584
  address market,
548
585
  uint256 exactYtIn,
549
- address baseToken
586
+ address baseToken,
587
+ bool useBulk
550
588
  )
551
589
  external
552
590
  returns (
@@ -555,13 +593,20 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
555
593
  uint256 priceImpact
556
594
  )
557
595
  {
558
- return MarketMathStatic.swapExactYtForBaseTokenStatic(market, exactYtIn, baseToken);
596
+ uint256 netSyOut;
597
+ (netSyOut, netSyFee, priceImpact) = MarketMathStatic.swapExactYtForSyStatic(
598
+ market,
599
+ exactYtIn
600
+ );
601
+
602
+ netBaseTokenOut = previewRedeemStatic(getSyMarket(market), baseToken, netSyOut, useBulk);
559
603
  }
560
604
 
561
605
  function swapExactBaseTokenForYtStatic(
562
606
  address market,
563
607
  address baseToken,
564
- uint256 amountBaseToken
608
+ uint256 amountBaseToken,
609
+ bool useBulk
565
610
  )
566
611
  external
567
612
  returns (
@@ -570,13 +615,14 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
570
615
  uint256 priceImpact
571
616
  )
572
617
  {
573
- return
574
- MarketMathStatic.swapExactBaseTokenForYtStatic(
575
- market,
576
- baseToken,
577
- amountBaseToken,
578
- getDefaultApproxParams()
579
- );
618
+ uint256 netSyIn = previewDepositStatic(
619
+ getSyMarket(market),
620
+ baseToken,
621
+ amountBaseToken,
622
+ useBulk
623
+ );
624
+
625
+ return MarketMathStatic.swapExactSyForYtStatic(market, netSyIn, getDefaultApproxParams());
580
626
  }
581
627
 
582
628
  function swapExactPtForYtStatic(address market, uint256 exactPtIn)
@@ -661,19 +707,51 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
661
707
  function mintPYFromBaseStatic(
662
708
  address YT,
663
709
  address baseToken,
664
- uint256 amountBaseToken
710
+ uint256 amountBaseToken,
711
+ bool useBulk
665
712
  ) external returns (uint256 amountPY) {
666
713
  IStandardizedYield SY = IStandardizedYield(IPYieldToken(YT).SY());
667
- return mintPYFromSyStatic(YT, SY.previewDeposit(baseToken, amountBaseToken));
714
+ uint256 amountSy = previewDepositStatic(SY, baseToken, amountBaseToken, useBulk);
715
+ return mintPYFromSyStatic(YT, amountSy);
668
716
  }
669
717
 
670
718
  function redeemPYToBaseStatic(
671
719
  address YT,
672
720
  uint256 amountPYToRedeem,
673
- address baseToken
721
+ address baseToken,
722
+ bool useBulk
674
723
  ) external returns (uint256 amountBaseToken) {
675
724
  IStandardizedYield SY = IStandardizedYield(IPYieldToken(YT).SY());
676
- return SY.previewRedeem(baseToken, redeemPYToSyStatic(YT, amountPYToRedeem));
725
+ uint256 amountSy = redeemPYToSyStatic(YT, amountPYToRedeem);
726
+ return previewRedeemStatic(SY, baseToken, amountSy, useBulk);
727
+ }
728
+
729
+ function previewDepositStatic(
730
+ IStandardizedYield SY,
731
+ address baseToken,
732
+ uint256 amountToken,
733
+ bool useBulk
734
+ ) public view returns (uint256 amountSy) {
735
+ if (useBulk) {
736
+ address bulk = bulkFactory.get(baseToken, address(SY));
737
+ return IPBulkSeller(bulk).calcSwapExactTokenForSy(amountToken);
738
+ } else {
739
+ return SY.previewDeposit(baseToken, amountToken);
740
+ }
741
+ }
742
+
743
+ function previewRedeemStatic(
744
+ IStandardizedYield SY,
745
+ address baseToken,
746
+ uint256 amountSy,
747
+ bool useBulk
748
+ ) public view returns (uint256 amountBaseToken) {
749
+ if (useBulk) {
750
+ address bulk = bulkFactory.get(baseToken, address(SY));
751
+ return IPBulkSeller(bulk).calcSwapExactSyForToken(amountSy);
752
+ } else {
753
+ return SY.previewRedeem(baseToken, amountSy);
754
+ }
677
755
  }
678
756
 
679
757
  function getPtImpliedYield(address market) public view returns (int256) {
@@ -719,10 +797,48 @@ contract RouterStatic is Initializable, BoringOwnableUpgradeable, UUPSUpgradeabl
719
797
  }
720
798
 
721
799
  function getAmountTokenToMintSy(
722
- address SY,
800
+ IStandardizedYield SY,
723
801
  address tokenIn,
802
+ bool useBulk,
724
803
  uint256 netSyOut
725
804
  ) public view returns (uint256 netTokenIn) {
726
- return MarketMathStatic.getAmountTokenToMintSy(SY, tokenIn, netSyOut);
805
+ uint256 pivotAmount = netSyOut;
806
+
807
+ uint256 low = pivotAmount;
808
+ {
809
+ while (true) {
810
+ uint256 lowSyOut = previewDepositStatic(SY, tokenIn, low, useBulk);
811
+ if (lowSyOut >= netSyOut) low /= 10;
812
+ else break;
813
+ }
814
+ }
815
+
816
+ uint256 high = pivotAmount;
817
+ {
818
+ while (true) {
819
+ uint256 highSyOut = previewDepositStatic(SY, tokenIn, high, useBulk);
820
+ if (highSyOut < netSyOut) high *= 10;
821
+ else break;
822
+ }
823
+ }
824
+
825
+ while (low <= high) {
826
+ uint256 mid = (low + high) / 2;
827
+ uint256 syOut = previewDepositStatic(SY, tokenIn, mid, useBulk);
828
+
829
+ if (syOut >= netSyOut) {
830
+ netTokenIn = mid;
831
+ high = mid - 1;
832
+ } else {
833
+ low = mid + 1;
834
+ }
835
+ }
836
+
837
+ assert(netTokenIn > 0);
838
+ }
839
+
840
+ function getSyMarket(address market) public view returns (IStandardizedYield) {
841
+ (IStandardizedYield SY, , ) = IPMarket(market).readTokens();
842
+ return SY;
727
843
  }
728
844
  }
@@ -14,10 +14,11 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
14
14
  using MarketApproxPtOutLib for MarketState;
15
15
  using SafeERC20 for IERC20;
16
16
  using PYIndexLib for IPYieldToken;
17
+ using BulkSellerMathCore for BulkSellerState;
17
18
 
18
19
  /// @dev since this contract will be proxied, it must not contains non-immutable variables
19
- constructor(address _kyberSwapRouter)
20
- ActionBaseMintRedeem(_kyberSwapRouter) //solhint-disable-next-line no-empty-blocks
20
+ constructor(address _kyberScalingLib, address _bulkSellerDirectory)
21
+ ActionBaseMintRedeem(_kyberScalingLib, _bulkSellerDirectory) //solhint-disable-next-line no-empty-blocks
21
22
  {}
22
23
 
23
24
  function addLiquidityDualSyAndPt(
@@ -36,6 +37,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
36
37
  {
37
38
  (IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
38
39
 
40
+ // calculate the amount of SY and PT to be used
39
41
  MarketState memory state = IPMarket(market).readState();
40
42
  (, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
41
43
  netSyDesired,
@@ -46,6 +48,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
46
48
  // early-check
47
49
  if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
48
50
 
51
+ // execute the addLiquidity
49
52
  IERC20(SY).safeTransferFrom(msg.sender, market, netSyUsed);
50
53
  IERC20(PT).safeTransferFrom(msg.sender, market, netPtUsed);
51
54
 
@@ -63,8 +66,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
63
66
  function addLiquidityDualTokenAndPt(
64
67
  address receiver,
65
68
  address market,
66
- address tokenIn,
67
- uint256 netTokenDesired,
69
+ TokenInput calldata input,
68
70
  uint256 netPtDesired,
69
71
  uint256 minLpOut
70
72
  )
@@ -78,46 +80,38 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
78
80
  {
79
81
  (IStandardizedYield SY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
80
82
 
81
- uint256 netSyDesired = SY.previewDeposit(tokenIn, netTokenDesired);
83
+ uint256 netSyDesired = _mintSyFromToken(market, address(SY), 1, input);
82
84
  uint256 netSyUsed;
83
85
 
84
86
  {
87
+ // calc the amount of SY and PT to be used
85
88
  MarketState memory state = IPMarket(market).readState();
86
89
  (, netLpOut, netSyUsed, netPtUsed) = state.addLiquidity(
87
90
  netSyDesired,
88
91
  netPtDesired,
89
92
  block.timestamp
90
93
  );
91
- }
92
-
93
- if (netSyDesired != netSyUsed) revert Errors.RouterNotAllSyUsed(netSyDesired, netSyUsed);
94
- if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
95
-
96
- IERC20(PT).safeTransferFrom(msg.sender, market, netPtUsed);
97
94
 
98
- // convert tokenIn to SY to deposit
99
- netTokenUsed = netTokenDesired;
95
+ if (netSyDesired != netSyUsed)
96
+ revert Errors.RouterNotAllSyUsed(netSyDesired, netSyUsed);
97
+ if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
100
98
 
101
- if (tokenIn == NATIVE) {
102
- _transferIn(tokenIn, msg.sender, netTokenDesired);
103
- SY.deposit{ value: netTokenUsed }(market, tokenIn, netTokenUsed, netSyUsed);
104
- _transferOut(tokenIn, msg.sender, netTokenDesired - netTokenUsed);
105
- } else {
106
- _transferIn(tokenIn, msg.sender, netTokenUsed);
107
- _safeApproveInf(tokenIn, address(SY));
108
- SY.deposit(market, tokenIn, netTokenUsed, netSyUsed);
99
+ netTokenUsed = input.netTokenIn;
109
100
  }
110
101
 
102
+ // SY has been minted and transferred to the market
103
+ IERC20(PT).safeTransferFrom(msg.sender, market, netPtUsed);
111
104
  (netLpOut, , ) = IPMarket(market).mint(receiver, netSyUsed, netPtUsed);
112
105
 
106
+ // fail-safe
113
107
  if (netLpOut < minLpOut) assert(false);
114
108
 
115
109
  emit AddLiquidityDualTokenAndPt(
116
110
  msg.sender,
117
111
  market,
118
112
  receiver,
119
- tokenIn,
120
- netTokenDesired,
113
+ input.tokenIn,
114
+ netTokenUsed,
121
115
  netPtUsed,
122
116
  netLpOut
123
117
  );
@@ -132,6 +126,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
132
126
  ) external returns (uint256 netLpOut, uint256 netSyFee) {
133
127
  (, IPPrincipalToken PT, IPYieldToken YT) = IPMarket(market).readTokens();
134
128
 
129
+ // calculate the amount of PT to swap
135
130
  MarketState memory state = IPMarket(market).readState();
136
131
 
137
132
  (uint256 netPtSwap, , ) = state.approxSwapPtToAddLiquidity(
@@ -141,6 +136,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
141
136
  guessPtSwapToSy
142
137
  );
143
138
 
139
+ // execute the swap
144
140
  IERC20(PT).safeTransferFrom(msg.sender, market, netPtIn);
145
141
 
146
142
  uint256 netSyReceived;
@@ -148,8 +144,9 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
148
144
  market,
149
145
  netPtSwap,
150
146
  EMPTY_BYTES
151
- ); // ignore return, receiver = market
147
+ );
152
148
 
149
+ // execute the addLiquidity
153
150
  (netLpOut, , ) = IPMarket(market).mint(receiver, netSyReceived, netPtIn - netPtSwap);
154
151
 
155
152
  if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
@@ -165,8 +162,11 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
165
162
  ApproxParams calldata guessPtReceivedFromSy
166
163
  ) external returns (uint256 netLpOut, uint256 netSyFee) {
167
164
  (IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
165
+
166
+ // transfer SY to market
168
167
  IERC20(SY).safeTransferFrom(msg.sender, market, netSyIn);
169
168
 
169
+ // mint LP
170
170
  (netLpOut, netSyFee) = _addLiquiditySingleSy(
171
171
  receiver,
172
172
  market,
@@ -188,9 +188,10 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
188
188
  ) external payable returns (uint256 netLpOut, uint256 netSyFee) {
189
189
  (IStandardizedYield SY, , IPYieldToken YT) = IPMarket(market).readTokens();
190
190
 
191
- // all output SY is transferred directly to the market
192
- uint256 netSyUsed = _mintSyFromToken(address(market), address(SY), 1, input);
191
+ // mint SY directly to the market
192
+ uint256 netSyUsed = _mintSyFromToken(market, address(SY), 1, input);
193
193
 
194
+ // mint LP
194
195
  (netLpOut, netSyFee) = _addLiquiditySingleSy(
195
196
  receiver,
196
197
  market,
@@ -238,28 +239,33 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
238
239
  address receiver,
239
240
  address market,
240
241
  uint256 netLpToRemove,
241
- address tokenOut,
242
- uint256 minTokenOut,
242
+ TokenOutput calldata output,
243
243
  uint256 minPtOut
244
244
  ) external returns (uint256 netTokenOut, uint256 netPtOut) {
245
245
  (IStandardizedYield SY, , ) = IPMarket(market).readTokens();
246
246
 
247
+ // burn LP, SY sent to either SY or bulk, PT sent to receiver
247
248
  IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
248
249
 
249
250
  uint256 netSyOut;
250
- (netSyOut, netPtOut) = IPMarket(market).burn(address(SY), receiver, netLpToRemove);
251
-
252
- netTokenOut = SY.redeem(receiver, netSyOut, tokenOut, minTokenOut, true);
251
+ (netSyOut, netPtOut) = IPMarket(market).burn(
252
+ _syOrBulk(address(SY), output),
253
+ receiver,
254
+ netLpToRemove
255
+ );
253
256
 
254
257
  if (netPtOut < minPtOut) revert Errors.RouterInsufficientPtOut(netPtOut, minPtOut);
255
258
 
259
+ // redeem SY to token
260
+ netTokenOut = _redeemSyToToken(receiver, address(SY), netSyOut, output, false);
261
+
256
262
  emit RemoveLiquidityDualTokenAndPt(
257
263
  msg.sender,
258
264
  market,
259
265
  receiver,
260
266
  netLpToRemove,
261
267
  netPtOut,
262
- tokenOut,
268
+ output.tokenOut,
263
269
  netTokenOut
264
270
  );
265
271
  }
@@ -273,8 +279,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
273
279
  ) external returns (uint256 netPtOut, uint256 netSyFee) {
274
280
  (, , IPYieldToken YT) = IPMarket(market).readTokens();
275
281
 
276
- IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
277
-
282
+ // calculate the total amount of PT received from burning & selling SY
278
283
  MarketState memory state = IPMarket(market).readState();
279
284
  (uint256 syFromBurn, uint256 ptFromBurn) = state.removeLiquidity(netLpToRemove);
280
285
  (uint256 ptFromSwap, ) = state.approxSwapExactSyForPt(
@@ -287,14 +292,17 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
287
292
  if (ptFromBurn + ptFromSwap < minPtOut)
288
293
  revert Errors.RouterInsufficientPtOut(ptFromBurn + ptFromSwap, minPtOut);
289
294
 
295
+ // execute the burn & the swap
296
+ IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
297
+
290
298
  (, ptFromBurn) = IPMarket(market).burn(market, receiver, netLpToRemove);
291
299
  (, netSyFee) = IPMarket(market).swapSyForExactPt(receiver, ptFromSwap, EMPTY_BYTES);
292
300
 
293
- // fail-safe
294
- if (ptFromBurn + ptFromSwap < minPtOut) assert(false);
295
-
296
301
  netPtOut = ptFromBurn + ptFromSwap;
297
302
 
303
+ // fail-safe
304
+ if (netPtOut < minPtOut) assert(false);
305
+
298
306
  emit RemoveLiquiditySinglePt(msg.sender, market, receiver, netLpToRemove, netPtOut);
299
307
  }
300
308
 
@@ -304,8 +312,12 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
304
312
  uint256 netLpToRemove,
305
313
  uint256 minSyOut
306
314
  ) external returns (uint256 netSyOut, uint256 netSyFee) {
315
+ // transfer LP to market
307
316
  IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
317
+
318
+ // burn LP, SY sent to receiver
308
319
  (netSyOut, netSyFee) = _removeLiquiditySingleSy(receiver, market, netLpToRemove, minSyOut);
320
+
309
321
  emit RemoveLiquiditySingleSy(msg.sender, market, receiver, netLpToRemove, netSyOut);
310
322
  }
311
323
 
@@ -317,19 +329,19 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
317
329
  ) external returns (uint256 netTokenOut, uint256 netSyFee) {
318
330
  (IStandardizedYield SY, , ) = IPMarket(market).readTokens();
319
331
 
332
+ // transfer LP to market, burn LP, SY sent to either SY or bulk
320
333
  IERC20(market).safeTransferFrom(msg.sender, market, netLpToRemove);
321
334
 
322
- // all output SY is directly transferred to the SY contract
323
335
  uint256 netSyReceived;
324
336
 
325
337
  (netSyReceived, netSyFee) = _removeLiquiditySingleSy(
326
- address(SY),
338
+ _syOrBulk(address(SY), output),
327
339
  market,
328
340
  netLpToRemove,
329
341
  1
330
342
  );
331
343
 
332
- // since all SY is already at the SY contract, doPull = false
344
+ // redeem SY to token
333
345
  netTokenOut = _redeemSyToToken(receiver, address(SY), netSyReceived, output, false);
334
346
 
335
347
  emit RemoveLiquiditySingleToken(
@@ -352,20 +364,23 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
352
364
  ) internal returns (uint256 netLpOut, uint256 netSyFee) {
353
365
  MarketState memory state = IPMarket(market).readState();
354
366
 
355
- (uint256 netPtReceived, , ) = state.approxSwapSyToAddLiquidity(
367
+ // calculate the PT amount needed to add liquidity
368
+ (uint256 netPtFromSwap, , ) = state.approxSwapSyToAddLiquidity(
356
369
  YT.newIndex(),
357
370
  netSyIn,
358
371
  block.timestamp,
359
372
  guessPtReceivedFromSy
360
373
  );
361
374
 
375
+ // execute the swap & the addLiquidity
362
376
  uint256 netSySwapped;
363
377
  (netSySwapped, netSyFee) = IPMarket(market).swapSyForExactPt(
364
378
  market,
365
- netPtReceived,
379
+ netPtFromSwap,
366
380
  EMPTY_BYTES
367
- ); // ignore return, receiver = market
368
- (netLpOut, , ) = IPMarket(market).mint(receiver, netSyIn - netSySwapped, netPtReceived);
381
+ );
382
+
383
+ (netLpOut, , ) = IPMarket(market).mint(receiver, netSyIn - netSySwapped, netPtFromSwap);
369
384
 
370
385
  if (netLpOut < minLpOut) revert Errors.RouterInsufficientLpOut(netLpOut, minLpOut);
371
386
  }
@@ -412,6 +427,7 @@ contract ActionAddRemoveLiq is IPActionAddRemoveLiq, ActionBaseMintRedeem {
412
427
  ptFromBurn,
413
428
  EMPTY_BYTES
414
429
  );
430
+
415
431
  netSyOut = syFromBurn + syFromSwap;
416
432
  }
417
433
  }