@pendle/core-v2 0.15.1-mainnet → 0.15.2-mainnet
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.json +13 -0
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/EpochResultManager.sol/EpochResultManager.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/FeeDistributor/PendleFeeDistributorFactory.sol/PendleFeeDistributorFactory.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.json +13 -0
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +15 -2
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/libraries/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +4 -0
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +699 -0
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +4 -0
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +515 -0
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +4 -0
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +10 -0
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
- package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.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 +2 -2
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +77 -17
- package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/PYIndex.sol/PYIndexLib.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +1003 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +1068 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol/PendleConvexLPSY.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +856 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -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 +15 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +85 -4
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +17 -4
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.json +2 -2
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.json +2 -2
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.json +3 -38
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.json +2 -2
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.json +13 -0
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.json +2 -2
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +284 -31
- package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +39 -85
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.json +213 -0
- package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.json +30 -0
- package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.json +76 -0
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.json +91 -17
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.json +50 -0
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.json +20 -0
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.json +20 -0
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.json +181 -17
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.json +173 -0
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.json +86 -0
- package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.json +34 -0
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.json +2 -2
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISJoe.sol/ISJoe.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.json +45 -0
- package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWAvax.sol/IWAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.json +15 -2
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +35 -0
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -80
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +271 -61
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +102 -41
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.json +2 -2
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +61 -24
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +31 -24
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +31 -24
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +15 -2
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +191 -2
- package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.json +35 -0
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.json +1 -1
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +58 -27
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +46 -12
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +31 -7
- package/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol +133 -0
- package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +27 -0
- package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +9 -10
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +9 -23
- package/contracts/core/BulkSeller/BulkSeller.sol +259 -0
- package/contracts/core/BulkSeller/BulkSellerFactory.sol +88 -0
- package/contracts/core/BulkSeller/BulkSellerMathCore.sol +143 -0
- package/contracts/core/Market/PendleMarket.sol +18 -7
- package/contracts/core/Market/PendleMarketFactory.sol +15 -5
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +102 -0
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +160 -0
- package/contracts/core/StandardizedYield/implementations/Convex/README.md +29 -0
- package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +215 -0
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +127 -0
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +152 -0
- package/contracts/core/StandardizedYield/implementations/Convex/{ConvexCurveLP → base}/PendleConvexLPSY.sol +2 -4
- package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +122 -0
- package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +17 -8
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +3 -3
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +38 -11
- package/contracts/core/YieldContracts/PendleYieldToken.sol +54 -21
- package/contracts/core/erc20/PendleERC20.sol +4 -7
- package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -1
- package/contracts/core/libraries/BoringOwnableUpgradeable.sol +1 -1
- package/contracts/core/libraries/Errors.sol +32 -4
- package/contracts/core/libraries/StringLib.sol +782 -0
- package/contracts/core/libraries/TokenHelper.sol +9 -0
- package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -1
- package/contracts/interfaces/Curve/ICrvPool.sol +12 -31
- package/contracts/interfaces/Curve/ITriCrvPool.sol +41 -0
- package/contracts/interfaces/ILayerZeroEndpoint.sol +39 -0
- package/contracts/interfaces/ILayerZeroReceiver.sol +12 -0
- package/contracts/interfaces/ILooksFeeSharing.sol +5 -0
- package/contracts/interfaces/ILooksStaking.sol +13 -0
- package/contracts/interfaces/IPActionAddRemoveLiq.sol +3 -5
- package/contracts/interfaces/IPActionMintRedeem.sol +2 -0
- package/contracts/interfaces/IPBulkSeller.sol +28 -0
- package/contracts/interfaces/IPBulkSellerFactory.sol +12 -0
- package/contracts/interfaces/IPBulkSellerSYCallback.sol +10 -0
- package/contracts/interfaces/IPMarketFactory.sol +1 -1
- package/contracts/interfaces/IPMsgSendEndpoint.sol +4 -2
- package/contracts/interfaces/IPYieldContractFactory.sol +1 -1
- package/contracts/interfaces/IStETH.sol +6 -0
- package/contracts/interfaces/IStandardizedYield.sol +15 -10
- package/contracts/offchain-helpers/BulkSellerOffchain.sol +43 -0
- package/contracts/offchain-helpers/MarketMathStatic.sol +0 -173
- package/contracts/offchain-helpers/RouterStatic.sol +189 -50
- package/contracts/router/ActionAddRemoveLiq.sol +71 -52
- package/contracts/router/ActionCallback.sol +4 -8
- package/contracts/router/ActionMintRedeem.sol +27 -18
- package/contracts/router/ActionSwapPT.sol +8 -9
- package/contracts/router/ActionSwapPTYT.sol +3 -7
- package/contracts/router/ActionSwapYT.sol +15 -10
- package/contracts/router/PendleRouter.sol +3 -0
- package/contracts/router/base/ActionBaseMintRedeem.sol +78 -83
- package/contracts/router/base/MarketApproxLib.sol +1 -1
- package/contracts/router/kyberswap/AggregationRouterHelper.sol +17 -1
- package/contracts/router/kyberswap/IAggregatorRouterHelper.sol +10 -0
- package/contracts/router/kyberswap/KyberSwapHelper.sol +21 -8
- package/deployments/1-markets/FRAX_30_MAR_23.json +8 -0
- package/deployments/1-markets/LOOKS_30_MAR_23.json +8 -0
- package/deployments/1-markets/USDD_MARCH_30.json +8 -0
- package/deployments/1-offchain-helper.json +3 -0
- package/package.json +3 -2
- package/typechain-types/AccessControl.ts +360 -0
- package/typechain-types/AccessControlUpgradeable.ts +369 -0
- package/typechain-types/ActionAddRemoveLiq.ts +64 -52
- package/typechain-types/ActionBaseMintRedeem.ts +8 -8
- package/typechain-types/ActionMintRedeem.ts +48 -16
- package/typechain-types/ActionSwapPT.ts +34 -12
- package/typechain-types/ActionSwapYT.ts +34 -12
- package/typechain-types/AggregationRouterHelper.ts +287 -3
- package/typechain-types/BaseSplitCodeFactoryContract.ts +9 -0
- package/typechain-types/BeaconProxy.ts +97 -0
- package/typechain-types/BoringOwnableUpgradeable.ts +9 -0
- package/typechain-types/BulkSeller.ts +777 -0
- package/typechain-types/BulkSellerFactory.ts +707 -0
- package/typechain-types/BulkSellerOffchain.ts +117 -0
- package/typechain-types/ContextUpgradeable.ts +68 -0
- package/typechain-types/Curve3CrvPoolHelper.ts +236 -0
- package/typechain-types/CurveFraxUsdcPoolHelper.ts +158 -0
- package/typechain-types/CurveUsdd3CrvPoolHelper.ts +184 -0
- package/typechain-types/ERC165.ts +102 -0
- package/typechain-types/ERC165Upgradeable.ts +113 -0
- package/typechain-types/IAccessControl.ts +305 -0
- package/typechain-types/IAccessControlUpgradeable.ts +305 -0
- package/typechain-types/IAggregationRouterHelper.ts +108 -0
- package/typechain-types/IBooster.ts +9 -3
- package/typechain-types/ICrvPool.ts +69 -172
- package/typechain-types/IERC165.ts +102 -0
- package/typechain-types/IERC165Upgradeable.ts +102 -0
- package/typechain-types/ILooksStaking.ts +27 -0
- package/typechain-types/IPActionAddRemoveLiq.ts +56 -44
- package/typechain-types/IPActionMintRedeem.ts +40 -8
- package/typechain-types/IPActionSwapPT.ts +26 -4
- package/typechain-types/IPActionSwapYT.ts +26 -4
- package/typechain-types/IPAllAction.ts +76 -54
- package/typechain-types/IPBulkSeller.ts +290 -0
- package/typechain-types/IPBulkSellerCallback.ts +115 -0
- package/typechain-types/IPBulkSellerFactory.ts +147 -0
- package/typechain-types/IPMarketFactory.ts +2 -2
- package/typechain-types/IPYieldContractFactory.ts +3 -3
- package/typechain-types/IStETH.ts +56 -0
- package/typechain-types/ITriCrvPool.ts +345 -0
- package/typechain-types/Initializable.ts +68 -0
- package/typechain-types/KyberSwapHelper.ts +8 -8
- package/typechain-types/MarketMathStatic.ts +0 -117
- package/typechain-types/PendleCurveFraxUsdcSY.ts +1228 -0
- package/typechain-types/PendleCurveUsdd3CrvSY.ts +1299 -0
- package/typechain-types/PendleFeeDistributor.ts +9 -0
- package/typechain-types/PendleFeeDistributorFactory.ts +9 -0
- package/typechain-types/PendleGaugeControllerBaseUpg.ts +9 -0
- package/typechain-types/PendleGaugeControllerMainchainUpg.ts +9 -0
- package/typechain-types/PendleGaugeControllerSidechainUpg.ts +9 -0
- package/typechain-types/PendleLooksStakingSY.ts +1052 -0
- package/typechain-types/PendleMarketFactory.ts +51 -2
- package/typechain-types/PendleMsgReceiveEndpointUpg.ts +9 -0
- package/typechain-types/PendleMsgSendEndpointUpg.ts +9 -0
- package/typechain-types/PendleMsgSenderAppUpg.ts +9 -0
- package/typechain-types/PendlePrincipalToken.ts +9 -0
- package/typechain-types/PendleRouter.ts +9 -0
- package/typechain-types/PendleVotingControllerUpg.ts +9 -0
- package/typechain-types/PendleYieldContractFactory.ts +57 -8
- package/typechain-types/PendleYieldToken.ts +21 -0
- package/typechain-types/ReentrancyGuardUpgradeable.ts +68 -0
- package/typechain-types/RouterStatic.ts +260 -22
- package/typechain-types/VotingEscrowPendleMainchain.ts +9 -0
- package/typechain-types/VotingEscrowPendleSidechain.ts +9 -0
- package/typechain-types/factories/AccessControlUpgradeable__factory.ts +247 -0
- package/typechain-types/factories/AccessControl__factory.ts +227 -0
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +106 -59
- package/typechain-types/factories/ActionBaseMintRedeem__factory.ts +1 -1
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +65 -42
- package/typechain-types/factories/ActionMisc__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPTYT__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapPT__factory.ts +35 -42
- package/typechain-types/factories/ActionSwapYT__factory.ts +35 -42
- package/typechain-types/factories/AggregationRouterHelper__factory.ts +190 -1
- package/typechain-types/factories/BaseSplitCodeFactoryContract__factory.ts +14 -1
- package/typechain-types/factories/BaseSplitCodeFactory__factory.ts +1 -1
- package/typechain-types/factories/BeaconProxy__factory.ts +141 -0
- package/typechain-types/factories/BoringOwnableUpgradeableData__factory.ts +1 -1
- package/typechain-types/factories/BoringOwnableUpgradeable__factory.ts +13 -0
- package/typechain-types/factories/BulkSellerFactory__factory.ts +568 -0
- package/typechain-types/factories/BulkSellerOffchain__factory.ts +88 -0
- package/typechain-types/factories/BulkSeller__factory.ts +749 -0
- package/typechain-types/factories/ContextUpgradeable__factory.ts +39 -0
- package/typechain-types/factories/Curve3CrvPoolHelper__factory.ts +220 -0
- package/typechain-types/factories/CurveFraxUsdcPoolHelper__factory.ts +146 -0
- package/typechain-types/factories/CurveUsdd3CrvPoolHelper__factory.ts +172 -0
- package/typechain-types/factories/ERC165Upgradeable__factory.ts +58 -0
- package/typechain-types/factories/ERC165__factory.ts +39 -0
- package/typechain-types/factories/ERC20__factory.ts +1 -1
- package/typechain-types/factories/Errors__factory.ts +283 -30
- package/typechain-types/factories/IAccessControlUpgradeable__factory.ts +202 -0
- package/typechain-types/factories/IAccessControl__factory.ts +198 -0
- package/typechain-types/factories/IAggregationRouterHelper__factory.ts +54 -0
- package/typechain-types/factories/IBooster__factory.ts +1 -1
- package/typechain-types/factories/ICrvPool__factory.ts +39 -85
- package/typechain-types/factories/IERC165Upgradeable__factory.ts +45 -0
- package/typechain-types/factories/IERC165__factory.ts +42 -0
- package/typechain-types/factories/ILooksStaking__factory.ts +7 -0
- package/typechain-types/factories/IPActionAddRemoveLiq__factory.ts +91 -17
- package/typechain-types/factories/IPActionMintRedeem__factory.ts +50 -0
- package/typechain-types/factories/IPActionSwapPT__factory.ts +20 -0
- package/typechain-types/factories/IPActionSwapYT__factory.ts +20 -0
- package/typechain-types/factories/IPAllAction__factory.ts +181 -17
- package/typechain-types/factories/IPBulkSellerCallback__factory.ts +53 -0
- package/typechain-types/factories/IPBulkSellerFactory__factory.ts +101 -0
- package/typechain-types/factories/IPBulkSeller__factory.ts +185 -0
- package/typechain-types/factories/IPMarketFactory__factory.ts +2 -2
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +1 -1
- package/typechain-types/factories/IStETH__factory.ts +45 -0
- package/typechain-types/factories/ITriCrvPool__factory.ts +225 -0
- package/typechain-types/factories/ImplicitSwapfeeContract__factory.ts +1 -1
- package/typechain-types/factories/Initializable__factory.ts +36 -0
- package/typechain-types/factories/KyberSwapHelper__factory.ts +1 -1
- package/typechain-types/factories/MarketMathStatic__factory.ts +1 -79
- package/typechain-types/factories/OracleLib__factory.ts +1 -1
- package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1068 -0
- package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1133 -0
- package/typechain-types/factories/PendleERC20Permit__factory.ts +1 -1
- package/typechain-types/factories/PendleERC20__factory.ts +1 -1
- package/typechain-types/factories/PendleFeeDistributorFactory__factory.ts +14 -1
- package/typechain-types/factories/PendleFeeDistributor__factory.ts +14 -1
- package/typechain-types/factories/PendleGaugeControllerBaseUpg__factory.ts +13 -0
- package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +14 -1
- package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +14 -1
- package/typechain-types/factories/PendleLooksStakingSY__factory.ts +937 -0
- package/typechain-types/factories/PendleMarketFactory__factory.ts +76 -16
- package/typechain-types/factories/PendleMarket__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +14 -1
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +14 -1
- package/typechain-types/factories/PendleMsgSenderAppUpg__factory.ts +13 -0
- package/typechain-types/factories/PendlePrincipalToken__factory.ts +14 -1
- package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
- package/typechain-types/factories/PendleRouter__factory.ts +14 -1
- package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +14 -1
- package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +84 -3
- package/typechain-types/factories/PendleYieldToken__factory.ts +16 -3
- package/typechain-types/factories/ReentrancyGuardUpgradeable__factory.ts +43 -0
- package/typechain-types/factories/RouterStatic__factory.ts +216 -2
- package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +14 -1
- package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +14 -1
- package/typechain-types/hardhat.d.ts +233 -17
- package/typechain-types/index.ts +50 -6
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol/Pendle3CrvAndTokenSY.json +0 -1018
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +0 -76
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.dbg.json +0 -4
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.json +0 -182
- package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol +0 -167
- package/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol +0 -83
- package/contracts/interfaces/ICelerMessageBus.sol +0 -28
- package/contracts/interfaces/ICelerMessageReceiverApp.sol +0 -25
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
|
|
5
|
+
|
|
6
|
+
import "../../interfaces/IStandardizedYield.sol";
|
|
7
|
+
import "../../interfaces/IPBulkSellerFactory.sol";
|
|
8
|
+
import "../../interfaces/IPBulkSeller.sol";
|
|
9
|
+
|
|
10
|
+
import "../libraries/TokenHelper.sol";
|
|
11
|
+
import "../libraries/math/Math.sol";
|
|
12
|
+
import "../libraries/Errors.sol";
|
|
13
|
+
|
|
14
|
+
import "./BulkSellerMathCore.sol";
|
|
15
|
+
|
|
16
|
+
contract BulkSeller is IPBulkSeller, Initializable, TokenHelper, ReentrancyGuardUpgradeable {
|
|
17
|
+
using Math for uint256;
|
|
18
|
+
using SafeERC20 for IERC20;
|
|
19
|
+
using BulkSellerMathCore for BulkSellerState;
|
|
20
|
+
|
|
21
|
+
event SwapExactTokenForSy(address receiver, uint256 netTokenIn, uint256 netSyOut);
|
|
22
|
+
event SwapExactSyForToken(address receiver, uint256 netSyIn, uint256 netTokenOut);
|
|
23
|
+
event RateUpdated(
|
|
24
|
+
uint256 newRateTokenToSy,
|
|
25
|
+
uint256 newRateSyToToken,
|
|
26
|
+
uint256 oldRateTokenToSy,
|
|
27
|
+
uint256 oldRateSyToToken
|
|
28
|
+
);
|
|
29
|
+
event ReBalanceTokenToSy(
|
|
30
|
+
uint256 netTokenDeposit,
|
|
31
|
+
uint256 netSyFromToken,
|
|
32
|
+
uint256 newTokenProp,
|
|
33
|
+
uint256 oldTokenProp
|
|
34
|
+
);
|
|
35
|
+
event ReBalanceSyToToken(
|
|
36
|
+
uint256 netSyRedeem,
|
|
37
|
+
uint256 netTokenFromSy,
|
|
38
|
+
uint256 newTokenProp,
|
|
39
|
+
uint256 oldTokenProp
|
|
40
|
+
);
|
|
41
|
+
event ReserveUpdated(uint256 totalToken, uint256 totalSy);
|
|
42
|
+
event FeeRateUpdated(uint256 newFeeRate, uint256 oldFeeRate);
|
|
43
|
+
|
|
44
|
+
struct BulkSellerStorage {
|
|
45
|
+
uint128 rateTokenToSy;
|
|
46
|
+
uint128 rateSyToToken;
|
|
47
|
+
uint128 totalSy;
|
|
48
|
+
uint128 totalToken;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
address public token;
|
|
52
|
+
address public SY;
|
|
53
|
+
uint64 public feeRate;
|
|
54
|
+
|
|
55
|
+
address public factory;
|
|
56
|
+
BulkSellerStorage public _storage;
|
|
57
|
+
|
|
58
|
+
modifier onlyMaintainer() {
|
|
59
|
+
if (!IPBulkSellerFactory(factory).isMaintainer(msg.sender))
|
|
60
|
+
revert Errors.BulkNotMaintainer();
|
|
61
|
+
_;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
modifier onlyAdmin() {
|
|
65
|
+
if (!IPBulkSellerFactory(factory).isAdmin(msg.sender)) revert Errors.BulkNotAdmin();
|
|
66
|
+
_;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Since this contract is a beacon contract, no constructor should be defined.
|
|
70
|
+
function initialize(
|
|
71
|
+
address _token,
|
|
72
|
+
address _SY,
|
|
73
|
+
address _factory
|
|
74
|
+
) external initializer {
|
|
75
|
+
__ReentrancyGuard_init();
|
|
76
|
+
token = _token;
|
|
77
|
+
SY = _SY;
|
|
78
|
+
factory = _factory;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function swapExactTokenForSy(
|
|
82
|
+
address receiver,
|
|
83
|
+
uint256 netTokenIn,
|
|
84
|
+
uint256 minSyOut
|
|
85
|
+
) external nonReentrant returns (uint256 netSyOut) {
|
|
86
|
+
BulkSellerState memory state = readState();
|
|
87
|
+
|
|
88
|
+
netSyOut = state.swapExactTokenForSy(netTokenIn);
|
|
89
|
+
|
|
90
|
+
if (netSyOut < minSyOut) revert Errors.BulkInSufficientSyOut(netSyOut, minSyOut);
|
|
91
|
+
|
|
92
|
+
if (receiver != address(this)) _transferOut(SY, receiver, netSyOut);
|
|
93
|
+
|
|
94
|
+
_writeState(state);
|
|
95
|
+
|
|
96
|
+
if (_selfBalance(token) < state.totalToken)
|
|
97
|
+
revert Errors.BulkInsufficientTokenReceived(_selfBalance(token), state.totalToken);
|
|
98
|
+
|
|
99
|
+
emit SwapExactTokenForSy(receiver, netTokenIn, netSyOut);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function swapExactSyForToken(
|
|
103
|
+
address receiver,
|
|
104
|
+
uint256 exactSyIn,
|
|
105
|
+
uint256 minTokenOut
|
|
106
|
+
) external nonReentrant returns (uint256 netTokenOut) {
|
|
107
|
+
BulkSellerState memory state = readState();
|
|
108
|
+
|
|
109
|
+
netTokenOut = state.swapExactSyForToken(exactSyIn);
|
|
110
|
+
|
|
111
|
+
if (netTokenOut < minTokenOut)
|
|
112
|
+
revert Errors.BulkInSufficientTokenOut(netTokenOut, minTokenOut);
|
|
113
|
+
if (receiver != address(this)) _transferOut(token, receiver, netTokenOut);
|
|
114
|
+
|
|
115
|
+
_writeState(state);
|
|
116
|
+
|
|
117
|
+
if (_selfBalance(SY) < state.totalSy)
|
|
118
|
+
revert Errors.BulkInsufficientSyReceived(_selfBalance(SY), state.totalSy);
|
|
119
|
+
|
|
120
|
+
emit SwapExactSyForToken(receiver, exactSyIn, netTokenOut);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function calcSwapExactTokenForSy(uint256 netTokenIn) external view returns (uint256 netSyOut) {
|
|
124
|
+
assert(_storage.rateTokenToSy != 0);
|
|
125
|
+
netSyOut = netTokenIn.mulDown(_storage.rateTokenToSy);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function calcSwapExactSyForToken(uint256 netSyIn) external view returns (uint256 netTokenOut) {
|
|
129
|
+
assert(_storage.rateSyToToken != 0);
|
|
130
|
+
netTokenOut = netSyIn.mulDown(_storage.rateSyToToken);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function readState() public view returns (BulkSellerState memory state) {
|
|
134
|
+
BulkSellerStorage storage s = _storage;
|
|
135
|
+
|
|
136
|
+
state = BulkSellerState({
|
|
137
|
+
rateTokenToSy: s.rateTokenToSy,
|
|
138
|
+
rateSyToToken: s.rateSyToToken,
|
|
139
|
+
totalToken: s.totalToken,
|
|
140
|
+
totalSy: s.totalSy,
|
|
141
|
+
feeRate: feeRate
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function _writeState(BulkSellerState memory state) internal {
|
|
146
|
+
BulkSellerStorage memory tmp = BulkSellerStorage({
|
|
147
|
+
rateTokenToSy: state.rateTokenToSy.Uint128(),
|
|
148
|
+
rateSyToToken: state.rateSyToToken.Uint128(),
|
|
149
|
+
totalSy: state.totalSy.Uint128(),
|
|
150
|
+
totalToken: state.totalToken.Uint128()
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
_storage = tmp;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ----------------- BulkSeller management -----------------
|
|
157
|
+
|
|
158
|
+
function increaseReserve(uint256 netTokenIn, uint256 netSyIn) external payable onlyMaintainer {
|
|
159
|
+
BulkSellerState memory state = readState();
|
|
160
|
+
|
|
161
|
+
state.totalToken += netTokenIn;
|
|
162
|
+
state.totalSy += netSyIn;
|
|
163
|
+
|
|
164
|
+
_transferIn(token, msg.sender, netTokenIn);
|
|
165
|
+
_transferIn(SY, msg.sender, netSyIn);
|
|
166
|
+
|
|
167
|
+
emit ReserveUpdated(state.totalToken, state.totalSy);
|
|
168
|
+
|
|
169
|
+
_writeState(state);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function decreaseReserve(uint256 netTokenOut, uint256 netSyOut) external onlyAdmin {
|
|
173
|
+
BulkSellerState memory state = readState();
|
|
174
|
+
|
|
175
|
+
if (netTokenOut == type(uint256).max) netTokenOut = state.totalToken;
|
|
176
|
+
if (netSyOut == type(uint256).max) netSyOut = state.totalSy;
|
|
177
|
+
|
|
178
|
+
state.totalToken -= netTokenOut;
|
|
179
|
+
state.totalSy -= netSyOut;
|
|
180
|
+
|
|
181
|
+
_transferOut(token, msg.sender, netTokenOut);
|
|
182
|
+
_transferOut(SY, msg.sender, netSyOut);
|
|
183
|
+
|
|
184
|
+
emit ReserveUpdated(state.totalToken, state.totalSy);
|
|
185
|
+
|
|
186
|
+
_writeState(state);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function reBalance(uint256 targetProp, uint256 maxDiff) external onlyMaintainer {
|
|
190
|
+
BulkSellerState memory state = readState();
|
|
191
|
+
uint256 oldTokenProp = state.getTokenProp();
|
|
192
|
+
|
|
193
|
+
(uint256 netTokenDeposit, uint256 netSyRedeem) = state.getReBalanceParams(targetProp);
|
|
194
|
+
|
|
195
|
+
if (netTokenDeposit > 0) {
|
|
196
|
+
uint256 netSyFromToken = _depositToken(netTokenDeposit);
|
|
197
|
+
state.reBalanceTokenToSy(netTokenDeposit, netSyFromToken, maxDiff);
|
|
198
|
+
|
|
199
|
+
uint256 newTokenProp = state.getTokenProp();
|
|
200
|
+
emit ReBalanceTokenToSy(netTokenDeposit, netSyFromToken, newTokenProp, oldTokenProp);
|
|
201
|
+
} else {
|
|
202
|
+
uint256 netTokenFromSy = _redeemSy(netSyRedeem);
|
|
203
|
+
state.reBalanceSyToToken(netSyRedeem, netTokenFromSy, maxDiff);
|
|
204
|
+
|
|
205
|
+
uint256 newTokenProp = state.getTokenProp();
|
|
206
|
+
emit ReBalanceSyToToken(netSyRedeem, netTokenFromSy, newTokenProp, oldTokenProp);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_writeState(state);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function setRate(
|
|
213
|
+
uint256 newRateSyToToken,
|
|
214
|
+
uint256 newRateTokenToSy,
|
|
215
|
+
uint256 maxDiff
|
|
216
|
+
) external onlyMaintainer {
|
|
217
|
+
BulkSellerState memory state = readState();
|
|
218
|
+
|
|
219
|
+
emit RateUpdated(
|
|
220
|
+
newRateTokenToSy,
|
|
221
|
+
newRateSyToToken,
|
|
222
|
+
state.rateTokenToSy,
|
|
223
|
+
state.rateSyToToken
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
state.setRate(newRateSyToToken, newRateTokenToSy, maxDiff);
|
|
227
|
+
|
|
228
|
+
_writeState(state);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function setFeeRate(uint64 newFeeRate) external onlyMaintainer {
|
|
232
|
+
emit FeeRateUpdated(newFeeRate, feeRate);
|
|
233
|
+
feeRate = newFeeRate;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function getTokenProp() external view returns (uint256) {
|
|
237
|
+
BulkSellerState memory state = readState();
|
|
238
|
+
return state.getTokenProp();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function _depositToken(uint256 netTokenDeposit) internal returns (uint256 netSyFromToken) {
|
|
242
|
+
_safeApprove(token, SY, netTokenDeposit);
|
|
243
|
+
uint256 nativeToDeposit = token == NATIVE ? netTokenDeposit : 0;
|
|
244
|
+
return
|
|
245
|
+
IStandardizedYield(SY).deposit{ value: nativeToDeposit }(
|
|
246
|
+
address(this),
|
|
247
|
+
token,
|
|
248
|
+
netTokenDeposit,
|
|
249
|
+
0
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function _redeemSy(uint256 netSyRedeem) internal returns (uint256 netTokenFromSy) {
|
|
254
|
+
_transferOut(SY, SY, netSyRedeem);
|
|
255
|
+
return IStandardizedYield(SY).redeem(address(this), netSyRedeem, token, 0, true);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
receive() external payable {}
|
|
259
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
|
|
5
|
+
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
|
|
6
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
7
|
+
|
|
8
|
+
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
|
|
9
|
+
import "../libraries/BoringOwnableUpgradeable.sol";
|
|
10
|
+
|
|
11
|
+
import "../../interfaces/IStandardizedYield.sol";
|
|
12
|
+
import "../../interfaces/IPBulkSellerFactory.sol";
|
|
13
|
+
import "../libraries/Errors.sol";
|
|
14
|
+
|
|
15
|
+
contract BulkSellerFactory is
|
|
16
|
+
IBeacon,
|
|
17
|
+
IPBulkSellerFactory,
|
|
18
|
+
Initializable,
|
|
19
|
+
AccessControlUpgradeable,
|
|
20
|
+
UUPSUpgradeable
|
|
21
|
+
{
|
|
22
|
+
bytes32 public constant MAINTAINER = keccak256("MAINTAINER");
|
|
23
|
+
|
|
24
|
+
address public implementation;
|
|
25
|
+
|
|
26
|
+
mapping(address => mapping(address => address)) internal syToBulkSeller;
|
|
27
|
+
|
|
28
|
+
modifier onlyAdmin() {
|
|
29
|
+
if (!isAdmin(msg.sender)) revert Errors.BulkNotAdmin();
|
|
30
|
+
_;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constructor() initializer {}
|
|
34
|
+
|
|
35
|
+
function initialize(address implementation_) external initializer {
|
|
36
|
+
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
37
|
+
upgradeBeacon(implementation_);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createBulkSeller(address token, address SY)
|
|
41
|
+
external
|
|
42
|
+
onlyAdmin
|
|
43
|
+
returns (address bulk)
|
|
44
|
+
{
|
|
45
|
+
IStandardizedYield _SY = IStandardizedYield(SY);
|
|
46
|
+
if (syToBulkSeller[token][SY] != address(0))
|
|
47
|
+
revert Errors.BulkSellerAlreadyExisted(token, SY, syToBulkSeller[token][SY]);
|
|
48
|
+
if (_SY.isValidTokenIn(token) == false || _SY.isValidTokenOut(token) == false)
|
|
49
|
+
revert Errors.BulkSellerInvalidToken(token, SY);
|
|
50
|
+
|
|
51
|
+
bytes memory data = abi.encodeWithSignature(
|
|
52
|
+
"initialize(address,address,address)",
|
|
53
|
+
token,
|
|
54
|
+
SY,
|
|
55
|
+
address(this)
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
bulk = address(new BeaconProxy(address(this), data));
|
|
59
|
+
|
|
60
|
+
syToBulkSeller[token][SY] = bulk;
|
|
61
|
+
|
|
62
|
+
return bulk;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function get(address token, address SY) external view override returns (address) {
|
|
66
|
+
return syToBulkSeller[token][SY];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isMaintainer(address addr) public view override returns (bool) {
|
|
70
|
+
return (hasRole(DEFAULT_ADMIN_ROLE, addr) || hasRole(MAINTAINER, addr));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function isAdmin(address addr) public view override returns (bool) {
|
|
74
|
+
return hasRole(DEFAULT_ADMIN_ROLE, addr);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ----------------- upgrade-related -----------------
|
|
78
|
+
function upgradeBeacon(address newImplementation) public onlyAdmin {
|
|
79
|
+
require(
|
|
80
|
+
AddressUpgradeable.isContract(newImplementation),
|
|
81
|
+
"UpgradeableBeacon: implementation is not a contract"
|
|
82
|
+
);
|
|
83
|
+
implementation = newImplementation;
|
|
84
|
+
emit UpgradedBeacon(newImplementation);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _authorizeUpgrade(address) internal override onlyAdmin {}
|
|
88
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../libraries/TokenHelper.sol";
|
|
5
|
+
import "../libraries/math/Math.sol";
|
|
6
|
+
import "../libraries/Errors.sol";
|
|
7
|
+
|
|
8
|
+
struct BulkSellerState {
|
|
9
|
+
uint256 rateTokenToSy;
|
|
10
|
+
uint256 rateSyToToken;
|
|
11
|
+
uint256 totalToken;
|
|
12
|
+
uint256 totalSy;
|
|
13
|
+
uint256 feeRate;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
library BulkSellerMathCore {
|
|
17
|
+
using Math for uint256;
|
|
18
|
+
|
|
19
|
+
function swapExactTokenForSy(BulkSellerState memory state, uint256 netTokenIn)
|
|
20
|
+
internal
|
|
21
|
+
pure
|
|
22
|
+
returns (uint256 netSyOut)
|
|
23
|
+
{
|
|
24
|
+
netSyOut = calcSwapExactTokenForSy(state, netTokenIn);
|
|
25
|
+
state.totalToken += netTokenIn;
|
|
26
|
+
state.totalSy -= netSyOut;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function swapExactSyForToken(BulkSellerState memory state, uint256 netSyIn)
|
|
30
|
+
internal
|
|
31
|
+
pure
|
|
32
|
+
returns (uint256 netTokenOut)
|
|
33
|
+
{
|
|
34
|
+
netTokenOut = calcSwapExactSyForToken(state, netSyIn);
|
|
35
|
+
state.totalSy += netSyIn;
|
|
36
|
+
state.totalToken -= netTokenOut;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function calcSwapExactTokenForSy(BulkSellerState memory state, uint256 netTokenIn)
|
|
40
|
+
internal
|
|
41
|
+
pure
|
|
42
|
+
returns (uint256 netSyOut)
|
|
43
|
+
{
|
|
44
|
+
uint256 postFeeRate = state.rateTokenToSy.mulDown(Math.ONE - state.feeRate);
|
|
45
|
+
assert(postFeeRate != 0);
|
|
46
|
+
|
|
47
|
+
netSyOut = netTokenIn.mulDown(postFeeRate);
|
|
48
|
+
if (netSyOut > state.totalSy)
|
|
49
|
+
revert Errors.BulkInsufficientSyForTrade(state.totalSy, netSyOut);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function calcSwapExactSyForToken(BulkSellerState memory state, uint256 netSyIn)
|
|
53
|
+
internal
|
|
54
|
+
pure
|
|
55
|
+
returns (uint256 netTokenOut)
|
|
56
|
+
{
|
|
57
|
+
uint256 postFeeRate = state.rateSyToToken.mulDown(Math.ONE - state.feeRate);
|
|
58
|
+
assert(postFeeRate != 0);
|
|
59
|
+
|
|
60
|
+
netTokenOut = netSyIn.mulDown(postFeeRate);
|
|
61
|
+
if (netTokenOut > state.totalToken)
|
|
62
|
+
revert Errors.BulkInsufficientTokenForTrade(state.totalToken, netTokenOut);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getTokenProp(BulkSellerState memory state) internal pure returns (uint256) {
|
|
66
|
+
uint256 totalToken = state.totalToken;
|
|
67
|
+
uint256 totalTokenFromSy = state.totalSy.mulDown(state.rateSyToToken);
|
|
68
|
+
return totalToken.divDown(totalToken + totalTokenFromSy);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getReBalanceParams(BulkSellerState memory state, uint256 targetTokenProp)
|
|
72
|
+
internal
|
|
73
|
+
pure
|
|
74
|
+
returns (uint256 netTokenToDeposit, uint256 netSyToRedeem)
|
|
75
|
+
{
|
|
76
|
+
uint256 currentTokenProp = getTokenProp(state);
|
|
77
|
+
|
|
78
|
+
if (currentTokenProp > targetTokenProp) {
|
|
79
|
+
netTokenToDeposit = state.totalToken.mulDown(
|
|
80
|
+
(currentTokenProp - targetTokenProp).divDown(currentTokenProp)
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
uint256 currentSyProp = Math.ONE - currentTokenProp;
|
|
84
|
+
netSyToRedeem = state.totalSy.mulDown(
|
|
85
|
+
(targetTokenProp - currentTokenProp).divDown(currentSyProp)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function reBalanceTokenToSy(
|
|
91
|
+
BulkSellerState memory state,
|
|
92
|
+
uint256 netTokenToDeposit,
|
|
93
|
+
uint256 netSyFromToken,
|
|
94
|
+
uint256 maxDiff
|
|
95
|
+
) internal pure {
|
|
96
|
+
uint256 rate = netSyFromToken.divDown(netTokenToDeposit);
|
|
97
|
+
|
|
98
|
+
if (!Math.isAApproxB(rate, state.rateTokenToSy, maxDiff))
|
|
99
|
+
revert Errors.BulkBadRateTokenToSy(rate, state.rateTokenToSy, maxDiff);
|
|
100
|
+
|
|
101
|
+
state.totalToken -= netTokenToDeposit;
|
|
102
|
+
state.totalSy += netSyFromToken;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function reBalanceSyToToken(
|
|
106
|
+
BulkSellerState memory state,
|
|
107
|
+
uint256 netSyToRedeem,
|
|
108
|
+
uint256 netTokenFromSy,
|
|
109
|
+
uint256 maxDiff
|
|
110
|
+
) internal pure {
|
|
111
|
+
uint256 rate = netTokenFromSy.divDown(netSyToRedeem);
|
|
112
|
+
|
|
113
|
+
if (!Math.isAApproxB(rate, state.rateSyToToken, maxDiff))
|
|
114
|
+
revert Errors.BulkBadRateSyToToken(rate, state.rateSyToToken, maxDiff);
|
|
115
|
+
|
|
116
|
+
state.totalToken += netTokenFromSy;
|
|
117
|
+
state.totalSy -= netSyToRedeem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function setRate(
|
|
121
|
+
BulkSellerState memory state,
|
|
122
|
+
uint256 rateSyToToken,
|
|
123
|
+
uint256 rateTokenToSy,
|
|
124
|
+
uint256 maxDiff
|
|
125
|
+
) internal pure {
|
|
126
|
+
if (
|
|
127
|
+
state.rateTokenToSy != 0 &&
|
|
128
|
+
!Math.isAApproxB(rateTokenToSy, state.rateTokenToSy, maxDiff)
|
|
129
|
+
) {
|
|
130
|
+
revert Errors.BulkBadRateTokenToSy(rateTokenToSy, state.rateTokenToSy, maxDiff);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (
|
|
134
|
+
state.rateSyToToken != 0 &&
|
|
135
|
+
!Math.isAApproxB(rateSyToToken, state.rateSyToToken, maxDiff)
|
|
136
|
+
) {
|
|
137
|
+
revert Errors.BulkBadRateSyToToken(rateSyToToken, state.rateSyToToken, maxDiff);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
state.rateTokenToSy = rateTokenToSy;
|
|
141
|
+
state.rateSyToToken = rateSyToToken;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -83,6 +83,10 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
83
83
|
/**
|
|
84
84
|
* @notice PendleMarket allows users to provide in PT & SY in exchange for LPs, which
|
|
85
85
|
* will grant LP holders more exchange fee over time
|
|
86
|
+
* @dev will mint as much LP as possible such that the corresponding SY and PT used do
|
|
87
|
+
* not exceed `netSyDesired` and `netPtDesired`, respectively
|
|
88
|
+
* @dev PT and SY should be transferred to this contract prior to calling
|
|
89
|
+
* @dev will revert if PT is expired
|
|
86
90
|
*/
|
|
87
91
|
function mint(
|
|
88
92
|
address receiver,
|
|
@@ -129,7 +133,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
129
133
|
|
|
130
134
|
/**
|
|
131
135
|
* @notice LP Holders can burn their LP to receive back SY & PT proportionally
|
|
132
|
-
* to their share of market
|
|
136
|
+
* to their share of the market
|
|
133
137
|
*/
|
|
134
138
|
function burn(
|
|
135
139
|
address receiverSy,
|
|
@@ -158,7 +162,8 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
158
162
|
- Release the calculated amount of SY to receiver
|
|
159
163
|
- Callback to msg.sender if data.length > 0
|
|
160
164
|
- Ensure exactPtIn amount of PT has been transferred to this address
|
|
161
|
-
* @
|
|
165
|
+
* @dev will revert if PT is expired
|
|
166
|
+
* @param data bytes data to be sent in the callback (if any)
|
|
162
167
|
*/
|
|
163
168
|
function swapExactPtForSy(
|
|
164
169
|
address receiver,
|
|
@@ -190,12 +195,13 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
190
195
|
|
|
191
196
|
/**
|
|
192
197
|
* @notice Pendle Market allows swaps between PT & SY it is holding. This function
|
|
193
|
-
* aims to swap an exact amount of
|
|
198
|
+
* aims to swap SY for an exact amount of PT.
|
|
194
199
|
* @dev steps working of this function
|
|
195
200
|
- The exact outcome amount of PT will be transferred to receiver
|
|
196
201
|
- Callback to msg.sender if data.length > 0
|
|
197
202
|
- Ensure the calculated required amount of SY is transferred to this address
|
|
198
|
-
* @
|
|
203
|
+
* @dev will revert if PT is expired
|
|
204
|
+
* @param data bytes data to be sent in the callback (if any)
|
|
199
205
|
*/
|
|
200
206
|
function swapSyForExactPt(
|
|
201
207
|
address receiver,
|
|
@@ -226,7 +232,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
226
232
|
emit Swap(receiver, exactPtOut.Int(), netSyIn.neg(), netSyToReserve);
|
|
227
233
|
}
|
|
228
234
|
|
|
229
|
-
/// @notice
|
|
235
|
+
/// @notice forces balances to match reserves
|
|
230
236
|
function skim() external nonReentrant {
|
|
231
237
|
MarketState memory market = readState();
|
|
232
238
|
uint256 excessPt = _selfBalance(PT) - market.totalPt.Uint();
|
|
@@ -235,10 +241,15 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
235
241
|
IERC20(SY).safeTransfer(market.treasury, excessSy);
|
|
236
242
|
}
|
|
237
243
|
|
|
244
|
+
/**
|
|
245
|
+
* @notice redeems the user's reward
|
|
246
|
+
* @return amount of reward token redeemed, in the same order as `getRewardTokens()`
|
|
247
|
+
*/
|
|
238
248
|
function redeemRewards(address user) external nonReentrant returns (uint256[] memory) {
|
|
239
249
|
return _redeemRewards(user);
|
|
240
250
|
}
|
|
241
251
|
|
|
252
|
+
/// @notice returns the list of reward tokens
|
|
242
253
|
function getRewardTokens() external view returns (address[] memory) {
|
|
243
254
|
return _getRewardTokens();
|
|
244
255
|
}
|
|
@@ -248,7 +259,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
248
259
|
//////////////////////////////////////////////////////////////*/
|
|
249
260
|
|
|
250
261
|
function observe(uint32[] memory secondsAgos)
|
|
251
|
-
|
|
262
|
+
external
|
|
252
263
|
view
|
|
253
264
|
returns (uint216[] memory lnImpliedRateCumulative)
|
|
254
265
|
{
|
|
@@ -302,7 +313,7 @@ contract PendleMarket is PendleERC20Permit, PendleGauge, IPMarket {
|
|
|
302
313
|
(uint16 observationIndex, uint16 observationCardinality) = observations.write(
|
|
303
314
|
_storage.observationIndex,
|
|
304
315
|
uint32(block.timestamp),
|
|
305
|
-
|
|
316
|
+
_storage.lastLnImpliedRate,
|
|
306
317
|
_storage.observationCardinality,
|
|
307
318
|
_storage.observationCardinalityNext
|
|
308
319
|
);
|
|
@@ -30,6 +30,8 @@ contract PendleMarketFactory is BoringOwnableUpgradeable, IPMarketFactory {
|
|
|
30
30
|
|
|
31
31
|
address public immutable yieldContractFactory;
|
|
32
32
|
uint256 public immutable maxLnFeeRateRoot;
|
|
33
|
+
uint8 public constant maxReserveFeePercent = 100;
|
|
34
|
+
int256 public constant minInitialAnchor = Math.IONE;
|
|
33
35
|
|
|
34
36
|
// PT -> scalarRoot -> initialAnchor
|
|
35
37
|
mapping(address => mapping(int256 => mapping(int256 => address))) internal markets;
|
|
@@ -72,8 +74,8 @@ contract PendleMarketFactory is BoringOwnableUpgradeable, IPMarketFactory {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
|
-
* @notice Create a market between PT and its corresponding SY
|
|
76
|
-
*
|
|
77
|
+
* @notice Create a market between PT and its corresponding SY with scalar & anchor config.
|
|
78
|
+
* Anyone is allowed to create a market on their own.
|
|
77
79
|
*/
|
|
78
80
|
function createNewMarket(
|
|
79
81
|
address PT,
|
|
@@ -87,6 +89,9 @@ contract PendleMarketFactory is BoringOwnableUpgradeable, IPMarketFactory {
|
|
|
87
89
|
if (markets[PT][scalarRoot][initialAnchor] != address(0))
|
|
88
90
|
revert Errors.MarketFactoryMarketExists();
|
|
89
91
|
|
|
92
|
+
if (initialAnchor < minInitialAnchor)
|
|
93
|
+
revert Errors.MarketFactoryInitialAnchorTooLow(initialAnchor, minInitialAnchor);
|
|
94
|
+
|
|
90
95
|
market = BaseSplitCodeFactory._create2(
|
|
91
96
|
0,
|
|
92
97
|
bytes32(block.chainid),
|
|
@@ -114,21 +119,26 @@ contract PendleMarketFactory is BoringOwnableUpgradeable, IPMarketFactory {
|
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
function setTreasury(address newTreasury) public onlyOwner {
|
|
122
|
+
if (newTreasury == address(0)) revert Errors.MarketFactoryZeroTreasury();
|
|
123
|
+
|
|
117
124
|
marketConfig.treasury = newTreasury;
|
|
118
125
|
_emitNewMarketConfigEvent();
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
function setlnFeeRateRoot(uint88 newLnFeeRateRoot) public onlyOwner {
|
|
122
129
|
if (newLnFeeRateRoot > maxLnFeeRateRoot)
|
|
123
|
-
revert Errors.
|
|
130
|
+
revert Errors.MarketFactoryLnFeeRateRootTooHigh(newLnFeeRateRoot, maxLnFeeRateRoot);
|
|
124
131
|
|
|
125
132
|
marketConfig.lnFeeRateRoot = newLnFeeRateRoot;
|
|
126
133
|
_emitNewMarketConfigEvent();
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
function setReserveFeePercent(uint8 newReserveFeePercent) public onlyOwner {
|
|
130
|
-
if (newReserveFeePercent >
|
|
131
|
-
revert Errors.
|
|
137
|
+
if (newReserveFeePercent > maxReserveFeePercent)
|
|
138
|
+
revert Errors.MarketFactoryReserveFeePercentTooHigh(
|
|
139
|
+
newReserveFeePercent,
|
|
140
|
+
maxReserveFeePercent
|
|
141
|
+
);
|
|
132
142
|
|
|
133
143
|
marketConfig.reserveFeePercent = newReserveFeePercent;
|
|
134
144
|
_emitNewMarketConfigEvent();
|