@pina-rs/amm 0.1.0 → 0.2.1
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/dist/index.cjs +501 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +451 -11
- package/dist/index.d.ts +451 -11
- package/dist/index.js +445 -16
- package/dist/index.js.map +1 -1
- package/package.json +59 -58
- package/src/generated/accounts/pool.ts +64 -8
- package/src/generated/errors/pinaAmm.ts +4 -2
- package/src/generated/events/configCreated.ts +80 -0
- package/src/generated/events/configUpdated.ts +64 -0
- package/src/generated/events/index.ts +5 -0
- package/src/generated/events/logs.ts +362 -2
- package/src/generated/events/poolCreatorChanged.ts +56 -0
- package/src/generated/events/poolSynced.ts +78 -0
- package/src/generated/events/poolSyncedV0.ts +44 -0
- package/src/generated/instructions/index.ts +1 -0
- package/src/generated/instructions/syncPool.ts +93 -0
- package/src/generated/pdas/ammConfig.ts +1 -1
- package/src/generated/pdas/pool.ts +1 -1
- package/src/generated/pdas/poolLpMint.ts +1 -1
- package/src/generated/pdas/poolVault.ts +1 -1
- package/src/generated/programs/pinaAmm.ts +17 -8
|
@@ -29,6 +29,31 @@ import {
|
|
|
29
29
|
getFeesCollectedEventDiscriminatorBytes,
|
|
30
30
|
type FeesCollectedEvent,
|
|
31
31
|
} from "./feesCollected.js";
|
|
32
|
+
import {
|
|
33
|
+
getPoolSyncedEventDecoder,
|
|
34
|
+
getPoolSyncedEventDiscriminatorBytes,
|
|
35
|
+
type PoolSyncedEvent,
|
|
36
|
+
} from "./poolSynced.js";
|
|
37
|
+
import {
|
|
38
|
+
getPoolSyncedV0EventDecoder,
|
|
39
|
+
getPoolSyncedV0EventDiscriminatorBytes,
|
|
40
|
+
type PoolSyncedV0Event,
|
|
41
|
+
} from "./poolSyncedV0.js";
|
|
42
|
+
import {
|
|
43
|
+
getConfigCreatedEventDecoder,
|
|
44
|
+
getConfigCreatedEventDiscriminatorBytes,
|
|
45
|
+
type ConfigCreatedEvent,
|
|
46
|
+
} from "./configCreated.js";
|
|
47
|
+
import {
|
|
48
|
+
getConfigUpdatedEventDecoder,
|
|
49
|
+
getConfigUpdatedEventDiscriminatorBytes,
|
|
50
|
+
type ConfigUpdatedEvent,
|
|
51
|
+
} from "./configUpdated.js";
|
|
52
|
+
import {
|
|
53
|
+
getPoolCreatorChangedEventDecoder,
|
|
54
|
+
getPoolCreatorChangedEventDiscriminatorBytes,
|
|
55
|
+
type PoolCreatorChangedEvent,
|
|
56
|
+
} from "./poolCreatorChanged.js";
|
|
32
57
|
|
|
33
58
|
/**
|
|
34
59
|
* Decode one `poolCreated` record: only records carrying this event's migration version decode.
|
|
@@ -258,6 +283,291 @@ export function parseFeesCollectedEventFromLog(log: string): DecodedFeesCollecte
|
|
|
258
283
|
return decodeFeesCollectedEvent(bytes);
|
|
259
284
|
}
|
|
260
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Decode one `poolSynced` record: only records carrying this event's migration version decode.
|
|
288
|
+
*/
|
|
289
|
+
export function decodePoolSyncedEvent(
|
|
290
|
+
data: ReadonlyUint8Array | Uint8Array,
|
|
291
|
+
): DecodedPoolSyncedEvent {
|
|
292
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
293
|
+
const discriminatorBytes = getPoolSyncedEventDiscriminatorBytes();
|
|
294
|
+
if (bytes.length < 2) {
|
|
295
|
+
throw new RangeError(
|
|
296
|
+
`the provided data is too short for the "PoolSyncedEvent" event envelope`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
for (let index = 0; index < 1; index += 1) {
|
|
300
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
301
|
+
throw new RangeError(
|
|
302
|
+
'the provided data does not match the "PoolSyncedEvent" event discriminator.',
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const sourceVersion = bytes[1];
|
|
307
|
+
if (sourceVersion !== 1) {
|
|
308
|
+
throw new RangeError(
|
|
309
|
+
`event migration version mismatch: expected 1, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
return { name: "poolSynced", data: getPoolSyncedEventDecoder().decode(bytes) };
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** One log entry that named this event. */
|
|
316
|
+
export type DecodedPoolSyncedEvent = { name: "poolSynced"; data: PoolSyncedEvent };
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Decode a `Program data:` log line, or return `null` when the line is not
|
|
320
|
+
* this event.
|
|
321
|
+
*/
|
|
322
|
+
export function parsePoolSyncedEventFromLog(log: string): DecodedPoolSyncedEvent | null {
|
|
323
|
+
const prefix = "Program data: ";
|
|
324
|
+
if (!log.startsWith(prefix)) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
const bytes = getBase64Encoder().encode(log.slice(prefix.length));
|
|
328
|
+
if (bytes.length < 2) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
const discriminatorBytes = getPoolSyncedEventDiscriminatorBytes();
|
|
332
|
+
for (let index = 0; index < 1; index += 1) {
|
|
333
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (bytes[1] !== 1) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
return decodePoolSyncedEvent(bytes);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Decode one `poolSyncedV0` record: only records carrying this event's migration version decode.
|
|
345
|
+
*/
|
|
346
|
+
export function decodePoolSyncedV0Event(
|
|
347
|
+
data: ReadonlyUint8Array | Uint8Array,
|
|
348
|
+
): DecodedPoolSyncedV0Event {
|
|
349
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
350
|
+
const discriminatorBytes = getPoolSyncedV0EventDiscriminatorBytes();
|
|
351
|
+
if (bytes.length < 2) {
|
|
352
|
+
throw new RangeError(
|
|
353
|
+
`the provided data is too short for the "PoolSyncedV0Event" event envelope`,
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
for (let index = 0; index < 1; index += 1) {
|
|
357
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
358
|
+
throw new RangeError(
|
|
359
|
+
'the provided data does not match the "PoolSyncedV0Event" event discriminator.',
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const sourceVersion = bytes[1];
|
|
364
|
+
if (sourceVersion !== 0) {
|
|
365
|
+
throw new RangeError(
|
|
366
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`,
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
return { name: "poolSyncedV0", data: getPoolSyncedV0EventDecoder().decode(bytes) };
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** One log entry that named this event. */
|
|
373
|
+
export type DecodedPoolSyncedV0Event = { name: "poolSyncedV0"; data: PoolSyncedV0Event };
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Decode a `Program data:` log line, or return `null` when the line is not
|
|
377
|
+
* this event.
|
|
378
|
+
*/
|
|
379
|
+
export function parsePoolSyncedV0EventFromLog(log: string): DecodedPoolSyncedV0Event | null {
|
|
380
|
+
const prefix = "Program data: ";
|
|
381
|
+
if (!log.startsWith(prefix)) {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
const bytes = getBase64Encoder().encode(log.slice(prefix.length));
|
|
385
|
+
if (bytes.length < 2) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
const discriminatorBytes = getPoolSyncedV0EventDiscriminatorBytes();
|
|
389
|
+
for (let index = 0; index < 1; index += 1) {
|
|
390
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (bytes[1] !== 0) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
return decodePoolSyncedV0Event(bytes);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Decode one `configCreated` record: only records carrying this event's migration version decode.
|
|
402
|
+
*/
|
|
403
|
+
export function decodeConfigCreatedEvent(
|
|
404
|
+
data: ReadonlyUint8Array | Uint8Array,
|
|
405
|
+
): DecodedConfigCreatedEvent {
|
|
406
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
407
|
+
const discriminatorBytes = getConfigCreatedEventDiscriminatorBytes();
|
|
408
|
+
if (bytes.length < 2) {
|
|
409
|
+
throw new RangeError(
|
|
410
|
+
`the provided data is too short for the "ConfigCreatedEvent" event envelope`,
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
for (let index = 0; index < 1; index += 1) {
|
|
414
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
415
|
+
throw new RangeError(
|
|
416
|
+
'the provided data does not match the "ConfigCreatedEvent" event discriminator.',
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const sourceVersion = bytes[1];
|
|
421
|
+
if (sourceVersion !== 0) {
|
|
422
|
+
throw new RangeError(
|
|
423
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`,
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
return { name: "configCreated", data: getConfigCreatedEventDecoder().decode(bytes) };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** One log entry that named this event. */
|
|
430
|
+
export type DecodedConfigCreatedEvent = { name: "configCreated"; data: ConfigCreatedEvent };
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Decode a `Program data:` log line, or return `null` when the line is not
|
|
434
|
+
* this event.
|
|
435
|
+
*/
|
|
436
|
+
export function parseConfigCreatedEventFromLog(log: string): DecodedConfigCreatedEvent | null {
|
|
437
|
+
const prefix = "Program data: ";
|
|
438
|
+
if (!log.startsWith(prefix)) {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
const bytes = getBase64Encoder().encode(log.slice(prefix.length));
|
|
442
|
+
if (bytes.length < 2) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
const discriminatorBytes = getConfigCreatedEventDiscriminatorBytes();
|
|
446
|
+
for (let index = 0; index < 1; index += 1) {
|
|
447
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (bytes[1] !== 0) {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
return decodeConfigCreatedEvent(bytes);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Decode one `configUpdated` record: only records carrying this event's migration version decode.
|
|
459
|
+
*/
|
|
460
|
+
export function decodeConfigUpdatedEvent(
|
|
461
|
+
data: ReadonlyUint8Array | Uint8Array,
|
|
462
|
+
): DecodedConfigUpdatedEvent {
|
|
463
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
464
|
+
const discriminatorBytes = getConfigUpdatedEventDiscriminatorBytes();
|
|
465
|
+
if (bytes.length < 2) {
|
|
466
|
+
throw new RangeError(
|
|
467
|
+
`the provided data is too short for the "ConfigUpdatedEvent" event envelope`,
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
for (let index = 0; index < 1; index += 1) {
|
|
471
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
472
|
+
throw new RangeError(
|
|
473
|
+
'the provided data does not match the "ConfigUpdatedEvent" event discriminator.',
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const sourceVersion = bytes[1];
|
|
478
|
+
if (sourceVersion !== 0) {
|
|
479
|
+
throw new RangeError(
|
|
480
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`,
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
return { name: "configUpdated", data: getConfigUpdatedEventDecoder().decode(bytes) };
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** One log entry that named this event. */
|
|
487
|
+
export type DecodedConfigUpdatedEvent = { name: "configUpdated"; data: ConfigUpdatedEvent };
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Decode a `Program data:` log line, or return `null` when the line is not
|
|
491
|
+
* this event.
|
|
492
|
+
*/
|
|
493
|
+
export function parseConfigUpdatedEventFromLog(log: string): DecodedConfigUpdatedEvent | null {
|
|
494
|
+
const prefix = "Program data: ";
|
|
495
|
+
if (!log.startsWith(prefix)) {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
const bytes = getBase64Encoder().encode(log.slice(prefix.length));
|
|
499
|
+
if (bytes.length < 2) {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
const discriminatorBytes = getConfigUpdatedEventDiscriminatorBytes();
|
|
503
|
+
for (let index = 0; index < 1; index += 1) {
|
|
504
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (bytes[1] !== 0) {
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
return decodeConfigUpdatedEvent(bytes);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Decode one `poolCreatorChanged` record: only records carrying this event's migration version decode.
|
|
516
|
+
*/
|
|
517
|
+
export function decodePoolCreatorChangedEvent(
|
|
518
|
+
data: ReadonlyUint8Array | Uint8Array,
|
|
519
|
+
): DecodedPoolCreatorChangedEvent {
|
|
520
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
521
|
+
const discriminatorBytes = getPoolCreatorChangedEventDiscriminatorBytes();
|
|
522
|
+
if (bytes.length < 2) {
|
|
523
|
+
throw new RangeError(
|
|
524
|
+
`the provided data is too short for the "PoolCreatorChangedEvent" event envelope`,
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
for (let index = 0; index < 1; index += 1) {
|
|
528
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
529
|
+
throw new RangeError(
|
|
530
|
+
'the provided data does not match the "PoolCreatorChangedEvent" event discriminator.',
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
const sourceVersion = bytes[1];
|
|
535
|
+
if (sourceVersion !== 0) {
|
|
536
|
+
throw new RangeError(
|
|
537
|
+
`event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`,
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
return { name: "poolCreatorChanged", data: getPoolCreatorChangedEventDecoder().decode(bytes) };
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** One log entry that named this event. */
|
|
544
|
+
export type DecodedPoolCreatorChangedEvent = { name: "poolCreatorChanged"; data: PoolCreatorChangedEvent };
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Decode a `Program data:` log line, or return `null` when the line is not
|
|
548
|
+
* this event.
|
|
549
|
+
*/
|
|
550
|
+
export function parsePoolCreatorChangedEventFromLog(log: string): DecodedPoolCreatorChangedEvent | null {
|
|
551
|
+
const prefix = "Program data: ";
|
|
552
|
+
if (!log.startsWith(prefix)) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
const bytes = getBase64Encoder().encode(log.slice(prefix.length));
|
|
556
|
+
if (bytes.length < 2) {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
const discriminatorBytes = getPoolCreatorChangedEventDiscriminatorBytes();
|
|
560
|
+
for (let index = 0; index < 1; index += 1) {
|
|
561
|
+
if (bytes[index] !== discriminatorBytes[index]) {
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (bytes[1] !== 0) {
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
return decodePoolCreatorChangedEvent(bytes);
|
|
569
|
+
}
|
|
570
|
+
|
|
261
571
|
|
|
262
572
|
/**
|
|
263
573
|
* Explain a `Program data:` line that names a migration-aware event but that
|
|
@@ -289,6 +599,26 @@ function unrecognizedEventVersion(log: string): string | null {
|
|
|
289
599
|
? 'event "feesCollected" log is too short for its version envelope'
|
|
290
600
|
: `event "feesCollected" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
291
601
|
}
|
|
602
|
+
if (bytes.length >= 1 && bytes[0] === 5) {
|
|
603
|
+
return bytes.length < 2
|
|
604
|
+
? 'event "poolSynced" log is too short for its version envelope'
|
|
605
|
+
: `event "poolSynced" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
606
|
+
}
|
|
607
|
+
if (bytes.length >= 1 && bytes[0] === 8) {
|
|
608
|
+
return bytes.length < 2
|
|
609
|
+
? 'event "configCreated" log is too short for its version envelope'
|
|
610
|
+
: `event "configCreated" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
611
|
+
}
|
|
612
|
+
if (bytes.length >= 1 && bytes[0] === 6) {
|
|
613
|
+
return bytes.length < 2
|
|
614
|
+
? 'event "configUpdated" log is too short for its version envelope'
|
|
615
|
+
: `event "configUpdated" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
616
|
+
}
|
|
617
|
+
if (bytes.length >= 1 && bytes[0] === 7) {
|
|
618
|
+
return bytes.length < 2
|
|
619
|
+
? 'event "poolCreatorChanged" log is too short for its version envelope'
|
|
620
|
+
: `event "poolCreatorChanged" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
|
|
621
|
+
}
|
|
292
622
|
return null;
|
|
293
623
|
}
|
|
294
624
|
|
|
@@ -297,10 +627,15 @@ export type DecodedPinaAmmEvent =
|
|
|
297
627
|
| DecodedPoolCreatedEvent
|
|
298
628
|
| DecodedSwappedEvent
|
|
299
629
|
| DecodedLiquidityChangedEvent
|
|
300
|
-
| DecodedFeesCollectedEvent
|
|
630
|
+
| DecodedFeesCollectedEvent
|
|
631
|
+
| DecodedPoolSyncedEvent
|
|
632
|
+
| DecodedPoolSyncedV0Event
|
|
633
|
+
| DecodedConfigCreatedEvent
|
|
634
|
+
| DecodedConfigUpdatedEvent
|
|
635
|
+
| DecodedPoolCreatorChangedEvent;
|
|
301
636
|
|
|
302
637
|
/** The program whose invocation frames emit the events decoded here. */
|
|
303
|
-
export const PINA_AMM_EVENT_SOURCE_ADDRESS = "
|
|
638
|
+
export const PINA_AMM_EVENT_SOURCE_ADDRESS = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi";
|
|
304
639
|
|
|
305
640
|
const PROGRAM_INVOKE_LOG = /^Program (\S+) invoke \[\d+\]$/;
|
|
306
641
|
const PROGRAM_EXIT_LOG = /^Program (\S+) (?:success|failed: .*)$/;
|
|
@@ -363,6 +698,31 @@ export function parsePinaAmmEventsFromLogs(
|
|
|
363
698
|
discovered.push(feesCollected);
|
|
364
699
|
continue;
|
|
365
700
|
}
|
|
701
|
+
const poolSynced = parsePoolSyncedEventFromLog(log);
|
|
702
|
+
if (poolSynced !== null) {
|
|
703
|
+
discovered.push(poolSynced);
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
const poolSyncedV0 = parsePoolSyncedV0EventFromLog(log);
|
|
707
|
+
if (poolSyncedV0 !== null) {
|
|
708
|
+
discovered.push(poolSyncedV0);
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
const configCreated = parseConfigCreatedEventFromLog(log);
|
|
712
|
+
if (configCreated !== null) {
|
|
713
|
+
discovered.push(configCreated);
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
const configUpdated = parseConfigUpdatedEventFromLog(log);
|
|
717
|
+
if (configUpdated !== null) {
|
|
718
|
+
discovered.push(configUpdated);
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
const poolCreatorChanged = parsePoolCreatorChangedEventFromLog(log);
|
|
722
|
+
if (poolCreatorChanged !== null) {
|
|
723
|
+
discovered.push(poolCreatorChanged);
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
366
726
|
const unknownVersion = unrecognizedEventVersion(log);
|
|
367
727
|
if (unknownVersion !== null) {
|
|
368
728
|
throw new RangeError(unknownVersion);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getPinaPodDiscriminatorDecoder, getPinaPodMigrationVersionDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, containsBytes, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR = 7;
|
|
13
|
+
|
|
14
|
+
export function getPoolCreatorChangedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getPoolCreatorChangedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Emitted by `SetPoolCreator`. */
|
|
21
|
+
export type PoolCreatorChangedEvent = { discriminator: number; migrationVersion: number;
|
|
22
|
+
/** The pool whose creator-fee rights moved. */
|
|
23
|
+
pool: Address;
|
|
24
|
+
/** The previous creator. */
|
|
25
|
+
previousCreator: Address;
|
|
26
|
+
/** The new creator. */
|
|
27
|
+
newCreator: Address; };
|
|
28
|
+
|
|
29
|
+
export type PoolCreatorChangedEventArgs = {
|
|
30
|
+
/** The pool whose creator-fee rights moved. */
|
|
31
|
+
pool: Address;
|
|
32
|
+
/** The previous creator. */
|
|
33
|
+
previousCreator: Address;
|
|
34
|
+
/** The new creator. */
|
|
35
|
+
newCreator: Address; };
|
|
36
|
+
|
|
37
|
+
/** Gets the encoder for {@link PoolCreatorChangedEventArgs} event data. */
|
|
38
|
+
export function getPoolCreatorChangedEventEncoder(): FixedSizeEncoder<PoolCreatorChangedEventArgs> {
|
|
39
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['previousCreator', getAddressEncoder()], ['newCreator', getAddressEncoder()]]), (value) => ({ ...value, discriminator: 7, migrationVersion: 0 }));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Gets the decoder for {@link PoolCreatorChangedEvent} event data. */
|
|
43
|
+
export function getPoolCreatorChangedEventDecoder(): FixedSizeDecoder<PoolCreatorChangedEvent> {
|
|
44
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['pool', getAddressDecoder()], ['previousCreator', getAddressDecoder()], ['newCreator', getAddressDecoder()]]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Gets the codec for {@link PoolCreatorChangedEvent} event data. */
|
|
48
|
+
export function getPoolCreatorChangedEventCodec(): FixedSizeCodec<PoolCreatorChangedEventArgs, PoolCreatorChangedEvent> {
|
|
49
|
+
return combineCodec(getPoolCreatorChangedEventEncoder(), getPoolCreatorChangedEventDecoder());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Parses the provided bytes into {@link PoolCreatorChangedEvent} event data. */
|
|
53
|
+
export function parsePoolCreatorChangedEvent(data: ReadonlyUint8Array | Uint8Array): PoolCreatorChangedEvent {
|
|
54
|
+
if (containsBytes(data, getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2), 1)) { return getPoolCreatorChangedEventDecoder().decode(data); }
|
|
55
|
+
throw new Error('The provided data does not match the "PoolCreatorChangedEvent" event discriminators.');
|
|
56
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getPinaPodDiscriminatorDecoder, getPinaPodMigrationVersionDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, containsBytes, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU128Decoder, getU128Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const POOL_SYNCED_EVENT_DISCRIMINATOR = 5;
|
|
13
|
+
|
|
14
|
+
export function getPoolSyncedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const POOL_SYNCED_EVENT_DISCRIMINATOR2 = 1;
|
|
17
|
+
|
|
18
|
+
export function getPoolSyncedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Emitted by `SyncPool`. Swaps, deposits, and withdrawals advance the same
|
|
22
|
+
* accumulator and report their effect through `Swapped` and
|
|
23
|
+
* `LiquidityChanged`.
|
|
24
|
+
*/
|
|
25
|
+
export type PoolSyncedEvent = { discriminator: number; migrationVersion: number;
|
|
26
|
+
/** The pool whose accumulator advanced. */
|
|
27
|
+
pool: Address;
|
|
28
|
+
/** Token 0 reserve recorded at the advance; it prices the next interval. */
|
|
29
|
+
reserve0: bigint;
|
|
30
|
+
/** Token 1 reserve recorded at the advance; it prices the next interval. */
|
|
31
|
+
reserve1: bigint;
|
|
32
|
+
/**
|
|
33
|
+
* Low 128 bits of the Q64.64 price-time integral after the advance.
|
|
34
|
+
* Combine with `price_0_cumulative_high_last` as `low + high * 2^128`.
|
|
35
|
+
*/
|
|
36
|
+
price0CumulativeLast: bigint;
|
|
37
|
+
/** High 128 bits of the Q64.64 price-time integral after the advance. */
|
|
38
|
+
price0CumulativeHighLast: bigint;
|
|
39
|
+
/** Unix second of the advance. */
|
|
40
|
+
lastUpdateTimestamp: bigint; };
|
|
41
|
+
|
|
42
|
+
export type PoolSyncedEventArgs = {
|
|
43
|
+
/** The pool whose accumulator advanced. */
|
|
44
|
+
pool: Address;
|
|
45
|
+
/** Token 0 reserve recorded at the advance; it prices the next interval. */
|
|
46
|
+
reserve0: number | bigint;
|
|
47
|
+
/** Token 1 reserve recorded at the advance; it prices the next interval. */
|
|
48
|
+
reserve1: number | bigint;
|
|
49
|
+
/**
|
|
50
|
+
* Low 128 bits of the Q64.64 price-time integral after the advance.
|
|
51
|
+
* Combine with `price_0_cumulative_high_last` as `low + high * 2^128`.
|
|
52
|
+
*/
|
|
53
|
+
price0CumulativeLast: number | bigint;
|
|
54
|
+
/** High 128 bits of the Q64.64 price-time integral after the advance. */
|
|
55
|
+
price0CumulativeHighLast: number | bigint;
|
|
56
|
+
/** Unix second of the advance. */
|
|
57
|
+
lastUpdateTimestamp: number | bigint; };
|
|
58
|
+
|
|
59
|
+
/** Gets the encoder for {@link PoolSyncedEventArgs} event data. */
|
|
60
|
+
export function getPoolSyncedEventEncoder(): FixedSizeEncoder<PoolSyncedEventArgs> {
|
|
61
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['reserve0', getU64Encoder()], ['reserve1', getU64Encoder()], ['price0CumulativeLast', getU128Encoder()], ['price0CumulativeHighLast', getU128Encoder()], ['lastUpdateTimestamp', getU64Encoder()]]), (value) => ({ ...value, discriminator: 5, migrationVersion: 1 }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Gets the decoder for {@link PoolSyncedEvent} event data. */
|
|
65
|
+
export function getPoolSyncedEventDecoder(): FixedSizeDecoder<PoolSyncedEvent> {
|
|
66
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_SYNCED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(1, getU8Decoder())], ['pool', getAddressDecoder()], ['reserve0', getU64Decoder()], ['reserve1', getU64Decoder()], ['price0CumulativeLast', getU128Decoder()], ['price0CumulativeHighLast', getU128Decoder()], ['lastUpdateTimestamp', getU64Decoder()]]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Gets the codec for {@link PoolSyncedEvent} event data. */
|
|
70
|
+
export function getPoolSyncedEventCodec(): FixedSizeCodec<PoolSyncedEventArgs, PoolSyncedEvent> {
|
|
71
|
+
return combineCodec(getPoolSyncedEventEncoder(), getPoolSyncedEventDecoder());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Parses the provided bytes into {@link PoolSyncedEvent} event data. */
|
|
75
|
+
export function parsePoolSyncedEvent(data: ReadonlyUint8Array | Uint8Array): PoolSyncedEvent {
|
|
76
|
+
if (containsBytes(data, getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2), 1)) { return getPoolSyncedEventDecoder().decode(data); }
|
|
77
|
+
throw new Error('The provided data does not match the "PoolSyncedEvent" event discriminators.');
|
|
78
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getPinaPodDiscriminatorDecoder, getPinaPodMigrationVersionDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, containsBytes, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU128Decoder, getU128Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const POOL_SYNCED_V0_EVENT_DISCRIMINATOR = 5;
|
|
13
|
+
|
|
14
|
+
export function getPoolSyncedV0EventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const POOL_SYNCED_V0_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getPoolSyncedV0EventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Version 0 of `PoolSynced`, as emitted before its current layout. Log records carrying this version decode with this event. */
|
|
21
|
+
export type PoolSyncedV0Event = { discriminator: number; migrationVersion: number; pool: Address; reserve0: bigint; reserve1: bigint; price0CumulativeLast: bigint; lastUpdateTimestamp: bigint; };
|
|
22
|
+
|
|
23
|
+
export type PoolSyncedV0EventArgs = { pool: Address; reserve0: number | bigint; reserve1: number | bigint; price0CumulativeLast: number | bigint; lastUpdateTimestamp: number | bigint; };
|
|
24
|
+
|
|
25
|
+
/** Gets the encoder for {@link PoolSyncedV0EventArgs} event data. */
|
|
26
|
+
export function getPoolSyncedV0EventEncoder(): FixedSizeEncoder<PoolSyncedV0EventArgs> {
|
|
27
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['reserve0', getU64Encoder()], ['reserve1', getU64Encoder()], ['price0CumulativeLast', getU128Encoder()], ['lastUpdateTimestamp', getU64Encoder()]]), (value) => ({ ...value, discriminator: 5, migrationVersion: 0 }));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Gets the decoder for {@link PoolSyncedV0Event} event data. */
|
|
31
|
+
export function getPoolSyncedV0EventDecoder(): FixedSizeDecoder<PoolSyncedV0Event> {
|
|
32
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_SYNCED_V0_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['pool', getAddressDecoder()], ['reserve0', getU64Decoder()], ['reserve1', getU64Decoder()], ['price0CumulativeLast', getU128Decoder()], ['lastUpdateTimestamp', getU64Decoder()]]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Gets the codec for {@link PoolSyncedV0Event} event data. */
|
|
36
|
+
export function getPoolSyncedV0EventCodec(): FixedSizeCodec<PoolSyncedV0EventArgs, PoolSyncedV0Event> {
|
|
37
|
+
return combineCodec(getPoolSyncedV0EventEncoder(), getPoolSyncedV0EventDecoder());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Parses the provided bytes into {@link PoolSyncedV0Event} event data. */
|
|
41
|
+
export function parsePoolSyncedV0Event(data: ReadonlyUint8Array | Uint8Array): PoolSyncedV0Event {
|
|
42
|
+
if (containsBytes(data, getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2), 1)) { return getPoolSyncedV0EventDecoder().decode(data); }
|
|
43
|
+
throw new Error('The provided data does not match the "PoolSyncedV0Event" event discriminators.');
|
|
44
|
+
}
|