@paraswap/dex-lib 3.5.6-maverick-v2-7 → 3.6.0

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 (111) hide show
  1. package/.vscode/launch.json +53 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  5. package/build/abi/wombat/pool.json +1289 -0
  6. package/build/constants.d.ts +2 -0
  7. package/build/constants.js +3 -1
  8. package/build/constants.js.map +1 -1
  9. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  10. package/build/dex/aave-v1/aave-v1.js +23 -0
  11. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  12. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  13. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  14. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  15. package/build/dex/compound.js +1 -1
  16. package/build/dex/compound.js.map +1 -1
  17. package/build/dex/index.js +0 -2
  18. package/build/dex/index.js.map +1 -1
  19. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  20. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  21. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  22. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  23. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  24. package/build/dex/maverick-v2/config.d.ts +2 -1
  25. package/build/dex/maverick-v2/config.js +6 -2
  26. package/build/dex/maverick-v2/config.js.map +1 -1
  27. package/build/dex/maverick-v2/maverick-v2.d.ts +3 -2
  28. package/build/dex/maverick-v2/maverick-v2.js +17 -6
  29. package/build/dex/maverick-v2/maverick-v2.js.map +1 -1
  30. package/build/dex/platypus/platypus.d.ts +2 -1
  31. package/build/dex/platypus/platypus.js +45 -0
  32. package/build/dex/platypus/platypus.js.map +1 -1
  33. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  34. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  35. package/build/dex/stable-pool.js +1 -8
  36. package/build/dex/stable-pool.js.map +1 -1
  37. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  38. package/build/dex/swaap-v1/swaap-v1.js +14 -0
  39. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  40. package/build/dex/uniswap-v2/uniswap-v2.d.ts +2 -2
  41. package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
  42. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  43. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  44. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  45. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  46. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  47. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  48. package/build/dex/uniswap-v3/uniswap-v3.d.ts +2 -2
  49. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  50. package/build/dex/zerox/index.d.ts +1 -1
  51. package/build/dex/zerox/index.js.map +1 -1
  52. package/build/executor/Executor03BytecodeBuilder.js +1 -12
  53. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  54. package/build/generic-swap-transaction-builder.d.ts +5 -3
  55. package/build/generic-swap-transaction-builder.js +22 -7
  56. package/build/generic-swap-transaction-builder.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/constants.ts +2 -0
  59. package/src/dex/index.ts +0 -2
  60. package/src/dex/maker-psm/scripts/gem.abi.json +136 -0
  61. package/src/dex/maker-psm/scripts/validate-state.ts +221 -0
  62. package/src/dex/maker-psm/scripts/vat.abi.json +243 -0
  63. package/src/dex/uniswap-v2/uniswap-v2.ts +2 -2
  64. package/src/dex/uniswap-v3/uniswap-v3.ts +2 -2
  65. package/src/dex/zerox/index.ts +1 -1
  66. package/src/executor/Executor03BytecodeBuilder.ts +1 -15
  67. package/src/generic-swap-transaction-builder.ts +40 -0
  68. package/tests/constants-e2e.ts +2 -2
  69. package/build/dex/etherfi/etherfi.d.ts +0 -26
  70. package/build/dex/etherfi/etherfi.js +0 -96
  71. package/build/dex/etherfi/etherfi.js.map +0 -1
  72. package/build/dex/sdai/config.d.ts +0 -11
  73. package/build/dex/sdai/config.js +0 -21
  74. package/build/dex/sdai/config.js.map +0 -1
  75. package/build/dex/sdai/constants.d.ts +0 -2
  76. package/build/dex/sdai/constants.js +0 -6
  77. package/build/dex/sdai/constants.js.map +0 -1
  78. package/build/dex/sdai/scripts/validate-state.js +0 -102
  79. package/build/dex/sdai/scripts/validate-state.js.map +0 -1
  80. package/build/dex/sdai/sdai-pool.d.ts +0 -16
  81. package/build/dex/sdai/sdai-pool.js +0 -85
  82. package/build/dex/sdai/sdai-pool.js.map +0 -1
  83. package/build/dex/sdai/sdai.d.ts +0 -51
  84. package/build/dex/sdai/sdai.js +0 -172
  85. package/build/dex/sdai/sdai.js.map +0 -1
  86. package/build/dex/sdai/types.d.ts +0 -21
  87. package/build/dex/sdai/types.js +0 -11
  88. package/build/dex/sdai/types.js.map +0 -1
  89. package/build/dex/sdai/utils.d.ts +0 -4
  90. package/build/dex/sdai/utils.js +0 -39
  91. package/build/dex/sdai/utils.js.map +0 -1
  92. package/src/abi/maverick-v2/MaverickV2Pool.json +0 -1234
  93. package/src/abi/maverick-v2/MaverickV2PoolLens.json +0 -1232
  94. package/src/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  95. package/src/dex/maverick-v2/config.ts +0 -17
  96. package/src/dex/maverick-v2/maverick-math/maverick-basic-math.ts +0 -152
  97. package/src/dex/maverick-v2/maverick-math/maverick-bin-math.ts +0 -288
  98. package/src/dex/maverick-v2/maverick-math/maverick-delta-math.ts +0 -32
  99. package/src/dex/maverick-v2/maverick-math/maverick-math.ts +0 -30
  100. package/src/dex/maverick-v2/maverick-math/maverick-pool-lib.ts +0 -42
  101. package/src/dex/maverick-v2/maverick-math/maverick-pool-math.ts +0 -709
  102. package/src/dex/maverick-v2/maverick-math/maverick-swap-math.ts +0 -199
  103. package/src/dex/maverick-v2/maverick-math/maverick-tick-math.ts +0 -171
  104. package/src/dex/maverick-v2/maverick-math/maverick-twa-math.ts +0 -54
  105. package/src/dex/maverick-v2/maverick-v2-e2e.test.ts +0 -176
  106. package/src/dex/maverick-v2/maverick-v2-events.test.ts +0 -112
  107. package/src/dex/maverick-v2/maverick-v2-integration.test.ts +0 -269
  108. package/src/dex/maverick-v2/maverick-v2-pool.ts +0 -276
  109. package/src/dex/maverick-v2/maverick-v2.ts +0 -424
  110. package/src/dex/maverick-v2/types.ts +0 -152
  111. /package/build/dex/{sdai/scripts/validate-state.d.ts → solidly-v3/scripts/check-event-pool-event.d.ts} +0 -0
