@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 CHANGED
@@ -26,19 +26,19 @@ function getPinaPodMigrationVersionDecoder(expected, decoder) {
26
26
  });
27
27
  }
28
28
  async function findAmmConfigPda(seeds, config = {}) {
29
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
29
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
30
30
  return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("amm_config"), kit.getU16Encoder().encode(seeds.index)] });
31
31
  }
32
32
  async function findPoolPda(seeds, config = {}) {
33
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
33
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
34
34
  return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("pool"), kit.getAddressEncoder().encode(seeds.ammConfig), kit.getAddressEncoder().encode(seeds.mint0), kit.getAddressEncoder().encode(seeds.mint1)] });
35
35
  }
36
36
  async function findPoolLpMintPda(seeds, config = {}) {
37
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
37
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
38
38
  return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("pool_lp_mint"), kit.getAddressEncoder().encode(seeds.pool)] });
39
39
  }
40
40
  async function findPoolVaultPda(seeds, config = {}) {
41
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
41
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
42
42
  return await kit.getProgramDerivedAddress({ programAddress, seeds: [kit.getUtf8Encoder().encode("pool_vault"), kit.getAddressEncoder().encode(seeds.pool), kit.getAddressEncoder().encode(seeds.mint)] });
43
43
  }
44
44
 
@@ -105,15 +105,15 @@ var POOL_DISCRIMINATOR = 2;
105
105
  function getPoolDiscriminatorBytes() {
106
106
  return kit.getU8Encoder().encode(POOL_DISCRIMINATOR);
107
107
  }
108
- var POOL_DISCRIMINATOR2 = 0;
108
+ var POOL_DISCRIMINATOR2 = 1;
109
109
  function getPoolDiscriminator2Bytes() {
110
110
  return kit.getU8Encoder().encode(POOL_DISCRIMINATOR2);
111
111
  }
112
112
  function getPoolEncoder() {
113
- return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["ammConfig", kit.getAddressEncoder()], ["creator", kit.getAddressEncoder()], ["mint0", kit.getAddressEncoder()], ["mint1", kit.getAddressEncoder()], ["vault0", kit.getAddressEncoder()], ["vault1", kit.getAddressEncoder()], ["lpMint", kit.getAddressEncoder()], ["lpSupply", kit.getU64Encoder()], ["protocolFees0", kit.getU64Encoder()], ["protocolFees1", kit.getU64Encoder()], ["creatorFees0", kit.getU64Encoder()], ["creatorFees1", kit.getU64Encoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()], ["creatorFeeMode", kit.getU8Encoder()], ["bump", kit.getU8Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 0 }));
113
+ return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["ammConfig", kit.getAddressEncoder()], ["creator", kit.getAddressEncoder()], ["mint0", kit.getAddressEncoder()], ["mint1", kit.getAddressEncoder()], ["vault0", kit.getAddressEncoder()], ["vault1", kit.getAddressEncoder()], ["lpMint", kit.getAddressEncoder()], ["lpSupply", kit.getU64Encoder()], ["protocolFees0", kit.getU64Encoder()], ["protocolFees1", kit.getU64Encoder()], ["creatorFees0", kit.getU64Encoder()], ["creatorFees1", kit.getU64Encoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()], ["creatorFeeMode", kit.getU8Encoder()], ["bump", kit.getU8Encoder()], ["price0CumulativeLast", kit.getU128Encoder()], ["price0CumulativeHighLast", kit.getU128Encoder()], ["lastUpdateTimestamp", kit.getU64Encoder()], ["reserve0Last", kit.getU64Encoder()], ["reserve1Last", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 1 }));
114
114
  }
115
115
  function getPoolDecoder() {
116
- return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["ammConfig", kit.getAddressDecoder()], ["creator", kit.getAddressDecoder()], ["mint0", kit.getAddressDecoder()], ["mint1", kit.getAddressDecoder()], ["vault0", kit.getAddressDecoder()], ["vault1", kit.getAddressDecoder()], ["lpMint", kit.getAddressDecoder()], ["lpSupply", kit.getU64Decoder()], ["protocolFees0", kit.getU64Decoder()], ["protocolFees1", kit.getU64Decoder()], ["creatorFees0", kit.getU64Decoder()], ["creatorFees1", kit.getU64Decoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()], ["creatorFeeMode", kit.getU8Decoder()], ["bump", kit.getU8Decoder()]]);
116
+ return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(1, kit.getU8Decoder())], ["ammConfig", kit.getAddressDecoder()], ["creator", kit.getAddressDecoder()], ["mint0", kit.getAddressDecoder()], ["mint1", kit.getAddressDecoder()], ["vault0", kit.getAddressDecoder()], ["vault1", kit.getAddressDecoder()], ["lpMint", kit.getAddressDecoder()], ["lpSupply", kit.getU64Decoder()], ["protocolFees0", kit.getU64Decoder()], ["protocolFees1", kit.getU64Decoder()], ["creatorFees0", kit.getU64Decoder()], ["creatorFees1", kit.getU64Decoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()], ["creatorFeeMode", kit.getU8Decoder()], ["bump", kit.getU8Decoder()], ["price0CumulativeLast", kit.getU128Decoder()], ["price0CumulativeHighLast", kit.getU128Decoder()], ["lastUpdateTimestamp", kit.getU64Decoder()], ["reserve0Last", kit.getU64Decoder()], ["reserve1Last", kit.getU64Decoder()]]);
117
117
  }
