@pina-rs/amm 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getProgramDerivedAddress, getUtf8Encoder, getU16Encoder, getAddressEncoder, getU8Encoder, transformEncoder, getStructEncoder, getU32Encoder, getStructDecoder, getU8Decoder, getAddressDecoder, getU32Decoder, getU16Decoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, getU64Encoder, getU64Decoder, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, containsBytes, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, assertIsInstructionWithAccounts, extendClient, isProgramError, getBase64Encoder, transformDecoder } from '@solana/kit';
1
+ import { getProgramDerivedAddress, getUtf8Encoder, getU16Encoder, getAddressEncoder, getU8Encoder, transformEncoder, getStructEncoder, getU32Encoder, getStructDecoder, getU8Decoder, getAddressDecoder, getU32Decoder, getU16Decoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, getU64Encoder, getU128Encoder, getU64Decoder, getU128Decoder, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, containsBytes, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, assertIsInstructionWithAccounts, extendClient, isProgramError, getBase64Encoder, transformDecoder } from '@solana/kit';
2
2
  import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, addSelfPlanAndSendFunctions, addSelfFetchFunctions } from '@solana/program-client-core';
3
3
 
4
4
  // src/generated/pinaPodCodecs.ts
@@ -24,19 +24,19 @@ function getPinaPodMigrationVersionDecoder(expected, decoder) {
24
24
  });
25
25
  }
26
26
  async function findAmmConfigPda(seeds, config = {}) {
27
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
27
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
28
28
  return await getProgramDerivedAddress({ programAddress, seeds: [getUtf8Encoder().encode("amm_config"), getU16Encoder().encode(seeds.index)] });
29
29
  }
30
30
  async function findPoolPda(seeds, config = {}) {
31
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
31
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
32
32
  return await getProgramDerivedAddress({ programAddress, seeds: [getUtf8Encoder().encode("pool"), getAddressEncoder().encode(seeds.ammConfig), getAddressEncoder().encode(seeds.mint0), getAddressEncoder().encode(seeds.mint1)] });
33
33
  }
34
34
  async function findPoolLpMintPda(seeds, config = {}) {
35
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
35
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
36
36
  return await getProgramDerivedAddress({ programAddress, seeds: [getUtf8Encoder().encode("pool_lp_mint"), getAddressEncoder().encode(seeds.pool)] });
37
37
  }
38
38
  async function findPoolVaultPda(seeds, config = {}) {
39
- const { programAddress = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV" } = config;
39
+ const { programAddress = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi" } = config;
40
40
  return await getProgramDerivedAddress({ programAddress, seeds: [getUtf8Encoder().encode("pool_vault"), getAddressEncoder().encode(seeds.pool), getAddressEncoder().encode(seeds.mint)] });
41
41
  }
42
42
 
@@ -103,15 +103,15 @@ var POOL_DISCRIMINATOR = 2;
103
103
  function getPoolDiscriminatorBytes() {
104
104
  return getU8Encoder().encode(POOL_DISCRIMINATOR);
105
105
  }
106
- var POOL_DISCRIMINATOR2 = 0;
106
+ var POOL_DISCRIMINATOR2 = 1;
107
107
  function getPoolDiscriminator2Bytes() {
108
108
  return getU8Encoder().encode(POOL_DISCRIMINATOR2);
109
109
  }
110
110
  function getPoolEncoder() {
111
- return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()], ["migrationVersion", getU8Encoder()], ["ammConfig", getAddressEncoder()], ["creator", getAddressEncoder()], ["mint0", getAddressEncoder()], ["mint1", getAddressEncoder()], ["vault0", getAddressEncoder()], ["vault1", getAddressEncoder()], ["lpMint", getAddressEncoder()], ["lpSupply", getU64Encoder()], ["protocolFees0", getU64Encoder()], ["protocolFees1", getU64Encoder()], ["creatorFees0", getU64Encoder()], ["creatorFees1", getU64Encoder()], ["tradeFeeRate", getU32Encoder()], ["protocolFeeRate", getU32Encoder()], ["creatorFeeRate", getU32Encoder()], ["creatorFeeMode", getU8Encoder()], ["bump", getU8Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 0 }));
111
+ return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()], ["migrationVersion", getU8Encoder()], ["ammConfig", getAddressEncoder()], ["creator", getAddressEncoder()], ["mint0", getAddressEncoder()], ["mint1", getAddressEncoder()], ["vault0", getAddressEncoder()], ["vault1", getAddressEncoder()], ["lpMint", getAddressEncoder()], ["lpSupply", getU64Encoder()], ["protocolFees0", getU64Encoder()], ["protocolFees1", getU64Encoder()], ["creatorFees0", getU64Encoder()], ["creatorFees1", getU64Encoder()], ["tradeFeeRate", getU32Encoder()], ["protocolFeeRate", getU32Encoder()], ["creatorFeeRate", getU32Encoder()], ["creatorFeeMode", getU8Encoder()], ["bump", getU8Encoder()], ["price0CumulativeLast", getU128Encoder()], ["price0CumulativeHighLast", getU128Encoder()], ["lastUpdateTimestamp", getU64Encoder()], ["reserve0Last", getU64Encoder()], ["reserve1Last", getU64Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 1 }));
112
112
  }
113
113
  function getPoolDecoder() {
114
- return getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_DISCRIMINATOR, getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ["ammConfig", getAddressDecoder()], ["creator", getAddressDecoder()], ["mint0", getAddressDecoder()], ["mint1", getAddressDecoder()], ["vault0", getAddressDecoder()], ["vault1", getAddressDecoder()], ["lpMint", getAddressDecoder()], ["lpSupply", getU64Decoder()], ["protocolFees0", getU64Decoder()], ["protocolFees1", getU64Decoder()], ["creatorFees0", getU64Decoder()], ["creatorFees1", getU64Decoder()], ["tradeFeeRate", getU32Decoder()], ["protocolFeeRate", getU32Decoder()], ["creatorFeeRate", getU32Decoder()], ["creatorFeeMode", getU8Decoder()], ["bump", getU8Decoder()]]);
114
+ return getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_DISCRIMINATOR, getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(1, getU8Decoder())], ["ammConfig", getAddressDecoder()], ["creator", getAddressDecoder()], ["mint0", getAddressDecoder()], ["mint1", getAddressDecoder()], ["vault0", getAddressDecoder()], ["vault1", getAddressDecoder()], ["lpMint", getAddressDecoder()], ["lpSupply", getU64Decoder()], ["protocolFees0", getU64Decoder()], ["protocolFees1", getU64Decoder()], ["creatorFees0", getU64Decoder()], ["creatorFees1", getU64Decoder()], ["tradeFeeRate", getU32Decoder()], ["protocolFeeRate", getU32Decoder()], ["creatorFeeRate", getU32Decoder()], ["creatorFeeMode", getU8Decoder()], ["bump", getU8Decoder()], ["price0CumulativeLast", getU128Decoder()], ["price0CumulativeHighLast", getU128Decoder()], ["lastUpdateTimestamp", getU64Decoder()], ["reserve0Last", getU64Decoder()], ["reserve1Last", getU64Decoder()]]);
115
115
  }
