@pendle/core-v2 0.17.8-testnet → 0.19.0-testnet

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
  2. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
  3. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
  4. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
  5. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +2 -2
  6. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
  7. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  8. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  9. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
  10. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  11. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
  12. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +4 -0
  13. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +560 -0
  14. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  15. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
  16. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  17. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  18. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
  19. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  20. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
  21. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  22. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  23. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  24. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  25. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
  26. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  27. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  28. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
  29. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +2 -2
  30. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
  31. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +2 -2
  32. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
  33. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
  34. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  35. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
  36. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  37. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
  38. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  39. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  40. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
  41. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  42. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +2 -2
  43. package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
  44. package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  46. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +4 -0
  48. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.json +934 -0
  49. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  50. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
  51. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  52. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
  53. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
  54. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +2 -2
  55. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +2 -2
  57. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
  59. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +2 -2
  60. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  61. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -2
  62. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  63. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +2 -2
  64. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  65. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
  66. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  67. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
  68. package/build/artifacts/contracts/core/libraries/ArrayLib.sol/ArrayLib.dbg.json +1 -1
  69. package/build/artifacts/contracts/core/libraries/ArrayLib.sol/ArrayLib.json +2 -2
  70. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  71. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +86 -5
  72. package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.dbg.json +1 -1
  73. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  74. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  75. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  76. package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
  77. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  78. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  79. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
  80. package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +1 -1
  81. package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.json +24 -32
  82. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  83. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  84. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  85. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
  86. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +2 -2
  87. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
  88. package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +42 -2
  89. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
  90. package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +73 -100
  91. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  92. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +2 -2
  93. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
  94. package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
  95. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  96. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +2 -2
  97. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
  98. package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
  99. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  100. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +2 -2
  101. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
  102. package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
  103. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  104. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +2 -2
  105. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  106. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -2
  107. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  108. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  109. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  110. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  111. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  112. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
  113. package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -2
  114. package/build/artifacts/contracts/router/kyberswap/IMultihopRouterEthereum.sol/IMultihopRouterEthereum.dbg.json +4 -0
  115. package/build/artifacts/contracts/router/kyberswap/{IMultihopRouter.sol/IMultihopRouter.json → IMultihopRouterEthereum.sol/IMultihopRouterEthereum.json} +3 -3
  116. package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
  117. package/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol +214 -0
  118. package/contracts/core/BulkSeller/BulkSeller.sol +1 -1
  119. package/contracts/core/StandardizedYield/implementations/Ape/{PendleApeStakingSY.sol → sAPE.sol} +43 -30
  120. package/contracts/core/libraries/ArrayLib.sol +9 -0
  121. package/contracts/core/libraries/Errors.sol +9 -2
  122. package/contracts/interfaces/IPFeeDistributor.sol +10 -10
  123. package/contracts/offchain-helpers/MarketMathStatic.sol +30 -55
  124. package/contracts/offchain-helpers/RouterStatic.sol +30 -52
  125. package/contracts/router/kyberswap/AggregationRouterHelper.sol +37 -23
  126. package/contracts/router/kyberswap/{IMultihopRouter.sol → IMultihopRouterEthereum.sol} +11 -9
  127. package/deployments/1-markets/APE-JUNE-29.json +8 -0
  128. package/deployments/43113-core.json +9 -3
  129. package/deployments/80001-core.json +28 -0
  130. package/deployments/80001-markets/USDC-FEB-4TH.json +10 -0
  131. package/deployments/80001-markets/WETH-FEB-4TH.json +11 -0
  132. package/deployments/80001-testenv.json +22 -0
  133. package/package.json +1 -1
  134. package/typechain-types/BribeDistributor.ts +363 -0
  135. package/typechain-types/DistributorBase.ts +363 -0
  136. package/typechain-types/FeeDistributor.ts +416 -0
  137. package/typechain-types/IMultihopRouterEthereum.ts +209 -0
  138. package/typechain-types/IPFeeDistributor.ts +43 -78
  139. package/typechain-types/IPFeeDistributorFactory.ts +53 -139
  140. package/typechain-types/MarketMathStatic.ts +49 -0
  141. package/typechain-types/PendleFeeDistributor.ts +373 -118
  142. package/typechain-types/RouterStatic.ts +0 -49
  143. package/typechain-types/SAPE.ts +1191 -0
  144. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
  145. package/typechain-types/factories/ActionCallback__factory.ts +1 -1
  146. package/typechain-types/factories/ActionMintRedeem__factory.ts +1 -1
  147. package/typechain-types/factories/ActionMisc__factory.ts +1 -1
  148. package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
  149. package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
  150. package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
  151. package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -1
  152. package/typechain-types/factories/BribeDistributor__factory.ts +303 -0
  153. package/typechain-types/factories/BulkSellerFactory__factory.ts +1 -1
  154. package/typechain-types/factories/BulkSellerOffchain__factory.ts +1 -1
  155. package/typechain-types/factories/BulkSeller__factory.ts +1 -1
  156. package/typechain-types/factories/DistributorBase__factory.ts +249 -0
  157. package/typechain-types/factories/Errors__factory.ts +85 -4
  158. package/typechain-types/factories/FeeDistributor__factory.ts +339 -0
  159. package/typechain-types/factories/IMultihopRouterEthereum__factory.ts +155 -0
  160. package/typechain-types/factories/IPFeeDistributorFactory__factory.ts +25 -34
  161. package/typechain-types/factories/IPFeeDistributor__factory.ts +24 -32
  162. package/typechain-types/factories/MarketMathStatic__factory.ts +41 -1
  163. package/typechain-types/factories/OracleLib__factory.ts +1 -1
  164. package/typechain-types/factories/PendleApeStakingSY__factory.ts +1 -1
  165. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -1
  166. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -1
  167. package/typechain-types/factories/PendleFeeDistributor__factory.ts +310 -67
  168. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
  169. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
  170. package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1 -1
  171. package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
  172. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  173. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
  174. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
  175. package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
  176. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  177. package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
  178. package/typechain-types/factories/PendleRouter__factory.ts +1 -1
  179. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
  180. package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
  181. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
  182. package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
  183. package/typechain-types/factories/RouterStatic__factory.ts +18 -41
  184. package/typechain-types/factories/SAPE__factory.ts +1001 -0
  185. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
  186. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
  187. package/typechain-types/hardhat.d.ts +22 -40
  188. package/typechain-types/index.ts +6 -10
  189. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +0 -4
  190. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.json +0 -131
  191. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +0 -4
  192. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +0 -310
  193. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +0 -4
  194. package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +0 -389
  195. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/PendleApeStakingSY.sol/PendleApeStakingSY.dbg.json +0 -4
  196. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/PendleApeStakingSY.sol/PendleApeStakingSY.json +0 -908
  197. package/build/artifacts/contracts/interfaces/IPFeeDistributorFactory.sol/IPFeeDistributorFactory.dbg.json +0 -4
  198. package/build/artifacts/contracts/interfaces/IPFeeDistributorFactory.sol/IPFeeDistributorFactory.json +0 -76
  199. package/build/artifacts/contracts/router/kyberswap/IMultihopRouter.sol/IMultihopRouter.dbg.json +0 -4
  200. package/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol +0 -159
  201. package/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol +0 -99
  202. package/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol +0 -70
  203. package/contracts/interfaces/IPFeeDistributorFactory.sol +0 -14
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d69e41af484ea90333c32629bab9bd77.json"
4
- }
@@ -1,76 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "IPFeeDistributorFactory",
4
- "sourceName": "contracts/interfaces/IPFeeDistributorFactory.sol",
5
- "abi": [
6
- {
7
- "inputs": [
8
- {
9
- "internalType": "address",
10
- "name": "user",
11
- "type": "address"
12
- },
13
- {
14
- "internalType": "address",
15
- "name": "pool",
16
- "type": "address"
17
- },
18
- {
19
- "internalType": "uint256",
20
- "name": "epoch",
21
- "type": "uint256"
22
- }
23
- ],
24
- "name": "getUserAndTotalSharesAt",
25
- "outputs": [
26
- {
27
- "internalType": "uint256",
28
- "name": "userShare",
29
- "type": "uint256"
30
- },
31
- {
32
- "internalType": "uint256",
33
- "name": "totalShare",
34
- "type": "uint256"
35
- }
36
- ],
37
- "stateMutability": "view",
38
- "type": "function"
39
- },
40
- {
41
- "inputs": [],
42
- "name": "lastFinishedEpoch",
43
- "outputs": [
44
- {
45
- "internalType": "uint256",
46
- "name": "",
47
- "type": "uint256"
48
- }
49
- ],
50
- "stateMutability": "nonpayable",
51
- "type": "function"
52
- },
53
- {
54
- "inputs": [
55
- {
56
- "internalType": "address",
57
- "name": "user",
58
- "type": "address"
59
- },
60
- {
61
- "internalType": "address",
62
- "name": "pool",
63
- "type": "address"
64
- }
65
- ],
66
- "name": "updateUserShare",
67
- "outputs": [],
68
- "stateMutability": "nonpayable",
69
- "type": "function"
70
- }
71
- ],
72
- "bytecode": "0x",
73
- "deployedBytecode": "0x",
74
- "linkReferences": {},
75
- "deployedLinkReferences": {}
76
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/a621fb3f7b594e543562ee2e030c795c.json"
4
- }
@@ -1,159 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
3
-
4
- import "./PendleFeeDistributor.sol";
5
- import "../../interfaces/IPVotingEscrowMainchain.sol";
6
- import "../../interfaces/IPVotingController.sol";
7
- import "../../interfaces/IPFeeDistributorFactory.sol";
8
- import "../../core/libraries/BoringOwnableUpgradeable.sol";
9
- import "../libraries/VeHistoryLib.sol";
10
- import "../libraries/WeekMath.sol";
11
-
12
- abstract contract EpochResultManager is IPFeeDistributorFactory {
13
- using Math for uint256;
14
- using ArrayLib for address[];
15
- using VeBalanceLib for VeBalance;
16
- using CheckpointHelper for Checkpoint;
17
-
18
- struct UserInfo {
19
- uint128 timestamp;
20
- uint128 iter;
21
- }
22
-
23
- address public immutable votingController;
24
- address public immutable vePendle;
25
-
26
- // [user, pool] => UserInfo
27
- mapping(address => mapping(address => UserInfo)) public userInfo;
28
-
29
- // [user, pool, epoch] => share
30
- mapping(address => mapping(address => mapping(uint256 => uint256))) internal userShareAtEpoch;
31
-
32
- constructor(address _votingController, address _vePendle) {
33
- votingController = _votingController;
34
- vePendle = _vePendle;
35
- }
36
-
37
- function updateUserShare(address user, address pool) external {
38
- _updateExternalGlobalShares(pool);
39
- _updateUserShare(user, pool);
40
- }
41
-
42
- function getUserAndTotalSharesAt(
43
- address user,
44
- address pool,
45
- uint256 epoch
46
- ) external view returns (uint256 userShare, uint256 totalShare) {
47
- userShare = userShareAtEpoch[user][pool][epoch];
48
- totalShare = _getExternalTotalShares(pool, epoch.Uint128());
49
- }
50
-
51
- function _updateUserShare(address user, address pool) internal {
52
- uint128 currentEpoch = WeekMath.getCurrentWeekStart();
53
- uint128 userEpoch = userInfo[user][pool].timestamp;
54
-
55
- if (userEpoch == currentEpoch) return;
56
- if (userEpoch == 0) userEpoch = _getPoolStartTime(pool);
57
-
58
- uint256 length = _getExternalUserHistoryLength(user, pool);
59
- if (length == 0) {
60
- userInfo[user][pool].timestamp = currentEpoch;
61
- return;
62
- }
63
-
64
- uint128 iter = userInfo[user][pool].iter;
65
- Checkpoint memory lowerCheckpoint = _getExternalUserCheckpointAt(user, pool, iter);
66
- Checkpoint memory upperCheckpoint;
67
-
68
- if (iter + 1 < length) {
69
- upperCheckpoint = _getExternalUserCheckpointAt(user, pool, iter + 1);
70
- }
71
-
72
- while (userEpoch < currentEpoch) {
73
- userEpoch += WeekMath.WEEK;
74
-
75
- iter = _moveIterToNextEpoch(
76
- user,
77
- pool,
78
- length,
79
- iter,
80
- lowerCheckpoint,
81
- upperCheckpoint,
82
- userEpoch
83
- );
84
-
85
- if (userEpoch >= lowerCheckpoint.timestamp) {
86
- userShareAtEpoch[user][pool][userEpoch] = lowerCheckpoint.value.getValueAt(
87
- userEpoch
88
- );
89
- }
90
- }
91
-
92
- userInfo[user][pool] = UserInfo({ timestamp: currentEpoch, iter: iter });
93
- }
94
-
95
- function _moveIterToNextEpoch(
96
- address user,
97
- address pool,
98
- uint256 userHistoryLength,
99
- uint128 iter,
100
- Checkpoint memory lowerCheckpoint,
101
- Checkpoint memory upperCheckpoint,
102
- uint128 nextEpoch
103
- ) internal view returns (uint128) {
104
- while (iter + 1 < userHistoryLength && nextEpoch > upperCheckpoint.timestamp) {
105
- lowerCheckpoint.assignWith(upperCheckpoint);
106
- if (iter + 2 < userHistoryLength) {
107
- upperCheckpoint.assignWith(_getExternalUserCheckpointAt(user, pool, iter + 2));
108
- }
109
- ++iter;
110
- }
111
- return iter;
112
- }
113
-
114
- function _updateExternalGlobalShares(address pool) internal {
115
- if (pool == vePendle) {
116
- IPVeToken(vePendle).totalSupplyCurrent();
117
- } else {
118
- IPVotingController(votingController).applyPoolSlopeChanges(pool);
119
- }
120
- }
121
-
122
- function _getExternalTotalShares(address pool, uint128 timestamp)
123
- internal
124
- view
125
- returns (uint256)
126
- {
127
- if (pool == vePendle) {
128
- return IPVotingEscrowMainchain(vePendle).totalSupplyAt(timestamp);
129
- } else {
130
- return IPVotingController(votingController).getPoolTotalVoteAt(pool, timestamp);
131
- }
132
- }
133
-
134
- function _getExternalUserCheckpointAt(
135
- address user,
136
- address pool,
137
- uint256 index
138
- ) internal view returns (Checkpoint memory) {
139
- if (pool == vePendle) {
140
- return IPVotingEscrowMainchain(vePendle).getUserHistoryAt(user, index);
141
- } else {
142
- return IPVotingController(votingController).getUserPoolHistoryAt(user, pool, index);
143
- }
144
- }
145
-
146
- function _getExternalUserHistoryLength(address user, address pool)
147
- internal
148
- view
149
- returns (uint256)
150
- {
151
- if (pool == vePendle) {
152
- return IPVotingEscrowMainchain(vePendle).getUserHistoryLength(user);
153
- } else {
154
- return IPVotingController(votingController).getUserPoolHistoryLength(user, pool);
155
- }
156
- }
157
-
158
- function _getPoolStartTime(address pool) internal view virtual returns (uint64);
159
- }
@@ -1,99 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
3
-
4
- import "../../core/libraries/math/Math.sol";
5
- import "../../core/libraries/ArrayLib.sol";
6
- import "../../core/libraries/MiniHelpers.sol";
7
- import "../../core/libraries/Errors.sol";
8
- import "../../core/libraries/BoringOwnableUpgradeable.sol";
9
-
10
- import "../libraries/WeekMath.sol";
11
- import "../libraries/VeHistoryLib.sol";
12
-
13
- import "../../interfaces/IPFeeDistributor.sol";
14
- import "../../interfaces/IPFeeDistributorFactory.sol";
15
-
16
- import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
17
-
18
- contract PendleFeeDistributor is IPFeeDistributor, BoringOwnableUpgradeable {
19
- using Math for uint256;
20
- using SafeERC20 for IERC20;
21
- using ArrayLib for address[];
22
- using VeBalanceLib for VeBalance;
23
-
24
- address public immutable factory;
25
- address public immutable pool;
26
- address public immutable rewardToken;
27
- uint256 public immutable startEpoch;
28
-
29
- uint256 public lastFinishedEpoch;
30
-
31
- // [user] => [epoch]
32
- mapping(address => uint256) public userLastClaimedEpoch;
33
-
34
- // [epoch] => [incentive]
35
- mapping(uint256 => uint256) public incentivesForEpoch;
36
-
37
- constructor(
38
- address _pool,
39
- address _rewardToken,
40
- uint256 _startEpoch
41
- ) initializer {
42
- pool = _pool;
43
- factory = msg.sender;
44
- rewardToken = _rewardToken;
45
- startEpoch = _startEpoch;
46
- lastFinishedEpoch = _startEpoch;
47
- __BoringOwnable_init();
48
- }
49
-
50
- function fund(uint256[] calldata rewardsForEpoch) external onlyOwner {
51
- uint256 epoch = lastFinishedEpoch;
52
- uint256 totalRewardFunding = 0;
53
- for (uint256 i = 0; i < rewardsForEpoch.length; ++i) {
54
- epoch += WeekMath.WEEK;
55
- uint256 incentive = rewardsForEpoch[i];
56
-
57
- incentivesForEpoch[epoch] += incentive;
58
- totalRewardFunding += incentive;
59
-
60
- emit Fund(epoch, incentive);
61
- }
62
-
63
- if (epoch > WeekMath.getCurrentWeekStart()) revert Errors.FDCantFundFutureEpoch();
64
-
65
- IERC20(rewardToken).transferFrom(msg.sender, address(this), totalRewardFunding);
66
- lastFinishedEpoch = epoch;
67
- }
68
-
69
- function claimReward(address user) external returns (uint256 amountRewardOut) {
70
- IPFeeDistributorFactory(factory).updateUserShare(user, pool);
71
-
72
- uint256 finishedEpoch = lastFinishedEpoch;
73
- uint256 userEpoch = userLastClaimedEpoch[user];
74
-
75
- if (userEpoch == finishedEpoch) return 0;
76
- if (userEpoch == 0) userEpoch = startEpoch;
77
-
78
- while (userEpoch < finishedEpoch) {
79
- userEpoch += WeekMath.WEEK;
80
-
81
- uint256 incentive = incentivesForEpoch[userEpoch];
82
- if (incentive == 0) continue;
83
-
84
- (uint256 userShare, uint256 totalShare) = IPFeeDistributorFactory(factory)
85
- .getUserAndTotalSharesAt(user, pool, userEpoch);
86
-
87
- if (userShare == 0) continue;
88
-
89
- amountRewardOut += (userShare * incentive) / totalShare;
90
- }
91
-
92
- userLastClaimedEpoch[user] = finishedEpoch;
93
- if (amountRewardOut > 0) {
94
- IERC20(rewardToken).safeTransfer(user, amountRewardOut);
95
- }
96
-
97
- emit ClaimReward(user, rewardToken, finishedEpoch, amountRewardOut);
98
- }
99
- }
@@ -1,70 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
3
-
4
- import "./PendleFeeDistributor.sol";
5
- import "./EpochResultManager.sol";
6
-
7
- import "../../core/libraries/BaseSplitCodeFactory.sol";
8
-
9
- import "../../interfaces/IBoringOwnableUpgradeable.sol";
10
- import "../../interfaces/IPFeeDistributorFactory.sol";
11
-
12
- contract PendleFeeDistributorFactory is BoringOwnableUpgradeable, EpochResultManager {
13
- using Math for uint256;
14
-
15
- struct PoolInfo {
16
- address distributor;
17
- uint64 startTime;
18
- }
19
-
20
- address public immutable feeDistributorCreationCodeContractA;
21
- uint256 public immutable feeDistributorCreationCodeSizeA;
22
- address public immutable feeDistributorCreationCodeContractB;
23
- uint256 public immutable feeDistributorCreationCodeSizeB;
24
-
25
- address public immutable rewardToken;
26
- uint256 public lastFinishedEpoch;
27
- mapping(address => PoolInfo) public poolInfos;
28
-
29
- constructor(
30
- address _rewardToken,
31
- address _votingController,
32
- address _vePendle,
33
- address _feeDistributorCreationCodeContractA,
34
- uint256 _feeDistributorCreationCodeSizeA,
35
- address _feeDistributorCreationCodeContractB,
36
- uint256 _feeDistributorCreationCodeSizeB
37
- ) EpochResultManager(_votingController, _vePendle) initializer {
38
- __BoringOwnable_init();
39
- rewardToken = _rewardToken;
40
- feeDistributorCreationCodeContractA = _feeDistributorCreationCodeContractA;
41
- feeDistributorCreationCodeSizeA = _feeDistributorCreationCodeSizeA;
42
- feeDistributorCreationCodeContractB = _feeDistributorCreationCodeContractB;
43
- feeDistributorCreationCodeSizeB = _feeDistributorCreationCodeSizeB;
44
- }
45
-
46
- function createFeeDistributor(address pool, uint64 startTime)
47
- external
48
- onlyOwner
49
- returns (address distributor)
50
- {
51
- if (poolInfos[pool].distributor != address(0))
52
- revert Errors.FDFactoryDistributorAlreadyExisted(pool, poolInfos[pool].distributor);
53
-
54
- distributor = BaseSplitCodeFactory._create2(
55
- 0,
56
- bytes32(""),
57
- abi.encode(pool, rewardToken, uint256(startTime)),
58
- feeDistributorCreationCodeContractA,
59
- feeDistributorCreationCodeSizeA,
60
- feeDistributorCreationCodeContractB,
61
- feeDistributorCreationCodeSizeB
62
- );
63
- IBoringOwnableUpgradeable(distributor).transferOwnership(msg.sender, true, false);
64
- poolInfos[pool] = PoolInfo({ distributor: distributor, startTime: startTime });
65
- }
66
-
67
- function _getPoolStartTime(address pool) internal view virtual override returns (uint64) {
68
- return poolInfos[pool].startTime;
69
- }
70
- }
@@ -1,14 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity 0.8.17;
3
-
4
- interface IPFeeDistributorFactory {
5
- function lastFinishedEpoch() external returns (uint256);
6
-
7
- function updateUserShare(address user, address pool) external;
8
-
9
- function getUserAndTotalSharesAt(
10
- address user,
11
- address pool,
12
- uint256 epoch
13
- ) external view returns (uint256 userShare, uint256 totalShare);
14
- }