@whetstone-research/doppler-sdk 1.0.27 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-U6B52TBT.cjs → chunk-4CI2M2F6.cjs} +27 -2
- package/dist/chunk-4CI2M2F6.cjs.map +1 -0
- package/dist/{chunk-XTL2GBZ4.cjs → chunk-7PXLEMBJ.cjs} +439 -91
- package/dist/chunk-7PXLEMBJ.cjs.map +1 -0
- package/dist/{chunk-WD5VOZGI.js → chunk-AFXFT3BD.js} +24 -3
- package/dist/chunk-AFXFT3BD.js.map +1 -0
- package/dist/{chunk-RVDRWCJN.js → chunk-PSLY7M7C.js} +392 -63
- package/dist/chunk-PSLY7M7C.js.map +1 -0
- package/dist/evm/index.cjs +243 -175
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.d.cts +36 -60
- package/dist/evm/index.d.ts +36 -60
- package/dist/evm/index.js +244 -176
- package/dist/evm/index.js.map +1 -1
- package/dist/{pda-H6VMGONM.cjs → pda-44IHEORD.cjs} +21 -17
- package/dist/pda-44IHEORD.cjs.map +1 -0
- package/dist/{pda-UJLXCO6I.js → pda-WJVDXQPW.js} +3 -3
- package/dist/pda-WJVDXQPW.js.map +1 -0
- package/dist/solana/index.cjs +1664 -925
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +748 -159
- package/dist/solana/index.d.ts +748 -159
- package/dist/solana/index.js +1311 -577
- 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-RVDRWCJN.js.map +0 -1
- package/dist/chunk-U6B52TBT.cjs.map +0 -1
- package/dist/chunk-WD5VOZGI.js.map +0 -1
- package/dist/chunk-XTL2GBZ4.cjs.map +0 -1
- package/dist/pda-H6VMGONM.cjs.map +0 -1
- package/dist/pda-UJLXCO6I.js.map +0 -1
package/dist/solana/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { transferAdminArgsCodec, swapExactInArgsCodec, sortPositionsByShares, sortPoolsByReserves, setHookArgsCodec, setFeesArgsCodec, removeLiquidityArgsCodec, ratioToNumber, q64ToNumber, q64Mul, q64Div, positionDataCodec, poolExists, poolDataCodec, parseWithdrawVaultExcessInstruction, parseUpdateConfigInstruction, parseUnpauseInstruction, parseTransferAdminInstruction, parseSwapExactInInstruction, parseSetHookInstruction, parseSetFeesInstruction, parseRemoveLiquidityInstruction, parseRedeemProtocolSharesInstruction, parsePreviewSwapExactInInstruction, parsePauseInstruction, parseOracleUpdateInstruction, parseOracleConsultInstruction, parseInitializePoolInstruction, parseInitializeOracleInstruction, parseInitializeConfigInstruction, parseCreatePositionInstruction, parseCollectProtocolFeesInstruction, parseCollectFeesInstruction, parseClosePositionInstruction, parseAddLiquidityInstruction, oracleStateDataCodec, oracleConsultArgsCodec, observationCodec, numberToQ64, minBigInt, maxBigInt, isqrt, isOracleStale, initializePoolArgsCodec, initializeOracleArgsCodec, initializeConfigArgsCodec, getWithdrawVaultExcessInstructionDataEncoder, getWithdrawVaultExcessInstructionDataDecoder, getWithdrawVaultExcessInstructionDataCodec, getWithdrawVaultExcessInstructionAsync, getWithdrawVaultExcessInstruction, getWithdrawVaultExcessDiscriminatorBytes, getUpdateConfigInstructionDataEncoder, getUpdateConfigInstructionDataDecoder, getUpdateConfigInstructionDataCodec, getUpdateConfigInstruction, getUpdateConfigDiscriminatorBytes, getUnpauseInstructionDataEncoder, getUnpauseInstructionDataDecoder, getUnpauseInstructionDataCodec, getUnpauseInstruction, getUnpauseDiscriminatorBytes, getTvl, getTransferAdminInstructionDataEncoder, getTransferAdminInstructionDataDecoder, getTransferAdminInstructionDataCodec, getTransferAdminInstruction, getTransferAdminDiscriminatorBytes, getSwapQuoteExactOut, getSwapQuote, getSwapExactInInstructionDataEncoder, getSwapExactInInstructionDataDecoder, getSwapExactInInstructionDataCodec, getSwapExactInInstructionAsync, getSwapExactInInstruction, getSwapExactInDiscriminatorBytes, getSpotPrice1, getSpotPrice0, getSetHookInstructionDataEncoder, getSetHookInstructionDataDecoder, getSetHookInstructionDataCodec, getSetHookInstruction, getSetHookDiscriminatorBytes, getSetFeesInstructionDataEncoder, getSetFeesInstructionDataDecoder, getSetFeesInstructionDataCodec, getSetFeesInstruction, getSetFeesDiscriminatorBytes, getRemoveLiquidityQuote, getRemoveLiquidityInstructionDataEncoder, getRemoveLiquidityInstructionDataDecoder, getRemoveLiquidityInstructionDataCodec, getRemoveLiquidityInstructionAsync, getRemoveLiquidityInstruction, getRemoveLiquidityDiscriminatorBytes, getRedeemProtocolSharesInstructionDataEncoder, getRedeemProtocolSharesInstructionDataDecoder, getRedeemProtocolSharesInstructionDataCodec, getRedeemProtocolSharesInstructionAsync, getRedeemProtocolSharesInstruction, getRedeemProtocolSharesDiscriminatorBytes, getPreviewSwapExactInInstructionDataEncoder, getPreviewSwapExactInInstructionDataDecoder, getPreviewSwapExactInInstructionDataCodec, getPreviewSwapExactInInstruction, getPreviewSwapExactInDiscriminatorBytes, getPositionValue, getPositionAddressFromParams, getPoolByMints, getPoolAddressFromMints, getPendingFees, getPauseInstructionDataEncoder, getPauseInstructionDataDecoder, getPauseInstructionDataCodec, getPauseInstruction, getPauseDiscriminatorBytes, getOracleUpdateInstructionDataEncoder, getOracleUpdateInstructionDataDecoder, getOracleUpdateInstructionDataCodec, getOracleUpdateInstructionAsync, getOracleUpdateInstruction, getOracleUpdateDiscriminatorBytes, getOracleSpotPrices, getOracleForPool, getOracleDeviation, getOracleConsultInstructionDataEncoder, getOracleConsultInstructionDataDecoder, getOracleConsultInstructionDataCodec, getOracleConsultInstructionAsync, getOracleConsultInstruction, getOracleConsultDiscriminatorBytes, getOracleBufferStats, getOracleAge, getOracleAddressFromPool, getK, getInitializePoolInstructionDataEncoder, getInitializePoolInstructionDataDecoder, getInitializePoolInstructionDataCodec, getInitializePoolInstructionAsync, getInitializePoolInstruction, getInitializePoolDiscriminatorBytes, getInitializeOracleInstructionDataEncoder, getInitializeOracleInstructionDataDecoder, getInitializeOracleInstructionDataCodec, getInitializeOracleInstructionAsync, getInitializeOracleInstruction, getInitializeOracleDiscriminatorBytes, getInitializeConfigInstructionDataEncoder, getInitializeConfigInstructionDataDecoder, getInitializeConfigInstructionDataCodec, getInitializeConfigInstructionAsync, getInitializeConfigInstruction, getInitializeConfigDiscriminatorBytes, getCreatePositionInstructionDataEncoder, getCreatePositionInstructionDataDecoder, getCreatePositionInstructionDataCodec, getCreatePositionInstructionAsync, getCreatePositionInstruction, getCreatePositionDiscriminatorBytes, getCollectProtocolFeesInstructionDataEncoder, getCollectProtocolFeesInstructionDataDecoder, getCollectProtocolFeesInstructionDataCodec, getCollectProtocolFeesInstructionAsync, getCollectProtocolFeesInstruction, getCollectProtocolFeesDiscriminatorBytes, getCollectFeesInstructionDataEncoder, getCollectFeesInstructionDataDecoder, getCollectFeesInstructionDataCodec, getCollectFeesInstructionAsync, getCollectFeesInstruction, getCollectFeesDiscriminatorBytes, getClosePositionInstructionDataEncoder, getClosePositionInstructionDataDecoder, getClosePositionInstructionDataCodec, getClosePositionInstruction, getClosePositionDiscriminatorBytes, getAddLiquidityQuote, getAddLiquidityInstructionDataEncoder, getAddLiquidityInstructionDataDecoder, getAddLiquidityInstructionDataCodec, getAddLiquidityInstructionAsync, getAddLiquidityInstruction, getAddLiquidityDiscriminatorBytes, filterPoolsByMint, filterActivePositions, fetchUserPositions, fetchPositionsBatch, fetchPositionByParams, fetchPosition, fetchPoolsBatch, fetchPoolPositions, fetchPool, fetchOraclesBatch, fetchOracle, fetchAllPools, encodeTransferAdminArgs, encodeSwapExactInArgs, encodeSetHookArgs, encodeSetFeesArgs, encodeRemoveLiquidityArgs, encodeOracleConsultArgs, encodeInstructionData, encodeInitializePoolArgs, encodeInitializeOracleArgs, encodeInitializeConfigArgs, encodeCreatePositionArgs, encodeCollectProtocolFeesArgs, encodeCollectFeesArgs, encodeAddLiquidityArgs, decodePosition, decodePool, decodeOracleState, decodeAmmConfig, createPositionArgsCodec, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, ammConfigDataCodec, addLiquidityArgsCodec, WITHDRAW_VAULT_EXCESS_DISCRIMINATOR, UPDATE_CONFIG_DISCRIMINATOR, UNPAUSE_DISCRIMINATOR, TRANSFER_ADMIN_DISCRIMINATOR, SWAP_EXACT_IN_DISCRIMINATOR, SET_HOOK_DISCRIMINATOR, SET_FEES_DISCRIMINATOR, REMOVE_LIQUIDITY_DISCRIMINATOR, REDEEM_PROTOCOL_SHARES_DISCRIMINATOR, PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR, PAUSE_DISCRIMINATOR, ORACLE_UPDATE_DISCRIMINATOR, ORACLE_CONSULT_DISCRIMINATOR, INITIALIZE_POOL_DISCRIMINATOR, INITIALIZE_ORACLE_DISCRIMINATOR, INITIALIZE_CONFIG_DISCRIMINATOR, CREATE_POSITION_DISCRIMINATOR, COLLECT_PROTOCOL_FEES_DISCRIMINATOR, COLLECT_FEES_DISCRIMINATOR, CLOSE_POSITION_DISCRIMINATOR, ADD_LIQUIDITY_DISCRIMINATOR, CPMM_PROGRAM_ADDRESS } from '../chunk-
|
|
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-
|
|
1
|
+
import { warnAccountDecodeFailure, transferAdminArgsCodec, swapExactInArgsCodec, sortPositionsByShares, sortPoolsByReserves, setHookArgsCodec, setFeesArgsCodec, removeLiquidityArgsCodec, ratioToNumber, q64ToNumber, q64Mul, q64Div, positionDataCodec, poolExists, poolDataCodec, parseWithdrawVaultExcessInstruction, parseUpdateConfigInstruction, parseUnpauseInstruction, parseTransferAdminInstruction, parseSwapExactInInstruction, parseSetHookInstruction, parseSetFeesInstruction, parseRemoveLiquidityInstruction, parseRedeemProtocolSharesInstruction, parsePreviewSwapExactInInstruction, parsePauseInstruction, parseOracleUpdateInstruction, parseOracleConsultInstruction, parseInitializeSpotPoolInstruction, parseInitializePoolInstruction, parseInitializeOracleInstruction, parseInitializeConfigInstruction, parseCreatePositionInstruction, parseCollectProtocolFeesInstruction, parseCollectFeesInstruction, parseClosePositionInstruction, parseAddLiquidityInstruction, oracleStateDataCodec, oracleConsultArgsCodec, observationCodec, numberToQ64, normalizeProgramAccountsResponse, minBigInt, maxBigInt, isqrt, isTransactionSigner, isOracleStale, initializePoolArgsCodec, initializeOracleArgsCodec, initializeConfigArgsCodec, getWithdrawVaultExcessInstructionDataEncoder, getWithdrawVaultExcessInstructionDataDecoder, getWithdrawVaultExcessInstructionDataCodec, getWithdrawVaultExcessInstructionAsync, getWithdrawVaultExcessInstruction, getWithdrawVaultExcessDiscriminatorBytes, getUpdateConfigInstructionDataEncoder, getUpdateConfigInstructionDataDecoder, getUpdateConfigInstructionDataCodec, getUpdateConfigInstruction, getUpdateConfigDiscriminatorBytes, getUnpauseInstructionDataEncoder, getUnpauseInstructionDataDecoder, getUnpauseInstructionDataCodec, getUnpauseInstruction, getUnpauseDiscriminatorBytes, getTvl, getTransferAdminInstructionDataEncoder, getTransferAdminInstructionDataDecoder, getTransferAdminInstructionDataCodec, getTransferAdminInstruction, getTransferAdminDiscriminatorBytes, getSwapQuoteExactOut, getSwapQuote, getSwapExactInInstructionDataEncoder, getSwapExactInInstructionDataDecoder, getSwapExactInInstructionDataCodec, getSwapExactInInstructionAsync, getSwapExactInInstruction, getSwapExactInDiscriminatorBytes, getSpotPrice1, getSpotPrice0, getSetHookInstructionDataEncoder, getSetHookInstructionDataDecoder, getSetHookInstructionDataCodec, getSetHookInstruction, getSetHookDiscriminatorBytes, getSetFeesInstructionDataEncoder, getSetFeesInstructionDataDecoder, getSetFeesInstructionDataCodec, getSetFeesInstruction, getSetFeesDiscriminatorBytes, getRemoveLiquidityQuote, getRemoveLiquidityInstructionDataEncoder, getRemoveLiquidityInstructionDataDecoder, getRemoveLiquidityInstructionDataCodec, getRemoveLiquidityInstructionAsync, getRemoveLiquidityInstruction, getRemoveLiquidityDiscriminatorBytes, getRedeemProtocolSharesInstructionDataEncoder, getRedeemProtocolSharesInstructionDataDecoder, getRedeemProtocolSharesInstructionDataCodec, getRedeemProtocolSharesInstructionAsync, getRedeemProtocolSharesInstruction, getRedeemProtocolSharesDiscriminatorBytes, getPreviewSwapExactInInstructionDataEncoder, getPreviewSwapExactInInstructionDataDecoder, getPreviewSwapExactInInstructionDataCodec, getPreviewSwapExactInInstruction, getPreviewSwapExactInDiscriminatorBytes, getPositionValue, getPositionAddressFromParams, getPoolByMints, getPoolAddressFromMints, getPendingFees, getPauseInstructionDataEncoder, getPauseInstructionDataDecoder, getPauseInstructionDataCodec, getPauseInstruction, getPauseDiscriminatorBytes, getOracleUpdateInstructionDataEncoder, getOracleUpdateInstructionDataDecoder, getOracleUpdateInstructionDataCodec, getOracleUpdateInstructionAsync, getOracleUpdateInstruction, getOracleUpdateDiscriminatorBytes, getOracleSpotPrices, getOracleForPool, getOracleDeviation, getOracleConsultInstructionDataEncoder, getOracleConsultInstructionDataDecoder, getOracleConsultInstructionDataCodec, getOracleConsultInstructionAsync, getOracleConsultInstruction, getOracleConsultDiscriminatorBytes, getOracleBufferStats, getOracleAge, getOracleAddressFromPool, getK, getInitializeSpotPoolInstructionDataEncoder, getInitializeSpotPoolInstructionDataDecoder, getInitializeSpotPoolInstructionDataCodec, getInitializeSpotPoolInstructionAsync, getInitializeSpotPoolInstruction, getInitializeSpotPoolDiscriminatorBytes, getInitializePoolInstructionDataEncoder, getInitializePoolInstructionDataDecoder, getInitializePoolInstructionDataCodec, getInitializePoolInstructionAsync, getInitializePoolInstruction, getInitializePoolDiscriminatorBytes, getInitializeOracleInstructionDataEncoder, getInitializeOracleInstructionDataDecoder, getInitializeOracleInstructionDataCodec, getInitializeOracleInstructionAsync, getInitializeOracleInstruction, getInitializeOracleDiscriminatorBytes, getInitializeConfigInstructionDataEncoder, getInitializeConfigInstructionDataDecoder, getInitializeConfigInstructionDataCodec, getInitializeConfigInstructionAsync, getInitializeConfigInstruction, getInitializeConfigDiscriminatorBytes, getCreatePositionInstructionDataEncoder, getCreatePositionInstructionDataDecoder, getCreatePositionInstructionDataCodec, getCreatePositionInstructionAsync, getCreatePositionInstruction, getCreatePositionDiscriminatorBytes, getCollectProtocolFeesInstructionDataEncoder, getCollectProtocolFeesInstructionDataDecoder, getCollectProtocolFeesInstructionDataCodec, getCollectProtocolFeesInstructionAsync, getCollectProtocolFeesInstruction, getCollectProtocolFeesDiscriminatorBytes, getCollectFeesInstructionDataEncoder, getCollectFeesInstructionDataDecoder, getCollectFeesInstructionDataCodec, getCollectFeesInstructionAsync, getCollectFeesInstruction, getCollectFeesDiscriminatorBytes, getClosePositionInstructionDataEncoder, getClosePositionInstructionDataDecoder, getClosePositionInstructionDataCodec, getClosePositionInstruction, getClosePositionDiscriminatorBytes, getAddressFromRemainingAccount, getAddressFromAddressOrSigner, getAddLiquidityQuote, getAddLiquidityInstructionDataEncoder, getAddLiquidityInstructionDataDecoder, getAddLiquidityInstructionDataCodec, getAddLiquidityInstructionAsync, getAddLiquidityInstruction, getAddLiquidityDiscriminatorBytes, filterPoolsByMint, filterActivePositions, fetchUserPositions, fetchPositionsBatch, fetchPositionByParams, fetchPosition, fetchPoolsBatch, fetchPoolPositions, fetchPool, fetchOraclesBatch, fetchOracle, fetchAllPools, encodeTransferAdminArgs, encodeSwapExactInArgs, encodeSetHookArgs, encodeSetFeesArgs, encodeRemoveLiquidityArgs, encodeOracleConsultArgs, encodeInstructionData, encodeInitializePoolArgs, encodeInitializeOracleArgs, encodeInitializeConfigArgs, encodeCreatePositionArgs, encodeCollectProtocolFeesArgs, encodeCollectFeesArgs, encodeAddLiquidityArgs, decodePosition, decodePool, decodeOracleState, decodeAmmConfig, createReadonlyRemainingAccountMeta, createPositionArgsCodec, createAccountMeta, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, bytesToBase64EncodedBytes, bytesToBase64, base64ToBytes, ammConfigDataCodec, addressToBase58EncodedBytes, addLiquidityArgsCodec, WITHDRAW_VAULT_EXCESS_DISCRIMINATOR, UPDATE_CONFIG_DISCRIMINATOR, UNPAUSE_DISCRIMINATOR, TRANSFER_ADMIN_DISCRIMINATOR, SWAP_EXACT_IN_DISCRIMINATOR, SET_HOOK_DISCRIMINATOR, SET_FEES_DISCRIMINATOR, REMOVE_LIQUIDITY_DISCRIMINATOR, REDEEM_PROTOCOL_SHARES_DISCRIMINATOR, PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR, PAUSE_DISCRIMINATOR, ORACLE_UPDATE_DISCRIMINATOR, ORACLE_CONSULT_DISCRIMINATOR, INITIALIZE_SPOT_POOL_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-PSLY7M7C.js';
|
|
2
|
+
import { sortMints, getSwapAddresses, getSpotPoolAddress, getProtocolFeePositionAddress, getProtocolFeeOwnerAddress, getPositionAddress, getPoolVault1Address, getPoolVault0Address, getPoolInitAddresses, getPoolAuthorityAddress, getPoolAddress, getOracleAddress, getLiquidityAddresses, getConfigAddress, CPMM_PROGRAM_ID, areMintsOrdered, TOKEN_METADATA_PROGRAM_ID, SEED_SPOT_POOL, 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, SEED_VAULT1, SEED_VAULT0, SYSVAR_RENT_ADDRESS as SYSVAR_RENT_ADDRESS$1 } from '../chunk-AFXFT3BD.js';
|
|
3
3
|
import { __export } from '../chunk-PZ5AY32C.js';
|
|
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,
|
|
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, getU128Encoder, getU128Decoder, getOptionEncoder, getOptionDecoder, getBooleanEncoder, getBooleanDecoder, mergeBytes, compressTransactionMessageUsingAddressLookupTables, getTransactionMessageSize, getEnumEncoder } from '@solana/kit';
|
|
5
5
|
import { getAccountMetaFactory, addSelfPlanAndSendFunctions, addSelfFetchFunctions, getAddressFromResolvedInstructionAccount } from '@solana/program-client-core';
|
|
6
6
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
7
|
-
import { findAssociatedTokenPda } from '@solana-program/token';
|
|
7
|
+
import { TOKEN_PROGRAM_ADDRESS as TOKEN_PROGRAM_ADDRESS$1, findAssociatedTokenPda, getCreateAssociatedTokenIdempotentInstruction, getSyncNativeInstruction } from '@solana-program/token';
|
|
8
|
+
import { SYSTEM_PROGRAM_ADDRESS as SYSTEM_PROGRAM_ADDRESS$1, getTransferSolInstruction } from '@solana-program/system';
|
|
9
|
+
import { SYSVAR_RENT_ADDRESS } from '@solana/sysvars';
|
|
8
10
|
import { findAddressLookupTablePda, getCreateLookupTableInstruction, getExtendLookupTableInstruction } from '@solana-program/address-lookup-table';
|
|
9
11
|
|
|
10
12
|
// src/solana/cpmm/index.ts
|
|
@@ -34,6 +36,7 @@ __export(cpmm_exports, {
|
|
|
34
36
|
INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR,
|
|
35
37
|
INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR,
|
|
36
38
|
INITIALIZE_POOL_DISCRIMINATOR: () => INITIALIZE_POOL_DISCRIMINATOR,
|
|
39
|
+
INITIALIZE_SPOT_POOL_DISCRIMINATOR: () => INITIALIZE_SPOT_POOL_DISCRIMINATOR,
|
|
37
40
|
INSTRUCTION_DISCRIMINATORS: () => INSTRUCTION_DISCRIMINATORS,
|
|
38
41
|
MAX_FEE_AMOUNT: () => MAX_FEE_AMOUNT,
|
|
39
42
|
MAX_HOOK_ALLOWLIST: () => MAX_HOOK_ALLOWLIST,
|
|
@@ -51,6 +54,7 @@ __export(cpmm_exports, {
|
|
|
51
54
|
SEED_POOL: () => SEED_POOL,
|
|
52
55
|
SEED_POSITION: () => SEED_POSITION,
|
|
53
56
|
SEED_PROTOCOL_FEE_OWNER: () => SEED_PROTOCOL_FEE_OWNER,
|
|
57
|
+
SEED_SPOT_POOL: () => SEED_SPOT_POOL,
|
|
54
58
|
SET_FEES_DISCRIMINATOR: () => SET_FEES_DISCRIMINATOR,
|
|
55
59
|
SET_HOOK_DISCRIMINATOR: () => SET_HOOK_DISCRIMINATOR,
|
|
56
60
|
SWAP_EXACT_IN_DISCRIMINATOR: () => SWAP_EXACT_IN_DISCRIMINATOR,
|
|
@@ -60,8 +64,12 @@ __export(cpmm_exports, {
|
|
|
60
64
|
UPDATE_CONFIG_DISCRIMINATOR: () => UPDATE_CONFIG_DISCRIMINATOR,
|
|
61
65
|
WITHDRAW_VAULT_EXCESS_DISCRIMINATOR: () => WITHDRAW_VAULT_EXCESS_DISCRIMINATOR,
|
|
62
66
|
addLiquidityArgsCodec: () => addLiquidityArgsCodec,
|
|
67
|
+
addressToBase58EncodedBytes: () => addressToBase58EncodedBytes,
|
|
63
68
|
ammConfigDataCodec: () => ammConfigDataCodec,
|
|
64
69
|
areMintsOrdered: () => areMintsOrdered,
|
|
70
|
+
base64ToBytes: () => base64ToBytes,
|
|
71
|
+
bytesToBase64: () => bytesToBase64,
|
|
72
|
+
bytesToBase64EncodedBytes: () => bytesToBase64EncodedBytes,
|
|
65
73
|
calculateAccruedFees: () => calculateAccruedFees,
|
|
66
74
|
calculateTwap: () => calculateTwap,
|
|
67
75
|
calculateTwapNumber: () => calculateTwapNumber,
|
|
@@ -72,6 +80,7 @@ __export(cpmm_exports, {
|
|
|
72
80
|
computePrice0Q64: () => computePrice0Q64,
|
|
73
81
|
computePrice1Q64: () => computePrice1Q64,
|
|
74
82
|
consultTwap: () => consultTwap,
|
|
83
|
+
createAccountMeta: () => createAccountMeta,
|
|
75
84
|
createAddLiquidityInstruction: () => getAddLiquidityInstruction,
|
|
76
85
|
createClosePositionInstruction: () => getClosePositionInstruction,
|
|
77
86
|
createCollectFeesInstruction: () => getCollectFeesInstruction,
|
|
@@ -84,6 +93,7 @@ __export(cpmm_exports, {
|
|
|
84
93
|
createOracleUpdateInstruction: () => getOracleUpdateInstruction,
|
|
85
94
|
createPauseInstruction: () => getPauseInstruction,
|
|
86
95
|
createPositionArgsCodec: () => createPositionArgsCodec,
|
|
96
|
+
createReadonlyRemainingAccountMeta: () => createReadonlyRemainingAccountMeta,
|
|
87
97
|
createRemoveLiquidityInstruction: () => getRemoveLiquidityInstruction,
|
|
88
98
|
createSetFeesInstruction: () => getSetFeesInstruction,
|
|
89
99
|
createSetHookInstruction: () => getSetHookInstruction,
|
|
@@ -132,6 +142,8 @@ __export(cpmm_exports, {
|
|
|
132
142
|
getAddLiquidityInstructionDataDecoder: () => getAddLiquidityInstructionDataDecoder,
|
|
133
143
|
getAddLiquidityInstructionDataEncoder: () => getAddLiquidityInstructionDataEncoder,
|
|
134
144
|
getAddLiquidityQuote: () => getAddLiquidityQuote,
|
|
145
|
+
getAddressFromAddressOrSigner: () => getAddressFromAddressOrSigner,
|
|
146
|
+
getAddressFromRemainingAccount: () => getAddressFromRemainingAccount,
|
|
135
147
|
getClosePositionDiscriminatorBytes: () => getClosePositionDiscriminatorBytes,
|
|
136
148
|
getClosePositionInstruction: () => getClosePositionInstruction,
|
|
137
149
|
getClosePositionInstructionDataCodec: () => getClosePositionInstructionDataCodec,
|
|
@@ -175,6 +187,12 @@ __export(cpmm_exports, {
|
|
|
175
187
|
getInitializePoolInstructionDataCodec: () => getInitializePoolInstructionDataCodec,
|
|
176
188
|
getInitializePoolInstructionDataDecoder: () => getInitializePoolInstructionDataDecoder,
|
|
177
189
|
getInitializePoolInstructionDataEncoder: () => getInitializePoolInstructionDataEncoder,
|
|
190
|
+
getInitializeSpotPoolDiscriminatorBytes: () => getInitializeSpotPoolDiscriminatorBytes,
|
|
191
|
+
getInitializeSpotPoolInstruction: () => getInitializeSpotPoolInstruction,
|
|
192
|
+
getInitializeSpotPoolInstructionAsync: () => getInitializeSpotPoolInstructionAsync,
|
|
193
|
+
getInitializeSpotPoolInstructionDataCodec: () => getInitializeSpotPoolInstructionDataCodec,
|
|
194
|
+
getInitializeSpotPoolInstructionDataDecoder: () => getInitializeSpotPoolInstructionDataDecoder,
|
|
195
|
+
getInitializeSpotPoolInstructionDataEncoder: () => getInitializeSpotPoolInstructionDataEncoder,
|
|
178
196
|
getK: () => getK,
|
|
179
197
|
getLiquidityAddresses: () => getLiquidityAddresses,
|
|
180
198
|
getMetadataAddress: () => getMetadataAddress,
|
|
@@ -243,6 +261,7 @@ __export(cpmm_exports, {
|
|
|
243
261
|
getSetHookInstructionDataCodec: () => getSetHookInstructionDataCodec,
|
|
244
262
|
getSetHookInstructionDataDecoder: () => getSetHookInstructionDataDecoder,
|
|
245
263
|
getSetHookInstructionDataEncoder: () => getSetHookInstructionDataEncoder,
|
|
264
|
+
getSpotPoolAddress: () => getSpotPoolAddress,
|
|
246
265
|
getSpotPrice0: () => getSpotPrice0,
|
|
247
266
|
getSpotPrice1: () => getSpotPrice1,
|
|
248
267
|
getSwapAddresses: () => getSwapAddresses,
|
|
@@ -281,12 +300,14 @@ __export(cpmm_exports, {
|
|
|
281
300
|
initializePoolArgsCodec: () => initializePoolArgsCodec,
|
|
282
301
|
isCpmmError: () => isCpmmError,
|
|
283
302
|
isOracleStale: () => isOracleStale,
|
|
303
|
+
isTransactionSigner: () => isTransactionSigner,
|
|
284
304
|
isqrt: () => isqrt,
|
|
285
305
|
marketCapToCurveParams: () => marketCapToCurveParams,
|
|
286
306
|
marketCapToSingleCurveParams: () => marketCapToSingleCurveParams,
|
|
287
307
|
marketCapToTokenPrice: () => marketCapToTokenPrice,
|
|
288
308
|
maxBigInt: () => maxBigInt,
|
|
289
309
|
minBigInt: () => minBigInt,
|
|
310
|
+
normalizeProgramAccountsResponse: () => normalizeProgramAccountsResponse,
|
|
290
311
|
numberToQ64: () => numberToQ64,
|
|
291
312
|
observationCodec: () => observationCodec,
|
|
292
313
|
oracleConsultArgsCodec: () => oracleConsultArgsCodec,
|
|
@@ -300,6 +321,7 @@ __export(cpmm_exports, {
|
|
|
300
321
|
parseInitializeConfigInstruction: () => parseInitializeConfigInstruction,
|
|
301
322
|
parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
|
|
302
323
|
parseInitializePoolInstruction: () => parseInitializePoolInstruction,
|
|
324
|
+
parseInitializeSpotPoolInstruction: () => parseInitializeSpotPoolInstruction,
|
|
303
325
|
parseOracleConsultInstruction: () => parseOracleConsultInstruction,
|
|
304
326
|
parseOracleUpdateInstruction: () => parseOracleUpdateInstruction,
|
|
305
327
|
parsePauseInstruction: () => parsePauseInstruction,
|
|
@@ -328,7 +350,8 @@ __export(cpmm_exports, {
|
|
|
328
350
|
sortPositionsByShares: () => sortPositionsByShares,
|
|
329
351
|
swapExactInArgsCodec: () => swapExactInArgsCodec,
|
|
330
352
|
transferAdminArgsCodec: () => transferAdminArgsCodec,
|
|
331
|
-
validateMarketCapParameters: () => validateMarketCapParameters
|
|
353
|
+
validateMarketCapParameters: () => validateMarketCapParameters,
|
|
354
|
+
warnAccountDecodeFailure: () => warnAccountDecodeFailure
|
|
332
355
|
});
|
|
333
356
|
var addressCodec = getAddressCodec();
|
|
334
357
|
var textEncoder = new TextEncoder();
|
|
@@ -629,22 +652,6 @@ function getErrorMessage(code) {
|
|
|
629
652
|
}
|
|
630
653
|
return `Unknown error code: ${code}`;
|
|
631
654
|
}
|
|
632
|
-
function isTransactionSigner(value) {
|
|
633
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
634
|
-
}
|
|
635
|
-
function toRemainingAccountMeta(account) {
|
|
636
|
-
if (typeof account === "string") {
|
|
637
|
-
return { address: account, role: AccountRole.READONLY };
|
|
638
|
-
}
|
|
639
|
-
if (isTransactionSigner(account)) {
|
|
640
|
-
return {
|
|
641
|
-
address: account.address,
|
|
642
|
-
role: AccountRole.READONLY_SIGNER,
|
|
643
|
-
signer: account
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
return account;
|
|
647
|
-
}
|
|
648
655
|
function createSwapInstruction(params) {
|
|
649
656
|
const {
|
|
650
657
|
config,
|
|
@@ -697,21 +704,13 @@ function createSwapInstruction(params) {
|
|
|
697
704
|
...instruction,
|
|
698
705
|
accounts: [
|
|
699
706
|
...instruction.accounts ?? [],
|
|
700
|
-
...remainingAccounts.map(
|
|
707
|
+
...remainingAccounts.map(createReadonlyRemainingAccountMeta)
|
|
701
708
|
]
|
|
702
709
|
};
|
|
703
710
|
}
|
|
704
711
|
var MAX_FEE_AMOUNT = BigInt("18446744073709551615");
|
|
705
712
|
|
|
706
713
|
// src/solana/client/config.ts
|
|
707
|
-
function base64ToBytes(base64) {
|
|
708
|
-
const binary = atob(base64);
|
|
709
|
-
const bytes = new Uint8Array(binary.length);
|
|
710
|
-
for (let i = 0; i < binary.length; i++) {
|
|
711
|
-
bytes[i] = binary.charCodeAt(i);
|
|
712
|
-
}
|
|
713
|
-
return bytes;
|
|
714
|
-
}
|
|
715
714
|
async function fetchConfig(rpc, programId = CPMM_PROGRAM_ID, commitment) {
|
|
716
715
|
const [configAddress] = await getConfigAddress(programId);
|
|
717
716
|
const response = await rpc.getAccountInfo(configAddress, {
|
|
@@ -732,22 +731,32 @@ async function fetchConfigWithAddress(rpc, programId = CPMM_PROGRAM_ID, commitme
|
|
|
732
731
|
return { address: configAddress, account };
|
|
733
732
|
}
|
|
734
733
|
|
|
735
|
-
// src/solana/
|
|
736
|
-
var
|
|
737
|
-
__export(
|
|
734
|
+
// src/solana/cpmmHook/index.ts
|
|
735
|
+
var cpmmHook_exports = {};
|
|
736
|
+
__export(cpmmHook_exports, {
|
|
738
737
|
ADD_COSIGNER_DISCRIMINATOR: () => ADD_COSIGNER_DISCRIMINATOR,
|
|
739
738
|
COSIGNER_CONFIG_DISCRIMINATOR: () => COSIGNER_CONFIG_DISCRIMINATOR,
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
739
|
+
CPMM_HOOK_ERROR__ARITHMETIC_OVERFLOW: () => CPMM_HOOK_ERROR__ARITHMETIC_OVERFLOW,
|
|
740
|
+
CPMM_HOOK_ERROR__COSIGNER_ALREADY_EXISTS: () => CPMM_HOOK_ERROR__COSIGNER_ALREADY_EXISTS,
|
|
741
|
+
CPMM_HOOK_ERROR__COSIGNER_LIST_FULL: () => CPMM_HOOK_ERROR__COSIGNER_LIST_FULL,
|
|
742
|
+
CPMM_HOOK_ERROR__COSIGNER_NOT_FOUND: () => CPMM_HOOK_ERROR__COSIGNER_NOT_FOUND,
|
|
743
|
+
CPMM_HOOK_ERROR__INVALID_AUTHORITY: () => CPMM_HOOK_ERROR__INVALID_AUTHORITY,
|
|
744
|
+
CPMM_HOOK_ERROR__INVALID_CONFIG: () => CPMM_HOOK_ERROR__INVALID_CONFIG,
|
|
745
|
+
CPMM_HOOK_ERROR__INVALID_COSIGNER: () => CPMM_HOOK_ERROR__INVALID_COSIGNER,
|
|
746
|
+
CPMM_HOOK_ERROR__INVALID_DURATION: () => CPMM_HOOK_ERROR__INVALID_DURATION,
|
|
747
|
+
CPMM_HOOK_ERROR__INVALID_FEE: () => CPMM_HOOK_ERROR__INVALID_FEE,
|
|
748
|
+
CPMM_HOOK_ERROR__INVALID_INSTRUCTION_DATA: () => CPMM_HOOK_ERROR__INVALID_INSTRUCTION_DATA,
|
|
749
|
+
CPMM_HOOK_ERROR__INVALID_SCHEDULE_DATA: () => CPMM_HOOK_ERROR__INVALID_SCHEDULE_DATA,
|
|
750
|
+
CPMM_HOOK_PROGRAM_ADDRESS: () => CPMM_HOOK_PROGRAM_ADDRESS,
|
|
751
|
+
CPMM_HOOK_PROGRAM_ID: () => CPMM_HOOK_PROGRAM_ID,
|
|
752
|
+
CpmmHookAccount: () => CpmmHookAccount,
|
|
753
|
+
CpmmHookInstruction: () => CpmmHookInstruction,
|
|
754
|
+
DEVNET_CPMM_HOOK_PROGRAM_ID: () => DEVNET_CPMM_HOOK_PROGRAM_ID,
|
|
755
|
+
DYNAMIC_FEE_SCHEDULE_HEADER_LEN: () => DYNAMIC_FEE_SCHEDULE_HEADER_LEN,
|
|
756
|
+
DYNAMIC_FEE_SCHEDULE_LEN: () => DYNAMIC_FEE_SCHEDULE_LEN,
|
|
757
|
+
DYNAMIC_FEE_SCHEDULE_MAGIC: () => DYNAMIC_FEE_SCHEDULE_MAGIC,
|
|
758
|
+
DYNAMIC_FEE_SCHEDULE_MAX_BPS: () => DYNAMIC_FEE_SCHEDULE_MAX_BPS,
|
|
759
|
+
DYNAMIC_FEE_SCHEDULE_VERSION: () => DYNAMIC_FEE_SCHEDULE_VERSION,
|
|
751
760
|
GATE_EXPIRY_DISABLED: () => GATE_EXPIRY_DISABLED,
|
|
752
761
|
GATE_EXPIRY_HEADER_LEN: () => GATE_EXPIRY_HEADER_LEN,
|
|
753
762
|
GATE_EXPIRY_PAYLOAD_LEN: () => GATE_EXPIRY_PAYLOAD_LEN,
|
|
@@ -757,12 +766,15 @@ __export(cosignerHook_exports, {
|
|
|
757
766
|
INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR2,
|
|
758
767
|
MAX_COSIGNERS: () => MAX_COSIGNERS,
|
|
759
768
|
REMOVE_COSIGNER_DISCRIMINATOR: () => REMOVE_COSIGNER_DISCRIMINATOR,
|
|
760
|
-
|
|
769
|
+
SEED_CPMM_HOOK_CONFIG: () => SEED_CPMM_HOOK_CONFIG,
|
|
761
770
|
SET_AUTHORITY_DISCRIMINATOR: () => SET_AUTHORITY_DISCRIMINATOR,
|
|
762
|
-
|
|
771
|
+
cpmmHookProgram: () => cpmmHookProgram,
|
|
763
772
|
decodeCosignerConfig: () => decodeCosignerConfig,
|
|
764
773
|
decodeCosignerGateExpiryPayload: () => decodeCosignerGateExpiryPayload,
|
|
765
774
|
encodeCosignerGateExpiryPayload: () => encodeCosignerGateExpiryPayload,
|
|
775
|
+
encodeCpmmHookPayload: () => encodeCpmmHookPayload,
|
|
776
|
+
encodeDynamicFeeCosignerGatePayload: () => encodeDynamicFeeCosignerGatePayload,
|
|
777
|
+
encodeDynamicFeeSchedule: () => encodeDynamicFeeSchedule,
|
|
766
778
|
fetchAllCosignerConfig: () => fetchAllCosignerConfig,
|
|
767
779
|
fetchAllMaybeCosignerConfig: () => fetchAllMaybeCosignerConfig,
|
|
768
780
|
fetchCosignerConfig: () => fetchCosignerConfig,
|
|
@@ -782,9 +794,10 @@ __export(cosignerHook_exports, {
|
|
|
782
794
|
getCosignerConfigEncoder: () => getCosignerConfigEncoder,
|
|
783
795
|
getCosignerConfigSize: () => getCosignerConfigSize,
|
|
784
796
|
getCosignerGateStatus: () => getCosignerGateStatus,
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
797
|
+
getCpmmHookConfigAddress: () => getCpmmHookConfigAddress,
|
|
798
|
+
getCpmmHookErrorMessage: () => getCpmmHookErrorMessage,
|
|
799
|
+
getCpmmHookRemainingAccountAddresses: () => getCpmmHookRemainingAccountAddresses,
|
|
800
|
+
getCpmmHookRemainingAccounts: () => getCpmmHookRemainingAccounts,
|
|
788
801
|
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
|
|
789
802
|
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder,
|
|
790
803
|
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder,
|
|
@@ -809,15 +822,17 @@ __export(cosignerHook_exports, {
|
|
|
809
822
|
getSetAuthorityInstructionDataCodec: () => getSetAuthorityInstructionDataCodec,
|
|
810
823
|
getSetAuthorityInstructionDataDecoder: () => getSetAuthorityInstructionDataDecoder,
|
|
811
824
|
getSetAuthorityInstructionDataEncoder: () => getSetAuthorityInstructionDataEncoder,
|
|
812
|
-
|
|
813
|
-
|
|
825
|
+
identifyCpmmHookAccount: () => identifyCpmmHookAccount,
|
|
826
|
+
identifyCpmmHookInstruction: () => identifyCpmmHookInstruction,
|
|
814
827
|
isCosignerGateEnforced: () => isCosignerGateEnforced,
|
|
815
|
-
|
|
828
|
+
isCpmmHookError: () => isCpmmHookError,
|
|
829
|
+
isDynamicFeeSchedulePayload: () => isDynamicFeeSchedulePayload,
|
|
816
830
|
parseAddCosignerInstruction: () => parseAddCosignerInstruction,
|
|
817
|
-
|
|
831
|
+
parseCpmmHookInstruction: () => parseCpmmHookInstruction,
|
|
818
832
|
parseInitializeConfigInstruction: () => parseInitializeConfigInstruction2,
|
|
819
833
|
parseRemoveCosignerInstruction: () => parseRemoveCosignerInstruction,
|
|
820
|
-
parseSetAuthorityInstruction: () => parseSetAuthorityInstruction
|
|
834
|
+
parseSetAuthorityInstruction: () => parseSetAuthorityInstruction,
|
|
835
|
+
validateDynamicFeeScheduleArgs: () => validateDynamicFeeScheduleArgs
|
|
821
836
|
});
|
|
822
837
|
var COSIGNER_CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
823
838
|
133,
|
|
@@ -868,13 +883,13 @@ function decodeCosignerConfig(encodedAccount) {
|
|
|
868
883
|
getCosignerConfigDecoder()
|
|
869
884
|
);
|
|
870
885
|
}
|
|
871
|
-
async function fetchCosignerConfig(rpc,
|
|
872
|
-
const maybeAccount = await fetchMaybeCosignerConfig(rpc,
|
|
886
|
+
async function fetchCosignerConfig(rpc, address6, config) {
|
|
887
|
+
const maybeAccount = await fetchMaybeCosignerConfig(rpc, address6, config);
|
|
873
888
|
assertAccountExists(maybeAccount);
|
|
874
889
|
return maybeAccount;
|
|
875
890
|
}
|
|
876
|
-
async function fetchMaybeCosignerConfig(rpc,
|
|
877
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
891
|
+
async function fetchMaybeCosignerConfig(rpc, address6, config) {
|
|
892
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
878
893
|
return decodeCosignerConfig(maybeAccount);
|
|
879
894
|
}
|
|
880
895
|
async function fetchAllCosignerConfig(rpc, addresses, config) {
|
|
@@ -932,7 +947,7 @@ function getAddCosignerInstructionDataCodec() {
|
|
|
932
947
|
);
|
|
933
948
|
}
|
|
934
949
|
async function getAddCosignerInstructionAsync(input, config) {
|
|
935
|
-
const programAddress = config?.programAddress ??
|
|
950
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
936
951
|
const originalAccounts = {
|
|
937
952
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
938
953
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -983,7 +998,7 @@ async function getAddCosignerInstructionAsync(input, config) {
|
|
|
983
998
|
});
|
|
984
999
|
}
|
|
985
1000
|
function getAddCosignerInstruction(input, config) {
|
|
986
|
-
const programAddress = config?.programAddress ??
|
|
1001
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
987
1002
|
const originalAccounts = {
|
|
988
1003
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
989
1004
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1014,9 +1029,9 @@ function parseAddCosignerInstruction(instruction) {
|
|
|
1014
1029
|
}
|
|
1015
1030
|
let accountIndex = 0;
|
|
1016
1031
|
const getNextAccount = () => {
|
|
1017
|
-
const
|
|
1032
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1018
1033
|
accountIndex += 1;
|
|
1019
|
-
return
|
|
1034
|
+
return accountMeta2;
|
|
1020
1035
|
};
|
|
1021
1036
|
return {
|
|
1022
1037
|
programAddress: instruction.programAddress,
|
|
@@ -1061,7 +1076,7 @@ function getInitializeConfigInstructionDataCodec2() {
|
|
|
1061
1076
|
);
|
|
1062
1077
|
}
|
|
1063
1078
|
async function getInitializeConfigInstructionAsync2(input, config) {
|
|
1064
|
-
const programAddress = config?.programAddress ??
|
|
1079
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1065
1080
|
const originalAccounts = {
|
|
1066
1081
|
payer: { value: input.payer ?? null, isWritable: true },
|
|
1067
1082
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
@@ -1121,7 +1136,7 @@ async function getInitializeConfigInstructionAsync2(input, config) {
|
|
|
1121
1136
|
});
|
|
1122
1137
|
}
|
|
1123
1138
|
function getInitializeConfigInstruction2(input, config) {
|
|
1124
|
-
const programAddress = config?.programAddress ??
|
|
1139
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1125
1140
|
const originalAccounts = {
|
|
1126
1141
|
payer: { value: input.payer ?? null, isWritable: true },
|
|
1127
1142
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
@@ -1161,9 +1176,9 @@ function parseInitializeConfigInstruction2(instruction) {
|
|
|
1161
1176
|
}
|
|
1162
1177
|
let accountIndex = 0;
|
|
1163
1178
|
const getNextAccount = () => {
|
|
1164
|
-
const
|
|
1179
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1165
1180
|
accountIndex += 1;
|
|
1166
|
-
return
|
|
1181
|
+
return accountMeta2;
|
|
1167
1182
|
};
|
|
1168
1183
|
return {
|
|
1169
1184
|
programAddress: instruction.programAddress,
|
|
@@ -1214,7 +1229,7 @@ function getRemoveCosignerInstructionDataCodec() {
|
|
|
1214
1229
|
);
|
|
1215
1230
|
}
|
|
1216
1231
|
async function getRemoveCosignerInstructionAsync(input, config) {
|
|
1217
|
-
const programAddress = config?.programAddress ??
|
|
1232
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1218
1233
|
const originalAccounts = {
|
|
1219
1234
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1220
1235
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1265,7 +1280,7 @@ async function getRemoveCosignerInstructionAsync(input, config) {
|
|
|
1265
1280
|
});
|
|
1266
1281
|
}
|
|
1267
1282
|
function getRemoveCosignerInstruction(input, config) {
|
|
1268
|
-
const programAddress = config?.programAddress ??
|
|
1283
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1269
1284
|
const originalAccounts = {
|
|
1270
1285
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1271
1286
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1296,9 +1311,9 @@ function parseRemoveCosignerInstruction(instruction) {
|
|
|
1296
1311
|
}
|
|
1297
1312
|
let accountIndex = 0;
|
|
1298
1313
|
const getNextAccount = () => {
|
|
1299
|
-
const
|
|
1314
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1300
1315
|
accountIndex += 1;
|
|
1301
|
-
return
|
|
1316
|
+
return accountMeta2;
|
|
1302
1317
|
};
|
|
1303
1318
|
return {
|
|
1304
1319
|
programAddress: instruction.programAddress,
|
|
@@ -1343,7 +1358,7 @@ function getSetAuthorityInstructionDataCodec() {
|
|
|
1343
1358
|
);
|
|
1344
1359
|
}
|
|
1345
1360
|
async function getSetAuthorityInstructionAsync(input, config) {
|
|
1346
|
-
const programAddress = config?.programAddress ??
|
|
1361
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1347
1362
|
const originalAccounts = {
|
|
1348
1363
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1349
1364
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1394,7 +1409,7 @@ async function getSetAuthorityInstructionAsync(input, config) {
|
|
|
1394
1409
|
});
|
|
1395
1410
|
}
|
|
1396
1411
|
function getSetAuthorityInstruction(input, config) {
|
|
1397
|
-
const programAddress = config?.programAddress ??
|
|
1412
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1398
1413
|
const originalAccounts = {
|
|
1399
1414
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1400
1415
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1425,9 +1440,9 @@ function parseSetAuthorityInstruction(instruction) {
|
|
|
1425
1440
|
}
|
|
1426
1441
|
let accountIndex = 0;
|
|
1427
1442
|
const getNextAccount = () => {
|
|
1428
|
-
const
|
|
1443
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1429
1444
|
accountIndex += 1;
|
|
1430
|
-
return
|
|
1445
|
+
return accountMeta2;
|
|
1431
1446
|
};
|
|
1432
1447
|
return {
|
|
1433
1448
|
programAddress: instruction.programAddress,
|
|
@@ -1436,13 +1451,13 @@ function parseSetAuthorityInstruction(instruction) {
|
|
|
1436
1451
|
};
|
|
1437
1452
|
}
|
|
1438
1453
|
|
|
1439
|
-
// src/solana/generated/
|
|
1440
|
-
var
|
|
1441
|
-
var
|
|
1442
|
-
|
|
1443
|
-
return
|
|
1444
|
-
})(
|
|
1445
|
-
function
|
|
1454
|
+
// src/solana/generated/cpmmHook/programs/cpmmHook.ts
|
|
1455
|
+
var CPMM_HOOK_PROGRAM_ADDRESS = "HVsPNZh98TgChUXHwKrUG47SUqvGQHxUy5wZwcQLFD4i";
|
|
1456
|
+
var CpmmHookAccount = /* @__PURE__ */ ((CpmmHookAccount2) => {
|
|
1457
|
+
CpmmHookAccount2[CpmmHookAccount2["CosignerConfig"] = 0] = "CosignerConfig";
|
|
1458
|
+
return CpmmHookAccount2;
|
|
1459
|
+
})(CpmmHookAccount || {});
|
|
1460
|
+
function identifyCpmmHookAccount(account) {
|
|
1446
1461
|
const data = "data" in account ? account.data : account;
|
|
1447
1462
|
if (containsBytes(
|
|
1448
1463
|
data,
|
|
@@ -1455,17 +1470,17 @@ function identifyCosignerHookAccount(account) {
|
|
|
1455
1470
|
}
|
|
1456
1471
|
throw new SolanaError(
|
|
1457
1472
|
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
|
|
1458
|
-
{ accountData: data, programName: "
|
|
1473
|
+
{ accountData: data, programName: "cpmmHook" }
|
|
1459
1474
|
);
|
|
1460
1475
|
}
|
|
1461
|
-
var
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
return
|
|
1467
|
-
})(
|
|
1468
|
-
function
|
|
1476
|
+
var CpmmHookInstruction = /* @__PURE__ */ ((CpmmHookInstruction2) => {
|
|
1477
|
+
CpmmHookInstruction2[CpmmHookInstruction2["AddCosigner"] = 0] = "AddCosigner";
|
|
1478
|
+
CpmmHookInstruction2[CpmmHookInstruction2["InitializeConfig"] = 1] = "InitializeConfig";
|
|
1479
|
+
CpmmHookInstruction2[CpmmHookInstruction2["RemoveCosigner"] = 2] = "RemoveCosigner";
|
|
1480
|
+
CpmmHookInstruction2[CpmmHookInstruction2["SetAuthority"] = 3] = "SetAuthority";
|
|
1481
|
+
return CpmmHookInstruction2;
|
|
1482
|
+
})(CpmmHookInstruction || {});
|
|
1483
|
+
function identifyCpmmHookInstruction(instruction) {
|
|
1469
1484
|
const data = "data" in instruction ? instruction.data : instruction;
|
|
1470
1485
|
if (containsBytes(
|
|
1471
1486
|
data,
|
|
@@ -1505,11 +1520,11 @@ function identifyCosignerHookInstruction(instruction) {
|
|
|
1505
1520
|
}
|
|
1506
1521
|
throw new SolanaError(
|
|
1507
1522
|
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
|
1508
|
-
{ instructionData: data, programName: "
|
|
1523
|
+
{ instructionData: data, programName: "cpmmHook" }
|
|
1509
1524
|
);
|
|
1510
1525
|
}
|
|
1511
|
-
function
|
|
1512
|
-
const instructionType =
|
|
1526
|
+
function parseCpmmHookInstruction(instruction) {
|
|
1527
|
+
const instructionType = identifyCpmmHookInstruction(instruction);
|
|
1513
1528
|
switch (instructionType) {
|
|
1514
1529
|
case 0 /* AddCosigner */: {
|
|
1515
1530
|
assertIsInstructionWithAccounts(instruction);
|
|
@@ -1542,18 +1557,15 @@ function parseCosignerHookInstruction(instruction) {
|
|
|
1542
1557
|
default:
|
|
1543
1558
|
throw new SolanaError(
|
|
1544
1559
|
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
|
1545
|
-
{
|
|
1546
|
-
instructionType,
|
|
1547
|
-
programName: "cosignerHook"
|
|
1548
|
-
}
|
|
1560
|
+
{ instructionType, programName: "cpmmHook" }
|
|
1549
1561
|
);
|
|
1550
1562
|
}
|
|
1551
1563
|
}
|
|
1552
|
-
function
|
|
1564
|
+
function cpmmHookProgram() {
|
|
1553
1565
|
return (client) => {
|
|
1554
1566
|
return {
|
|
1555
1567
|
...client,
|
|
1556
|
-
|
|
1568
|
+
cpmmHook: {
|
|
1557
1569
|
accounts: {
|
|
1558
1570
|
cosignerConfig: addSelfFetchFunctions(
|
|
1559
1571
|
client,
|
|
@@ -1586,35 +1598,45 @@ function cosignerHookProgram() {
|
|
|
1586
1598
|
};
|
|
1587
1599
|
}
|
|
1588
1600
|
|
|
1589
|
-
// src/solana/generated/
|
|
1590
|
-
var
|
|
1591
|
-
var
|
|
1592
|
-
var
|
|
1593
|
-
var
|
|
1594
|
-
var
|
|
1595
|
-
var
|
|
1596
|
-
var
|
|
1601
|
+
// src/solana/generated/cpmmHook/errors/cpmmHook.ts
|
|
1602
|
+
var CPMM_HOOK_ERROR__INVALID_INSTRUCTION_DATA = 6e3;
|
|
1603
|
+
var CPMM_HOOK_ERROR__INVALID_SCHEDULE_DATA = 6001;
|
|
1604
|
+
var CPMM_HOOK_ERROR__INVALID_FEE = 6002;
|
|
1605
|
+
var CPMM_HOOK_ERROR__INVALID_DURATION = 6003;
|
|
1606
|
+
var CPMM_HOOK_ERROR__ARITHMETIC_OVERFLOW = 6004;
|
|
1607
|
+
var CPMM_HOOK_ERROR__INVALID_AUTHORITY = 6005;
|
|
1608
|
+
var CPMM_HOOK_ERROR__INVALID_CONFIG = 6006;
|
|
1609
|
+
var CPMM_HOOK_ERROR__INVALID_COSIGNER = 6007;
|
|
1610
|
+
var CPMM_HOOK_ERROR__COSIGNER_ALREADY_EXISTS = 6008;
|
|
1611
|
+
var CPMM_HOOK_ERROR__COSIGNER_NOT_FOUND = 6009;
|
|
1612
|
+
var CPMM_HOOK_ERROR__COSIGNER_LIST_FULL = 6010;
|
|
1613
|
+
var cpmmHookErrorMessages;
|
|
1597
1614
|
if (process.env.NODE_ENV !== "production") {
|
|
1598
|
-
|
|
1599
|
-
[
|
|
1600
|
-
[
|
|
1601
|
-
[
|
|
1602
|
-
[
|
|
1603
|
-
[
|
|
1604
|
-
[
|
|
1615
|
+
cpmmHookErrorMessages = {
|
|
1616
|
+
[CPMM_HOOK_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
1617
|
+
[CPMM_HOOK_ERROR__COSIGNER_ALREADY_EXISTS]: `Cosigner already exists`,
|
|
1618
|
+
[CPMM_HOOK_ERROR__COSIGNER_LIST_FULL]: `Cosigner list is full`,
|
|
1619
|
+
[CPMM_HOOK_ERROR__COSIGNER_NOT_FOUND]: `Cosigner not found`,
|
|
1620
|
+
[CPMM_HOOK_ERROR__INVALID_AUTHORITY]: `Invalid hook authority`,
|
|
1621
|
+
[CPMM_HOOK_ERROR__INVALID_CONFIG]: `Invalid cosigner hook config`,
|
|
1622
|
+
[CPMM_HOOK_ERROR__INVALID_COSIGNER]: `Invalid cosigner key`,
|
|
1623
|
+
[CPMM_HOOK_ERROR__INVALID_DURATION]: `Invalid fee duration`,
|
|
1624
|
+
[CPMM_HOOK_ERROR__INVALID_FEE]: `Invalid fee`,
|
|
1625
|
+
[CPMM_HOOK_ERROR__INVALID_INSTRUCTION_DATA]: `Invalid instruction data`,
|
|
1626
|
+
[CPMM_HOOK_ERROR__INVALID_SCHEDULE_DATA]: `Invalid schedule payload`
|
|
1605
1627
|
};
|
|
1606
1628
|
}
|
|
1607
|
-
function
|
|
1629
|
+
function getCpmmHookErrorMessage(code) {
|
|
1608
1630
|
if (process.env.NODE_ENV !== "production") {
|
|
1609
|
-
return
|
|
1631
|
+
return cpmmHookErrorMessages[code];
|
|
1610
1632
|
}
|
|
1611
1633
|
return "Error message not available in production bundles.";
|
|
1612
1634
|
}
|
|
1613
|
-
function
|
|
1635
|
+
function isCpmmHookError(error, transactionMessage, code) {
|
|
1614
1636
|
return isProgramError(
|
|
1615
1637
|
error,
|
|
1616
1638
|
transactionMessage,
|
|
1617
|
-
|
|
1639
|
+
CPMM_HOOK_PROGRAM_ADDRESS,
|
|
1618
1640
|
code
|
|
1619
1641
|
);
|
|
1620
1642
|
}
|
|
@@ -1655,11 +1677,11 @@ function getSetAuthorityArgsCodec() {
|
|
|
1655
1677
|
getSetAuthorityArgsDecoder()
|
|
1656
1678
|
);
|
|
1657
1679
|
}
|
|
1658
|
-
var
|
|
1659
|
-
"
|
|
1680
|
+
var DEVNET_CPMM_HOOK_PROGRAM_ID = address(
|
|
1681
|
+
"HVsPNZh98TgChUXHwKrUG47SUqvGQHxUy5wZwcQLFD4i"
|
|
1660
1682
|
);
|
|
1661
|
-
var
|
|
1662
|
-
var
|
|
1683
|
+
var CPMM_HOOK_PROGRAM_ID = DEVNET_CPMM_HOOK_PROGRAM_ID;
|
|
1684
|
+
var SEED_CPMM_HOOK_CONFIG = "cosigner_hook_config";
|
|
1663
1685
|
var MAX_COSIGNERS = 32;
|
|
1664
1686
|
var GATE_EXPIRY_DISABLED = 0;
|
|
1665
1687
|
var GATE_EXPIRY_UNIX_TIMESTAMP = 1;
|
|
@@ -1667,15 +1689,146 @@ var GATE_EXPIRY_SLOT = 2;
|
|
|
1667
1689
|
var GATE_EXPIRY_PAYLOAD_VERSION = 1;
|
|
1668
1690
|
var GATE_EXPIRY_HEADER_LEN = 10;
|
|
1669
1691
|
var GATE_EXPIRY_PAYLOAD_LEN = 42;
|
|
1692
|
+
var DYNAMIC_FEE_SCHEDULE_MAGIC = new Uint8Array([
|
|
1693
|
+
68,
|
|
1694
|
+
70,
|
|
1695
|
+
69,
|
|
1696
|
+
69,
|
|
1697
|
+
86,
|
|
1698
|
+
49,
|
|
1699
|
+
95,
|
|
1700
|
+
95
|
|
1701
|
+
]);
|
|
1702
|
+
var DYNAMIC_FEE_SCHEDULE_VERSION = 1;
|
|
1703
|
+
var DYNAMIC_FEE_SCHEDULE_LEN = 32;
|
|
1704
|
+
var DYNAMIC_FEE_SCHEDULE_HEADER_LEN = 16;
|
|
1705
|
+
var DYNAMIC_FEE_SCHEDULE_MAX_BPS = 1e4;
|
|
1706
|
+
var MAX_U64 = (1n << 64n) - 1n;
|
|
1707
|
+
function toBigInt(value) {
|
|
1708
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
1709
|
+
}
|
|
1710
|
+
function isValidExpiryMode(mode) {
|
|
1711
|
+
return mode === GATE_EXPIRY_UNIX_TIMESTAMP || mode === GATE_EXPIRY_SLOT;
|
|
1712
|
+
}
|
|
1713
|
+
function readU64Le(bytes, offset) {
|
|
1714
|
+
let value = 0n;
|
|
1715
|
+
for (let i = 0; i < 8; i++) {
|
|
1716
|
+
value |= BigInt(bytes[offset + i] ?? 0) << BigInt(i * 8);
|
|
1717
|
+
}
|
|
1718
|
+
return value;
|
|
1719
|
+
}
|
|
1720
|
+
function writeU64Le(bytes, offset, value) {
|
|
1721
|
+
for (let i = 0; i < 8; i++) {
|
|
1722
|
+
bytes[offset + i] = Number(value >> BigInt(i * 8) & 0xffn);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
function encodeCosignerGateExpiryPayload(expiry) {
|
|
1726
|
+
if (expiry.mode === GATE_EXPIRY_DISABLED) {
|
|
1727
|
+
if (expiry.cosigner !== void 0) {
|
|
1728
|
+
throw new Error("Cosigner hint cannot be encoded for disabled gates");
|
|
1729
|
+
}
|
|
1730
|
+
return new Uint8Array();
|
|
1731
|
+
}
|
|
1732
|
+
if (!isValidExpiryMode(expiry.mode)) {
|
|
1733
|
+
throw new Error(`Invalid cosigner gate expiry mode: ${expiry.mode}`);
|
|
1734
|
+
}
|
|
1735
|
+
const value = toBigInt(expiry.value);
|
|
1736
|
+
if (value < 0n || value > MAX_U64) {
|
|
1737
|
+
throw new Error(`Invalid cosigner gate expiry value: ${expiry.value}`);
|
|
1738
|
+
}
|
|
1739
|
+
if (expiry.cosigner === void 0) {
|
|
1740
|
+
throw new Error("Cosigner hint is required for expiring gates");
|
|
1741
|
+
}
|
|
1742
|
+
const payload = new Uint8Array(GATE_EXPIRY_PAYLOAD_LEN);
|
|
1743
|
+
payload[0] = GATE_EXPIRY_PAYLOAD_VERSION;
|
|
1744
|
+
payload[1] = expiry.mode;
|
|
1745
|
+
writeU64Le(payload, 2, value);
|
|
1746
|
+
payload.set(
|
|
1747
|
+
getAddressEncoder().encode(expiry.cosigner),
|
|
1748
|
+
GATE_EXPIRY_HEADER_LEN
|
|
1749
|
+
);
|
|
1750
|
+
return payload;
|
|
1751
|
+
}
|
|
1752
|
+
function decodeCosignerGateExpiryPayload(payload) {
|
|
1753
|
+
if (!payload || payload.length === 0) {
|
|
1754
|
+
return { mode: GATE_EXPIRY_DISABLED, value: 0n };
|
|
1755
|
+
}
|
|
1756
|
+
if (payload.length !== GATE_EXPIRY_PAYLOAD_LEN || payload[0] !== GATE_EXPIRY_PAYLOAD_VERSION) {
|
|
1757
|
+
return null;
|
|
1758
|
+
}
|
|
1759
|
+
const mode = payload[1] ?? GATE_EXPIRY_DISABLED;
|
|
1760
|
+
if (!isValidExpiryMode(mode)) {
|
|
1761
|
+
return null;
|
|
1762
|
+
}
|
|
1763
|
+
return {
|
|
1764
|
+
mode,
|
|
1765
|
+
value: readU64Le(payload, 2),
|
|
1766
|
+
cosigner: getAddressDecoder().decode(
|
|
1767
|
+
payload.slice(GATE_EXPIRY_HEADER_LEN, GATE_EXPIRY_PAYLOAD_LEN)
|
|
1768
|
+
)
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
function getCosignerGateStatus(hookPayload, clock = {}) {
|
|
1772
|
+
const expiry = decodeCosignerGateExpiryPayload(hookPayload);
|
|
1773
|
+
if (!expiry) {
|
|
1774
|
+
return {
|
|
1775
|
+
gateEnforced: true,
|
|
1776
|
+
expiryMode: GATE_EXPIRY_DISABLED,
|
|
1777
|
+
expiryValue: 0n,
|
|
1778
|
+
reason: "invalid_expiry_payload"
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
if (expiry.mode === GATE_EXPIRY_DISABLED) {
|
|
1782
|
+
return {
|
|
1783
|
+
gateEnforced: true,
|
|
1784
|
+
expiryMode: expiry.mode,
|
|
1785
|
+
expiryValue: expiry.value,
|
|
1786
|
+
reason: "expiry_disabled"
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
if (expiry.mode === GATE_EXPIRY_UNIX_TIMESTAMP) {
|
|
1790
|
+
const unixTimestamp = clock.unixTimestamp === void 0 ? BigInt(Math.floor(Date.now() / 1e3)) : toBigInt(clock.unixTimestamp);
|
|
1791
|
+
const expired = unixTimestamp >= expiry.value;
|
|
1792
|
+
return {
|
|
1793
|
+
gateEnforced: !expired,
|
|
1794
|
+
expiryMode: expiry.mode,
|
|
1795
|
+
expiryValue: expiry.value,
|
|
1796
|
+
reason: expired ? "timestamp_expired" : "timestamp_pending"
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
if (expiry.mode === GATE_EXPIRY_SLOT) {
|
|
1800
|
+
if (clock.slot === void 0) {
|
|
1801
|
+
return {
|
|
1802
|
+
gateEnforced: true,
|
|
1803
|
+
expiryMode: expiry.mode,
|
|
1804
|
+
expiryValue: expiry.value,
|
|
1805
|
+
reason: "slot_unavailable"
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
const expired = toBigInt(clock.slot) >= expiry.value;
|
|
1809
|
+
return {
|
|
1810
|
+
gateEnforced: !expired,
|
|
1811
|
+
expiryMode: expiry.mode,
|
|
1812
|
+
expiryValue: expiry.value,
|
|
1813
|
+
reason: expired ? "slot_expired" : "slot_pending"
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
return {
|
|
1817
|
+
gateEnforced: true,
|
|
1818
|
+
expiryMode: expiry.mode,
|
|
1819
|
+
expiryValue: expiry.value,
|
|
1820
|
+
reason: "invalid_expiry_mode"
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
function isCosignerGateEnforced(hookPayload, clock = {}) {
|
|
1824
|
+
return getCosignerGateStatus(hookPayload, clock).gateEnforced;
|
|
1825
|
+
}
|
|
1670
1826
|
var INITIALIZER_PROGRAM_ID = address(
|
|
1671
1827
|
"4h3Dqyo5qmteJoMxXt3tdtfXELDB6pdRTPU9mWruiKp1"
|
|
1672
1828
|
);
|
|
1673
1829
|
var BPF_LOADER_UPGRADEABLE_PROGRAM_ID = address(
|
|
1674
1830
|
"BPFLoaderUpgradeab1e11111111111111111111111"
|
|
1675
1831
|
);
|
|
1676
|
-
var CPMM_HOOK_PROGRAM_ID = address(
|
|
1677
|
-
"2vJ1c62knEwZbxp3XdHB4RSmCfz55pA6tRkCho63gW7u"
|
|
1678
|
-
);
|
|
1679
1832
|
var PREDICTION_HOOK_PROGRAM_ID = address(
|
|
1680
1833
|
"7QcQDANJVC17Jgc6KjjeagSkm2zAphgHVPK5agJzyihB"
|
|
1681
1834
|
);
|
|
@@ -1875,148 +2028,112 @@ function phaseLabel(phase) {
|
|
|
1875
2028
|
}
|
|
1876
2029
|
}
|
|
1877
2030
|
|
|
1878
|
-
// src/solana/
|
|
1879
|
-
var
|
|
1880
|
-
|
|
2031
|
+
// src/solana/cpmmHook/payload.ts
|
|
2032
|
+
var MAX_I64 = (1n << 63n) - 1n;
|
|
2033
|
+
var MAX_U32 = (1n << 32n) - 1n;
|
|
2034
|
+
function toBigInt2(value) {
|
|
1881
2035
|
return typeof value === "bigint" ? value : BigInt(value);
|
|
1882
2036
|
}
|
|
1883
|
-
function
|
|
1884
|
-
|
|
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);
|
|
2037
|
+
function assertU16Bps(label, value) {
|
|
2038
|
+
if (!Number.isInteger(value) || value < 0 || value > DYNAMIC_FEE_SCHEDULE_MAX_BPS) {
|
|
2039
|
+
throw new Error(`${label} must be an integer between 0 and 10000`);
|
|
1890
2040
|
}
|
|
1891
|
-
return value;
|
|
1892
2041
|
}
|
|
1893
|
-
function
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
}
|
|
2042
|
+
function writeI64Le(bytes, offset, value) {
|
|
2043
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2044
|
+
view.setBigInt64(offset, value, true);
|
|
1897
2045
|
}
|
|
1898
|
-
function
|
|
1899
|
-
|
|
1900
|
-
|
|
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;
|
|
2046
|
+
function writeU16Le(bytes, offset, value) {
|
|
2047
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2048
|
+
view.setUint16(offset, value, true);
|
|
1924
2049
|
}
|
|
1925
|
-
function
|
|
1926
|
-
|
|
1927
|
-
|
|
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
|
-
};
|
|
2050
|
+
function writeU32Le(bytes, offset, value) {
|
|
2051
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2052
|
+
view.setUint32(offset, Number(value), true);
|
|
1943
2053
|
}
|
|
1944
|
-
function
|
|
1945
|
-
const
|
|
1946
|
-
if (
|
|
1947
|
-
|
|
1948
|
-
gateEnforced: true,
|
|
1949
|
-
expiryMode: GATE_EXPIRY_DISABLED,
|
|
1950
|
-
expiryValue: 0n,
|
|
1951
|
-
reason: "invalid_expiry_payload"
|
|
1952
|
-
};
|
|
2054
|
+
function validateDynamicFeeScheduleArgs(schedule) {
|
|
2055
|
+
const startingTime = toBigInt2(schedule.startingTime);
|
|
2056
|
+
if (startingTime < 0n || startingTime > MAX_I64) {
|
|
2057
|
+
throw new Error("startingTime must be between 0 and i64::MAX");
|
|
1953
2058
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
expiryValue: expiry.value,
|
|
1959
|
-
reason: "expiry_disabled"
|
|
1960
|
-
};
|
|
2059
|
+
assertU16Bps("startFeeBps", schedule.startFeeBps);
|
|
2060
|
+
assertU16Bps("endFeeBps", schedule.endFeeBps);
|
|
2061
|
+
if (schedule.endFeeBps > schedule.startFeeBps) {
|
|
2062
|
+
throw new Error("endFeeBps must be less than or equal to startFeeBps");
|
|
1961
2063
|
}
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
return {
|
|
1966
|
-
gateEnforced: !expired,
|
|
1967
|
-
expiryMode: expiry.mode,
|
|
1968
|
-
expiryValue: expiry.value,
|
|
1969
|
-
reason: expired ? "timestamp_expired" : "timestamp_pending"
|
|
1970
|
-
};
|
|
2064
|
+
const durationSeconds = toBigInt2(schedule.durationSeconds);
|
|
2065
|
+
if (durationSeconds < 0n || durationSeconds > MAX_U32) {
|
|
2066
|
+
throw new Error("durationSeconds must be between 0 and u32::MAX");
|
|
1971
2067
|
}
|
|
1972
|
-
if (
|
|
1973
|
-
|
|
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
|
-
};
|
|
2068
|
+
if (schedule.startFeeBps > schedule.endFeeBps && durationSeconds === 0n) {
|
|
2069
|
+
throw new Error("durationSeconds must be nonzero for decaying schedules");
|
|
1988
2070
|
}
|
|
1989
|
-
return {
|
|
1990
|
-
gateEnforced: true,
|
|
1991
|
-
expiryMode: expiry.mode,
|
|
1992
|
-
expiryValue: expiry.value,
|
|
1993
|
-
reason: "invalid_expiry_mode"
|
|
1994
|
-
};
|
|
2071
|
+
return { startingTime, durationSeconds };
|
|
1995
2072
|
}
|
|
1996
|
-
function
|
|
1997
|
-
|
|
2073
|
+
function encodeDynamicFeeSchedule(schedule) {
|
|
2074
|
+
const { startingTime, durationSeconds } = validateDynamicFeeScheduleArgs(schedule);
|
|
2075
|
+
const payload = new Uint8Array(DYNAMIC_FEE_SCHEDULE_LEN);
|
|
2076
|
+
payload.set(DYNAMIC_FEE_SCHEDULE_MAGIC, 0);
|
|
2077
|
+
payload[8] = DYNAMIC_FEE_SCHEDULE_VERSION;
|
|
2078
|
+
writeI64Le(payload, DYNAMIC_FEE_SCHEDULE_HEADER_LEN, startingTime);
|
|
2079
|
+
writeU16Le(payload, 24, schedule.startFeeBps);
|
|
2080
|
+
writeU16Le(payload, 26, schedule.endFeeBps);
|
|
2081
|
+
writeU32Le(payload, 28, durationSeconds);
|
|
2082
|
+
return payload;
|
|
2083
|
+
}
|
|
2084
|
+
function encodeCpmmHookPayload(args = {}) {
|
|
2085
|
+
const schedulePayload = args.schedule ? encodeDynamicFeeSchedule(args.schedule) : new Uint8Array();
|
|
2086
|
+
const gatePayload = args.gateExpiry ? encodeCosignerGateExpiryPayload(args.gateExpiry) : new Uint8Array();
|
|
2087
|
+
const payload = new Uint8Array(schedulePayload.length + gatePayload.length);
|
|
2088
|
+
payload.set(schedulePayload, 0);
|
|
2089
|
+
payload.set(gatePayload, schedulePayload.length);
|
|
2090
|
+
return payload;
|
|
1998
2091
|
}
|
|
1999
|
-
function
|
|
2092
|
+
function encodeDynamicFeeCosignerGatePayload(args) {
|
|
2093
|
+
return encodeCosignerGateExpiryPayload(args);
|
|
2094
|
+
}
|
|
2095
|
+
function getCpmmHookRemainingAccounts({
|
|
2000
2096
|
namespace,
|
|
2097
|
+
config,
|
|
2001
2098
|
cosigner
|
|
2002
2099
|
}) {
|
|
2003
|
-
const
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2100
|
+
const signedHookRemainingAccounts = [namespace];
|
|
2101
|
+
if (config && config !== namespace) {
|
|
2102
|
+
signedHookRemainingAccounts.push(config);
|
|
2103
|
+
}
|
|
2104
|
+
if (cosigner) {
|
|
2105
|
+
signedHookRemainingAccounts.push(cosigner);
|
|
2106
|
+
}
|
|
2107
|
+
const unsignedHookRemainingAccounts = signedHookRemainingAccounts.map(
|
|
2108
|
+
getAddressFromRemainingAccount
|
|
2109
|
+
);
|
|
2007
2110
|
return {
|
|
2008
|
-
signedHookRemainingAccounts
|
|
2111
|
+
signedHookRemainingAccounts,
|
|
2009
2112
|
unsignedHookRemainingAccounts,
|
|
2010
2113
|
hookRemainingAccountsHash: computeRemainingAccountsHash(
|
|
2011
2114
|
unsignedHookRemainingAccounts
|
|
2012
2115
|
)
|
|
2013
2116
|
};
|
|
2014
2117
|
}
|
|
2118
|
+
function getCpmmHookRemainingAccountAddresses({
|
|
2119
|
+
namespace,
|
|
2120
|
+
config,
|
|
2121
|
+
cosigner
|
|
2122
|
+
}) {
|
|
2123
|
+
return getCpmmHookRemainingAccounts({
|
|
2124
|
+
namespace,
|
|
2125
|
+
config,
|
|
2126
|
+
cosigner
|
|
2127
|
+
}).unsignedHookRemainingAccounts;
|
|
2128
|
+
}
|
|
2129
|
+
function isDynamicFeeSchedulePayload(payload) {
|
|
2130
|
+
return payload.length >= DYNAMIC_FEE_SCHEDULE_LEN && DYNAMIC_FEE_SCHEDULE_MAGIC.every((byte, index) => payload[index] === byte);
|
|
2131
|
+
}
|
|
2015
2132
|
var textEncoder2 = new TextEncoder();
|
|
2016
|
-
async function
|
|
2133
|
+
async function getCpmmHookConfigAddress(programId = CPMM_HOOK_PROGRAM_ID) {
|
|
2017
2134
|
return getProgramDerivedAddress({
|
|
2018
2135
|
programAddress: programId,
|
|
2019
|
-
seeds: [textEncoder2.encode(
|
|
2136
|
+
seeds: [textEncoder2.encode(SEED_CPMM_HOOK_CONFIG)]
|
|
2020
2137
|
});
|
|
2021
2138
|
}
|
|
2022
2139
|
|
|
@@ -2024,7 +2141,6 @@ async function getCosignerHookConfigAddress(programId = COSIGNER_HOOK_PROGRAM_ID
|
|
|
2024
2141
|
var initializer_exports = {};
|
|
2025
2142
|
__export(initializer_exports, {
|
|
2026
2143
|
BPF_LOADER_UPGRADEABLE_PROGRAM_ID: () => BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
|
|
2027
|
-
CPMM_HOOK_PROGRAM_ID: () => CPMM_HOOK_PROGRAM_ID,
|
|
2028
2144
|
CURVE_KIND_XYK: () => CURVE_KIND_XYK,
|
|
2029
2145
|
CURVE_PARAMS_FORMAT_XYK_V0: () => CURVE_PARAMS_FORMAT_XYK_V0,
|
|
2030
2146
|
DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND: () => DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND,
|
|
@@ -3141,15 +3257,6 @@ function launchIdFromU64(launchId) {
|
|
|
3141
3257
|
out.set(encodeU64LE(launchId), 0);
|
|
3142
3258
|
return out;
|
|
3143
3259
|
}
|
|
3144
|
-
function isTransactionSigner2(value) {
|
|
3145
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
3146
|
-
}
|
|
3147
|
-
function createSignerAccountMeta(value, role) {
|
|
3148
|
-
if (isTransactionSigner2(value)) {
|
|
3149
|
-
return { address: value.address, role, signer: value };
|
|
3150
|
-
}
|
|
3151
|
-
return { address: value, role };
|
|
3152
|
-
}
|
|
3153
3260
|
function createInitializeConfigInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
3154
3261
|
const {
|
|
3155
3262
|
admin,
|
|
@@ -3158,7 +3265,7 @@ function createInitializeConfigInstruction(accounts, args, programId = INITIALIZ
|
|
|
3158
3265
|
systemProgram = SYSTEM_PROGRAM_ADDRESS
|
|
3159
3266
|
} = accounts;
|
|
3160
3267
|
const keys = [
|
|
3161
|
-
|
|
3268
|
+
createAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
|
|
3162
3269
|
{ address: config, role: AccountRole.WRITABLE },
|
|
3163
3270
|
{ address: programData, role: AccountRole.READONLY },
|
|
3164
3271
|
{ address: systemProgram, role: AccountRole.READONLY }
|
|
@@ -3168,19 +3275,10 @@ function createInitializeConfigInstruction(accounts, args, programId = INITIALIZ
|
|
|
3168
3275
|
);
|
|
3169
3276
|
return { programAddress: programId, accounts: keys, data };
|
|
3170
3277
|
}
|
|
3171
|
-
function isTransactionSigner3(value) {
|
|
3172
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
3173
|
-
}
|
|
3174
|
-
function createSignerAccountMeta2(value, role) {
|
|
3175
|
-
if (isTransactionSigner3(value)) {
|
|
3176
|
-
return { address: value.address, role, signer: value };
|
|
3177
|
-
}
|
|
3178
|
-
return { address: value, role };
|
|
3179
|
-
}
|
|
3180
3278
|
function createSetMigratorAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
|
|
3181
3279
|
const { admin, config } = accounts;
|
|
3182
3280
|
const keys = [
|
|
3183
|
-
|
|
3281
|
+
createAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
|
|
3184
3282
|
{ address: config, role: AccountRole.WRITABLE }
|
|
3185
3283
|
];
|
|
3186
3284
|
const data = new Uint8Array(
|
|
@@ -3188,19 +3286,10 @@ function createSetMigratorAllowlistInstruction(accounts, allowlist, programId =
|
|
|
3188
3286
|
);
|
|
3189
3287
|
return { programAddress: programId, accounts: keys, data };
|
|
3190
3288
|
}
|
|
3191
|
-
function isTransactionSigner4(value) {
|
|
3192
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
3193
|
-
}
|
|
3194
|
-
function createSignerAccountMeta3(value, role) {
|
|
3195
|
-
if (isTransactionSigner4(value)) {
|
|
3196
|
-
return { address: value.address, role, signer: value };
|
|
3197
|
-
}
|
|
3198
|
-
return { address: value, role };
|
|
3199
|
-
}
|
|
3200
3289
|
function createSetHookAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
|
|
3201
3290
|
const { admin, config } = accounts;
|
|
3202
3291
|
const keys = [
|
|
3203
|
-
|
|
3292
|
+
createAccountMeta(admin, AccountRole.WRITABLE_SIGNER),
|
|
3204
3293
|
{ address: config, role: AccountRole.WRITABLE }
|
|
3205
3294
|
];
|
|
3206
3295
|
const data = new Uint8Array(
|
|
@@ -3215,6 +3304,17 @@ var SEED_STATE = "state";
|
|
|
3215
3304
|
var SEED_MIGRATION_AUTHORITY = "migration_authority";
|
|
3216
3305
|
var MAX_RECIPIENTS = 2;
|
|
3217
3306
|
var CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS = {
|
|
3307
|
+
// SHA256("global:create_spot_pool")[0:8]
|
|
3308
|
+
createSpotPool: new Uint8Array([
|
|
3309
|
+
13,
|
|
3310
|
+
137,
|
|
3311
|
+
16,
|
|
3312
|
+
26,
|
|
3313
|
+
40,
|
|
3314
|
+
36,
|
|
3315
|
+
110,
|
|
3316
|
+
26
|
|
3317
|
+
]),
|
|
3218
3318
|
// SHA256("global:register_launch")[0:8]
|
|
3219
3319
|
registerLaunch: new Uint8Array([
|
|
3220
3320
|
114,
|
|
@@ -3305,13 +3405,13 @@ function decodeClaimReceipt(encodedAccount) {
|
|
|
3305
3405
|
getClaimReceiptDecoder()
|
|
3306
3406
|
);
|
|
3307
3407
|
}
|
|
3308
|
-
async function fetchClaimReceipt(rpc,
|
|
3309
|
-
const maybeAccount = await fetchMaybeClaimReceipt(rpc,
|
|
3408
|
+
async function fetchClaimReceipt(rpc, address6, config) {
|
|
3409
|
+
const maybeAccount = await fetchMaybeClaimReceipt(rpc, address6, config);
|
|
3310
3410
|
assertAccountExists(maybeAccount);
|
|
3311
3411
|
return maybeAccount;
|
|
3312
3412
|
}
|
|
3313
|
-
async function fetchMaybeClaimReceipt(rpc,
|
|
3314
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3413
|
+
async function fetchMaybeClaimReceipt(rpc, address6, config) {
|
|
3414
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3315
3415
|
return decodeClaimReceipt(maybeAccount);
|
|
3316
3416
|
}
|
|
3317
3417
|
async function fetchAllClaimReceipt(rpc, addresses, config) {
|
|
@@ -3375,13 +3475,13 @@ function decodeEntry(encodedAccount) {
|
|
|
3375
3475
|
getEntryDecoder()
|
|
3376
3476
|
);
|
|
3377
3477
|
}
|
|
3378
|
-
async function fetchEntry(rpc,
|
|
3379
|
-
const maybeAccount = await fetchMaybeEntry(rpc,
|
|
3478
|
+
async function fetchEntry(rpc, address6, config) {
|
|
3479
|
+
const maybeAccount = await fetchMaybeEntry(rpc, address6, config);
|
|
3380
3480
|
assertAccountExists(maybeAccount);
|
|
3381
3481
|
return maybeAccount;
|
|
3382
3482
|
}
|
|
3383
|
-
async function fetchMaybeEntry(rpc,
|
|
3384
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3483
|
+
async function fetchMaybeEntry(rpc, address6, config) {
|
|
3484
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3385
3485
|
return decodeEntry(maybeAccount);
|
|
3386
3486
|
}
|
|
3387
3487
|
async function fetchAllEntry(rpc, addresses, config) {
|
|
@@ -3443,13 +3543,13 @@ function decodeEntryByMint(encodedAccount) {
|
|
|
3443
3543
|
getEntryByMintDecoder()
|
|
3444
3544
|
);
|
|
3445
3545
|
}
|
|
3446
|
-
async function fetchEntryByMint(rpc,
|
|
3447
|
-
const maybeAccount = await fetchMaybeEntryByMint(rpc,
|
|
3546
|
+
async function fetchEntryByMint(rpc, address6, config) {
|
|
3547
|
+
const maybeAccount = await fetchMaybeEntryByMint(rpc, address6, config);
|
|
3448
3548
|
assertAccountExists(maybeAccount);
|
|
3449
3549
|
return maybeAccount;
|
|
3450
3550
|
}
|
|
3451
|
-
async function fetchMaybeEntryByMint(rpc,
|
|
3452
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3551
|
+
async function fetchMaybeEntryByMint(rpc, address6, config) {
|
|
3552
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3453
3553
|
return decodeEntryByMint(maybeAccount);
|
|
3454
3554
|
}
|
|
3455
3555
|
async function fetchAllEntryByMint(rpc, addresses, config) {
|
|
@@ -3521,13 +3621,13 @@ function decodeInitConfig(encodedAccount) {
|
|
|
3521
3621
|
getInitConfigDecoder2()
|
|
3522
3622
|
);
|
|
3523
3623
|
}
|
|
3524
|
-
async function fetchInitConfig(rpc,
|
|
3525
|
-
const maybeAccount = await fetchMaybeInitConfig(rpc,
|
|
3624
|
+
async function fetchInitConfig(rpc, address6, config) {
|
|
3625
|
+
const maybeAccount = await fetchMaybeInitConfig(rpc, address6, config);
|
|
3526
3626
|
assertAccountExists(maybeAccount);
|
|
3527
3627
|
return maybeAccount;
|
|
3528
3628
|
}
|
|
3529
|
-
async function fetchMaybeInitConfig(rpc,
|
|
3530
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3629
|
+
async function fetchMaybeInitConfig(rpc, address6, config) {
|
|
3630
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3531
3631
|
return decodeInitConfig(maybeAccount);
|
|
3532
3632
|
}
|
|
3533
3633
|
async function fetchAllInitConfig(rpc, addresses, config) {
|
|
@@ -3827,13 +3927,13 @@ function decodeLaunch(encodedAccount) {
|
|
|
3827
3927
|
getLaunchDecoder2()
|
|
3828
3928
|
);
|
|
3829
3929
|
}
|
|
3830
|
-
async function fetchLaunch(rpc,
|
|
3831
|
-
const maybeAccount = await fetchMaybeLaunch(rpc,
|
|
3930
|
+
async function fetchLaunch(rpc, address6, config) {
|
|
3931
|
+
const maybeAccount = await fetchMaybeLaunch(rpc, address6, config);
|
|
3832
3932
|
assertAccountExists(maybeAccount);
|
|
3833
3933
|
return maybeAccount;
|
|
3834
3934
|
}
|
|
3835
|
-
async function fetchMaybeLaunch(rpc,
|
|
3836
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3935
|
+
async function fetchMaybeLaunch(rpc, address6, config) {
|
|
3936
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3837
3937
|
return decodeLaunch(maybeAccount);
|
|
3838
3938
|
}
|
|
3839
3939
|
async function fetchAllLaunch(rpc, addresses, config) {
|
|
@@ -3907,13 +4007,13 @@ function decodeMarket(encodedAccount) {
|
|
|
3907
4007
|
getMarketDecoder()
|
|
3908
4008
|
);
|
|
3909
4009
|
}
|
|
3910
|
-
async function fetchMarket(rpc,
|
|
3911
|
-
const maybeAccount = await fetchMaybeMarket(rpc,
|
|
4010
|
+
async function fetchMarket(rpc, address6, config) {
|
|
4011
|
+
const maybeAccount = await fetchMaybeMarket(rpc, address6, config);
|
|
3912
4012
|
assertAccountExists(maybeAccount);
|
|
3913
4013
|
return maybeAccount;
|
|
3914
4014
|
}
|
|
3915
|
-
async function fetchMaybeMarket(rpc,
|
|
3916
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
4015
|
+
async function fetchMaybeMarket(rpc, address6, config) {
|
|
4016
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3917
4017
|
return decodeMarket(maybeAccount);
|
|
3918
4018
|
}
|
|
3919
4019
|
async function fetchAllMarket(rpc, addresses, config) {
|
|
@@ -3979,13 +4079,13 @@ function decodeOracleState2(encodedAccount) {
|
|
|
3979
4079
|
getOracleStateDecoder()
|
|
3980
4080
|
);
|
|
3981
4081
|
}
|
|
3982
|
-
async function fetchOracleState(rpc,
|
|
3983
|
-
const maybeAccount = await fetchMaybeOracleState(rpc,
|
|
4082
|
+
async function fetchOracleState(rpc, address6, config) {
|
|
4083
|
+
const maybeAccount = await fetchMaybeOracleState(rpc, address6, config);
|
|
3984
4084
|
assertAccountExists(maybeAccount);
|
|
3985
4085
|
return maybeAccount;
|
|
3986
4086
|
}
|
|
3987
|
-
async function fetchMaybeOracleState(rpc,
|
|
3988
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
4087
|
+
async function fetchMaybeOracleState(rpc, address6, config) {
|
|
4088
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3989
4089
|
return decodeOracleState2(maybeAccount);
|
|
3990
4090
|
}
|
|
3991
4091
|
async function fetchAllOracleState(rpc, addresses, config) {
|
|
@@ -4255,9 +4355,9 @@ function parseClaimInstruction(instruction) {
|
|
|
4255
4355
|
}
|
|
4256
4356
|
let accountIndex = 0;
|
|
4257
4357
|
const getNextAccount = () => {
|
|
4258
|
-
const
|
|
4358
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4259
4359
|
accountIndex += 1;
|
|
4260
|
-
return
|
|
4360
|
+
return accountMeta2;
|
|
4261
4361
|
};
|
|
4262
4362
|
return {
|
|
4263
4363
|
programAddress: instruction.programAddress,
|
|
@@ -4563,9 +4663,9 @@ function parseMigrateEntryInstruction(instruction) {
|
|
|
4563
4663
|
}
|
|
4564
4664
|
let accountIndex = 0;
|
|
4565
4665
|
const getNextAccount = () => {
|
|
4566
|
-
const
|
|
4666
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4567
4667
|
accountIndex += 1;
|
|
4568
|
-
return
|
|
4668
|
+
return accountMeta2;
|
|
4569
4669
|
};
|
|
4570
4670
|
return {
|
|
4571
4671
|
programAddress: instruction.programAddress,
|
|
@@ -4665,9 +4765,9 @@ function parsePreviewPayoutIfWinnerInstruction(instruction) {
|
|
|
4665
4765
|
}
|
|
4666
4766
|
let accountIndex = 0;
|
|
4667
4767
|
const getNextAccount = () => {
|
|
4668
|
-
const
|
|
4768
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4669
4769
|
accountIndex += 1;
|
|
4670
|
-
return
|
|
4770
|
+
return accountMeta2;
|
|
4671
4771
|
};
|
|
4672
4772
|
return {
|
|
4673
4773
|
programAddress: instruction.programAddress,
|
|
@@ -4976,9 +5076,9 @@ function parseRegisterEntryInstruction(instruction) {
|
|
|
4976
5076
|
}
|
|
4977
5077
|
let accountIndex = 0;
|
|
4978
5078
|
const getNextAccount = () => {
|
|
4979
|
-
const
|
|
5079
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4980
5080
|
accountIndex += 1;
|
|
4981
|
-
return
|
|
5081
|
+
return accountMeta2;
|
|
4982
5082
|
};
|
|
4983
5083
|
return {
|
|
4984
5084
|
programAddress: instruction.programAddress,
|
|
@@ -5269,15 +5369,6 @@ async function getPredictionEntryByMintAddress(market, mint, programId = PREDICT
|
|
|
5269
5369
|
}
|
|
5270
5370
|
|
|
5271
5371
|
// src/solana/initializer/instructions/initializeLaunch.ts
|
|
5272
|
-
function isTransactionSigner5(value) {
|
|
5273
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
5274
|
-
}
|
|
5275
|
-
function createAccountMeta(value, role) {
|
|
5276
|
-
if (isTransactionSigner5(value)) {
|
|
5277
|
-
return { address: value.address, role, signer: value };
|
|
5278
|
-
}
|
|
5279
|
-
return { address: value, role };
|
|
5280
|
-
}
|
|
5281
5372
|
async function getTokenMetadataAddress(mint) {
|
|
5282
5373
|
const encoder = getAddressEncoder();
|
|
5283
5374
|
const [metadataAddress] = await getProgramDerivedAddress({
|
|
@@ -5334,7 +5425,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
|
|
|
5334
5425
|
}
|
|
5335
5426
|
const createHooksEnabled = (args.hookFlags & (HF_BEFORE_CREATE | HF_AFTER_CREATE)) !== 0;
|
|
5336
5427
|
const hookCreateRemainingAccountAddresses = hookCreateRemainingAccounts.map(
|
|
5337
|
-
|
|
5428
|
+
getAddressFromAddressOrSigner
|
|
5338
5429
|
);
|
|
5339
5430
|
const swapFeeBps = args.swapFeeBps ?? args.curveFeeBps;
|
|
5340
5431
|
if (swapFeeBps === void 0) {
|
|
@@ -5396,7 +5487,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
|
|
|
5396
5487
|
...hookCreateRemainingAccounts.map(
|
|
5397
5488
|
(account) => createAccountMeta(
|
|
5398
5489
|
account,
|
|
5399
|
-
|
|
5490
|
+
isTransactionSigner(account) ? AccountRole.READONLY_SIGNER : AccountRole.READONLY
|
|
5400
5491
|
)
|
|
5401
5492
|
)
|
|
5402
5493
|
);
|
|
@@ -5420,7 +5511,7 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
|
|
|
5420
5511
|
if (migratorProgram === PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
|
|
5421
5512
|
const oracleState = args.namespace;
|
|
5422
5513
|
const entryId = args.launchId;
|
|
5423
|
-
const baseMintAddress =
|
|
5514
|
+
const baseMintAddress = getAddressFromAddressOrSigner(baseMint);
|
|
5424
5515
|
const [market] = await getPredictionMarketAddress(oracleState, quoteMint);
|
|
5425
5516
|
const [potVault] = await getPredictionPotVaultAddress(market);
|
|
5426
5517
|
const [marketAuthority] = await getPredictionMarketAuthorityAddress(market);
|
|
@@ -5438,28 +5529,6 @@ async function createInitializeLaunchInstruction(accounts, args, programId = INI
|
|
|
5438
5529
|
}
|
|
5439
5530
|
return { programAddress: programId, accounts: keys, data };
|
|
5440
5531
|
}
|
|
5441
|
-
function isTransactionSigner6(value) {
|
|
5442
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
5443
|
-
}
|
|
5444
|
-
function createAccountMeta2(value, role) {
|
|
5445
|
-
if (isTransactionSigner6(value)) {
|
|
5446
|
-
return { address: value.address, role, signer: value };
|
|
5447
|
-
}
|
|
5448
|
-
return { address: value, role };
|
|
5449
|
-
}
|
|
5450
|
-
function createRemainingAccountMeta(value) {
|
|
5451
|
-
if (typeof value === "string") {
|
|
5452
|
-
return { address: value, role: AccountRole.READONLY };
|
|
5453
|
-
}
|
|
5454
|
-
if (isTransactionSigner6(value)) {
|
|
5455
|
-
return {
|
|
5456
|
-
address: value.address,
|
|
5457
|
-
role: AccountRole.READONLY_SIGNER,
|
|
5458
|
-
signer: value
|
|
5459
|
-
};
|
|
5460
|
-
}
|
|
5461
|
-
return value;
|
|
5462
|
-
}
|
|
5463
5532
|
function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
5464
5533
|
const {
|
|
5465
5534
|
launch,
|
|
@@ -5486,7 +5555,7 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
|
|
|
5486
5555
|
{ address: userQuoteAccount, role: AccountRole.WRITABLE },
|
|
5487
5556
|
{ address: baseMint, role: AccountRole.READONLY },
|
|
5488
5557
|
{ address: quoteMint, role: AccountRole.READONLY },
|
|
5489
|
-
|
|
5558
|
+
createAccountMeta(user, AccountRole.READONLY_SIGNER),
|
|
5490
5559
|
// hook_program is Optional in the on-chain struct but still occupies a fixed
|
|
5491
5560
|
// slot (token_program follows it). Always emit it — use SYSTEM_PROGRAM_ADDRESS as the
|
|
5492
5561
|
// no-op placeholder when no real hook is configured.
|
|
@@ -5494,22 +5563,13 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
|
|
|
5494
5563
|
{ address: launchFeeState, role: AccountRole.WRITABLE },
|
|
5495
5564
|
{ address: baseTokenProgram, role: AccountRole.READONLY },
|
|
5496
5565
|
{ address: quoteTokenProgram, role: AccountRole.READONLY },
|
|
5497
|
-
...remainingAccounts.map(
|
|
5566
|
+
...remainingAccounts.map(createReadonlyRemainingAccountMeta)
|
|
5498
5567
|
];
|
|
5499
5568
|
const data = new Uint8Array(
|
|
5500
5569
|
getCurveSwapExactInInstructionDataEncoder().encode(args)
|
|
5501
5570
|
);
|
|
5502
5571
|
return { programAddress: programId, accounts: keys, data };
|
|
5503
5572
|
}
|
|
5504
|
-
function isTransactionSigner7(value) {
|
|
5505
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
5506
|
-
}
|
|
5507
|
-
function createSignerAccountMeta4(value, role) {
|
|
5508
|
-
if (isTransactionSigner7(value)) {
|
|
5509
|
-
return { address: value.address, role, signer: value };
|
|
5510
|
-
}
|
|
5511
|
-
return { address: value, role };
|
|
5512
|
-
}
|
|
5513
5573
|
function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
|
|
5514
5574
|
const {
|
|
5515
5575
|
config,
|
|
@@ -5537,7 +5597,7 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
|
|
|
5537
5597
|
{ address: quoteVault, role: AccountRole.WRITABLE },
|
|
5538
5598
|
{ address: launchFeeState, role: AccountRole.READONLY },
|
|
5539
5599
|
{ address: migratorProgram, role: AccountRole.READONLY },
|
|
5540
|
-
|
|
5600
|
+
createAccountMeta(payer, AccountRole.WRITABLE_SIGNER),
|
|
5541
5601
|
{ address: baseTokenProgram, role: AccountRole.READONLY },
|
|
5542
5602
|
{ address: quoteTokenProgram, role: AccountRole.READONLY },
|
|
5543
5603
|
{ address: systemProgram, role: AccountRole.READONLY },
|
|
@@ -5548,22 +5608,6 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
|
|
|
5548
5608
|
);
|
|
5549
5609
|
return { programAddress: programId, accounts: keys, data };
|
|
5550
5610
|
}
|
|
5551
|
-
function isTransactionSigner8(value) {
|
|
5552
|
-
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
5553
|
-
}
|
|
5554
|
-
function createRemainingAccountMeta2(value) {
|
|
5555
|
-
if (typeof value === "string") {
|
|
5556
|
-
return { address: value, role: AccountRole.READONLY };
|
|
5557
|
-
}
|
|
5558
|
-
if (isTransactionSigner8(value)) {
|
|
5559
|
-
return {
|
|
5560
|
-
address: value.address,
|
|
5561
|
-
role: AccountRole.READONLY_SIGNER,
|
|
5562
|
-
signer: value
|
|
5563
|
-
};
|
|
5564
|
-
}
|
|
5565
|
-
return value;
|
|
5566
|
-
}
|
|
5567
5611
|
var previewSwapExactInResultCodec = getStructCodec([
|
|
5568
5612
|
["amountOut", getU64Codec()],
|
|
5569
5613
|
["feePaid", getU64Codec()]
|
|
@@ -5586,7 +5630,7 @@ function createPreviewSwapExactInInstruction(accounts, args, programId = INITIAL
|
|
|
5586
5630
|
const accountsList = hookProgram ? [...keys, { address: hookProgram, role: AccountRole.READONLY }] : keys;
|
|
5587
5631
|
const accountsWithRemaining = [
|
|
5588
5632
|
...accountsList,
|
|
5589
|
-
...remainingAccounts.map(
|
|
5633
|
+
...remainingAccounts.map(createReadonlyRemainingAccountMeta)
|
|
5590
5634
|
];
|
|
5591
5635
|
const data = new Uint8Array(
|
|
5592
5636
|
getPreviewSwapExactInInstructionDataEncoder2().encode(args)
|
|
@@ -5629,6 +5673,9 @@ __export(cpmmMigrator_exports, {
|
|
|
5629
5673
|
SEED_STATE: () => SEED_STATE,
|
|
5630
5674
|
buildCpmmMigrationRemainingAccounts: () => buildCpmmMigrationRemainingAccounts,
|
|
5631
5675
|
buildCpmmMigrationRemainingAccountsHash: () => buildCpmmMigrationRemainingAccountsHash,
|
|
5676
|
+
createSpotPoolInstruction: () => createSpotPoolInstruction,
|
|
5677
|
+
deriveSpotPoolAccounts: () => deriveSpotPoolAccounts,
|
|
5678
|
+
encodeCreateSpotPoolPayload: () => encodeCreateSpotPoolPayload,
|
|
5632
5679
|
encodeMigratePayload: () => encodeMigratePayload,
|
|
5633
5680
|
encodeRegisterLaunchPayload: () => encodeRegisterLaunchPayload,
|
|
5634
5681
|
fetchCpmmMigratorState: () => fetchCpmmMigratorState,
|
|
@@ -5637,6 +5684,14 @@ __export(cpmmMigrator_exports, {
|
|
|
5637
5684
|
getCpmmMigratorStateCodec: () => getCpmmMigratorStateCodec,
|
|
5638
5685
|
getCpmmMigratorStateDecoder: () => getCpmmMigratorStateDecoder,
|
|
5639
5686
|
getCpmmMigratorStateEncoder: () => getCpmmMigratorStateEncoder,
|
|
5687
|
+
getCreateSpotPoolArgsCodec: () => getCreateSpotPoolArgsCodec,
|
|
5688
|
+
getCreateSpotPoolArgsDecoder: () => getCreateSpotPoolArgsDecoder,
|
|
5689
|
+
getCreateSpotPoolArgsEncoder: () => getCreateSpotPoolArgsEncoder,
|
|
5690
|
+
getCreateSpotPoolInstruction: () => getCreateSpotPoolInstruction,
|
|
5691
|
+
getCreateSpotPoolInstructionAsync: () => getCreateSpotPoolInstructionAsync,
|
|
5692
|
+
getCreateSpotPoolInstructionDataCodec: () => getCreateSpotPoolInstructionDataCodec,
|
|
5693
|
+
getCreateSpotPoolInstructionDataDecoder: () => getCreateSpotPoolInstructionDataDecoder,
|
|
5694
|
+
getCreateSpotPoolInstructionDataEncoder: () => getCreateSpotPoolInstructionDataEncoder,
|
|
5640
5695
|
getMigrateArgsCodec: () => getMigrateArgsCodec,
|
|
5641
5696
|
getMigrateArgsDecoder: () => getMigrateArgsDecoder,
|
|
5642
5697
|
getMigrateArgsEncoder: () => getMigrateArgsEncoder,
|
|
@@ -5647,6 +5702,30 @@ __export(cpmmMigrator_exports, {
|
|
|
5647
5702
|
getRegisterLaunchArgsDecoder: () => getRegisterLaunchArgsDecoder,
|
|
5648
5703
|
getRegisterLaunchArgsEncoder: () => getRegisterLaunchArgsEncoder
|
|
5649
5704
|
});
|
|
5705
|
+
function getCreateSpotPoolArgsEncoder() {
|
|
5706
|
+
return getStructEncoder([
|
|
5707
|
+
["swapFeeBps", getU16Encoder()],
|
|
5708
|
+
["positionId", getU64Encoder()],
|
|
5709
|
+
["amount0Max", getU64Encoder()],
|
|
5710
|
+
["amount1Max", getU64Encoder()],
|
|
5711
|
+
["minSharesOut", getU128Encoder()]
|
|
5712
|
+
]);
|
|
5713
|
+
}
|
|
5714
|
+
function getCreateSpotPoolArgsDecoder() {
|
|
5715
|
+
return getStructDecoder([
|
|
5716
|
+
["swapFeeBps", getU16Decoder()],
|
|
5717
|
+
["positionId", getU64Decoder()],
|
|
5718
|
+
["amount0Max", getU64Decoder()],
|
|
5719
|
+
["amount1Max", getU64Decoder()],
|
|
5720
|
+
["minSharesOut", getU128Decoder()]
|
|
5721
|
+
]);
|
|
5722
|
+
}
|
|
5723
|
+
function getCreateSpotPoolArgsCodec() {
|
|
5724
|
+
return combineCodec(
|
|
5725
|
+
getCreateSpotPoolArgsEncoder(),
|
|
5726
|
+
getCreateSpotPoolArgsDecoder()
|
|
5727
|
+
);
|
|
5728
|
+
}
|
|
5650
5729
|
function getMigrateArgsEncoder() {
|
|
5651
5730
|
return getStructEncoder([
|
|
5652
5731
|
["baseForDistribution", getU64Encoder()],
|
|
@@ -5717,87 +5796,474 @@ function getRegisterLaunchArgsDecoder() {
|
|
|
5717
5796
|
]
|
|
5718
5797
|
]);
|
|
5719
5798
|
}
|
|
5720
|
-
function getRegisterLaunchArgsCodec() {
|
|
5721
|
-
return combineCodec(
|
|
5722
|
-
getRegisterLaunchArgsEncoder(),
|
|
5723
|
-
getRegisterLaunchArgsDecoder()
|
|
5724
|
-
);
|
|
5799
|
+
function getRegisterLaunchArgsCodec() {
|
|
5800
|
+
return combineCodec(
|
|
5801
|
+
getRegisterLaunchArgsEncoder(),
|
|
5802
|
+
getRegisterLaunchArgsDecoder()
|
|
5803
|
+
);
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5806
|
+
// src/solana/generated/cpmmMigrator/accounts/cpmmMigratorState.ts
|
|
5807
|
+
var CPMM_MIGRATOR_STATE_DISCRIMINATOR = new Uint8Array([
|
|
5808
|
+
169,
|
|
5809
|
+
86,
|
|
5810
|
+
255,
|
|
5811
|
+
187,
|
|
5812
|
+
37,
|
|
5813
|
+
248,
|
|
5814
|
+
11,
|
|
5815
|
+
176
|
|
5816
|
+
]);
|
|
5817
|
+
function getCpmmMigratorStateEncoder() {
|
|
5818
|
+
return transformEncoder(
|
|
5819
|
+
getStructEncoder([
|
|
5820
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
5821
|
+
["launch", getAddressEncoder()],
|
|
5822
|
+
["admin", getAddressEncoder()],
|
|
5823
|
+
["cpmmConfig", getAddressEncoder()],
|
|
5824
|
+
["initialSwapFeeBps", getU16Encoder()],
|
|
5825
|
+
["initialFeeSplitBps", getU16Encoder()],
|
|
5826
|
+
["pad0", fixEncoderSize(getBytesEncoder(), 4)],
|
|
5827
|
+
["migratedPoolHookProgram", getAddressEncoder()],
|
|
5828
|
+
["migratedPoolHookFlags", getU32Encoder()],
|
|
5829
|
+
["recipients", getArrayEncoder(getRecipientEncoder(), { size: 2 })],
|
|
5830
|
+
["minRaiseQuote", getU64Encoder()],
|
|
5831
|
+
["minMigrationPriceQ64Opt", getOptionEncoder(getU128Encoder())],
|
|
5832
|
+
["isMigrated", getBooleanEncoder()],
|
|
5833
|
+
["bump", getU8Encoder()],
|
|
5834
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 14)]
|
|
5835
|
+
]),
|
|
5836
|
+
(value) => ({ ...value, discriminator: CPMM_MIGRATOR_STATE_DISCRIMINATOR })
|
|
5837
|
+
);
|
|
5838
|
+
}
|
|
5839
|
+
function getCpmmMigratorStateDecoder() {
|
|
5840
|
+
return getStructDecoder([
|
|
5841
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
5842
|
+
["launch", getAddressDecoder()],
|
|
5843
|
+
["admin", getAddressDecoder()],
|
|
5844
|
+
["cpmmConfig", getAddressDecoder()],
|
|
5845
|
+
["initialSwapFeeBps", getU16Decoder()],
|
|
5846
|
+
["initialFeeSplitBps", getU16Decoder()],
|
|
5847
|
+
["pad0", fixDecoderSize(getBytesDecoder(), 4)],
|
|
5848
|
+
["migratedPoolHookProgram", getAddressDecoder()],
|
|
5849
|
+
["migratedPoolHookFlags", getU32Decoder()],
|
|
5850
|
+
["recipients", getArrayDecoder(getRecipientDecoder(), { size: 2 })],
|
|
5851
|
+
["minRaiseQuote", getU64Decoder()],
|
|
5852
|
+
["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())],
|
|
5853
|
+
["isMigrated", getBooleanDecoder()],
|
|
5854
|
+
["bump", getU8Decoder()],
|
|
5855
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 14)]
|
|
5856
|
+
]);
|
|
5857
|
+
}
|
|
5858
|
+
function getCpmmMigratorStateCodec() {
|
|
5859
|
+
return combineCodec(
|
|
5860
|
+
getCpmmMigratorStateEncoder(),
|
|
5861
|
+
getCpmmMigratorStateDecoder()
|
|
5862
|
+
);
|
|
5863
|
+
}
|
|
5864
|
+
var CREATE_SPOT_POOL_DISCRIMINATOR = new Uint8Array([
|
|
5865
|
+
13,
|
|
5866
|
+
137,
|
|
5867
|
+
16,
|
|
5868
|
+
26,
|
|
5869
|
+
40,
|
|
5870
|
+
36,
|
|
5871
|
+
110,
|
|
5872
|
+
26
|
|
5873
|
+
]);
|
|
5874
|
+
function getCreateSpotPoolInstructionDataEncoder() {
|
|
5875
|
+
return transformEncoder(
|
|
5876
|
+
getStructEncoder([
|
|
5877
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
5878
|
+
["swapFeeBps", getU16Encoder()],
|
|
5879
|
+
["positionId", getU64Encoder()],
|
|
5880
|
+
["amount0Max", getU64Encoder()],
|
|
5881
|
+
["amount1Max", getU64Encoder()],
|
|
5882
|
+
["minSharesOut", getU128Encoder()]
|
|
5883
|
+
]),
|
|
5884
|
+
(value) => ({ ...value, discriminator: CREATE_SPOT_POOL_DISCRIMINATOR })
|
|
5885
|
+
);
|
|
5886
|
+
}
|
|
5887
|
+
function getCreateSpotPoolInstructionDataDecoder() {
|
|
5888
|
+
return getStructDecoder([
|
|
5889
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
5890
|
+
["swapFeeBps", getU16Decoder()],
|
|
5891
|
+
["positionId", getU64Decoder()],
|
|
5892
|
+
["amount0Max", getU64Decoder()],
|
|
5893
|
+
["amount1Max", getU64Decoder()],
|
|
5894
|
+
["minSharesOut", getU128Decoder()]
|
|
5895
|
+
]);
|
|
5896
|
+
}
|
|
5897
|
+
function getCreateSpotPoolInstructionDataCodec() {
|
|
5898
|
+
return combineCodec(
|
|
5899
|
+
getCreateSpotPoolInstructionDataEncoder(),
|
|
5900
|
+
getCreateSpotPoolInstructionDataDecoder()
|
|
5901
|
+
);
|
|
5902
|
+
}
|
|
5903
|
+
async function getCreateSpotPoolInstructionAsync(input, config) {
|
|
5904
|
+
const programAddress = config?.programAddress ?? CPMM_MIGRATOR_PROGRAM_ADDRESS;
|
|
5905
|
+
const originalAccounts = {
|
|
5906
|
+
cpmmConfig: { value: input.cpmmConfig ?? null, isWritable: false },
|
|
5907
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
5908
|
+
liquidityOwner: { value: input.liquidityOwner ?? null, isWritable: false },
|
|
5909
|
+
token0Mint: { value: input.token0Mint ?? null, isWritable: false },
|
|
5910
|
+
token1Mint: { value: input.token1Mint ?? null, isWritable: false },
|
|
5911
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
5912
|
+
poolAuthority: { value: input.poolAuthority ?? null, isWritable: false },
|
|
5913
|
+
poolVault0: { value: input.poolVault0 ?? null, isWritable: true },
|
|
5914
|
+
poolVault1: { value: input.poolVault1 ?? null, isWritable: true },
|
|
5915
|
+
protocolFeeOwner: {
|
|
5916
|
+
value: input.protocolFeeOwner ?? null,
|
|
5917
|
+
isWritable: false
|
|
5918
|
+
},
|
|
5919
|
+
protocolFeePosition: {
|
|
5920
|
+
value: input.protocolFeePosition ?? null,
|
|
5921
|
+
isWritable: true
|
|
5922
|
+
},
|
|
5923
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
5924
|
+
user0: { value: input.user0 ?? null, isWritable: true },
|
|
5925
|
+
user1: { value: input.user1 ?? null, isWritable: true },
|
|
5926
|
+
cpmmProgram: { value: input.cpmmProgram ?? null, isWritable: false },
|
|
5927
|
+
migrationAuthority: {
|
|
5928
|
+
value: input.migrationAuthority ?? null,
|
|
5929
|
+
isWritable: false
|
|
5930
|
+
},
|
|
5931
|
+
token0Program: { value: input.token0Program ?? null, isWritable: false },
|
|
5932
|
+
token1Program: { value: input.token1Program ?? null, isWritable: false },
|
|
5933
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
5934
|
+
rent: { value: input.rent ?? null, isWritable: false }
|
|
5935
|
+
};
|
|
5936
|
+
const accounts = originalAccounts;
|
|
5937
|
+
const args = { ...input };
|
|
5938
|
+
if (!accounts.cpmmProgram.value) {
|
|
5939
|
+
accounts.cpmmProgram.value = "9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ";
|
|
5940
|
+
}
|
|
5941
|
+
if (!accounts.migrationAuthority.value) {
|
|
5942
|
+
accounts.migrationAuthority.value = await getProgramDerivedAddress({
|
|
5943
|
+
programAddress,
|
|
5944
|
+
seeds: [
|
|
5945
|
+
getBytesEncoder().encode(
|
|
5946
|
+
new Uint8Array([
|
|
5947
|
+
109,
|
|
5948
|
+
105,
|
|
5949
|
+
103,
|
|
5950
|
+
114,
|
|
5951
|
+
97,
|
|
5952
|
+
116,
|
|
5953
|
+
105,
|
|
5954
|
+
111,
|
|
5955
|
+
110,
|
|
5956
|
+
95,
|
|
5957
|
+
97,
|
|
5958
|
+
117,
|
|
5959
|
+
116,
|
|
5960
|
+
104,
|
|
5961
|
+
111,
|
|
5962
|
+
114,
|
|
5963
|
+
105,
|
|
5964
|
+
116,
|
|
5965
|
+
121
|
|
5966
|
+
])
|
|
5967
|
+
)
|
|
5968
|
+
]
|
|
5969
|
+
});
|
|
5970
|
+
}
|
|
5971
|
+
if (!accounts.systemProgram.value) {
|
|
5972
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
5973
|
+
}
|
|
5974
|
+
if (!accounts.rent.value) {
|
|
5975
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
5976
|
+
}
|
|
5977
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
5978
|
+
return Object.freeze({
|
|
5979
|
+
accounts: [
|
|
5980
|
+
getAccountMeta("cpmmConfig", accounts.cpmmConfig),
|
|
5981
|
+
getAccountMeta("payer", accounts.payer),
|
|
5982
|
+
getAccountMeta("liquidityOwner", accounts.liquidityOwner),
|
|
5983
|
+
getAccountMeta("token0Mint", accounts.token0Mint),
|
|
5984
|
+
getAccountMeta("token1Mint", accounts.token1Mint),
|
|
5985
|
+
getAccountMeta("pool", accounts.pool),
|
|
5986
|
+
getAccountMeta("poolAuthority", accounts.poolAuthority),
|
|
5987
|
+
getAccountMeta("poolVault0", accounts.poolVault0),
|
|
5988
|
+
getAccountMeta("poolVault1", accounts.poolVault1),
|
|
5989
|
+
getAccountMeta("protocolFeeOwner", accounts.protocolFeeOwner),
|
|
5990
|
+
getAccountMeta("protocolFeePosition", accounts.protocolFeePosition),
|
|
5991
|
+
getAccountMeta("position", accounts.position),
|
|
5992
|
+
getAccountMeta("user0", accounts.user0),
|
|
5993
|
+
getAccountMeta("user1", accounts.user1),
|
|
5994
|
+
getAccountMeta("cpmmProgram", accounts.cpmmProgram),
|
|
5995
|
+
getAccountMeta("migrationAuthority", accounts.migrationAuthority),
|
|
5996
|
+
getAccountMeta("token0Program", accounts.token0Program),
|
|
5997
|
+
getAccountMeta("token1Program", accounts.token1Program),
|
|
5998
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
5999
|
+
getAccountMeta("rent", accounts.rent)
|
|
6000
|
+
],
|
|
6001
|
+
data: getCreateSpotPoolInstructionDataEncoder().encode(
|
|
6002
|
+
args
|
|
6003
|
+
),
|
|
6004
|
+
programAddress
|
|
6005
|
+
});
|
|
6006
|
+
}
|
|
6007
|
+
function getCreateSpotPoolInstruction(input, config) {
|
|
6008
|
+
const programAddress = config?.programAddress ?? CPMM_MIGRATOR_PROGRAM_ADDRESS;
|
|
6009
|
+
const originalAccounts = {
|
|
6010
|
+
cpmmConfig: { value: input.cpmmConfig ?? null, isWritable: false },
|
|
6011
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
6012
|
+
liquidityOwner: { value: input.liquidityOwner ?? null, isWritable: false },
|
|
6013
|
+
token0Mint: { value: input.token0Mint ?? null, isWritable: false },
|
|
6014
|
+
token1Mint: { value: input.token1Mint ?? null, isWritable: false },
|
|
6015
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
6016
|
+
poolAuthority: { value: input.poolAuthority ?? null, isWritable: false },
|
|
6017
|
+
poolVault0: { value: input.poolVault0 ?? null, isWritable: true },
|
|
6018
|
+
poolVault1: { value: input.poolVault1 ?? null, isWritable: true },
|
|
6019
|
+
protocolFeeOwner: {
|
|
6020
|
+
value: input.protocolFeeOwner ?? null,
|
|
6021
|
+
isWritable: false
|
|
6022
|
+
},
|
|
6023
|
+
protocolFeePosition: {
|
|
6024
|
+
value: input.protocolFeePosition ?? null,
|
|
6025
|
+
isWritable: true
|
|
6026
|
+
},
|
|
6027
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
6028
|
+
user0: { value: input.user0 ?? null, isWritable: true },
|
|
6029
|
+
user1: { value: input.user1 ?? null, isWritable: true },
|
|
6030
|
+
cpmmProgram: { value: input.cpmmProgram ?? null, isWritable: false },
|
|
6031
|
+
migrationAuthority: {
|
|
6032
|
+
value: input.migrationAuthority ?? null,
|
|
6033
|
+
isWritable: false
|
|
6034
|
+
},
|
|
6035
|
+
token0Program: { value: input.token0Program ?? null, isWritable: false },
|
|
6036
|
+
token1Program: { value: input.token1Program ?? null, isWritable: false },
|
|
6037
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
6038
|
+
rent: { value: input.rent ?? null, isWritable: false }
|
|
6039
|
+
};
|
|
6040
|
+
const accounts = originalAccounts;
|
|
6041
|
+
const args = { ...input };
|
|
6042
|
+
if (!accounts.cpmmProgram.value) {
|
|
6043
|
+
accounts.cpmmProgram.value = "9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ";
|
|
6044
|
+
}
|
|
6045
|
+
if (!accounts.systemProgram.value) {
|
|
6046
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
6047
|
+
}
|
|
6048
|
+
if (!accounts.rent.value) {
|
|
6049
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
6050
|
+
}
|
|
6051
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
6052
|
+
return Object.freeze({
|
|
6053
|
+
accounts: [
|
|
6054
|
+
getAccountMeta("cpmmConfig", accounts.cpmmConfig),
|
|
6055
|
+
getAccountMeta("payer", accounts.payer),
|
|
6056
|
+
getAccountMeta("liquidityOwner", accounts.liquidityOwner),
|
|
6057
|
+
getAccountMeta("token0Mint", accounts.token0Mint),
|
|
6058
|
+
getAccountMeta("token1Mint", accounts.token1Mint),
|
|
6059
|
+
getAccountMeta("pool", accounts.pool),
|
|
6060
|
+
getAccountMeta("poolAuthority", accounts.poolAuthority),
|
|
6061
|
+
getAccountMeta("poolVault0", accounts.poolVault0),
|
|
6062
|
+
getAccountMeta("poolVault1", accounts.poolVault1),
|
|
6063
|
+
getAccountMeta("protocolFeeOwner", accounts.protocolFeeOwner),
|
|
6064
|
+
getAccountMeta("protocolFeePosition", accounts.protocolFeePosition),
|
|
6065
|
+
getAccountMeta("position", accounts.position),
|
|
6066
|
+
getAccountMeta("user0", accounts.user0),
|
|
6067
|
+
getAccountMeta("user1", accounts.user1),
|
|
6068
|
+
getAccountMeta("cpmmProgram", accounts.cpmmProgram),
|
|
6069
|
+
getAccountMeta("migrationAuthority", accounts.migrationAuthority),
|
|
6070
|
+
getAccountMeta("token0Program", accounts.token0Program),
|
|
6071
|
+
getAccountMeta("token1Program", accounts.token1Program),
|
|
6072
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
6073
|
+
getAccountMeta("rent", accounts.rent)
|
|
6074
|
+
],
|
|
6075
|
+
data: getCreateSpotPoolInstructionDataEncoder().encode(
|
|
6076
|
+
args
|
|
6077
|
+
),
|
|
6078
|
+
programAddress
|
|
6079
|
+
});
|
|
6080
|
+
}
|
|
6081
|
+
|
|
6082
|
+
// src/solana/generated/cpmmMigrator/programs/cpmmMigrator.ts
|
|
6083
|
+
var CPMM_MIGRATOR_PROGRAM_ADDRESS = "7WMUTNC41eMCo6eGH5Sy2xbgE3AycvLbFPo95AU9CSUd";
|
|
6084
|
+
if (process.env.NODE_ENV !== "production") ;
|
|
6085
|
+
var addressCodec5 = getAddressCodec();
|
|
6086
|
+
var textEncoder6 = new TextEncoder();
|
|
6087
|
+
var U64_MAX = (1n << 64n) - 1n;
|
|
6088
|
+
var PROTOCOL_FEE_POSITION_ID = 0n;
|
|
6089
|
+
async function pda(programAddress, seeds) {
|
|
6090
|
+
const [derived] = await getProgramDerivedAddress({
|
|
6091
|
+
programAddress,
|
|
6092
|
+
seeds
|
|
6093
|
+
});
|
|
6094
|
+
return derived;
|
|
6095
|
+
}
|
|
6096
|
+
function seed(value) {
|
|
6097
|
+
return textEncoder6.encode(value);
|
|
6098
|
+
}
|
|
6099
|
+
function addressSeed(value) {
|
|
6100
|
+
return addressCodec5.encode(value);
|
|
6101
|
+
}
|
|
6102
|
+
function assertSafeInteger(name, value) {
|
|
6103
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
6104
|
+
throw new RangeError(
|
|
6105
|
+
`${name} must be a safe integer when provided as a number; use bigint for values above Number.MAX_SAFE_INTEGER`
|
|
6106
|
+
);
|
|
6107
|
+
}
|
|
6108
|
+
}
|
|
6109
|
+
function u64Seed(value) {
|
|
6110
|
+
assertSafeInteger("positionId", value);
|
|
6111
|
+
const bigintValue = BigInt(value);
|
|
6112
|
+
if (bigintValue < 0n || bigintValue > U64_MAX) {
|
|
6113
|
+
throw new RangeError("u64 position ID must be between 0 and 2^64 - 1");
|
|
6114
|
+
}
|
|
6115
|
+
const bytes = new Uint8Array(8);
|
|
6116
|
+
new DataView(bytes.buffer).setBigUint64(0, bigintValue, true);
|
|
6117
|
+
return bytes;
|
|
6118
|
+
}
|
|
6119
|
+
function addressOf(value) {
|
|
6120
|
+
return typeof value === "string" ? value : value.address;
|
|
5725
6121
|
}
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
6122
|
+
function accountMeta(value, role) {
|
|
6123
|
+
if (typeof value === "string") {
|
|
6124
|
+
return { address: value, role };
|
|
6125
|
+
}
|
|
6126
|
+
return { address: value.address, role, signer: value };
|
|
6127
|
+
}
|
|
6128
|
+
async function deriveSpotPoolAccounts({
|
|
6129
|
+
tokenAMint,
|
|
6130
|
+
tokenBMint,
|
|
6131
|
+
swapFeeBps,
|
|
6132
|
+
liquidityOwner,
|
|
6133
|
+
tokenAProgram = TOKEN_PROGRAM_ADDRESS$1,
|
|
6134
|
+
tokenBProgram = TOKEN_PROGRAM_ADDRESS$1,
|
|
6135
|
+
tokenAAccount,
|
|
6136
|
+
tokenBAccount,
|
|
6137
|
+
token0Account,
|
|
6138
|
+
token1Account,
|
|
6139
|
+
positionId = 0n,
|
|
6140
|
+
cpmmProgram = CPMM_PROGRAM_ID,
|
|
6141
|
+
cpmmMigratorProgram = CPMM_MIGRATOR_PROGRAM_ID
|
|
6142
|
+
}) {
|
|
6143
|
+
const [token0Mint, token1Mint] = sortMints(tokenAMint, tokenBMint);
|
|
6144
|
+
const token0IsA = token0Mint === tokenAMint;
|
|
6145
|
+
const token0Program = token0IsA ? tokenAProgram : tokenBProgram;
|
|
6146
|
+
const token1Program = token0IsA ? tokenBProgram : tokenAProgram;
|
|
6147
|
+
const [userA] = await findAssociatedTokenPda({
|
|
6148
|
+
owner: liquidityOwner,
|
|
6149
|
+
mint: tokenAMint,
|
|
6150
|
+
tokenProgram: tokenAProgram
|
|
6151
|
+
});
|
|
6152
|
+
const [userB] = await findAssociatedTokenPda({
|
|
6153
|
+
owner: liquidityOwner,
|
|
6154
|
+
mint: tokenBMint,
|
|
6155
|
+
tokenProgram: tokenBProgram
|
|
6156
|
+
});
|
|
6157
|
+
const user0 = token0Account ?? (token0IsA ? tokenAAccount ?? userA : tokenBAccount ?? userB);
|
|
6158
|
+
const user1 = token1Account ?? (token0IsA ? tokenBAccount ?? userB : tokenAAccount ?? userA);
|
|
6159
|
+
const [pool] = await getSpotPoolAddress(
|
|
6160
|
+
token0Mint,
|
|
6161
|
+
token1Mint,
|
|
6162
|
+
swapFeeBps,
|
|
6163
|
+
cpmmProgram
|
|
5758
6164
|
);
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
5763
|
-
["launch", getAddressDecoder()],
|
|
5764
|
-
["admin", getAddressDecoder()],
|
|
5765
|
-
["cpmmConfig", getAddressDecoder()],
|
|
5766
|
-
["initialSwapFeeBps", getU16Decoder()],
|
|
5767
|
-
["initialFeeSplitBps", getU16Decoder()],
|
|
5768
|
-
["pad0", fixDecoderSize(getBytesDecoder(), 4)],
|
|
5769
|
-
["migratedPoolHookProgram", getAddressDecoder()],
|
|
5770
|
-
["migratedPoolHookFlags", getU32Decoder()],
|
|
5771
|
-
["recipients", getArrayDecoder(getRecipientDecoder(), { size: 2 })],
|
|
5772
|
-
["minRaiseQuote", getU64Decoder()],
|
|
5773
|
-
["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())],
|
|
5774
|
-
["isMigrated", getBooleanDecoder()],
|
|
5775
|
-
["bump", getU8Decoder()],
|
|
5776
|
-
["reserved", fixDecoderSize(getBytesDecoder(), 14)]
|
|
6165
|
+
const protocolFeeOwner = await pda(cpmmProgram, [
|
|
6166
|
+
seed(SEED_PROTOCOL_FEE_OWNER),
|
|
6167
|
+
addressSeed(pool)
|
|
5777
6168
|
]);
|
|
6169
|
+
return {
|
|
6170
|
+
cpmmConfig: await pda(cpmmProgram, [seed(SEED_CONFIG)]),
|
|
6171
|
+
token0Mint,
|
|
6172
|
+
token1Mint,
|
|
6173
|
+
token0Program,
|
|
6174
|
+
token1Program,
|
|
6175
|
+
pool,
|
|
6176
|
+
poolAuthority: await pda(cpmmProgram, [
|
|
6177
|
+
seed(SEED_AUTHORITY),
|
|
6178
|
+
addressSeed(pool)
|
|
6179
|
+
]),
|
|
6180
|
+
poolVault0: await pda(cpmmProgram, [seed(SEED_VAULT0), addressSeed(pool)]),
|
|
6181
|
+
poolVault1: await pda(cpmmProgram, [seed(SEED_VAULT1), addressSeed(pool)]),
|
|
6182
|
+
protocolFeeOwner,
|
|
6183
|
+
protocolFeePosition: await pda(cpmmProgram, [
|
|
6184
|
+
seed(SEED_POSITION),
|
|
6185
|
+
addressSeed(pool),
|
|
6186
|
+
addressSeed(protocolFeeOwner),
|
|
6187
|
+
u64Seed(PROTOCOL_FEE_POSITION_ID)
|
|
6188
|
+
]),
|
|
6189
|
+
position: await pda(cpmmProgram, [
|
|
6190
|
+
seed(SEED_POSITION),
|
|
6191
|
+
addressSeed(pool),
|
|
6192
|
+
addressSeed(liquidityOwner),
|
|
6193
|
+
u64Seed(positionId)
|
|
6194
|
+
]),
|
|
6195
|
+
user0,
|
|
6196
|
+
user1,
|
|
6197
|
+
migrationAuthority: await pda(cpmmMigratorProgram, [
|
|
6198
|
+
seed(SEED_MIGRATION_AUTHORITY)
|
|
6199
|
+
])
|
|
6200
|
+
};
|
|
5778
6201
|
}
|
|
5779
|
-
function
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
6202
|
+
async function createSpotPoolInstruction(input) {
|
|
6203
|
+
const payer = input.payer;
|
|
6204
|
+
const liquidityOwner = input.liquidityOwner ?? payer;
|
|
6205
|
+
const positionId = input.positionId ?? 0n;
|
|
6206
|
+
const minSharesOut = input.minSharesOut ?? 1n;
|
|
6207
|
+
assertSafeInteger("positionId", positionId);
|
|
6208
|
+
assertSafeInteger("tokenAAmount", input.tokenAAmount);
|
|
6209
|
+
assertSafeInteger("tokenBAmount", input.tokenBAmount);
|
|
6210
|
+
assertSafeInteger("minSharesOut", minSharesOut);
|
|
6211
|
+
const cpmmProgram = input.cpmmProgram ?? CPMM_PROGRAM_ID;
|
|
6212
|
+
const cpmmMigratorProgram = input.cpmmMigratorProgram ?? CPMM_MIGRATOR_PROGRAM_ID;
|
|
6213
|
+
const accounts = await deriveSpotPoolAccounts({
|
|
6214
|
+
...input,
|
|
6215
|
+
liquidityOwner: addressOf(liquidityOwner),
|
|
6216
|
+
cpmmProgram,
|
|
6217
|
+
cpmmMigratorProgram,
|
|
6218
|
+
positionId
|
|
6219
|
+
});
|
|
6220
|
+
const token0IsA = accounts.token0Mint === input.tokenAMint;
|
|
6221
|
+
return {
|
|
6222
|
+
programAddress: cpmmMigratorProgram,
|
|
6223
|
+
accounts: [
|
|
6224
|
+
{ address: accounts.cpmmConfig, role: AccountRole.READONLY },
|
|
6225
|
+
accountMeta(payer, AccountRole.WRITABLE_SIGNER),
|
|
6226
|
+
accountMeta(liquidityOwner, AccountRole.READONLY_SIGNER),
|
|
6227
|
+
{ address: accounts.token0Mint, role: AccountRole.READONLY },
|
|
6228
|
+
{ address: accounts.token1Mint, role: AccountRole.READONLY },
|
|
6229
|
+
{ address: accounts.pool, role: AccountRole.WRITABLE },
|
|
6230
|
+
{ address: accounts.poolAuthority, role: AccountRole.READONLY },
|
|
6231
|
+
{ address: accounts.poolVault0, role: AccountRole.WRITABLE },
|
|
6232
|
+
{ address: accounts.poolVault1, role: AccountRole.WRITABLE },
|
|
6233
|
+
{ address: accounts.protocolFeeOwner, role: AccountRole.READONLY },
|
|
6234
|
+
{ address: accounts.protocolFeePosition, role: AccountRole.WRITABLE },
|
|
6235
|
+
{ address: accounts.position, role: AccountRole.WRITABLE },
|
|
6236
|
+
{ address: accounts.user0, role: AccountRole.WRITABLE },
|
|
6237
|
+
{ address: accounts.user1, role: AccountRole.WRITABLE },
|
|
6238
|
+
{ address: cpmmProgram, role: AccountRole.READONLY },
|
|
6239
|
+
{ address: accounts.migrationAuthority, role: AccountRole.READONLY },
|
|
6240
|
+
{ address: accounts.token0Program, role: AccountRole.READONLY },
|
|
6241
|
+
{ address: accounts.token1Program, role: AccountRole.READONLY },
|
|
6242
|
+
{
|
|
6243
|
+
address: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS$1,
|
|
6244
|
+
role: AccountRole.READONLY
|
|
6245
|
+
},
|
|
6246
|
+
{
|
|
6247
|
+
address: input.rent ?? SYSVAR_RENT_ADDRESS,
|
|
6248
|
+
role: AccountRole.READONLY
|
|
6249
|
+
}
|
|
6250
|
+
],
|
|
6251
|
+
data: getCreateSpotPoolInstructionDataEncoder().encode({
|
|
6252
|
+
swapFeeBps: input.swapFeeBps,
|
|
6253
|
+
positionId,
|
|
6254
|
+
amount0Max: token0IsA ? input.tokenAAmount : input.tokenBAmount,
|
|
6255
|
+
amount1Max: token0IsA ? input.tokenBAmount : input.tokenAAmount,
|
|
6256
|
+
minSharesOut
|
|
6257
|
+
})
|
|
6258
|
+
};
|
|
5784
6259
|
}
|
|
5785
|
-
if (process.env.NODE_ENV !== "production") ;
|
|
5786
6260
|
|
|
5787
6261
|
// src/solana/migrators/cpmmMigrator/client.ts
|
|
5788
|
-
function
|
|
5789
|
-
const
|
|
5790
|
-
const bytes = new Uint8Array(binary.length);
|
|
5791
|
-
for (let i = 0; i < binary.length; i++) {
|
|
5792
|
-
bytes[i] = binary.charCodeAt(i);
|
|
5793
|
-
}
|
|
5794
|
-
return bytes;
|
|
5795
|
-
}
|
|
5796
|
-
async function fetchCpmmMigratorState(rpc, address4) {
|
|
5797
|
-
const response = await rpc.getAccountInfo(address4, { encoding: "base64" }).send();
|
|
6262
|
+
async function fetchCpmmMigratorState(rpc, address6) {
|
|
6263
|
+
const response = await rpc.getAccountInfo(address6, { encoding: "base64" }).send();
|
|
5798
6264
|
if (!response.value) return null;
|
|
5799
6265
|
return getCpmmMigratorStateDecoder().decode(
|
|
5800
|
-
|
|
6266
|
+
base64ToBytes(response.value.data[0])
|
|
5801
6267
|
);
|
|
5802
6268
|
}
|
|
5803
6269
|
async function buildCpmmMigrationRemainingAccounts({
|
|
@@ -5857,8 +6323,8 @@ async function buildCpmmMigrationRemainingAccounts({
|
|
|
5857
6323
|
{ address: migrationAuthority, role: AccountRole.READONLY },
|
|
5858
6324
|
{ address: adminBaseAta, role: AccountRole.WRITABLE },
|
|
5859
6325
|
{ address: adminQuoteAta, role: AccountRole.WRITABLE },
|
|
5860
|
-
...recipientAtas.map((
|
|
5861
|
-
address:
|
|
6326
|
+
...recipientAtas.map((address6) => ({
|
|
6327
|
+
address: address6,
|
|
5862
6328
|
role: AccountRole.WRITABLE
|
|
5863
6329
|
}))
|
|
5864
6330
|
],
|
|
@@ -5882,8 +6348,24 @@ async function buildCpmmMigrationRemainingAccountsHash(input) {
|
|
|
5882
6348
|
}
|
|
5883
6349
|
|
|
5884
6350
|
// src/solana/migrators/cpmmMigrator/index.ts
|
|
6351
|
+
function encodeCreateSpotPoolPayload(args) {
|
|
6352
|
+
assertSafeInteger("positionId", args.positionId);
|
|
6353
|
+
assertSafeInteger("amount0Max", args.amount0Max);
|
|
6354
|
+
assertSafeInteger("amount1Max", args.amount1Max);
|
|
6355
|
+
assertSafeInteger("minSharesOut", args.minSharesOut);
|
|
6356
|
+
const encoded = new Uint8Array(getCreateSpotPoolArgsEncoder().encode(args));
|
|
6357
|
+
return mergeBytes([
|
|
6358
|
+
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.createSpotPool,
|
|
6359
|
+
encoded
|
|
6360
|
+
]);
|
|
6361
|
+
}
|
|
5885
6362
|
function encodeRegisterLaunchPayload(args) {
|
|
5886
|
-
const encoded = new Uint8Array(
|
|
6363
|
+
const encoded = new Uint8Array(
|
|
6364
|
+
getRegisterLaunchArgsEncoder().encode({
|
|
6365
|
+
...args,
|
|
6366
|
+
migratedPoolHookConfig: args.migratedPoolHookConfig ?? null
|
|
6367
|
+
})
|
|
6368
|
+
);
|
|
5887
6369
|
return mergeBytes([
|
|
5888
6370
|
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.registerLaunch,
|
|
5889
6371
|
encoded
|
|
@@ -5923,30 +6405,8 @@ function createLaunchId() {
|
|
|
5923
6405
|
bytes.set([68, 79, 80, 76], 28);
|
|
5924
6406
|
return bytes;
|
|
5925
6407
|
}
|
|
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
6408
|
function getSignerAddress(value) {
|
|
5936
|
-
return
|
|
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;
|
|
6409
|
+
return getAddressFromAddressOrSigner(value);
|
|
5950
6410
|
}
|
|
5951
6411
|
function hasMetadata(metadata) {
|
|
5952
6412
|
return Boolean(metadata?.metadataName);
|
|
@@ -5961,47 +6421,39 @@ function hashRemainingAccounts(accounts) {
|
|
|
5961
6421
|
if (!accounts) {
|
|
5962
6422
|
return void 0;
|
|
5963
6423
|
}
|
|
5964
|
-
return computeRemainingAccountsHash(
|
|
6424
|
+
return computeRemainingAccountsHash(
|
|
6425
|
+
accounts.map(getAddressFromRemainingAccount)
|
|
6426
|
+
);
|
|
5965
6427
|
}
|
|
5966
6428
|
function isCustomMigrationConfig(migration) {
|
|
5967
6429
|
return migration.kind === "custom";
|
|
5968
6430
|
}
|
|
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
6431
|
async function getCreateLaunchHookContext(input) {
|
|
5976
|
-
const
|
|
5977
|
-
if (
|
|
5978
|
-
|
|
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();
|
|
6432
|
+
const program = input.deployment?.cpmmHookProgram ?? CPMM_HOOK_PROGRAM_ID;
|
|
6433
|
+
if (input.cosignGateExpiresAt != null && !input.cosigner) {
|
|
6434
|
+
throw new Error("cosigner is required when cosignGateExpiresAt is set");
|
|
5997
6435
|
}
|
|
5998
6436
|
if (!input.cosigner) {
|
|
5999
|
-
|
|
6437
|
+
return { program };
|
|
6438
|
+
}
|
|
6439
|
+
const [config] = await getCpmmHookConfigAddress(program);
|
|
6440
|
+
return { program, config };
|
|
6441
|
+
}
|
|
6442
|
+
function resolveCpmmHookPayload(input) {
|
|
6443
|
+
let gateExpiry = null;
|
|
6444
|
+
if (input.cosignGateExpiresAt !== void 0 && input.cosignGateExpiresAt !== null) {
|
|
6445
|
+
if (!input.cosigner) {
|
|
6446
|
+
throw new Error("cosigner is required when cosignGateExpiresAt is set");
|
|
6447
|
+
}
|
|
6448
|
+
gateExpiry = {
|
|
6449
|
+
mode: GATE_EXPIRY_UNIX_TIMESTAMP,
|
|
6450
|
+
value: input.cosignGateExpiresAt,
|
|
6451
|
+
cosigner: getSignerAddress(input.cosigner)
|
|
6452
|
+
};
|
|
6000
6453
|
}
|
|
6001
|
-
return
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
cosigner: getSignerAddress(input.cosigner)
|
|
6454
|
+
return encodeCpmmHookPayload({
|
|
6455
|
+
schedule: input.dynamicFee ?? null,
|
|
6456
|
+
gateExpiry
|
|
6005
6457
|
});
|
|
6006
6458
|
}
|
|
6007
6459
|
function resolveCreateLaunchHook({
|
|
@@ -6009,37 +6461,18 @@ function resolveCreateLaunchHook({
|
|
|
6009
6461
|
namespace,
|
|
6010
6462
|
hookContext
|
|
6011
6463
|
}) {
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
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
|
-
}
|
|
6464
|
+
const hasCosigner = Boolean(input.cosigner);
|
|
6465
|
+
const hasSchedule = Boolean(input.dynamicFee);
|
|
6466
|
+
const remainingAccounts = getCpmmHookRemainingAccounts({
|
|
6467
|
+
namespace,
|
|
6468
|
+
config: hookContext.config,
|
|
6469
|
+
cosigner: input.cosigner
|
|
6470
|
+
});
|
|
6038
6471
|
return {
|
|
6039
|
-
program:
|
|
6040
|
-
flags: HF_BEFORE_SWAP2,
|
|
6041
|
-
payload:
|
|
6042
|
-
remainingAccountsHash:
|
|
6472
|
+
program: hookContext.program,
|
|
6473
|
+
flags: HF_BEFORE_SWAP2 | (hasSchedule ? HF_BEFORE_CREATE : 0) | (hasCosigner ? HF_FORWARD_READONLY_SIGNERS2 : 0),
|
|
6474
|
+
payload: resolveCpmmHookPayload(input),
|
|
6475
|
+
remainingAccountsHash: remainingAccounts.hookRemainingAccountsHash
|
|
6043
6476
|
};
|
|
6044
6477
|
}
|
|
6045
6478
|
async function getAssociatedTokenAddress({
|
|
@@ -6177,7 +6610,7 @@ async function createLaunch(input) {
|
|
|
6177
6610
|
const programId = getInitializerProgramId(input);
|
|
6178
6611
|
const launchId = input.launchId ?? createLaunchId();
|
|
6179
6612
|
const hookContext = await getCreateLaunchHookContext(input);
|
|
6180
|
-
const namespace = input.namespace ??
|
|
6613
|
+
const namespace = input.namespace ?? SYSTEM_PROGRAM_ADDRESS;
|
|
6181
6614
|
const tokenPrograms = {
|
|
6182
6615
|
...launchTokenPrograms.splToken(),
|
|
6183
6616
|
...input.tokenPrograms
|
|
@@ -6224,7 +6657,7 @@ async function createLaunch(input) {
|
|
|
6224
6657
|
baseTokenProgram: tokenPrograms.baseTokenProgram,
|
|
6225
6658
|
quoteTokenProgram: tokenPrograms.quoteTokenProgram,
|
|
6226
6659
|
systemProgram: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS,
|
|
6227
|
-
rent: input.rent ?? SYSVAR_RENT_ADDRESS,
|
|
6660
|
+
rent: input.rent ?? SYSVAR_RENT_ADDRESS$1,
|
|
6228
6661
|
metadataAccount: addresses.metadataAccount,
|
|
6229
6662
|
metadataProgram: input.metadataProgram ?? TOKEN_METADATA_PROGRAM_ID
|
|
6230
6663
|
},
|
|
@@ -6243,7 +6676,7 @@ async function createLaunch(input) {
|
|
|
6243
6676
|
allowBuy: input.allowBuy ?? true,
|
|
6244
6677
|
allowSell: input.allowSell ?? true,
|
|
6245
6678
|
hookFlags: hook.flags,
|
|
6246
|
-
hookPayload: hook.payload
|
|
6679
|
+
hookPayload: hook.payload,
|
|
6247
6680
|
migratorInitPayload: migration?.initPayload ?? new Uint8Array(),
|
|
6248
6681
|
migratorMigratePayload: migration?.migratePayload ?? new Uint8Array(),
|
|
6249
6682
|
hookRemainingAccountsHash: hook.remainingAccountsHash,
|
|
@@ -6261,7 +6694,7 @@ async function createLaunch(input) {
|
|
|
6261
6694
|
accounts: [
|
|
6262
6695
|
...instruction.accounts ?? [],
|
|
6263
6696
|
...(migration?.initRemainingAccounts ?? []).map(
|
|
6264
|
-
|
|
6697
|
+
createReadonlyRemainingAccountMeta
|
|
6265
6698
|
)
|
|
6266
6699
|
]
|
|
6267
6700
|
} : instruction;
|
|
@@ -6377,38 +6810,23 @@ function assertTransactionMessageFitsWithLookupTable(transactionMessage, lookupT
|
|
|
6377
6810
|
);
|
|
6378
6811
|
return assertTransactionMessageFits(compressedMessage, options);
|
|
6379
6812
|
}
|
|
6380
|
-
var
|
|
6381
|
-
function
|
|
6382
|
-
|
|
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, {
|
|
6813
|
+
var addressCodec6 = getAddressCodec();
|
|
6814
|
+
async function fetchLaunch2(rpc, address6, config) {
|
|
6815
|
+
const response = await rpc.getAccountInfo(address6, {
|
|
6398
6816
|
encoding: "base64",
|
|
6399
6817
|
commitment: config?.commitment
|
|
6400
6818
|
}).send();
|
|
6401
6819
|
if (!response.value) {
|
|
6402
6820
|
return null;
|
|
6403
6821
|
}
|
|
6404
|
-
return getLaunchDecoder().decode(
|
|
6822
|
+
return getLaunchDecoder().decode(base64ToBytes(response.value.data[0]));
|
|
6405
6823
|
}
|
|
6406
6824
|
async function fetchAllLaunches(rpc, config) {
|
|
6407
6825
|
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
6408
6826
|
const discriminatorFilter = {
|
|
6409
6827
|
memcmp: {
|
|
6410
6828
|
offset: 0n,
|
|
6411
|
-
bytes:
|
|
6829
|
+
bytes: bytesToBase64EncodedBytes(
|
|
6412
6830
|
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
6413
6831
|
),
|
|
6414
6832
|
encoding: "base64"
|
|
@@ -6419,15 +6837,15 @@ async function fetchAllLaunches(rpc, config) {
|
|
|
6419
6837
|
commitment: config?.commitment,
|
|
6420
6838
|
filters: [discriminatorFilter]
|
|
6421
6839
|
}).send();
|
|
6422
|
-
const accounts =
|
|
6840
|
+
const accounts = normalizeProgramAccountsResponse(response);
|
|
6423
6841
|
const launches = [];
|
|
6424
6842
|
const decoder = getLaunchDecoder();
|
|
6425
6843
|
for (const account of accounts) {
|
|
6426
6844
|
try {
|
|
6427
|
-
const launch = decoder.decode(
|
|
6845
|
+
const launch = decoder.decode(base64ToBytes(account.account.data[0]));
|
|
6428
6846
|
launches.push({ address: account.pubkey, account: launch });
|
|
6429
6847
|
} catch {
|
|
6430
|
-
|
|
6848
|
+
warnAccountDecodeFailure("launch", account.pubkey);
|
|
6431
6849
|
}
|
|
6432
6850
|
}
|
|
6433
6851
|
return launches;
|
|
@@ -6437,7 +6855,7 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
|
6437
6855
|
const discriminatorFilter = {
|
|
6438
6856
|
memcmp: {
|
|
6439
6857
|
offset: 0n,
|
|
6440
|
-
bytes:
|
|
6858
|
+
bytes: bytesToBase64EncodedBytes(
|
|
6441
6859
|
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
6442
6860
|
),
|
|
6443
6861
|
encoding: "base64"
|
|
@@ -6446,9 +6864,7 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
|
6446
6864
|
const authorityFilter = {
|
|
6447
6865
|
memcmp: {
|
|
6448
6866
|
offset: 8n,
|
|
6449
|
-
bytes:
|
|
6450
|
-
addressCodec5.encode(authority)
|
|
6451
|
-
),
|
|
6867
|
+
bytes: bytesToBase64EncodedBytes(addressCodec6.encode(authority)),
|
|
6452
6868
|
encoding: "base64"
|
|
6453
6869
|
}
|
|
6454
6870
|
};
|
|
@@ -6457,15 +6873,15 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
|
6457
6873
|
commitment: config?.commitment,
|
|
6458
6874
|
filters: [discriminatorFilter, authorityFilter]
|
|
6459
6875
|
}).send();
|
|
6460
|
-
const accounts =
|
|
6876
|
+
const accounts = normalizeProgramAccountsResponse(response);
|
|
6461
6877
|
const launches = [];
|
|
6462
6878
|
const decoder = getLaunchDecoder();
|
|
6463
6879
|
for (const account of accounts) {
|
|
6464
6880
|
try {
|
|
6465
|
-
const launch = decoder.decode(
|
|
6881
|
+
const launch = decoder.decode(base64ToBytes(account.account.data[0]));
|
|
6466
6882
|
launches.push({ address: account.pubkey, account: launch });
|
|
6467
6883
|
} catch {
|
|
6468
|
-
|
|
6884
|
+
warnAccountDecodeFailure("launch", account.pubkey);
|
|
6469
6885
|
}
|
|
6470
6886
|
}
|
|
6471
6887
|
return launches;
|
|
@@ -6801,13 +7217,13 @@ function decodeOracleState3(encodedAccount) {
|
|
|
6801
7217
|
getOracleStateDecoder2()
|
|
6802
7218
|
);
|
|
6803
7219
|
}
|
|
6804
|
-
async function fetchOracleState2(rpc,
|
|
6805
|
-
const maybeAccount = await fetchMaybeOracleState2(rpc,
|
|
7220
|
+
async function fetchOracleState2(rpc, address6, config) {
|
|
7221
|
+
const maybeAccount = await fetchMaybeOracleState2(rpc, address6, config);
|
|
6806
7222
|
assertAccountExists(maybeAccount);
|
|
6807
7223
|
return maybeAccount;
|
|
6808
7224
|
}
|
|
6809
|
-
async function fetchMaybeOracleState2(rpc,
|
|
6810
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
7225
|
+
async function fetchMaybeOracleState2(rpc, address6, config) {
|
|
7226
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
6811
7227
|
return decodeOracleState3(maybeAccount);
|
|
6812
7228
|
}
|
|
6813
7229
|
async function fetchAllOracleState2(rpc, addresses, config) {
|
|
@@ -6891,9 +7307,9 @@ function parseFinalizeInstruction(instruction) {
|
|
|
6891
7307
|
}
|
|
6892
7308
|
let accountIndex = 0;
|
|
6893
7309
|
const getNextAccount = () => {
|
|
6894
|
-
const
|
|
7310
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
6895
7311
|
accountIndex += 1;
|
|
6896
|
-
return
|
|
7312
|
+
return accountMeta2;
|
|
6897
7313
|
};
|
|
6898
7314
|
return {
|
|
6899
7315
|
programAddress: instruction.programAddress,
|
|
@@ -6979,9 +7395,9 @@ function parseInitializeOracleInstruction2(instruction) {
|
|
|
6979
7395
|
}
|
|
6980
7396
|
let accountIndex = 0;
|
|
6981
7397
|
const getNextAccount = () => {
|
|
6982
|
-
const
|
|
7398
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
6983
7399
|
accountIndex += 1;
|
|
6984
|
-
return
|
|
7400
|
+
return accountMeta2;
|
|
6985
7401
|
};
|
|
6986
7402
|
return {
|
|
6987
7403
|
programAddress: instruction.programAddress,
|
|
@@ -7149,14 +7565,332 @@ async function getOracleStateAddress(oracleAuthority, nonce) {
|
|
|
7149
7565
|
]
|
|
7150
7566
|
});
|
|
7151
7567
|
}
|
|
7568
|
+
var WRAPPED_SOL_MINT = address("So11111111111111111111111111111111111111112");
|
|
7569
|
+
var BPS_DENOMINATOR = 10000n;
|
|
7570
|
+
function isTransactionSigner2(value) {
|
|
7571
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
7572
|
+
}
|
|
7573
|
+
function getAddress(value) {
|
|
7574
|
+
return isTransactionSigner2(value) ? value.address : value;
|
|
7575
|
+
}
|
|
7576
|
+
async function getAssociatedTokenAddress2({
|
|
7577
|
+
owner,
|
|
7578
|
+
mint,
|
|
7579
|
+
tokenProgram
|
|
7580
|
+
}) {
|
|
7581
|
+
const [ata] = await findAssociatedTokenPda({
|
|
7582
|
+
owner,
|
|
7583
|
+
mint,
|
|
7584
|
+
tokenProgram
|
|
7585
|
+
});
|
|
7586
|
+
return ata;
|
|
7587
|
+
}
|
|
7588
|
+
function resolveSlippageBps(slippageBps) {
|
|
7589
|
+
const resolved = slippageBps === void 0 ? 50n : BigInt(slippageBps);
|
|
7590
|
+
if (resolved < 0n || resolved > BPS_DENOMINATOR) {
|
|
7591
|
+
throw new Error("slippageBps must be between 0 and 10000");
|
|
7592
|
+
}
|
|
7593
|
+
return resolved;
|
|
7594
|
+
}
|
|
7595
|
+
function getMinAmountOut({
|
|
7596
|
+
quotedAmountOut,
|
|
7597
|
+
minAmountOut,
|
|
7598
|
+
slippageBps
|
|
7599
|
+
}) {
|
|
7600
|
+
if (minAmountOut !== void 0) {
|
|
7601
|
+
return minAmountOut;
|
|
7602
|
+
}
|
|
7603
|
+
const slippage = resolveSlippageBps(slippageBps);
|
|
7604
|
+
return quotedAmountOut * (BPS_DENOMINATOR - slippage) / BPS_DENOMINATOR;
|
|
7605
|
+
}
|
|
7606
|
+
async function curveSwapExactIn(input) {
|
|
7607
|
+
const programId = input.programId ?? input.deployment?.initializerProgram ?? INITIALIZER_PROGRAM_ID;
|
|
7608
|
+
const user = input.user ?? input.payer;
|
|
7609
|
+
const userAddress = getAddress(user);
|
|
7610
|
+
const baseTokenProgram = input.baseTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
|
|
7611
|
+
const quoteTokenProgram = input.quoteTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
|
|
7612
|
+
const userBaseAccount = await getAssociatedTokenAddress2({
|
|
7613
|
+
owner: userAddress,
|
|
7614
|
+
mint: input.baseMint,
|
|
7615
|
+
tokenProgram: baseTokenProgram
|
|
7616
|
+
});
|
|
7617
|
+
const userQuoteAccount = await getAssociatedTokenAddress2({
|
|
7618
|
+
owner: userAddress,
|
|
7619
|
+
mint: input.quoteMint,
|
|
7620
|
+
tokenProgram: quoteTokenProgram
|
|
7621
|
+
});
|
|
7622
|
+
const setupInstructions = [
|
|
7623
|
+
getCreateAssociatedTokenIdempotentInstruction({
|
|
7624
|
+
payer: input.payer,
|
|
7625
|
+
ata: userBaseAccount,
|
|
7626
|
+
owner: userAddress,
|
|
7627
|
+
mint: input.baseMint,
|
|
7628
|
+
tokenProgram: baseTokenProgram
|
|
7629
|
+
}),
|
|
7630
|
+
getCreateAssociatedTokenIdempotentInstruction({
|
|
7631
|
+
payer: input.payer,
|
|
7632
|
+
ata: userQuoteAccount,
|
|
7633
|
+
owner: userAddress,
|
|
7634
|
+
mint: input.quoteMint,
|
|
7635
|
+
tokenProgram: quoteTokenProgram
|
|
7636
|
+
})
|
|
7637
|
+
];
|
|
7638
|
+
const shouldWrapSol = input.wrapSol ?? (input.quoteMint === WRAPPED_SOL_MINT && input.tradeDirection === TRADE_DIRECTION_BUY);
|
|
7639
|
+
if (shouldWrapSol) {
|
|
7640
|
+
setupInstructions.push(
|
|
7641
|
+
getTransferSolInstruction({
|
|
7642
|
+
source: input.payer,
|
|
7643
|
+
destination: userQuoteAccount,
|
|
7644
|
+
amount: input.amountIn
|
|
7645
|
+
}),
|
|
7646
|
+
getSyncNativeInstruction({ account: userQuoteAccount })
|
|
7647
|
+
);
|
|
7648
|
+
}
|
|
7649
|
+
const swapAccounts = {
|
|
7650
|
+
launch: input.launch,
|
|
7651
|
+
launchAuthority: input.launchAuthority,
|
|
7652
|
+
baseVault: input.baseVault,
|
|
7653
|
+
quoteVault: input.quoteVault,
|
|
7654
|
+
launchFeeState: input.launchFeeState,
|
|
7655
|
+
userBaseAccount,
|
|
7656
|
+
userQuoteAccount,
|
|
7657
|
+
baseMint: input.baseMint,
|
|
7658
|
+
quoteMint: input.quoteMint,
|
|
7659
|
+
user,
|
|
7660
|
+
hookProgram: input.deployment?.cpmmHookProgram ?? CPMM_HOOK_PROGRAM_ID,
|
|
7661
|
+
baseTokenProgram,
|
|
7662
|
+
quoteTokenProgram,
|
|
7663
|
+
remainingAccounts: input.remainingAccounts ? [...input.remainingAccounts] : void 0
|
|
7664
|
+
};
|
|
7665
|
+
const swapInstruction = createCurveSwapExactInInstruction(
|
|
7666
|
+
swapAccounts,
|
|
7667
|
+
{
|
|
7668
|
+
amountIn: input.amountIn,
|
|
7669
|
+
minAmountOut: input.minAmountOut,
|
|
7670
|
+
tradeDirection: input.tradeDirection
|
|
7671
|
+
},
|
|
7672
|
+
programId
|
|
7673
|
+
);
|
|
7674
|
+
const userIn = input.tradeDirection === TRADE_DIRECTION_BUY ? userQuoteAccount : userBaseAccount;
|
|
7675
|
+
const userOut = input.tradeDirection === TRADE_DIRECTION_BUY ? userBaseAccount : userQuoteAccount;
|
|
7676
|
+
return {
|
|
7677
|
+
userBaseAccount,
|
|
7678
|
+
userQuoteAccount,
|
|
7679
|
+
userIn,
|
|
7680
|
+
userOut,
|
|
7681
|
+
setupInstructions,
|
|
7682
|
+
swapInstruction,
|
|
7683
|
+
instructions: [...setupInstructions, swapInstruction]
|
|
7684
|
+
};
|
|
7685
|
+
}
|
|
7686
|
+
async function swapExactIn(input) {
|
|
7687
|
+
const programId = input.programId ?? input.deployment?.cpmmProgram ?? void 0;
|
|
7688
|
+
const pool = "pool" in input ? input.pool : await getPoolByMints(input.rpc, input.mintA, input.mintB, {
|
|
7689
|
+
programId
|
|
7690
|
+
});
|
|
7691
|
+
if (!pool) {
|
|
7692
|
+
throw new Error(`No pool found for ${input.mintA} / ${input.mintB}`);
|
|
7693
|
+
}
|
|
7694
|
+
const user = input.user ?? input.payer;
|
|
7695
|
+
const userAddress = getAddress(user);
|
|
7696
|
+
const token0Program = input.token0Program ?? input.tokenProgram ?? TOKEN_PROGRAM_ADDRESS;
|
|
7697
|
+
const token1Program = input.token1Program ?? input.tokenProgram ?? TOKEN_PROGRAM_ADDRESS;
|
|
7698
|
+
const quote = getSwapQuote(
|
|
7699
|
+
pool.account,
|
|
7700
|
+
input.amountIn,
|
|
7701
|
+
input.tradeDirection
|
|
7702
|
+
);
|
|
7703
|
+
const minAmountOut = getMinAmountOut({
|
|
7704
|
+
quotedAmountOut: quote.amountOut,
|
|
7705
|
+
minAmountOut: input.minAmountOut,
|
|
7706
|
+
slippageBps: input.slippageBps
|
|
7707
|
+
});
|
|
7708
|
+
const userToken0 = await getAssociatedTokenAddress2({
|
|
7709
|
+
owner: userAddress,
|
|
7710
|
+
mint: pool.account.token0Mint,
|
|
7711
|
+
tokenProgram: token0Program
|
|
7712
|
+
});
|
|
7713
|
+
const userToken1 = await getAssociatedTokenAddress2({
|
|
7714
|
+
owner: userAddress,
|
|
7715
|
+
mint: pool.account.token1Mint,
|
|
7716
|
+
tokenProgram: token1Program
|
|
7717
|
+
});
|
|
7718
|
+
const setupInstructions = [
|
|
7719
|
+
getCreateAssociatedTokenIdempotentInstruction({
|
|
7720
|
+
payer: input.payer,
|
|
7721
|
+
ata: userToken0,
|
|
7722
|
+
owner: userAddress,
|
|
7723
|
+
mint: pool.account.token0Mint,
|
|
7724
|
+
tokenProgram: token0Program
|
|
7725
|
+
}),
|
|
7726
|
+
getCreateAssociatedTokenIdempotentInstruction({
|
|
7727
|
+
payer: input.payer,
|
|
7728
|
+
ata: userToken1,
|
|
7729
|
+
owner: userAddress,
|
|
7730
|
+
mint: pool.account.token1Mint,
|
|
7731
|
+
tokenProgram: token1Program
|
|
7732
|
+
})
|
|
7733
|
+
];
|
|
7734
|
+
const swapInstruction = createSwapInstruction({
|
|
7735
|
+
config: input.config ?? input.deployment?.cpmmConfig ?? pool.account.config,
|
|
7736
|
+
pool: pool.address,
|
|
7737
|
+
authority: pool.account.authority,
|
|
7738
|
+
vault0: pool.account.vault0,
|
|
7739
|
+
vault1: pool.account.vault1,
|
|
7740
|
+
token0Mint: pool.account.token0Mint,
|
|
7741
|
+
token1Mint: pool.account.token1Mint,
|
|
7742
|
+
userToken0,
|
|
7743
|
+
userToken1,
|
|
7744
|
+
user,
|
|
7745
|
+
amountIn: input.amountIn,
|
|
7746
|
+
minAmountOut,
|
|
7747
|
+
tradeDirection: input.tradeDirection,
|
|
7748
|
+
oracle: input.oracle,
|
|
7749
|
+
remainingAccounts: input.remainingAccounts ? [...input.remainingAccounts] : void 0,
|
|
7750
|
+
updateOracle: input.updateOracle,
|
|
7751
|
+
token0Program,
|
|
7752
|
+
token1Program,
|
|
7753
|
+
programId: programId ?? input.deployment?.cpmmProgram
|
|
7754
|
+
});
|
|
7755
|
+
const userIn = input.tradeDirection === 0 ? userToken0 : userToken1;
|
|
7756
|
+
const userOut = input.tradeDirection === 0 ? userToken1 : userToken0;
|
|
7757
|
+
return {
|
|
7758
|
+
pool,
|
|
7759
|
+
quote,
|
|
7760
|
+
minAmountOut,
|
|
7761
|
+
userToken0,
|
|
7762
|
+
userToken1,
|
|
7763
|
+
userIn,
|
|
7764
|
+
userOut,
|
|
7765
|
+
setupInstructions,
|
|
7766
|
+
swapInstruction,
|
|
7767
|
+
instructions: [...setupInstructions, swapInstruction]
|
|
7768
|
+
};
|
|
7769
|
+
}
|
|
7770
|
+
var COMPUTE_BUDGET_PROGRAM_ID = address(
|
|
7771
|
+
"ComputeBudget111111111111111111111111111111"
|
|
7772
|
+
);
|
|
7773
|
+
function createSetComputeUnitLimitInstruction(units) {
|
|
7774
|
+
const data = new Uint8Array(5);
|
|
7775
|
+
data[0] = 2;
|
|
7776
|
+
new DataView(data.buffer).setUint32(1, units, true);
|
|
7777
|
+
return {
|
|
7778
|
+
programAddress: COMPUTE_BUDGET_PROGRAM_ID,
|
|
7779
|
+
accounts: [],
|
|
7780
|
+
data
|
|
7781
|
+
};
|
|
7782
|
+
}
|
|
7783
|
+
function getDefaultComputeUnitLimit(cpmmMigration) {
|
|
7784
|
+
return cpmmMigration.recipientAtas.length > 0 ? 8e5 : 4e5;
|
|
7785
|
+
}
|
|
7786
|
+
function migrateLaunch(input) {
|
|
7787
|
+
const baseTokenProgram = input.baseTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
|
|
7788
|
+
const quoteTokenProgram = input.quoteTokenProgram ?? TOKEN_PROGRAM_ADDRESS;
|
|
7789
|
+
const recipients = input.recipients ? [...input.recipients] : [];
|
|
7790
|
+
if (recipients.length > 0 && recipients.length !== input.cpmmMigration.recipientAtas.length) {
|
|
7791
|
+
throw new Error(
|
|
7792
|
+
"recipients length must match cpmmMigration.recipientAtas length"
|
|
7793
|
+
);
|
|
7794
|
+
}
|
|
7795
|
+
const initializerConfig = input.config ?? input.deployment?.initializerConfig;
|
|
7796
|
+
if (!initializerConfig) {
|
|
7797
|
+
throw new Error("config or deployment.initializerConfig is required");
|
|
7798
|
+
}
|
|
7799
|
+
const recipientAtaInstructions = recipients.map(
|
|
7800
|
+
(recipient, index) => getCreateAssociatedTokenIdempotentInstruction({
|
|
7801
|
+
payer: input.payer,
|
|
7802
|
+
ata: input.cpmmMigration.recipientAtas[index],
|
|
7803
|
+
owner: recipient.wallet,
|
|
7804
|
+
mint: input.baseMint,
|
|
7805
|
+
tokenProgram: baseTokenProgram
|
|
7806
|
+
})
|
|
7807
|
+
);
|
|
7808
|
+
const migrateLaunchInstruction = createMigrateLaunchInstruction(
|
|
7809
|
+
{
|
|
7810
|
+
config: initializerConfig,
|
|
7811
|
+
launch: input.launch,
|
|
7812
|
+
launchAuthority: input.launchAuthority,
|
|
7813
|
+
baseMint: input.baseMint,
|
|
7814
|
+
quoteMint: input.quoteMint,
|
|
7815
|
+
baseVault: input.baseVault,
|
|
7816
|
+
quoteVault: input.quoteVault,
|
|
7817
|
+
launchFeeState: input.launchFeeState,
|
|
7818
|
+
migratorProgram: input.deployment?.cpmmMigratorProgram ?? CPMM_MIGRATOR_PROGRAM_ID,
|
|
7819
|
+
payer: input.payer,
|
|
7820
|
+
baseTokenProgram,
|
|
7821
|
+
quoteTokenProgram,
|
|
7822
|
+
systemProgram: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS,
|
|
7823
|
+
rent: input.rent ?? SYSVAR_RENT_ADDRESS$1
|
|
7824
|
+
},
|
|
7825
|
+
input.programId ?? input.deployment?.initializerProgram ?? INITIALIZER_PROGRAM_ID
|
|
7826
|
+
);
|
|
7827
|
+
const migrateInstruction = {
|
|
7828
|
+
...migrateLaunchInstruction,
|
|
7829
|
+
accounts: [
|
|
7830
|
+
...migrateLaunchInstruction.accounts ?? [],
|
|
7831
|
+
...input.cpmmMigration.metas
|
|
7832
|
+
]
|
|
7833
|
+
};
|
|
7834
|
+
const computeUnitLimit = input.computeUnitLimit === void 0 ? getDefaultComputeUnitLimit(input.cpmmMigration) : input.computeUnitLimit;
|
|
7835
|
+
const computeUnitLimitInstruction = computeUnitLimit === false ? void 0 : createSetComputeUnitLimitInstruction(computeUnitLimit);
|
|
7836
|
+
const instructions = [
|
|
7837
|
+
...computeUnitLimitInstruction ? [computeUnitLimitInstruction] : [],
|
|
7838
|
+
...recipientAtaInstructions,
|
|
7839
|
+
migrateInstruction
|
|
7840
|
+
];
|
|
7841
|
+
return {
|
|
7842
|
+
recipientAtaInstructions,
|
|
7843
|
+
computeUnitLimitInstruction,
|
|
7844
|
+
migrateInstruction,
|
|
7845
|
+
instructions
|
|
7846
|
+
};
|
|
7847
|
+
}
|
|
7848
|
+
async function getMigrationQuoteProgress({
|
|
7849
|
+
rpc,
|
|
7850
|
+
quoteVault,
|
|
7851
|
+
pendingQuoteFees,
|
|
7852
|
+
commitment = "confirmed"
|
|
7853
|
+
}) {
|
|
7854
|
+
const vaultBalance = await rpc.getTokenAccountBalance(quoteVault, { commitment }).send();
|
|
7855
|
+
const quoteVaultAmount = BigInt(vaultBalance.value.amount);
|
|
7856
|
+
if (pendingQuoteFees > quoteVaultAmount) {
|
|
7857
|
+
throw new Error(
|
|
7858
|
+
"pendingQuoteFees cannot exceed the quote vault token balance"
|
|
7859
|
+
);
|
|
7860
|
+
}
|
|
7861
|
+
return {
|
|
7862
|
+
quoteVaultAmount,
|
|
7863
|
+
pendingQuoteFees,
|
|
7864
|
+
migrationQuoteAmount: quoteVaultAmount - pendingQuoteFees
|
|
7865
|
+
};
|
|
7866
|
+
}
|
|
7867
|
+
async function assertMigrationQuoteThreshold({
|
|
7868
|
+
rpc,
|
|
7869
|
+
quoteVault,
|
|
7870
|
+
pendingQuoteFees,
|
|
7871
|
+
minRaiseQuote,
|
|
7872
|
+
commitment = "confirmed"
|
|
7873
|
+
}) {
|
|
7874
|
+
const progress = await getMigrationQuoteProgress({
|
|
7875
|
+
rpc,
|
|
7876
|
+
quoteVault,
|
|
7877
|
+
pendingQuoteFees,
|
|
7878
|
+
commitment
|
|
7879
|
+
});
|
|
7880
|
+
if (progress.migrationQuoteAmount < minRaiseQuote) {
|
|
7881
|
+
throw new Error(
|
|
7882
|
+
`Quote available for migration ${progress.migrationQuoteAmount} is below minRaiseQuote ${minRaiseQuote}`
|
|
7883
|
+
);
|
|
7884
|
+
}
|
|
7885
|
+
return progress;
|
|
7886
|
+
}
|
|
7152
7887
|
|
|
7153
7888
|
// src/solana/deployment.ts
|
|
7154
7889
|
var DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES = {
|
|
7155
7890
|
cpmmProgram: CPMM_PROGRAM_ID,
|
|
7156
7891
|
initializerProgram: INITIALIZER_PROGRAM_ID,
|
|
7157
7892
|
cpmmMigratorProgram: CPMM_MIGRATOR_PROGRAM_ID,
|
|
7158
|
-
cpmmHookProgram: CPMM_HOOK_PROGRAM_ID
|
|
7159
|
-
cosignerHookProgram: DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID
|
|
7893
|
+
cpmmHookProgram: CPMM_HOOK_PROGRAM_ID
|
|
7160
7894
|
};
|
|
7161
7895
|
async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES) {
|
|
7162
7896
|
const [cpmmConfig] = await getConfigAddress(programs.cpmmProgram);
|
|
@@ -7170,6 +7904,6 @@ async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGR
|
|
|
7170
7904
|
};
|
|
7171
7905
|
}
|
|
7172
7906
|
|
|
7173
|
-
export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES,
|
|
7907
|
+
export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES, assertMigrationQuoteThreshold, cpmm_exports as cpmm, cpmmHook_exports as cpmmHook, cpmmMigrator_exports as cpmmMigrator, createLaunch, curveSwapExactIn, deriveSolanaCpmmDeployment, getMigrationQuoteProgress, initializer_exports as initializer, migrateLaunch, predictionMigrator_exports as predictionMigrator, swapExactIn, trustedOracle_exports as trustedOracle };
|
|
7174
7908
|
//# sourceMappingURL=index.js.map
|
|
7175
7909
|
//# sourceMappingURL=index.js.map
|