@paraswap/dex-lib 3.8.38 → 3.8.39-1701-1507-1721
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/abi/USDM.json +807 -0
- package/build/abi/bebop/BebopSettlement.abi.json +2137 -0
- package/build/abi/wUSDM.json +757 -0
- package/build/config.js +16 -9
- package/build/config.js.map +1 -1
- package/build/dex/aave-v2/aave-v2.d.ts +1 -0
- package/build/dex/aave-v2/aave-v2.js +1 -0
- package/build/dex/aave-v2/aave-v2.js.map +1 -1
- package/build/dex/aave-v3/aave-v3.d.ts +1 -0
- package/build/dex/aave-v3/aave-v3.js +1 -0
- package/build/dex/aave-v3/aave-v3.js.map +1 -1
- package/build/dex/aave-v3-stata/aave-v3-stata.d.ts +1 -0
- package/build/dex/aave-v3-stata/aave-v3-stata.js +1 -0
- package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -1
- package/build/dex/bancor/bancor.d.ts +1 -0
- package/build/dex/bancor/bancor.js +1 -0
- package/build/dex/bancor/bancor.js.map +1 -1
- package/build/dex/bebop/bebop.d.ts +55 -0
- package/build/dex/bebop/bebop.js +524 -0
- package/build/dex/bebop/bebop.js.map +1 -0
- package/build/dex/bebop/config.d.ts +3 -0
- package/build/dex/bebop/config.js +38 -0
- package/build/dex/bebop/config.js.map +1 -0
- package/build/dex/bebop/constants.d.ts +9 -0
- package/build/dex/bebop/constants.js +13 -0
- package/build/dex/bebop/constants.js.map +1 -0
- package/build/dex/bebop/rate-fetcher.d.ts +22 -0
- package/build/dex/bebop/rate-fetcher.js +80 -0
- package/build/dex/bebop/rate-fetcher.js.map +1 -0
- package/build/dex/bebop/types.d.ts +76 -0
- package/build/dex/bebop/types.js +3 -0
- package/build/dex/bebop/types.js.map +1 -0
- package/build/dex/bebop/validators.d.ts +4 -0
- package/build/dex/bebop/validators.js +42 -0
- package/build/dex/bebop/validators.js.map +1 -0
- package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
- package/build/dex/bebop/websocket-fetcher.js +87 -0
- package/build/dex/bebop/websocket-fetcher.js.map +1 -0
- package/build/dex/compound/compound.d.ts +1 -0
- package/build/dex/compound/compound.js +1 -0
- package/build/dex/compound/compound.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.d.ts +1 -0
- package/build/dex/curve-v1/curve-v1.js +1 -0
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/dodo-v1/dodo-v1.d.ts +1 -0
- package/build/dex/dodo-v1/dodo-v1.js +1 -0
- package/build/dex/dodo-v1/dodo-v1.js.map +1 -1
- package/build/dex/hashflow/hashflow.d.ts +6 -4
- package/build/dex/hashflow/hashflow.js +183 -29
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/hashflow/types.d.ts +2 -0
- package/build/dex/hashflow/types.js.map +1 -1
- package/build/dex/idex.d.ts +8 -1
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/jarvis-v6/jarvis-v6.d.ts +1 -0
- package/build/dex/jarvis-v6/jarvis-v6.js +1 -0
- package/build/dex/jarvis-v6/jarvis-v6.js.map +1 -1
- package/build/dex/lido/lido.d.ts +1 -0
- package/build/dex/lido/lido.js +1 -0
- package/build/dex/lido/lido.js.map +1 -1
- package/build/dex/lite-psm/lite-psm.d.ts +1 -0
- package/build/dex/lite-psm/lite-psm.js +1 -0
- package/build/dex/lite-psm/lite-psm.js.map +1 -1
- package/build/dex/maker-psm/maker-psm.d.ts +1 -0
- package/build/dex/maker-psm/maker-psm.js +1 -0
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/nerve/nerve.d.ts +1 -0
- package/build/dex/nerve/nerve.js +1 -0
- package/build/dex/nerve/nerve.js.map +1 -1
- package/build/dex/polygon-migrator/polygon-migrator.d.ts +1 -0
- package/build/dex/polygon-migrator/polygon-migrator.js +1 -0
- package/build/dex/polygon-migrator/polygon-migrator.js.map +1 -1
- package/build/dex/simple-exchange.d.ts +3 -1
- package/build/dex/simple-exchange.js +1 -0
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/smoothy/smoothy.d.ts +1 -0
- package/build/dex/smoothy/smoothy.js +1 -0
- package/build/dex/smoothy/smoothy.js.map +1 -1
- package/build/dex/spark/config.js +8 -0
- package/build/dex/spark/config.js.map +1 -1
- package/build/dex/spark/spark.d.ts +4 -1
- package/build/dex/spark/spark.js +20 -15
- package/build/dex/spark/spark.js.map +1 -1
- package/build/dex/spark/types.d.ts +9 -0
- package/build/dex/spark/types.js +8 -1
- package/build/dex/spark/types.js.map +1 -1
- package/build/dex/stable-pool/stable-pool.d.ts +3 -2
- package/build/dex/stable-pool/stable-pool.js +2 -1
- package/build/dex/stable-pool/stable-pool.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.d.ts +5 -3
- package/build/dex/swaap-v2/swaap-v2.js +112 -21
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/build/dex/swaap-v2/types.d.ts +2 -0
- package/build/dex/swaap-v2/types.js.map +1 -1
- package/build/dex/trader-joe-v2.1/base.d.ts +1 -0
- package/build/dex/trader-joe-v2.1/base.js +1 -0
- package/build/dex/trader-joe-v2.1/base.js.map +1 -1
- package/build/dex/weth/weth.d.ts +1 -0
- package/build/dex/weth/weth.js +1 -0
- package/build/dex/weth/weth.js.map +1 -1
- package/build/dex/woo-fi-v2/woo-fi-v2-pool.d.ts +2 -2
- package/build/dex/woo-fi-v2/woo-fi-v2-pool.js +30 -9
- package/build/dex/woo-fi-v2/woo-fi-v2-pool.js.map +1 -1
- package/build/dex/woo-fi-v2/woo-fi-v2.js +1 -1
- package/build/dex/woo-fi-v2/woo-fi-v2.js.map +1 -1
- package/build/dex/wusdm/config.d.ts +3 -0
- package/build/dex/wusdm/config.js +29 -0
- package/build/dex/wusdm/config.js.map +1 -0
- package/build/dex/wusdm/types.d.ts +10 -0
- package/build/dex/wusdm/types.js +3 -0
- package/build/dex/wusdm/types.js.map +1 -0
- package/build/dex/wusdm/wusdm.d.ts +39 -0
- package/build/dex/wusdm/wusdm.js +212 -0
- package/build/dex/wusdm/wusdm.js.map +1 -0
- package/build/executor/Executor01BytecodeBuilder.d.ts +3 -3
- package/build/executor/Executor01BytecodeBuilder.js +65 -16
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.d.ts +4 -4
- package/build/executor/Executor02BytecodeBuilder.js +65 -18
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.d.ts +2 -2
- package/build/executor/Executor03BytecodeBuilder.js +52 -8
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorBytecodeBuilder.d.ts +5 -4
- package/build/executor/ExecutorBytecodeBuilder.js +4 -4
- package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorDetector.js +2 -1
- package/build/executor/ExecutorDetector.js.map +1 -1
- package/build/executor/types.d.ts +1 -0
- package/build/executor/types.js +1 -0
- package/build/executor/types.js.map +1 -1
- package/build/generic-swap-transaction-builder.d.ts +2 -0
- package/build/generic-swap-transaction-builder.js +49 -11
- package/build/generic-swap-transaction-builder.js.map +1 -1
- package/build/implementations/local-paraswap-sdk.js +3 -1
- package/build/implementations/local-paraswap-sdk.js.map +1 -1
- package/build/lib/fetcher/wsFetcher.d.ts +35 -0
- package/build/lib/fetcher/wsFetcher.js +87 -0
- package/build/lib/fetcher/wsFetcher.js.map +1 -0
- package/build/router/simpleswap.js +51 -13
- package/build/router/simpleswap.js.map +1 -1
- package/build/types.d.ts +2 -0
- package/package.json +4 -2
- package/src/abi/bebop/BebopSettlement.abi.json +2137 -0
- package/src/config.ts +17 -9
- package/src/dex/aave-v2/aave-v2.ts +2 -0
- package/src/dex/aave-v3/aave-v3.ts +2 -0
- package/src/dex/aave-v3-stata/aave-v3-stata.ts +2 -0
- package/src/dex/bancor/bancor.ts +2 -0
- package/src/dex/bebop/bebop-e2e.test.ts +195 -0
- package/src/dex/bebop/bebop-integration.test.ts +170 -0
- package/src/dex/bebop/bebop.ts +732 -0
- package/src/dex/bebop/config.ts +37 -0
- package/src/dex/bebop/constants.ts +9 -0
- package/src/dex/bebop/rate-fetcher.ts +138 -0
- package/src/dex/bebop/types.ts +81 -0
- package/src/dex/bebop/validators.ts +43 -0
- package/src/dex/compound/compound.ts +2 -0
- package/src/dex/curve-v1/curve-v1.ts +2 -0
- package/src/dex/dodo-v1/dodo-v1.ts +2 -0
- package/src/dex/hashflow/hashflow-e2e.test.ts +281 -28
- package/src/dex/hashflow/hashflow.ts +285 -54
- package/src/dex/hashflow/types.ts +2 -0
- package/src/dex/idex.ts +18 -1
- package/src/dex/index.ts +2 -0
- package/src/dex/jarvis-v6/jarvis-v6.ts +2 -0
- package/src/dex/lido/lido.ts +2 -0
- package/src/dex/lite-psm/lite-psm.ts +2 -0
- package/src/dex/maker-psm/maker-psm.ts +2 -0
- package/src/dex/nerve/nerve.ts +2 -0
- package/src/dex/polygon-migrator/polygon-migrator.ts +2 -0
- package/src/dex/simple-exchange.ts +4 -2
- package/src/dex/smoothy/smoothy.ts +2 -0
- package/src/dex/spark/config.ts +8 -1
- package/src/dex/spark/spark.ts +27 -18
- package/src/dex/spark/types.ts +10 -0
- package/src/dex/stable-pool/stable-pool.ts +4 -1
- package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +13 -13
- package/src/dex/swaap-v2/swaap-v2.ts +217 -32
- package/src/dex/swaap-v2/types.ts +2 -0
- package/src/dex/trader-joe-v2.1/base.ts +2 -0
- package/src/dex/weth/weth.ts +2 -0
- package/src/dex/woo-fi-v2/woo-fi-v2-pool.ts +58 -27
- package/src/dex/woo-fi-v2/woo-fi-v2.ts +1 -2
- package/src/executor/Executor01BytecodeBuilder.ts +105 -11
- package/src/executor/Executor02BytecodeBuilder.ts +95 -8
- package/src/executor/Executor03BytecodeBuilder.ts +89 -5
- package/src/executor/ExecutorBytecodeBuilder.ts +6 -0
- package/src/executor/ExecutorDetector.ts +2 -1
- package/src/executor/types.ts +1 -0
- package/src/generic-swap-transaction-builder.ts +96 -24
- package/src/implementations/local-paraswap-sdk.ts +21 -10
- package/src/lib/fetcher/wsFetcher.ts +126 -0
- package/src/router/simpleswap.ts +94 -18
- package/src/types.ts +2 -0
- package/tests/constants-e2e.ts +2 -2
- package/tests/utils-e2e.ts +308 -2
|
@@ -26,8 +26,7 @@ export class WooFiV2PollingPool extends StatefulRpcPoller<
|
|
|
26
26
|
poolIdentifier: string,
|
|
27
27
|
dexHelper: IDexHelper,
|
|
28
28
|
protected config: DexParams,
|
|
29
|
-
|
|
30
|
-
protected tokens: Token[],
|
|
29
|
+
protected baseTokens: Token[],
|
|
31
30
|
) {
|
|
32
31
|
const callbacks = pollingManagerCbExtractor(
|
|
33
32
|
StatePollingManager.getInstance(dexHelper),
|
|
@@ -50,37 +49,66 @@ export class WooFiV2PollingPool extends StatefulRpcPoller<
|
|
|
50
49
|
decodeFunction: uint256ToBigInt,
|
|
51
50
|
},
|
|
52
51
|
] as MultiCallParams<MulticallResultOutputs>[]
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
)
|
|
53
|
+
.concat([
|
|
54
|
+
{
|
|
55
|
+
target: this.config.wooPPV2Address,
|
|
56
|
+
callData: ifaces.PPV2.encodeFunctionData('tokenInfos', [
|
|
57
|
+
this.config.quoteToken.address,
|
|
58
|
+
]),
|
|
59
|
+
decodeFunction: tokenInfoDecoder,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
target: this.config.wooPPV2Address,
|
|
63
|
+
callData: ifaces.PPV2.encodeFunctionData('decimalInfo', [
|
|
64
|
+
this.config.quoteToken.address,
|
|
65
|
+
]),
|
|
66
|
+
decodeFunction: decimalInfoDecoder,
|
|
67
|
+
},
|
|
68
|
+
])
|
|
69
|
+
.concat(
|
|
70
|
+
this.baseTokens
|
|
71
|
+
.map(t => [
|
|
72
|
+
{
|
|
73
|
+
target: this.config.wooPPV2Address,
|
|
74
|
+
callData: ifaces.PPV2.encodeFunctionData('tokenInfos', [
|
|
75
|
+
t.address,
|
|
76
|
+
]),
|
|
77
|
+
decodeFunction: tokenInfoDecoder,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
target: this.config.wooPPV2Address,
|
|
81
|
+
callData: ifaces.PPV2.encodeFunctionData('decimalInfo', [
|
|
82
|
+
t.address,
|
|
83
|
+
]),
|
|
84
|
+
decodeFunction: decimalInfoDecoder,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
target: this.config.wooOracleV2Address,
|
|
88
|
+
callData: ifaces.oracleV2.encodeFunctionData('state', [
|
|
89
|
+
t.address,
|
|
90
|
+
]),
|
|
91
|
+
decodeFunction: stateDecoder,
|
|
92
|
+
},
|
|
93
|
+
])
|
|
94
|
+
.flat(),
|
|
95
|
+
);
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
protected _parseStateFromMultiResults(
|
|
79
99
|
multiOutputs: MulticallResultOutputs[],
|
|
80
100
|
): PoolState {
|
|
81
|
-
const [
|
|
101
|
+
const [
|
|
102
|
+
isPaused,
|
|
103
|
+
oracleTimestamp,
|
|
104
|
+
quoteTokenInfo,
|
|
105
|
+
quoteTokenDecimals,
|
|
106
|
+
...remained
|
|
107
|
+
] = multiOutputs as [
|
|
82
108
|
boolean,
|
|
83
109
|
bigint,
|
|
110
|
+
TokenInfo,
|
|
111
|
+
DecimalInfo,
|
|
84
112
|
...MulticallResultOutputs[],
|
|
85
113
|
];
|
|
86
114
|
|
|
@@ -88,13 +116,16 @@ export class WooFiV2PollingPool extends StatefulRpcPoller<
|
|
|
88
116
|
const decimals: Record<string, DecimalInfo> = {};
|
|
89
117
|
const tokenStates: Record<string, TokenState> = {};
|
|
90
118
|
|
|
119
|
+
tokenInfos[this.config.quoteToken.address] = quoteTokenInfo;
|
|
120
|
+
decimals[this.config.quoteToken.address] = quoteTokenDecimals;
|
|
121
|
+
|
|
91
122
|
_.chunk(remained, 3).forEach((chunk, i) => {
|
|
92
123
|
const [tokenInfo, decimalInfo, tokenState] = chunk as [
|
|
93
124
|
TokenInfo,
|
|
94
125
|
DecimalInfo,
|
|
95
126
|
TokenState,
|
|
96
127
|
];
|
|
97
|
-
const token = this.
|
|
128
|
+
const token = this.baseTokens[i];
|
|
98
129
|
|
|
99
130
|
tokenInfos[token.address] = tokenInfo;
|
|
100
131
|
decimals[token.address] = decimalInfo;
|
|
@@ -27,7 +27,6 @@ import { ethers } from 'ethers';
|
|
|
27
27
|
import { addressDecode } from '../../lib/decoders';
|
|
28
28
|
import { ifaces } from './utils';
|
|
29
29
|
import { StatePollingManager } from '../../lib/stateful-rpc-poller/state-polling-manager';
|
|
30
|
-
import { solidityPack } from 'ethers/lib/utils';
|
|
31
30
|
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
32
31
|
|
|
33
32
|
export class WooFiV2 extends SimpleExchange implements IDex<WooFiV2Data> {
|
|
@@ -521,7 +520,7 @@ export class WooFiV2 extends SimpleExchange implements IDex<WooFiV2Data> {
|
|
|
521
520
|
this.getIdentifier(),
|
|
522
521
|
this.dexHelper,
|
|
523
522
|
this.config,
|
|
524
|
-
|
|
523
|
+
this.baseTokens,
|
|
525
524
|
);
|
|
526
525
|
|
|
527
526
|
this.pollingManager.initializeAllPendingPools();
|
|
@@ -47,16 +47,22 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
47
47
|
swapExchangeIndex: number,
|
|
48
48
|
exchangeParamIndex: number,
|
|
49
49
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
50
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
50
51
|
): { dexFlag: Flag; approveFlag: Flag } {
|
|
51
52
|
const { srcToken, destToken } =
|
|
52
53
|
priceRoute.bestRoute[routeIndex].swaps[swapIndex];
|
|
53
54
|
const isEthSrc = isETHAddress(srcToken);
|
|
54
55
|
const isEthDest = isETHAddress(destToken);
|
|
56
|
+
const wethAddr =
|
|
57
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
|
|
58
|
+
const isWethSrc = srcToken.toLowerCase() === wethAddr;
|
|
59
|
+
const isWethDest = destToken.toLowerCase() === wethAddr;
|
|
55
60
|
|
|
56
61
|
const exchangeParam = exchangeParams[exchangeParamIndex];
|
|
57
62
|
const {
|
|
58
63
|
dexFuncHasRecipient,
|
|
59
64
|
needWrapNative,
|
|
65
|
+
needUnwrapWeth,
|
|
60
66
|
specialDexFlag,
|
|
61
67
|
specialDexSupportsInsertFromAmount,
|
|
62
68
|
swappedAmountNotPresentInExchangeData,
|
|
@@ -66,6 +72,17 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
66
72
|
const needWrap = needWrapNative && isEthSrc && maybeWethCallData?.deposit;
|
|
67
73
|
const needUnwrap =
|
|
68
74
|
needWrapNative && isEthDest && maybeWethCallData?.withdraw;
|
|
75
|
+
|
|
76
|
+
const needUnwrapForWethSrc =
|
|
77
|
+
needUnwrapWeth &&
|
|
78
|
+
isWethSrc &&
|
|
79
|
+
maybeWethCallDataForNeedUnwrapWeth?.withdraw;
|
|
80
|
+
|
|
81
|
+
const needWrapForWethDest =
|
|
82
|
+
needUnwrapWeth &&
|
|
83
|
+
isWethDest &&
|
|
84
|
+
maybeWethCallDataForNeedUnwrapWeth?.deposit;
|
|
85
|
+
|
|
69
86
|
const isSpecialDex =
|
|
70
87
|
specialDexFlag !== undefined && specialDexFlag !== SpecialDex.DEFAULT;
|
|
71
88
|
|
|
@@ -82,7 +99,13 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
82
99
|
if (isEthSrc && !needWrap) {
|
|
83
100
|
dexFlag =
|
|
84
101
|
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 5
|
|
85
|
-
} else if (
|
|
102
|
+
} else if (isWethSrc && needUnwrapForWethSrc) {
|
|
103
|
+
dexFlag =
|
|
104
|
+
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP; // 9
|
|
105
|
+
} else if (
|
|
106
|
+
(isEthDest && !needUnwrap) ||
|
|
107
|
+
(isWethDest && needWrapForWethDest)
|
|
108
|
+
) {
|
|
86
109
|
dexFlag = forcePreventInsertFromAmount
|
|
87
110
|
? Flag.DONT_INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP
|
|
88
111
|
: Flag.INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP; // 4 or 7
|
|
@@ -127,6 +150,7 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
127
150
|
swapExchangeIndex: number,
|
|
128
151
|
exchangeParamIndex: number,
|
|
129
152
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
153
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
130
154
|
): { dexFlag: Flag; approveFlag: Flag } {
|
|
131
155
|
// same as for Executor02 multi flags, except forceBalanceOfCheck
|
|
132
156
|
const swap = priceRoute.bestRoute[routeIndex].swaps[swapIndex];
|
|
@@ -135,6 +159,7 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
135
159
|
const {
|
|
136
160
|
dexFuncHasRecipient,
|
|
137
161
|
needWrapNative,
|
|
162
|
+
needUnwrapWeth,
|
|
138
163
|
specialDexFlag,
|
|
139
164
|
specialDexSupportsInsertFromAmount,
|
|
140
165
|
swappedAmountNotPresentInExchangeData,
|
|
@@ -146,6 +171,10 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
146
171
|
swapIndex === priceRoute.bestRoute[routeIndex].swaps.length - 1;
|
|
147
172
|
const isEthSrc = isETHAddress(srcToken);
|
|
148
173
|
const isEthDest = isETHAddress(destToken);
|
|
174
|
+
const wethAddr =
|
|
175
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
|
|
176
|
+
const isWethSrc = srcToken.toLowerCase() === wethAddr;
|
|
177
|
+
const isWethDest = destToken.toLowerCase() === wethAddr;
|
|
149
178
|
|
|
150
179
|
const isSpecialDex =
|
|
151
180
|
specialDexFlag !== undefined && specialDexFlag !== SpecialDex.DEFAULT;
|
|
@@ -157,14 +186,27 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
157
186
|
const needUnwrap =
|
|
158
187
|
needWrapNative && isEthDest && maybeWethCallData?.withdraw;
|
|
159
188
|
|
|
189
|
+
const needUnwrapForWethSrc =
|
|
190
|
+
needUnwrapWeth &&
|
|
191
|
+
isWethSrc &&
|
|
192
|
+
maybeWethCallDataForNeedUnwrapWeth?.withdraw;
|
|
193
|
+
|
|
194
|
+
const needWrapForWethDest =
|
|
195
|
+
needUnwrapWeth &&
|
|
196
|
+
isWethDest &&
|
|
197
|
+
maybeWethCallDataForNeedUnwrapWeth?.deposit;
|
|
198
|
+
|
|
160
199
|
const forceBalanceOfCheck = isLastSwap
|
|
161
|
-
? !dexFuncHasRecipient || needUnwrap
|
|
200
|
+
? !dexFuncHasRecipient || needUnwrap || needUnwrapForWethSrc
|
|
162
201
|
: true;
|
|
163
202
|
|
|
164
|
-
const needSendEth =
|
|
165
|
-
|
|
203
|
+
const needSendEth =
|
|
204
|
+
(isEthSrc && !needWrapNative) || (isWethSrc && needUnwrapForWethSrc);
|
|
205
|
+
const needCheckEthBalance =
|
|
206
|
+
(isEthDest && !needWrapNative) || (isWethDest && needWrapForWethDest);
|
|
166
207
|
|
|
167
|
-
const needCheckSrcTokenBalanceOf =
|
|
208
|
+
const needCheckSrcTokenBalanceOf =
|
|
209
|
+
(needUnwrap && !isLastSwap) || needWrapForWethDest;
|
|
168
210
|
|
|
169
211
|
let dexFlag: Flag;
|
|
170
212
|
let approveFlag =
|
|
@@ -208,7 +250,7 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
208
250
|
// Need to check balance, some dexes don't have 1:1 ETH -> custom_ETH rate
|
|
209
251
|
if (preSwapUnwrapCalldata) {
|
|
210
252
|
dexFlag =
|
|
211
|
-
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP;
|
|
253
|
+
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 5
|
|
212
254
|
}
|
|
213
255
|
|
|
214
256
|
return {
|
|
@@ -220,8 +262,14 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
220
262
|
protected buildSingleSwapCallData(
|
|
221
263
|
params: SingleSwapCallDataParams<Executor01SingleSwapCallDataParams>,
|
|
222
264
|
): string {
|
|
223
|
-
const {
|
|
224
|
-
|
|
265
|
+
const {
|
|
266
|
+
priceRoute,
|
|
267
|
+
index,
|
|
268
|
+
exchangeParams,
|
|
269
|
+
flags,
|
|
270
|
+
maybeWethCallData,
|
|
271
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
272
|
+
} = params;
|
|
225
273
|
|
|
226
274
|
let swapCallData = '';
|
|
227
275
|
const swap = priceRoute.bestRoute[0].swaps[index];
|
|
@@ -279,7 +327,47 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
279
327
|
swapCallData = hexConcat([approveCallData, swapCallData]);
|
|
280
328
|
}
|
|
281
329
|
|
|
282
|
-
if (curExchangeParam.
|
|
330
|
+
if (curExchangeParam.needUnwrapWeth && maybeWethCallDataForNeedUnwrapWeth) {
|
|
331
|
+
if (
|
|
332
|
+
maybeWethCallDataForNeedUnwrapWeth.withdraw &&
|
|
333
|
+
swap.srcToken.toLowerCase() ===
|
|
334
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase()
|
|
335
|
+
) {
|
|
336
|
+
const prevExchangeParam = exchangeParams[index - 1];
|
|
337
|
+
|
|
338
|
+
if (
|
|
339
|
+
!prevExchangeParam ||
|
|
340
|
+
(prevExchangeParam && !prevExchangeParam.needUnwrapWeth)
|
|
341
|
+
) {
|
|
342
|
+
const withdrawCallData = this.buildUnwrapEthCallData(
|
|
343
|
+
this.getWETHAddress(curExchangeParam),
|
|
344
|
+
maybeWethCallDataForNeedUnwrapWeth.withdraw.calldata,
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
swapCallData = hexConcat([withdrawCallData, swapCallData]);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (
|
|
352
|
+
maybeWethCallDataForNeedUnwrapWeth.deposit &&
|
|
353
|
+
swap.destToken.toLowerCase() ===
|
|
354
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase()
|
|
355
|
+
) {
|
|
356
|
+
const nextExchangeParam = exchangeParams[index + 1];
|
|
357
|
+
|
|
358
|
+
if (
|
|
359
|
+
!nextExchangeParam ||
|
|
360
|
+
(nextExchangeParam && !nextExchangeParam.needUnwrapWeth)
|
|
361
|
+
) {
|
|
362
|
+
const depositCallData = this.buildWrapEthCallData(
|
|
363
|
+
this.getWETHAddress(curExchangeParam),
|
|
364
|
+
maybeWethCallDataForNeedUnwrapWeth.deposit.calldata,
|
|
365
|
+
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP,
|
|
366
|
+
);
|
|
367
|
+
swapCallData = hexConcat([swapCallData, depositCallData]);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
} else if (curExchangeParam.needWrapNative && maybeWethCallData) {
|
|
283
371
|
if (maybeWethCallData.deposit && isETHAddress(swap.srcToken)) {
|
|
284
372
|
const prevExchangeParam = exchangeParams[index - 1];
|
|
285
373
|
|
|
@@ -410,11 +498,13 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
410
498
|
exchangeParams: DexExchangeBuildParam[],
|
|
411
499
|
sender: string,
|
|
412
500
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
501
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
413
502
|
): string {
|
|
414
503
|
const flags = this.buildFlags(
|
|
415
504
|
priceRoute,
|
|
416
505
|
exchangeParams,
|
|
417
506
|
maybeWethCallData,
|
|
507
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
418
508
|
);
|
|
419
509
|
|
|
420
510
|
let swapsCalldata = exchangeParams.reduce<string>(
|
|
@@ -428,14 +518,18 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
428
518
|
flags,
|
|
429
519
|
sender,
|
|
430
520
|
maybeWethCallData,
|
|
521
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
431
522
|
}),
|
|
432
523
|
]),
|
|
433
524
|
'0x',
|
|
434
525
|
);
|
|
435
526
|
|
|
436
527
|
if (
|
|
437
|
-
!exchangeParams[exchangeParams.length - 1].dexFuncHasRecipient &&
|
|
438
|
-
|
|
528
|
+
(!exchangeParams[exchangeParams.length - 1].dexFuncHasRecipient &&
|
|
529
|
+
!isETHAddress(priceRoute.destToken)) ||
|
|
530
|
+
(maybeWethCallDataForNeedUnwrapWeth?.deposit &&
|
|
531
|
+
priceRoute.destToken.toLowerCase() ===
|
|
532
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase())
|
|
439
533
|
) {
|
|
440
534
|
const transferCallData = this.buildTransferCallData(
|
|
441
535
|
this.erc20Interface.encodeFunctionData('transfer', [
|
|
@@ -70,16 +70,22 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
70
70
|
swapExchangeIndex: number,
|
|
71
71
|
exchangeParamIndex: number,
|
|
72
72
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
73
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
73
74
|
): { dexFlag: Flag; approveFlag: Flag } {
|
|
74
75
|
const { srcToken, destToken } =
|
|
75
76
|
priceRoute.bestRoute[routeIndex].swaps[swapIndex];
|
|
76
77
|
const isEthSrc = isETHAddress(srcToken);
|
|
77
78
|
const isEthDest = isETHAddress(destToken);
|
|
79
|
+
const wethAddr =
|
|
80
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
|
|
81
|
+
const isWethSrc = srcToken.toLowerCase() === wethAddr;
|
|
82
|
+
const isWethDest = destToken.toLowerCase() === wethAddr;
|
|
78
83
|
|
|
79
84
|
const exchangeParam = exchangeParams[exchangeParamIndex];
|
|
80
85
|
const {
|
|
81
86
|
dexFuncHasRecipient,
|
|
82
87
|
needWrapNative,
|
|
88
|
+
needUnwrapWeth,
|
|
83
89
|
specialDexFlag,
|
|
84
90
|
specialDexSupportsInsertFromAmount,
|
|
85
91
|
swappedAmountNotPresentInExchangeData,
|
|
@@ -92,6 +98,16 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
92
98
|
const isSpecialDex =
|
|
93
99
|
specialDexFlag !== undefined && specialDexFlag !== SpecialDex.DEFAULT;
|
|
94
100
|
|
|
101
|
+
const needUnwrapForWethSrc =
|
|
102
|
+
needUnwrapWeth &&
|
|
103
|
+
isWethSrc &&
|
|
104
|
+
maybeWethCallDataForNeedUnwrapWeth?.withdraw;
|
|
105
|
+
|
|
106
|
+
const needWrapForWethDest =
|
|
107
|
+
needUnwrapWeth &&
|
|
108
|
+
isWethDest &&
|
|
109
|
+
maybeWethCallDataForNeedUnwrapWeth?.deposit;
|
|
110
|
+
|
|
95
111
|
const forcePreventInsertFromAmount =
|
|
96
112
|
swappedAmountNotPresentInExchangeData ||
|
|
97
113
|
(isSpecialDex && !specialDexSupportsInsertFromAmount);
|
|
@@ -105,7 +121,13 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
105
121
|
if (isEthSrc && !needWrap) {
|
|
106
122
|
dexFlag =
|
|
107
123
|
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 5
|
|
108
|
-
} else if (
|
|
124
|
+
} else if (isWethSrc && needUnwrapForWethSrc) {
|
|
125
|
+
dexFlag =
|
|
126
|
+
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP; // 9
|
|
127
|
+
} else if (
|
|
128
|
+
(isEthDest && !needUnwrap) ||
|
|
129
|
+
(isWethDest && needWrapForWethDest)
|
|
130
|
+
) {
|
|
109
131
|
dexFlag = forcePreventInsertFromAmount
|
|
110
132
|
? Flag.DONT_INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP
|
|
111
133
|
: Flag.INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP; // 4 or 7
|
|
@@ -149,6 +171,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
149
171
|
swapExchangeIndex: number,
|
|
150
172
|
exchangeParamIndex: number,
|
|
151
173
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
174
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
152
175
|
): { dexFlag: Flag; approveFlag: Flag } {
|
|
153
176
|
const route = priceRoute.bestRoute[routeIndex];
|
|
154
177
|
const swap = route.swaps[swapIndex];
|
|
@@ -169,6 +192,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
169
192
|
const {
|
|
170
193
|
dexFuncHasRecipient,
|
|
171
194
|
needWrapNative,
|
|
195
|
+
needUnwrapWeth,
|
|
172
196
|
specialDexFlag,
|
|
173
197
|
specialDexSupportsInsertFromAmount,
|
|
174
198
|
swappedAmountNotPresentInExchangeData,
|
|
@@ -179,9 +203,20 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
179
203
|
|
|
180
204
|
const isEthSrc = isETHAddress(srcToken);
|
|
181
205
|
const isEthDest = isETHAddress(destToken);
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
206
|
+
const wethAddr =
|
|
207
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
|
|
208
|
+
const isWethSrc = srcToken.toLowerCase() === wethAddr;
|
|
209
|
+
const isWethDest = destToken.toLowerCase() === wethAddr;
|
|
210
|
+
|
|
211
|
+
const needUnwrapForWethSrc =
|
|
212
|
+
needUnwrapWeth &&
|
|
213
|
+
isWethSrc &&
|
|
214
|
+
maybeWethCallDataForNeedUnwrapWeth?.withdraw;
|
|
215
|
+
|
|
216
|
+
const needWrapForWethDest =
|
|
217
|
+
needUnwrapWeth &&
|
|
218
|
+
isWethDest &&
|
|
219
|
+
maybeWethCallDataForNeedUnwrapWeth?.deposit;
|
|
185
220
|
|
|
186
221
|
const isSpecialDex =
|
|
187
222
|
specialDexFlag !== undefined && specialDexFlag !== SpecialDex.DEFAULT;
|
|
@@ -195,13 +230,16 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
195
230
|
isHorizontalSequence &&
|
|
196
231
|
!applyVerticalBranching &&
|
|
197
232
|
!isLastSwap) ||
|
|
198
|
-
!dexFuncHasRecipient
|
|
233
|
+
!dexFuncHasRecipient ||
|
|
234
|
+
(isWethDest && needWrapForWethDest);
|
|
199
235
|
|
|
200
236
|
const needUnwrap =
|
|
201
237
|
needWrapNative && isEthDest && maybeWethCallData?.withdraw;
|
|
202
238
|
|
|
203
|
-
const needSendEth =
|
|
204
|
-
|
|
239
|
+
const needSendEth =
|
|
240
|
+
(isEthSrc && !needWrapNative) || (isWethSrc && needUnwrapForWethSrc);
|
|
241
|
+
const needCheckEthBalance =
|
|
242
|
+
(isEthDest && !needWrapNative) || (isWethDest && needWrapForWethDest);
|
|
205
243
|
|
|
206
244
|
const needCheckSrcTokenBalanceOf =
|
|
207
245
|
(needUnwrap && !applyVerticalBranching) ||
|
|
@@ -529,6 +567,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
529
567
|
allowToAddWrap = true,
|
|
530
568
|
prevBranchWasWrapped = false,
|
|
531
569
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
570
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
532
571
|
addMultiSwapMetadata?: boolean,
|
|
533
572
|
applyVerticalBranching?: boolean,
|
|
534
573
|
): string {
|
|
@@ -542,6 +581,11 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
542
581
|
let exchangeParamIndex = 0;
|
|
543
582
|
let tempExchangeParamIndex = 0;
|
|
544
583
|
|
|
584
|
+
const wethAddr =
|
|
585
|
+
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
|
|
586
|
+
const isWethSrc = swap.srcToken.toLowerCase() === wethAddr;
|
|
587
|
+
const isWethDest = swap.destToken.toLowerCase() === wethAddr;
|
|
588
|
+
|
|
545
589
|
priceRoute.bestRoute.map(route =>
|
|
546
590
|
route.swaps.map(curSwap => {
|
|
547
591
|
curSwap.swapExchanges.map(async se => {
|
|
@@ -613,6 +657,42 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
613
657
|
swapExchangeCallData = hexConcat([approveCallData, swapExchangeCallData]);
|
|
614
658
|
}
|
|
615
659
|
|
|
660
|
+
if (curExchangeParam.needUnwrapWeth) {
|
|
661
|
+
if (isWethSrc && maybeWethCallDataForNeedUnwrapWeth?.withdraw) {
|
|
662
|
+
const withdrawCallData = this.buildUnwrapEthCallData(
|
|
663
|
+
this.getWETHAddress(curExchangeParam),
|
|
664
|
+
maybeWethCallDataForNeedUnwrapWeth.withdraw.calldata,
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
swapExchangeCallData = hexConcat([
|
|
668
|
+
withdrawCallData,
|
|
669
|
+
swapExchangeCallData,
|
|
670
|
+
]);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (isWethDest && maybeWethCallDataForNeedUnwrapWeth?.deposit) {
|
|
674
|
+
const depositCallData = this.buildWrapEthCallData(
|
|
675
|
+
this.getWETHAddress(curExchangeParam),
|
|
676
|
+
maybeWethCallDataForNeedUnwrapWeth.deposit.calldata,
|
|
677
|
+
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP,
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
const transferCallData = this.buildTransferCallData(
|
|
681
|
+
this.erc20Interface.encodeFunctionData('transfer', [
|
|
682
|
+
this.dexHelper.config.data.augustusV6Address,
|
|
683
|
+
priceRoute.destAmount,
|
|
684
|
+
]),
|
|
685
|
+
priceRoute.destToken,
|
|
686
|
+
);
|
|
687
|
+
|
|
688
|
+
swapExchangeCallData = hexConcat([
|
|
689
|
+
swapExchangeCallData,
|
|
690
|
+
depositCallData,
|
|
691
|
+
transferCallData,
|
|
692
|
+
]);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
616
696
|
if (curExchangeParam.needWrapNative) {
|
|
617
697
|
if (isETHAddress(swap.srcToken)) {
|
|
618
698
|
let approveWethCalldata = '0x';
|
|
@@ -1046,6 +1126,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1046
1126
|
swapIndex,
|
|
1047
1127
|
flags,
|
|
1048
1128
|
maybeWethCallData,
|
|
1129
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
1049
1130
|
wrapToSwapMap,
|
|
1050
1131
|
wrapToSwapExchangeMap,
|
|
1051
1132
|
swap,
|
|
@@ -1088,6 +1169,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1088
1169
|
!wrapToSwapMap[swapIndex - 1],
|
|
1089
1170
|
wrapToSwapMap[swapIndex - 1],
|
|
1090
1171
|
maybeWethCallData,
|
|
1172
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
1091
1173
|
swap.swapExchanges.length > 1,
|
|
1092
1174
|
applyVerticalBranching,
|
|
1093
1175
|
),
|
|
@@ -1144,6 +1226,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1144
1226
|
flags: { approves: Flag[]; dexes: Flag[]; wrap: Flag },
|
|
1145
1227
|
sender: string,
|
|
1146
1228
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
1229
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
1147
1230
|
): string {
|
|
1148
1231
|
const isMegaSwap = priceRoute.bestRoute.length > 1;
|
|
1149
1232
|
|
|
@@ -1165,6 +1248,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1165
1248
|
wrapToSwapExchangeMap: appendedWrapToSwapExchangeMap,
|
|
1166
1249
|
wrapToSwapMap: addedWrapToSwapMap,
|
|
1167
1250
|
maybeWethCallData,
|
|
1251
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
1168
1252
|
swap,
|
|
1169
1253
|
index: 0,
|
|
1170
1254
|
}),
|
|
@@ -1204,7 +1288,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1204
1288
|
return false;
|
|
1205
1289
|
}
|
|
1206
1290
|
|
|
1207
|
-
const res = priceRoute.bestRoute.every(
|
|
1291
|
+
const res = priceRoute.bestRoute.every(route => {
|
|
1208
1292
|
const firstSwap = route.swaps[0];
|
|
1209
1293
|
const eachDexOnSwapNeedsWrapNative = this.eachDexOnSwapNeedsWrapNative(
|
|
1210
1294
|
priceRoute,
|
|
@@ -1249,6 +1333,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1249
1333
|
exchangeParams: DexExchangeBuildParam[],
|
|
1250
1334
|
sender: string,
|
|
1251
1335
|
maybeWethCallData?: DepositWithdrawReturn,
|
|
1336
|
+
maybeWethCallDataForNeedUnwrapWeth?: DepositWithdrawReturn,
|
|
1252
1337
|
): string {
|
|
1253
1338
|
const isMegaSwap = priceRoute.bestRoute.length > 1;
|
|
1254
1339
|
const isMultiSwap = !isMegaSwap && priceRoute.bestRoute[0].swaps.length > 1;
|
|
@@ -1271,6 +1356,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1271
1356
|
priceRoute,
|
|
1272
1357
|
exchangeParams,
|
|
1273
1358
|
maybeWethCallData,
|
|
1359
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
1274
1360
|
);
|
|
1275
1361
|
|
|
1276
1362
|
let swapsCalldata = priceRoute.bestRoute.reduce<string>(
|
|
@@ -1285,6 +1371,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
1285
1371
|
flags,
|
|
1286
1372
|
sender,
|
|
1287
1373
|
maybeWethCallData,
|
|
1374
|
+
maybeWethCallDataForNeedUnwrapWeth,
|
|
1288
1375
|
),
|
|
1289
1376
|
]),
|
|
1290
1377
|
'0x',
|