@whetstone-research/doppler-sdk 1.0.24 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/{chunk-BESE77DM.js → chunk-RVDRWCJN.js} +3 -3
- package/dist/{chunk-BESE77DM.js.map → chunk-RVDRWCJN.js.map} +1 -1
- package/dist/{chunk-Y6TJIH33.cjs → chunk-U6B52TBT.cjs} +13 -4
- package/dist/chunk-U6B52TBT.cjs.map +1 -0
- package/dist/{chunk-ZUJKBFXW.js → chunk-WD5VOZGI.js} +8 -5
- package/dist/chunk-WD5VOZGI.js.map +1 -0
- package/dist/{chunk-KJ6W44WF.cjs → chunk-XTL2GBZ4.cjs} +36 -36
- package/dist/{chunk-KJ6W44WF.cjs.map → chunk-XTL2GBZ4.cjs.map} +1 -1
- package/dist/evm/index.cjs +79 -0
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.d.cts +3 -2
- package/dist/evm/index.d.ts +3 -2
- package/dist/evm/index.js +79 -0
- package/dist/evm/index.js.map +1 -1
- package/dist/{pda-A4PIAS5Y.cjs → pda-H6VMGONM.cjs} +17 -17
- package/dist/pda-H6VMGONM.cjs.map +1 -0
- package/dist/{pda-JVAD45XJ.js → pda-UJLXCO6I.js} +3 -3
- package/dist/pda-UJLXCO6I.js.map +1 -0
- package/dist/solana/index.cjs +1362 -801
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +493 -279
- package/dist/solana/index.d.ts +493 -279
- package/dist/solana/index.js +1029 -469
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/react/index.cjs +45 -45
- package/dist/solana/react/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-Y6TJIH33.cjs.map +0 -1
- package/dist/chunk-ZUJKBFXW.js.map +0 -1
- package/dist/pda-A4PIAS5Y.cjs.map +0 -1
- package/dist/pda-JVAD45XJ.js.map +0 -1
package/dist/solana/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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-
|
|
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 } from '../chunk-
|
|
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';
|
|
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
|
-
import { getAddressCodec, getProgramDerivedAddress, createNoopSigner, 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,
|
|
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
8
|
import { findAddressLookupTablePda, getCreateLookupTableInstruction, getExtendLookupTableInstruction } from '@solana-program/address-lookup-table';
|
|
8
9
|
|
|
9
10
|
// src/solana/cpmm/index.ts
|
|
@@ -746,6 +747,13 @@ __export(cosignerHook_exports, {
|
|
|
746
747
|
COSIGNER_HOOK_PROGRAM_ID: () => COSIGNER_HOOK_PROGRAM_ID,
|
|
747
748
|
CosignerHookAccount: () => CosignerHookAccount,
|
|
748
749
|
CosignerHookInstruction: () => CosignerHookInstruction,
|
|
750
|
+
DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID: () => DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID,
|
|
751
|
+
GATE_EXPIRY_DISABLED: () => GATE_EXPIRY_DISABLED,
|
|
752
|
+
GATE_EXPIRY_HEADER_LEN: () => GATE_EXPIRY_HEADER_LEN,
|
|
753
|
+
GATE_EXPIRY_PAYLOAD_LEN: () => GATE_EXPIRY_PAYLOAD_LEN,
|
|
754
|
+
GATE_EXPIRY_PAYLOAD_VERSION: () => GATE_EXPIRY_PAYLOAD_VERSION,
|
|
755
|
+
GATE_EXPIRY_SLOT: () => GATE_EXPIRY_SLOT,
|
|
756
|
+
GATE_EXPIRY_UNIX_TIMESTAMP: () => GATE_EXPIRY_UNIX_TIMESTAMP,
|
|
749
757
|
INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR2,
|
|
750
758
|
MAX_COSIGNERS: () => MAX_COSIGNERS,
|
|
751
759
|
REMOVE_COSIGNER_DISCRIMINATOR: () => REMOVE_COSIGNER_DISCRIMINATOR,
|
|
@@ -753,6 +761,8 @@ __export(cosignerHook_exports, {
|
|
|
753
761
|
SET_AUTHORITY_DISCRIMINATOR: () => SET_AUTHORITY_DISCRIMINATOR,
|
|
754
762
|
cosignerHookProgram: () => cosignerHookProgram,
|
|
755
763
|
decodeCosignerConfig: () => decodeCosignerConfig,
|
|
764
|
+
decodeCosignerGateExpiryPayload: () => decodeCosignerGateExpiryPayload,
|
|
765
|
+
encodeCosignerGateExpiryPayload: () => encodeCosignerGateExpiryPayload,
|
|
756
766
|
fetchAllCosignerConfig: () => fetchAllCosignerConfig,
|
|
757
767
|
fetchAllMaybeCosignerConfig: () => fetchAllMaybeCosignerConfig,
|
|
758
768
|
fetchCosignerConfig: () => fetchCosignerConfig,
|
|
@@ -771,8 +781,10 @@ __export(cosignerHook_exports, {
|
|
|
771
781
|
getCosignerConfigDiscriminatorBytes: () => getCosignerConfigDiscriminatorBytes,
|
|
772
782
|
getCosignerConfigEncoder: () => getCosignerConfigEncoder,
|
|
773
783
|
getCosignerConfigSize: () => getCosignerConfigSize,
|
|
784
|
+
getCosignerGateStatus: () => getCosignerGateStatus,
|
|
774
785
|
getCosignerHookConfigAddress: () => getCosignerHookConfigAddress,
|
|
775
786
|
getCosignerHookErrorMessage: () => getCosignerHookErrorMessage,
|
|
787
|
+
getCosignerHookRemainingAccounts: () => getCosignerHookRemainingAccounts,
|
|
776
788
|
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
|
|
777
789
|
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder,
|
|
778
790
|
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder,
|
|
@@ -799,6 +811,7 @@ __export(cosignerHook_exports, {
|
|
|
799
811
|
getSetAuthorityInstructionDataEncoder: () => getSetAuthorityInstructionDataEncoder,
|
|
800
812
|
identifyCosignerHookAccount: () => identifyCosignerHookAccount,
|
|
801
813
|
identifyCosignerHookInstruction: () => identifyCosignerHookInstruction,
|
|
814
|
+
isCosignerGateEnforced: () => isCosignerGateEnforced,
|
|
802
815
|
isCosignerHookError: () => isCosignerHookError,
|
|
803
816
|
parseAddCosignerInstruction: () => parseAddCosignerInstruction,
|
|
804
817
|
parseCosignerHookInstruction: () => parseCosignerHookInstruction,
|
|
@@ -855,13 +868,13 @@ function decodeCosignerConfig(encodedAccount) {
|
|
|
855
868
|
getCosignerConfigDecoder()
|
|
856
869
|
);
|
|
857
870
|
}
|
|
858
|
-
async function fetchCosignerConfig(rpc,
|
|
859
|
-
const maybeAccount = await fetchMaybeCosignerConfig(rpc,
|
|
871
|
+
async function fetchCosignerConfig(rpc, address4, config) {
|
|
872
|
+
const maybeAccount = await fetchMaybeCosignerConfig(rpc, address4, config);
|
|
860
873
|
assertAccountExists(maybeAccount);
|
|
861
874
|
return maybeAccount;
|
|
862
875
|
}
|
|
863
|
-
async function fetchMaybeCosignerConfig(rpc,
|
|
864
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
876
|
+
async function fetchMaybeCosignerConfig(rpc, address4, config) {
|
|
877
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
865
878
|
return decodeCosignerConfig(maybeAccount);
|
|
866
879
|
}
|
|
867
880
|
async function fetchAllCosignerConfig(rpc, addresses, config) {
|
|
@@ -1642,104 +1655,18 @@ function getSetAuthorityArgsCodec() {
|
|
|
1642
1655
|
getSetAuthorityArgsDecoder()
|
|
1643
1656
|
);
|
|
1644
1657
|
}
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1658
|
+
var DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID = address(
|
|
1659
|
+
"5iWYdN9SEDeF3FTjKB48XYyCFAcVDuYHsz31Z4Wmq7Ch"
|
|
1660
|
+
);
|
|
1661
|
+
var COSIGNER_HOOK_PROGRAM_ID = DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID;
|
|
1648
1662
|
var SEED_COSIGNER_HOOK_CONFIG = "cosigner_hook_config";
|
|
1649
1663
|
var MAX_COSIGNERS = 32;
|
|
1650
|
-
var
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
// src/solana/initializer/index.ts
|
|
1659
|
-
var initializer_exports = {};
|
|
1660
|
-
__export(initializer_exports, {
|
|
1661
|
-
BPF_LOADER_UPGRADEABLE_PROGRAM_ID: () => BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
|
|
1662
|
-
CPMM_HOOK_PROGRAM_ID: () => CPMM_HOOK_PROGRAM_ID,
|
|
1663
|
-
CURVE_KIND_XYK: () => CURVE_KIND_XYK,
|
|
1664
|
-
CURVE_PARAMS_FORMAT_XYK_V0: () => CURVE_PARAMS_FORMAT_XYK_V0,
|
|
1665
|
-
DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND: () => DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND,
|
|
1666
|
-
EMPTY_REMAINING_ACCOUNTS_HASH: () => EMPTY_REMAINING_ACCOUNTS_HASH,
|
|
1667
|
-
HF_AFTER_CREATE: () => HF_AFTER_CREATE,
|
|
1668
|
-
HF_AFTER_MIGRATE: () => HF_AFTER_MIGRATE,
|
|
1669
|
-
HF_AFTER_SWAP: () => HF_AFTER_SWAP2,
|
|
1670
|
-
HF_BEFORE_CREATE: () => HF_BEFORE_CREATE,
|
|
1671
|
-
HF_BEFORE_MIGRATE: () => HF_BEFORE_MIGRATE,
|
|
1672
|
-
HF_BEFORE_SWAP: () => HF_BEFORE_SWAP2,
|
|
1673
|
-
HF_FORWARD_READONLY_SIGNERS: () => HF_FORWARD_READONLY_SIGNERS2,
|
|
1674
|
-
HOOK_NO_CHANGE: () => HOOK_NO_CHANGE2,
|
|
1675
|
-
INITIALIZER_ACCOUNT_DISCRIMINATORS: () => INITIALIZER_ACCOUNT_DISCRIMINATORS,
|
|
1676
|
-
INITIALIZER_INSTRUCTION_DISCRIMINATORS: () => INITIALIZER_INSTRUCTION_DISCRIMINATORS,
|
|
1677
|
-
INITIALIZER_PROGRAM_ID: () => INITIALIZER_PROGRAM_ID,
|
|
1678
|
-
MAX_HOOK_ALLOWLIST: () => MAX_HOOK_ALLOWLIST2,
|
|
1679
|
-
MAX_MIGRATOR_ALLOWLIST: () => MAX_MIGRATOR_ALLOWLIST,
|
|
1680
|
-
MAX_PAYLOAD: () => MAX_PAYLOAD,
|
|
1681
|
-
PHASE_ABORTED: () => PHASE_ABORTED,
|
|
1682
|
-
PHASE_MIGRATED: () => PHASE_MIGRATED,
|
|
1683
|
-
PHASE_TRADING: () => PHASE_TRADING,
|
|
1684
|
-
PREDICTION_HOOK_PROGRAM_ID: () => PREDICTION_HOOK_PROGRAM_ID,
|
|
1685
|
-
SEED_CONFIG: () => SEED_CONFIG2,
|
|
1686
|
-
SEED_LAUNCH: () => SEED_LAUNCH,
|
|
1687
|
-
SEED_LAUNCH_AUTHORITY: () => SEED_LAUNCH_AUTHORITY,
|
|
1688
|
-
SEED_LAUNCH_FEE_STATE: () => SEED_LAUNCH_FEE_STATE,
|
|
1689
|
-
SOLANA_TRANSACTION_SIZE_LIMIT: () => SOLANA_TRANSACTION_SIZE_LIMIT,
|
|
1690
|
-
TRADE_DIRECTION_BUY: () => TRADE_DIRECTION_BUY,
|
|
1691
|
-
TRADE_DIRECTION_SELL: () => TRADE_DIRECTION_SELL,
|
|
1692
|
-
assertTransactionMessageFits: () => assertTransactionMessageFits,
|
|
1693
|
-
assertTransactionMessageFitsWithLookupTable: () => assertTransactionMessageFitsWithLookupTable,
|
|
1694
|
-
buildAddressLookupTableSetupInstructions: () => buildAddressLookupTableSetupInstructions,
|
|
1695
|
-
compressTransactionMessageWithLookupTable: () => compressTransactionMessageWithLookupTable,
|
|
1696
|
-
computeRemainingAccountsHash: () => computeRemainingAccountsHash,
|
|
1697
|
-
createCurveSwapExactInInstruction: () => createCurveSwapExactInInstruction,
|
|
1698
|
-
createInitializeConfigInstruction: () => createInitializeConfigInstruction,
|
|
1699
|
-
createInitializeLaunchInstruction: () => createInitializeLaunchInstruction,
|
|
1700
|
-
createMigrateLaunchInstruction: () => createMigrateLaunchInstruction,
|
|
1701
|
-
createPreviewMigrationInstruction: () => createPreviewMigrationInstruction,
|
|
1702
|
-
createPreviewSwapExactInInstruction: () => createPreviewSwapExactInInstruction,
|
|
1703
|
-
createSetHookAllowlistInstruction: () => createSetHookAllowlistInstruction,
|
|
1704
|
-
createSetMigratorAllowlistInstruction: () => createSetMigratorAllowlistInstruction,
|
|
1705
|
-
decodePreviewMigrationResult: () => decodePreviewMigrationResult,
|
|
1706
|
-
decodePreviewSwapExactInResult: () => decodePreviewSwapExactInResult,
|
|
1707
|
-
encodeU64LE: () => encodeU64LE,
|
|
1708
|
-
fetchAllLaunches: () => fetchAllLaunches,
|
|
1709
|
-
fetchLaunch: () => fetchLaunch2,
|
|
1710
|
-
fetchLaunchesByAuthority: () => fetchLaunchesByAuthority,
|
|
1711
|
-
getClaimFeesInstructionAsync: () => getClaimFeesInstructionAsync,
|
|
1712
|
-
getConfigAddress: () => getConfigAddress2,
|
|
1713
|
-
getHarvestMigratedFeesInstructionAsync: () => getHarvestMigratedFeesInstructionAsync,
|
|
1714
|
-
getInitConfigCodec: () => getInitConfigCodec,
|
|
1715
|
-
getInitConfigDecoder: () => getInitConfigDecoder,
|
|
1716
|
-
getInitConfigEncoder: () => getInitConfigEncoder,
|
|
1717
|
-
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec2,
|
|
1718
|
-
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder2,
|
|
1719
|
-
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder2,
|
|
1720
|
-
getInitializeLaunchArgsCodec: () => getInitializeLaunchArgsCodec,
|
|
1721
|
-
getInitializeLaunchArgsDecoder: () => getInitializeLaunchArgsDecoder,
|
|
1722
|
-
getInitializeLaunchArgsEncoder: () => getInitializeLaunchArgsEncoder,
|
|
1723
|
-
getInstructionLookupTableAddresses: () => getInstructionLookupTableAddresses,
|
|
1724
|
-
getLaunchAddress: () => getLaunchAddress,
|
|
1725
|
-
getLaunchAuthorityAddress: () => getLaunchAuthorityAddress,
|
|
1726
|
-
getLaunchCodec: () => getLaunchCodec,
|
|
1727
|
-
getLaunchDecoder: () => getLaunchDecoder,
|
|
1728
|
-
getLaunchEncoder: () => getLaunchEncoder,
|
|
1729
|
-
getLaunchFeeStateAddress: () => getLaunchFeeStateAddress,
|
|
1730
|
-
getLaunchFeeStateCodec: () => getLaunchFeeStateCodec,
|
|
1731
|
-
getLaunchFeeStateDecoder: () => getLaunchFeeStateDecoder,
|
|
1732
|
-
getLaunchFeeStateEncoder: () => getLaunchFeeStateEncoder,
|
|
1733
|
-
getProgramDataAddress: () => getProgramDataAddress,
|
|
1734
|
-
getReplaceFeeBeneficiaryInstructionAsync: () => getReplaceFeeBeneficiaryInstructionAsync,
|
|
1735
|
-
getSetFeePolicyInstructionAsync: () => getSetFeePolicyInstructionAsync,
|
|
1736
|
-
getTokenMetadataAddress: () => getTokenMetadataAddress,
|
|
1737
|
-
launchExists: () => launchExists,
|
|
1738
|
-
launchIdFromU64: () => launchIdFromU64,
|
|
1739
|
-
measureTransactionMessageSize: () => measureTransactionMessageSize,
|
|
1740
|
-
measureTransactionMessageSizeWithLookupTable: () => measureTransactionMessageSizeWithLookupTable,
|
|
1741
|
-
phaseLabel: () => phaseLabel
|
|
1742
|
-
});
|
|
1664
|
+
var GATE_EXPIRY_DISABLED = 0;
|
|
1665
|
+
var GATE_EXPIRY_UNIX_TIMESTAMP = 1;
|
|
1666
|
+
var GATE_EXPIRY_SLOT = 2;
|
|
1667
|
+
var GATE_EXPIRY_PAYLOAD_VERSION = 1;
|
|
1668
|
+
var GATE_EXPIRY_HEADER_LEN = 10;
|
|
1669
|
+
var GATE_EXPIRY_PAYLOAD_LEN = 42;
|
|
1743
1670
|
var INITIALIZER_PROGRAM_ID = address(
|
|
1744
1671
|
"4h3Dqyo5qmteJoMxXt3tdtfXELDB6pdRTPU9mWruiKp1"
|
|
1745
1672
|
);
|
|
@@ -1915,114 +1842,381 @@ var INITIALIZER_ACCOUNT_DISCRIMINATORS = {
|
|
|
1915
1842
|
232
|
|
1916
1843
|
])
|
|
1917
1844
|
};
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
function getInitConfigEncoder() {
|
|
1929
|
-
return transformEncoder(
|
|
1930
|
-
getStructEncoder([
|
|
1931
|
-
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1932
|
-
["admin", getAddressEncoder()],
|
|
1933
|
-
["migratorAllowlistLen", getU8Encoder()],
|
|
1934
|
-
["migratorAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
1935
|
-
["hookAllowlistLen", getU8Encoder()],
|
|
1936
|
-
["hookAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
1937
|
-
["bump", getU8Encoder()],
|
|
1938
|
-
["version", getU8Encoder()],
|
|
1939
|
-
["protocolFeeBps", getU16Encoder()],
|
|
1940
|
-
["minSwapFeeBps", getU16Encoder()],
|
|
1941
|
-
["maxSwapFeeBps", getU16Encoder()],
|
|
1942
|
-
["reserved", fixEncoderSize(getBytesEncoder(), 24)]
|
|
1943
|
-
]),
|
|
1944
|
-
(value) => ({ ...value, discriminator: INIT_CONFIG_DISCRIMINATOR })
|
|
1945
|
-
);
|
|
1946
|
-
}
|
|
1947
|
-
function getInitConfigDecoder() {
|
|
1948
|
-
return getStructDecoder([
|
|
1949
|
-
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
1950
|
-
["admin", getAddressDecoder()],
|
|
1951
|
-
["migratorAllowlistLen", getU8Decoder()],
|
|
1952
|
-
["migratorAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
1953
|
-
["hookAllowlistLen", getU8Decoder()],
|
|
1954
|
-
["hookAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
1955
|
-
["bump", getU8Decoder()],
|
|
1956
|
-
["version", getU8Decoder()],
|
|
1957
|
-
["protocolFeeBps", getU16Decoder()],
|
|
1958
|
-
["minSwapFeeBps", getU16Decoder()],
|
|
1959
|
-
["maxSwapFeeBps", getU16Decoder()],
|
|
1960
|
-
["reserved", fixDecoderSize(getBytesDecoder(), 24)]
|
|
1961
|
-
]);
|
|
1845
|
+
|
|
1846
|
+
// src/solana/initializer/helpers.ts
|
|
1847
|
+
function computeRemainingAccountsHash(addresses) {
|
|
1848
|
+
const addressEncoder = getAddressEncoder();
|
|
1849
|
+
const buf = new Uint8Array(4 + addresses.length * 32);
|
|
1850
|
+
new DataView(buf.buffer).setUint32(0, addresses.length, true);
|
|
1851
|
+
for (let i = 0; i < addresses.length; i++) {
|
|
1852
|
+
buf.set(addressEncoder.encode(addresses[i]), 4 + i * 32);
|
|
1853
|
+
}
|
|
1854
|
+
return keccak_256(buf);
|
|
1962
1855
|
}
|
|
1963
|
-
function
|
|
1964
|
-
|
|
1856
|
+
function getCurveSwapFeeAmount(amountIn, swapFeeBps) {
|
|
1857
|
+
if (amountIn < 0n) {
|
|
1858
|
+
throw new Error("amountIn must be non-negative");
|
|
1859
|
+
}
|
|
1860
|
+
if (!Number.isInteger(swapFeeBps) || swapFeeBps < 0 || swapFeeBps > Number(BPS_DENOM)) {
|
|
1861
|
+
throw new Error("swapFeeBps must be an integer from 0 to 10000");
|
|
1862
|
+
}
|
|
1863
|
+
return ceilDiv(amountIn * BigInt(swapFeeBps), BPS_DENOM);
|
|
1965
1864
|
}
|
|
1966
|
-
function
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1865
|
+
function phaseLabel(phase) {
|
|
1866
|
+
switch (phase) {
|
|
1867
|
+
case PHASE_TRADING:
|
|
1868
|
+
return "TRADING";
|
|
1869
|
+
case PHASE_MIGRATED:
|
|
1870
|
+
return "MIGRATED";
|
|
1871
|
+
case PHASE_ABORTED:
|
|
1872
|
+
return "ABORTED";
|
|
1873
|
+
default:
|
|
1874
|
+
return String(phase);
|
|
1875
|
+
}
|
|
1972
1876
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1877
|
+
|
|
1878
|
+
// src/solana/cosignerHook/gate.ts
|
|
1879
|
+
var MAX_U64 = (1n << 64n) - 1n;
|
|
1880
|
+
function toBigInt(value) {
|
|
1881
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
1882
|
+
}
|
|
1883
|
+
function isValidExpiryMode(mode) {
|
|
1884
|
+
return mode === GATE_EXPIRY_UNIX_TIMESTAMP || mode === GATE_EXPIRY_SLOT;
|
|
1885
|
+
}
|
|
1886
|
+
function readU64Le(bytes, offset) {
|
|
1887
|
+
let value = 0n;
|
|
1888
|
+
for (let i = 0; i < 8; i++) {
|
|
1889
|
+
value |= BigInt(bytes[offset + i] ?? 0) << BigInt(i * 8);
|
|
1890
|
+
}
|
|
1891
|
+
return value;
|
|
1979
1892
|
}
|
|
1980
|
-
function
|
|
1981
|
-
|
|
1982
|
-
[
|
|
1983
|
-
|
|
1984
|
-
]);
|
|
1893
|
+
function writeU64Le(bytes, offset, value) {
|
|
1894
|
+
for (let i = 0; i < 8; i++) {
|
|
1895
|
+
bytes[offset + i] = Number(value >> BigInt(i * 8) & 0xffn);
|
|
1896
|
+
}
|
|
1985
1897
|
}
|
|
1986
|
-
function
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1898
|
+
function encodeCosignerGateExpiryPayload(expiry) {
|
|
1899
|
+
if (expiry.mode === GATE_EXPIRY_DISABLED) {
|
|
1900
|
+
if (expiry.cosigner !== void 0) {
|
|
1901
|
+
throw new Error("Cosigner hint cannot be encoded for disabled gates");
|
|
1902
|
+
}
|
|
1903
|
+
return new Uint8Array();
|
|
1904
|
+
}
|
|
1905
|
+
if (!isValidExpiryMode(expiry.mode)) {
|
|
1906
|
+
throw new Error(`Invalid cosigner gate expiry mode: ${expiry.mode}`);
|
|
1907
|
+
}
|
|
1908
|
+
const value = toBigInt(expiry.value);
|
|
1909
|
+
if (value < 0n || value > MAX_U64) {
|
|
1910
|
+
throw new Error(`Invalid cosigner gate expiry value: ${expiry.value}`);
|
|
1911
|
+
}
|
|
1912
|
+
if (expiry.cosigner === void 0) {
|
|
1913
|
+
throw new Error("Cosigner hint is required for expiring gates");
|
|
1914
|
+
}
|
|
1915
|
+
const payload = new Uint8Array(GATE_EXPIRY_PAYLOAD_LEN);
|
|
1916
|
+
payload[0] = GATE_EXPIRY_PAYLOAD_VERSION;
|
|
1917
|
+
payload[1] = expiry.mode;
|
|
1918
|
+
writeU64Le(payload, 2, value);
|
|
1919
|
+
payload.set(
|
|
1920
|
+
getAddressEncoder().encode(expiry.cosigner),
|
|
1921
|
+
GATE_EXPIRY_HEADER_LEN
|
|
1922
|
+
);
|
|
1923
|
+
return payload;
|
|
1991
1924
|
}
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1925
|
+
function decodeCosignerGateExpiryPayload(payload) {
|
|
1926
|
+
if (!payload || payload.length === 0) {
|
|
1927
|
+
return { mode: GATE_EXPIRY_DISABLED, value: 0n };
|
|
1928
|
+
}
|
|
1929
|
+
if (payload.length !== GATE_EXPIRY_PAYLOAD_LEN || payload[0] !== GATE_EXPIRY_PAYLOAD_VERSION) {
|
|
1930
|
+
return null;
|
|
1931
|
+
}
|
|
1932
|
+
const mode = payload[1] ?? GATE_EXPIRY_DISABLED;
|
|
1933
|
+
if (!isValidExpiryMode(mode)) {
|
|
1934
|
+
return null;
|
|
1935
|
+
}
|
|
1936
|
+
return {
|
|
1937
|
+
mode,
|
|
1938
|
+
value: readU64Le(payload, 2),
|
|
1939
|
+
cosigner: getAddressDecoder().decode(
|
|
1940
|
+
payload.slice(GATE_EXPIRY_HEADER_LEN, GATE_EXPIRY_PAYLOAD_LEN)
|
|
1941
|
+
)
|
|
1942
|
+
};
|
|
1999
1943
|
}
|
|
2000
|
-
function
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
1944
|
+
function getCosignerGateStatus(hookPayload, clock = {}) {
|
|
1945
|
+
const expiry = decodeCosignerGateExpiryPayload(hookPayload);
|
|
1946
|
+
if (!expiry) {
|
|
1947
|
+
return {
|
|
1948
|
+
gateEnforced: true,
|
|
1949
|
+
expiryMode: GATE_EXPIRY_DISABLED,
|
|
1950
|
+
expiryValue: 0n,
|
|
1951
|
+
reason: "invalid_expiry_payload"
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
if (expiry.mode === GATE_EXPIRY_DISABLED) {
|
|
1955
|
+
return {
|
|
1956
|
+
gateEnforced: true,
|
|
1957
|
+
expiryMode: expiry.mode,
|
|
1958
|
+
expiryValue: expiry.value,
|
|
1959
|
+
reason: "expiry_disabled"
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
if (expiry.mode === GATE_EXPIRY_UNIX_TIMESTAMP) {
|
|
1963
|
+
const unixTimestamp = clock.unixTimestamp === void 0 ? BigInt(Math.floor(Date.now() / 1e3)) : toBigInt(clock.unixTimestamp);
|
|
1964
|
+
const expired = unixTimestamp >= expiry.value;
|
|
1965
|
+
return {
|
|
1966
|
+
gateEnforced: !expired,
|
|
1967
|
+
expiryMode: expiry.mode,
|
|
1968
|
+
expiryValue: expiry.value,
|
|
1969
|
+
reason: expired ? "timestamp_expired" : "timestamp_pending"
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
if (expiry.mode === GATE_EXPIRY_SLOT) {
|
|
1973
|
+
if (clock.slot === void 0) {
|
|
1974
|
+
return {
|
|
1975
|
+
gateEnforced: true,
|
|
1976
|
+
expiryMode: expiry.mode,
|
|
1977
|
+
expiryValue: expiry.value,
|
|
1978
|
+
reason: "slot_unavailable"
|
|
1979
|
+
};
|
|
1980
|
+
}
|
|
1981
|
+
const expired = toBigInt(clock.slot) >= expiry.value;
|
|
1982
|
+
return {
|
|
1983
|
+
gateEnforced: !expired,
|
|
1984
|
+
expiryMode: expiry.mode,
|
|
1985
|
+
expiryValue: expiry.value,
|
|
1986
|
+
reason: expired ? "slot_expired" : "slot_pending"
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1989
|
+
return {
|
|
1990
|
+
gateEnforced: true,
|
|
1991
|
+
expiryMode: expiry.mode,
|
|
1992
|
+
expiryValue: expiry.value,
|
|
1993
|
+
reason: "invalid_expiry_mode"
|
|
1994
|
+
};
|
|
2008
1995
|
}
|
|
2009
|
-
function
|
|
2010
|
-
return
|
|
2011
|
-
["migratorAllowlist", getArrayDecoder(getAddressDecoder())],
|
|
2012
|
-
["hookAllowlist", getArrayDecoder(getAddressDecoder())],
|
|
2013
|
-
["protocolFeeBps", getU16Decoder()],
|
|
2014
|
-
["minSwapFeeBps", getU16Decoder()],
|
|
2015
|
-
["maxSwapFeeBps", getU16Decoder()]
|
|
2016
|
-
]);
|
|
1996
|
+
function isCosignerGateEnforced(hookPayload, clock = {}) {
|
|
1997
|
+
return getCosignerGateStatus(hookPayload, clock).gateEnforced;
|
|
2017
1998
|
}
|
|
2018
|
-
function
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
1999
|
+
function getCosignerHookRemainingAccounts({
|
|
2000
|
+
namespace,
|
|
2001
|
+
cosigner
|
|
2002
|
+
}) {
|
|
2003
|
+
const unsignedHookRemainingAccounts = [
|
|
2004
|
+
namespace,
|
|
2005
|
+
cosigner.address
|
|
2006
|
+
];
|
|
2007
|
+
return {
|
|
2008
|
+
signedHookRemainingAccounts: [namespace, cosigner],
|
|
2009
|
+
unsignedHookRemainingAccounts,
|
|
2010
|
+
hookRemainingAccountsHash: computeRemainingAccountsHash(
|
|
2011
|
+
unsignedHookRemainingAccounts
|
|
2012
|
+
)
|
|
2013
|
+
};
|
|
2023
2014
|
}
|
|
2024
|
-
|
|
2025
|
-
|
|
2015
|
+
var textEncoder2 = new TextEncoder();
|
|
2016
|
+
async function getCosignerHookConfigAddress(programId = COSIGNER_HOOK_PROGRAM_ID) {
|
|
2017
|
+
return getProgramDerivedAddress({
|
|
2018
|
+
programAddress: programId,
|
|
2019
|
+
seeds: [textEncoder2.encode(SEED_COSIGNER_HOOK_CONFIG)]
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
// src/solana/initializer/index.ts
|
|
2024
|
+
var initializer_exports = {};
|
|
2025
|
+
__export(initializer_exports, {
|
|
2026
|
+
BPF_LOADER_UPGRADEABLE_PROGRAM_ID: () => BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
|
|
2027
|
+
CPMM_HOOK_PROGRAM_ID: () => CPMM_HOOK_PROGRAM_ID,
|
|
2028
|
+
CURVE_KIND_XYK: () => CURVE_KIND_XYK,
|
|
2029
|
+
CURVE_PARAMS_FORMAT_XYK_V0: () => CURVE_PARAMS_FORMAT_XYK_V0,
|
|
2030
|
+
DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND: () => DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND,
|
|
2031
|
+
EMPTY_REMAINING_ACCOUNTS_HASH: () => EMPTY_REMAINING_ACCOUNTS_HASH,
|
|
2032
|
+
HF_AFTER_CREATE: () => HF_AFTER_CREATE,
|
|
2033
|
+
HF_AFTER_MIGRATE: () => HF_AFTER_MIGRATE,
|
|
2034
|
+
HF_AFTER_SWAP: () => HF_AFTER_SWAP2,
|
|
2035
|
+
HF_BEFORE_CREATE: () => HF_BEFORE_CREATE,
|
|
2036
|
+
HF_BEFORE_MIGRATE: () => HF_BEFORE_MIGRATE,
|
|
2037
|
+
HF_BEFORE_SWAP: () => HF_BEFORE_SWAP2,
|
|
2038
|
+
HF_FORWARD_READONLY_SIGNERS: () => HF_FORWARD_READONLY_SIGNERS2,
|
|
2039
|
+
HOOK_NO_CHANGE: () => HOOK_NO_CHANGE2,
|
|
2040
|
+
INITIALIZER_ACCOUNT_DISCRIMINATORS: () => INITIALIZER_ACCOUNT_DISCRIMINATORS,
|
|
2041
|
+
INITIALIZER_INSTRUCTION_DISCRIMINATORS: () => INITIALIZER_INSTRUCTION_DISCRIMINATORS,
|
|
2042
|
+
INITIALIZER_PROGRAM_ID: () => INITIALIZER_PROGRAM_ID,
|
|
2043
|
+
MAX_HOOK_ALLOWLIST: () => MAX_HOOK_ALLOWLIST2,
|
|
2044
|
+
MAX_MIGRATOR_ALLOWLIST: () => MAX_MIGRATOR_ALLOWLIST,
|
|
2045
|
+
MAX_PAYLOAD: () => MAX_PAYLOAD,
|
|
2046
|
+
PHASE_ABORTED: () => PHASE_ABORTED,
|
|
2047
|
+
PHASE_MIGRATED: () => PHASE_MIGRATED,
|
|
2048
|
+
PHASE_TRADING: () => PHASE_TRADING,
|
|
2049
|
+
PREDICTION_HOOK_PROGRAM_ID: () => PREDICTION_HOOK_PROGRAM_ID,
|
|
2050
|
+
SEED_CONFIG: () => SEED_CONFIG2,
|
|
2051
|
+
SEED_LAUNCH: () => SEED_LAUNCH,
|
|
2052
|
+
SEED_LAUNCH_AUTHORITY: () => SEED_LAUNCH_AUTHORITY,
|
|
2053
|
+
SEED_LAUNCH_FEE_STATE: () => SEED_LAUNCH_FEE_STATE,
|
|
2054
|
+
SOLANA_TRANSACTION_SIZE_LIMIT: () => SOLANA_TRANSACTION_SIZE_LIMIT,
|
|
2055
|
+
TRADE_DIRECTION_BUY: () => TRADE_DIRECTION_BUY,
|
|
2056
|
+
TRADE_DIRECTION_SELL: () => TRADE_DIRECTION_SELL,
|
|
2057
|
+
assertTransactionMessageFits: () => assertTransactionMessageFits,
|
|
2058
|
+
assertTransactionMessageFitsWithLookupTable: () => assertTransactionMessageFitsWithLookupTable,
|
|
2059
|
+
buildAddressLookupTableSetupInstructions: () => buildAddressLookupTableSetupInstructions,
|
|
2060
|
+
compressTransactionMessageWithLookupTable: () => compressTransactionMessageWithLookupTable,
|
|
2061
|
+
computeRemainingAccountsHash: () => computeRemainingAccountsHash,
|
|
2062
|
+
createCurveSwapExactInInstruction: () => createCurveSwapExactInInstruction,
|
|
2063
|
+
createInitializeConfigInstruction: () => createInitializeConfigInstruction,
|
|
2064
|
+
createInitializeLaunchInstruction: () => createInitializeLaunchInstruction,
|
|
2065
|
+
createLaunchId: () => createLaunchId,
|
|
2066
|
+
createMigrateLaunchInstruction: () => createMigrateLaunchInstruction,
|
|
2067
|
+
createPreviewMigrationInstruction: () => createPreviewMigrationInstruction,
|
|
2068
|
+
createPreviewSwapExactInInstruction: () => createPreviewSwapExactInInstruction,
|
|
2069
|
+
createSetHookAllowlistInstruction: () => createSetHookAllowlistInstruction,
|
|
2070
|
+
createSetMigratorAllowlistInstruction: () => createSetMigratorAllowlistInstruction,
|
|
2071
|
+
decodePreviewMigrationResult: () => decodePreviewMigrationResult,
|
|
2072
|
+
decodePreviewSwapExactInResult: () => decodePreviewSwapExactInResult,
|
|
2073
|
+
deriveCreateLaunchAddresses: () => deriveCreateLaunchAddresses,
|
|
2074
|
+
encodeU64LE: () => encodeU64LE,
|
|
2075
|
+
fetchAllLaunches: () => fetchAllLaunches,
|
|
2076
|
+
fetchLaunch: () => fetchLaunch2,
|
|
2077
|
+
fetchLaunchesByAuthority: () => fetchLaunchesByAuthority,
|
|
2078
|
+
getClaimFeesInstructionAsync: () => getClaimFeesInstructionAsync,
|
|
2079
|
+
getConfigAddress: () => getConfigAddress2,
|
|
2080
|
+
getCurveSwapFeeAmount: () => getCurveSwapFeeAmount,
|
|
2081
|
+
getHarvestMigratedFeesInstructionAsync: () => getHarvestMigratedFeesInstructionAsync,
|
|
2082
|
+
getInitConfigCodec: () => getInitConfigCodec,
|
|
2083
|
+
getInitConfigDecoder: () => getInitConfigDecoder,
|
|
2084
|
+
getInitConfigEncoder: () => getInitConfigEncoder,
|
|
2085
|
+
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec2,
|
|
2086
|
+
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder2,
|
|
2087
|
+
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder2,
|
|
2088
|
+
getInitializeLaunchArgsCodec: () => getInitializeLaunchArgsCodec,
|
|
2089
|
+
getInitializeLaunchArgsDecoder: () => getInitializeLaunchArgsDecoder,
|
|
2090
|
+
getInitializeLaunchArgsEncoder: () => getInitializeLaunchArgsEncoder,
|
|
2091
|
+
getInstructionLookupTableAddresses: () => getInstructionLookupTableAddresses,
|
|
2092
|
+
getLaunchAddress: () => getLaunchAddress,
|
|
2093
|
+
getLaunchAuthorityAddress: () => getLaunchAuthorityAddress,
|
|
2094
|
+
getLaunchCodec: () => getLaunchCodec,
|
|
2095
|
+
getLaunchDecoder: () => getLaunchDecoder,
|
|
2096
|
+
getLaunchEncoder: () => getLaunchEncoder,
|
|
2097
|
+
getLaunchFeeStateAddress: () => getLaunchFeeStateAddress,
|
|
2098
|
+
getLaunchFeeStateCodec: () => getLaunchFeeStateCodec,
|
|
2099
|
+
getLaunchFeeStateDecoder: () => getLaunchFeeStateDecoder,
|
|
2100
|
+
getLaunchFeeStateEncoder: () => getLaunchFeeStateEncoder,
|
|
2101
|
+
getProgramDataAddress: () => getProgramDataAddress,
|
|
2102
|
+
getReplaceFeeBeneficiaryInstructionAsync: () => getReplaceFeeBeneficiaryInstructionAsync,
|
|
2103
|
+
getSetFeePolicyInstructionAsync: () => getSetFeePolicyInstructionAsync,
|
|
2104
|
+
getTokenMetadataAddress: () => getTokenMetadataAddress,
|
|
2105
|
+
launchExists: () => launchExists,
|
|
2106
|
+
launchIdFromU64: () => launchIdFromU64,
|
|
2107
|
+
launchTokenPrograms: () => launchTokenPrograms,
|
|
2108
|
+
measureTransactionMessageSize: () => measureTransactionMessageSize,
|
|
2109
|
+
measureTransactionMessageSizeWithLookupTable: () => measureTransactionMessageSizeWithLookupTable,
|
|
2110
|
+
phaseLabel: () => phaseLabel
|
|
2111
|
+
});
|
|
2112
|
+
var INIT_CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
2113
|
+
97,
|
|
2114
|
+
166,
|
|
2115
|
+
35,
|
|
2116
|
+
7,
|
|
2117
|
+
20,
|
|
2118
|
+
2,
|
|
2119
|
+
164,
|
|
2120
|
+
126
|
|
2121
|
+
]);
|
|
2122
|
+
function getInitConfigEncoder() {
|
|
2123
|
+
return transformEncoder(
|
|
2124
|
+
getStructEncoder([
|
|
2125
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2126
|
+
["admin", getAddressEncoder()],
|
|
2127
|
+
["migratorAllowlistLen", getU8Encoder()],
|
|
2128
|
+
["migratorAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
2129
|
+
["hookAllowlistLen", getU8Encoder()],
|
|
2130
|
+
["hookAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
2131
|
+
["bump", getU8Encoder()],
|
|
2132
|
+
["version", getU8Encoder()],
|
|
2133
|
+
["protocolFeeBps", getU16Encoder()],
|
|
2134
|
+
["minSwapFeeBps", getU16Encoder()],
|
|
2135
|
+
["maxSwapFeeBps", getU16Encoder()],
|
|
2136
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 24)]
|
|
2137
|
+
]),
|
|
2138
|
+
(value) => ({ ...value, discriminator: INIT_CONFIG_DISCRIMINATOR })
|
|
2139
|
+
);
|
|
2140
|
+
}
|
|
2141
|
+
function getInitConfigDecoder() {
|
|
2142
|
+
return getStructDecoder([
|
|
2143
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2144
|
+
["admin", getAddressDecoder()],
|
|
2145
|
+
["migratorAllowlistLen", getU8Decoder()],
|
|
2146
|
+
["migratorAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
2147
|
+
["hookAllowlistLen", getU8Decoder()],
|
|
2148
|
+
["hookAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
2149
|
+
["bump", getU8Decoder()],
|
|
2150
|
+
["version", getU8Decoder()],
|
|
2151
|
+
["protocolFeeBps", getU16Decoder()],
|
|
2152
|
+
["minSwapFeeBps", getU16Decoder()],
|
|
2153
|
+
["maxSwapFeeBps", getU16Decoder()],
|
|
2154
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 24)]
|
|
2155
|
+
]);
|
|
2156
|
+
}
|
|
2157
|
+
function getInitConfigCodec() {
|
|
2158
|
+
return combineCodec(getInitConfigEncoder(), getInitConfigDecoder());
|
|
2159
|
+
}
|
|
2160
|
+
function getFeeBeneficiaryEncoder() {
|
|
2161
|
+
return getStructEncoder([
|
|
2162
|
+
["wallet", getAddressEncoder()],
|
|
2163
|
+
["shareBps", getU16Encoder()],
|
|
2164
|
+
["pad", fixEncoderSize(getBytesEncoder(), 6)]
|
|
2165
|
+
]);
|
|
2166
|
+
}
|
|
2167
|
+
function getFeeBeneficiaryDecoder() {
|
|
2168
|
+
return getStructDecoder([
|
|
2169
|
+
["wallet", getAddressDecoder()],
|
|
2170
|
+
["shareBps", getU16Decoder()],
|
|
2171
|
+
["pad", fixDecoderSize(getBytesDecoder(), 6)]
|
|
2172
|
+
]);
|
|
2173
|
+
}
|
|
2174
|
+
function getFeeBeneficiaryInputEncoder() {
|
|
2175
|
+
return getStructEncoder([
|
|
2176
|
+
["wallet", getAddressEncoder()],
|
|
2177
|
+
["shareBps", getU16Encoder()]
|
|
2178
|
+
]);
|
|
2179
|
+
}
|
|
2180
|
+
function getFeeBeneficiaryInputDecoder() {
|
|
2181
|
+
return getStructDecoder([
|
|
2182
|
+
["wallet", getAddressDecoder()],
|
|
2183
|
+
["shareBps", getU16Decoder()]
|
|
2184
|
+
]);
|
|
2185
|
+
}
|
|
2186
|
+
var FeeClaimRole = /* @__PURE__ */ ((FeeClaimRole2) => {
|
|
2187
|
+
FeeClaimRole2[FeeClaimRole2["Protocol"] = 0] = "Protocol";
|
|
2188
|
+
FeeClaimRole2[FeeClaimRole2["Beneficiary"] = 1] = "Beneficiary";
|
|
2189
|
+
return FeeClaimRole2;
|
|
2190
|
+
})(FeeClaimRole || {});
|
|
2191
|
+
function getFeeClaimRoleEncoder() {
|
|
2192
|
+
return getEnumEncoder(FeeClaimRole);
|
|
2193
|
+
}
|
|
2194
|
+
function getInitializeConfigArgsEncoder2() {
|
|
2195
|
+
return getStructEncoder([
|
|
2196
|
+
["migratorAllowlist", getArrayEncoder(getAddressEncoder())],
|
|
2197
|
+
["hookAllowlist", getArrayEncoder(getAddressEncoder())],
|
|
2198
|
+
["protocolFeeBps", getU16Encoder()],
|
|
2199
|
+
["minSwapFeeBps", getU16Encoder()],
|
|
2200
|
+
["maxSwapFeeBps", getU16Encoder()]
|
|
2201
|
+
]);
|
|
2202
|
+
}
|
|
2203
|
+
function getInitializeConfigArgsDecoder2() {
|
|
2204
|
+
return getStructDecoder([
|
|
2205
|
+
["migratorAllowlist", getArrayDecoder(getAddressDecoder())],
|
|
2206
|
+
["hookAllowlist", getArrayDecoder(getAddressDecoder())],
|
|
2207
|
+
["protocolFeeBps", getU16Decoder()],
|
|
2208
|
+
["minSwapFeeBps", getU16Decoder()],
|
|
2209
|
+
["maxSwapFeeBps", getU16Decoder()]
|
|
2210
|
+
]);
|
|
2211
|
+
}
|
|
2212
|
+
function getInitializeConfigArgsCodec2() {
|
|
2213
|
+
return combineCodec(
|
|
2214
|
+
getInitializeConfigArgsEncoder2(),
|
|
2215
|
+
getInitializeConfigArgsDecoder2()
|
|
2216
|
+
);
|
|
2217
|
+
}
|
|
2218
|
+
function getInitializeLaunchArgsEncoder() {
|
|
2219
|
+
return getStructEncoder([
|
|
2026
2220
|
["namespace", getAddressEncoder()],
|
|
2027
2221
|
["launchId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
2028
2222
|
["baseDecimals", getU8Encoder()],
|
|
@@ -3014,27 +3208,6 @@ function createSetHookAllowlistInstruction(accounts, allowlist, programId = INIT
|
|
|
3014
3208
|
);
|
|
3015
3209
|
return { programAddress: programId, accounts: keys, data };
|
|
3016
3210
|
}
|
|
3017
|
-
function computeRemainingAccountsHash(addresses) {
|
|
3018
|
-
const addressEncoder = getAddressEncoder();
|
|
3019
|
-
const buf = new Uint8Array(4 + addresses.length * 32);
|
|
3020
|
-
new DataView(buf.buffer).setUint32(0, addresses.length, true);
|
|
3021
|
-
for (let i = 0; i < addresses.length; i++) {
|
|
3022
|
-
buf.set(addressEncoder.encode(addresses[i]), 4 + i * 32);
|
|
3023
|
-
}
|
|
3024
|
-
return keccak_256(buf);
|
|
3025
|
-
}
|
|
3026
|
-
function phaseLabel(phase) {
|
|
3027
|
-
switch (phase) {
|
|
3028
|
-
case PHASE_TRADING:
|
|
3029
|
-
return "TRADING";
|
|
3030
|
-
case PHASE_MIGRATED:
|
|
3031
|
-
return "MIGRATED";
|
|
3032
|
-
case PHASE_ABORTED:
|
|
3033
|
-
return "ABORTED";
|
|
3034
|
-
default:
|
|
3035
|
-
return String(phase);
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
3211
|
var CPMM_MIGRATOR_PROGRAM_ID = address(
|
|
3039
3212
|
"7WMUTNC41eMCo6eGH5Sy2xbgE3AycvLbFPo95AU9CSUd"
|
|
3040
3213
|
);
|
|
@@ -3132,13 +3305,13 @@ function decodeClaimReceipt(encodedAccount) {
|
|
|
3132
3305
|
getClaimReceiptDecoder()
|
|
3133
3306
|
);
|
|
3134
3307
|
}
|
|
3135
|
-
async function fetchClaimReceipt(rpc,
|
|
3136
|
-
const maybeAccount = await fetchMaybeClaimReceipt(rpc,
|
|
3308
|
+
async function fetchClaimReceipt(rpc, address4, config) {
|
|
3309
|
+
const maybeAccount = await fetchMaybeClaimReceipt(rpc, address4, config);
|
|
3137
3310
|
assertAccountExists(maybeAccount);
|
|
3138
3311
|
return maybeAccount;
|
|
3139
3312
|
}
|
|
3140
|
-
async function fetchMaybeClaimReceipt(rpc,
|
|
3141
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3313
|
+
async function fetchMaybeClaimReceipt(rpc, address4, config) {
|
|
3314
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
3142
3315
|
return decodeClaimReceipt(maybeAccount);
|
|
3143
3316
|
}
|
|
3144
3317
|
async function fetchAllClaimReceipt(rpc, addresses, config) {
|
|
@@ -3202,13 +3375,13 @@ function decodeEntry(encodedAccount) {
|
|
|
3202
3375
|
getEntryDecoder()
|
|
3203
3376
|
);
|
|
3204
3377
|
}
|
|
3205
|
-
async function fetchEntry(rpc,
|
|
3206
|
-
const maybeAccount = await fetchMaybeEntry(rpc,
|
|
3378
|
+
async function fetchEntry(rpc, address4, config) {
|
|
3379
|
+
const maybeAccount = await fetchMaybeEntry(rpc, address4, config);
|
|
3207
3380
|
assertAccountExists(maybeAccount);
|
|
3208
3381
|
return maybeAccount;
|
|
3209
3382
|
}
|
|
3210
|
-
async function fetchMaybeEntry(rpc,
|
|
3211
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3383
|
+
async function fetchMaybeEntry(rpc, address4, config) {
|
|
3384
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
3212
3385
|
return decodeEntry(maybeAccount);
|
|
3213
3386
|
}
|
|
3214
3387
|
async function fetchAllEntry(rpc, addresses, config) {
|
|
@@ -3270,13 +3443,13 @@ function decodeEntryByMint(encodedAccount) {
|
|
|
3270
3443
|
getEntryByMintDecoder()
|
|
3271
3444
|
);
|
|
3272
3445
|
}
|
|
3273
|
-
async function fetchEntryByMint(rpc,
|
|
3274
|
-
const maybeAccount = await fetchMaybeEntryByMint(rpc,
|
|
3446
|
+
async function fetchEntryByMint(rpc, address4, config) {
|
|
3447
|
+
const maybeAccount = await fetchMaybeEntryByMint(rpc, address4, config);
|
|
3275
3448
|
assertAccountExists(maybeAccount);
|
|
3276
3449
|
return maybeAccount;
|
|
3277
3450
|
}
|
|
3278
|
-
async function fetchMaybeEntryByMint(rpc,
|
|
3279
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3451
|
+
async function fetchMaybeEntryByMint(rpc, address4, config) {
|
|
3452
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
3280
3453
|
return decodeEntryByMint(maybeAccount);
|
|
3281
3454
|
}
|
|
3282
3455
|
async function fetchAllEntryByMint(rpc, addresses, config) {
|
|
@@ -3348,13 +3521,13 @@ function decodeInitConfig(encodedAccount) {
|
|
|
3348
3521
|
getInitConfigDecoder2()
|
|
3349
3522
|
);
|
|
3350
3523
|
}
|
|
3351
|
-
async function fetchInitConfig(rpc,
|
|
3352
|
-
const maybeAccount = await fetchMaybeInitConfig(rpc,
|
|
3524
|
+
async function fetchInitConfig(rpc, address4, config) {
|
|
3525
|
+
const maybeAccount = await fetchMaybeInitConfig(rpc, address4, config);
|
|
3353
3526
|
assertAccountExists(maybeAccount);
|
|
3354
3527
|
return maybeAccount;
|
|
3355
3528
|
}
|
|
3356
|
-
async function fetchMaybeInitConfig(rpc,
|
|
3357
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3529
|
+
async function fetchMaybeInitConfig(rpc, address4, config) {
|
|
3530
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
3358
3531
|
return decodeInitConfig(maybeAccount);
|
|
3359
3532
|
}
|
|
3360
3533
|
async function fetchAllInitConfig(rpc, addresses, config) {
|
|
@@ -3654,13 +3827,13 @@ function decodeLaunch(encodedAccount) {
|
|
|
3654
3827
|
getLaunchDecoder2()
|
|
3655
3828
|
);
|
|
3656
3829
|
}
|
|
3657
|
-
async function fetchLaunch(rpc,
|
|
3658
|
-
const maybeAccount = await fetchMaybeLaunch(rpc,
|
|
3830
|
+
async function fetchLaunch(rpc, address4, config) {
|
|
3831
|
+
const maybeAccount = await fetchMaybeLaunch(rpc, address4, config);
|
|
3659
3832
|
assertAccountExists(maybeAccount);
|
|
3660
3833
|
return maybeAccount;
|
|
3661
3834
|
}
|
|
3662
|
-
async function fetchMaybeLaunch(rpc,
|
|
3663
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3835
|
+
async function fetchMaybeLaunch(rpc, address4, config) {
|
|
3836
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
3664
3837
|
return decodeLaunch(maybeAccount);
|
|
3665
3838
|
}
|
|
3666
3839
|
async function fetchAllLaunch(rpc, addresses, config) {
|
|
@@ -3734,13 +3907,13 @@ function decodeMarket(encodedAccount) {
|
|
|
3734
3907
|
getMarketDecoder()
|
|
3735
3908
|
);
|
|
3736
3909
|
}
|
|
3737
|
-
async function fetchMarket(rpc,
|
|
3738
|
-
const maybeAccount = await fetchMaybeMarket(rpc,
|
|
3910
|
+
async function fetchMarket(rpc, address4, config) {
|
|
3911
|
+
const maybeAccount = await fetchMaybeMarket(rpc, address4, config);
|
|
3739
3912
|
assertAccountExists(maybeAccount);
|
|
3740
3913
|
return maybeAccount;
|
|
3741
3914
|
}
|
|
3742
|
-
async function fetchMaybeMarket(rpc,
|
|
3743
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3915
|
+
async function fetchMaybeMarket(rpc, address4, config) {
|
|
3916
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
3744
3917
|
return decodeMarket(maybeAccount);
|
|
3745
3918
|
}
|
|
3746
3919
|
async function fetchAllMarket(rpc, addresses, config) {
|
|
@@ -3806,13 +3979,13 @@ function decodeOracleState2(encodedAccount) {
|
|
|
3806
3979
|
getOracleStateDecoder()
|
|
3807
3980
|
);
|
|
3808
3981
|
}
|
|
3809
|
-
async function fetchOracleState(rpc,
|
|
3810
|
-
const maybeAccount = await fetchMaybeOracleState(rpc,
|
|
3982
|
+
async function fetchOracleState(rpc, address4, config) {
|
|
3983
|
+
const maybeAccount = await fetchMaybeOracleState(rpc, address4, config);
|
|
3811
3984
|
assertAccountExists(maybeAccount);
|
|
3812
3985
|
return maybeAccount;
|
|
3813
3986
|
}
|
|
3814
|
-
async function fetchMaybeOracleState(rpc,
|
|
3815
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3987
|
+
async function fetchMaybeOracleState(rpc, address4, config) {
|
|
3988
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
3816
3989
|
return decodeOracleState2(maybeAccount);
|
|
3817
3990
|
}
|
|
3818
3991
|
async function fetchAllOracleState(rpc, addresses, config) {
|
|
@@ -5153,6 +5326,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
|
|
|
5153
5326
|
const withMetadata = Boolean(
|
|
5154
5327
|
args.metadataName && args.metadataName.length > 0
|
|
5155
5328
|
);
|
|
5329
|
+
const withToken2022Metadata = withMetadata && baseTokenProgram === TOKEN_2022_PROGRAM_ADDRESS;
|
|
5156
5330
|
if (withMetadata && !metadataAccount) {
|
|
5157
5331
|
throw new Error(
|
|
5158
5332
|
"metadataName is set but metadataAccount was not provided. Derive it with await initializer.getTokenMetadataAddress(baseMintAddress)."
|
|
@@ -5212,6 +5386,12 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
|
|
|
5212
5386
|
const data = new Uint8Array(
|
|
5213
5387
|
getInitializeLaunchInstructionDataEncoder().encode(encoderArgs)
|
|
5214
5388
|
);
|
|
5389
|
+
if (withToken2022Metadata) {
|
|
5390
|
+
keys.push({
|
|
5391
|
+
address: SYSVAR_INSTRUCTIONS_ADDRESS,
|
|
5392
|
+
role: AccountRole.READONLY
|
|
5393
|
+
});
|
|
5394
|
+
}
|
|
5215
5395
|
keys.push(
|
|
5216
5396
|
...hookCreateRemainingAccounts.map(
|
|
5217
5397
|
(account) => createAccountMeta(
|
|
@@ -5437,213 +5617,6 @@ function createPreviewMigrationInstruction(accounts, programId = INITIALIZER_PRO
|
|
|
5437
5617
|
function decodePreviewMigrationResult(data) {
|
|
5438
5618
|
return previewMigrationResultCodec.decode(data);
|
|
5439
5619
|
}
|
|
5440
|
-
var DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND = 20;
|
|
5441
|
-
function getInstructionLookupTableAddresses(instructions) {
|
|
5442
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5443
|
-
const addresses = [];
|
|
5444
|
-
for (const instruction of Array.isArray(instructions) ? instructions : [instructions]) {
|
|
5445
|
-
for (const account of instruction.accounts ?? []) {
|
|
5446
|
-
if ("signer" in account || account.role === AccountRole.READONLY_SIGNER || account.role === AccountRole.WRITABLE_SIGNER) {
|
|
5447
|
-
continue;
|
|
5448
|
-
}
|
|
5449
|
-
if (!seen.has(account.address)) {
|
|
5450
|
-
seen.add(account.address);
|
|
5451
|
-
addresses.push(account.address);
|
|
5452
|
-
}
|
|
5453
|
-
}
|
|
5454
|
-
}
|
|
5455
|
-
return addresses;
|
|
5456
|
-
}
|
|
5457
|
-
async function buildAddressLookupTableSetupInstructions({
|
|
5458
|
-
authority,
|
|
5459
|
-
payer,
|
|
5460
|
-
recentSlot,
|
|
5461
|
-
addresses,
|
|
5462
|
-
addressesPerExtendInstruction = DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND
|
|
5463
|
-
}) {
|
|
5464
|
-
if (addressesPerExtendInstruction <= 0) {
|
|
5465
|
-
throw new Error("addressesPerExtendInstruction must be greater than zero");
|
|
5466
|
-
}
|
|
5467
|
-
const dedupedAddresses = [...new Set(addresses)];
|
|
5468
|
-
const lookupTablePda = await findAddressLookupTablePda({
|
|
5469
|
-
authority: authority.address,
|
|
5470
|
-
recentSlot
|
|
5471
|
-
});
|
|
5472
|
-
const [lookupTableAddress] = lookupTablePda;
|
|
5473
|
-
const createInstruction = getCreateLookupTableInstruction({
|
|
5474
|
-
address: lookupTablePda,
|
|
5475
|
-
authority: authority.address,
|
|
5476
|
-
payer,
|
|
5477
|
-
recentSlot
|
|
5478
|
-
});
|
|
5479
|
-
const extendInstructions = [];
|
|
5480
|
-
for (let start = 0; start < dedupedAddresses.length; start += addressesPerExtendInstruction) {
|
|
5481
|
-
extendInstructions.push(
|
|
5482
|
-
getExtendLookupTableInstruction({
|
|
5483
|
-
address: lookupTableAddress,
|
|
5484
|
-
authority,
|
|
5485
|
-
payer,
|
|
5486
|
-
addresses: dedupedAddresses.slice(
|
|
5487
|
-
start,
|
|
5488
|
-
start + addressesPerExtendInstruction
|
|
5489
|
-
)
|
|
5490
|
-
})
|
|
5491
|
-
);
|
|
5492
|
-
}
|
|
5493
|
-
return {
|
|
5494
|
-
lookupTableAddress,
|
|
5495
|
-
createInstruction,
|
|
5496
|
-
extendInstructions,
|
|
5497
|
-
addresses: dedupedAddresses
|
|
5498
|
-
};
|
|
5499
|
-
}
|
|
5500
|
-
function compressTransactionMessageWithLookupTable(transactionMessage, {
|
|
5501
|
-
lookupTableAddress,
|
|
5502
|
-
addresses
|
|
5503
|
-
}) {
|
|
5504
|
-
return compressTransactionMessageUsingAddressLookupTables(
|
|
5505
|
-
transactionMessage,
|
|
5506
|
-
{
|
|
5507
|
-
[lookupTableAddress]: [...addresses]
|
|
5508
|
-
}
|
|
5509
|
-
);
|
|
5510
|
-
}
|
|
5511
|
-
var SOLANA_TRANSACTION_SIZE_LIMIT = 1232;
|
|
5512
|
-
function measureTransactionMessageSize(transactionMessage) {
|
|
5513
|
-
const size = getTransactionMessageSize(transactionMessage);
|
|
5514
|
-
const overBy = Math.max(0, size - SOLANA_TRANSACTION_SIZE_LIMIT);
|
|
5515
|
-
return {
|
|
5516
|
-
size,
|
|
5517
|
-
limit: SOLANA_TRANSACTION_SIZE_LIMIT,
|
|
5518
|
-
overBy,
|
|
5519
|
-
fits: overBy === 0
|
|
5520
|
-
};
|
|
5521
|
-
}
|
|
5522
|
-
function measureTransactionMessageSizeWithLookupTable(transactionMessage, lookupTable) {
|
|
5523
|
-
return measureTransactionMessageSize(
|
|
5524
|
-
compressTransactionMessageWithLookupTable(transactionMessage, lookupTable)
|
|
5525
|
-
);
|
|
5526
|
-
}
|
|
5527
|
-
function assertTransactionMessageFits(transactionMessage, { label = "Transaction", metadataBytes } = {}) {
|
|
5528
|
-
const report = measureTransactionMessageSize(transactionMessage);
|
|
5529
|
-
if (report.fits) {
|
|
5530
|
-
return report;
|
|
5531
|
-
}
|
|
5532
|
-
const metadataHint = metadataBytes && metadataBytes > 0 ? ` Metadata contributes ${metadataBytes} instruction-data bytes; address lookup tables do not compress metadata strings.` : "";
|
|
5533
|
-
throw new Error(
|
|
5534
|
-
`${label} is ${report.size} bytes, exceeding Solana's ${report.limit}-byte transaction limit by ${report.overBy} bytes.${metadataHint}`
|
|
5535
|
-
);
|
|
5536
|
-
}
|
|
5537
|
-
function assertTransactionMessageFitsWithLookupTable(transactionMessage, lookupTable, options = {}) {
|
|
5538
|
-
const compressedMessage = compressTransactionMessageWithLookupTable(
|
|
5539
|
-
transactionMessage,
|
|
5540
|
-
lookupTable
|
|
5541
|
-
);
|
|
5542
|
-
return assertTransactionMessageFits(compressedMessage, options);
|
|
5543
|
-
}
|
|
5544
|
-
var addressCodec5 = getAddressCodec();
|
|
5545
|
-
function bytesToBase64(bytes) {
|
|
5546
|
-
let binary = "";
|
|
5547
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
5548
|
-
binary += String.fromCharCode(bytes[i]);
|
|
5549
|
-
}
|
|
5550
|
-
return btoa(binary);
|
|
5551
|
-
}
|
|
5552
|
-
function base64ToBytes2(base64) {
|
|
5553
|
-
const binary = atob(base64);
|
|
5554
|
-
const bytes = new Uint8Array(binary.length);
|
|
5555
|
-
for (let i = 0; i < binary.length; i++) {
|
|
5556
|
-
bytes[i] = binary.charCodeAt(i);
|
|
5557
|
-
}
|
|
5558
|
-
return bytes;
|
|
5559
|
-
}
|
|
5560
|
-
async function fetchLaunch2(rpc, address3, config) {
|
|
5561
|
-
const response = await rpc.getAccountInfo(address3, {
|
|
5562
|
-
encoding: "base64",
|
|
5563
|
-
commitment: config?.commitment
|
|
5564
|
-
}).send();
|
|
5565
|
-
if (!response.value) {
|
|
5566
|
-
return null;
|
|
5567
|
-
}
|
|
5568
|
-
return getLaunchDecoder().decode(base64ToBytes2(response.value.data[0]));
|
|
5569
|
-
}
|
|
5570
|
-
async function fetchAllLaunches(rpc, config) {
|
|
5571
|
-
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
5572
|
-
const discriminatorFilter = {
|
|
5573
|
-
memcmp: {
|
|
5574
|
-
offset: 0n,
|
|
5575
|
-
bytes: bytesToBase64(
|
|
5576
|
-
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
5577
|
-
),
|
|
5578
|
-
encoding: "base64"
|
|
5579
|
-
}
|
|
5580
|
-
};
|
|
5581
|
-
const response = await rpc.getProgramAccounts(programId, {
|
|
5582
|
-
encoding: "base64",
|
|
5583
|
-
commitment: config?.commitment,
|
|
5584
|
-
filters: [discriminatorFilter]
|
|
5585
|
-
}).send();
|
|
5586
|
-
const accounts = Array.isArray(response) ? response : response.value;
|
|
5587
|
-
const launches = [];
|
|
5588
|
-
const decoder = getLaunchDecoder();
|
|
5589
|
-
for (const account of accounts) {
|
|
5590
|
-
try {
|
|
5591
|
-
const launch = decoder.decode(base64ToBytes2(account.account.data[0]));
|
|
5592
|
-
launches.push({ address: account.pubkey, account: launch });
|
|
5593
|
-
} catch {
|
|
5594
|
-
console.warn(`Failed to decode launch account: ${account.pubkey}`);
|
|
5595
|
-
}
|
|
5596
|
-
}
|
|
5597
|
-
return launches;
|
|
5598
|
-
}
|
|
5599
|
-
async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
5600
|
-
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
5601
|
-
const discriminatorFilter = {
|
|
5602
|
-
memcmp: {
|
|
5603
|
-
offset: 0n,
|
|
5604
|
-
bytes: bytesToBase64(
|
|
5605
|
-
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
5606
|
-
),
|
|
5607
|
-
encoding: "base64"
|
|
5608
|
-
}
|
|
5609
|
-
};
|
|
5610
|
-
const authorityFilter = {
|
|
5611
|
-
memcmp: {
|
|
5612
|
-
offset: 8n,
|
|
5613
|
-
bytes: bytesToBase64(
|
|
5614
|
-
addressCodec5.encode(authority)
|
|
5615
|
-
),
|
|
5616
|
-
encoding: "base64"
|
|
5617
|
-
}
|
|
5618
|
-
};
|
|
5619
|
-
const response = await rpc.getProgramAccounts(programId, {
|
|
5620
|
-
encoding: "base64",
|
|
5621
|
-
commitment: config?.commitment,
|
|
5622
|
-
filters: [discriminatorFilter, authorityFilter]
|
|
5623
|
-
}).send();
|
|
5624
|
-
const accounts = Array.isArray(response) ? response : response.value;
|
|
5625
|
-
const launches = [];
|
|
5626
|
-
const decoder = getLaunchDecoder();
|
|
5627
|
-
for (const account of accounts) {
|
|
5628
|
-
try {
|
|
5629
|
-
const launch = decoder.decode(base64ToBytes2(account.account.data[0]));
|
|
5630
|
-
launches.push({ address: account.pubkey, account: launch });
|
|
5631
|
-
} catch {
|
|
5632
|
-
console.warn(`Failed to decode launch account: ${account.pubkey}`);
|
|
5633
|
-
}
|
|
5634
|
-
}
|
|
5635
|
-
return launches;
|
|
5636
|
-
}
|
|
5637
|
-
async function launchExists(rpc, namespace, launchId, config) {
|
|
5638
|
-
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
5639
|
-
const [launchAddress] = await getLaunchAddress(
|
|
5640
|
-
namespace,
|
|
5641
|
-
launchId,
|
|
5642
|
-
programId
|
|
5643
|
-
);
|
|
5644
|
-
const launch = await fetchLaunch2(rpc, launchAddress, config);
|
|
5645
|
-
return launch !== null;
|
|
5646
|
-
}
|
|
5647
5620
|
|
|
5648
5621
|
// src/solana/migrators/cpmmMigrator/index.ts
|
|
5649
5622
|
var cpmmMigrator_exports = {};
|
|
@@ -5812,7 +5785,7 @@ function getCpmmMigratorStateCodec() {
|
|
|
5812
5785
|
if (process.env.NODE_ENV !== "production") ;
|
|
5813
5786
|
|
|
5814
5787
|
// src/solana/migrators/cpmmMigrator/client.ts
|
|
5815
|
-
function
|
|
5788
|
+
function base64ToBytes2(base64) {
|
|
5816
5789
|
const binary = atob(base64);
|
|
5817
5790
|
const bytes = new Uint8Array(binary.length);
|
|
5818
5791
|
for (let i = 0; i < binary.length; i++) {
|
|
@@ -5820,11 +5793,11 @@ function base64ToBytes3(base64) {
|
|
|
5820
5793
|
}
|
|
5821
5794
|
return bytes;
|
|
5822
5795
|
}
|
|
5823
|
-
async function fetchCpmmMigratorState(rpc,
|
|
5824
|
-
const response = await rpc.getAccountInfo(
|
|
5796
|
+
async function fetchCpmmMigratorState(rpc, address4) {
|
|
5797
|
+
const response = await rpc.getAccountInfo(address4, { encoding: "base64" }).send();
|
|
5825
5798
|
if (!response.value) return null;
|
|
5826
5799
|
return getCpmmMigratorStateDecoder().decode(
|
|
5827
|
-
|
|
5800
|
+
base64ToBytes2(response.value.data[0])
|
|
5828
5801
|
);
|
|
5829
5802
|
}
|
|
5830
5803
|
async function buildCpmmMigrationRemainingAccounts({
|
|
@@ -5884,13 +5857,16 @@ async function buildCpmmMigrationRemainingAccounts({
|
|
|
5884
5857
|
{ address: migrationAuthority, role: AccountRole.READONLY },
|
|
5885
5858
|
{ address: adminBaseAta, role: AccountRole.WRITABLE },
|
|
5886
5859
|
{ address: adminQuoteAta, role: AccountRole.WRITABLE },
|
|
5887
|
-
...recipientAtas.map((
|
|
5888
|
-
address:
|
|
5860
|
+
...recipientAtas.map((address4) => ({
|
|
5861
|
+
address: address4,
|
|
5889
5862
|
role: AccountRole.WRITABLE
|
|
5890
5863
|
}))
|
|
5891
5864
|
],
|
|
5892
5865
|
cpmmMigrationState,
|
|
5893
5866
|
cpmmConfig: poolInit.config[0],
|
|
5867
|
+
adminBaseAta,
|
|
5868
|
+
adminQuoteAta,
|
|
5869
|
+
recipientAtas,
|
|
5894
5870
|
pool,
|
|
5895
5871
|
poolAuthority: poolInit.authority[0],
|
|
5896
5872
|
poolVault0: poolInit.vault0[0],
|
|
@@ -5921,6 +5897,590 @@ function encodeMigratePayload(args) {
|
|
|
5921
5897
|
]);
|
|
5922
5898
|
}
|
|
5923
5899
|
|
|
5900
|
+
// src/solana/initializer/createLaunch.ts
|
|
5901
|
+
var DEFAULT_CPMM_MIGRATION_FEE_SPLIT_BPS = 1e4;
|
|
5902
|
+
var launchIdCounter = 0n;
|
|
5903
|
+
var launchTokenPrograms = {
|
|
5904
|
+
splToken() {
|
|
5905
|
+
return {
|
|
5906
|
+
baseTokenProgram: TOKEN_PROGRAM_ADDRESS,
|
|
5907
|
+
quoteTokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
5908
|
+
};
|
|
5909
|
+
},
|
|
5910
|
+
token2022Base() {
|
|
5911
|
+
return {
|
|
5912
|
+
baseTokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
|
|
5913
|
+
quoteTokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
5914
|
+
};
|
|
5915
|
+
}
|
|
5916
|
+
};
|
|
5917
|
+
function createLaunchId() {
|
|
5918
|
+
const bytes = new Uint8Array(32);
|
|
5919
|
+
const view = new DataView(bytes.buffer);
|
|
5920
|
+
view.setBigUint64(0, BigInt(Date.now()), true);
|
|
5921
|
+
view.setBigUint64(8, launchIdCounter, true);
|
|
5922
|
+
launchIdCounter += 1n;
|
|
5923
|
+
bytes.set([68, 79, 80, 76], 28);
|
|
5924
|
+
return bytes;
|
|
5925
|
+
}
|
|
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
|
+
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;
|
|
5950
|
+
}
|
|
5951
|
+
function hasMetadata(metadata) {
|
|
5952
|
+
return Boolean(metadata?.metadataName);
|
|
5953
|
+
}
|
|
5954
|
+
function getInitializerProgramId(input) {
|
|
5955
|
+
return input.programId ?? input.deployment?.initializerProgram ?? INITIALIZER_PROGRAM_ID;
|
|
5956
|
+
}
|
|
5957
|
+
function getInitializerConfig(input) {
|
|
5958
|
+
return input.config ?? input.deployment?.initializerConfig;
|
|
5959
|
+
}
|
|
5960
|
+
function hashRemainingAccounts(accounts) {
|
|
5961
|
+
if (!accounts) {
|
|
5962
|
+
return void 0;
|
|
5963
|
+
}
|
|
5964
|
+
return computeRemainingAccountsHash(accounts.map(getAccountAddress));
|
|
5965
|
+
}
|
|
5966
|
+
function isCustomMigrationConfig(migration) {
|
|
5967
|
+
return migration.kind === "custom";
|
|
5968
|
+
}
|
|
5969
|
+
function getCreateLaunchHookMode(input) {
|
|
5970
|
+
if (input.hook !== void 0 && input.hook !== null) {
|
|
5971
|
+
return input.hook;
|
|
5972
|
+
}
|
|
5973
|
+
return input.cosigner ? "cosigner" : "cpmm";
|
|
5974
|
+
}
|
|
5975
|
+
async function getCreateLaunchHookContext(input) {
|
|
5976
|
+
const mode = getCreateLaunchHookMode(input);
|
|
5977
|
+
if (mode !== "cosigner") {
|
|
5978
|
+
return { mode };
|
|
5979
|
+
}
|
|
5980
|
+
const [cosignerConfig] = await getCosignerHookConfigAddress(
|
|
5981
|
+
input.deployment?.cosignerHookProgram ?? DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID
|
|
5982
|
+
);
|
|
5983
|
+
return { mode, cosignerConfig };
|
|
5984
|
+
}
|
|
5985
|
+
function getCosignerHookRemainingAccounts2({
|
|
5986
|
+
namespace,
|
|
5987
|
+
cosigner,
|
|
5988
|
+
cosignerConfig
|
|
5989
|
+
}) {
|
|
5990
|
+
const accounts = namespace === cosignerConfig ? [cosignerConfig] : [namespace, cosignerConfig];
|
|
5991
|
+
accounts.push(cosigner);
|
|
5992
|
+
return accounts;
|
|
5993
|
+
}
|
|
5994
|
+
function resolveCosignerHookPayload(input) {
|
|
5995
|
+
if (input.cosignGateExpiresAt === void 0 || input.cosignGateExpiresAt === null) {
|
|
5996
|
+
return new Uint8Array();
|
|
5997
|
+
}
|
|
5998
|
+
if (!input.cosigner) {
|
|
5999
|
+
throw new Error("cosigner is required when cosignGateExpiresAt is set");
|
|
6000
|
+
}
|
|
6001
|
+
return encodeCosignerGateExpiryPayload({
|
|
6002
|
+
mode: GATE_EXPIRY_UNIX_TIMESTAMP,
|
|
6003
|
+
value: input.cosignGateExpiresAt,
|
|
6004
|
+
cosigner: getSignerAddress(input.cosigner)
|
|
6005
|
+
});
|
|
6006
|
+
}
|
|
6007
|
+
function resolveCreateLaunchHook({
|
|
6008
|
+
input,
|
|
6009
|
+
namespace,
|
|
6010
|
+
hookContext
|
|
6011
|
+
}) {
|
|
6012
|
+
if (hookContext.mode === false) {
|
|
6013
|
+
return {
|
|
6014
|
+
flags: 0,
|
|
6015
|
+
remainingAccountsHash: EMPTY_REMAINING_ACCOUNTS_HASH
|
|
6016
|
+
};
|
|
6017
|
+
}
|
|
6018
|
+
if (hookContext.mode === "cosigner") {
|
|
6019
|
+
if (!input.cosigner) {
|
|
6020
|
+
throw new Error('cosigner is required when hook is "cosigner"');
|
|
6021
|
+
}
|
|
6022
|
+
if (!hookContext.cosignerConfig) {
|
|
6023
|
+
throw new Error("cosigner hook config could not be derived");
|
|
6024
|
+
}
|
|
6025
|
+
const remainingAccounts = getCosignerHookRemainingAccounts2({
|
|
6026
|
+
namespace,
|
|
6027
|
+
cosigner: input.cosigner,
|
|
6028
|
+
cosignerConfig: hookContext.cosignerConfig
|
|
6029
|
+
});
|
|
6030
|
+
return {
|
|
6031
|
+
program: input.deployment?.cosignerHookProgram ?? DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID,
|
|
6032
|
+
flags: HF_BEFORE_SWAP2 | HF_FORWARD_READONLY_SIGNERS2,
|
|
6033
|
+
payload: resolveCosignerHookPayload(input),
|
|
6034
|
+
remainingAccounts,
|
|
6035
|
+
remainingAccountsHash: hashRemainingAccounts(remainingAccounts) ?? EMPTY_REMAINING_ACCOUNTS_HASH
|
|
6036
|
+
};
|
|
6037
|
+
}
|
|
6038
|
+
return {
|
|
6039
|
+
program: input.deployment?.cpmmHookProgram ?? CPMM_HOOK_PROGRAM_ID,
|
|
6040
|
+
flags: HF_BEFORE_SWAP2,
|
|
6041
|
+
payload: new Uint8Array(),
|
|
6042
|
+
remainingAccountsHash: EMPTY_REMAINING_ACCOUNTS_HASH
|
|
6043
|
+
};
|
|
6044
|
+
}
|
|
6045
|
+
async function getAssociatedTokenAddress({
|
|
6046
|
+
owner,
|
|
6047
|
+
mint,
|
|
6048
|
+
tokenProgram
|
|
6049
|
+
}) {
|
|
6050
|
+
const [ata] = await findAssociatedTokenPda({
|
|
6051
|
+
owner,
|
|
6052
|
+
mint,
|
|
6053
|
+
tokenProgram
|
|
6054
|
+
});
|
|
6055
|
+
return ata;
|
|
6056
|
+
}
|
|
6057
|
+
async function resolveCreateLaunchMigration({
|
|
6058
|
+
addresses,
|
|
6059
|
+
input,
|
|
6060
|
+
tokenPrograms
|
|
6061
|
+
}) {
|
|
6062
|
+
const migration = input.migration === void 0 ? true : input.migration;
|
|
6063
|
+
if (migration === false || migration === null) {
|
|
6064
|
+
return null;
|
|
6065
|
+
}
|
|
6066
|
+
const cpmmMigratorProgram = input.deployment?.cpmmMigratorProgram ?? CPMM_MIGRATOR_PROGRAM_ID;
|
|
6067
|
+
if (migration !== true && isCustomMigrationConfig(migration)) {
|
|
6068
|
+
if (!migration.program) {
|
|
6069
|
+
throw new Error("custom launch migration requires a migrator program");
|
|
6070
|
+
}
|
|
6071
|
+
return migration;
|
|
6072
|
+
}
|
|
6073
|
+
const cpmmMigration = migration === true ? {} : migration;
|
|
6074
|
+
const admin = cpmmMigration.admin ?? getSignerAddress(input.payer);
|
|
6075
|
+
const baseMint = getSignerAddress(input.launchAccounts.baseMint);
|
|
6076
|
+
const adminBaseAta = cpmmMigration.adminBaseAta ?? await getAssociatedTokenAddress({
|
|
6077
|
+
owner: admin,
|
|
6078
|
+
mint: baseMint,
|
|
6079
|
+
tokenProgram: tokenPrograms.baseTokenProgram
|
|
6080
|
+
});
|
|
6081
|
+
const adminQuoteAta = cpmmMigration.adminQuoteAta ?? await getAssociatedTokenAddress({
|
|
6082
|
+
owner: admin,
|
|
6083
|
+
mint: input.launchAccounts.quoteMint,
|
|
6084
|
+
tokenProgram: tokenPrograms.quoteTokenProgram
|
|
6085
|
+
});
|
|
6086
|
+
const recipients = [...cpmmMigration.recipients ?? []];
|
|
6087
|
+
const recipientAtas = cpmmMigration.recipientAtas ?? await Promise.all(
|
|
6088
|
+
recipients.map(
|
|
6089
|
+
({ wallet }) => getAssociatedTokenAddress({
|
|
6090
|
+
owner: wallet,
|
|
6091
|
+
mint: baseMint,
|
|
6092
|
+
tokenProgram: tokenPrograms.baseTokenProgram
|
|
6093
|
+
})
|
|
6094
|
+
)
|
|
6095
|
+
);
|
|
6096
|
+
const migrationAccounts = await buildCpmmMigrationRemainingAccounts({
|
|
6097
|
+
launch: addresses.launch,
|
|
6098
|
+
baseMint,
|
|
6099
|
+
quoteMint: input.launchAccounts.quoteMint,
|
|
6100
|
+
launchAuthority: addresses.launchAuthority,
|
|
6101
|
+
adminBaseAta,
|
|
6102
|
+
adminQuoteAta,
|
|
6103
|
+
recipientAtas: [...recipientAtas],
|
|
6104
|
+
cpmmProgram: cpmmMigration.cpmmProgram ?? input.deployment?.cpmmProgram,
|
|
6105
|
+
cpmmMigratorProgram: cpmmMigration.program ?? cpmmMigratorProgram
|
|
6106
|
+
});
|
|
6107
|
+
const initPayload = encodeRegisterLaunchPayload({
|
|
6108
|
+
cpmmConfig: migrationAccounts.cpmmConfig,
|
|
6109
|
+
initialSwapFeeBps: cpmmMigration.initialSwapFeeBps ?? input.curve.swapFeeBps,
|
|
6110
|
+
initialFeeSplitBps: cpmmMigration.initialFeeSplitBps ?? DEFAULT_CPMM_MIGRATION_FEE_SPLIT_BPS,
|
|
6111
|
+
recipients,
|
|
6112
|
+
minRaiseQuote: cpmmMigration.minRaiseQuote ?? 0n,
|
|
6113
|
+
minMigrationPriceQ64Opt: cpmmMigration.minMigrationPriceQ64Opt ?? null,
|
|
6114
|
+
migratedPoolHookConfig: cpmmMigration.migratedPoolHookConfig ?? null
|
|
6115
|
+
});
|
|
6116
|
+
const migratePayload = encodeMigratePayload({
|
|
6117
|
+
baseForDistribution: cpmmMigration.baseForDistribution ?? input.supply.baseForDistribution,
|
|
6118
|
+
baseForLiquidity: cpmmMigration.baseForLiquidity ?? input.supply.baseForLiquidity
|
|
6119
|
+
});
|
|
6120
|
+
return {
|
|
6121
|
+
program: cpmmMigration.program ?? cpmmMigratorProgram,
|
|
6122
|
+
initPayload,
|
|
6123
|
+
migratePayload,
|
|
6124
|
+
cpmmConfig: migrationAccounts.cpmmConfig,
|
|
6125
|
+
remainingAccounts: migrationAccounts.addresses,
|
|
6126
|
+
remainingAccountsHash: migrationAccounts.hash,
|
|
6127
|
+
cpmmMigration: migrationAccounts
|
|
6128
|
+
};
|
|
6129
|
+
}
|
|
6130
|
+
async function deriveCreateLaunchAddresses(input) {
|
|
6131
|
+
const programId = input.programId ?? input.deployment?.initializerProgram ?? INITIALIZER_PROGRAM_ID;
|
|
6132
|
+
const config = input.config ?? input.deployment?.initializerConfig ?? (await getConfigAddress2(programId))[0];
|
|
6133
|
+
const [launch] = await getLaunchAddress(
|
|
6134
|
+
input.namespace,
|
|
6135
|
+
input.launchId,
|
|
6136
|
+
programId
|
|
6137
|
+
);
|
|
6138
|
+
const [launchAuthority] = await getLaunchAuthorityAddress(launch, programId);
|
|
6139
|
+
const [launchFeeState] = await getLaunchFeeStateAddress(launch, programId);
|
|
6140
|
+
const metadataAccount = hasMetadata(input.metadata) ? input.metadataAccount ?? await getTokenMetadataAddress(getSignerAddress(input.baseMint)) : input.metadataAccount;
|
|
6141
|
+
return {
|
|
6142
|
+
config,
|
|
6143
|
+
launch,
|
|
6144
|
+
launchAuthority,
|
|
6145
|
+
launchFeeState,
|
|
6146
|
+
metadataAccount
|
|
6147
|
+
};
|
|
6148
|
+
}
|
|
6149
|
+
async function getMigrationInitRemainingAccountsHash({
|
|
6150
|
+
launch,
|
|
6151
|
+
migration
|
|
6152
|
+
}) {
|
|
6153
|
+
if (!migration) {
|
|
6154
|
+
return EMPTY_REMAINING_ACCOUNTS_HASH;
|
|
6155
|
+
}
|
|
6156
|
+
if (migration.initRemainingAccountsHash) {
|
|
6157
|
+
return migration.initRemainingAccountsHash;
|
|
6158
|
+
}
|
|
6159
|
+
const initHash = hashRemainingAccounts(migration.initRemainingAccounts);
|
|
6160
|
+
if (initHash) {
|
|
6161
|
+
return initHash;
|
|
6162
|
+
}
|
|
6163
|
+
if (migration.cpmmConfig) {
|
|
6164
|
+
const migratorProgram = migration.program ?? CPMM_MIGRATOR_PROGRAM_ID;
|
|
6165
|
+
const [cpmmMigrationState] = await getCpmmMigratorStateAddress(
|
|
6166
|
+
launch,
|
|
6167
|
+
migratorProgram
|
|
6168
|
+
);
|
|
6169
|
+
return computeRemainingAccountsHash([
|
|
6170
|
+
cpmmMigrationState,
|
|
6171
|
+
migration.cpmmConfig
|
|
6172
|
+
]);
|
|
6173
|
+
}
|
|
6174
|
+
return EMPTY_REMAINING_ACCOUNTS_HASH;
|
|
6175
|
+
}
|
|
6176
|
+
async function createLaunch(input) {
|
|
6177
|
+
const programId = getInitializerProgramId(input);
|
|
6178
|
+
const launchId = input.launchId ?? createLaunchId();
|
|
6179
|
+
const hookContext = await getCreateLaunchHookContext(input);
|
|
6180
|
+
const namespace = input.namespace ?? hookContext.cosignerConfig ?? getSignerAddress(input.payer);
|
|
6181
|
+
const tokenPrograms = {
|
|
6182
|
+
...launchTokenPrograms.splToken(),
|
|
6183
|
+
...input.tokenPrograms
|
|
6184
|
+
};
|
|
6185
|
+
const addresses = input.addresses ?? await deriveCreateLaunchAddresses({
|
|
6186
|
+
deployment: input.deployment,
|
|
6187
|
+
programId,
|
|
6188
|
+
config: getInitializerConfig(input),
|
|
6189
|
+
namespace,
|
|
6190
|
+
launchId,
|
|
6191
|
+
baseMint: input.launchAccounts.baseMint,
|
|
6192
|
+
metadata: input.metadata
|
|
6193
|
+
});
|
|
6194
|
+
const migration = await resolveCreateLaunchMigration({
|
|
6195
|
+
addresses,
|
|
6196
|
+
input,
|
|
6197
|
+
tokenPrograms
|
|
6198
|
+
});
|
|
6199
|
+
const hook = resolveCreateLaunchHook({
|
|
6200
|
+
input,
|
|
6201
|
+
namespace,
|
|
6202
|
+
hookContext
|
|
6203
|
+
});
|
|
6204
|
+
const migratorInitRemainingAccountsHash = await getMigrationInitRemainingAccountsHash({
|
|
6205
|
+
launch: addresses.launch,
|
|
6206
|
+
migration
|
|
6207
|
+
});
|
|
6208
|
+
const migratorRemainingAccountsHash = migration?.remainingAccountsHash ?? hashRemainingAccounts(migration?.remainingAccounts) ?? EMPTY_REMAINING_ACCOUNTS_HASH;
|
|
6209
|
+
const instruction = await createInitializeLaunchInstruction(
|
|
6210
|
+
{
|
|
6211
|
+
config: addresses.config,
|
|
6212
|
+
launch: addresses.launch,
|
|
6213
|
+
launchAuthority: addresses.launchAuthority,
|
|
6214
|
+
baseMint: input.launchAccounts.baseMint,
|
|
6215
|
+
quoteMint: input.launchAccounts.quoteMint,
|
|
6216
|
+
baseVault: input.launchAccounts.baseVault,
|
|
6217
|
+
quoteVault: input.launchAccounts.quoteVault,
|
|
6218
|
+
launchFeeState: addresses.launchFeeState,
|
|
6219
|
+
payer: input.payer,
|
|
6220
|
+
authority: input.authority,
|
|
6221
|
+
hookProgram: hook.program,
|
|
6222
|
+
migratorProgram: migration?.program,
|
|
6223
|
+
cpmmConfig: migration?.cpmmConfig,
|
|
6224
|
+
baseTokenProgram: tokenPrograms.baseTokenProgram,
|
|
6225
|
+
quoteTokenProgram: tokenPrograms.quoteTokenProgram,
|
|
6226
|
+
systemProgram: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS,
|
|
6227
|
+
rent: input.rent ?? SYSVAR_RENT_ADDRESS,
|
|
6228
|
+
metadataAccount: addresses.metadataAccount,
|
|
6229
|
+
metadataProgram: input.metadataProgram ?? TOKEN_METADATA_PROGRAM_ID
|
|
6230
|
+
},
|
|
6231
|
+
{
|
|
6232
|
+
namespace,
|
|
6233
|
+
launchId,
|
|
6234
|
+
baseDecimals: input.supply.baseDecimals,
|
|
6235
|
+
baseTotalSupply: input.supply.baseTotalSupply,
|
|
6236
|
+
baseForDistribution: input.supply.baseForDistribution,
|
|
6237
|
+
baseForLiquidity: input.supply.baseForLiquidity,
|
|
6238
|
+
curveVirtualBase: input.curve.curveVirtualBase,
|
|
6239
|
+
curveVirtualQuote: input.curve.curveVirtualQuote,
|
|
6240
|
+
swapFeeBps: input.curve.swapFeeBps,
|
|
6241
|
+
curveKind: CURVE_KIND_XYK,
|
|
6242
|
+
curveParams: new Uint8Array([CURVE_PARAMS_FORMAT_XYK_V0]),
|
|
6243
|
+
allowBuy: input.allowBuy ?? true,
|
|
6244
|
+
allowSell: input.allowSell ?? true,
|
|
6245
|
+
hookFlags: hook.flags,
|
|
6246
|
+
hookPayload: hook.payload ?? new Uint8Array(),
|
|
6247
|
+
migratorInitPayload: migration?.initPayload ?? new Uint8Array(),
|
|
6248
|
+
migratorMigratePayload: migration?.migratePayload ?? new Uint8Array(),
|
|
6249
|
+
hookRemainingAccountsHash: hook.remainingAccountsHash,
|
|
6250
|
+
migratorInitRemainingAccountsHash,
|
|
6251
|
+
migratorRemainingAccountsHash,
|
|
6252
|
+
feeBeneficiaries: input.feeBeneficiaries ?? [],
|
|
6253
|
+
metadataName: input.metadata?.metadataName ?? "",
|
|
6254
|
+
metadataSymbol: input.metadata?.metadataSymbol ?? "",
|
|
6255
|
+
metadataUri: input.metadata?.metadataUri ?? ""
|
|
6256
|
+
},
|
|
6257
|
+
programId
|
|
6258
|
+
);
|
|
6259
|
+
const preparedInstruction = migration?.initRemainingAccounts ? {
|
|
6260
|
+
...instruction,
|
|
6261
|
+
accounts: [
|
|
6262
|
+
...instruction.accounts ?? [],
|
|
6263
|
+
...(migration?.initRemainingAccounts ?? []).map(
|
|
6264
|
+
getRemainingAccountMeta
|
|
6265
|
+
)
|
|
6266
|
+
]
|
|
6267
|
+
} : instruction;
|
|
6268
|
+
return {
|
|
6269
|
+
namespace,
|
|
6270
|
+
launchId,
|
|
6271
|
+
addresses,
|
|
6272
|
+
instruction: preparedInstruction,
|
|
6273
|
+
cpmmMigration: migration?.cpmmMigration
|
|
6274
|
+
};
|
|
6275
|
+
}
|
|
6276
|
+
var DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND = 20;
|
|
6277
|
+
function getInstructionLookupTableAddresses(instructions) {
|
|
6278
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6279
|
+
const addresses = [];
|
|
6280
|
+
for (const instruction of Array.isArray(instructions) ? instructions : [instructions]) {
|
|
6281
|
+
for (const account of instruction.accounts ?? []) {
|
|
6282
|
+
if ("signer" in account || account.role === AccountRole.READONLY_SIGNER || account.role === AccountRole.WRITABLE_SIGNER) {
|
|
6283
|
+
continue;
|
|
6284
|
+
}
|
|
6285
|
+
if (!seen.has(account.address)) {
|
|
6286
|
+
seen.add(account.address);
|
|
6287
|
+
addresses.push(account.address);
|
|
6288
|
+
}
|
|
6289
|
+
}
|
|
6290
|
+
}
|
|
6291
|
+
return addresses;
|
|
6292
|
+
}
|
|
6293
|
+
async function buildAddressLookupTableSetupInstructions({
|
|
6294
|
+
authority,
|
|
6295
|
+
payer,
|
|
6296
|
+
recentSlot,
|
|
6297
|
+
addresses,
|
|
6298
|
+
addressesPerExtendInstruction = DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND
|
|
6299
|
+
}) {
|
|
6300
|
+
if (addressesPerExtendInstruction <= 0) {
|
|
6301
|
+
throw new Error("addressesPerExtendInstruction must be greater than zero");
|
|
6302
|
+
}
|
|
6303
|
+
const dedupedAddresses = [...new Set(addresses)];
|
|
6304
|
+
const lookupTablePda = await findAddressLookupTablePda({
|
|
6305
|
+
authority: authority.address,
|
|
6306
|
+
recentSlot
|
|
6307
|
+
});
|
|
6308
|
+
const [lookupTableAddress] = lookupTablePda;
|
|
6309
|
+
const createInstruction = getCreateLookupTableInstruction({
|
|
6310
|
+
address: lookupTablePda,
|
|
6311
|
+
authority: authority.address,
|
|
6312
|
+
payer,
|
|
6313
|
+
recentSlot
|
|
6314
|
+
});
|
|
6315
|
+
const extendInstructions = [];
|
|
6316
|
+
for (let start = 0; start < dedupedAddresses.length; start += addressesPerExtendInstruction) {
|
|
6317
|
+
extendInstructions.push(
|
|
6318
|
+
getExtendLookupTableInstruction({
|
|
6319
|
+
address: lookupTableAddress,
|
|
6320
|
+
authority,
|
|
6321
|
+
payer,
|
|
6322
|
+
addresses: dedupedAddresses.slice(
|
|
6323
|
+
start,
|
|
6324
|
+
start + addressesPerExtendInstruction
|
|
6325
|
+
)
|
|
6326
|
+
})
|
|
6327
|
+
);
|
|
6328
|
+
}
|
|
6329
|
+
return {
|
|
6330
|
+
lookupTableAddress,
|
|
6331
|
+
createInstruction,
|
|
6332
|
+
extendInstructions,
|
|
6333
|
+
addresses: dedupedAddresses
|
|
6334
|
+
};
|
|
6335
|
+
}
|
|
6336
|
+
function compressTransactionMessageWithLookupTable(transactionMessage, {
|
|
6337
|
+
lookupTableAddress,
|
|
6338
|
+
addresses
|
|
6339
|
+
}) {
|
|
6340
|
+
return compressTransactionMessageUsingAddressLookupTables(
|
|
6341
|
+
transactionMessage,
|
|
6342
|
+
{
|
|
6343
|
+
[lookupTableAddress]: [...addresses]
|
|
6344
|
+
}
|
|
6345
|
+
);
|
|
6346
|
+
}
|
|
6347
|
+
var SOLANA_TRANSACTION_SIZE_LIMIT = 1232;
|
|
6348
|
+
function measureTransactionMessageSize(transactionMessage) {
|
|
6349
|
+
const size = getTransactionMessageSize(transactionMessage);
|
|
6350
|
+
const overBy = Math.max(0, size - SOLANA_TRANSACTION_SIZE_LIMIT);
|
|
6351
|
+
return {
|
|
6352
|
+
size,
|
|
6353
|
+
limit: SOLANA_TRANSACTION_SIZE_LIMIT,
|
|
6354
|
+
overBy,
|
|
6355
|
+
fits: overBy === 0
|
|
6356
|
+
};
|
|
6357
|
+
}
|
|
6358
|
+
function measureTransactionMessageSizeWithLookupTable(transactionMessage, lookupTable) {
|
|
6359
|
+
return measureTransactionMessageSize(
|
|
6360
|
+
compressTransactionMessageWithLookupTable(transactionMessage, lookupTable)
|
|
6361
|
+
);
|
|
6362
|
+
}
|
|
6363
|
+
function assertTransactionMessageFits(transactionMessage, { label = "Transaction", metadataBytes } = {}) {
|
|
6364
|
+
const report = measureTransactionMessageSize(transactionMessage);
|
|
6365
|
+
if (report.fits) {
|
|
6366
|
+
return report;
|
|
6367
|
+
}
|
|
6368
|
+
const metadataHint = metadataBytes && metadataBytes > 0 ? ` Metadata contributes ${metadataBytes} instruction-data bytes; address lookup tables do not compress metadata strings.` : "";
|
|
6369
|
+
throw new Error(
|
|
6370
|
+
`${label} is ${report.size} bytes, exceeding Solana's ${report.limit}-byte transaction limit by ${report.overBy} bytes.${metadataHint}`
|
|
6371
|
+
);
|
|
6372
|
+
}
|
|
6373
|
+
function assertTransactionMessageFitsWithLookupTable(transactionMessage, lookupTable, options = {}) {
|
|
6374
|
+
const compressedMessage = compressTransactionMessageWithLookupTable(
|
|
6375
|
+
transactionMessage,
|
|
6376
|
+
lookupTable
|
|
6377
|
+
);
|
|
6378
|
+
return assertTransactionMessageFits(compressedMessage, options);
|
|
6379
|
+
}
|
|
6380
|
+
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, {
|
|
6398
|
+
encoding: "base64",
|
|
6399
|
+
commitment: config?.commitment
|
|
6400
|
+
}).send();
|
|
6401
|
+
if (!response.value) {
|
|
6402
|
+
return null;
|
|
6403
|
+
}
|
|
6404
|
+
return getLaunchDecoder().decode(base64ToBytes3(response.value.data[0]));
|
|
6405
|
+
}
|
|
6406
|
+
async function fetchAllLaunches(rpc, config) {
|
|
6407
|
+
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
6408
|
+
const discriminatorFilter = {
|
|
6409
|
+
memcmp: {
|
|
6410
|
+
offset: 0n,
|
|
6411
|
+
bytes: bytesToBase64(
|
|
6412
|
+
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
6413
|
+
),
|
|
6414
|
+
encoding: "base64"
|
|
6415
|
+
}
|
|
6416
|
+
};
|
|
6417
|
+
const response = await rpc.getProgramAccounts(programId, {
|
|
6418
|
+
encoding: "base64",
|
|
6419
|
+
commitment: config?.commitment,
|
|
6420
|
+
filters: [discriminatorFilter]
|
|
6421
|
+
}).send();
|
|
6422
|
+
const accounts = Array.isArray(response) ? response : response.value;
|
|
6423
|
+
const launches = [];
|
|
6424
|
+
const decoder = getLaunchDecoder();
|
|
6425
|
+
for (const account of accounts) {
|
|
6426
|
+
try {
|
|
6427
|
+
const launch = decoder.decode(base64ToBytes3(account.account.data[0]));
|
|
6428
|
+
launches.push({ address: account.pubkey, account: launch });
|
|
6429
|
+
} catch {
|
|
6430
|
+
console.warn(`Failed to decode launch account: ${account.pubkey}`);
|
|
6431
|
+
}
|
|
6432
|
+
}
|
|
6433
|
+
return launches;
|
|
6434
|
+
}
|
|
6435
|
+
async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
6436
|
+
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
6437
|
+
const discriminatorFilter = {
|
|
6438
|
+
memcmp: {
|
|
6439
|
+
offset: 0n,
|
|
6440
|
+
bytes: bytesToBase64(
|
|
6441
|
+
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
6442
|
+
),
|
|
6443
|
+
encoding: "base64"
|
|
6444
|
+
}
|
|
6445
|
+
};
|
|
6446
|
+
const authorityFilter = {
|
|
6447
|
+
memcmp: {
|
|
6448
|
+
offset: 8n,
|
|
6449
|
+
bytes: bytesToBase64(
|
|
6450
|
+
addressCodec5.encode(authority)
|
|
6451
|
+
),
|
|
6452
|
+
encoding: "base64"
|
|
6453
|
+
}
|
|
6454
|
+
};
|
|
6455
|
+
const response = await rpc.getProgramAccounts(programId, {
|
|
6456
|
+
encoding: "base64",
|
|
6457
|
+
commitment: config?.commitment,
|
|
6458
|
+
filters: [discriminatorFilter, authorityFilter]
|
|
6459
|
+
}).send();
|
|
6460
|
+
const accounts = Array.isArray(response) ? response : response.value;
|
|
6461
|
+
const launches = [];
|
|
6462
|
+
const decoder = getLaunchDecoder();
|
|
6463
|
+
for (const account of accounts) {
|
|
6464
|
+
try {
|
|
6465
|
+
const launch = decoder.decode(base64ToBytes3(account.account.data[0]));
|
|
6466
|
+
launches.push({ address: account.pubkey, account: launch });
|
|
6467
|
+
} catch {
|
|
6468
|
+
console.warn(`Failed to decode launch account: ${account.pubkey}`);
|
|
6469
|
+
}
|
|
6470
|
+
}
|
|
6471
|
+
return launches;
|
|
6472
|
+
}
|
|
6473
|
+
async function launchExists(rpc, namespace, launchId, config) {
|
|
6474
|
+
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
6475
|
+
const [launchAddress] = await getLaunchAddress(
|
|
6476
|
+
namespace,
|
|
6477
|
+
launchId,
|
|
6478
|
+
programId
|
|
6479
|
+
);
|
|
6480
|
+
const launch = await fetchLaunch2(rpc, launchAddress, config);
|
|
6481
|
+
return launch !== null;
|
|
6482
|
+
}
|
|
6483
|
+
|
|
5924
6484
|
// src/solana/migrators/predictionMigrator/index.ts
|
|
5925
6485
|
var predictionMigrator_exports = {};
|
|
5926
6486
|
__export(predictionMigrator_exports, {
|
|
@@ -6241,13 +6801,13 @@ function decodeOracleState3(encodedAccount) {
|
|
|
6241
6801
|
getOracleStateDecoder2()
|
|
6242
6802
|
);
|
|
6243
6803
|
}
|
|
6244
|
-
async function fetchOracleState2(rpc,
|
|
6245
|
-
const maybeAccount = await fetchMaybeOracleState2(rpc,
|
|
6804
|
+
async function fetchOracleState2(rpc, address4, config) {
|
|
6805
|
+
const maybeAccount = await fetchMaybeOracleState2(rpc, address4, config);
|
|
6246
6806
|
assertAccountExists(maybeAccount);
|
|
6247
6807
|
return maybeAccount;
|
|
6248
6808
|
}
|
|
6249
|
-
async function fetchMaybeOracleState2(rpc,
|
|
6250
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
6809
|
+
async function fetchMaybeOracleState2(rpc, address4, config) {
|
|
6810
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address4, config);
|
|
6251
6811
|
return decodeOracleState3(maybeAccount);
|
|
6252
6812
|
}
|
|
6253
6813
|
async function fetchAllOracleState2(rpc, addresses, config) {
|
|
@@ -6596,7 +7156,7 @@ var DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES = {
|
|
|
6596
7156
|
initializerProgram: INITIALIZER_PROGRAM_ID,
|
|
6597
7157
|
cpmmMigratorProgram: CPMM_MIGRATOR_PROGRAM_ID,
|
|
6598
7158
|
cpmmHookProgram: CPMM_HOOK_PROGRAM_ID,
|
|
6599
|
-
cosignerHookProgram:
|
|
7159
|
+
cosignerHookProgram: DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID
|
|
6600
7160
|
};
|
|
6601
7161
|
async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES) {
|
|
6602
7162
|
const [cpmmConfig] = await getConfigAddress(programs.cpmmProgram);
|
|
@@ -6610,6 +7170,6 @@ async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGR
|
|
|
6610
7170
|
};
|
|
6611
7171
|
}
|
|
6612
7172
|
|
|
6613
|
-
export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES, cosignerHook_exports as cosignerHook, cpmm_exports as cpmm, cpmmMigrator_exports as cpmmMigrator, deriveSolanaCpmmDeployment, initializer_exports as initializer, predictionMigrator_exports as predictionMigrator, trustedOracle_exports as trustedOracle };
|
|
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 };
|
|
6614
7174
|
//# sourceMappingURL=index.js.map
|
|
6615
7175
|
//# sourceMappingURL=index.js.map
|