116
116
  function getPoolCodec() {
117
117
  return combineCodec(getPoolEncoder(), getPoolDecoder());
@@ -147,7 +147,7 @@ async function fetchMaybePoolFromSeeds(rpc, seeds, config = {}) {
147
147
  const [address] = await findPoolPda(seeds, { programAddress });
148
148
  return await fetchMaybePool(rpc, address, fetchConfig);
149
149
  }
150
- var POOL_MIGRATION_VERSION = 0;
150
+ var POOL_MIGRATION_VERSION = 1;
151
151
  function poolNeedsMigration(data) {
152
152
  if (data.length < 2) {
153
153
  return false;
@@ -155,7 +155,7 @@ function poolNeedsMigration(data) {
155
155
  if (data[0] !== 2) {
156
156
  return false;
157
157
  }
158
- return data[1] < 0;
158
+ return data[1] < 1;
159
159
  }
160
160
  var MIGRATE_DISCRIMINATOR = 255;
161
161
  function getMigrateDiscriminatorBytes() {
@@ -488,6 +488,38 @@ function parseSwapExactOutInstruction(instruction) {
488
488
  };
489
489
  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) };
490
490
  }
491
+ var SYNC_POOL_DISCRIMINATOR = 10;
492
+ function getSyncPoolDiscriminatorBytes() {
493
+ return getU8Encoder().encode(SYNC_POOL_DISCRIMINATOR);
494
+ }
495
+ function getSyncPoolInstructionDataEncoder() {
496
+ return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({ ...value, discriminator: 10 }));
497
+ }
498
+ function getSyncPoolInstructionDataDecoder() {
499
+ return getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(SYNC_POOL_DISCRIMINATOR, getU8Decoder())]]);
500
+ }
501
+ function getSyncPoolInstructionDataCodec() {
502
+ return combineCodec(getSyncPoolInstructionDataEncoder(), getSyncPoolInstructionDataDecoder());
503
+ }
504
+ function getSyncPoolInstruction(input, config) {
505
+ const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
506
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
507
+ 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 } };
508
+ const accounts = originalAccounts;
509
+ 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 });
510
+ }
511
+ function parseSyncPoolInstruction(instruction) {
512
+ if (instruction.accounts.length < 5) {
513
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 5 });
514
+ }
515
+ let accountIndex = 0;
516
+ const getNextAccount = () => {
517
+ const accountMeta = instruction.accounts[accountIndex];
518
+ accountIndex += 1;
519
+ return accountMeta;
520
+ };
521
+ return { programAddress: instruction.programAddress, accounts: { pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount() }, data: getSyncPoolInstructionDataDecoder().decode(instruction.data) };
522
+ }
491
523
  var UPDATE_CONFIG_DISCRIMINATOR = 1;
492
524
  function getUpdateConfigDiscriminatorBytes() {
493
525
  return getU8Encoder().encode(UPDATE_CONFIG_DISCRIMINATOR);
@@ -559,7 +591,7 @@ function parseWithdrawInstruction(instruction) {
559
591
  }
560
592
 
561
593
  // src/generated/programs/pinaAmm.ts
562
- var PINA_AMM_PROGRAM_ADDRESS = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV";
594
+ var PINA_AMM_PROGRAM_ADDRESS = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi";
563
595
  var PinaAmmAccount = /* @__PURE__ */ ((PinaAmmAccount2) => {
564
596
  PinaAmmAccount2[PinaAmmAccount2["AmmConfig"] = 0] = "AmmConfig";
565
597
  PinaAmmAccount2[PinaAmmAccount2["Pool"] = 1] = "Pool";
@@ -570,7 +602,7 @@ function identifyPinaAmmAccount(account) {
570
602
  if (containsBytes(data, getU8Encoder().encode(1), 0) && containsBytes(data, getU8Encoder().encode(0), 1)) {
571
603
  return 0 /* AmmConfig */;
572
604
  }
573
- if (containsBytes(data, getU8Encoder().encode(2), 0) && containsBytes(data, getU8Encoder().encode(0), 1)) {
605
+ if (containsBytes(data, getU8Encoder().encode(2), 0) && containsBytes(data, getU8Encoder().encode(1), 1)) {
574
606
  return 1 /* Pool */;
575
607
  }
576
608
  throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, { accountData: data, programName: "pinaAmm" });
@@ -580,6 +612,11 @@ var PinaAmmEvent = /* @__PURE__ */ ((PinaAmmEvent2) => {
580
612
  PinaAmmEvent2[PinaAmmEvent2["Swapped"] = 1] = "Swapped";
581
613
  PinaAmmEvent2[PinaAmmEvent2["LiquidityChanged"] = 2] = "LiquidityChanged";
582
614
  PinaAmmEvent2[PinaAmmEvent2["FeesCollected"] = 3] = "FeesCollected";
615
+ PinaAmmEvent2[PinaAmmEvent2["PoolSynced"] = 4] = "PoolSynced";
616
+ PinaAmmEvent2[PinaAmmEvent2["PoolSyncedV0"] = 5] = "PoolSyncedV0";
617
+ PinaAmmEvent2[PinaAmmEvent2["ConfigCreated"] = 6] = "ConfigCreated";
618
+ PinaAmmEvent2[PinaAmmEvent2["ConfigUpdated"] = 7] = "ConfigUpdated";
619
+ PinaAmmEvent2[PinaAmmEvent2["PoolCreatorChanged"] = 8] = "PoolCreatorChanged";
583
620
  return PinaAmmEvent2;
584
621
  })(PinaAmmEvent || {});
585
622
  function identifyPinaAmmEvent(event) {
@@ -596,6 +633,21 @@ function identifyPinaAmmEvent(event) {
596
633
  if (containsBytes(data, getU8Encoder().encode(4), 0) && containsBytes(data, getU8Encoder().encode(0), 1)) {
597
634
  return 3 /* FeesCollected */;
598
635
  }
636
+ if (containsBytes(data, getU8Encoder().encode(5), 0) && containsBytes(data, getU8Encoder().encode(1), 1)) {
637
+ return 4 /* PoolSynced */;
638
+ }
639
+ if (containsBytes(data, getU8Encoder().encode(5), 0) && containsBytes(data, getU8Encoder().encode(0), 1)) {
640
+ return 5 /* PoolSyncedV0 */;
641
+ }
642
+ if (containsBytes(data, getU8Encoder().encode(8), 0) && containsBytes(data, getU8Encoder().encode(0), 1)) {
643
+ return 6 /* ConfigCreated */;
644
+ }
645
+ if (containsBytes(data, getU8Encoder().encode(6), 0) && containsBytes(data, getU8Encoder().encode(0), 1)) {
646
+ return 7 /* ConfigUpdated */;
647
+ }
648
+ if (containsBytes(data, getU8Encoder().encode(7), 0) && containsBytes(data, getU8Encoder().encode(0), 1)) {
649
+ return 8 /* PoolCreatorChanged */;
650
+ }
599
651
  throw new Error("The provided event could not be identified as a pinaAmm event.");
600
652
  }
601
653
  var PinaAmmInstruction = /* @__PURE__ */ ((PinaAmmInstruction2) => {
@@ -609,6 +661,7 @@ var PinaAmmInstruction = /* @__PURE__ */ ((PinaAmmInstruction2) => {
609
661
  PinaAmmInstruction2[PinaAmmInstruction2["CollectProtocolFees"] = 7] = "CollectProtocolFees";
610
662
  PinaAmmInstruction2[PinaAmmInstruction2["CollectCreatorFees"] = 8] = "CollectCreatorFees";
611
663
  PinaAmmInstruction2[PinaAmmInstruction2["SetPoolCreator"] = 9] = "SetPoolCreator";
664
+ PinaAmmInstruction2[PinaAmmInstruction2["SyncPool"] = 10] = "SyncPool";
612
665
  return PinaAmmInstruction2;
613
666
  })(PinaAmmInstruction || {});
614
667
  function identifyPinaAmmInstruction(instruction) {
@@ -643,6 +696,9 @@ function identifyPinaAmmInstruction(instruction) {
643
696
  if (containsBytes(data, getU8Encoder().encode(9), 0)) {
644
697
  return 9 /* SetPoolCreator */;
645
698
  }
699
+ if (containsBytes(data, getU8Encoder().encode(10), 0)) {
700
+ return 10 /* SyncPool */;
701
+ }
646
702
  throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, { instructionData: data, programName: "pinaAmm" });
647
703
  }
648
704
  function parsePinaAmmInstruction(instruction) {
@@ -688,6 +744,10 @@ function parsePinaAmmInstruction(instruction) {
688
744
  assertIsInstructionWithAccounts(instruction);
689
745
  return { instructionType: 9 /* SetPoolCreator */, ...parseSetPoolCreatorInstruction(instruction) };
690
746
  }
747
+ case 10 /* SyncPool */: {
748
+ assertIsInstructionWithAccounts(instruction);
749
+ return { instructionType: 10 /* SyncPool */, ...parseSyncPoolInstruction(instruction) };
750
+ }
691
751
  default:
692
752
  throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, { instructionType, programName: "pinaAmm" });
693
753
  }
@@ -705,7 +765,8 @@ function pinaAmmProgram() {
705
765
  swapExactOut: (input) => addSelfPlanAndSendFunctions(client, getSwapExactOutInstruction(input)),
706
766
  collectProtocolFees: (input) => addSelfPlanAndSendFunctions(client, getCollectProtocolFeesInstruction(input)),
707
767
  collectCreatorFees: (input) => addSelfPlanAndSendFunctions(client, getCollectCreatorFeesInstruction(input)),
708
- setPoolCreator: (input) => addSelfPlanAndSendFunctions(client, getSetPoolCreatorInstruction(input))
768
+ setPoolCreator: (input) => addSelfPlanAndSendFunctions(client, getSetPoolCreatorInstruction(input)),
769
+ syncPool: (input) => addSelfPlanAndSendFunctions(client, getSyncPoolInstruction(input))
709
770
  }, pdas: { ammConfig: findAmmConfigPda, pool: findPoolPda, poolVault: findPoolVaultPda, poolLpMint: findPoolLpMintPda }, identifyAccount: identifyPinaAmmAccount, identifyInstruction: identifyPinaAmmInstruction, parseInstruction: parsePinaAmmInstruction } });
710
771
  };
711
772
  }
@@ -726,9 +787,10 @@ var PINA_AMM_ERROR__MATH_OVERFLOW = 11;
726
787
  var PINA_AMM_ERROR__INVARIANT_VIOLATION = 12;
727
788
  var PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH = 13;
728
789
  var PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED = 14;
790
+ var PINA_AMM_ERROR__DEFAULT_CREATOR = 15;
729
791
  var pinaAmmErrorMessages;
730
792
  if (process.env["NODE_ENV"] !== "production") {
731
- 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.` };
793
+ 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.` };
732
794
  }
