@pendle/core-v2 2.15.2 → 2.16.0
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/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/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol/ExcessivelySafeCall.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol/PendleFeeDistributorV2.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- 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/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- 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/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
- 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/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- 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/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/SYUtils.sol/SYUtils.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/StEthHelper.sol/StEthHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol/PendleAuraBbAWethSwethSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol/PendleAuraBbAWethSwethSY.json +1189 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol/PendleAuraWethAnkrethSYV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol/PendleAuraWethAnkrethSYV2.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol/PendleAuraWethRocketEthSYV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol/PendleAuraWethRocketEthSYV2.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol/PendleAuraWethStafiEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol/PendleAuraWethStafiEthSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol/PendleAuraWethWstethSYV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol/PendleAuraWethWstethSYV2.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol/ComposableStableMath.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol/ComposableStableMath.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreview.sol/ComposableStablePreview.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreview.sol/ComposableStablePreview.json +322 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/FixedPoint.sol/FixedPoint.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol/BbAPoolHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol/BbAPoolHelper.json +24 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol/BbAWethHelper.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol/BbAWethHelper.json +24 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol/LinearMath.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol/LinearMath.json +10 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearPreview.sol/LinearPreview.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearPreview.sol/LinearPreview.json +234 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol/MetaStableMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol/MetaStablePreview.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol/MetaStablePreview.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol/PendleAuraBalancerStableLPSYV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol/StablePoolUserData.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol/StablePreviewBase.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/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotRewardHelper.sol/CamelotRewardHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileCommon.sol/CamelotV1VolatileCommon.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileLpHelper.sol/CamelotV1VolatileLpHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatilePreview.sol/CamelotV1VolatilePreview.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol/PendleCamelotV1VolatileSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol/Curve3CrvPoolHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol/CurveFraxUsdcPoolHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol/CurveUsdd3CrvPoolHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/GLPPreviewHelper.sol/GLPPreviewHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol/PendleGDaiSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol/PendleSfrxEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol/PendleStargateLPSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
- 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/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContractsV2/InterestManagerYTV2.sol/InterestManagerYTV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol/PendlePrincipalTokenV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/erc20/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/ArrayLib.sol/ArrayLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/BaseSplitCodeFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BaseSplitCodeFactory.sol/CodeDeployer.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeable.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/BoringOwnableUpgradeable.sol/BoringOwnableUpgradeableData.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/ExpiryUtilsLib.sol/ExpiryUtils.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/StringLib.sol/StringLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/math/LogExpMath.sol/LogExpMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/math/Math.sol/Math.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IAsset.sol/IAsset.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerFees.sol/IBalancerFees.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerStablePreview.sol/IBalancerStablePreview.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IBasePool.sol/IBasePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IComposableStable.sol/IComposableStable.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IERC4626LinearPool.sol/IERC4626LinearPool.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Balancer/IERC4626LinearPool.sol/IERC4626LinearPool.json +1172 -0
- package/build/artifacts/contracts/interfaces/Balancer/IGauge.sol/IGauge.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/ILiquidityGaugeFactory.sol/ILiquidityGaugeFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IMetaStablePool.sol/IMetaStablePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IRateProvider.sol/IRateProvider.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IVault.sol/IVault.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotFactory.sol/ICamelotFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotNFTFactory.sol/ICamelotNFTFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotNFTHandler.sol/ICamelotNFTHandler.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotNFTPool.sol/ICamelotNFTPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotNitroPool.sol/ICamelotNitroPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotNitroPoolFactory.sol/ICamelotNitroPoolFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotPair.sol/ICamelotPair.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotRouter.sol/ICamelotRouter.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/ICamelotYieldBooster.sol/ICamelotYieldBooster.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Camelot/IXGrail.sol/IXGrail.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IBooster.sol/IBooster.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICrvDepositor.sol/ICrvDepositor.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/ICvxCrv.sol/ICvxCrv.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ICrvPool.sol/ICrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Curve/ITriCrvPool.sol/ITriCrvPool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Frax/IFrxEthMinter.sol/IFrxEthMinter.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/GMX/IGMXVault.sol/IGMXVault.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/GMX/IGlpManager.sol/IGlpManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/GMX/IRewardRouterV2.sol/IRewardRouterV2.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/GMX/IVaultPriceFeed.sol/IVaultPriceFeed.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAddressProvider.sol/IAddressProvider.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiComptroller.sol/IBenQiComptroller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiInterestRateModel.sol/IBenQiInterestRateModel.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IDiamondCut.sol/IDiamondCut.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IDiamondLoupe.sol/IDiamondLoupe.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILayerZeroEndpoint.sol/ILayerZeroEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILayerZeroReceiver.sol/ILayerZeroReceiver.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILooksFeeSharing.sol/ILooksFeeSharing.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ILooksStaking.sol/ILooksStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionInfoStatic.sol/IPActionInfoStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMarketAuxStatic.sol/IPActionMarketAuxStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMarketCoreStatic.sol/IPActionMarketCoreStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeemStatic.sol/IPActionMintRedeemStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMisc.sol/IPActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionStorageStatic.sol/IPActionStorageStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionVePendleStatic.sol/IPActionVePendleStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSellerFactory.sol/IPBulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSellerSYCallback.sol/IPBulkSellerCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributorV2.sol/IPFeeDistributorV2.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGauge.sol/IPGauge.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeController.sol/IPGaugeController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeControllerMainchain.sol/IPGaugeControllerMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPInterestManagerYT.sol/IPInterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPInterestManagerYTV2.sol/IPInterestManagerYTV2.dbg.json +1 -1
- 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/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMiniDiamond.sol/IPMiniDiamond.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgReceiverApp.sol/IPMsgReceiverApp.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMsgSendEndpoint.sol/IPMsgSendEndpoint.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPtOracle.sol/IPPtOracle.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPRouterHelper.sol/IPRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVeToken.sol/IPVeToken.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/IPYieldTokenV2.sol/IPYieldTokenV2.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/IRewardManager.sol/IRewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStETH.sol/IStETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargateLP.sol/IStargateLP.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargateRouter.sol/IStargateRouter.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IStargateStaking.sol/IStargateStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWstETH.sol/IWstETH.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/AddressProvider.sol/AddressProvider.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol/BaseSplitCodeFactoryContract.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BoringPtSeller.sol/BoringPtSeller.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/Broadcaster.sol/Broadcaster.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/EmptyUUPS.sol/EmptyUUPS.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketExchangeRateLib.sol/MarketExchangeRateLib.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/MarketExchangeRateLib.sol/MarketExchangeRateLib.json +10 -0
- package/build/artifacts/contracts/offchain-helpers/Multicall2.sol/Multicall2.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/PendleMulticallV1.sol/PendleMulticallV1.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/PendleRouterStatic.sol/PendleRouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol/ActionInfoStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol/ActionMarketCoreStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol/ActionMintRedeemStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol/ActionStorageStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol/ActionVePendleStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/StorageLayout.sol/StorageLayout.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/PendlePtOracle.sol/PendlePtOracle.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/samples/PendlePtGlpOracle.sol/PendlePtGlpOracle.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/samples/PendlePtUsdChainlinkOracle.sol/PendlePtUsdChainlinkOracle.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouterHelper.sol/PendleRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/ActionBaseCallback.sol/ActionBaseCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/swap-aggregator/IPSwapAggregator.sol/IPSwapAggregator.dbg.json +1 -1
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/PendleSwap.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/PendleSwap.json +60 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IAggregationExecutor.sol/IAggregationExecutor.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/{arbitrum/IAggregationExecutor.sol → IAggregationExecutor.sol}/IAggregationExecutor.json +1 -1
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol/IExecutorHelper.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/{arbitrum/IExecutorHelper1.sol/IExecutorHelper1.json → IExecutorHelper.sol/IExecutorHelper.json} +147 -2
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IHashflow.sol/IHashflow.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/{ethereum/IHashflow.sol → IHashflow.sol}/IHashflow.json +1 -1
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/{arbitrum/IMetaAggregationRouterV2.sol → IMetaAggregationRouterV2.sol}/IMetaAggregationRouterV2.json +1 -1
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/KyberInputScalingHelper.sol/KyberInputScalingHelper.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/{arbitrum/KyberHelperArbitrum.sol/KyberHelperArbitrum.json → KyberInputScalingHelper.sol/KyberInputScalingHelper.json} +2 -2
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ScalingDataLib.sol/ScalingDataLib.dbg.json +4 -0
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ScalingDataLib.sol/ScalingDataLib.json +10 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol +153 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol +289 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreview.sol +629 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol +113 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol +381 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearPreview.sol +206 -0
- package/contracts/interfaces/Balancer/IERC4626LinearPool.sol +181 -0
- package/contracts/interfaces/Balancer/IVault.sol +13 -0
- package/deployments/1-markets/BALANCER-LP-AURA-BBAWETHSWETH-SEP-26-2024.json +10 -0
- package/deployments/1-markets/STETH-DEC2027.json +10 -0
- package/package.json +1 -1
- package/typechain-types/BbAPoolHelper.ts +89 -0
- package/typechain-types/BbAWethHelper.ts +89 -0
- package/typechain-types/ComposableStablePreview.ts +501 -0
- package/typechain-types/IERC4626LinearPool.ts +1649 -0
- package/typechain-types/IExecutorHelper.ts +863 -0
- package/typechain-types/{CamelotV1PreviewHelper.ts → LinearPreview.ts} +49 -118
- package/typechain-types/{PendleCamelotV1SY.ts → PendleAuraBbAWethSwethSY.ts} +199 -383
- package/typechain-types/PendleSwap.ts +126 -0
- package/typechain-types/factories/BbAPoolHelper__factory.ts +36 -0
- package/typechain-types/factories/BbAWethHelper__factory.ts +36 -0
- package/typechain-types/factories/ComposableStablePreview__factory.ts +379 -0
- package/typechain-types/factories/IERC4626LinearPool__factory.ts +1187 -0
- package/typechain-types/factories/IExecutorHelper__factory.ts +548 -0
- package/typechain-types/factories/LinearPreview__factory.ts +284 -0
- package/typechain-types/factories/MetaStablePreview__factory.ts +1 -1
- package/typechain-types/factories/PendleAuraBbAWethSwethSY__factory.ts +1266 -0
- package/typechain-types/factories/PendleAuraWethAnkrethSYV2__factory.ts +1 -1
- package/typechain-types/factories/PendleAuraWethRocketEthSYV2__factory.ts +1 -1
- package/typechain-types/factories/PendleAuraWethStafiEthSY__factory.ts +1 -1
- package/typechain-types/factories/PendleAuraWethWstethSYV2__factory.ts +1 -1
- package/typechain-types/factories/PendleSwap__factory.ts +110 -0
- package/typechain-types/hardhat.d.ts +99 -0
- package/typechain-types/index.ts +16 -0
- package/build/artifacts/contracts/router/swap-aggregator/1inch/I1inchAggregationRouterV5.sol/I1inchAggregationRouterV5.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/1inch/I1inchAggregationRouterV5.sol/I1inchAggregationRouterV5.json +0 -160
- package/build/artifacts/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol/OneInchAggregationRouterHelper.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol/OneInchAggregationRouterHelper.json +0 -10
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwapArbitrum.sol/PendleSwapArbitrum.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwapArbitrum.sol/PendleSwapArbitrum.json +0 -76
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwapEthereum.sol/PendleSwapEthereum.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/PendleSwapEthereum.sol/PendleSwapEthereum.json +0 -76
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/IAggregationExecutor.sol/IAggregationExecutor.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/IExecutorHelper1.sol/IExecutorHelper1.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/IExecutorHelper2.sol/IExecutorHelper2.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/IExecutorHelper2.sol/IExecutorHelper2.json +0 -40
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/IHashflow.sol/IHashflow.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/IHashflow.sol/IHashflow.json +0 -101
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/KyberHelperArbitrum.sol/KyberHelperArbitrum.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/ScaleDataHelperArbitrum.sol/ScaleDataHelperArbitrum.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/arbitrum/ScaleDataHelperArbitrum.sol/ScaleDataHelperArbitrum.json +0 -10
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/IAggregationExecutor.sol/IAggregationExecutor.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/IAggregationExecutor.sol/IAggregationExecutor.json +0 -65
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/IExecutorHelperEthereum1.sol/IExecutorHelperEthereum1.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/IExecutorHelperEthereum1.sol/IExecutorHelperEthereum1.json +0 -388
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/IHashflow.sol/IHashflow.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.json +0 -215
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/KyberHelperEthereum.sol/KyberHelperEthereum.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/KyberHelperEthereum.sol/KyberHelperEthereum.json +0 -10
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/ScaleDataHelperEthereum.sol/ScaleDataHelperEthereum.dbg.json +0 -4
- package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ethereum/ScaleDataHelperEthereum.sol/ScaleDataHelperEthereum.json +0 -10
- package/typechain-types/IPVotingEscrowSidechain.ts +0 -155
- package/typechain-types/PendleCamelotRewardHelper.ts +0 -347
- package/typechain-types/PendleCamelotV1RouterHelper.ts +0 -133
- package/typechain-types/factories/CamelotV1PreviewHelper__factory.ts +0 -400
- package/typechain-types/factories/IPVotingEscrowSidechain__factory.ts +0 -112
- package/typechain-types/factories/PendleCamelotRewardHelper__factory.ts +0 -317
- package/typechain-types/factories/PendleCamelotV1RouterHelper__factory.ts +0 -95
- package/typechain-types/factories/PendleCamelotV1SY__factory.ts +0 -1448
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../../../../libraries/TokenHelper.sol";
|
|
5
|
+
import "../../../../../../interfaces/Balancer/IVault.sol";
|
|
6
|
+
import "./LinearPreview.sol";
|
|
7
|
+
|
|
8
|
+
abstract contract BbAPoolHelper is TokenHelper {
|
|
9
|
+
address private constant BALANCER_VAULT = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;
|
|
10
|
+
bytes private constant EMPTY_BYTES = abi.encode();
|
|
11
|
+
|
|
12
|
+
LinearPreview public immutable linearPreviewHelper;
|
|
13
|
+
|
|
14
|
+
constructor(LinearPreview _linearPreviewHelper) {
|
|
15
|
+
linearPreviewHelper = _linearPreviewHelper;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _safeApproveInfVault(address token) internal {
|
|
19
|
+
_safeApproveInf(token, BALANCER_VAULT);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function joinExitPool(
|
|
23
|
+
address receiver,
|
|
24
|
+
bytes32 poolId,
|
|
25
|
+
address tokenIn,
|
|
26
|
+
address tokenOut,
|
|
27
|
+
uint256 amountIn
|
|
28
|
+
) internal returns (uint256 amountOut) {
|
|
29
|
+
return
|
|
30
|
+
IVault(BALANCER_VAULT).swap{ value: (tokenIn == NATIVE ? amountIn : 0) }(
|
|
31
|
+
IVault.SingleSwap({
|
|
32
|
+
poolId: poolId,
|
|
33
|
+
kind: IVault.SwapKind.GIVEN_IN,
|
|
34
|
+
assetIn: IAsset(tokenIn),
|
|
35
|
+
assetOut: IAsset(tokenOut),
|
|
36
|
+
amount: amountIn,
|
|
37
|
+
userData: EMPTY_BYTES
|
|
38
|
+
}),
|
|
39
|
+
IVault.FundManagement({
|
|
40
|
+
sender: address(this),
|
|
41
|
+
fromInternalBalance: false,
|
|
42
|
+
recipient: payable(receiver),
|
|
43
|
+
toInternalBalance: false
|
|
44
|
+
}),
|
|
45
|
+
0,
|
|
46
|
+
block.timestamp
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
abstract contract BbAWethHelper is BbAPoolHelper {
|
|
52
|
+
address internal constant BB_A_WETH = 0x60D604890feaa0b5460B28A424407c24fe89374a;
|
|
53
|
+
address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
|
|
54
|
+
address internal constant WA_WETH = 0x59463BB67dDD04fe58ED291ba36C26d99A39fbc6;
|
|
55
|
+
bytes32 internal constant BB_A_WETH_POOL_ID =
|
|
56
|
+
bytes32(0x60d604890feaa0b5460b28a424407c24fe89374a0000000000000000000004fc);
|
|
57
|
+
|
|
58
|
+
constructor(LinearPreview _linearPreviewHelper) BbAPoolHelper(_linearPreviewHelper) {
|
|
59
|
+
_safeApproveInfVault(WETH);
|
|
60
|
+
_safeApproveInfVault(WA_WETH);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _depositBbAWeth(address tokenIn, uint256 amountDep)
|
|
64
|
+
internal
|
|
65
|
+
virtual
|
|
66
|
+
returns (uint256 amountOut)
|
|
67
|
+
{
|
|
68
|
+
amountOut = joinExitPool(address(this), BB_A_WETH_POOL_ID, tokenIn, BB_A_WETH, amountDep);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _redeemBbAWeth(
|
|
72
|
+
address receiver,
|
|
73
|
+
address tokenOut,
|
|
74
|
+
uint256 amountRedeem
|
|
75
|
+
) internal virtual returns (uint256 amountTokenOut) {
|
|
76
|
+
amountTokenOut = joinExitPool(
|
|
77
|
+
receiver,
|
|
78
|
+
BB_A_WETH_POOL_ID,
|
|
79
|
+
BB_A_WETH,
|
|
80
|
+
tokenOut,
|
|
81
|
+
amountRedeem
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function _previewDepositBbAWeth(address tokenIn, uint256 amountDep)
|
|
86
|
+
internal
|
|
87
|
+
view
|
|
88
|
+
virtual
|
|
89
|
+
returns (uint256 amountOut)
|
|
90
|
+
{
|
|
91
|
+
return
|
|
92
|
+
linearPreviewHelper.joinExitPoolPreview(
|
|
93
|
+
BB_A_WETH_POOL_ID,
|
|
94
|
+
tokenIn == NATIVE ? WETH : tokenIn,
|
|
95
|
+
BB_A_WETH,
|
|
96
|
+
amountDep
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _previewRedeemBbAWeth(address tokenOut, uint256 amountRedeem)
|
|
101
|
+
internal
|
|
102
|
+
view
|
|
103
|
+
returns (uint256 amountOut)
|
|
104
|
+
{
|
|
105
|
+
return
|
|
106
|
+
linearPreviewHelper.joinExitPoolPreview(
|
|
107
|
+
BB_A_WETH_POOL_ID,
|
|
108
|
+
BB_A_WETH,
|
|
109
|
+
tokenOut == NATIVE ? WETH : tokenOut,
|
|
110
|
+
amountRedeem
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
|
+
import "../FixedPoint.sol";
|
|
4
|
+
|
|
5
|
+
// These functions start with an underscore, as if they were part of a contract and not a library. At some point this
|
|
6
|
+
// should be fixed.
|
|
7
|
+
// solhint-disable private-vars-leading-underscore
|
|
8
|
+
|
|
9
|
+
library LinearMath {
|
|
10
|
+
using FixedPoint for uint256;
|
|
11
|
+
|
|
12
|
+
// A thorough derivation of the formulas and derivations found here exceeds the scope of this file, so only
|
|
13
|
+
// introductory notions will be presented.
|
|
14
|
+
|
|
15
|
+
// A Linear Pool holds three tokens: the main token, the wrapped token, and the Pool share token (BPT). It is
|
|
16
|
+
// possible to exchange any of these tokens for any of the other two (so we have three trading pairs) in both
|
|
17
|
+
// directions (the first token of each pair can be bought or sold for the second) and by specifying either the input
|
|
18
|
+
// or output amount (typically referred to as 'given in' or 'given out'). A full description thus requires
|
|
19
|
+
// 3*2*2 = 12 functions.
|
|
20
|
+
// Wrapped tokens have a known, trusted exchange rate to main tokens. All functions here assume such a rate has
|
|
21
|
+
// already been applied, meaning main and wrapped balances can be compared as they are both expressed in the same
|
|
22
|
+
// units (those of main token).
|
|
23
|
+
// Additionally, Linear Pools feature a lower and upper target that represent the desired range of values for the
|
|
24
|
+
// main token balance. Any action that moves the main balance away from this range is charged a proportional fee,
|
|
25
|
+
// and any action that moves it towards this range is incentivized by paying the actor using these collected fees.
|
|
26
|
+
// The collected fees are not stored in a separate data structure: they are a function of the current main balance,
|
|
27
|
+
// targets and fee percentage. The main balance sans fees is known as the 'nominal balance', which is always smaller
|
|
28
|
+
// than the real balance except when the real balance is within the targets.
|
|
29
|
+
// The rule under which Linear Pools conduct trades between main and wrapped tokens is by keeping the sum of nominal
|
|
30
|
+
// main balance and wrapped balance constant: this value is known as the 'invariant'. BPT is backed by nominal
|
|
31
|
+
// reserves, meaning its supply is proportional to the invariant. As the wrapped token appreciates in value and its
|
|
32
|
+
// exchange rate to the main token increases, so does the invariant and thus the value of BPT (in main token units).
|
|
33
|
+
|
|
34
|
+
struct Params {
|
|
35
|
+
uint256 fee;
|
|
36
|
+
uint256 lowerTarget;
|
|
37
|
+
uint256 upperTarget;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _calcBptOutPerMainIn(
|
|
41
|
+
uint256 mainIn,
|
|
42
|
+
uint256 mainBalance,
|
|
43
|
+
uint256 wrappedBalance,
|
|
44
|
+
uint256 bptSupply,
|
|
45
|
+
Params memory params
|
|
46
|
+
) internal pure returns (uint256) {
|
|
47
|
+
// Amount out, so we round down overall.
|
|
48
|
+
|
|
49
|
+
if (bptSupply == 0) {
|
|
50
|
+
// BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the
|
|
51
|
+
// BPT supply is initialized to equal the invariant (which in this case is just the nominal main balance as
|
|
52
|
+
// there is no wrapped balance).
|
|
53
|
+
return _toNominal(mainIn, params);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
57
|
+
uint256 afterNominalMain = _toNominal(mainBalance.add(mainIn), params);
|
|
58
|
+
uint256 deltaNominalMain = afterNominalMain.sub(previousNominalMain);
|
|
59
|
+
uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance);
|
|
60
|
+
return divDown(mul(bptSupply, deltaNominalMain), invariant);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _calcBptInPerMainOut(
|
|
64
|
+
uint256 mainOut,
|
|
65
|
+
uint256 mainBalance,
|
|
66
|
+
uint256 wrappedBalance,
|
|
67
|
+
uint256 bptSupply,
|
|
68
|
+
Params memory params
|
|
69
|
+
) internal pure returns (uint256) {
|
|
70
|
+
// Amount in, so we round up overall.
|
|
71
|
+
|
|
72
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
73
|
+
uint256 afterNominalMain = _toNominal(mainBalance.sub(mainOut), params);
|
|
74
|
+
uint256 deltaNominalMain = previousNominalMain.sub(afterNominalMain);
|
|
75
|
+
uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance);
|
|
76
|
+
return divUp(mul(bptSupply, deltaNominalMain), invariant);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _calcWrappedOutPerMainIn(
|
|
80
|
+
uint256 mainIn,
|
|
81
|
+
uint256 mainBalance,
|
|
82
|
+
Params memory params
|
|
83
|
+
) internal pure returns (uint256) {
|
|
84
|
+
// Amount out, so we round down overall.
|
|
85
|
+
|
|
86
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
87
|
+
uint256 afterNominalMain = _toNominal(mainBalance.add(mainIn), params);
|
|
88
|
+
return afterNominalMain.sub(previousNominalMain);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function _calcWrappedInPerMainOut(
|
|
92
|
+
uint256 mainOut,
|
|
93
|
+
uint256 mainBalance,
|
|
94
|
+
Params memory params
|
|
95
|
+
) internal pure returns (uint256) {
|
|
96
|
+
// Amount in, so we round up overall.
|
|
97
|
+
|
|
98
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
99
|
+
uint256 afterNominalMain = _toNominal(mainBalance.sub(mainOut), params);
|
|
100
|
+
return previousNominalMain.sub(afterNominalMain);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function _calcMainInPerBptOut(
|
|
104
|
+
uint256 bptOut,
|
|
105
|
+
uint256 mainBalance,
|
|
106
|
+
uint256 wrappedBalance,
|
|
107
|
+
uint256 bptSupply,
|
|
108
|
+
Params memory params
|
|
109
|
+
) internal pure returns (uint256) {
|
|
110
|
+
// Amount in, so we round up overall.
|
|
111
|
+
|
|
112
|
+
if (bptSupply == 0) {
|
|
113
|
+
// BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the
|
|
114
|
+
// BPT supply is initialized to equal the invariant (which in this case is just the nominal main balance as
|
|
115
|
+
// there is no wrapped balance).
|
|
116
|
+
return _fromNominal(bptOut, params);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
120
|
+
uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance);
|
|
121
|
+
uint256 deltaNominalMain = divUp(mul(invariant, bptOut), bptSupply);
|
|
122
|
+
uint256 afterNominalMain = previousNominalMain.add(deltaNominalMain);
|
|
123
|
+
uint256 newMainBalance = _fromNominal(afterNominalMain, params);
|
|
124
|
+
return newMainBalance.sub(mainBalance);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function _calcMainOutPerBptIn(
|
|
128
|
+
uint256 bptIn,
|
|
129
|
+
uint256 mainBalance,
|
|
130
|
+
uint256 wrappedBalance,
|
|
131
|
+
uint256 bptSupply,
|
|
132
|
+
Params memory params
|
|
133
|
+
) internal pure returns (uint256) {
|
|
134
|
+
// Amount out, so we round down overall.
|
|
135
|
+
|
|
136
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
137
|
+
uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance);
|
|
138
|
+
uint256 deltaNominalMain = divDown(mul(invariant, bptIn), bptSupply);
|
|
139
|
+
uint256 afterNominalMain = previousNominalMain.sub(deltaNominalMain);
|
|
140
|
+
uint256 newMainBalance = _fromNominal(afterNominalMain, params);
|
|
141
|
+
return mainBalance.sub(newMainBalance);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function _calcMainOutPerWrappedIn(
|
|
145
|
+
uint256 wrappedIn,
|
|
146
|
+
uint256 mainBalance,
|
|
147
|
+
Params memory params
|
|
148
|
+
) internal pure returns (uint256) {
|
|
149
|
+
// Amount out, so we round down overall.
|
|
150
|
+
|
|
151
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
152
|
+
uint256 afterNominalMain = previousNominalMain.sub(wrappedIn);
|
|
153
|
+
uint256 newMainBalance = _fromNominal(afterNominalMain, params);
|
|
154
|
+
return mainBalance.sub(newMainBalance);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function _calcMainInPerWrappedOut(
|
|
158
|
+
uint256 wrappedOut,
|
|
159
|
+
uint256 mainBalance,
|
|
160
|
+
Params memory params
|
|
161
|
+
) internal pure returns (uint256) {
|
|
162
|
+
// Amount in, so we round up overall.
|
|
163
|
+
|
|
164
|
+
uint256 previousNominalMain = _toNominal(mainBalance, params);
|
|
165
|
+
uint256 afterNominalMain = previousNominalMain.add(wrappedOut);
|
|
166
|
+
uint256 newMainBalance = _fromNominal(afterNominalMain, params);
|
|
167
|
+
return newMainBalance.sub(mainBalance);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function _calcBptOutPerWrappedIn(
|
|
171
|
+
uint256 wrappedIn,
|
|
172
|
+
uint256 mainBalance,
|
|
173
|
+
uint256 wrappedBalance,
|
|
174
|
+
uint256 bptSupply,
|
|
175
|
+
Params memory params
|
|
176
|
+
) internal pure returns (uint256) {
|
|
177
|
+
// Amount out, so we round down overall.
|
|
178
|
+
|
|
179
|
+
if (bptSupply == 0) {
|
|
180
|
+
// BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the
|
|
181
|
+
// BPT supply is initialized to equal the invariant (which in this case is just the wrapped balance as
|
|
182
|
+
// there is no main balance).
|
|
183
|
+
return wrappedIn;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
uint256 nominalMain = _toNominal(mainBalance, params);
|
|
187
|
+
uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance);
|
|
188
|
+
|
|
189
|
+
uint256 newWrappedBalance = wrappedBalance.add(wrappedIn);
|
|
190
|
+
uint256 newInvariant = _calcInvariant(nominalMain, newWrappedBalance);
|
|
191
|
+
|
|
192
|
+
uint256 newBptBalance = divDown(mul(bptSupply, newInvariant), previousInvariant);
|
|
193
|
+
|
|
194
|
+
return newBptBalance.sub(bptSupply);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function _calcBptInPerWrappedOut(
|
|
198
|
+
uint256 wrappedOut,
|
|
199
|
+
uint256 mainBalance,
|
|
200
|
+
uint256 wrappedBalance,
|
|
201
|
+
uint256 bptSupply,
|
|
202
|
+
Params memory params
|
|
203
|
+
) internal pure returns (uint256) {
|
|
204
|
+
// Amount in, so we round up overall.
|
|
205
|
+
|
|
206
|
+
uint256 nominalMain = _toNominal(mainBalance, params);
|
|
207
|
+
uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance);
|
|
208
|
+
|
|
209
|
+
uint256 newWrappedBalance = wrappedBalance.sub(wrappedOut);
|
|
210
|
+
uint256 newInvariant = _calcInvariant(nominalMain, newWrappedBalance);
|
|
211
|
+
|
|
212
|
+
uint256 newBptBalance = divDown(mul(bptSupply, newInvariant), previousInvariant);
|
|
213
|
+
|
|
214
|
+
return bptSupply.sub(newBptBalance);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function _calcWrappedInPerBptOut(
|
|
218
|
+
uint256 bptOut,
|
|
219
|
+
uint256 mainBalance,
|
|
220
|
+
uint256 wrappedBalance,
|
|
221
|
+
uint256 bptSupply,
|
|
222
|
+
Params memory params
|
|
223
|
+
) internal pure returns (uint256) {
|
|
224
|
+
// Amount in, so we round up overall.
|
|
225
|
+
|
|
226
|
+
if (bptSupply == 0) {
|
|
227
|
+
// BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the
|
|
228
|
+
// BPT supply is initialized to equal the invariant (which in this case is just the wrapped balance as
|
|
229
|
+
// there is no main balance).
|
|
230
|
+
return bptOut;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
uint256 nominalMain = _toNominal(mainBalance, params);
|
|
234
|
+
uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance);
|
|
235
|
+
|
|
236
|
+
uint256 newBptBalance = bptSupply.add(bptOut);
|
|
237
|
+
uint256 newWrappedBalance = divUp(mul(newBptBalance, previousInvariant), bptSupply).sub(
|
|
238
|
+
nominalMain
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
return newWrappedBalance.sub(wrappedBalance);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function _calcWrappedOutPerBptIn(
|
|
245
|
+
uint256 bptIn,
|
|
246
|
+
uint256 mainBalance,
|
|
247
|
+
uint256 wrappedBalance,
|
|
248
|
+
uint256 bptSupply,
|
|
249
|
+
Params memory params
|
|
250
|
+
) internal pure returns (uint256) {
|
|
251
|
+
// Amount out, so we round down overall.
|
|
252
|
+
|
|
253
|
+
uint256 nominalMain = _toNominal(mainBalance, params);
|
|
254
|
+
uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance);
|
|
255
|
+
|
|
256
|
+
uint256 newBptBalance = bptSupply.sub(bptIn);
|
|
257
|
+
uint256 newWrappedBalance = divUp(mul(newBptBalance, previousInvariant), bptSupply).sub(
|
|
258
|
+
nominalMain
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
return wrappedBalance.sub(newWrappedBalance);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function _calcInvariant(uint256 nominalMainBalance, uint256 wrappedBalance)
|
|
265
|
+
internal
|
|
266
|
+
pure
|
|
267
|
+
returns (uint256)
|
|
268
|
+
{
|
|
269
|
+
return nominalMainBalance.add(wrappedBalance);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function _toNominal(uint256 real, Params memory params) internal pure returns (uint256) {
|
|
273
|
+
unchecked {
|
|
274
|
+
// Fees are always rounded down: either direction would work but we need to be consistent, and rounding down
|
|
275
|
+
// uses less gas.
|
|
276
|
+
|
|
277
|
+
if (real < params.lowerTarget) {
|
|
278
|
+
uint256 fees = (params.lowerTarget - real).mulDown(params.fee);
|
|
279
|
+
return real.sub(fees);
|
|
280
|
+
} else if (real <= params.upperTarget) {
|
|
281
|
+
return real;
|
|
282
|
+
} else {
|
|
283
|
+
uint256 fees = (real - params.upperTarget).mulDown(params.fee);
|
|
284
|
+
return real.sub(fees);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function _fromNominal(uint256 nominal, Params memory params) internal pure returns (uint256) {
|
|
290
|
+
unchecked {
|
|
291
|
+
// Since real = nominal + fees, rounding down fees is equivalent to rounding down real.
|
|
292
|
+
|
|
293
|
+
if (nominal < params.lowerTarget) {
|
|
294
|
+
return
|
|
295
|
+
(nominal.add(params.fee.mulDown(params.lowerTarget))).divDown(
|
|
296
|
+
FixedPoint.ONE.add(params.fee)
|
|
297
|
+
);
|
|
298
|
+
} else if (nominal <= params.upperTarget) {
|
|
299
|
+
return nominal;
|
|
300
|
+
} else {
|
|
301
|
+
return (
|
|
302
|
+
nominal.sub(params.fee.mulDown(params.upperTarget)).divDown(
|
|
303
|
+
FixedPoint.ONE.sub(params.fee)
|
|
304
|
+
)
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function _calcTokensOutGivenExactBptIn(
|
|
311
|
+
uint256[] memory balances,
|
|
312
|
+
uint256 bptAmountIn,
|
|
313
|
+
uint256 bptTotalSupply,
|
|
314
|
+
uint256 bptIndex
|
|
315
|
+
) internal pure returns (uint256[] memory) {
|
|
316
|
+
unchecked {
|
|
317
|
+
/**********************************************************************************************
|
|
318
|
+
// exactBPTInForTokensOut //
|
|
319
|
+
// (per token) //
|
|
320
|
+
// aO = tokenAmountOut / bptIn \ //
|
|
321
|
+
// b = tokenBalance a0 = b * | --------------------- | //
|
|
322
|
+
// bptIn = bptAmountIn \ bptTotalSupply / //
|
|
323
|
+
// bpt = bptTotalSupply //
|
|
324
|
+
**********************************************************************************************/
|
|
325
|
+
|
|
326
|
+
// Since we're computing an amount out, we round down overall. This means rounding down on both the
|
|
327
|
+
// multiplication and division.
|
|
328
|
+
|
|
329
|
+
uint256 bptRatio = bptAmountIn.divDown(bptTotalSupply);
|
|
330
|
+
|
|
331
|
+
uint256[] memory amountsOut = new uint256[](balances.length);
|
|
332
|
+
for (uint256 i = 0; i < balances.length; i++) {
|
|
333
|
+
// BPT is skipped as those tokens are not the LPs, but rather the preminted and undistributed amount.
|
|
334
|
+
if (i != bptIndex) {
|
|
335
|
+
amountsOut[i] = balances[i].mulDown(bptRatio);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return amountsOut;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/*///////////////////////////////////////////////////////////////
|
|
344
|
+
LEGACY MATH FUNCTIONS
|
|
345
|
+
//////////////////////////////////////////////////////////////*/
|
|
346
|
+
|
|
347
|
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
348
|
+
unchecked {
|
|
349
|
+
uint256 c = a * b;
|
|
350
|
+
require(a == 0 || c / a == b);
|
|
351
|
+
return c;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function div(
|
|
356
|
+
uint256 a,
|
|
357
|
+
uint256 b,
|
|
358
|
+
bool roundUp
|
|
359
|
+
) internal pure returns (uint256) {
|
|
360
|
+
return roundUp ? divUp(a, b) : divDown(a, b);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
364
|
+
unchecked {
|
|
365
|
+
require(b != 0);
|
|
366
|
+
return a / b;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function divUp(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
371
|
+
unchecked {
|
|
372
|
+
require(b != 0);
|
|
373
|
+
|
|
374
|
+
if (a == 0) {
|
|
375
|
+
return 0;
|
|
376
|
+
} else {
|
|
377
|
+
return 1 + (a - 1) / b;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "../../../../../../interfaces/Balancer/IVault.sol";
|
|
5
|
+
import "../../../../../../interfaces/Balancer/IERC4626LinearPool.sol";
|
|
6
|
+
import "../../../../../libraries/BoringOwnableUpgradeable.sol";
|
|
7
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
8
|
+
import "./LinearMath.sol";
|
|
9
|
+
|
|
10
|
+
contract LinearPreview is BoringOwnableUpgradeable, UUPSUpgradeable {
|
|
11
|
+
using FixedPoint for uint256;
|
|
12
|
+
|
|
13
|
+
struct ImmutableData {
|
|
14
|
+
address pool;
|
|
15
|
+
uint256 _BPT_INDEX;
|
|
16
|
+
IERC20 _mainToken;
|
|
17
|
+
uint256 _mainIndex;
|
|
18
|
+
IERC20 _wrappedToken;
|
|
19
|
+
uint256 _wrappedIndex;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
address internal constant BALANCER_VAULT = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;
|
|
23
|
+
bytes internal constant EMPTY_BYTES = abi.encode();
|
|
24
|
+
|
|
25
|
+
constructor() initializer {}
|
|
26
|
+
|
|
27
|
+
function initialize() external initializer {
|
|
28
|
+
__BoringOwnable_init();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
|
|
32
|
+
|
|
33
|
+
function joinExitPoolPreview(bytes32 poolId, address tokenIn, address tokenOut, uint256 amountIn)
|
|
34
|
+
external
|
|
35
|
+
view
|
|
36
|
+
returns (uint256 amountOut)
|
|
37
|
+
{
|
|
38
|
+
IVault.SwapRequest memory request = IVault.SwapRequest({
|
|
39
|
+
kind: IVault.SwapKind.GIVEN_IN,
|
|
40
|
+
tokenIn: IERC20(tokenIn),
|
|
41
|
+
tokenOut: IERC20(tokenOut),
|
|
42
|
+
amount: amountIn,
|
|
43
|
+
// unused data
|
|
44
|
+
poolId: bytes32(0),
|
|
45
|
+
lastChangeBlock: 0,
|
|
46
|
+
from: address(0),
|
|
47
|
+
to: address(0),
|
|
48
|
+
userData: EMPTY_BYTES
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
(IERC20[] memory tokens, uint256[] memory balances,) = IVault(BALANCER_VAULT).getPoolTokens(poolId);
|
|
52
|
+
address pool = address(uint160(uint256(poolId) >> (12 * 8)));
|
|
53
|
+
IERC20 mainToken = IERC20(IERC4626LinearPool(pool).getMainToken());
|
|
54
|
+
|
|
55
|
+
uint256 indexIn;
|
|
56
|
+
uint256 indexOut;
|
|
57
|
+
ImmutableData memory imd;
|
|
58
|
+
|
|
59
|
+
for (uint256 i = 0; i < tokens.length;) {
|
|
60
|
+
if (tokens[i] == mainToken) {
|
|
61
|
+
imd._mainToken = mainToken;
|
|
62
|
+
imd._mainIndex = i;
|
|
63
|
+
} else if (tokens[i] == IERC20(pool)) {
|
|
64
|
+
imd.pool = pool;
|
|
65
|
+
imd._BPT_INDEX = i;
|
|
66
|
+
} else {
|
|
67
|
+
imd._wrappedToken = tokens[i];
|
|
68
|
+
imd._wrappedIndex = i;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (tokens[i] == IERC20(tokenIn)) {
|
|
72
|
+
indexIn = i;
|
|
73
|
+
} else if (tokens[i] == IERC20(tokenOut)) {
|
|
74
|
+
indexOut = i;
|
|
75
|
+
}
|
|
76
|
+
unchecked {
|
|
77
|
+
i++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return _onSwapGeneral(request, balances, indexIn, indexOut, imd);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _onSwapGeneral(
|
|
85
|
+
IVault.SwapRequest memory request,
|
|
86
|
+
uint256[] memory balances,
|
|
87
|
+
uint256 indexIn,
|
|
88
|
+
uint256 indexOut,
|
|
89
|
+
ImmutableData memory imd
|
|
90
|
+
) internal view returns (uint256) {
|
|
91
|
+
// Upscale balances by the scaling factors (taking into account the wrapped token rate)
|
|
92
|
+
uint256[] memory scalingFactors = IERC4626LinearPool(imd.pool).getScalingFactors();
|
|
93
|
+
_upscaleArray(balances, scalingFactors);
|
|
94
|
+
|
|
95
|
+
(uint256 lowerTarget, uint256 upperTarget) = IERC4626LinearPool(imd.pool).getTargets();
|
|
96
|
+
LinearMath.Params memory params = LinearMath.Params({
|
|
97
|
+
fee: IERC4626LinearPool(imd.pool).getSwapFeePercentage(),
|
|
98
|
+
lowerTarget: lowerTarget,
|
|
99
|
+
upperTarget: upperTarget
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
assert(request.kind == IVault.SwapKind.GIVEN_IN);
|
|
103
|
+
// The amount given is for token in, the amount calculated is for token out
|
|
104
|
+
request.amount = _upscale(request.amount, scalingFactors[indexIn]);
|
|
105
|
+
uint256 amountOut = _onSwapGivenIn(request, balances, params, imd);
|
|
106
|
+
|
|
107
|
+
// amountOut tokens are exiting the Pool, so we round down.
|
|
108
|
+
return _downscaleDown(amountOut, scalingFactors[indexOut]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function _onSwapGivenIn(
|
|
112
|
+
IVault.SwapRequest memory request,
|
|
113
|
+
uint256[] memory balances,
|
|
114
|
+
LinearMath.Params memory params,
|
|
115
|
+
ImmutableData memory imd
|
|
116
|
+
) internal view returns (uint256) {
|
|
117
|
+
if (request.tokenIn == IERC20(imd.pool)) {
|
|
118
|
+
return _swapGivenBptIn(request, balances, params, imd);
|
|
119
|
+
} else if (request.tokenIn == imd._mainToken) {
|
|
120
|
+
return _swapGivenMainIn(request, balances, params, imd);
|
|
121
|
+
} else if (request.tokenIn == imd._wrappedToken) {
|
|
122
|
+
return _swapGivenWrappedIn(request, balances, params, imd);
|
|
123
|
+
} else {
|
|
124
|
+
assert(false);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function _swapGivenBptIn(
|
|
129
|
+
IVault.SwapRequest memory request,
|
|
130
|
+
uint256[] memory balances,
|
|
131
|
+
LinearMath.Params memory params,
|
|
132
|
+
ImmutableData memory imd
|
|
133
|
+
) internal view returns (uint256) {
|
|
134
|
+
// _require(
|
|
135
|
+
// request.tokenOut == _mainToken || request.tokenOut == _wrappedToken,
|
|
136
|
+
// Errors.INVALID_TOKEN
|
|
137
|
+
// );
|
|
138
|
+
return (
|
|
139
|
+
request.tokenOut == imd._mainToken ? LinearMath._calcMainOutPerBptIn : LinearMath._calcWrappedOutPerBptIn
|
|
140
|
+
)(
|
|
141
|
+
request.amount,
|
|
142
|
+
balances[imd._mainIndex],
|
|
143
|
+
balances[imd._wrappedIndex],
|
|
144
|
+
_getVirtualSupply(balances[imd._BPT_INDEX], imd.pool),
|
|
145
|
+
params
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function _swapGivenMainIn(
|
|
150
|
+
IVault.SwapRequest memory request,
|
|
151
|
+
uint256[] memory balances,
|
|
152
|
+
LinearMath.Params memory params,
|
|
153
|
+
ImmutableData memory imd
|
|
154
|
+
) internal view returns (uint256) {
|
|
155
|
+
// _require(
|
|
156
|
+
// request.tokenOut == _wrappedToken || request.tokenOut == this,
|
|
157
|
+
// Errors.INVALID_TOKEN
|
|
158
|
+
// );
|
|
159
|
+
return request.tokenOut == IERC20(imd.pool)
|
|
160
|
+
? LinearMath._calcBptOutPerMainIn(
|
|
161
|
+
request.amount,
|
|
162
|
+
balances[imd._mainIndex],
|
|
163
|
+
balances[imd._wrappedIndex],
|
|
164
|
+
_getVirtualSupply(balances[imd._BPT_INDEX], imd.pool),
|
|
165
|
+
params
|
|
166
|
+
)
|
|
167
|
+
: LinearMath._calcWrappedOutPerMainIn(request.amount, balances[imd._mainIndex], params);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function _swapGivenWrappedIn(
|
|
171
|
+
IVault.SwapRequest memory request,
|
|
172
|
+
uint256[] memory balances,
|
|
173
|
+
LinearMath.Params memory params,
|
|
174
|
+
ImmutableData memory imd
|
|
175
|
+
) internal view returns (uint256) {
|
|
176
|
+
// _require(request.tokenOut == _mainToken || request.tokenOut == this, Errors.INVALID_TOKEN);
|
|
177
|
+
return request.tokenOut == IERC20(imd.pool)
|
|
178
|
+
? LinearMath._calcBptOutPerWrappedIn(
|
|
179
|
+
request.amount,
|
|
180
|
+
balances[imd._mainIndex],
|
|
181
|
+
balances[imd._wrappedIndex],
|
|
182
|
+
_getVirtualSupply(balances[imd._BPT_INDEX], imd.pool),
|
|
183
|
+
params
|
|
184
|
+
)
|
|
185
|
+
: LinearMath._calcMainOutPerWrappedIn(request.amount, balances[imd._mainIndex], params);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function _getVirtualSupply(uint256 bptBalance, address pool) internal view returns (uint256) {
|
|
189
|
+
return (IERC20(pool).totalSupply()).sub(bptBalance);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) {
|
|
193
|
+
return FixedPoint.mulDown(amount, scalingFactor);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function _downscaleDown(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) {
|
|
197
|
+
return FixedPoint.divDown(amount, scalingFactor);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal pure {
|
|
201
|
+
uint256 length = amounts.length;
|
|
202
|
+
for (uint256 i = 0; i < length; ++i) {
|
|
203
|
+
amounts[i] = FixedPoint.mulDown(amounts[i], scalingFactors[i]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|