118
118
  function getPoolCodec() {
119
119
  return kit.combineCodec(getPoolEncoder(), getPoolDecoder());
@@ -149,7 +149,7 @@ async function fetchMaybePoolFromSeeds(rpc, seeds, config = {}) {
149
149
  const [address] = await findPoolPda(seeds, { programAddress });
150
150
  return await fetchMaybePool(rpc, address, fetchConfig);
151
151
  }
152
- var POOL_MIGRATION_VERSION = 0;
152
+ var POOL_MIGRATION_VERSION = 1;
153
153
  function poolNeedsMigration(data) {
154
154
  if (data.length < 2) {
155
155
  return false;
@@ -157,7 +157,7 @@ function poolNeedsMigration(data) {
157
157
  if (data[0] !== 2) {
158
158
  return false;
159
159
  }
160
- return data[1] < 0;
160
+ return data[1] < 1;
161
161
  }
162
162
  var MIGRATE_DISCRIMINATOR = 255;
163
163
  function getMigrateDiscriminatorBytes() {
@@ -490,6 +490,38 @@ function parseSwapExactOutInstruction(instruction) {
490
490
  };
491
491
  return { programAddress: instruction.programAddress, accounts: { trader: getNextAccount(), pool: getNextAccount(), inputToken: getNextAccount(), outputToken: getNextAccount(), inputVault: getNextAccount(), outputVault: getNextAccount(), inputTokenProgram: getNextAccount(), outputTokenProgram: getNextAccount() }, data: getSwapExactOutInstructionDataDecoder().decode(instruction.data) };
492
492
  }
493
+ var SYNC_POOL_DISCRIMINATOR = 10;
494
+ function getSyncPoolDiscriminatorBytes() {
495
+ return kit.getU8Encoder().encode(SYNC_POOL_DISCRIMINATOR);
496
+ }
497
+ function getSyncPoolInstructionDataEncoder() {
498
+ return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()]]), (value) => ({ ...value, discriminator: 10 }));
499
+ }
500
+ function getSyncPoolInstructionDataDecoder() {
501
+ return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(SYNC_POOL_DISCRIMINATOR, kit.getU8Decoder())]]);
502
+ }
503
+ function getSyncPoolInstructionDataCodec() {
504
+ return kit.combineCodec(getSyncPoolInstructionDataEncoder(), getSyncPoolInstructionDataDecoder());
505
+ }
506
+ function getSyncPoolInstruction(input, config) {
507
+ const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
508
+ const getAccountMeta = programClientCore.getAccountMetaFactory(programAddress, "programId");
509
+ const originalAccounts = { pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: false }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: false }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false } };
510
+ const accounts = originalAccounts;
511
+ return Object.freeze({ accounts: [getAccountMeta("pool", accounts.pool), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1)], data: getSyncPoolInstructionDataEncoder().encode({}), programAddress });
512
+ }
513
+ function parseSyncPoolInstruction(instruction) {
514
+ if (instruction.accounts.length < 5) {
515
+ throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 5 });
516
+ }
517
+ let accountIndex = 0;
518
+ const getNextAccount = () => {
519
+ const accountMeta = instruction.accounts[accountIndex];
520
+ accountIndex += 1;
521
+ return accountMeta;
522
+ };
523
+ return { programAddress: instruction.programAddress, accounts: { pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount() }, data: getSyncPoolInstructionDataDecoder().decode(instruction.data) };
524
+ }
493
525
  var UPDATE_CONFIG_DISCRIMINATOR = 1;
494
526
  function getUpdateConfigDiscriminatorBytes() {
495
527
  return kit.getU8Encoder().encode(UPDATE_CONFIG_DISCRIMINATOR);
@@ -561,7 +593,7 @@ function parseWithdrawInstruction(instruction) {
561
593
  }
562
594
 
563
595
  // src/generated/programs/pinaAmm.ts
564
- var PINA_AMM_PROGRAM_ADDRESS = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV";
596
+ var PINA_AMM_PROGRAM_ADDRESS = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi";
565
597
  var PinaAmmAccount = /* @__PURE__ */ ((PinaAmmAccount2) => {
566
598
  PinaAmmAccount2[PinaAmmAccount2["AmmConfig"] = 0] = "AmmConfig";
567
599
  PinaAmmAccount2[PinaAmmAccount2["Pool"] = 1] = "Pool";
@@ -572,7 +604,7 @@ function identifyPinaAmmAccount(account) {
572
604
  if (kit.containsBytes(data, kit.getU8Encoder().encode(1), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
573
605
  return 0 /* AmmConfig */;
574
606
  }
575
- if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
607
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(1), 1)) {
576
608
  return 1 /* Pool */;
577
609
  }
578
610
  throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, { accountData: data, programName: "pinaAmm" });
@@ -582,6 +614,11 @@ var PinaAmmEvent = /* @__PURE__ */ ((PinaAmmEvent2) => {
582
614
  PinaAmmEvent2[PinaAmmEvent2["Swapped"] = 1] = "Swapped";
583
615
  PinaAmmEvent2[PinaAmmEvent2["LiquidityChanged"] = 2] = "LiquidityChanged";
584
616
  PinaAmmEvent2[PinaAmmEvent2["FeesCollected"] = 3] = "FeesCollected";
617
+ PinaAmmEvent2[PinaAmmEvent2["PoolSynced"] = 4] = "PoolSynced";
618
+ PinaAmmEvent2[PinaAmmEvent2["PoolSyncedV0"] = 5] = "PoolSyncedV0";
619
+ PinaAmmEvent2[PinaAmmEvent2["ConfigCreated"] = 6] = "ConfigCreated";
620
+ PinaAmmEvent2[PinaAmmEvent2["ConfigUpdated"] = 7] = "ConfigUpdated";
621
+ PinaAmmEvent2[PinaAmmEvent2["PoolCreatorChanged"] = 8] = "PoolCreatorChanged";
585
622
  return PinaAmmEvent2;
586
623
  })(PinaAmmEvent || {});
587
624
  function identifyPinaAmmEvent(event) {
@@ -598,6 +635,21 @@ function identifyPinaAmmEvent(event) {
598
635
  if (kit.containsBytes(data, kit.getU8Encoder().encode(4), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
599
636
  return 3 /* FeesCollected */;
600
637
  }
638
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(5), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(1), 1)) {
639
+ return 4 /* PoolSynced */;
640
+ }
641
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(5), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
642
+ return 5 /* PoolSyncedV0 */;
643
+ }
644
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(8), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
645
+ return 6 /* ConfigCreated */;
646
+ }
647
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(6), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
648
+ return 7 /* ConfigUpdated */;
649
+ }
650
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(7), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(0), 1)) {
651
+ return 8 /* PoolCreatorChanged */;
652
+ }
601
653
  throw new Error("The provided event could not be identified as a pinaAmm event.");
602
654
  }
603
655
  var PinaAmmInstruction = /* @__PURE__ */ ((PinaAmmInstruction2) => {
@@ -611,6 +663,7 @@ var PinaAmmInstruction = /* @__PURE__ */ ((PinaAmmInstruction2) => {
611
663
  PinaAmmInstruction2[PinaAmmInstruction2["CollectProtocolFees"] = 7] = "CollectProtocolFees";
612
664
  PinaAmmInstruction2[PinaAmmInstruction2["CollectCreatorFees"] = 8] = "CollectCreatorFees";
613
665
  PinaAmmInstruction2[PinaAmmInstruction2["SetPoolCreator"] = 9] = "SetPoolCreator";
666
+ PinaAmmInstruction2[PinaAmmInstruction2["SyncPool"] = 10] = "SyncPool";
614
667
  return PinaAmmInstruction2;
615
668
  })(PinaAmmInstruction || {});
616
669
  function identifyPinaAmmInstruction(instruction) {
@@ -645,6 +698,9 @@ function identifyPinaAmmInstruction(instruction) {
645
698
  if (kit.containsBytes(data, kit.getU8Encoder().encode(9), 0)) {
646
699
  return 9 /* SetPoolCreator */;
647
700
  }
701
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(10), 0)) {
702
+ return 10 /* SyncPool */;
703
+ }
648
704
  throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, { instructionData: data, programName: "pinaAmm" });
649
705
  }
650
706
  function parsePinaAmmInstruction(instruction) {
@@ -690,6 +746,10 @@ function parsePinaAmmInstruction(instruction) {
690
746
  kit.assertIsInstructionWithAccounts(instruction);
691
747
  return { instructionType: 9 /* SetPoolCreator */, ...parseSetPoolCreatorInstruction(instruction) };
692
748
  }
749
+ case 10 /* SyncPool */: {
750
+ kit.assertIsInstructionWithAccounts(instruction);
751
+ return { instructionType: 10 /* SyncPool */, ...parseSyncPoolInstruction(instruction) };
752
+ }
693
753
  default:
694
754
  throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, { instructionType, programName: "pinaAmm" });
