@pendle/core-v2 0.8.0-beta-12 → 0.8.1-gamma

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 (330) hide show
  1. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +1 -1
  2. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.json +39 -7
  3. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +1 -1
  4. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.dbg.json +4 -0
  5. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.json +833 -0
  6. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  7. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
  8. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json +39 -7
  9. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.dbg.json +4 -0
  10. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.json +723 -0
  11. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.dbg.json +4 -0
  12. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.json +723 -0
  13. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.dbg.json +1 -1
  14. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.json +38 -6
  15. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.dbg.json +4 -0
  16. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.json +864 -0
  17. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +1 -1
  18. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.json +56 -6
  19. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol/PendleYearnVaultSCY.dbg.json +1 -1
  20. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol/PendleYearnVaultSCY.json +38 -6
  21. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.dbg.json +4 -0
  22. package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.json +784 -0
  23. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
  24. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.json +36 -4
  25. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
  26. package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.json +36 -4
  27. package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.dbg.json +1 -1
  28. package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.dbg.json +1 -1
  29. package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.json +2 -2
  30. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  31. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +4 -0
  32. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +242 -0
  33. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +4 -0
  34. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/{PendleGaugeControllerSidechain.sol → PendleGaugeControllerSidechainUpg.sol}/PendleGaugeControllerSidechainUpg.json +3 -3
  35. package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  36. package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  37. package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +46 -40
  38. package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  39. package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.json +0 -13
  40. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  41. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +66 -4
  42. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  43. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +26 -2
  44. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.json +24 -0
  46. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
  48. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  49. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +2 -2
  50. package/build/artifacts/contracts/core/PendleERC20.sol/PendleERC20.dbg.json +1 -1
  51. package/build/artifacts/contracts/core/PendleERC20.sol/PendleERC20.json +2 -2
  52. package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  53. package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.json +2 -2
  54. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  55. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +2 -77
  57. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
  59. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  60. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +21 -96
  61. package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  62. package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.json +2 -2
  63. package/build/artifacts/contracts/core/actions/ActionCore.sol/ActionCore.dbg.json +1 -1
  64. package/build/artifacts/contracts/core/actions/ActionCore.sol/ActionCore.json +2 -2
  65. package/build/artifacts/contracts/core/actions/ActionYT.sol/ActionYT.dbg.json +1 -1
  66. package/build/artifacts/contracts/core/actions/ActionYT.sol/ActionYT.json +2 -2
  67. package/build/artifacts/contracts/core/actions/base/ActionSCYAndPTBase.sol/ActionSCYAndPTBase.dbg.json +1 -1
  68. package/build/artifacts/contracts/core/actions/base/ActionSCYAndPYBase.sol/ActionSCYAndPYBase.dbg.json +1 -1
  69. package/build/artifacts/contracts/core/actions/base/ActionSCYAndYTBase.sol/ActionSCYAndYTBase.dbg.json +1 -1
  70. package/build/artifacts/contracts/core/actions/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
  71. package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
  72. package/build/artifacts/contracts/interfaces/IAavePool.sol/IAavePool.dbg.json +1 -1
  73. package/build/artifacts/contracts/interfaces/IAaveRewardsController.sol/IAaveRewardsController.dbg.json +1 -1
  74. package/build/artifacts/contracts/interfaces/IBenQiComptroller.sol/IBenQiComptroller.dbg.json +1 -1
  75. package/build/artifacts/contracts/interfaces/IBenQiInterestRateModel.sol/IBenQiInterestRateModel.dbg.json +1 -1
  76. package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.dbg.json +1 -1
  77. package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.dbg.json +1 -1
  78. package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
  79. package/build/artifacts/contracts/interfaces/IEulerEToken.sol/IEulerEToken.dbg.json +4 -0
  80. package/build/artifacts/contracts/interfaces/IEulerEToken.sol/IEulerEToken.json +162 -0
  81. package/build/artifacts/contracts/interfaces/IEulerMarkets.sol/IEulerMarkets.dbg.json +4 -0
  82. package/build/artifacts/contracts/interfaces/IEulerMarkets.sol/IEulerMarkets.json +87 -0
  83. package/build/artifacts/contracts/interfaces/IJoePair.sol/IJoePair.dbg.json +1 -1
  84. package/build/artifacts/contracts/interfaces/IJoeRouter01.sol/IJoeRouter01.dbg.json +1 -1
  85. package/build/artifacts/contracts/interfaces/IJoeRouter02.sol/IJoeRouter02.dbg.json +1 -1
  86. package/build/artifacts/contracts/interfaces/IPActionCore.sol/IPActionCore.dbg.json +1 -1
  87. package/build/artifacts/contracts/interfaces/IPActionYT.sol/IPActionYT.dbg.json +1 -1
  88. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  89. package/build/artifacts/contracts/interfaces/IPGaugeController.sol/IPGaugeController.dbg.json +1 -1
  90. package/build/artifacts/contracts/interfaces/IPGaugeControllerMainchain.sol/IPGaugeControllerMainchain.dbg.json +1 -1
  91. package/build/artifacts/contracts/interfaces/IPGovernanceManager.sol/IPGovernanceManager.dbg.json +1 -1
  92. package/build/artifacts/contracts/interfaces/IPInterestManagerYT.sol/IPInterestManagerYT.dbg.json +1 -1
  93. package/build/artifacts/contracts/interfaces/IPInterestManagerYT.sol/IPInterestManagerYT.json +1 -1
  94. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  95. package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
  96. package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
  97. package/build/artifacts/contracts/interfaces/IPPermissionsV2Upg.sol/IPermissionsV2Upg.dbg.json +1 -1
  98. package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
  99. package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
  100. package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.json +38 -23
  101. package/build/artifacts/contracts/interfaces/IPVeToken.sol/IPVeToken.dbg.json +1 -1
  102. package/build/artifacts/contracts/interfaces/IPVeToken.sol/IPVeToken.json +24 -0
  103. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  104. package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.dbg.json +1 -1
  105. package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
  106. package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
  107. package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.json +27 -27
  108. package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
  109. package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
  110. package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
  111. package/build/artifacts/contracts/interfaces/IRewardManager.sol/IRewardManager.dbg.json +1 -1
  112. package/build/artifacts/contracts/interfaces/ISAvax.sol/ISAvax.dbg.json +4 -0
  113. package/build/artifacts/contracts/interfaces/ISAvax.sol/ISAvax.json +199 -0
  114. package/build/artifacts/contracts/interfaces/ISJoe.sol/ISJoe.dbg.json +4 -0
  115. package/build/artifacts/contracts/interfaces/ISJoe.sol/ISJoe.json +168 -0
  116. package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +4 -0
  117. package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.json +92 -0
  118. package/build/artifacts/contracts/interfaces/IStargateLPStaking.sol/IStargateLPStaking.dbg.json +4 -0
  119. package/build/artifacts/contracts/interfaces/IStargateLPStaking.sol/IStargateLPStaking.json +137 -0
  120. package/build/artifacts/contracts/interfaces/IStargatePool.sol/IStargatePool.dbg.json +4 -0
  121. package/build/artifacts/contracts/interfaces/IStargatePool.sol/IStargatePool.json +135 -0
  122. package/build/artifacts/contracts/interfaces/IStargateRouter.sol/IStargateRouter.dbg.json +4 -0
  123. package/build/artifacts/contracts/interfaces/IStargateRouter.sol/IStargateRouter.json +63 -0
  124. package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
  125. package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.json +36 -4
  126. package/build/artifacts/contracts/interfaces/IWAvax.sol/IWAvax.dbg.json +4 -0
  127. package/build/artifacts/contracts/interfaces/IWAvax.sol/IWAvax.json +252 -0
  128. package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
  129. package/build/artifacts/contracts/interfaces/IWstETH.sol/IWstETH.dbg.json +1 -1
  130. package/build/artifacts/contracts/interfaces/IYearnVault.sol/IYearnVault.dbg.json +1 -1
  131. package/build/artifacts/contracts/libraries/RewardManager.sol/RewardManager.dbg.json +1 -1
  132. package/build/artifacts/contracts/libraries/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  133. package/build/artifacts/contracts/libraries/SCY/SCYUtils.sol/SCYUtils.dbg.json +1 -1
  134. package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  135. package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  136. package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  137. package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  138. package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.dbg.json +1 -1
  139. package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.json +2 -2
  140. package/build/artifacts/contracts/libraries/helpers/ExpiryUtilsLib.sol/ExpiryUtils.dbg.json +1 -1
  141. package/build/artifacts/contracts/libraries/helpers/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
  142. package/build/artifacts/contracts/libraries/helpers/PYIndex.sol/PYIndexLib.dbg.json +4 -0
  143. package/build/artifacts/contracts/libraries/{SCY/SCYIndex.sol/SCYIndexLib.json → helpers/PYIndex.sol/PYIndexLib.json} +4 -4
  144. package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +1 -1
  145. package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
  146. package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.dbg.json +1 -1
  147. package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.json +2 -2
  148. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxLib.dbg.json +1 -1
  149. package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxLib.json +2 -2
  150. package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  151. package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.json +2 -2
  152. package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
  153. package/build/artifacts/contracts/libraries/math/Math.sol/Math.json +2 -2
  154. package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.dbg.json +1 -1
  155. package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.dbg.json +1 -1
  156. package/build/artifacts/contracts/libraries/traderjoe/JoeLibrary.sol/JoeLibrary.dbg.json +1 -1
  157. package/build/artifacts/contracts/libraries/traderjoe/PendleJoeSwapHelperUpg.sol/PendleJoeSwapHelperUpg.dbg.json +1 -1
  158. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  159. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +209 -41
  160. package/build/artifacts/contracts/periphery/PermissionsV2Upg.sol/PermissionsV2Upg.dbg.json +1 -1
  161. package/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol +13 -3
  162. package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol +242 -0
  163. package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol +14 -10
  164. package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol +146 -0
  165. package/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol +170 -0
  166. package/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol +12 -2
  167. package/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol +194 -0
  168. package/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol +41 -10
  169. package/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol +12 -8
  170. package/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol +184 -0
  171. package/contracts/SuperComposableYield/base-implementations/SCYBase.sol +10 -12
  172. package/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol +1 -2
  173. package/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol +20 -10
  174. package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +3 -1
  175. package/contracts/core/LiquidityMining/GaugeController/{PendleGaugeControllerMainchain.sol → PendleGaugeControllerMainchainUpg.sol} +0 -0
  176. package/contracts/core/LiquidityMining/GaugeController/{PendleGaugeControllerSidechain.sol → PendleGaugeControllerSidechainUpg.sol} +0 -0
  177. package/contracts/core/LiquidityMining/PendleGauge.sol +3 -2
  178. package/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +41 -29
  179. package/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +4 -10
  180. package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +33 -16
  181. package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +2 -4
  182. package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +5 -1
  183. package/contracts/core/Market/PendleMarket.sol +4 -5
  184. package/contracts/core/Market/PendleMarketFactory.sol +2 -1
  185. package/contracts/core/PendleERC20.sol +1 -1
  186. package/contracts/core/YieldContracts/InterestManagerYT.sol +0 -2
  187. package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
  188. package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +2 -2
  189. package/contracts/core/YieldContracts/PendleYieldToken.sol +24 -32
  190. package/contracts/core/actions/ActionCallback.sol +10 -8
  191. package/contracts/core/actions/base/ActionSCYAndPTBase.sol +10 -9
  192. package/contracts/core/actions/base/ActionSCYAndYTBase.sol +5 -4
  193. package/contracts/core/actions/base/CallbackHelper.sol +1 -1
  194. package/contracts/interfaces/IEulerEToken.sol +60 -0
  195. package/contracts/interfaces/IEulerMarkets.sol +46 -0
  196. package/contracts/interfaces/IPGaugeController.sol +1 -1
  197. package/contracts/interfaces/IPInterestManagerYT.sol +1 -1
  198. package/contracts/interfaces/IPMarket.sol +1 -0
  199. package/contracts/interfaces/IPRouterStatic.sol +17 -10
  200. package/contracts/interfaces/IPVeToken.sol +2 -0
  201. package/contracts/interfaces/IPYieldToken.sol +2 -2
  202. package/contracts/interfaces/ISAvax.sol +61 -0
  203. package/contracts/interfaces/ISJoe.sol +60 -0
  204. package/contracts/interfaces/IStETH.sol +14 -0
  205. package/contracts/interfaces/IStargateLPStaking.sol +47 -0
  206. package/contracts/interfaces/IStargatePool.sol +49 -0
  207. package/contracts/interfaces/IStargateRouter.sol +37 -0
  208. package/contracts/interfaces/ISuperComposableYield.sol +6 -9
  209. package/contracts/interfaces/IWAvax.sol +34 -0
  210. package/contracts/libraries/RewardManager.sol +2 -3
  211. package/contracts/libraries/RewardManagerAbstract.sol +1 -0
  212. package/contracts/libraries/VeBalanceLib.sol +13 -0
  213. package/contracts/libraries/helpers/ArrayLib.sol +0 -17
  214. package/contracts/libraries/helpers/PYIndex.sol +69 -0
  215. package/contracts/libraries/helpers/TokenHelper.sol +4 -2
  216. package/contracts/libraries/math/LogExpMath.sol +46 -44
  217. package/contracts/libraries/math/MarketApproxLib.sol +10 -12
  218. package/contracts/libraries/math/MarketMathCore.sol +24 -15
  219. package/contracts/libraries/math/Math.sol +14 -0
  220. package/contracts/offchain-helpers/RouterStatic.sol +177 -66
  221. package/deployments/43113-benqi.json +2 -2
  222. package/deployments/43113-core.json +7 -7
  223. package/deployments/43113-markets/benqi-market-599408.json +7 -0
  224. package/deployments/43113-markets/benqi-market-93bbf0.json +7 -0
  225. package/deployments/80001-benqi.json +2 -2
  226. package/deployments/80001-core.json +6 -6
  227. package/deployments/80001-markets/benqi-market-007811.json +7 -0
  228. package/deployments/80001-markets/benqi-market-3fe528.json +7 -0
  229. package/package.json +3 -3
  230. package/typechain-types/CelerSenderUpg.ts +16 -16
  231. package/typechain-types/IERC20Upgradeable.ts +300 -0
  232. package/typechain-types/IEulerEToken.ts +320 -0
  233. package/typechain-types/IEulerMarkets.ts +204 -0
  234. package/typechain-types/IPInterestManagerYT.ts +3 -3
  235. package/typechain-types/IPRouterStatic.ts +75 -97
  236. package/typechain-types/IPVeToken.ts +34 -0
  237. package/typechain-types/IPYieldToken.ts +47 -47
  238. package/typechain-types/ISAvax.ts +430 -0
  239. package/typechain-types/ISJoe.ts +340 -0
  240. package/typechain-types/IStETH.ts +201 -0
  241. package/typechain-types/IStargateLPStaking.ts +108 -0
  242. package/typechain-types/IStargatePool.ts +94 -0
  243. package/typechain-types/ISuperComposableYield.ts +72 -26
  244. package/typechain-types/IWAvax.ts +380 -0
  245. package/typechain-types/PendleAaveV3SCY.ts +74 -28
  246. package/typechain-types/PendleERC4626SCY.ts +73 -27
  247. package/typechain-types/PendleEulerSCY.ts +965 -0
  248. package/typechain-types/PendlePrincipalToken.ts +0 -104
  249. package/typechain-types/PendleQiSAvaxSCY.ts +1098 -0
  250. package/typechain-types/PendleQiTokenSCY.ts +74 -28
  251. package/typechain-types/PendleSAvaxSCY.ts +962 -0
  252. package/typechain-types/PendleSJoeSCY.ts +1053 -0
  253. package/typechain-types/PendleStargatePool.ts +73 -27
  254. package/typechain-types/PendleStargateSCY.ts +1135 -0
  255. package/typechain-types/PendleVotingControllerUpg.ts +88 -75
  256. package/typechain-types/PendleWstEthSCY.ts +86 -27
  257. package/typechain-types/PendleYearnVaultScy.ts +73 -27
  258. package/typechain-types/PendleYieldToken.ts +44 -148
  259. package/typechain-types/RouterStatic.ts +327 -253
  260. package/typechain-types/SCYBase.ts +73 -27
  261. package/typechain-types/SCYBaseWithRewards.ts +73 -27
  262. package/typechain-types/VotingControllerStorageUpg.ts +0 -21
  263. package/typechain-types/VotingEscrowPendleMainchain.ts +118 -16
  264. package/typechain-types/VotingEscrowPendleSidechain.ts +34 -0
  265. package/typechain-types/VotingEscrowTokenBase.ts +34 -0
  266. package/typechain-types/factories/ActionCallback__factory.ts +1 -1
  267. package/typechain-types/factories/ActionCore__factory.ts +1 -1
  268. package/typechain-types/factories/ActionYT__factory.ts +1 -1
  269. package/typechain-types/factories/CelerSenderUpg__factory.ts +2 -2
  270. package/typechain-types/factories/IERC20Upgradeable__factory.ts +209 -0
  271. package/typechain-types/factories/IEulerEToken__factory.ts +174 -0
  272. package/typechain-types/factories/IEulerMarkets__factory.ts +99 -0
  273. package/typechain-types/factories/IPInterestManagerYT__factory.ts +1 -1
  274. package/typechain-types/factories/IPRouterStatic__factory.ts +38 -23
  275. package/typechain-types/factories/IPVeToken__factory.ts +24 -0
  276. package/typechain-types/factories/IPYieldToken__factory.ts +27 -27
  277. package/typechain-types/factories/ISAvax__factory.ts +208 -0
  278. package/typechain-types/factories/ISJoe__factory.ts +177 -0
  279. package/typechain-types/factories/IStETH__factory.ts +101 -0
  280. package/typechain-types/factories/IStargateLPStaking__factory.ts +90 -0
  281. package/typechain-types/factories/IStargatePool__factory.ts +79 -0
  282. package/typechain-types/factories/ISuperComposableYield__factory.ts +36 -4
  283. package/typechain-types/factories/IWAvax__factory.ts +261 -0
  284. package/typechain-types/factories/PendleAaveV3SCY__factory.ts +38 -6
  285. package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
  286. package/typechain-types/factories/PendleERC20__factory.ts +1 -1
  287. package/typechain-types/factories/PendleERC4626SCY__factory.ts +37 -5
  288. package/typechain-types/factories/PendleEulerSCY__factory.ts +796 -0
  289. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
  290. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
  291. package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
  292. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  293. package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -76
  294. package/typechain-types/factories/PendleQiSAvaxSCY__factory.ts +917 -0
  295. package/typechain-types/factories/PendleQiTokenSCY__factory.ts +38 -6
  296. package/typechain-types/factories/PendleRouter__factory.ts +1 -1
  297. package/typechain-types/factories/PendleSAvaxSCY__factory.ts +796 -0
  298. package/typechain-types/factories/PendleSJoeSCY__factory.ts +845 -0
  299. package/typechain-types/factories/PendleStargatePool__factory.ts +37 -5
  300. package/typechain-types/factories/PendleStargateSCY__factory.ts +952 -0
  301. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +44 -38
  302. package/typechain-types/factories/PendleWstEthSCY__factory.ts +65 -6
  303. package/typechain-types/factories/PendleYearnVaultScy__factory.ts +37 -5
  304. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
  305. package/typechain-types/factories/PendleYieldToken__factory.ts +19 -94
  306. package/typechain-types/factories/RouterStatic__factory.ts +208 -40
  307. package/typechain-types/factories/SCYBaseWithRewards__factory.ts +36 -4
  308. package/typechain-types/factories/SCYBase__factory.ts +36 -4
  309. package/typechain-types/factories/VotingControllerStorageUpg__factory.ts +0 -13
  310. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +65 -3
  311. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +25 -1
  312. package/typechain-types/factories/VotingEscrowTokenBase__factory.ts +24 -0
  313. package/typechain-types/hardhat.d.ts +103 -13
  314. package/typechain-types/index.ts +24 -4
  315. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchain.sol/PendleGaugeControllerMainchainUpg.dbg.json +0 -4
  316. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchain.sol/PendleGaugeControllerMainchainUpg.json +0 -242
  317. package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechain.sol/PendleGaugeControllerSidechainUpg.dbg.json +0 -4
  318. package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +0 -4
  319. package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.json +0 -329
  320. package/build/artifacts/contracts/libraries/SCY/SCYIndex.sol/SCYIndexLib.dbg.json +0 -4
  321. package/contracts/core/PendleERC20Permit.sol +0 -84
  322. package/contracts/libraries/SCY/SCYIndex.sol +0 -72
  323. package/deployments/43113-markets/benqi-market-5C60ba.json +0 -7
  324. package/deployments/43113-markets/benqi-market-611eA3.json +0 -7
  325. package/deployments/43113-markets/benqi-market-A386eA.json +0 -7
  326. package/deployments/43113-markets/benqi-market-bf8841.json +0 -7
  327. package/deployments/80001-markets/benqi-market-5E1104.json +0 -7
  328. package/deployments/80001-markets/benqi-market-899134.json +0 -7
  329. package/deployments/80001-markets/benqi-market-94C86f.json +0 -7
  330. package/deployments/80001-markets/benqi-market-c68429.json +0 -7
