@skate-org/amm-evm-v2 2.0.0-beta.2 → 2.0.0-beta.20
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/CHANGELOG.md +45 -119
- package/README.md +56 -4
- package/dist/chain-clients.d.ts.map +1 -1
- package/dist/client.d.ts +7361 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/devConfig.d.ts +0 -2
- package/dist/devConfig.d.ts.map +1 -1
- package/dist/index.cjs +513 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +513 -116
- package/dist/index.js.map +1 -1
- package/dist/kernel/lens.d.ts +20 -4
- package/dist/kernel/lens.d.ts.map +1 -1
- package/dist/kernel/reader.d.ts +42 -8
- package/dist/kernel/reader.d.ts.map +1 -1
- package/dist/periphery/calldata.d.ts +87 -0
- package/dist/periphery/calldata.d.ts.map +1 -0
- package/dist/periphery/index.d.ts +1 -0
- package/dist/periphery/index.d.ts.map +1 -1
- package/dist/periphery/reader.d.ts +29 -28
- package/dist/periphery/reader.d.ts.map +1 -1
- package/dist/skate-amm.d.ts +7373 -0
- package/dist/skate-amm.d.ts.map +1 -0
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -20,10 +20,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AmmEvm: () => AmmEvm,
|
|
23
24
|
EvmReadError: () => EvmReadError,
|
|
24
25
|
EvmWriteError: () => EvmWriteError,
|
|
25
26
|
KERNEL_EVENT_NAMES: () => KERNEL_EVENT_NAMES,
|
|
26
27
|
PERIPHERY_EVENT_NAMES: () => PERIPHERY_EVENT_NAMES,
|
|
28
|
+
SkateAmm: () => SkateAmm,
|
|
29
|
+
buildBurn: () => buildBurn,
|
|
30
|
+
buildDecreaseLiquidity: () => buildDecreaseLiquidity,
|
|
31
|
+
buildIncreaseLiquidity: () => buildIncreaseLiquidity,
|
|
32
|
+
buildMint: () => buildMint,
|
|
33
|
+
buildSwap: () => buildSwap,
|
|
27
34
|
computePositionAmounts: () => computePositionAmounts,
|
|
28
35
|
createDevConfig: () => createDevConfig,
|
|
29
36
|
decodeTickBitmapWord: () => decodeTickBitmapWord,
|
|
@@ -32,6 +39,7 @@ __export(index_exports, {
|
|
|
32
39
|
megaethChain: () => megaethChain,
|
|
33
40
|
parseKernelEventLog: () => parseKernelEventLog,
|
|
34
41
|
parsePeripheryEventLog: () => parsePeripheryEventLog,
|
|
42
|
+
readKernelBalances: () => readKernelBalances,
|
|
35
43
|
readPeripheryPool: () => readPeripheryPool,
|
|
36
44
|
readPool: () => readPool,
|
|
37
45
|
readPosition: () => readPosition,
|
|
@@ -69,7 +77,8 @@ var megaethChain = (0, import_viem.defineChain)({
|
|
|
69
77
|
});
|
|
70
78
|
var DEFAULT_RPC = {
|
|
71
79
|
[import_amm_core_v2.CHAIN.MEGAETH]: "https://mainnet.megaeth.com/rpc",
|
|
72
|
-
[import_amm_core_v2.CHAIN.ARBITRUM]: "https://arb1.arbitrum.io/rpc"
|
|
80
|
+
[import_amm_core_v2.CHAIN.ARBITRUM]: "https://arb1.arbitrum.io/rpc",
|
|
81
|
+
[import_amm_core_v2.CHAIN.ETHEREUM]: "https://ethereum-rpc.publicnode.com"
|
|
73
82
|
};
|
|
74
83
|
function chainDefFor(chain) {
|
|
75
84
|
switch (chain) {
|
|
@@ -77,6 +86,8 @@ function chainDefFor(chain) {
|
|
|
77
86
|
return megaethChain;
|
|
78
87
|
case import_amm_core_v2.CHAIN.ARBITRUM:
|
|
79
88
|
return import_chains.arbitrum;
|
|
89
|
+
case import_amm_core_v2.CHAIN.ETHEREUM:
|
|
90
|
+
return import_chains.mainnet;
|
|
80
91
|
default:
|
|
81
92
|
return void 0;
|
|
82
93
|
}
|
|
@@ -123,17 +134,9 @@ function getSourcePublicClient(chain, mode, transport) {
|
|
|
123
134
|
});
|
|
124
135
|
}
|
|
125
136
|
|
|
126
|
-
// src/
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
mode: "DEV",
|
|
131
|
-
config: {
|
|
132
|
-
apiEndpoint: overrides.apiEndpoint ?? DEFAULT_DEV_API_ENDPOINT,
|
|
133
|
-
...overrides.rpcEndpoints ? { rpcEndpoints: overrides.rpcEndpoints } : {}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
+
// src/kernel/reader.ts
|
|
138
|
+
var import_amm_bindings = require("@skate-org/amm-bindings");
|
|
139
|
+
var import_amm_core_v23 = require("@skate-org/amm-core-v2");
|
|
137
140
|
|
|
138
141
|
// src/errors.ts
|
|
139
142
|
var import_amm_core_v22 = require("@skate-org/amm-core-v2");
|
|
@@ -170,27 +173,23 @@ function wrapWriteError(err, functionName) {
|
|
|
170
173
|
return new EvmWriteError(functionName, message, { cause: err });
|
|
171
174
|
}
|
|
172
175
|
|
|
173
|
-
// src/kernel/reader.ts
|
|
174
|
-
var import_amm_bindings = require("@skate-org/amm-bindings");
|
|
175
|
-
var import_amm_core_v23 = require("@skate-org/amm-core-v2");
|
|
176
|
-
|
|
177
176
|
// src/kernel/_client.ts
|
|
178
177
|
function resolveKernelClient(mode, client) {
|
|
179
178
|
return client ?? getKernelPublicClient(mode);
|
|
180
179
|
}
|
|
181
180
|
|
|
182
181
|
// src/kernel/reader.ts
|
|
183
|
-
async function readPool(
|
|
184
|
-
const c = resolveKernelClient(mode, client);
|
|
182
|
+
async function readPool(p) {
|
|
183
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
185
184
|
try {
|
|
186
185
|
const [slot0, liquidity] = await Promise.all([
|
|
187
186
|
c.readContract({
|
|
188
|
-
address: kernelPool,
|
|
187
|
+
address: p.kernelPool,
|
|
189
188
|
abi: import_amm_bindings.KernelPoolABI,
|
|
190
189
|
functionName: "slot0"
|
|
191
190
|
}),
|
|
192
191
|
c.readContract({
|
|
193
|
-
address: kernelPool,
|
|
192
|
+
address: p.kernelPool,
|
|
194
193
|
abi: import_amm_bindings.KernelPoolABI,
|
|
195
194
|
functionName: "liquidity"
|
|
196
195
|
})
|
|
@@ -212,16 +211,36 @@ async function readPool(kernelPool, mode, client) {
|
|
|
212
211
|
throw wrapReadError(err, "readPool");
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
|
-
async function
|
|
216
|
-
const
|
|
214
|
+
async function readKernelBalances(p) {
|
|
215
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
216
|
+
try {
|
|
217
|
+
const [balance0, balance1] = await Promise.all([
|
|
218
|
+
c.readContract({
|
|
219
|
+
address: p.kernelPool,
|
|
220
|
+
abi: import_amm_bindings.KernelPoolABI,
|
|
221
|
+
functionName: "balance0"
|
|
222
|
+
}),
|
|
223
|
+
c.readContract({
|
|
224
|
+
address: p.kernelPool,
|
|
225
|
+
abi: import_amm_bindings.KernelPoolABI,
|
|
226
|
+
functionName: "balance1"
|
|
227
|
+
})
|
|
228
|
+
]);
|
|
229
|
+
return { balance0, balance1 };
|
|
230
|
+
} catch (err) {
|
|
231
|
+
throw wrapReadError(err, "readKernelBalances");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async function readPosition(p) {
|
|
235
|
+
const { mode: baseMode } = (0, import_amm_core_v23.normalizeMode)(p.mode);
|
|
217
236
|
const manager = (0, import_amm_core_v23.KernelManagerAddress)(baseMode);
|
|
218
|
-
const c = resolveKernelClient(mode, client);
|
|
237
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
219
238
|
try {
|
|
220
239
|
const raw = await c.readContract({
|
|
221
240
|
address: manager,
|
|
222
241
|
abi: import_amm_bindings.KernelManagerABI,
|
|
223
242
|
functionName: "nftPositions",
|
|
224
|
-
args: [tokenId]
|
|
243
|
+
args: [p.tokenId]
|
|
225
244
|
});
|
|
226
245
|
const asTuple = Array.isArray(raw) ? raw : null;
|
|
227
246
|
if (asTuple) {
|
|
@@ -241,28 +260,28 @@ async function readPosition(tokenId, mode, client) {
|
|
|
241
260
|
throw wrapReadError(err, "readPosition");
|
|
242
261
|
}
|
|
243
262
|
}
|
|
244
|
-
async function readTickBitmap(
|
|
245
|
-
const c = resolveKernelClient(mode, client);
|
|
263
|
+
async function readTickBitmap(p) {
|
|
264
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
246
265
|
try {
|
|
247
266
|
const word = await c.readContract({
|
|
248
|
-
address: kernelPool,
|
|
267
|
+
address: p.kernelPool,
|
|
249
268
|
abi: import_amm_bindings.KernelPoolABI,
|
|
250
269
|
functionName: "tickBitmap",
|
|
251
|
-
args: [wordPos]
|
|
270
|
+
args: [p.wordPos]
|
|
252
271
|
});
|
|
253
272
|
return word;
|
|
254
273
|
} catch (err) {
|
|
255
274
|
throw wrapReadError(err, "readTickBitmap");
|
|
256
275
|
}
|
|
257
276
|
}
|
|
258
|
-
async function readTick(
|
|
259
|
-
const c = resolveKernelClient(mode, client);
|
|
277
|
+
async function readTick(p) {
|
|
278
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
260
279
|
try {
|
|
261
280
|
const raw = await c.readContract({
|
|
262
|
-
address: kernelPool,
|
|
281
|
+
address: p.kernelPool,
|
|
263
282
|
abi: import_amm_bindings.KernelPoolABI,
|
|
264
283
|
functionName: "ticks",
|
|
265
|
-
args: [tick]
|
|
284
|
+
args: [p.tick]
|
|
266
285
|
});
|
|
267
286
|
return {
|
|
268
287
|
liquidityGross: raw[0],
|
|
@@ -278,10 +297,10 @@ async function readTick(kernelPool, tick, mode, client) {
|
|
|
278
297
|
throw wrapReadError(err, "readTick");
|
|
279
298
|
}
|
|
280
299
|
}
|
|
281
|
-
async function computePositionAmounts(
|
|
282
|
-
const c = resolveKernelClient(mode, client);
|
|
283
|
-
const position = await readPosition(tokenId, mode, c);
|
|
284
|
-
const { slot0 } = await readPool(position.pool, mode, c);
|
|
300
|
+
async function computePositionAmounts(p) {
|
|
301
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
302
|
+
const position = await readPosition({ tokenId: p.tokenId, mode: p.mode, client: c });
|
|
303
|
+
const { slot0 } = await readPool({ kernelPool: position.pool, mode: p.mode, client: c });
|
|
285
304
|
const sqrtLower = (0, import_amm_core_v23.getSqrtRatioAtTick)(position.tickLower);
|
|
286
305
|
const sqrtUpper = (0, import_amm_core_v23.getSqrtRatioAtTick)(position.tickUpper);
|
|
287
306
|
if (slot0.tick < position.tickLower) {
|
|
@@ -312,45 +331,23 @@ async function computePositionAmounts(tokenId, mode, client) {
|
|
|
312
331
|
};
|
|
313
332
|
}
|
|
314
333
|
|
|
315
|
-
// src/kernel/tickBitmap.ts
|
|
316
|
-
function decodeTickBitmapWord(word, wordPos, tickSpacing) {
|
|
317
|
-
if (!Number.isSafeInteger(wordPos)) {
|
|
318
|
-
throw new RangeError(
|
|
319
|
-
`decodeTickBitmapWord: wordPos must be a safe integer, got ${wordPos}`
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
if (!Number.isSafeInteger(tickSpacing) || tickSpacing <= 0) {
|
|
323
|
-
throw new RangeError(
|
|
324
|
-
`decodeTickBitmapWord: tickSpacing must be a positive integer, got ${tickSpacing}`
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
const result = [];
|
|
328
|
-
const base = wordPos * 256;
|
|
329
|
-
for (let k = 0; k < 256; k++) {
|
|
330
|
-
if ((word >> BigInt(k) & 1n) === 1n) {
|
|
331
|
-
result.push((base + k) * tickSpacing);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return result;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
334
|
// src/kernel/lens.ts
|
|
338
335
|
var import_amm_bindings2 = require("@skate-org/amm-bindings");
|
|
339
336
|
var import_amm_core_v24 = require("@skate-org/amm-core-v2");
|
|
340
|
-
async function simulateSwap(
|
|
341
|
-
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(mode);
|
|
342
|
-
const c = resolveKernelClient(mode, client);
|
|
337
|
+
async function simulateSwap(p) {
|
|
338
|
+
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(p.mode);
|
|
339
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
343
340
|
try {
|
|
344
341
|
const out = await c.simulateContract({
|
|
345
342
|
address: (0, import_amm_core_v24.KernelManagerAddress)(baseMode),
|
|
346
343
|
abi: import_amm_bindings2.KernelManagerABI,
|
|
347
344
|
functionName: "lensSwap",
|
|
348
345
|
args: [
|
|
349
|
-
params.pool,
|
|
350
|
-
params.recipient,
|
|
351
|
-
params.zeroForOne,
|
|
352
|
-
params.amountSpecified,
|
|
353
|
-
params.sqrtPriceLimitX96
|
|
346
|
+
p.params.pool,
|
|
347
|
+
p.params.recipient,
|
|
348
|
+
p.params.zeroForOne,
|
|
349
|
+
p.params.amountSpecified,
|
|
350
|
+
p.params.sqrtPriceLimitX96
|
|
354
351
|
]
|
|
355
352
|
});
|
|
356
353
|
const [amount0, amount1, sqrtPriceX96After, returnData] = out.result;
|
|
@@ -359,22 +356,22 @@ async function simulateSwap(params, mode, client) {
|
|
|
359
356
|
throw wrapReadError(err, "simulateSwap");
|
|
360
357
|
}
|
|
361
358
|
}
|
|
362
|
-
async function simulateMint(
|
|
363
|
-
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(mode);
|
|
364
|
-
const c = resolveKernelClient(mode, client);
|
|
359
|
+
async function simulateMint(p) {
|
|
360
|
+
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(p.mode);
|
|
361
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
365
362
|
try {
|
|
366
363
|
const out = await c.simulateContract({
|
|
367
364
|
address: (0, import_amm_core_v24.KernelManagerAddress)(baseMode),
|
|
368
365
|
abi: import_amm_bindings2.KernelManagerABI,
|
|
369
366
|
functionName: "lensMint",
|
|
370
367
|
args: [
|
|
371
|
-
params.pool,
|
|
372
|
-
params.recipient,
|
|
373
|
-
params.tickLower,
|
|
374
|
-
params.tickUpper,
|
|
375
|
-
params.amount0,
|
|
376
|
-
params.amount1,
|
|
377
|
-
params.data
|
|
368
|
+
p.params.pool,
|
|
369
|
+
p.params.recipient,
|
|
370
|
+
p.params.tickLower,
|
|
371
|
+
p.params.tickUpper,
|
|
372
|
+
p.params.amount0,
|
|
373
|
+
p.params.amount1,
|
|
374
|
+
p.params.data
|
|
378
375
|
]
|
|
379
376
|
});
|
|
380
377
|
const [amount0Used, amount1Used, liquidityAmount, returnData] = out.result;
|
|
@@ -383,20 +380,20 @@ async function simulateMint(params, mode, client) {
|
|
|
383
380
|
throw wrapReadError(err, "simulateMint");
|
|
384
381
|
}
|
|
385
382
|
}
|
|
386
|
-
async function simulateBurn(
|
|
387
|
-
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(mode);
|
|
388
|
-
const c = resolveKernelClient(mode, client);
|
|
383
|
+
async function simulateBurn(p) {
|
|
384
|
+
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(p.mode);
|
|
385
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
389
386
|
try {
|
|
390
387
|
const out = await c.simulateContract({
|
|
391
388
|
address: (0, import_amm_core_v24.KernelManagerAddress)(baseMode),
|
|
392
389
|
abi: import_amm_bindings2.KernelManagerABI,
|
|
393
390
|
functionName: "lensBurn",
|
|
394
391
|
args: [
|
|
395
|
-
params.pool,
|
|
396
|
-
params.recipient,
|
|
397
|
-
params.tickLower,
|
|
398
|
-
params.tickUpper,
|
|
399
|
-
params.amount
|
|
392
|
+
p.params.pool,
|
|
393
|
+
p.params.recipient,
|
|
394
|
+
p.params.tickLower,
|
|
395
|
+
p.params.tickUpper,
|
|
396
|
+
p.params.amount
|
|
400
397
|
]
|
|
401
398
|
});
|
|
402
399
|
const [amount0, amount1, returnData] = out.result;
|
|
@@ -405,15 +402,15 @@ async function simulateBurn(params, mode, client) {
|
|
|
405
402
|
throw wrapReadError(err, "simulateBurn");
|
|
406
403
|
}
|
|
407
404
|
}
|
|
408
|
-
async function simulateDecreaseLiquidity(
|
|
409
|
-
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(mode);
|
|
410
|
-
const c = resolveKernelClient(mode, client);
|
|
405
|
+
async function simulateDecreaseLiquidity(p) {
|
|
406
|
+
const { mode: baseMode } = (0, import_amm_core_v24.normalizeMode)(p.mode);
|
|
407
|
+
const c = resolveKernelClient(p.mode, p.client);
|
|
411
408
|
try {
|
|
412
409
|
const out = await c.simulateContract({
|
|
413
410
|
address: (0, import_amm_core_v24.KernelManagerAddress)(baseMode),
|
|
414
411
|
abi: import_amm_bindings2.KernelManagerABI,
|
|
415
412
|
functionName: "lensDecreaseLiquidity",
|
|
416
|
-
args: [params.tokenId, params.liquidity]
|
|
413
|
+
args: [p.params.tokenId, p.params.liquidity]
|
|
417
414
|
});
|
|
418
415
|
const [amount0, amount1, returnData] = out.result;
|
|
419
416
|
return { amount0, amount1, returnData };
|
|
@@ -428,21 +425,21 @@ var import_amm_core_v25 = require("@skate-org/amm-core-v2");
|
|
|
428
425
|
function resolveClient(chain, mode, client) {
|
|
429
426
|
return client ?? getSourcePublicClient(chain, mode);
|
|
430
427
|
}
|
|
431
|
-
async function readPeripheryPool(
|
|
432
|
-
const { mode: baseMode } = (0, import_amm_core_v25.normalizeMode)(mode);
|
|
428
|
+
async function readPeripheryPool(p) {
|
|
429
|
+
const { mode: baseMode } = (0, import_amm_core_v25.normalizeMode)(p.mode);
|
|
433
430
|
const details = (0, import_amm_core_v25.getPeripheryDetailsByKernelPoolAndChainId)(
|
|
434
|
-
kernelPool,
|
|
435
|
-
chain,
|
|
431
|
+
p.kernelPool,
|
|
432
|
+
p.chain,
|
|
436
433
|
baseMode
|
|
437
434
|
);
|
|
438
435
|
if (!details) {
|
|
439
436
|
throw new EvmReadError(
|
|
440
437
|
"readPeripheryPool",
|
|
441
|
-
`no periphery entry for kernelPool=${kernelPool} chain=${chain} mode=${baseMode}`
|
|
438
|
+
`no periphery entry for kernelPool=${p.kernelPool} chain=${p.chain} mode=${baseMode}`
|
|
442
439
|
);
|
|
443
440
|
}
|
|
444
441
|
const address = details.address;
|
|
445
|
-
const c = resolveClient(chain, mode, client);
|
|
442
|
+
const c = resolveClient(p.chain, p.mode, p.client);
|
|
446
443
|
try {
|
|
447
444
|
const [
|
|
448
445
|
balancesAvailableRaw,
|
|
@@ -507,26 +504,24 @@ async function readPeripheryPool(chain, kernelPool, mode, client) {
|
|
|
507
504
|
throw wrapReadError(err, "readPeripheryPool");
|
|
508
505
|
}
|
|
509
506
|
}
|
|
510
|
-
async function readUserPoolBalances(
|
|
511
|
-
const { mode: baseMode } = (0, import_amm_core_v25.normalizeMode)(mode);
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
);
|
|
517
|
-
if (!details) {
|
|
507
|
+
async function readUserPoolBalances(p) {
|
|
508
|
+
const { mode: baseMode } = (0, import_amm_core_v25.normalizeMode)(p.mode);
|
|
509
|
+
const core = new import_amm_core_v25.AmmCore(p.mode);
|
|
510
|
+
const info = core.getPoolInfoByKey(p.poolKey);
|
|
511
|
+
const periphery = info?.peripheryInfo[p.chain];
|
|
512
|
+
if (!periphery?.address) {
|
|
518
513
|
throw new EvmReadError(
|
|
519
514
|
"readUserPoolBalances",
|
|
520
|
-
`no periphery entry for
|
|
515
|
+
`no periphery entry for poolKey=${p.poolKey} chain=${p.chain} mode=${baseMode}`
|
|
521
516
|
);
|
|
522
517
|
}
|
|
523
|
-
const c = resolveClient(chain, mode, client);
|
|
518
|
+
const c = resolveClient(p.chain, p.mode, p.client);
|
|
524
519
|
try {
|
|
525
520
|
const raw = await c.readContract({
|
|
526
|
-
address:
|
|
521
|
+
address: periphery.address,
|
|
527
522
|
abi: import_amm_bindings3.PeripheryPoolABI,
|
|
528
523
|
functionName: "usersData",
|
|
529
|
-
args: [user]
|
|
524
|
+
args: [p.user]
|
|
530
525
|
});
|
|
531
526
|
if (Array.isArray(raw)) {
|
|
532
527
|
const tuple = raw;
|
|
@@ -584,9 +579,403 @@ async function submitApproval(wallet, params, mode) {
|
|
|
584
579
|
}
|
|
585
580
|
}
|
|
586
581
|
|
|
587
|
-
// src/
|
|
582
|
+
// src/periphery/calldata.ts
|
|
588
583
|
var import_viem2 = require("viem");
|
|
589
584
|
var import_amm_bindings4 = require("@skate-org/amm-bindings");
|
|
585
|
+
var import_amm_core_v26 = require("@skate-org/amm-core-v2");
|
|
586
|
+
function resolvePeripheryTarget(poolKey, chain, mode) {
|
|
587
|
+
const core = new import_amm_core_v26.AmmCore(mode);
|
|
588
|
+
const info = core.getPoolInfoByKey(poolKey);
|
|
589
|
+
if (!info) throw new Error(`unknown poolKey: ${poolKey}`);
|
|
590
|
+
const periphery = info.peripheryInfo[chain];
|
|
591
|
+
if (!periphery?.address) {
|
|
592
|
+
throw new Error(`pool ${poolKey} has no periphery on chain ${chain}`);
|
|
593
|
+
}
|
|
594
|
+
return periphery.address;
|
|
595
|
+
}
|
|
596
|
+
function encodeSwap(params) {
|
|
597
|
+
const {
|
|
598
|
+
recipient,
|
|
599
|
+
zeroForOne,
|
|
600
|
+
amount,
|
|
601
|
+
sqrtPriceLimitX96,
|
|
602
|
+
destVmType,
|
|
603
|
+
destChainId,
|
|
604
|
+
minAmountOut,
|
|
605
|
+
deadline
|
|
606
|
+
} = params;
|
|
607
|
+
const extraData = (0, import_viem2.encodeAbiParameters)(
|
|
608
|
+
(0, import_viem2.parseAbiParameters)("uint256,uint256,uint256,uint256"),
|
|
609
|
+
[
|
|
610
|
+
minAmountOut ?? 0n,
|
|
611
|
+
BigInt(destChainId),
|
|
612
|
+
BigInt(destVmType),
|
|
613
|
+
deadline ?? import_viem2.maxUint256
|
|
614
|
+
]
|
|
615
|
+
);
|
|
616
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
617
|
+
abi: import_amm_bindings4.PeripheryPoolABI,
|
|
618
|
+
functionName: "swap",
|
|
619
|
+
args: [recipient, zeroForOne, amount, sqrtPriceLimitX96, extraData]
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
function encodeMint(params) {
|
|
623
|
+
const {
|
|
624
|
+
recipient,
|
|
625
|
+
tickLower,
|
|
626
|
+
tickUpper,
|
|
627
|
+
amount0,
|
|
628
|
+
amount1,
|
|
629
|
+
amount0Min,
|
|
630
|
+
amount1Min,
|
|
631
|
+
deadline
|
|
632
|
+
} = params;
|
|
633
|
+
const extraData = (0, import_viem2.encodeAbiParameters)(
|
|
634
|
+
(0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
|
|
635
|
+
[amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
|
|
636
|
+
);
|
|
637
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
638
|
+
abi: import_amm_bindings4.PeripheryPoolABI,
|
|
639
|
+
functionName: "mint",
|
|
640
|
+
args: [recipient, tickLower, tickUpper, amount0, amount1, extraData]
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
function encodeBurn(params) {
|
|
644
|
+
const { tokenId, amount0Min, amount1Min, deadline } = params;
|
|
645
|
+
const extraData = (0, import_viem2.encodeAbiParameters)(
|
|
646
|
+
(0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
|
|
647
|
+
[amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
|
|
648
|
+
);
|
|
649
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
650
|
+
abi: import_amm_bindings4.PeripheryPoolABI,
|
|
651
|
+
functionName: "burn",
|
|
652
|
+
args: [tokenId, extraData]
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
function encodeIncreaseLiquidity(params) {
|
|
656
|
+
const { tokenId, amount0, amount1, amount0Min, amount1Min, deadline } = params;
|
|
657
|
+
const extraData = (0, import_viem2.encodeAbiParameters)(
|
|
658
|
+
(0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
|
|
659
|
+
[amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
|
|
660
|
+
);
|
|
661
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
662
|
+
abi: import_amm_bindings4.PeripheryPoolABI,
|
|
663
|
+
functionName: "increaseLiquidity",
|
|
664
|
+
args: [tokenId, amount0, amount1, extraData]
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
function encodeDecreaseLiquidity(params) {
|
|
668
|
+
const { tokenId, liquidityAmount, amount0Min, amount1Min, deadline } = params;
|
|
669
|
+
const extraData = (0, import_viem2.encodeAbiParameters)(
|
|
670
|
+
(0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
|
|
671
|
+
[amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
|
|
672
|
+
);
|
|
673
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
674
|
+
abi: import_amm_bindings4.PeripheryPoolABI,
|
|
675
|
+
functionName: "decreaseLiquidity",
|
|
676
|
+
args: [tokenId, liquidityAmount, extraData]
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
async function buildSwap(params) {
|
|
680
|
+
const { poolKey, chain, mode, ...encodeParams } = params;
|
|
681
|
+
return {
|
|
682
|
+
target: resolvePeripheryTarget(poolKey, chain, mode),
|
|
683
|
+
calldata: encodeSwap(encodeParams)
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
async function buildMint(params) {
|
|
687
|
+
const { poolKey, chain, mode, ...encodeParams } = params;
|
|
688
|
+
return {
|
|
689
|
+
target: resolvePeripheryTarget(poolKey, chain, mode),
|
|
690
|
+
calldata: encodeMint(encodeParams)
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
async function buildBurn(params) {
|
|
694
|
+
const { poolKey, chain, mode, ...encodeParams } = params;
|
|
695
|
+
return {
|
|
696
|
+
target: resolvePeripheryTarget(poolKey, chain, mode),
|
|
697
|
+
calldata: encodeBurn(encodeParams)
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
async function buildIncreaseLiquidity(params) {
|
|
701
|
+
const { poolKey, chain, mode, ...encodeParams } = params;
|
|
702
|
+
return {
|
|
703
|
+
target: resolvePeripheryTarget(poolKey, chain, mode),
|
|
704
|
+
calldata: encodeIncreaseLiquidity(encodeParams)
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
async function buildDecreaseLiquidity(params) {
|
|
708
|
+
const { poolKey, chain, mode, ...encodeParams } = params;
|
|
709
|
+
return {
|
|
710
|
+
target: resolvePeripheryTarget(poolKey, chain, mode),
|
|
711
|
+
calldata: encodeDecreaseLiquidity(encodeParams)
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// src/client.ts
|
|
716
|
+
var AmmEvm = class {
|
|
717
|
+
env;
|
|
718
|
+
constructor(env) {
|
|
719
|
+
this.env = env;
|
|
720
|
+
}
|
|
721
|
+
// ── Kernel readers ────────────────────────────────────────────────────────
|
|
722
|
+
readPool(p) {
|
|
723
|
+
return readPool({ ...p, mode: this.env, client: p.client });
|
|
724
|
+
}
|
|
725
|
+
readKernelBalances(p) {
|
|
726
|
+
return readKernelBalances({ ...p, mode: this.env, client: p.client });
|
|
727
|
+
}
|
|
728
|
+
readPosition(p) {
|
|
729
|
+
return readPosition({ ...p, mode: this.env, client: p.client });
|
|
730
|
+
}
|
|
731
|
+
readTickBitmap(p) {
|
|
732
|
+
return readTickBitmap({ ...p, mode: this.env, client: p.client });
|
|
733
|
+
}
|
|
734
|
+
readTick(p) {
|
|
735
|
+
return readTick({ ...p, mode: this.env, client: p.client });
|
|
736
|
+
}
|
|
737
|
+
computePositionAmounts(p) {
|
|
738
|
+
return computePositionAmounts({ ...p, mode: this.env, client: p.client });
|
|
739
|
+
}
|
|
740
|
+
// ── Kernel lens (simulate) ────────────────────────────────────────────────
|
|
741
|
+
simulateSwap(p) {
|
|
742
|
+
return simulateSwap({ ...p, mode: this.env, client: p.client });
|
|
743
|
+
}
|
|
744
|
+
simulateMint(p) {
|
|
745
|
+
return simulateMint({ ...p, mode: this.env, client: p.client });
|
|
746
|
+
}
|
|
747
|
+
simulateBurn(p) {
|
|
748
|
+
return simulateBurn({ ...p, mode: this.env, client: p.client });
|
|
749
|
+
}
|
|
750
|
+
simulateDecreaseLiquidity(p) {
|
|
751
|
+
return simulateDecreaseLiquidity({ ...p, mode: this.env, client: p.client });
|
|
752
|
+
}
|
|
753
|
+
// ── Periphery readers ─────────────────────────────────────────────────────
|
|
754
|
+
readPeripheryPool(p) {
|
|
755
|
+
return readPeripheryPool({ ...p, mode: this.env, client: p.client });
|
|
756
|
+
}
|
|
757
|
+
readUserPoolBalances(p) {
|
|
758
|
+
return readUserPoolBalances({ ...p, mode: this.env, client: p.client });
|
|
759
|
+
}
|
|
760
|
+
// ── Periphery calldata builders ───────────────────────────────────────────
|
|
761
|
+
buildSwap(p) {
|
|
762
|
+
return buildSwap({ ...p, mode: this.env });
|
|
763
|
+
}
|
|
764
|
+
buildMint(p) {
|
|
765
|
+
return buildMint({ ...p, mode: this.env });
|
|
766
|
+
}
|
|
767
|
+
buildBurn(p) {
|
|
768
|
+
return buildBurn({ ...p, mode: this.env });
|
|
769
|
+
}
|
|
770
|
+
buildIncreaseLiquidity(p) {
|
|
771
|
+
return buildIncreaseLiquidity({ ...p, mode: this.env });
|
|
772
|
+
}
|
|
773
|
+
buildDecreaseLiquidity(p) {
|
|
774
|
+
return buildDecreaseLiquidity({ ...p, mode: this.env });
|
|
775
|
+
}
|
|
776
|
+
// ── Periphery submitters ──────────────────────────────────────────────────
|
|
777
|
+
submitAction(wallet, params) {
|
|
778
|
+
return submitAction(wallet, params, this.env);
|
|
779
|
+
}
|
|
780
|
+
submitSwap(wallet, params) {
|
|
781
|
+
return submitSwap(wallet, params, this.env);
|
|
782
|
+
}
|
|
783
|
+
submitApproval(wallet, params) {
|
|
784
|
+
return submitApproval(wallet, params, this.env);
|
|
785
|
+
}
|
|
786
|
+
/** EVM submits any action via the same path — alias of `submitAction`. */
|
|
787
|
+
submitMint(wallet, params) {
|
|
788
|
+
return submitAction(wallet, params, this.env);
|
|
789
|
+
}
|
|
790
|
+
/** EVM submits any action via the same path — alias of `submitAction`. */
|
|
791
|
+
submitBurn(wallet, params) {
|
|
792
|
+
return submitAction(wallet, params, this.env);
|
|
793
|
+
}
|
|
794
|
+
/** EVM submits any action via the same path — alias of `submitAction`. */
|
|
795
|
+
submitIncreaseLiquidity(wallet, params) {
|
|
796
|
+
return submitAction(wallet, params, this.env);
|
|
797
|
+
}
|
|
798
|
+
/** EVM submits any action via the same path — alias of `submitAction`. */
|
|
799
|
+
submitDecreaseLiquidity(wallet, params) {
|
|
800
|
+
return submitAction(wallet, params, this.env);
|
|
801
|
+
}
|
|
802
|
+
// ── Chain-client factories ────────────────────────────────────────────────
|
|
803
|
+
getKernelPublicClient(transport) {
|
|
804
|
+
return getKernelPublicClient(this.env, transport);
|
|
805
|
+
}
|
|
806
|
+
getSourcePublicClient(chain, transport) {
|
|
807
|
+
return getSourcePublicClient(chain, this.env, transport);
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
// src/skate-amm.ts
|
|
812
|
+
var import_amm_core_v27 = require("@skate-org/amm-core-v2");
|
|
813
|
+
var import_amm_api_v2 = require("@skate-org/amm-api-v2");
|
|
814
|
+
var SkateAmm = class {
|
|
815
|
+
env;
|
|
816
|
+
core;
|
|
817
|
+
api;
|
|
818
|
+
vm;
|
|
819
|
+
quote;
|
|
820
|
+
actions;
|
|
821
|
+
pools;
|
|
822
|
+
constructor(env) {
|
|
823
|
+
this.env = env;
|
|
824
|
+
this.core = new import_amm_core_v27.AmmCore(env);
|
|
825
|
+
this.api = new import_amm_api_v2.AmmApi(env);
|
|
826
|
+
this.vm = new AmmEvm(env);
|
|
827
|
+
const api = this.api;
|
|
828
|
+
const core = this.core;
|
|
829
|
+
this.quote = {
|
|
830
|
+
swap: api.swapQuote.bind(api),
|
|
831
|
+
mint: api.mintQuote.bind(api),
|
|
832
|
+
burn: api.burnQuote.bind(api),
|
|
833
|
+
increaseLiquidity: api.increaseLiquidityQuote.bind(api),
|
|
834
|
+
decreaseLiquidity: api.decreaseLiquidityQuote.bind(api),
|
|
835
|
+
boostedMint: api.boostedMintQuote.bind(api),
|
|
836
|
+
boostedRange: api.boostedRangeQuote.bind(api),
|
|
837
|
+
streamSwap: api.streamSwapQuote.bind(api),
|
|
838
|
+
subscribeSwap: api.subscribeSwapQuote.bind(api)
|
|
839
|
+
};
|
|
840
|
+
this.actions = {
|
|
841
|
+
get: api.getAction.bind(api),
|
|
842
|
+
byUser: api.getActionsByUser.bind(api),
|
|
843
|
+
byUserTimeRange: api.getActionsByUserTimeRange.bind(api),
|
|
844
|
+
waitForExecuted: api.waitForExecuted.bind(api),
|
|
845
|
+
position: api.getPosition.bind(api)
|
|
846
|
+
};
|
|
847
|
+
this.pools = {
|
|
848
|
+
all: core.getAllPoolInfo.bind(core),
|
|
849
|
+
keys: core.getAllPoolKeys.bind(core),
|
|
850
|
+
byKey: core.getPoolInfoByKey.bind(core),
|
|
851
|
+
supportedChains: core.getSupportedChains.bind(core),
|
|
852
|
+
supportedPairs: core.getSupportedPairs.bind(core),
|
|
853
|
+
supportedTokens: core.getSupportedTokens.bind(core),
|
|
854
|
+
keyByKernelPool: core.kernelPoolToPoolKey.bind(core)
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
// ── AmmVmClient: builders ────────────────────────────────────────────────────
|
|
858
|
+
buildSwap(p) {
|
|
859
|
+
return this.vm.buildSwap(p);
|
|
860
|
+
}
|
|
861
|
+
buildMint(p) {
|
|
862
|
+
return this.vm.buildMint(p);
|
|
863
|
+
}
|
|
864
|
+
buildBurn(p) {
|
|
865
|
+
return this.vm.buildBurn(p);
|
|
866
|
+
}
|
|
867
|
+
buildIncreaseLiquidity(p) {
|
|
868
|
+
return this.vm.buildIncreaseLiquidity(p);
|
|
869
|
+
}
|
|
870
|
+
buildDecreaseLiquidity(p) {
|
|
871
|
+
return this.vm.buildDecreaseLiquidity(p);
|
|
872
|
+
}
|
|
873
|
+
// ── AmmVmClient: submitters ──────────────────────────────────────────────────
|
|
874
|
+
submitSwap(w, p) {
|
|
875
|
+
return this.vm.submitSwap(w, p);
|
|
876
|
+
}
|
|
877
|
+
submitMint(w, p) {
|
|
878
|
+
return this.vm.submitMint(w, p);
|
|
879
|
+
}
|
|
880
|
+
submitBurn(w, p) {
|
|
881
|
+
return this.vm.submitBurn(w, p);
|
|
882
|
+
}
|
|
883
|
+
submitIncreaseLiquidity(w, p) {
|
|
884
|
+
return this.vm.submitIncreaseLiquidity(w, p);
|
|
885
|
+
}
|
|
886
|
+
submitDecreaseLiquidity(w, p) {
|
|
887
|
+
return this.vm.submitDecreaseLiquidity(w, p);
|
|
888
|
+
}
|
|
889
|
+
// ── AmmVmClient: readers ─────────────────────────────────────────────────────
|
|
890
|
+
readPeripheryPool(p) {
|
|
891
|
+
return this.vm.readPeripheryPool(p);
|
|
892
|
+
}
|
|
893
|
+
readUserPoolBalances(p) {
|
|
894
|
+
return this.vm.readUserPoolBalances(p);
|
|
895
|
+
}
|
|
896
|
+
// ── EVM extras ───────────────────────────────────────────────────────────────
|
|
897
|
+
/** Read raw kernel pool slot. */
|
|
898
|
+
readPool(p) {
|
|
899
|
+
return this.vm.readPool(p);
|
|
900
|
+
}
|
|
901
|
+
readKernelBalances(p) {
|
|
902
|
+
return this.vm.readKernelBalances(p);
|
|
903
|
+
}
|
|
904
|
+
readPosition(p) {
|
|
905
|
+
return this.vm.readPosition(p);
|
|
906
|
+
}
|
|
907
|
+
readTickBitmap(p) {
|
|
908
|
+
return this.vm.readTickBitmap(p);
|
|
909
|
+
}
|
|
910
|
+
readTick(p) {
|
|
911
|
+
return this.vm.readTick(p);
|
|
912
|
+
}
|
|
913
|
+
computePositionAmounts(p) {
|
|
914
|
+
return this.vm.computePositionAmounts(p);
|
|
915
|
+
}
|
|
916
|
+
simulateSwap(p) {
|
|
917
|
+
return this.vm.simulateSwap(p);
|
|
918
|
+
}
|
|
919
|
+
simulateMint(p) {
|
|
920
|
+
return this.vm.simulateMint(p);
|
|
921
|
+
}
|
|
922
|
+
simulateBurn(p) {
|
|
923
|
+
return this.vm.simulateBurn(p);
|
|
924
|
+
}
|
|
925
|
+
simulateDecreaseLiquidity(p) {
|
|
926
|
+
return this.vm.simulateDecreaseLiquidity(p);
|
|
927
|
+
}
|
|
928
|
+
submitAction(w, p) {
|
|
929
|
+
return this.vm.submitAction(w, p);
|
|
930
|
+
}
|
|
931
|
+
submitApproval(w, p) {
|
|
932
|
+
return this.vm.submitApproval(w, p);
|
|
933
|
+
}
|
|
934
|
+
getKernelPublicClient(...args) {
|
|
935
|
+
return this.vm.getKernelPublicClient(...args);
|
|
936
|
+
}
|
|
937
|
+
getSourcePublicClient(...args) {
|
|
938
|
+
return this.vm.getSourcePublicClient(...args);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
// src/devConfig.ts
|
|
943
|
+
var DEFAULT_DEV_API_ENDPOINT = "https://dev.api.skatechain.org/amm-action-v2";
|
|
944
|
+
function createDevConfig(overrides = {}) {
|
|
945
|
+
return {
|
|
946
|
+
mode: "DEV",
|
|
947
|
+
config: {
|
|
948
|
+
apiEndpoint: overrides.apiEndpoint ?? DEFAULT_DEV_API_ENDPOINT,
|
|
949
|
+
...overrides.rpcEndpoints ? { rpcEndpoints: overrides.rpcEndpoints } : {}
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// src/kernel/tickBitmap.ts
|
|
955
|
+
function decodeTickBitmapWord(word, wordPos, tickSpacing) {
|
|
956
|
+
if (!Number.isSafeInteger(wordPos)) {
|
|
957
|
+
throw new RangeError(
|
|
958
|
+
`decodeTickBitmapWord: wordPos must be a safe integer, got ${wordPos}`
|
|
959
|
+
);
|
|
960
|
+
}
|
|
961
|
+
if (!Number.isSafeInteger(tickSpacing) || tickSpacing <= 0) {
|
|
962
|
+
throw new RangeError(
|
|
963
|
+
`decodeTickBitmapWord: tickSpacing must be a positive integer, got ${tickSpacing}`
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
const result = [];
|
|
967
|
+
const base = wordPos * 256;
|
|
968
|
+
for (let k = 0; k < 256; k++) {
|
|
969
|
+
if ((word >> BigInt(k) & 1n) === 1n) {
|
|
970
|
+
result.push((base + k) * tickSpacing);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
return result;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
// src/events/kernel.ts
|
|
977
|
+
var import_viem3 = require("viem");
|
|
978
|
+
var import_amm_bindings5 = require("@skate-org/amm-bindings");
|
|
590
979
|
var KERNEL_EVENT_NAMES = [
|
|
591
980
|
"Burn",
|
|
592
981
|
"Collect",
|
|
@@ -603,8 +992,8 @@ var KERNEL_EVENT_NAMES = [
|
|
|
603
992
|
];
|
|
604
993
|
function parseKernelEventLog(log) {
|
|
605
994
|
try {
|
|
606
|
-
const decoded = (0,
|
|
607
|
-
abi:
|
|
995
|
+
const decoded = (0, import_viem3.decodeEventLog)({
|
|
996
|
+
abi: import_amm_bindings5.KernelEventEmitterABI,
|
|
608
997
|
data: log.data,
|
|
609
998
|
topics: log.topics
|
|
610
999
|
});
|
|
@@ -624,8 +1013,8 @@ function parseKernelEventLog(log) {
|
|
|
624
1013
|
}
|
|
625
1014
|
|
|
626
1015
|
// src/events/periphery.ts
|
|
627
|
-
var
|
|
628
|
-
var
|
|
1016
|
+
var import_viem4 = require("viem");
|
|
1017
|
+
var import_amm_bindings6 = require("@skate-org/amm-bindings");
|
|
629
1018
|
var PERIPHERY_EVENT_NAMES = [
|
|
630
1019
|
"AmountSettled",
|
|
631
1020
|
"Burned",
|
|
@@ -640,8 +1029,8 @@ var PERIPHERY_EVENT_NAMES = [
|
|
|
640
1029
|
];
|
|
641
1030
|
function parsePeripheryEventLog(log) {
|
|
642
1031
|
try {
|
|
643
|
-
const decoded = (0,
|
|
644
|
-
abi:
|
|
1032
|
+
const decoded = (0, import_viem4.decodeEventLog)({
|
|
1033
|
+
abi: import_amm_bindings6.PeripheryEventEmitterABI,
|
|
645
1034
|
data: log.data,
|
|
646
1035
|
topics: log.topics
|
|
647
1036
|
});
|
|
@@ -661,10 +1050,10 @@ function parsePeripheryEventLog(log) {
|
|
|
661
1050
|
}
|
|
662
1051
|
|
|
663
1052
|
// src/events/watch.ts
|
|
664
|
-
var
|
|
1053
|
+
var import_amm_bindings7 = require("@skate-org/amm-bindings");
|
|
665
1054
|
function watchKernelEvents(client, address, opts) {
|
|
666
1055
|
return client.watchContractEvent({
|
|
667
|
-
abi:
|
|
1056
|
+
abi: import_amm_bindings7.KernelEventEmitterABI,
|
|
668
1057
|
address,
|
|
669
1058
|
onLogs: (logs) => {
|
|
670
1059
|
for (const log of logs) {
|
|
@@ -679,7 +1068,7 @@ function watchKernelEvents(client, address, opts) {
|
|
|
679
1068
|
}
|
|
680
1069
|
function watchPeripheryEvents(client, address, opts) {
|
|
681
1070
|
return client.watchContractEvent({
|
|
682
|
-
abi:
|
|
1071
|
+
abi: import_amm_bindings7.PeripheryEventEmitterABI,
|
|
683
1072
|
address,
|
|
684
1073
|
onLogs: (logs) => {
|
|
685
1074
|
for (const log of logs) {
|
|
@@ -694,10 +1083,17 @@ function watchPeripheryEvents(client, address, opts) {
|
|
|
694
1083
|
}
|
|
695
1084
|
// Annotate the CommonJS export names for ESM import in node:
|
|
696
1085
|
0 && (module.exports = {
|
|
1086
|
+
AmmEvm,
|
|
697
1087
|
EvmReadError,
|
|
698
1088
|
EvmWriteError,
|
|
699
1089
|
KERNEL_EVENT_NAMES,
|
|
700
1090
|
PERIPHERY_EVENT_NAMES,
|
|
1091
|
+
SkateAmm,
|
|
1092
|
+
buildBurn,
|
|
1093
|
+
buildDecreaseLiquidity,
|
|
1094
|
+
buildIncreaseLiquidity,
|
|
1095
|
+
buildMint,
|
|
1096
|
+
buildSwap,
|
|
701
1097
|
computePositionAmounts,
|
|
702
1098
|
createDevConfig,
|
|
703
1099
|
decodeTickBitmapWord,
|
|
@@ -706,6 +1102,7 @@ function watchPeripheryEvents(client, address, opts) {
|
|
|
706
1102
|
megaethChain,
|
|
707
1103
|
parseKernelEventLog,
|
|
708
1104
|
parsePeripheryEventLog,
|
|
1105
|
+
readKernelBalances,
|
|
709
1106
|
readPeripheryPool,
|
|
710
1107
|
readPool,
|
|
711
1108
|
readPosition,
|