@pendle/core-v2 3.0.0-beta-11 → 3.0.0-beta-12
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/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol +5 -23
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol +2 -5
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol +6 -20
- package/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol +6 -27
- package/contracts/LiquidityMining/CrossChainMsg/libraries/ExcessivelySafeCall.sol +1 -2
- package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +1 -1
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol +16 -17
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol +6 -7
- package/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol +7 -8
- package/contracts/LiquidityMining/PendleMerkleDistributor.sol +2 -11
- package/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol +14 -37
- package/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol +19 -34
- package/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol +4 -14
- package/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol +4 -16
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol +11 -39
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol +3 -10
- package/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol +1 -1
- package/contracts/LiquidityMining/libraries/VeBalanceLib.sol +5 -20
- package/contracts/LiquidityMining/libraries/VeHistoryLib.sol +1 -3
- package/contracts/core/Market/MarketMathCore.sol +12 -37
- package/contracts/core/Market/OracleLib.sol +6 -24
- package/contracts/core/Market/PendleExternalRewardDistributor.sol +4 -10
- package/contracts/core/Market/PendleGauge.sol +3 -9
- package/contracts/core/Market/PendleMarket.sol +14 -39
- package/contracts/core/Market/PendleMarketFactory.sol +14 -21
- package/contracts/core/Market/v2/PendleGaugeV2.sol +8 -24
- package/contracts/core/Market/v2/PendleMarketFactoryV2.sol +7 -27
- package/contracts/core/Market/v2/PendleMarketV2.sol +13 -36
- package/contracts/core/Market/v3/PendleMarketFactoryV3.sol +137 -0
- package/contracts/core/Market/v3/PendleMarketV3.sol +360 -0
- package/contracts/core/RewardManager/PendleLinearDistributor.sol +143 -0
- package/contracts/core/RewardManager/RewardManager.sol +14 -7
- package/contracts/core/RewardManager/RewardManagerAbstract.sol +5 -17
- package/contracts/core/StandardizedYield/SYBase.sol +10 -40
- package/contracts/core/StandardizedYield/SYBaseUpg.sol +197 -0
- package/contracts/core/StandardizedYield/SYBaseWithRewards.sol +9 -41
- package/contracts/core/StandardizedYield/SYBaseWithRewardsUpg.sol +88 -0
- package/contracts/core/StandardizedYield/SYUtils.sol +1 -4
- package/contracts/core/StandardizedYield/StEthHelper.sol +3 -9
- package/contracts/core/StandardizedYield/implementations/AaveV3/PendleAaveV3SY.sol +94 -0
- package/contracts/core/StandardizedYield/implementations/AaveV3/libraries/AaveAdapterLib.sol +19 -0
- package/contracts/core/StandardizedYield/implementations/AaveV3/libraries/WadRayMath.sol +126 -0
- package/contracts/core/StandardizedYield/implementations/Ankr/PendleAnkrBNBSY.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol +5 -19
- package/contracts/core/StandardizedYield/implementations/BalancerStable/AuraEthxBbAWethSY.sol +4 -14
- package/contracts/core/StandardizedYield/implementations/BalancerStable/AuraSwEthBbAWethSYV2.sol +4 -14
- package/contracts/core/StandardizedYield/implementations/BalancerStable/{PendleAuraWethVethSY.sol → AuraWethVethSYUpg.sol} +13 -20
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol +3 -7
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol +12 -29
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol +12 -29
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol +12 -29
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol +14 -39
- package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol +7 -28
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol +13 -30
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewProxy.sol +1 -1
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV4.sol +50 -153
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreviewV5.sol +50 -157
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/BbAPoolHelper.sol +4 -16
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearMath.sol +6 -25
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/Linear/LinearPreview.sol +36 -34
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol +4 -13
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol +20 -58
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol +28 -79
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV3Upg.sol +310 -0
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol +1 -3
- package/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol +2 -6
- package/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol +5 -13
- package/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol +9 -29
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotRewardHelper.sol +2 -8
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileCommon.sol +1 -5
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatileLpHelper.sol +8 -19
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/CamelotV1VolatilePreview.sol +7 -25
- package/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol +8 -27
- package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkReceiver.sol +2 -2
- package/contracts/core/StandardizedYield/implementations/ChainlinkRelayer/PendleChainlinkRelayer.sol +4 -9
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol +3 -15
- package/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol +5 -23
- package/contracts/core/StandardizedYield/implementations/Convex/base/Curve3CrvPoolHelper.sol +10 -40
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveFraxUsdcPoolHelper.sol +2 -8
- package/contracts/core/StandardizedYield/implementations/Convex/base/CurveUsdd3CrvPoolHelper.sol +2 -7
- package/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol +5 -20
- package/contracts/core/StandardizedYield/implementations/Flux/FluxTokenLib.sol +6 -4
- package/contracts/core/StandardizedYield/implementations/Flux/PendleFluxLendingSY.sol +3 -11
- package/contracts/core/StandardizedYield/implementations/GLP/GLPPreviewHelper.sol +3 -9
- package/contracts/core/StandardizedYield/implementations/GLP/GMTokenPricingHelper.sol +115 -0
- package/contracts/core/StandardizedYield/implementations/GLP/PendleGMV2TokenSY.sol +134 -0
- package/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol +5 -19
- package/contracts/core/StandardizedYield/implementations/HMX/HLPPricingHelper.sol +3 -4
- package/contracts/core/StandardizedYield/implementations/HMX/PendleHlpSY.sol +18 -25
- package/contracts/core/StandardizedYield/implementations/Kyber/KyberMathHelper.sol +425 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/KyberNftManagerBaseUpg.sol +438 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/PendleKyberElasticSYUpg.sol +155 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/FullMath.sol +123 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/LiqDeltaMath.sol +17 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/LiquidityMath.sol +74 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/MathConstants.sol +19 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/QtyDeltaMath.sol +103 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/QuadMath.sol +31 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/ReinvestmentMath.sol +26 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/SafeCast.sol +73 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/SwapMath.sol +272 -0
- package/contracts/core/StandardizedYield/implementations/Kyber/libraries/TickMath.sol +223 -0
- package/contracts/core/StandardizedYield/implementations/MUX/MlpPricingHelper.sol +26 -0
- package/contracts/core/StandardizedYield/implementations/MUX/PendleMlpSY.sol +195 -0
- package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleMantleStakedEthSY.sol +12 -41
- package/contracts/core/StandardizedYield/implementations/MantleStakedEth/PendleOracleForSyProxy.sol +1 -1
- package/contracts/core/StandardizedYield/implementations/PendleArbitrumStakedEthSY.sol +13 -42
- package/contracts/core/StandardizedYield/implementations/PendleBridgedLSDSY.sol +4 -11
- package/contracts/core/StandardizedYield/implementations/PendleERC4626SY.sol +4 -16
- package/contracts/core/StandardizedYield/implementations/PendleEUSDSY.sol +3 -11
- package/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol +3 -11
- package/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol +5 -18
- package/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol +3 -7
- package/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol +5 -18
- package/contracts/core/StandardizedYield/implementations/PendleWbEthSY.sol +3 -10
- package/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Silo/PendleSiloWithIncentiveSY.sol +157 -0
- package/contracts/core/StandardizedYield/implementations/Stader/PendleETHXSY.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Swell/PendleSwETH.sol +4 -12
- package/contracts/core/StandardizedYield/implementations/Thena/PendleThenaSY.sol +9 -29
- package/contracts/core/StandardizedYield/implementations/Thena/ThenaLpHelper.sol +3 -10
- package/contracts/core/StandardizedYield/implementations/Thena/ThenaMath.sol +9 -30
- package/contracts/core/StandardizedYield/implementations/Thena/ThenaPreview.sol +10 -40
- package/contracts/core/YieldContracts/InterestManagerYT.sol +6 -8
- package/contracts/core/YieldContracts/PendlePrincipalToken.sol +1 -1
- package/contracts/core/YieldContracts/PendleYieldContractFactory.sol +2 -3
- package/contracts/core/YieldContracts/PendleYieldToken.sol +17 -44
- package/contracts/core/YieldContractsV2/InterestManagerYTV2.sol +5 -14
- package/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol +1 -1
- package/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol +2 -3
- package/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol +13 -48
- package/contracts/core/erc20/PendleERC20.sol +2 -8
- package/contracts/core/erc20/PendleERC20Permit.sol +2 -6
- package/contracts/core/erc20/PendleERC20PermitUpg.sol +82 -0
- package/contracts/core/erc20/PendleERC20Upg.sol +334 -0
- package/contracts/core/libraries/ArrayLib.sol +7 -8
- package/contracts/core/libraries/BaseSplitCodeFactory.sol +1 -6
- package/contracts/core/libraries/Errors.sol +19 -1
- package/contracts/core/libraries/ExpiryUtilsLib.sol +3 -26
- package/contracts/core/libraries/StringLib.sol +5 -21
- package/contracts/core/libraries/TokenHelper.sol +3 -3
- package/contracts/core/libraries/math/LogExpMath.sol +1 -4
- package/contracts/core/libraries/math/PMath.sol +13 -15
- package/contracts/interfaces/AaveV3/IAaveV3AToken.sol +15 -0
- package/contracts/interfaces/AaveV3/IAaveV3Pool.sol +11 -0
- package/contracts/interfaces/Balancer/IComposableStable.sol +3 -4
- package/contracts/interfaces/Balancer/IERC4626LinearPool.sol +2 -10
- package/contracts/interfaces/Balancer/IMetaStablePool.sol +3 -11
- package/contracts/interfaces/Balancer/IVault.sol +3 -8
- package/contracts/interfaces/BinanceEth/IWBETH.sol +1 -1
- package/contracts/interfaces/Camelot/ICamelotNFTFactory.sol +1 -3
- package/contracts/interfaces/Camelot/ICamelotNFTHandler.sol +2 -10
- package/contracts/interfaces/Camelot/ICamelotNitroPool.sol +0 -1
- package/contracts/interfaces/Camelot/ICamelotNitroPoolFactory.sol +3 -12
- package/contracts/interfaces/Camelot/ICamelotPair.sol +5 -25
- package/contracts/interfaces/Camelot/ICamelotRouter.sol +1 -5
- package/contracts/interfaces/Camelot/IXGrail.sol +3 -11
- package/contracts/interfaces/ConvexCurve/IBooster.sol +1 -3
- package/contracts/interfaces/Curve/ICrvPool.sol +3 -12
- package/contracts/interfaces/Curve/ITriCrvPool.sol +2 -9
- package/contracts/interfaces/Flux/IFluxErc20.sol +1 -1
- package/contracts/interfaces/Flux/IFluxInterestRateModel.sol +1 -5
- package/contracts/interfaces/GMX/IGMXPriceHelper.sol +6 -0
- package/contracts/interfaces/GMX/IGMXVault.sol +2 -9
- package/contracts/interfaces/GMX/IRewardRouterV2.sol +1 -4
- package/contracts/interfaces/HMX/IHLPStaking.sol +1 -1
- package/contracts/interfaces/HMX/IHMXCalculator.sol +1 -1
- package/contracts/interfaces/HMX/IHMXCompounder.sol +1 -1
- package/contracts/interfaces/HMX/IHMXStaking.sol +1 -1
- package/contracts/interfaces/HMX/IHMXVester.sol +1 -1
- package/contracts/interfaces/IApeStaking.sol +3 -9
- package/contracts/interfaces/IBenQiInterestRateModel.sol +1 -5
- package/contracts/interfaces/IDiamondCut.sol +1 -5
- package/contracts/interfaces/IDiamondLoupe.sol +1 -3
- package/contracts/interfaces/ILayerZeroReceiver.sol +1 -6
- package/contracts/interfaces/IPActionAddRemoveLiqV3.sol +10 -2
- package/contracts/interfaces/IPActionInfoStatic.sol +4 -7
- package/contracts/interfaces/IPActionMarketAuxStatic.sol +5 -9
- package/contracts/interfaces/IPActionMarketCoreStatic.sol +118 -58
- package/contracts/interfaces/IPActionMintRedeemStatic.sol +38 -21
- package/contracts/interfaces/IPActionMiscV3.sol +51 -26
- package/contracts/interfaces/IPActionStorageStatic.sol +5 -1
- package/contracts/interfaces/IPAllActionTypeV3.sol +1 -0
- package/contracts/interfaces/IPBulkSeller.sol +49 -0
- package/contracts/interfaces/IPBulkSellerFactory.sol +12 -0
- package/contracts/interfaces/IPBulkSellerSYCallback.sol +6 -0
- package/contracts/interfaces/IPFeeDistributor.sol +1 -3
- package/contracts/interfaces/IPFeeDistributorV2.sol +8 -7
- package/contracts/interfaces/IPGaugeController.sol +2 -8
- package/contracts/interfaces/IPGaugeControllerMainchain.sol +1 -5
- package/contracts/interfaces/IPInterestManagerYT.sol +3 -3
- package/contracts/interfaces/IPInterestManagerYTV2.sol +1 -4
- package/contracts/interfaces/IPLimitRouter.sol +24 -19
- package/contracts/interfaces/IPLinearDistributor.sol +21 -0
- package/contracts/interfaces/IPMarket.sol +4 -17
- package/contracts/interfaces/IPMarketFactory.sol +2 -13
- package/contracts/interfaces/IPMarketFactoryV3.sol +24 -0
- package/contracts/interfaces/IPMarketV3.sol +8 -0
- package/contracts/interfaces/IPOffchainStorage.sol +11 -0
- package/contracts/interfaces/IPPriceFeed.sol +6 -0
- package/contracts/interfaces/IPPtOracle.sol +2 -9
- package/contracts/interfaces/IPRouterHelper.sol +11 -7
- package/contracts/interfaces/IPRouterStatic.sol +1 -3
- package/contracts/interfaces/IPVotingController.sol +7 -19
- package/contracts/interfaces/IPVotingEscrowMainchain.sol +2 -8
- package/contracts/interfaces/IPYieldToken.sol +2 -8
- package/contracts/interfaces/IPYieldTokenV2.sol +1 -6
- package/contracts/interfaces/IPendlePreviewHelper.sol +2 -8
- package/contracts/interfaces/IRewardManager.sol +1 -4
- package/contracts/interfaces/IStETH.sol +1 -4
- package/contracts/interfaces/IStandardizedYield.sol +9 -16
- package/contracts/interfaces/IStargateLP.sol +0 -3
- package/contracts/interfaces/IStargateRouter.sol +1 -5
- package/contracts/interfaces/Kyber/IKyberElasticFactory.sol +157 -0
- package/contracts/interfaces/Kyber/IKyberElasticPool.sol +101 -0
- package/contracts/interfaces/Kyber/IKyberElasticRouter.sol +98 -0
- package/contracts/interfaces/Kyber/IKyberLiquidityMining.sol +209 -0
- package/contracts/interfaces/Kyber/IKyberMathHelper.sol +28 -0
- package/contracts/interfaces/Kyber/IKyberPositionManager.sol +179 -0
- package/contracts/interfaces/Lybra/IEUSD.sol +1 -1
- package/contracts/interfaces/MUX/IMUXRewardRouter.sol +139 -0
- package/contracts/interfaces/Silo/ISilo.sol +298 -0
- package/contracts/interfaces/Silo/ISiloIncentiveController.sol +16 -0
- package/contracts/interfaces/Silo/ISiloLens.sol +6 -0
- package/contracts/interfaces/Stader/IStaderStakeManager.sol +2 -2
- package/contracts/interfaces/Thena/IThenaFactory.sol +1 -5
- package/contracts/interfaces/Thena/IThenaGaugeV2.sol +1 -2
- package/contracts/interfaces/Thena/IThenaPair.sol +3 -5
- package/contracts/limit/LimitMathCore.sol +69 -60
- package/contracts/limit/{PendleOrderMixin.sol → LimitRouterBase.sol} +96 -79
- package/contracts/limit/PendleLimitRouter.sol +9 -13
- package/contracts/offchain-helpers/AutomateReady.sol +17 -32
- package/contracts/offchain-helpers/BaseSplitCodeFactoryContract.sol +6 -3
- package/contracts/offchain-helpers/BoringLpSeller.sol +4 -17
- package/contracts/offchain-helpers/BoringPtSeller.sol +2 -7
- package/contracts/offchain-helpers/Broadcaster.sol +1 -1
- package/contracts/offchain-helpers/BytesLib.sol +26 -14
- package/contracts/offchain-helpers/EmptyUUPS.sol +0 -1
- package/contracts/offchain-helpers/LegacyNFTHelper.sol +4 -23
- package/contracts/offchain-helpers/LimitBackendHelper.sol +25 -16
- package/contracts/offchain-helpers/MarketExchangeRateLib.sol +2 -13
- package/contracts/offchain-helpers/Multicall2.sol +2 -7
- package/contracts/offchain-helpers/PendleMulticallV1.sol +7 -7
- package/contracts/offchain-helpers/PendleMulticallV2.sol +12 -13
- package/contracts/offchain-helpers/PendleOffchainStorage.sol +59 -0
- package/contracts/offchain-helpers/SimulateHelper.sol +6 -7
- package/contracts/offchain-helpers/errors/SDKErrorsDirectory.sol +15 -1
- package/contracts/oracles/PendleLpOracleLib.sol +9 -10
- package/contracts/oracles/PendlePtOracle.sol +8 -19
- package/contracts/oracles/PendlePtOracleLib.sol +8 -13
- package/contracts/oracles/samples/PendleLpGlpOracle.sol +6 -10
- package/contracts/oracles/samples/PendlePtGlpOracle.sol +6 -10
- package/contracts/oracles/samples/PendlePtUsdChainlinkOracle.sol +8 -15
- package/contracts/router/ActionAddRemoveLiqV3.sol +147 -52
- package/contracts/router/ActionCallbackV3.sol +11 -4
- package/contracts/router/ActionMiscV3.sol +43 -33
- package/contracts/router/ActionSwapPTV3.sol +18 -6
- package/contracts/router/ActionSwapYTV3.sol +42 -14
- package/contracts/router/PendleRouterHelper.sol +72 -40
- package/contracts/router/PendleRouterV3.sol +50 -50
- package/contracts/router/base/ActionBase.sol +86 -43
- package/contracts/router/base/CallbackHelper.sol +18 -20
- package/contracts/router/base/MarketApproxLib.sol +36 -32
- package/contracts/router/swap-aggregator/PendleSwap.sol +31 -7
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IAggregationExecutorOptimistic.sol +63 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelper.sol +314 -0
- package/contracts/router/swap-aggregator/kyberswap/interfaces/IExecutorHelperL2.sol +560 -0
- package/contracts/router/swap-aggregator/kyberswap/{IMetaAggregationRouterV2.sol → interfaces/IMetaAggregationRouterV2.sol} +11 -6
- package/contracts/router/swap-aggregator/kyberswap/{KyberInputScalingHelper.sol → l1-contracts/InputScalingHelper.sol} +70 -19
- package/contracts/router/swap-aggregator/kyberswap/{ScalingDataLib.sol → l1-contracts/ScalingDataLib.sol} +111 -53
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/BytesHelper.sol +29 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/CalldataReader.sol +149 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/CalldataWriter.sol +118 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/Common.sol +42 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/DexScaler.sol +382 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/ExecutorReader.sol +61 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/InputScalingHelperL2.sol +329 -0
- package/contracts/router/swap-aggregator/kyberswap/l2-contracts/ScalingDataL2Lib.sol +173 -0
- package/contracts/router/swap-aggregator/oneinch/I1inchAggregationRouterV5.sol +4 -10
- package/contracts/router/swap-aggregator/oneinch/OneInchAggregationRouterHelper.sol +20 -14
- package/deployments/1-core.json +5 -2
- package/deployments/1-markets/EPENDLE-SEP2024.json +12 -0
- package/deployments/1-markets/SFRAX-MARCH2024.json +10 -0
- package/deployments/1-markets/SILO-CRVUSD-MARCH2024.json +10 -0
- package/deployments/10-core.json +6 -3
- package/deployments/42161-core.json +5 -2
- package/deployments/42161-markets/AAVE-USDC-JUNE2024.json +11 -0
- package/deployments/42161-markets/ARBSILO-USDC-FEB2024.json +10 -0
- package/deployments/42161-markets/GM-ARB-USDC-MARCH2024.json +10 -0
- package/deployments/42161-markets/KYBER-AXLWSTETH-WSTETH-MARCH2024.json +10 -0
- package/deployments/42161-markets/MLP-MARCH2024.json +10 -0
- package/deployments/42161-markets/WSTETH-ARBITRUM-MARCH2024.json +11 -0
- package/deployments/42161-markets/WSTETHSILO-ETH-MARCH2024.json +11 -0
- package/deployments/56-core.json +5 -2
- package/deployments/merkle-distribution/2023-10-26.json +7300 -0
- package/deployments/merkle-distribution/2023-11-30.json +7730 -0
- package/package.json +8 -8
- package/contracts/limit/helpers/ArgumentsDecoder.sol +0 -47
- package/contracts/limit/helpers/Permitable.sol +0 -48
- package/contracts/limit/helpers/RevertReasonParser.sol +0 -75
- package/contracts/offchain-helpers/ChainlinkRelayerGelato.sol +0 -37
- package/contracts/offchain-helpers/PtAndLpToAsset.sol +0 -62
- package/contracts/offchain-helpers/router-static/PendleRouterStatic.sol +0 -19
- package/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol +0 -112
- package/contracts/offchain-helpers/router-static/base/ActionLimitOrdersStatic.sol +0 -145
- package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +0 -171
- package/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol +0 -582
- package/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol +0 -116
- package/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol +0 -64
- package/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol +0 -53
- package/contracts/offchain-helpers/router-static/base/StorageLayout.sol +0 -18
- package/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol +0 -231
- package/deployments/1-markets/BALANCER-LP-AURA-VETH-WETH-SEP2024.json +0 -8
- /package/contracts/router/swap-aggregator/kyberswap/{IAggregationExecutor.sol → interfaces/IAggregationExecutor.sol} +0 -0
- /package/deployments/1-markets/{BALANCER-LP-AURA-BBAWETHSWETH-SEP-26-2024.json → deprecated/BALANCER-LP-AURA-BBAWETHSWETH-SEP-26-2024.json} +0 -0
- /package/deployments/1-markets/{BALANCER-LP-AURA-ETHX-BBAWETH-SEP-26-2024.json → deprecated/BALANCER-LP-AURA-ETHX-BBAWETH-SEP-26-2024.json} +0 -0
package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
5
|
import "./base/PendleAuraBalancerStableLPSYV2.sol";
|
|
@@ -16,14 +16,9 @@ contract PendleAuraWethWstethSYV2 is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
16
16
|
MetaStablePreview _previewHelper
|
|
17
17
|
) PendleAuraBalancerStableLPSYV2(_name, _symbol, LP, AURA_PID, _previewHelper) StEthHelper() {}
|
|
18
18
|
|
|
19
|
-
function _deposit(address tokenIn, uint256 amount)
|
|
20
|
-
internal
|
|
21
|
-
virtual
|
|
22
|
-
override
|
|
23
|
-
returns (uint256 amountSharesOut)
|
|
24
|
-
{
|
|
19
|
+
function _deposit(address tokenIn, uint256 amount) internal virtual override returns (uint256 amountSharesOut) {
|
|
25
20
|
if (tokenIn == NATIVE) {
|
|
26
|
-
IWETH(WETH).deposit{
|
|
21
|
+
IWETH(WETH).deposit{value: amount}();
|
|
27
22
|
amountSharesOut = super._deposit(WETH, amount);
|
|
28
23
|
} else if (tokenIn == STETH) {
|
|
29
24
|
uint256 amountWstETH = _depositWstETH(STETH, amount);
|
|
@@ -50,13 +45,10 @@ contract PendleAuraWethWstethSYV2 is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
50
45
|
}
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
function _previewDeposit(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
override
|
|
58
|
-
returns (uint256 amountSharesOut)
|
|
59
|
-
{
|
|
48
|
+
function _previewDeposit(
|
|
49
|
+
address tokenIn,
|
|
50
|
+
uint256 amountTokenToDeposit
|
|
51
|
+
) internal view virtual override returns (uint256 amountSharesOut) {
|
|
60
52
|
if (tokenIn == NATIVE) {
|
|
61
53
|
amountSharesOut = super._previewDeposit(WETH, amountTokenToDeposit);
|
|
62
54
|
} else if (tokenIn == STETH) {
|
|
@@ -67,13 +59,10 @@ contract PendleAuraWethWstethSYV2 is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
67
59
|
}
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
function _previewRedeem(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
override
|
|
75
|
-
returns (uint256 amountTokenOut)
|
|
76
|
-
{
|
|
62
|
+
function _previewRedeem(
|
|
63
|
+
address tokenOut,
|
|
64
|
+
uint256 amountSharesToRedeem
|
|
65
|
+
) internal view virtual override returns (uint256 amountTokenOut) {
|
|
77
66
|
if (tokenOut == NATIVE) {
|
|
78
67
|
amountTokenOut = super._previewRedeem(WETH, amountSharesToRedeem);
|
|
79
68
|
} else if (tokenOut == STETH) {
|
|
@@ -84,13 +73,7 @@ contract PendleAuraWethWstethSYV2 is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
84
73
|
}
|
|
85
74
|
}
|
|
86
75
|
|
|
87
|
-
function _getPoolTokenAddresses()
|
|
88
|
-
internal
|
|
89
|
-
view
|
|
90
|
-
virtual
|
|
91
|
-
override
|
|
92
|
-
returns (address[] memory res)
|
|
93
|
-
{
|
|
76
|
+
function _getPoolTokenAddresses() internal view virtual override returns (address[] memory res) {
|
|
94
77
|
res = new address[](2);
|
|
95
78
|
res[0] = WSTETH;
|
|
96
79
|
res[1] = WETH;
|
|
@@ -137,18 +120,10 @@ contract PendleAuraWethWstethSYV2 is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
137
120
|
}
|
|
138
121
|
|
|
139
122
|
function isValidTokenIn(address token) public view virtual override returns (bool) {
|
|
140
|
-
return (token == LP ||
|
|
141
|
-
token == WSTETH ||
|
|
142
|
-
token == WETH ||
|
|
143
|
-
token == STETH ||
|
|
144
|
-
token == NATIVE);
|
|
123
|
+
return (token == LP || token == WSTETH || token == WETH || token == STETH || token == NATIVE);
|
|
145
124
|
}
|
|
146
125
|
|
|
147
126
|
function isValidTokenOut(address token) public view virtual override returns (bool) {
|
|
148
|
-
return (token == LP ||
|
|
149
|
-
token == WSTETH ||
|
|
150
|
-
token == WETH ||
|
|
151
|
-
token == STETH ||
|
|
152
|
-
token == NATIVE);
|
|
127
|
+
return (token == LP || token == WSTETH || token == WETH || token == STETH || token == NATIVE);
|
|
153
128
|
}
|
|
154
129
|
}
|
package/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "./base/PendleAuraBalancerStableLPSYV2.sol";
|
|
5
5
|
import "./base/ComposableStable/ComposableStablePreview.sol";
|
|
@@ -18,17 +18,10 @@ contract PendleAuraWstethAnkreth is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
18
18
|
string memory _symbol,
|
|
19
19
|
ComposableStablePreview _composablePreviewHelper
|
|
20
20
|
)
|
|
21
|
-
PendleAuraBalancerStableLPSYV2(_name, _symbol, LP, AURA_PID, _composablePreviewHelper)
|
|
22
|
-
|
|
23
|
-
{
|
|
21
|
+
PendleAuraBalancerStableLPSYV2(_name, _symbol, LP, AURA_PID, _composablePreviewHelper) //solhint-disable-next-line
|
|
22
|
+
{}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function _deposit(address tokenIn, uint256 amount)
|
|
28
|
-
internal
|
|
29
|
-
override
|
|
30
|
-
returns (uint256 amountSharesOut)
|
|
31
|
-
{
|
|
24
|
+
function _deposit(address tokenIn, uint256 amount) internal override returns (uint256 amountSharesOut) {
|
|
32
25
|
if (tokenIn == NATIVE || tokenIn == STETH) {
|
|
33
26
|
uint256 amountWstETH = _depositWstETH(tokenIn, amount);
|
|
34
27
|
amountSharesOut = super._deposit(WSTETH, amountWstETH);
|
|
@@ -50,12 +43,7 @@ contract PendleAuraWstethAnkreth is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
45
|
|
|
53
|
-
function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit)
|
|
54
|
-
internal
|
|
55
|
-
view
|
|
56
|
-
override
|
|
57
|
-
returns (uint256)
|
|
58
|
-
{
|
|
46
|
+
function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit) internal view override returns (uint256) {
|
|
59
47
|
if (tokenIn == NATIVE || tokenIn == STETH) {
|
|
60
48
|
uint256 amountWstETH = _previewDepositWstETH(tokenIn, amountTokenToDeposit);
|
|
61
49
|
return super._previewDeposit(WSTETH, amountWstETH);
|
|
@@ -64,12 +52,7 @@ contract PendleAuraWstethAnkreth is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
64
52
|
}
|
|
65
53
|
}
|
|
66
54
|
|
|
67
|
-
function _previewRedeem(address tokenOut, uint256 amountSharesToRedeem)
|
|
68
|
-
internal
|
|
69
|
-
view
|
|
70
|
-
override
|
|
71
|
-
returns (uint256)
|
|
72
|
-
{
|
|
55
|
+
function _previewRedeem(address tokenOut, uint256 amountSharesToRedeem) internal view override returns (uint256) {
|
|
73
56
|
if (tokenOut == STETH) {
|
|
74
57
|
uint256 amountWstETH = super._previewRedeem(WSTETH, amountSharesToRedeem);
|
|
75
58
|
return _previewRedeemWstETH(amountWstETH);
|
|
@@ -140,11 +123,7 @@ contract PendleAuraWstethAnkreth is PendleAuraBalancerStableLPSYV2, StEthHelper
|
|
|
140
123
|
}
|
|
141
124
|
|
|
142
125
|
function isValidTokenIn(address token) public pure override returns (bool) {
|
|
143
|
-
return (token == NATIVE ||
|
|
144
|
-
token == STETH ||
|
|
145
|
-
token == WSTETH ||
|
|
146
|
-
token == ANKRETH ||
|
|
147
|
-
token == LP);
|
|
126
|
+
return (token == NATIVE || token == STETH || token == WSTETH || token == ANKRETH || token == LP);
|
|
148
127
|
}
|
|
149
128
|
|
|
150
129
|
function isValidTokenOut(address token) public pure override returns (bool) {
|
|
@@ -11,11 +11,10 @@ library ComposableStableMath {
|
|
|
11
11
|
uint256 internal constant _MAX_AMP = 5000;
|
|
12
12
|
uint256 internal constant _AMP_PRECISION = 1e3;
|
|
13
13
|
|
|
14
|
-
function _calculateInvariant(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
14
|
+
function _calculateInvariant(
|
|
15
|
+
uint256 amplificationParameter,
|
|
16
|
+
uint256[] memory balances
|
|
17
|
+
) internal pure returns (uint256) {
|
|
19
18
|
unchecked {
|
|
20
19
|
/**********************************************************************************************
|
|
21
20
|
// invariant //
|
|
@@ -54,17 +53,14 @@ library ComposableStableMath {
|
|
|
54
53
|
invariant = divDown(
|
|
55
54
|
mul(
|
|
56
55
|
// (ampTimesTotal * sum) / AMP_PRECISION + D_P * numTokens
|
|
57
|
-
(
|
|
58
|
-
divDown(mul(ampTimesTotal, sum), _AMP_PRECISION).add(
|
|
59
|
-
mul(D_P, numTokens)
|
|
60
|
-
)
|
|
61
|
-
),
|
|
56
|
+
(divDown(mul(ampTimesTotal, sum), _AMP_PRECISION).add(mul(D_P, numTokens))),
|
|
62
57
|
invariant
|
|
63
58
|
),
|
|
64
59
|
// ((ampTimesTotal - _AMP_PRECISION) * invariant) / _AMP_PRECISION + (numTokens + 1) * D_P
|
|
65
60
|
(
|
|
66
|
-
divDown(mul((ampTimesTotal - _AMP_PRECISION), invariant), _AMP_PRECISION)
|
|
67
|
-
|
|
61
|
+
divDown(mul((ampTimesTotal - _AMP_PRECISION), invariant), _AMP_PRECISION).add(
|
|
62
|
+
mul((numTokens + 1), D_P)
|
|
63
|
+
)
|
|
68
64
|
)
|
|
69
65
|
);
|
|
70
66
|
|
|
@@ -106,9 +102,7 @@ library ComposableStableMath {
|
|
|
106
102
|
for (uint256 i = 0; i < balances.length; i++) {
|
|
107
103
|
uint256 currentWeight = balances[i].divDown(sumBalances);
|
|
108
104
|
balanceRatiosWithFee[i] = balances[i].add(amountsIn[i]).divDown(balances[i]);
|
|
109
|
-
invariantRatioWithFees = invariantRatioWithFees.add(
|
|
110
|
-
balanceRatiosWithFee[i].mulDown(currentWeight)
|
|
111
|
-
);
|
|
105
|
+
invariantRatioWithFees = invariantRatioWithFees.add(balanceRatiosWithFee[i].mulDown(currentWeight));
|
|
112
106
|
}
|
|
113
107
|
|
|
114
108
|
// Second loop calculates new amounts in, taking into account the fee on the percentage excess
|
|
@@ -118,9 +112,7 @@ library ComposableStableMath {
|
|
|
118
112
|
|
|
119
113
|
// Check if the balance ratio is greater than the ideal ratio to charge fees or not
|
|
120
114
|
if (balanceRatiosWithFee[i] > invariantRatioWithFees) {
|
|
121
|
-
uint256 nonTaxableAmount = balances[i].mulDown(
|
|
122
|
-
invariantRatioWithFees.sub(FixedPoint.ONE)
|
|
123
|
-
);
|
|
115
|
+
uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithFees.sub(FixedPoint.ONE));
|
|
124
116
|
uint256 taxableAmount = amountsIn[i].sub(nonTaxableAmount);
|
|
125
117
|
// No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50%
|
|
126
118
|
amountInWithoutFee = nonTaxableAmount.add(
|
|
@@ -157,9 +149,7 @@ library ComposableStableMath {
|
|
|
157
149
|
unchecked {
|
|
158
150
|
// Token out, so we round down overall.
|
|
159
151
|
|
|
160
|
-
uint256 newInvariant = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply).mulUp(
|
|
161
|
-
currentInvariant
|
|
162
|
-
);
|
|
152
|
+
uint256 newInvariant = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply).mulUp(currentInvariant);
|
|
163
153
|
|
|
164
154
|
// Calculate amount out without fee
|
|
165
155
|
uint256 newBalanceTokenIndex = _getTokenBalanceGivenInvariantAndAllOtherBalances(
|
|
@@ -215,10 +205,7 @@ library ComposableStableMath {
|
|
|
215
205
|
|
|
216
206
|
uint256 inv2 = mul(invariant, invariant);
|
|
217
207
|
// We remove the balance from c by multiplying it
|
|
218
|
-
uint256 c = mul(
|
|
219
|
-
mul(divUp(inv2, mul(ampTimesTotal, P_D)), _AMP_PRECISION),
|
|
220
|
-
balances[tokenIndex]
|
|
221
|
-
);
|
|
208
|
+
uint256 c = mul(mul(divUp(inv2, mul(ampTimesTotal, P_D)), _AMP_PRECISION), balances[tokenIndex]);
|
|
222
209
|
uint256 b = sum.add(mul(divDown(invariant, ampTimesTotal), _AMP_PRECISION));
|
|
223
210
|
|
|
224
211
|
// We iterate to find the balance
|
|
@@ -260,11 +247,7 @@ library ComposableStableMath {
|
|
|
260
247
|
}
|
|
261
248
|
}
|
|
262
249
|
|
|
263
|
-
function div(
|
|
264
|
-
uint256 a,
|
|
265
|
-
uint256 b,
|
|
266
|
-
bool roundUp
|
|
267
|
-
) private pure returns (uint256) {
|
|
250
|
+
function div(uint256 a, uint256 b, bool roundUp) private pure returns (uint256) {
|
|
268
251
|
return roundUp ? divUp(a, b) : divDown(a, b);
|
|
269
252
|
}
|
|
270
253
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
pragma solidity 0.8.17;
|
|
2
|
+
pragma solidity ^0.8.17;
|
|
3
3
|
|
|
4
4
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
5
|
import "../../../../../../interfaces/Balancer/IComposableStable.sol";
|
|
@@ -145,17 +145,10 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
145
145
|
uint256 preJoinExitInvariant
|
|
146
146
|
) = _beforeJoinExit(registeredBalances, imd, caches);
|
|
147
147
|
|
|
148
|
-
function(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
uint256,
|
|
152
|
-
uint256,
|
|
153
|
-
uint256[] memory,
|
|
154
|
-
bytes memory,
|
|
155
|
-
ImmutableData memory
|
|
156
|
-
) internal view returns (uint256, uint256[] memory) _doJoinOrExit = (
|
|
157
|
-
isJoin ? _doJoin : _doExit
|
|
158
|
-
);
|
|
148
|
+
function(uint256[] memory, uint256, uint256, uint256, uint256[] memory, bytes memory, ImmutableData memory)
|
|
149
|
+
internal
|
|
150
|
+
view
|
|
151
|
+
returns (uint256, uint256[] memory) _doJoinOrExit = (isJoin ? _doJoin : _doExit);
|
|
159
152
|
|
|
160
153
|
(bptAmount, amountsDelta) = _doJoinOrExit(
|
|
161
154
|
balances,
|
|
@@ -180,9 +173,7 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
180
173
|
) internal pure returns (uint256[] memory registeredTokenAmounts) {
|
|
181
174
|
registeredTokenAmounts = new uint256[](amounts.length + 1);
|
|
182
175
|
for (uint256 i = 0; i < registeredTokenAmounts.length; i++) {
|
|
183
|
-
registeredTokenAmounts[i] = i == imd.bptIndex
|
|
184
|
-
? bptAmount
|
|
185
|
-
: amounts[i < imd.bptIndex ? i : i - 1];
|
|
176
|
+
registeredTokenAmounts[i] = i == imd.bptIndex ? bptAmount : amounts[i < imd.bptIndex ? i : i - 1];
|
|
186
177
|
}
|
|
187
178
|
}
|
|
188
179
|
|
|
@@ -237,20 +228,12 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
237
228
|
uint256 currentAmp,
|
|
238
229
|
uint256 preJoinExitSupply,
|
|
239
230
|
uint256 preJoinExitInvariant,
|
|
240
|
-
uint256[] memory
|
|
231
|
+
uint256[] memory /*scalingFactors*/,
|
|
241
232
|
bytes memory userData,
|
|
242
233
|
ImmutableData memory imd
|
|
243
234
|
) internal view returns (uint256, uint256[] memory) {
|
|
244
235
|
// this is always true given Pendle SY context
|
|
245
|
-
return
|
|
246
|
-
_exitExactBPTInForTokenOut(
|
|
247
|
-
preJoinExitSupply,
|
|
248
|
-
preJoinExitInvariant,
|
|
249
|
-
currentAmp,
|
|
250
|
-
balances,
|
|
251
|
-
userData,
|
|
252
|
-
imd
|
|
253
|
-
);
|
|
236
|
+
return _exitExactBPTInForTokenOut(preJoinExitSupply, preJoinExitInvariant, currentAmp, balances, userData, imd);
|
|
254
237
|
}
|
|
255
238
|
|
|
256
239
|
function _exitExactBPTInForTokenOut(
|
|
@@ -281,30 +264,14 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
281
264
|
uint256[] memory registeredBalances,
|
|
282
265
|
ImmutableData memory imd,
|
|
283
266
|
TokenRateCache[] memory caches
|
|
284
|
-
)
|
|
285
|
-
|
|
286
|
-
view
|
|
287
|
-
returns (
|
|
288
|
-
uint256,
|
|
289
|
-
uint256[] memory,
|
|
290
|
-
uint256,
|
|
291
|
-
uint256
|
|
292
|
-
)
|
|
293
|
-
{
|
|
294
|
-
(uint256 lastJoinExitAmp, uint256 lastPostJoinExitInvariant) = IComposableStable(imd.LP)
|
|
295
|
-
.getLastJoinExitData();
|
|
267
|
+
) internal view returns (uint256, uint256[] memory, uint256, uint256) {
|
|
268
|
+
(uint256 lastJoinExitAmp, uint256 lastPostJoinExitInvariant) = IComposableStable(imd.LP).getLastJoinExitData();
|
|
296
269
|
|
|
297
270
|
(
|
|
298
271
|
uint256 preJoinExitSupply,
|
|
299
272
|
uint256[] memory balances,
|
|
300
273
|
uint256 oldAmpPreJoinExitInvariant
|
|
301
|
-
) = _payProtocolFeesBeforeJoinExit(
|
|
302
|
-
registeredBalances,
|
|
303
|
-
lastJoinExitAmp,
|
|
304
|
-
lastPostJoinExitInvariant,
|
|
305
|
-
imd,
|
|
306
|
-
caches
|
|
307
|
-
);
|
|
274
|
+
) = _payProtocolFeesBeforeJoinExit(registeredBalances, lastJoinExitAmp, lastPostJoinExitInvariant, imd, caches);
|
|
308
275
|
|
|
309
276
|
(uint256 currentAmp, , ) = IComposableStable(imd.LP).getAmplificationParameter();
|
|
310
277
|
uint256 preJoinExitInvariant = currentAmp == lastJoinExitAmp
|
|
@@ -320,30 +287,13 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
320
287
|
uint256 lastPostJoinExitInvariant,
|
|
321
288
|
ImmutableData memory imd,
|
|
322
289
|
TokenRateCache[] memory caches
|
|
323
|
-
)
|
|
324
|
-
|
|
325
|
-
view
|
|
326
|
-
returns (
|
|
327
|
-
uint256,
|
|
328
|
-
uint256[] memory,
|
|
329
|
-
uint256
|
|
330
|
-
)
|
|
331
|
-
{
|
|
332
|
-
(uint256 virtualSupply, uint256[] memory balances) = _dropBptItemFromBalances(
|
|
333
|
-
imd,
|
|
334
|
-
registeredBalances
|
|
335
|
-
);
|
|
290
|
+
) internal view returns (uint256, uint256[] memory, uint256) {
|
|
291
|
+
(uint256 virtualSupply, uint256[] memory balances) = _dropBptItemFromBalances(imd, registeredBalances);
|
|
336
292
|
|
|
337
293
|
(
|
|
338
294
|
uint256 expectedProtocolOwnershipPercentage,
|
|
339
295
|
uint256 currentInvariantWithLastJoinExitAmp
|
|
340
|
-
) = _getProtocolPoolOwnershipPercentage(
|
|
341
|
-
balances,
|
|
342
|
-
lastJoinExitAmp,
|
|
343
|
-
lastPostJoinExitInvariant,
|
|
344
|
-
imd,
|
|
345
|
-
caches
|
|
346
|
-
);
|
|
296
|
+
) = _getProtocolPoolOwnershipPercentage(balances, lastJoinExitAmp, lastPostJoinExitInvariant, imd, caches);
|
|
347
297
|
|
|
348
298
|
uint256 protocolFeeAmount = _calculateAdjustedProtocolFeeAmount(
|
|
349
299
|
virtualSupply,
|
|
@@ -371,22 +321,17 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
371
321
|
uint256 swapFeeGrowthInvariantDelta = (swapFeeGrowthInvariant > lastPostJoinExitInvariant)
|
|
372
322
|
? swapFeeGrowthInvariant - lastPostJoinExitInvariant
|
|
373
323
|
: 0;
|
|
374
|
-
uint256 nonExemptYieldGrowthInvariantDelta = (totalNonExemptGrowthInvariant >
|
|
375
|
-
swapFeeGrowthInvariant)
|
|
324
|
+
uint256 nonExemptYieldGrowthInvariantDelta = (totalNonExemptGrowthInvariant > swapFeeGrowthInvariant)
|
|
376
325
|
? totalNonExemptGrowthInvariant - swapFeeGrowthInvariant
|
|
377
326
|
: 0;
|
|
378
327
|
|
|
379
|
-
uint256 protocolSwapFeePercentage = swapFeeGrowthInvariantDelta
|
|
380
|
-
.
|
|
381
|
-
|
|
382
|
-
IComposableStable(imd.LP).getProtocolFeePercentageCache(0) // ProtocolFeeType.SWAP // can't get better
|
|
383
|
-
);
|
|
328
|
+
uint256 protocolSwapFeePercentage = swapFeeGrowthInvariantDelta.divDown(totalGrowthInvariant).mulDown(
|
|
329
|
+
IComposableStable(imd.LP).getProtocolFeePercentageCache(0) // ProtocolFeeType.SWAP // can't get better
|
|
330
|
+
);
|
|
384
331
|
|
|
385
|
-
uint256 protocolYieldPercentage = nonExemptYieldGrowthInvariantDelta
|
|
386
|
-
.
|
|
387
|
-
|
|
388
|
-
IComposableStable(imd.LP).getProtocolFeePercentageCache(2) // ProtocolFeeType.YIELD // can't get better
|
|
389
|
-
);
|
|
332
|
+
uint256 protocolYieldPercentage = nonExemptYieldGrowthInvariantDelta.divDown(totalGrowthInvariant).mulDown(
|
|
333
|
+
IComposableStable(imd.LP).getProtocolFeePercentageCache(2) // ProtocolFeeType.YIELD // can't get better
|
|
334
|
+
);
|
|
390
335
|
|
|
391
336
|
// These percentages can then be simply added to compute the total protocol Pool ownership percentage.
|
|
392
337
|
// This is naturally bounded above by FixedPoint.ONE so this addition cannot overflow.
|
|
@@ -401,15 +346,9 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
401
346
|
)
|
|
402
347
|
internal
|
|
403
348
|
pure
|
|
404
|
-
returns (
|
|
405
|
-
uint256 swapFeeGrowthInvariant,
|
|
406
|
-
uint256 totalNonExemptGrowthInvariant,
|
|
407
|
-
uint256 totalGrowthInvariant
|
|
408
|
-
)
|
|
349
|
+
returns (uint256 swapFeeGrowthInvariant, uint256 totalNonExemptGrowthInvariant, uint256 totalGrowthInvariant)
|
|
409
350
|
{
|
|
410
|
-
swapFeeGrowthInvariant = lastJoinExitAmp._calculateInvariant(
|
|
411
|
-
_getAdjustedBalances(balances, true, imd, caches)
|
|
412
|
-
);
|
|
351
|
+
swapFeeGrowthInvariant = lastJoinExitAmp._calculateInvariant(_getAdjustedBalances(balances, true, imd, caches));
|
|
413
352
|
|
|
414
353
|
if (imd.noTokensExempt) {
|
|
415
354
|
totalNonExemptGrowthInvariant = lastJoinExitAmp._calculateInvariant(balances);
|
|
@@ -446,19 +385,14 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
446
385
|
return adjustedBalances;
|
|
447
386
|
}
|
|
448
387
|
|
|
449
|
-
function _adjustedBalance(uint256 balance, TokenRateCache memory cache)
|
|
450
|
-
private
|
|
451
|
-
pure
|
|
452
|
-
returns (uint256)
|
|
453
|
-
{
|
|
388
|
+
function _adjustedBalance(uint256 balance, TokenRateCache memory cache) private pure returns (uint256) {
|
|
454
389
|
return (balance * cache.oldRate) / cache.currentRate;
|
|
455
390
|
}
|
|
456
391
|
|
|
457
|
-
function _calculateAdjustedProtocolFeeAmount(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
{
|
|
392
|
+
function _calculateAdjustedProtocolFeeAmount(
|
|
393
|
+
uint256 supply,
|
|
394
|
+
uint256 basePercentage
|
|
395
|
+
) internal pure returns (uint256) {
|
|
462
396
|
return supply.mulDown(basePercentage).divDown(basePercentage.complement());
|
|
463
397
|
}
|
|
464
398
|
|
|
@@ -466,17 +400,10 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
466
400
|
ImmutableData memory imd,
|
|
467
401
|
uint256[] memory registeredBalances
|
|
468
402
|
) internal view returns (uint256, uint256[] memory) {
|
|
469
|
-
return (
|
|
470
|
-
_getVirtualSupply(imd, registeredBalances[imd.bptIndex]),
|
|
471
|
-
_dropBptItem(imd, registeredBalances)
|
|
472
|
-
);
|
|
403
|
+
return (_getVirtualSupply(imd, registeredBalances[imd.bptIndex]), _dropBptItem(imd, registeredBalances));
|
|
473
404
|
}
|
|
474
405
|
|
|
475
|
-
function _dropBptItem(ImmutableData memory imd, uint256[] memory amounts)
|
|
476
|
-
internal
|
|
477
|
-
pure
|
|
478
|
-
returns (uint256[] memory)
|
|
479
|
-
{
|
|
406
|
+
function _dropBptItem(ImmutableData memory imd, uint256[] memory amounts) internal pure returns (uint256[] memory) {
|
|
480
407
|
uint256[] memory amountsWithoutBpt = new uint256[](amounts.length - 1);
|
|
481
408
|
for (uint256 i = 0; i < amountsWithoutBpt.length; i++) {
|
|
482
409
|
amountsWithoutBpt[i] = amounts[i < imd.bptIndex ? i : i + 1];
|
|
@@ -485,27 +412,19 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
485
412
|
return amountsWithoutBpt;
|
|
486
413
|
}
|
|
487
414
|
|
|
488
|
-
function _getVirtualSupply(ImmutableData memory imd, uint256 bptBalance)
|
|
489
|
-
internal
|
|
490
|
-
view
|
|
491
|
-
returns (uint256)
|
|
492
|
-
{
|
|
415
|
+
function _getVirtualSupply(ImmutableData memory imd, uint256 bptBalance) internal view returns (uint256) {
|
|
493
416
|
return (IERC20(imd.LP).totalSupply()).sub(bptBalance); // can't get better
|
|
494
417
|
}
|
|
495
418
|
|
|
496
|
-
function _beforeSwapJoinExit(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
returns (TokenRateCache[] memory tokenRateCaches)
|
|
500
|
-
{
|
|
419
|
+
function _beforeSwapJoinExit(
|
|
420
|
+
ImmutableData memory imd
|
|
421
|
+
) internal view returns (TokenRateCache[] memory tokenRateCaches) {
|
|
501
422
|
return _cacheTokenRatesIfNecessary(imd);
|
|
502
423
|
}
|
|
503
424
|
|
|
504
|
-
function _cacheTokenRatesIfNecessary(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
returns (TokenRateCache[] memory tokenRateCaches)
|
|
508
|
-
{
|
|
425
|
+
function _cacheTokenRatesIfNecessary(
|
|
426
|
+
ImmutableData memory imd
|
|
427
|
+
) internal view returns (TokenRateCache[] memory tokenRateCaches) {
|
|
509
428
|
tokenRateCaches = new TokenRateCache[](imd.totalTokens);
|
|
510
429
|
|
|
511
430
|
for (uint256 i = 0; i < imd.totalTokens; ++i) {
|
|
@@ -516,11 +435,10 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
516
435
|
/**
|
|
517
436
|
* @dev Caches the rate for a token if necessary. It ignores the call if there is no provider set.
|
|
518
437
|
*/
|
|
519
|
-
function _cacheTokenRateIfNecessary(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
{
|
|
438
|
+
function _cacheTokenRateIfNecessary(
|
|
439
|
+
uint256 index,
|
|
440
|
+
ImmutableData memory imd
|
|
441
|
+
) internal view returns (TokenRateCache memory res) {
|
|
524
442
|
if (index == imd.bptIndex || !_hasRateProvider(imd, index)) return res;
|
|
525
443
|
|
|
526
444
|
uint256 expires;
|
|
@@ -533,12 +451,10 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
533
451
|
}
|
|
534
452
|
}
|
|
535
453
|
|
|
536
|
-
function _scalingFactors(
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
returns (uint256[] memory)
|
|
541
|
-
{
|
|
454
|
+
function _scalingFactors(
|
|
455
|
+
ImmutableData memory imd,
|
|
456
|
+
TokenRateCache[] memory caches
|
|
457
|
+
) internal view virtual returns (uint256[] memory) {
|
|
542
458
|
// There is no need to check the arrays length since both are based on `_getTotalTokens`
|
|
543
459
|
uint256[] memory scalingFactors = new uint256[](imd.totalTokens);
|
|
544
460
|
|
|
@@ -549,12 +465,7 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
549
465
|
return scalingFactors;
|
|
550
466
|
}
|
|
551
467
|
|
|
552
|
-
function _getTokenRate(TokenRateCache[] memory caches, uint256 index)
|
|
553
|
-
internal
|
|
554
|
-
view
|
|
555
|
-
virtual
|
|
556
|
-
returns (uint256)
|
|
557
|
-
{
|
|
468
|
+
function _getTokenRate(TokenRateCache[] memory caches, uint256 index) internal view virtual returns (uint256) {
|
|
558
469
|
return caches[index].currentRate == 0 ? FixedPoint.ONE : caches[index].currentRate;
|
|
559
470
|
}
|
|
560
471
|
|
|
@@ -562,39 +473,25 @@ contract ComposableStablePreviewV4 is ComposableStablePreview {
|
|
|
562
473
|
Helpers functions
|
|
563
474
|
//////////////////////////////////////////////////////////////*/
|
|
564
475
|
|
|
565
|
-
function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors)
|
|
566
|
-
internal
|
|
567
|
-
pure
|
|
568
|
-
{
|
|
476
|
+
function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal pure {
|
|
569
477
|
uint256 length = amounts.length;
|
|
570
478
|
for (uint256 i = 0; i < length; ++i) {
|
|
571
479
|
amounts[i] = FixedPoint.mulDown(amounts[i], scalingFactors[i]);
|
|
572
480
|
}
|
|
573
481
|
}
|
|
574
482
|
|
|
575
|
-
function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors)
|
|
576
|
-
internal
|
|
577
|
-
pure
|
|
578
|
-
{
|
|
483
|
+
function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal pure {
|
|
579
484
|
uint256 length = amounts.length;
|
|
580
485
|
for (uint256 i = 0; i < length; ++i) {
|
|
581
486
|
amounts[i] = FixedPoint.divDown(amounts[i], scalingFactors[i]);
|
|
582
487
|
}
|
|
583
488
|
}
|
|
584
489
|
|
|
585
|
-
function _hasRateProvider(ImmutableData memory imd, uint256 index)
|
|
586
|
-
internal
|
|
587
|
-
pure
|
|
588
|
-
returns (bool)
|
|
589
|
-
{
|
|
490
|
+
function _hasRateProvider(ImmutableData memory imd, uint256 index) internal pure returns (bool) {
|
|
590
491
|
return address(imd.rateProviders[index]) != address(0);
|
|
591
492
|
}
|
|
592
493
|
|
|
593
|
-
function _isTokenExemptFromYieldProtocolFee(ImmutableData memory imd, uint256 index)
|
|
594
|
-
internal
|
|
595
|
-
pure
|
|
596
|
-
returns (bool)
|
|
597
|
-
{
|
|
494
|
+
function _isTokenExemptFromYieldProtocolFee(ImmutableData memory imd, uint256 index) internal pure returns (bool) {
|
|
598
495
|
return imd.isExemptFromYieldProtocolFee[index];
|
|
599
496
|
}
|
|
600
497
|
}
|