695
755
  }
@@ -707,7 +767,8 @@ function pinaAmmProgram() {
707
767
  swapExactOut: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSwapExactOutInstruction(input)),
708
768
  collectProtocolFees: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getCollectProtocolFeesInstruction(input)),
709
769
  collectCreatorFees: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getCollectCreatorFeesInstruction(input)),
710
- setPoolCreator: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSetPoolCreatorInstruction(input))
770
+ setPoolCreator: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSetPoolCreatorInstruction(input)),
771
+ syncPool: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSyncPoolInstruction(input))
711
772
  }, pdas: { ammConfig: findAmmConfigPda, pool: findPoolPda, poolVault: findPoolVaultPda, poolLpMint: findPoolLpMintPda }, identifyAccount: identifyPinaAmmAccount, identifyInstruction: identifyPinaAmmInstruction, parseInstruction: parsePinaAmmInstruction } });
712
773
  };
713
774
  }
@@ -728,9 +789,10 @@ var PINA_AMM_ERROR__MATH_OVERFLOW = 11;
728
789
  var PINA_AMM_ERROR__INVARIANT_VIOLATION = 12;
729
790
  var PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH = 13;
730
791
  var PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED = 14;
792
+ var PINA_AMM_ERROR__DEFAULT_CREATOR = 15;
731
793
  var pinaAmmErrorMessages;
732
794
  if (process.env["NODE_ENV"] !== "production") {
733
- pinaAmmErrorMessages = { [PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY]: `The initial deposit must mint more LP than the permanently locked minimum.`, [PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY]: `The pool cannot pay this amount from its reserves.`, [PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE]: `The creator fee mode must be 0 (input token), 1 (token 0), or 2 (token 1).`, [PINA_AMM_ERROR__INVALID_FEE_RATES]: `Fee rates are out of range: trade plus creator fee above 10% or protocol share above 100%.`, [PINA_AMM_ERROR__INVALID_MINT_ORDER]: `Pool mints must be distinct and passed in ascending byte order.`, [PINA_AMM_ERROR__INVALID_PROGRAM_DATA]: `The program-data account is not this program's, or the program is not upgradeable.`, [PINA_AMM_ERROR__INVARIANT_VIOLATION]: `The trade would decrease the pool's constant product.`, [PINA_AMM_ERROR__MATH_OVERFLOW]: `An intermediate value overflowed or did not fit its type.`, [PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH]: `A vault, LP mint, or fee tier account does not belong to this pool.`, [PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED]: `This fee tier only lets its pool-creator authority create pools.`, [PINA_AMM_ERROR__SLIPPAGE_EXCEEDED]: `The result is worse than the caller's slippage limit.`, [PINA_AMM_ERROR__UNAUTHORIZED]: `The signer is not the authority this instruction requires.`, [PINA_AMM_ERROR__UNSUPPORTED_MINT]: `The mint's token program or Token-2022 extensions are not supported.`, [PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH]: `A vault holds less than the fees accrued against it.`, [PINA_AMM_ERROR__ZERO_AMOUNT]: `An amount is zero or the trade rounds down to nothing.` };
795
+ pinaAmmErrorMessages = { [PINA_AMM_ERROR__DEFAULT_CREATOR]: `The pool creator may not be the default address, which can never sign or collect.`, [PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY]: `The initial deposit must mint more LP than the permanently locked minimum.`, [PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY]: `The pool cannot pay this amount from its reserves.`, [PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE]: `The creator fee mode must be 0 (input token), 1 (token 0), or 2 (token 1).`, [PINA_AMM_ERROR__INVALID_FEE_RATES]: `Fee rates are out of range: trade plus creator fee above 10% or protocol share above 100%.`, [PINA_AMM_ERROR__INVALID_MINT_ORDER]: `Pool mints must be distinct and passed in ascending byte order.`, [PINA_AMM_ERROR__INVALID_PROGRAM_DATA]: `The program-data account is not this program's, or the program is not upgradeable.`, [PINA_AMM_ERROR__INVARIANT_VIOLATION]: `The trade would decrease the pool's constant product.`, [PINA_AMM_ERROR__MATH_OVERFLOW]: `An intermediate value overflowed or did not fit its type.`, [PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH]: `A vault, LP mint, or fee tier account does not belong to this pool.`, [PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED]: `This fee tier only lets its pool-creator authority create pools.`, [PINA_AMM_ERROR__SLIPPAGE_EXCEEDED]: `The result is worse than the caller's slippage limit.`, [PINA_AMM_ERROR__UNAUTHORIZED]: `The signer is not the authority this instruction requires.`, [PINA_AMM_ERROR__UNSUPPORTED_MINT]: `The mint's token program or Token-2022 extensions are not supported.`, [PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH]: `A vault holds less than the fees accrued against it.`, [PINA_AMM_ERROR__ZERO_AMOUNT]: `An amount is zero or the trade rounds down to nothing.` };
734
796
  }
