@pendle/core-v2 0.11.10-testnet → 0.12.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.
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.json +199 -30
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.dbg.json +4 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol/Pendle3CrvAndTokenSCY.json +1030 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.dbg.json +4 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol/PendleConvexCurveLP2PoolSCY.json +1025 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.dbg.json +4 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol/PendleConvexCurveLPSCY.json +948 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +4 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +76 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.json +140 -25
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.json +138 -23
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.json +138 -23
- package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +4 -0
- package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +310 -0
- package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +4 -0
- package/build/artifacts/contracts/core/LiquidityMining/{CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.json → CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.json} +18 -85
- package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +4 -0
- package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +336 -0
- package/build/artifacts/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +4 -0
- package/build/artifacts/contracts/core/LiquidityMining/{CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.json → CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.json} +8 -21
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +4 -0
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.json +131 -0
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +4 -0
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +297 -0
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +4 -0
- package/build/artifacts/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +376 -0
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +11 -0
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +29 -2
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +40 -86
- package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +228 -40
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.json +232 -12
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +164 -47
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +25 -93
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +222 -9
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +106 -5
- package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +4 -0
- package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.json +329 -0
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.json +13 -2
- package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +87 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +80 -16
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +164 -2
- package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +172 -4
- package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.json +109 -2
- package/build/artifacts/contracts/core/actions/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionMintRedeem.sol/ActionMintRedeem.json +62 -4
- package/build/artifacts/contracts/core/actions/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionMisc.sol/ActionMisc.json +7 -2
- package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionSwapPT.sol/ActionSwapPT.json +199 -4
- package/build/artifacts/contracts/core/actions/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionSwapPTYT.sol/ActionSwapPTYT.json +108 -2
- package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionSwapYT.sol/ActionSwapYT.json +146 -4
- package/build/artifacts/contracts/core/actions/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.json +177 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICrvDepositor.sol/ICrvDepositor.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICrvDepositor.sol/ICrvDepositor.json +78 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICvxCrv.sol/ICvxCrv.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICvxCrv.sol/ICvxCrv.json +24 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.json +264 -0
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +305 -0
- package/build/artifacts/contracts/interfaces/IBoringOwnableUpgradeable.sol/IBoringOwnableUpgradeable.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IBoringOwnableUpgradeable.sol/IBoringOwnableUpgradeable.json +34 -0
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +31 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +5 -0
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +30 -0
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.json +10 -0
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +30 -0
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +106 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.json +112 -0
- package/build/artifacts/contracts/interfaces/IPFeeDistributorFactory.sol/IPFeeDistributorFactory.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPFeeDistributorFactory.sol/IPFeeDistributorFactory.json +76 -0
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.json +13 -0
- package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.json +24 -0
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.json +63 -0
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.json +148 -0
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/{IPVotingEscrow.sol/IPVotingEscrow.json → IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.json} +88 -2
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.json +4 -28
- package/build/artifacts/contracts/libraries/Errors.sol/Errors.dbg.json +4 -0
- package/build/artifacts/contracts/libraries/Errors.sol/Errors.json +886 -0
- package/build/artifacts/contracts/libraries/OracleLib.sol/OracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/OracleLib.sol/OracleLib.json +28 -2
- package/build/artifacts/contracts/libraries/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +4 -0
- package/build/artifacts/contracts/libraries/{solmate/SSTORE2.sol/SSTORE2.json → VeHistoryLib.sol/CheckpointHelper.json} +4 -4
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +4 -0
- package/build/artifacts/contracts/libraries/helpers/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +45 -0
- package/build/artifacts/contracts/libraries/helpers/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +4 -0
- package/build/artifacts/contracts/libraries/helpers/{SSTORE2Deployer.sol/SSTORE2Deployer.json → BaseSplitCodeFactory.sol/CodeDeployer.json} +4 -4
- package/build/artifacts/contracts/libraries/helpers/PYIndex.sol/PYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/PYIndex.sol/PYIndexLib.json +2 -2
- package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -2
- package/build/artifacts/contracts/libraries/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.json +2 -2
- package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +167 -0
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +182 -4
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +126 -79
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol +3 -1
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol +19 -16
- package/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSCY.sol +135 -0
- package/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLP2PoolSCY.sol +96 -0
- package/contracts/SuperComposableYield/SCY-implementations/Convex/ConvexCurveLP/PendleConvexCurveLPSCY.sol +215 -0
- package/contracts/SuperComposableYield/SCY-implementations/Convex/Pendle3CrvHelper.sol +83 -0
- package/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol +10 -15
- package/contracts/SuperComposableYield/base-implementations/SCYBase.sol +30 -43
- package/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +74 -0
- package/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol +38 -0
- package/contracts/core/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +83 -0
- package/contracts/core/LiquidityMining/{CelerAbstracts/CelerSenderUpg.sol → CrossChainMsg/PendleMsgSenderAppUpg.sol} +12 -13
- package/contracts/core/LiquidityMining/FeeDistributor/EpochResultManager.sol +159 -0
- package/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol +96 -0
- package/contracts/core/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol +68 -0
- package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +4 -3
- package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol +6 -2
- package/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol +12 -4
- package/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +29 -19
- package/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +27 -19
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +63 -27
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +6 -5
- package/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +2 -2
- package/contracts/core/Market/PendleMarket.sol +26 -24
- package/contracts/core/Market/PendleMarketFactory.sol +41 -20
- package/contracts/core/PendleERC20Permit.sol +84 -0
- package/contracts/core/PendleRouter.sol +2 -1
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +8 -7
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +37 -22
- package/contracts/core/YieldContracts/PendleYieldToken.sol +106 -35
- package/contracts/core/actions/ActionAddRemoveLiq.sol +58 -41
- package/contracts/core/actions/ActionCallback.sol +24 -14
- package/contracts/core/actions/ActionMintRedeem.sol +14 -4
- package/contracts/core/actions/ActionMisc.sol +2 -1
- package/contracts/core/actions/ActionSwapPT.sol +38 -19
- package/contracts/core/actions/ActionSwapPTYT.sol +7 -6
- package/contracts/core/actions/ActionSwapYT.sol +36 -19
- package/contracts/core/actions/base/ActionBaseMintRedeem.sol +15 -8
- package/contracts/interfaces/ConvexCurve/IBooster.sol +32 -0
- package/contracts/interfaces/ConvexCurve/ICrvDepositor.sol +20 -0
- package/contracts/interfaces/ConvexCurve/ICvxCrv.sol +6 -0
- package/contracts/interfaces/ConvexCurve/IRewards.sol +38 -0
- package/contracts/interfaces/Curve/ICrvPool.sol +69 -0
- package/contracts/interfaces/IBoringOwnableUpgradeable.sol +10 -0
- package/contracts/interfaces/IPActionAddRemoveLiq.sol +7 -7
- package/contracts/interfaces/IPActionMintRedeem.sol +1 -0
- package/contracts/interfaces/IPActionSwapPT.sol +6 -6
- package/contracts/interfaces/IPActionSwapPTYT.sol +2 -2
- package/contracts/interfaces/IPActionSwapYT.sol +13 -13
- package/contracts/interfaces/IPFeeDistributor.sol +19 -0
- package/contracts/interfaces/IPFeeDistributorFactory.sol +14 -0
- package/contracts/interfaces/IPMarket.sol +2 -0
- package/contracts/interfaces/IPMsgReceiverApp.sol +7 -0
- package/contracts/interfaces/IPMsgSendEndpoint.sol +17 -0
- package/contracts/interfaces/IPVotingController.sol +22 -0
- package/contracts/interfaces/{IPVotingEscrow.sol → IPVotingEscrowMainchain.sol} +11 -1
- package/contracts/interfaces/ISuperComposableYield.sol +2 -7
- package/contracts/libraries/Errors.sol +121 -0
- package/contracts/libraries/OracleLib.sol +6 -3
- package/contracts/libraries/VeBalanceLib.sol +5 -1
- package/contracts/libraries/VeHistoryLib.sol +20 -31
- package/contracts/libraries/helpers/ArrayLib.sol +0 -17
- package/contracts/libraries/helpers/BaseSplitCodeFactory.sol +288 -0
- package/contracts/libraries/helpers/TokenHelper.sol +4 -0
- package/contracts/libraries/kyberswap/AggregationRouterHelper.sol +0 -7
- package/contracts/libraries/math/MarketMathCore.sol +29 -25
- package/contracts/libraries/math/Math.sol +6 -2
- package/contracts/libraries/math/WeekMath.sol +2 -2
- package/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol +43 -0
- package/contracts/offchain-helpers/MarketMathStatic.sol +36 -36
- package/contracts/offchain-helpers/RouterStatic.sol +45 -37
- package/deployments/43113-core.json +11 -10
- package/deployments/43113-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
- package/deployments/43113-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
- package/deployments/43113-testenv.json +9 -9
- package/deployments/80001-core.json +10 -9
- package/deployments/80001-markets/benqi-market-QI-USDC-FEB-2ND.json +8 -0
- package/deployments/80001-markets/benqi-market-QI-WETH-DEC-1ST.json +8 -0
- package/deployments/80001-testenv.json +16 -16
- package/package.json +1 -1
- package/typechain-types/ActionAddRemoveLiq.ts +18 -6
- package/typechain-types/ActionMintRedeem.ts +9 -2
- package/typechain-types/ActionSwapPT.ts +18 -6
- package/typechain-types/ActionSwapPTYT.ts +6 -2
- package/typechain-types/ActionSwapYT.ts +18 -6
- package/typechain-types/Errors.ts +57 -0
- package/typechain-types/ICrvPool.ts +137 -22
- package/typechain-types/IPActionAddRemoveLiq.ts +19 -7
- package/typechain-types/IPActionMintRedeem.ts +9 -2
- package/typechain-types/IPActionSwapPT.ts +18 -6
- package/typechain-types/IPActionSwapPTYT.ts +6 -2
- package/typechain-types/IPActionSwapYT.ts +18 -6
- package/typechain-types/IPAllAction.ts +70 -23
- package/typechain-types/IPBatchSeller.ts +252 -0
- package/typechain-types/IPMarket.ts +13 -0
- package/typechain-types/IPVotingController.ts +244 -7
- package/typechain-types/IPVotingEscrowMainchain.ts +461 -0
- package/typechain-types/IRewards.ts +25 -10
- package/typechain-types/ISuperComposableYield.ts +7 -46
- package/typechain-types/MarketMathStatic.ts +139 -10
- package/typechain-types/Pendle3CrvAndTokenSCY.ts +1215 -0
- package/typechain-types/Pendle3CrvTokenSCY.ts +85 -185
- package/typechain-types/PendleBatchSeller.ts +626 -0
- package/typechain-types/PendleConvexCurveLP2PoolSCY.ts +185 -220
- package/typechain-types/PendleConvexCurveLPSCY.ts +159 -182
- package/typechain-types/PendleCvxCRVSCY.ts +0 -34
- package/typechain-types/PendleGaugeControllerSidechainUpg.ts +28 -149
- package/typechain-types/PendleMarket.ts +104 -0
- package/typechain-types/PendleMarketFactory.ts +76 -13
- package/typechain-types/PendlePrincipalToken.ts +104 -0
- package/typechain-types/PendleQiTokenSCY.ts +111 -46
- package/typechain-types/PendleVotingControllerUpg.ts +133 -77
- package/typechain-types/PendleWstEthSCY.ts +111 -46
- package/typechain-types/PendleYieldContractFactory.ts +84 -21
- package/typechain-types/PendleYieldToken.ts +175 -0
- package/typechain-types/PtAMMArb.ts +587 -0
- package/typechain-types/RouterStatic.ts +99 -75
- package/typechain-types/SCYBase.ts +111 -46
- package/typechain-types/SCYBaseWithRewards.ts +111 -46
- package/typechain-types/VotingControllerStorageUpg.ts +246 -27
- package/typechain-types/VotingEscrowPendleMainchain.ts +81 -93
- package/typechain-types/VotingEscrowPendleSidechain.ts +26 -171
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +169 -1
- package/typechain-types/factories/ActionCallback__factory.ts +108 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +59 -1
- package/typechain-types/factories/ActionMisc__factory.ts +6 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +107 -1
- package/typechain-types/factories/ActionSwapPT__factory.ts +196 -1
- package/typechain-types/factories/ActionSwapYT__factory.ts +143 -1
- package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -1
- package/typechain-types/factories/Errors__factory.ts +933 -0
- package/typechain-types/factories/ICrvPool__factory.ts +85 -12
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +31 -1
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +5 -0
- package/typechain-types/factories/IPActionSwapPTYT__factory.ts +10 -0
- package/typechain-types/factories/IPActionSwapPT__factory.ts +30 -0
- package/typechain-types/factories/IPActionSwapYT__factory.ts +30 -0
- package/typechain-types/factories/IPAllAction__factory.ts +106 -1
- package/typechain-types/factories/IPBatchSeller__factory.ts +138 -0
- package/typechain-types/factories/IPMarket__factory.ts +13 -0
- package/typechain-types/factories/IPVotingController__factory.ts +148 -0
- package/typechain-types/factories/IPVotingEscrowMainchain__factory.ts +340 -0
- package/typechain-types/factories/IRewards__factory.ts +14 -1
- package/typechain-types/factories/ISuperComposableYield__factory.ts +4 -28
- package/typechain-types/factories/MarketMathStatic__factory.ts +181 -3
- package/typechain-types/factories/OracleLib__factory.ts +27 -1
- package/typechain-types/factories/Pendle3CrvAndTokenSCY__factory.ts +1130 -0
- package/typechain-types/factories/Pendle3CrvHelper__factory.ts +1 -1
- package/typechain-types/factories/Pendle3CrvTokenSCY__factory.ts +74 -128
- package/typechain-types/factories/PendleBatchSeller__factory.ts +558 -0
- package/typechain-types/factories/PendleConvexCurveLP2PoolSCY__factory.ts +207 -136
- package/typechain-types/factories/PendleConvexCurveLPSCY__factory.ts +170 -95
- package/typechain-types/factories/PendleCvxCRVSCY__factory.ts +1 -29
- package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +17 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +6 -1
- package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +11 -0
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +28 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +48 -86
- package/typechain-types/factories/PendleMarketFactory__factory.ts +129 -9
- package/typechain-types/factories/PendleMarket__factory.ts +214 -1
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +17 -1
- package/typechain-types/factories/PendleMsgReceiverAppUpg__factory.ts +11 -0
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +6 -1
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +86 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSCY__factory.ts +198 -29
- package/typechain-types/factories/PendleRouter__factory.ts +12 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +235 -40
- package/typechain-types/factories/PendleWstEthSCY__factory.ts +137 -22
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +103 -20
- package/typechain-types/factories/PendleYieldToken__factory.ts +163 -1
- package/typechain-types/factories/PtAMMArb__factory.ts +525 -0
- package/typechain-types/factories/RouterStatic__factory.ts +67 -20
- package/typechain-types/factories/SCYBaseWithRewards__factory.ts +136 -21
- package/typechain-types/factories/SCYBase__factory.ts +136 -21
- package/typechain-types/factories/VotingControllerStorageUpg__factory.ts +232 -12
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +171 -47
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +31 -93
- package/typechain-types/hardhat.d.ts +99 -0
- package/typechain-types/index.ts +22 -0
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.json +0 -810
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.json +0 -10
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol/PendleQiSAvaxSCY.json +0 -833
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol/PendleSAvaxSCY.json +0 -723
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol/PendleEulerSCY.json +0 -728
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.json +0 -705
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol/PendleStargateSCY.json +0 -864
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultSCY.sol/PendleYearnVaultSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultSCY.sol/PendleYearnVaultSCY.json +0 -718
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.dbg.json +0 -4
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol/PendleSJoeSCY.json +0 -784
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.dbg.json +0 -4
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.dbg.json +0 -4
- package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.dbg.json +0 -4
- package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +0 -4
- package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/SSTORE2DeployerContract.sol/SSTORE2DeployerContract.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/SSTORE2DeployerContract.sol/SSTORE2DeployerContract.json +0 -134
- package/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol +0 -161
- package/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol +0 -126
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiSAvaxSCY.sol +0 -242
- package/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleSAvaxSCY.sol +0 -146
- package/contracts/SuperComposableYield/SCY-implementations/Euler/PendleEulerSCY.sol +0 -176
- package/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol +0 -129
- package/contracts/SuperComposableYield/SCY-implementations/PendleStargateSCY.sol +0 -193
- package/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultSCY.sol +0 -155
- package/contracts/SuperComposableYield/SCY-implementations/TraderJoe/PendleSJoeSCY.sol +0 -182
- package/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol +0 -53
- package/contracts/libraries/helpers/SSTORE2Deployer.sol +0 -30
- package/contracts/libraries/solmate/SSTORE2.sol +0 -99
- package/contracts/offchain-helpers/SSTORE2DeployerContract.sol +0 -21
- package/deployments/43113-markets/benqi-market-10D931.json +0 -8
- package/deployments/43113-markets/benqi-market-9fbD64.json +0 -8
- package/deployments/43113-markets/benqi-market-A12361.json +0 -8
|
@@ -7,9 +7,10 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
|
|
|
7
7
|
import "../../libraries/math/Math.sol";
|
|
8
8
|
import "../../libraries/SCY/SCYUtils.sol";
|
|
9
9
|
import "../../libraries/helpers/TokenHelper.sol";
|
|
10
|
-
import "
|
|
10
|
+
import "../../libraries/Errors.sol";
|
|
11
|
+
import "../../../contracts/core/PendleERC20Permit.sol";
|
|
11
12
|
|
|
12
|
-
abstract contract SCYBase is ISuperComposableYield,
|
|
13
|
+
abstract contract SCYBase is ISuperComposableYield, PendleERC20Permit, TokenHelper {
|
|
13
14
|
using Math for uint256;
|
|
14
15
|
|
|
15
16
|
address public immutable yieldToken;
|
|
@@ -18,7 +19,7 @@ abstract contract SCYBase is ISuperComposableYield, PendleERC20, TokenHelper {
|
|
|
18
19
|
string memory _name,
|
|
19
20
|
string memory _symbol,
|
|
20
21
|
address _yieldToken
|
|
21
|
-
)
|
|
22
|
+
) PendleERC20Permit(_name, _symbol, IERC20Metadata(_yieldToken).decimals()) {
|
|
22
23
|
yieldToken = _yieldToken;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -38,14 +39,14 @@ abstract contract SCYBase is ISuperComposableYield, PendleERC20, TokenHelper {
|
|
|
38
39
|
uint256 amountTokenToDeposit,
|
|
39
40
|
uint256 minSharesOut
|
|
40
41
|
) external payable nonReentrant returns (uint256 amountSharesOut) {
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
if (!isValidTokenIn(tokenIn)) revert Errors.SCYInvalidTokenIn(tokenIn);
|
|
43
|
+
if (amountTokenToDeposit == 0) revert Errors.SCYZeroDeposit();
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
else _transferIn(tokenIn, msg.sender, amountTokenToDeposit);
|
|
45
|
+
_transferIn(tokenIn, msg.sender, amountTokenToDeposit);
|
|
46
46
|
|
|
47
47
|
amountSharesOut = _deposit(tokenIn, amountTokenToDeposit);
|
|
48
|
-
|
|
48
|
+
if (amountSharesOut < minSharesOut)
|
|
49
|
+
revert Errors.SCYInsufficientSharesOut(amountSharesOut, minSharesOut);
|
|
49
50
|
|
|
50
51
|
_mint(receiver, amountSharesOut);
|
|
51
52
|
emit Deposit(msg.sender, receiver, tokenIn, amountTokenToDeposit, amountSharesOut);
|
|
@@ -58,36 +59,21 @@ abstract contract SCYBase is ISuperComposableYield, PendleERC20, TokenHelper {
|
|
|
58
59
|
address receiver,
|
|
59
60
|
uint256 amountSharesToRedeem,
|
|
60
61
|
address tokenOut,
|
|
61
|
-
uint256 minTokenOut
|
|
62
|
+
uint256 minTokenOut,
|
|
63
|
+
bool burnFromInternalBalance
|
|
62
64
|
) external nonReentrant returns (uint256 amountTokenOut) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function _redeem(
|
|
78
|
-
address receiver,
|
|
79
|
-
uint256 amountSharesToRedeem,
|
|
80
|
-
address tokenOut,
|
|
81
|
-
uint256 minTokenOut
|
|
82
|
-
) internal returns (uint256 amountTokenOut) {
|
|
83
|
-
require(isValidTokenOut(tokenOut), "SCY: invalid tokenOut");
|
|
84
|
-
require(amountSharesToRedeem != 0, "SCY: amountSharesToRedeem cannot be 0");
|
|
85
|
-
|
|
86
|
-
amountTokenOut = _redeem(tokenOut, amountSharesToRedeem);
|
|
87
|
-
require(amountTokenOut >= minTokenOut, "SCY: insufficient out");
|
|
88
|
-
|
|
89
|
-
_transferOut(tokenOut, receiver, amountTokenOut);
|
|
90
|
-
|
|
65
|
+
if (!isValidTokenOut(tokenOut)) revert Errors.SCYInvalidTokenOut(tokenOut);
|
|
66
|
+
if (amountSharesToRedeem == 0) revert Errors.SCYZeroRedeem();
|
|
67
|
+
|
|
68
|
+
if (burnFromInternalBalance) {
|
|
69
|
+
_burn(address(this), amountSharesToRedeem);
|
|
70
|
+
} else {
|
|
71
|
+
_burn(msg.sender, amountSharesToRedeem);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
amountTokenOut = _redeem(receiver, tokenOut, amountSharesToRedeem);
|
|
75
|
+
if (amountTokenOut < minTokenOut)
|
|
76
|
+
revert Errors.SCYInsufficientTokenOut(amountTokenOut, minTokenOut);
|
|
91
77
|
emit Redeem(msg.sender, receiver, tokenOut, amountSharesToRedeem, amountTokenOut);
|
|
92
78
|
}
|
|
93
79
|
|
|
@@ -108,10 +94,11 @@ abstract contract SCYBase is ISuperComposableYield, PendleERC20, TokenHelper {
|
|
|
108
94
|
* @param amountSharesToRedeem amount of shares to be burned
|
|
109
95
|
* @return amountTokenOut amount of base tokens redeemed
|
|
110
96
|
*/
|
|
111
|
-
function _redeem(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
97
|
+
function _redeem(
|
|
98
|
+
address receiver,
|
|
99
|
+
address tokenOut,
|
|
100
|
+
uint256 amountSharesToRedeem
|
|
101
|
+
) internal virtual returns (uint256 amountTokenOut);
|
|
115
102
|
|
|
116
103
|
/*///////////////////////////////////////////////////////////////
|
|
117
104
|
EXCHANGE-RATE
|
|
@@ -181,7 +168,7 @@ abstract contract SCYBase is ISuperComposableYield, PendleERC20, TokenHelper {
|
|
|
181
168
|
virtual
|
|
182
169
|
returns (uint256 amountSharesOut)
|
|
183
170
|
{
|
|
184
|
-
|
|
171
|
+
if (!isValidTokenIn(tokenIn)) revert Errors.SCYInvalidTokenIn(tokenIn);
|
|
185
172
|
return _previewDeposit(tokenIn, amountTokenToDeposit);
|
|
186
173
|
}
|
|
187
174
|
|
|
@@ -191,7 +178,7 @@ abstract contract SCYBase is ISuperComposableYield, PendleERC20, TokenHelper {
|
|
|
191
178
|
virtual
|
|
192
179
|
returns (uint256 amountTokenOut)
|
|
193
180
|
{
|
|
194
|
-
|
|
181
|
+
if (!isValidTokenOut(tokenOut)) revert Errors.SCYInvalidTokenOut(tokenOut);
|
|
195
182
|
return _previewRedeem(tokenOut, amountSharesToRedeem);
|
|
196
183
|
}
|
|
197
184
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.15;
|
|
3
|
+
|
|
4
|
+
import "../../../interfaces/ICelerMessageReceiverApp.sol";
|
|
5
|
+
import "../../../interfaces/IPMsgReceiverApp.sol";
|
|
6
|
+
import "../../../interfaces/ICelerMessageBus.sol";
|
|
7
|
+
import "../../../periphery/BoringOwnableUpgradeable.sol";
|
|
8
|
+
import "../../../libraries/Errors.sol";
|
|
9
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
10
|
+
|
|
11
|
+
contract PendleMsgReceiveEndpointUpg is
|
|
12
|
+
ICelerMessageReceiverApp,
|
|
13
|
+
Initializable,
|
|
14
|
+
UUPSUpgradeable,
|
|
15
|
+
BoringOwnableUpgradeable
|
|
16
|
+
{
|
|
17
|
+
ICelerMessageBus public immutable celerMessageBus;
|
|
18
|
+
address public immutable sendEndpointAddr;
|
|
19
|
+
uint64 public immutable sendEndpointChainId;
|
|
20
|
+
|
|
21
|
+
modifier onlyCelerMessageBus() {
|
|
22
|
+
if (msg.sender != address(celerMessageBus)) revert Errors.OnlyCelerBus();
|
|
23
|
+
_;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
modifier mustOriginateFromSendEndpoint(address srcAddress, uint64 srcChainId) {
|
|
27
|
+
if (srcAddress != sendEndpointAddr || srcChainId != sendEndpointChainId)
|
|
28
|
+
revert Errors.MsgNotFromSendEndpoint(msg.sender);
|
|
29
|
+
_;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor(
|
|
33
|
+
ICelerMessageBus _celerMessageBus,
|
|
34
|
+
address _sendEndpointAddr,
|
|
35
|
+
uint64 _sendEndpointChainId
|
|
36
|
+
) initializer {
|
|
37
|
+
celerMessageBus = _celerMessageBus;
|
|
38
|
+
sendEndpointAddr = _sendEndpointAddr;
|
|
39
|
+
sendEndpointChainId = _sendEndpointChainId;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function initialize() external initializer {
|
|
43
|
+
__BoringOwnable_init();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// @notice for Celer
|
|
47
|
+
function executeMessage(
|
|
48
|
+
address srcAddress,
|
|
49
|
+
uint64 srcChainId,
|
|
50
|
+
bytes calldata message,
|
|
51
|
+
address /*_executor*/
|
|
52
|
+
)
|
|
53
|
+
external
|
|
54
|
+
payable
|
|
55
|
+
onlyCelerMessageBus
|
|
56
|
+
mustOriginateFromSendEndpoint(srcAddress, srcChainId)
|
|
57
|
+
returns (ExecutionStatus)
|
|
58
|
+
{
|
|
59
|
+
(address receiver, bytes memory actualMessage) = abi.decode(message, (address, bytes));
|
|
60
|
+
IPMsgReceiverApp(receiver).executeMessage(actualMessage);
|
|
61
|
+
return ExecutionStatus.Success;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function govExecuteMessage(address receiver, bytes calldata message)
|
|
65
|
+
external
|
|
66
|
+
payable
|
|
67
|
+
onlyOwner
|
|
68
|
+
{
|
|
69
|
+
IPMsgReceiverApp(receiver).executeMessage(message);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//solhint-disable-next-line
|
|
73
|
+
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
|
|
74
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.15;
|
|
3
|
+
|
|
4
|
+
import "../../../interfaces/IPMsgReceiverApp.sol";
|
|
5
|
+
import "../../../periphery/BoringOwnableUpgradeable.sol";
|
|
6
|
+
import "../../../libraries/Errors.sol";
|
|
7
|
+
|
|
8
|
+
// solhint-disable no-empty-blocks
|
|
9
|
+
/// This contract is upgradable because
|
|
10
|
+
/// - its constructor only sets immutable variables
|
|
11
|
+
/// - it has storage gaps for safe addition of future variables
|
|
12
|
+
/// - it inherits only upgradable contract
|
|
13
|
+
abstract contract PendleMsgReceiverAppUpg is IPMsgReceiverApp, BoringOwnableUpgradeable {
|
|
14
|
+
address public immutable pendleMsgReceiveEndpoint;
|
|
15
|
+
|
|
16
|
+
uint256[100] private __gap;
|
|
17
|
+
|
|
18
|
+
modifier onlyFromPendleMsgReceiveEndpoint() {
|
|
19
|
+
if (msg.sender != pendleMsgReceiveEndpoint)
|
|
20
|
+
revert Errors.MsgNotFromReceiveEndpoint(msg.sender);
|
|
21
|
+
_;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor(address _pendleMsgReceiveEndpoint) {
|
|
25
|
+
pendleMsgReceiveEndpoint = _pendleMsgReceiveEndpoint;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function executeMessage(bytes calldata message)
|
|
29
|
+
external
|
|
30
|
+
payable
|
|
31
|
+
virtual
|
|
32
|
+
onlyFromPendleMsgReceiveEndpoint
|
|
33
|
+
{
|
|
34
|
+
_executeMessage(message);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _executeMessage(bytes memory message) internal virtual;
|
|
38
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.15;
|
|
3
|
+
|
|
4
|
+
import "../../../interfaces/IPMsgSendEndpoint.sol";
|
|
5
|
+
import "../../../interfaces/ICelerMessageBus.sol";
|
|
6
|
+
import "../../../periphery/BoringOwnableUpgradeable.sol";
|
|
7
|
+
import "../../../libraries/Errors.sol";
|
|
8
|
+
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
|
|
9
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
10
|
+
|
|
11
|
+
contract PendleMsgSendEndpointUpg is
|
|
12
|
+
IPMsgSendEndpoint,
|
|
13
|
+
Initializable,
|
|
14
|
+
UUPSUpgradeable,
|
|
15
|
+
BoringOwnableUpgradeable
|
|
16
|
+
{
|
|
17
|
+
using EnumerableMap for EnumerableMap.UintToAddressMap;
|
|
18
|
+
|
|
19
|
+
ICelerMessageBus public immutable celerMessageBus;
|
|
20
|
+
EnumerableMap.UintToAddressMap internal receiveEndpoints;
|
|
21
|
+
mapping(address => bool) public isWhitelisted;
|
|
22
|
+
|
|
23
|
+
modifier onlyWhitelisted() {
|
|
24
|
+
if (!isWhitelisted[msg.sender]) revert Errors.OnlyWhitelisted();
|
|
25
|
+
_;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor(ICelerMessageBus _celerMessageBus) initializer {
|
|
29
|
+
celerMessageBus = _celerMessageBus;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function initialize() external initializer {
|
|
33
|
+
__BoringOwnable_init();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function calcFee(
|
|
37
|
+
address dstAddress,
|
|
38
|
+
uint256, /*dstChainId*/
|
|
39
|
+
bytes memory message
|
|
40
|
+
) external view returns (uint256) {
|
|
41
|
+
return celerMessageBus.calcFee(abi.encode(dstAddress, message));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function sendMessage(
|
|
45
|
+
address dstAddress,
|
|
46
|
+
uint256 dstChainId,
|
|
47
|
+
bytes calldata message
|
|
48
|
+
) external payable onlyWhitelisted {
|
|
49
|
+
celerMessageBus.sendMessage{ value: msg.value }(
|
|
50
|
+
receiveEndpoints.get(dstChainId),
|
|
51
|
+
dstChainId,
|
|
52
|
+
abi.encode(dstAddress, message)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function addReceiveEndpoints(address endpointAddr, uint256 endpointChainId)
|
|
57
|
+
external
|
|
58
|
+
payable
|
|
59
|
+
onlyOwner
|
|
60
|
+
{
|
|
61
|
+
receiveEndpoints.set(endpointChainId, endpointAddr);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function setWhitelisted(address addr, bool status) external onlyOwner {
|
|
65
|
+
isWhitelisted[addr] = status;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getAllReceiveEndpoints()
|
|
69
|
+
external
|
|
70
|
+
view
|
|
71
|
+
returns (uint256[] memory chainIds, address[] memory addrs)
|
|
72
|
+
{
|
|
73
|
+
uint256 length = receiveEndpoints.length();
|
|
74
|
+
chainIds = new uint256[](length);
|
|
75
|
+
addrs = new address[](length);
|
|
76
|
+
|
|
77
|
+
for (uint256 i = 0; i < length; ++i) {
|
|
78
|
+
(chainIds[i], addrs[i]) = receiveEndpoints.at(i);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
|
|
83
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity 0.8.15;
|
|
3
3
|
|
|
4
|
-
import "../../../interfaces/
|
|
4
|
+
import "../../../interfaces/IPMsgSendEndpoint.sol";
|
|
5
5
|
import "../../../periphery/BoringOwnableUpgradeable.sol";
|
|
6
|
-
import "
|
|
6
|
+
import "../../../libraries/Errors.sol";
|
|
7
7
|
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
|
|
8
8
|
|
|
9
9
|
// solhint-disable no-empty-blocks
|
|
@@ -11,10 +11,10 @@ import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
|
|
|
11
11
|
/// - its constructor only sets immutable variables
|
|
12
12
|
/// - it has storage gaps for safe addition of future variables
|
|
13
13
|
/// - it inherits only upgradable contract
|
|
14
|
-
abstract contract
|
|
14
|
+
abstract contract PendleMsgSenderAppUpg is BoringOwnableUpgradeable {
|
|
15
15
|
using EnumerableMap for EnumerableMap.UintToAddressMap;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
IPMsgSendEndpoint public immutable pendleMsgSendEndpoint;
|
|
18
18
|
|
|
19
19
|
// destinationContracts mapping contains one address for each chainId only
|
|
20
20
|
EnumerableMap.UintToAddressMap internal destinationContracts;
|
|
@@ -28,23 +28,20 @@ abstract contract CelerSenderUpg is BoringOwnableUpgradeable {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
constructor() {
|
|
32
|
-
|
|
33
|
-
function setCelerMessageBus(address _celerMessageBus) external onlyOwner {
|
|
34
|
-
celerMessageBus = ICelerMessageBus(_celerMessageBus);
|
|
31
|
+
constructor(address _pendleMsgSendEndpoint) {
|
|
32
|
+
pendleMsgSendEndpoint = IPMsgSendEndpoint(_pendleMsgSendEndpoint);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
function _sendMessage(uint256 chainId, bytes memory message) internal {
|
|
38
36
|
assert(destinationContracts.contains(chainId));
|
|
39
37
|
address toAddr = destinationContracts.get(chainId);
|
|
40
|
-
uint256 fee =
|
|
38
|
+
uint256 fee = pendleMsgSendEndpoint.calcFee(toAddr, chainId, message);
|
|
41
39
|
// LM contracts won't hold ETH on its own so this is fine
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
if (address(this).balance < fee)
|
|
41
|
+
revert Errors.InsufficientFeeToSendMsg(address(this).balance, fee);
|
|
42
|
+
pendleMsgSendEndpoint.sendMessage{ value: fee }(toAddr, chainId, message);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
function _afterAddDestinationContract(address addr, uint256 chainId) internal virtual {}
|
|
47
|
-
|
|
48
45
|
function addDestinationContract(address _address, uint256 _chainId)
|
|
49
46
|
external
|
|
50
47
|
payable
|
|
@@ -67,4 +64,6 @@ abstract contract CelerSenderUpg is BoringOwnableUpgradeable {
|
|
|
67
64
|
(chainIds[i], addrs[i]) = destinationContracts.at(i);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
67
|
+
|
|
68
|
+
function _afterAddDestinationContract(address addr, uint256 chainId) internal virtual {}
|
|
70
69
|
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.15;
|
|
3
|
+
|
|
4
|
+
import "./PendleFeeDistributor.sol";
|
|
5
|
+
import "../../../interfaces/IPVotingEscrowMainchain.sol";
|
|
6
|
+
import "../../../interfaces/IPVotingController.sol";
|
|
7
|
+
import "../../../interfaces/IPFeeDistributorFactory.sol";
|
|
8
|
+
import "../../../periphery/BoringOwnableUpgradeable.sol";
|
|
9
|
+
import "../../../libraries/VeHistoryLib.sol";
|
|
10
|
+
import "../../../libraries/math/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
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.15;
|
|
3
|
+
|
|
4
|
+
import "../../../libraries/math/Math.sol";
|
|
5
|
+
import "../../../libraries/helpers/ArrayLib.sol";
|
|
6
|
+
import "../../../libraries/helpers/MiniHelpers.sol";
|
|
7
|
+
import "../../../libraries/math/WeekMath.sol";
|
|
8
|
+
import "../../../libraries/Errors.sol";
|
|
9
|
+
import "../../../libraries/VeHistoryLib.sol";
|
|
10
|
+
import "../../../interfaces/IPFeeDistributor.sol";
|
|
11
|
+
import "../../../interfaces/IPFeeDistributorFactory.sol";
|
|
12
|
+
import "../../../periphery/BoringOwnableUpgradeable.sol";
|
|
13
|
+
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
14
|
+
|
|
15
|
+
contract PendleFeeDistributor is IPFeeDistributor, BoringOwnableUpgradeable {
|
|
16
|
+
using Math for uint256;
|
|
17
|
+
using SafeERC20 for IERC20;
|
|
18
|
+
using ArrayLib for address[];
|
|
19
|
+
using VeBalanceLib for VeBalance;
|
|
20
|
+
|
|
21
|
+
address public immutable factory;
|
|
22
|
+
address public immutable pool;
|
|
23
|
+
address public immutable rewardToken;
|
|
24
|
+
uint256 public immutable startEpoch;
|
|
25
|
+
|
|
26
|
+
uint256 public lastFinishedEpoch;
|
|
27
|
+
|
|
28
|
+
// [user] => [epoch]
|
|
29
|
+
mapping(address => uint256) public userLastClaimedEpoch;
|
|
30
|
+
|
|
31
|
+
// [epoch] => [incentive]
|
|
32
|
+
mapping(uint256 => uint256) public incentivesForEpoch;
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
address _pool,
|
|
36
|
+
address _rewardToken,
|
|
37
|
+
uint256 _startEpoch
|
|
38
|
+
) initializer {
|
|
39
|
+
pool = _pool;
|
|
40
|
+
factory = msg.sender;
|
|
41
|
+
rewardToken = _rewardToken;
|
|
42
|
+
startEpoch = _startEpoch;
|
|
43
|
+
lastFinishedEpoch = _startEpoch;
|
|
44
|
+
__BoringOwnable_init();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function fund(uint256[] calldata rewardsForEpoch) external onlyOwner {
|
|
48
|
+
uint256 epoch = lastFinishedEpoch;
|
|
49
|
+
uint256 totalRewardFunding = 0;
|
|
50
|
+
for (uint256 i = 0; i < rewardsForEpoch.length; ++i) {
|
|
51
|
+
epoch += WeekMath.WEEK;
|
|
52
|
+
uint256 incentive = rewardsForEpoch[i];
|
|
53
|
+
|
|
54
|
+
incentivesForEpoch[epoch] += incentive;
|
|
55
|
+
totalRewardFunding += incentive;
|
|
56
|
+
|
|
57
|
+
emit Fund(epoch, incentive);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (epoch > WeekMath.getCurrentWeekStart()) revert Errors.FDCantFundFutureEpoch();
|
|
61
|
+
|
|
62
|
+
IERC20(rewardToken).transferFrom(msg.sender, address(this), totalRewardFunding);
|
|
63
|
+
lastFinishedEpoch = epoch;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function claimReward(address user) external returns (uint256 amountRewardOut) {
|
|
67
|
+
IPFeeDistributorFactory(factory).updateUserShare(user, pool);
|
|
68
|
+
|
|
69
|
+
uint256 finishedEpoch = lastFinishedEpoch;
|
|
70
|
+
uint256 userEpoch = userLastClaimedEpoch[user];
|
|
71
|
+
|
|
72
|
+
if (userEpoch == finishedEpoch) return 0;
|
|
73
|
+
if (userEpoch == 0) userEpoch = startEpoch;
|
|
74
|
+
|
|
75
|
+
while (userEpoch < finishedEpoch) {
|
|
76
|
+
userEpoch += WeekMath.WEEK;
|
|
77
|
+
|
|
78
|
+
uint256 incentive = incentivesForEpoch[userEpoch];
|
|
79
|
+
if (incentive == 0) continue;
|
|
80
|
+
|
|
81
|
+
(uint256 userShare, uint256 totalShare) = IPFeeDistributorFactory(factory)
|
|
82
|
+
.getUserAndTotalSharesAt(user, pool, userEpoch);
|
|
83
|
+
|
|
84
|
+
if (userShare == 0) continue;
|
|
85
|
+
|
|
86
|
+
amountRewardOut += (userShare * incentive) / totalShare;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
userLastClaimedEpoch[user] = finishedEpoch;
|
|
90
|
+
if (amountRewardOut > 0) {
|
|
91
|
+
IERC20(rewardToken).safeTransfer(user, amountRewardOut);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
emit ClaimReward(user, rewardToken, finishedEpoch, amountRewardOut);
|
|
95
|
+
}
|
|
96
|
+
}
|