@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
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
+
import {IAggregationExecutorOptimistic as IExecutorHelperL2} from "../interfaces/IAggregationExecutorOptimistic.sol";
|
|
6
|
+
import {IExecutorHelper as IExecutorHelperL1} from "../interfaces/IExecutorHelper.sol";
|
|
7
|
+
import {IMetaAggregationRouterV2} from "../interfaces/IMetaAggregationRouterV2.sol";
|
|
8
|
+
import {ScalingDataL2Lib} from "./ScalingDataL2Lib.sol";
|
|
9
|
+
import {ExecutorReader} from "./ExecutorReader.sol";
|
|
10
|
+
import {CalldataWriter} from "./CalldataWriter.sol";
|
|
11
|
+
|
|
12
|
+
library InputScalingHelperL2 {
|
|
13
|
+
using ExecutorReader for bytes;
|
|
14
|
+
using ScalingDataL2Lib for bytes;
|
|
15
|
+
|
|
16
|
+
uint256 private constant _PARTIAL_FILL = 0x01;
|
|
17
|
+
uint256 private constant _REQUIRES_EXTRA_ETH = 0x02;
|
|
18
|
+
uint256 private constant _SHOULD_CLAIM = 0x04;
|
|
19
|
+
uint256 private constant _BURN_FROM_MSG_SENDER = 0x08;
|
|
20
|
+
uint256 private constant _BURN_FROM_TX_ORIGIN = 0x10;
|
|
21
|
+
uint256 private constant _SIMPLE_SWAP = 0x20;
|
|
22
|
+
|
|
23
|
+
struct PositiveSlippageFeeData {
|
|
24
|
+
uint256 partnerPSInfor;
|
|
25
|
+
uint256 expectedReturnAmount;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
enum DexIndex {
|
|
29
|
+
UNI,
|
|
30
|
+
KyberDMM,
|
|
31
|
+
Velodrome,
|
|
32
|
+
Fraxswap,
|
|
33
|
+
Camelot,
|
|
34
|
+
KyberLO,
|
|
35
|
+
RFQ,
|
|
36
|
+
Hashflow,
|
|
37
|
+
StableSwap,
|
|
38
|
+
Curve,
|
|
39
|
+
UniswapV3KSElastic,
|
|
40
|
+
BalancerV2,
|
|
41
|
+
DODO,
|
|
42
|
+
GMX,
|
|
43
|
+
Synthetix,
|
|
44
|
+
wstETH,
|
|
45
|
+
stETH,
|
|
46
|
+
Platypus,
|
|
47
|
+
PSM,
|
|
48
|
+
Maverick,
|
|
49
|
+
SyncSwap,
|
|
50
|
+
AlgebraV1,
|
|
51
|
+
BalancerBatch,
|
|
52
|
+
Mantis,
|
|
53
|
+
Wombat,
|
|
54
|
+
iZiSwap,
|
|
55
|
+
TraderJoeV2,
|
|
56
|
+
WooFiV2,
|
|
57
|
+
KyberDSLO,
|
|
58
|
+
LevelFiV2,
|
|
59
|
+
GMXGLP,
|
|
60
|
+
PancakeStableSwap,
|
|
61
|
+
Vooi,
|
|
62
|
+
VelocoreV2,
|
|
63
|
+
Smardex,
|
|
64
|
+
SolidlyV2,
|
|
65
|
+
Kokonut
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function _getScaledInputData(bytes calldata inputData, uint256 newAmount) internal pure returns (bytes memory) {
|
|
69
|
+
bytes4 selector = bytes4(inputData[:4]);
|
|
70
|
+
bytes calldata dataToDecode = inputData[4:];
|
|
71
|
+
|
|
72
|
+
if (selector == IMetaAggregationRouterV2.swap.selector) {
|
|
73
|
+
IMetaAggregationRouterV2.SwapExecutionParams memory params = abi.decode(
|
|
74
|
+
dataToDecode,
|
|
75
|
+
(IMetaAggregationRouterV2.SwapExecutionParams)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
(params.desc, params.targetData) = _getScaledInputDataV2(
|
|
79
|
+
params.desc,
|
|
80
|
+
params.targetData,
|
|
81
|
+
newAmount,
|
|
82
|
+
_flagsChecked(params.desc.flags, _SIMPLE_SWAP)
|
|
83
|
+
);
|
|
84
|
+
return abi.encodeWithSelector(selector, params);
|
|
85
|
+
} else if (selector == IMetaAggregationRouterV2.swapSimpleMode.selector) {
|
|
86
|
+
(
|
|
87
|
+
address callTarget,
|
|
88
|
+
IMetaAggregationRouterV2.SwapDescriptionV2 memory desc,
|
|
89
|
+
bytes memory targetData,
|
|
90
|
+
bytes memory clientData
|
|
91
|
+
) = abi.decode(dataToDecode, (address, IMetaAggregationRouterV2.SwapDescriptionV2, bytes, bytes));
|
|
92
|
+
|
|
93
|
+
(desc, targetData) = _getScaledInputDataV2(desc, targetData, newAmount, true);
|
|
94
|
+
return abi.encodeWithSelector(selector, callTarget, desc, targetData, clientData);
|
|
95
|
+
} else {
|
|
96
|
+
revert("InputScalingHelper: Invalid selector");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _getScaledInputDataV2(
|
|
101
|
+
IMetaAggregationRouterV2.SwapDescriptionV2 memory desc,
|
|
102
|
+
bytes memory executorData,
|
|
103
|
+
uint256 newAmount,
|
|
104
|
+
bool isSimpleMode
|
|
105
|
+
) internal pure returns (IMetaAggregationRouterV2.SwapDescriptionV2 memory, bytes memory) {
|
|
106
|
+
uint256 oldAmount = desc.amount;
|
|
107
|
+
if (oldAmount == newAmount) {
|
|
108
|
+
return (desc, executorData);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// simple mode swap
|
|
112
|
+
if (isSimpleMode) {
|
|
113
|
+
return (
|
|
114
|
+
_scaledSwapDescriptionV2(desc, oldAmount, newAmount),
|
|
115
|
+
_scaledSimpleSwapData(executorData, oldAmount, newAmount)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//normal mode swap
|
|
120
|
+
return (
|
|
121
|
+
_scaledSwapDescriptionV2(desc, oldAmount, newAmount),
|
|
122
|
+
_scaledExecutorCallBytesData(executorData, oldAmount, newAmount)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/// @dev Scale the swap description
|
|
127
|
+
function _scaledSwapDescriptionV2(
|
|
128
|
+
IMetaAggregationRouterV2.SwapDescriptionV2 memory desc,
|
|
129
|
+
uint256 oldAmount,
|
|
130
|
+
uint256 newAmount
|
|
131
|
+
) internal pure returns (IMetaAggregationRouterV2.SwapDescriptionV2 memory) {
|
|
132
|
+
desc.minReturnAmount = (desc.minReturnAmount * newAmount) / oldAmount;
|
|
133
|
+
if (desc.minReturnAmount == 0) desc.minReturnAmount = 1;
|
|
134
|
+
desc.amount = (desc.amount * newAmount) / oldAmount;
|
|
135
|
+
|
|
136
|
+
uint256 nReceivers = desc.srcReceivers.length;
|
|
137
|
+
for (uint256 i = 0; i < nReceivers; ) {
|
|
138
|
+
desc.srcAmounts[i] = (desc.srcAmounts[i] * newAmount) / oldAmount;
|
|
139
|
+
unchecked {
|
|
140
|
+
++i;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return desc;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/// @dev Scale the executorData in case swapSimpleMode
|
|
147
|
+
function _scaledSimpleSwapData(
|
|
148
|
+
bytes memory data,
|
|
149
|
+
uint256 oldAmount,
|
|
150
|
+
uint256 newAmount
|
|
151
|
+
) internal pure returns (bytes memory) {
|
|
152
|
+
IMetaAggregationRouterV2.SimpleSwapData memory simpleSwapData = abi.decode(
|
|
153
|
+
data,
|
|
154
|
+
(IMetaAggregationRouterV2.SimpleSwapData)
|
|
155
|
+
);
|
|
156
|
+
uint256 nPools = simpleSwapData.firstPools.length;
|
|
157
|
+
address tokenIn;
|
|
158
|
+
|
|
159
|
+
for (uint256 i = 0; i < nPools; ) {
|
|
160
|
+
simpleSwapData.firstSwapAmounts[i] = (simpleSwapData.firstSwapAmounts[i] * newAmount) / oldAmount;
|
|
161
|
+
|
|
162
|
+
IExecutorHelperL2.Swap[] memory dexData;
|
|
163
|
+
|
|
164
|
+
(dexData, tokenIn) = simpleSwapData.swapDatas[i].readSwapSingleSequence();
|
|
165
|
+
|
|
166
|
+
// only need to scale the first dex in each sequence
|
|
167
|
+
if (dexData.length > 0) {
|
|
168
|
+
dexData[0] = _scaleDexData(dexData[0], oldAmount, newAmount);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
simpleSwapData.swapDatas[i] = CalldataWriter._writeSwapSingleSequence(abi.encode(dexData), tokenIn);
|
|
172
|
+
|
|
173
|
+
unchecked {
|
|
174
|
+
++i;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
simpleSwapData.positiveSlippageData = _scaledPositiveSlippageFeeData(
|
|
179
|
+
simpleSwapData.positiveSlippageData,
|
|
180
|
+
oldAmount,
|
|
181
|
+
newAmount
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return abi.encode(simpleSwapData);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/// @dev Scale the executorData in case normal swap
|
|
188
|
+
function _scaledExecutorCallBytesData(
|
|
189
|
+
bytes memory data,
|
|
190
|
+
uint256 oldAmount,
|
|
191
|
+
uint256 newAmount
|
|
192
|
+
) internal pure returns (bytes memory) {
|
|
193
|
+
IExecutorHelperL2.SwapExecutorDescription memory executorDesc = abi.decode(
|
|
194
|
+
data.readSwapExecutorDescription(),
|
|
195
|
+
(IExecutorHelperL2.SwapExecutorDescription)
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
executorDesc.positiveSlippageData = _scaledPositiveSlippageFeeData(
|
|
199
|
+
executorDesc.positiveSlippageData,
|
|
200
|
+
oldAmount,
|
|
201
|
+
newAmount
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
uint256 nSequences = executorDesc.swapSequences.length;
|
|
205
|
+
for (uint256 i = 0; i < nSequences; ) {
|
|
206
|
+
// only need to scale the first dex in each sequence
|
|
207
|
+
IExecutorHelperL2.Swap memory swap = executorDesc.swapSequences[i][0];
|
|
208
|
+
executorDesc.swapSequences[i][0] = _scaleDexData(swap, oldAmount, newAmount);
|
|
209
|
+
unchecked {
|
|
210
|
+
++i;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return CalldataWriter.writeSwapExecutorDescription(executorDesc);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function _scaledPositiveSlippageFeeData(
|
|
217
|
+
bytes memory data,
|
|
218
|
+
uint256 oldAmount,
|
|
219
|
+
uint256 newAmount
|
|
220
|
+
) internal pure returns (bytes memory newData) {
|
|
221
|
+
if (data.length > 32) {
|
|
222
|
+
PositiveSlippageFeeData memory psData = abi.decode(data, (PositiveSlippageFeeData));
|
|
223
|
+
uint256 left = uint256(psData.expectedReturnAmount >> 128);
|
|
224
|
+
uint256 right = (uint256(uint128(psData.expectedReturnAmount)) * newAmount) / oldAmount;
|
|
225
|
+
require(right <= type(uint128).max, "_scaledPositiveSlippageFeeData/Exceeded type range");
|
|
226
|
+
psData.expectedReturnAmount = right | (left << 128);
|
|
227
|
+
data = abi.encode(psData);
|
|
228
|
+
} else if (data.length == 32) {
|
|
229
|
+
uint256 expectedReturnAmount = abi.decode(data, (uint256));
|
|
230
|
+
uint256 left = uint256(expectedReturnAmount >> 128);
|
|
231
|
+
uint256 right = (uint256(uint128(expectedReturnAmount)) * newAmount) / oldAmount;
|
|
232
|
+
require(right <= type(uint128).max, "_scaledPositiveSlippageFeeData/Exceeded type range");
|
|
233
|
+
expectedReturnAmount = right | (left << 128);
|
|
234
|
+
data = abi.encode(expectedReturnAmount);
|
|
235
|
+
}
|
|
236
|
+
return data;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function _scaleDexData(
|
|
240
|
+
IExecutorHelperL2.Swap memory swap,
|
|
241
|
+
uint256 oldAmount,
|
|
242
|
+
uint256 newAmount
|
|
243
|
+
) internal pure returns (IExecutorHelperL2.Swap memory) {
|
|
244
|
+
uint8 functionSelectorIndex = uint8(uint32(swap.functionSelector));
|
|
245
|
+
|
|
246
|
+
if (DexIndex(functionSelectorIndex) == DexIndex.UNI) {
|
|
247
|
+
swap.data = swap.data.newUniSwap(oldAmount, newAmount);
|
|
248
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.StableSwap) {
|
|
249
|
+
swap.data = swap.data.newStableSwap(oldAmount, newAmount);
|
|
250
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Curve) {
|
|
251
|
+
swap.data = swap.data.newCurveSwap(oldAmount, newAmount);
|
|
252
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.KyberDMM) {
|
|
253
|
+
swap.data = swap.data.newKyberDMM(oldAmount, newAmount);
|
|
254
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.UniswapV3KSElastic) {
|
|
255
|
+
swap.data = swap.data.newUniswapV3KSElastic(oldAmount, newAmount);
|
|
256
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.RFQ) {
|
|
257
|
+
revert("InputScalingHelper: Can not scale RFQ swap");
|
|
258
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.BalancerV2) {
|
|
259
|
+
swap.data = swap.data.newBalancerV2(oldAmount, newAmount);
|
|
260
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.wstETH) {
|
|
261
|
+
swap.data = swap.data.newWrappedstETHSwap(oldAmount, newAmount);
|
|
262
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.stETH) {
|
|
263
|
+
swap.data = swap.data.newStETHSwap(oldAmount, newAmount);
|
|
264
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.DODO) {
|
|
265
|
+
swap.data = swap.data.newDODO(oldAmount, newAmount);
|
|
266
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Velodrome) {
|
|
267
|
+
swap.data = swap.data.newVelodrome(oldAmount, newAmount);
|
|
268
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.GMX) {
|
|
269
|
+
swap.data = swap.data.newGMX(oldAmount, newAmount);
|
|
270
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Synthetix) {
|
|
271
|
+
swap.data = swap.data.newSynthetix(oldAmount, newAmount);
|
|
272
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Hashflow) {
|
|
273
|
+
revert("InputScalingHelper: Can not scale Hashflow swap");
|
|
274
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Camelot) {
|
|
275
|
+
swap.data = swap.data.newCamelot(oldAmount, newAmount);
|
|
276
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.KyberLO) {
|
|
277
|
+
revert("InputScalingHelper: Can not scale KyberLO swap");
|
|
278
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.PSM) {
|
|
279
|
+
swap.data = swap.data.newPSM(oldAmount, newAmount);
|
|
280
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Fraxswap) {
|
|
281
|
+
swap.data = swap.data.newFrax(oldAmount, newAmount);
|
|
282
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Platypus) {
|
|
283
|
+
swap.data = swap.data.newPlatypus(oldAmount, newAmount);
|
|
284
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Maverick) {
|
|
285
|
+
swap.data = swap.data.newMaverick(oldAmount, newAmount);
|
|
286
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.SyncSwap) {
|
|
287
|
+
swap.data = swap.data.newSyncSwap(oldAmount, newAmount);
|
|
288
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.AlgebraV1) {
|
|
289
|
+
swap.data = swap.data.newAlgebraV1(oldAmount, newAmount);
|
|
290
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.BalancerBatch) {
|
|
291
|
+
swap.data = swap.data.newBalancerBatch(oldAmount, newAmount);
|
|
292
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Mantis) {
|
|
293
|
+
swap.data = swap.data.newMantis(oldAmount, newAmount);
|
|
294
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Wombat) {
|
|
295
|
+
swap.data = swap.data.newMantis(oldAmount, newAmount); // @dev use identical calldata structure as Mantis
|
|
296
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.iZiSwap) {
|
|
297
|
+
swap.data = swap.data.newIziSwap(oldAmount, newAmount);
|
|
298
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.TraderJoeV2) {
|
|
299
|
+
swap.data = swap.data.newTraderJoeV2(oldAmount, newAmount);
|
|
300
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.WooFiV2) {
|
|
301
|
+
swap.data = swap.data.newMantis(oldAmount, newAmount); // @dev use identical calldata structure as Mantis
|
|
302
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.KyberDSLO) {
|
|
303
|
+
revert("InputScalingHelper: Can not scale KyberDSLO swap");
|
|
304
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.LevelFiV2) {
|
|
305
|
+
swap.data = swap.data.newLevelFiV2(oldAmount, newAmount);
|
|
306
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.PancakeStableSwap) {
|
|
307
|
+
swap.data = swap.data.newCurveSwap(oldAmount, newAmount); // @dev same encoded data as Curve
|
|
308
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.GMXGLP) {
|
|
309
|
+
swap.data = swap.data.newGMXGLP(oldAmount, newAmount);
|
|
310
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Vooi) {
|
|
311
|
+
swap.data = swap.data.newVooi(oldAmount, newAmount);
|
|
312
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.VelocoreV2) {
|
|
313
|
+
swap.data = swap.data.newVelocoreV2(oldAmount, newAmount);
|
|
314
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Smardex) {
|
|
315
|
+
swap.data = swap.data.newMantis(oldAmount, newAmount); // @dev use identical calldata structure as Mantis
|
|
316
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.SolidlyV2) {
|
|
317
|
+
swap.data = swap.data.newMantis(oldAmount, newAmount); // @dev use identical calldata structure as Mantis
|
|
318
|
+
} else if (DexIndex(functionSelectorIndex) == DexIndex.Kokonut) {
|
|
319
|
+
swap.data = swap.data.newKokonut(oldAmount, newAmount);
|
|
320
|
+
} else {
|
|
321
|
+
revert("InputScaleHelper: Dex type not supported");
|
|
322
|
+
}
|
|
323
|
+
return swap;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function _flagsChecked(uint256 number, uint256 flag) internal pure returns (bool) {
|
|
327
|
+
return number & flag != 0;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {IExecutorHelper} from "../interfaces/IExecutorHelper.sol";
|
|
5
|
+
import {DexScaler} from "./DexScaler.sol";
|
|
6
|
+
|
|
7
|
+
library ScalingDataL2Lib {
|
|
8
|
+
using DexScaler for bytes;
|
|
9
|
+
|
|
10
|
+
function newUniSwap(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
11
|
+
return data.scaleUniSwap(oldAmount, newAmount);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function newStableSwap(
|
|
15
|
+
bytes memory data,
|
|
16
|
+
uint256 oldAmount,
|
|
17
|
+
uint256 newAmount
|
|
18
|
+
) internal pure returns (bytes memory) {
|
|
19
|
+
return data.scaleStableSwap(oldAmount, newAmount);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function newCurveSwap(
|
|
23
|
+
bytes memory data,
|
|
24
|
+
uint256 oldAmount,
|
|
25
|
+
uint256 newAmount
|
|
26
|
+
) internal pure returns (bytes memory) {
|
|
27
|
+
return data.scaleCurveSwap(oldAmount, newAmount);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function newKyberDMM(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
31
|
+
return data.scaleUniSwap(oldAmount, newAmount);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function newUniswapV3KSElastic(
|
|
35
|
+
bytes memory data,
|
|
36
|
+
uint256 oldAmount,
|
|
37
|
+
uint256 newAmount
|
|
38
|
+
) internal pure returns (bytes memory) {
|
|
39
|
+
return data.scaleUniswapV3KSElastic(oldAmount, newAmount);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function newBalancerV2(
|
|
43
|
+
bytes memory data,
|
|
44
|
+
uint256 oldAmount,
|
|
45
|
+
uint256 newAmount
|
|
46
|
+
) internal pure returns (bytes memory) {
|
|
47
|
+
return data.scaleBalancerV2(oldAmount, newAmount);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function newDODO(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
51
|
+
return data.scaleDODO(oldAmount, newAmount);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function newVelodrome(
|
|
55
|
+
bytes memory data,
|
|
56
|
+
uint256 oldAmount,
|
|
57
|
+
uint256 newAmount
|
|
58
|
+
) internal pure returns (bytes memory) {
|
|
59
|
+
return data.scaleUniSwap(oldAmount, newAmount);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function newGMX(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
63
|
+
return data.scaleGMX(oldAmount, newAmount);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function newSynthetix(
|
|
67
|
+
bytes memory data,
|
|
68
|
+
uint256 oldAmount,
|
|
69
|
+
uint256 newAmount
|
|
70
|
+
) internal pure returns (bytes memory) {
|
|
71
|
+
return data.scaleSynthetix(oldAmount, newAmount);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function newCamelot(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
75
|
+
return data.scaleUniSwap(oldAmount, newAmount);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function newPlatypus(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
79
|
+
return data.scalePlatypus(oldAmount, newAmount);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function newWrappedstETHSwap(
|
|
83
|
+
bytes memory data,
|
|
84
|
+
uint256 oldAmount,
|
|
85
|
+
uint256 newAmount
|
|
86
|
+
) internal pure returns (bytes memory) {
|
|
87
|
+
return data.scaleWrappedstETH(oldAmount, newAmount);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function newPSM(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
91
|
+
return data.scalePSM(oldAmount, newAmount);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function newFrax(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
95
|
+
return data.scaleUniSwap(oldAmount, newAmount);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function newStETHSwap(
|
|
99
|
+
bytes memory data,
|
|
100
|
+
uint256 oldAmount,
|
|
101
|
+
uint256 newAmount
|
|
102
|
+
) internal pure returns (bytes memory) {
|
|
103
|
+
return data.scaleStETH(oldAmount, newAmount);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function newMaverick(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
107
|
+
return data.scaleMaverick(oldAmount, newAmount);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function newSyncSwap(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
111
|
+
return data.scaleSyncSwap(oldAmount, newAmount);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function newAlgebraV1(
|
|
115
|
+
bytes memory data,
|
|
116
|
+
uint256 oldAmount,
|
|
117
|
+
uint256 newAmount
|
|
118
|
+
) internal pure returns (bytes memory) {
|
|
119
|
+
return data.scaleAlgebraV1(oldAmount, newAmount);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function newBalancerBatch(
|
|
123
|
+
bytes memory data,
|
|
124
|
+
uint256 oldAmount,
|
|
125
|
+
uint256 newAmount
|
|
126
|
+
) internal pure returns (bytes memory) {
|
|
127
|
+
return data.scaleBalancerBatch(oldAmount, newAmount);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function newMantis(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
131
|
+
return data.scaleMantis(oldAmount, newAmount);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function newIziSwap(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
135
|
+
return data.scaleIziSwap(oldAmount, newAmount);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function newTraderJoeV2(
|
|
139
|
+
bytes memory data,
|
|
140
|
+
uint256 oldAmount,
|
|
141
|
+
uint256 newAmount
|
|
142
|
+
) internal pure returns (bytes memory) {
|
|
143
|
+
return data.scaleTraderJoeV2(oldAmount, newAmount);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function newLevelFiV2(
|
|
147
|
+
bytes memory data,
|
|
148
|
+
uint256 oldAmount,
|
|
149
|
+
uint256 newAmount
|
|
150
|
+
) internal pure returns (bytes memory) {
|
|
151
|
+
return data.scaleLevelFiV2(oldAmount, newAmount);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function newGMXGLP(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
155
|
+
return data.scaleGMXGLP(oldAmount, newAmount);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function newVooi(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
159
|
+
return data.scaleVooi(oldAmount, newAmount);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function newVelocoreV2(
|
|
163
|
+
bytes memory data,
|
|
164
|
+
uint256 oldAmount,
|
|
165
|
+
uint256 newAmount
|
|
166
|
+
) internal pure returns (bytes memory) {
|
|
167
|
+
return data.scaleVelocoreV2(oldAmount, newAmount);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function newKokonut(bytes memory data, uint256 oldAmount, uint256 newAmount) internal pure returns (bytes memory) {
|
|
171
|
+
return data.scaleKokonut(oldAmount, newAmount);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -20,20 +20,14 @@ interface I1inchAggregationRouterV5 {
|
|
|
20
20
|
uint256 amount,
|
|
21
21
|
uint256 minReturn,
|
|
22
22
|
uint256[] calldata pools
|
|
23
|
-
) external payable returns(uint256 returnAmount);
|
|
23
|
+
) external payable returns (uint256 returnAmount);
|
|
24
24
|
|
|
25
25
|
function swap(
|
|
26
26
|
address executor,
|
|
27
27
|
SwapDescription calldata desc,
|
|
28
28
|
bytes calldata permit,
|
|
29
29
|
bytes calldata data
|
|
30
|
-
)
|
|
31
|
-
external
|
|
32
|
-
payable
|
|
33
|
-
returns (
|
|
34
|
-
uint256 returnAmount,
|
|
35
|
-
uint256 spentAmount
|
|
36
|
-
);
|
|
30
|
+
) external payable returns (uint256 returnAmount, uint256 spentAmount);
|
|
37
31
|
|
|
38
32
|
function unoswapTo(
|
|
39
33
|
address payable recipient,
|
|
@@ -41,5 +35,5 @@ interface I1inchAggregationRouterV5 {
|
|
|
41
35
|
uint256 amount,
|
|
42
36
|
uint256 minReturn,
|
|
43
37
|
uint256[] calldata pools
|
|
44
|
-
) external payable returns(uint256 returnAmount);
|
|
45
|
-
}
|
|
38
|
+
) external payable returns (uint256 returnAmount);
|
|
39
|
+
}
|
|
@@ -5,25 +5,26 @@ import "./I1inchAggregationRouterV5.sol";
|
|
|
5
5
|
import "../../../core/libraries/Errors.sol";
|
|
6
6
|
|
|
7
7
|
abstract contract OneInchAggregationRouterHelper {
|
|
8
|
-
function _rescaleMinAmount(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{
|
|
8
|
+
function _rescaleMinAmount(
|
|
9
|
+
uint256 minAmount,
|
|
10
|
+
uint256 oldAmount,
|
|
11
|
+
uint256 newAmount
|
|
12
|
+
) internal pure returns (uint256) {
|
|
13
13
|
return (minAmount * newAmount) / oldAmount;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function _get1inchScaledInputData(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
16
|
+
function _get1inchScaledInputData(
|
|
17
|
+
bytes calldata rawCallData,
|
|
18
|
+
uint256 newAmount
|
|
19
|
+
) internal pure returns (bytes memory) {
|
|
21
20
|
bytes4 selector = bytes4(rawCallData[:4]);
|
|
22
21
|
bytes memory args = rawCallData[4:];
|
|
23
22
|
|
|
24
23
|
if (selector == I1inchAggregationRouterV5.uniswapV3SwapTo.selector) {
|
|
25
|
-
(address payable recipient, uint256 amount, uint256 minReturn, uint256[] memory pools) =
|
|
26
|
-
|
|
24
|
+
(address payable recipient, uint256 amount, uint256 minReturn, uint256[] memory pools) = abi.decode(
|
|
25
|
+
args,
|
|
26
|
+
(address, uint256, uint256, uint256[])
|
|
27
|
+
);
|
|
27
28
|
|
|
28
29
|
amount = newAmount;
|
|
29
30
|
return abi.encodeWithSelector(selector, recipient, amount, minReturn, pools);
|
|
@@ -42,8 +43,13 @@ abstract contract OneInchAggregationRouterHelper {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
if (selector == I1inchAggregationRouterV5.unoswapTo.selector) {
|
|
45
|
-
(
|
|
46
|
-
|
|
46
|
+
(
|
|
47
|
+
address payable recipient,
|
|
48
|
+
address srcToken,
|
|
49
|
+
uint256 amount,
|
|
50
|
+
uint256 minReturn,
|
|
51
|
+
uint256[] memory pools
|
|
52
|
+
) = abi.decode(args, (address, address, uint256, uint256, uint256[]));
|
|
47
53
|
|
|
48
54
|
amount = newAmount;
|
|
49
55
|
return abi.encodeWithSelector(selector, recipient, srcToken, amount, minReturn, pools);
|
package/deployments/1-core.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"chainId": 1,
|
|
5
5
|
"treasury": "0x8270400d528c34e1596EF367eeDEc99080A1b592",
|
|
6
6
|
"governance": "0x8119EC16F0573B7dAc7C0CB94EB504FB32456ee1",
|
|
7
|
+
"devMultisig": "0xE6F0489ED91dc27f40f9dbe8f81fccbFC16b9cb1",
|
|
7
8
|
"pendle": "0x808507121b80c02388fad14726482e061b8da827",
|
|
8
9
|
"lzEndpoint": "0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675",
|
|
9
10
|
"wrappedNative": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
@@ -21,12 +22,14 @@
|
|
|
21
22
|
"marketFactory": "0x27b1dAcd74688aF24a64BD3C9C1B143118740784",
|
|
22
23
|
"bulkSellerFactory": "0x4B1da107B50529d53e5C906a79eaEcDCbC0E1dE3",
|
|
23
24
|
"bulkSellerOffchain": "0x9ACc60F915dFcd190D270fc92567aE71776bd320",
|
|
24
|
-
"router": "
|
|
25
|
+
"router": "0x00000000005BBB0EF59571E58418F9a4357b68A0",
|
|
25
26
|
"routerStatic": "0x263833d47eA3fA4a30f269323aba6a107f9eB14C",
|
|
26
27
|
"pendleSwap": "0x324D838b26Eb73786bDBBc53bb0682F1EBB50603",
|
|
27
28
|
"routerHelper": "0x462206b11d185ef6F64B41D344325401C37EC335",
|
|
28
29
|
"routerHelper2": "0x2ed3af0275a1fd0c53c39d70241a1c14e8ce37d3",
|
|
29
|
-
"ptOracle": "
|
|
30
|
+
"ptOracle": "0xbbd487268A295531d299c125F3e5f749884A3e30",
|
|
31
|
+
"yieldContractFactoryV3": "0xdF3601014686674e53d1Fa52F7602525483F9122",
|
|
32
|
+
"marketFactoryV3": "0x1A6fCc85557BC4fB7B534ed835a03EF056552D52",
|
|
30
33
|
"liquiditySeedingHelper": "0x39cD9CB33dA6b5eb2A22CbE0a07647E2c3C76D23",
|
|
31
34
|
"vePendle": "0x4f30A9D41B80ecC5B94306AB4364951AE3170210",
|
|
32
35
|
"senderEndpoint": "0x07b1014c88f14C9E910092526db57A20052E989F",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "SY ePendle",
|
|
3
|
+
"symbol": "SY-ePendle",
|
|
4
|
+
"doCacheIndex": true,
|
|
5
|
+
"expiry": 1727308800,
|
|
6
|
+
"scalarRoot": "22259416476000000000",
|
|
7
|
+
"initialRateAnchor": "1134651159000000000",
|
|
8
|
+
"SY": "0x887bdD18D042A85b9c702698eFE71E1C38d5C868",
|
|
9
|
+
"PT": "0x0Ba11DEe8b63f08EA25d0cc733601e8C15325a8D",
|
|
10
|
+
"YT": "0x41535fc6AdCb81a7af1bD4669d221983Ed4e33Af",
|
|
11
|
+
"market": "0x0eB3f11ed8ca69813744868D02D83D4Fbf72841e"
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "SY sFRAX",
|
|
3
|
+
"SY": "0xb359F0A97Ca269Ae5574dc75be48b0e81eFD1dA2",
|
|
4
|
+
"YT": "0xDe364a895D4EC08c05A34F6883A8E41C15619Ed8",
|
|
5
|
+
"PT": "0xBF44fbCc181e297E1532B72c6ca500fe150C5b9E",
|
|
6
|
+
"market": "0x1806855b73881eD4E435c97C6Da58b01Be5D7390",
|
|
7
|
+
"expiry": 1711584000,
|
|
8
|
+
"scalarRoot": "151425174849000000000",
|
|
9
|
+
"initAnchor": "1025338668000000000"
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "SY Silo crvUSD",
|
|
3
|
+
"SY": "0xE05082B184a34668CD8A904D85FA815802BBb04c",
|
|
4
|
+
"YT": "0xED97f94dd94255637A054098604E0201C442a3FD",
|
|
5
|
+
"PT": "0xB87511364014C088e30f872EfC4a00D7efB843AC",
|
|
6
|
+
"market": "0xC9beCdbC62efb867cB52222b34c187fB170379C6",
|
|
7
|
+
"expiry": 1711584000,
|
|
8
|
+
"scalarRoot": "50749840533000000000",
|
|
9
|
+
"initAnchor": "1033799235000000000"
|
|
10
|
+
}
|