733
795
  function getPinaAmmErrorMessage(code) {
734
796
  if (process.env["NODE_ENV"] !== "production") {
@@ -831,6 +893,121 @@ function parseFeesCollectedEvent(data) {
831
893
  }
832
894
  throw new Error('The provided data does not match the "FeesCollectedEvent" event discriminators.');
833
895
  }
896
+ var POOL_SYNCED_EVENT_DISCRIMINATOR = 5;
897
+ function getPoolSyncedEventDiscriminatorBytes() {
898
+ return getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR);
899
+ }
900
+ var POOL_SYNCED_EVENT_DISCRIMINATOR2 = 1;
901
+ function getPoolSyncedEventDiscriminator2Bytes() {
902
+ return getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2);
903
+ }
904
+ function getPoolSyncedEventEncoder() {
905
+ 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 }));
906
+ }
907
+ function getPoolSyncedEventDecoder() {
908
+ 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()]]);
909
+ }
910
+ function getPoolSyncedEventCodec() {
911
+ return combineCodec(getPoolSyncedEventEncoder(), getPoolSyncedEventDecoder());
912
+ }
913
+ function parsePoolSyncedEvent(data) {
914
+ if (containsBytes(data, getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2), 1)) {
915
+ return getPoolSyncedEventDecoder().decode(data);
916
+ }
917
+ throw new Error('The provided data does not match the "PoolSyncedEvent" event discriminators.');
918
+ }
919
+ var POOL_SYNCED_V0_EVENT_DISCRIMINATOR = 5;
920
+ function getPoolSyncedV0EventDiscriminatorBytes() {
921
+ return getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR);
922
+ }
923
+ var POOL_SYNCED_V0_EVENT_DISCRIMINATOR2 = 0;
924
+ function getPoolSyncedV0EventDiscriminator2Bytes() {
925
+ return getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2);
926
+ }
927
+ function getPoolSyncedV0EventEncoder() {
928
+ return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()], ["migrationVersion", getU8Encoder()], ["pool", getAddressEncoder()], ["reserve0", getU64Encoder()], ["reserve1", getU64Encoder()], ["price0CumulativeLast", getU128Encoder()], ["lastUpdateTimestamp", getU64Encoder()]]), (value) => ({ ...value, discriminator: 5, migrationVersion: 0 }));
929
+ }
930
+ function getPoolSyncedV0EventDecoder() {
931
+ return getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_SYNCED_V0_EVENT_DISCRIMINATOR, getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ["pool", getAddressDecoder()], ["reserve0", getU64Decoder()], ["reserve1", getU64Decoder()], ["price0CumulativeLast", getU128Decoder()], ["lastUpdateTimestamp", getU64Decoder()]]);
932
+ }
933
+ function getPoolSyncedV0EventCodec() {
934
+ return combineCodec(getPoolSyncedV0EventEncoder(), getPoolSyncedV0EventDecoder());
935
+ }
936
+ function parsePoolSyncedV0Event(data) {
937
+ if (containsBytes(data, getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2), 1)) {
938
+ return getPoolSyncedV0EventDecoder().decode(data);
939
+ }
940
+ throw new Error('The provided data does not match the "PoolSyncedV0Event" event discriminators.');
941
+ }
942
+ var CONFIG_CREATED_EVENT_DISCRIMINATOR = 8;
943
+ function getConfigCreatedEventDiscriminatorBytes() {
944
+ return getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR);
945
+ }
946
+ var CONFIG_CREATED_EVENT_DISCRIMINATOR2 = 0;
947
+ function getConfigCreatedEventDiscriminator2Bytes() {
948
+ return getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR2);
949
+ }
950
+ function getConfigCreatedEventEncoder() {
951
+ return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()], ["migrationVersion", getU8Encoder()], ["ammConfig", getAddressEncoder()], ["authority", getAddressEncoder()], ["poolCreatorAuthority", getAddressEncoder()], ["tradeFeeRate", getU32Encoder()], ["protocolFeeRate", getU32Encoder()], ["creatorFeeRate", getU32Encoder()], ["index", getU16Encoder()]]), (value) => ({ ...value, discriminator: 8, migrationVersion: 0 }));
952
+ }
953
+ function getConfigCreatedEventDecoder() {
954
+ return getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(CONFIG_CREATED_EVENT_DISCRIMINATOR, getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ["ammConfig", getAddressDecoder()], ["authority", getAddressDecoder()], ["poolCreatorAuthority", getAddressDecoder()], ["tradeFeeRate", getU32Decoder()], ["protocolFeeRate", getU32Decoder()], ["creatorFeeRate", getU32Decoder()], ["index", getU16Decoder()]]);
955
+ }
956
+ function getConfigCreatedEventCodec() {
957
+ return combineCodec(getConfigCreatedEventEncoder(), getConfigCreatedEventDecoder());
958
+ }
959
+ function parseConfigCreatedEvent(data) {
960
+ if (containsBytes(data, getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR2), 1)) {
961
+ return getConfigCreatedEventDecoder().decode(data);
962
+ }
963
+ throw new Error('The provided data does not match the "ConfigCreatedEvent" event discriminators.');
964
+ }
965
+ var CONFIG_UPDATED_EVENT_DISCRIMINATOR = 6;
966
+ function getConfigUpdatedEventDiscriminatorBytes() {
967
+ return getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR);
968
+ }
969
+ var CONFIG_UPDATED_EVENT_DISCRIMINATOR2 = 0;
970
+ function getConfigUpdatedEventDiscriminator2Bytes() {
971
+ return getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR2);
972
+ }
973
+ function getConfigUpdatedEventEncoder() {
974
+ return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()], ["migrationVersion", getU8Encoder()], ["ammConfig", getAddressEncoder()], ["newAuthority", getAddressEncoder()], ["tradeFeeRate", getU32Encoder()], ["protocolFeeRate", getU32Encoder()], ["creatorFeeRate", getU32Encoder()]]), (value) => ({ ...value, discriminator: 6, migrationVersion: 0 }));
975
+ }
976
+ function getConfigUpdatedEventDecoder() {
977
+ return getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(CONFIG_UPDATED_EVENT_DISCRIMINATOR, getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ["ammConfig", getAddressDecoder()], ["newAuthority", getAddressDecoder()], ["tradeFeeRate", getU32Decoder()], ["protocolFeeRate", getU32Decoder()], ["creatorFeeRate", getU32Decoder()]]);
978
+ }
979
+ function getConfigUpdatedEventCodec() {
980
+ return combineCodec(getConfigUpdatedEventEncoder(), getConfigUpdatedEventDecoder());
981
+ }
982
+ function parseConfigUpdatedEvent(data) {
983
+ if (containsBytes(data, getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR2), 1)) {
984
+ return getConfigUpdatedEventDecoder().decode(data);
985
+ }
986
+ throw new Error('The provided data does not match the "ConfigUpdatedEvent" event discriminators.');
987
+ }
988
+ var POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR = 7;
989
+ function getPoolCreatorChangedEventDiscriminatorBytes() {
990
+ return getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR);
991
+ }
992
+ var POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2 = 0;
993
+ function getPoolCreatorChangedEventDiscriminator2Bytes() {
994
+ return getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2);
995
+ }
996
+ function getPoolCreatorChangedEventEncoder() {
997
+ return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()], ["migrationVersion", getU8Encoder()], ["pool", getAddressEncoder()], ["previousCreator", getAddressEncoder()], ["newCreator", getAddressEncoder()]]), (value) => ({ ...value, discriminator: 7, migrationVersion: 0 }));
998
+ }
999
+ function getPoolCreatorChangedEventDecoder() {
1000
+ return getStructDecoder([["discriminator", getPinaPodDiscriminatorDecoder(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR, getU8Decoder())], ["migrationVersion", getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ["pool", getAddressDecoder()], ["previousCreator", getAddressDecoder()], ["newCreator", getAddressDecoder()]]);
1001
+ }
1002
+ function getPoolCreatorChangedEventCodec() {
1003
+ return combineCodec(getPoolCreatorChangedEventEncoder(), getPoolCreatorChangedEventDecoder());
1004
+ }
1005
+ function parsePoolCreatorChangedEvent(data) {
1006
+ if (containsBytes(data, getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2), 1)) {
1007
+ return getPoolCreatorChangedEventDecoder().decode(data);
1008
+ }
1009
+ throw new Error('The provided data does not match the "PoolCreatorChangedEvent" event discriminators.');
1010
+ }
834
1011
 
