@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
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
import "
|
|
5
|
-
import "
|
|
6
|
-
import "
|
|
4
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
+
import {IExecutorHelper} from "../interfaces/IExecutorHelper.sol";
|
|
6
|
+
import {IMetaAggregationRouterV2} from "../interfaces/IMetaAggregationRouterV2.sol";
|
|
7
|
+
import {ScalingDataLib} from "./ScalingDataLib.sol";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
/* ----------------------------------------
|
|
10
|
+
.__ __. ______ .___________. _______
|
|
11
|
+
| \ | | / __ \ | || ____|
|
|
12
|
+
| \| | | | | | `---| |----`| |__
|
|
13
|
+
| . ` | | | | | | | | __|
|
|
14
|
+
| |\ | | `--' | | | | |____
|
|
15
|
+
|__| \__| \______/ |__| |_______|
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Please use InputScalingHelperL2 contract for scaling data on Arbitrum, Optimism, Base
|
|
19
|
+
|
|
20
|
+
---------------------------------------- */
|
|
21
|
+
|
|
22
|
+
library InputScalingHelper {
|
|
9
23
|
uint256 private constant _PARTIAL_FILL = 0x01;
|
|
10
24
|
uint256 private constant _REQUIRES_EXTRA_ETH = 0x02;
|
|
11
25
|
uint256 private constant _SHOULD_CLAIM = 0x04;
|
|
@@ -41,11 +55,7 @@ abstract contract KyberInputScalingHelper {
|
|
|
41
55
|
bytes positiveSlippageData;
|
|
42
56
|
}
|
|
43
57
|
|
|
44
|
-
function
|
|
45
|
-
internal
|
|
46
|
-
pure
|
|
47
|
-
returns (bytes memory)
|
|
48
|
-
{
|
|
58
|
+
function _getScaledInputData(bytes calldata inputData, uint256 newAmount) internal pure returns (bytes memory) {
|
|
49
59
|
bytes4 selector = bytes4(inputData[:4]);
|
|
50
60
|
bytes calldata dataToDecode = inputData[4:];
|
|
51
61
|
|
|
@@ -68,14 +78,13 @@ abstract contract KyberInputScalingHelper {
|
|
|
68
78
|
IMetaAggregationRouterV2.SwapDescriptionV2 memory desc,
|
|
69
79
|
bytes memory targetData,
|
|
70
80
|
bytes memory clientData
|
|
71
|
-
) = abi.decode(
|
|
72
|
-
dataToDecode,
|
|
73
|
-
(address, IMetaAggregationRouterV2.SwapDescriptionV2, bytes, bytes)
|
|
74
|
-
);
|
|
81
|
+
) = abi.decode(dataToDecode, (address, IMetaAggregationRouterV2.SwapDescriptionV2, bytes, bytes));
|
|
75
82
|
|
|
76
83
|
(desc, targetData) = _getScaledInputDataV2(desc, targetData, newAmount, true);
|
|
77
84
|
return abi.encodeWithSelector(selector, callTarget, desc, targetData, clientData);
|
|
78
|
-
} else
|
|
85
|
+
} else {
|
|
86
|
+
revert("InputScalingHelper: Invalid selector");
|
|
87
|
+
}
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
function _getScaledInputDataV2(
|
|
@@ -192,11 +201,11 @@ abstract contract KyberInputScalingHelper {
|
|
|
192
201
|
} else if (functionSelector == IExecutorHelper.executeSynthetix.selector) {
|
|
193
202
|
swap.data = ScalingDataLib.newSynthetix(swap.data, oldAmount, newAmount);
|
|
194
203
|
} else if (functionSelector == IExecutorHelper.executeHashflow.selector) {
|
|
195
|
-
revert("InputScalingHelper: Can not scale
|
|
204
|
+
revert("InputScalingHelper: Can not scale Hasflow swap");
|
|
196
205
|
} else if (functionSelector == IExecutorHelper.executeCamelot.selector) {
|
|
197
206
|
swap.data = ScalingDataLib.newCamelot(swap.data, oldAmount, newAmount);
|
|
198
207
|
} else if (functionSelector == IExecutorHelper.executeKyberLimitOrder.selector) {
|
|
199
|
-
revert("InputScalingHelper: Can not scale
|
|
208
|
+
revert("InputScalingHelper: Can not scale KyberLO swap");
|
|
200
209
|
} else if (functionSelector == IExecutorHelper.executePSM.selector) {
|
|
201
210
|
swap.data = ScalingDataLib.newPSM(swap.data, oldAmount, newAmount);
|
|
202
211
|
} else if (functionSelector == IExecutorHelper.executeFrax.selector) {
|
|
@@ -205,7 +214,43 @@ abstract contract KyberInputScalingHelper {
|
|
|
205
214
|
swap.data = ScalingDataLib.newPlatypus(swap.data, oldAmount, newAmount);
|
|
206
215
|
} else if (functionSelector == IExecutorHelper.executeMaverick.selector) {
|
|
207
216
|
swap.data = ScalingDataLib.newMaverick(swap.data, oldAmount, newAmount);
|
|
208
|
-
} else
|
|
217
|
+
} else if (functionSelector == IExecutorHelper.executeSyncSwap.selector) {
|
|
218
|
+
swap.data = ScalingDataLib.newSyncSwap(swap.data, oldAmount, newAmount);
|
|
219
|
+
} else if (functionSelector == IExecutorHelper.executeAlgebraV1.selector) {
|
|
220
|
+
swap.data = ScalingDataLib.newAlgebraV1(swap.data, oldAmount, newAmount);
|
|
221
|
+
} else if (functionSelector == IExecutorHelper.executeBalancerBatch.selector) {
|
|
222
|
+
swap.data = ScalingDataLib.newBalancerBatch(swap.data, oldAmount, newAmount);
|
|
223
|
+
} else if (functionSelector == IExecutorHelper.executeWombat.selector) {
|
|
224
|
+
swap.data = ScalingDataLib.newMantis(swap.data, oldAmount, newAmount); // @dev struct Mantis is used for both Wombat and Mantis because of same fields
|
|
225
|
+
} else if (functionSelector == IExecutorHelper.executeMantis.selector) {
|
|
226
|
+
swap.data = ScalingDataLib.newMantis(swap.data, oldAmount, newAmount);
|
|
227
|
+
} else if (functionSelector == IExecutorHelper.executeIziSwap.selector) {
|
|
228
|
+
swap.data = ScalingDataLib.newIziSwap(swap.data, oldAmount, newAmount);
|
|
229
|
+
} else if (functionSelector == IExecutorHelper.executeWooFiV2.selector) {
|
|
230
|
+
swap.data = ScalingDataLib.newMantis(swap.data, oldAmount, newAmount); // @dev using Mantis struct because WooFiV2 and Mantis have same fields
|
|
231
|
+
} else if (functionSelector == IExecutorHelper.executeTraderJoeV2.selector) {
|
|
232
|
+
swap.data = ScalingDataLib.newTraderJoeV2(swap.data, oldAmount, newAmount);
|
|
233
|
+
} else if (functionSelector == IExecutorHelper.executePancakeStableSwap.selector) {
|
|
234
|
+
swap.data = ScalingDataLib.newCurveSwap(swap.data, oldAmount, newAmount);
|
|
235
|
+
} else if (functionSelector == IExecutorHelper.executeLevelFiV2.selector) {
|
|
236
|
+
swap.data = ScalingDataLib.newLevelFiV2(swap.data, oldAmount, newAmount);
|
|
237
|
+
} else if (functionSelector == IExecutorHelper.executeGMXGLP.selector) {
|
|
238
|
+
swap.data = ScalingDataLib.newGMXGLP(swap.data, oldAmount, newAmount);
|
|
239
|
+
} else if (functionSelector == IExecutorHelper.executeVooi.selector) {
|
|
240
|
+
swap.data = ScalingDataLib.newVooi(swap.data, oldAmount, newAmount);
|
|
241
|
+
} else if (functionSelector == IExecutorHelper.executeVelocoreV2.selector) {
|
|
242
|
+
swap.data = ScalingDataLib.newVelocoreV2(swap.data, oldAmount, newAmount);
|
|
243
|
+
} else if (functionSelector == IExecutorHelper.executeMaticMigrate.selector) {
|
|
244
|
+
swap.data = ScalingDataLib.newMaticMigrate(swap.data, oldAmount, newAmount);
|
|
245
|
+
} else if (functionSelector == IExecutorHelper.executeSmardex.selector) {
|
|
246
|
+
swap.data = ScalingDataLib.newMantis(swap.data, oldAmount, newAmount); // @dev using Mantis struct because Smardex and Mantis have same fields
|
|
247
|
+
} else if (functionSelector == IExecutorHelper.executeSolidlyV2.selector) {
|
|
248
|
+
swap.data = ScalingDataLib.newMantis(swap.data, oldAmount, newAmount); // @dev using Mantis struct because Solidly V2 and Mantis have same fields
|
|
249
|
+
} else if (functionSelector == IExecutorHelper.executeKokonut.selector) {
|
|
250
|
+
swap.data = ScalingDataLib.newKokonut(swap.data, oldAmount, newAmount);
|
|
251
|
+
} else {
|
|
252
|
+
revert("AggregationExecutor: Dex type not supported");
|
|
253
|
+
}
|
|
209
254
|
unchecked {
|
|
210
255
|
++i;
|
|
211
256
|
}
|
|
@@ -220,11 +265,17 @@ abstract contract KyberInputScalingHelper {
|
|
|
220
265
|
) internal pure returns (bytes memory newData) {
|
|
221
266
|
if (data.length > 32) {
|
|
222
267
|
PositiveSlippageFeeData memory psData = abi.decode(data, (PositiveSlippageFeeData));
|
|
223
|
-
|
|
268
|
+
uint256 left = uint256(psData.expectedReturnAmount >> 128);
|
|
269
|
+
uint256 right = (uint256(uint128(psData.expectedReturnAmount)) * newAmount) / oldAmount;
|
|
270
|
+
require(right <= type(uint128).max, "Exceeded type range");
|
|
271
|
+
psData.expectedReturnAmount = right | (left << 128);
|
|
224
272
|
data = abi.encode(psData);
|
|
225
273
|
} else if (data.length == 32) {
|
|
226
274
|
uint256 expectedReturnAmount = abi.decode(data, (uint256));
|
|
227
|
-
|
|
275
|
+
uint256 left = uint256(expectedReturnAmount >> 128);
|
|
276
|
+
uint256 right = (uint256(uint128(expectedReturnAmount)) * newAmount) / oldAmount;
|
|
277
|
+
require(right <= type(uint128).max, "Exceeded type range");
|
|
278
|
+
expectedReturnAmount = right | (left << 128);
|
|
228
279
|
data = abi.encode(expectedReturnAmount);
|
|
229
280
|
}
|
|
230
281
|
return data;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
import "
|
|
4
|
+
import {IExecutorHelper} from "../interfaces/IExecutorHelper.sol";
|
|
5
5
|
|
|
6
6
|
library ScalingDataLib {
|
|
7
|
-
function newUniSwap(
|
|
8
|
-
bytes memory data,
|
|
9
|
-
uint256 oldAmount,
|
|
10
|
-
uint256 newAmount
|
|
11
|
-
) internal pure returns (bytes memory) {
|
|
7
|
+
function newUniSwap(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
12
8
|
IExecutorHelper.UniSwap memory uniSwap = abi.decode(data, (IExecutorHelper.UniSwap));
|
|
13
9
|
uniSwap.collectAmount = (uniSwap.collectAmount * newAmount) / oldAmount;
|
|
14
10
|
return abi.encode(uniSwap);
|
|
@@ -19,10 +15,7 @@ library ScalingDataLib {
|
|
|
19
15
|
uint256 oldAmount,
|
|
20
16
|
uint256 newAmount
|
|
21
17
|
) internal pure returns (bytes memory) {
|
|
22
|
-
IExecutorHelper.StableSwap memory stableSwap = abi.decode(
|
|
23
|
-
data,
|
|
24
|
-
(IExecutorHelper.StableSwap)
|
|
25
|
-
);
|
|
18
|
+
IExecutorHelper.StableSwap memory stableSwap = abi.decode(data, (IExecutorHelper.StableSwap));
|
|
26
19
|
stableSwap.dx = (stableSwap.dx * newAmount) / oldAmount;
|
|
27
20
|
return abi.encode(stableSwap);
|
|
28
21
|
}
|
|
@@ -37,11 +30,7 @@ library ScalingDataLib {
|
|
|
37
30
|
return abi.encode(curveSwap);
|
|
38
31
|
}
|
|
39
32
|
|
|
40
|
-
function newKyberDMM(
|
|
41
|
-
bytes memory data,
|
|
42
|
-
uint256 oldAmount,
|
|
43
|
-
uint256 newAmount
|
|
44
|
-
) internal pure returns (bytes memory) {
|
|
33
|
+
function newKyberDMM(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
45
34
|
IExecutorHelper.UniSwap memory kyberDMMSwap = abi.decode(data, (IExecutorHelper.UniSwap));
|
|
46
35
|
kyberDMMSwap.collectAmount = (kyberDMMSwap.collectAmount * newAmount) / oldAmount;
|
|
47
36
|
return abi.encode(kyberDMMSwap);
|
|
@@ -66,19 +55,12 @@ library ScalingDataLib {
|
|
|
66
55
|
uint256 oldAmount,
|
|
67
56
|
uint256 newAmount
|
|
68
57
|
) internal pure returns (bytes memory) {
|
|
69
|
-
IExecutorHelper.BalancerV2 memory balancerV2 = abi.decode(
|
|
70
|
-
data,
|
|
71
|
-
(IExecutorHelper.BalancerV2)
|
|
72
|
-
);
|
|
58
|
+
IExecutorHelper.BalancerV2 memory balancerV2 = abi.decode(data, (IExecutorHelper.BalancerV2));
|
|
73
59
|
balancerV2.amount = (balancerV2.amount * newAmount) / oldAmount;
|
|
74
60
|
return abi.encode(balancerV2);
|
|
75
61
|
}
|
|
76
62
|
|
|
77
|
-
function newDODO(
|
|
78
|
-
bytes memory data,
|
|
79
|
-
uint256 oldAmount,
|
|
80
|
-
uint256 newAmount
|
|
81
|
-
) internal pure returns (bytes memory) {
|
|
63
|
+
function newDODO(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
82
64
|
IExecutorHelper.DODO memory dodo = abi.decode(data, (IExecutorHelper.DODO));
|
|
83
65
|
dodo.amount = (dodo.amount * newAmount) / oldAmount;
|
|
84
66
|
return abi.encode(dodo);
|
|
@@ -94,11 +76,7 @@ library ScalingDataLib {
|
|
|
94
76
|
return abi.encode(velodrome);
|
|
95
77
|
}
|
|
96
78
|
|
|
97
|
-
function newGMX(
|
|
98
|
-
bytes memory data,
|
|
99
|
-
uint256 oldAmount,
|
|
100
|
-
uint256 newAmount
|
|
101
|
-
) internal pure returns (bytes memory) {
|
|
79
|
+
function newGMX(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
102
80
|
IExecutorHelper.GMX memory gmx = abi.decode(data, (IExecutorHelper.GMX));
|
|
103
81
|
gmx.amount = (gmx.amount * newAmount) / oldAmount;
|
|
104
82
|
return abi.encode(gmx);
|
|
@@ -114,21 +92,13 @@ library ScalingDataLib {
|
|
|
114
92
|
return abi.encode(synthetix);
|
|
115
93
|
}
|
|
116
94
|
|
|
117
|
-
function newCamelot(
|
|
118
|
-
bytes memory data,
|
|
119
|
-
uint256 oldAmount,
|
|
120
|
-
uint256 newAmount
|
|
121
|
-
) internal pure returns (bytes memory) {
|
|
95
|
+
function newCamelot(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
122
96
|
IExecutorHelper.UniSwap memory camelot = abi.decode(data, (IExecutorHelper.UniSwap));
|
|
123
97
|
camelot.collectAmount = (camelot.collectAmount * newAmount) / oldAmount;
|
|
124
98
|
return abi.encode(camelot);
|
|
125
99
|
}
|
|
126
100
|
|
|
127
|
-
function newPlatypus(
|
|
128
|
-
bytes memory data,
|
|
129
|
-
uint256 oldAmount,
|
|
130
|
-
uint256 newAmount
|
|
131
|
-
) internal pure returns (bytes memory) {
|
|
101
|
+
function newPlatypus(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
132
102
|
IExecutorHelper.Platypus memory platypus = abi.decode(data, (IExecutorHelper.Platypus));
|
|
133
103
|
platypus.collectAmount = (platypus.collectAmount * newAmount) / oldAmount;
|
|
134
104
|
return abi.encode(platypus);
|
|
@@ -144,21 +114,13 @@ library ScalingDataLib {
|
|
|
144
114
|
return abi.encode(wstEthData);
|
|
145
115
|
}
|
|
146
116
|
|
|
147
|
-
function newPSM(
|
|
148
|
-
bytes memory data,
|
|
149
|
-
uint256 oldAmount,
|
|
150
|
-
uint256 newAmount
|
|
151
|
-
) internal pure returns (bytes memory) {
|
|
117
|
+
function newPSM(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
152
118
|
IExecutorHelper.PSM memory psm = abi.decode(data, (IExecutorHelper.PSM));
|
|
153
119
|
psm.amountIn = (psm.amountIn * newAmount) / oldAmount;
|
|
154
120
|
return abi.encode(psm);
|
|
155
121
|
}
|
|
156
122
|
|
|
157
|
-
function newFrax(
|
|
158
|
-
bytes memory data,
|
|
159
|
-
uint256 oldAmount,
|
|
160
|
-
uint256 newAmount
|
|
161
|
-
) internal pure returns (bytes memory) {
|
|
123
|
+
function newFrax(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
162
124
|
IExecutorHelper.UniSwap memory frax = abi.decode(data, (IExecutorHelper.UniSwap));
|
|
163
125
|
frax.collectAmount = (frax.collectAmount * newAmount) / oldAmount;
|
|
164
126
|
return abi.encode(frax);
|
|
@@ -174,13 +136,109 @@ library ScalingDataLib {
|
|
|
174
136
|
return abi.encode(amount);
|
|
175
137
|
}
|
|
176
138
|
|
|
177
|
-
function newMaverick(
|
|
139
|
+
function newMaverick(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
140
|
+
IExecutorHelper.Maverick memory maverick = abi.decode(data, (IExecutorHelper.Maverick));
|
|
141
|
+
maverick.swapAmount = (maverick.swapAmount * newAmount) / oldAmount;
|
|
142
|
+
return abi.encode(maverick);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function newSyncSwap(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
146
|
+
IExecutorHelper.SyncSwap memory syncSwap = abi.decode(data, (IExecutorHelper.SyncSwap));
|
|
147
|
+
syncSwap.collectAmount = (syncSwap.collectAmount * newAmount) / oldAmount;
|
|
148
|
+
return abi.encode(syncSwap);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function newAlgebraV1(
|
|
178
152
|
bytes memory data,
|
|
179
153
|
uint256 oldAmount,
|
|
180
154
|
uint256 newAmount
|
|
181
155
|
) internal pure returns (bytes memory) {
|
|
182
|
-
IExecutorHelper.
|
|
183
|
-
|
|
184
|
-
return abi.encode(
|
|
156
|
+
IExecutorHelper.AlgebraV1 memory algebraV1Swap = abi.decode(data, (IExecutorHelper.AlgebraV1));
|
|
157
|
+
algebraV1Swap.swapAmount = (algebraV1Swap.swapAmount * newAmount) / oldAmount;
|
|
158
|
+
return abi.encode(algebraV1Swap);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function newBalancerBatch(
|
|
162
|
+
bytes memory data,
|
|
163
|
+
uint256 oldAmount,
|
|
164
|
+
uint256 newAmount
|
|
165
|
+
) internal pure returns (bytes memory) {
|
|
166
|
+
IExecutorHelper.BalancerBatch memory balancerBatch = abi.decode(data, (IExecutorHelper.BalancerBatch));
|
|
167
|
+
balancerBatch.amountIn = (balancerBatch.amountIn * newAmount) / oldAmount;
|
|
168
|
+
return abi.encode(balancerBatch);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function newMantis(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
172
|
+
IExecutorHelper.Mantis memory mantis = abi.decode(data, (IExecutorHelper.Mantis));
|
|
173
|
+
mantis.amount = (mantis.amount * newAmount) / oldAmount;
|
|
174
|
+
return abi.encode(mantis);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function newIziSwap(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
178
|
+
IExecutorHelper.IziSwap memory iZi = abi.decode(data, (IExecutorHelper.IziSwap));
|
|
179
|
+
iZi.swapAmount = (iZi.swapAmount * newAmount) / oldAmount;
|
|
180
|
+
return abi.encode(iZi);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function newTraderJoeV2(
|
|
184
|
+
bytes memory data,
|
|
185
|
+
uint256 oldAmount,
|
|
186
|
+
uint256 newAmount
|
|
187
|
+
) internal pure returns (bytes memory) {
|
|
188
|
+
IExecutorHelper.TraderJoeV2 memory traderJoe = abi.decode(data, (IExecutorHelper.TraderJoeV2));
|
|
189
|
+
|
|
190
|
+
// traderJoe.collectAmount; // most significant 1 bit is to determine whether pool is v2.1, else v2.0
|
|
191
|
+
traderJoe.collectAmount =
|
|
192
|
+
(traderJoe.collectAmount & (1 << 255)) |
|
|
193
|
+
((uint256((traderJoe.collectAmount << 1) >> 1) * newAmount) / oldAmount);
|
|
194
|
+
return abi.encode(traderJoe);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function newLevelFiV2(
|
|
198
|
+
bytes memory data,
|
|
199
|
+
uint256 oldAmount,
|
|
200
|
+
uint256 newAmount
|
|
201
|
+
) internal pure returns (bytes memory) {
|
|
202
|
+
IExecutorHelper.LevelFiV2 memory levelFiV2 = abi.decode(data, (IExecutorHelper.LevelFiV2));
|
|
203
|
+
levelFiV2.amountIn = (levelFiV2.amountIn * newAmount) / oldAmount;
|
|
204
|
+
return abi.encode(levelFiV2);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function newGMXGLP(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
208
|
+
IExecutorHelper.GMXGLP memory swapData = abi.decode(data, (IExecutorHelper.GMXGLP));
|
|
209
|
+
swapData.swapAmount = (swapData.swapAmount * newAmount) / oldAmount;
|
|
210
|
+
return abi.encode(swapData);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function newVooi(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
214
|
+
IExecutorHelper.Vooi memory vooi = abi.decode(data, (IExecutorHelper.Vooi));
|
|
215
|
+
vooi.fromAmount = (vooi.fromAmount * newAmount) / oldAmount;
|
|
216
|
+
return abi.encode(vooi);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function newVelocoreV2(
|
|
220
|
+
bytes memory data,
|
|
221
|
+
uint256 oldAmount,
|
|
222
|
+
uint256 newAmount
|
|
223
|
+
) internal pure returns (bytes memory) {
|
|
224
|
+
IExecutorHelper.VelocoreV2 memory velocorev2 = abi.decode(data, (IExecutorHelper.VelocoreV2));
|
|
225
|
+
velocorev2.amount = (velocorev2.amount * newAmount) / oldAmount;
|
|
226
|
+
return abi.encode(velocorev2);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function newMaticMigrate(
|
|
230
|
+
bytes memory data,
|
|
231
|
+
uint256 oldAmount,
|
|
232
|
+
uint256 newAmount
|
|
233
|
+
) internal pure returns (bytes memory) {
|
|
234
|
+
IExecutorHelper.MaticMigrate memory maticMigrate = abi.decode(data, (IExecutorHelper.MaticMigrate));
|
|
235
|
+
maticMigrate.amount = (maticMigrate.amount * newAmount) / oldAmount;
|
|
236
|
+
return abi.encode(maticMigrate);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function newKokonut(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
240
|
+
IExecutorHelper.Kokonut memory kokonut = abi.decode(data, (IExecutorHelper.Kokonut));
|
|
241
|
+
kokonut.dx = (kokonut.dx * newAmount) / oldAmount;
|
|
242
|
+
return abi.encode(kokonut);
|
|
185
243
|
}
|
|
186
244
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
library BytesHelper {
|
|
5
|
+
function write16Bytes(bytes memory original, uint256 index, bytes16 value) internal pure returns (bytes memory) {
|
|
6
|
+
assembly {
|
|
7
|
+
let offset := add(original, add(index, 32))
|
|
8
|
+
let val := mload(offset) // read 32 bytes [index : index + 32]
|
|
9
|
+
val := and(val, not(0xffffffffffffffffffffffffffffffff00000000000000000000000000000000)) // clear [index : index + 16]
|
|
10
|
+
val := or(val, value) // set 16 bytes to val above
|
|
11
|
+
mstore(offset, val) // store to [index : index + 32]
|
|
12
|
+
}
|
|
13
|
+
return original;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function write16Bytes(bytes memory original, uint256 index, uint128 value) internal pure returns (bytes memory) {
|
|
17
|
+
return write16Bytes(original, index, bytes16(value));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function write16Bytes(
|
|
21
|
+
bytes memory original,
|
|
22
|
+
uint256 index,
|
|
23
|
+
uint256 value,
|
|
24
|
+
string memory errorMsg
|
|
25
|
+
) internal pure returns (bytes memory) {
|
|
26
|
+
require(value <= type(uint128).max, string(abi.encodePacked(errorMsg, "/Exceed compressed type range")));
|
|
27
|
+
return write16Bytes(original, index, uint128(value));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
library CalldataReader {
|
|
5
|
+
/// @notice read the bytes value of data from a starting position and length
|
|
6
|
+
/// @param data bytes array of data
|
|
7
|
+
/// @param startByte starting position to read
|
|
8
|
+
/// @param length length from starting position
|
|
9
|
+
/// @return retVal value of the bytes
|
|
10
|
+
/// @return (the next position to read from)
|
|
11
|
+
function _calldataVal(
|
|
12
|
+
bytes memory data,
|
|
13
|
+
uint256 startByte,
|
|
14
|
+
uint256 length
|
|
15
|
+
) internal pure returns (bytes memory retVal, uint256) {
|
|
16
|
+
require(length + startByte <= data.length, "calldataVal trying to read beyond data size");
|
|
17
|
+
uint256 loops = (length + 31) / 32;
|
|
18
|
+
assembly {
|
|
19
|
+
let m := mload(0x40)
|
|
20
|
+
mstore(m, length)
|
|
21
|
+
for {
|
|
22
|
+
let i := 0
|
|
23
|
+
} lt(i, loops) {
|
|
24
|
+
i := add(1, i)
|
|
25
|
+
} {
|
|
26
|
+
mstore(add(m, mul(32, add(1, i))), mload(add(data, add(mul(32, add(1, i)), startByte))))
|
|
27
|
+
}
|
|
28
|
+
mstore(0x40, add(m, add(32, length)))
|
|
29
|
+
retVal := m
|
|
30
|
+
}
|
|
31
|
+
return (retVal, length + startByte);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _readBool(bytes memory data, uint256 startByte) internal pure returns (bool, uint256) {
|
|
35
|
+
bytes memory ret;
|
|
36
|
+
(ret, startByte) = _calldataVal(data, startByte, 1);
|
|
37
|
+
return (bytes1(ret) > 0, startByte);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _readUint8(bytes memory data, uint256 startByte) internal pure returns (uint8, uint256) {
|
|
41
|
+
bytes memory ret;
|
|
42
|
+
(ret, startByte) = _calldataVal(data, startByte, 1);
|
|
43
|
+
return (uint8(bytes1(ret)), startByte);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function _readUint24(bytes memory data, uint256 startByte) internal pure returns (uint24, uint256) {
|
|
47
|
+
bytes memory ret;
|
|
48
|
+
(ret, startByte) = _calldataVal(data, startByte, 3);
|
|
49
|
+
return (uint24(bytes3(ret)), startByte);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _readUint32(bytes memory data, uint256 startByte) internal pure returns (uint32, uint256) {
|
|
53
|
+
bytes memory ret;
|
|
54
|
+
(ret, startByte) = _calldataVal(data, startByte, 4);
|
|
55
|
+
return (uint32(bytes4(ret)), startByte);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _readUint160(bytes memory data, uint256 startByte) internal pure returns (uint160, uint256) {
|
|
59
|
+
bytes memory ret;
|
|
60
|
+
(ret, startByte) = _calldataVal(data, startByte, 20);
|
|
61
|
+
return (uint160(bytes20(ret)), startByte);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// @dev only when sure that the value of uint256 never exceed uint128
|
|
65
|
+
function _readUint128AsUint256(bytes memory data, uint256 startByte) internal pure returns (uint256, uint256) {
|
|
66
|
+
bytes memory ret;
|
|
67
|
+
(ret, startByte) = _calldataVal(data, startByte, 16);
|
|
68
|
+
return (uint256(uint128(bytes16(ret))), startByte);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _readAddress(bytes memory data, uint256 startByte) internal pure returns (address, uint256) {
|
|
72
|
+
bytes memory ret;
|
|
73
|
+
(ret, startByte) = _calldataVal(data, startByte, 20);
|
|
74
|
+
return (address(bytes20(ret)), startByte);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _readBytes1(bytes memory data, uint256 startByte) internal pure returns (bytes1, uint256) {
|
|
78
|
+
bytes memory ret;
|
|
79
|
+
(ret, startByte) = _calldataVal(data, startByte, 1);
|
|
80
|
+
return (bytes1(ret), startByte);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _readBytes4(bytes memory data, uint256 startByte) internal pure returns (bytes4, uint256) {
|
|
84
|
+
bytes memory ret;
|
|
85
|
+
(ret, startByte) = _calldataVal(data, startByte, 4);
|
|
86
|
+
return (bytes4(ret), startByte);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function _readBytes32(bytes memory data, uint256 startByte) internal pure returns (bytes32, uint256) {
|
|
90
|
+
bytes memory ret;
|
|
91
|
+
(ret, startByte) = _calldataVal(data, startByte, 32);
|
|
92
|
+
return (bytes32(ret), startByte);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// @dev length of bytes is currently limited to uint32
|
|
96
|
+
function _readBytes(bytes memory data, uint256 startByte) internal pure returns (bytes memory b, uint256) {
|
|
97
|
+
bytes memory ret;
|
|
98
|
+
(ret, startByte) = _calldataVal(data, startByte, 4);
|
|
99
|
+
uint256 length = uint256(uint32(bytes4(ret)));
|
|
100
|
+
(b, startByte) = _calldataVal(data, startByte, length);
|
|
101
|
+
return (b, startByte);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// @dev length of bytes array is currently limited to uint8
|
|
105
|
+
function _readBytesArray(
|
|
106
|
+
bytes memory data,
|
|
107
|
+
uint256 startByte
|
|
108
|
+
) internal pure returns (bytes[] memory bytesArray, uint256) {
|
|
109
|
+
bytes memory ret;
|
|
110
|
+
(ret, startByte) = _calldataVal(data, startByte, 1);
|
|
111
|
+
uint256 length = uint256(uint8(bytes1(ret)));
|
|
112
|
+
bytesArray = new bytes[](length);
|
|
113
|
+
for (uint8 i = 0; i < length; ++i) {
|
|
114
|
+
(bytesArray[i], startByte) = _readBytes(data, startByte);
|
|
115
|
+
}
|
|
116
|
+
return (bytesArray, startByte);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// @dev length of address array is currently limited to uint8 to save bytes
|
|
120
|
+
function _readAddressArray(
|
|
121
|
+
bytes memory data,
|
|
122
|
+
uint256 startByte
|
|
123
|
+
) internal pure returns (address[] memory addrs, uint256) {
|
|
124
|
+
bytes memory ret;
|
|
125
|
+
(ret, startByte) = _calldataVal(data, startByte, 1);
|
|
126
|
+
uint256 length = uint256(uint8(bytes1(ret)));
|
|
127
|
+
addrs = new address[](length);
|
|
128
|
+
for (uint8 i = 0; i < length; ++i) {
|
|
129
|
+
(addrs[i], startByte) = _readAddress(data, startByte);
|
|
130
|
+
}
|
|
131
|
+
return (addrs, startByte);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// @dev length of uint array is currently limited to uint8 to save bytes
|
|
135
|
+
/// @dev same as _readUint128AsUint256, only use when sure that value never exceed uint128
|
|
136
|
+
function _readUint128ArrayAsUint256Array(
|
|
137
|
+
bytes memory data,
|
|
138
|
+
uint256 startByte
|
|
139
|
+
) internal pure returns (uint256[] memory, uint256) {
|
|
140
|
+
bytes memory ret;
|
|
141
|
+
(ret, startByte) = _calldataVal(data, startByte, 1);
|
|
142
|
+
uint256 length = uint256(uint8(bytes1(ret)));
|
|
143
|
+
uint256[] memory us = new uint256[](length);
|
|
144
|
+
for (uint8 i = 0; i < length; ++i) {
|
|
145
|
+
(us[i], startByte) = _readUint128AsUint256(data, startByte);
|
|
146
|
+
}
|
|
147
|
+
return (us, startByte);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {IMetaAggregationRouterV2} from "../interfaces/IMetaAggregationRouterV2.sol";
|
|
5
|
+
import {IAggregationExecutorOptimistic as IExecutorHelperL2} from "../interfaces/IAggregationExecutorOptimistic.sol";
|
|
6
|
+
import {IExecutorHelper as IExecutorHelperL1} from "../interfaces/IExecutorHelper.sol";
|
|
7
|
+
|
|
8
|
+
library CalldataWriter {
|
|
9
|
+
function writeSimpleSwapData(
|
|
10
|
+
IMetaAggregationRouterV2.SimpleSwapData memory simpleSwapData
|
|
11
|
+
) internal pure returns (bytes memory shortData) {
|
|
12
|
+
shortData = bytes.concat(shortData, _writeAddressArray(simpleSwapData.firstPools));
|
|
13
|
+
shortData = bytes.concat(shortData, _writeUint256ArrayAsUint128Array(simpleSwapData.firstSwapAmounts));
|
|
14
|
+
shortData = bytes.concat(shortData, _writeBytesArray(simpleSwapData.swapDatas));
|
|
15
|
+
shortData = bytes.concat(shortData, bytes16(uint128(simpleSwapData.deadline)));
|
|
16
|
+
shortData = bytes.concat(shortData, _writeBytes(simpleSwapData.positiveSlippageData));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
************************ AggregationExecutor ************************
|
|
21
|
+
*/
|
|
22
|
+
function writeSwapExecutorDescription(
|
|
23
|
+
IExecutorHelperL2.SwapExecutorDescription memory desc
|
|
24
|
+
) internal pure returns (bytes memory shortData) {
|
|
25
|
+
// write Swap array
|
|
26
|
+
uint8 lX = uint8(desc.swapSequences.length);
|
|
27
|
+
shortData = bytes.concat(shortData, bytes1(lX));
|
|
28
|
+
for (uint8 i = 0; i < lX; ++i) {
|
|
29
|
+
uint8 lY = uint8(desc.swapSequences[i].length);
|
|
30
|
+
shortData = bytes.concat(shortData, bytes1(lY));
|
|
31
|
+
for (uint8 j = 0; j < lY; ++j) {
|
|
32
|
+
shortData = bytes.concat(shortData, _writeSwap(desc.swapSequences[i][j]));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// basic members
|
|
37
|
+
shortData = bytes.concat(shortData, bytes20(desc.tokenIn));
|
|
38
|
+
shortData = bytes.concat(shortData, bytes20(desc.tokenOut));
|
|
39
|
+
shortData = bytes.concat(shortData, bytes20(desc.to));
|
|
40
|
+
shortData = bytes.concat(shortData, bytes16(uint128(desc.deadline)));
|
|
41
|
+
shortData = bytes.concat(shortData, _writeBytes(desc.positiveSlippageData));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function writeSimpleModeSwapDatas(
|
|
45
|
+
bytes[] memory swapDatas,
|
|
46
|
+
address tokenIn
|
|
47
|
+
) internal pure returns (bytes[] memory shortData) {
|
|
48
|
+
uint8 len = uint8(swapDatas.length);
|
|
49
|
+
for (uint8 i = 0; i < len; ++i) {
|
|
50
|
+
swapDatas[i] = _writeSwapSingleSequence(swapDatas[i], tokenIn);
|
|
51
|
+
}
|
|
52
|
+
return (swapDatas);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _writeSwapSingleSequence(
|
|
56
|
+
bytes memory data,
|
|
57
|
+
address tokenIn
|
|
58
|
+
) internal pure returns (bytes memory shortData) {
|
|
59
|
+
IExecutorHelperL2.Swap[] memory swaps = abi.decode(data, (IExecutorHelperL2.Swap[]));
|
|
60
|
+
|
|
61
|
+
uint8 len = uint8(swaps.length);
|
|
62
|
+
shortData = bytes.concat(shortData, bytes1(len));
|
|
63
|
+
for (uint8 i = 0; i < len; ++i) {
|
|
64
|
+
shortData = bytes.concat(shortData, _writeSwap(swaps[i]));
|
|
65
|
+
}
|
|
66
|
+
shortData = bytes.concat(shortData, bytes20(tokenIn));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function _writeAddressArray(address[] memory addrs) internal pure returns (bytes memory data) {
|
|
70
|
+
uint8 length = uint8(addrs.length);
|
|
71
|
+
data = bytes.concat(data, bytes1(length));
|
|
72
|
+
for (uint8 i = 0; i < length; ++i) {
|
|
73
|
+
data = bytes.concat(data, bytes20(addrs[i]));
|
|
74
|
+
}
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function _writeUint256ArrayAsUint128Array(uint256[] memory us) internal pure returns (bytes memory data) {
|
|
79
|
+
uint8 length = uint8(us.length);
|
|
80
|
+
data = bytes.concat(data, bytes1(length));
|
|
81
|
+
for (uint8 i = 0; i < length; ++i) {
|
|
82
|
+
data = bytes.concat(data, bytes16(uint128(us[i])));
|
|
83
|
+
}
|
|
84
|
+
return data;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _writeBytes(bytes memory b) internal pure returns (bytes memory data) {
|
|
88
|
+
uint32 length = uint32(b.length);
|
|
89
|
+
data = bytes.concat(data, bytes4(length));
|
|
90
|
+
data = bytes.concat(data, b);
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _writeBytesArray(bytes[] memory bytesArray) internal pure returns (bytes memory data) {
|
|
95
|
+
uint8 x = uint8(bytesArray.length);
|
|
96
|
+
data = bytes.concat(data, bytes1(x));
|
|
97
|
+
for (uint8 i; i < x; ++i) {
|
|
98
|
+
uint32 length = uint32(bytesArray[i].length);
|
|
99
|
+
data = bytes.concat(data, bytes4(length));
|
|
100
|
+
data = bytes.concat(data, bytesArray[i]);
|
|
101
|
+
}
|
|
102
|
+
return data;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function _writeBytes32Array(bytes32[] memory bytesArray) internal pure returns (bytes memory data) {
|
|
106
|
+
uint8 x = uint8(bytesArray.length);
|
|
107
|
+
data = bytes.concat(data, bytes1(x));
|
|
108
|
+
for (uint8 i; i < x; ++i) {
|
|
109
|
+
data = bytes.concat(data, bytesArray[i]);
|
|
110
|
+
}
|
|
111
|
+
return data;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _writeSwap(IExecutorHelperL2.Swap memory swap) internal pure returns (bytes memory shortData) {
|
|
115
|
+
shortData = bytes.concat(shortData, _writeBytes(swap.data));
|
|
116
|
+
shortData = bytes.concat(shortData, bytes1(uint8(uint32(swap.functionSelector))));
|
|
117
|
+
}
|
|
118
|
+
}
|