735
797
  function getPinaAmmErrorMessage(code) {
736
798
  if (process.env["NODE_ENV"] !== "production") {
@@ -833,6 +895,121 @@ function parseFeesCollectedEvent(data) {
833
895
  }
834
896
  throw new Error('The provided data does not match the "FeesCollectedEvent" event discriminators.');
835
897
  }
898
+ var POOL_SYNCED_EVENT_DISCRIMINATOR = 5;
899
+ function getPoolSyncedEventDiscriminatorBytes() {
900
+ return kit.getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR);
901
+ }
902
+ var POOL_SYNCED_EVENT_DISCRIMINATOR2 = 1;
903
+ function getPoolSyncedEventDiscriminator2Bytes() {
904
+ return kit.getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2);
905
+ }
906
+ function getPoolSyncedEventEncoder() {
907
+ return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["pool", kit.getAddressEncoder()], ["reserve0", kit.getU64Encoder()], ["reserve1", kit.getU64Encoder()], ["price0CumulativeLast", kit.getU128Encoder()], ["price0CumulativeHighLast", kit.getU128Encoder()], ["lastUpdateTimestamp", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 5, migrationVersion: 1 }));
908
+ }
909
+ function getPoolSyncedEventDecoder() {
910
+ return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_SYNCED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(1, kit.getU8Decoder())], ["pool", kit.getAddressDecoder()], ["reserve0", kit.getU64Decoder()], ["reserve1", kit.getU64Decoder()], ["price0CumulativeLast", kit.getU128Decoder()], ["price0CumulativeHighLast", kit.getU128Decoder()], ["lastUpdateTimestamp", kit.getU64Decoder()]]);
911
+ }
912
+ function getPoolSyncedEventCodec() {
913
+ return kit.combineCodec(getPoolSyncedEventEncoder(), getPoolSyncedEventDecoder());
914
+ }
915
+ function parsePoolSyncedEvent(data) {
916
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2), 1)) {
917
+ return getPoolSyncedEventDecoder().decode(data);
918
+ }
919
+ throw new Error('The provided data does not match the "PoolSyncedEvent" event discriminators.');
920
+ }
921
+ var POOL_SYNCED_V0_EVENT_DISCRIMINATOR = 5;
922
+ function getPoolSyncedV0EventDiscriminatorBytes() {
923
+ return kit.getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR);
924
+ }
925
+ var POOL_SYNCED_V0_EVENT_DISCRIMINATOR2 = 0;
926
+ function getPoolSyncedV0EventDiscriminator2Bytes() {
927
+ return kit.getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2);
928
+ }
929
+ function getPoolSyncedV0EventEncoder() {
930
+ return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["pool", kit.getAddressEncoder()], ["reserve0", kit.getU64Encoder()], ["reserve1", kit.getU64Encoder()], ["price0CumulativeLast", kit.getU128Encoder()], ["lastUpdateTimestamp", kit.getU64Encoder()]]), (value) => ({ ...value, discriminator: 5, migrationVersion: 0 }));
931
+ }
932
+ function getPoolSyncedV0EventDecoder() {
933
+ return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_SYNCED_V0_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["pool", kit.getAddressDecoder()], ["reserve0", kit.getU64Decoder()], ["reserve1", kit.getU64Decoder()], ["price0CumulativeLast", kit.getU128Decoder()], ["lastUpdateTimestamp", kit.getU64Decoder()]]);
934
+ }
935
+ function getPoolSyncedV0EventCodec() {
936
+ return kit.combineCodec(getPoolSyncedV0EventEncoder(), getPoolSyncedV0EventDecoder());
937
+ }
938
+ function parsePoolSyncedV0Event(data) {
939
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2), 1)) {
940
+ return getPoolSyncedV0EventDecoder().decode(data);
941
+ }
942
+ throw new Error('The provided data does not match the "PoolSyncedV0Event" event discriminators.');
943
+ }
944
+ var CONFIG_CREATED_EVENT_DISCRIMINATOR = 8;
945
+ function getConfigCreatedEventDiscriminatorBytes() {
946
+ return kit.getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR);
947
+ }
948
+ var CONFIG_CREATED_EVENT_DISCRIMINATOR2 = 0;
949
+ function getConfigCreatedEventDiscriminator2Bytes() {
950
+ return kit.getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR2);
951
+ }
952
+ function getConfigCreatedEventEncoder() {
953
+ return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["ammConfig", kit.getAddressEncoder()], ["authority", kit.getAddressEncoder()], ["poolCreatorAuthority", kit.getAddressEncoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()], ["index", kit.getU16Encoder()]]), (value) => ({ ...value, discriminator: 8, migrationVersion: 0 }));
954
+ }
955
+ function getConfigCreatedEventDecoder() {
956
+ return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(CONFIG_CREATED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["ammConfig", kit.getAddressDecoder()], ["authority", kit.getAddressDecoder()], ["poolCreatorAuthority", kit.getAddressDecoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()], ["index", kit.getU16Decoder()]]);
957
+ }
958
+ function getConfigCreatedEventCodec() {
959
+ return kit.combineCodec(getConfigCreatedEventEncoder(), getConfigCreatedEventDecoder());
960
+ }
961
+ function parseConfigCreatedEvent(data) {
962
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR2), 1)) {
963
+ return getConfigCreatedEventDecoder().decode(data);
964
+ }
965
+ throw new Error('The provided data does not match the "ConfigCreatedEvent" event discriminators.');
966
+ }
967
+ var CONFIG_UPDATED_EVENT_DISCRIMINATOR = 6;
968
+ function getConfigUpdatedEventDiscriminatorBytes() {
969
+ return kit.getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR);
970
+ }
971
+ var CONFIG_UPDATED_EVENT_DISCRIMINATOR2 = 0;
972
+ function getConfigUpdatedEventDiscriminator2Bytes() {
973
+ return kit.getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR2);
974
+ }
975
+ function getConfigUpdatedEventEncoder() {
976
+ return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["ammConfig", kit.getAddressEncoder()], ["newAuthority", kit.getAddressEncoder()], ["tradeFeeRate", kit.getU32Encoder()], ["protocolFeeRate", kit.getU32Encoder()], ["creatorFeeRate", kit.getU32Encoder()]]), (value) => ({ ...value, discriminator: 6, migrationVersion: 0 }));
977
+ }
978
+ function getConfigUpdatedEventDecoder() {
979
+ return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(CONFIG_UPDATED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["ammConfig", kit.getAddressDecoder()], ["newAuthority", kit.getAddressDecoder()], ["tradeFeeRate", kit.getU32Decoder()], ["protocolFeeRate", kit.getU32Decoder()], ["creatorFeeRate", kit.getU32Decoder()]]);
980
+ }
981
+ function getConfigUpdatedEventCodec() {
982
+ return kit.combineCodec(getConfigUpdatedEventEncoder(), getConfigUpdatedEventDecoder());
983
+ }
984
+ function parseConfigUpdatedEvent(data) {
985
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR2), 1)) {
986
+ return getConfigUpdatedEventDecoder().decode(data);
987
+ }
988
+ throw new Error('The provided data does not match the "ConfigUpdatedEvent" event discriminators.');
989
+ }
990
+ var POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR = 7;
991
+ function getPoolCreatorChangedEventDiscriminatorBytes() {
992
+ return kit.getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR);
993
+ }
994
+ var POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2 = 0;
995
+ function getPoolCreatorChangedEventDiscriminator2Bytes() {
996
+ return kit.getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2);
997
+ }
998
+ function getPoolCreatorChangedEventEncoder() {
999
+ return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU8Encoder()], ["migrationVersion", kit.getU8Encoder()], ["pool", kit.getAddressEncoder()], ["previousCreator", kit.getAddressEncoder()], ["newCreator", kit.getAddressEncoder()]]), (value) => ({ ...value, discriminator: 7, migrationVersion: 0 }));
1000
+ }
1001
+ function getPoolCreatorChangedEventDecoder() {
1002
+ return kit.getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR, kit.getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, kit.getU8Decoder())], ["pool", kit.getAddressDecoder()], ["previousCreator", kit.getAddressDecoder()], ["newCreator", kit.getAddressDecoder()]]);
1003
+ }
1004
+ function getPoolCreatorChangedEventCodec() {
1005
+ return kit.combineCodec(getPoolCreatorChangedEventEncoder(), getPoolCreatorChangedEventDecoder());
1006
+ }
1007
+ function parsePoolCreatorChangedEvent(data) {
1008
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR), 0) && kit.containsBytes(data, kit.getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2), 1)) {
1009
+ return getPoolCreatorChangedEventDecoder().decode(data);
1010
+ }
1011
+ throw new Error('The provided data does not match the "PoolCreatorChangedEvent" event discriminators.');
1012
+ }
836
1013
 
837
1014
  // src/generated/events/logs.ts
838
1015
  function decodePoolCreatedEvent(data) {
@@ -1007,6 +1184,221 @@ function parseFeesCollectedEventFromLog(log) {
1007
1184
  }
1008
1185
  return decodeFeesCollectedEvent(bytes);
1009
1186
  }
