@pendle/core-v2 3.0.0-beta-11 → 3.0.0-beta-12

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 (316) hide show
  1. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +5 -23
  2. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol +2 -5
  3. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +6 -20
  4. package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +6 -27
  5. package/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol +1 -2
  6. package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +1 -1
  7. package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +16 -17
  8. package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol +6 -7
  9. package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol +7 -8
  10. package/contracts/LiquidityMining/PendleMerkleDistributor.sol +2 -11
  11. package/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol +14 -37
  12. package/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol +19 -34
  13. package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +4 -14
  14. package/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +4 -16
  15. package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +11 -39
  16. package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +3 -10
  17. package/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +1 -1
  18. package/contracts/LiquidityMining/libraries/VeBalanceLib.sol +5 -20
  19. package/contracts/LiquidityMining/libraries/VeHistoryLib.sol +1 -3
  20. package/contracts/core/Market/MarketMathCore.sol +12 -37
  21. package/contracts/core/Market/OracleLib.sol +6 -24
  22. package/contracts/core/Market/PendleExternalRewardDistributor.sol +4 -10
  23. package/contracts/core/Market/PendleGauge.sol +3 -9
  24. package/contracts/core/Market/PendleMarket.sol +14 -39
  25. package/contracts/core/Market/PendleMarketFactory.sol +14 -21
  26. package/contracts/core/Market/v2/PendleGaugeV2.sol +8 -24
  27. package/contracts/core/Market/v2/PendleMarketFactoryV2.sol +7 -27
  28. package/contracts/core/Market/v2/PendleMarketV2.sol +13 -36
  29. package/contracts/core/Market/v3/PendleMarketFactoryV3.sol +137 -0
  30. package/contracts/core/Market/v3/PendleMarketV3.sol +360 -0
  31. package/contracts/core/RewardManager/PendleLinearDistributor.sol +143 -0
  32. package/contracts/core/RewardManager/RewardManager.sol +14 -7
  33. package/contracts/core/RewardManager/RewardManagerAbstract.sol +5 -17
  34. package/contracts/core/StandardizedYield/SYBase.sol +10 -40
  35. package/contracts/core/StandardizedYield/SYBaseUpg.sol +197 -0
  36. package/contracts/core/StandardizedYield/SYBaseWithRewards.sol +9 -41
  37. package/contracts/core/StandardizedYield/SYBaseWithRewardsUpg.sol +88 -0
  38. package/contracts/core/StandardizedYield/SYUtils.sol +1 -4
  39. package/contracts/core/StandardizedYield/StEthHelper.sol +3 -9
  40. package/contracts/core/StandardizedYield/implementations/AaveV3/PendleAaveV3SY.sol +94 -0
  41. package/contracts/core/StandardizedYield/implementations/AaveV3/libraries/AaveAdapterLib.sol +19 -0
  42. package/contracts/core/StandardizedYield/implementations/AaveV3/libraries/WadRayMath.sol +126 -0
  43. package/contracts/core/StandardizedYield/implementations/Ankr/PendleAnkrBNBSY.sol +4 -12
  44. package/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol +5 -19
  45. package/contracts/core/StandardizedYield/implementations/BalancerStable/AuraEthxBbAWethSY.sol +4 -14
  46. package/contracts/core/StandardizedYield/implementations/BalancerStable/AuraSwEthBbAWethSYV2.sol +4 -14
  47. package/contracts/core/StandardizedYield/implementations/BalancerStable/{PendleAuraWethVethSY.sol → AuraWethVethSYUpg.sol} +13 -20
  48. package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol +3 -7
  49. package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol +12 -29
  50. package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol +12 -29
  51. package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol +12 -29
  52. package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol +14 -39
  53. package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol +7 -28
  54. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol +13 -30
  55. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewProxy.sol +1 -1
  56. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV4.sol +50 -153
  57. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV5.sol +50 -157
  58. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol +4 -16
  59. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol +6 -25
  60. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearPreview.sol +36 -34
  61. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol +4 -13
  62. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol +20 -58
  63. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol +28 -79
  64. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV3Upg.sol +310 -0
  65. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol +1 -3
  66. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol +2 -6
  67. package/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol +5 -13
  68. package/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol +9 -29
  69. package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotRewardHelper.sol +2 -8
  70. package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileCommon.sol +1 -5
  71. package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileLpHelper.sol +8 -19
  72. package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatilePreview.sol +7 -25
  73. package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol +8 -27
  74. package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkReceiver.sol +2 -2
  75. package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkRelayer.sol +4 -9
  76. package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +3 -15
  77. package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +5 -23
  78. package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +10 -40
  79. package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +2 -8
  80. package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +2 -7
  81. package/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol +5 -20
  82. package/contracts/core/StandardizedYield/implementations/Flux/FluxTokenLib.sol +6 -4
  83. package/contracts/core/StandardizedYield/implementations/Flux/PendleFluxLendingSY.sol +3 -11
  84. package/contracts/core/StandardizedYield/implementations/GLP/GLPPreviewHelper.sol +3 -9
  85. package/contracts/core/StandardizedYield/implementations/GLP/GMTokenPricingHelper.sol +115 -0
  86. package/contracts/core/StandardizedYield/implementations/GLP/PendleGMV2TokenSY.sol +134 -0
  87. package/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol +5 -19
  88. package/contracts/core/StandardizedYield/implementations/HMX/HLPPricingHelper.sol +3 -4
  89. package/contracts/core/StandardizedYield/implementations/HMX/PendleHlpSY.sol +18 -25
  90. package/contracts/core/StandardizedYield/implementations/Kyber/KyberMathHelper.sol +425 -0
  91. package/contracts/core/StandardizedYield/implementations/Kyber/KyberNftManagerBaseUpg.sol +438 -0
  92. package/contracts/core/StandardizedYield/implementations/Kyber/PendleKyberElasticSYUpg.sol +155 -0
  93. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/FullMath.sol +123 -0
  94. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/LiqDeltaMath.sol +17 -0
  95. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/LiquidityMath.sol +74 -0
  96. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/MathConstants.sol +19 -0
  97. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/QtyDeltaMath.sol +103 -0
  98. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/QuadMath.sol +31 -0
  99. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/ReinvestmentMath.sol +26 -0
  100. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/SafeCast.sol +73 -0
  101. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/SwapMath.sol +272 -0
  102. package/contracts/core/StandardizedYield/implementations/Kyber/libraries/TickMath.sol +223 -0
  103. package/contracts/core/StandardizedYield/implementations/MUX/MlpPricingHelper.sol +26 -0
  104. package/contracts/core/StandardizedYield/implementations/MUX/PendleMlpSY.sol +195 -0
  105. package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleMantleStakedEthSY.sol +12 -41
  106. package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleOracleForSyProxy.sol +1 -1
  107. package/contracts/core/StandardizedYield/implementations/PendleArbitrumStakedEthSY.sol +13 -42
  108. package/contracts/core/StandardizedYield/implementations/PendleBridgedLSDSY.sol +4 -11
  109. package/contracts/core/StandardizedYield/implementations/PendleERC4626SY.sol +4 -16
  110. package/contracts/core/StandardizedYield/implementations/PendleEUSDSY.sol +3 -11
  111. package/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol +3 -11
  112. package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +5 -18
  113. package/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol +3 -7
  114. package/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol +5 -18
  115. package/contracts/core/StandardizedYield/implementations/PendleWbEthSY.sol +3 -10
  116. package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +4 -12
  117. package/contracts/core/StandardizedYield/implementations/Silo/PendleSiloWithIncentiveSY.sol +157 -0
  118. package/contracts/core/StandardizedYield/implementations/Stader/PendleETHXSY.sol +4 -12
  119. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwETH.sol +4 -12
  120. package/contracts/core/StandardizedYield/implementations/Thena/PendleThenaSY.sol +9 -29
  121. package/contracts/core/StandardizedYield/implementations/Thena/ThenaLpHelper.sol +3 -10
  122. package/contracts/core/StandardizedYield/implementations/Thena/ThenaMath.sol +9 -30
  123. package/contracts/core/StandardizedYield/implementations/Thena/ThenaPreview.sol +10 -40
  124. package/contracts/core/YieldContracts/InterestManagerYT.sol +6 -8
  125. package/contracts/core/YieldContracts/PendlePrincipalToken.sol +1 -1
  126. package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +2 -3
  127. package/contracts/core/YieldContracts/PendleYieldToken.sol +17 -44
  128. package/contracts/core/YieldContractsV2/InterestManagerYTV2.sol +5 -14
  129. package/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol +1 -1
  130. package/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol +2 -3
  131. package/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol +13 -48
  132. package/contracts/core/erc20/PendleERC20.sol +2 -8
  133. package/contracts/core/erc20/PendleERC20Permit.sol +2 -6
  134. package/contracts/core/erc20/PendleERC20PermitUpg.sol +82 -0
  135. package/contracts/core/erc20/PendleERC20Upg.sol +334 -0
  136. package/contracts/core/libraries/ArrayLib.sol +7 -8
  137. package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -6
  138. package/contracts/core/libraries/Errors.sol +19 -1
  139. package/contracts/core/libraries/ExpiryUtilsLib.sol +3 -26
  140. package/contracts/core/libraries/StringLib.sol +5 -21
  141. package/contracts/core/libraries/TokenHelper.sol +3 -3
  142. package/contracts/core/libraries/math/LogExpMath.sol +1 -4
  143. package/contracts/core/libraries/math/PMath.sol +13 -15
  144. package/contracts/interfaces/AaveV3/IAaveV3AToken.sol +15 -0
  145. package/contracts/interfaces/AaveV3/IAaveV3Pool.sol +11 -0
  146. package/contracts/interfaces/Balancer/IComposableStable.sol +3 -4
  147. package/contracts/interfaces/Balancer/IERC4626LinearPool.sol +2 -10
  148. package/contracts/interfaces/Balancer/IMetaStablePool.sol +3 -11
  149. package/contracts/interfaces/Balancer/IVault.sol +3 -8
  150. package/contracts/interfaces/BinanceEth/IWBETH.sol +1 -1
  151. package/contracts/interfaces/Camelot/ICamelotNFTFactory.sol +1 -3
  152. package/contracts/interfaces/Camelot/ICamelotNFTHandler.sol +2 -10
  153. package/contracts/interfaces/Camelot/ICamelotNitroPool.sol +0 -1
  154. package/contracts/interfaces/Camelot/ICamelotNitroPoolFactory.sol +3 -12
  155. package/contracts/interfaces/Camelot/ICamelotPair.sol +5 -25
  156. package/contracts/interfaces/Camelot/ICamelotRouter.sol +1 -5
  157. package/contracts/interfaces/Camelot/IXGrail.sol +3 -11
  158. package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -3
  159. package/contracts/interfaces/Curve/ICrvPool.sol +3 -12
  160. package/contracts/interfaces/Curve/ITriCrvPool.sol +2 -9
  161. package/contracts/interfaces/Flux/IFluxErc20.sol +1 -1
  162. package/contracts/interfaces/Flux/IFluxInterestRateModel.sol +1 -5
  163. package/contracts/interfaces/GMX/IGMXPriceHelper.sol +6 -0
  164. package/contracts/interfaces/GMX/IGMXVault.sol +2 -9
  165. package/contracts/interfaces/GMX/IRewardRouterV2.sol +1 -4
  166. package/contracts/interfaces/HMX/IHLPStaking.sol +1 -1
  167. package/contracts/interfaces/HMX/IHMXCalculator.sol +1 -1
  168. package/contracts/interfaces/HMX/IHMXCompounder.sol +1 -1
  169. package/contracts/interfaces/HMX/IHMXStaking.sol +1 -1
  170. package/contracts/interfaces/HMX/IHMXVester.sol +1 -1
  171. package/contracts/interfaces/IApeStaking.sol +3 -9
  172. package/contracts/interfaces/IBenQiInterestRateModel.sol +1 -5
  173. package/contracts/interfaces/IDiamondCut.sol +1 -5
  174. package/contracts/interfaces/IDiamondLoupe.sol +1 -3
  175. package/contracts/interfaces/ILayerZeroReceiver.sol +1 -6
  176. package/contracts/interfaces/IPActionAddRemoveLiqV3.sol +10 -2
  177. package/contracts/interfaces/IPActionInfoStatic.sol +4 -7
  178. package/contracts/interfaces/IPActionMarketAuxStatic.sol +5 -9
  179. package/contracts/interfaces/IPActionMarketCoreStatic.sol +118 -58
  180. package/contracts/interfaces/IPActionMintRedeemStatic.sol +38 -21
  181. package/contracts/interfaces/IPActionMiscV3.sol +51 -26
  182. package/contracts/interfaces/IPActionStorageStatic.sol +5 -1
  183. package/contracts/interfaces/IPAllActionTypeV3.sol +1 -0
  184. package/contracts/interfaces/IPBulkSeller.sol +49 -0
  185. package/contracts/interfaces/IPBulkSellerFactory.sol +12 -0
  186. package/contracts/interfaces/IPBulkSellerSYCallback.sol +6 -0
  187. package/contracts/interfaces/IPFeeDistributor.sol +1 -3
  188. package/contracts/interfaces/IPFeeDistributorV2.sol +8 -7
  189. package/contracts/interfaces/IPGaugeController.sol +2 -8
  190. package/contracts/interfaces/IPGaugeControllerMainchain.sol +1 -5
  191. package/contracts/interfaces/IPInterestManagerYT.sol +3 -3
  192. package/contracts/interfaces/IPInterestManagerYTV2.sol +1 -4
  193. package/contracts/interfaces/IPLimitRouter.sol +24 -19
  194. package/contracts/interfaces/IPLinearDistributor.sol +21 -0
  195. package/contracts/interfaces/IPMarket.sol +4 -17
  196. package/contracts/interfaces/IPMarketFactory.sol +2 -13
  197. package/contracts/interfaces/IPMarketFactoryV3.sol +24 -0
  198. package/contracts/interfaces/IPMarketV3.sol +8 -0
  199. package/contracts/interfaces/IPOffchainStorage.sol +11 -0
  200. package/contracts/interfaces/IPPriceFeed.sol +6 -0
  201. package/contracts/interfaces/IPPtOracle.sol +2 -9
  202. package/contracts/interfaces/IPRouterHelper.sol +11 -7
  203. package/contracts/interfaces/IPRouterStatic.sol +1 -3
  204. package/contracts/interfaces/IPVotingController.sol +7 -19
  205. package/contracts/interfaces/IPVotingEscrowMainchain.sol +2 -8
  206. package/contracts/interfaces/IPYieldToken.sol +2 -8
  207. package/contracts/interfaces/IPYieldTokenV2.sol +1 -6
  208. package/contracts/interfaces/IPendlePreviewHelper.sol +2 -8
  209. package/contracts/interfaces/IRewardManager.sol +1 -4
  210. package/contracts/interfaces/IStETH.sol +1 -4
  211. package/contracts/interfaces/IStandardizedYield.sol +9 -16
  212. package/contracts/interfaces/IStargateLP.sol +0 -3
  213. package/contracts/interfaces/IStargateRouter.sol +1 -5
  214. package/contracts/interfaces/Kyber/IKyberElasticFactory.sol +157 -0
  215. package/contracts/interfaces/Kyber/IKyberElasticPool.sol +101 -0
  216. package/contracts/interfaces/Kyber/IKyberElasticRouter.sol +98 -0
  217. package/contracts/interfaces/Kyber/IKyberLiquidityMining.sol +209 -0
  218. package/contracts/interfaces/Kyber/IKyberMathHelper.sol +28 -0
  219. package/contracts/interfaces/Kyber/IKyberPositionManager.sol +179 -0
  220. package/contracts/interfaces/Lybra/IEUSD.sol +1 -1
  221. package/contracts/interfaces/MUX/IMUXRewardRouter.sol +139 -0
  222. package/contracts/interfaces/Silo/ISilo.sol +298 -0
  223. package/contracts/interfaces/Silo/ISiloIncentiveController.sol +16 -0
  224. package/contracts/interfaces/Silo/ISiloLens.sol +6 -0
  225. package/contracts/interfaces/Stader/IStaderStakeManager.sol +2 -2
  226. package/contracts/interfaces/Thena/IThenaFactory.sol +1 -5
  227. package/contracts/interfaces/Thena/IThenaGaugeV2.sol +1 -2
  228. package/contracts/interfaces/Thena/IThenaPair.sol +3 -5
  229. package/contracts/limit/LimitMathCore.sol +69 -60
  230. package/contracts/limit/{PendleOrderMixin.sol → LimitRouterBase.sol} +96 -79
  231. package/contracts/limit/PendleLimitRouter.sol +9 -13
  232. package/contracts/offchain-helpers/AutomateReady.sol +17 -32
  233. package/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol +6 -3
  234. package/contracts/offchain-helpers/BoringLpSeller.sol +4 -17
  235. package/contracts/offchain-helpers/BoringPtSeller.sol +2 -7
  236. package/contracts/offchain-helpers/Broadcaster.sol +1 -1
  237. package/contracts/offchain-helpers/BytesLib.sol +26 -14
  238. package/contracts/offchain-helpers/EmptyUUPS.sol +0 -1
  239. package/contracts/offchain-helpers/LegacyNFTHelper.sol +4 -23
  240. package/contracts/offchain-helpers/LimitBackendHelper.sol +25 -16
  241. package/contracts/offchain-helpers/MarketExchangeRateLib.sol +2 -13
  242. package/contracts/offchain-helpers/Multicall2.sol +2 -7
  243. package/contracts/offchain-helpers/PendleMulticallV1.sol +7 -7
  244. package/contracts/offchain-helpers/PendleMulticallV2.sol +12 -13
  245. package/contracts/offchain-helpers/PendleOffchainStorage.sol +59 -0
  246. package/contracts/offchain-helpers/SimulateHelper.sol +6 -7
  247. package/contracts/offchain-helpers/errors/SDKErrorsDirectory.sol +15 -1
  248. package/contracts/oracles/PendleLpOracleLib.sol +9 -10
  249. package/contracts/oracles/PendlePtOracle.sol +8 -19
  250. package/contracts/oracles/PendlePtOracleLib.sol +8 -13
  251. package/contracts/oracles/samples/PendleLpGlpOracle.sol +6 -10
  252. package/contracts/oracles/samples/PendlePtGlpOracle.sol +6 -10
  253. package/contracts/oracles/samples/PendlePtUsdChainlinkOracle.sol +8 -15
  254. package/contracts/router/ActionAddRemoveLiqV3.sol +147 -52
  255. package/contracts/router/ActionCallbackV3.sol +11 -4
  256. package/contracts/router/ActionMiscV3.sol +43 -33
  257. package/contracts/router/ActionSwapPTV3.sol +18 -6
  258. package/contracts/router/ActionSwapYTV3.sol +42 -14
  259. package/contracts/router/PendleRouterHelper.sol +72 -40
  260. package/contracts/router/PendleRouterV3.sol +50 -50
  261. package/contracts/router/base/ActionBase.sol +86 -43
  262. package/contracts/router/base/CallbackHelper.sol +18 -20
  263. package/contracts/router/base/MarketApproxLib.sol +36 -32
  264. package/contracts/router/swap-aggregator/PendleSwap.sol +31 -7
  265. package/contracts/router/swap-aggregator/kyberswap/interfaces/IAggregationExecutorOptimistic.sol +63 -0
  266. package/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelper.sol +314 -0
  267. package/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelperL2.sol +560 -0
  268. package/contracts/router/swap-aggregator/kyberswap/{IMetaAggregationRouterV2.sol → interfaces/IMetaAggregationRouterV2.sol} +11 -6
  269. package/contracts/router/swap-aggregator/kyberswap/{KyberInputScalingHelper.sol → l1-contracts/InputScalingHelper.sol} +70 -19
  270. package/contracts/router/swap-aggregator/kyberswap/{ScalingDataLib.sol → l1-contracts/ScalingDataLib.sol} +111 -53
  271. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/BytesHelper.sol +29 -0
  272. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/CalldataReader.sol +149 -0
  273. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/CalldataWriter.sol +118 -0
  274. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/Common.sol +42 -0
  275. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/DexScaler.sol +382 -0
  276. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/ExecutorReader.sol +61 -0
  277. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/InputScalingHelperL2.sol +329 -0
  278. package/contracts/router/swap-aggregator/kyberswap/l2-contracts/ScalingDataL2Lib.sol +173 -0
  279. package/contracts/router/swap-aggregator/oneinch/I1inchAggregationRouterV5.sol +4 -10
  280. package/contracts/router/swap-aggregator/oneinch/OneInchAggregationRouterHelper.sol +20 -14
  281. package/deployments/1-core.json +5 -2
  282. package/deployments/1-markets/EPENDLE-SEP2024.json +12 -0
  283. package/deployments/1-markets/SFRAX-MARCH2024.json +10 -0
  284. package/deployments/1-markets/SILO-CRVUSD-MARCH2024.json +10 -0
  285. package/deployments/10-core.json +6 -3
  286. package/deployments/42161-core.json +5 -2
  287. package/deployments/42161-markets/AAVE-USDC-JUNE2024.json +11 -0
  288. package/deployments/42161-markets/ARBSILO-USDC-FEB2024.json +10 -0
  289. package/deployments/42161-markets/GM-ARB-USDC-MARCH2024.json +10 -0
  290. package/deployments/42161-markets/KYBER-AXLWSTETH-WSTETH-MARCH2024.json +10 -0
  291. package/deployments/42161-markets/MLP-MARCH2024.json +10 -0
  292. package/deployments/42161-markets/WSTETH-ARBITRUM-MARCH2024.json +11 -0
  293. package/deployments/42161-markets/WSTETHSILO-ETH-MARCH2024.json +11 -0
  294. package/deployments/56-core.json +5 -2
  295. package/deployments/merkle-distribution/2023-10-26.json +7300 -0
  296. package/deployments/merkle-distribution/2023-11-30.json +7730 -0
  297. package/package.json +8 -8
  298. package/contracts/limit/helpers/ArgumentsDecoder.sol +0 -47
  299. package/contracts/limit/helpers/Permitable.sol +0 -48
  300. package/contracts/limit/helpers/RevertReasonParser.sol +0 -75
  301. package/contracts/offchain-helpers/ChainlinkRelayerGelato.sol +0 -37
  302. package/contracts/offchain-helpers/PtAndLpToAsset.sol +0 -62
  303. package/contracts/offchain-helpers/router-static/PendleRouterStatic.sol +0 -19
  304. package/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol +0 -112
  305. package/contracts/offchain-helpers/router-static/base/ActionLimitOrdersStatic.sol +0 -145
  306. package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +0 -171
  307. package/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol +0 -582
  308. package/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol +0 -116
  309. package/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol +0 -64
  310. package/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol +0 -53
  311. package/contracts/offchain-helpers/router-static/base/StorageLayout.sol +0 -18
  312. package/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol +0 -231
  313. package/deployments/1-markets/BALANCER-LP-AURA-VETH-WETH-SEP2024.json +0 -8
  314. /package/contracts/router/swap-aggregator/kyberswap/{IAggregationExecutor.sol → interfaces/IAggregationExecutor.sol} +0 -0
  315. /package/deployments/1-markets/{BALANCER-LP-AURA-BBAWETHSWETH-SEP-26-2024.json → deprecated/BALANCER-LP-AURA-BBAWETHSWETH-SEP-26-2024.json} +0 -0
  316. /package/deployments/1-markets/{BALANCER-LP-AURA-ETHX-BBAWETH-SEP-26-2024.json → deprecated/BALANCER-LP-AURA-ETHX-BBAWETH-SEP-26-2024.json} +0 -0
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
2
+ pragma solidity ^0.8.17;
3
3
 
