@whetstone-research/doppler-sdk 1.0.27 → 1.0.28

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.
@@ -1,11 +1,12 @@
1
- import { transferAdminArgsCodec, swapExactInArgsCodec, sortPositionsByShares, sortPoolsByReserves, setHookArgsCodec, setFeesArgsCodec, removeLiquidityArgsCodec, ratioToNumber, q64ToNumber, q64Mul, q64Div, positionDataCodec, poolExists, poolDataCodec, parseWithdrawVaultExcessInstruction, parseUpdateConfigInstruction, parseUnpauseInstruction, parseTransferAdminInstruction, parseSwapExactInInstruction, parseSetHookInstruction, parseSetFeesInstruction, parseRemoveLiquidityInstruction, parseRedeemProtocolSharesInstruction, parsePreviewSwapExactInInstruction, parsePauseInstruction, parseOracleUpdateInstruction, parseOracleConsultInstruction, parseInitializePoolInstruction, parseInitializeOracleInstruction, parseInitializeConfigInstruction, parseCreatePositionInstruction, parseCollectProtocolFeesInstruction, parseCollectFeesInstruction, parseClosePositionInstruction, parseAddLiquidityInstruction, oracleStateDataCodec, oracleConsultArgsCodec, observationCodec, numberToQ64, minBigInt, maxBigInt, isqrt, isOracleStale, initializePoolArgsCodec, initializeOracleArgsCodec, initializeConfigArgsCodec, getWithdrawVaultExcessInstructionDataEncoder, getWithdrawVaultExcessInstructionDataDecoder, getWithdrawVaultExcessInstructionDataCodec, getWithdrawVaultExcessInstructionAsync, getWithdrawVaultExcessInstruction, getWithdrawVaultExcessDiscriminatorBytes, getUpdateConfigInstructionDataEncoder, getUpdateConfigInstructionDataDecoder, getUpdateConfigInstructionDataCodec, getUpdateConfigInstruction, getUpdateConfigDiscriminatorBytes, getUnpauseInstructionDataEncoder, getUnpauseInstructionDataDecoder, getUnpauseInstructionDataCodec, getUnpauseInstruction, getUnpauseDiscriminatorBytes, getTvl, getTransferAdminInstructionDataEncoder, getTransferAdminInstructionDataDecoder, getTransferAdminInstructionDataCodec, getTransferAdminInstruction, getTransferAdminDiscriminatorBytes, getSwapQuoteExactOut, getSwapQuote, getSwapExactInInstructionDataEncoder, getSwapExactInInstructionDataDecoder, getSwapExactInInstructionDataCodec, getSwapExactInInstructionAsync, getSwapExactInInstruction, getSwapExactInDiscriminatorBytes, getSpotPrice1, getSpotPrice0, getSetHookInstructionDataEncoder, getSetHookInstructionDataDecoder, getSetHookInstructionDataCodec, getSetHookInstruction, getSetHookDiscriminatorBytes, getSetFeesInstructionDataEncoder, getSetFeesInstructionDataDecoder, getSetFeesInstructionDataCodec, getSetFeesInstruction, getSetFeesDiscriminatorBytes, getRemoveLiquidityQuote, getRemoveLiquidityInstructionDataEncoder, getRemoveLiquidityInstructionDataDecoder, getRemoveLiquidityInstructionDataCodec, getRemoveLiquidityInstructionAsync, getRemoveLiquidityInstruction, getRemoveLiquidityDiscriminatorBytes, getRedeemProtocolSharesInstructionDataEncoder, getRedeemProtocolSharesInstructionDataDecoder, getRedeemProtocolSharesInstructionDataCodec, getRedeemProtocolSharesInstructionAsync, getRedeemProtocolSharesInstruction, getRedeemProtocolSharesDiscriminatorBytes, getPreviewSwapExactInInstructionDataEncoder, getPreviewSwapExactInInstructionDataDecoder, getPreviewSwapExactInInstructionDataCodec, getPreviewSwapExactInInstruction, getPreviewSwapExactInDiscriminatorBytes, getPositionValue, getPositionAddressFromParams, getPoolByMints, getPoolAddressFromMints, getPendingFees, getPauseInstructionDataEncoder, getPauseInstructionDataDecoder, getPauseInstructionDataCodec, getPauseInstruction, getPauseDiscriminatorBytes, getOracleUpdateInstructionDataEncoder, getOracleUpdateInstructionDataDecoder, getOracleUpdateInstructionDataCodec, getOracleUpdateInstructionAsync, getOracleUpdateInstruction, getOracleUpdateDiscriminatorBytes, getOracleSpotPrices, getOracleForPool, getOracleDeviation, getOracleConsultInstructionDataEncoder, getOracleConsultInstructionDataDecoder, getOracleConsultInstructionDataCodec, getOracleConsultInstructionAsync, getOracleConsultInstruction, getOracleConsultDiscriminatorBytes, getOracleBufferStats, getOracleAge, getOracleAddressFromPool, getK, getInitializePoolInstructionDataEncoder, getInitializePoolInstructionDataDecoder, getInitializePoolInstructionDataCodec, getInitializePoolInstructionAsync, getInitializePoolInstruction, getInitializePoolDiscriminatorBytes, getInitializeOracleInstructionDataEncoder, getInitializeOracleInstructionDataDecoder, getInitializeOracleInstructionDataCodec, getInitializeOracleInstructionAsync, getInitializeOracleInstruction, getInitializeOracleDiscriminatorBytes, getInitializeConfigInstructionDataEncoder, getInitializeConfigInstructionDataDecoder, getInitializeConfigInstructionDataCodec, getInitializeConfigInstructionAsync, getInitializeConfigInstruction, getInitializeConfigDiscriminatorBytes, getCreatePositionInstructionDataEncoder, getCreatePositionInstructionDataDecoder, getCreatePositionInstructionDataCodec, getCreatePositionInstructionAsync, getCreatePositionInstruction, getCreatePositionDiscriminatorBytes, getCollectProtocolFeesInstructionDataEncoder, getCollectProtocolFeesInstructionDataDecoder, getCollectProtocolFeesInstructionDataCodec, getCollectProtocolFeesInstructionAsync, getCollectProtocolFeesInstruction, getCollectProtocolFeesDiscriminatorBytes, getCollectFeesInstructionDataEncoder, getCollectFeesInstructionDataDecoder, getCollectFeesInstructionDataCodec, getCollectFeesInstructionAsync, getCollectFeesInstruction, getCollectFeesDiscriminatorBytes, getClosePositionInstructionDataEncoder, getClosePositionInstructionDataDecoder, getClosePositionInstructionDataCodec, getClosePositionInstruction, getClosePositionDiscriminatorBytes, getAddLiquidityQuote, getAddLiquidityInstructionDataEncoder, getAddLiquidityInstructionDataDecoder, getAddLiquidityInstructionDataCodec, getAddLiquidityInstructionAsync, getAddLiquidityInstruction, getAddLiquidityDiscriminatorBytes, filterPoolsByMint, filterActivePositions, fetchUserPositions, fetchPositionsBatch, fetchPositionByParams, fetchPosition, fetchPoolsBatch, fetchPoolPositions, fetchPool, fetchOraclesBatch, fetchOracle, fetchAllPools, encodeTransferAdminArgs, encodeSwapExactInArgs, encodeSetHookArgs, encodeSetFeesArgs, encodeRemoveLiquidityArgs, encodeOracleConsultArgs, encodeInstructionData, encodeInitializePoolArgs, encodeInitializeOracleArgs, encodeInitializeConfigArgs, encodeCreatePositionArgs, encodeCollectProtocolFeesArgs, encodeCollectFeesArgs, encodeAddLiquidityArgs, decodePosition, decodePool, decodeOracleState, decodeAmmConfig, createPositionArgsCodec, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, ammConfigDataCodec, addLiquidityArgsCodec, WITHDRAW_VAULT_EXCESS_DISCRIMINATOR, UPDATE_CONFIG_DISCRIMINATOR, UNPAUSE_DISCRIMINATOR, TRANSFER_ADMIN_DISCRIMINATOR, SWAP_EXACT_IN_DISCRIMINATOR, SET_HOOK_DISCRIMINATOR, SET_FEES_DISCRIMINATOR, REMOVE_LIQUIDITY_DISCRIMINATOR, REDEEM_PROTOCOL_SHARES_DISCRIMINATOR, PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR, PAUSE_DISCRIMINATOR, ORACLE_UPDATE_DISCRIMINATOR, ORACLE_CONSULT_DISCRIMINATOR, INITIALIZE_POOL_DISCRIMINATOR, INITIALIZE_ORACLE_DISCRIMINATOR, INITIALIZE_CONFIG_DISCRIMINATOR, CREATE_POSITION_DISCRIMINATOR, COLLECT_PROTOCOL_FEES_DISCRIMINATOR, COLLECT_FEES_DISCRIMINATOR, CLOSE_POSITION_DISCRIMINATOR, ADD_LIQUIDITY_DISCRIMINATOR, CPMM_PROGRAM_ADDRESS } from '../chunk-RVDRWCJN.js';
1
+ import { warnAccountDecodeFailure, transferAdminArgsCodec, swapExactInArgsCodec, sortPositionsByShares, sortPoolsByReserves, setHookArgsCodec, setFeesArgsCodec, removeLiquidityArgsCodec, ratioToNumber, q64ToNumber, q64Mul, q64Div, positionDataCodec, poolExists, poolDataCodec, parseWithdrawVaultExcessInstruction, parseUpdateConfigInstruction, parseUnpauseInstruction, parseTransferAdminInstruction, parseSwapExactInInstruction, parseSetHookInstruction, parseSetFeesInstruction, parseRemoveLiquidityInstruction, parseRedeemProtocolSharesInstruction, parsePreviewSwapExactInInstruction, parsePauseInstruction, parseOracleUpdateInstruction, parseOracleConsultInstruction, parseInitializePoolInstruction, parseInitializeOracleInstruction, parseInitializeConfigInstruction, parseCreatePositionInstruction, parseCollectProtocolFeesInstruction, parseCollectFeesInstruction, parseClosePositionInstruction, parseAddLiquidityInstruction, oracleStateDataCodec, oracleConsultArgsCodec, observationCodec, numberToQ64, normalizeProgramAccountsResponse, minBigInt, maxBigInt, isqrt, isTransactionSigner, isOracleStale, initializePoolArgsCodec, initializeOracleArgsCodec, initializeConfigArgsCodec, getWithdrawVaultExcessInstructionDataEncoder, getWithdrawVaultExcessInstructionDataDecoder, getWithdrawVaultExcessInstructionDataCodec, getWithdrawVaultExcessInstructionAsync, getWithdrawVaultExcessInstruction, getWithdrawVaultExcessDiscriminatorBytes, getUpdateConfigInstructionDataEncoder, getUpdateConfigInstructionDataDecoder, getUpdateConfigInstructionDataCodec, getUpdateConfigInstruction, getUpdateConfigDiscriminatorBytes, getUnpauseInstructionDataEncoder, getUnpauseInstructionDataDecoder, getUnpauseInstructionDataCodec, getUnpauseInstruction, getUnpauseDiscriminatorBytes, getTvl, getTransferAdminInstructionDataEncoder, getTransferAdminInstructionDataDecoder, getTransferAdminInstructionDataCodec, getTransferAdminInstruction, getTransferAdminDiscriminatorBytes, getSwapQuoteExactOut, getSwapQuote, getSwapExactInInstructionDataEncoder, getSwapExactInInstructionDataDecoder, getSwapExactInInstructionDataCodec, getSwapExactInInstructionAsync, getSwapExactInInstruction, getSwapExactInDiscriminatorBytes, getSpotPrice1, getSpotPrice0, getSetHookInstructionDataEncoder, getSetHookInstructionDataDecoder, getSetHookInstructionDataCodec, getSetHookInstruction, getSetHookDiscriminatorBytes, getSetFeesInstructionDataEncoder, getSetFeesInstructionDataDecoder, getSetFeesInstructionDataCodec, getSetFeesInstruction, getSetFeesDiscriminatorBytes, getRemoveLiquidityQuote, getRemoveLiquidityInstructionDataEncoder, getRemoveLiquidityInstructionDataDecoder, getRemoveLiquidityInstructionDataCodec, getRemoveLiquidityInstructionAsync, getRemoveLiquidityInstruction, getRemoveLiquidityDiscriminatorBytes, getRedeemProtocolSharesInstructionDataEncoder, getRedeemProtocolSharesInstructionDataDecoder, getRedeemProtocolSharesInstructionDataCodec, getRedeemProtocolSharesInstructionAsync, getRedeemProtocolSharesInstruction, getRedeemProtocolSharesDiscriminatorBytes, getPreviewSwapExactInInstructionDataEncoder, getPreviewSwapExactInInstructionDataDecoder, getPreviewSwapExactInInstructionDataCodec, getPreviewSwapExactInInstruction, getPreviewSwapExactInDiscriminatorBytes, getPositionValue, getPositionAddressFromParams, getPoolByMints, getPoolAddressFromMints, getPendingFees, getPauseInstructionDataEncoder, getPauseInstructionDataDecoder, getPauseInstructionDataCodec, getPauseInstruction, getPauseDiscriminatorBytes, getOracleUpdateInstructionDataEncoder, getOracleUpdateInstructionDataDecoder, getOracleUpdateInstructionDataCodec, getOracleUpdateInstructionAsync, getOracleUpdateInstruction, getOracleUpdateDiscriminatorBytes, getOracleSpotPrices, getOracleForPool, getOracleDeviation, getOracleConsultInstructionDataEncoder, getOracleConsultInstructionDataDecoder, getOracleConsultInstructionDataCodec, getOracleConsultInstructionAsync, getOracleConsultInstruction, getOracleConsultDiscriminatorBytes, getOracleBufferStats, getOracleAge, getOracleAddressFromPool, getK, getInitializePoolInstructionDataEncoder, getInitializePoolInstructionDataDecoder, getInitializePoolInstructionDataCodec, getInitializePoolInstructionAsync, getInitializePoolInstruction, getInitializePoolDiscriminatorBytes, getInitializeOracleInstructionDataEncoder, getInitializeOracleInstructionDataDecoder, getInitializeOracleInstructionDataCodec, getInitializeOracleInstructionAsync, getInitializeOracleInstruction, getInitializeOracleDiscriminatorBytes, getInitializeConfigInstructionDataEncoder, getInitializeConfigInstructionDataDecoder, getInitializeConfigInstructionDataCodec, getInitializeConfigInstructionAsync, getInitializeConfigInstruction, getInitializeConfigDiscriminatorBytes, getCreatePositionInstructionDataEncoder, getCreatePositionInstructionDataDecoder, getCreatePositionInstructionDataCodec, getCreatePositionInstructionAsync, getCreatePositionInstruction, getCreatePositionDiscriminatorBytes, getCollectProtocolFeesInstructionDataEncoder, getCollectProtocolFeesInstructionDataDecoder, getCollectProtocolFeesInstructionDataCodec, getCollectProtocolFeesInstructionAsync, getCollectProtocolFeesInstruction, getCollectProtocolFeesDiscriminatorBytes, getCollectFeesInstructionDataEncoder, getCollectFeesInstructionDataDecoder, getCollectFeesInstructionDataCodec, getCollectFeesInstructionAsync, getCollectFeesInstruction, getCollectFeesDiscriminatorBytes, getClosePositionInstructionDataEncoder, getClosePositionInstructionDataDecoder, getClosePositionInstructionDataCodec, getClosePositionInstruction, getClosePositionDiscriminatorBytes, getAddressFromRemainingAccount, getAddressFromAddressOrSigner, getAddLiquidityQuote, getAddLiquidityInstructionDataEncoder, getAddLiquidityInstructionDataDecoder, getAddLiquidityInstructionDataCodec, getAddLiquidityInstructionAsync, getAddLiquidityInstruction, getAddLiquidityDiscriminatorBytes, filterPoolsByMint, filterActivePositions, fetchUserPositions, fetchPositionsBatch, fetchPositionByParams, fetchPosition, fetchPoolsBatch, fetchPoolPositions, fetchPool, fetchOraclesBatch, fetchOracle, fetchAllPools, encodeTransferAdminArgs, encodeSwapExactInArgs, encodeSetHookArgs, encodeSetFeesArgs, encodeRemoveLiquidityArgs, encodeOracleConsultArgs, encodeInstructionData, encodeInitializePoolArgs, encodeInitializeOracleArgs, encodeInitializeConfigArgs, encodeCreatePositionArgs, encodeCollectProtocolFeesArgs, encodeCollectFeesArgs, encodeAddLiquidityArgs, decodePosition, decodePool, decodeOracleState, decodeAmmConfig, createReadonlyRemainingAccountMeta, createPositionArgsCodec, createAccountMeta, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, bytesToBase64EncodedBytes, bytesToBase64, base64ToBytes, ammConfigDataCodec, addressToBase58EncodedBytes, addLiquidityArgsCodec, WITHDRAW_VAULT_EXCESS_DISCRIMINATOR, UPDATE_CONFIG_DISCRIMINATOR, UNPAUSE_DISCRIMINATOR, TRANSFER_ADMIN_DISCRIMINATOR, SWAP_EXACT_IN_DISCRIMINATOR, SET_HOOK_DISCRIMINATOR, SET_FEES_DISCRIMINATOR, REMOVE_LIQUIDITY_DISCRIMINATOR, REDEEM_PROTOCOL_SHARES_DISCRIMINATOR, PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR, PAUSE_DISCRIMINATOR, ORACLE_UPDATE_DISCRIMINATOR, ORACLE_CONSULT_DISCRIMINATOR, INITIALIZE_POOL_DISCRIMINATOR, INITIALIZE_ORACLE_DISCRIMINATOR, INITIALIZE_CONFIG_DISCRIMINATOR, CREATE_POSITION_DISCRIMINATOR, COLLECT_PROTOCOL_FEES_DISCRIMINATOR, COLLECT_FEES_DISCRIMINATOR, CLOSE_POSITION_DISCRIMINATOR, ADD_LIQUIDITY_DISCRIMINATOR, CPMM_PROGRAM_ADDRESS } from '../chunk-AYVFWD5P.js';
2
2
  import { sortMints, getSwapAddresses, getProtocolFeePositionAddress, getProtocolFeeOwnerAddress, getPositionAddress, getPoolVault1Address, getPoolVault0Address, getPoolInitAddresses, getPoolAuthorityAddress, getPoolAddress, getOracleAddress, getLiquidityAddresses, getConfigAddress, CPMM_PROGRAM_ID, areMintsOrdered, TOKEN_METADATA_PROGRAM_ID, SEED_PROTOCOL_FEE_OWNER, SEED_POSITION, SEED_POOL, SEED_ORACLE, SEED_CONFIG, SEED_AUTHORITY, Q64_ONE, MAX_ORACLE_OBSERVATIONS, MAX_HOOK_ALLOWLIST, INSTRUCTION_DISCRIMINATORS, HOOK_NO_CHANGE, HF_REQUIRE_ORACLE, HF_FORWARD_READONLY_SIGNERS, HF_BEFORE_SWAP, HF_BEFORE_REMOVE_LIQ, HF_BEFORE_ADD_LIQ, HF_AFTER_SWAP, HF_AFTER_REMOVE_LIQ, HF_AFTER_ADD_LIQ, BPS_DENOM, ACCOUNT_VERSION, ACCOUNT_DISCRIMINATORS, TOKEN_PROGRAM_ADDRESS, SYSTEM_PROGRAM_ADDRESS, SYSVAR_INSTRUCTIONS_ADDRESS, TOKEN_2022_PROGRAM_ADDRESS, SYSVAR_RENT_ADDRESS } from '../chunk-WD5VOZGI.js';