@@ -1,278 +0,0 @@
1
- [
2
- {
3
- "inputs": [],
4
- "name": "BytesLibSliceOutOfBounds",
5
- "type": "error"
6
- },
7
- {
8
- "inputs": [],
9
- "name": "BytesLibSliceOverflow",
10
- "type": "error"
11
- },
12
- {
13
- "inputs": [],
14
- "name": "BytesLibToAddressOutOfBounds",
15
- "type": "error"
16
- },
17
- {
18
- "inputs": [],
19
- "name": "BytesLibToBoolOutOfBounds",
20
- "type": "error"
21
- },
22
- {
23
- "inputs": [],
24
- "name": "MathOverflowedMulDiv",
25
- "type": "error"
26
- },
27
- {
28
- "inputs": [],
29
- "name": "QuoterInvalidAddLiquidity",
30
- "type": "error"
31
- },
32
- {
33
- "inputs": [],
34
- "name": "QuoterInvalidSwap",
35
- "type": "error"
36
- },
37
- {
38
- "inputs": [
39
- {
40
- "internalType": "uint8",
41
- "name": "bits",
42
- "type": "uint8"
43
- },
44
- {
45
- "internalType": "uint256",
46
- "name": "value",
47
- "type": "uint256"
48
- }
49
- ],
50
- "name": "SafeCastOverflowedUintDowncast",
51
- "type": "error"
52
- },
53
- {
54
- "inputs": [
55
- {
56
- "internalType": "int256",
57
- "name": "tick",
58
- "type": "int256"
59
- }
60
- ],
61
- "name": "TickMaxExceeded",
62
- "type": "error"
63
- },
64
- {
65
- "inputs": [
66
- {
67
- "internalType": "contract IMaverickV2Pool",
68
- "name": "pool",
69
- "type": "address"
70
- },
71
- {
72
- "components": [
73
- {
74
- "internalType": "uint8",
75
- "name": "kind",
76
- "type": "uint8"
77
- },
78
- {
79
- "internalType": "int32[]",
80
- "name": "ticks",
81
- "type": "int32[]"
82
- },
83
- {
84
- "internalType": "uint128[]",
85
- "name": "amounts",
86
- "type": "uint128[]"
87
- }
88
- ],
89
- "internalType": "struct IMaverickV2Pool.AddLiquidityParams",
90
- "name": "params",
91
- "type": "tuple"
92
- }
93
- ],
94
- "name": "calculateAddLiquidity",
95
- "outputs": [
96
- {
97
- "internalType": "uint256",
98
- "name": "amountA",
99
- "type": "uint256"
100
- },
101
- {
102
- "internalType": "uint256",
103
- "name": "amountB",
104
- "type": "uint256"
105
- },
106
- {
107
- "internalType": "uint256",
108
- "name": "gasEstimate",
109
- "type": "uint256"
110
- }
111
- ],
112
- "stateMutability": "nonpayable",
113
- "type": "function"
114
- },
115
- {
116
- "inputs": [
117
- {
118
- "internalType": "bytes",
119
- "name": "path",
120
- "type": "bytes"
121
- },
122
- {
123
- "internalType": "uint256",
124
- "name": "amount",
125
- "type": "uint256"
126
- },
127
- {
128
- "internalType": "bool",
129
- "name": "exactOutput",
130
- "type": "bool"
131
- }
132
- ],
133
- "name": "calculateMultiHopSwap",
134
- "outputs": [
135
- {
136
- "internalType": "uint256",
137
- "name": "returnAmount",
138
- "type": "uint256"
139
- },
140
- {
141
- "internalType": "uint256",
142
- "name": "gasEstimate",
143
- "type": "uint256"
144
- }
145
- ],
146
- "stateMutability": "nonpayable",
147
- "type": "function"
148
- },
149
- {
150
- "inputs": [
151
- {
152
- "internalType": "contract IMaverickV2Pool",
153
- "name": "pool",
154
- "type": "address"
155
- },
156
- {
157
- "internalType": "uint128",
158
- "name": "amount",
159
- "type": "uint128"
160
- },
161
- {
162
- "internalType": "bool",
163
- "name": "tokenAIn",
164
- "type": "bool"
165
- },
166
- {
167
- "internalType": "bool",
168
- "name": "exactOutput",
169
- "type": "bool"
170
- },
171
- {
172
- "internalType": "int32",
173
- "name": "tickLimit",
174
- "type": "int32"
175
- }
176
- ],
177
- "name": "calculateSwap",
178
- "outputs": [
179
- {
180
- "internalType": "uint256",
181
- "name": "amountIn",
182
- "type": "uint256"
183
- },
184
- {
185
- "internalType": "uint256",
186
- "name": "amountOut",
187
- "type": "uint256"
188
- },
189
- {
190
- "internalType": "uint256",
191
- "name": "gasEstimate",
192
- "type": "uint256"
193
- }
194
- ],
195
- "stateMutability": "nonpayable",
196
- "type": "function"
197
- },
198
- {
199
- "inputs": [
200
- {
201
- "internalType": "contract IERC20",
202
- "name": "",
203
- "type": "address"
204
- },
205
- {
206
- "internalType": "contract IERC20",
207
- "name": "",
208
- "type": "address"
209
- },
210
- {
211
- "internalType": "uint256",
212
- "name": "amountA",
213
- "type": "uint256"
214
- },
215
- {
216
- "internalType": "uint256",
217
- "name": "amountB",
218
- "type": "uint256"
219
- },
220
- {
221
- "internalType": "bytes",
222
- "name": "",
223
- "type": "bytes"
224
- }
225
- ],
226
- "name": "maverickV2AddLiquidityCallback",
227
- "outputs": [],
228
- "stateMutability": "pure",
229
- "type": "function"
230
- },
231
- {
232
- "inputs": [
233
- {
234
- "internalType": "contract IERC20",
235
- "name": "",
236
- "type": "address"
237
- },
238
- {
239
- "internalType": "uint256",
240
- "name": "amountIn",
241
- "type": "uint256"
242
- },
243
- {
244
- "internalType": "uint256",
245
- "name": "amountOut",
246
- "type": "uint256"
247
- },
248
- {
249
- "internalType": "bytes",
250
- "name": "",
251
- "type": "bytes"
252
- }
253
- ],
254
- "name": "maverickV2SwapCallback",
255
- "outputs": [],
256
- "stateMutability": "pure",
257
- "type": "function"
258
- },
259
- {
260
- "inputs": [
261
- {
262
- "internalType": "contract IMaverickV2Pool",
263
- "name": "pool",
264
- "type": "address"
265
- }
266
- ],
267
- "name": "poolSqrtPrice",
268
- "outputs": [
269
- {
270
- "internalType": "uint256",
271
- "name": "sqrtPrice",
272
- "type": "uint256"
273
- }
274
- ],
275
- "stateMutability": "view",
276
- "type": "function"
277
- }
278
- ]
@@ -1,17 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap, AdapterMappings } from '../../types';
3
- import { Network, SwapSide } from '../../constants';
4
-
5
- export const MAV_V2_BASE_GAS_COST = 50_000;
6
- export const MAV_V2_TICK_GAS_COST = 10_000;
7
-
8
- export const MaverickV2Config: DexConfigMap<DexParams> = {
9
- MaverickV2: {
10
- [Network.BASE]: {
11
- poolLensAddress: '0x56eFfDD51b20705e152CAF482D9A6972e97B571C',
12
- quoterAddress: '0xb40AfdB85a07f37aE217E7D6462e609900dD8D7A',
13
- apiURL: 'https://maverick-v2-api-delta.vercel.app',
14
- },
15
- },
16
- };
17
- ;
@@ -1,152 +0,0 @@
1
- import { BI_MAX_UINT256, BI_POWS } from '../../../bigint-constants';
2
- import { _require } from '../../../utils';
3
-
4
- export class MaverickBasicMath {
5
- static MAX_POW_RELATIVE_ERROR = BI_POWS[4];
6
-
7
- static abs(x: bigint) {
8
- return x < 0n ? -x : x;
9
- }
10
-
11
- static min(a: bigint, b: bigint): bigint {
12
- return a < b ? a : b;
13
- }
14
-
15
- static max(a: bigint, b: bigint): bigint {
16
- return a >= b ? a : b;
17
- }
18
-
19
- static clip(x: bigint, y: bigint): bigint {
20
- return x < y ? 0n : x - y;
21
- }
22
-
23
- static mulDivFloor(x: bigint, y: bigint, k: bigint): bigint {
24
- return this.mulDiv(x, y, this.max(1n, k));
25
- }
26
-
27
- static mulmod(x: bigint, y: bigint, k: bigint): bigint {
28
- return (x * y) % k;
29
- }
30
-
31
- static mulFloor(x: bigint, y: bigint): bigint {
32
- return this.mulDiv(x, y, BI_POWS[18]);
33
- }
34
-
35
- static mulDivCeil(x: bigint, y: bigint, k: bigint): bigint {
36
- let result = this.mulDivFloor(x, y, k);
37
- if (this.mulmod(x, y, this.max(1n, k)) != 0n) result = result + 1n;
38
- return result;
39
- }
40
-
41
- static sqrt(x: bigint) {
42
- let y = x;
43
-
44
- let z = 181n;
45
-
46
- if (y >= 0x10000000000000000000000000000000000) {
47
- y >>= 128n;
48
- z <<= 64n;
49
- }
50
-
51
- if (y >= 0x1000000000000000000) {
52
- y >>= 64n;
53
- z <<= 32n;
54
- }
55
-
56
- if (y >= 0x10000000000) {
57
- y >>= 32n;
58
- z <<= 16n;
59
- }
60
-
61
- if (y >= 0x1000000) {
62
- y >>= 16n;
63
- z <<= 8n;
64
- }
65
-
66
- z = (z * (y + 65536n)) >> 18n;
67
- z = (x / z + z) >> 1n;
68
- z = (x / z + z) >> 1n;
69
- z = (x / z + z) >> 1n;
70
- z = (x / z + z) >> 1n;
71
- z = (x / z + z) >> 1n;
72
- z = (x / z + z) >> 1n;
73
- z = (x / z + z) >> 1n;
74
-
75
- return x / z < z ? z - 1n : z;
76
- }
77
-
78
- static divDown(x: bigint, y: bigint): bigint {
79
- return this.mulDivDown(x, BI_POWS[18], y);
80
- }
81
-
82
- static divUp(x: bigint, y: bigint): bigint {
83
- return this.mulDivUp(x, BI_POWS[18], y);
84
- }
85
-
86
- static mulUp(x: bigint, y: bigint): bigint {
87
- return this.mulDivUp(x, y, BI_POWS[18]);
88
- }
89
-
90
- static mulDown(x: bigint, y: bigint): bigint {
91
- return this.mulDivDown(x, y, BI_POWS[18]);
92
- }
93
-
94
- static invFloor(x: bigint): bigint {
95
- return BI_POWS[36] / x;
96
- }
97
-
98
- static invCeil(denominator: bigint): bigint {
99
- return (BI_POWS[36] - 1n) / denominator + 1n;
100
- }
101
-
102
- static mulDivDown(x: bigint, y: bigint, denominator: bigint): bigint {
103
- let z = x * y;
104
-
105
- if (denominator == 0n) {
106
- denominator = 1n;
107
- }
108
-
109
- if (denominator == 0n && !(y == 0n || x <= BI_MAX_UINT256 / y)) {
110
- throw new Error('MATH: MUL_DIV_DOWN_OVERFLOW');
111
- }
112
-
113
- return z / denominator;
114
- }
115
-
116
- static mulDiv(x: bigint, y: bigint, denominator: bigint): bigint {
117
- const result = (x * y) / denominator;
118
-
119
- _require(
120
- result <= BI_MAX_UINT256,
121
- '',
122
- { result, BI_MAX_UINT: BI_MAX_UINT256 },
123
- 'result <= BI_MAX_UINT256',
124
- );
125
-
126
- return result;
127
- }
128
-
129
- static divCeil(x: bigint, y: bigint): bigint {
130
- return this.mulDivCeil(x, BI_POWS[18], y);
131
- }
132
-
133
- static mulCeil(x: bigint, y: bigint): bigint {
134
- return this.mulDivCeil(x, y, BI_POWS[18]);
135
- }
136
-
137
- static mulDivUp(x: bigint, y: bigint, denominator: bigint): bigint {
138
- let z = x * y;
139
-
140
- if (z == 0n) {
141
- return 0n;
142
- }
143
-
144
- return (z - 1n) / denominator + 1n;
145
- }
146
-
147
- static floorD8Unchecked(val: bigint): bigint {
148
- let val32 = val / BI_POWS[8];
149
- let check = val < 0 && val % BI_POWS[8] != 0n;
150
- return check ? val32 - 1n : val32;
151
- }
152
- }