@pendle/core-v2 0.16.2-testnet → 0.16.3-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/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 +695 -0
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +4 -0
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +531 -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 +15 -2
- 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/ConvexCurveLP/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
- 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 +89 -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 +15 -2
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
- 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 +2 -2
- 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 +208 -2
- 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/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.json +30 -83
- 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/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/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/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 +67 -0
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/ImplicitSwapfeeContract.sol/ImplicitSwapfeeContract.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.json +2 -36
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +237 -61
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +120 -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 +79 -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 +49 -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 +49 -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 +14 -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/core/BulkSeller/BulkSeller.sol +250 -0
- package/contracts/core/BulkSeller/BulkSellerFactory.sol +89 -0
- package/contracts/core/BulkSeller/BulkSellerMathCore.sol +143 -0
- package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol +2 -4
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +107 -0
- package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +19 -4
- package/contracts/core/libraries/Errors.sol +17 -0
- package/contracts/interfaces/Curve/ICrvPool.sol +9 -27
- 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/IStETH.sol +6 -0
- package/contracts/offchain-helpers/BulkSellerOffchain.sol +43 -0
- package/contracts/offchain-helpers/MarketMathStatic.sol +0 -144
- package/contracts/offchain-helpers/RouterStatic.sol +167 -51
- package/contracts/router/ActionAddRemoveLiq.sol +60 -44
- package/contracts/router/ActionMintRedeem.sol +19 -15
- package/contracts/router/ActionSwapPT.sol +3 -3
- package/contracts/router/ActionSwapYT.sol +11 -4
- package/contracts/router/base/ActionBaseMintRedeem.sol +73 -74
- package/contracts/router/kyberswap/AggregationRouterHelper.sol +17 -1
- package/contracts/router/kyberswap/IAggregatorRouterHelper.sol +10 -0
- package/contracts/router/kyberswap/KyberSwapHelper.sol +17 -8
- package/deployments/43113-core.json +3 -2
- package/deployments/43113-markets/benqi-market-QI-AVAX-FEB-2ND.json +9 -0
- package/deployments/80001-core.json +3 -2
- package/package.json +3 -2
- package/typechain-types/AccessControl.ts +360 -0
- package/typechain-types/ActionAddRemoveLiq.ts +83 -52
- package/typechain-types/ActionBaseMintRedeem.ts +27 -8
- package/typechain-types/ActionMintRedeem.ts +68 -17
- package/typechain-types/ActionSwapPT.ts +53 -12
- package/typechain-types/ActionSwapYT.ts +53 -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 +776 -0
- package/typechain-types/BulkSellerFactory.ts +707 -0
- package/typechain-types/BulkSellerOffchain.ts +117 -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/IAccessControl.ts +305 -0
- package/typechain-types/IAggregationRouterHelper.ts +108 -0
- package/typechain-types/ICrvPool.ts +66 -164
- package/typechain-types/IERC165.ts +102 -0
- package/typechain-types/IPActionAddRemoveLiq.ts +56 -44
- package/typechain-types/IPActionMintRedeem.ts +41 -9
- package/typechain-types/IPActionSwapPT.ts +26 -4
- package/typechain-types/IPActionSwapYT.ts +26 -4
- package/typechain-types/IPAllAction.ts +77 -55
- package/typechain-types/IPBulkSeller.ts +290 -0
- package/typechain-types/IPBulkSellerCallback.ts +115 -0
- package/typechain-types/IPBulkSellerFactory.ts +147 -0
- 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 -50
- 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/PendleMarketFactory.ts +9 -0
- 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 +9 -0
- package/typechain-types/ReentrancyGuardUpgradeable.ts +68 -0
- package/typechain-types/RouterStatic.ts +203 -22
- package/typechain-types/VotingEscrowPendleMainchain.ts +9 -0
- package/typechain-types/VotingEscrowPendleSidechain.ts +9 -0
- package/typechain-types/factories/AccessControl__factory.ts +227 -0
- package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +131 -59
- package/typechain-types/factories/ActionBaseMintRedeem__factory.ts +14 -1
- package/typechain-types/factories/ActionCallback__factory.ts +1 -1
- package/typechain-types/factories/ActionMintRedeem__factory.ts +90 -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 +60 -42
- package/typechain-types/factories/ActionSwapYT__factory.ts +60 -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 +584 -0
- package/typechain-types/factories/BulkSellerOffchain__factory.ts +120 -0
- package/typechain-types/factories/BulkSeller__factory.ts +745 -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/ERC165__factory.ts +39 -0
- package/typechain-types/factories/ERC20__factory.ts +1 -1
- package/typechain-types/factories/Errors__factory.ts +207 -1
- package/typechain-types/factories/IAccessControl__factory.ts +198 -0
- package/typechain-types/factories/IAggregationRouterHelper__factory.ts +54 -0
- package/typechain-types/factories/ICrvPool__factory.ts +30 -83
- package/typechain-types/factories/IERC165__factory.ts +42 -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/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 -35
- 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 +1168 -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/PendleMarketFactory__factory.ts +14 -1
- 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 +14 -1
- package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
- package/typechain-types/factories/ReentrancyGuardUpgradeable__factory.ts +43 -0
- package/typechain-types/factories/RouterStatic__factory.ts +182 -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 +139 -13
- package/typechain-types/index.ts +30 -4
- 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/Pendle3CrvHelper.sol/Pendle3CrvHelper.dbg.json +0 -4
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol/Pendle3CrvHelper.json +0 -76
- package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/Pendle3CrvAndTokenSY.sol +0 -167
- package/contracts/core/StandardizedYield/implementations/Convex/Pendle3CrvHelper.sol +0 -83
|
@@ -0,0 +1,250 @@
|
|
|
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 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
|
+
return IStandardizedYield(SY).deposit(address(this), token, netTokenDeposit, 0);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function _redeemSy(uint256 netSyRedeem) internal returns (uint256 netTokenFromSy) {
|
|
247
|
+
_transferOut(SY, SY, netSyRedeem);
|
|
248
|
+
return IStandardizedYield(SY).redeem(address(this), netSyRedeem, token, 0, true);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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/access/AccessControl.sol";
|
|
7
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
8
|
+
|
|
9
|
+
import "../../interfaces/IStandardizedYield.sol";
|
|
10
|
+
import "../../interfaces/IPBulkSellerFactory.sol";
|
|
11
|
+
import "../libraries/BoringOwnableUpgradeable.sol";
|
|
12
|
+
import "../libraries/Errors.sol";
|
|
13
|
+
|
|
14
|
+
contract BulkSellerFactory is
|
|
15
|
+
IBeacon,
|
|
16
|
+
IPBulkSellerFactory,
|
|
17
|
+
AccessControl,
|
|
18
|
+
UUPSUpgradeable,
|
|
19
|
+
Initializable
|
|
20
|
+
{
|
|
21
|
+
bytes32 public constant MAINTAINER = keccak256("MAINTAINER");
|
|
22
|
+
|
|
23
|
+
address public implementation;
|
|
24
|
+
|
|
25
|
+
mapping(address => mapping(address => address)) internal syToBulkSeller;
|
|
26
|
+
|
|
27
|
+
modifier onlyAdmin() {
|
|
28
|
+
if (!isAdmin(msg.sender)) revert Errors.BulkNotAdmin();
|
|
29
|
+
_;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor() initializer {}
|
|
33
|
+
|
|
34
|
+
function initialize(address implementation_) external initializer {
|
|
35
|
+
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
36
|
+
upgradeBeacon(implementation_);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createBulkSeller(address token, address SY)
|
|
40
|
+
external
|
|
41
|
+
onlyAdmin
|
|
42
|
+
returns (address bulk)
|
|
43
|
+
{
|
|
44
|
+
IStandardizedYield _SY = IStandardizedYield(SY);
|
|
45
|
+
if (syToBulkSeller[token][SY] != address(0))
|
|
46
|
+
revert Errors.BulkSellerAlreadyExisted(token, SY, syToBulkSeller[token][SY]);
|
|
47
|
+
if (_SY.isValidTokenIn(token) == false || _SY.isValidTokenOut(token) == false)
|
|
48
|
+
revert Errors.BulkSellerInvalidToken(token, SY);
|
|
49
|
+
|
|
50
|
+
bytes memory data = abi.encodeWithSignature(
|
|
51
|
+
"initialize(address,address,address)",
|
|
52
|
+
token,
|
|
53
|
+
SY,
|
|
54
|
+
address(this)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
bulk = address(new BeaconProxy(address(this), data));
|
|
58
|
+
|
|
59
|
+
syToBulkSeller[token][SY] = bulk;
|
|
60
|
+
|
|
61
|
+
return bulk;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function get(address token, address SY) external view override returns (address) {
|
|
65
|
+
if (syToBulkSeller[token][SY] == address(0))
|
|
66
|
+
revert Errors.RouterBulkSellerNotFound(token, SY);
|
|
67
|
+
return syToBulkSeller[token][SY];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function isMaintainer(address addr) public view override returns (bool) {
|
|
71
|
+
return (hasRole(DEFAULT_ADMIN_ROLE, addr) || hasRole(MAINTAINER, addr));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isAdmin(address addr) public view override returns (bool) {
|
|
75
|
+
return hasRole(DEFAULT_ADMIN_ROLE, addr);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ----------------- upgrade-related -----------------
|
|
79
|
+
function upgradeBeacon(address newImplementation) public onlyAdmin {
|
|
80
|
+
require(
|
|
81
|
+
Address.isContract(newImplementation),
|
|
82
|
+
"UpgradeableBeacon: implementation is not a contract"
|
|
83
|
+
);
|
|
84
|
+
implementation = newImplementation;
|
|
85
|
+
emit UpgradedBeacon(newImplementation);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _authorizeUpgrade(address) internal override onlyAdmin {}
|
|
89
|
+
}
|
|
@@ -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 rateTokenToSy,
|
|
123
|
+
uint256 rateSyToToken,
|
|
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
|
+
}
|
package/contracts/core/StandardizedYield/implementations/Convex/ConvexCurveLP/PendleConvexLPSY.sol
CHANGED
|
@@ -143,12 +143,10 @@ abstract contract PendleConvexLPSY is SYBaseWithRewards {
|
|
|
143
143
|
override
|
|
144
144
|
returns (uint256 amountTokenOut)
|
|
145
145
|
{
|
|
146
|
-
uint256 amountLpTokenToReceive = (amountSharesToRedeem * exchangeRate()) / 1e18;
|
|
147
|
-
|
|
148
146
|
if (tokenOut == crvLp) {
|
|
149
|
-
amountTokenOut =
|
|
147
|
+
amountTokenOut = amountSharesToRedeem;
|
|
150
148
|
} else {
|
|
151
|
-
amountTokenOut = _previewRedeemFromCurve(tokenOut,
|
|
149
|
+
amountTokenOut = _previewRedeemFromCurve(tokenOut, amountSharesToRedeem);
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
|
package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../../../libraries/math/Math.sol";
|
|
5
|
+
import "../../../../../interfaces/Curve/ICrvPool.sol";
|
|
6
|
+
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
7
|
+
|
|
8
|
+
library CurveFraxUsdcPoolHelper {
|
|
9
|
+
uint256 public constant N_COINS = 2;
|
|
10
|
+
uint256 public constant A_PRECISION = 100;
|
|
11
|
+
uint256 public constant PRECISION = 10 ** 18;
|
|
12
|
+
uint256 public constant RATE_0 = 1000000000000000000;
|
|
13
|
+
uint256 public constant RATE_1 = 1000000000000000000000000000000;
|
|
14
|
+
uint256 public constant FEE_DENOMINATOR = 10 ** 10;
|
|
15
|
+
|
|
16
|
+
using Math for uint256;
|
|
17
|
+
|
|
18
|
+
function previewAddLiquidity(address pool, uint256[N_COINS] memory _amounts) internal view returns (uint256) {
|
|
19
|
+
uint256 amp = ICrvPool(pool).A_precise();
|
|
20
|
+
uint256[N_COINS] memory old_balances;
|
|
21
|
+
old_balances[0] = ICrvPool(pool).balances(0);
|
|
22
|
+
old_balances[1] = ICrvPool(pool).balances(1);
|
|
23
|
+
uint256 D0 = _get_D_mem(old_balances, amp);
|
|
24
|
+
|
|
25
|
+
address lp_token = ICrvPool(pool).lp_token();
|
|
26
|
+
uint256 total_supply = IERC20(lp_token).totalSupply();
|
|
27
|
+
|
|
28
|
+
uint256[N_COINS] memory new_balances;
|
|
29
|
+
new_balances[0] = old_balances[0];
|
|
30
|
+
new_balances[1] = old_balances[1];
|
|
31
|
+
|
|
32
|
+
for(uint256 i = 0; i < N_COINS; ++i) {
|
|
33
|
+
// skip totalSupply = 0 check
|
|
34
|
+
new_balances[i] += _amounts[i];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
uint256 D1 = _get_D_mem(new_balances, amp);
|
|
38
|
+
assert (D1 > D0);
|
|
39
|
+
|
|
40
|
+
uint256[N_COINS] memory fees;
|
|
41
|
+
|
|
42
|
+
// skip total_supply > 0 check
|
|
43
|
+
uint256 fee = ICrvPool(pool).fee() * N_COINS / (4 * (N_COINS - 1));
|
|
44
|
+
for (uint256 i = 0; i < N_COINS; ++i) {
|
|
45
|
+
uint256 ideal_balance = D1 * old_balances[i] / D0;
|
|
46
|
+
uint256 difference = 0;
|
|
47
|
+
uint256 new_balance = new_balances[i];
|
|
48
|
+
|
|
49
|
+
if (ideal_balance > new_balance) {
|
|
50
|
+
difference = ideal_balance - new_balance;
|
|
51
|
+
} else {
|
|
52
|
+
difference = new_balance - ideal_balance;
|
|
53
|
+
}
|
|
54
|
+
fees[i] = fee * difference / FEE_DENOMINATOR;
|
|
55
|
+
new_balances[i] -= fees[i];
|
|
56
|
+
}
|
|
57
|
+
uint256 D2 = _get_D_mem(new_balances, amp);
|
|
58
|
+
return total_supply * (D2 - D0) / D0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _get_D_mem(uint256[N_COINS] memory balances, uint256 _amp)
|
|
62
|
+
internal
|
|
63
|
+
pure
|
|
64
|
+
returns (uint256)
|
|
65
|
+
{
|
|
66
|
+
uint256[N_COINS] memory _xp;
|
|
67
|
+
_xp[0] = RATE_0 * balances[0] / PRECISION;
|
|
68
|
+
_xp[1] = RATE_1 * balances[1] / PRECISION;
|
|
69
|
+
|
|
70
|
+
return _get_D(_xp, _amp);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function _get_D(uint256[N_COINS] memory _xp, uint256 _amp) internal pure returns (uint256) {
|
|
74
|
+
uint256 S = 0;
|
|
75
|
+
uint256 Dprev = 0;
|
|
76
|
+
|
|
77
|
+
for (uint256 k = 0; k < N_COINS; ++k) {
|
|
78
|
+
S += _xp[k];
|
|
79
|
+
}
|
|
80
|
+
if (S == 0) return 0;
|
|
81
|
+
|
|
82
|
+
uint256 D = S;
|
|
83
|
+
uint256 Ann = _amp * N_COINS;
|
|
84
|
+
|
|
85
|
+
for (uint256 _i = 0; _i < 255; ++_i) {
|
|
86
|
+
uint256 D_P = D;
|
|
87
|
+
for (uint256 k = 0; k < N_COINS; ++k) {
|
|
88
|
+
D_P = (D_P * D) / (_xp[k] * N_COINS);
|
|
89
|
+
}
|
|
90
|
+
Dprev = D;
|
|
91
|
+
D =
|
|
92
|
+
(((Ann * S) / A_PRECISION + D_P * N_COINS) * D) /
|
|
93
|
+
(((Ann - A_PRECISION) * D) / A_PRECISION + (N_COINS + 1) * D_P);
|
|
94
|
+
|
|
95
|
+
if (D > Dprev) {
|
|
96
|
+
if (D - Dprev <= 1) {
|
|
97
|
+
return D;
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
if (Dprev - D <= 1) {
|
|
101
|
+
return D;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
assert(false);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -50,9 +50,10 @@ contract PendleWstEthSY is SYBase {
|
|
|
50
50
|
} else {
|
|
51
51
|
if (tokenIn == wETH) IWETH(wETH).withdraw(amountDeposited);
|
|
52
52
|
|
|
53
|
-
uint256
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
uint256 amountStEthSharesOut = IStETH(stETH).submit{ value: amountDeposited }(
|
|
54
|
+
address(0)
|
|
55
|
+
);
|
|
56
|
+
amountStETH = IStETH(stETH).getPooledEthByShares(amountStEthSharesOut);
|
|
56
57
|
}
|
|
57
58
|
amountSharesOut = IWstETH(wstETH).wrap(amountStETH);
|
|
58
59
|
}
|
|
@@ -101,7 +102,21 @@ contract PendleWstEthSY is SYBase {
|
|
|
101
102
|
{
|
|
102
103
|
if (tokenIn == wstETH) amountSharesOut = amountTokenToDeposit;
|
|
103
104
|
else {
|
|
104
|
-
|
|
105
|
+
if (tokenIn != stETH) {
|
|
106
|
+
uint256 totalShares = IStETH(stETH).getTotalShares();
|
|
107
|
+
uint256 totalPooledEth = IStETH(stETH).getTotalPooledEther();
|
|
108
|
+
uint256 amountStEthSharesOut = IStETH(stETH).getSharesByPooledEth(
|
|
109
|
+
amountTokenToDeposit
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
totalShares += amountStEthSharesOut;
|
|
113
|
+
totalPooledEth += amountTokenToDeposit;
|
|
114
|
+
|
|
115
|
+
uint256 stEthBalance = (amountStEthSharesOut * totalPooledEth) / totalShares;
|
|
116
|
+
amountSharesOut = (stEthBalance * totalShares) / totalPooledEth;
|
|
117
|
+
} else {
|
|
118
|
+
amountSharesOut = IStETH(stETH).getSharesByPooledEth(amountTokenToDeposit);
|
|
119
|
+
}
|
|
105
120
|
}
|
|
106
121
|
}
|
|
107
122
|
|
|
@@ -4,6 +4,20 @@ pragma solidity 0.8.17;
|
|
|
4
4
|
/// Adapted from UniswapV3's Oracle
|
|
5
5
|
|
|
6
6
|
library Errors {
|
|
7
|
+
// BulkSeller
|
|
8
|
+
error BulkInsufficientSyForTrade(uint256 currentAmount, uint256 requiredAmount);
|
|
9
|
+
error BulkInsufficientTokenForTrade(uint256 currentAmount, uint256 requiredAmount);
|
|
10
|
+
error BulkInSufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut);
|
|
11
|
+
error BulkInSufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);
|
|
12
|
+
error BulkInsufficientTokenReceived(uint256 actualBalance, uint256 requiredBalance);
|
|
13
|
+
error BulkInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance);
|
|
14
|
+
error BulkNotMaintainer();
|
|
15
|
+
error BulkNotAdmin();
|
|
16
|
+
error BulkSellerAlreadyExisted(address token, address SY, address bulkSeller);
|
|
17
|
+
error BulkSellerInvalidToken(address token, address SY);
|
|
18
|
+
error BulkBadRateTokenToSy(uint256 actualRate, uint256 currentRate, uint256 eps);
|
|
19
|
+
error BulkBadRateSyToToken(uint256 actualRate, uint256 currentRate, uint256 eps);
|
|
20
|
+
|
|
7
21
|
// APPROX
|
|
8
22
|
error ApproxFail();
|
|
9
23
|
error ApproxParamsInvalid(uint256 guessMin, uint256 guessMax, uint256 eps);
|
|
@@ -46,12 +60,15 @@ library Errors {
|
|
|
46
60
|
error RouterExceededLimitYtIn(uint256 actualYtIn, uint256 limitYtIn);
|
|
47
61
|
error RouterInsufficientSyRepay(uint256 actualSyRepay, uint256 requiredSyRepay);
|
|
48
62
|
error RouterInsufficientPtRepay(uint256 actualPtRepay, uint256 requiredPtRepay);
|
|
63
|
+
error RouterBulkSellerNotFound(address token, address SY);
|
|
49
64
|
error RouterNotAllSyUsed(uint256 netSyDesired, uint256 netSyUsed);
|
|
50
65
|
|
|
51
66
|
error RouterTimeRangeZero();
|
|
52
67
|
error RouterCallbackNotPendleMarket(address caller);
|
|
53
68
|
error RouterInvalidAction(bytes4 selector);
|
|
54
69
|
|
|
70
|
+
error RouterKyberSwapDataZero();
|
|
71
|
+
|
|
55
72
|
// YIELD CONTRACT
|
|
56
73
|
error YCExpired();
|
|
57
74
|
error YCNotExpired();
|