3
3
  import { __export } from '../chunk-PZ5AY32C.js';
4
4
  import { getAddressCodec, getProgramDerivedAddress, createNoopSigner, address, fixEncoderSize, getBytesEncoder, transformEncoder, getStructEncoder, getAddressEncoder, getU8Encoder, getArrayEncoder, getStructDecoder, fixDecoderSize, getAddressDecoder, getU8Decoder, getArrayDecoder, getBytesDecoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, 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, isProgramError, getU16Encoder, getU16Decoder, getU64Encoder, addEncoderSizePrefix, getU32Encoder, getUtf8Encoder, getU64Decoder, addDecoderSizePrefix, getU32Decoder, getUtf8Decoder, AccountRole, getStructCodec, getU64Codec, getOptionEncoder, getU128Encoder, getOptionDecoder, getU128Decoder, getBooleanEncoder, getBooleanDecoder, mergeBytes, compressTransactionMessageUsingAddressLookupTables, getTransactionMessageSize, getEnumEncoder } from '@solana/kit';
5
5
  import { getAccountMetaFactory, addSelfPlanAndSendFunctions, addSelfFetchFunctions, getAddressFromResolvedInstructionAccount } from '@solana/program-client-core';
6
6
  import { keccak_256 } from '@noble/hashes/sha3.js';
7
- import { findAssociatedTokenPda } from '@solana-program/token';
7
+ import { getCreateAssociatedTokenIdempotentInstruction, getSyncNativeInstruction, findAssociatedTokenPda } from '@solana-program/token';
8
8
  import { findAddressLookupTablePda, getCreateLookupTableInstruction, getExtendLookupTableInstruction } from '@solana-program/address-lookup-table';
9
+ import { getTransferSolInstruction } from '@solana-program/system';
9
10
 
10
11
  // src/solana/cpmm/index.ts
11
12
  var cpmm_exports = {};
