@pendle/core-v2 0.15.0-mainnet → 0.15.2-mainnet

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 (431) 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 +110 -48
  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 +75 -21
  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 +39 -0
  8. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol/ExcessivelySafeCall.dbg.json +4 -0
  9. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol/ExcessivelySafeCall.json +10 -0
  10. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.dbg.json +4 -0
  11. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.json +10 -0
  12. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
  13. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
  14. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +15 -2
  15. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
  16. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +15 -2
  17. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  18. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +13 -0
  19. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  20. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +15 -2
  21. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  22. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +15 -2
  23. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  24. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +46 -2
  25. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  26. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  27. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +52 -8
  28. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  29. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +15 -2
  30. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  31. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  32. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  33. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  34. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
  35. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  36. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  37. package/build/artifacts/contracts/LiquidityMining/libraries/WeekMath.sol/WeekMath.dbg.json +1 -1
  38. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +4 -0
  39. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +699 -0
  40. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +4 -0
  41. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +515 -0
  42. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +4 -0
  43. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +10 -0
  44. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
  46. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
  48. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  49. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  50. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
  51. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  52. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +77 -17
  53. package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
  54. package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  55. package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.json +2 -2
  57. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  59. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  60. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
  61. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  62. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
  63. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +4 -0
  64. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +1003 -0
  65. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +4 -0
  66. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +1068 -0
  67. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +4 -0
  68. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.json +10 -0
  69. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +4 -0
  70. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.json +10 -0
  71. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +4 -0
  72. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.json +10 -0
  73. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +4 -0
  74. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol/PendleConvexLPSY.json +1 -1
  75. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +4 -0
  76. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +856 -0
  77. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  78. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -2
  79. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  80. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  81. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +15 -2
  82. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  83. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +85 -4
  84. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  85. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +17 -4
  86. package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
  87. package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.json +2 -2
  88. package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
  89. package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
  90. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
  91. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +3 -38
  92. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +1 -1
  93. package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.json +2 -2
  94. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
  95. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.json +13 -0
  96. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
  97. package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.json +2 -2
  98. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  99. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +319 -35
  100. package/build/artifacts/contracts/core/libraries/StringLib.sol/StringLib.dbg.json +4 -0
  101. package/build/artifacts/contracts/core/libraries/StringLib.sol/StringLib.json +10 -0
  102. package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
  103. package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
  104. package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.json +1 -1
  105. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
  106. package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +39 -85
  107. package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.dbg.json +4 -0
  108. package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.json +213 -0
  109. package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
  110. package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
  111. package/build/artifacts/contracts/interfaces/ILayerZeroEndpoint.sol/ILayerZeroEndpoint.dbg.json +4 -0
  112. package/build/artifacts/contracts/interfaces/ILayerZeroEndpoint.sol/ILayerZeroEndpoint.json +119 -0
  113. package/build/artifacts/contracts/interfaces/ILayerZeroReceiver.sol/ILayerZeroReceiver.dbg.json +4 -0
  114. package/build/artifacts/contracts/interfaces/ILayerZeroReceiver.sol/ILayerZeroReceiver.json +39 -0
  115. package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.dbg.json +4 -0
  116. package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.json +30 -0
  117. package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.dbg.json +4 -0
  118. package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.json +76 -0
  119. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  120. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +91 -17
  121. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  122. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +50 -0
  123. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  124. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +20 -0
  125. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
  126. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  127. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +20 -0
  128. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  129. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +181 -17
  130. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +4 -0
  131. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.json +173 -0
  132. package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +4 -0
  133. package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.json +86 -0
  134. package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.dbg.json +4 -0
  135. package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.json +34 -0
  136. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  137. package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
  138. package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.json +2 -2
  139. package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +1 -1
  140. package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.json +12 -2
  141. package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
  142. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  143. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  144. package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
  145. package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.json +1 -1
  146. package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
  147. package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
  148. package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
  149. package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
  150. package/build/artifacts/contracts/interfaces/ISJoe.sol/ISJoe.dbg.json +1 -1
  151. package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
  152. package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.json +45 -0
  153. package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
  154. package/build/artifacts/contracts/interfaces/IWAvax.sol/IWAvax.dbg.json +1 -1
  155. package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
  156. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
  157. package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +15 -2
  158. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +4 -0
  159. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +35 -0
  160. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
  161. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -80
  162. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  163. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +299 -60
  164. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  165. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +118 -41
  166. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  167. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
  168. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  169. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +61 -24
  170. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
  171. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
  172. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  173. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +31 -24
  174. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
  175. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
  176. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  177. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +31 -24
  178. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  179. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +15 -2
  180. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  181. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.json +1 -1
  182. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  183. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  184. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  185. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  186. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
  187. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +191 -2
  188. package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.dbg.json +4 -0
  189. package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.json +35 -0
  190. package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
  191. package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.json +1 -1
  192. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +58 -27
  193. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +46 -12
  194. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +31 -7
  195. package/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol +133 -0
  196. package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +27 -0
  197. package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +9 -10
  198. package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +9 -23
  199. package/contracts/core/BulkSeller/BulkSeller.sol +259 -0
  200. package/contracts/core/BulkSeller/BulkSellerFactory.sol +88 -0
  201. package/contracts/core/BulkSeller/BulkSellerMathCore.sol +143 -0
  202. package/contracts/core/Market/PendleMarket.sol +18 -7
  203. package/contracts/core/Market/PendleMarketFactory.sol +15 -5
  204. package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +102 -0
  205. package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +160 -0
  206. package/contracts/core/StandardizedYield/implementations/Convex/README.md +29 -0
  207. package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +215 -0
  208. package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +127 -0
  209. package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +152 -0
  210. package/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol +2 -4
  211. package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +122 -0
  212. package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +17 -8
  213. package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
  214. package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +38 -11
  215. package/contracts/core/YieldContracts/PendleYieldToken.sol +54 -21
  216. package/contracts/core/erc20/PendleERC20.sol +4 -7
  217. package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -1
  218. package/contracts/core/libraries/BoringOwnableUpgradeable.sol +1 -1
  219. package/contracts/core/libraries/Errors.sol +32 -4
  220. package/contracts/core/libraries/StringLib.sol +782 -0
  221. package/contracts/core/libraries/TokenHelper.sol +9 -0
  222. package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -1
  223. package/contracts/interfaces/Curve/ICrvPool.sol +12 -31
  224. package/contracts/interfaces/Curve/ITriCrvPool.sol +41 -0
  225. package/contracts/interfaces/ILayerZeroEndpoint.sol +39 -0
  226. package/contracts/interfaces/ILayerZeroReceiver.sol +12 -0
  227. package/contracts/interfaces/ILooksFeeSharing.sol +5 -0
  228. package/contracts/interfaces/ILooksStaking.sol +13 -0
  229. package/contracts/interfaces/IPActionAddRemoveLiq.sol +3 -5
  230. package/contracts/interfaces/IPActionMintRedeem.sol +2 -0
  231. package/contracts/interfaces/IPBulkSeller.sol +28 -0
  232. package/contracts/interfaces/IPBulkSellerFactory.sol +12 -0
  233. package/contracts/interfaces/IPBulkSellerSYCallback.sol +10 -0
  234. package/contracts/interfaces/IPMarketFactory.sol +1 -1
  235. package/contracts/interfaces/IPMsgSendEndpoint.sol +4 -2
  236. package/contracts/interfaces/IPYieldContractFactory.sol +1 -1
  237. package/contracts/interfaces/IStETH.sol +6 -0
  238. package/contracts/interfaces/IStandardizedYield.sol +15 -10
  239. package/contracts/offchain-helpers/BulkSellerOffchain.sol +43 -0
  240. package/contracts/offchain-helpers/MarketMathStatic.sol +0 -173
  241. package/contracts/offchain-helpers/RouterStatic.sol +189 -50
  242. package/contracts/router/ActionAddRemoveLiq.sol +71 -52
  243. package/contracts/router/ActionCallback.sol +4 -8
  244. package/contracts/router/ActionMintRedeem.sol +27 -18
  245. package/contracts/router/ActionSwapPT.sol +8 -9
  246. package/contracts/router/ActionSwapPTYT.sol +3 -7
  247. package/contracts/router/ActionSwapYT.sol +15 -10
  248. package/contracts/router/PendleRouter.sol +3 -0
  249. package/contracts/router/base/ActionBaseMintRedeem.sol +78 -83
  250. package/contracts/router/base/MarketApproxLib.sol +1 -1
  251. package/contracts/router/kyberswap/AggregationRouterHelper.sol +17 -1
  252. package/contracts/router/kyberswap/IAggregatorRouterHelper.sol +10 -0
  253. package/contracts/router/kyberswap/KyberSwapHelper.sol +21 -8
  254. package/deployments/1-markets/FRAX_30_MAR_23.json +8 -0
  255. package/deployments/1-markets/LOOKS_30_MAR_23.json +8 -0
  256. package/deployments/1-markets/STETH_MARCH_30.json +1 -1
  257. package/deployments/1-markets/USDD_MARCH_30.json +8 -0
  258. package/deployments/1-offchain-helper.json +3 -0
  259. package/package.json +3 -2
  260. package/typechain-types/AccessControl.ts +360 -0
  261. package/typechain-types/AccessControlUpgradeable.ts +369 -0
  262. package/typechain-types/ActionAddRemoveLiq.ts +64 -52
  263. package/typechain-types/ActionBaseMintRedeem.ts +8 -8
  264. package/typechain-types/ActionMintRedeem.ts +48 -16
  265. package/typechain-types/ActionSwapPT.ts +34 -12
  266. package/typechain-types/ActionSwapYT.ts +34 -12
  267. package/typechain-types/AggregationRouterHelper.ts +287 -3
  268. package/typechain-types/BaseSplitCodeFactoryContract.ts +9 -0
  269. package/typechain-types/BeaconProxy.ts +97 -0
  270. package/typechain-types/BoringOwnableUpgradeable.ts +9 -0
  271. package/typechain-types/BulkSeller.ts +777 -0
  272. package/typechain-types/BulkSellerFactory.ts +707 -0
  273. package/typechain-types/BulkSellerOffchain.ts +117 -0
  274. package/typechain-types/ContextUpgradeable.ts +68 -0
  275. package/typechain-types/Curve3CrvPoolHelper.ts +236 -0
  276. package/typechain-types/CurveFraxUsdcPoolHelper.ts +158 -0
  277. package/typechain-types/CurveUsdd3CrvPoolHelper.ts +184 -0
  278. package/typechain-types/ERC165.ts +102 -0
  279. package/typechain-types/ERC165Upgradeable.ts +113 -0
  280. package/typechain-types/IAccessControl.ts +305 -0
  281. package/typechain-types/IAccessControlUpgradeable.ts +305 -0
  282. package/typechain-types/IAggregationRouterHelper.ts +108 -0
  283. package/typechain-types/IBooster.ts +9 -3
  284. package/typechain-types/ICrvPool.ts +69 -172
  285. package/typechain-types/IERC165.ts +102 -0
  286. package/typechain-types/IERC165Upgradeable.ts +102 -0
  287. package/typechain-types/ILayerZeroEndpoint.ts +256 -0
  288. package/typechain-types/ILayerZeroReceiver.ts +117 -0
  289. package/typechain-types/ILooksFeeSharing.ts +102 -0
  290. package/typechain-types/ILooksStaking.ts +189 -0
  291. package/typechain-types/IPActionAddRemoveLiq.ts +56 -44
  292. package/typechain-types/IPActionMintRedeem.ts +40 -8
  293. package/typechain-types/IPActionSwapPT.ts +26 -4
  294. package/typechain-types/IPActionSwapYT.ts +26 -4
  295. package/typechain-types/IPAllAction.ts +76 -54
  296. package/typechain-types/IPBulkSeller.ts +290 -0
  297. package/typechain-types/IPBulkSellerCallback.ts +115 -0
  298. package/typechain-types/IPBulkSellerFactory.ts +147 -0
  299. package/typechain-types/IPMarketFactory.ts +2 -2
  300. package/typechain-types/IPMsgSendEndpoint.ts +24 -14
  301. package/typechain-types/IPYieldContractFactory.ts +3 -3
  302. package/typechain-types/IStETH.ts +56 -0
  303. package/typechain-types/ITriCrvPool.ts +345 -0
  304. package/typechain-types/ImplicitSwapfeeContract.ts +9 -17
  305. package/typechain-types/Initializable.ts +68 -0
  306. package/typechain-types/KyberSwapHelper.ts +8 -8
  307. package/typechain-types/MarketMathStatic.ts +0 -117
  308. package/typechain-types/PendleConvex2TokensSY.ts +1215 -0
  309. package/typechain-types/PendleCurveFraxUsdcSY.ts +1228 -0
  310. package/typechain-types/PendleCurveUsdd3CrvSY.ts +1299 -0
  311. package/typechain-types/PendleFeeDistributor.ts +9 -0
  312. package/typechain-types/PendleFeeDistributorFactory.ts +9 -0
  313. package/typechain-types/PendleGaugeControllerBaseUpg.ts +9 -0
  314. package/typechain-types/PendleGaugeControllerMainchainUpg.ts +9 -0
  315. package/typechain-types/PendleGaugeControllerSidechainUpg.ts +9 -0
  316. package/typechain-types/PendleLooksStaking.ts +1052 -0
  317. package/typechain-types/PendleLooksStakingSY.ts +1052 -0
  318. package/typechain-types/PendleMarketFactory.ts +51 -2
  319. package/typechain-types/PendleMsgReceiveEndpointUpg.ts +135 -68
  320. package/typechain-types/PendleMsgSendEndpointUpg.ts +108 -39
  321. package/typechain-types/PendleMsgSenderAppUpg.ts +64 -0
  322. package/typechain-types/PendlePrincipalToken.ts +9 -0
  323. package/typechain-types/PendleRouter.ts +9 -0
  324. package/typechain-types/PendleVotingControllerUpg.ts +64 -0
  325. package/typechain-types/PendleYieldContractFactory.ts +57 -8
  326. package/typechain-types/PendleYieldToken.ts +21 -0
  327. package/typechain-types/ReentrancyGuardUpgradeable.ts +68 -0
  328. package/typechain-types/RouterStatic.ts +302 -20
  329. package/typechain-types/VotingEscrowPendleMainchain.ts +70 -6
  330. package/typechain-types/VotingEscrowPendleSidechain.ts +9 -0
  331. package/typechain-types/factories/AccessControlUpgradeable__factory.ts +247 -0
  332. package/typechain-types/factories/AccessControl__factory.ts +227 -0
  333. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +122 -59
  334. package/typechain-types/factories/ActionBaseMintRedeem__factory.ts +1 -1
  335. package/typechain-types/factories/ActionCallback__factory.ts +1 -1
  336. package/typechain-types/factories/ActionMintRedeem__factory.ts +65 -42
  337. package/typechain-types/factories/ActionMisc__factory.ts +1 -1
  338. package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
  339. package/typechain-types/factories/ActionSwapPT__factory.ts +35 -42
  340. package/typechain-types/factories/ActionSwapYT__factory.ts +35 -42
  341. package/typechain-types/factories/AggregationRouterHelper__factory.ts +190 -1
  342. package/typechain-types/factories/BaseSplitCodeFactoryContract__factory.ts +14 -1
  343. package/typechain-types/factories/BaseSplitCodeFactory__factory.ts +1 -1
  344. package/typechain-types/factories/BeaconProxy__factory.ts +141 -0
  345. package/typechain-types/factories/BoringOwnableUpgradeableData__factory.ts +1 -1
  346. package/typechain-types/factories/BoringOwnableUpgradeable__factory.ts +13 -0
  347. package/typechain-types/factories/BulkSellerFactory__factory.ts +568 -0
  348. package/typechain-types/factories/BulkSellerOffchain__factory.ts +88 -0
  349. package/typechain-types/factories/BulkSeller__factory.ts +749 -0
  350. package/typechain-types/factories/ContextUpgradeable__factory.ts +39 -0
  351. package/typechain-types/factories/Curve3CrvPoolHelper__factory.ts +220 -0
  352. package/typechain-types/factories/CurveFraxUsdcPoolHelper__factory.ts +146 -0
  353. package/typechain-types/factories/CurveUsdd3CrvPoolHelper__factory.ts +172 -0
  354. package/typechain-types/factories/ERC165Upgradeable__factory.ts +58 -0
  355. package/typechain-types/factories/ERC165__factory.ts +39 -0
  356. package/typechain-types/factories/ERC20__factory.ts +1 -1
  357. package/typechain-types/factories/Errors__factory.ts +318 -34
  358. package/typechain-types/factories/IAccessControlUpgradeable__factory.ts +202 -0
  359. package/typechain-types/factories/IAccessControl__factory.ts +198 -0
  360. package/typechain-types/factories/IAggregationRouterHelper__factory.ts +54 -0
  361. package/typechain-types/factories/IBooster__factory.ts +1 -1
  362. package/typechain-types/factories/ICrvPool__factory.ts +39 -85
  363. package/typechain-types/factories/IERC165Upgradeable__factory.ts +45 -0
  364. package/typechain-types/factories/IERC165__factory.ts +42 -0
  365. package/typechain-types/factories/ILayerZeroEndpoint__factory.ts +134 -0
  366. package/typechain-types/factories/ILayerZeroReceiver__factory.ts +54 -0
  367. package/typechain-types/factories/ILooksFeeSharing__factory.ts +45 -0
  368. package/typechain-types/factories/ILooksStaking__factory.ts +88 -0
  369. package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +91 -17
  370. package/typechain-types/factories/IPActionMintRedeem__factory.ts +50 -0
  371. package/typechain-types/factories/IPActionSwapPT__factory.ts +20 -0
  372. package/typechain-types/factories/IPActionSwapYT__factory.ts +20 -0
  373. package/typechain-types/factories/IPAllAction__factory.ts +181 -17
  374. package/typechain-types/factories/IPBulkSellerCallback__factory.ts +53 -0
  375. package/typechain-types/factories/IPBulkSellerFactory__factory.ts +101 -0
  376. package/typechain-types/factories/IPBulkSeller__factory.ts +185 -0
  377. package/typechain-types/factories/IPMarketFactory__factory.ts +2 -2
  378. package/typechain-types/factories/IPMsgSendEndpoint__factory.ts +12 -2
  379. package/typechain-types/factories/IPYieldContractFactory__factory.ts +1 -1
  380. package/typechain-types/factories/IStETH__factory.ts +45 -0
  381. package/typechain-types/factories/ITriCrvPool__factory.ts +225 -0
  382. package/typechain-types/factories/ImplicitSwapfeeContract__factory.ts +4 -12
  383. package/typechain-types/factories/Initializable__factory.ts +36 -0
  384. package/typechain-types/factories/KyberSwapHelper__factory.ts +1 -1
  385. package/typechain-types/factories/MarketMathStatic__factory.ts +1 -79
  386. package/typechain-types/factories/OracleLib__factory.ts +1 -1
  387. package/typechain-types/factories/Pendle3CrvAndTokenSY__factory.ts +1 -1
  388. package/typechain-types/factories/PendleConvex2TokensSY__factory.ts +1093 -0
  389. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1068 -0
  390. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1133 -0
  391. package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
  392. package/typechain-types/factories/PendleERC20__factory.ts +1 -1
  393. package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +14 -1
  394. package/typechain-types/factories/PendleFeeDistributor__factory.ts +14 -1
  395. package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +13 -0
  396. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +14 -1
  397. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +14 -1
  398. package/typechain-types/factories/PendleLooksStakingSY__factory.ts +937 -0
  399. package/typechain-types/factories/PendleLooksStaking__factory.ts +933 -0
  400. package/typechain-types/factories/PendleMarketFactory__factory.ts +76 -16
  401. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  402. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +113 -51
  403. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +84 -23
  404. package/typechain-types/factories/PendleMsgSenderAppUpg__factory.ts +39 -0
  405. package/typechain-types/factories/PendlePrincipalToken__factory.ts +14 -1
  406. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  407. package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
  408. package/typechain-types/factories/PendleRouter__factory.ts +14 -1
  409. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +57 -2
  410. package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
  411. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +84 -3
  412. package/typechain-types/factories/PendleYieldToken__factory.ts +16 -3
  413. package/typechain-types/factories/ReentrancyGuardUpgradeable__factory.ts +43 -0
  414. package/typechain-types/factories/RouterStatic__factory.ts +244 -1
  415. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +63 -8
  416. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +14 -1
  417. package/typechain-types/hardhat.d.ts +260 -35
  418. package/typechain-types/index.ts +56 -10
  419. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.dbg.json +0 -4
  420. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.json +0 -1018
  421. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +0 -4
  422. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +0 -4
  423. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +0 -76
  424. package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.dbg.json +0 -4
  425. package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.json +0 -53
  426. package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.dbg.json +0 -4
  427. package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.json +0 -45
  428. package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol +0 -167
  429. package/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol +0 -83
  430. package/contracts/interfaces/ICelerMessageBus.sol +0 -28
  431. package/contracts/interfaces/ICelerMessageReceiverApp.sol +0 -25