1187
+ function decodePoolSyncedEvent(data) {
1188
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1189
+ const discriminatorBytes = getPoolSyncedEventDiscriminatorBytes();
1190
+ if (bytes.length < 2) {
1191
+ throw new RangeError(
1192
+ `the provided data is too short for the "PoolSyncedEvent" event envelope`
1193
+ );
1194
+ }
1195
+ for (let index = 0; index < 1; index += 1) {
1196
+ if (bytes[index] !== discriminatorBytes[index]) {
1197
+ throw new RangeError(
1198
+ 'the provided data does not match the "PoolSyncedEvent" event discriminator.'
1199
+ );
1200
+ }
1201
+ }
1202
+ const sourceVersion = bytes[1];
1203
+ if (sourceVersion !== 1) {
1204
+ throw new RangeError(
1205
+ `event migration version mismatch: expected 1, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1206
+ );
1207
+ }
1208
+ return { name: "poolSynced", data: getPoolSyncedEventDecoder().decode(bytes) };
1209
+ }
1210
+ function parsePoolSyncedEventFromLog(log) {
1211
+ const prefix = "Program data: ";
1212
+ if (!log.startsWith(prefix)) {
1213
+ return null;
1214
+ }
1215
+ const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
1216
+ if (bytes.length < 2) {
1217
+ return null;
1218
+ }
1219
+ const discriminatorBytes = getPoolSyncedEventDiscriminatorBytes();
1220
+ for (let index = 0; index < 1; index += 1) {
1221
+ if (bytes[index] !== discriminatorBytes[index]) {
1222
+ return null;
1223
+ }
1224
+ }
1225
+ if (bytes[1] !== 1) {
1226
+ return null;
1227
+ }
1228
+ return decodePoolSyncedEvent(bytes);
1229
+ }
1230
+ function decodePoolSyncedV0Event(data) {
1231
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1232
+ const discriminatorBytes = getPoolSyncedV0EventDiscriminatorBytes();
1233
+ if (bytes.length < 2) {
1234
+ throw new RangeError(
1235
+ `the provided data is too short for the "PoolSyncedV0Event" event envelope`
1236
+ );
1237
+ }
1238
+ for (let index = 0; index < 1; index += 1) {
1239
+ if (bytes[index] !== discriminatorBytes[index]) {
1240
+ throw new RangeError(
1241
+ 'the provided data does not match the "PoolSyncedV0Event" event discriminator.'
1242
+ );
1243
+ }
1244
+ }
1245
+ const sourceVersion = bytes[1];
1246
+ if (sourceVersion !== 0) {
1247
+ throw new RangeError(
1248
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1249
+ );
1250
+ }
1251
+ return { name: "poolSyncedV0", data: getPoolSyncedV0EventDecoder().decode(bytes) };
1252
+ }
1253
+ function parsePoolSyncedV0EventFromLog(log) {
1254
+ const prefix = "Program data: ";
1255
+ if (!log.startsWith(prefix)) {
1256
+ return null;
1257
+ }
1258
+ const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
1259
+ if (bytes.length < 2) {
1260
+ return null;
1261
+ }
1262
+ const discriminatorBytes = getPoolSyncedV0EventDiscriminatorBytes();
1263
+ for (let index = 0; index < 1; index += 1) {
1264
+ if (bytes[index] !== discriminatorBytes[index]) {
1265
+ return null;
1266
+ }
1267
+ }
1268
+ if (bytes[1] !== 0) {
1269
+ return null;
1270
+ }
1271
+ return decodePoolSyncedV0Event(bytes);
1272
+ }
1273
+ function decodeConfigCreatedEvent(data) {
1274
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1275
+ const discriminatorBytes = getConfigCreatedEventDiscriminatorBytes();
1276
+ if (bytes.length < 2) {
1277
+ throw new RangeError(
1278
+ `the provided data is too short for the "ConfigCreatedEvent" event envelope`
1279
+ );
1280
+ }
1281
+ for (let index = 0; index < 1; index += 1) {
1282
+ if (bytes[index] !== discriminatorBytes[index]) {
1283
+ throw new RangeError(
1284
+ 'the provided data does not match the "ConfigCreatedEvent" event discriminator.'
1285
+ );
1286
+ }
1287
+ }
1288
+ const sourceVersion = bytes[1];
1289
+ if (sourceVersion !== 0) {
1290
+ throw new RangeError(
1291
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1292
+ );
1293
+ }
1294
+ return { name: "configCreated", data: getConfigCreatedEventDecoder().decode(bytes) };
1295
+ }
1296
+ function parseConfigCreatedEventFromLog(log) {
1297
+ const prefix = "Program data: ";
1298
+ if (!log.startsWith(prefix)) {
1299
+ return null;
1300
+ }
1301
+ const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
1302
+ if (bytes.length < 2) {
1303
+ return null;
1304
+ }
1305
+ const discriminatorBytes = getConfigCreatedEventDiscriminatorBytes();
1306
+ for (let index = 0; index < 1; index += 1) {
1307
+ if (bytes[index] !== discriminatorBytes[index]) {
1308
+ return null;
1309
+ }
1310
+ }
1311
+ if (bytes[1] !== 0) {
1312
+ return null;
1313
+ }
1314
+ return decodeConfigCreatedEvent(bytes);
1315
+ }
1316
+ function decodeConfigUpdatedEvent(data) {
1317
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1318
+ const discriminatorBytes = getConfigUpdatedEventDiscriminatorBytes();
1319
+ if (bytes.length < 2) {
1320
+ throw new RangeError(
1321
+ `the provided data is too short for the "ConfigUpdatedEvent" event envelope`
1322
+ );
1323
+ }
1324
+ for (let index = 0; index < 1; index += 1) {
1325
+ if (bytes[index] !== discriminatorBytes[index]) {
1326
+ throw new RangeError(
1327
+ 'the provided data does not match the "ConfigUpdatedEvent" event discriminator.'
1328
+ );
1329
+ }
1330
+ }
1331
+ const sourceVersion = bytes[1];
1332
+ if (sourceVersion !== 0) {
1333
+ throw new RangeError(
1334
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1335
+ );
1336
+ }
1337
+ return { name: "configUpdated", data: getConfigUpdatedEventDecoder().decode(bytes) };
1338
+ }
1339
+ function parseConfigUpdatedEventFromLog(log) {
1340
+ const prefix = "Program data: ";
1341
+ if (!log.startsWith(prefix)) {
1342
+ return null;
1343
+ }
1344
+ const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
1345
+ if (bytes.length < 2) {
1346
+ return null;
1347
+ }
1348
+ const discriminatorBytes = getConfigUpdatedEventDiscriminatorBytes();
1349
+ for (let index = 0; index < 1; index += 1) {
1350
+ if (bytes[index] !== discriminatorBytes[index]) {
1351
+ return null;
1352
+ }
1353
+ }
1354
+ if (bytes[1] !== 0) {
1355
+ return null;
1356
+ }
1357
+ return decodeConfigUpdatedEvent(bytes);
1358
+ }
1359
+ function decodePoolCreatorChangedEvent(data) {
1360
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1361
+ const discriminatorBytes = getPoolCreatorChangedEventDiscriminatorBytes();
1362
+ if (bytes.length < 2) {
1363
+ throw new RangeError(
1364
+ `the provided data is too short for the "PoolCreatorChangedEvent" event envelope`
1365
+ );
1366
+ }
1367
+ for (let index = 0; index < 1; index += 1) {
1368
+ if (bytes[index] !== discriminatorBytes[index]) {
1369
+ throw new RangeError(
1370
+ 'the provided data does not match the "PoolCreatorChangedEvent" event discriminator.'
1371
+ );
1372
+ }
1373
+ }
1374
+ const sourceVersion = bytes[1];
1375
+ if (sourceVersion !== 0) {
1376
+ throw new RangeError(
1377
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1378
+ );
1379
+ }
1380
+ return { name: "poolCreatorChanged", data: getPoolCreatorChangedEventDecoder().decode(bytes) };
1381
+ }
1382
+ function parsePoolCreatorChangedEventFromLog(log) {
1383
+ const prefix = "Program data: ";
1384
+ if (!log.startsWith(prefix)) {
1385
+ return null;
1386
+ }
1387
+ const bytes = kit.getBase64Encoder().encode(log.slice(prefix.length));
1388
+ if (bytes.length < 2) {
1389
+ return null;
1390
+ }
1391
+ const discriminatorBytes = getPoolCreatorChangedEventDiscriminatorBytes();
1392
+ for (let index = 0; index < 1; index += 1) {
1393
+ if (bytes[index] !== discriminatorBytes[index]) {
1394
+ return null;
1395
+ }
1396
+ }
1397
+ if (bytes[1] !== 0) {
1398
+ return null;
1399
+ }
1400
+ return decodePoolCreatorChangedEvent(bytes);
1401
+ }
1010
1402
  function unrecognizedEventVersion(log) {
1011
1403
  const prefix = "Program data: ";
1012
1404
  if (!log.startsWith(prefix)) {
@@ -1025,9 +1417,21 @@ function unrecognizedEventVersion(log) {
1025
1417
  if (bytes.length >= 1 && bytes[0] === 4) {
1026
1418
  return bytes.length < 2 ? 'event "feesCollected" log is too short for its version envelope' : `event "feesCollected" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
1027
1419
  }
1420
+ if (bytes.length >= 1 && bytes[0] === 5) {
1421
+ return bytes.length < 2 ? 'event "poolSynced" log is too short for its version envelope' : `event "poolSynced" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
1422
+ }
1423
+ if (bytes.length >= 1 && bytes[0] === 8) {
1424
+ return bytes.length < 2 ? 'event "configCreated" log is too short for its version envelope' : `event "configCreated" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
1425
+ }
1426
+ if (bytes.length >= 1 && bytes[0] === 6) {
1427
+ return bytes.length < 2 ? 'event "configUpdated" log is too short for its version envelope' : `event "configUpdated" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
1428
+ }
1429
+ if (bytes.length >= 1 && bytes[0] === 7) {
1430
+ return bytes.length < 2 ? 'event "poolCreatorChanged" log is too short for its version envelope' : `event "poolCreatorChanged" log carries migration version ${bytes[1]}, which this client cannot decode; regenerate it`;
1431
+ }
1028
1432
  return null;
1029
1433
  }
1030
- var PINA_AMM_EVENT_SOURCE_ADDRESS = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV";
1434
+ var PINA_AMM_EVENT_SOURCE_ADDRESS = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi";
1031
1435
  var PROGRAM_INVOKE_LOG = /^Program (\S+) invoke \[\d+\]$/;
1032
1436
  var PROGRAM_EXIT_LOG = /^Program (\S+) (?:success|failed: .*)$/;
1033
1437
  function parsePinaAmmEventsFromLogs(logs, programAddress = PINA_AMM_EVENT_SOURCE_ADDRESS) {
@@ -1067,6 +1471,31 @@ function parsePinaAmmEventsFromLogs(logs, programAddress = PINA_AMM_EVENT_SOURCE
1067
1471
  discovered.push(feesCollected);
1068
1472
  continue;
1069
1473
  }
1474
+ const poolSynced = parsePoolSyncedEventFromLog(log);
1475
+ if (poolSynced !== null) {
1476
+ discovered.push(poolSynced);
1477
+ continue;
1478
+ }
1479
+ const poolSyncedV0 = parsePoolSyncedV0EventFromLog(log);
1480
+ if (poolSyncedV0 !== null) {
1481
+ discovered.push(poolSyncedV0);
1482
+ continue;
1483
+ }
1484
+ const configCreated = parseConfigCreatedEventFromLog(log);
1485
+ if (configCreated !== null) {
1486
+ discovered.push(configCreated);
1487
+ continue;
1488
+ }
1489
+ const configUpdated = parseConfigUpdatedEventFromLog(log);
1490
+ if (configUpdated !== null) {
1491
+ discovered.push(configUpdated);
1492
+ continue;
1493
+ }
1494
+ const poolCreatorChanged = parsePoolCreatorChangedEventFromLog(log);
1495
+ if (poolCreatorChanged !== null) {
1496
+ discovered.push(poolCreatorChanged);
1497
+ continue;
1498
+ }
1070
1499
  const unknownVersion = unrecognizedEventVersion(log);
1071
1500
  if (unknownVersion !== null) {
1072
1501
  throw new RangeError(unknownVersion);
@@ -1080,6 +1509,10 @@ exports.AMM_CONFIG_DISCRIMINATOR2 = AMM_CONFIG_DISCRIMINATOR2;
1080
1509
  exports.AMM_CONFIG_MIGRATION_VERSION = AMM_CONFIG_MIGRATION_VERSION;
1081
1510
  exports.COLLECT_CREATOR_FEES_DISCRIMINATOR = COLLECT_CREATOR_FEES_DISCRIMINATOR;
1082
1511
  exports.COLLECT_PROTOCOL_FEES_DISCRIMINATOR = COLLECT_PROTOCOL_FEES_DISCRIMINATOR;
1512
+ exports.CONFIG_CREATED_EVENT_DISCRIMINATOR = CONFIG_CREATED_EVENT_DISCRIMINATOR;
1513
+ exports.CONFIG_CREATED_EVENT_DISCRIMINATOR2 = CONFIG_CREATED_EVENT_DISCRIMINATOR2;
1514
+ exports.CONFIG_UPDATED_EVENT_DISCRIMINATOR = CONFIG_UPDATED_EVENT_DISCRIMINATOR;
1515
+ exports.CONFIG_UPDATED_EVENT_DISCRIMINATOR2 = CONFIG_UPDATED_EVENT_DISCRIMINATOR2;
1083
1516
  exports.CREATE_CONFIG_DISCRIMINATOR = CREATE_CONFIG_DISCRIMINATOR;
1084
1517
  exports.CREATE_POOL_DISCRIMINATOR = CREATE_POOL_DISCRIMINATOR;
1085
1518
  exports.DEPOSIT_DISCRIMINATOR = DEPOSIT_DISCRIMINATOR;
@@ -1088,6 +1521,7 @@ exports.FEES_COLLECTED_EVENT_DISCRIMINATOR2 = FEES_COLLECTED_EVENT_DISCRIMINATOR
1088
1521
  exports.LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR = LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR;
1089
1522
  exports.LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2 = LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2;
1090
1523
  exports.MIGRATE_DISCRIMINATOR = MIGRATE_DISCRIMINATOR;
1524
+ exports.PINA_AMM_ERROR__DEFAULT_CREATOR = PINA_AMM_ERROR__DEFAULT_CREATOR;
1091
1525
  exports.PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY = PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY;
1092
1526
  exports.PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY = PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY;
1093
1527
  exports.PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE = PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE;
@@ -1107,9 +1541,15 @@ exports.PINA_AMM_EVENT_SOURCE_ADDRESS = PINA_AMM_EVENT_SOURCE_ADDRESS;
1107
1541
  exports.PINA_AMM_PROGRAM_ADDRESS = PINA_AMM_PROGRAM_ADDRESS;
1108
1542
  exports.POOL_CREATED_EVENT_DISCRIMINATOR = POOL_CREATED_EVENT_DISCRIMINATOR;
1109
1543
  exports.POOL_CREATED_EVENT_DISCRIMINATOR2 = POOL_CREATED_EVENT_DISCRIMINATOR2;
1544
+ exports.POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR = POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR;
1545
+ exports.POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2 = POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2;
1110
1546
  exports.POOL_DISCRIMINATOR = POOL_DISCRIMINATOR;
1111
1547
  exports.POOL_DISCRIMINATOR2 = POOL_DISCRIMINATOR2;
1112
1548
  exports.POOL_MIGRATION_VERSION = POOL_MIGRATION_VERSION;
1549
+ exports.POOL_SYNCED_EVENT_DISCRIMINATOR = POOL_SYNCED_EVENT_DISCRIMINATOR;
1550
+ exports.POOL_SYNCED_EVENT_DISCRIMINATOR2 = POOL_SYNCED_EVENT_DISCRIMINATOR2;
1551
+ exports.POOL_SYNCED_V0_EVENT_DISCRIMINATOR = POOL_SYNCED_V0_EVENT_DISCRIMINATOR;
1552
+ exports.POOL_SYNCED_V0_EVENT_DISCRIMINATOR2 = POOL_SYNCED_V0_EVENT_DISCRIMINATOR2;
1113
1553
  exports.PinaAmmAccount = PinaAmmAccount;
1114
1554
  exports.PinaAmmEvent = PinaAmmEvent;
1115
1555
  exports.PinaAmmInstruction = PinaAmmInstruction;
@@ -1118,14 +1558,20 @@ exports.SWAPPED_EVENT_DISCRIMINATOR = SWAPPED_EVENT_DISCRIMINATOR;
1118
1558
  exports.SWAPPED_EVENT_DISCRIMINATOR2 = SWAPPED_EVENT_DISCRIMINATOR2;
1119
1559
  exports.SWAP_EXACT_IN_DISCRIMINATOR = SWAP_EXACT_IN_DISCRIMINATOR;
1120
1560
  exports.SWAP_EXACT_OUT_DISCRIMINATOR = SWAP_EXACT_OUT_DISCRIMINATOR;
1561
+ exports.SYNC_POOL_DISCRIMINATOR = SYNC_POOL_DISCRIMINATOR;
1121
1562
  exports.UPDATE_CONFIG_DISCRIMINATOR = UPDATE_CONFIG_DISCRIMINATOR;
1122
1563
  exports.WITHDRAW_DISCRIMINATOR = WITHDRAW_DISCRIMINATOR;
1123
1564
  exports.ammConfigNeedsMigration = ammConfigNeedsMigration;
1124
1565
  exports.decodeAmmConfig = decodeAmmConfig;
1566
+ exports.decodeConfigCreatedEvent = decodeConfigCreatedEvent;
1567
+ exports.decodeConfigUpdatedEvent = decodeConfigUpdatedEvent;
1125
1568
  exports.decodeFeesCollectedEvent = decodeFeesCollectedEvent;
1126
1569
  exports.decodeLiquidityChangedEvent = decodeLiquidityChangedEvent;
1127
1570
  exports.decodePool = decodePool;
1128
1571
  exports.decodePoolCreatedEvent = decodePoolCreatedEvent;
1572
+ exports.decodePoolCreatorChangedEvent = decodePoolCreatorChangedEvent;
1573
+ exports.decodePoolSyncedEvent = decodePoolSyncedEvent;
1574
+ exports.decodePoolSyncedV0Event = decodePoolSyncedV0Event;
1129
1575
  exports.decodeSwappedEvent = decodeSwappedEvent;
1130
1576
  exports.fetchAllAmmConfig = fetchAllAmmConfig;
1131
1577
  exports.fetchAllMaybeAmmConfig = fetchAllMaybeAmmConfig;
@@ -1158,6 +1604,16 @@ exports.getCollectProtocolFeesInstruction = getCollectProtocolFeesInstruction;
1158
1604
  exports.getCollectProtocolFeesInstructionDataCodec = getCollectProtocolFeesInstructionDataCodec;
1159
1605
  exports.getCollectProtocolFeesInstructionDataDecoder = getCollectProtocolFeesInstructionDataDecoder;
1160
1606
  exports.getCollectProtocolFeesInstructionDataEncoder = getCollectProtocolFeesInstructionDataEncoder;
1607
+ exports.getConfigCreatedEventCodec = getConfigCreatedEventCodec;
1608
+ exports.getConfigCreatedEventDecoder = getConfigCreatedEventDecoder;
1609
+ exports.getConfigCreatedEventDiscriminator2Bytes = getConfigCreatedEventDiscriminator2Bytes;
1610
+ exports.getConfigCreatedEventDiscriminatorBytes = getConfigCreatedEventDiscriminatorBytes;
1611
+ exports.getConfigCreatedEventEncoder = getConfigCreatedEventEncoder;
1612
+ exports.getConfigUpdatedEventCodec = getConfigUpdatedEventCodec;
1613
+ exports.getConfigUpdatedEventDecoder = getConfigUpdatedEventDecoder;
1614
+ exports.getConfigUpdatedEventDiscriminator2Bytes = getConfigUpdatedEventDiscriminator2Bytes;
1615
+ exports.getConfigUpdatedEventDiscriminatorBytes = getConfigUpdatedEventDiscriminatorBytes;
1616
+ exports.getConfigUpdatedEventEncoder = getConfigUpdatedEventEncoder;
1161
1617
  exports.getCreateConfigDiscriminatorBytes = getCreateConfigDiscriminatorBytes;
1162
1618
  exports.getCreateConfigInstruction = getCreateConfigInstruction;
1163
1619
  exports.getCreateConfigInstructionDataCodec = getCreateConfigInstructionDataCodec;
@@ -1193,10 +1649,25 @@ exports.getPoolCreatedEventDecoder = getPoolCreatedEventDecoder;
1193
1649
  exports.getPoolCreatedEventDiscriminator2Bytes = getPoolCreatedEventDiscriminator2Bytes;
1194
1650
  exports.getPoolCreatedEventDiscriminatorBytes = getPoolCreatedEventDiscriminatorBytes;
1195
1651
  exports.getPoolCreatedEventEncoder = getPoolCreatedEventEncoder;
1652
+ exports.getPoolCreatorChangedEventCodec = getPoolCreatorChangedEventCodec;
1653
+ exports.getPoolCreatorChangedEventDecoder = getPoolCreatorChangedEventDecoder;
1654
+ exports.getPoolCreatorChangedEventDiscriminator2Bytes = getPoolCreatorChangedEventDiscriminator2Bytes;
1655
+ exports.getPoolCreatorChangedEventDiscriminatorBytes = getPoolCreatorChangedEventDiscriminatorBytes;
1656
+ exports.getPoolCreatorChangedEventEncoder = getPoolCreatorChangedEventEncoder;
1196
1657
  exports.getPoolDecoder = getPoolDecoder;
1197
1658
  exports.getPoolDiscriminator2Bytes = getPoolDiscriminator2Bytes;
1198
1659
  exports.getPoolDiscriminatorBytes = getPoolDiscriminatorBytes;
1199
1660
  exports.getPoolEncoder = getPoolEncoder;
1661
+ exports.getPoolSyncedEventCodec = getPoolSyncedEventCodec;
1662
+ exports.getPoolSyncedEventDecoder = getPoolSyncedEventDecoder;
1663
+ exports.getPoolSyncedEventDiscriminator2Bytes = getPoolSyncedEventDiscriminator2Bytes;
1664
+ exports.getPoolSyncedEventDiscriminatorBytes = getPoolSyncedEventDiscriminatorBytes;
1665
+ exports.getPoolSyncedEventEncoder = getPoolSyncedEventEncoder;
1666
+ exports.getPoolSyncedV0EventCodec = getPoolSyncedV0EventCodec;
1667
+ exports.getPoolSyncedV0EventDecoder = getPoolSyncedV0EventDecoder;
1668
+ exports.getPoolSyncedV0EventDiscriminator2Bytes = getPoolSyncedV0EventDiscriminator2Bytes;
1669
+ exports.getPoolSyncedV0EventDiscriminatorBytes = getPoolSyncedV0EventDiscriminatorBytes;
1670
+ exports.getPoolSyncedV0EventEncoder = getPoolSyncedV0EventEncoder;
1200
1671
  exports.getSetPoolCreatorDiscriminatorBytes = getSetPoolCreatorDiscriminatorBytes;
1201
1672
  exports.getSetPoolCreatorInstruction = getSetPoolCreatorInstruction;
1202
1673
  exports.getSetPoolCreatorInstructionDataCodec = getSetPoolCreatorInstructionDataCodec;
@@ -1217,6 +1688,11 @@ exports.getSwappedEventDecoder = getSwappedEventDecoder;
1217
1688
  exports.getSwappedEventDiscriminator2Bytes = getSwappedEventDiscriminator2Bytes;
1218
1689
  exports.getSwappedEventDiscriminatorBytes = getSwappedEventDiscriminatorBytes;
1219
1690
  exports.getSwappedEventEncoder = getSwappedEventEncoder;
1691
+ exports.getSyncPoolDiscriminatorBytes = getSyncPoolDiscriminatorBytes;
1692
+ exports.getSyncPoolInstruction = getSyncPoolInstruction;
1693
+ exports.getSyncPoolInstructionDataCodec = getSyncPoolInstructionDataCodec;
1694
+ exports.getSyncPoolInstructionDataDecoder = getSyncPoolInstructionDataDecoder;
1695
+ exports.getSyncPoolInstructionDataEncoder = getSyncPoolInstructionDataEncoder;
1220
1696
  exports.getUpdateConfigDiscriminatorBytes = getUpdateConfigDiscriminatorBytes;
1221
1697
  exports.getUpdateConfigInstruction = getUpdateConfigInstruction;
1222
1698
  exports.getUpdateConfigInstructionDataCodec = getUpdateConfigInstructionDataCodec;
@@ -1233,6 +1709,10 @@ exports.identifyPinaAmmInstruction = identifyPinaAmmInstruction;
1233
1709
  exports.isPinaAmmError = isPinaAmmError;
1234
1710
  exports.parseCollectCreatorFeesInstruction = parseCollectCreatorFeesInstruction;
1235
1711
  exports.parseCollectProtocolFeesInstruction = parseCollectProtocolFeesInstruction;
1712
+ exports.parseConfigCreatedEvent = parseConfigCreatedEvent;
1713
+ exports.parseConfigCreatedEventFromLog = parseConfigCreatedEventFromLog;
1714
+ exports.parseConfigUpdatedEvent = parseConfigUpdatedEvent;
1715
+ exports.parseConfigUpdatedEventFromLog = parseConfigUpdatedEventFromLog;
1236
1716
  exports.parseCreateConfigInstruction = parseCreateConfigInstruction;
1237
1717
  exports.parseCreatePoolInstruction = parseCreatePoolInstruction;
1238
1718
  exports.parseDepositInstruction = parseDepositInstruction;
@@ -1244,11 +1724,18 @@ exports.parsePinaAmmEventsFromLogs = parsePinaAmmEventsFromLogs;
1244
1724
  exports.parsePinaAmmInstruction = parsePinaAmmInstruction;
1245
1725
  exports.parsePoolCreatedEvent = parsePoolCreatedEvent;
1246
1726
  exports.parsePoolCreatedEventFromLog = parsePoolCreatedEventFromLog;
1727
+ exports.parsePoolCreatorChangedEvent = parsePoolCreatorChangedEvent;
1728
+ exports.parsePoolCreatorChangedEventFromLog = parsePoolCreatorChangedEventFromLog;
1729
+ exports.parsePoolSyncedEvent = parsePoolSyncedEvent;
1730
+ exports.parsePoolSyncedEventFromLog = parsePoolSyncedEventFromLog;
1731
+ exports.parsePoolSyncedV0Event = parsePoolSyncedV0Event;
1732
+ exports.parsePoolSyncedV0EventFromLog = parsePoolSyncedV0EventFromLog;
1247
1733
  exports.parseSetPoolCreatorInstruction = parseSetPoolCreatorInstruction;
1248
1734
  exports.parseSwapExactInInstruction = parseSwapExactInInstruction;
1249
1735
  exports.parseSwapExactOutInstruction = parseSwapExactOutInstruction;
1250
1736
  exports.parseSwappedEvent = parseSwappedEvent;
1251
1737
  exports.parseSwappedEventFromLog = parseSwappedEventFromLog;
1738
+ exports.parseSyncPoolInstruction = parseSyncPoolInstruction;
1252
1739
  exports.parseUpdateConfigInstruction = parseUpdateConfigInstruction;
1253
1740
  exports.parseWithdrawInstruction = parseWithdrawInstruction;
1254
1741
  exports.pinaAmmProgram = pinaAmmProgram;