4
4
  import "../../interfaces/IPVeToken.sol";
5
5
  import "../../interfaces/IPVotingController.sol";
@@ -93,15 +93,10 @@ abstract contract VotingControllerStorageUpg is IPVotingController {
93
93
  }
94
94
 
95
95
  /// @notice deprecated, only kept for compatibility reasons
96
- function getUserPoolHistoryAt(
97
- address user,
98
- address pool,
99
- uint256 index
100
- ) external view returns (Checkpoint memory) {
96
+ function getUserPoolHistoryAt(address user, address pool, uint256 index) external view returns (Checkpoint memory) {
101
97
  return __dep_userPoolHistory[user][pool].get(index);
102
98
  }
103
99
 
104
-
105
100
  function getPoolData(
106
101
  address pool,
107
102
  uint128[] calldata wTimes
@@ -116,11 +111,7 @@ abstract contract VotingControllerStorageUpg is IPVotingController {
116
111
  )
117
112
  {
118
113
  PoolData storage data = poolData[pool];
119
- (chainId, lastSlopeChangeAppliedAt, totalVote) = (
120
- data.chainId,
121
- data.lastSlopeChangeAppliedAt,
122
- data.totalVote
123
- );
114
+ (chainId, lastSlopeChangeAppliedAt, totalVote) = (data.chainId, data.lastSlopeChangeAppliedAt, data.totalVote);
124
115
 
125
116
  slopeChanges = new uint128[](wTimes.length);
126
117
  for (uint256 i = 0; i < wTimes.length; ++i) {
@@ -175,10 +166,7 @@ abstract contract VotingControllerStorageUpg is IPVotingController {
175
166
  return activeChainPools[chainId].values();
176
167
  }
177
168
 
178
- function getUserPoolVote(
179
- address user,
180
- address pool
181
- ) external view returns (UserPoolData memory) {
169
+ function getUserPoolVote(address user, address pool) external view returns (UserPoolData memory) {
182
170
  return userData[user].voteForPools[pool];
183
171
  }
184
172
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
2
+ pragma solidity ^0.8.17;
3
3
  import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
4
4
  import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
5
 
@@ -13,11 +13,7 @@ import "../../core/libraries/Errors.sol";
13
13
  import "./VotingEscrowTokenBase.sol";
14
14
  import "../CrossChainMsg/PendleMsgSenderAppUpg.sol";
15
15
 
16
- contract VotingEscrowPendleMainchain is
17
- VotingEscrowTokenBase,
18
- IPVotingEscrowMainchain,
19
- PendleMsgSenderAppUpg
20
- {
16
+ contract VotingEscrowPendleMainchain is VotingEscrowTokenBase, IPVotingEscrowMainchain, PendleMsgSenderAppUpg {
21
17
  using SafeERC20 for IERC20;
22
18
  using VeBalanceLib for VeBalance;
23
19
  using VeBalanceLib for LockedPosition;
@@ -25,8 +21,7 @@ contract VotingEscrowPendleMainchain is
25
21
  using EnumerableMap for EnumerableMap.UintToAddressMap;
26
22
 
27
23
  bytes private constant EMPTY_BYTES = abi.encode();
28
- bytes private constant SAMPLE_SUPPLY_UPDATE_MESSAGE =
29
- abi.encode(0, VeBalance(0, 0), EMPTY_BYTES);
24
+ bytes private constant SAMPLE_SUPPLY_UPDATE_MESSAGE = abi.encode(0, VeBalance(0, 0), EMPTY_BYTES);
30
25
  bytes private constant SAMPLE_POSITION_UPDATE_MESSAGE =
31
26
  abi.encode(0, VeBalance(0, 0), abi.encode(address(0), LockedPosition(0, 0)));
32
27
 
@@ -127,12 +122,7 @@ contract VotingEscrowPendleMainchain is
127
122
  * @notice update & return the current totalSupply, but does not broadcast info to other chains
128
123
  * @dev See `broadcastTotalSupply()` and `broadcastUserPosition()` for broadcasting
129
124
  */
130
- function totalSupplyCurrent()
131
- public
132
- virtual
133
- override(IPVeToken, VotingEscrowTokenBase)
134
- returns (uint128)
135
- {
125
+ function totalSupplyCurrent() public virtual override(IPVeToken, VotingEscrowTokenBase) returns (uint128) {
136
126
  (VeBalance memory supply, ) = _applySlopeChange();
137
127
  return supply.getCurrentValue();
138
128
  }
@@ -146,10 +136,7 @@ contract VotingEscrowPendleMainchain is
146
136
  * @notice updates and broadcast the position of `user` to different chains, also updates and
147
137
  * broadcasts totalSupply
148
138
  */
149
- function broadcastUserPosition(
150
- address user,
151
- uint256[] calldata chainIds
152
- ) public payable refundUnusedEth {
139
+ function broadcastUserPosition(address user, uint256[] calldata chainIds) public payable refundUnusedEth {
153
140
  if (user == address(0)) revert Errors.ZeroAddress();
154
141
  _broadcastPosition(user, chainIds);
155
142
  }
@@ -158,24 +145,17 @@ contract VotingEscrowPendleMainchain is
158
145
  return userHistory[user].length();
159
146
  }
160
147
 
161
- function getUserHistoryAt(
162
- address user,
163
- uint256 index
164
- ) external view returns (Checkpoint memory) {
148
+ function getUserHistoryAt(address user, uint256 index) external view returns (Checkpoint memory) {
165
149
  return userHistory[user].get(index);
166
150
  }
167
151
 
168
- function getBroadcastSupplyFee(
169
- uint256[] calldata chainIds
170
- ) external view returns (uint256 fee) {
152
+ function getBroadcastSupplyFee(uint256[] calldata chainIds) external view returns (uint256 fee) {
171
153
  for (uint256 i = 0; i < chainIds.length; i++) {
172
154
  fee += _getSendMessageFee(chainIds[i], SAMPLE_SUPPLY_UPDATE_MESSAGE);
173
155
  }
174
156
  }
175
157
 
176
- function getBroadcastPositionFee(
177
- uint256[] calldata chainIds
178
- ) external view returns (uint256 fee) {
158
+ function getBroadcastPositionFee(uint256[] calldata chainIds) external view returns (uint256 fee) {
179
159
  for (uint256 i = 0; i < chainIds.length; i++) {
180
160
  fee += _getSendMessageFee(chainIds[i], SAMPLE_POSITION_UPDATE_MESSAGE);
181
161
  }
@@ -249,13 +229,10 @@ contract VotingEscrowPendleMainchain is
249
229
 
250
230
  (VeBalance memory supply, ) = _applySlopeChange();
251
231
 
252
- bytes memory userData = (
253
- user == address(0) ? EMPTY_BYTES : abi.encode(user, positionData[user])
254
- );
232
+ bytes memory userData = (user == address(0) ? EMPTY_BYTES : abi.encode(user, positionData[user]));
255
233
 
256
234
  for (uint256 i = 0; i < chainIds.length; ++i) {
257
- if (!destinationContracts.contains(chainIds[i]))
258
- revert Errors.ChainNotSupported(chainIds[i]);
235
+ if (!destinationContracts.contains(chainIds[i])) revert Errors.ChainNotSupported(chainIds[i]);
259
236
  _broadcast(chainIds[i], uint128(block.timestamp), supply, userData);
260
237
  }
261
238
 
@@ -265,12 +242,7 @@ contract VotingEscrowPendleMainchain is
265
242
  emit BroadcastTotalSupply(supply, chainIds);
266
243
  }
267
244
 
268
- function _broadcast(
269
- uint256 chainId,
270
- uint128 msgTime,
271
- VeBalance memory supply,
272
- bytes memory userData
273
- ) internal {
245
+ function _broadcast(uint256 chainId, uint128 msgTime, VeBalance memory supply, bytes memory userData) internal {
274
246
  _sendMessage(chainId, abi.encode(msgTime, supply, userData));
275
247
  }
276
248
  }
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
 
3
- pragma solidity 0.8.17;
3
+ pragma solidity ^0.8.17;
4
4
 
5
5
  import "../libraries/VeBalanceLib.sol";
6
6
  import "../libraries/WeekMath.sol";
@@ -9,11 +9,7 @@ import "./VotingEscrowTokenBase.sol";
9
9
  import "../CrossChainMsg/PendleMsgReceiverAppUpg.sol";
10
10
 
11
11
  // solhint-disable no-empty-blocks
12
- contract VotingEscrowPendleSidechain is
13
- VotingEscrowTokenBase,
14
- PendleMsgReceiverAppUpg,
15
- BoringOwnableUpgradeable
16
- {
12
+ contract VotingEscrowPendleSidechain is VotingEscrowTokenBase, PendleMsgReceiverAppUpg, BoringOwnableUpgradeable {
17
13
  uint256 public lastTotalSupplyReceivedAt;
18
14
 
19
15
  mapping(address => address) internal delegatorOf;
@@ -59,10 +55,7 @@ contract VotingEscrowPendleSidechain is
59
55
  }
60
56
 
61
57
  function _setNewUserPosition(bytes memory userData) internal {
62
- (address userAddr, LockedPosition memory position) = abi.decode(
63
- userData,
64
- (address, LockedPosition)
65
- );
58
+ (address userAddr, LockedPosition memory position) = abi.decode(userData, (address, LockedPosition));
66
59
  positionData[userAddr] = position;
67
60
  emit SetNewUserPosition(position);
68
61
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
2
+ pragma solidity ^0.8.17;
3
3
 
4
4
  import "../../interfaces/IPVeToken.sol";
5
5
 
@@ -19,27 +19,17 @@ library VeBalanceLib {
19
19
  uint128 internal constant MAX_LOCK_TIME = 104 weeks;
20
20
  uint256 internal constant USER_VOTE_MAX_WEIGHT = 10 ** 18;
21
21
 
22
- function add(
23
- VeBalance memory a,
24
- VeBalance memory b
25
- ) internal pure returns (VeBalance memory res) {
22
+ function add(VeBalance memory a, VeBalance memory b) internal pure returns (VeBalance memory res) {
26
23
  res.bias = a.bias + b.bias;
27
24
  res.slope = a.slope + b.slope;
28
25
  }
29
26
 
30
- function sub(
31
- VeBalance memory a,
32
- VeBalance memory b
33
- ) internal pure returns (VeBalance memory res) {
27
+ function sub(VeBalance memory a, VeBalance memory b) internal pure returns (VeBalance memory res) {
34
28
  res.bias = a.bias - b.bias;
35
29
  res.slope = a.slope - b.slope;
36
30
  }
37
31
 
38
- function sub(
39
- VeBalance memory a,
40
- uint128 slope,
41
- uint128 expiry
42
- ) internal pure returns (VeBalance memory res) {
32
+ function sub(VeBalance memory a, uint128 slope, uint128 expiry) internal pure returns (VeBalance memory res) {
43
33
  res.slope = a.slope - slope;
44
34
  res.bias = a.bias - slope * expiry;
45
35
  }
@@ -65,9 +55,7 @@ library VeBalanceLib {
65
55
  return a.bias / a.slope;
66
56
  }
67
57
 
68
- function convertToVeBalance(
69
- LockedPosition memory position
70
- ) internal pure returns (VeBalance memory res) {
58
+ function convertToVeBalance(LockedPosition memory position) internal pure returns (VeBalance memory res) {
71
59
  res.slope = position.amount / MAX_LOCK_TIME;
72
60
  res.bias = res.slope * position.expiry;
73
61
  }
@@ -80,10 +68,7 @@ library VeBalanceLib {
80
68
  res.bias = res.slope * position.expiry;
81
69
  }
82
70
 
83
- function convertToVeBalance(
84
- uint128 amount,
85
- uint128 expiry
86
- ) internal pure returns (uint128, uint128) {
71
+ function convertToVeBalance(uint128 amount, uint128 expiry) internal pure returns (uint128, uint128) {
87
72
  VeBalance memory balance = convertToVeBalance(LockedPosition(amount, expiry));
88
73
  return (balance.bias, balance.slope);
89
74
  }
@@ -36,9 +36,7 @@ library Checkpoints {
36
36
  if (pos > 0 && self._checkpoints[pos - 1].timestamp == WeekMath.getCurrentWeekStart()) {
37
37
  self._checkpoints[pos - 1].value = value;
38
38
  } else {
39
- self._checkpoints.push(
40
- Checkpoint({ timestamp: WeekMath.getCurrentWeekStart(), value: value })
41
- );
39
+ self._checkpoints.push(Checkpoint({timestamp: WeekMath.getCurrentWeekStart(), value: value}));
42
40
  }
43
41
  }
44
42
  }
@@ -57,17 +57,13 @@ library MarketMathCore {
57
57
  uint256 syDesired,
58
58
  uint256 ptDesired,
59
59
  uint256 blockTime
60
- )
61
- internal
62
- pure
63
- returns (uint256 lpToReserve, uint256 lpToAccount, uint256 syUsed, uint256 ptUsed)
64
- {
65
- (
66
- int256 _lpToReserve,
67
- int256 _lpToAccount,
68
- int256 _syUsed,
69
- int256 _ptUsed
70
- ) = addLiquidityCore(market, syDesired.Int(), ptDesired.Int(), blockTime);
60
+ ) internal pure returns (uint256 lpToReserve, uint256 lpToAccount, uint256 syUsed, uint256 ptUsed) {
61
+ (int256 _lpToReserve, int256 _lpToAccount, int256 _syUsed, int256 _ptUsed) = addLiquidityCore(
62
+ market,
63
+ syDesired.Int(),
64
+ ptDesired.Int(),
65
+ blockTime
66
+ );
71
67
 
72
68
  lpToReserve = _lpToReserve.Uint();
73
69
  lpToAccount = _lpToAccount.Uint();
@@ -130,11 +126,7 @@ library MarketMathCore {
130
126
  int256 syDesired,
131
127
  int256 ptDesired,
132
128
  uint256 blockTime
133
- )
134
- internal
135
- pure
136
- returns (int256 lpToReserve, int256 lpToAccount, int256 syUsed, int256 ptUsed)
137
- {
129
+ ) internal pure returns (int256 lpToReserve, int256 lpToAccount, int256 syUsed, int256 ptUsed) {
138
130
  /// ------------------------------------------------------------
139
131
  /// CHECKS
140
132
  /// ------------------------------------------------------------
@@ -216,25 +208,12 @@ library MarketMathCore {
216
208
  /// ------------------------------------------------------------
217
209
  MarketPreCompute memory comp = getMarketPreCompute(market, index, blockTime);
218
210
 
219
- (netSyToAccount, netSyFee, netSyToReserve) = calcTrade(
220
- market,
221
- comp,
222
- index,
223
- netPtToAccount
224
- );
211
+ (netSyToAccount, netSyFee, netSyToReserve) = calcTrade(market, comp, index, netPtToAccount);
225
212
 
226
213
  /// ------------------------------------------------------------
227
214
  /// WRITE
228
215
  /// ------------------------------------------------------------
229
- _setNewMarketStateTrade(
230
- market,
231
- comp,
232
- index,
233
- netPtToAccount,
234
- netSyToAccount,
235
- netSyToReserve,
236
- blockTime
237
- );
216
+ _setNewMarketStateTrade(market, comp, index, netPtToAccount, netSyToAccount, netSyToReserve, blockTime);
238
217
  }
239
218
 
240
219
  function getMarketPreCompute(
@@ -281,8 +260,7 @@ library MarketMathCore {
281
260
 
282
261
  if (netPtToAccount > 0) {
283
262
  int256 postFeeExchangeRate = preFeeExchangeRate.divDown(fee);
284
- if (postFeeExchangeRate < PMath.IONE)
285
- revert Errors.MarketExchangeRateBelowOne(postFeeExchangeRate);
263
+ if (postFeeExchangeRate < PMath.IONE) revert Errors.MarketExchangeRateBelowOne(postFeeExchangeRate);
286
264
 
287
265
  fee = preFeeAssetToAccount.mulDown(PMath.IONE - fee);
288
266
  } else {
@@ -402,10 +380,7 @@ library MarketMathCore {
402
380
  res = logitP.ln();
403
381
  }
404
382
 
405
- function _getRateScalar(
406
- MarketState memory market,
407
- uint256 timeToExpiry
408
- ) internal pure returns (int256 rateScalar) {
383
+ function _getRateScalar(MarketState memory market, uint256 timeToExpiry) internal pure returns (int256 rateScalar) {
409
384
  rateScalar = (market.scalarRoot * IMPLIED_RATE_TIME.Int()) / timeToExpiry.Int();
410
385
  if (rateScalar <= 0) revert Errors.MarketRateScalarBelowZero(rateScalar);
411
386
  }
@@ -32,11 +32,7 @@ library OracleLib {
32
32
  Observation[65535] storage self,
33
33
  uint32 time
34
34
  ) public returns (uint16 cardinality, uint16 cardinalityNext) {
35
- self[0] = Observation({
36
- blockTimestamp: time,
37
- lnImpliedRateCumulative: 0,
38
- initialized: true
39
- });
35
+ self[0] = Observation({blockTimestamp: time, lnImpliedRateCumulative: 0, initialized: true});
40
36
  return (1, 1);
41
37
  }
42
38
 
@@ -64,11 +60,7 @@ library OracleLib {
64
60
  self[indexUpdated] = transform(last, blockTimestamp, lnImpliedRate);
65
61
  }
66
62
 
67
- function grow(
68
- Observation[65535] storage self,
69
- uint16 current,
70
- uint16 next
71
- ) public returns (uint16) {
63
+ function grow(Observation[65535] storage self, uint16 current, uint16 next) public returns (uint16) {
72
64
  if (current == 0) revert Errors.OracleUninitialized();
73
65
  // no-op if the passed next value isn't greater than the current next value
74
66
  if (next <= current) return current;
@@ -141,8 +133,7 @@ library OracleLib {
141
133
  if (!beforeOrAt.initialized) beforeOrAt = self[0];
142
134
 
143
135
  // ensure that the target is chronologically at or after the oldest observation
144
- if (target < beforeOrAt.blockTimestamp)
145
- revert Errors.OracleTargetTooOld(target, beforeOrAt.blockTimestamp);
136
+ if (target < beforeOrAt.blockTimestamp) revert Errors.OracleTargetTooOld(target, beforeOrAt.blockTimestamp);
146
137
 
147
138
  // if we've reached this point, we have to binary search
148
139
  return binarySearch(self, target, index, cardinality);
@@ -184,10 +175,8 @@ library OracleLib {
184
175
  // we're in the middle
185
176
  return (beforeOrAt.lnImpliedRateCumulative +
186
177
  uint216(
187
- (uint256(
188
- atOrAfter.lnImpliedRateCumulative - beforeOrAt.lnImpliedRateCumulative
189
- ) * (target - beforeOrAt.blockTimestamp)) /
190
- (atOrAfter.blockTimestamp - beforeOrAt.blockTimestamp)
178
+ (uint256(atOrAfter.lnImpliedRateCumulative - beforeOrAt.lnImpliedRateCumulative) *
179
+ (target - beforeOrAt.blockTimestamp)) / (atOrAfter.blockTimestamp - beforeOrAt.blockTimestamp)
191
180
  ));
192
181
  }
193
182
  }
@@ -204,14 +193,7 @@ library OracleLib {
204
193
 
205
194
  lnImpliedRateCumulative = new uint216[](secondsAgos.length);
206
195
  for (uint256 i = 0; i < lnImpliedRateCumulative.length; ++i) {
207
- lnImpliedRateCumulative[i] = observeSingle(
208
- self,
209
- time,
210
- secondsAgos[i],
211
- lnImpliedRate,
212
- index,
213
- cardinality
214
- );
196
+ lnImpliedRateCumulative[i] = observeSingle(self, time, secondsAgos[i], lnImpliedRate, index, cardinality);
215
197
  }
216
198
  }
217
199
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
2
+ pragma solidity ^0.8.17;
3
3
  import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
4
4
  import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
5
5
  import "../libraries/math/PMath.sol";
@@ -28,8 +28,7 @@ contract PendleExternalRewardDistributor is
28
28
 
29
29
  modifier onlyValidMarket(address market) {
30
30
  require(
31
- IPMarketFactory(marketFactory).isValidMarket(market) &&
32
- block.timestamp < IPMarket(market).expiry(),
31
+ IPMarketFactory(marketFactory).isValidMarket(market) && block.timestamp < IPMarket(market).expiry(),
33
32
  "invalid market"
34
33
  );
35
34
  _;
@@ -43,9 +42,7 @@ contract PendleExternalRewardDistributor is
43
42
  __BoringOwnable_init();
44
43
  }
45
44
 
46
- function getRewardTokens(
47
- address market
48
- ) external view returns (address[] memory) {
45
+ function getRewardTokens(address market) external view returns (address[] memory) {
49
46
  return rewardTokens[market];
50
47
  }
51
48
 
@@ -120,10 +117,7 @@ contract PendleExternalRewardDistributor is
120
117
  emit AddRewardToMarket(market, token, rewardData[market][token]);
121
118
  }
122
119
 
123
- function _getUpdatedMarketReward(
124
- address market,
125
- address token
126
- ) internal view returns (MarketRewardData memory) {
120
+ function _getUpdatedMarketReward(address market, address token) internal view returns (MarketRewardData memory) {
127
121
  MarketRewardData memory rwd = rewardData[market][token];
128
122
  uint128 newLastUpdated = uint128(PMath.min(uint128(block.timestamp), rwd.incentiveEndsAt));
129
123
  rwd.accumulatedReward += rwd.rewardPerSec * (newLastUpdated - rwd.lastUpdated);
@@ -71,19 +71,13 @@ abstract contract PendleGauge is RewardManager, IPGauge {
71
71
  activeBalance[user] = newActiveBalance;
72
72
  }
73
73
 
74
- function _calcVeBoostedLpBalance(
75
- address user,
76
- uint256 lpBalance
77
- ) internal virtual returns (uint256) {
78
- (uint256 vePendleSupply, uint256 vePendleBalance) = vePENDLE.totalSupplyAndBalanceCurrent(
79
- user
80
- );
74
+ function _calcVeBoostedLpBalance(address user, uint256 lpBalance) internal virtual returns (uint256) {
75
+ (uint256 vePendleSupply, uint256 vePendleBalance) = vePENDLE.totalSupplyAndBalanceCurrent(user);
81
76
  // Inspired by Curve's Gauge
82
77
  uint256 veBoostedLpBalance = (lpBalance * TOKENLESS_PRODUCTION) / 100;
83
78
  if (vePendleSupply > 0) {
84
79
  veBoostedLpBalance +=
85
- (((_totalStaked() * vePendleBalance) / vePendleSupply) *
86
- (100 - TOKENLESS_PRODUCTION)) /
80
+ (((_totalStaked() * vePendleBalance) / vePendleSupply) * (100 - TOKENLESS_PRODUCTION)) /
87
81
  100;
88
82
  }
89
83
  return veBoostedLpBalance;
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
2
+ pragma solidity ^0.8.17;
3
3
 
4
4
  import "../../interfaces/IPMarket.sol";
5
5
  import "../../interfaces/IPMarketFactory.sol";
@@ -61,16 +61,14 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
61
61
  int256 _initialAnchor,
62
62
  address _vePendle,
63
63
  address _gaugeController
64
- )
65
- PendleERC20Permit(NAME, SYMBOL, 18)
66
- PendleGauge(IPPrincipalToken(_PT).SY(), _vePendle, _gaugeController)
67
- {
64
+ ) PendleERC20Permit(NAME, SYMBOL, 18) PendleGauge(IPPrincipalToken(_PT).SY(), _vePendle, _gaugeController) {
68
65
  PT = IPPrincipalToken(_PT);
69
66
  SY = IStandardizedYield(PT.SY());
70
67
  YT = IPYieldToken(PT.YT());
71
68
 
72
- (_storage.observationCardinality, _storage.observationCardinalityNext) = observations
73
- .initialize(uint32(block.timestamp));
69
+ (_storage.observationCardinality, _storage.observationCardinalityNext) = observations.initialize(
70
+ uint32(block.timestamp)
71
+ );
74
72
 
75
73
  if (_scalarRoot <= 0) revert Errors.MarketScalarRootBelowZero(_scalarRoot);
76
74
 
@@ -92,12 +90,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
92
90
  address receiver,
93
91
  uint256 netSyDesired,
94
92
  uint256 netPtDesired
95
- )
96
- external
97
- nonReentrant
98
- notExpired
99
- returns (uint256 netLpOut, uint256 netSyUsed, uint256 netPtUsed)
100
- {
93
+ ) external nonReentrant notExpired returns (uint256 netLpOut, uint256 netSyUsed, uint256 netPtUsed) {
101
94
  MarketState memory market = readState(msg.sender);
102
95
  PYIndex index = YT.newIndex();
103
96
 
@@ -169,11 +162,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
169
162
  MarketState memory market = readState(msg.sender);
170
163
 
171
164
  uint256 netSyToReserve;
172
- (netSyOut, netSyFee, netSyToReserve) = market.swapExactPtForSy(
173
- YT.newIndex(),
174
- exactPtIn,
175
- block.timestamp
176
- );
165
+ (netSyOut, netSyFee, netSyToReserve) = market.swapExactPtForSy(YT.newIndex(), exactPtIn, block.timestamp);
177
166
 
178
167
  if (receiver != address(this)) IERC20(SY).safeTransfer(receiver, netSyOut);
179
168
  IERC20(SY).safeTransfer(market.treasury, netSyToReserve);
@@ -208,11 +197,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
208
197
  MarketState memory market = readState(msg.sender);
209
198
 
210
199
  uint256 netSyToReserve;
211
- (netSyIn, netSyFee, netSyToReserve) = market.swapSyForExactPt(
212
- YT.newIndex(),
213
- exactPtOut,
214
- block.timestamp
215
- );
200
+ (netSyIn, netSyFee, netSyToReserve) = market.swapSyForExactPt(YT.newIndex(), exactPtOut, block.timestamp);
216
201
 
217
202
  if (receiver != address(this)) IERC20(PT).safeTransfer(receiver, exactPtOut);
218
203
  IERC20(SY).safeTransfer(market.treasury, netSyToReserve);
@@ -256,9 +241,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
256
241
  ORACLE
257
242
  //////////////////////////////////////////////////////////////*/
258
243
 
259
- function observe(
260
- uint32[] memory secondsAgos
261
- ) external view returns (uint216[] memory lnImpliedRateCumulative) {
244
+ function observe(uint32[] memory secondsAgos) external view returns (uint216[] memory lnImpliedRateCumulative) {
262
245
  return
263
246
  observations.observe(
264
247
  uint32(block.timestamp),
@@ -290,9 +273,9 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
290
273
  market.totalSy = _storage.totalSy;
291
274
  market.totalLp = totalSupply().Int();
292
275
 
293
- (market.treasury, market.lnFeeRateRoot, market.reserveFeePercent) = IPMarketFactory(
294
- factory
295
- ).getMarketConfig(router);
276
+ (market.treasury, market.lnFeeRateRoot, market.reserveFeePercent) = IPMarketFactory(factory).getMarketConfig(
277
+ router
278
+ );
296
279
 
297
280
  market.scalarRoot = scalarRoot;
298
281
  market.expiry = expiry;
@@ -327,11 +310,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
327
310
  TRIVIAL FUNCTIONS
328
311
  //////////////////////////////////////////////////////////////*/
329
312
 
330
- function readTokens()
331
- external
332
- view
333
- returns (IStandardizedYield _SY, IPPrincipalToken _PT, IPYieldToken _YT)
334
- {
313
+ function readTokens() external view returns (IStandardizedYield _SY, IPPrincipalToken _PT, IPYieldToken _YT) {
335
314
  _SY = SY;
336
315
  _PT = PT;
337
316
  _YT = YT;
@@ -363,11 +342,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
363
342
  }
364
343
 
365
344
  // solhint-disable-next-line ordering
366
- function _afterTokenTransfer(
367
- address from,
368
- address to,
369
- uint256 amount
370
- ) internal override(PendleERC20, PendleGauge) {
345
+ function _afterTokenTransfer(address from, address to, uint256 amount) internal override(PendleERC20, PendleGauge) {
371
346
  PendleGauge._afterTokenTransfer(from, to, amount);
372
347
  }
373
348
  }
@@ -1,6 +1,5 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
3
-
2
+ pragma solidity ^0.8.17;
4
3
  import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
4
 
6
5
  import "../../interfaces/IPMarket.sol";
@@ -73,18 +72,13 @@ contract PendleMarketFactory is BoringOwnableUpgradeable, IPMarketFactory {
73
72
  * Anyone is allowed to create a market on their own.
74
73
  */
75
74
  function createNewMarket(address PT, int256 scalarRoot, int256 initialAnchor) external returns (address market) {
76
- if (!IPYieldContractFactory(yieldContractFactory).isPT(PT)) {
77
- revert Errors.MarketFactoryInvalidPt();
78
- }
75
+ if (!IPYieldContractFactory(yieldContractFactory).isPT(PT)) revert Errors.MarketFactoryInvalidPt();
79
76
  if (IPPrincipalToken(PT).isExpired()) revert Errors.MarketFactoryExpiredPt();
80
77
 
81
- if (markets[PT][scalarRoot][initialAnchor] != address(0)) {
82
- revert Errors.MarketFactoryMarketExists();
83
- }
78
+ if (markets[PT][scalarRoot][initialAnchor] != address(0)) revert Errors.MarketFactoryMarketExists();
84
79
 
85
- if (initialAnchor < minInitialAnchor) {
80
+ if (initialAnchor < minInitialAnchor)
86
81
  revert Errors.MarketFactoryInitialAnchorTooLow(initialAnchor, minInitialAnchor);
87
- }
88
82
 
89
83
  market = BaseSplitCodeFactory._create2(
90
84
  0,
@@ -103,13 +97,14 @@ contract PendleMarketFactory is BoringOwnableUpgradeable, IPMarketFactory {
103
97
  emit CreateNewMarket(market, PT, scalarRoot, initialAnchor);
104
98
  }
105
99
 
106
- function getMarketConfig(address router)
107
- external
108
- view
109
- returns (address _treasury, uint80 _lnFeeRateRoot, uint8 _reserveFeePercent)
110
- {
111
- (_treasury, _lnFeeRateRoot, _reserveFeePercent) =
112
- (treasury, defaultFee.lnFeeRateRoot, defaultFee.reserveFeePercent);
100
+ function getMarketConfig(
101
+ address router
102
+ ) external view returns (address _treasury, uint80 _lnFeeRateRoot, uint8 _reserveFeePercent) {
103
+ (_treasury, _lnFeeRateRoot, _reserveFeePercent) = (
104
+ treasury,
105
+ defaultFee.lnFeeRateRoot,
106
+ defaultFee.reserveFeePercent
107
+ );
113
108
 
114
109
  FeeConfig memory over = overriddenFee[router];
115
110
  if (over.active) {
@@ -147,12 +142,10 @@ contract PendleMarketFactory is BoringOwnableUpgradeable, IPMarketFactory {
147
142
  }
148
143
 
149
144
  function _verifyFeeConfig(uint80 newLnFeeRateRoot, uint8 newReserveFeePercent) internal view {
150
- if (newLnFeeRateRoot > maxLnFeeRateRoot) {
145
+ if (newLnFeeRateRoot > maxLnFeeRateRoot)
151
146
  revert Errors.MarketFactoryLnFeeRateRootTooHigh(newLnFeeRateRoot, maxLnFeeRateRoot);
152
- }
153
- if (newReserveFeePercent > maxReserveFeePercent) {
147
+ if (newReserveFeePercent > maxReserveFeePercent)
154
148
  revert Errors.MarketFactoryReserveFeePercentTooHigh(newReserveFeePercent, maxReserveFeePercent);
155
- }
156
149
  }
157
150
 
158
151
  function _emitNewMarketConfigEvent() internal {