@pendle/core-v2 1.3.0-mainnet → 1.4.0-mainnet
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol/LayerZeroHelper.json +2 -2
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
- package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/StEthHelper.sol/StEthHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/StEthHelper.sol/StEthHelper.json +1 -41
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAura3EthSY.sol/PendleAura3EthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAura3EthSY.sol/PendleAura3EthSY.json +2 -41
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraCbethWstethSY.sol/PendleAuraCbethWstethSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraCbethWstethSY.sol/PendleAuraCbethWstethSY.json +2 -41
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRethSY.sol/PendleAuraWethRethSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSY.sol/PendleAuraWethWstethSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSY.sol/PendleAuraWethWstethSY.json +2 -41
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStableMath.sol/ComposableStableMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/ComposableStable/ComposableStablePreview.sol/ComposableStablePreview.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/FixedPoint.sol/FixedPoint.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStableMath.sol/MetaStableMath.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/MetaStable/MetaStablePreview.sol/MetaStablePreview.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSY.sol/PendleAuraBalancerStableLPSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePoolUserData.sol/StablePoolUserData.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/StablePreviewBase.sol/StablePreviewBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/ArrayLib.sol/ArrayLib.dbg.json +1 -1
- package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IAsset.sol/IAsset.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerFees.sol/IBalancerFees.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IBalancerStablePreview.sol/IBalancerStablePreview.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IBasePool.sol/IBasePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IComposableStable.sol/IComposableStable.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IGauge.sol/IGauge.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/ILiquidityGaugeFactory.sol/ILiquidityGaugeFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IMetaStablePool.sol/IMetaStablePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IRateProvider.sol/IRateProvider.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Balancer/IVault.sol/IVault.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ConvexCurve/IRewards.sol/IRewards.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IApeStaking.sol/IApeStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapPTYT.sol/IPActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPFeeDistributor.sol/IPFeeDistributor.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/MarketMathStatic.sol/MarketMathStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/Multicall2.sol/Multicall2.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/PendleMulticall.sol/PendleMulticall.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/PendleMulticall.sol/PendleMulticall.json +47 -0
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMisc.sol/ActionMisc.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTYT.sol/ActionSwapPTYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
- package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/AggregationRouterHelper.sol/AggregationRouterHelper.json +2 -2
- package/build/artifacts/contracts/router/kyberswap/IAggregatorRouterHelper.sol/IAggregationRouterHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/KyberSwapHelper.sol/KyberSwapHelper.dbg.json +1 -1
- package/build/artifacts/contracts/router/kyberswap/ScaleDataHelperEthereum1.sol/ScaleDataHelperEthereum1.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/ScaleDataHelperEthereum1.sol/ScaleDataHelperEthereum1.json +10 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IAggregationExecutor.sol/IAggregationExecutor.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IAggregationExecutor.sol/IAggregationExecutor.json +65 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IExecutorHelperEthereum1.sol/IExecutorHelperEthereum1.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IExecutorHelperEthereum1.sol/IExecutorHelperEthereum1.json +359 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IHashflow.sol/IHashflow.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IHashflow.sol/IHashflow.json +101 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IMetaAggregationRouter.sol/IMetaAggregationRouter.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IMetaAggregationRouter.sol/IMetaAggregationRouter.json +183 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.dbg.json +4 -0
- package/build/artifacts/contracts/router/kyberswap/interfaces/IMetaAggregationRouterV2.sol/IMetaAggregationRouterV2.json +215 -0
- package/contracts/LiquidityMining/CrossChainMsg/libraries/LayerZeroHelper.sol +7 -9
- package/contracts/core/StandardizedYield/StEthHelper.sol +4 -4
- package/contracts/offchain-helpers/PendleMulticall.sol +26 -0
- package/contracts/router/kyberswap/AggregationRouterHelper.sol +182 -206
- package/contracts/router/kyberswap/ScaleDataHelperEthereum1.sol +134 -0
- package/contracts/router/kyberswap/interfaces/IAggregationExecutor.sol +17 -0
- package/contracts/router/kyberswap/interfaces/IExecutorHelperEthereum1.sol +185 -0
- package/contracts/router/kyberswap/interfaces/IHashflow.sol +30 -0
- package/contracts/router/kyberswap/interfaces/IMetaAggregationRouter.sol +33 -0
- package/contracts/router/kyberswap/interfaces/IMetaAggregationRouterV2.sol +42 -0
- package/deployments/1-markets/BALANCER-LP-AURA-WSTETH-WETH-JUN272024.json +10 -0
- package/deployments/1-offchain-helper.json +4 -0
- package/package.json +1 -1
- package/typechain-types/GMXPreviewHelper.ts +81 -0
- package/typechain-types/I1inchAggregationRouterV5.ts +257 -0
- package/typechain-types/IAggregationExecutor.ts +182 -0
- package/typechain-types/IExecutorHelperEthereum1.ts +599 -0
- package/typechain-types/IGMXVault.ts +494 -0
- package/typechain-types/IGlpManager.ts +115 -0
- package/typechain-types/IHashflow.ts +159 -0
- package/typechain-types/IKyberSwapAggregationRouterHelper.ts +109 -0
- package/typechain-types/IMetaAggregationRouter.ts +213 -0
- package/typechain-types/IMetaAggregationRouterV2.ts +221 -0
- package/typechain-types/IPYieldTokenV2.ts +915 -0
- package/typechain-types/IRewardRouterV2.ts +303 -0
- package/typechain-types/ISwapAggregator.ts +124 -0
- package/typechain-types/IVaultPriceFeed.ts +114 -0
- package/typechain-types/InterestManagerYTV2.ts +124 -0
- package/typechain-types/PendleAura3EthSY.ts +0 -39
- package/typechain-types/PendleAuraCbethWstethSY.ts +0 -39
- package/typechain-types/PendleAuraWethWstethSY.ts +0 -39
- package/typechain-types/PendleGlpSY.ts +1396 -0
- package/typechain-types/PendleMulticall.ts +110 -0
- package/typechain-types/PendlePrincipalTokenV2.ts +614 -0
- package/typechain-types/PendleYieldContractFactoryV2.ts +801 -0
- package/typechain-types/PendleYieldTokenV2.ts +1304 -0
- package/typechain-types/SwapAggregator.ts +406 -0
- package/typechain-types/factories/AggregationRouterHelper__factory.ts +1 -1
- package/typechain-types/factories/GMXPreviewHelper__factory.ts +39 -0
- package/typechain-types/factories/I1inchAggregationRouterV5__factory.ts +179 -0
- package/typechain-types/factories/IAggregationExecutor__factory.ts +84 -0
- package/typechain-types/factories/IExecutorHelperEthereum1__factory.ts +378 -0
- package/typechain-types/factories/IGMXVault__factory.ts +320 -0
- package/typechain-types/factories/IGlpManager__factory.ts +55 -0
- package/typechain-types/factories/IHashflow__factory.ts +113 -0
- package/typechain-types/factories/IKyberSwapAggregationRouterHelper__factory.ts +56 -0
- package/typechain-types/factories/IMetaAggregationRouterV2__factory.ts +234 -0
- package/typechain-types/factories/IMetaAggregationRouter__factory.ts +202 -0
- package/typechain-types/factories/IPYieldTokenV2__factory.ts +702 -0
- package/typechain-types/factories/IRewardRouterV2__factory.ts +180 -0
- package/typechain-types/factories/ISwapAggregator__factory.ts +66 -0
- package/typechain-types/factories/IVaultPriceFeed__factory.ts +60 -0
- package/typechain-types/factories/InterestManagerYTV2__factory.ts +63 -0
- package/typechain-types/factories/PendleAura3EthSY__factory.ts +1 -40
- package/typechain-types/factories/PendleAuraCbethWstethSY__factory.ts +1 -40
- package/typechain-types/factories/PendleAuraWethWstethSY__factory.ts +1 -40
- package/typechain-types/factories/PendleGlpSY__factory.ts +1216 -0
- package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
- package/typechain-types/factories/PendleMulticall__factory.ts +100 -0
- package/typechain-types/factories/PendlePrincipalTokenV2__factory.ts +564 -0
- package/typechain-types/factories/PendleYieldContractFactoryV2__factory.ts +674 -0
- package/typechain-types/factories/PendleYieldTokenV2__factory.ts +1122 -0
- package/typechain-types/factories/SwapAggregator__factory.ts +309 -0
- package/typechain-types/hardhat.d.ts +103 -13
- package/typechain-types/index.ts +24 -4
- package/build/artifacts/contracts/router/kyberswap/IMultihopRouterEthereum.sol/IMultihopRouterEthereum.dbg.json +0 -4
- package/build/artifacts/contracts/router/kyberswap/IMultihopRouterEthereum.sol/IMultihopRouterEthereum.json +0 -136
- package/contracts/router/kyberswap/IMultihopRouterEthereum.sol +0 -141
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
|
|
3
3
|
pragma solidity 0.8.17;
|
|
4
|
-
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
-
import "./IMultihopRouterEthereum.sol";
|
|
6
|
-
import "./IAggregatorRouterHelper.sol";
|
|
7
|
-
import "../../interfaces/IWETH.sol";
|
|
8
4
|
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
9
5
|
import "../../core/libraries/BoringOwnableUpgradeable.sol";
|
|
10
6
|
|
|
7
|
+
import "../../interfaces/IWETH.sol";
|
|
8
|
+
|
|
9
|
+
import "./interfaces/IMetaAggregationRouter.sol";
|
|
10
|
+
import "./interfaces/IMetaAggregationRouterV2.sol";
|
|
11
|
+
import "./interfaces/IHashflow.sol";
|
|
12
|
+
import "./interfaces/IExecutorHelperEthereum1.sol";
|
|
13
|
+
|
|
14
|
+
import "./IAggregatorRouterHelper.sol";
|
|
15
|
+
import "./ScaleDataHelperEthereum1.sol";
|
|
16
|
+
|
|
11
17
|
contract AggregationRouterHelper is
|
|
12
18
|
IAggregationRouterHelper,
|
|
13
19
|
Initializable,
|
|
@@ -21,8 +27,6 @@ contract AggregationRouterHelper is
|
|
|
21
27
|
uint256 private constant _BURN_FROM_TX_ORIGIN = 0x10;
|
|
22
28
|
uint256 private constant _SIMPLE_SWAP = 0x20;
|
|
23
29
|
|
|
24
|
-
uint256 private constant SLIPPAGE_RANGE = 10; // over 100
|
|
25
|
-
|
|
26
30
|
constructor() initializer {}
|
|
27
31
|
|
|
28
32
|
function initialize() external initializer {
|
|
@@ -31,29 +35,9 @@ contract AggregationRouterHelper is
|
|
|
31
35
|
|
|
32
36
|
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
CURVE,
|
|
38
|
-
KYBERDMM,
|
|
39
|
-
SADDLE,
|
|
40
|
-
UNIV3PROMM,
|
|
41
|
-
BALANCERV2,
|
|
42
|
-
KYBERRFQ,
|
|
43
|
-
DODO,
|
|
44
|
-
WSTETH
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
struct SwapDescription {
|
|
48
|
-
IERC20 srcToken;
|
|
49
|
-
IERC20 dstToken;
|
|
50
|
-
address[] srcReceivers;
|
|
51
|
-
uint256[] srcAmounts;
|
|
52
|
-
address dstReceiver;
|
|
53
|
-
uint256 amount;
|
|
54
|
-
uint256 minReturnAmount;
|
|
55
|
-
uint256 flags;
|
|
56
|
-
bytes permit;
|
|
38
|
+
struct Swap {
|
|
39
|
+
bytes data;
|
|
40
|
+
bytes4 selector;
|
|
57
41
|
}
|
|
58
42
|
|
|
59
43
|
struct SimpleSwapData {
|
|
@@ -65,7 +49,7 @@ contract AggregationRouterHelper is
|
|
|
65
49
|
}
|
|
66
50
|
|
|
67
51
|
struct SwapExecutorDescription {
|
|
68
|
-
|
|
52
|
+
Swap[][] swapSequences;
|
|
69
53
|
address tokenIn;
|
|
70
54
|
address tokenOut;
|
|
71
55
|
uint256 minTotalAmountOut;
|
|
@@ -89,47 +73,120 @@ contract AggregationRouterHelper is
|
|
|
89
73
|
return abi.encodeWithSelector(selector, newAmount);
|
|
90
74
|
}
|
|
91
75
|
|
|
92
|
-
(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
76
|
+
if (
|
|
77
|
+
selector == IMetaAggregationRouter.swap.selector ||
|
|
78
|
+
selector == IMetaAggregationRouter.swapSimpleMode.selector
|
|
79
|
+
) {
|
|
80
|
+
(
|
|
81
|
+
address callTarget,
|
|
82
|
+
IMetaAggregationRouter.SwapDescription memory desc,
|
|
83
|
+
bytes memory targetData,
|
|
84
|
+
bytes memory clientData
|
|
85
|
+
) = abi.decode(
|
|
86
|
+
kybercall[4:],
|
|
87
|
+
(address, IMetaAggregationRouter.SwapDescription, bytes, bytes)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
(desc, targetData) = _getScaledInputDataV1(
|
|
91
|
+
desc,
|
|
92
|
+
targetData,
|
|
93
|
+
newAmount,
|
|
94
|
+
selector == IMetaAggregationRouter.swapSimpleMode.selector ||
|
|
95
|
+
_flagsChecked(desc.flags, _SIMPLE_SWAP)
|
|
96
|
+
);
|
|
97
|
+
return abi.encodeWithSelector(selector, callTarget, desc, targetData, clientData);
|
|
98
|
+
}
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
if (selector == IMetaAggregationRouterV2.swap.selector) {
|
|
101
|
+
IMetaAggregationRouterV2.SwapExecutionParams memory params = abi.decode(
|
|
102
|
+
kybercall[4:],
|
|
103
|
+
(IMetaAggregationRouterV2.SwapExecutionParams)
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
(params.desc, params.targetData) = _getScaledInputDataV2(
|
|
107
|
+
params.desc,
|
|
108
|
+
params.targetData,
|
|
109
|
+
newAmount,
|
|
110
|
+
_flagsChecked(params.desc.flags, _SIMPLE_SWAP)
|
|
111
|
+
);
|
|
112
|
+
return abi.encodeWithSelector(selector, params);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (selector == IMetaAggregationRouterV2.swapSimpleMode.selector) {
|
|
116
|
+
(
|
|
117
|
+
address callTarget,
|
|
118
|
+
IMetaAggregationRouterV2.SwapDescriptionV2 memory desc,
|
|
119
|
+
bytes memory targetData,
|
|
120
|
+
bytes memory clientData
|
|
121
|
+
) = abi.decode(
|
|
122
|
+
kybercall[4:],
|
|
123
|
+
(address, IMetaAggregationRouterV2.SwapDescriptionV2, bytes, bytes)
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
(desc, targetData) = _getScaledInputDataV2(desc, targetData, newAmount, true);
|
|
127
|
+
return abi.encodeWithSelector(selector, callTarget, desc, targetData, clientData);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
revert("InputScalingHelper: Invalid selector");
|
|
101
131
|
}
|
|
102
132
|
|
|
103
|
-
function
|
|
104
|
-
SwapDescription memory desc,
|
|
133
|
+
function _getScaledInputDataV1(
|
|
134
|
+
IMetaAggregationRouter.SwapDescription memory desc,
|
|
105
135
|
bytes memory executorData,
|
|
106
|
-
uint256 newAmount
|
|
107
|
-
|
|
108
|
-
|
|
136
|
+
uint256 newAmount,
|
|
137
|
+
bool isSimpleMode
|
|
138
|
+
) internal pure returns (IMetaAggregationRouter.SwapDescription memory, bytes memory) {
|
|
139
|
+
uint256 oldAmount = desc.amount;
|
|
140
|
+
if (oldAmount == newAmount) {
|
|
141
|
+
return (desc, executorData);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// simple mode swap
|
|
145
|
+
if (isSimpleMode) {
|
|
146
|
+
return (
|
|
147
|
+
_scaledSwapDescriptionV1(desc, oldAmount, newAmount),
|
|
148
|
+
_scaledSimpleSwapData(executorData, oldAmount, newAmount)
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//normal mode swap
|
|
153
|
+
return (
|
|
154
|
+
_scaledSwapDescriptionV1(desc, oldAmount, newAmount),
|
|
155
|
+
_scaledExecutorCallBytesData(executorData, oldAmount, newAmount)
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function _getScaledInputDataV2(
|
|
160
|
+
IMetaAggregationRouterV2.SwapDescriptionV2 memory desc,
|
|
161
|
+
bytes memory executorData,
|
|
162
|
+
uint256 newAmount,
|
|
163
|
+
bool isSimpleMode
|
|
164
|
+
) internal pure returns (IMetaAggregationRouterV2.SwapDescriptionV2 memory, bytes memory) {
|
|
109
165
|
uint256 oldAmount = desc.amount;
|
|
110
166
|
if (oldAmount == newAmount) {
|
|
111
167
|
return (desc, executorData);
|
|
112
168
|
}
|
|
113
169
|
|
|
114
170
|
// simple mode swap
|
|
115
|
-
if (
|
|
116
|
-
require(desc.srcReceivers.length == 0, "kyber: can't scale if take fee");
|
|
171
|
+
if (isSimpleMode) {
|
|
117
172
|
return (
|
|
118
|
-
|
|
119
|
-
|
|
173
|
+
_scaledSwapDescriptionV2(desc, oldAmount, newAmount),
|
|
174
|
+
_scaledSimpleSwapData(executorData, oldAmount, newAmount)
|
|
120
175
|
);
|
|
121
176
|
}
|
|
122
177
|
|
|
123
178
|
//normal mode swap
|
|
124
|
-
|
|
125
|
-
|
|
179
|
+
return (
|
|
180
|
+
_scaledSwapDescriptionV2(desc, oldAmount, newAmount),
|
|
181
|
+
_scaledExecutorCallBytesData(executorData, oldAmount, newAmount)
|
|
182
|
+
);
|
|
126
183
|
}
|
|
127
184
|
|
|
128
|
-
function
|
|
129
|
-
SwapDescription memory desc,
|
|
185
|
+
function _scaledSwapDescriptionV1(
|
|
186
|
+
IMetaAggregationRouter.SwapDescription memory desc,
|
|
130
187
|
uint256 oldAmount,
|
|
131
188
|
uint256 newAmount
|
|
132
|
-
) internal pure returns (SwapDescription memory) {
|
|
189
|
+
) internal pure returns (IMetaAggregationRouter.SwapDescription memory) {
|
|
133
190
|
uint256 oldMinReturnAmount = desc.minReturnAmount;
|
|
134
191
|
desc.minReturnAmount = (desc.minReturnAmount * newAmount) / oldAmount;
|
|
135
192
|
//newMinReturnAmount should no be 0 if oldMinReturnAmount > 0
|
|
@@ -151,7 +208,7 @@ contract AggregationRouterHelper is
|
|
|
151
208
|
return desc;
|
|
152
209
|
}
|
|
153
210
|
|
|
154
|
-
function
|
|
211
|
+
function _scaledSimpleSwapData(
|
|
155
212
|
bytes memory data,
|
|
156
213
|
uint256 oldAmount,
|
|
157
214
|
uint256 newAmount
|
|
@@ -172,170 +229,89 @@ contract AggregationRouterHelper is
|
|
|
172
229
|
return abi.encode(swapData);
|
|
173
230
|
}
|
|
174
231
|
|
|
175
|
-
function
|
|
232
|
+
function _scaledExecutorCallBytesData(
|
|
176
233
|
bytes memory data,
|
|
177
234
|
uint256 oldAmount,
|
|
178
235
|
uint256 newAmount
|
|
179
236
|
) internal pure returns (bytes memory) {
|
|
180
|
-
SwapExecutorDescription memory
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
} else if (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
} else if (
|
|
205
|
-
(
|
|
206
|
-
} else if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
} else if (
|
|
213
|
-
|
|
214
|
-
} else {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
237
|
+
SwapExecutorDescription memory executorDesc = abi.decode(data, (SwapExecutorDescription));
|
|
238
|
+
executorDesc.minTotalAmountOut = (executorDesc.minTotalAmountOut * newAmount) / oldAmount;
|
|
239
|
+
for (uint256 i = 0; i < executorDesc.swapSequences.length; i++) {
|
|
240
|
+
Swap memory swap = executorDesc.swapSequences[i][0];
|
|
241
|
+
bytes4 selector = swap.selector;
|
|
242
|
+
|
|
243
|
+
if (selector == IExecutorHelperEthereum1.executeUniSwap.selector) {
|
|
244
|
+
swap.data = ScaleDataHelperEthereum1.newUniSwap(swap.data, oldAmount, newAmount);
|
|
245
|
+
} else if (selector == IExecutorHelperEthereum1.executeStableSwap.selector) {
|
|
246
|
+
swap.data = ScaleDataHelperEthereum1.newStableSwap(
|
|
247
|
+
swap.data,
|
|
248
|
+
oldAmount,
|
|
249
|
+
newAmount
|
|
250
|
+
);
|
|
251
|
+
} else if (selector == IExecutorHelperEthereum1.executeCurveSwap.selector) {
|
|
252
|
+
swap.data = ScaleDataHelperEthereum1.newCurveSwap(swap.data, oldAmount, newAmount);
|
|
253
|
+
} else if (selector == IExecutorHelperEthereum1.executeKyberDMMSwap.selector) {
|
|
254
|
+
swap.data = ScaleDataHelperEthereum1.newKyberDMM(swap.data, oldAmount, newAmount);
|
|
255
|
+
} else if (selector == IExecutorHelperEthereum1.executeUniV3ProMMSwap.selector) {
|
|
256
|
+
swap.data = ScaleDataHelperEthereum1.newUniV3ProMM(
|
|
257
|
+
swap.data,
|
|
258
|
+
oldAmount,
|
|
259
|
+
newAmount
|
|
260
|
+
);
|
|
261
|
+
} else if (selector == IExecutorHelperEthereum1.executeRfqSwap.selector) {
|
|
262
|
+
revert("InputScalingHelper: Can not scale RFQ swap");
|
|
263
|
+
} else if (selector == IExecutorHelperEthereum1.executeBalV2Swap.selector) {
|
|
264
|
+
swap.data = ScaleDataHelperEthereum1.newBalancerV2(
|
|
265
|
+
swap.data,
|
|
266
|
+
oldAmount,
|
|
267
|
+
newAmount
|
|
268
|
+
);
|
|
269
|
+
} else if (selector == IExecutorHelperEthereum1.executeDODOSwap.selector) {
|
|
270
|
+
swap.data = ScaleDataHelperEthereum1.newDODO(swap.data, oldAmount, newAmount);
|
|
271
|
+
} else if (selector == IExecutorHelperEthereum1.executeWrappedstETHSwap.selector) {
|
|
272
|
+
swap.data = ScaleDataHelperEthereum1.newWrappedstETHSwap(
|
|
273
|
+
swap.data,
|
|
274
|
+
oldAmount,
|
|
275
|
+
newAmount
|
|
276
|
+
);
|
|
277
|
+
} else if (selector == IExecutorHelperEthereum1.executeSynthetixSwap.selector) {
|
|
278
|
+
swap.data = ScaleDataHelperEthereum1.newSynthetix(swap.data, oldAmount, newAmount);
|
|
279
|
+
} else if (selector == IExecutorHelperEthereum1.executePSMSwap.selector) {
|
|
280
|
+
swap.data = ScaleDataHelperEthereum1.newPSM(swap.data, oldAmount, newAmount);
|
|
281
|
+
} else if (selector == IExecutorHelperEthereum1.executeHashflowSwap.selector) {
|
|
282
|
+
revert("InputScalingHelper: Can not scale RFQ swap");
|
|
283
|
+
} else revert("AggregationExecutor: Dex type not supported");
|
|
218
284
|
}
|
|
219
|
-
return abi.encode(
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function _newUniSwap(
|
|
223
|
-
bytes memory data,
|
|
224
|
-
uint256 value,
|
|
225
|
-
uint256 oldAmount,
|
|
226
|
-
uint256 newAmount
|
|
227
|
-
) internal pure returns (bytes memory, uint256) {
|
|
228
|
-
IMultihopRouterEthereum.UniSwap memory uniSwap = abi.decode(
|
|
229
|
-
data,
|
|
230
|
-
(IMultihopRouterEthereum.UniSwap)
|
|
231
|
-
);
|
|
232
|
-
if (value > 0) uniSwap.collectAmount = value;
|
|
233
|
-
else uniSwap.collectAmount = (uniSwap.collectAmount * newAmount) / oldAmount;
|
|
234
|
-
return (abi.encode(uniSwap), uniSwap.collectAmount);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function _newStableSwap(
|
|
238
|
-
bytes memory data,
|
|
239
|
-
uint256 value,
|
|
240
|
-
uint256 oldAmount,
|
|
241
|
-
uint256 newAmount
|
|
242
|
-
) internal pure returns (bytes memory, uint256) {
|
|
243
|
-
IMultihopRouterEthereum.StableSwap memory stableSwap = abi.decode(
|
|
244
|
-
data,
|
|
245
|
-
(IMultihopRouterEthereum.StableSwap)
|
|
246
|
-
);
|
|
247
|
-
if (value > 0) stableSwap.dx = value;
|
|
248
|
-
else stableSwap.dx = (stableSwap.dx * newAmount) / oldAmount;
|
|
249
|
-
return (abi.encode(stableSwap), stableSwap.dx);
|
|
285
|
+
return abi.encode(executorDesc);
|
|
250
286
|
}
|
|
251
287
|
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
uint256 value,
|
|
288
|
+
function _scaledSwapDescriptionV2(
|
|
289
|
+
IMetaAggregationRouterV2.SwapDescriptionV2 memory desc,
|
|
255
290
|
uint256 oldAmount,
|
|
256
291
|
uint256 newAmount
|
|
257
|
-
) internal pure returns (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
function _newKyberDMMSwap(
|
|
268
|
-
bytes memory data,
|
|
269
|
-
uint256 value,
|
|
270
|
-
uint256 oldAmount,
|
|
271
|
-
uint256 newAmount
|
|
272
|
-
) internal pure returns (bytes memory, uint256) {
|
|
273
|
-
IMultihopRouterEthereum.UniSwap memory kyberDMMSwap = abi.decode(
|
|
274
|
-
data,
|
|
275
|
-
(IMultihopRouterEthereum.UniSwap)
|
|
276
|
-
);
|
|
277
|
-
if (value > 0) kyberDMMSwap.collectAmount = value;
|
|
278
|
-
else kyberDMMSwap.collectAmount = (kyberDMMSwap.collectAmount * newAmount) / oldAmount;
|
|
279
|
-
return (abi.encode(kyberDMMSwap), kyberDMMSwap.collectAmount);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
function _newUniV3ProMMSwap(
|
|
283
|
-
bytes memory data,
|
|
284
|
-
uint256 value,
|
|
285
|
-
uint256 oldAmount,
|
|
286
|
-
uint256 newAmount
|
|
287
|
-
) internal pure returns (bytes memory, uint256) {
|
|
288
|
-
IMultihopRouterEthereum.UniSwapV3ProMM memory uniSwapV3ProMM = abi.decode(
|
|
289
|
-
data,
|
|
290
|
-
(IMultihopRouterEthereum.UniSwapV3ProMM)
|
|
291
|
-
);
|
|
292
|
-
if (value > 0) uniSwapV3ProMM.swapAmount = value;
|
|
293
|
-
else uniSwapV3ProMM.swapAmount = (uniSwapV3ProMM.swapAmount * newAmount) / oldAmount;
|
|
294
|
-
return (abi.encode(uniSwapV3ProMM), uniSwapV3ProMM.swapAmount);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function _newBalancerV2Swap(
|
|
298
|
-
bytes memory data,
|
|
299
|
-
uint256 value,
|
|
300
|
-
uint256 oldAmount,
|
|
301
|
-
uint256 newAmount
|
|
302
|
-
) internal pure returns (bytes memory, uint256) {
|
|
303
|
-
IMultihopRouterEthereum.BalancerV2 memory balancerV2 = abi.decode(
|
|
304
|
-
data,
|
|
305
|
-
(IMultihopRouterEthereum.BalancerV2)
|
|
306
|
-
);
|
|
307
|
-
if (value > 0) balancerV2.amount = value;
|
|
308
|
-
else balancerV2.amount = (balancerV2.amount * newAmount) / oldAmount;
|
|
309
|
-
return (abi.encode(balancerV2, balancerV2.amount), balancerV2.amount);
|
|
310
|
-
}
|
|
292
|
+
) internal pure returns (IMetaAggregationRouterV2.SwapDescriptionV2 memory) {
|
|
293
|
+
uint256 oldMinReturnAmount = desc.minReturnAmount;
|
|
294
|
+
desc.minReturnAmount = (desc.minReturnAmount * newAmount) / oldAmount;
|
|
295
|
+
//newMinReturnAmount should no be 0 if oldMinReturnAmount > 0
|
|
296
|
+
if (oldMinReturnAmount > 0 && desc.minReturnAmount == 0) desc.minReturnAmount = 1;
|
|
297
|
+
desc.amount = newAmount;
|
|
298
|
+
if (desc.srcReceivers.length == 0) {
|
|
299
|
+
return desc;
|
|
300
|
+
}
|
|
311
301
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (value > 0) dodo.amount = value;
|
|
323
|
-
else dodo.amount = (dodo.amount * newAmount) / oldAmount;
|
|
324
|
-
return (abi.encode(dodo), dodo.amount);
|
|
302
|
+
uint256 newTotal;
|
|
303
|
+
for (uint256 i = 0; i < desc.srcReceivers.length; i++) {
|
|
304
|
+
if (i == desc.srcReceivers.length - 1) {
|
|
305
|
+
desc.srcAmounts[i] = newAmount - newTotal;
|
|
306
|
+
} else {
|
|
307
|
+
desc.srcAmounts[i] = (desc.srcAmounts[i] * newAmount) / oldAmount;
|
|
308
|
+
}
|
|
309
|
+
newTotal += desc.srcAmounts[i];
|
|
310
|
+
}
|
|
311
|
+
return desc;
|
|
325
312
|
}
|
|
326
313
|
|
|
327
|
-
function
|
|
328
|
-
|
|
329
|
-
uint256 value,
|
|
330
|
-
uint256 oldAmount,
|
|
331
|
-
uint256 newAmount
|
|
332
|
-
) internal pure returns (bytes memory, uint256) {
|
|
333
|
-
IMultihopRouterEthereum.WSTETH memory wstEthData = abi.decode(
|
|
334
|
-
data,
|
|
335
|
-
(IMultihopRouterEthereum.WSTETH)
|
|
336
|
-
);
|
|
337
|
-
if (value > 0) wstEthData.amount = value;
|
|
338
|
-
else wstEthData.amount = (wstEthData.amount * newAmount) / oldAmount;
|
|
339
|
-
return (abi.encode(wstEthData), wstEthData.amount);
|
|
314
|
+
function _flagsChecked(uint256 number, uint256 flag) internal pure returns (bool) {
|
|
315
|
+
return number & flag != 0;
|
|
340
316
|
}
|
|
341
317
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "./interfaces/IExecutorHelperEthereum1.sol";
|
|
5
|
+
|
|
6
|
+
library ScaleDataHelperEthereum1 {
|
|
7
|
+
function newUniSwap(
|
|
8
|
+
bytes memory data,
|
|
9
|
+
uint256 oldAmount,
|
|
10
|
+
uint256 newAmount
|
|
11
|
+
) internal pure returns (bytes memory) {
|
|
12
|
+
IExecutorHelperEthereum1.UniSwap memory uniSwap = abi.decode(
|
|
13
|
+
data,
|
|
14
|
+
(IExecutorHelperEthereum1.UniSwap)
|
|
15
|
+
);
|
|
16
|
+
uniSwap.collectAmount = (uniSwap.collectAmount * newAmount) / oldAmount;
|
|
17
|
+
return abi.encode(uniSwap);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function newStableSwap(
|
|
21
|
+
bytes memory data,
|
|
22
|
+
uint256 oldAmount,
|
|
23
|
+
uint256 newAmount
|
|
24
|
+
) internal pure returns (bytes memory) {
|
|
25
|
+
IExecutorHelperEthereum1.StableSwap memory stableSwap = abi.decode(
|
|
26
|
+
data,
|
|
27
|
+
(IExecutorHelperEthereum1.StableSwap)
|
|
28
|
+
);
|
|
29
|
+
stableSwap.dx = (stableSwap.dx * newAmount) / oldAmount;
|
|
30
|
+
return abi.encode(stableSwap);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function newCurveSwap(
|
|
34
|
+
bytes memory data,
|
|
35
|
+
uint256 oldAmount,
|
|
36
|
+
uint256 newAmount
|
|
37
|
+
) internal pure returns (bytes memory) {
|
|
38
|
+
IExecutorHelperEthereum1.CurveSwap memory curveSwap = abi.decode(
|
|
39
|
+
data,
|
|
40
|
+
(IExecutorHelperEthereum1.CurveSwap)
|
|
41
|
+
);
|
|
42
|
+
curveSwap.dx = (curveSwap.dx * newAmount) / oldAmount;
|
|
43
|
+
return abi.encode(curveSwap);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function newKyberDMM(
|
|
47
|
+
bytes memory data,
|
|
48
|
+
uint256 oldAmount,
|
|
49
|
+
uint256 newAmount
|
|
50
|
+
) internal pure returns (bytes memory) {
|
|
51
|
+
IExecutorHelperEthereum1.UniSwap memory kyberDMMSwap = abi.decode(
|
|
52
|
+
data,
|
|
53
|
+
(IExecutorHelperEthereum1.UniSwap)
|
|
54
|
+
);
|
|
55
|
+
kyberDMMSwap.collectAmount = (kyberDMMSwap.collectAmount * newAmount) / oldAmount;
|
|
56
|
+
return abi.encode(kyberDMMSwap);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function newUniV3ProMM(
|
|
60
|
+
bytes memory data,
|
|
61
|
+
uint256 oldAmount,
|
|
62
|
+
uint256 newAmount
|
|
63
|
+
) internal pure returns (bytes memory) {
|
|
64
|
+
IExecutorHelperEthereum1.UniSwapV3ProMM memory uniSwapV3ProMM = abi.decode(
|
|
65
|
+
data,
|
|
66
|
+
(IExecutorHelperEthereum1.UniSwapV3ProMM)
|
|
67
|
+
);
|
|
68
|
+
uniSwapV3ProMM.swapAmount = (uniSwapV3ProMM.swapAmount * newAmount) / oldAmount;
|
|
69
|
+
|
|
70
|
+
return abi.encode(uniSwapV3ProMM);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function newBalancerV2(
|
|
74
|
+
bytes memory data,
|
|
75
|
+
uint256 oldAmount,
|
|
76
|
+
uint256 newAmount
|
|
77
|
+
) internal pure returns (bytes memory) {
|
|
78
|
+
IExecutorHelperEthereum1.BalancerV2 memory balancerV2 = abi.decode(
|
|
79
|
+
data,
|
|
80
|
+
(IExecutorHelperEthereum1.BalancerV2)
|
|
81
|
+
);
|
|
82
|
+
balancerV2.amount = (balancerV2.amount * newAmount) / oldAmount;
|
|
83
|
+
return abi.encode(balancerV2);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function newDODO(
|
|
87
|
+
bytes memory data,
|
|
88
|
+
uint256 oldAmount,
|
|
89
|
+
uint256 newAmount
|
|
90
|
+
) internal pure returns (bytes memory) {
|
|
91
|
+
IExecutorHelperEthereum1.DODO memory dodo = abi.decode(
|
|
92
|
+
data,
|
|
93
|
+
(IExecutorHelperEthereum1.DODO)
|
|
94
|
+
);
|
|
95
|
+
dodo.amount = (dodo.amount * newAmount) / oldAmount;
|
|
96
|
+
return abi.encode(dodo);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function newSynthetix(
|
|
100
|
+
bytes memory data,
|
|
101
|
+
uint256 oldAmount,
|
|
102
|
+
uint256 newAmount
|
|
103
|
+
) internal pure returns (bytes memory) {
|
|
104
|
+
IExecutorHelperEthereum1.Synthetix memory synthetix = abi.decode(
|
|
105
|
+
data,
|
|
106
|
+
(IExecutorHelperEthereum1.Synthetix)
|
|
107
|
+
);
|
|
108
|
+
synthetix.sourceAmount = (synthetix.sourceAmount * newAmount) / oldAmount;
|
|
109
|
+
return abi.encode(synthetix);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function newWrappedstETHSwap(
|
|
113
|
+
bytes memory data,
|
|
114
|
+
uint256 oldAmount,
|
|
115
|
+
uint256 newAmount
|
|
116
|
+
) internal pure returns (bytes memory) {
|
|
117
|
+
IExecutorHelperEthereum1.WSTETH memory wstEthData = abi.decode(
|
|
118
|
+
data,
|
|
119
|
+
(IExecutorHelperEthereum1.WSTETH)
|
|
120
|
+
);
|
|
121
|
+
wstEthData.amount = (wstEthData.amount * newAmount) / oldAmount;
|
|
122
|
+
return abi.encode(wstEthData);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function newPSM(
|
|
126
|
+
bytes memory data,
|
|
127
|
+
uint256 oldAmount,
|
|
128
|
+
uint256 newAmount
|
|
129
|
+
) internal pure returns (bytes memory) {
|
|
130
|
+
IExecutorHelperEthereum1.PSM memory psm = abi.decode(data, (IExecutorHelperEthereum1.PSM));
|
|
131
|
+
psm.amountIn = (psm.amountIn * newAmount) / oldAmount;
|
|
132
|
+
return abi.encode(psm);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.6.12;
|
|
4
|
+
|
|
5
|
+
interface IAggregationExecutor {
|
|
6
|
+
function callBytes(bytes calldata data) external payable; // 0xd9c45357
|
|
7
|
+
|
|
8
|
+
// callbytes per swap sequence
|
|
9
|
+
function swapSingleSequence(bytes calldata data) external;
|
|
10
|
+
|
|
11
|
+
function finalTransactionProcessing(
|
|
12
|
+
address tokenIn,
|
|
13
|
+
address tokenOut,
|
|
14
|
+
address to,
|
|
15
|
+
bytes calldata destTokenFeeData
|
|
16
|
+
) external;
|
|
17
|
+
}
|