@@ -0,0 +1,14 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.15;
3
+
4
+ interface IStETH {
5
+ function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256);
6
+
7
+ function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);
8
+
9
+ function submit(address referral) external payable returns (uint256 amount);
10
+
11
+ function burnShares(address _account, uint256 _sharesAmount)
12
+ external
13
+ returns (uint256 newTotalShares);
14
+ }
@@ -0,0 +1,47 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+ pragma solidity 0.8.15;
24
+
25
+ interface IStargateLPStaking {
26
+ struct PoolInfo {
27
+ address lpToken; // Address of LP token contract.
28
+ uint256 allocPoint; // How many allocation points assigned to this pool. STGs to distribute per block.
29
+ uint256 lastRewardBlock; // Last block number that STGs distribution occurs.
30
+ uint256 accStargatePerShare; // Accumulated STGs per share, times 1e12. See below.
31
+ }
32
+
33
+ struct UserInfo {
34
+ uint256 amount; // How many LP tokens the user has provided.
35
+ uint256 rewardDebt; // Reward debt. See explanation below.
36
+ }
37
+
38
+ function stargate() external view returns (address);
39
+
40
+ function deposit(uint256 _pid, uint256 _amount) external;
41
+
42
+ function withdraw(uint256 _pid, uint256 _amount) external;
43
+
44
+ function poolInfo(uint256 _pid) external view returns (PoolInfo memory);
45
+
46
+ function userInfo(uint256 _pid, address _user) external view returns (UserInfo memory);
47
+ }
@@ -0,0 +1,49 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+ pragma solidity 0.8.15;
24
+
25
+ interface IStargatePool {
26
+ struct SwapObj {
27
+ uint256 amount;
28
+ uint256 eqFee;
29
+ uint256 eqReward;
30
+ uint256 lpFee;
31
+ uint256 protocolFee;
32
+ uint256 lkbRemove;
33
+ }
34
+
35
+ function swapRemote(
36
+ uint16 _srcChainId,
37
+ uint256 _srcPoolId,
38
+ address _to,
39
+ SwapObj memory _s
40
+ ) external returns (uint256 amountLD);
41
+
42
+ function poolId() external view returns (uint256);
43
+
44
+ function amountLPtoLD(uint256 _amountLP) external view returns (uint256);
45
+
46
+ function token() external view returns (address);
47
+
48
+ function totalLiquidity() external view returns (uint256);
49
+ }
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+ pragma solidity 0.8.15;
24
+
25
+ interface IStargateRouter {
26
+ function addLiquidity(
27
+ uint256 _poolId,
28
+ uint256 _amountLD,
29
+ address _to
30
+ ) external;
31
+
32
+ function instantRedeemLocal(
33
+ uint16 _srcPoolId,
34
+ uint256 _amountLP,
35
+ address _to
36
+ ) external returns (uint256 amountSD);
37
+ }
@@ -136,16 +136,13 @@ interface ISuperComposableYield is IERC20Metadata {
136
136
  */
137
137
  function yieldToken() external view returns (address);
138
138
 
139
- /**
140
- * @notice returns a list of all the base tokens that can be deposited to mint shares
141
- */
142
- function getBaseTokens() external view returns (address[] memory res);
139
+ function getTokensIn() external view returns (address[] memory res);
143
140
 
144
- /**
145
- * @notice checks whether a token is a valid base token
146
- * @notice returns a boolean indicating whether this is a valid token
147
- */
148
- function isValidBaseToken(address token) external view returns (bool);
141
+ function getTokensOut() external view returns (address[] memory res);
142
+
143
+ function isValidTokenIn(address token) external view returns (bool);
144
+
145
+ function isValidTokenOut(address token) external view returns (bool);
149
146
 
150
147
  function previewDeposit(address tokenIn, uint256 amountTokenToDeposit)
151
148
  external
@@ -0,0 +1,34 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+ pragma solidity 0.8.15;
24
+
25
+ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
26
+
27
+ interface IWAvax is IERC20 {
28
+ event Deposit(address indexed dst, uint256 wad);
29
+ event Withdrawal(address indexed src, uint256 wad);
30
+
31
+ function deposit() external payable;
32
+
33
+ function withdraw(uint256 wad) external;
34
+ }
@@ -5,9 +5,8 @@ import "./RewardManagerAbstract.sol";
5
5
  import "./math/Math.sol";
6
6
  import "../libraries/helpers/ArrayLib.sol";
7
7
 
8
- /// * This RewardManager can be used with any contracts, regardless of what tokens that contract stores
9
- /// since the RewardManager will maintain its own internal balance
10
- /// * Use with SCY + PendleMarket. For YT, it has its own native implementation for gas saving
8
+ /// NOTE: This RewardManager is used with PendleMarket & SCY. For YT, it will use RewardManagerAbstract
9
+ /// NOTE: RewardManager must not have duplicated rewardTokens
11
10
  abstract contract RewardManager is RewardManagerAbstract {
12
11
  using Math for uint256;
13
12
  using ArrayLib for uint256[];
@@ -4,6 +4,7 @@ import "../interfaces/IRewardManager.sol";
4
4
  import "./helpers/TokenHelper.sol";
5
5
  import "./math/Math.sol";
6
6
 
7
+ /// NOTE: RewardManager must not have duplicated rewardTokens
7
8
  abstract contract RewardManagerAbstract is IRewardManager, TokenHelper {
8
9
  using Math for uint256;
9
10
 
@@ -1,6 +1,8 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
  pragma solidity 0.8.15;
3
3
 
4
+ import "./math/Math.sol";
5
+
4
6
  struct VeBalance {
5
7
  uint128 bias;
6
8
  uint128 slope;
@@ -12,7 +14,9 @@ struct LockedPosition {
12
14
  }
13
15
 
14
16
  library VeBalanceLib {
17
+ using Math for uint256;
15
18
  uint128 internal constant MAX_LOCK_TIME = 104 weeks;
19
+ uint256 internal constant USER_VOTE_MAX_WEIGHT = 10**18;
16
20
 
17
21
  function add(VeBalance memory a, VeBalance memory b)
18
22
  internal
@@ -68,6 +72,15 @@ library VeBalanceLib {
68
72
  res.bias = res.slope * position.expiry;
69
73
  }
70
74
 
75
+ function convertToVeBalance(LockedPosition memory position, uint256 weight)
76
+ internal
77
+ pure
78
+ returns (VeBalance memory res)
79
+ {
80
+ res.slope = ((position.amount * weight) / MAX_LOCK_TIME / USER_VOTE_MAX_WEIGHT).Uint128();
81
+ res.bias = res.slope * position.expiry;
82
+ }
83
+
71
84
  function convertToVeBalance(uint128 amount, uint128 expiry)
72
85
  internal
73
86
  pure
@@ -2,23 +2,6 @@
2
2
  pragma solidity >=0.8.0;
3
3
 
4
4
  library ArrayLib {
5
- function padZeroRight(uint256[] memory input, uint256 length)
6
- internal
7
- pure
8
- returns (uint256[] memory)
9
- {
10
- uint256[] memory output = new uint256[](length);
11
- uint256 inputLength = input.length;
12
- for (uint8 i = 0; i < length; ) {
13
- if (i < inputLength) output[i] = input[i];
14
- else output[i] = 0;
15
- unchecked {
16
- i++;
17
- }
18
- }
19
- return output;
20
- }
21
-
22
5
  function sum(uint256[] memory input) internal pure returns (uint256) {
23
6
  uint256 value = 0;
24
7
  for (uint256 i = 0; i < input.length; ) {
@@ -0,0 +1,69 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.15;
3
+ import "../../interfaces/IPYieldToken.sol";
4
+ import "../../interfaces/IPPrincipalToken.sol";
5
+ import "../SCY/SCYUtils.sol";
6
+ import "../math/Math.sol";
7
+
8
+ type PYIndex is uint256;
9
+
10
+ library PYIndexLib {
11
+ using Math for uint256;
12
+ using Math for int256;
13
+
14
+ function newIndex(IPYieldToken YT) internal returns (PYIndex) {
15
+ return PYIndex.wrap(YT.pyIndexCurrent());
16
+ }
17
+
18
+ function scyToAsset(PYIndex index, uint256 scyAmount)
19
+ internal
20
+ pure
21
+ returns (uint256)
22
+ {
23
+ return SCYUtils.scyToAsset(PYIndex.unwrap(index), scyAmount);
24
+ }
25
+
26
+ function assetToScy(PYIndex index, uint256 assetAmount)
27
+ internal
28
+ pure
29
+ returns (uint256)
30
+ {
31
+ return SCYUtils.assetToScy(PYIndex.unwrap(index), assetAmount);
32
+ }
33
+
34
+ function assetToScyUp(PYIndex index, uint256 assetAmount)
35
+ internal
36
+ pure
37
+ returns (uint256)
38
+ {
39
+ return SCYUtils.assetToScyUp(PYIndex.unwrap(index), assetAmount);
40
+ }
41
+
42
+ function scyToAssetUp(PYIndex index, uint256 scyAmount)
43
+ internal
44
+ pure
45
+ returns (uint256)
46
+ {
47
+ uint256 _index = PYIndex.unwrap(index);
48
+ return SCYUtils.scyToAssetUp(_index, scyAmount);
49
+ }
50
+
51
+ function scyToAsset(PYIndex index, int256 scyAmount)
52
+ internal
53
+ pure
54
+ returns (int256)
55
+ {
56
+ int256 sign = scyAmount < 0 ? int256(-1) : int256(1);
57
+ return sign * (SCYUtils.scyToAsset(PYIndex.unwrap(index), scyAmount.abs())).Int();
58
+ }
59
+
60
+ function assetToScy(PYIndex index, int256 assetAmount)
61
+ internal
62
+ pure
63
+ returns (int256)
64
+ {
65
+ int256 sign = assetAmount < 0 ? int256(-1) : int256(1);
66
+ return sign * (SCYUtils.assetToScy(PYIndex.unwrap(index), assetAmount.abs())).Int();
67
+ }
68
+
69
+ }
@@ -12,8 +12,10 @@ abstract contract TokenHelper {
12
12
  address from,
13
13
  uint256 amount
14
14
  ) internal {
15
- if (amount == 0 || token == NATIVE) return;
16
- IERC20(token).safeTransferFrom(from, address(this), amount);
15
+ if (token == NATIVE) require(msg.value == amount, "eth mismatch");
16
+ else if (amount != 0) {
17
+ IERC20(token).safeTransferFrom(from, address(this), amount);
18
+ }
17
19
  }
18
20
 
19
21
  function _transferOut(
@@ -248,54 +248,56 @@ library LogExpMath {
248
248
  * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`.
249
249
  */
250
250
  function pow(uint256 x, uint256 y) internal pure returns (uint256) {
251
- if (y == 0) {
252
- // We solve the 0^0 indetermination by making it equal one.
253
- return uint256(ONE_18);
254
- }
251
+ unchecked {
252
+ if (y == 0) {
253
+ // We solve the 0^0 indetermination by making it equal one.
254
+ return uint256(ONE_18);
255
+ }
255
256
 
256
- if (x == 0) {
257
- return 0;
258
- }
257
+ if (x == 0) {
258
+ return 0;
259
+ }
259
260
 
260
- // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to
261
- // arrive at that r`esult. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means
262
- // x^y = exp(y * ln(x)).
263
-
264
- // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range.
265
- require(x < 2**255, "x out of bounds");
266
- int256 x_int256 = int256(x);
267
-
268
- // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36. In
269
- // both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end.
270
-
271
- // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit range.
272
- require(y < MILD_EXPONENT_BOUND, "y out of bounds");
273
- int256 y_int256 = int256(y);
274
-
275
- int256 logx_times_y;
276
- if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) {
277
- int256 ln_36_x = _ln_36(x_int256);
278
-
279
- // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't just
280
- // bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal
281
- // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the
282
- // (downscaled) last 18 decimals.
283
- logx_times_y = ((ln_36_x / ONE_18) *
284
- y_int256 +
285
- ((ln_36_x % ONE_18) * y_int256) /
286
- ONE_18);
287
- } else {
288
- logx_times_y = _ln(x_int256) * y_int256;
289
- }
290
- logx_times_y /= ONE_18;
261
+ // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to
262
+ // arrive at that r`esult. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means
263
+ // x^y = exp(y * ln(x)).
264
+
265
+ // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range.
266
+ require(x < 2**255, "x out of bounds");
267
+ int256 x_int256 = int256(x);
268
+
269
+ // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36. In
270
+ // both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end.
271
+
272
+ // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit range.
273
+ require(y < MILD_EXPONENT_BOUND, "y out of bounds");
274
+ int256 y_int256 = int256(y);
275
+
276
+ int256 logx_times_y;
277
+ if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) {
278
+ int256 ln_36_x = _ln_36(x_int256);
279
+
280
+ // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't just
281
+ // bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal
282
+ // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the
283
+ // (downscaled) last 18 decimals.
284
+ logx_times_y = ((ln_36_x / ONE_18) *
285
+ y_int256 +
286
+ ((ln_36_x % ONE_18) * y_int256) /
287
+ ONE_18);
288
+ } else {
289
+ logx_times_y = _ln(x_int256) * y_int256;
290
+ }
291
+ logx_times_y /= ONE_18;
291
292
 
292
- // Finally, we compute exp(y * ln(x)) to arrive at x^y
293
- require(
294
- MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT,
295
- "product out of bounds"
296
- );
293
+ // Finally, we compute exp(y * ln(x)) to arrive at x^y
294
+ require(
295
+ MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT,
296
+ "product out of bounds"
297
+ );
297
298
 
298
- return uint256(exp(logx_times_y));
299
+ return uint256(exp(logx_times_y));
300
+ }
299
301
  }
300
302
 
301
303
  /**
@@ -33,7 +33,7 @@ library MarketApproxLib {
33
33
  using Math for uint256;
34
34
  using Math for int256;
35
35
  using LogExpMath for int256;
36
- using SCYIndexLib for SCYIndex;
36
+ using PYIndexLib for PYIndex;
37
37
  using MarketMathCore for MarketState;
38
38
 
39
39
  struct VarsSwapPtForExactScy {
@@ -50,7 +50,7 @@ library MarketApproxLib {
50
50
 
51
51
  function approxSwapPtForExactScy(
52
52
  MarketState memory market,
53
- SCYIndex index,
53
+ PYIndex index,
54
54
  uint256 minScyOut,
55
55
  uint256 blockTime,
56
56
  ApproxParams memory approx
@@ -85,7 +85,7 @@ library MarketApproxLib {
85
85
 
86
86
  if (approx.guessMax == type(uint256).max) approx.guessMax = calcMaxPtIn(comp.totalAsset);
87
87
 
88
- vars.minAssetOut = index.scyToAsset(minScyOut);
88
+ vars.minAssetOut = index.scyToAssetUp(minScyOut);
89
89
 
90
90
  for (uint256 iter = 0; iter < approx.maxIteration; ) {
91
91
  vars.netPtInGuess = getCurrentGuess(iter, approx);
@@ -145,7 +145,7 @@ library MarketApproxLib {
145
145
  /// `guessMin` & `guessMax` is to guess the `netPtIn` == `netYtOut`
146
146
  function approxSwapExactScyForYt(
147
147
  MarketState memory market,
148
- SCYIndex index,
148
+ PYIndex index,
149
149
  uint256 maxScyIn,
150
150
  uint256 blockTime,
151
151
  ApproxParams memory approx
@@ -155,7 +155,7 @@ library MarketApproxLib {
155
155
  returns (
156
156
  uint256, /*netYtOut*/
157
157
  uint256, /*netScyIn*/
158
- uint256
158
+ uint256 /*netScyToReserve*/
159
159
  )
160
160
  {
161
161
  /*
@@ -244,7 +244,7 @@ library MarketApproxLib {
244
244
 
245
245
  function approxSwapExactScyForPt(
246
246
  MarketState memory market,
247
- SCYIndex index,
247
+ PYIndex index,
248
248
  uint256 maxScyIn,
249
249
  uint256 blockTime,
250
250
  ApproxParams memory approx
@@ -254,7 +254,7 @@ library MarketApproxLib {
254
254
  returns (
255
255
  uint256, /*netPtOut*/
256
256
  uint256, /*netScyIn*/
257
- uint256
257
+ uint256 /*netScyToReserve*/
258
258
  )
259
259
  {
260
260
  /*
@@ -326,7 +326,7 @@ library MarketApproxLib {
326
326
 
327
327
  function approxSwapYtForExactScy(
328
328
  MarketState memory market,
329
- SCYIndex index,
329
+ PYIndex index,
330
330
  uint256 minScyOut,
331
331
  uint256 blockTime,
332
332
  ApproxParams memory approx
@@ -336,7 +336,7 @@ library MarketApproxLib {
336
336
  returns (
337
337
  uint256, /*netYtIn*/
338
338
  uint256, /*netScyOut*/
339
- uint256
339
+ uint256 /*netScyToReserve*/
340
340
  )
341
341
  {
342
342
  /*
@@ -448,9 +448,7 @@ library MarketApproxLib {
448
448
  pure
449
449
  returns (uint256)
450
450
  {
451
- int256 logitP = (Math.IONE.mulDown(comp.feeRate) - comp.rateAnchor)
452
- .mulDown(comp.rateScalar)
453
- .exp();
451
+ int256 logitP = (comp.feeRate - comp.rateAnchor).mulDown(comp.rateScalar).exp();
454
452
  int256 proportion = logitP.divDown(logitP + Math.IONE);
455
453
  int256 numerator = proportion.mulDown(totalPt + comp.totalAsset);
456
454
  int256 maxPtOut = totalPt - numerator;