@paraswap/dex-lib 3.4.2-balancer-v2-single-swap.0 → 3.4.2

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.
Files changed (110) hide show
  1. package/README.md +377 -377
  2. package/build/config.js +9 -5
  3. package/build/config.js.map +1 -1
  4. package/build/dex/algebra/algebra.js +25 -25
  5. package/build/dex/balancer-v1/balancer-v1.js +34 -34
  6. package/build/dex/balancer-v2/balancer-v2.d.ts +1 -1
  7. package/build/dex/balancer-v2/balancer-v2.js +65 -78
  8. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  9. package/build/dex/camelot/camelot.js +27 -27
  10. package/build/dex/kyberdmm/kyberdmm.js +27 -27
  11. package/build/dex/pancakeswap-v3/pancakeswap-v3.js +25 -25
  12. package/build/dex/solidly/solidly.js +27 -27
  13. package/build/dex/solidly-v3/solidly-v3.js +25 -25
  14. package/build/dex/swaap-v2/config.js +15 -0
  15. package/build/dex/swaap-v2/config.js.map +1 -1
  16. package/build/dex/uniswap-v2/uniswap-v2.js +26 -26
  17. package/build/dex/uniswap-v3/uniswap-v3.js +25 -25
  18. package/funding.json +5 -5
  19. package/package.json +1 -1
  20. package/src/config.ts +500 -496
  21. package/src/constants.ts +67 -67
  22. package/src/dex/aave-v2/aave-v2.ts +409 -409
  23. package/src/dex/aave-v3/aave-v3.ts +320 -320
  24. package/src/dex/algebra/algebra.ts +1180 -1180
  25. package/src/dex/angle-staked-stable/angle-staked-stable.ts +347 -347
  26. package/src/dex/augustus-rfq.ts +180 -180
  27. package/src/dex/bProtocol/bProtocol.ts +108 -108
  28. package/src/dex/balancer-v1/balancer-v1.ts +572 -572
  29. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +1699 -1699
  30. package/src/dex/balancer-v2/balancer-v2.ts +1669 -1701
  31. package/src/dex/bancor/bancor.ts +128 -128
  32. package/src/dex/camelot/camelot.ts +873 -873
  33. package/src/dex/compound/compound.ts +107 -107
  34. package/src/dex/curve-v1/config.ts +1179 -1179
  35. package/src/dex/curve-v1/curve-v1-e2e.test.ts +507 -507
  36. package/src/dex/curve-v1/curve-v1.ts +1315 -1315
  37. package/src/dex/curve-v1-factory/config.ts +1018 -1018
  38. package/src/dex/curve-v1-factory/curve-v1-factory.ts +1288 -1288
  39. package/src/dex/curve-v2/curve-v2.ts +440 -440
  40. package/src/dex/dexalot/dexalot.ts +1100 -1100
  41. package/src/dex/dodo-v1/dodo-v1.ts +132 -132
  42. package/src/dex/dodo-v2.ts +266 -266
  43. package/src/dex/etherfi.ts +239 -239
  44. package/src/dex/generic-rfq/generic-rfq.ts +431 -431
  45. package/src/dex/gmx/gmx.ts +321 -321
  46. package/src/dex/hashflow/hashflow.ts +1135 -1135
  47. package/src/dex/idex.ts +254 -254
  48. package/src/dex/index.ts +357 -357
  49. package/src/dex/jarvis-v6/jarvis-v6.ts +509 -509
  50. package/src/dex/jarvis.ts +262 -262
  51. package/src/dex/kyberdmm/kyberdmm.ts +649 -649
  52. package/src/dex/lido/lido.ts +110 -110
  53. package/src/dex/maker-psm/maker-psm.ts +592 -592
  54. package/src/dex/maverick-v1/maverick-v1.ts +537 -537
  55. package/src/dex/nerve/config.ts +635 -635
  56. package/src/dex/nerve/nerve-e2e.test.ts +731 -731
  57. package/src/dex/nerve/nerve-events.test.ts +911 -911
  58. package/src/dex/nerve/nerve.ts +467 -467
  59. package/src/dex/onebit/onebit.ts +113 -113
  60. package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +1150 -1150
  61. package/src/dex/paraswap-limit-orders/config.ts +60 -60
  62. package/src/dex/paraswap-limit-orders/paraswap-limit-orders-e2e.test.ts +137 -137
  63. package/src/dex/paraswap-limit-orders/paraswap-limit-orders-integration.test.ts +328 -328
  64. package/src/dex/paraswap-limit-orders/paraswap-limit-orders.ts +631 -631
  65. package/src/dex/polygon-migrator/polygon-migrator.ts +194 -194
  66. package/src/dex/quick-perps/quick-perps.ts +337 -337
  67. package/src/dex/quickswap/config.ts +16 -16
  68. package/src/dex/quickswap/quickswap-e2e.test.ts +384 -384
  69. package/src/dex/smoothy/smoothy.ts +110 -110
  70. package/src/dex/solidly/config.ts +225 -225
  71. package/src/dex/solidly/solidly-e2e.test.ts +1421 -1421
  72. package/src/dex/solidly/solidly-integration.test.ts +1753 -1753
  73. package/src/dex/solidly/solidly.ts +687 -687
  74. package/src/dex/solidly-v3/solidly-v3.ts +968 -968
  75. package/src/dex/spark/spark.ts +284 -284
  76. package/src/dex/stable-pool/stable-pool.ts +129 -129
  77. package/src/dex/swaap-v2/config.ts +15 -0
  78. package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +233 -17
  79. package/src/dex/swaap-v2/swaap-v2-integration.test.ts +1 -1
  80. package/src/dex/swaap-v2/swaap-v2.ts +1056 -1056
  81. package/src/dex/swell/swell.ts +312 -312
  82. package/src/dex/synthetix/synthetix.ts +420 -420
  83. package/src/dex/trader-joe-v2.1/trader-joe-v2.1.ts +180 -180
  84. package/src/dex/uniswap-v2/config.ts +637 -637
  85. package/src/dex/uniswap-v2/constants.ts +58 -58
  86. package/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts +1257 -1257
  87. package/src/dex/uniswap-v2/uniswap-v2-e2e-base.test.ts +42 -42
  88. package/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +1295 -1295
  89. package/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts +1834 -1834
  90. package/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts +871 -871
  91. package/src/dex/uniswap-v2/uniswap-v2.ts +1117 -1117
  92. package/src/dex/uniswap-v3/uniswap-v3.ts +1501 -1501
  93. package/src/dex/uniswap-v3.ts +242 -242
  94. package/src/dex/weth/config.ts +73 -73
  95. package/src/dex/weth/weth.ts +230 -230
  96. package/src/dex/wombat/wombat.ts +467 -467
  97. package/src/dex/woo-fi-v2/woo-fi-v2.ts +529 -529
  98. package/src/dex/wsteth/wsteth.ts +304 -304
  99. package/src/dex/zerox/index.ts +328 -328
  100. package/src/executor/Executor01BytecodeBuilder.ts +474 -474
  101. package/src/executor/Executor02BytecodeBuilder.ts +1392 -1392
  102. package/src/executor/ExecutorBytecodeBuilder.ts +390 -390
  103. package/src/executor/ExecutorDetector.ts +131 -131
  104. package/src/executor/constants.ts +66 -66
  105. package/src/executor/executor01-bytecode-builder-e2e.test.ts +1478 -1478
  106. package/src/executor/utils.ts +62 -62
  107. package/src/router/simpleswap.ts +366 -366
  108. package/src/types.ts +342 -342
  109. package/tests/constants-e2e.ts +1632 -1622
  110. package/tests/generate-new-limit-order.ts +107 -107