@@ -60,8 +61,12 @@ __export(cpmm_exports, {
60
61
  UPDATE_CONFIG_DISCRIMINATOR: () => UPDATE_CONFIG_DISCRIMINATOR,
61
62
  WITHDRAW_VAULT_EXCESS_DISCRIMINATOR: () => WITHDRAW_VAULT_EXCESS_DISCRIMINATOR,
62
63
  addLiquidityArgsCodec: () => addLiquidityArgsCodec,
64
+ addressToBase58EncodedBytes: () => addressToBase58EncodedBytes,
63
65
  ammConfigDataCodec: () => ammConfigDataCodec,
64
66
  areMintsOrdered: () => areMintsOrdered,
67
+ base64ToBytes: () => base64ToBytes,
68
+ bytesToBase64: () => bytesToBase64,
69
+ bytesToBase64EncodedBytes: () => bytesToBase64EncodedBytes,
65
70
  calculateAccruedFees: () => calculateAccruedFees,
66
71
  calculateTwap: () => calculateTwap,
67
72
  calculateTwapNumber: () => calculateTwapNumber,
@@ -72,6 +77,7 @@ __export(cpmm_exports, {
72
77
  computePrice0Q64: () => computePrice0Q64,
73
78
  computePrice1Q64: () => computePrice1Q64,
74
79
  consultTwap: () => consultTwap,
80
+ createAccountMeta: () => createAccountMeta,
75
81
  createAddLiquidityInstruction: () => getAddLiquidityInstruction,
76
82
  createClosePositionInstruction: () => getClosePositionInstruction,
77
83
  createCollectFeesInstruction: () => getCollectFeesInstruction,
@@ -84,6 +90,7 @@ __export(cpmm_exports, {
84
90
  createOracleUpdateInstruction: () => getOracleUpdateInstruction,
85
91
  createPauseInstruction: () => getPauseInstruction,
86
92
  createPositionArgsCodec: () => createPositionArgsCodec,
93
+ createReadonlyRemainingAccountMeta: () => createReadonlyRemainingAccountMeta,
87
94
  createRemoveLiquidityInstruction: () => getRemoveLiquidityInstruction,
88
95
  createSetFeesInstruction: () => getSetFeesInstruction,
89
96
  createSetHookInstruction: () => getSetHookInstruction,
@@ -132,6 +139,8 @@ __export(cpmm_exports, {
132
139
  getAddLiquidityInstructionDataDecoder: () => getAddLiquidityInstructionDataDecoder,
133
140
  getAddLiquidityInstructionDataEncoder: () => getAddLiquidityInstructionDataEncoder,
134
141
  getAddLiquidityQuote: () => getAddLiquidityQuote,
142
+ getAddressFromAddressOrSigner: () => getAddressFromAddressOrSigner,
143
+ getAddressFromRemainingAccount: () => getAddressFromRemainingAccount,
135
144
  getClosePositionDiscriminatorBytes: () => getClosePositionDiscriminatorBytes,
136
145
  getClosePositionInstruction: () => getClosePositionInstruction,
137
146
  getClosePositionInstructionDataCodec: () => getClosePositionInstructionDataCodec,
@@ -281,12 +290,14 @@ __export(cpmm_exports, {
281
290
  initializePoolArgsCodec: () => initializePoolArgsCodec,
282
291
  isCpmmError: () => isCpmmError,
283
292
  isOracleStale: () => isOracleStale,
293
+ isTransactionSigner: () => isTransactionSigner,
284
294
  isqrt: () => isqrt,
285
295
  marketCapToCurveParams: () => marketCapToCurveParams,
286
296
  marketCapToSingleCurveParams: () => marketCapToSingleCurveParams,
287
297
  marketCapToTokenPrice: () => marketCapToTokenPrice,
288
298
  maxBigInt: () => maxBigInt,
289
299
  minBigInt: () => minBigInt,
300
+ normalizeProgramAccountsResponse: () => normalizeProgramAccountsResponse,
290
301
  numberToQ64: () => numberToQ64,
291
302
  observationCodec: () => observationCodec,
292
303
  oracleConsultArgsCodec: () => oracleConsultArgsCodec,
@@ -328,7 +339,8 @@ __export(cpmm_exports, {
328
339
  sortPositionsByShares: () => sortPositionsByShares,
329
340
  swapExactInArgsCodec: () => swapExactInArgsCodec,
330
341
  transferAdminArgsCodec: () => transferAdminArgsCodec,
331
- validateMarketCapParameters: () => validateMarketCapParameters
342
+ validateMarketCapParameters: () => validateMarketCapParameters,
343
+ warnAccountDecodeFailure: () => warnAccountDecodeFailure
332
344
  });
333
345
  var addressCodec = getAddressCodec();
334
346
  var textEncoder = new TextEncoder();
@@ -629,22 +641,6 @@ function getErrorMessage(code) {
629
641
  }
630
642
  return `Unknown error code: ${code}`;
631
643
  }
632
- function isTransactionSigner(value) {
633
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
634
- }
635
- function toRemainingAccountMeta(account) {
636
- if (typeof account === "string") {
637
- return { address: account, role: AccountRole.READONLY };
638
- }
639
- if (isTransactionSigner(account)) {
640
- return {
641
- address: account.address,
642
- role: AccountRole.READONLY_SIGNER,
643
- signer: account
644
- };
645
- }
646
- return account;
647
- }
648
644
  function createSwapInstruction(params) {
649
645
  const {
650
646
  config,
@@ -697,21 +693,13 @@ function createSwapInstruction(params) {
697
693
  ...instruction,
698
694
  accounts: [
699
695
  ...instruction.accounts ?? [],
700
- ...remainingAccounts.map(toRemainingAccountMeta)
696
+ ...remainingAccounts.map(createReadonlyRemainingAccountMeta)
701
697
  ]
702
698
  };
703
699
  }
704
700
  var MAX_FEE_AMOUNT = BigInt("18446744073709551615");
705
701
 
706
702
  // src/solana/client/config.ts
707
- function base64ToBytes(base64) {
708
- const binary = atob(base64);
709
- const bytes = new Uint8Array(binary.length);
710
- for (let i = 0; i < binary.length; i++) {
711
- bytes[i] = binary.charCodeAt(i);
712
- }
713
- return bytes;
714
- }
715
703
  async function fetchConfig(rpc, programId = CPMM_PROGRAM_ID, commitment) {
716
704
  const [configAddress] = await getConfigAddress(programId);
717
705
  const response = await rpc.getAccountInfo(configAddress, {
@@ -868,13 +856,13 @@ function decodeCosignerConfig(encodedAccount) {
868
856
  getCosignerConfigDecoder()
869
857
  );
870
858
  }
871
- async function fetchCosignerConfig(rpc, address4, config) {
872
- const maybeAccount = await fetchMaybeCosignerConfig(rpc, address4, config);
859
+ async function fetchCosignerConfig(rpc, address7, config) {
860
+ const maybeAccount = await fetchMaybeCosignerConfig(rpc, address7, config);
873
861
  assertAccountExists(maybeAccount);
874
862
  return maybeAccount;
875
863
  }
876
- async function fetchMaybeCosignerConfig(rpc, address4, config) {
877
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
864
+ async function fetchMaybeCosignerConfig(rpc, address7, config) {
865
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
878
866
  return decodeCosignerConfig(maybeAccount);
879
867
  }
880
868
  async function fetchAllCosignerConfig(rpc, addresses, config) {
@@ -3141,15 +3129,6 @@ function launchIdFromU64(launchId) {
3141
3129
  out.set(encodeU64LE(launchId), 0);
3142
3130
  return out;
3143
3131
  }
3144
- function isTransactionSigner2(value) {
3145
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3146
- }
3147
- function createSignerAccountMeta(value, role) {
3148
- if (isTransactionSigner2(value)) {
3149
- return { address: value.address, role, signer: value };
3150
- }
3151
- return { address: value, role };
3152
- }
3153
3132
  function createInitializeConfigInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
3154
3133
  const {
3155
3134
  admin,
@@ -3158,7 +3137,7 @@ function createInitializeConfigInstruction(accounts, args, programId = INITIALIZ
3158
3137
  systemProgram = SYSTEM_PROGRAM_ADDRESS
3159
3138
  } = accounts;
3160
3139
  const keys = [
3161
- createSignerAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
3140
+ createAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
3162
3141
  { address: config, role: AccountRole.WRITABLE },
3163
3142
  { address: programData, role: AccountRole.READONLY },
3164
3143
  { address: systemProgram, role: AccountRole.READONLY }
@@ -3168,19 +3147,10 @@ function createInitializeConfigInstruction(accounts, args, programId = INITIALIZ
3168
3147
  );
3169
3148
  return { programAddress: programId, accounts: keys, data };
3170
3149
  }
3171
- function isTransactionSigner3(value) {
3172
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3173
- }
3174
- function createSignerAccountMeta2(value, role) {
3175
- if (isTransactionSigner3(value)) {
3176
- return { address: value.address, role, signer: value };
3177
- }
3178
- return { address: value, role };
3179
- }
3180
3150
  function createSetMigratorAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
3181
3151
  const { admin, config } = accounts;
3182
3152
  const keys = [
3183
- createSignerAccountMeta2(admin, AccountRole.WRITABLE_SIGNER),
3153
+ createAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
3184
3154
  { address: config, role: AccountRole.WRITABLE }
3185
3155
  ];
3186
3156
  const data = new Uint8Array(
@@ -3188,19 +3158,10 @@ function createSetMigratorAllowlistInstruction(accounts, allowlist, programId =
3188
3158
  );
3189
3159
  return { programAddress: programId, accounts: keys, data };
3190
3160
  }
3191
- function isTransactionSigner4(value) {
3192
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
3193
- }
3194
- function createSignerAccountMeta3(value, role) {
3195
- if (isTransactionSigner4(value)) {
3196
- return { address: value.address, role, signer: value };
3197
- }
3198
- return { address: value, role };
3199
- }
3200
3161
  function createSetHookAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
3201
3162
  const { admin, config } = accounts;
3202
3163
  const keys = [
3203
- createSignerAccountMeta3(admin, AccountRole.WRITABLE_SIGNER),
3164
+ createAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
3204
3165
  { address: config, role: AccountRole.WRITABLE }
3205
3166
  ];
3206
3167
  const data = new Uint8Array(
@@ -3305,13 +3266,13 @@ function decodeClaimReceipt(encodedAccount) {
3305
3266
  getClaimReceiptDecoder()
3306
3267
  );
3307
3268
  }
3308
- async function fetchClaimReceipt(rpc, address4, config) {
3309
- const maybeAccount = await fetchMaybeClaimReceipt(rpc, address4, config);
3269
+ async function fetchClaimReceipt(rpc, address7, config) {
3270
+ const maybeAccount = await fetchMaybeClaimReceipt(rpc, address7, config);
3310
3271
  assertAccountExists(maybeAccount);
3311
3272
  return maybeAccount;
3312
3273
  }
3313
- async function fetchMaybeClaimReceipt(rpc, address4, config) {
3314
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
3274
+ async function fetchMaybeClaimReceipt(rpc, address7, config) {
3275
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
3315
3276
  return decodeClaimReceipt(maybeAccount);
3316
3277
  }
3317
3278
  async function fetchAllClaimReceipt(rpc, addresses, config) {
@@ -3375,13 +3336,13 @@ function decodeEntry(encodedAccount) {
3375
3336
  getEntryDecoder()
3376
3337
  );
3377
3338
  }
3378
- async function fetchEntry(rpc, address4, config) {
3379
- const maybeAccount = await fetchMaybeEntry(rpc, address4, config);
3339
+ async function fetchEntry(rpc, address7, config) {
3340
+ const maybeAccount = await fetchMaybeEntry(rpc, address7, config);
3380
3341
  assertAccountExists(maybeAccount);
3381
3342
  return maybeAccount;
3382
3343
  }
3383
- async function fetchMaybeEntry(rpc, address4, config) {
3384
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
3344
+ async function fetchMaybeEntry(rpc, address7, config) {
3345
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
3385
3346
  return decodeEntry(maybeAccount);
3386
3347
  }
3387
3348
  async function fetchAllEntry(rpc, addresses, config) {
@@ -3443,13 +3404,13 @@ function decodeEntryByMint(encodedAccount) {
3443
3404
  getEntryByMintDecoder()
3444
3405
  );
3445
3406
  }
3446
- async function fetchEntryByMint(rpc, address4, config) {
3447
- const maybeAccount = await fetchMaybeEntryByMint(rpc, address4, config);
3407
+ async function fetchEntryByMint(rpc, address7, config) {
3408
+ const maybeAccount = await fetchMaybeEntryByMint(rpc, address7, config);
3448
3409
  assertAccountExists(maybeAccount);
3449
3410
  return maybeAccount;
3450
3411
  }
3451
- async function fetchMaybeEntryByMint(rpc, address4, config) {
3452
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
3412
+ async function fetchMaybeEntryByMint(rpc, address7, config) {
3413
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
3453
3414
  return decodeEntryByMint(maybeAccount);
3454
3415
  }
3455
3416
  async function fetchAllEntryByMint(rpc, addresses, config) {
@@ -3521,13 +3482,13 @@ function decodeInitConfig(encodedAccount) {
3521
3482
  getInitConfigDecoder2()
3522
3483
  );
3523
3484
  }
3524
- async function fetchInitConfig(rpc, address4, config) {
3525
- const maybeAccount = await fetchMaybeInitConfig(rpc, address4, config);
3485
+ async function fetchInitConfig(rpc, address7, config) {
3486
+ const maybeAccount = await fetchMaybeInitConfig(rpc, address7, config);
3526
3487
  assertAccountExists(maybeAccount);
3527
3488
  return maybeAccount;
3528
3489
  }
3529
- async function fetchMaybeInitConfig(rpc, address4, config) {
3530
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
3490
+ async function fetchMaybeInitConfig(rpc, address7, config) {
3491
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
3531
3492
  return decodeInitConfig(maybeAccount);
3532
3493
  }
3533
3494
  async function fetchAllInitConfig(rpc, addresses, config) {
@@ -3827,13 +3788,13 @@ function decodeLaunch(encodedAccount) {
3827
3788
  getLaunchDecoder2()
3828
3789
  );
3829
3790
  }
3830
- async function fetchLaunch(rpc, address4, config) {
3831
- const maybeAccount = await fetchMaybeLaunch(rpc, address4, config);
3791
+ async function fetchLaunch(rpc, address7, config) {
3792
+ const maybeAccount = await fetchMaybeLaunch(rpc, address7, config);
3832
3793
  assertAccountExists(maybeAccount);
3833
3794
  return maybeAccount;
3834
3795
  }
3835
- async function fetchMaybeLaunch(rpc, address4, config) {
3836
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
3796
+ async function fetchMaybeLaunch(rpc, address7, config) {
3797
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
3837
3798
  return decodeLaunch(maybeAccount);
3838
3799
  }
3839
3800
  async function fetchAllLaunch(rpc, addresses, config) {
@@ -3907,13 +3868,13 @@ function decodeMarket(encodedAccount) {
3907
3868
  getMarketDecoder()
3908
3869
  );
3909
3870
  }
3910
- async function fetchMarket(rpc, address4, config) {
3911
- const maybeAccount = await fetchMaybeMarket(rpc, address4, config);
3871
+ async function fetchMarket(rpc, address7, config) {
3872
+ const maybeAccount = await fetchMaybeMarket(rpc, address7, config);
3912
3873
  assertAccountExists(maybeAccount);
3913
3874
  return maybeAccount;
3914
3875
  }
3915
- async function fetchMaybeMarket(rpc, address4, config) {
3916
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
3876
+ async function fetchMaybeMarket(rpc, address7, config) {
3877
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
3917
3878
  return decodeMarket(maybeAccount);
3918
3879
  }
3919
3880
  async function fetchAllMarket(rpc, addresses, config) {
@@ -3979,13 +3940,13 @@ function decodeOracleState2(encodedAccount) {
3979
3940
  getOracleStateDecoder()
3980
3941
  );
3981
3942
  }
3982
- async function fetchOracleState(rpc, address4, config) {
3983
- const maybeAccount = await fetchMaybeOracleState(rpc, address4, config);
3943
+ async function fetchOracleState(rpc, address7, config) {
3944
+ const maybeAccount = await fetchMaybeOracleState(rpc, address7, config);
3984
3945
  assertAccountExists(maybeAccount);
3985
3946
  return maybeAccount;
3986
3947
  }
3987
- async function fetchMaybeOracleState(rpc, address4, config) {
3988
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
3948
+ async function fetchMaybeOracleState(rpc, address7, config) {
3949
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
3989
3950
  return decodeOracleState2(maybeAccount);
3990
3951
  }
3991
3952
  async function fetchAllOracleState(rpc, addresses, config) {
@@ -5269,15 +5230,6 @@ async function getPredictionEntryByMintAddress(market, mint, programId = PREDICT
5269
5230
  }
5270
5231
 
5271
5232
  // src/solana/initializer/instructions/initializeLaunch.ts
5272
- function isTransactionSigner5(value) {
5273
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
5274
- }
5275
- function createAccountMeta(value, role) {
5276
- if (isTransactionSigner5(value)) {
5277
- return { address: value.address, role, signer: value };
5278
- }
5279
- return { address: value, role };
5280
- }
5281
5233
  async function getTokenMetadataAddress(mint) {
5282
5234
  const encoder = getAddressEncoder();
5283
5235
  const [metadataAddress] = await getProgramDerivedAddress({
@@ -5334,7 +5286,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
5334
5286
  }
5335
5287
  const createHooksEnabled = (args.hookFlags & (HF_BEFORE_CREATE | HF_AFTER_CREATE)) !== 0;
5336
5288
  const hookCreateRemainingAccountAddresses = hookCreateRemainingAccounts.map(
5337
- (account) => isTransactionSigner5(account) ? account.address : account
5289
+ getAddressFromAddressOrSigner
5338
5290
  );
5339
5291
  const swapFeeBps = args.swapFeeBps ?? args.curveFeeBps;
5340
5292
  if (swapFeeBps === void 0) {
@@ -5396,7 +5348,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
5396
5348
  ...hookCreateRemainingAccounts.map(
5397
5349
  (account) => createAccountMeta(
5398
5350
  account,
5399
- isTransactionSigner5(account) ? AccountRole.READONLY_SIGNER : AccountRole.READONLY
5351
+ isTransactionSigner(account) ? AccountRole.READONLY_SIGNER : AccountRole.READONLY
5400
5352
  )
5401
5353
  )
5402
5354
  );
@@ -5420,7 +5372,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
5420
5372
  if (migratorProgram === PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
5421
5373
  const oracleState = args.namespace;
5422
5374
  const entryId = args.launchId;
5423
- const baseMintAddress = isTransactionSigner5(baseMint) ? baseMint.address : baseMint;
5375
+ const baseMintAddress = getAddressFromAddressOrSigner(baseMint);
5424
5376
  const [market] = await getPredictionMarketAddress(oracleState, quoteMint);
5425
5377
  const [potVault] = await getPredictionPotVaultAddress(market);
5426
5378
  const [marketAuthority] = await getPredictionMarketAuthorityAddress(market);
@@ -5438,28 +5390,6 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
5438
5390
  }
5439
5391
  return { programAddress: programId, accounts: keys, data };
5440
5392
  }
5441
- function isTransactionSigner6(value) {
5442
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
5443
- }
5444
- function createAccountMeta2(value, role) {
5445
- if (isTransactionSigner6(value)) {
5446
- return { address: value.address, role, signer: value };
5447
- }
5448
- return { address: value, role };
5449
- }
5450
- function createRemainingAccountMeta(value) {
5451
- if (typeof value === "string") {
5452
- return { address: value, role: AccountRole.READONLY };
5453
- }
5454
- if (isTransactionSigner6(value)) {
5455
- return {
5456
- address: value.address,
5457
- role: AccountRole.READONLY_SIGNER,
5458
- signer: value
5459
- };
5460
- }
5461
- return value;
5462
- }
5463
5393
  function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
5464
5394
  const {
5465
5395
  launch,
@@ -5486,7 +5416,7 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
5486
5416
  { address: userQuoteAccount, role: AccountRole.WRITABLE },
5487
5417
  { address: baseMint, role: AccountRole.READONLY },
5488
5418
  { address: quoteMint, role: AccountRole.READONLY },
5489
- createAccountMeta2(user, AccountRole.READONLY_SIGNER),
5419
+ createAccountMeta(user, AccountRole.READONLY_SIGNER),
5490
5420
  // hook_program is Optional in the on-chain struct but still occupies a fixed
5491
5421
  // slot (token_program follows it). Always emit it — use SYSTEM_PROGRAM_ADDRESS as the
5492
5422
  // no-op placeholder when no real hook is configured.
@@ -5494,22 +5424,13 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
5494
5424
  { address: launchFeeState, role: AccountRole.WRITABLE },
5495
5425
  { address: baseTokenProgram, role: AccountRole.READONLY },
5496
5426
  { address: quoteTokenProgram, role: AccountRole.READONLY },
5497
- ...remainingAccounts.map(createRemainingAccountMeta)
5427
+ ...remainingAccounts.map(createReadonlyRemainingAccountMeta)
5498
5428
  ];
5499
5429
  const data = new Uint8Array(
5500
5430
  getCurveSwapExactInInstructionDataEncoder().encode(args)
5501
5431
  );
5502
5432
  return { programAddress: programId, accounts: keys, data };
5503
5433
  }
5504
- function isTransactionSigner7(value) {
5505
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
5506
- }
5507
- function createSignerAccountMeta4(value, role) {
5508
- if (isTransactionSigner7(value)) {
5509
- return { address: value.address, role, signer: value };
5510
- }
5511
- return { address: value, role };
5512
- }
5513
5434
  function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
5514
5435
  const {
5515
5436
  config,
@@ -5537,7 +5458,7 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
5537
5458
  { address: quoteVault, role: AccountRole.WRITABLE },
5538
5459
  { address: launchFeeState, role: AccountRole.READONLY },
5539
5460
  { address: migratorProgram, role: AccountRole.READONLY },
5540
- createSignerAccountMeta4(payer, AccountRole.WRITABLE_SIGNER),
5461
+ createAccountMeta(payer, AccountRole.WRITABLE_SIGNER),
5541
5462
  { address: baseTokenProgram, role: AccountRole.READONLY },
5542
5463
  { address: quoteTokenProgram, role: AccountRole.READONLY },
5543
5464
  { address: systemProgram, role: AccountRole.READONLY },
@@ -5548,22 +5469,6 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
5548
5469
  );
5549
5470
  return { programAddress: programId, accounts: keys, data };
5550
5471
  }
5551
- function isTransactionSigner8(value) {
5552
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
5553
- }
5554
- function createRemainingAccountMeta2(value) {
5555
- if (typeof value === "string") {
5556
- return { address: value, role: AccountRole.READONLY };
5557
- }
5558
- if (isTransactionSigner8(value)) {
5559
- return {
5560
- address: value.address,
5561
- role: AccountRole.READONLY_SIGNER,
5562
- signer: value
5563
- };
5564
- }
5565
- return value;
5566
- }
5567
5472
  var previewSwapExactInResultCodec = getStructCodec([
5568
5473
  ["amountOut", getU64Codec()],
5569
5474
  ["feePaid", getU64Codec()]
@@ -5586,7 +5491,7 @@ function createPreviewSwapExactInInstruction(accounts, args, programId = INITIAL
5586
5491
  const accountsList = hookProgram ? [...keys, { address: hookProgram, role: AccountRole.READONLY }] : keys;
5587
5492
  const accountsWithRemaining = [
5588
5493
  ...accountsList,
5589
- ...remainingAccounts.map(createRemainingAccountMeta2)
5494
+ ...remainingAccounts.map(createReadonlyRemainingAccountMeta)
5590
5495
  ];
5591
5496
  const data = new Uint8Array(
5592
5497
  getPreviewSwapExactInInstructionDataEncoder2().encode(args)
@@ -5618,193 +5523,1254 @@ function decodePreviewMigrationResult(data) {
5618
5523
  return previewMigrationResultCodec.decode(data);
5619
5524
  }
5620
5525
 
5621
- // src/solana/migrators/cpmmMigrator/index.ts
5622
- var cpmmMigrator_exports = {};
5623
- __export(cpmmMigrator_exports, {
5624
- CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS: () => CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS,
5625
- CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS: () => CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS,
5626
- CPMM_MIGRATOR_PROGRAM_ID: () => CPMM_MIGRATOR_PROGRAM_ID,
5627
- MAX_RECIPIENTS: () => MAX_RECIPIENTS,
5628
- SEED_MIGRATION_AUTHORITY: () => SEED_MIGRATION_AUTHORITY,
5629
- SEED_STATE: () => SEED_STATE,
5630
- buildCpmmMigrationRemainingAccounts: () => buildCpmmMigrationRemainingAccounts,
5631
- buildCpmmMigrationRemainingAccountsHash: () => buildCpmmMigrationRemainingAccountsHash,
5632
- encodeMigratePayload: () => encodeMigratePayload,
5633
- encodeRegisterLaunchPayload: () => encodeRegisterLaunchPayload,
5634
- fetchCpmmMigratorState: () => fetchCpmmMigratorState,
5635
- getCpmmMigrationAuthorityAddress: () => getCpmmMigrationAuthorityAddress,
5636
- getCpmmMigratorStateAddress: () => getCpmmMigratorStateAddress,
5637
- getCpmmMigratorStateCodec: () => getCpmmMigratorStateCodec,
5638
- getCpmmMigratorStateDecoder: () => getCpmmMigratorStateDecoder,
5639
- getCpmmMigratorStateEncoder: () => getCpmmMigratorStateEncoder,
5640
- getMigrateArgsCodec: () => getMigrateArgsCodec,
5641
- getMigrateArgsDecoder: () => getMigrateArgsDecoder,
5642
- getMigrateArgsEncoder: () => getMigrateArgsEncoder,
5643
- getRecipientCodec: () => getRecipientCodec,
5644
- getRecipientDecoder: () => getRecipientDecoder,
5645
- getRecipientEncoder: () => getRecipientEncoder,
5646
- getRegisterLaunchArgsCodec: () => getRegisterLaunchArgsCodec,
5647
- getRegisterLaunchArgsDecoder: () => getRegisterLaunchArgsDecoder,
5648
- getRegisterLaunchArgsEncoder: () => getRegisterLaunchArgsEncoder
5526
+ // src/solana/dynamicFeeHook/index.ts
5527
+ var dynamicFeeHook_exports = {};
5528
+ __export(dynamicFeeHook_exports, {
5529
+ ADD_COSIGNER_DISCRIMINATOR: () => ADD_COSIGNER_DISCRIMINATOR2,
5530
+ COSIGNER_CONFIG_DISCRIMINATOR: () => COSIGNER_CONFIG_DISCRIMINATOR2,
5531
+ DEVNET_DYNAMIC_FEE_HOOK_PROGRAM_ID: () => DEVNET_DYNAMIC_FEE_HOOK_PROGRAM_ID,
5532
+ DYNAMIC_FEE_HOOK_ERROR__ARITHMETIC_OVERFLOW: () => DYNAMIC_FEE_HOOK_ERROR__ARITHMETIC_OVERFLOW,
5533
+ DYNAMIC_FEE_HOOK_ERROR__COSIGNER_ALREADY_EXISTS: () => DYNAMIC_FEE_HOOK_ERROR__COSIGNER_ALREADY_EXISTS,
5534
+ DYNAMIC_FEE_HOOK_ERROR__COSIGNER_LIST_FULL: () => DYNAMIC_FEE_HOOK_ERROR__COSIGNER_LIST_FULL,
5535
+ DYNAMIC_FEE_HOOK_ERROR__COSIGNER_NOT_FOUND: () => DYNAMIC_FEE_HOOK_ERROR__COSIGNER_NOT_FOUND,
5536
+ DYNAMIC_FEE_HOOK_ERROR__INVALID_AUTHORITY: () => DYNAMIC_FEE_HOOK_ERROR__INVALID_AUTHORITY,
5537
+ DYNAMIC_FEE_HOOK_ERROR__INVALID_CONFIG: () => DYNAMIC_FEE_HOOK_ERROR__INVALID_CONFIG,
5538
+ DYNAMIC_FEE_HOOK_ERROR__INVALID_COSIGNER: () => DYNAMIC_FEE_HOOK_ERROR__INVALID_COSIGNER,
5539
+ DYNAMIC_FEE_HOOK_ERROR__INVALID_DURATION: () => DYNAMIC_FEE_HOOK_ERROR__INVALID_DURATION,
5540
+ DYNAMIC_FEE_HOOK_ERROR__INVALID_FEE: () => DYNAMIC_FEE_HOOK_ERROR__INVALID_FEE,
5541
+ DYNAMIC_FEE_HOOK_ERROR__INVALID_INSTRUCTION_DATA: () => DYNAMIC_FEE_HOOK_ERROR__INVALID_INSTRUCTION_DATA,
5542
+ DYNAMIC_FEE_HOOK_ERROR__INVALID_SCHEDULE_DATA: () => DYNAMIC_FEE_HOOK_ERROR__INVALID_SCHEDULE_DATA,
5543
+ DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS: () => DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS,
5544
+ DYNAMIC_FEE_HOOK_PROGRAM_ID: () => DYNAMIC_FEE_HOOK_PROGRAM_ID,
5545
+ DYNAMIC_FEE_SCHEDULE_HEADER_LEN: () => DYNAMIC_FEE_SCHEDULE_HEADER_LEN,
5546
+ DYNAMIC_FEE_SCHEDULE_LEN: () => DYNAMIC_FEE_SCHEDULE_LEN,
5547
+ DYNAMIC_FEE_SCHEDULE_MAGIC: () => DYNAMIC_FEE_SCHEDULE_MAGIC,
5548
+ DYNAMIC_FEE_SCHEDULE_MAX_BPS: () => DYNAMIC_FEE_SCHEDULE_MAX_BPS,
5549
+ DYNAMIC_FEE_SCHEDULE_VERSION: () => DYNAMIC_FEE_SCHEDULE_VERSION,
5550
+ DynamicFeeHookAccount: () => DynamicFeeHookAccount,
5551
+ DynamicFeeHookInstruction: () => DynamicFeeHookInstruction,
5552
+ INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR4,
5553
+ MAX_COSIGNERS: () => MAX_COSIGNERS2,
5554
+ REMOVE_COSIGNER_DISCRIMINATOR: () => REMOVE_COSIGNER_DISCRIMINATOR2,
5555
+ SEED_DYNAMIC_FEE_HOOK_CONFIG: () => SEED_DYNAMIC_FEE_HOOK_CONFIG,
5556
+ SET_AUTHORITY_DISCRIMINATOR: () => SET_AUTHORITY_DISCRIMINATOR2,
5557
+ decodeCosignerConfig: () => decodeCosignerConfig2,
5558
+ dynamicFeeHookProgram: () => dynamicFeeHookProgram,
5559
+ encodeDynamicFeeCosignerGatePayload: () => encodeDynamicFeeCosignerGatePayload,
5560
+ encodeDynamicFeeHookPayload: () => encodeDynamicFeeHookPayload,
5561
+ encodeDynamicFeeSchedule: () => encodeDynamicFeeSchedule,
5562
+ fetchAllCosignerConfig: () => fetchAllCosignerConfig2,
5563
+ fetchAllMaybeCosignerConfig: () => fetchAllMaybeCosignerConfig2,
5564
+ fetchCosignerConfig: () => fetchCosignerConfig2,
5565
+ fetchMaybeCosignerConfig: () => fetchMaybeCosignerConfig2,
5566
+ getAddCosignerDiscriminatorBytes: () => getAddCosignerDiscriminatorBytes2,
5567
+ getAddCosignerInstruction: () => getAddCosignerInstruction2,
5568
+ getAddCosignerInstructionAsync: () => getAddCosignerInstructionAsync2,
5569
+ getAddCosignerInstructionDataCodec: () => getAddCosignerInstructionDataCodec2,
5570
+ getAddCosignerInstructionDataDecoder: () => getAddCosignerInstructionDataDecoder2,
5571
+ getAddCosignerInstructionDataEncoder: () => getAddCosignerInstructionDataEncoder2,
5572
+ getCosignerArgCodec: () => getCosignerArgCodec2,
5573
+ getCosignerArgDecoder: () => getCosignerArgDecoder2,
5574
+ getCosignerArgEncoder: () => getCosignerArgEncoder2,
5575
+ getCosignerConfigCodec: () => getCosignerConfigCodec2,
5576
+ getCosignerConfigDecoder: () => getCosignerConfigDecoder2,
5577
+ getCosignerConfigDiscriminatorBytes: () => getCosignerConfigDiscriminatorBytes2,
5578
+ getCosignerConfigEncoder: () => getCosignerConfigEncoder2,
5579
+ getCosignerConfigSize: () => getCosignerConfigSize2,
5580
+ getDynamicFeeHookConfigAddress: () => getDynamicFeeHookConfigAddress,
5581
+ getDynamicFeeHookErrorMessage: () => getDynamicFeeHookErrorMessage,
5582
+ getDynamicFeeHookRemainingAccountAddresses: () => getDynamicFeeHookRemainingAccountAddresses,
5583
+ getDynamicFeeHookRemainingAccounts: () => getDynamicFeeHookRemainingAccounts,
5584
+ getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec3,
5585
+ getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder3,
5586
+ getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder3,
5587
+ getInitializeConfigDiscriminatorBytes: () => getInitializeConfigDiscriminatorBytes3,
5588
+ getInitializeConfigInstruction: () => getInitializeConfigInstruction3,
5589
+ getInitializeConfigInstructionAsync: () => getInitializeConfigInstructionAsync4,
5590
+ getInitializeConfigInstructionDataCodec: () => getInitializeConfigInstructionDataCodec3,
5591
+ getInitializeConfigInstructionDataDecoder: () => getInitializeConfigInstructionDataDecoder3,
5592
+ getInitializeConfigInstructionDataEncoder: () => getInitializeConfigInstructionDataEncoder4,
5593
+ getRemoveCosignerDiscriminatorBytes: () => getRemoveCosignerDiscriminatorBytes2,
5594
+ getRemoveCosignerInstruction: () => getRemoveCosignerInstruction2,
5595
+ getRemoveCosignerInstructionAsync: () => getRemoveCosignerInstructionAsync2,
5596
+ getRemoveCosignerInstructionDataCodec: () => getRemoveCosignerInstructionDataCodec2,
5597
+ getRemoveCosignerInstructionDataDecoder: () => getRemoveCosignerInstructionDataDecoder2,
5598
+ getRemoveCosignerInstructionDataEncoder: () => getRemoveCosignerInstructionDataEncoder2,
5599
+ getSetAuthorityArgsCodec: () => getSetAuthorityArgsCodec2,
5600
+ getSetAuthorityArgsDecoder: () => getSetAuthorityArgsDecoder2,
5601
+ getSetAuthorityArgsEncoder: () => getSetAuthorityArgsEncoder2,
5602
+ getSetAuthorityDiscriminatorBytes: () => getSetAuthorityDiscriminatorBytes2,
5603
+ getSetAuthorityInstruction: () => getSetAuthorityInstruction2,
5604
+ getSetAuthorityInstructionAsync: () => getSetAuthorityInstructionAsync2,
5605
+ getSetAuthorityInstructionDataCodec: () => getSetAuthorityInstructionDataCodec2,
5606
+ getSetAuthorityInstructionDataDecoder: () => getSetAuthorityInstructionDataDecoder2,
5607
+ getSetAuthorityInstructionDataEncoder: () => getSetAuthorityInstructionDataEncoder2,
5608
+ identifyDynamicFeeHookAccount: () => identifyDynamicFeeHookAccount,
5609
+ identifyDynamicFeeHookInstruction: () => identifyDynamicFeeHookInstruction,
5610
+ isDynamicFeeHookError: () => isDynamicFeeHookError,
5611
+ isDynamicFeeSchedulePayload: () => isDynamicFeeSchedulePayload,
5612
+ parseAddCosignerInstruction: () => parseAddCosignerInstruction2,
5613
+ parseDynamicFeeHookInstruction: () => parseDynamicFeeHookInstruction,
5614
+ parseInitializeConfigInstruction: () => parseInitializeConfigInstruction4,
5615
+ parseRemoveCosignerInstruction: () => parseRemoveCosignerInstruction2,
5616
+ parseSetAuthorityInstruction: () => parseSetAuthorityInstruction2,
5617
+ validateDynamicFeeScheduleArgs: () => validateDynamicFeeScheduleArgs
5649
5618
  });
5650
- function getMigrateArgsEncoder() {
5651
- return getStructEncoder([
5652
- ["baseForDistribution", getU64Encoder()],
5653
- ["baseForLiquidity", getU64Encoder()]
5654
- ]);
5655
- }
5656
- function getMigrateArgsDecoder() {
5657
- return getStructDecoder([
5658
- ["baseForDistribution", getU64Decoder()],
5659
- ["baseForLiquidity", getU64Decoder()]
5660
- ]);
5661
- }
5662
- function getMigrateArgsCodec() {
5663
- return combineCodec(getMigrateArgsEncoder(), getMigrateArgsDecoder());
5619
+ var COSIGNER_CONFIG_DISCRIMINATOR2 = new Uint8Array([
5620
+ 133,
5621
+ 227,
5622
+ 177,
5623
+ 74,
5624
+ 145,
5625
+ 74,
5626
+ 247,
5627
+ 183
5628
+ ]);
5629
+ function getCosignerConfigDiscriminatorBytes2() {
5630
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
5631
+ COSIGNER_CONFIG_DISCRIMINATOR2
5632
+ );
5664
5633
  }
5665
- function getMigratedPoolHookConfigEncoder() {
5666
- return getStructEncoder([
5667
- ["hookProgram", getAddressEncoder()],
5668
- ["hookFlags", getU32Encoder()]
5669
- ]);
5634
+ function getCosignerConfigEncoder2() {
5635
+ return transformEncoder(
5636
+ getStructEncoder([
5637
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
5638
+ ["adminAuthority", getAddressEncoder()],
5639
+ ["cosignerCount", getU8Encoder()],
5640
+ ["bump", getU8Encoder()],
5641
+ ["version", getU8Encoder()],
5642
+ ["reserved", fixEncoderSize(getBytesEncoder(), 37)],
5643
+ ["cosigners", getArrayEncoder(getAddressEncoder(), { size: 32 })]
5644
+ ]),
5645
+ (value) => ({ ...value, discriminator: COSIGNER_CONFIG_DISCRIMINATOR2 })
5646
+ );
5670
5647
  }
5671
- function getMigratedPoolHookConfigDecoder() {
5648
+ function getCosignerConfigDecoder2() {
5672
5649
  return getStructDecoder([
5673
- ["hookProgram", getAddressDecoder()],
5674
- ["hookFlags", getU32Decoder()]
5650
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
5651
+ ["adminAuthority", getAddressDecoder()],
5652
+ ["cosignerCount", getU8Decoder()],
5653
+ ["bump", getU8Decoder()],
5654
+ ["version", getU8Decoder()],
5655
+ ["reserved", fixDecoderSize(getBytesDecoder(), 37)],
5656
+ ["cosigners", getArrayDecoder(getAddressDecoder(), { size: 32 })]
5675
5657
  ]);
5676
5658
  }
5677
- function getRecipientEncoder() {
5678
- return getStructEncoder([
5679
- ["wallet", getAddressEncoder()],
5680
- ["amount", getU64Encoder()]
5681
- ]);
5659
+ function getCosignerConfigCodec2() {
5660
+ return combineCodec(getCosignerConfigEncoder2(), getCosignerConfigDecoder2());
5682
5661
  }
5683
- function getRecipientDecoder() {
5684
- return getStructDecoder([
5685
- ["wallet", getAddressDecoder()],
5686
- ["amount", getU64Decoder()]
5687
- ]);
5662
+ function decodeCosignerConfig2(encodedAccount) {
5663
+ return decodeAccount(
5664
+ encodedAccount,
5665
+ getCosignerConfigDecoder2()
5666
+ );
5688
5667
  }
5689
- function getRecipientCodec() {
5690
- return combineCodec(getRecipientEncoder(), getRecipientDecoder());
5668
+ async function fetchCosignerConfig2(rpc, address7, config) {
5669
+ const maybeAccount = await fetchMaybeCosignerConfig2(rpc, address7, config);
5670
+ assertAccountExists(maybeAccount);
5671
+ return maybeAccount;
5691
5672
  }
5692
- function getRegisterLaunchArgsEncoder() {
5693
- return getStructEncoder([
5694
- ["cpmmConfig", getAddressEncoder()],
5695
- ["initialSwapFeeBps", getU16Encoder()],
5696
- ["initialFeeSplitBps", getU16Encoder()],
5697
- ["recipients", getArrayEncoder(getRecipientEncoder())],
5698
- ["minRaiseQuote", getU64Encoder()],
5699
- ["minMigrationPriceQ64Opt", getOptionEncoder(getU128Encoder())],
5700
- [
5701
- "migratedPoolHookConfig",
5702
- getOptionEncoder(getMigratedPoolHookConfigEncoder())
5703
- ]
5704
- ]);
5673
+ async function fetchMaybeCosignerConfig2(rpc, address7, config) {
5674
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
5675
+ return decodeCosignerConfig2(maybeAccount);
5705
5676
  }
5706
- function getRegisterLaunchArgsDecoder() {
5707
- return getStructDecoder([
5708
- ["cpmmConfig", getAddressDecoder()],
5709
- ["initialSwapFeeBps", getU16Decoder()],
5710
- ["initialFeeSplitBps", getU16Decoder()],
5711
- ["recipients", getArrayDecoder(getRecipientDecoder())],
5712
- ["minRaiseQuote", getU64Decoder()],
5713
- ["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())],
5714
- [
5715
- "migratedPoolHookConfig",
5716
- getOptionDecoder(getMigratedPoolHookConfigDecoder())
5717
- ]
5718
- ]);
5677
+ async function fetchAllCosignerConfig2(rpc, addresses, config) {
5678
+ const maybeAccounts = await fetchAllMaybeCosignerConfig2(
5679
+ rpc,
5680
+ addresses,
5681
+ config
5682
+ );
5683
+ assertAccountsExist(maybeAccounts);
5684
+ return maybeAccounts;
5719
5685
  }
5720
- function getRegisterLaunchArgsCodec() {
5721
- return combineCodec(
5722
- getRegisterLaunchArgsEncoder(),
5723
- getRegisterLaunchArgsDecoder()
5686
+ async function fetchAllMaybeCosignerConfig2(rpc, addresses, config) {
5687
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
5688
+ return maybeAccounts.map(
5689
+ (maybeAccount) => decodeCosignerConfig2(maybeAccount)
5724
5690
  );
5725
5691
  }
5726
-
5727
- // src/solana/generated/cpmmMigrator/accounts/cpmmMigratorState.ts
5728
- var CPMM_MIGRATOR_STATE_DISCRIMINATOR = new Uint8Array([
5729
- 169,
5730
- 86,
5692
+ function getCosignerConfigSize2() {
5693
+ return 1104;
5694
+ }
5695
+ var ADD_COSIGNER_DISCRIMINATOR2 = new Uint8Array([
5696
+ 17,
5697
+ 34,
5698
+ 183,
5699
+ 119,
5700
+ 202,
5731
5701
  255,
5732
- 187,
5733
- 37,
5734
- 248,
5735
- 11,
5736
- 176
5702
+ 218,
5703
+ 233
5737
5704
  ]);
5738
- function getCpmmMigratorStateEncoder() {
5705
+ function getAddCosignerDiscriminatorBytes2() {
5706
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
5707
+ ADD_COSIGNER_DISCRIMINATOR2
5708
+ );
5709
+ }
5710
+ function getAddCosignerInstructionDataEncoder2() {
5739
5711
  return transformEncoder(
5740
5712
  getStructEncoder([
5741
5713
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
5742
- ["launch", getAddressEncoder()],
5743
- ["admin", getAddressEncoder()],
5744
- ["cpmmConfig", getAddressEncoder()],
5745
- ["initialSwapFeeBps", getU16Encoder()],
5746
- ["initialFeeSplitBps", getU16Encoder()],
5747
- ["pad0", fixEncoderSize(getBytesEncoder(), 4)],
5748
- ["migratedPoolHookProgram", getAddressEncoder()],
5749
- ["migratedPoolHookFlags", getU32Encoder()],
5750
- ["recipients", getArrayEncoder(getRecipientEncoder(), { size: 2 })],
5751
- ["minRaiseQuote", getU64Encoder()],
5752
- ["minMigrationPriceQ64Opt", getOptionEncoder(getU128Encoder())],
5753
- ["isMigrated", getBooleanEncoder()],
5754
- ["bump", getU8Encoder()],
5755
- ["reserved", fixEncoderSize(getBytesEncoder(), 14)]
5714
+ ["cosigner", getAddressEncoder()]
5756
5715
  ]),
5757
- (value) => ({ ...value, discriminator: CPMM_MIGRATOR_STATE_DISCRIMINATOR })
5716
+ (value) => ({ ...value, discriminator: ADD_COSIGNER_DISCRIMINATOR2 })
5758
5717
  );
5759
5718
  }
5760
- function getCpmmMigratorStateDecoder() {
5719
+ function getAddCosignerInstructionDataDecoder2() {
5761
5720
  return getStructDecoder([
5762
5721
  ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
5763
- ["launch", getAddressDecoder()],
5764
- ["admin", getAddressDecoder()],
5765
- ["cpmmConfig", getAddressDecoder()],
5766
- ["initialSwapFeeBps", getU16Decoder()],
5767
- ["initialFeeSplitBps", getU16Decoder()],
5768
- ["pad0", fixDecoderSize(getBytesDecoder(), 4)],
5769
- ["migratedPoolHookProgram", getAddressDecoder()],
5770
- ["migratedPoolHookFlags", getU32Decoder()],
5771
- ["recipients", getArrayDecoder(getRecipientDecoder(), { size: 2 })],
5772
- ["minRaiseQuote", getU64Decoder()],
5773
- ["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())],
5774
- ["isMigrated", getBooleanDecoder()],
5775
- ["bump", getU8Decoder()],
5776
- ["reserved", fixDecoderSize(getBytesDecoder(), 14)]
5722
+ ["cosigner", getAddressDecoder()]
5777
5723
  ]);
5778
5724
  }
5779
- function getCpmmMigratorStateCodec() {
5725
+ function getAddCosignerInstructionDataCodec2() {
5780
5726
  return combineCodec(
5781
- getCpmmMigratorStateEncoder(),
5782
- getCpmmMigratorStateDecoder()
5783
- );
5784
- }
5785
- if (process.env.NODE_ENV !== "production") ;
5786
-
5787
- // src/solana/migrators/cpmmMigrator/client.ts
5788
- function base64ToBytes2(base64) {
5789
- const binary = atob(base64);
5790
- const bytes = new Uint8Array(binary.length);
5791
- for (let i = 0; i < binary.length; i++) {
5792
- bytes[i] = binary.charCodeAt(i);
5793
- }
5794
- return bytes;
5795
- }
5796
- async function fetchCpmmMigratorState(rpc, address4) {
5797
- const response = await rpc.getAccountInfo(address4, { encoding: "base64" }).send();
5798
- if (!response.value) return null;
5799
- return getCpmmMigratorStateDecoder().decode(
5800
- base64ToBytes2(response.value.data[0])
5727
+ getAddCosignerInstructionDataEncoder2(),
5728
+ getAddCosignerInstructionDataDecoder2()
5801
5729
  );
5802
5730
  }
5803
- async function buildCpmmMigrationRemainingAccounts({
5804
- launch,
5805
- baseMint,
5806
- quoteMint,
5807
- launchAuthority,
5731
+ async function getAddCosignerInstructionAsync2(input, config) {
5732
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
5733
+ const originalAccounts = {
5734
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
5735
+ config: { value: input.config ?? null, isWritable: true }
5736
+ };
5737
+ const accounts = originalAccounts;
5738
+ const args = { ...input };
5739
+ if (!accounts.config.value) {
5740
+ accounts.config.value = await getProgramDerivedAddress({
5741
+ programAddress,
5742
+ seeds: [
5743
+ getBytesEncoder().encode(
5744
+ new Uint8Array([
5745
+ 99,
5746
+ 111,
5747
+ 115,
5748
+ 105,
5749
+ 103,
5750
+ 110,
5751
+ 101,
5752
+ 114,
5753
+ 95,
5754
+ 104,
5755
+ 111,
5756
+ 111,
5757
+ 107,
5758
+ 95,
5759
+ 99,
5760
+ 111,
5761
+ 110,
5762
+ 102,
5763
+ 105,
5764
+ 103
5765
+ ])
5766
+ )
5767
+ ]
5768
+ });
5769
+ }
5770
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5771
+ return Object.freeze({
5772
+ accounts: [
5773
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
5774
+ getAccountMeta("config", accounts.config)
5775
+ ],
5776
+ data: getAddCosignerInstructionDataEncoder2().encode(
5777
+ args
5778
+ ),
5779
+ programAddress
5780
+ });
5781
+ }
5782
+ function getAddCosignerInstruction2(input, config) {
5783
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
5784
+ const originalAccounts = {
5785
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
5786
+ config: { value: input.config ?? null, isWritable: true }
5787
+ };
5788
+ const accounts = originalAccounts;
5789
+ const args = { ...input };
5790
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5791
+ return Object.freeze({
5792
+ accounts: [
5793
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
5794
+ getAccountMeta("config", accounts.config)
5795
+ ],
5796
+ data: getAddCosignerInstructionDataEncoder2().encode(
5797
+ args
5798
+ ),
5799
+ programAddress
5800
+ });
5801
+ }
5802
+ function parseAddCosignerInstruction2(instruction) {
5803
+ if (instruction.accounts.length < 2) {
5804
+ throw new SolanaError(
5805
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
5806
+ {
5807
+ actualAccountMetas: instruction.accounts.length,
5808
+ expectedAccountMetas: 2
5809
+ }
5810
+ );
5811
+ }
5812
+ let accountIndex = 0;
5813
+ const getNextAccount = () => {
5814
+ const accountMeta = instruction.accounts[accountIndex];
5815
+ accountIndex += 1;
5816
+ return accountMeta;
5817
+ };
5818
+ return {
5819
+ programAddress: instruction.programAddress,
5820
+ accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
5821
+ data: getAddCosignerInstructionDataDecoder2().decode(instruction.data)
5822
+ };
5823
+ }
5824
+ var INITIALIZE_CONFIG_DISCRIMINATOR4 = new Uint8Array([
5825
+ 208,
5826
+ 127,
5827
+ 21,
5828
+ 1,
5829
+ 194,
5830
+ 190,
5831
+ 196,
5832
+ 70
5833
+ ]);
5834
+ function getInitializeConfigDiscriminatorBytes3() {
5835
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
5836
+ INITIALIZE_CONFIG_DISCRIMINATOR4
5837
+ );
5838
+ }
5839
+ function getInitializeConfigInstructionDataEncoder4() {
5840
+ return transformEncoder(
5841
+ getStructEncoder([
5842
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
5843
+ ["cosigners", getArrayEncoder(getAddressEncoder())]
5844
+ ]),
5845
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR4 })
5846
+ );
5847
+ }
5848
+ function getInitializeConfigInstructionDataDecoder3() {
5849
+ return getStructDecoder([
5850
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
5851
+ ["cosigners", getArrayDecoder(getAddressDecoder())]
5852
+ ]);
5853
+ }
5854
+ function getInitializeConfigInstructionDataCodec3() {
5855
+ return combineCodec(
5856
+ getInitializeConfigInstructionDataEncoder4(),
5857
+ getInitializeConfigInstructionDataDecoder3()
5858
+ );
5859
+ }
5860
+ async function getInitializeConfigInstructionAsync4(input, config) {
5861
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
5862
+ const originalAccounts = {
5863
+ payer: { value: input.payer ?? null, isWritable: true },
5864
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
5865
+ config: { value: input.config ?? null, isWritable: true },
5866
+ programData: { value: input.programData ?? null, isWritable: false },
5867
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
5868
+ };
5869
+ const accounts = originalAccounts;
5870
+ const args = { ...input };
5871
+ if (!accounts.config.value) {
5872
+ accounts.config.value = await getProgramDerivedAddress({
5873
+ programAddress,
5874
+ seeds: [
5875
+ getBytesEncoder().encode(
5876
+ new Uint8Array([
5877
+ 99,
5878
+ 111,
5879
+ 115,
5880
+ 105,
5881
+ 103,
5882
+ 110,
5883
+ 101,
5884
+ 114,
5885
+ 95,
5886
+ 104,
5887
+ 111,
5888
+ 111,
5889
+ 107,
5890
+ 95,
5891
+ 99,
5892
+ 111,
5893
+ 110,
5894
+ 102,
5895
+ 105,
5896
+ 103
5897
+ ])
5898
+ )
5899
+ ]
5900
+ });
5901
+ }
5902
+ if (!accounts.systemProgram.value) {
5903
+ accounts.systemProgram.value = "11111111111111111111111111111111";
5904
+ }
5905
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5906
+ return Object.freeze({
5907
+ accounts: [
5908
+ getAccountMeta("payer", accounts.payer),
5909
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
5910
+ getAccountMeta("config", accounts.config),
5911
+ getAccountMeta("programData", accounts.programData),
5912
+ getAccountMeta("systemProgram", accounts.systemProgram)
5913
+ ],
5914
+ data: getInitializeConfigInstructionDataEncoder4().encode(
5915
+ args
5916
+ ),
5917
+ programAddress
5918
+ });
5919
+ }
5920
+ function getInitializeConfigInstruction3(input, config) {
5921
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
5922
+ const originalAccounts = {
5923
+ payer: { value: input.payer ?? null, isWritable: true },
5924
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
5925
+ config: { value: input.config ?? null, isWritable: true },
5926
+ programData: { value: input.programData ?? null, isWritable: false },
5927
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
5928
+ };
5929
+ const accounts = originalAccounts;
5930
+ const args = { ...input };
5931
+ if (!accounts.systemProgram.value) {
5932
+ accounts.systemProgram.value = "11111111111111111111111111111111";
5933
+ }
5934
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5935
+ return Object.freeze({
5936
+ accounts: [
5937
+ getAccountMeta("payer", accounts.payer),
5938
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
5939
+ getAccountMeta("config", accounts.config),
5940
+ getAccountMeta("programData", accounts.programData),
5941
+ getAccountMeta("systemProgram", accounts.systemProgram)
5942
+ ],
5943
+ data: getInitializeConfigInstructionDataEncoder4().encode(
5944
+ args
5945
+ ),
5946
+ programAddress
5947
+ });
5948
+ }
5949
+ function parseInitializeConfigInstruction4(instruction) {
5950
+ if (instruction.accounts.length < 5) {
5951
+ throw new SolanaError(
5952
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
5953
+ {
5954
+ actualAccountMetas: instruction.accounts.length,
5955
+ expectedAccountMetas: 5
5956
+ }
5957
+ );
5958
+ }
5959
+ let accountIndex = 0;
5960
+ const getNextAccount = () => {
5961
+ const accountMeta = instruction.accounts[accountIndex];
5962
+ accountIndex += 1;
5963
+ return accountMeta;
5964
+ };
5965
+ return {
5966
+ programAddress: instruction.programAddress,
5967
+ accounts: {
5968
+ payer: getNextAccount(),
5969
+ adminAuthority: getNextAccount(),
5970
+ config: getNextAccount(),
5971
+ programData: getNextAccount(),
5972
+ systemProgram: getNextAccount()
5973
+ },
5974
+ data: getInitializeConfigInstructionDataDecoder3().decode(instruction.data)
5975
+ };
5976
+ }
5977
+ var REMOVE_COSIGNER_DISCRIMINATOR2 = new Uint8Array([
5978
+ 174,
5979
+ 11,
5980
+ 171,
5981
+ 252,
5982
+ 179,
5983
+ 99,
5984
+ 220,
5985
+ 27
5986
+ ]);
5987
+ function getRemoveCosignerDiscriminatorBytes2() {
5988
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
5989
+ REMOVE_COSIGNER_DISCRIMINATOR2
5990
+ );
5991
+ }
5992
+ function getRemoveCosignerInstructionDataEncoder2() {
5993
+ return transformEncoder(
5994
+ getStructEncoder([
5995
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
5996
+ ["cosigner", getAddressEncoder()]
5997
+ ]),
5998
+ (value) => ({ ...value, discriminator: REMOVE_COSIGNER_DISCRIMINATOR2 })
5999
+ );
6000
+ }
6001
+ function getRemoveCosignerInstructionDataDecoder2() {
6002
+ return getStructDecoder([
6003
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
6004
+ ["cosigner", getAddressDecoder()]
6005
+ ]);
6006
+ }
6007
+ function getRemoveCosignerInstructionDataCodec2() {
6008
+ return combineCodec(
6009
+ getRemoveCosignerInstructionDataEncoder2(),
6010
+ getRemoveCosignerInstructionDataDecoder2()
6011
+ );
6012
+ }
6013
+ async function getRemoveCosignerInstructionAsync2(input, config) {
6014
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
6015
+ const originalAccounts = {
6016
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
6017
+ config: { value: input.config ?? null, isWritable: true }
6018
+ };
6019
+ const accounts = originalAccounts;
6020
+ const args = { ...input };
6021
+ if (!accounts.config.value) {
6022
+ accounts.config.value = await getProgramDerivedAddress({
6023
+ programAddress,
6024
+ seeds: [
6025
+ getBytesEncoder().encode(
6026
+ new Uint8Array([
6027
+ 99,
6028
+ 111,
6029
+ 115,
6030
+ 105,
6031
+ 103,
6032
+ 110,
6033
+ 101,
6034
+ 114,
6035
+ 95,
6036
+ 104,
6037
+ 111,
6038
+ 111,
6039
+ 107,
6040
+ 95,
6041
+ 99,
6042
+ 111,
6043
+ 110,
6044
+ 102,
6045
+ 105,
6046
+ 103
6047
+ ])
6048
+ )
6049
+ ]
6050
+ });
6051
+ }
6052
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
6053
+ return Object.freeze({
6054
+ accounts: [
6055
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
6056
+ getAccountMeta("config", accounts.config)
6057
+ ],
6058
+ data: getRemoveCosignerInstructionDataEncoder2().encode(
6059
+ args
6060
+ ),
6061
+ programAddress
6062
+ });
6063
+ }
6064
+ function getRemoveCosignerInstruction2(input, config) {
6065
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
6066
+ const originalAccounts = {
6067
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
6068
+ config: { value: input.config ?? null, isWritable: true }
6069
+ };
6070
+ const accounts = originalAccounts;
6071
+ const args = { ...input };
6072
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
6073
+ return Object.freeze({
6074
+ accounts: [
6075
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
6076
+ getAccountMeta("config", accounts.config)
6077
+ ],
6078
+ data: getRemoveCosignerInstructionDataEncoder2().encode(
6079
+ args
6080
+ ),
6081
+ programAddress
6082
+ });
6083
+ }
6084
+ function parseRemoveCosignerInstruction2(instruction) {
6085
+ if (instruction.accounts.length < 2) {
6086
+ throw new SolanaError(
6087
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
6088
+ {
6089
+ actualAccountMetas: instruction.accounts.length,
6090
+ expectedAccountMetas: 2
6091
+ }
6092
+ );
6093
+ }
6094
+ let accountIndex = 0;
6095
+ const getNextAccount = () => {
6096
+ const accountMeta = instruction.accounts[accountIndex];
6097
+ accountIndex += 1;
6098
+ return accountMeta;
6099
+ };
6100
+ return {
6101
+ programAddress: instruction.programAddress,
6102
+ accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
6103
+ data: getRemoveCosignerInstructionDataDecoder2().decode(instruction.data)
6104
+ };
6105
+ }
6106
+ var SET_AUTHORITY_DISCRIMINATOR2 = new Uint8Array([
6107
+ 133,
6108
+ 250,
6109
+ 37,
6110
+ 21,
6111
+ 110,
6112
+ 163,
6113
+ 26,
6114
+ 121
6115
+ ]);
6116
+ function getSetAuthorityDiscriminatorBytes2() {
6117
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
6118
+ SET_AUTHORITY_DISCRIMINATOR2
6119
+ );
6120
+ }
6121
+ function getSetAuthorityInstructionDataEncoder2() {
6122
+ return transformEncoder(
6123
+ getStructEncoder([
6124
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
6125
+ ["adminAuthority", getAddressEncoder()]
6126
+ ]),
6127
+ (value) => ({ ...value, discriminator: SET_AUTHORITY_DISCRIMINATOR2 })
6128
+ );
6129
+ }
6130
+ function getSetAuthorityInstructionDataDecoder2() {
6131
+ return getStructDecoder([
6132
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
6133
+ ["adminAuthority", getAddressDecoder()]
6134
+ ]);
6135
+ }
6136
+ function getSetAuthorityInstructionDataCodec2() {
6137
+ return combineCodec(
6138
+ getSetAuthorityInstructionDataEncoder2(),
6139
+ getSetAuthorityInstructionDataDecoder2()
6140
+ );
6141
+ }
6142
+ async function getSetAuthorityInstructionAsync2(input, config) {
6143
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
6144
+ const originalAccounts = {
6145
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
6146
+ config: { value: input.config ?? null, isWritable: true }
6147
+ };
6148
+ const accounts = originalAccounts;
6149
+ const args = { ...input, adminAuthority: input.adminAuthorityArg };
6150
+ if (!accounts.config.value) {
6151
+ accounts.config.value = await getProgramDerivedAddress({
6152
+ programAddress,
6153
+ seeds: [
6154
+ getBytesEncoder().encode(
6155
+ new Uint8Array([
6156
+ 99,
6157
+ 111,
6158
+ 115,
6159
+ 105,
6160
+ 103,
6161
+ 110,
6162
+ 101,
6163
+ 114,
6164
+ 95,
6165
+ 104,
6166
+ 111,
6167
+ 111,
6168
+ 107,
6169
+ 95,
6170
+ 99,
6171
+ 111,
6172
+ 110,
6173
+ 102,
6174
+ 105,
6175
+ 103
6176
+ ])
6177
+ )
6178
+ ]
6179
+ });
6180
+ }
6181
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
6182
+ return Object.freeze({
6183
+ accounts: [
6184
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
6185
+ getAccountMeta("config", accounts.config)
6186
+ ],
6187
+ data: getSetAuthorityInstructionDataEncoder2().encode(
6188
+ args
6189
+ ),
6190
+ programAddress
6191
+ });
6192
+ }
6193
+ function getSetAuthorityInstruction2(input, config) {
6194
+ const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
6195
+ const originalAccounts = {
6196
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
6197
+ config: { value: input.config ?? null, isWritable: true }
6198
+ };
6199
+ const accounts = originalAccounts;
6200
+ const args = { ...input, adminAuthority: input.adminAuthorityArg };
6201
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
6202
+ return Object.freeze({
6203
+ accounts: [
6204
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
6205
+ getAccountMeta("config", accounts.config)
6206
+ ],
6207
+ data: getSetAuthorityInstructionDataEncoder2().encode(
6208
+ args
6209
+ ),
6210
+ programAddress
6211
+ });
6212
+ }
6213
+ function parseSetAuthorityInstruction2(instruction) {
6214
+ if (instruction.accounts.length < 2) {
6215
+ throw new SolanaError(
6216
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
6217
+ {
6218
+ actualAccountMetas: instruction.accounts.length,
6219
+ expectedAccountMetas: 2
6220
+ }
6221
+ );
6222
+ }
6223
+ let accountIndex = 0;
6224
+ const getNextAccount = () => {
6225
+ const accountMeta = instruction.accounts[accountIndex];
6226
+ accountIndex += 1;
6227
+ return accountMeta;
6228
+ };
6229
+ return {
6230
+ programAddress: instruction.programAddress,
6231
+ accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
6232
+ data: getSetAuthorityInstructionDataDecoder2().decode(instruction.data)
6233
+ };
6234
+ }
6235
+
6236
+ // src/solana/generated/dynamicFeeHook/programs/dynamicFeeHook.ts
6237
+ var DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS = "HVsPNZh98TgChUXHwKrUG47SUqvGQHxUy5wZwcQLFD4i";
6238
+ var DynamicFeeHookAccount = /* @__PURE__ */ ((DynamicFeeHookAccount2) => {
6239
+ DynamicFeeHookAccount2[DynamicFeeHookAccount2["CosignerConfig"] = 0] = "CosignerConfig";
6240
+ return DynamicFeeHookAccount2;
6241
+ })(DynamicFeeHookAccount || {});
6242
+ function identifyDynamicFeeHookAccount(account) {
6243
+ const data = "data" in account ? account.data : account;
6244
+ if (containsBytes(
6245
+ data,
6246
+ fixEncoderSize(getBytesEncoder(), 8).encode(
6247
+ new Uint8Array([133, 227, 177, 74, 145, 74, 247, 183])
6248
+ ),
6249
+ 0
6250
+ )) {
6251
+ return 0 /* CosignerConfig */;
6252
+ }
6253
+ throw new SolanaError(
6254
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
6255
+ { accountData: data, programName: "dynamicFeeHook" }
6256
+ );
6257
+ }
6258
+ var DynamicFeeHookInstruction = /* @__PURE__ */ ((DynamicFeeHookInstruction2) => {
6259
+ DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["AddCosigner"] = 0] = "AddCosigner";
6260
+ DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["InitializeConfig"] = 1] = "InitializeConfig";
6261
+ DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["RemoveCosigner"] = 2] = "RemoveCosigner";
6262
+ DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["SetAuthority"] = 3] = "SetAuthority";
6263
+ return DynamicFeeHookInstruction2;
6264
+ })(DynamicFeeHookInstruction || {});
6265
+ function identifyDynamicFeeHookInstruction(instruction) {
6266
+ const data = "data" in instruction ? instruction.data : instruction;
6267
+ if (containsBytes(
6268
+ data,
6269
+ fixEncoderSize(getBytesEncoder(), 8).encode(
6270
+ new Uint8Array([17, 34, 183, 119, 202, 255, 218, 233])
6271
+ ),
6272
+ 0
6273
+ )) {
6274
+ return 0 /* AddCosigner */;
6275
+ }
6276
+ if (containsBytes(
6277
+ data,
6278
+ fixEncoderSize(getBytesEncoder(), 8).encode(
6279
+ new Uint8Array([208, 127, 21, 1, 194, 190, 196, 70])
6280
+ ),
6281
+ 0
6282
+ )) {
6283
+ return 1 /* InitializeConfig */;
6284
+ }
6285
+ if (containsBytes(
6286
+ data,
6287
+ fixEncoderSize(getBytesEncoder(), 8).encode(
6288
+ new Uint8Array([174, 11, 171, 252, 179, 99, 220, 27])
6289
+ ),
6290
+ 0
6291
+ )) {
6292
+ return 2 /* RemoveCosigner */;
6293
+ }
6294
+ if (containsBytes(
6295
+ data,
6296
+ fixEncoderSize(getBytesEncoder(), 8).encode(
6297
+ new Uint8Array([133, 250, 37, 21, 110, 163, 26, 121])
6298
+ ),
6299
+ 0
6300
+ )) {
6301
+ return 3 /* SetAuthority */;
6302
+ }
6303
+ throw new SolanaError(
6304
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
6305
+ { instructionData: data, programName: "dynamicFeeHook" }
6306
+ );
6307
+ }
6308
+ function parseDynamicFeeHookInstruction(instruction) {
6309
+ const instructionType = identifyDynamicFeeHookInstruction(instruction);
6310
+ switch (instructionType) {
6311
+ case 0 /* AddCosigner */: {
6312
+ assertIsInstructionWithAccounts(instruction);
6313
+ return {
6314
+ instructionType: 0 /* AddCosigner */,
6315
+ ...parseAddCosignerInstruction2(instruction)
6316
+ };
6317
+ }
6318
+ case 1 /* InitializeConfig */: {
6319
+ assertIsInstructionWithAccounts(instruction);
6320
+ return {
6321
+ instructionType: 1 /* InitializeConfig */,
6322
+ ...parseInitializeConfigInstruction4(instruction)
6323
+ };
6324
+ }
6325
+ case 2 /* RemoveCosigner */: {
6326
+ assertIsInstructionWithAccounts(instruction);
6327
+ return {
6328
+ instructionType: 2 /* RemoveCosigner */,
6329
+ ...parseRemoveCosignerInstruction2(instruction)
6330
+ };
6331
+ }
6332
+ case 3 /* SetAuthority */: {
6333
+ assertIsInstructionWithAccounts(instruction);
6334
+ return {
6335
+ instructionType: 3 /* SetAuthority */,
6336
+ ...parseSetAuthorityInstruction2(instruction)
6337
+ };
6338
+ }
6339
+ default:
6340
+ throw new SolanaError(
6341
+ SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
6342
+ {
6343
+ instructionType,
6344
+ programName: "dynamicFeeHook"
6345
+ }
6346
+ );
6347
+ }
6348
+ }
6349
+ function dynamicFeeHookProgram() {
6350
+ return (client) => {
6351
+ return {
6352
+ ...client,
6353
+ dynamicFeeHook: {
6354
+ accounts: {
6355
+ cosignerConfig: addSelfFetchFunctions(
6356
+ client,
6357
+ getCosignerConfigCodec2()
6358
+ )
6359
+ },
6360
+ instructions: {
6361
+ addCosigner: (input) => addSelfPlanAndSendFunctions(
6362
+ client,
6363
+ getAddCosignerInstructionAsync2(input)
6364
+ ),
6365
+ initializeConfig: (input) => addSelfPlanAndSendFunctions(
6366
+ client,
6367
+ getInitializeConfigInstructionAsync4({
6368
+ ...input,
6369
+ payer: input.payer ?? client.payer
6370
+ })
6371
+ ),
6372
+ removeCosigner: (input) => addSelfPlanAndSendFunctions(
6373
+ client,
6374
+ getRemoveCosignerInstructionAsync2(input)
6375
+ ),
6376
+ setAuthority: (input) => addSelfPlanAndSendFunctions(
6377
+ client,
6378
+ getSetAuthorityInstructionAsync2(input)
6379
+ )
6380
+ }
6381
+ }
6382
+ };
6383
+ };
6384
+ }
6385
+
6386
+ // src/solana/generated/dynamicFeeHook/errors/dynamicFeeHook.ts
6387
+ var DYNAMIC_FEE_HOOK_ERROR__INVALID_INSTRUCTION_DATA = 6e3;
6388
+ var DYNAMIC_FEE_HOOK_ERROR__INVALID_SCHEDULE_DATA = 6001;
6389
+ var DYNAMIC_FEE_HOOK_ERROR__INVALID_FEE = 6002;
6390
+ var DYNAMIC_FEE_HOOK_ERROR__INVALID_DURATION = 6003;
6391
+ var DYNAMIC_FEE_HOOK_ERROR__ARITHMETIC_OVERFLOW = 6004;
6392
+ var DYNAMIC_FEE_HOOK_ERROR__INVALID_AUTHORITY = 6005;
6393
+ var DYNAMIC_FEE_HOOK_ERROR__INVALID_CONFIG = 6006;
6394
+ var DYNAMIC_FEE_HOOK_ERROR__INVALID_COSIGNER = 6007;
6395
+ var DYNAMIC_FEE_HOOK_ERROR__COSIGNER_ALREADY_EXISTS = 6008;
6396
+ var DYNAMIC_FEE_HOOK_ERROR__COSIGNER_NOT_FOUND = 6009;
6397
+ var DYNAMIC_FEE_HOOK_ERROR__COSIGNER_LIST_FULL = 6010;
6398
+ var dynamicFeeHookErrorMessages;
6399
+ if (process.env.NODE_ENV !== "production") {
6400
+ dynamicFeeHookErrorMessages = {
6401
+ [DYNAMIC_FEE_HOOK_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
6402
+ [DYNAMIC_FEE_HOOK_ERROR__COSIGNER_ALREADY_EXISTS]: `Cosigner already exists`,
6403
+ [DYNAMIC_FEE_HOOK_ERROR__COSIGNER_LIST_FULL]: `Cosigner list is full`,
6404
+ [DYNAMIC_FEE_HOOK_ERROR__COSIGNER_NOT_FOUND]: `Cosigner not found`,
6405
+ [DYNAMIC_FEE_HOOK_ERROR__INVALID_AUTHORITY]: `Invalid hook authority`,
6406
+ [DYNAMIC_FEE_HOOK_ERROR__INVALID_CONFIG]: `Invalid cosigner hook config`,
6407
+ [DYNAMIC_FEE_HOOK_ERROR__INVALID_COSIGNER]: `Invalid cosigner key`,
6408
+ [DYNAMIC_FEE_HOOK_ERROR__INVALID_DURATION]: `Invalid fee duration`,
6409
+ [DYNAMIC_FEE_HOOK_ERROR__INVALID_FEE]: `Invalid fee`,
6410
+ [DYNAMIC_FEE_HOOK_ERROR__INVALID_INSTRUCTION_DATA]: `Invalid instruction data`,
6411
+ [DYNAMIC_FEE_HOOK_ERROR__INVALID_SCHEDULE_DATA]: `Invalid schedule payload`
6412
+ };
6413
+ }
6414
+ function getDynamicFeeHookErrorMessage(code) {
6415
+ if (process.env.NODE_ENV !== "production") {
6416
+ return dynamicFeeHookErrorMessages[code];
6417
+ }
6418
+ return "Error message not available in production bundles.";
6419
+ }
6420
+ function isDynamicFeeHookError(error, transactionMessage, code) {
6421
+ return isProgramError(
6422
+ error,
6423
+ transactionMessage,
6424
+ DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS,
6425
+ code
6426
+ );
6427
+ }
6428
+ function getCosignerArgEncoder2() {
6429
+ return getStructEncoder([["cosigner", getAddressEncoder()]]);
6430
+ }
6431
+ function getCosignerArgDecoder2() {
6432
+ return getStructDecoder([["cosigner", getAddressDecoder()]]);
6433
+ }
6434
+ function getCosignerArgCodec2() {
6435
+ return combineCodec(getCosignerArgEncoder2(), getCosignerArgDecoder2());
6436
+ }
6437
+ function getInitializeConfigArgsEncoder3() {
6438
+ return getStructEncoder([
6439
+ ["cosigners", getArrayEncoder(getAddressEncoder())]
6440
+ ]);
6441
+ }
6442
+ function getInitializeConfigArgsDecoder3() {
6443
+ return getStructDecoder([
6444
+ ["cosigners", getArrayDecoder(getAddressDecoder())]
6445
+ ]);
6446
+ }
6447
+ function getInitializeConfigArgsCodec3() {
6448
+ return combineCodec(
6449
+ getInitializeConfigArgsEncoder3(),
6450
+ getInitializeConfigArgsDecoder3()
6451
+ );
6452
+ }
6453
+ function getSetAuthorityArgsEncoder2() {
6454
+ return getStructEncoder([["adminAuthority", getAddressEncoder()]]);
6455
+ }
6456
+ function getSetAuthorityArgsDecoder2() {
6457
+ return getStructDecoder([["adminAuthority", getAddressDecoder()]]);
6458
+ }
6459
+ function getSetAuthorityArgsCodec2() {
6460
+ return combineCodec(
6461
+ getSetAuthorityArgsEncoder2(),
6462
+ getSetAuthorityArgsDecoder2()
6463
+ );
6464
+ }
6465
+ var DEVNET_DYNAMIC_FEE_HOOK_PROGRAM_ID = address(
6466
+ "HVsPNZh98TgChUXHwKrUG47SUqvGQHxUy5wZwcQLFD4i"
6467
+ );
6468
+ var DYNAMIC_FEE_HOOK_PROGRAM_ID = DEVNET_DYNAMIC_FEE_HOOK_PROGRAM_ID;
6469
+ var SEED_DYNAMIC_FEE_HOOK_CONFIG = "cosigner_hook_config";
6470
+ var MAX_COSIGNERS2 = 32;
6471
+ var DYNAMIC_FEE_SCHEDULE_MAGIC = new Uint8Array([
6472
+ 68,
6473
+ 70,
6474
+ 69,
6475
+ 69,
6476
+ 86,
6477
+ 49,
6478
+ 95,
6479
+ 95
6480
+ ]);
6481
+ var DYNAMIC_FEE_SCHEDULE_VERSION = 1;
6482
+ var DYNAMIC_FEE_SCHEDULE_LEN = 32;
6483
+ var DYNAMIC_FEE_SCHEDULE_HEADER_LEN = 16;
6484
+ var DYNAMIC_FEE_SCHEDULE_MAX_BPS = 1e4;
6485
+
6486
+ // src/solana/dynamicFeeHook/payload.ts
6487
+ var MAX_I64 = (1n << 63n) - 1n;
6488
+ var MAX_U32 = (1n << 32n) - 1n;
6489
+ function toBigInt2(value) {
6490
+ return typeof value === "bigint" ? value : BigInt(value);
6491
+ }
6492
+ function assertU16Bps(label, value) {
6493
+ if (!Number.isInteger(value) || value < 0 || value > DYNAMIC_FEE_SCHEDULE_MAX_BPS) {
6494
+ throw new Error(`${label} must be an integer between 0 and 10000`);
6495
+ }
6496
+ }
6497
+ function writeI64Le(bytes, offset, value) {
6498
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
6499
+ view.setBigInt64(offset, value, true);
6500
+ }
6501
+ function writeU16Le(bytes, offset, value) {
6502
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
6503
+ view.setUint16(offset, value, true);
6504
+ }
6505
+ function writeU32Le(bytes, offset, value) {
6506
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
6507
+ view.setUint32(offset, Number(value), true);
6508
+ }
6509
+ function validateDynamicFeeScheduleArgs(schedule) {
6510
+ const startingTime = toBigInt2(schedule.startingTime);
6511
+ if (startingTime < 0n || startingTime > MAX_I64) {
6512
+ throw new Error("startingTime must be between 0 and i64::MAX");
6513
+ }
6514
+ assertU16Bps("startFeeBps", schedule.startFeeBps);
6515
+ assertU16Bps("endFeeBps", schedule.endFeeBps);
6516
+ if (schedule.endFeeBps > schedule.startFeeBps) {
6517
+ throw new Error("endFeeBps must be less than or equal to startFeeBps");
6518
+ }
6519
+ const durationSeconds = toBigInt2(schedule.durationSeconds);
6520
+ if (durationSeconds < 0n || durationSeconds > MAX_U32) {
6521
+ throw new Error("durationSeconds must be between 0 and u32::MAX");
6522
+ }
6523
+ if (schedule.startFeeBps > schedule.endFeeBps && durationSeconds === 0n) {
6524
+ throw new Error("durationSeconds must be nonzero for decaying schedules");
6525
+ }
6526
+ return { startingTime, durationSeconds };
6527
+ }
6528
+ function encodeDynamicFeeSchedule(schedule) {
6529
+ const { startingTime, durationSeconds } = validateDynamicFeeScheduleArgs(schedule);
6530
+ const payload = new Uint8Array(DYNAMIC_FEE_SCHEDULE_LEN);
6531
+ payload.set(DYNAMIC_FEE_SCHEDULE_MAGIC, 0);
6532
+ payload[8] = DYNAMIC_FEE_SCHEDULE_VERSION;
6533
+ writeI64Le(payload, DYNAMIC_FEE_SCHEDULE_HEADER_LEN, startingTime);
6534
+ writeU16Le(payload, 24, schedule.startFeeBps);
6535
+ writeU16Le(payload, 26, schedule.endFeeBps);
6536
+ writeU32Le(payload, 28, durationSeconds);
6537
+ return payload;
6538
+ }
6539
+ function encodeDynamicFeeHookPayload(args = {}) {
6540
+ const schedulePayload = args.schedule ? encodeDynamicFeeSchedule(args.schedule) : new Uint8Array();
6541
+ const gatePayload = args.gateExpiry ? encodeCosignerGateExpiryPayload(args.gateExpiry) : new Uint8Array();
6542
+ const payload = new Uint8Array(schedulePayload.length + gatePayload.length);
6543
+ payload.set(schedulePayload, 0);
6544
+ payload.set(gatePayload, schedulePayload.length);
6545
+ return payload;
6546
+ }
6547
+ function encodeDynamicFeeCosignerGatePayload(args) {
6548
+ return encodeCosignerGateExpiryPayload(args);
6549
+ }
6550
+ function getDynamicFeeHookRemainingAccounts({
6551
+ namespace,
6552
+ config,
6553
+ cosigner
6554
+ }) {
6555
+ const signedHookRemainingAccounts = [namespace];
6556
+ if (config && config !== namespace) {
6557
+ signedHookRemainingAccounts.push(config);
6558
+ }
6559
+ if (cosigner) {
6560
+ signedHookRemainingAccounts.push(cosigner);
6561
+ }
6562
+ const unsignedHookRemainingAccounts = signedHookRemainingAccounts.map(
6563
+ getAddressFromRemainingAccount
6564
+ );
6565
+ return {
6566
+ signedHookRemainingAccounts,
6567
+ unsignedHookRemainingAccounts,
6568
+ hookRemainingAccountsHash: computeRemainingAccountsHash(
6569
+ unsignedHookRemainingAccounts
6570
+ )
6571
+ };
6572
+ }
6573
+ function getDynamicFeeHookRemainingAccountAddresses({
6574
+ namespace,
6575
+ config,
6576
+ cosigner
6577
+ }) {
6578
+ return getDynamicFeeHookRemainingAccounts({
6579
+ namespace,
6580
+ config,
6581
+ cosigner
6582
+ }).unsignedHookRemainingAccounts;
6583
+ }
6584
+ function isDynamicFeeSchedulePayload(payload) {
6585
+ return payload.length >= DYNAMIC_FEE_SCHEDULE_LEN && DYNAMIC_FEE_SCHEDULE_MAGIC.every((byte, index) => payload[index] === byte);
6586
+ }
6587
+ var textEncoder6 = new TextEncoder();
6588
+ async function getDynamicFeeHookConfigAddress(programId = DYNAMIC_FEE_HOOK_PROGRAM_ID) {
6589
+ return getProgramDerivedAddress({
6590
+ programAddress: programId,
6591
+ seeds: [textEncoder6.encode(SEED_DYNAMIC_FEE_HOOK_CONFIG)]
6592
+ });
6593
+ }
6594
+
6595
+ // src/solana/migrators/cpmmMigrator/index.ts
6596
+ var cpmmMigrator_exports = {};
6597
+ __export(cpmmMigrator_exports, {
6598
+ CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS: () => CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS,
6599
+ CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS: () => CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS,
6600
+ CPMM_MIGRATOR_PROGRAM_ID: () => CPMM_MIGRATOR_PROGRAM_ID,
6601
+ MAX_RECIPIENTS: () => MAX_RECIPIENTS,
6602
+ SEED_MIGRATION_AUTHORITY: () => SEED_MIGRATION_AUTHORITY,
6603
+ SEED_STATE: () => SEED_STATE,
6604
+ buildCpmmMigrationRemainingAccounts: () => buildCpmmMigrationRemainingAccounts,
6605
+ buildCpmmMigrationRemainingAccountsHash: () => buildCpmmMigrationRemainingAccountsHash,
6606
+ encodeMigratePayload: () => encodeMigratePayload,
6607
+ encodeRegisterLaunchPayload: () => encodeRegisterLaunchPayload,
6608
+ fetchCpmmMigratorState: () => fetchCpmmMigratorState,
6609
+ getCpmmMigrationAuthorityAddress: () => getCpmmMigrationAuthorityAddress,
6610
+ getCpmmMigratorStateAddress: () => getCpmmMigratorStateAddress,
6611
+ getCpmmMigratorStateCodec: () => getCpmmMigratorStateCodec,
6612
+ getCpmmMigratorStateDecoder: () => getCpmmMigratorStateDecoder,
6613
+ getCpmmMigratorStateEncoder: () => getCpmmMigratorStateEncoder,
6614
+ getMigrateArgsCodec: () => getMigrateArgsCodec,
6615
+ getMigrateArgsDecoder: () => getMigrateArgsDecoder,
6616
+ getMigrateArgsEncoder: () => getMigrateArgsEncoder,
6617
+ getRecipientCodec: () => getRecipientCodec,
6618
+ getRecipientDecoder: () => getRecipientDecoder,
6619
+ getRecipientEncoder: () => getRecipientEncoder,
6620
+ getRegisterLaunchArgsCodec: () => getRegisterLaunchArgsCodec,
6621
+ getRegisterLaunchArgsDecoder: () => getRegisterLaunchArgsDecoder,
6622
+ getRegisterLaunchArgsEncoder: () => getRegisterLaunchArgsEncoder
6623
+ });
6624
+ function getMigrateArgsEncoder() {
6625
+ return getStructEncoder([
6626
+ ["baseForDistribution", getU64Encoder()],
6627
+ ["baseForLiquidity", getU64Encoder()]
6628
+ ]);
6629
+ }
6630
+ function getMigrateArgsDecoder() {
6631
+ return getStructDecoder([
6632
+ ["baseForDistribution", getU64Decoder()],
6633
+ ["baseForLiquidity", getU64Decoder()]
6634
+ ]);
6635
+ }
6636
+ function getMigrateArgsCodec() {
6637
+ return combineCodec(getMigrateArgsEncoder(), getMigrateArgsDecoder());
6638
+ }
6639
+ function getMigratedPoolHookConfigEncoder() {
6640
+ return getStructEncoder([
6641
+ ["hookProgram", getAddressEncoder()],
6642
+ ["hookFlags", getU32Encoder()]
6643
+ ]);
6644
+ }
6645
+ function getMigratedPoolHookConfigDecoder() {
6646
+ return getStructDecoder([
6647
+ ["hookProgram", getAddressDecoder()],
6648
+ ["hookFlags", getU32Decoder()]
6649
+ ]);
6650
+ }
6651
+ function getRecipientEncoder() {
6652
+ return getStructEncoder([
6653
+ ["wallet", getAddressEncoder()],
6654
+ ["amount", getU64Encoder()]
6655
+ ]);
6656
+ }
6657
+ function getRecipientDecoder() {
6658
+ return getStructDecoder([
6659
+ ["wallet", getAddressDecoder()],
6660
+ ["amount", getU64Decoder()]
6661
+ ]);
6662
+ }
6663
+ function getRecipientCodec() {
6664
+ return combineCodec(getRecipientEncoder(), getRecipientDecoder());
6665
+ }
6666
+ function getRegisterLaunchArgsEncoder() {
6667
+ return getStructEncoder([
6668
+ ["cpmmConfig", getAddressEncoder()],
6669
+ ["initialSwapFeeBps", getU16Encoder()],
6670
+ ["initialFeeSplitBps", getU16Encoder()],
6671
+ ["recipients", getArrayEncoder(getRecipientEncoder())],
6672
+ ["minRaiseQuote", getU64Encoder()],
6673
+ ["minMigrationPriceQ64Opt", getOptionEncoder(getU128Encoder())],
6674
+ [
6675
+ "migratedPoolHookConfig",
6676
+ getOptionEncoder(getMigratedPoolHookConfigEncoder())
6677
+ ]
6678
+ ]);
6679
+ }
6680
+ function getRegisterLaunchArgsDecoder() {
6681
+ return getStructDecoder([
6682
+ ["cpmmConfig", getAddressDecoder()],
6683
+ ["initialSwapFeeBps", getU16Decoder()],
6684
+ ["initialFeeSplitBps", getU16Decoder()],
6685
+ ["recipients", getArrayDecoder(getRecipientDecoder())],
6686
+ ["minRaiseQuote", getU64Decoder()],
6687
+ ["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())],
6688
+ [
6689
+ "migratedPoolHookConfig",
6690
+ getOptionDecoder(getMigratedPoolHookConfigDecoder())
6691
+ ]
6692
+ ]);
6693
+ }
6694
+ function getRegisterLaunchArgsCodec() {
6695
+ return combineCodec(
6696
+ getRegisterLaunchArgsEncoder(),
6697
+ getRegisterLaunchArgsDecoder()
6698
+ );
6699
+ }
6700
+
6701
+ // src/solana/generated/cpmmMigrator/accounts/cpmmMigratorState.ts
6702
+ var CPMM_MIGRATOR_STATE_DISCRIMINATOR = new Uint8Array([
6703
+ 169,
6704
+ 86,
6705
+ 255,
6706
+ 187,
6707
+ 37,
6708
+ 248,
6709
+ 11,
6710
+ 176
6711
+ ]);
6712
+ function getCpmmMigratorStateEncoder() {
6713
+ return transformEncoder(
6714
+ getStructEncoder([
6715
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
6716
+ ["launch", getAddressEncoder()],
6717
+ ["admin", getAddressEncoder()],
6718
+ ["cpmmConfig", getAddressEncoder()],
6719
+ ["initialSwapFeeBps", getU16Encoder()],
6720
+ ["initialFeeSplitBps", getU16Encoder()],
6721
+ ["pad0", fixEncoderSize(getBytesEncoder(), 4)],
6722
+ ["migratedPoolHookProgram", getAddressEncoder()],
6723
+ ["migratedPoolHookFlags", getU32Encoder()],
6724
+ ["recipients", getArrayEncoder(getRecipientEncoder(), { size: 2 })],
6725
+ ["minRaiseQuote", getU64Encoder()],
6726
+ ["minMigrationPriceQ64Opt", getOptionEncoder(getU128Encoder())],
6727
+ ["isMigrated", getBooleanEncoder()],
6728
+ ["bump", getU8Encoder()],
6729
+ ["reserved", fixEncoderSize(getBytesEncoder(), 14)]
6730
+ ]),
6731
+ (value) => ({ ...value, discriminator: CPMM_MIGRATOR_STATE_DISCRIMINATOR })
6732
+ );
6733
+ }
6734
+ function getCpmmMigratorStateDecoder() {
6735
+ return getStructDecoder([
6736
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
6737
+ ["launch", getAddressDecoder()],
6738
+ ["admin", getAddressDecoder()],
6739
+ ["cpmmConfig", getAddressDecoder()],
6740
+ ["initialSwapFeeBps", getU16Decoder()],
6741
+ ["initialFeeSplitBps", getU16Decoder()],
6742
+ ["pad0", fixDecoderSize(getBytesDecoder(), 4)],
6743
+ ["migratedPoolHookProgram", getAddressDecoder()],
6744
+ ["migratedPoolHookFlags", getU32Decoder()],
6745
+ ["recipients", getArrayDecoder(getRecipientDecoder(), { size: 2 })],
6746
+ ["minRaiseQuote", getU64Decoder()],
6747
+ ["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())],
6748
+ ["isMigrated", getBooleanDecoder()],
6749
+ ["bump", getU8Decoder()],
6750
+ ["reserved", fixDecoderSize(getBytesDecoder(), 14)]
6751
+ ]);
6752
+ }
6753
+ function getCpmmMigratorStateCodec() {
6754
+ return combineCodec(
6755
+ getCpmmMigratorStateEncoder(),
6756
+ getCpmmMigratorStateDecoder()
6757
+ );
6758
+ }
6759
+ if (process.env.NODE_ENV !== "production") ;
6760
+
6761
+ // src/solana/migrators/cpmmMigrator/client.ts
6762
+ async function fetchCpmmMigratorState(rpc, address7) {
6763
+ const response = await rpc.getAccountInfo(address7, { encoding: "base64" }).send();
6764
+ if (!response.value) return null;
6765
+ return getCpmmMigratorStateDecoder().decode(
6766
+ base64ToBytes(response.value.data[0])
6767
+ );
6768
+ }
6769
+ async function buildCpmmMigrationRemainingAccounts({
6770
+ launch,
6771
+ baseMint,
6772
+ quoteMint,
6773
+ launchAuthority,
5808
6774
  adminBaseAta,
5809
6775
  adminQuoteAta,
5810
6776
  recipientAtas,
@@ -5857,8 +6823,8 @@ async function buildCpmmMigrationRemainingAccounts({
5857
6823
  { address: migrationAuthority, role: AccountRole.READONLY },
5858
6824
  { address: adminBaseAta, role: AccountRole.WRITABLE },
5859
6825
  { address: adminQuoteAta, role: AccountRole.WRITABLE },
5860
- ...recipientAtas.map((address4) => ({
5861
- address: address4,
6826
+ ...recipientAtas.map((address7) => ({
6827
+ address: address7,
5862
6828
  role: AccountRole.WRITABLE
5863
6829
  }))
5864
6830
  ],
@@ -5923,30 +6889,8 @@ function createLaunchId() {
5923
6889
  bytes.set([68, 79, 80, 76], 28);
5924
6890
  return bytes;
5925
6891
  }
5926
- function isTransactionSigner9(value) {
5927
- return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
5928
- }
5929
- function getAccountAddress(account) {
5930
- if (typeof account === "string") {
5931
- return account;
5932
- }
5933
- return account.address;
5934
- }
5935
6892
  function getSignerAddress(value) {
5936
- return isTransactionSigner9(value) ? value.address : value;
5937
- }
5938
- function getRemainingAccountMeta(account) {
5939
- if (typeof account === "string") {
5940
- return { address: account, role: AccountRole.READONLY };
5941
- }
5942
- if (isTransactionSigner9(account)) {
5943
- return {
5944
- address: account.address,
5945
- role: AccountRole.READONLY_SIGNER,
5946
- signer: account
5947
- };
5948
- }
5949
- return account;
6893
+ return getAddressFromAddressOrSigner(value);
5950
6894
  }
5951
6895
  function hasMetadata(metadata) {
5952
6896
  return Boolean(metadata?.metadataName);
@@ -5961,7 +6905,9 @@ function hashRemainingAccounts(accounts) {
5961
6905
  if (!accounts) {
5962
6906
  return void 0;
5963
6907
  }
5964
- return computeRemainingAccountsHash(accounts.map(getAccountAddress));
6908
+ return computeRemainingAccountsHash(
6909
+ accounts.map(getAddressFromRemainingAccount)
6910
+ );
5965
6911
  }
5966
6912
  function isCustomMigrationConfig(migration) {
5967
6913
  return migration.kind === "custom";
@@ -5970,13 +6916,35 @@ function getCreateLaunchHookMode(input) {
5970
6916
  if (input.hook !== void 0 && input.hook !== null) {
5971
6917
  return input.hook;
5972
6918
  }
6919
+ if (input.dynamicFee) {
6920
+ return "dynamicFee";
6921
+ }
5973
6922
  return input.cosigner ? "cosigner" : "cpmm";
5974
6923
  }
5975
6924
  async function getCreateLaunchHookContext(input) {
5976
6925
  const mode = getCreateLaunchHookMode(input);
5977
- if (mode !== "cosigner") {
6926
+ if (input.dynamicFee && mode !== "dynamicFee") {
6927
+ throw new Error(
6928
+ 'dynamicFee requires hook to be unset or set to "dynamicFee"'
6929
+ );
6930
+ }
6931
+ if (mode !== "cosigner" && mode !== "dynamicFee") {
5978
6932
  return { mode };
5979
6933
  }
6934
+ if (mode === "dynamicFee") {
6935
+ if (!input.dynamicFee && !input.cosigner) {
6936
+ throw new Error(
6937
+ "dynamicFee hook mode requires dynamicFee or cosigner input"
6938
+ );
6939
+ }
6940
+ if (!input.cosigner) {
6941
+ return { mode };
6942
+ }
6943
+ const [dynamicFeeConfig] = await getDynamicFeeHookConfigAddress(
6944
+ input.deployment?.dynamicFeeHookProgram ?? DYNAMIC_FEE_HOOK_PROGRAM_ID
6945
+ );
6946
+ return { mode, dynamicFeeConfig };
6947
+ }
5980
6948
  const [cosignerConfig] = await getCosignerHookConfigAddress(
5981
6949
  input.deployment?.cosignerHookProgram ?? DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID
5982
6950
  );
@@ -6004,6 +6972,23 @@ function resolveCosignerHookPayload(input) {
6004
6972
  cosigner: getSignerAddress(input.cosigner)
6005
6973
  });
6006
6974
  }
6975
+ function resolveDynamicFeeHookPayload(input) {
6976
+ let gateExpiry = null;
6977
+ if (input.cosignGateExpiresAt !== void 0 && input.cosignGateExpiresAt !== null) {
6978
+ if (!input.cosigner) {
6979
+ throw new Error("cosigner is required when cosignGateExpiresAt is set");
6980
+ }
6981
+ gateExpiry = {
6982
+ mode: GATE_EXPIRY_UNIX_TIMESTAMP,
6983
+ value: input.cosignGateExpiresAt,
6984
+ cosigner: getSignerAddress(input.cosigner)
6985
+ };
6986
+ }
6987
+ return encodeDynamicFeeHookPayload({
6988
+ schedule: input.dynamicFee ?? null,
6989
+ gateExpiry
6990
+ });
6991
+ }
6007
6992
  function resolveCreateLaunchHook({
6008
6993
  input,
6009
6994
  namespace,
@@ -6035,6 +7020,28 @@ function resolveCreateLaunchHook({
6035
7020
  remainingAccountsHash: hashRemainingAccounts(remainingAccounts) ?? EMPTY_REMAINING_ACCOUNTS_HASH
6036
7021
  };
6037
7022
  }
7023
+ if (hookContext.mode === "dynamicFee") {
7024
+ const hasCosigner = Boolean(input.cosigner);
7025
+ const hasSchedule = Boolean(input.dynamicFee);
7026
+ if (input.cosignGateExpiresAt !== void 0 && input.cosignGateExpiresAt !== null && !input.cosigner) {
7027
+ throw new Error("cosigner is required when cosignGateExpiresAt is set");
7028
+ }
7029
+ if (hasCosigner && !hookContext.dynamicFeeConfig) {
7030
+ throw new Error("dynamic fee hook config could not be derived");
7031
+ }
7032
+ const remainingAccounts = getDynamicFeeHookRemainingAccounts({
7033
+ namespace,
7034
+ config: hookContext.dynamicFeeConfig,
7035
+ cosigner: input.cosigner
7036
+ });
7037
+ return {
7038
+ program: input.deployment?.dynamicFeeHookProgram ?? DYNAMIC_FEE_HOOK_PROGRAM_ID,
7039
+ flags: HF_BEFORE_SWAP2 | (hasSchedule ? HF_BEFORE_CREATE : 0) | (hasCosigner ? HF_FORWARD_READONLY_SIGNERS2 : 0),
7040
+ payload: resolveDynamicFeeHookPayload(input),
7041
+ remainingAccounts: remainingAccounts.signedHookRemainingAccounts,
7042
+ remainingAccountsHash: remainingAccounts.hookRemainingAccountsHash
7043
+ };
7044
+ }
6038
7045
  return {
6039
7046
  program: input.deployment?.cpmmHookProgram ?? CPMM_HOOK_PROGRAM_ID,
6040
7047
  flags: HF_BEFORE_SWAP2,
@@ -6177,7 +7184,7 @@ async function createLaunch(input) {
6177
7184
  const programId = getInitializerProgramId(input);
6178
7185
  const launchId = input.launchId ?? createLaunchId();
6179
7186
  const hookContext = await getCreateLaunchHookContext(input);
6180
- const namespace = input.namespace ?? hookContext.cosignerConfig ?? getSignerAddress(input.payer);
7187
+ const namespace = input.namespace ?? hookContext.cosignerConfig ?? (hookContext.mode === "dynamicFee" ? SYSTEM_PROGRAM_ADDRESS : void 0) ?? getSignerAddress(input.payer);
6181
7188
  const tokenPrograms = {
6182
7189
  ...launchTokenPrograms.splToken(),
6183
7190
  ...input.tokenPrograms
@@ -6261,7 +7268,7 @@ async function createLaunch(input) {
6261
7268
  accounts: [
6262
7269
  ...instruction.accounts ?? [],
6263
7270
  ...(migration?.initRemainingAccounts ?? []).map(
6264
- getRemainingAccountMeta
7271
+ createReadonlyRemainingAccountMeta
6265
7272
  )
6266
7273
  ]
6267
7274
  } : instruction;
@@ -6378,37 +7385,22 @@ function assertTransactionMessageFitsWithLookupTable(transactionMessage, lookupT
6378
7385
  return assertTransactionMessageFits(compressedMessage, options);
6379
7386
  }
6380
7387
  var addressCodec5 = getAddressCodec();
6381
- function bytesToBase64(bytes) {
6382
- let binary = "";
6383
- for (let i = 0; i < bytes.length; i++) {
6384
- binary += String.fromCharCode(bytes[i]);
6385
- }
6386
- return btoa(binary);
6387
- }
6388
- function base64ToBytes3(base64) {
6389
- const binary = atob(base64);
6390
- const bytes = new Uint8Array(binary.length);
6391
- for (let i = 0; i < binary.length; i++) {
6392
- bytes[i] = binary.charCodeAt(i);
6393
- }
6394
- return bytes;
6395
- }
6396
- async function fetchLaunch2(rpc, address4, config) {
6397
- const response = await rpc.getAccountInfo(address4, {
7388
+ async function fetchLaunch2(rpc, address7, config) {
7389
+ const response = await rpc.getAccountInfo(address7, {
6398
7390
  encoding: "base64",
6399
7391
  commitment: config?.commitment
6400
7392
  }).send();
6401
7393
  if (!response.value) {
6402
7394
  return null;
6403
7395
  }
6404
- return getLaunchDecoder().decode(base64ToBytes3(response.value.data[0]));
7396
+ return getLaunchDecoder().decode(base64ToBytes(response.value.data[0]));
6405
7397
  }
6406
7398
  async function fetchAllLaunches(rpc, config) {
6407
7399
  const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
6408
7400
  const discriminatorFilter = {
6409
7401
  memcmp: {
6410
7402
  offset: 0n,
6411
- bytes: bytesToBase64(
7403
+ bytes: bytesToBase64EncodedBytes(
6412
7404
  INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
6413
7405
  ),
6414
7406
  encoding: "base64"
@@ -6419,15 +7411,15 @@ async function fetchAllLaunches(rpc, config) {
6419
7411
  commitment: config?.commitment,
6420
7412
  filters: [discriminatorFilter]
6421
7413
  }).send();
6422
- const accounts = Array.isArray(response) ? response : response.value;
7414
+ const accounts = normalizeProgramAccountsResponse(response);
6423
7415
  const launches = [];
6424
7416
  const decoder = getLaunchDecoder();
6425
7417
  for (const account of accounts) {
6426
7418
  try {
6427
- const launch = decoder.decode(base64ToBytes3(account.account.data[0]));
7419
+ const launch = decoder.decode(base64ToBytes(account.account.data[0]));
6428
7420
  launches.push({ address: account.pubkey, account: launch });
6429
7421
  } catch {
6430
- console.warn(`Failed to decode launch account: ${account.pubkey}`);
7422
+ warnAccountDecodeFailure("launch", account.pubkey);
6431
7423
  }
6432
7424
  }
6433
7425
  return launches;
@@ -6437,7 +7429,7 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
6437
7429
  const discriminatorFilter = {
6438
7430
  memcmp: {
6439
7431
  offset: 0n,
6440
- bytes: bytesToBase64(
7432
+ bytes: bytesToBase64EncodedBytes(
6441
7433
  INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
6442
7434
  ),
6443
7435
  encoding: "base64"
@@ -6446,9 +7438,7 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
6446
7438
  const authorityFilter = {
6447
7439
  memcmp: {
6448
7440
  offset: 8n,
6449
- bytes: bytesToBase64(
6450
- addressCodec5.encode(authority)
6451
- ),
7441
+ bytes: bytesToBase64EncodedBytes(addressCodec5.encode(authority)),
6452
7442
  encoding: "base64"
6453
7443
  }
6454
7444
  };
@@ -6457,15 +7447,15 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
6457
7447
  commitment: config?.commitment,
6458
7448
  filters: [discriminatorFilter, authorityFilter]
6459
7449
  }).send();
6460
- const accounts = Array.isArray(response) ? response : response.value;
7450
+ const accounts = normalizeProgramAccountsResponse(response);
6461
7451
  const launches = [];
6462
7452
  const decoder = getLaunchDecoder();
6463
7453
  for (const account of accounts) {
6464
7454
  try {
6465
- const launch = decoder.decode(base64ToBytes3(account.account.data[0]));
7455
+ const launch = decoder.decode(base64ToBytes(account.account.data[0]));
6466
7456
  launches.push({ address: account.pubkey, account: launch });
6467
7457
  } catch {
6468
- console.warn(`Failed to decode launch account: ${account.pubkey}`);
7458
+ warnAccountDecodeFailure("launch", account.pubkey);
6469
7459
  }
6470
7460
  }
6471
7461
  return launches;
@@ -6801,13 +7791,13 @@ function decodeOracleState3(encodedAccount) {
6801
7791
  getOracleStateDecoder2()
6802
7792
  );
6803
7793
  }
6804
- async function fetchOracleState2(rpc, address4, config) {
6805
- const maybeAccount = await fetchMaybeOracleState2(rpc, address4, config);
7794
+ async function fetchOracleState2(rpc, address7, config) {
7795
+ const maybeAccount = await fetchMaybeOracleState2(rpc, address7, config);
6806
7796
  assertAccountExists(maybeAccount);
6807
7797
  return maybeAccount;
6808
7798
  }
6809
- async function fetchMaybeOracleState2(rpc, address4, config) {
6810
- const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
7799
+ async function fetchMaybeOracleState2(rpc, address7, config) {
7800
+ const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
6811
7801
  return decodeOracleState3(maybeAccount);
6812
7802
  }
6813
7803
  async function fetchAllOracleState2(rpc, addresses, config) {
@@ -7149,6 +8139,325 @@ async function getOracleStateAddress(oracleAuthority, nonce) {
7149
8139
  ]
7150
8140
  });
7151
8141
  }
8142
+ var WRAPPED_SOL_MINT = address("So11111111111111111111111111111111111111112");
8143
+ var BPS_DENOMINATOR = 10000n;
8144
+ function isTransactionSigner2(value) {
8145
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
8146
+ }
8147
+ function getAddress(value) {
8148
+ return isTransactionSigner2(value) ? value.address : value;
8149
+ }
8150
+ async function getAssociatedTokenAddress2({
8151
+ owner,
8152
+ mint,
8153
+ tokenProgram
8154
+ }) {
8155
+ const [ata] = await findAssociatedTokenPda({
8156
+ owner,
8157
+ mint,
8158
+ tokenProgram
8159
+ });
8160
+ return ata;
8161
+ }
8162
+ function resolveSlippageBps(slippageBps) {
8163
+ const resolved = slippageBps === void 0 ? 50n : BigInt(slippageBps);
8164
+ if (resolved < 0n || resolved > BPS_DENOMINATOR) {
8165
+ throw new Error("slippageBps must be between 0 and 10000");
8166
+ }
8167
+ return resolved;
8168
+ }
8169
+ function getMinAmountOut({
8170
+ quotedAmountOut,
8171
+ minAmountOut,
8172
+ slippageBps
8173
+ }) {
8174
+ if (minAmountOut !== void 0) {
8175
+ return minAmountOut;
8176
+ }
8177
+ const slippage = resolveSlippageBps(slippageBps);
8178
+ return quotedAmountOut * (BPS_DENOMINATOR - slippage) / BPS_DENOMINATOR;
8179
+ }
8180
+ async function curveSwapExactIn(input) {
8181
+ const programId = input.programId ?? input.deployment?.initializerProgram ?? INITIALIZER_PROGRAM_ID;
8182
+ const user = input.user ?? input.payer;
8183
+ const userAddress = getAddress(user);
8184
+ const baseTokenProgram = input.baseTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
8185
+ const quoteTokenProgram = input.quoteTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
8186
+ const userBaseAccount = await getAssociatedTokenAddress2({
8187
+ owner: userAddress,
8188
+ mint: input.baseMint,
8189
+ tokenProgram: baseTokenProgram
8190
+ });
8191
+ const userQuoteAccount = await getAssociatedTokenAddress2({
8192
+ owner: userAddress,
8193
+ mint: input.quoteMint,
8194
+ tokenProgram: quoteTokenProgram
8195
+ });
8196
+ const setupInstructions = [
8197
+ getCreateAssociatedTokenIdempotentInstruction({
8198
+ payer: input.payer,
8199
+ ata: userBaseAccount,
8200
+ owner: userAddress,
8201
+ mint: input.baseMint,
8202
+ tokenProgram: baseTokenProgram
8203
+ }),
8204
+ getCreateAssociatedTokenIdempotentInstruction({
8205
+ payer: input.payer,
8206
+ ata: userQuoteAccount,
8207
+ owner: userAddress,
8208
+ mint: input.quoteMint,
8209
+ tokenProgram: quoteTokenProgram
8210
+ })
8211
+ ];
8212
+ const shouldWrapSol = input.wrapSol ?? (input.quoteMint === WRAPPED_SOL_MINT && input.tradeDirection === TRADE_DIRECTION_BUY);
8213
+ if (shouldWrapSol) {
8214
+ setupInstructions.push(
8215
+ getTransferSolInstruction({
8216
+ source: input.payer,
8217
+ destination: userQuoteAccount,
8218
+ amount: input.amountIn
8219
+ }),
8220
+ getSyncNativeInstruction({ account: userQuoteAccount })
8221
+ );
8222
+ }
8223
+ const swapAccounts = {
8224
+ launch: input.launch,
8225
+ launchAuthority: input.launchAuthority,
8226
+ baseVault: input.baseVault,
8227
+ quoteVault: input.quoteVault,
8228
+ launchFeeState: input.launchFeeState,
8229
+ userBaseAccount,
8230
+ userQuoteAccount,
8231
+ baseMint: input.baseMint,
8232
+ quoteMint: input.quoteMint,
8233
+ user,
8234
+ hookProgram: input.hookProgram ?? input.deployment?.cpmmHookProgram,
8235
+ baseTokenProgram,
8236
+ quoteTokenProgram,
8237
+ remainingAccounts: input.remainingAccounts ? [...input.remainingAccounts] : void 0
8238
+ };
8239
+ const swapInstruction = createCurveSwapExactInInstruction(
8240
+ swapAccounts,
8241
+ {
8242
+ amountIn: input.amountIn,
8243
+ minAmountOut: input.minAmountOut,
8244
+ tradeDirection: input.tradeDirection
8245
+ },
8246
+ programId
8247
+ );
8248
+ const userIn = input.tradeDirection === TRADE_DIRECTION_BUY ? userQuoteAccount : userBaseAccount;
8249
+ const userOut = input.tradeDirection === TRADE_DIRECTION_BUY ? userBaseAccount : userQuoteAccount;
8250
+ return {
8251
+ userBaseAccount,
8252
+ userQuoteAccount,
8253
+ userIn,
8254
+ userOut,
8255
+ setupInstructions,
8256
+ swapInstruction,
8257
+ instructions: [...setupInstructions, swapInstruction]
8258
+ };
8259
+ }
8260
+ async function swapExactIn(input) {
8261
+ const programId = input.programId ?? input.deployment?.cpmmProgram ?? void 0;
8262
+ const pool = "pool" in input ? input.pool : await getPoolByMints(input.rpc, input.mintA, input.mintB, {
8263
+ programId
8264
+ });
8265
+ if (!pool) {
8266
+ throw new Error(`No pool found for ${input.mintA} / ${input.mintB}`);
8267
+ }
8268
+ const user = input.user ?? input.payer;
8269
+ const userAddress = getAddress(user);
8270
+ const token0Program = input.token0Program ?? input.tokenProgram ?? TOKEN_PROGRAM_ADDRESS;
8271
+ const token1Program = input.token1Program ?? input.tokenProgram ?? TOKEN_PROGRAM_ADDRESS;
8272
+ const quote = getSwapQuote(
8273
+ pool.account,
8274
+ input.amountIn,
8275
+ input.tradeDirection
8276
+ );
8277
+ const minAmountOut = getMinAmountOut({
8278
+ quotedAmountOut: quote.amountOut,
8279
+ minAmountOut: input.minAmountOut,
8280
+ slippageBps: input.slippageBps
8281
+ });
8282
+ const userToken0 = await getAssociatedTokenAddress2({
8283
+ owner: userAddress,
8284
+ mint: pool.account.token0Mint,
8285
+ tokenProgram: token0Program
8286
+ });
8287
+ const userToken1 = await getAssociatedTokenAddress2({
8288
+ owner: userAddress,
8289
+ mint: pool.account.token1Mint,
8290
+ tokenProgram: token1Program
8291
+ });
8292
+ const setupInstructions = [
8293
+ getCreateAssociatedTokenIdempotentInstruction({
8294
+ payer: input.payer,
8295
+ ata: userToken0,
8296
+ owner: userAddress,
8297
+ mint: pool.account.token0Mint,
8298
+ tokenProgram: token0Program
8299
+ }),
8300
+ getCreateAssociatedTokenIdempotentInstruction({
8301
+ payer: input.payer,
8302
+ ata: userToken1,
8303
+ owner: userAddress,
8304
+ mint: pool.account.token1Mint,
8305
+ tokenProgram: token1Program
8306
+ })
8307
+ ];
8308
+ const swapInstruction = createSwapInstruction({
8309
+ config: input.config ?? input.deployment?.cpmmConfig ?? pool.account.config,
8310
+ pool: pool.address,
8311
+ authority: pool.account.authority,
8312
+ vault0: pool.account.vault0,
8313
+ vault1: pool.account.vault1,
8314
+ token0Mint: pool.account.token0Mint,
8315
+ token1Mint: pool.account.token1Mint,
8316
+ userToken0,
8317
+ userToken1,
8318
+ user,
8319
+ amountIn: input.amountIn,
8320
+ minAmountOut,
8321
+ tradeDirection: input.tradeDirection,
8322
+ oracle: input.oracle,
8323
+ remainingAccounts: input.remainingAccounts ? [...input.remainingAccounts] : void 0,
8324
+ updateOracle: input.updateOracle,
8325
+ token0Program,
8326
+ token1Program,
8327
+ programId: programId ?? input.deployment?.cpmmProgram
8328
+ });
8329
+ const userIn = input.tradeDirection === 0 ? userToken0 : userToken1;
8330
+ const userOut = input.tradeDirection === 0 ? userToken1 : userToken0;
8331
+ return {
8332
+ pool,
8333
+ quote,
8334
+ minAmountOut,
8335
+ userToken0,
8336
+ userToken1,
8337
+ userIn,
8338
+ userOut,
8339
+ setupInstructions,
8340
+ swapInstruction,
8341
+ instructions: [...setupInstructions, swapInstruction]
8342
+ };
8343
+ }
8344
+ var COMPUTE_BUDGET_PROGRAM_ID = address(
8345
+ "ComputeBudget111111111111111111111111111111"
8346
+ );
8347
+ function createSetComputeUnitLimitInstruction(units) {
8348
+ const data = new Uint8Array(5);
8349
+ data[0] = 2;
8350
+ new DataView(data.buffer).setUint32(1, units, true);
8351
+ return {
8352
+ programAddress: COMPUTE_BUDGET_PROGRAM_ID,
8353
+ accounts: [],
8354
+ data
8355
+ };
8356
+ }
8357
+ function getDefaultComputeUnitLimit(cpmmMigration) {
8358
+ return cpmmMigration.recipientAtas.length > 0 ? 8e5 : 4e5;
8359
+ }
8360
+ function migrateLaunch(input) {
8361
+ const baseTokenProgram = input.baseTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
8362
+ const quoteTokenProgram = input.quoteTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
8363
+ const recipients = input.recipients ? [...input.recipients] : [];
8364
+ if (recipients.length > 0 && recipients.length !== input.cpmmMigration.recipientAtas.length) {
8365
+ throw new Error(
8366
+ "recipients length must match cpmmMigration.recipientAtas length"
8367
+ );
8368
+ }
8369
+ const initializerConfig = input.config ?? input.deployment?.initializerConfig;
8370
+ if (!initializerConfig) {
8371
+ throw new Error("config or deployment.initializerConfig is required");
8372
+ }
8373
+ const recipientAtaInstructions = recipients.map(
8374
+ (recipient, index) => getCreateAssociatedTokenIdempotentInstruction({
8375
+ payer: input.payer,
8376
+ ata: input.cpmmMigration.recipientAtas[index],
8377
+ owner: recipient.wallet,
8378
+ mint: input.baseMint,
8379
+ tokenProgram: baseTokenProgram
8380
+ })
8381
+ );
8382
+ const migrateLaunchInstruction = createMigrateLaunchInstruction(
8383
+ {
8384
+ config: initializerConfig,
8385
+ launch: input.launch,
8386
+ launchAuthority: input.launchAuthority,
8387
+ baseMint: input.baseMint,
8388
+ quoteMint: input.quoteMint,
8389
+ baseVault: input.baseVault,
8390
+ quoteVault: input.quoteVault,
8391
+ launchFeeState: input.launchFeeState,
8392
+ migratorProgram: input.deployment?.cpmmMigratorProgram ?? CPMM_MIGRATOR_PROGRAM_ID,
8393
+ payer: input.payer,
8394
+ baseTokenProgram,
8395
+ quoteTokenProgram,
8396
+ systemProgram: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS,
8397
+ rent: input.rent ?? SYSVAR_RENT_ADDRESS
8398
+ },
8399
+ input.programId ?? input.deployment?.initializerProgram ?? INITIALIZER_PROGRAM_ID
8400
+ );
8401
+ const migrateInstruction = {
8402
+ ...migrateLaunchInstruction,
8403
+ accounts: [
8404
+ ...migrateLaunchInstruction.accounts ?? [],
8405
+ ...input.cpmmMigration.metas
8406
+ ]
8407
+ };
8408
+ const computeUnitLimit = input.computeUnitLimit === void 0 ? getDefaultComputeUnitLimit(input.cpmmMigration) : input.computeUnitLimit;
8409
+ const computeUnitLimitInstruction = computeUnitLimit === false ? void 0 : createSetComputeUnitLimitInstruction(computeUnitLimit);
8410
+ const instructions = [
8411
+ ...computeUnitLimitInstruction ? [computeUnitLimitInstruction] : [],
8412
+ ...recipientAtaInstructions,
8413
+ migrateInstruction
8414
+ ];
8415
+ return {
8416
+ recipientAtaInstructions,
8417
+ computeUnitLimitInstruction,
8418
+ migrateInstruction,
8419
+ instructions
8420
+ };
8421
+ }
8422
+ async function getMigrationQuoteProgress({
8423
+ rpc,
8424
+ quoteVault,
8425
+ pendingQuoteFees,
8426
+ commitment = "confirmed"
8427
+ }) {
8428
+ const vaultBalance = await rpc.getTokenAccountBalance(quoteVault, { commitment }).send();
8429
+ const quoteVaultAmount = BigInt(vaultBalance.value.amount);
8430
+ if (pendingQuoteFees > quoteVaultAmount) {
8431
+ throw new Error(
8432
+ "pendingQuoteFees cannot exceed the quote vault token balance"
8433
+ );
8434
+ }
8435
+ return {
8436
+ quoteVaultAmount,
8437
+ pendingQuoteFees,
8438
+ migrationQuoteAmount: quoteVaultAmount - pendingQuoteFees
8439
+ };
8440
+ }
8441
+ async function assertMigrationQuoteThreshold({
8442
+ rpc,
8443
+ quoteVault,
8444
+ pendingQuoteFees,
8445
+ minRaiseQuote,
8446
+ commitment = "confirmed"
8447
+ }) {
8448
+ const progress = await getMigrationQuoteProgress({
8449
+ rpc,
8450
+ quoteVault,
8451
+ pendingQuoteFees,
8452
+ commitment
8453
+ });
8454
+ if (progress.migrationQuoteAmount < minRaiseQuote) {
8455
+ throw new Error(
8456
+ `Quote available for migration ${progress.migrationQuoteAmount} is below minRaiseQuote ${minRaiseQuote}`
8457
+ );
8458
+ }
8459
+ return progress;
8460
+ }
7152
8461
 
7153
8462
  // src/solana/deployment.ts
7154
8463
  var DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES = {
@@ -7156,7 +8465,8 @@ var DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES = {
7156
8465
  initializerProgram: INITIALIZER_PROGRAM_ID,
7157
8466
  cpmmMigratorProgram: CPMM_MIGRATOR_PROGRAM_ID,
7158
8467
  cpmmHookProgram: CPMM_HOOK_PROGRAM_ID,
7159
- cosignerHookProgram: DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID
8468
+ cosignerHookProgram: DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID,
8469
+ dynamicFeeHookProgram: DYNAMIC_FEE_HOOK_PROGRAM_ID
7160
8470
  };
7161
8471
  async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES) {
7162
8472
  const [cpmmConfig] = await getConfigAddress(programs.cpmmProgram);
@@ -7170,6 +8480,6 @@ async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGR
7170
8480
  };
7171
8481
  }
7172
8482
 
7173
- export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES, cosignerHook_exports as cosignerHook, cpmm_exports as cpmm, cpmmMigrator_exports as cpmmMigrator, createLaunch, deriveSolanaCpmmDeployment, initializer_exports as initializer, predictionMigrator_exports as predictionMigrator, trustedOracle_exports as trustedOracle };
8483
+ export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES, assertMigrationQuoteThreshold, cosignerHook_exports as cosignerHook, cpmm_exports as cpmm, cpmmMigrator_exports as cpmmMigrator, createLaunch, curveSwapExactIn, deriveSolanaCpmmDeployment, dynamicFeeHook_exports as dynamicFeeHook, getMigrationQuoteProgress, initializer_exports as initializer, migrateLaunch, predictionMigrator_exports as predictionMigrator, swapExactIn, trustedOracle_exports as trustedOracle };
7174
8484
  //# sourceMappingURL=index.js.map
7175
8485
  //# sourceMappingURL=index.js.map