@@ -0,0 +1,782 @@
1
+ /*
2
+ * @title String & slice utility library for Solidity contracts.
3
+ * @author Nick Johnson <arachnid@notdot.net>
4
+ *
5
+ * @dev Functionality in this library is largely implemented using an
6
+ * abstraction called a 'slice'. A slice represents a part of a string -
7
+ * anything from the entire string to a single character, or even no
8
+ * characters at all (a 0-length slice). Since a slice only has to specify
9
+ * an offset and a length, copying and manipulating slices is a lot less
10
+ * expensive than copying and manipulating the strings they reference.
11
+ *
12
+ * To further reduce gas costs, most functions on slice that need to return
13
+ * a slice modify the original one instead of allocating a new one; for
14
+ * instance, `s.split(".")` will return the text up to the first '.',
15
+ * modifying s to only contain the remainder of the string after the '.'.
16
+ * In situations where you do not want to modify the original slice, you
17
+ * can make a copy first with `.copy()`, for example:
18
+ * `s.copy().split(".")`. Try and avoid using this idiom in loops; since
19
+ * Solidity has no memory management, it will result in allocating many
20
+ * short-lived slices that are later discarded.
21
+ *
22
+ * Functions that return two slices come in two versions: a non-allocating
23
+ * version that takes the second slice as an argument, modifying it in
24
+ * place, and an allocating version that allocates and returns the second
25
+ * slice; see `nextRune` for example.
26
+ *
27
+ * Functions that have to copy string data will return strings rather than
28
+ * slices; these can be cast back to slices for further processing if
29
+ * required.
30
+ *
31
+ * For convenience, some functions are provided with non-modifying
32
+ * variants that create a new slice and return both; for instance,
33
+ * `s.splitNew('.')` leaves s unmodified, and returns two values
34
+ * corresponding to the left and right parts of the string.
35
+ */
36
+
37
+ pragma solidity ^0.8.0;
38
+
39
+ library StringLib {
40
+ struct slice {
41
+ uint256 _len;
42
+ uint256 _ptr;
43
+ }
44
+
45
+ function memcpy(
46
+ uint256 dest,
47
+ uint256 src,
48
+ uint256 len
49
+ ) private pure {
50
+ // Copy word-length chunks while possible
51
+ for (; len >= 32; len -= 32) {
52
+ assembly {
53
+ mstore(dest, mload(src))
54
+ }
55
+ dest += 32;
56
+ src += 32;
57
+ }
58
+
59
+ // Copy remaining bytes
60
+ uint256 mask = type(uint256).max;
61
+ if (len > 0) {
62
+ mask = 256**(32 - len) - 1;
63
+ }
64
+ assembly {
65
+ let srcpart := and(mload(src), not(mask))
66
+ let destpart := and(mload(dest), mask)
67
+ mstore(dest, or(destpart, srcpart))
68
+ }
69
+ }
70
+
71
+ /*
72
+ * @dev Returns a slice containing the entire string.
73
+ * @param self The string to make a slice from.
74
+ * @return A newly allocated slice containing the entire string.
75
+ */
76
+ function toSlice(string memory self) internal pure returns (slice memory) {
77
+ uint256 ptr;
78
+ assembly {
79
+ ptr := add(self, 0x20)
80
+ }
81
+ return slice(bytes(self).length, ptr);
82
+ }
83
+
84
+ /*
85
+ * @dev Returns the length of a null-terminated bytes32 string.
86
+ * @param self The value to find the length of.
87
+ * @return The length of the string, from 0 to 32.
88
+ */
89
+ function len(bytes32 self) internal pure returns (uint256) {
90
+ uint256 ret;
91
+ if (self == 0) return 0;
92
+ if (uint256(self) & type(uint128).max == 0) {
93
+ ret += 16;
94
+ self = bytes32(uint256(self) / 0x100000000000000000000000000000000);
95
+ }
96
+ if (uint256(self) & type(uint64).max == 0) {
97
+ ret += 8;
98
+ self = bytes32(uint256(self) / 0x10000000000000000);
99
+ }
100
+ if (uint256(self) & type(uint32).max == 0) {
101
+ ret += 4;
102
+ self = bytes32(uint256(self) / 0x100000000);
103
+ }
104
+ if (uint256(self) & type(uint16).max == 0) {
105
+ ret += 2;
106
+ self = bytes32(uint256(self) / 0x10000);
107
+ }
108
+ if (uint256(self) & type(uint8).max == 0) {
109
+ ret += 1;
110
+ }
111
+ return 32 - ret;
112
+ }
113
+
114
+ /*
115
+ * @dev Returns a slice containing the entire bytes32, interpreted as a
116
+ * null-terminated utf-8 string.
117
+ * @param self The bytes32 value to convert to a slice.
118
+ * @return A new slice containing the value of the input argument up to the
119
+ * first null.
120
+ */
121
+ function toSliceB32(bytes32 self) internal pure returns (slice memory ret) {
122
+ // Allocate space for `self` in memory, copy it there, and point ret at it
123
+ assembly {
124
+ let ptr := mload(0x40)
125
+ mstore(0x40, add(ptr, 0x20))
126
+ mstore(ptr, self)
127
+ mstore(add(ret, 0x20), ptr)
128
+ }
129
+ ret._len = len(self);
130
+ }
131
+
132
+ /*
133
+ * @dev Returns a new slice containing the same data as the current slice.
134
+ * @param self The slice to copy.
135
+ * @return A new slice containing the same data as `self`.
136
+ */
137
+ function copy(slice memory self) internal pure returns (slice memory) {
138
+ return slice(self._len, self._ptr);
139
+ }
140
+
141
+ /*
142
+ * @dev Copies a slice to a new string.
143
+ * @param self The slice to copy.
144
+ * @return A newly allocated string containing the slice's text.
145
+ */
146
+ function toString(slice memory self) internal pure returns (string memory) {
147
+ string memory ret = new string(self._len);
148
+ uint256 retptr;
149
+ assembly {
150
+ retptr := add(ret, 32)
151
+ }
152
+
153
+ memcpy(retptr, self._ptr, self._len);
154
+ return ret;
155
+ }
156
+
157
+ /*
158
+ * @dev Returns the length in runes of the slice. Note that this operation
159
+ * takes time proportional to the length of the slice; avoid using it
160
+ * in loops, and call `slice.empty()` if you only need to know whether
161
+ * the slice is empty or not.
162
+ * @param self The slice to operate on.
163
+ * @return The length of the slice in runes.
164
+ */
165
+ function len(slice memory self) internal pure returns (uint256 l) {
166
+ // Starting at ptr-31 means the LSB will be the byte we care about
167
+ uint256 ptr = self._ptr - 31;
168
+ uint256 end = ptr + self._len;
169
+ for (l = 0; ptr < end; l++) {
170
+ uint8 b;
171
+ assembly {
172
+ b := and(mload(ptr), 0xFF)
173
+ }
174
+ if (b < 0x80) {
175
+ ptr += 1;
176
+ } else if (b < 0xE0) {
177
+ ptr += 2;
178
+ } else if (b < 0xF0) {
179
+ ptr += 3;
180
+ } else if (b < 0xF8) {
181
+ ptr += 4;
182
+ } else if (b < 0xFC) {
183
+ ptr += 5;
184
+ } else {
185
+ ptr += 6;
186
+ }
187
+ }
188
+ }
189
+
190
+ /*
191
+ * @dev Returns true if the slice is empty (has a length of 0).
192
+ * @param self The slice to operate on.
193
+ * @return True if the slice is empty, False otherwise.
194
+ */
195
+ function empty(slice memory self) internal pure returns (bool) {
196
+ return self._len == 0;
197
+ }
198
+
199
+ /*
200
+ * @dev Returns a positive number if `other` comes lexicographically after
201
+ * `self`, a negative number if it comes before, or zero if the
202
+ * contents of the two slices are equal. Comparison is done per-rune,
203
+ * on unicode codepoints.
204
+ * @param self The first slice to compare.
205
+ * @param other The second slice to compare.
206
+ * @return The result of the comparison.
207
+ */
208
+ function compare(slice memory self, slice memory other) internal pure returns (int256) {
209
+ uint256 shortest = self._len;
210
+ if (other._len < self._len) shortest = other._len;
211
+
212
+ uint256 selfptr = self._ptr;
213
+ uint256 otherptr = other._ptr;
214
+ for (uint256 idx = 0; idx < shortest; idx += 32) {
215
+ uint256 a;
216
+ uint256 b;
217
+ assembly {
218
+ a := mload(selfptr)
219
+ b := mload(otherptr)
220
+ }
221
+ if (a != b) {
222
+ // Mask out irrelevant bytes and check again
223
+ uint256 mask = type(uint256).max; // 0xffff...
224
+ if (shortest < 32) {
225
+ mask = ~(2**(8 * (32 - shortest + idx)) - 1);
226
+ }
227
+ unchecked {
228
+ uint256 diff = (a & mask) - (b & mask);
229
+ if (diff != 0) return int256(diff);
230
+ }
231
+ }
232
+ selfptr += 32;
233
+ otherptr += 32;
234
+ }
235
+ return int256(self._len) - int256(other._len);
236
+ }
237
+
238
+ /*
239
+ * @dev Returns true if the two slices contain the same text.
240
+ * @param self The first slice to compare.
241
+ * @param self The second slice to compare.
242
+ * @return True if the slices are equal, false otherwise.
243
+ */
244
+ function equals(slice memory self, slice memory other) internal pure returns (bool) {
245
+ return compare(self, other) == 0;
246
+ }
247
+
248
+ /*
249
+ * @dev Extracts the first rune in the slice into `rune`, advancing the
250
+ * slice to point to the next rune and returning `self`.
251
+ * @param self The slice to operate on.
252
+ * @param rune The slice that will contain the first rune.
253
+ * @return `rune`.
254
+ */
255
+ function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) {
256
+ rune._ptr = self._ptr;
257
+
258
+ if (self._len == 0) {
259
+ rune._len = 0;
260
+ return rune;
261
+ }
262
+
263
+ uint256 l;
264
+ uint256 b;
265
+ // Load the first byte of the rune into the LSBs of b
266
+ assembly {
267
+ b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF)
268
+ }
269
+ if (b < 0x80) {
270
+ l = 1;
271
+ } else if (b < 0xE0) {
272
+ l = 2;
273
+ } else if (b < 0xF0) {
274
+ l = 3;
275
+ } else {
276
+ l = 4;
277
+ }
278
+
279
+ // Check for truncated codepoints
280
+ if (l > self._len) {
281
+ rune._len = self._len;
282
+ self._ptr += self._len;
283
+ self._len = 0;
284
+ return rune;
285
+ }
286
+
287
+ self._ptr += l;
288
+ self._len -= l;
289
+ rune._len = l;
290
+ return rune;
291
+ }
292
+
293
+ /*
294
+ * @dev Returns the first rune in the slice, advancing the slice to point
295
+ * to the next rune.
296
+ * @param self The slice to operate on.
297
+ * @return A slice containing only the first rune from `self`.
298
+ */
299
+ function nextRune(slice memory self) internal pure returns (slice memory ret) {
300
+ nextRune(self, ret);
301
+ }
302
+
303
+ /*
304
+ * @dev Returns the number of the first codepoint in the slice.
305
+ * @param self The slice to operate on.
306
+ * @return The number of the first codepoint in the slice.
307
+ */
308
+ function ord(slice memory self) internal pure returns (uint256 ret) {
309
+ if (self._len == 0) {
310
+ return 0;
311
+ }
312
+
313
+ uint256 word;
314
+ uint256 length;
315
+ uint256 divisor = 2**248;
316
+
317
+ // Load the rune into the MSBs of b
318
+ assembly {
319
+ word := mload(mload(add(self, 32)))
320
+ }
321
+ uint256 b = word / divisor;
322
+ if (b < 0x80) {
323
+ ret = b;
324
+ length = 1;
325
+ } else if (b < 0xE0) {
326
+ ret = b & 0x1F;
327
+ length = 2;
328
+ } else if (b < 0xF0) {
329
+ ret = b & 0x0F;
330
+ length = 3;
331
+ } else {
332
+ ret = b & 0x07;
333
+ length = 4;
334
+ }
335
+
336
+ // Check for truncated codepoints
337
+ if (length > self._len) {
338
+ return 0;
339
+ }
340
+
341
+ for (uint256 i = 1; i < length; i++) {
342
+ divisor = divisor / 256;
343
+ b = (word / divisor) & 0xFF;
344
+ if (b & 0xC0 != 0x80) {
345
+ // Invalid UTF-8 sequence
346
+ return 0;
347
+ }
348
+ ret = (ret * 64) | (b & 0x3F);
349
+ }
350
+
351
+ return ret;
352
+ }
353
+
354
+ /*
355
+ * @dev Returns the keccak-256 hash of the slice.
356
+ * @param self The slice to hash.
357
+ * @return The hash of the slice.
358
+ */
359
+ function keccak(slice memory self) internal pure returns (bytes32 ret) {
360
+ assembly {
361
+ ret := keccak256(mload(add(self, 32)), mload(self))
362
+ }
363
+ }
364
+
365
+ /*
366
+ * @dev Returns true if `self` starts with `needle`.
367
+ * @param self The slice to operate on.
368
+ * @param needle The slice to search for.
369
+ * @return True if the slice starts with the provided text, false otherwise.
370
+ */
371
+ function startsWith(slice memory self, slice memory needle) internal pure returns (bool) {
372
+ if (self._len < needle._len) {
373
+ return false;
374
+ }
375
+
376
+ if (self._ptr == needle._ptr) {
377
+ return true;
378
+ }
379
+
380
+ bool equal;
381
+ assembly {
382
+ let length := mload(needle)
383
+ let selfptr := mload(add(self, 0x20))
384
+ let needleptr := mload(add(needle, 0x20))
385
+ equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
386
+ }
387
+ return equal;
388
+ }
389
+
390
+ /*
391
+ * @dev If `self` starts with `needle`, `needle` is removed from the
392
+ * beginning of `self`. Otherwise, `self` is unmodified.
393
+ * @param self The slice to operate on.
394
+ * @param needle The slice to search for.
395
+ * @return `self`
396
+ */
397
+ function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {
398
+ if (self._len < needle._len) {
399
+ return self;
400
+ }
401
+
402
+ bool equal = true;
403
+ if (self._ptr != needle._ptr) {
404
+ assembly {
405
+ let length := mload(needle)
406
+ let selfptr := mload(add(self, 0x20))
407
+ let needleptr := mload(add(needle, 0x20))
408
+ equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
409
+ }
410
+ }
411
+
412
+ if (equal) {
413
+ self._len -= needle._len;
414
+ self._ptr += needle._len;
415
+ }
416
+
417
+ return self;
418
+ }
419
+
420
+ /*
421
+ * @dev Returns true if the slice ends with `needle`.
422
+ * @param self The slice to operate on.
423
+ * @param needle The slice to search for.
424
+ * @return True if the slice starts with the provided text, false otherwise.
425
+ */
426
+ function endsWith(slice memory self, slice memory needle) internal pure returns (bool) {
427
+ if (self._len < needle._len) {
428
+ return false;
429
+ }
430
+
431
+ uint256 selfptr = self._ptr + self._len - needle._len;
432
+
433
+ if (selfptr == needle._ptr) {
434
+ return true;
435
+ }
436
+
437
+ bool equal;
438
+ assembly {
439
+ let length := mload(needle)
440
+ let needleptr := mload(add(needle, 0x20))
441
+ equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
442
+ }
443
+
444
+ return equal;
445
+ }
446
+
447
+ /*
448
+ * @dev If `self` ends with `needle`, `needle` is removed from the
449
+ * end of `self`. Otherwise, `self` is unmodified.
450
+ * @param self The slice to operate on.
451
+ * @param needle The slice to search for.
452
+ * @return `self`
453
+ */
454
+ function until(slice memory self, slice memory needle) internal pure returns (slice memory) {
455
+ if (self._len < needle._len) {
456
+ return self;
457
+ }
458
+
459
+ uint256 selfptr = self._ptr + self._len - needle._len;
460
+ bool equal = true;
461
+ if (selfptr != needle._ptr) {
462
+ assembly {
463
+ let length := mload(needle)
464
+ let needleptr := mload(add(needle, 0x20))
465
+ equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
466
+ }
467
+ }
468
+
469
+ if (equal) {
470
+ self._len -= needle._len;
471
+ }
472
+
473
+ return self;
474
+ }
475
+
476
+ // Returns the memory address of the first byte of the first occurrence of
477
+ // `needle` in `self`, or the first byte after `self` if not found.
478
+ function findPtr(
479
+ uint256 selflen,
480
+ uint256 selfptr,
481
+ uint256 needlelen,
482
+ uint256 needleptr
483
+ ) private pure returns (uint256) {
484
+ uint256 ptr = selfptr;
485
+ uint256 idx;
486
+
487
+ if (needlelen <= selflen) {
488
+ if (needlelen <= 32) {
489
+ bytes32 mask;
490
+ if (needlelen > 0) {
491
+ mask = bytes32(~(2**(8 * (32 - needlelen)) - 1));
492
+ }
493
+
494
+ bytes32 needledata;
495
+ assembly {
496
+ needledata := and(mload(needleptr), mask)
497
+ }
498
+
499
+ uint256 end = selfptr + selflen - needlelen;
500
+ bytes32 ptrdata;
501
+ assembly {
502
+ ptrdata := and(mload(ptr), mask)
503
+ }
504
+
505
+ while (ptrdata != needledata) {
506
+ if (ptr >= end) return selfptr + selflen;
507
+ ptr++;
508
+ assembly {
509
+ ptrdata := and(mload(ptr), mask)
510
+ }
511
+ }
512
+ return ptr;
513
+ } else {
514
+ // For long needles, use hashing
515
+ bytes32 hash;
516
+ assembly {
517
+ hash := keccak256(needleptr, needlelen)
518
+ }
519
+
520
+ for (idx = 0; idx <= selflen - needlelen; idx++) {
521
+ bytes32 testHash;
522
+ assembly {
523
+ testHash := keccak256(ptr, needlelen)
524
+ }
525
+ if (hash == testHash) return ptr;
526
+ ptr += 1;
527
+ }
528
+ }
529
+ }
530
+ return selfptr + selflen;
531
+ }
532
+
533
+ // Returns the memory address of the first byte after the last occurrence of
534
+ // `needle` in `self`, or the address of `self` if not found.
535
+ function rfindPtr(
536
+ uint256 selflen,
537
+ uint256 selfptr,
538
+ uint256 needlelen,
539
+ uint256 needleptr
540
+ ) private pure returns (uint256) {
541
+ uint256 ptr;
542
+
543
+ if (needlelen <= selflen) {
544
+ if (needlelen <= 32) {
545
+ bytes32 mask;
546
+ if (needlelen > 0) {
547
+ mask = bytes32(~(2**(8 * (32 - needlelen)) - 1));
548
+ }
549
+
550
+ bytes32 needledata;
551
+ assembly {
552
+ needledata := and(mload(needleptr), mask)
553
+ }
554
+
555
+ ptr = selfptr + selflen - needlelen;
556
+ bytes32 ptrdata;
557
+ assembly {
558
+ ptrdata := and(mload(ptr), mask)
559
+ }
560
+
561
+ while (ptrdata != needledata) {
562
+ if (ptr <= selfptr) return selfptr;
563
+ ptr--;
564
+ assembly {
565
+ ptrdata := and(mload(ptr), mask)
566
+ }
567
+ }
568
+ return ptr + needlelen;
569
+ } else {
570
+ // For long needles, use hashing
571
+ bytes32 hash;
572
+ assembly {
573
+ hash := keccak256(needleptr, needlelen)
574
+ }
575
+ ptr = selfptr + (selflen - needlelen);
576
+ while (ptr >= selfptr) {
577
+ bytes32 testHash;
578
+ assembly {
579
+ testHash := keccak256(ptr, needlelen)
580
+ }
581
+ if (hash == testHash) return ptr + needlelen;
582
+ ptr -= 1;
583
+ }
584
+ }
585
+ }
586
+ return selfptr;
587
+ }
588
+
589
+ /*
590
+ * @dev Modifies `self` to contain everything from the first occurrence of
591
+ * `needle` to the end of the slice. `self` is set to the empty slice
592
+ * if `needle` is not found.
593
+ * @param self The slice to search and modify.
594
+ * @param needle The text to search for.
595
+ * @return `self`.
596
+ */
597
+ function find(slice memory self, slice memory needle) internal pure returns (slice memory) {
598
+ uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
599
+ self._len -= ptr - self._ptr;
600
+ self._ptr = ptr;
601
+ return self;
602
+ }
603
+
604
+ /*
605
+ * @dev Modifies `self` to contain the part of the string from the start of
606
+ * `self` to the end of the first occurrence of `needle`. If `needle`
607
+ * is not found, `self` is set to the empty slice.
608
+ * @param self The slice to search and modify.
609
+ * @param needle The text to search for.
610
+ * @return `self`.
611
+ */
612
+ function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) {
613
+ uint256 ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
614
+ self._len = ptr - self._ptr;
615
+ return self;
616
+ }
617
+
618
+ /*
619
+ * @dev Splits the slice, setting `self` to everything after the first
620
+ * occurrence of `needle`, and `token` to everything before it. If
621
+ * `needle` does not occur in `self`, `self` is set to the empty slice,
622
+ * and `token` is set to the entirety of `self`.
623
+ * @param self The slice to split.
624
+ * @param needle The text to search for in `self`.
625
+ * @param token An output parameter to which the first token is written.
626
+ * @return `token`.
627
+ */
628
+ function split(
629
+ slice memory self,
630
+ slice memory needle,
631
+ slice memory token
632
+ ) internal pure returns (slice memory) {
633
+ uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
634
+ token._ptr = self._ptr;
635
+ token._len = ptr - self._ptr;
636
+ if (ptr == self._ptr + self._len) {
637
+ // Not found
638
+ self._len = 0;
639
+ } else {
640
+ self._len -= token._len + needle._len;
641
+ self._ptr = ptr + needle._len;
642
+ }
643
+ return token;
644
+ }
645
+
646
+ /*
647
+ * @dev Splits the slice, setting `self` to everything after the first
648
+ * occurrence of `needle`, and returning everything before it. If
649
+ * `needle` does not occur in `self`, `self` is set to the empty slice,
650
+ * and the entirety of `self` is returned.
651
+ * @param self The slice to split.
652
+ * @param needle The text to search for in `self`.
653
+ * @return The part of `self` up to the first occurrence of `delim`.
654
+ */
655
+ function split(slice memory self, slice memory needle)
656
+ internal
657
+ pure
658
+ returns (slice memory token)
659
+ {
660
+ split(self, needle, token);
661
+ }
662
+
663
+ /*
664
+ * @dev Splits the slice, setting `self` to everything before the last
665
+ * occurrence of `needle`, and `token` to everything after it. If
666
+ * `needle` does not occur in `self`, `self` is set to the empty slice,
667
+ * and `token` is set to the entirety of `self`.
668
+ * @param self The slice to split.
669
+ * @param needle The text to search for in `self`.
670
+ * @param token An output parameter to which the first token is written.
671
+ * @return `token`.
672
+ */
673
+ function rsplit(
674
+ slice memory self,
675
+ slice memory needle,
676
+ slice memory token
677
+ ) internal pure returns (slice memory) {
678
+ uint256 ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
679
+ token._ptr = ptr;
680
+ token._len = self._len - (ptr - self._ptr);
681
+ if (ptr == self._ptr) {
682
+ // Not found
683
+ self._len = 0;
684
+ } else {
685
+ self._len -= token._len + needle._len;
686
+ }
687
+ return token;
688
+ }
689
+
690
+ /*
691
+ * @dev Splits the slice, setting `self` to everything before the last
692
+ * occurrence of `needle`, and returning everything after it. If
693
+ * `needle` does not occur in `self`, `self` is set to the empty slice,
694
+ * and the entirety of `self` is returned.
695
+ * @param self The slice to split.
696
+ * @param needle The text to search for in `self`.
697
+ * @return The part of `self` after the last occurrence of `delim`.
698
+ */
699
+ function rsplit(slice memory self, slice memory needle)
700
+ internal
701
+ pure
702
+ returns (slice memory token)
703
+ {
704
+ rsplit(self, needle, token);
705
+ }
706
+
707
+ /*
708
+ * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`.
709
+ * @param self The slice to search.
710
+ * @param needle The text to search for in `self`.
711
+ * @return The number of occurrences of `needle` found in `self`.
712
+ */
713
+ function count(slice memory self, slice memory needle) internal pure returns (uint256 cnt) {
714
+ uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len;
715
+ while (ptr <= self._ptr + self._len) {
716
+ cnt++;
717
+ ptr =
718
+ findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) +
719
+ needle._len;
720
+ }
721
+ }
722
+
723
+ /*
724
+ * @dev Returns True if `self` contains `needle`.
725
+ * @param self The slice to search.
726
+ * @param needle The text to search for in `self`.
727
+ * @return True if `needle` is found in `self`, false otherwise.
728
+ */
729
+ function contains(slice memory self, slice memory needle) internal pure returns (bool) {
730
+ return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
731
+ }
732
+
733
+ /*
734
+ * @dev Returns a newly allocated string containing the concatenation of
735
+ * `self` and `other`.
736
+ * @param self The first slice to concatenate.
737
+ * @param other The second slice to concatenate.
738
+ * @return The concatenation of the two strings.
739
+ */
740
+ function concat(slice memory self, slice memory other) internal pure returns (string memory) {
741
+ string memory ret = new string(self._len + other._len);
742
+ uint256 retptr;
743
+ assembly {
744
+ retptr := add(ret, 32)
745
+ }
746
+ memcpy(retptr, self._ptr, self._len);
747
+ memcpy(retptr + self._len, other._ptr, other._len);
748
+ return ret;
749
+ }
750
+
751
+ /*
752
+ * @dev Joins an array of slices, using `self` as a delimiter, returning a
753
+ * newly allocated string.
754
+ * @param self The delimiter to use.
755
+ * @param parts A list of slices to join.
756
+ * @return A newly allocated string containing all the slices in `parts`,
757
+ * joined with `self`.
758
+ */
759
+ function join(slice memory self, slice[] memory parts) internal pure returns (string memory) {
760
+ if (parts.length == 0) return "";
761
+
762
+ uint256 length = self._len * (parts.length - 1);
763
+ for (uint256 i = 0; i < parts.length; i++) length += parts[i]._len;
764
+
765
+ string memory ret = new string(length);
766
+ uint256 retptr;
767
+ assembly {
768
+ retptr := add(ret, 32)
769
+ }
770
+
771
+ for (uint256 i = 0; i < parts.length; i++) {
772
+ memcpy(retptr, parts[i]._ptr, parts[i]._len);
773
+ retptr += parts[i]._len;
774
+ if (i < parts.length - 1) {
775
+ memcpy(retptr, self._ptr, self._len);
776
+ retptr += self._len;
777
+ }
778
+ }
779
+
780
+ return ret;
781
+ }
782
+ }