@@ -1,131 +1,131 @@
1
- import { IDexHelper } from '../dex-helper';
2
- import { Address, OptimalRate, SwapSide } from '@paraswap/core';
3
- import { ExecutorBytecodeBuilder } from './ExecutorBytecodeBuilder';
4
- import { Executor01BytecodeBuilder } from './Executor01BytecodeBuilder';
5
- import { Executor02BytecodeBuilder } from './Executor02BytecodeBuilder';
6
- import { Executors, RouteExecutionType } from './types';
7
- import { Executor03BytecodeBuilder } from './Executor03BytecodeBuilder';
8
- import { WETHBytecodeBuilder, isSingleWrapRoute } from './WETHBytecodeBuilder';
9
-
10
- export class ExecutorDetector {
11
- private executor01BytecodeBuilder: ExecutorBytecodeBuilder;
12
- private executor02BytecodeBuilder: ExecutorBytecodeBuilder;
13
- private executor03BytecodeBuilder: ExecutorBytecodeBuilder;
14
- private wethBytecodeBuilder: ExecutorBytecodeBuilder;
15
-
16
- protected routeExecutionTypeToExecutorMap: Record<
17
- SwapSide,
18
- Partial<Record<RouteExecutionType, Executors>>
19
- > = {
20
- [SwapSide.SELL]: {
21
- [RouteExecutionType.SINGLE_STEP]: Executors.ONE, // simpleSwap via Executor01
22
- [RouteExecutionType.HORIZONTAL_SEQUENCE]: Executors.ONE, // multiSwap via Executor01
23
- [RouteExecutionType.VERTICAL_BRANCH]: Executors.TWO, // simpleSwap with percentage on a path via Executor02
24
- [RouteExecutionType.VERTICAL_BRANCH_HORIZONTAL_SEQUENCE]: Executors.TWO, // multiSwap with percentages on paths via Executor02
25
- // megaSwap via Executor02
26
- [RouteExecutionType.NESTED_VERTICAL_BRANCH_HORIZONTAL_SEQUENCE]:
27
- Executors.TWO,
28
- },
29
- [SwapSide.BUY]: {
30
- [RouteExecutionType.SINGLE_STEP]: Executors.THREE, // simpleBuy via Executor03
31
- [RouteExecutionType.VERTICAL_BRANCH]: Executors.THREE, // simpleBuy via Executor03
32
- },
33
- };
34
-
35
- constructor(protected dexHelper: IDexHelper) {
36
- this.executor01BytecodeBuilder = new Executor01BytecodeBuilder(
37
- this.dexHelper,
38
- );
39
- this.executor02BytecodeBuilder = new Executor02BytecodeBuilder(
40
- this.dexHelper,
41
- );
42
- this.executor03BytecodeBuilder = new Executor03BytecodeBuilder(
43
- this.dexHelper,
44
- );
45
-
46
- this.wethBytecodeBuilder = new WETHBytecodeBuilder(this.dexHelper);
47
- }
48
-
49
- public getRouteExecutionType(priceRoute: OptimalRate): RouteExecutionType {
50
- if (
51
- priceRoute.bestRoute.length === 1 &&
52
- priceRoute.bestRoute[0].percent === 100 &&
53
- priceRoute.bestRoute[0].swaps.length === 1 &&
54
- priceRoute.bestRoute[0].swaps[0].swapExchanges.length > 1
55
- ) {
56
- return RouteExecutionType.VERTICAL_BRANCH;
57
- } else if (
58
- priceRoute.bestRoute.length === 1 &&
59
- priceRoute.bestRoute[0].percent === 100 &&
60
- priceRoute.bestRoute[0].swaps.length === 1
61
- ) {
62
- return RouteExecutionType.SINGLE_STEP;
63
- } else if (
64
- priceRoute.bestRoute.length === 1 &&
65
- priceRoute.bestRoute[0].percent === 100 &&
66
- priceRoute.bestRoute[0].swaps.length > 1
67
- ) {
68
- let has100PercentOnEachPath = true;
69
- priceRoute.bestRoute[0].swaps.map(swap => {
70
- swap.swapExchanges.map(se => {
71
- if (se.percent !== 100) {
72
- has100PercentOnEachPath = false;
73
- }
74
- });
75
- });
76
-
77
- if (has100PercentOnEachPath) {
78
- return RouteExecutionType.HORIZONTAL_SEQUENCE;
79
- } else {
80
- return RouteExecutionType.VERTICAL_BRANCH_HORIZONTAL_SEQUENCE;
81
- }
82
- } else if (priceRoute.bestRoute.length > 1) {
83
- return RouteExecutionType.NESTED_VERTICAL_BRANCH_HORIZONTAL_SEQUENCE;
84
- }
85
-
86
- throw new Error('Route type is not supported yet');
87
- }
88
-
89
- detectSpecialExecutor(priceRoute: OptimalRate): Executors | null {
90
- if (isSingleWrapRoute(priceRoute)) return Executors.WETH;
91
- return null;
92
- }
93
-
94
- getExecutorByPriceRoute(priceRoute: OptimalRate): Executors {
95
- const specialExecutor = this.detectSpecialExecutor(priceRoute);
96
- if (specialExecutor) return specialExecutor;
97
-
98
- const routeExecutionType = this.getRouteExecutionType(priceRoute);
99
- const executorName =
100
- this.routeExecutionTypeToExecutorMap[priceRoute.side][routeExecutionType];
101
-
102
- if (executorName) {
103
- return executorName;
104
- }
105
-
106
- throw new Error(`${executorName} is not implemented`);
107
- }
108
-
109
- getAddress(executorName: Executors): Address {
110
- if (!Object.values(Executors).includes(executorName)) {
111
- throw new Error(`${executorName} is not supported`);
112
- }
113
-
114
- return this.dexHelper.config.data.executorsAddresses![executorName];
115
- }
116
-
117
- getBytecodeBuilder(executorName: Executors): ExecutorBytecodeBuilder {
118
- switch (executorName) {
119
- case Executors.ONE:
120
- return this.executor01BytecodeBuilder;
121
- case Executors.TWO:
122
- return this.executor02BytecodeBuilder;
123
- case Executors.THREE:
124
- return this.executor03BytecodeBuilder;
125
- case Executors.WETH:
126
- return this.wethBytecodeBuilder;
127
- default:
128
- throw new Error(`${executorName} is not supported`);
129
- }
130
- }
131
- }
1
+ import { IDexHelper } from '../dex-helper';
2
+ import { Address, OptimalRate, SwapSide } from '@paraswap/core';
3
+ import { ExecutorBytecodeBuilder } from './ExecutorBytecodeBuilder';
4
+ import { Executor01BytecodeBuilder } from './Executor01BytecodeBuilder';
5
+ import { Executor02BytecodeBuilder } from './Executor02BytecodeBuilder';
6
+ import { Executors, RouteExecutionType } from './types';
7
+ import { Executor03BytecodeBuilder } from './Executor03BytecodeBuilder';
8
+ import { WETHBytecodeBuilder, isSingleWrapRoute } from './WETHBytecodeBuilder';
9
+
10
+ export class ExecutorDetector {
11
+ private executor01BytecodeBuilder: ExecutorBytecodeBuilder;
12
+ private executor02BytecodeBuilder: ExecutorBytecodeBuilder;
13
+ private executor03BytecodeBuilder: ExecutorBytecodeBuilder;
14
+ private wethBytecodeBuilder: ExecutorBytecodeBuilder;
15
+
16
+ protected routeExecutionTypeToExecutorMap: Record<
17
+ SwapSide,
18
+ Partial<Record<RouteExecutionType, Executors>>
19
+ > = {
20
+ [SwapSide.SELL]: {
21
+ [RouteExecutionType.SINGLE_STEP]: Executors.ONE, // simpleSwap via Executor01
22
+ [RouteExecutionType.HORIZONTAL_SEQUENCE]: Executors.ONE, // multiSwap via Executor01
23
+ [RouteExecutionType.VERTICAL_BRANCH]: Executors.TWO, // simpleSwap with percentage on a path via Executor02
24
+ [RouteExecutionType.VERTICAL_BRANCH_HORIZONTAL_SEQUENCE]: Executors.TWO, // multiSwap with percentages on paths via Executor02
25
+ // megaSwap via Executor02
26
+ [RouteExecutionType.NESTED_VERTICAL_BRANCH_HORIZONTAL_SEQUENCE]:
27
+ Executors.TWO,
28
+ },
29
+ [SwapSide.BUY]: {
30
+ [RouteExecutionType.SINGLE_STEP]: Executors.THREE, // simpleBuy via Executor03
31
+ [RouteExecutionType.VERTICAL_BRANCH]: Executors.THREE, // simpleBuy via Executor03
32
+ },
33
+ };
34
+
35
+ constructor(protected dexHelper: IDexHelper) {
36
+ this.executor01BytecodeBuilder = new Executor01BytecodeBuilder(
37
+ this.dexHelper,
38
+ );
39
+ this.executor02BytecodeBuilder = new Executor02BytecodeBuilder(
40
+ this.dexHelper,
41
+ );
42
+ this.executor03BytecodeBuilder = new Executor03BytecodeBuilder(
43
+ this.dexHelper,
44
+ );
45
+
46
+ this.wethBytecodeBuilder = new WETHBytecodeBuilder(this.dexHelper);
47
+ }
48
+
49
+ public getRouteExecutionType(priceRoute: OptimalRate): RouteExecutionType {
50
+ if (
51
+ priceRoute.bestRoute.length === 1 &&
52
+ priceRoute.bestRoute[0].percent === 100 &&
53
+ priceRoute.bestRoute[0].swaps.length === 1 &&
54
+ priceRoute.bestRoute[0].swaps[0].swapExchanges.length > 1
55
+ ) {
56
+ return RouteExecutionType.VERTICAL_BRANCH;
57
+ } else if (
58
+ priceRoute.bestRoute.length === 1 &&
59
+ priceRoute.bestRoute[0].percent === 100 &&
60
+ priceRoute.bestRoute[0].swaps.length === 1
61
+ ) {
62
+ return RouteExecutionType.SINGLE_STEP;
63
+ } else if (
64
+ priceRoute.bestRoute.length === 1 &&
65
+ priceRoute.bestRoute[0].percent === 100 &&
66
+ priceRoute.bestRoute[0].swaps.length > 1
67
+ ) {
68
+ let has100PercentOnEachPath = true;
69
+ priceRoute.bestRoute[0].swaps.map(swap => {
70
+ swap.swapExchanges.map(se => {
71
+ if (se.percent !== 100) {
72
+ has100PercentOnEachPath = false;
73
+ }
74
+ });
75
+ });
76
+
77
+ if (has100PercentOnEachPath) {
78
+ return RouteExecutionType.HORIZONTAL_SEQUENCE;
79
+ } else {
80
+ return RouteExecutionType.VERTICAL_BRANCH_HORIZONTAL_SEQUENCE;
81
+ }
82
+ } else if (priceRoute.bestRoute.length > 1) {
83
+ return RouteExecutionType.NESTED_VERTICAL_BRANCH_HORIZONTAL_SEQUENCE;
84
+ }
85
+
86
+ throw new Error('Route type is not supported yet');
87
+ }
88
+
89
+ detectSpecialExecutor(priceRoute: OptimalRate): Executors | null {
90
+ if (isSingleWrapRoute(priceRoute)) return Executors.WETH;
91
+ return null;
92
+ }
93
+
94
+ getExecutorByPriceRoute(priceRoute: OptimalRate): Executors {
95
+ const specialExecutor = this.detectSpecialExecutor(priceRoute);
96
+ if (specialExecutor) return specialExecutor;
97
+
98
+ const routeExecutionType = this.getRouteExecutionType(priceRoute);
99
+ const executorName =
100
+ this.routeExecutionTypeToExecutorMap[priceRoute.side][routeExecutionType];
101
+
102
+ if (executorName) {
103
+ return executorName;
104
+ }
105
+
106
+ throw new Error(`${executorName} is not implemented`);
107
+ }
108
+
109
+ getAddress(executorName: Executors): Address {
110
+ if (!Object.values(Executors).includes(executorName)) {
111
+ throw new Error(`${executorName} is not supported`);
112
+ }
113
+
114
+ return this.dexHelper.config.data.executorsAddresses![executorName];
115
+ }
116
+
117
+ getBytecodeBuilder(executorName: Executors): ExecutorBytecodeBuilder {
118
+ switch (executorName) {
119
+ case Executors.ONE:
120
+ return this.executor01BytecodeBuilder;
121
+ case Executors.TWO:
122
+ return this.executor02BytecodeBuilder;
123
+ case Executors.THREE:
124
+ return this.executor03BytecodeBuilder;
125
+ case Executors.WETH:
126
+ return this.wethBytecodeBuilder;
127
+ default:
128
+ throw new Error(`${executorName} is not supported`);
129
+ }
130
+ }
131
+ }
@@ -1,66 +1,66 @@
1
- import { ethers } from 'ethers';
2
- import { Network } from '../constants';
3
-
4
- const {
5
- utils: { hexlify, hexZeroPad },
6
- } = ethers;
7
-
8
- export const BYTES_28_LENGTH = 28;
9
- export const BYTES_64_LENGTH = 64;
10
- export const BYTES_96_LENGTH = 96;
11
-
12
- export const ZEROS_4_BYTES = hexZeroPad(hexlify(0), 4);
13
- export const ZEROS_12_BYTES = hexZeroPad(hexlify(0), 12);
14
- export const ZEROS_20_BYTES = hexZeroPad(hexlify(0), 20);
15
- export const ZEROS_28_BYTES = hexZeroPad(hexlify(0), 28);
16
- export const ZEROS_32_BYTES = hexZeroPad(hexlify(0), 32);
17
-
18
- export const SWAP_EXCHANGE_100_PERCENTAGE = 100;
19
-
20
- export const NOT_EXISTING_EXCHANGE_PARAM_INDEX = -1;
21
-
22
- export const ETH_SRC_TOKEN_POS_FOR_MULTISWAP_METADATA = '0xEEEEEEEEEEEEEEEE';
23
-
24
- export const EXECUTOR_01_02_FUNCTION_CALL_DATA_TYPES: string[] = [
25
- 'bytes20', // address
26
- 'bytes4', // calldata Size
27
- 'bytes2', // fromAmount Pos
28
- 'bytes2', // srcTokenPos
29
- 'bytes1', // returnAmount Pos
30
- 'bytes1', // specialExchange
31
- 'bytes2', // flag
32
- 'bytes28', // zero padding
33
- 'bytes', // dex calldata
34
- ];
35
-
36
- export const EXECUTOR_03_FUNCTION_CALL_DATA_TYPES: string[] = [
37
- 'bytes20', // address(bytes20)
38
- 'bytes2', // calldata Size(bytes 2)
39
- 'bytes2', // toAmount Pos(bytes2)
40
- 'bytes2', // fromAmount Pos(bytes2)
41
- 'bytes2', // srcTokenPos(bytes2)
42
- 'bytes2', // specialExchange (bytes2)
43
- 'bytes2', // flag(bytes2)
44
- 'bytes28', // zero padding (bytes28)
45
- 'bytes', // dex calldata (bytes)
46
- ];
47
-
48
- export const APPROVE_CALLDATA_DEST_TOKEN_POS = 68;
49
- export const WRAP_UNWRAP_FROM_AMOUNT_POS = 4;
50
- export const DEFAULT_RETURN_AMOUNT_POS = 255;
51
-
52
- export const RETURN_AMOUNT_POS_0 = 0;
53
- export const RETURN_AMOUNT_POS_32 = 32;
54
-
55
- // TODO-v6?: can it be removed after approval/cache task, because we are going to give approvals only once,
56
- // therefore for any case initial allowance would be 0
57
- export const DISABLED_MAX_UNIT_APPROVAL_TOKENS: Partial<
58
- Record<Network, string[]>
59
- > = {
60
- // USDT don't allow approve for MAX_UINT if current approval is not 0
61
- [Network.MAINNET]: [
62
- '0xdac17f958d2ee523a2206206994597c13d831ec7',
63
- '0xd101dcc414f310268c37eeb4cd376ccfa507f571',
64
- '0x0f5d2fb29fb7d3cfee444a200298f468908cc942',
65
- ],
66
- };
1
+ import { ethers } from 'ethers';
2
+ import { Network } from '../constants';
3
+
4
+ const {
5
+ utils: { hexlify, hexZeroPad },
6
+ } = ethers;
7
+
8
+ export const BYTES_28_LENGTH = 28;
9
+ export const BYTES_64_LENGTH = 64;
10
+ export const BYTES_96_LENGTH = 96;
11
+
12
+ export const ZEROS_4_BYTES = hexZeroPad(hexlify(0), 4);
13
+ export const ZEROS_12_BYTES = hexZeroPad(hexlify(0), 12);
14
+ export const ZEROS_20_BYTES = hexZeroPad(hexlify(0), 20);
15
+ export const ZEROS_28_BYTES = hexZeroPad(hexlify(0), 28);
16
+ export const ZEROS_32_BYTES = hexZeroPad(hexlify(0), 32);
17
+
18
+ export const SWAP_EXCHANGE_100_PERCENTAGE = 100;
19
+
20
+ export const NOT_EXISTING_EXCHANGE_PARAM_INDEX = -1;
21
+
22
+ export const ETH_SRC_TOKEN_POS_FOR_MULTISWAP_METADATA = '0xEEEEEEEEEEEEEEEE';
23
+
24
+ export const EXECUTOR_01_02_FUNCTION_CALL_DATA_TYPES: string[] = [
25
+ 'bytes20', // address
26
+ 'bytes4', // calldata Size
27
+ 'bytes2', // fromAmount Pos
28
+ 'bytes2', // srcTokenPos
29
+ 'bytes1', // returnAmount Pos
30
+ 'bytes1', // specialExchange
31
+ 'bytes2', // flag
32
+ 'bytes28', // zero padding
33
+ 'bytes', // dex calldata
34
+ ];
35
+
36
+ export const EXECUTOR_03_FUNCTION_CALL_DATA_TYPES: string[] = [
37
+ 'bytes20', // address(bytes20)
38
+ 'bytes2', // calldata Size(bytes 2)
39
+ 'bytes2', // toAmount Pos(bytes2)
40
+ 'bytes2', // fromAmount Pos(bytes2)
41
+ 'bytes2', // srcTokenPos(bytes2)
42
+ 'bytes2', // specialExchange (bytes2)
43
+ 'bytes2', // flag(bytes2)
44
+ 'bytes28', // zero padding (bytes28)
45
+ 'bytes', // dex calldata (bytes)
46
+ ];
47
+
48
+ export const APPROVE_CALLDATA_DEST_TOKEN_POS = 68;
49
+ export const WRAP_UNWRAP_FROM_AMOUNT_POS = 4;
50
+ export const DEFAULT_RETURN_AMOUNT_POS = 255;
51
+
52
+ export const RETURN_AMOUNT_POS_0 = 0;
53
+ export const RETURN_AMOUNT_POS_32 = 32;
54
+
55
+ // TODO-v6?: can it be removed after approval/cache task, because we are going to give approvals only once,
56
+ // therefore for any case initial allowance would be 0
57
+ export const DISABLED_MAX_UNIT_APPROVAL_TOKENS: Partial<
58
+ Record<Network, string[]>
59
+ > = {
60
+ // USDT don't allow approve for MAX_UINT if current approval is not 0
61
+ [Network.MAINNET]: [
62
+ '0xdac17f958d2ee523a2206206994597c13d831ec7',
63
+ '0xd101dcc414f310268c37eeb4cd376ccfa507f571',
64
+ '0x0f5d2fb29fb7d3cfee444a200298f468908cc942',
65
+ ],
66
+ };