835
1012
  // src/generated/events/logs.ts
836
1013
  function decodePoolCreatedEvent(data) {
@@ -1005,6 +1182,221 @@ function parseFeesCollectedEventFromLog(log) {
1005
1182
  }
1006
1183
  return decodeFeesCollectedEvent(bytes);
1007
1184
  }
1185
+ function decodePoolSyncedEvent(data) {
1186
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1187
+ const discriminatorBytes = getPoolSyncedEventDiscriminatorBytes();
1188
+ if (bytes.length < 2) {
1189
+ throw new RangeError(
1190
+ `the provided data is too short for the "PoolSyncedEvent" event envelope`
1191
+ );
1192
+ }
1193
+ for (let index = 0; index < 1; index += 1) {
1194
+ if (bytes[index] !== discriminatorBytes[index]) {
1195
+ throw new RangeError(
1196
+ 'the provided data does not match the "PoolSyncedEvent" event discriminator.'
1197
+ );
1198
+ }
1199
+ }
1200
+ const sourceVersion = bytes[1];
1201
+ if (sourceVersion !== 1) {
1202
+ throw new RangeError(
1203
+ `event migration version mismatch: expected 1, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1204
+ );
1205
+ }
1206
+ return { name: "poolSynced", data: getPoolSyncedEventDecoder().decode(bytes) };
1207
+ }
1208
+ function parsePoolSyncedEventFromLog(log) {
1209
+ const prefix = "Program data: ";
1210
+ if (!log.startsWith(prefix)) {
1211
+ return null;
1212
+ }
1213
+ const bytes = getBase64Encoder().encode(log.slice(prefix.length));
1214
+ if (bytes.length < 2) {
1215
+ return null;
1216
+ }
1217
+ const discriminatorBytes = getPoolSyncedEventDiscriminatorBytes();
1218
+ for (let index = 0; index < 1; index += 1) {
1219
+ if (bytes[index] !== discriminatorBytes[index]) {
1220
+ return null;
1221
+ }
1222
+ }
1223
+ if (bytes[1] !== 1) {
1224
+ return null;
1225
+ }
1226
+ return decodePoolSyncedEvent(bytes);
1227
+ }
1228
+ function decodePoolSyncedV0Event(data) {
1229
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1230
+ const discriminatorBytes = getPoolSyncedV0EventDiscriminatorBytes();
1231
+ if (bytes.length < 2) {
1232
+ throw new RangeError(
1233
+ `the provided data is too short for the "PoolSyncedV0Event" event envelope`
1234
+ );
1235
+ }
1236
+ for (let index = 0; index < 1; index += 1) {
1237
+ if (bytes[index] !== discriminatorBytes[index]) {
1238
+ throw new RangeError(
1239
+ 'the provided data does not match the "PoolSyncedV0Event" event discriminator.'
1240
+ );
1241
+ }
1242
+ }
1243
+ const sourceVersion = bytes[1];
1244
+ if (sourceVersion !== 0) {
1245
+ throw new RangeError(
1246
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1247
+ );
1248
+ }
1249
+ return { name: "poolSyncedV0", data: getPoolSyncedV0EventDecoder().decode(bytes) };
1250
+ }
1251
+ function parsePoolSyncedV0EventFromLog(log) {
1252
+ const prefix = "Program data: ";
1253
+ if (!log.startsWith(prefix)) {
1254
+ return null;
1255
+ }
1256
+ const bytes = getBase64Encoder().encode(log.slice(prefix.length));
1257
+ if (bytes.length < 2) {
1258
+ return null;
1259
+ }
1260
+ const discriminatorBytes = getPoolSyncedV0EventDiscriminatorBytes();
1261
+ for (let index = 0; index < 1; index += 1) {
1262
+ if (bytes[index] !== discriminatorBytes[index]) {
1263
+ return null;
1264
+ }
1265
+ }
1266
+ if (bytes[1] !== 0) {
1267
+ return null;
1268
+ }
1269
+ return decodePoolSyncedV0Event(bytes);
1270
+ }
1271
+ function decodeConfigCreatedEvent(data) {
1272
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1273
+ const discriminatorBytes = getConfigCreatedEventDiscriminatorBytes();
1274
+ if (bytes.length < 2) {
1275
+ throw new RangeError(
1276
+ `the provided data is too short for the "ConfigCreatedEvent" event envelope`
1277
+ );
1278
+ }
1279
+ for (let index = 0; index < 1; index += 1) {
1280
+ if (bytes[index] !== discriminatorBytes[index]) {
1281
+ throw new RangeError(
1282
+ 'the provided data does not match the "ConfigCreatedEvent" event discriminator.'
1283
+ );
1284
+ }
1285
+ }
1286
+ const sourceVersion = bytes[1];
1287
+ if (sourceVersion !== 0) {
1288
+ throw new RangeError(
1289
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1290
+ );
1291
+ }
1292
+ return { name: "configCreated", data: getConfigCreatedEventDecoder().decode(bytes) };
1293
+ }
1294
+ function parseConfigCreatedEventFromLog(log) {
1295
+ const prefix = "Program data: ";
1296
+ if (!log.startsWith(prefix)) {
1297
+ return null;
1298
+ }
1299
+ const bytes = getBase64Encoder().encode(log.slice(prefix.length));
1300
+ if (bytes.length < 2) {
1301
+ return null;
1302
+ }
1303
+ const discriminatorBytes = getConfigCreatedEventDiscriminatorBytes();
1304
+ for (let index = 0; index < 1; index += 1) {
1305
+ if (bytes[index] !== discriminatorBytes[index]) {
1306
+ return null;
1307
+ }
1308
+ }
1309
+ if (bytes[1] !== 0) {
1310
+ return null;
1311
+ }
1312
+ return decodeConfigCreatedEvent(bytes);
1313
+ }
1314
+ function decodeConfigUpdatedEvent(data) {
1315
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1316
+ const discriminatorBytes = getConfigUpdatedEventDiscriminatorBytes();
1317
+ if (bytes.length < 2) {
1318
+ throw new RangeError(
1319
+ `the provided data is too short for the "ConfigUpdatedEvent" event envelope`
1320
+ );
1321
+ }
1322
+ for (let index = 0; index < 1; index += 1) {
1323
+ if (bytes[index] !== discriminatorBytes[index]) {
1324
+ throw new RangeError(
1325
+ 'the provided data does not match the "ConfigUpdatedEvent" event discriminator.'
1326
+ );
1327
+ }
1328
+ }
1329
+ const sourceVersion = bytes[1];
1330
+ if (sourceVersion !== 0) {
1331
+ throw new RangeError(
1332
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1333
+ );
1334
+ }
1335
+ return { name: "configUpdated", data: getConfigUpdatedEventDecoder().decode(bytes) };
1336
+ }
1337
+ function parseConfigUpdatedEventFromLog(log) {
1338
+ const prefix = "Program data: ";
1339
+ if (!log.startsWith(prefix)) {
1340
+ return null;
1341
+ }
1342
+ const bytes = getBase64Encoder().encode(log.slice(prefix.length));
1343
+ if (bytes.length < 2) {
1344
+ return null;
1345
+ }
1346
+ const discriminatorBytes = getConfigUpdatedEventDiscriminatorBytes();
1347
+ for (let index = 0; index < 1; index += 1) {
1348
+ if (bytes[index] !== discriminatorBytes[index]) {
1349
+ return null;
1350
+ }
1351
+ }
1352
+ if (bytes[1] !== 0) {
1353
+ return null;
1354
+ }
1355
+ return decodeConfigUpdatedEvent(bytes);
1356
+ }
1357
+ function decodePoolCreatorChangedEvent(data) {
1358
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
1359
+ const discriminatorBytes = getPoolCreatorChangedEventDiscriminatorBytes();
1360
+ if (bytes.length < 2) {
1361
+ throw new RangeError(
1362
+ `the provided data is too short for the "PoolCreatorChangedEvent" event envelope`
1363
+ );
1364
+ }
1365
+ for (let index = 0; index < 1; index += 1) {
1366
+ if (bytes[index] !== discriminatorBytes[index]) {
1367
+ throw new RangeError(
1368
+ 'the provided data does not match the "PoolCreatorChangedEvent" event discriminator.'
1369
+ );
1370
+ }
1371
+ }
1372
+ const sourceVersion = bytes[1];
1373
+ if (sourceVersion !== 0) {
1374
+ throw new RangeError(
1375
+ `event migration version mismatch: expected 0, received ${sourceVersion} (decode it with the event for that version, or regenerate this client)`
1376
+ );
1377
+ }
1378
+ return { name: "poolCreatorChanged", data: getPoolCreatorChangedEventDecoder().decode(bytes) };
1379
+ }
1380
+ function parsePoolCreatorChangedEventFromLog(log) {
1381
+ const prefix = "Program data: ";
1382
+ if (!log.startsWith(prefix)) {
1383
+ return null;
1384
+ }
1385
+ const bytes = getBase64Encoder().encode(log.slice(prefix.length));
1386
+ if (bytes.length < 2) {
1387
+ return null;
1388
+ }
1389
+ const discriminatorBytes = getPoolCreatorChangedEventDiscriminatorBytes();
1390
+ for (let index = 0; index < 1; index += 1) {
1391
+ if (bytes[index] !== discriminatorBytes[index]) {
1392
+ return null;
1393
+ }
1394
+ }
1395
+ if (bytes[1] !== 0) {
1396
+ return null;
1397
+ }
1398
+ return decodePoolCreatorChangedEvent(bytes);
1399
+ }
1008
1400
  function unrecognizedEventVersion(log) {
1009
1401
  const prefix = "Program data: ";
1010
1402
  if (!log.startsWith(prefix)) {
@@ -1023,9 +1415,21 @@ function unrecognizedEventVersion(log) {
1023
1415
  if (bytes.length >= 1 && bytes[0] === 4) {
1024
1416
  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`;
1025
1417
  }
1418
+ if (bytes.length >= 1 && bytes[0] === 5) {
1419
+ 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`;
1420
+ }
1421
+ if (bytes.length >= 1 && bytes[0] === 8) {
1422
+ 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`;
1423
+ }
1424
+ if (bytes.length >= 1 && bytes[0] === 6) {
1425
+ 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`;
1426
+ }
1427
+ if (bytes.length >= 1 && bytes[0] === 7) {
1428
+ 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`;
1429
+ }
1026
1430
  return null;
1027
1431
  }
1028
- var PINA_AMM_EVENT_SOURCE_ADDRESS = "pAMMvXaqR2VVFqznf6dgvUFQjLXXAEeL9cb48cXsGeV";
1432
+ var PINA_AMM_EVENT_SOURCE_ADDRESS = "pAMMzVPRwtrxQs2CjLTUUpfCAp9XdvVmwwVhpAuCobi";
1029
1433
  var PROGRAM_INVOKE_LOG = /^Program (\S+) invoke \[\d+\]$/;
1030
1434
  var PROGRAM_EXIT_LOG = /^Program (\S+) (?:success|failed: .*)$/;
1031
1435
  function parsePinaAmmEventsFromLogs(logs, programAddress = PINA_AMM_EVENT_SOURCE_ADDRESS) {
@@ -1065,6 +1469,31 @@ function parsePinaAmmEventsFromLogs(logs, programAddress = PINA_AMM_EVENT_SOURCE
1065
1469
  discovered.push(feesCollected);
1066
1470
  continue;
1067
1471
  }
1472
+ const poolSynced = parsePoolSyncedEventFromLog(log);
1473
+ if (poolSynced !== null) {
1474
+ discovered.push(poolSynced);
1475
+ continue;
1476
+ }
1477
+ const poolSyncedV0 = parsePoolSyncedV0EventFromLog(log);
1478
+ if (poolSyncedV0 !== null) {
1479
+ discovered.push(poolSyncedV0);
1480
+ continue;
1481
+ }
1482
+ const configCreated = parseConfigCreatedEventFromLog(log);
1483
+ if (configCreated !== null) {
1484
+ discovered.push(configCreated);
1485
+ continue;
1486
+ }
1487
+ const configUpdated = parseConfigUpdatedEventFromLog(log);
1488
+ if (configUpdated !== null) {
1489
+ discovered.push(configUpdated);
1490
+ continue;
1491
+ }
1492
+ const poolCreatorChanged = parsePoolCreatorChangedEventFromLog(log);
1493
+ if (poolCreatorChanged !== null) {
1494
+ discovered.push(poolCreatorChanged);
1495
+ continue;
1496
+ }
1068
1497
  const unknownVersion = unrecognizedEventVersion(log);
1069
1498
  if (unknownVersion !== null) {
1070
1499
  throw new RangeError(unknownVersion);
@@ -1073,6 +1502,6 @@ function parsePinaAmmEventsFromLogs(logs, programAddress = PINA_AMM_EVENT_SOURCE
1073
1502
  return discovered;
1074
1503
  }
1075
1504
 
1076
- export { AMM_CONFIG_DISCRIMINATOR, AMM_CONFIG_DISCRIMINATOR2, AMM_CONFIG_MIGRATION_VERSION, COLLECT_CREATOR_FEES_DISCRIMINATOR, COLLECT_PROTOCOL_FEES_DISCRIMINATOR, CREATE_CONFIG_DISCRIMINATOR, CREATE_POOL_DISCRIMINATOR, DEPOSIT_DISCRIMINATOR, FEES_COLLECTED_EVENT_DISCRIMINATOR, FEES_COLLECTED_EVENT_DISCRIMINATOR2, LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR, LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2, MIGRATE_DISCRIMINATOR, PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY, PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY, PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE, PINA_AMM_ERROR__INVALID_FEE_RATES, PINA_AMM_ERROR__INVALID_MINT_ORDER, PINA_AMM_ERROR__INVALID_PROGRAM_DATA, PINA_AMM_ERROR__INVARIANT_VIOLATION, PINA_AMM_ERROR__MATH_OVERFLOW, PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH, PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED, PINA_AMM_ERROR__SLIPPAGE_EXCEEDED, PINA_AMM_ERROR__UNAUTHORIZED, PINA_AMM_ERROR__UNSUPPORTED_MINT, PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH, PINA_AMM_ERROR__ZERO_AMOUNT, PINA_AMM_EVENT_SOURCE_ADDRESS, PINA_AMM_PROGRAM_ADDRESS, POOL_CREATED_EVENT_DISCRIMINATOR, POOL_CREATED_EVENT_DISCRIMINATOR2, POOL_DISCRIMINATOR, POOL_DISCRIMINATOR2, POOL_MIGRATION_VERSION, PinaAmmAccount, PinaAmmEvent, PinaAmmInstruction, SET_POOL_CREATOR_DISCRIMINATOR, SWAPPED_EVENT_DISCRIMINATOR, SWAPPED_EVENT_DISCRIMINATOR2, SWAP_EXACT_IN_DISCRIMINATOR, SWAP_EXACT_OUT_DISCRIMINATOR, UPDATE_CONFIG_DISCRIMINATOR, WITHDRAW_DISCRIMINATOR, ammConfigNeedsMigration, decodeAmmConfig, decodeFeesCollectedEvent, decodeLiquidityChangedEvent, decodePool, decodePoolCreatedEvent, decodeSwappedEvent, fetchAllAmmConfig, fetchAllMaybeAmmConfig, fetchAllMaybePool, fetchAllPool, fetchAmmConfig, fetchAmmConfigFromSeeds, fetchMaybeAmmConfig, fetchMaybeAmmConfigFromSeeds, fetchMaybePool, fetchMaybePoolFromSeeds, fetchPool, fetchPoolFromSeeds, findAmmConfigPda, findPoolLpMintPda, findPoolPda, findPoolVaultPda, getAmmConfigCodec, getAmmConfigDecoder, getAmmConfigDiscriminator2Bytes, getAmmConfigDiscriminatorBytes, getAmmConfigEncoder, getCollectCreatorFeesDiscriminatorBytes, getCollectCreatorFeesInstruction, getCollectCreatorFeesInstructionDataCodec, getCollectCreatorFeesInstructionDataDecoder, getCollectCreatorFeesInstructionDataEncoder, getCollectProtocolFeesDiscriminatorBytes, getCollectProtocolFeesInstruction, getCollectProtocolFeesInstructionDataCodec, getCollectProtocolFeesInstructionDataDecoder, getCollectProtocolFeesInstructionDataEncoder, getCreateConfigDiscriminatorBytes, getCreateConfigInstruction, getCreateConfigInstructionDataCodec, getCreateConfigInstructionDataDecoder, getCreateConfigInstructionDataEncoder, getCreatePoolDiscriminatorBytes, getCreatePoolInstruction, getCreatePoolInstructionAsync, getCreatePoolInstructionDataCodec, getCreatePoolInstructionDataDecoder, getCreatePoolInstructionDataEncoder, getDepositDiscriminatorBytes, getDepositInstruction, getDepositInstructionDataCodec, getDepositInstructionDataDecoder, getDepositInstructionDataEncoder, getFeesCollectedEventCodec, getFeesCollectedEventDecoder, getFeesCollectedEventDiscriminator2Bytes, getFeesCollectedEventDiscriminatorBytes, getFeesCollectedEventEncoder, getLiquidityChangedEventCodec, getLiquidityChangedEventDecoder, getLiquidityChangedEventDiscriminator2Bytes, getLiquidityChangedEventDiscriminatorBytes, getLiquidityChangedEventEncoder, getMigrateDiscriminatorBytes, getMigrateInstruction, getPinaAmmErrorMessage, getPoolCodec, getPoolCreatedEventCodec, getPoolCreatedEventDecoder, getPoolCreatedEventDiscriminator2Bytes, getPoolCreatedEventDiscriminatorBytes, getPoolCreatedEventEncoder, getPoolDecoder, getPoolDiscriminator2Bytes, getPoolDiscriminatorBytes, getPoolEncoder, getSetPoolCreatorDiscriminatorBytes, getSetPoolCreatorInstruction, getSetPoolCreatorInstructionDataCodec, getSetPoolCreatorInstructionDataDecoder, getSetPoolCreatorInstructionDataEncoder, getSwapExactInDiscriminatorBytes, getSwapExactInInstruction, getSwapExactInInstructionDataCodec, getSwapExactInInstructionDataDecoder, getSwapExactInInstructionDataEncoder, getSwapExactOutDiscriminatorBytes, getSwapExactOutInstruction, getSwapExactOutInstructionDataCodec, getSwapExactOutInstructionDataDecoder, getSwapExactOutInstructionDataEncoder, getSwappedEventCodec, getSwappedEventDecoder, getSwappedEventDiscriminator2Bytes, getSwappedEventDiscriminatorBytes, getSwappedEventEncoder, getUpdateConfigDiscriminatorBytes, getUpdateConfigInstruction, getUpdateConfigInstructionDataCodec, getUpdateConfigInstructionDataDecoder, getUpdateConfigInstructionDataEncoder, getWithdrawDiscriminatorBytes, getWithdrawInstruction, getWithdrawInstructionDataCodec, getWithdrawInstructionDataDecoder, getWithdrawInstructionDataEncoder, identifyPinaAmmAccount, identifyPinaAmmEvent, identifyPinaAmmInstruction, isPinaAmmError, parseCollectCreatorFeesInstruction, parseCollectProtocolFeesInstruction, parseCreateConfigInstruction, parseCreatePoolInstruction, parseDepositInstruction, parseFeesCollectedEvent, parseFeesCollectedEventFromLog, parseLiquidityChangedEvent, parseLiquidityChangedEventFromLog, parsePinaAmmEventsFromLogs, parsePinaAmmInstruction, parsePoolCreatedEvent, parsePoolCreatedEventFromLog, parseSetPoolCreatorInstruction, parseSwapExactInInstruction, parseSwapExactOutInstruction, parseSwappedEvent, parseSwappedEventFromLog, parseUpdateConfigInstruction, parseWithdrawInstruction, pinaAmmProgram, poolNeedsMigration };
1505
+ export { AMM_CONFIG_DISCRIMINATOR, AMM_CONFIG_DISCRIMINATOR2, AMM_CONFIG_MIGRATION_VERSION, COLLECT_CREATOR_FEES_DISCRIMINATOR, COLLECT_PROTOCOL_FEES_DISCRIMINATOR, CONFIG_CREATED_EVENT_DISCRIMINATOR, CONFIG_CREATED_EVENT_DISCRIMINATOR2, CONFIG_UPDATED_EVENT_DISCRIMINATOR, CONFIG_UPDATED_EVENT_DISCRIMINATOR2, CREATE_CONFIG_DISCRIMINATOR, CREATE_POOL_DISCRIMINATOR, DEPOSIT_DISCRIMINATOR, FEES_COLLECTED_EVENT_DISCRIMINATOR, FEES_COLLECTED_EVENT_DISCRIMINATOR2, LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR, LIQUIDITY_CHANGED_EVENT_DISCRIMINATOR2, MIGRATE_DISCRIMINATOR, PINA_AMM_ERROR__DEFAULT_CREATOR, PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY, PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY, PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE, PINA_AMM_ERROR__INVALID_FEE_RATES, PINA_AMM_ERROR__INVALID_MINT_ORDER, PINA_AMM_ERROR__INVALID_PROGRAM_DATA, PINA_AMM_ERROR__INVARIANT_VIOLATION, PINA_AMM_ERROR__MATH_OVERFLOW, PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH, PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED, PINA_AMM_ERROR__SLIPPAGE_EXCEEDED, PINA_AMM_ERROR__UNAUTHORIZED, PINA_AMM_ERROR__UNSUPPORTED_MINT, PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH, PINA_AMM_ERROR__ZERO_AMOUNT, PINA_AMM_EVENT_SOURCE_ADDRESS, PINA_AMM_PROGRAM_ADDRESS, POOL_CREATED_EVENT_DISCRIMINATOR, POOL_CREATED_EVENT_DISCRIMINATOR2, POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR, POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2, POOL_DISCRIMINATOR, POOL_DISCRIMINATOR2, POOL_MIGRATION_VERSION, POOL_SYNCED_EVENT_DISCRIMINATOR, POOL_SYNCED_EVENT_DISCRIMINATOR2, POOL_SYNCED_V0_EVENT_DISCRIMINATOR, POOL_SYNCED_V0_EVENT_DISCRIMINATOR2, PinaAmmAccount, PinaAmmEvent, PinaAmmInstruction, SET_POOL_CREATOR_DISCRIMINATOR, SWAPPED_EVENT_DISCRIMINATOR, SWAPPED_EVENT_DISCRIMINATOR2, SWAP_EXACT_IN_DISCRIMINATOR, SWAP_EXACT_OUT_DISCRIMINATOR, SYNC_POOL_DISCRIMINATOR, UPDATE_CONFIG_DISCRIMINATOR, WITHDRAW_DISCRIMINATOR, ammConfigNeedsMigration, decodeAmmConfig, decodeConfigCreatedEvent, decodeConfigUpdatedEvent, decodeFeesCollectedEvent, decodeLiquidityChangedEvent, decodePool, decodePoolCreatedEvent, decodePoolCreatorChangedEvent, decodePoolSyncedEvent, decodePoolSyncedV0Event, decodeSwappedEvent, fetchAllAmmConfig, fetchAllMaybeAmmConfig, fetchAllMaybePool, fetchAllPool, fetchAmmConfig, fetchAmmConfigFromSeeds, fetchMaybeAmmConfig, fetchMaybeAmmConfigFromSeeds, fetchMaybePool, fetchMaybePoolFromSeeds, fetchPool, fetchPoolFromSeeds, findAmmConfigPda, findPoolLpMintPda, findPoolPda, findPoolVaultPda, getAmmConfigCodec, getAmmConfigDecoder, getAmmConfigDiscriminator2Bytes, getAmmConfigDiscriminatorBytes, getAmmConfigEncoder, getCollectCreatorFeesDiscriminatorBytes, getCollectCreatorFeesInstruction, getCollectCreatorFeesInstructionDataCodec, getCollectCreatorFeesInstructionDataDecoder, getCollectCreatorFeesInstructionDataEncoder, getCollectProtocolFeesDiscriminatorBytes, getCollectProtocolFeesInstruction, getCollectProtocolFeesInstructionDataCodec, getCollectProtocolFeesInstructionDataDecoder, getCollectProtocolFeesInstructionDataEncoder, getConfigCreatedEventCodec, getConfigCreatedEventDecoder, getConfigCreatedEventDiscriminator2Bytes, getConfigCreatedEventDiscriminatorBytes, getConfigCreatedEventEncoder, getConfigUpdatedEventCodec, getConfigUpdatedEventDecoder, getConfigUpdatedEventDiscriminator2Bytes, getConfigUpdatedEventDiscriminatorBytes, getConfigUpdatedEventEncoder, getCreateConfigDiscriminatorBytes, getCreateConfigInstruction, getCreateConfigInstructionDataCodec, getCreateConfigInstructionDataDecoder, getCreateConfigInstructionDataEncoder, getCreatePoolDiscriminatorBytes, getCreatePoolInstruction, getCreatePoolInstructionAsync, getCreatePoolInstructionDataCodec, getCreatePoolInstructionDataDecoder, getCreatePoolInstructionDataEncoder, getDepositDiscriminatorBytes, getDepositInstruction, getDepositInstructionDataCodec, getDepositInstructionDataDecoder, getDepositInstructionDataEncoder, getFeesCollectedEventCodec, getFeesCollectedEventDecoder, getFeesCollectedEventDiscriminator2Bytes, getFeesCollectedEventDiscriminatorBytes, getFeesCollectedEventEncoder, getLiquidityChangedEventCodec, getLiquidityChangedEventDecoder, getLiquidityChangedEventDiscriminator2Bytes, getLiquidityChangedEventDiscriminatorBytes, getLiquidityChangedEventEncoder, getMigrateDiscriminatorBytes, getMigrateInstruction, getPinaAmmErrorMessage, getPoolCodec, getPoolCreatedEventCodec, getPoolCreatedEventDecoder, getPoolCreatedEventDiscriminator2Bytes, getPoolCreatedEventDiscriminatorBytes, getPoolCreatedEventEncoder, getPoolCreatorChangedEventCodec, getPoolCreatorChangedEventDecoder, getPoolCreatorChangedEventDiscriminator2Bytes, getPoolCreatorChangedEventDiscriminatorBytes, getPoolCreatorChangedEventEncoder, getPoolDecoder, getPoolDiscriminator2Bytes, getPoolDiscriminatorBytes, getPoolEncoder, getPoolSyncedEventCodec, getPoolSyncedEventDecoder, getPoolSyncedEventDiscriminator2Bytes, getPoolSyncedEventDiscriminatorBytes, getPoolSyncedEventEncoder, getPoolSyncedV0EventCodec, getPoolSyncedV0EventDecoder, getPoolSyncedV0EventDiscriminator2Bytes, getPoolSyncedV0EventDiscriminatorBytes, getPoolSyncedV0EventEncoder, getSetPoolCreatorDiscriminatorBytes, getSetPoolCreatorInstruction, getSetPoolCreatorInstructionDataCodec, getSetPoolCreatorInstructionDataDecoder, getSetPoolCreatorInstructionDataEncoder, getSwapExactInDiscriminatorBytes, getSwapExactInInstruction, getSwapExactInInstructionDataCodec, getSwapExactInInstructionDataDecoder, getSwapExactInInstructionDataEncoder, getSwapExactOutDiscriminatorBytes, getSwapExactOutInstruction, getSwapExactOutInstructionDataCodec, getSwapExactOutInstructionDataDecoder, getSwapExactOutInstructionDataEncoder, getSwappedEventCodec, getSwappedEventDecoder, getSwappedEventDiscriminator2Bytes, getSwappedEventDiscriminatorBytes, getSwappedEventEncoder, getSyncPoolDiscriminatorBytes, getSyncPoolInstruction, getSyncPoolInstructionDataCodec, getSyncPoolInstructionDataDecoder, getSyncPoolInstructionDataEncoder, getUpdateConfigDiscriminatorBytes, getUpdateConfigInstruction, getUpdateConfigInstructionDataCodec, getUpdateConfigInstructionDataDecoder, getUpdateConfigInstructionDataEncoder, getWithdrawDiscriminatorBytes, getWithdrawInstruction, getWithdrawInstructionDataCodec, getWithdrawInstructionDataDecoder, getWithdrawInstructionDataEncoder, identifyPinaAmmAccount, identifyPinaAmmEvent, identifyPinaAmmInstruction, isPinaAmmError, parseCollectCreatorFeesInstruction, parseCollectProtocolFeesInstruction, parseConfigCreatedEvent, parseConfigCreatedEventFromLog, parseConfigUpdatedEvent, parseConfigUpdatedEventFromLog, parseCreateConfigInstruction, parseCreatePoolInstruction, parseDepositInstruction, parseFeesCollectedEvent, parseFeesCollectedEventFromLog, parseLiquidityChangedEvent, parseLiquidityChangedEventFromLog, parsePinaAmmEventsFromLogs, parsePinaAmmInstruction, parsePoolCreatedEvent, parsePoolCreatedEventFromLog, parsePoolCreatorChangedEvent, parsePoolCreatorChangedEventFromLog, parsePoolSyncedEvent, parsePoolSyncedEventFromLog, parsePoolSyncedV0Event, parsePoolSyncedV0EventFromLog, parseSetPoolCreatorInstruction, parseSwapExactInInstruction, parseSwapExactOutInstruction, parseSwappedEvent, parseSwappedEventFromLog, parseSyncPoolInstruction, parseUpdateConfigInstruction, parseWithdrawInstruction, pinaAmmProgram, poolNeedsMigration };
1077
1506
  //# sourceMappingURL=index.js.map
1078
1507
  //# sourceMappingURL=index.js.map