@whetstone-research/doppler-sdk 1.0.28 → 1.0.30
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-4WY5GNZD.cjs → chunk-7PXLEMBJ.cjs} +336 -36
- 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-AYVFWD5P.js → chunk-PSLY7M7C.js} +296 -4
- package/dist/chunk-PSLY7M7C.js.map +1 -0
- 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 +1408 -1963
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +1294 -1376
- package/dist/solana/index.d.ts +1294 -1376
- package/dist/solana/index.js +1008 -1562
- 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-4WY5GNZD.cjs.map +0 -1
- package/dist/chunk-AYVFWD5P.js.map +0 -1
- package/dist/chunk-U6B52TBT.cjs.map +0 -1
- package/dist/chunk-WD5VOZGI.js.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,12 +1,13 @@
|
|
|
1
|
-
import { warnAccountDecodeFailure, transferAdminArgsCodec, swapExactInArgsCodec, sortPositionsByShares, sortPoolsByReserves, setHookArgsCodec, setFeesArgsCodec, removeLiquidityArgsCodec, ratioToNumber, q64ToNumber, q64Mul, q64Div, positionDataCodec, poolExists, poolDataCodec, parseWithdrawVaultExcessInstruction, parseUpdateConfigInstruction, parseUnpauseInstruction, parseTransferAdminInstruction, parseSwapExactInInstruction, parseSetHookInstruction, parseSetFeesInstruction, parseRemoveLiquidityInstruction, parseRedeemProtocolSharesInstruction, parsePreviewSwapExactInInstruction, parsePauseInstruction, parseOracleUpdateInstruction, parseOracleConsultInstruction, parseInitializePoolInstruction, parseInitializeOracleInstruction, parseInitializeConfigInstruction, parseCreatePositionInstruction, parseCollectProtocolFeesInstruction, parseCollectFeesInstruction, parseClosePositionInstruction, parseAddLiquidityInstruction, oracleStateDataCodec, oracleConsultArgsCodec, observationCodec, numberToQ64, normalizeProgramAccountsResponse, minBigInt, maxBigInt, isqrt, isTransactionSigner, isOracleStale, initializePoolArgsCodec, initializeOracleArgsCodec, initializeConfigArgsCodec, getWithdrawVaultExcessInstructionDataEncoder, getWithdrawVaultExcessInstructionDataDecoder, getWithdrawVaultExcessInstructionDataCodec, getWithdrawVaultExcessInstructionAsync, getWithdrawVaultExcessInstruction, getWithdrawVaultExcessDiscriminatorBytes, getUpdateConfigInstructionDataEncoder, getUpdateConfigInstructionDataDecoder, getUpdateConfigInstructionDataCodec, getUpdateConfigInstruction, getUpdateConfigDiscriminatorBytes, getUnpauseInstructionDataEncoder, getUnpauseInstructionDataDecoder, getUnpauseInstructionDataCodec, getUnpauseInstruction, getUnpauseDiscriminatorBytes, getTvl, getTransferAdminInstructionDataEncoder, getTransferAdminInstructionDataDecoder, getTransferAdminInstructionDataCodec, getTransferAdminInstruction, getTransferAdminDiscriminatorBytes, getSwapQuoteExactOut, getSwapQuote, getSwapExactInInstructionDataEncoder, getSwapExactInInstructionDataDecoder, getSwapExactInInstructionDataCodec, getSwapExactInInstructionAsync, getSwapExactInInstruction, getSwapExactInDiscriminatorBytes, getSpotPrice1, getSpotPrice0, getSetHookInstructionDataEncoder, getSetHookInstructionDataDecoder, getSetHookInstructionDataCodec, getSetHookInstruction, getSetHookDiscriminatorBytes, getSetFeesInstructionDataEncoder, getSetFeesInstructionDataDecoder, getSetFeesInstructionDataCodec, getSetFeesInstruction, getSetFeesDiscriminatorBytes, getRemoveLiquidityQuote, getRemoveLiquidityInstructionDataEncoder, getRemoveLiquidityInstructionDataDecoder, getRemoveLiquidityInstructionDataCodec, getRemoveLiquidityInstructionAsync, getRemoveLiquidityInstruction, getRemoveLiquidityDiscriminatorBytes, getRedeemProtocolSharesInstructionDataEncoder, getRedeemProtocolSharesInstructionDataDecoder, getRedeemProtocolSharesInstructionDataCodec, getRedeemProtocolSharesInstructionAsync, getRedeemProtocolSharesInstruction, getRedeemProtocolSharesDiscriminatorBytes, getPreviewSwapExactInInstructionDataEncoder, getPreviewSwapExactInInstructionDataDecoder, getPreviewSwapExactInInstructionDataCodec, getPreviewSwapExactInInstruction, getPreviewSwapExactInDiscriminatorBytes, getPositionValue, getPositionAddressFromParams, getPoolByMints, getPoolAddressFromMints, getPendingFees, getPauseInstructionDataEncoder, getPauseInstructionDataDecoder, getPauseInstructionDataCodec, getPauseInstruction, getPauseDiscriminatorBytes, getOracleUpdateInstructionDataEncoder, getOracleUpdateInstructionDataDecoder, getOracleUpdateInstructionDataCodec, getOracleUpdateInstructionAsync, getOracleUpdateInstruction, getOracleUpdateDiscriminatorBytes, getOracleSpotPrices, getOracleForPool, getOracleDeviation, getOracleConsultInstructionDataEncoder, getOracleConsultInstructionDataDecoder, getOracleConsultInstructionDataCodec, getOracleConsultInstructionAsync, getOracleConsultInstruction, getOracleConsultDiscriminatorBytes, getOracleBufferStats, getOracleAge, getOracleAddressFromPool, getK, getInitializePoolInstructionDataEncoder, getInitializePoolInstructionDataDecoder, getInitializePoolInstructionDataCodec, getInitializePoolInstructionAsync, getInitializePoolInstruction, getInitializePoolDiscriminatorBytes, getInitializeOracleInstructionDataEncoder, getInitializeOracleInstructionDataDecoder, getInitializeOracleInstructionDataCodec, getInitializeOracleInstructionAsync, getInitializeOracleInstruction, getInitializeOracleDiscriminatorBytes, getInitializeConfigInstructionDataEncoder, getInitializeConfigInstructionDataDecoder, getInitializeConfigInstructionDataCodec, getInitializeConfigInstructionAsync, getInitializeConfigInstruction, getInitializeConfigDiscriminatorBytes, getCreatePositionInstructionDataEncoder, getCreatePositionInstructionDataDecoder, getCreatePositionInstructionDataCodec, getCreatePositionInstructionAsync, getCreatePositionInstruction, getCreatePositionDiscriminatorBytes, getCollectProtocolFeesInstructionDataEncoder, getCollectProtocolFeesInstructionDataDecoder, getCollectProtocolFeesInstructionDataCodec, getCollectProtocolFeesInstructionAsync, getCollectProtocolFeesInstruction, getCollectProtocolFeesDiscriminatorBytes, getCollectFeesInstructionDataEncoder, getCollectFeesInstructionDataDecoder, getCollectFeesInstructionDataCodec, getCollectFeesInstructionAsync, getCollectFeesInstruction, getCollectFeesDiscriminatorBytes, getClosePositionInstructionDataEncoder, getClosePositionInstructionDataDecoder, getClosePositionInstructionDataCodec, getClosePositionInstruction, getClosePositionDiscriminatorBytes, getAddressFromRemainingAccount, getAddressFromAddressOrSigner, getAddLiquidityQuote, getAddLiquidityInstructionDataEncoder, getAddLiquidityInstructionDataDecoder, getAddLiquidityInstructionDataCodec, getAddLiquidityInstructionAsync, getAddLiquidityInstruction, getAddLiquidityDiscriminatorBytes, filterPoolsByMint, filterActivePositions, fetchUserPositions, fetchPositionsBatch, fetchPositionByParams, fetchPosition, fetchPoolsBatch, fetchPoolPositions, fetchPool, fetchOraclesBatch, fetchOracle, fetchAllPools, encodeTransferAdminArgs, encodeSwapExactInArgs, encodeSetHookArgs, encodeSetFeesArgs, encodeRemoveLiquidityArgs, encodeOracleConsultArgs, encodeInstructionData, encodeInitializePoolArgs, encodeInitializeOracleArgs, encodeInitializeConfigArgs, encodeCreatePositionArgs, encodeCollectProtocolFeesArgs, encodeCollectFeesArgs, encodeAddLiquidityArgs, decodePosition, decodePool, decodeOracleState, decodeAmmConfig, createReadonlyRemainingAccountMeta, createPositionArgsCodec, createAccountMeta, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, bytesToBase64EncodedBytes, bytesToBase64, base64ToBytes, ammConfigDataCodec, addressToBase58EncodedBytes, addLiquidityArgsCodec, WITHDRAW_VAULT_EXCESS_DISCRIMINATOR, UPDATE_CONFIG_DISCRIMINATOR, UNPAUSE_DISCRIMINATOR, TRANSFER_ADMIN_DISCRIMINATOR, SWAP_EXACT_IN_DISCRIMINATOR, SET_HOOK_DISCRIMINATOR, SET_FEES_DISCRIMINATOR, REMOVE_LIQUIDITY_DISCRIMINATOR, REDEEM_PROTOCOL_SHARES_DISCRIMINATOR, PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR, PAUSE_DISCRIMINATOR, ORACLE_UPDATE_DISCRIMINATOR, ORACLE_CONSULT_DISCRIMINATOR, INITIALIZE_POOL_DISCRIMINATOR, INITIALIZE_ORACLE_DISCRIMINATOR, INITIALIZE_CONFIG_DISCRIMINATOR, CREATE_POSITION_DISCRIMINATOR, COLLECT_PROTOCOL_FEES_DISCRIMINATOR, COLLECT_FEES_DISCRIMINATOR, CLOSE_POSITION_DISCRIMINATOR, ADD_LIQUIDITY_DISCRIMINATOR, CPMM_PROGRAM_ADDRESS } from '../chunk-
|
|
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 { getCreateAssociatedTokenIdempotentInstruction, getSyncNativeInstruction
|
|
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
|
-
import { getTransferSolInstruction } from '@solana-program/system';
|
|
10
11
|
|
|
11
12
|
// src/solana/cpmm/index.ts
|
|
12
13
|
var cpmm_exports = {};
|
|
@@ -35,6 +36,7 @@ __export(cpmm_exports, {
|
|
|
35
36
|
INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR,
|
|
36
37
|
INITIALIZE_ORACLE_DISCRIMINATOR: () => INITIALIZE_ORACLE_DISCRIMINATOR,
|
|
37
38
|
INITIALIZE_POOL_DISCRIMINATOR: () => INITIALIZE_POOL_DISCRIMINATOR,
|
|
39
|
+
INITIALIZE_SPOT_POOL_DISCRIMINATOR: () => INITIALIZE_SPOT_POOL_DISCRIMINATOR,
|
|
38
40
|
INSTRUCTION_DISCRIMINATORS: () => INSTRUCTION_DISCRIMINATORS,
|
|
39
41
|
MAX_FEE_AMOUNT: () => MAX_FEE_AMOUNT,
|
|
40
42
|
MAX_HOOK_ALLOWLIST: () => MAX_HOOK_ALLOWLIST,
|
|
@@ -52,6 +54,7 @@ __export(cpmm_exports, {
|
|
|
52
54
|
SEED_POOL: () => SEED_POOL,
|
|
53
55
|
SEED_POSITION: () => SEED_POSITION,
|
|
54
56
|
SEED_PROTOCOL_FEE_OWNER: () => SEED_PROTOCOL_FEE_OWNER,
|
|
57
|
+
SEED_SPOT_POOL: () => SEED_SPOT_POOL,
|
|
55
58
|
SET_FEES_DISCRIMINATOR: () => SET_FEES_DISCRIMINATOR,
|
|
56
59
|
SET_HOOK_DISCRIMINATOR: () => SET_HOOK_DISCRIMINATOR,
|
|
57
60
|
SWAP_EXACT_IN_DISCRIMINATOR: () => SWAP_EXACT_IN_DISCRIMINATOR,
|
|
@@ -184,6 +187,12 @@ __export(cpmm_exports, {
|
|
|
184
187
|
getInitializePoolInstructionDataCodec: () => getInitializePoolInstructionDataCodec,
|
|
185
188
|
getInitializePoolInstructionDataDecoder: () => getInitializePoolInstructionDataDecoder,
|
|
186
189
|
getInitializePoolInstructionDataEncoder: () => getInitializePoolInstructionDataEncoder,
|
|
190
|
+
getInitializeSpotPoolDiscriminatorBytes: () => getInitializeSpotPoolDiscriminatorBytes,
|
|
191
|
+
getInitializeSpotPoolInstruction: () => getInitializeSpotPoolInstruction,
|
|
192
|
+
getInitializeSpotPoolInstructionAsync: () => getInitializeSpotPoolInstructionAsync,
|
|
193
|
+
getInitializeSpotPoolInstructionDataCodec: () => getInitializeSpotPoolInstructionDataCodec,
|
|
194
|
+
getInitializeSpotPoolInstructionDataDecoder: () => getInitializeSpotPoolInstructionDataDecoder,
|
|
195
|
+
getInitializeSpotPoolInstructionDataEncoder: () => getInitializeSpotPoolInstructionDataEncoder,
|
|
187
196
|
getK: () => getK,
|
|
188
197
|
getLiquidityAddresses: () => getLiquidityAddresses,
|
|
189
198
|
getMetadataAddress: () => getMetadataAddress,
|
|
@@ -252,6 +261,7 @@ __export(cpmm_exports, {
|
|
|
252
261
|
getSetHookInstructionDataCodec: () => getSetHookInstructionDataCodec,
|
|
253
262
|
getSetHookInstructionDataDecoder: () => getSetHookInstructionDataDecoder,
|
|
254
263
|
getSetHookInstructionDataEncoder: () => getSetHookInstructionDataEncoder,
|
|
264
|
+
getSpotPoolAddress: () => getSpotPoolAddress,
|
|
255
265
|
getSpotPrice0: () => getSpotPrice0,
|
|
256
266
|
getSpotPrice1: () => getSpotPrice1,
|
|
257
267
|
getSwapAddresses: () => getSwapAddresses,
|
|
@@ -311,6 +321,7 @@ __export(cpmm_exports, {
|
|
|
311
321
|
parseInitializeConfigInstruction: () => parseInitializeConfigInstruction,
|
|
312
322
|
parseInitializeOracleInstruction: () => parseInitializeOracleInstruction,
|
|
313
323
|
parseInitializePoolInstruction: () => parseInitializePoolInstruction,
|
|
324
|
+
parseInitializeSpotPoolInstruction: () => parseInitializeSpotPoolInstruction,
|
|
314
325
|
parseOracleConsultInstruction: () => parseOracleConsultInstruction,
|
|
315
326
|
parseOracleUpdateInstruction: () => parseOracleUpdateInstruction,
|
|
316
327
|
parsePauseInstruction: () => parsePauseInstruction,
|
|
@@ -720,22 +731,32 @@ async function fetchConfigWithAddress(rpc, programId = CPMM_PROGRAM_ID, commitme
|
|
|
720
731
|
return { address: configAddress, account };
|
|
721
732
|
}
|
|
722
733
|
|
|
723
|
-
// src/solana/
|
|
724
|
-
var
|
|
725
|
-
__export(
|
|
734
|
+
// src/solana/cpmmHook/index.ts
|
|
735
|
+
var cpmmHook_exports = {};
|
|
736
|
+
__export(cpmmHook_exports, {
|
|
726
737
|
ADD_COSIGNER_DISCRIMINATOR: () => ADD_COSIGNER_DISCRIMINATOR,
|
|
727
738
|
COSIGNER_CONFIG_DISCRIMINATOR: () => COSIGNER_CONFIG_DISCRIMINATOR,
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
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,
|
|
739
760
|
GATE_EXPIRY_DISABLED: () => GATE_EXPIRY_DISABLED,
|
|
740
761
|
GATE_EXPIRY_HEADER_LEN: () => GATE_EXPIRY_HEADER_LEN,
|
|
741
762
|
GATE_EXPIRY_PAYLOAD_LEN: () => GATE_EXPIRY_PAYLOAD_LEN,
|
|
@@ -745,12 +766,15 @@ __export(cosignerHook_exports, {
|
|
|
745
766
|
INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR2,
|
|
746
767
|
MAX_COSIGNERS: () => MAX_COSIGNERS,
|
|
747
768
|
REMOVE_COSIGNER_DISCRIMINATOR: () => REMOVE_COSIGNER_DISCRIMINATOR,
|
|
748
|
-
|
|
769
|
+
SEED_CPMM_HOOK_CONFIG: () => SEED_CPMM_HOOK_CONFIG,
|
|
749
770
|
SET_AUTHORITY_DISCRIMINATOR: () => SET_AUTHORITY_DISCRIMINATOR,
|
|
750
|
-
|
|
771
|
+
cpmmHookProgram: () => cpmmHookProgram,
|
|
751
772
|
decodeCosignerConfig: () => decodeCosignerConfig,
|
|
752
773
|
decodeCosignerGateExpiryPayload: () => decodeCosignerGateExpiryPayload,
|
|
753
774
|
encodeCosignerGateExpiryPayload: () => encodeCosignerGateExpiryPayload,
|
|
775
|
+
encodeCpmmHookPayload: () => encodeCpmmHookPayload,
|
|
776
|
+
encodeDynamicFeeCosignerGatePayload: () => encodeDynamicFeeCosignerGatePayload,
|
|
777
|
+
encodeDynamicFeeSchedule: () => encodeDynamicFeeSchedule,
|
|
754
778
|
fetchAllCosignerConfig: () => fetchAllCosignerConfig,
|
|
755
779
|
fetchAllMaybeCosignerConfig: () => fetchAllMaybeCosignerConfig,
|
|
756
780
|
fetchCosignerConfig: () => fetchCosignerConfig,
|
|
@@ -770,9 +794,10 @@ __export(cosignerHook_exports, {
|
|
|
770
794
|
getCosignerConfigEncoder: () => getCosignerConfigEncoder,
|
|
771
795
|
getCosignerConfigSize: () => getCosignerConfigSize,
|
|
772
796
|
getCosignerGateStatus: () => getCosignerGateStatus,
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
797
|
+
getCpmmHookConfigAddress: () => getCpmmHookConfigAddress,
|
|
798
|
+
getCpmmHookErrorMessage: () => getCpmmHookErrorMessage,
|
|
799
|
+
getCpmmHookRemainingAccountAddresses: () => getCpmmHookRemainingAccountAddresses,
|
|
800
|
+
getCpmmHookRemainingAccounts: () => getCpmmHookRemainingAccounts,
|
|
776
801
|
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
|
|
777
802
|
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder,
|
|
778
803
|
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder,
|
|
@@ -797,15 +822,17 @@ __export(cosignerHook_exports, {
|
|
|
797
822
|
getSetAuthorityInstructionDataCodec: () => getSetAuthorityInstructionDataCodec,
|
|
798
823
|
getSetAuthorityInstructionDataDecoder: () => getSetAuthorityInstructionDataDecoder,
|
|
799
824
|
getSetAuthorityInstructionDataEncoder: () => getSetAuthorityInstructionDataEncoder,
|
|
800
|
-
|
|
801
|
-
|
|
825
|
+
identifyCpmmHookAccount: () => identifyCpmmHookAccount,
|
|
826
|
+
identifyCpmmHookInstruction: () => identifyCpmmHookInstruction,
|
|
802
827
|
isCosignerGateEnforced: () => isCosignerGateEnforced,
|
|
803
|
-
|
|
828
|
+
isCpmmHookError: () => isCpmmHookError,
|
|
829
|
+
isDynamicFeeSchedulePayload: () => isDynamicFeeSchedulePayload,
|
|
804
830
|
parseAddCosignerInstruction: () => parseAddCosignerInstruction,
|
|
805
|
-
|
|
831
|
+
parseCpmmHookInstruction: () => parseCpmmHookInstruction,
|
|
806
832
|
parseInitializeConfigInstruction: () => parseInitializeConfigInstruction2,
|
|
807
833
|
parseRemoveCosignerInstruction: () => parseRemoveCosignerInstruction,
|
|
808
|
-
parseSetAuthorityInstruction: () => parseSetAuthorityInstruction
|
|
834
|
+
parseSetAuthorityInstruction: () => parseSetAuthorityInstruction,
|
|
835
|
+
validateDynamicFeeScheduleArgs: () => validateDynamicFeeScheduleArgs
|
|
809
836
|
});
|
|
810
837
|
var COSIGNER_CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
811
838
|
133,
|
|
@@ -856,13 +883,13 @@ function decodeCosignerConfig(encodedAccount) {
|
|
|
856
883
|
getCosignerConfigDecoder()
|
|
857
884
|
);
|
|
858
885
|
}
|
|
859
|
-
async function fetchCosignerConfig(rpc,
|
|
860
|
-
const maybeAccount = await fetchMaybeCosignerConfig(rpc,
|
|
886
|
+
async function fetchCosignerConfig(rpc, address6, config) {
|
|
887
|
+
const maybeAccount = await fetchMaybeCosignerConfig(rpc, address6, config);
|
|
861
888
|
assertAccountExists(maybeAccount);
|
|
862
889
|
return maybeAccount;
|
|
863
890
|
}
|
|
864
|
-
async function fetchMaybeCosignerConfig(rpc,
|
|
865
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
891
|
+
async function fetchMaybeCosignerConfig(rpc, address6, config) {
|
|
892
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
866
893
|
return decodeCosignerConfig(maybeAccount);
|
|
867
894
|
}
|
|
868
895
|
async function fetchAllCosignerConfig(rpc, addresses, config) {
|
|
@@ -920,7 +947,7 @@ function getAddCosignerInstructionDataCodec() {
|
|
|
920
947
|
);
|
|
921
948
|
}
|
|
922
949
|
async function getAddCosignerInstructionAsync(input, config) {
|
|
923
|
-
const programAddress = config?.programAddress ??
|
|
950
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
924
951
|
const originalAccounts = {
|
|
925
952
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
926
953
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -971,7 +998,7 @@ async function getAddCosignerInstructionAsync(input, config) {
|
|
|
971
998
|
});
|
|
972
999
|
}
|
|
973
1000
|
function getAddCosignerInstruction(input, config) {
|
|
974
|
-
const programAddress = config?.programAddress ??
|
|
1001
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
975
1002
|
const originalAccounts = {
|
|
976
1003
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
977
1004
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1002,9 +1029,9 @@ function parseAddCosignerInstruction(instruction) {
|
|
|
1002
1029
|
}
|
|
1003
1030
|
let accountIndex = 0;
|
|
1004
1031
|
const getNextAccount = () => {
|
|
1005
|
-
const
|
|
1032
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1006
1033
|
accountIndex += 1;
|
|
1007
|
-
return
|
|
1034
|
+
return accountMeta2;
|
|
1008
1035
|
};
|
|
1009
1036
|
return {
|
|
1010
1037
|
programAddress: instruction.programAddress,
|
|
@@ -1049,7 +1076,7 @@ function getInitializeConfigInstructionDataCodec2() {
|
|
|
1049
1076
|
);
|
|
1050
1077
|
}
|
|
1051
1078
|
async function getInitializeConfigInstructionAsync2(input, config) {
|
|
1052
|
-
const programAddress = config?.programAddress ??
|
|
1079
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1053
1080
|
const originalAccounts = {
|
|
1054
1081
|
payer: { value: input.payer ?? null, isWritable: true },
|
|
1055
1082
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
@@ -1109,7 +1136,7 @@ async function getInitializeConfigInstructionAsync2(input, config) {
|
|
|
1109
1136
|
});
|
|
1110
1137
|
}
|
|
1111
1138
|
function getInitializeConfigInstruction2(input, config) {
|
|
1112
|
-
const programAddress = config?.programAddress ??
|
|
1139
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1113
1140
|
const originalAccounts = {
|
|
1114
1141
|
payer: { value: input.payer ?? null, isWritable: true },
|
|
1115
1142
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
@@ -1149,9 +1176,9 @@ function parseInitializeConfigInstruction2(instruction) {
|
|
|
1149
1176
|
}
|
|
1150
1177
|
let accountIndex = 0;
|
|
1151
1178
|
const getNextAccount = () => {
|
|
1152
|
-
const
|
|
1179
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1153
1180
|
accountIndex += 1;
|
|
1154
|
-
return
|
|
1181
|
+
return accountMeta2;
|
|
1155
1182
|
};
|
|
1156
1183
|
return {
|
|
1157
1184
|
programAddress: instruction.programAddress,
|
|
@@ -1202,7 +1229,7 @@ function getRemoveCosignerInstructionDataCodec() {
|
|
|
1202
1229
|
);
|
|
1203
1230
|
}
|
|
1204
1231
|
async function getRemoveCosignerInstructionAsync(input, config) {
|
|
1205
|
-
const programAddress = config?.programAddress ??
|
|
1232
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1206
1233
|
const originalAccounts = {
|
|
1207
1234
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1208
1235
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1253,7 +1280,7 @@ async function getRemoveCosignerInstructionAsync(input, config) {
|
|
|
1253
1280
|
});
|
|
1254
1281
|
}
|
|
1255
1282
|
function getRemoveCosignerInstruction(input, config) {
|
|
1256
|
-
const programAddress = config?.programAddress ??
|
|
1283
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1257
1284
|
const originalAccounts = {
|
|
1258
1285
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1259
1286
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1284,9 +1311,9 @@ function parseRemoveCosignerInstruction(instruction) {
|
|
|
1284
1311
|
}
|
|
1285
1312
|
let accountIndex = 0;
|
|
1286
1313
|
const getNextAccount = () => {
|
|
1287
|
-
const
|
|
1314
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1288
1315
|
accountIndex += 1;
|
|
1289
|
-
return
|
|
1316
|
+
return accountMeta2;
|
|
1290
1317
|
};
|
|
1291
1318
|
return {
|
|
1292
1319
|
programAddress: instruction.programAddress,
|
|
@@ -1331,7 +1358,7 @@ function getSetAuthorityInstructionDataCodec() {
|
|
|
1331
1358
|
);
|
|
1332
1359
|
}
|
|
1333
1360
|
async function getSetAuthorityInstructionAsync(input, config) {
|
|
1334
|
-
const programAddress = config?.programAddress ??
|
|
1361
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1335
1362
|
const originalAccounts = {
|
|
1336
1363
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1337
1364
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1382,7 +1409,7 @@ async function getSetAuthorityInstructionAsync(input, config) {
|
|
|
1382
1409
|
});
|
|
1383
1410
|
}
|
|
1384
1411
|
function getSetAuthorityInstruction(input, config) {
|
|
1385
|
-
const programAddress = config?.programAddress ??
|
|
1412
|
+
const programAddress = config?.programAddress ?? CPMM_HOOK_PROGRAM_ADDRESS;
|
|
1386
1413
|
const originalAccounts = {
|
|
1387
1414
|
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
1388
1415
|
config: { value: input.config ?? null, isWritable: true }
|
|
@@ -1413,9 +1440,9 @@ function parseSetAuthorityInstruction(instruction) {
|
|
|
1413
1440
|
}
|
|
1414
1441
|
let accountIndex = 0;
|
|
1415
1442
|
const getNextAccount = () => {
|
|
1416
|
-
const
|
|
1443
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
1417
1444
|
accountIndex += 1;
|
|
1418
|
-
return
|
|
1445
|
+
return accountMeta2;
|
|
1419
1446
|
};
|
|
1420
1447
|
return {
|
|
1421
1448
|
programAddress: instruction.programAddress,
|
|
@@ -1424,13 +1451,13 @@ function parseSetAuthorityInstruction(instruction) {
|
|
|
1424
1451
|
};
|
|
1425
1452
|
}
|
|
1426
1453
|
|
|
1427
|
-
// src/solana/generated/
|
|
1428
|
-
var
|
|
1429
|
-
var
|
|
1430
|
-
|
|
1431
|
-
return
|
|
1432
|
-
})(
|
|
1433
|
-
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) {
|
|
1434
1461
|
const data = "data" in account ? account.data : account;
|
|
1435
1462
|
if (containsBytes(
|
|
1436
1463
|
data,
|
|
@@ -1443,17 +1470,17 @@ function identifyCosignerHookAccount(account) {
|
|
|
1443
1470
|
}
|
|
1444
1471
|
throw new SolanaError(
|
|
1445
1472
|
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
|
|
1446
|
-
{ accountData: data, programName: "
|
|
1473
|
+
{ accountData: data, programName: "cpmmHook" }
|
|
1447
1474
|
);
|
|
1448
1475
|
}
|
|
1449
|
-
var
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
return
|
|
1455
|
-
})(
|
|
1456
|
-
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) {
|
|
1457
1484
|
const data = "data" in instruction ? instruction.data : instruction;
|
|
1458
1485
|
if (containsBytes(
|
|
1459
1486
|
data,
|
|
@@ -1493,11 +1520,11 @@ function identifyCosignerHookInstruction(instruction) {
|
|
|
1493
1520
|
}
|
|
1494
1521
|
throw new SolanaError(
|
|
1495
1522
|
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
|
1496
|
-
{ instructionData: data, programName: "
|
|
1523
|
+
{ instructionData: data, programName: "cpmmHook" }
|
|
1497
1524
|
);
|
|
1498
1525
|
}
|
|
1499
|
-
function
|
|
1500
|
-
const instructionType =
|
|
1526
|
+
function parseCpmmHookInstruction(instruction) {
|
|
1527
|
+
const instructionType = identifyCpmmHookInstruction(instruction);
|
|
1501
1528
|
switch (instructionType) {
|
|
1502
1529
|
case 0 /* AddCosigner */: {
|
|
1503
1530
|
assertIsInstructionWithAccounts(instruction);
|
|
@@ -1530,18 +1557,15 @@ function parseCosignerHookInstruction(instruction) {
|
|
|
1530
1557
|
default:
|
|
1531
1558
|
throw new SolanaError(
|
|
1532
1559
|
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
|
1533
|
-
{
|
|
1534
|
-
instructionType,
|
|
1535
|
-
programName: "cosignerHook"
|
|
1536
|
-
}
|
|
1560
|
+
{ instructionType, programName: "cpmmHook" }
|
|
1537
1561
|
);
|
|
1538
1562
|
}
|
|
1539
1563
|
}
|
|
1540
|
-
function
|
|
1564
|
+
function cpmmHookProgram() {
|
|
1541
1565
|
return (client) => {
|
|
1542
1566
|
return {
|
|
1543
1567
|
...client,
|
|
1544
|
-
|
|
1568
|
+
cpmmHook: {
|
|
1545
1569
|
accounts: {
|
|
1546
1570
|
cosignerConfig: addSelfFetchFunctions(
|
|
1547
1571
|
client,
|
|
@@ -1574,35 +1598,45 @@ function cosignerHookProgram() {
|
|
|
1574
1598
|
};
|
|
1575
1599
|
}
|
|
1576
1600
|
|
|
1577
|
-
// src/solana/generated/
|
|
1578
|
-
var
|
|
1579
|
-
var
|
|
1580
|
-
var
|
|
1581
|
-
var
|
|
1582
|
-
var
|
|
1583
|
-
var
|
|
1584
|
-
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;
|
|
1585
1614
|
if (process.env.NODE_ENV !== "production") {
|
|
1586
|
-
|
|
1587
|
-
[
|
|
1588
|
-
[
|
|
1589
|
-
[
|
|
1590
|
-
[
|
|
1591
|
-
[
|
|
1592
|
-
[
|
|
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`
|
|
1593
1627
|
};
|
|
1594
1628
|
}
|
|
1595
|
-
function
|
|
1629
|
+
function getCpmmHookErrorMessage(code) {
|
|
1596
1630
|
if (process.env.NODE_ENV !== "production") {
|
|
1597
|
-
return
|
|
1631
|
+
return cpmmHookErrorMessages[code];
|
|
1598
1632
|
}
|
|
1599
1633
|
return "Error message not available in production bundles.";
|
|
1600
1634
|
}
|
|
1601
|
-
function
|
|
1635
|
+
function isCpmmHookError(error, transactionMessage, code) {
|
|
1602
1636
|
return isProgramError(
|
|
1603
1637
|
error,
|
|
1604
1638
|
transactionMessage,
|
|
1605
|
-
|
|
1639
|
+
CPMM_HOOK_PROGRAM_ADDRESS,
|
|
1606
1640
|
code
|
|
1607
1641
|
);
|
|
1608
1642
|
}
|
|
@@ -1643,11 +1677,11 @@ function getSetAuthorityArgsCodec() {
|
|
|
1643
1677
|
getSetAuthorityArgsDecoder()
|
|
1644
1678
|
);
|
|
1645
1679
|
}
|
|
1646
|
-
var
|
|
1647
|
-
"
|
|
1680
|
+
var DEVNET_CPMM_HOOK_PROGRAM_ID = address(
|
|
1681
|
+
"HVsPNZh98TgChUXHwKrUG47SUqvGQHxUy5wZwcQLFD4i"
|
|
1648
1682
|
);
|
|
1649
|
-
var
|
|
1650
|
-
var
|
|
1683
|
+
var CPMM_HOOK_PROGRAM_ID = DEVNET_CPMM_HOOK_PROGRAM_ID;
|
|
1684
|
+
var SEED_CPMM_HOOK_CONFIG = "cosigner_hook_config";
|
|
1651
1685
|
var MAX_COSIGNERS = 32;
|
|
1652
1686
|
var GATE_EXPIRY_DISABLED = 0;
|
|
1653
1687
|
var GATE_EXPIRY_UNIX_TIMESTAMP = 1;
|
|
@@ -1655,15 +1689,146 @@ var GATE_EXPIRY_SLOT = 2;
|
|
|
1655
1689
|
var GATE_EXPIRY_PAYLOAD_VERSION = 1;
|
|
1656
1690
|
var GATE_EXPIRY_HEADER_LEN = 10;
|
|
1657
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
|
+
}
|
|
1658
1826
|
var INITIALIZER_PROGRAM_ID = address(
|
|
1659
1827
|
"4h3Dqyo5qmteJoMxXt3tdtfXELDB6pdRTPU9mWruiKp1"
|
|
1660
1828
|
);
|
|
1661
1829
|
var BPF_LOADER_UPGRADEABLE_PROGRAM_ID = address(
|
|
1662
1830
|
"BPFLoaderUpgradeab1e11111111111111111111111"
|
|
1663
1831
|
);
|
|
1664
|
-
var CPMM_HOOK_PROGRAM_ID = address(
|
|
1665
|
-
"2vJ1c62knEwZbxp3XdHB4RSmCfz55pA6tRkCho63gW7u"
|
|
1666
|
-
);
|
|
1667
1832
|
var PREDICTION_HOOK_PROGRAM_ID = address(
|
|
1668
1833
|
"7QcQDANJVC17Jgc6KjjeagSkm2zAphgHVPK5agJzyihB"
|
|
1669
1834
|
);
|
|
@@ -1863,148 +2028,112 @@ function phaseLabel(phase) {
|
|
|
1863
2028
|
}
|
|
1864
2029
|
}
|
|
1865
2030
|
|
|
1866
|
-
// src/solana/
|
|
1867
|
-
var
|
|
1868
|
-
|
|
2031
|
+
// src/solana/cpmmHook/payload.ts
|
|
2032
|
+
var MAX_I64 = (1n << 63n) - 1n;
|
|
2033
|
+
var MAX_U32 = (1n << 32n) - 1n;
|
|
2034
|
+
function toBigInt2(value) {
|
|
1869
2035
|
return typeof value === "bigint" ? value : BigInt(value);
|
|
1870
2036
|
}
|
|
1871
|
-
function
|
|
1872
|
-
|
|
1873
|
-
}
|
|
1874
|
-
function readU64Le(bytes, offset) {
|
|
1875
|
-
let value = 0n;
|
|
1876
|
-
for (let i = 0; i < 8; i++) {
|
|
1877
|
-
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`);
|
|
1878
2040
|
}
|
|
1879
|
-
return value;
|
|
1880
2041
|
}
|
|
1881
|
-
function
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
}
|
|
2042
|
+
function writeI64Le(bytes, offset, value) {
|
|
2043
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2044
|
+
view.setBigInt64(offset, value, true);
|
|
1885
2045
|
}
|
|
1886
|
-
function
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2046
|
+
function writeU16Le(bytes, offset, value) {
|
|
2047
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2048
|
+
view.setUint16(offset, value, true);
|
|
2049
|
+
}
|
|
2050
|
+
function writeU32Le(bytes, offset, value) {
|
|
2051
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2052
|
+
view.setUint32(offset, Number(value), true);
|
|
2053
|
+
}
|
|
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");
|
|
1892
2058
|
}
|
|
1893
|
-
|
|
1894
|
-
|
|
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");
|
|
1895
2063
|
}
|
|
1896
|
-
const
|
|
1897
|
-
if (
|
|
1898
|
-
throw new Error(
|
|
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");
|
|
1899
2067
|
}
|
|
1900
|
-
if (
|
|
1901
|
-
throw new Error("
|
|
2068
|
+
if (schedule.startFeeBps > schedule.endFeeBps && durationSeconds === 0n) {
|
|
2069
|
+
throw new Error("durationSeconds must be nonzero for decaying schedules");
|
|
1902
2070
|
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
payload
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
);
|
|
2071
|
+
return { startingTime, durationSeconds };
|
|
2072
|
+
}
|
|
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);
|
|
1911
2082
|
return payload;
|
|
1912
2083
|
}
|
|
1913
|
-
function
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
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;
|
|
2091
|
+
}
|
|
2092
|
+
function encodeDynamicFeeCosignerGatePayload(args) {
|
|
2093
|
+
return encodeCosignerGateExpiryPayload(args);
|
|
2094
|
+
}
|
|
2095
|
+
function getCpmmHookRemainingAccounts({
|
|
2096
|
+
namespace,
|
|
2097
|
+
config,
|
|
2098
|
+
cosigner
|
|
2099
|
+
}) {
|
|
2100
|
+
const signedHookRemainingAccounts = [namespace];
|
|
2101
|
+
if (config && config !== namespace) {
|
|
2102
|
+
signedHookRemainingAccounts.push(config);
|
|
1919
2103
|
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
return null;
|
|
2104
|
+
if (cosigner) {
|
|
2105
|
+
signedHookRemainingAccounts.push(cosigner);
|
|
1923
2106
|
}
|
|
2107
|
+
const unsignedHookRemainingAccounts = signedHookRemainingAccounts.map(
|
|
2108
|
+
getAddressFromRemainingAccount
|
|
2109
|
+
);
|
|
1924
2110
|
return {
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
2111
|
+
signedHookRemainingAccounts,
|
|
2112
|
+
unsignedHookRemainingAccounts,
|
|
2113
|
+
hookRemainingAccountsHash: computeRemainingAccountsHash(
|
|
2114
|
+
unsignedHookRemainingAccounts
|
|
1929
2115
|
)
|
|
1930
2116
|
};
|
|
1931
2117
|
}
|
|
1932
|
-
function
|
|
1933
|
-
const expiry = decodeCosignerGateExpiryPayload(hookPayload);
|
|
1934
|
-
if (!expiry) {
|
|
1935
|
-
return {
|
|
1936
|
-
gateEnforced: true,
|
|
1937
|
-
expiryMode: GATE_EXPIRY_DISABLED,
|
|
1938
|
-
expiryValue: 0n,
|
|
1939
|
-
reason: "invalid_expiry_payload"
|
|
1940
|
-
};
|
|
1941
|
-
}
|
|
1942
|
-
if (expiry.mode === GATE_EXPIRY_DISABLED) {
|
|
1943
|
-
return {
|
|
1944
|
-
gateEnforced: true,
|
|
1945
|
-
expiryMode: expiry.mode,
|
|
1946
|
-
expiryValue: expiry.value,
|
|
1947
|
-
reason: "expiry_disabled"
|
|
1948
|
-
};
|
|
1949
|
-
}
|
|
1950
|
-
if (expiry.mode === GATE_EXPIRY_UNIX_TIMESTAMP) {
|
|
1951
|
-
const unixTimestamp = clock.unixTimestamp === void 0 ? BigInt(Math.floor(Date.now() / 1e3)) : toBigInt(clock.unixTimestamp);
|
|
1952
|
-
const expired = unixTimestamp >= expiry.value;
|
|
1953
|
-
return {
|
|
1954
|
-
gateEnforced: !expired,
|
|
1955
|
-
expiryMode: expiry.mode,
|
|
1956
|
-
expiryValue: expiry.value,
|
|
1957
|
-
reason: expired ? "timestamp_expired" : "timestamp_pending"
|
|
1958
|
-
};
|
|
1959
|
-
}
|
|
1960
|
-
if (expiry.mode === GATE_EXPIRY_SLOT) {
|
|
1961
|
-
if (clock.slot === void 0) {
|
|
1962
|
-
return {
|
|
1963
|
-
gateEnforced: true,
|
|
1964
|
-
expiryMode: expiry.mode,
|
|
1965
|
-
expiryValue: expiry.value,
|
|
1966
|
-
reason: "slot_unavailable"
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
const expired = toBigInt(clock.slot) >= expiry.value;
|
|
1970
|
-
return {
|
|
1971
|
-
gateEnforced: !expired,
|
|
1972
|
-
expiryMode: expiry.mode,
|
|
1973
|
-
expiryValue: expiry.value,
|
|
1974
|
-
reason: expired ? "slot_expired" : "slot_pending"
|
|
1975
|
-
};
|
|
1976
|
-
}
|
|
1977
|
-
return {
|
|
1978
|
-
gateEnforced: true,
|
|
1979
|
-
expiryMode: expiry.mode,
|
|
1980
|
-
expiryValue: expiry.value,
|
|
1981
|
-
reason: "invalid_expiry_mode"
|
|
1982
|
-
};
|
|
1983
|
-
}
|
|
1984
|
-
function isCosignerGateEnforced(hookPayload, clock = {}) {
|
|
1985
|
-
return getCosignerGateStatus(hookPayload, clock).gateEnforced;
|
|
1986
|
-
}
|
|
1987
|
-
function getCosignerHookRemainingAccounts({
|
|
2118
|
+
function getCpmmHookRemainingAccountAddresses({
|
|
1988
2119
|
namespace,
|
|
2120
|
+
config,
|
|
1989
2121
|
cosigner
|
|
1990
2122
|
}) {
|
|
1991
|
-
|
|
2123
|
+
return getCpmmHookRemainingAccounts({
|
|
1992
2124
|
namespace,
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
unsignedHookRemainingAccounts
|
|
2000
|
-
)
|
|
2001
|
-
};
|
|
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);
|
|
2002
2131
|
}
|
|
2003
2132
|
var textEncoder2 = new TextEncoder();
|
|
2004
|
-
async function
|
|
2133
|
+
async function getCpmmHookConfigAddress(programId = CPMM_HOOK_PROGRAM_ID) {
|
|
2005
2134
|
return getProgramDerivedAddress({
|
|
2006
2135
|
programAddress: programId,
|
|
2007
|
-
seeds: [textEncoder2.encode(
|
|
2136
|
+
seeds: [textEncoder2.encode(SEED_CPMM_HOOK_CONFIG)]
|
|
2008
2137
|
});
|
|
2009
2138
|
}
|
|
2010
2139
|
|
|
@@ -2012,7 +2141,6 @@ async function getCosignerHookConfigAddress(programId = COSIGNER_HOOK_PROGRAM_ID
|
|
|
2012
2141
|
var initializer_exports = {};
|
|
2013
2142
|
__export(initializer_exports, {
|
|
2014
2143
|
BPF_LOADER_UPGRADEABLE_PROGRAM_ID: () => BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
|
|
2015
|
-
CPMM_HOOK_PROGRAM_ID: () => CPMM_HOOK_PROGRAM_ID,
|
|
2016
2144
|
CURVE_KIND_XYK: () => CURVE_KIND_XYK,
|
|
2017
2145
|
CURVE_PARAMS_FORMAT_XYK_V0: () => CURVE_PARAMS_FORMAT_XYK_V0,
|
|
2018
2146
|
DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND: () => DEFAULT_LOOKUP_TABLE_ADDRESSES_PER_EXTEND,
|
|
@@ -2070,6 +2198,7 @@ __export(initializer_exports, {
|
|
|
2070
2198
|
getInitConfigCodec: () => getInitConfigCodec,
|
|
2071
2199
|
getInitConfigDecoder: () => getInitConfigDecoder,
|
|
2072
2200
|
getInitConfigEncoder: () => getInitConfigEncoder,
|
|
2201
|
+
getInitConfigSize: () => getInitConfigSize,
|
|
2073
2202
|
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec2,
|
|
2074
2203
|
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder2,
|
|
2075
2204
|
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder2,
|
|
@@ -2108,43 +2237,55 @@ var INIT_CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
|
2108
2237
|
126
|
|
2109
2238
|
]);
|
|
2110
2239
|
function getInitConfigEncoder() {
|
|
2111
|
-
return
|
|
2112
|
-
|
|
2113
|
-
[
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2240
|
+
return fixEncoderSize(
|
|
2241
|
+
transformEncoder(
|
|
2242
|
+
getStructEncoder([
|
|
2243
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2244
|
+
["admin", getAddressEncoder()],
|
|
2245
|
+
["migratorAllowlistLen", getU8Encoder()],
|
|
2246
|
+
[
|
|
2247
|
+
"migratorAllowlist",
|
|
2248
|
+
getArrayEncoder(getAddressEncoder(), { size: 32 })
|
|
2249
|
+
],
|
|
2250
|
+
["hookAllowlistLen", getU8Encoder()],
|
|
2251
|
+
["hookAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
2252
|
+
["bump", getU8Encoder()],
|
|
2253
|
+
["version", getU8Encoder()],
|
|
2254
|
+
["protocolFeeBps", getU16Encoder()],
|
|
2255
|
+
["minSwapFeeBps", getU16Encoder()],
|
|
2256
|
+
["maxSwapFeeBps", getU16Encoder()],
|
|
2257
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 24)]
|
|
2258
|
+
]),
|
|
2259
|
+
(value) => ({ ...value, discriminator: INIT_CONFIG_DISCRIMINATOR })
|
|
2260
|
+
),
|
|
2261
|
+
2123
|
|
2127
2262
|
);
|
|
2128
2263
|
}
|
|
2129
2264
|
function getInitConfigDecoder() {
|
|
2130
|
-
return
|
|
2131
|
-
[
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2265
|
+
return fixDecoderSize(
|
|
2266
|
+
getStructDecoder([
|
|
2267
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2268
|
+
["admin", getAddressDecoder()],
|
|
2269
|
+
["migratorAllowlistLen", getU8Decoder()],
|
|
2270
|
+
["migratorAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
2271
|
+
["hookAllowlistLen", getU8Decoder()],
|
|
2272
|
+
["hookAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
2273
|
+
["bump", getU8Decoder()],
|
|
2274
|
+
["version", getU8Decoder()],
|
|
2275
|
+
["protocolFeeBps", getU16Decoder()],
|
|
2276
|
+
["minSwapFeeBps", getU16Decoder()],
|
|
2277
|
+
["maxSwapFeeBps", getU16Decoder()],
|
|
2278
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 24)]
|
|
2279
|
+
]),
|
|
2280
|
+
2123
|
|
2281
|
+
);
|
|
2144
2282
|
}
|
|
2145
2283
|
function getInitConfigCodec() {
|
|
2146
2284
|
return combineCodec(getInitConfigEncoder(), getInitConfigDecoder());
|
|
2147
2285
|
}
|
|
2286
|
+
function getInitConfigSize() {
|
|
2287
|
+
return 2123;
|
|
2288
|
+
}
|
|
2148
2289
|
function getFeeBeneficiaryEncoder() {
|
|
2149
2290
|
return getStructEncoder([
|
|
2150
2291
|
["wallet", getAddressEncoder()],
|
|
@@ -3176,6 +3317,17 @@ var SEED_STATE = "state";
|
|
|
3176
3317
|
var SEED_MIGRATION_AUTHORITY = "migration_authority";
|
|
3177
3318
|
var MAX_RECIPIENTS = 2;
|
|
3178
3319
|
var CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS = {
|
|
3320
|
+
// SHA256("global:create_spot_pool")[0:8]
|
|
3321
|
+
createSpotPool: new Uint8Array([
|
|
3322
|
+
13,
|
|
3323
|
+
137,
|
|
3324
|
+
16,
|
|
3325
|
+
26,
|
|
3326
|
+
40,
|
|
3327
|
+
36,
|
|
3328
|
+
110,
|
|
3329
|
+
26
|
|
3330
|
+
]),
|
|
3179
3331
|
// SHA256("global:register_launch")[0:8]
|
|
3180
3332
|
registerLaunch: new Uint8Array([
|
|
3181
3333
|
114,
|
|
@@ -3266,13 +3418,13 @@ function decodeClaimReceipt(encodedAccount) {
|
|
|
3266
3418
|
getClaimReceiptDecoder()
|
|
3267
3419
|
);
|
|
3268
3420
|
}
|
|
3269
|
-
async function fetchClaimReceipt(rpc,
|
|
3270
|
-
const maybeAccount = await fetchMaybeClaimReceipt(rpc,
|
|
3421
|
+
async function fetchClaimReceipt(rpc, address6, config) {
|
|
3422
|
+
const maybeAccount = await fetchMaybeClaimReceipt(rpc, address6, config);
|
|
3271
3423
|
assertAccountExists(maybeAccount);
|
|
3272
3424
|
return maybeAccount;
|
|
3273
3425
|
}
|
|
3274
|
-
async function fetchMaybeClaimReceipt(rpc,
|
|
3275
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3426
|
+
async function fetchMaybeClaimReceipt(rpc, address6, config) {
|
|
3427
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3276
3428
|
return decodeClaimReceipt(maybeAccount);
|
|
3277
3429
|
}
|
|
3278
3430
|
async function fetchAllClaimReceipt(rpc, addresses, config) {
|
|
@@ -3336,13 +3488,13 @@ function decodeEntry(encodedAccount) {
|
|
|
3336
3488
|
getEntryDecoder()
|
|
3337
3489
|
);
|
|
3338
3490
|
}
|
|
3339
|
-
async function fetchEntry(rpc,
|
|
3340
|
-
const maybeAccount = await fetchMaybeEntry(rpc,
|
|
3491
|
+
async function fetchEntry(rpc, address6, config) {
|
|
3492
|
+
const maybeAccount = await fetchMaybeEntry(rpc, address6, config);
|
|
3341
3493
|
assertAccountExists(maybeAccount);
|
|
3342
3494
|
return maybeAccount;
|
|
3343
3495
|
}
|
|
3344
|
-
async function fetchMaybeEntry(rpc,
|
|
3345
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3496
|
+
async function fetchMaybeEntry(rpc, address6, config) {
|
|
3497
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3346
3498
|
return decodeEntry(maybeAccount);
|
|
3347
3499
|
}
|
|
3348
3500
|
async function fetchAllEntry(rpc, addresses, config) {
|
|
@@ -3404,13 +3556,13 @@ function decodeEntryByMint(encodedAccount) {
|
|
|
3404
3556
|
getEntryByMintDecoder()
|
|
3405
3557
|
);
|
|
3406
3558
|
}
|
|
3407
|
-
async function fetchEntryByMint(rpc,
|
|
3408
|
-
const maybeAccount = await fetchMaybeEntryByMint(rpc,
|
|
3559
|
+
async function fetchEntryByMint(rpc, address6, config) {
|
|
3560
|
+
const maybeAccount = await fetchMaybeEntryByMint(rpc, address6, config);
|
|
3409
3561
|
assertAccountExists(maybeAccount);
|
|
3410
3562
|
return maybeAccount;
|
|
3411
3563
|
}
|
|
3412
|
-
async function fetchMaybeEntryByMint(rpc,
|
|
3413
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3564
|
+
async function fetchMaybeEntryByMint(rpc, address6, config) {
|
|
3565
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3414
3566
|
return decodeEntryByMint(maybeAccount);
|
|
3415
3567
|
}
|
|
3416
3568
|
async function fetchAllEntryByMint(rpc, addresses, config) {
|
|
@@ -3439,39 +3591,48 @@ function getInitConfigDiscriminatorBytes() {
|
|
|
3439
3591
|
return fixEncoderSize(getBytesEncoder(), 8).encode(INIT_CONFIG_DISCRIMINATOR2);
|
|
3440
3592
|
}
|
|
3441
3593
|
function getInitConfigEncoder2() {
|
|
3442
|
-
return
|
|
3443
|
-
|
|
3444
|
-
[
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3594
|
+
return fixEncoderSize(
|
|
3595
|
+
transformEncoder(
|
|
3596
|
+
getStructEncoder([
|
|
3597
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
3598
|
+
["admin", getAddressEncoder()],
|
|
3599
|
+
["migratorAllowlistLen", getU8Encoder()],
|
|
3600
|
+
[
|
|
3601
|
+
"migratorAllowlist",
|
|
3602
|
+
getArrayEncoder(getAddressEncoder(), { size: 32 })
|
|
3603
|
+
],
|
|
3604
|
+
["hookAllowlistLen", getU8Encoder()],
|
|
3605
|
+
["hookAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
3606
|
+
["bump", getU8Encoder()],
|
|
3607
|
+
["version", getU8Encoder()],
|
|
3608
|
+
["protocolFeeBps", getU16Encoder()],
|
|
3609
|
+
["minSwapFeeBps", getU16Encoder()],
|
|
3610
|
+
["maxSwapFeeBps", getU16Encoder()],
|
|
3611
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 24)]
|
|
3612
|
+
]),
|
|
3613
|
+
(value) => ({ ...value, discriminator: INIT_CONFIG_DISCRIMINATOR2 })
|
|
3614
|
+
),
|
|
3615
|
+
2123
|
|
3458
3616
|
);
|
|
3459
3617
|
}
|
|
3460
3618
|
function getInitConfigDecoder2() {
|
|
3461
|
-
return
|
|
3462
|
-
[
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3619
|
+
return fixDecoderSize(
|
|
3620
|
+
getStructDecoder([
|
|
3621
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
3622
|
+
["admin", getAddressDecoder()],
|
|
3623
|
+
["migratorAllowlistLen", getU8Decoder()],
|
|
3624
|
+
["migratorAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
3625
|
+
["hookAllowlistLen", getU8Decoder()],
|
|
3626
|
+
["hookAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
3627
|
+
["bump", getU8Decoder()],
|
|
3628
|
+
["version", getU8Decoder()],
|
|
3629
|
+
["protocolFeeBps", getU16Decoder()],
|
|
3630
|
+
["minSwapFeeBps", getU16Decoder()],
|
|
3631
|
+
["maxSwapFeeBps", getU16Decoder()],
|
|
3632
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 24)]
|
|
3633
|
+
]),
|
|
3634
|
+
2123
|
|
3635
|
+
);
|
|
3475
3636
|
}
|
|
3476
3637
|
function getInitConfigCodec2() {
|
|
3477
3638
|
return combineCodec(getInitConfigEncoder2(), getInitConfigDecoder2());
|
|
@@ -3482,13 +3643,13 @@ function decodeInitConfig(encodedAccount) {
|
|
|
3482
3643
|
getInitConfigDecoder2()
|
|
3483
3644
|
);
|
|
3484
3645
|
}
|
|
3485
|
-
async function fetchInitConfig(rpc,
|
|
3486
|
-
const maybeAccount = await fetchMaybeInitConfig(rpc,
|
|
3646
|
+
async function fetchInitConfig(rpc, address6, config) {
|
|
3647
|
+
const maybeAccount = await fetchMaybeInitConfig(rpc, address6, config);
|
|
3487
3648
|
assertAccountExists(maybeAccount);
|
|
3488
3649
|
return maybeAccount;
|
|
3489
3650
|
}
|
|
3490
|
-
async function fetchMaybeInitConfig(rpc,
|
|
3491
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3651
|
+
async function fetchMaybeInitConfig(rpc, address6, config) {
|
|
3652
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3492
3653
|
return decodeInitConfig(maybeAccount);
|
|
3493
3654
|
}
|
|
3494
3655
|
async function fetchAllInitConfig(rpc, addresses, config) {
|
|
@@ -3500,7 +3661,7 @@ async function fetchAllMaybeInitConfig(rpc, addresses, config) {
|
|
|
3500
3661
|
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
3501
3662
|
return maybeAccounts.map((maybeAccount) => decodeInitConfig(maybeAccount));
|
|
3502
3663
|
}
|
|
3503
|
-
function
|
|
3664
|
+
function getInitConfigSize2() {
|
|
3504
3665
|
return 2123;
|
|
3505
3666
|
}
|
|
3506
3667
|
function getAccumulatorUpdatedEncoder() {
|
|
@@ -3788,13 +3949,13 @@ function decodeLaunch(encodedAccount) {
|
|
|
3788
3949
|
getLaunchDecoder2()
|
|
3789
3950
|
);
|
|
3790
3951
|
}
|
|
3791
|
-
async function fetchLaunch(rpc,
|
|
3792
|
-
const maybeAccount = await fetchMaybeLaunch(rpc,
|
|
3952
|
+
async function fetchLaunch(rpc, address6, config) {
|
|
3953
|
+
const maybeAccount = await fetchMaybeLaunch(rpc, address6, config);
|
|
3793
3954
|
assertAccountExists(maybeAccount);
|
|
3794
3955
|
return maybeAccount;
|
|
3795
3956
|
}
|
|
3796
|
-
async function fetchMaybeLaunch(rpc,
|
|
3797
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3957
|
+
async function fetchMaybeLaunch(rpc, address6, config) {
|
|
3958
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3798
3959
|
return decodeLaunch(maybeAccount);
|
|
3799
3960
|
}
|
|
3800
3961
|
async function fetchAllLaunch(rpc, addresses, config) {
|
|
@@ -3868,13 +4029,13 @@ function decodeMarket(encodedAccount) {
|
|
|
3868
4029
|
getMarketDecoder()
|
|
3869
4030
|
);
|
|
3870
4031
|
}
|
|
3871
|
-
async function fetchMarket(rpc,
|
|
3872
|
-
const maybeAccount = await fetchMaybeMarket(rpc,
|
|
4032
|
+
async function fetchMarket(rpc, address6, config) {
|
|
4033
|
+
const maybeAccount = await fetchMaybeMarket(rpc, address6, config);
|
|
3873
4034
|
assertAccountExists(maybeAccount);
|
|
3874
4035
|
return maybeAccount;
|
|
3875
4036
|
}
|
|
3876
|
-
async function fetchMaybeMarket(rpc,
|
|
3877
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
4037
|
+
async function fetchMaybeMarket(rpc, address6, config) {
|
|
4038
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3878
4039
|
return decodeMarket(maybeAccount);
|
|
3879
4040
|
}
|
|
3880
4041
|
async function fetchAllMarket(rpc, addresses, config) {
|
|
@@ -3940,13 +4101,13 @@ function decodeOracleState2(encodedAccount) {
|
|
|
3940
4101
|
getOracleStateDecoder()
|
|
3941
4102
|
);
|
|
3942
4103
|
}
|
|
3943
|
-
async function fetchOracleState(rpc,
|
|
3944
|
-
const maybeAccount = await fetchMaybeOracleState(rpc,
|
|
4104
|
+
async function fetchOracleState(rpc, address6, config) {
|
|
4105
|
+
const maybeAccount = await fetchMaybeOracleState(rpc, address6, config);
|
|
3945
4106
|
assertAccountExists(maybeAccount);
|
|
3946
4107
|
return maybeAccount;
|
|
3947
4108
|
}
|
|
3948
|
-
async function fetchMaybeOracleState(rpc,
|
|
3949
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
4109
|
+
async function fetchMaybeOracleState(rpc, address6, config) {
|
|
4110
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
3950
4111
|
return decodeOracleState2(maybeAccount);
|
|
3951
4112
|
}
|
|
3952
4113
|
async function fetchAllOracleState(rpc, addresses, config) {
|
|
@@ -4216,9 +4377,9 @@ function parseClaimInstruction(instruction) {
|
|
|
4216
4377
|
}
|
|
4217
4378
|
let accountIndex = 0;
|
|
4218
4379
|
const getNextAccount = () => {
|
|
4219
|
-
const
|
|
4380
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4220
4381
|
accountIndex += 1;
|
|
4221
|
-
return
|
|
4382
|
+
return accountMeta2;
|
|
4222
4383
|
};
|
|
4223
4384
|
return {
|
|
4224
4385
|
programAddress: instruction.programAddress,
|
|
@@ -4524,9 +4685,9 @@ function parseMigrateEntryInstruction(instruction) {
|
|
|
4524
4685
|
}
|
|
4525
4686
|
let accountIndex = 0;
|
|
4526
4687
|
const getNextAccount = () => {
|
|
4527
|
-
const
|
|
4688
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4528
4689
|
accountIndex += 1;
|
|
4529
|
-
return
|
|
4690
|
+
return accountMeta2;
|
|
4530
4691
|
};
|
|
4531
4692
|
return {
|
|
4532
4693
|
programAddress: instruction.programAddress,
|
|
@@ -4626,9 +4787,9 @@ function parsePreviewPayoutIfWinnerInstruction(instruction) {
|
|
|
4626
4787
|
}
|
|
4627
4788
|
let accountIndex = 0;
|
|
4628
4789
|
const getNextAccount = () => {
|
|
4629
|
-
const
|
|
4790
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4630
4791
|
accountIndex += 1;
|
|
4631
|
-
return
|
|
4792
|
+
return accountMeta2;
|
|
4632
4793
|
};
|
|
4633
4794
|
return {
|
|
4634
4795
|
programAddress: instruction.programAddress,
|
|
@@ -4937,9 +5098,9 @@ function parseRegisterEntryInstruction(instruction) {
|
|
|
4937
5098
|
}
|
|
4938
5099
|
let accountIndex = 0;
|
|
4939
5100
|
const getNextAccount = () => {
|
|
4940
|
-
const
|
|
5101
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
4941
5102
|
accountIndex += 1;
|
|
4942
|
-
return
|
|
5103
|
+
return accountMeta2;
|
|
4943
5104
|
};
|
|
4944
5105
|
return {
|
|
4945
5106
|
programAddress: instruction.programAddress,
|
|
@@ -5523,1129 +5684,95 @@ function decodePreviewMigrationResult(data) {
|
|
|
5523
5684
|
return previewMigrationResultCodec.decode(data);
|
|
5524
5685
|
}
|
|
5525
5686
|
|
|
5526
|
-
// src/solana/
|
|
5527
|
-
var
|
|
5528
|
-
__export(
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
fetchMaybeCosignerConfig: () => fetchMaybeCosignerConfig2,
|
|
5566
|
-
getAddCosignerDiscriminatorBytes: () => getAddCosignerDiscriminatorBytes2,
|
|
5567
|
-
getAddCosignerInstruction: () => getAddCosignerInstruction2,
|
|
5568
|
-
getAddCosignerInstructionAsync: () => getAddCosignerInstructionAsync2,
|
|
5569
|
-
getAddCosignerInstructionDataCodec: () => getAddCosignerInstructionDataCodec2,
|
|
5570
|
-
getAddCosignerInstructionDataDecoder: () => getAddCosignerInstructionDataDecoder2,
|
|
5571
|
-
getAddCosignerInstructionDataEncoder: () => getAddCosignerInstructionDataEncoder2,
|
|
5572
|
-
getCosignerArgCodec: () => getCosignerArgCodec2,
|
|
5573
|
-
getCosignerArgDecoder: () => getCosignerArgDecoder2,
|
|
5574
|
-
getCosignerArgEncoder: () => getCosignerArgEncoder2,
|
|
5575
|
-
getCosignerConfigCodec: () => getCosignerConfigCodec2,
|
|
5576
|
-
getCosignerConfigDecoder: () => getCosignerConfigDecoder2,
|
|
5577
|
-
getCosignerConfigDiscriminatorBytes: () => getCosignerConfigDiscriminatorBytes2,
|
|
5578
|
-
getCosignerConfigEncoder: () => getCosignerConfigEncoder2,
|
|
5579
|
-
getCosignerConfigSize: () => getCosignerConfigSize2,
|
|
5580
|
-
getDynamicFeeHookConfigAddress: () => getDynamicFeeHookConfigAddress,
|
|
5581
|
-
getDynamicFeeHookErrorMessage: () => getDynamicFeeHookErrorMessage,
|
|
5582
|
-
getDynamicFeeHookRemainingAccountAddresses: () => getDynamicFeeHookRemainingAccountAddresses,
|
|
5583
|
-
getDynamicFeeHookRemainingAccounts: () => getDynamicFeeHookRemainingAccounts,
|
|
5584
|
-
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec3,
|
|
5585
|
-
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder3,
|
|
5586
|
-
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder3,
|
|
5587
|
-
getInitializeConfigDiscriminatorBytes: () => getInitializeConfigDiscriminatorBytes3,
|
|
5588
|
-
getInitializeConfigInstruction: () => getInitializeConfigInstruction3,
|
|
5589
|
-
getInitializeConfigInstructionAsync: () => getInitializeConfigInstructionAsync4,
|
|
5590
|
-
getInitializeConfigInstructionDataCodec: () => getInitializeConfigInstructionDataCodec3,
|
|
5591
|
-
getInitializeConfigInstructionDataDecoder: () => getInitializeConfigInstructionDataDecoder3,
|
|
5592
|
-
getInitializeConfigInstructionDataEncoder: () => getInitializeConfigInstructionDataEncoder4,
|
|
5593
|
-
getRemoveCosignerDiscriminatorBytes: () => getRemoveCosignerDiscriminatorBytes2,
|
|
5594
|
-
getRemoveCosignerInstruction: () => getRemoveCosignerInstruction2,
|
|
5595
|
-
getRemoveCosignerInstructionAsync: () => getRemoveCosignerInstructionAsync2,
|
|
5596
|
-
getRemoveCosignerInstructionDataCodec: () => getRemoveCosignerInstructionDataCodec2,
|
|
5597
|
-
getRemoveCosignerInstructionDataDecoder: () => getRemoveCosignerInstructionDataDecoder2,
|
|
5598
|
-
getRemoveCosignerInstructionDataEncoder: () => getRemoveCosignerInstructionDataEncoder2,
|
|
5599
|
-
getSetAuthorityArgsCodec: () => getSetAuthorityArgsCodec2,
|
|
5600
|
-
getSetAuthorityArgsDecoder: () => getSetAuthorityArgsDecoder2,
|
|
5601
|
-
getSetAuthorityArgsEncoder: () => getSetAuthorityArgsEncoder2,
|
|
5602
|
-
getSetAuthorityDiscriminatorBytes: () => getSetAuthorityDiscriminatorBytes2,
|
|
5603
|
-
getSetAuthorityInstruction: () => getSetAuthorityInstruction2,
|
|
5604
|
-
getSetAuthorityInstructionAsync: () => getSetAuthorityInstructionAsync2,
|
|
5605
|
-
getSetAuthorityInstructionDataCodec: () => getSetAuthorityInstructionDataCodec2,
|
|
5606
|
-
getSetAuthorityInstructionDataDecoder: () => getSetAuthorityInstructionDataDecoder2,
|
|
5607
|
-
getSetAuthorityInstructionDataEncoder: () => getSetAuthorityInstructionDataEncoder2,
|
|
5608
|
-
identifyDynamicFeeHookAccount: () => identifyDynamicFeeHookAccount,
|
|
5609
|
-
identifyDynamicFeeHookInstruction: () => identifyDynamicFeeHookInstruction,
|
|
5610
|
-
isDynamicFeeHookError: () => isDynamicFeeHookError,
|
|
5611
|
-
isDynamicFeeSchedulePayload: () => isDynamicFeeSchedulePayload,
|
|
5612
|
-
parseAddCosignerInstruction: () => parseAddCosignerInstruction2,
|
|
5613
|
-
parseDynamicFeeHookInstruction: () => parseDynamicFeeHookInstruction,
|
|
5614
|
-
parseInitializeConfigInstruction: () => parseInitializeConfigInstruction4,
|
|
5615
|
-
parseRemoveCosignerInstruction: () => parseRemoveCosignerInstruction2,
|
|
5616
|
-
parseSetAuthorityInstruction: () => parseSetAuthorityInstruction2,
|
|
5617
|
-
validateDynamicFeeScheduleArgs: () => validateDynamicFeeScheduleArgs
|
|
5687
|
+
// src/solana/migrators/cpmmMigrator/index.ts
|
|
5688
|
+
var cpmmMigrator_exports = {};
|
|
5689
|
+
__export(cpmmMigrator_exports, {
|
|
5690
|
+
CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS: () => CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS,
|
|
5691
|
+
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS: () => CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS,
|
|
5692
|
+
CPMM_MIGRATOR_PROGRAM_ID: () => CPMM_MIGRATOR_PROGRAM_ID,
|
|
5693
|
+
MAX_RECIPIENTS: () => MAX_RECIPIENTS,
|
|
5694
|
+
SEED_MIGRATION_AUTHORITY: () => SEED_MIGRATION_AUTHORITY,
|
|
5695
|
+
SEED_STATE: () => SEED_STATE,
|
|
5696
|
+
buildCpmmMigrationRemainingAccounts: () => buildCpmmMigrationRemainingAccounts,
|
|
5697
|
+
buildCpmmMigrationRemainingAccountsHash: () => buildCpmmMigrationRemainingAccountsHash,
|
|
5698
|
+
createSpotPoolInstruction: () => createSpotPoolInstruction,
|
|
5699
|
+
deriveSpotPoolAccounts: () => deriveSpotPoolAccounts,
|
|
5700
|
+
encodeCreateSpotPoolPayload: () => encodeCreateSpotPoolPayload,
|
|
5701
|
+
encodeMigratePayload: () => encodeMigratePayload,
|
|
5702
|
+
encodeRegisterLaunchPayload: () => encodeRegisterLaunchPayload,
|
|
5703
|
+
fetchCpmmMigratorState: () => fetchCpmmMigratorState,
|
|
5704
|
+
getCpmmMigrationAuthorityAddress: () => getCpmmMigrationAuthorityAddress,
|
|
5705
|
+
getCpmmMigratorStateAddress: () => getCpmmMigratorStateAddress,
|
|
5706
|
+
getCpmmMigratorStateCodec: () => getCpmmMigratorStateCodec,
|
|
5707
|
+
getCpmmMigratorStateDecoder: () => getCpmmMigratorStateDecoder,
|
|
5708
|
+
getCpmmMigratorStateEncoder: () => getCpmmMigratorStateEncoder,
|
|
5709
|
+
getCreateSpotPoolArgsCodec: () => getCreateSpotPoolArgsCodec,
|
|
5710
|
+
getCreateSpotPoolArgsDecoder: () => getCreateSpotPoolArgsDecoder,
|
|
5711
|
+
getCreateSpotPoolArgsEncoder: () => getCreateSpotPoolArgsEncoder,
|
|
5712
|
+
getCreateSpotPoolInstruction: () => getCreateSpotPoolInstruction,
|
|
5713
|
+
getCreateSpotPoolInstructionAsync: () => getCreateSpotPoolInstructionAsync,
|
|
5714
|
+
getCreateSpotPoolInstructionDataCodec: () => getCreateSpotPoolInstructionDataCodec,
|
|
5715
|
+
getCreateSpotPoolInstructionDataDecoder: () => getCreateSpotPoolInstructionDataDecoder,
|
|
5716
|
+
getCreateSpotPoolInstructionDataEncoder: () => getCreateSpotPoolInstructionDataEncoder,
|
|
5717
|
+
getMigrateArgsCodec: () => getMigrateArgsCodec,
|
|
5718
|
+
getMigrateArgsDecoder: () => getMigrateArgsDecoder,
|
|
5719
|
+
getMigrateArgsEncoder: () => getMigrateArgsEncoder,
|
|
5720
|
+
getRecipientCodec: () => getRecipientCodec,
|
|
5721
|
+
getRecipientDecoder: () => getRecipientDecoder,
|
|
5722
|
+
getRecipientEncoder: () => getRecipientEncoder,
|
|
5723
|
+
getRegisterLaunchArgsCodec: () => getRegisterLaunchArgsCodec,
|
|
5724
|
+
getRegisterLaunchArgsDecoder: () => getRegisterLaunchArgsDecoder,
|
|
5725
|
+
getRegisterLaunchArgsEncoder: () => getRegisterLaunchArgsEncoder
|
|
5618
5726
|
});
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
183
|
|
5628
|
-
]);
|
|
5629
|
-
function getCosignerConfigDiscriminatorBytes2() {
|
|
5630
|
-
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
5631
|
-
COSIGNER_CONFIG_DISCRIMINATOR2
|
|
5632
|
-
);
|
|
5633
|
-
}
|
|
5634
|
-
function getCosignerConfigEncoder2() {
|
|
5635
|
-
return transformEncoder(
|
|
5636
|
-
getStructEncoder([
|
|
5637
|
-
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
5638
|
-
["adminAuthority", getAddressEncoder()],
|
|
5639
|
-
["cosignerCount", getU8Encoder()],
|
|
5640
|
-
["bump", getU8Encoder()],
|
|
5641
|
-
["version", getU8Encoder()],
|
|
5642
|
-
["reserved", fixEncoderSize(getBytesEncoder(), 37)],
|
|
5643
|
-
["cosigners", getArrayEncoder(getAddressEncoder(), { size: 32 })]
|
|
5644
|
-
]),
|
|
5645
|
-
(value) => ({ ...value, discriminator: COSIGNER_CONFIG_DISCRIMINATOR2 })
|
|
5646
|
-
);
|
|
5727
|
+
function getCreateSpotPoolArgsEncoder() {
|
|
5728
|
+
return getStructEncoder([
|
|
5729
|
+
["swapFeeBps", getU16Encoder()],
|
|
5730
|
+
["positionId", getU64Encoder()],
|
|
5731
|
+
["amount0Max", getU64Encoder()],
|
|
5732
|
+
["amount1Max", getU64Encoder()],
|
|
5733
|
+
["minSharesOut", getU128Encoder()]
|
|
5734
|
+
]);
|
|
5647
5735
|
}
|
|
5648
|
-
function
|
|
5736
|
+
function getCreateSpotPoolArgsDecoder() {
|
|
5649
5737
|
return getStructDecoder([
|
|
5650
|
-
["
|
|
5651
|
-
["
|
|
5652
|
-
["
|
|
5653
|
-
["
|
|
5654
|
-
["
|
|
5655
|
-
["reserved", fixDecoderSize(getBytesDecoder(), 37)],
|
|
5656
|
-
["cosigners", getArrayDecoder(getAddressDecoder(), { size: 32 })]
|
|
5738
|
+
["swapFeeBps", getU16Decoder()],
|
|
5739
|
+
["positionId", getU64Decoder()],
|
|
5740
|
+
["amount0Max", getU64Decoder()],
|
|
5741
|
+
["amount1Max", getU64Decoder()],
|
|
5742
|
+
["minSharesOut", getU128Decoder()]
|
|
5657
5743
|
]);
|
|
5658
5744
|
}
|
|
5659
|
-
function
|
|
5660
|
-
return combineCodec(
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
return decodeAccount(
|
|
5664
|
-
encodedAccount,
|
|
5665
|
-
getCosignerConfigDecoder2()
|
|
5666
|
-
);
|
|
5667
|
-
}
|
|
5668
|
-
async function fetchCosignerConfig2(rpc, address7, config) {
|
|
5669
|
-
const maybeAccount = await fetchMaybeCosignerConfig2(rpc, address7, config);
|
|
5670
|
-
assertAccountExists(maybeAccount);
|
|
5671
|
-
return maybeAccount;
|
|
5672
|
-
}
|
|
5673
|
-
async function fetchMaybeCosignerConfig2(rpc, address7, config) {
|
|
5674
|
-
const maybeAccount = await fetchEncodedAccount(rpc, address7, config);
|
|
5675
|
-
return decodeCosignerConfig2(maybeAccount);
|
|
5676
|
-
}
|
|
5677
|
-
async function fetchAllCosignerConfig2(rpc, addresses, config) {
|
|
5678
|
-
const maybeAccounts = await fetchAllMaybeCosignerConfig2(
|
|
5679
|
-
rpc,
|
|
5680
|
-
addresses,
|
|
5681
|
-
config
|
|
5745
|
+
function getCreateSpotPoolArgsCodec() {
|
|
5746
|
+
return combineCodec(
|
|
5747
|
+
getCreateSpotPoolArgsEncoder(),
|
|
5748
|
+
getCreateSpotPoolArgsDecoder()
|
|
5682
5749
|
);
|
|
5683
|
-
assertAccountsExist(maybeAccounts);
|
|
5684
|
-
return maybeAccounts;
|
|
5685
5750
|
}
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
);
|
|
5751
|
+
function getMigrateArgsEncoder() {
|
|
5752
|
+
return getStructEncoder([
|
|
5753
|
+
["baseForDistribution", getU64Encoder()],
|
|
5754
|
+
["baseForLiquidity", getU64Encoder()]
|
|
5755
|
+
]);
|
|
5691
5756
|
}
|
|
5692
|
-
function
|
|
5693
|
-
return
|
|
5757
|
+
function getMigrateArgsDecoder() {
|
|
5758
|
+
return getStructDecoder([
|
|
5759
|
+
["baseForDistribution", getU64Decoder()],
|
|
5760
|
+
["baseForLiquidity", getU64Decoder()]
|
|
5761
|
+
]);
|
|
5694
5762
|
}
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
34,
|
|
5698
|
-
183,
|
|
5699
|
-
119,
|
|
5700
|
-
202,
|
|
5701
|
-
255,
|
|
5702
|
-
218,
|
|
5703
|
-
233
|
|
5704
|
-
]);
|
|
5705
|
-
function getAddCosignerDiscriminatorBytes2() {
|
|
5706
|
-
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
5707
|
-
ADD_COSIGNER_DISCRIMINATOR2
|
|
5708
|
-
);
|
|
5763
|
+
function getMigrateArgsCodec() {
|
|
5764
|
+
return combineCodec(getMigrateArgsEncoder(), getMigrateArgsDecoder());
|
|
5709
5765
|
}
|
|
5710
|
-
function
|
|
5711
|
-
return
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
]),
|
|
5716
|
-
(value) => ({ ...value, discriminator: ADD_COSIGNER_DISCRIMINATOR2 })
|
|
5717
|
-
);
|
|
5766
|
+
function getMigratedPoolHookConfigEncoder() {
|
|
5767
|
+
return getStructEncoder([
|
|
5768
|
+
["hookProgram", getAddressEncoder()],
|
|
5769
|
+
["hookFlags", getU32Encoder()]
|
|
5770
|
+
]);
|
|
5718
5771
|
}
|
|
5719
|
-
function
|
|
5772
|
+
function getMigratedPoolHookConfigDecoder() {
|
|
5720
5773
|
return getStructDecoder([
|
|
5721
|
-
["
|
|
5722
|
-
["
|
|
5723
|
-
]);
|
|
5724
|
-
}
|
|
5725
|
-
function getAddCosignerInstructionDataCodec2() {
|
|
5726
|
-
return combineCodec(
|
|
5727
|
-
getAddCosignerInstructionDataEncoder2(),
|
|
5728
|
-
getAddCosignerInstructionDataDecoder2()
|
|
5729
|
-
);
|
|
5730
|
-
}
|
|
5731
|
-
async function getAddCosignerInstructionAsync2(input, config) {
|
|
5732
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
5733
|
-
const originalAccounts = {
|
|
5734
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
5735
|
-
config: { value: input.config ?? null, isWritable: true }
|
|
5736
|
-
};
|
|
5737
|
-
const accounts = originalAccounts;
|
|
5738
|
-
const args = { ...input };
|
|
5739
|
-
if (!accounts.config.value) {
|
|
5740
|
-
accounts.config.value = await getProgramDerivedAddress({
|
|
5741
|
-
programAddress,
|
|
5742
|
-
seeds: [
|
|
5743
|
-
getBytesEncoder().encode(
|
|
5744
|
-
new Uint8Array([
|
|
5745
|
-
99,
|
|
5746
|
-
111,
|
|
5747
|
-
115,
|
|
5748
|
-
105,
|
|
5749
|
-
103,
|
|
5750
|
-
110,
|
|
5751
|
-
101,
|
|
5752
|
-
114,
|
|
5753
|
-
95,
|
|
5754
|
-
104,
|
|
5755
|
-
111,
|
|
5756
|
-
111,
|
|
5757
|
-
107,
|
|
5758
|
-
95,
|
|
5759
|
-
99,
|
|
5760
|
-
111,
|
|
5761
|
-
110,
|
|
5762
|
-
102,
|
|
5763
|
-
105,
|
|
5764
|
-
103
|
|
5765
|
-
])
|
|
5766
|
-
)
|
|
5767
|
-
]
|
|
5768
|
-
});
|
|
5769
|
-
}
|
|
5770
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
5771
|
-
return Object.freeze({
|
|
5772
|
-
accounts: [
|
|
5773
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
5774
|
-
getAccountMeta("config", accounts.config)
|
|
5775
|
-
],
|
|
5776
|
-
data: getAddCosignerInstructionDataEncoder2().encode(
|
|
5777
|
-
args
|
|
5778
|
-
),
|
|
5779
|
-
programAddress
|
|
5780
|
-
});
|
|
5781
|
-
}
|
|
5782
|
-
function getAddCosignerInstruction2(input, config) {
|
|
5783
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
5784
|
-
const originalAccounts = {
|
|
5785
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
5786
|
-
config: { value: input.config ?? null, isWritable: true }
|
|
5787
|
-
};
|
|
5788
|
-
const accounts = originalAccounts;
|
|
5789
|
-
const args = { ...input };
|
|
5790
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
5791
|
-
return Object.freeze({
|
|
5792
|
-
accounts: [
|
|
5793
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
5794
|
-
getAccountMeta("config", accounts.config)
|
|
5795
|
-
],
|
|
5796
|
-
data: getAddCosignerInstructionDataEncoder2().encode(
|
|
5797
|
-
args
|
|
5798
|
-
),
|
|
5799
|
-
programAddress
|
|
5800
|
-
});
|
|
5801
|
-
}
|
|
5802
|
-
function parseAddCosignerInstruction2(instruction) {
|
|
5803
|
-
if (instruction.accounts.length < 2) {
|
|
5804
|
-
throw new SolanaError(
|
|
5805
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
5806
|
-
{
|
|
5807
|
-
actualAccountMetas: instruction.accounts.length,
|
|
5808
|
-
expectedAccountMetas: 2
|
|
5809
|
-
}
|
|
5810
|
-
);
|
|
5811
|
-
}
|
|
5812
|
-
let accountIndex = 0;
|
|
5813
|
-
const getNextAccount = () => {
|
|
5814
|
-
const accountMeta = instruction.accounts[accountIndex];
|
|
5815
|
-
accountIndex += 1;
|
|
5816
|
-
return accountMeta;
|
|
5817
|
-
};
|
|
5818
|
-
return {
|
|
5819
|
-
programAddress: instruction.programAddress,
|
|
5820
|
-
accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
|
|
5821
|
-
data: getAddCosignerInstructionDataDecoder2().decode(instruction.data)
|
|
5822
|
-
};
|
|
5823
|
-
}
|
|
5824
|
-
var INITIALIZE_CONFIG_DISCRIMINATOR4 = new Uint8Array([
|
|
5825
|
-
208,
|
|
5826
|
-
127,
|
|
5827
|
-
21,
|
|
5828
|
-
1,
|
|
5829
|
-
194,
|
|
5830
|
-
190,
|
|
5831
|
-
196,
|
|
5832
|
-
70
|
|
5833
|
-
]);
|
|
5834
|
-
function getInitializeConfigDiscriminatorBytes3() {
|
|
5835
|
-
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
5836
|
-
INITIALIZE_CONFIG_DISCRIMINATOR4
|
|
5837
|
-
);
|
|
5838
|
-
}
|
|
5839
|
-
function getInitializeConfigInstructionDataEncoder4() {
|
|
5840
|
-
return transformEncoder(
|
|
5841
|
-
getStructEncoder([
|
|
5842
|
-
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
5843
|
-
["cosigners", getArrayEncoder(getAddressEncoder())]
|
|
5844
|
-
]),
|
|
5845
|
-
(value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR4 })
|
|
5846
|
-
);
|
|
5847
|
-
}
|
|
5848
|
-
function getInitializeConfigInstructionDataDecoder3() {
|
|
5849
|
-
return getStructDecoder([
|
|
5850
|
-
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
5851
|
-
["cosigners", getArrayDecoder(getAddressDecoder())]
|
|
5852
|
-
]);
|
|
5853
|
-
}
|
|
5854
|
-
function getInitializeConfigInstructionDataCodec3() {
|
|
5855
|
-
return combineCodec(
|
|
5856
|
-
getInitializeConfigInstructionDataEncoder4(),
|
|
5857
|
-
getInitializeConfigInstructionDataDecoder3()
|
|
5858
|
-
);
|
|
5859
|
-
}
|
|
5860
|
-
async function getInitializeConfigInstructionAsync4(input, config) {
|
|
5861
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
5862
|
-
const originalAccounts = {
|
|
5863
|
-
payer: { value: input.payer ?? null, isWritable: true },
|
|
5864
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
5865
|
-
config: { value: input.config ?? null, isWritable: true },
|
|
5866
|
-
programData: { value: input.programData ?? null, isWritable: false },
|
|
5867
|
-
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
5868
|
-
};
|
|
5869
|
-
const accounts = originalAccounts;
|
|
5870
|
-
const args = { ...input };
|
|
5871
|
-
if (!accounts.config.value) {
|
|
5872
|
-
accounts.config.value = await getProgramDerivedAddress({
|
|
5873
|
-
programAddress,
|
|
5874
|
-
seeds: [
|
|
5875
|
-
getBytesEncoder().encode(
|
|
5876
|
-
new Uint8Array([
|
|
5877
|
-
99,
|
|
5878
|
-
111,
|
|
5879
|
-
115,
|
|
5880
|
-
105,
|
|
5881
|
-
103,
|
|
5882
|
-
110,
|
|
5883
|
-
101,
|
|
5884
|
-
114,
|
|
5885
|
-
95,
|
|
5886
|
-
104,
|
|
5887
|
-
111,
|
|
5888
|
-
111,
|
|
5889
|
-
107,
|
|
5890
|
-
95,
|
|
5891
|
-
99,
|
|
5892
|
-
111,
|
|
5893
|
-
110,
|
|
5894
|
-
102,
|
|
5895
|
-
105,
|
|
5896
|
-
103
|
|
5897
|
-
])
|
|
5898
|
-
)
|
|
5899
|
-
]
|
|
5900
|
-
});
|
|
5901
|
-
}
|
|
5902
|
-
if (!accounts.systemProgram.value) {
|
|
5903
|
-
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
5904
|
-
}
|
|
5905
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
5906
|
-
return Object.freeze({
|
|
5907
|
-
accounts: [
|
|
5908
|
-
getAccountMeta("payer", accounts.payer),
|
|
5909
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
5910
|
-
getAccountMeta("config", accounts.config),
|
|
5911
|
-
getAccountMeta("programData", accounts.programData),
|
|
5912
|
-
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
5913
|
-
],
|
|
5914
|
-
data: getInitializeConfigInstructionDataEncoder4().encode(
|
|
5915
|
-
args
|
|
5916
|
-
),
|
|
5917
|
-
programAddress
|
|
5918
|
-
});
|
|
5919
|
-
}
|
|
5920
|
-
function getInitializeConfigInstruction3(input, config) {
|
|
5921
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
5922
|
-
const originalAccounts = {
|
|
5923
|
-
payer: { value: input.payer ?? null, isWritable: true },
|
|
5924
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
5925
|
-
config: { value: input.config ?? null, isWritable: true },
|
|
5926
|
-
programData: { value: input.programData ?? null, isWritable: false },
|
|
5927
|
-
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
5928
|
-
};
|
|
5929
|
-
const accounts = originalAccounts;
|
|
5930
|
-
const args = { ...input };
|
|
5931
|
-
if (!accounts.systemProgram.value) {
|
|
5932
|
-
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
5933
|
-
}
|
|
5934
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
5935
|
-
return Object.freeze({
|
|
5936
|
-
accounts: [
|
|
5937
|
-
getAccountMeta("payer", accounts.payer),
|
|
5938
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
5939
|
-
getAccountMeta("config", accounts.config),
|
|
5940
|
-
getAccountMeta("programData", accounts.programData),
|
|
5941
|
-
getAccountMeta("systemProgram", accounts.systemProgram)
|
|
5942
|
-
],
|
|
5943
|
-
data: getInitializeConfigInstructionDataEncoder4().encode(
|
|
5944
|
-
args
|
|
5945
|
-
),
|
|
5946
|
-
programAddress
|
|
5947
|
-
});
|
|
5948
|
-
}
|
|
5949
|
-
function parseInitializeConfigInstruction4(instruction) {
|
|
5950
|
-
if (instruction.accounts.length < 5) {
|
|
5951
|
-
throw new SolanaError(
|
|
5952
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
5953
|
-
{
|
|
5954
|
-
actualAccountMetas: instruction.accounts.length,
|
|
5955
|
-
expectedAccountMetas: 5
|
|
5956
|
-
}
|
|
5957
|
-
);
|
|
5958
|
-
}
|
|
5959
|
-
let accountIndex = 0;
|
|
5960
|
-
const getNextAccount = () => {
|
|
5961
|
-
const accountMeta = instruction.accounts[accountIndex];
|
|
5962
|
-
accountIndex += 1;
|
|
5963
|
-
return accountMeta;
|
|
5964
|
-
};
|
|
5965
|
-
return {
|
|
5966
|
-
programAddress: instruction.programAddress,
|
|
5967
|
-
accounts: {
|
|
5968
|
-
payer: getNextAccount(),
|
|
5969
|
-
adminAuthority: getNextAccount(),
|
|
5970
|
-
config: getNextAccount(),
|
|
5971
|
-
programData: getNextAccount(),
|
|
5972
|
-
systemProgram: getNextAccount()
|
|
5973
|
-
},
|
|
5974
|
-
data: getInitializeConfigInstructionDataDecoder3().decode(instruction.data)
|
|
5975
|
-
};
|
|
5976
|
-
}
|
|
5977
|
-
var REMOVE_COSIGNER_DISCRIMINATOR2 = new Uint8Array([
|
|
5978
|
-
174,
|
|
5979
|
-
11,
|
|
5980
|
-
171,
|
|
5981
|
-
252,
|
|
5982
|
-
179,
|
|
5983
|
-
99,
|
|
5984
|
-
220,
|
|
5985
|
-
27
|
|
5986
|
-
]);
|
|
5987
|
-
function getRemoveCosignerDiscriminatorBytes2() {
|
|
5988
|
-
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
5989
|
-
REMOVE_COSIGNER_DISCRIMINATOR2
|
|
5990
|
-
);
|
|
5991
|
-
}
|
|
5992
|
-
function getRemoveCosignerInstructionDataEncoder2() {
|
|
5993
|
-
return transformEncoder(
|
|
5994
|
-
getStructEncoder([
|
|
5995
|
-
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
5996
|
-
["cosigner", getAddressEncoder()]
|
|
5997
|
-
]),
|
|
5998
|
-
(value) => ({ ...value, discriminator: REMOVE_COSIGNER_DISCRIMINATOR2 })
|
|
5999
|
-
);
|
|
6000
|
-
}
|
|
6001
|
-
function getRemoveCosignerInstructionDataDecoder2() {
|
|
6002
|
-
return getStructDecoder([
|
|
6003
|
-
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
6004
|
-
["cosigner", getAddressDecoder()]
|
|
6005
|
-
]);
|
|
6006
|
-
}
|
|
6007
|
-
function getRemoveCosignerInstructionDataCodec2() {
|
|
6008
|
-
return combineCodec(
|
|
6009
|
-
getRemoveCosignerInstructionDataEncoder2(),
|
|
6010
|
-
getRemoveCosignerInstructionDataDecoder2()
|
|
6011
|
-
);
|
|
6012
|
-
}
|
|
6013
|
-
async function getRemoveCosignerInstructionAsync2(input, config) {
|
|
6014
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
6015
|
-
const originalAccounts = {
|
|
6016
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
6017
|
-
config: { value: input.config ?? null, isWritable: true }
|
|
6018
|
-
};
|
|
6019
|
-
const accounts = originalAccounts;
|
|
6020
|
-
const args = { ...input };
|
|
6021
|
-
if (!accounts.config.value) {
|
|
6022
|
-
accounts.config.value = await getProgramDerivedAddress({
|
|
6023
|
-
programAddress,
|
|
6024
|
-
seeds: [
|
|
6025
|
-
getBytesEncoder().encode(
|
|
6026
|
-
new Uint8Array([
|
|
6027
|
-
99,
|
|
6028
|
-
111,
|
|
6029
|
-
115,
|
|
6030
|
-
105,
|
|
6031
|
-
103,
|
|
6032
|
-
110,
|
|
6033
|
-
101,
|
|
6034
|
-
114,
|
|
6035
|
-
95,
|
|
6036
|
-
104,
|
|
6037
|
-
111,
|
|
6038
|
-
111,
|
|
6039
|
-
107,
|
|
6040
|
-
95,
|
|
6041
|
-
99,
|
|
6042
|
-
111,
|
|
6043
|
-
110,
|
|
6044
|
-
102,
|
|
6045
|
-
105,
|
|
6046
|
-
103
|
|
6047
|
-
])
|
|
6048
|
-
)
|
|
6049
|
-
]
|
|
6050
|
-
});
|
|
6051
|
-
}
|
|
6052
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
6053
|
-
return Object.freeze({
|
|
6054
|
-
accounts: [
|
|
6055
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
6056
|
-
getAccountMeta("config", accounts.config)
|
|
6057
|
-
],
|
|
6058
|
-
data: getRemoveCosignerInstructionDataEncoder2().encode(
|
|
6059
|
-
args
|
|
6060
|
-
),
|
|
6061
|
-
programAddress
|
|
6062
|
-
});
|
|
6063
|
-
}
|
|
6064
|
-
function getRemoveCosignerInstruction2(input, config) {
|
|
6065
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
6066
|
-
const originalAccounts = {
|
|
6067
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
6068
|
-
config: { value: input.config ?? null, isWritable: true }
|
|
6069
|
-
};
|
|
6070
|
-
const accounts = originalAccounts;
|
|
6071
|
-
const args = { ...input };
|
|
6072
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
6073
|
-
return Object.freeze({
|
|
6074
|
-
accounts: [
|
|
6075
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
6076
|
-
getAccountMeta("config", accounts.config)
|
|
6077
|
-
],
|
|
6078
|
-
data: getRemoveCosignerInstructionDataEncoder2().encode(
|
|
6079
|
-
args
|
|
6080
|
-
),
|
|
6081
|
-
programAddress
|
|
6082
|
-
});
|
|
6083
|
-
}
|
|
6084
|
-
function parseRemoveCosignerInstruction2(instruction) {
|
|
6085
|
-
if (instruction.accounts.length < 2) {
|
|
6086
|
-
throw new SolanaError(
|
|
6087
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
6088
|
-
{
|
|
6089
|
-
actualAccountMetas: instruction.accounts.length,
|
|
6090
|
-
expectedAccountMetas: 2
|
|
6091
|
-
}
|
|
6092
|
-
);
|
|
6093
|
-
}
|
|
6094
|
-
let accountIndex = 0;
|
|
6095
|
-
const getNextAccount = () => {
|
|
6096
|
-
const accountMeta = instruction.accounts[accountIndex];
|
|
6097
|
-
accountIndex += 1;
|
|
6098
|
-
return accountMeta;
|
|
6099
|
-
};
|
|
6100
|
-
return {
|
|
6101
|
-
programAddress: instruction.programAddress,
|
|
6102
|
-
accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
|
|
6103
|
-
data: getRemoveCosignerInstructionDataDecoder2().decode(instruction.data)
|
|
6104
|
-
};
|
|
6105
|
-
}
|
|
6106
|
-
var SET_AUTHORITY_DISCRIMINATOR2 = new Uint8Array([
|
|
6107
|
-
133,
|
|
6108
|
-
250,
|
|
6109
|
-
37,
|
|
6110
|
-
21,
|
|
6111
|
-
110,
|
|
6112
|
-
163,
|
|
6113
|
-
26,
|
|
6114
|
-
121
|
|
6115
|
-
]);
|
|
6116
|
-
function getSetAuthorityDiscriminatorBytes2() {
|
|
6117
|
-
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
6118
|
-
SET_AUTHORITY_DISCRIMINATOR2
|
|
6119
|
-
);
|
|
6120
|
-
}
|
|
6121
|
-
function getSetAuthorityInstructionDataEncoder2() {
|
|
6122
|
-
return transformEncoder(
|
|
6123
|
-
getStructEncoder([
|
|
6124
|
-
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
6125
|
-
["adminAuthority", getAddressEncoder()]
|
|
6126
|
-
]),
|
|
6127
|
-
(value) => ({ ...value, discriminator: SET_AUTHORITY_DISCRIMINATOR2 })
|
|
6128
|
-
);
|
|
6129
|
-
}
|
|
6130
|
-
function getSetAuthorityInstructionDataDecoder2() {
|
|
6131
|
-
return getStructDecoder([
|
|
6132
|
-
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
6133
|
-
["adminAuthority", getAddressDecoder()]
|
|
6134
|
-
]);
|
|
6135
|
-
}
|
|
6136
|
-
function getSetAuthorityInstructionDataCodec2() {
|
|
6137
|
-
return combineCodec(
|
|
6138
|
-
getSetAuthorityInstructionDataEncoder2(),
|
|
6139
|
-
getSetAuthorityInstructionDataDecoder2()
|
|
6140
|
-
);
|
|
6141
|
-
}
|
|
6142
|
-
async function getSetAuthorityInstructionAsync2(input, config) {
|
|
6143
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
6144
|
-
const originalAccounts = {
|
|
6145
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
6146
|
-
config: { value: input.config ?? null, isWritable: true }
|
|
6147
|
-
};
|
|
6148
|
-
const accounts = originalAccounts;
|
|
6149
|
-
const args = { ...input, adminAuthority: input.adminAuthorityArg };
|
|
6150
|
-
if (!accounts.config.value) {
|
|
6151
|
-
accounts.config.value = await getProgramDerivedAddress({
|
|
6152
|
-
programAddress,
|
|
6153
|
-
seeds: [
|
|
6154
|
-
getBytesEncoder().encode(
|
|
6155
|
-
new Uint8Array([
|
|
6156
|
-
99,
|
|
6157
|
-
111,
|
|
6158
|
-
115,
|
|
6159
|
-
105,
|
|
6160
|
-
103,
|
|
6161
|
-
110,
|
|
6162
|
-
101,
|
|
6163
|
-
114,
|
|
6164
|
-
95,
|
|
6165
|
-
104,
|
|
6166
|
-
111,
|
|
6167
|
-
111,
|
|
6168
|
-
107,
|
|
6169
|
-
95,
|
|
6170
|
-
99,
|
|
6171
|
-
111,
|
|
6172
|
-
110,
|
|
6173
|
-
102,
|
|
6174
|
-
105,
|
|
6175
|
-
103
|
|
6176
|
-
])
|
|
6177
|
-
)
|
|
6178
|
-
]
|
|
6179
|
-
});
|
|
6180
|
-
}
|
|
6181
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
6182
|
-
return Object.freeze({
|
|
6183
|
-
accounts: [
|
|
6184
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
6185
|
-
getAccountMeta("config", accounts.config)
|
|
6186
|
-
],
|
|
6187
|
-
data: getSetAuthorityInstructionDataEncoder2().encode(
|
|
6188
|
-
args
|
|
6189
|
-
),
|
|
6190
|
-
programAddress
|
|
6191
|
-
});
|
|
6192
|
-
}
|
|
6193
|
-
function getSetAuthorityInstruction2(input, config) {
|
|
6194
|
-
const programAddress = config?.programAddress ?? DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS;
|
|
6195
|
-
const originalAccounts = {
|
|
6196
|
-
adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
|
|
6197
|
-
config: { value: input.config ?? null, isWritable: true }
|
|
6198
|
-
};
|
|
6199
|
-
const accounts = originalAccounts;
|
|
6200
|
-
const args = { ...input, adminAuthority: input.adminAuthorityArg };
|
|
6201
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
6202
|
-
return Object.freeze({
|
|
6203
|
-
accounts: [
|
|
6204
|
-
getAccountMeta("adminAuthority", accounts.adminAuthority),
|
|
6205
|
-
getAccountMeta("config", accounts.config)
|
|
6206
|
-
],
|
|
6207
|
-
data: getSetAuthorityInstructionDataEncoder2().encode(
|
|
6208
|
-
args
|
|
6209
|
-
),
|
|
6210
|
-
programAddress
|
|
6211
|
-
});
|
|
6212
|
-
}
|
|
6213
|
-
function parseSetAuthorityInstruction2(instruction) {
|
|
6214
|
-
if (instruction.accounts.length < 2) {
|
|
6215
|
-
throw new SolanaError(
|
|
6216
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
6217
|
-
{
|
|
6218
|
-
actualAccountMetas: instruction.accounts.length,
|
|
6219
|
-
expectedAccountMetas: 2
|
|
6220
|
-
}
|
|
6221
|
-
);
|
|
6222
|
-
}
|
|
6223
|
-
let accountIndex = 0;
|
|
6224
|
-
const getNextAccount = () => {
|
|
6225
|
-
const accountMeta = instruction.accounts[accountIndex];
|
|
6226
|
-
accountIndex += 1;
|
|
6227
|
-
return accountMeta;
|
|
6228
|
-
};
|
|
6229
|
-
return {
|
|
6230
|
-
programAddress: instruction.programAddress,
|
|
6231
|
-
accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
|
|
6232
|
-
data: getSetAuthorityInstructionDataDecoder2().decode(instruction.data)
|
|
6233
|
-
};
|
|
6234
|
-
}
|
|
6235
|
-
|
|
6236
|
-
// src/solana/generated/dynamicFeeHook/programs/dynamicFeeHook.ts
|
|
6237
|
-
var DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS = "HVsPNZh98TgChUXHwKrUG47SUqvGQHxUy5wZwcQLFD4i";
|
|
6238
|
-
var DynamicFeeHookAccount = /* @__PURE__ */ ((DynamicFeeHookAccount2) => {
|
|
6239
|
-
DynamicFeeHookAccount2[DynamicFeeHookAccount2["CosignerConfig"] = 0] = "CosignerConfig";
|
|
6240
|
-
return DynamicFeeHookAccount2;
|
|
6241
|
-
})(DynamicFeeHookAccount || {});
|
|
6242
|
-
function identifyDynamicFeeHookAccount(account) {
|
|
6243
|
-
const data = "data" in account ? account.data : account;
|
|
6244
|
-
if (containsBytes(
|
|
6245
|
-
data,
|
|
6246
|
-
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
6247
|
-
new Uint8Array([133, 227, 177, 74, 145, 74, 247, 183])
|
|
6248
|
-
),
|
|
6249
|
-
0
|
|
6250
|
-
)) {
|
|
6251
|
-
return 0 /* CosignerConfig */;
|
|
6252
|
-
}
|
|
6253
|
-
throw new SolanaError(
|
|
6254
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
|
|
6255
|
-
{ accountData: data, programName: "dynamicFeeHook" }
|
|
6256
|
-
);
|
|
6257
|
-
}
|
|
6258
|
-
var DynamicFeeHookInstruction = /* @__PURE__ */ ((DynamicFeeHookInstruction2) => {
|
|
6259
|
-
DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["AddCosigner"] = 0] = "AddCosigner";
|
|
6260
|
-
DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["InitializeConfig"] = 1] = "InitializeConfig";
|
|
6261
|
-
DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["RemoveCosigner"] = 2] = "RemoveCosigner";
|
|
6262
|
-
DynamicFeeHookInstruction2[DynamicFeeHookInstruction2["SetAuthority"] = 3] = "SetAuthority";
|
|
6263
|
-
return DynamicFeeHookInstruction2;
|
|
6264
|
-
})(DynamicFeeHookInstruction || {});
|
|
6265
|
-
function identifyDynamicFeeHookInstruction(instruction) {
|
|
6266
|
-
const data = "data" in instruction ? instruction.data : instruction;
|
|
6267
|
-
if (containsBytes(
|
|
6268
|
-
data,
|
|
6269
|
-
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
6270
|
-
new Uint8Array([17, 34, 183, 119, 202, 255, 218, 233])
|
|
6271
|
-
),
|
|
6272
|
-
0
|
|
6273
|
-
)) {
|
|
6274
|
-
return 0 /* AddCosigner */;
|
|
6275
|
-
}
|
|
6276
|
-
if (containsBytes(
|
|
6277
|
-
data,
|
|
6278
|
-
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
6279
|
-
new Uint8Array([208, 127, 21, 1, 194, 190, 196, 70])
|
|
6280
|
-
),
|
|
6281
|
-
0
|
|
6282
|
-
)) {
|
|
6283
|
-
return 1 /* InitializeConfig */;
|
|
6284
|
-
}
|
|
6285
|
-
if (containsBytes(
|
|
6286
|
-
data,
|
|
6287
|
-
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
6288
|
-
new Uint8Array([174, 11, 171, 252, 179, 99, 220, 27])
|
|
6289
|
-
),
|
|
6290
|
-
0
|
|
6291
|
-
)) {
|
|
6292
|
-
return 2 /* RemoveCosigner */;
|
|
6293
|
-
}
|
|
6294
|
-
if (containsBytes(
|
|
6295
|
-
data,
|
|
6296
|
-
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
6297
|
-
new Uint8Array([133, 250, 37, 21, 110, 163, 26, 121])
|
|
6298
|
-
),
|
|
6299
|
-
0
|
|
6300
|
-
)) {
|
|
6301
|
-
return 3 /* SetAuthority */;
|
|
6302
|
-
}
|
|
6303
|
-
throw new SolanaError(
|
|
6304
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
|
6305
|
-
{ instructionData: data, programName: "dynamicFeeHook" }
|
|
6306
|
-
);
|
|
6307
|
-
}
|
|
6308
|
-
function parseDynamicFeeHookInstruction(instruction) {
|
|
6309
|
-
const instructionType = identifyDynamicFeeHookInstruction(instruction);
|
|
6310
|
-
switch (instructionType) {
|
|
6311
|
-
case 0 /* AddCosigner */: {
|
|
6312
|
-
assertIsInstructionWithAccounts(instruction);
|
|
6313
|
-
return {
|
|
6314
|
-
instructionType: 0 /* AddCosigner */,
|
|
6315
|
-
...parseAddCosignerInstruction2(instruction)
|
|
6316
|
-
};
|
|
6317
|
-
}
|
|
6318
|
-
case 1 /* InitializeConfig */: {
|
|
6319
|
-
assertIsInstructionWithAccounts(instruction);
|
|
6320
|
-
return {
|
|
6321
|
-
instructionType: 1 /* InitializeConfig */,
|
|
6322
|
-
...parseInitializeConfigInstruction4(instruction)
|
|
6323
|
-
};
|
|
6324
|
-
}
|
|
6325
|
-
case 2 /* RemoveCosigner */: {
|
|
6326
|
-
assertIsInstructionWithAccounts(instruction);
|
|
6327
|
-
return {
|
|
6328
|
-
instructionType: 2 /* RemoveCosigner */,
|
|
6329
|
-
...parseRemoveCosignerInstruction2(instruction)
|
|
6330
|
-
};
|
|
6331
|
-
}
|
|
6332
|
-
case 3 /* SetAuthority */: {
|
|
6333
|
-
assertIsInstructionWithAccounts(instruction);
|
|
6334
|
-
return {
|
|
6335
|
-
instructionType: 3 /* SetAuthority */,
|
|
6336
|
-
...parseSetAuthorityInstruction2(instruction)
|
|
6337
|
-
};
|
|
6338
|
-
}
|
|
6339
|
-
default:
|
|
6340
|
-
throw new SolanaError(
|
|
6341
|
-
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
|
6342
|
-
{
|
|
6343
|
-
instructionType,
|
|
6344
|
-
programName: "dynamicFeeHook"
|
|
6345
|
-
}
|
|
6346
|
-
);
|
|
6347
|
-
}
|
|
6348
|
-
}
|
|
6349
|
-
function dynamicFeeHookProgram() {
|
|
6350
|
-
return (client) => {
|
|
6351
|
-
return {
|
|
6352
|
-
...client,
|
|
6353
|
-
dynamicFeeHook: {
|
|
6354
|
-
accounts: {
|
|
6355
|
-
cosignerConfig: addSelfFetchFunctions(
|
|
6356
|
-
client,
|
|
6357
|
-
getCosignerConfigCodec2()
|
|
6358
|
-
)
|
|
6359
|
-
},
|
|
6360
|
-
instructions: {
|
|
6361
|
-
addCosigner: (input) => addSelfPlanAndSendFunctions(
|
|
6362
|
-
client,
|
|
6363
|
-
getAddCosignerInstructionAsync2(input)
|
|
6364
|
-
),
|
|
6365
|
-
initializeConfig: (input) => addSelfPlanAndSendFunctions(
|
|
6366
|
-
client,
|
|
6367
|
-
getInitializeConfigInstructionAsync4({
|
|
6368
|
-
...input,
|
|
6369
|
-
payer: input.payer ?? client.payer
|
|
6370
|
-
})
|
|
6371
|
-
),
|
|
6372
|
-
removeCosigner: (input) => addSelfPlanAndSendFunctions(
|
|
6373
|
-
client,
|
|
6374
|
-
getRemoveCosignerInstructionAsync2(input)
|
|
6375
|
-
),
|
|
6376
|
-
setAuthority: (input) => addSelfPlanAndSendFunctions(
|
|
6377
|
-
client,
|
|
6378
|
-
getSetAuthorityInstructionAsync2(input)
|
|
6379
|
-
)
|
|
6380
|
-
}
|
|
6381
|
-
}
|
|
6382
|
-
};
|
|
6383
|
-
};
|
|
6384
|
-
}
|
|
6385
|
-
|
|
6386
|
-
// src/solana/generated/dynamicFeeHook/errors/dynamicFeeHook.ts
|
|
6387
|
-
var DYNAMIC_FEE_HOOK_ERROR__INVALID_INSTRUCTION_DATA = 6e3;
|
|
6388
|
-
var DYNAMIC_FEE_HOOK_ERROR__INVALID_SCHEDULE_DATA = 6001;
|
|
6389
|
-
var DYNAMIC_FEE_HOOK_ERROR__INVALID_FEE = 6002;
|
|
6390
|
-
var DYNAMIC_FEE_HOOK_ERROR__INVALID_DURATION = 6003;
|
|
6391
|
-
var DYNAMIC_FEE_HOOK_ERROR__ARITHMETIC_OVERFLOW = 6004;
|
|
6392
|
-
var DYNAMIC_FEE_HOOK_ERROR__INVALID_AUTHORITY = 6005;
|
|
6393
|
-
var DYNAMIC_FEE_HOOK_ERROR__INVALID_CONFIG = 6006;
|
|
6394
|
-
var DYNAMIC_FEE_HOOK_ERROR__INVALID_COSIGNER = 6007;
|
|
6395
|
-
var DYNAMIC_FEE_HOOK_ERROR__COSIGNER_ALREADY_EXISTS = 6008;
|
|
6396
|
-
var DYNAMIC_FEE_HOOK_ERROR__COSIGNER_NOT_FOUND = 6009;
|
|
6397
|
-
var DYNAMIC_FEE_HOOK_ERROR__COSIGNER_LIST_FULL = 6010;
|
|
6398
|
-
var dynamicFeeHookErrorMessages;
|
|
6399
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6400
|
-
dynamicFeeHookErrorMessages = {
|
|
6401
|
-
[DYNAMIC_FEE_HOOK_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
6402
|
-
[DYNAMIC_FEE_HOOK_ERROR__COSIGNER_ALREADY_EXISTS]: `Cosigner already exists`,
|
|
6403
|
-
[DYNAMIC_FEE_HOOK_ERROR__COSIGNER_LIST_FULL]: `Cosigner list is full`,
|
|
6404
|
-
[DYNAMIC_FEE_HOOK_ERROR__COSIGNER_NOT_FOUND]: `Cosigner not found`,
|
|
6405
|
-
[DYNAMIC_FEE_HOOK_ERROR__INVALID_AUTHORITY]: `Invalid hook authority`,
|
|
6406
|
-
[DYNAMIC_FEE_HOOK_ERROR__INVALID_CONFIG]: `Invalid cosigner hook config`,
|
|
6407
|
-
[DYNAMIC_FEE_HOOK_ERROR__INVALID_COSIGNER]: `Invalid cosigner key`,
|
|
6408
|
-
[DYNAMIC_FEE_HOOK_ERROR__INVALID_DURATION]: `Invalid fee duration`,
|
|
6409
|
-
[DYNAMIC_FEE_HOOK_ERROR__INVALID_FEE]: `Invalid fee`,
|
|
6410
|
-
[DYNAMIC_FEE_HOOK_ERROR__INVALID_INSTRUCTION_DATA]: `Invalid instruction data`,
|
|
6411
|
-
[DYNAMIC_FEE_HOOK_ERROR__INVALID_SCHEDULE_DATA]: `Invalid schedule payload`
|
|
6412
|
-
};
|
|
6413
|
-
}
|
|
6414
|
-
function getDynamicFeeHookErrorMessage(code) {
|
|
6415
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6416
|
-
return dynamicFeeHookErrorMessages[code];
|
|
6417
|
-
}
|
|
6418
|
-
return "Error message not available in production bundles.";
|
|
6419
|
-
}
|
|
6420
|
-
function isDynamicFeeHookError(error, transactionMessage, code) {
|
|
6421
|
-
return isProgramError(
|
|
6422
|
-
error,
|
|
6423
|
-
transactionMessage,
|
|
6424
|
-
DYNAMIC_FEE_HOOK_PROGRAM_ADDRESS,
|
|
6425
|
-
code
|
|
6426
|
-
);
|
|
6427
|
-
}
|
|
6428
|
-
function getCosignerArgEncoder2() {
|
|
6429
|
-
return getStructEncoder([["cosigner", getAddressEncoder()]]);
|
|
6430
|
-
}
|
|
6431
|
-
function getCosignerArgDecoder2() {
|
|
6432
|
-
return getStructDecoder([["cosigner", getAddressDecoder()]]);
|
|
6433
|
-
}
|
|
6434
|
-
function getCosignerArgCodec2() {
|
|
6435
|
-
return combineCodec(getCosignerArgEncoder2(), getCosignerArgDecoder2());
|
|
6436
|
-
}
|
|
6437
|
-
function getInitializeConfigArgsEncoder3() {
|
|
6438
|
-
return getStructEncoder([
|
|
6439
|
-
["cosigners", getArrayEncoder(getAddressEncoder())]
|
|
6440
|
-
]);
|
|
6441
|
-
}
|
|
6442
|
-
function getInitializeConfigArgsDecoder3() {
|
|
6443
|
-
return getStructDecoder([
|
|
6444
|
-
["cosigners", getArrayDecoder(getAddressDecoder())]
|
|
6445
|
-
]);
|
|
6446
|
-
}
|
|
6447
|
-
function getInitializeConfigArgsCodec3() {
|
|
6448
|
-
return combineCodec(
|
|
6449
|
-
getInitializeConfigArgsEncoder3(),
|
|
6450
|
-
getInitializeConfigArgsDecoder3()
|
|
6451
|
-
);
|
|
6452
|
-
}
|
|
6453
|
-
function getSetAuthorityArgsEncoder2() {
|
|
6454
|
-
return getStructEncoder([["adminAuthority", getAddressEncoder()]]);
|
|
6455
|
-
}
|
|
6456
|
-
function getSetAuthorityArgsDecoder2() {
|
|
6457
|
-
return getStructDecoder([["adminAuthority", getAddressDecoder()]]);
|
|
6458
|
-
}
|
|
6459
|
-
function getSetAuthorityArgsCodec2() {
|
|
6460
|
-
return combineCodec(
|
|
6461
|
-
getSetAuthorityArgsEncoder2(),
|
|
6462
|
-
getSetAuthorityArgsDecoder2()
|
|
6463
|
-
);
|
|
6464
|
-
}
|
|
6465
|
-
var DEVNET_DYNAMIC_FEE_HOOK_PROGRAM_ID = address(
|
|
6466
|
-
"HVsPNZh98TgChUXHwKrUG47SUqvGQHxUy5wZwcQLFD4i"
|
|
6467
|
-
);
|
|
6468
|
-
var DYNAMIC_FEE_HOOK_PROGRAM_ID = DEVNET_DYNAMIC_FEE_HOOK_PROGRAM_ID;
|
|
6469
|
-
var SEED_DYNAMIC_FEE_HOOK_CONFIG = "cosigner_hook_config";
|
|
6470
|
-
var MAX_COSIGNERS2 = 32;
|
|
6471
|
-
var DYNAMIC_FEE_SCHEDULE_MAGIC = new Uint8Array([
|
|
6472
|
-
68,
|
|
6473
|
-
70,
|
|
6474
|
-
69,
|
|
6475
|
-
69,
|
|
6476
|
-
86,
|
|
6477
|
-
49,
|
|
6478
|
-
95,
|
|
6479
|
-
95
|
|
6480
|
-
]);
|
|
6481
|
-
var DYNAMIC_FEE_SCHEDULE_VERSION = 1;
|
|
6482
|
-
var DYNAMIC_FEE_SCHEDULE_LEN = 32;
|
|
6483
|
-
var DYNAMIC_FEE_SCHEDULE_HEADER_LEN = 16;
|
|
6484
|
-
var DYNAMIC_FEE_SCHEDULE_MAX_BPS = 1e4;
|
|
6485
|
-
|
|
6486
|
-
// src/solana/dynamicFeeHook/payload.ts
|
|
6487
|
-
var MAX_I64 = (1n << 63n) - 1n;
|
|
6488
|
-
var MAX_U32 = (1n << 32n) - 1n;
|
|
6489
|
-
function toBigInt2(value) {
|
|
6490
|
-
return typeof value === "bigint" ? value : BigInt(value);
|
|
6491
|
-
}
|
|
6492
|
-
function assertU16Bps(label, value) {
|
|
6493
|
-
if (!Number.isInteger(value) || value < 0 || value > DYNAMIC_FEE_SCHEDULE_MAX_BPS) {
|
|
6494
|
-
throw new Error(`${label} must be an integer between 0 and 10000`);
|
|
6495
|
-
}
|
|
6496
|
-
}
|
|
6497
|
-
function writeI64Le(bytes, offset, value) {
|
|
6498
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6499
|
-
view.setBigInt64(offset, value, true);
|
|
6500
|
-
}
|
|
6501
|
-
function writeU16Le(bytes, offset, value) {
|
|
6502
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6503
|
-
view.setUint16(offset, value, true);
|
|
6504
|
-
}
|
|
6505
|
-
function writeU32Le(bytes, offset, value) {
|
|
6506
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6507
|
-
view.setUint32(offset, Number(value), true);
|
|
6508
|
-
}
|
|
6509
|
-
function validateDynamicFeeScheduleArgs(schedule) {
|
|
6510
|
-
const startingTime = toBigInt2(schedule.startingTime);
|
|
6511
|
-
if (startingTime < 0n || startingTime > MAX_I64) {
|
|
6512
|
-
throw new Error("startingTime must be between 0 and i64::MAX");
|
|
6513
|
-
}
|
|
6514
|
-
assertU16Bps("startFeeBps", schedule.startFeeBps);
|
|
6515
|
-
assertU16Bps("endFeeBps", schedule.endFeeBps);
|
|
6516
|
-
if (schedule.endFeeBps > schedule.startFeeBps) {
|
|
6517
|
-
throw new Error("endFeeBps must be less than or equal to startFeeBps");
|
|
6518
|
-
}
|
|
6519
|
-
const durationSeconds = toBigInt2(schedule.durationSeconds);
|
|
6520
|
-
if (durationSeconds < 0n || durationSeconds > MAX_U32) {
|
|
6521
|
-
throw new Error("durationSeconds must be between 0 and u32::MAX");
|
|
6522
|
-
}
|
|
6523
|
-
if (schedule.startFeeBps > schedule.endFeeBps && durationSeconds === 0n) {
|
|
6524
|
-
throw new Error("durationSeconds must be nonzero for decaying schedules");
|
|
6525
|
-
}
|
|
6526
|
-
return { startingTime, durationSeconds };
|
|
6527
|
-
}
|
|
6528
|
-
function encodeDynamicFeeSchedule(schedule) {
|
|
6529
|
-
const { startingTime, durationSeconds } = validateDynamicFeeScheduleArgs(schedule);
|
|
6530
|
-
const payload = new Uint8Array(DYNAMIC_FEE_SCHEDULE_LEN);
|
|
6531
|
-
payload.set(DYNAMIC_FEE_SCHEDULE_MAGIC, 0);
|
|
6532
|
-
payload[8] = DYNAMIC_FEE_SCHEDULE_VERSION;
|
|
6533
|
-
writeI64Le(payload, DYNAMIC_FEE_SCHEDULE_HEADER_LEN, startingTime);
|
|
6534
|
-
writeU16Le(payload, 24, schedule.startFeeBps);
|
|
6535
|
-
writeU16Le(payload, 26, schedule.endFeeBps);
|
|
6536
|
-
writeU32Le(payload, 28, durationSeconds);
|
|
6537
|
-
return payload;
|
|
6538
|
-
}
|
|
6539
|
-
function encodeDynamicFeeHookPayload(args = {}) {
|
|
6540
|
-
const schedulePayload = args.schedule ? encodeDynamicFeeSchedule(args.schedule) : new Uint8Array();
|
|
6541
|
-
const gatePayload = args.gateExpiry ? encodeCosignerGateExpiryPayload(args.gateExpiry) : new Uint8Array();
|
|
6542
|
-
const payload = new Uint8Array(schedulePayload.length + gatePayload.length);
|
|
6543
|
-
payload.set(schedulePayload, 0);
|
|
6544
|
-
payload.set(gatePayload, schedulePayload.length);
|
|
6545
|
-
return payload;
|
|
6546
|
-
}
|
|
6547
|
-
function encodeDynamicFeeCosignerGatePayload(args) {
|
|
6548
|
-
return encodeCosignerGateExpiryPayload(args);
|
|
6549
|
-
}
|
|
6550
|
-
function getDynamicFeeHookRemainingAccounts({
|
|
6551
|
-
namespace,
|
|
6552
|
-
config,
|
|
6553
|
-
cosigner
|
|
6554
|
-
}) {
|
|
6555
|
-
const signedHookRemainingAccounts = [namespace];
|
|
6556
|
-
if (config && config !== namespace) {
|
|
6557
|
-
signedHookRemainingAccounts.push(config);
|
|
6558
|
-
}
|
|
6559
|
-
if (cosigner) {
|
|
6560
|
-
signedHookRemainingAccounts.push(cosigner);
|
|
6561
|
-
}
|
|
6562
|
-
const unsignedHookRemainingAccounts = signedHookRemainingAccounts.map(
|
|
6563
|
-
getAddressFromRemainingAccount
|
|
6564
|
-
);
|
|
6565
|
-
return {
|
|
6566
|
-
signedHookRemainingAccounts,
|
|
6567
|
-
unsignedHookRemainingAccounts,
|
|
6568
|
-
hookRemainingAccountsHash: computeRemainingAccountsHash(
|
|
6569
|
-
unsignedHookRemainingAccounts
|
|
6570
|
-
)
|
|
6571
|
-
};
|
|
6572
|
-
}
|
|
6573
|
-
function getDynamicFeeHookRemainingAccountAddresses({
|
|
6574
|
-
namespace,
|
|
6575
|
-
config,
|
|
6576
|
-
cosigner
|
|
6577
|
-
}) {
|
|
6578
|
-
return getDynamicFeeHookRemainingAccounts({
|
|
6579
|
-
namespace,
|
|
6580
|
-
config,
|
|
6581
|
-
cosigner
|
|
6582
|
-
}).unsignedHookRemainingAccounts;
|
|
6583
|
-
}
|
|
6584
|
-
function isDynamicFeeSchedulePayload(payload) {
|
|
6585
|
-
return payload.length >= DYNAMIC_FEE_SCHEDULE_LEN && DYNAMIC_FEE_SCHEDULE_MAGIC.every((byte, index) => payload[index] === byte);
|
|
6586
|
-
}
|
|
6587
|
-
var textEncoder6 = new TextEncoder();
|
|
6588
|
-
async function getDynamicFeeHookConfigAddress(programId = DYNAMIC_FEE_HOOK_PROGRAM_ID) {
|
|
6589
|
-
return getProgramDerivedAddress({
|
|
6590
|
-
programAddress: programId,
|
|
6591
|
-
seeds: [textEncoder6.encode(SEED_DYNAMIC_FEE_HOOK_CONFIG)]
|
|
6592
|
-
});
|
|
6593
|
-
}
|
|
6594
|
-
|
|
6595
|
-
// src/solana/migrators/cpmmMigrator/index.ts
|
|
6596
|
-
var cpmmMigrator_exports = {};
|
|
6597
|
-
__export(cpmmMigrator_exports, {
|
|
6598
|
-
CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS: () => CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS,
|
|
6599
|
-
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS: () => CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS,
|
|
6600
|
-
CPMM_MIGRATOR_PROGRAM_ID: () => CPMM_MIGRATOR_PROGRAM_ID,
|
|
6601
|
-
MAX_RECIPIENTS: () => MAX_RECIPIENTS,
|
|
6602
|
-
SEED_MIGRATION_AUTHORITY: () => SEED_MIGRATION_AUTHORITY,
|
|
6603
|
-
SEED_STATE: () => SEED_STATE,
|
|
6604
|
-
buildCpmmMigrationRemainingAccounts: () => buildCpmmMigrationRemainingAccounts,
|
|
6605
|
-
buildCpmmMigrationRemainingAccountsHash: () => buildCpmmMigrationRemainingAccountsHash,
|
|
6606
|
-
encodeMigratePayload: () => encodeMigratePayload,
|
|
6607
|
-
encodeRegisterLaunchPayload: () => encodeRegisterLaunchPayload,
|
|
6608
|
-
fetchCpmmMigratorState: () => fetchCpmmMigratorState,
|
|
6609
|
-
getCpmmMigrationAuthorityAddress: () => getCpmmMigrationAuthorityAddress,
|
|
6610
|
-
getCpmmMigratorStateAddress: () => getCpmmMigratorStateAddress,
|
|
6611
|
-
getCpmmMigratorStateCodec: () => getCpmmMigratorStateCodec,
|
|
6612
|
-
getCpmmMigratorStateDecoder: () => getCpmmMigratorStateDecoder,
|
|
6613
|
-
getCpmmMigratorStateEncoder: () => getCpmmMigratorStateEncoder,
|
|
6614
|
-
getMigrateArgsCodec: () => getMigrateArgsCodec,
|
|
6615
|
-
getMigrateArgsDecoder: () => getMigrateArgsDecoder,
|
|
6616
|
-
getMigrateArgsEncoder: () => getMigrateArgsEncoder,
|
|
6617
|
-
getRecipientCodec: () => getRecipientCodec,
|
|
6618
|
-
getRecipientDecoder: () => getRecipientDecoder,
|
|
6619
|
-
getRecipientEncoder: () => getRecipientEncoder,
|
|
6620
|
-
getRegisterLaunchArgsCodec: () => getRegisterLaunchArgsCodec,
|
|
6621
|
-
getRegisterLaunchArgsDecoder: () => getRegisterLaunchArgsDecoder,
|
|
6622
|
-
getRegisterLaunchArgsEncoder: () => getRegisterLaunchArgsEncoder
|
|
6623
|
-
});
|
|
6624
|
-
function getMigrateArgsEncoder() {
|
|
6625
|
-
return getStructEncoder([
|
|
6626
|
-
["baseForDistribution", getU64Encoder()],
|
|
6627
|
-
["baseForLiquidity", getU64Encoder()]
|
|
6628
|
-
]);
|
|
6629
|
-
}
|
|
6630
|
-
function getMigrateArgsDecoder() {
|
|
6631
|
-
return getStructDecoder([
|
|
6632
|
-
["baseForDistribution", getU64Decoder()],
|
|
6633
|
-
["baseForLiquidity", getU64Decoder()]
|
|
6634
|
-
]);
|
|
6635
|
-
}
|
|
6636
|
-
function getMigrateArgsCodec() {
|
|
6637
|
-
return combineCodec(getMigrateArgsEncoder(), getMigrateArgsDecoder());
|
|
6638
|
-
}
|
|
6639
|
-
function getMigratedPoolHookConfigEncoder() {
|
|
6640
|
-
return getStructEncoder([
|
|
6641
|
-
["hookProgram", getAddressEncoder()],
|
|
6642
|
-
["hookFlags", getU32Encoder()]
|
|
6643
|
-
]);
|
|
6644
|
-
}
|
|
6645
|
-
function getMigratedPoolHookConfigDecoder() {
|
|
6646
|
-
return getStructDecoder([
|
|
6647
|
-
["hookProgram", getAddressDecoder()],
|
|
6648
|
-
["hookFlags", getU32Decoder()]
|
|
5774
|
+
["hookProgram", getAddressDecoder()],
|
|
5775
|
+
["hookFlags", getU32Decoder()]
|
|
6649
5776
|
]);
|
|
6650
5777
|
}
|
|
6651
5778
|
function getRecipientEncoder() {
|
|
@@ -6756,11 +5883,406 @@ function getCpmmMigratorStateCodec() {
|
|
|
6756
5883
|
getCpmmMigratorStateDecoder()
|
|
6757
5884
|
);
|
|
6758
5885
|
}
|
|
5886
|
+
var CREATE_SPOT_POOL_DISCRIMINATOR = new Uint8Array([
|
|
5887
|
+
13,
|
|
5888
|
+
137,
|
|
5889
|
+
16,
|
|
5890
|
+
26,
|
|
5891
|
+
40,
|
|
5892
|
+
36,
|
|
5893
|
+
110,
|
|
5894
|
+
26
|
|
5895
|
+
]);
|
|
5896
|
+
function getCreateSpotPoolInstructionDataEncoder() {
|
|
5897
|
+
return transformEncoder(
|
|
5898
|
+
getStructEncoder([
|
|
5899
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
5900
|
+
["swapFeeBps", getU16Encoder()],
|
|
5901
|
+
["positionId", getU64Encoder()],
|
|
5902
|
+
["amount0Max", getU64Encoder()],
|
|
5903
|
+
["amount1Max", getU64Encoder()],
|
|
5904
|
+
["minSharesOut", getU128Encoder()]
|
|
5905
|
+
]),
|
|
5906
|
+
(value) => ({ ...value, discriminator: CREATE_SPOT_POOL_DISCRIMINATOR })
|
|
5907
|
+
);
|
|
5908
|
+
}
|
|
5909
|
+
function getCreateSpotPoolInstructionDataDecoder() {
|
|
5910
|
+
return getStructDecoder([
|
|
5911
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
5912
|
+
["swapFeeBps", getU16Decoder()],
|
|
5913
|
+
["positionId", getU64Decoder()],
|
|
5914
|
+
["amount0Max", getU64Decoder()],
|
|
5915
|
+
["amount1Max", getU64Decoder()],
|
|
5916
|
+
["minSharesOut", getU128Decoder()]
|
|
5917
|
+
]);
|
|
5918
|
+
}
|
|
5919
|
+
function getCreateSpotPoolInstructionDataCodec() {
|
|
5920
|
+
return combineCodec(
|
|
5921
|
+
getCreateSpotPoolInstructionDataEncoder(),
|
|
5922
|
+
getCreateSpotPoolInstructionDataDecoder()
|
|
5923
|
+
);
|
|
5924
|
+
}
|
|
5925
|
+
async function getCreateSpotPoolInstructionAsync(input, config) {
|
|
5926
|
+
const programAddress = config?.programAddress ?? CPMM_MIGRATOR_PROGRAM_ADDRESS;
|
|
5927
|
+
const originalAccounts = {
|
|
5928
|
+
cpmmConfig: { value: input.cpmmConfig ?? null, isWritable: false },
|
|
5929
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
5930
|
+
liquidityOwner: { value: input.liquidityOwner ?? null, isWritable: false },
|
|
5931
|
+
token0Mint: { value: input.token0Mint ?? null, isWritable: false },
|
|
5932
|
+
token1Mint: { value: input.token1Mint ?? null, isWritable: false },
|
|
5933
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
5934
|
+
poolAuthority: { value: input.poolAuthority ?? null, isWritable: false },
|
|
5935
|
+
poolVault0: { value: input.poolVault0 ?? null, isWritable: true },
|
|
5936
|
+
poolVault1: { value: input.poolVault1 ?? null, isWritable: true },
|
|
5937
|
+
protocolFeeOwner: {
|
|
5938
|
+
value: input.protocolFeeOwner ?? null,
|
|
5939
|
+
isWritable: false
|
|
5940
|
+
},
|
|
5941
|
+
protocolFeePosition: {
|
|
5942
|
+
value: input.protocolFeePosition ?? null,
|
|
5943
|
+
isWritable: true
|
|
5944
|
+
},
|
|
5945
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
5946
|
+
user0: { value: input.user0 ?? null, isWritable: true },
|
|
5947
|
+
user1: { value: input.user1 ?? null, isWritable: true },
|
|
5948
|
+
cpmmProgram: { value: input.cpmmProgram ?? null, isWritable: false },
|
|
5949
|
+
migrationAuthority: {
|
|
5950
|
+
value: input.migrationAuthority ?? null,
|
|
5951
|
+
isWritable: false
|
|
5952
|
+
},
|
|
5953
|
+
token0Program: { value: input.token0Program ?? null, isWritable: false },
|
|
5954
|
+
token1Program: { value: input.token1Program ?? null, isWritable: false },
|
|
5955
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
5956
|
+
rent: { value: input.rent ?? null, isWritable: false }
|
|
5957
|
+
};
|
|
5958
|
+
const accounts = originalAccounts;
|
|
5959
|
+
const args = { ...input };
|
|
5960
|
+
if (!accounts.cpmmProgram.value) {
|
|
5961
|
+
accounts.cpmmProgram.value = "9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ";
|
|
5962
|
+
}
|
|
5963
|
+
if (!accounts.migrationAuthority.value) {
|
|
5964
|
+
accounts.migrationAuthority.value = await getProgramDerivedAddress({
|
|
5965
|
+
programAddress,
|
|
5966
|
+
seeds: [
|
|
5967
|
+
getBytesEncoder().encode(
|
|
5968
|
+
new Uint8Array([
|
|
5969
|
+
109,
|
|
5970
|
+
105,
|
|
5971
|
+
103,
|
|
5972
|
+
114,
|
|
5973
|
+
97,
|
|
5974
|
+
116,
|
|
5975
|
+
105,
|
|
5976
|
+
111,
|
|
5977
|
+
110,
|
|
5978
|
+
95,
|
|
5979
|
+
97,
|
|
5980
|
+
117,
|
|
5981
|
+
116,
|
|
5982
|
+
104,
|
|
5983
|
+
111,
|
|
5984
|
+
114,
|
|
5985
|
+
105,
|
|
5986
|
+
116,
|
|
5987
|
+
121
|
|
5988
|
+
])
|
|
5989
|
+
)
|
|
5990
|
+
]
|
|
5991
|
+
});
|
|
5992
|
+
}
|
|
5993
|
+
if (!accounts.systemProgram.value) {
|
|
5994
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
5995
|
+
}
|
|
5996
|
+
if (!accounts.rent.value) {
|
|
5997
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
5998
|
+
}
|
|
5999
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
6000
|
+
return Object.freeze({
|
|
6001
|
+
accounts: [
|
|
6002
|
+
getAccountMeta("cpmmConfig", accounts.cpmmConfig),
|
|
6003
|
+
getAccountMeta("payer", accounts.payer),
|
|
6004
|
+
getAccountMeta("liquidityOwner", accounts.liquidityOwner),
|
|
6005
|
+
getAccountMeta("token0Mint", accounts.token0Mint),
|
|
6006
|
+
getAccountMeta("token1Mint", accounts.token1Mint),
|
|
6007
|
+
getAccountMeta("pool", accounts.pool),
|
|
6008
|
+
getAccountMeta("poolAuthority", accounts.poolAuthority),
|
|
6009
|
+
getAccountMeta("poolVault0", accounts.poolVault0),
|
|
6010
|
+
getAccountMeta("poolVault1", accounts.poolVault1),
|
|
6011
|
+
getAccountMeta("protocolFeeOwner", accounts.protocolFeeOwner),
|
|
6012
|
+
getAccountMeta("protocolFeePosition", accounts.protocolFeePosition),
|
|
6013
|
+
getAccountMeta("position", accounts.position),
|
|
6014
|
+
getAccountMeta("user0", accounts.user0),
|
|
6015
|
+
getAccountMeta("user1", accounts.user1),
|
|
6016
|
+
getAccountMeta("cpmmProgram", accounts.cpmmProgram),
|
|
6017
|
+
getAccountMeta("migrationAuthority", accounts.migrationAuthority),
|
|
6018
|
+
getAccountMeta("token0Program", accounts.token0Program),
|
|
6019
|
+
getAccountMeta("token1Program", accounts.token1Program),
|
|
6020
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
6021
|
+
getAccountMeta("rent", accounts.rent)
|
|
6022
|
+
],
|
|
6023
|
+
data: getCreateSpotPoolInstructionDataEncoder().encode(
|
|
6024
|
+
args
|
|
6025
|
+
),
|
|
6026
|
+
programAddress
|
|
6027
|
+
});
|
|
6028
|
+
}
|
|
6029
|
+
function getCreateSpotPoolInstruction(input, config) {
|
|
6030
|
+
const programAddress = config?.programAddress ?? CPMM_MIGRATOR_PROGRAM_ADDRESS;
|
|
6031
|
+
const originalAccounts = {
|
|
6032
|
+
cpmmConfig: { value: input.cpmmConfig ?? null, isWritable: false },
|
|
6033
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
6034
|
+
liquidityOwner: { value: input.liquidityOwner ?? null, isWritable: false },
|
|
6035
|
+
token0Mint: { value: input.token0Mint ?? null, isWritable: false },
|
|
6036
|
+
token1Mint: { value: input.token1Mint ?? null, isWritable: false },
|
|
6037
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
6038
|
+
poolAuthority: { value: input.poolAuthority ?? null, isWritable: false },
|
|
6039
|
+
poolVault0: { value: input.poolVault0 ?? null, isWritable: true },
|
|
6040
|
+
poolVault1: { value: input.poolVault1 ?? null, isWritable: true },
|
|
6041
|
+
protocolFeeOwner: {
|
|
6042
|
+
value: input.protocolFeeOwner ?? null,
|
|
6043
|
+
isWritable: false
|
|
6044
|
+
},
|
|
6045
|
+
protocolFeePosition: {
|
|
6046
|
+
value: input.protocolFeePosition ?? null,
|
|
6047
|
+
isWritable: true
|
|
6048
|
+
},
|
|
6049
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
6050
|
+
user0: { value: input.user0 ?? null, isWritable: true },
|
|
6051
|
+
user1: { value: input.user1 ?? null, isWritable: true },
|
|
6052
|
+
cpmmProgram: { value: input.cpmmProgram ?? null, isWritable: false },
|
|
6053
|
+
migrationAuthority: {
|
|
6054
|
+
value: input.migrationAuthority ?? null,
|
|
6055
|
+
isWritable: false
|
|
6056
|
+
},
|
|
6057
|
+
token0Program: { value: input.token0Program ?? null, isWritable: false },
|
|
6058
|
+
token1Program: { value: input.token1Program ?? null, isWritable: false },
|
|
6059
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
6060
|
+
rent: { value: input.rent ?? null, isWritable: false }
|
|
6061
|
+
};
|
|
6062
|
+
const accounts = originalAccounts;
|
|
6063
|
+
const args = { ...input };
|
|
6064
|
+
if (!accounts.cpmmProgram.value) {
|
|
6065
|
+
accounts.cpmmProgram.value = "9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ";
|
|
6066
|
+
}
|
|
6067
|
+
if (!accounts.systemProgram.value) {
|
|
6068
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
6069
|
+
}
|
|
6070
|
+
if (!accounts.rent.value) {
|
|
6071
|
+
accounts.rent.value = "SysvarRent111111111111111111111111111111111";
|
|
6072
|
+
}
|
|
6073
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
6074
|
+
return Object.freeze({
|
|
6075
|
+
accounts: [
|
|
6076
|
+
getAccountMeta("cpmmConfig", accounts.cpmmConfig),
|
|
6077
|
+
getAccountMeta("payer", accounts.payer),
|
|
6078
|
+
getAccountMeta("liquidityOwner", accounts.liquidityOwner),
|
|
6079
|
+
getAccountMeta("token0Mint", accounts.token0Mint),
|
|
6080
|
+
getAccountMeta("token1Mint", accounts.token1Mint),
|
|
6081
|
+
getAccountMeta("pool", accounts.pool),
|
|
6082
|
+
getAccountMeta("poolAuthority", accounts.poolAuthority),
|
|
6083
|
+
getAccountMeta("poolVault0", accounts.poolVault0),
|
|
6084
|
+
getAccountMeta("poolVault1", accounts.poolVault1),
|
|
6085
|
+
getAccountMeta("protocolFeeOwner", accounts.protocolFeeOwner),
|
|
6086
|
+
getAccountMeta("protocolFeePosition", accounts.protocolFeePosition),
|
|
6087
|
+
getAccountMeta("position", accounts.position),
|
|
6088
|
+
getAccountMeta("user0", accounts.user0),
|
|
6089
|
+
getAccountMeta("user1", accounts.user1),
|
|
6090
|
+
getAccountMeta("cpmmProgram", accounts.cpmmProgram),
|
|
6091
|
+
getAccountMeta("migrationAuthority", accounts.migrationAuthority),
|
|
6092
|
+
getAccountMeta("token0Program", accounts.token0Program),
|
|
6093
|
+
getAccountMeta("token1Program", accounts.token1Program),
|
|
6094
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
6095
|
+
getAccountMeta("rent", accounts.rent)
|
|
6096
|
+
],
|
|
6097
|
+
data: getCreateSpotPoolInstructionDataEncoder().encode(
|
|
6098
|
+
args
|
|
6099
|
+
),
|
|
6100
|
+
programAddress
|
|
6101
|
+
});
|
|
6102
|
+
}
|
|
6103
|
+
|
|
6104
|
+
// src/solana/generated/cpmmMigrator/programs/cpmmMigrator.ts
|
|
6105
|
+
var CPMM_MIGRATOR_PROGRAM_ADDRESS = "7WMUTNC41eMCo6eGH5Sy2xbgE3AycvLbFPo95AU9CSUd";
|
|
6759
6106
|
if (process.env.NODE_ENV !== "production") ;
|
|
6107
|
+
var addressCodec5 = getAddressCodec();
|
|
6108
|
+
var textEncoder6 = new TextEncoder();
|
|
6109
|
+
var U64_MAX = (1n << 64n) - 1n;
|
|
6110
|
+
var PROTOCOL_FEE_POSITION_ID = 0n;
|
|
6111
|
+
async function pda(programAddress, seeds) {
|
|
6112
|
+
const [derived] = await getProgramDerivedAddress({
|
|
6113
|
+
programAddress,
|
|
6114
|
+
seeds
|
|
6115
|
+
});
|
|
6116
|
+
return derived;
|
|
6117
|
+
}
|
|
6118
|
+
function seed(value) {
|
|
6119
|
+
return textEncoder6.encode(value);
|
|
6120
|
+
}
|
|
6121
|
+
function addressSeed(value) {
|
|
6122
|
+
return addressCodec5.encode(value);
|
|
6123
|
+
}
|
|
6124
|
+
function assertSafeInteger(name, value) {
|
|
6125
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
6126
|
+
throw new RangeError(
|
|
6127
|
+
`${name} must be a safe integer when provided as a number; use bigint for values above Number.MAX_SAFE_INTEGER`
|
|
6128
|
+
);
|
|
6129
|
+
}
|
|
6130
|
+
}
|
|
6131
|
+
function u64Seed(value) {
|
|
6132
|
+
assertSafeInteger("positionId", value);
|
|
6133
|
+
const bigintValue = BigInt(value);
|
|
6134
|
+
if (bigintValue < 0n || bigintValue > U64_MAX) {
|
|
6135
|
+
throw new RangeError("u64 position ID must be between 0 and 2^64 - 1");
|
|
6136
|
+
}
|
|
6137
|
+
const bytes = new Uint8Array(8);
|
|
6138
|
+
new DataView(bytes.buffer).setBigUint64(0, bigintValue, true);
|
|
6139
|
+
return bytes;
|
|
6140
|
+
}
|
|
6141
|
+
function addressOf(value) {
|
|
6142
|
+
return typeof value === "string" ? value : value.address;
|
|
6143
|
+
}
|
|
6144
|
+
function accountMeta(value, role) {
|
|
6145
|
+
if (typeof value === "string") {
|
|
6146
|
+
return { address: value, role };
|
|
6147
|
+
}
|
|
6148
|
+
return { address: value.address, role, signer: value };
|
|
6149
|
+
}
|
|
6150
|
+
async function deriveSpotPoolAccounts({
|
|
6151
|
+
tokenAMint,
|
|
6152
|
+
tokenBMint,
|
|
6153
|
+
swapFeeBps,
|
|
6154
|
+
liquidityOwner,
|
|
6155
|
+
tokenAProgram = TOKEN_PROGRAM_ADDRESS$1,
|
|
6156
|
+
tokenBProgram = TOKEN_PROGRAM_ADDRESS$1,
|
|
6157
|
+
tokenAAccount,
|
|
6158
|
+
tokenBAccount,
|
|
6159
|
+
token0Account,
|
|
6160
|
+
token1Account,
|
|
6161
|
+
positionId = 0n,
|
|
6162
|
+
cpmmProgram = CPMM_PROGRAM_ID,
|
|
6163
|
+
cpmmMigratorProgram = CPMM_MIGRATOR_PROGRAM_ID
|
|
6164
|
+
}) {
|
|
6165
|
+
const [token0Mint, token1Mint] = sortMints(tokenAMint, tokenBMint);
|
|
6166
|
+
const token0IsA = token0Mint === tokenAMint;
|
|
6167
|
+
const token0Program = token0IsA ? tokenAProgram : tokenBProgram;
|
|
6168
|
+
const token1Program = token0IsA ? tokenBProgram : tokenAProgram;
|
|
6169
|
+
const [userA] = await findAssociatedTokenPda({
|
|
6170
|
+
owner: liquidityOwner,
|
|
6171
|
+
mint: tokenAMint,
|
|
6172
|
+
tokenProgram: tokenAProgram
|
|
6173
|
+
});
|
|
6174
|
+
const [userB] = await findAssociatedTokenPda({
|
|
6175
|
+
owner: liquidityOwner,
|
|
6176
|
+
mint: tokenBMint,
|
|
6177
|
+
tokenProgram: tokenBProgram
|
|
6178
|
+
});
|
|
6179
|
+
const user0 = token0Account ?? (token0IsA ? tokenAAccount ?? userA : tokenBAccount ?? userB);
|
|
6180
|
+
const user1 = token1Account ?? (token0IsA ? tokenBAccount ?? userB : tokenAAccount ?? userA);
|
|
6181
|
+
const [pool] = await getSpotPoolAddress(
|
|
6182
|
+
token0Mint,
|
|
6183
|
+
token1Mint,
|
|
6184
|
+
swapFeeBps,
|
|
6185
|
+
cpmmProgram
|
|
6186
|
+
);
|
|
6187
|
+
const protocolFeeOwner = await pda(cpmmProgram, [
|
|
6188
|
+
seed(SEED_PROTOCOL_FEE_OWNER),
|
|
6189
|
+
addressSeed(pool)
|
|
6190
|
+
]);
|
|
6191
|
+
return {
|
|
6192
|
+
cpmmConfig: await pda(cpmmProgram, [seed(SEED_CONFIG)]),
|
|
6193
|
+
token0Mint,
|
|
6194
|
+
token1Mint,
|
|
6195
|
+
token0Program,
|
|
6196
|
+
token1Program,
|
|
6197
|
+
pool,
|
|
6198
|
+
poolAuthority: await pda(cpmmProgram, [
|
|
6199
|
+
seed(SEED_AUTHORITY),
|
|
6200
|
+
addressSeed(pool)
|
|
6201
|
+
]),
|
|
6202
|
+
poolVault0: await pda(cpmmProgram, [seed(SEED_VAULT0), addressSeed(pool)]),
|
|
6203
|
+
poolVault1: await pda(cpmmProgram, [seed(SEED_VAULT1), addressSeed(pool)]),
|
|
6204
|
+
protocolFeeOwner,
|
|
6205
|
+
protocolFeePosition: await pda(cpmmProgram, [
|
|
6206
|
+
seed(SEED_POSITION),
|
|
6207
|
+
addressSeed(pool),
|
|
6208
|
+
addressSeed(protocolFeeOwner),
|
|
6209
|
+
u64Seed(PROTOCOL_FEE_POSITION_ID)
|
|
6210
|
+
]),
|
|
6211
|
+
position: await pda(cpmmProgram, [
|
|
6212
|
+
seed(SEED_POSITION),
|
|
6213
|
+
addressSeed(pool),
|
|
6214
|
+
addressSeed(liquidityOwner),
|
|
6215
|
+
u64Seed(positionId)
|
|
6216
|
+
]),
|
|
6217
|
+
user0,
|
|
6218
|
+
user1,
|
|
6219
|
+
migrationAuthority: await pda(cpmmMigratorProgram, [
|
|
6220
|
+
seed(SEED_MIGRATION_AUTHORITY)
|
|
6221
|
+
])
|
|
6222
|
+
};
|
|
6223
|
+
}
|
|
6224
|
+
async function createSpotPoolInstruction(input) {
|
|
6225
|
+
const payer = input.payer;
|
|
6226
|
+
const liquidityOwner = input.liquidityOwner ?? payer;
|
|
6227
|
+
const positionId = input.positionId ?? 0n;
|
|
6228
|
+
const minSharesOut = input.minSharesOut ?? 1n;
|
|
6229
|
+
assertSafeInteger("positionId", positionId);
|
|
6230
|
+
assertSafeInteger("tokenAAmount", input.tokenAAmount);
|
|
6231
|
+
assertSafeInteger("tokenBAmount", input.tokenBAmount);
|
|
6232
|
+
assertSafeInteger("minSharesOut", minSharesOut);
|
|
6233
|
+
const cpmmProgram = input.cpmmProgram ?? CPMM_PROGRAM_ID;
|
|
6234
|
+
const cpmmMigratorProgram = input.cpmmMigratorProgram ?? CPMM_MIGRATOR_PROGRAM_ID;
|
|
6235
|
+
const accounts = await deriveSpotPoolAccounts({
|
|
6236
|
+
...input,
|
|
6237
|
+
liquidityOwner: addressOf(liquidityOwner),
|
|
6238
|
+
cpmmProgram,
|
|
6239
|
+
cpmmMigratorProgram,
|
|
6240
|
+
positionId
|
|
6241
|
+
});
|
|
6242
|
+
const token0IsA = accounts.token0Mint === input.tokenAMint;
|
|
6243
|
+
return {
|
|
6244
|
+
programAddress: cpmmMigratorProgram,
|
|
6245
|
+
accounts: [
|
|
6246
|
+
{ address: accounts.cpmmConfig, role: AccountRole.READONLY },
|
|
6247
|
+
accountMeta(payer, AccountRole.WRITABLE_SIGNER),
|
|
6248
|
+
accountMeta(liquidityOwner, AccountRole.READONLY_SIGNER),
|
|
6249
|
+
{ address: accounts.token0Mint, role: AccountRole.READONLY },
|
|
6250
|
+
{ address: accounts.token1Mint, role: AccountRole.READONLY },
|
|
6251
|
+
{ address: accounts.pool, role: AccountRole.WRITABLE },
|
|
6252
|
+
{ address: accounts.poolAuthority, role: AccountRole.READONLY },
|
|
6253
|
+
{ address: accounts.poolVault0, role: AccountRole.WRITABLE },
|
|
6254
|
+
{ address: accounts.poolVault1, role: AccountRole.WRITABLE },
|
|
6255
|
+
{ address: accounts.protocolFeeOwner, role: AccountRole.READONLY },
|
|
6256
|
+
{ address: accounts.protocolFeePosition, role: AccountRole.WRITABLE },
|
|
6257
|
+
{ address: accounts.position, role: AccountRole.WRITABLE },
|
|
6258
|
+
{ address: accounts.user0, role: AccountRole.WRITABLE },
|
|
6259
|
+
{ address: accounts.user1, role: AccountRole.WRITABLE },
|
|
6260
|
+
{ address: cpmmProgram, role: AccountRole.READONLY },
|
|
6261
|
+
{ address: accounts.migrationAuthority, role: AccountRole.READONLY },
|
|
6262
|
+
{ address: accounts.token0Program, role: AccountRole.READONLY },
|
|
6263
|
+
{ address: accounts.token1Program, role: AccountRole.READONLY },
|
|
6264
|
+
{
|
|
6265
|
+
address: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS$1,
|
|
6266
|
+
role: AccountRole.READONLY
|
|
6267
|
+
},
|
|
6268
|
+
{
|
|
6269
|
+
address: input.rent ?? SYSVAR_RENT_ADDRESS,
|
|
6270
|
+
role: AccountRole.READONLY
|
|
6271
|
+
}
|
|
6272
|
+
],
|
|
6273
|
+
data: getCreateSpotPoolInstructionDataEncoder().encode({
|
|
6274
|
+
swapFeeBps: input.swapFeeBps,
|
|
6275
|
+
positionId,
|
|
6276
|
+
amount0Max: token0IsA ? input.tokenAAmount : input.tokenBAmount,
|
|
6277
|
+
amount1Max: token0IsA ? input.tokenBAmount : input.tokenAAmount,
|
|
6278
|
+
minSharesOut
|
|
6279
|
+
})
|
|
6280
|
+
};
|
|
6281
|
+
}
|
|
6760
6282
|
|
|
6761
6283
|
// src/solana/migrators/cpmmMigrator/client.ts
|
|
6762
|
-
async function fetchCpmmMigratorState(rpc,
|
|
6763
|
-
const response = await rpc.getAccountInfo(
|
|
6284
|
+
async function fetchCpmmMigratorState(rpc, address6) {
|
|
6285
|
+
const response = await rpc.getAccountInfo(address6, { encoding: "base64" }).send();
|
|
6764
6286
|
if (!response.value) return null;
|
|
6765
6287
|
return getCpmmMigratorStateDecoder().decode(
|
|
6766
6288
|
base64ToBytes(response.value.data[0])
|
|
@@ -6823,8 +6345,8 @@ async function buildCpmmMigrationRemainingAccounts({
|
|
|
6823
6345
|
{ address: migrationAuthority, role: AccountRole.READONLY },
|
|
6824
6346
|
{ address: adminBaseAta, role: AccountRole.WRITABLE },
|
|
6825
6347
|
{ address: adminQuoteAta, role: AccountRole.WRITABLE },
|
|
6826
|
-
...recipientAtas.map((
|
|
6827
|
-
address:
|
|
6348
|
+
...recipientAtas.map((address6) => ({
|
|
6349
|
+
address: address6,
|
|
6828
6350
|
role: AccountRole.WRITABLE
|
|
6829
6351
|
}))
|
|
6830
6352
|
],
|
|
@@ -6848,8 +6370,24 @@ async function buildCpmmMigrationRemainingAccountsHash(input) {
|
|
|
6848
6370
|
}
|
|
6849
6371
|
|
|
6850
6372
|
// src/solana/migrators/cpmmMigrator/index.ts
|
|
6373
|
+
function encodeCreateSpotPoolPayload(args) {
|
|
6374
|
+
assertSafeInteger("positionId", args.positionId);
|
|
6375
|
+
assertSafeInteger("amount0Max", args.amount0Max);
|
|
6376
|
+
assertSafeInteger("amount1Max", args.amount1Max);
|
|
6377
|
+
assertSafeInteger("minSharesOut", args.minSharesOut);
|
|
6378
|
+
const encoded = new Uint8Array(getCreateSpotPoolArgsEncoder().encode(args));
|
|
6379
|
+
return mergeBytes([
|
|
6380
|
+
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.createSpotPool,
|
|
6381
|
+
encoded
|
|
6382
|
+
]);
|
|
6383
|
+
}
|
|
6851
6384
|
function encodeRegisterLaunchPayload(args) {
|
|
6852
|
-
const encoded = new Uint8Array(
|
|
6385
|
+
const encoded = new Uint8Array(
|
|
6386
|
+
getRegisterLaunchArgsEncoder().encode({
|
|
6387
|
+
...args,
|
|
6388
|
+
migratedPoolHookConfig: args.migratedPoolHookConfig ?? null
|
|
6389
|
+
})
|
|
6390
|
+
);
|
|
6853
6391
|
return mergeBytes([
|
|
6854
6392
|
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.registerLaunch,
|
|
6855
6393
|
encoded
|
|
@@ -6912,67 +6450,18 @@ function hashRemainingAccounts(accounts) {
|
|
|
6912
6450
|
function isCustomMigrationConfig(migration) {
|
|
6913
6451
|
return migration.kind === "custom";
|
|
6914
6452
|
}
|
|
6915
|
-
function getCreateLaunchHookMode(input) {
|
|
6916
|
-
if (input.hook !== void 0 && input.hook !== null) {
|
|
6917
|
-
return input.hook;
|
|
6918
|
-
}
|
|
6919
|
-
if (input.dynamicFee) {
|
|
6920
|
-
return "dynamicFee";
|
|
6921
|
-
}
|
|
6922
|
-
return input.cosigner ? "cosigner" : "cpmm";
|
|
6923
|
-
}
|
|
6924
6453
|
async function getCreateLaunchHookContext(input) {
|
|
6925
|
-
const
|
|
6926
|
-
if (input.
|
|
6927
|
-
throw new Error(
|
|
6928
|
-
'dynamicFee requires hook to be unset or set to "dynamicFee"'
|
|
6929
|
-
);
|
|
6930
|
-
}
|
|
6931
|
-
if (mode !== "cosigner" && mode !== "dynamicFee") {
|
|
6932
|
-
return { mode };
|
|
6933
|
-
}
|
|
6934
|
-
if (mode === "dynamicFee") {
|
|
6935
|
-
if (!input.dynamicFee && !input.cosigner) {
|
|
6936
|
-
throw new Error(
|
|
6937
|
-
"dynamicFee hook mode requires dynamicFee or cosigner input"
|
|
6938
|
-
);
|
|
6939
|
-
}
|
|
6940
|
-
if (!input.cosigner) {
|
|
6941
|
-
return { mode };
|
|
6942
|
-
}
|
|
6943
|
-
const [dynamicFeeConfig] = await getDynamicFeeHookConfigAddress(
|
|
6944
|
-
input.deployment?.dynamicFeeHookProgram ?? DYNAMIC_FEE_HOOK_PROGRAM_ID
|
|
6945
|
-
);
|
|
6946
|
-
return { mode, dynamicFeeConfig };
|
|
6947
|
-
}
|
|
6948
|
-
const [cosignerConfig] = await getCosignerHookConfigAddress(
|
|
6949
|
-
input.deployment?.cosignerHookProgram ?? DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID
|
|
6950
|
-
);
|
|
6951
|
-
return { mode, cosignerConfig };
|
|
6952
|
-
}
|
|
6953
|
-
function getCosignerHookRemainingAccounts2({
|
|
6954
|
-
namespace,
|
|
6955
|
-
cosigner,
|
|
6956
|
-
cosignerConfig
|
|
6957
|
-
}) {
|
|
6958
|
-
const accounts = namespace === cosignerConfig ? [cosignerConfig] : [namespace, cosignerConfig];
|
|
6959
|
-
accounts.push(cosigner);
|
|
6960
|
-
return accounts;
|
|
6961
|
-
}
|
|
6962
|
-
function resolveCosignerHookPayload(input) {
|
|
6963
|
-
if (input.cosignGateExpiresAt === void 0 || input.cosignGateExpiresAt === null) {
|
|
6964
|
-
return new Uint8Array();
|
|
6454
|
+
const program = input.deployment?.cpmmHookProgram ?? CPMM_HOOK_PROGRAM_ID;
|
|
6455
|
+
if (input.cosignGateExpiresAt != null && !input.cosigner) {
|
|
6456
|
+
throw new Error("cosigner is required when cosignGateExpiresAt is set");
|
|
6965
6457
|
}
|
|
6966
6458
|
if (!input.cosigner) {
|
|
6967
|
-
|
|
6459
|
+
return { program };
|
|
6968
6460
|
}
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
value: input.cosignGateExpiresAt,
|
|
6972
|
-
cosigner: getSignerAddress(input.cosigner)
|
|
6973
|
-
});
|
|
6461
|
+
const [config] = await getCpmmHookConfigAddress(program);
|
|
6462
|
+
return { program, config };
|
|
6974
6463
|
}
|
|
6975
|
-
function
|
|
6464
|
+
function resolveCpmmHookPayload(input) {
|
|
6976
6465
|
let gateExpiry = null;
|
|
6977
6466
|
if (input.cosignGateExpiresAt !== void 0 && input.cosignGateExpiresAt !== null) {
|
|
6978
6467
|
if (!input.cosigner) {
|
|
@@ -6984,7 +6473,7 @@ function resolveDynamicFeeHookPayload(input) {
|
|
|
6984
6473
|
cosigner: getSignerAddress(input.cosigner)
|
|
6985
6474
|
};
|
|
6986
6475
|
}
|
|
6987
|
-
return
|
|
6476
|
+
return encodeCpmmHookPayload({
|
|
6988
6477
|
schedule: input.dynamicFee ?? null,
|
|
6989
6478
|
gateExpiry
|
|
6990
6479
|
});
|
|
@@ -6994,59 +6483,18 @@ function resolveCreateLaunchHook({
|
|
|
6994
6483
|
namespace,
|
|
6995
6484
|
hookContext
|
|
6996
6485
|
}) {
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
if (!input.cosigner) {
|
|
7005
|
-
throw new Error('cosigner is required when hook is "cosigner"');
|
|
7006
|
-
}
|
|
7007
|
-
if (!hookContext.cosignerConfig) {
|
|
7008
|
-
throw new Error("cosigner hook config could not be derived");
|
|
7009
|
-
}
|
|
7010
|
-
const remainingAccounts = getCosignerHookRemainingAccounts2({
|
|
7011
|
-
namespace,
|
|
7012
|
-
cosigner: input.cosigner,
|
|
7013
|
-
cosignerConfig: hookContext.cosignerConfig
|
|
7014
|
-
});
|
|
7015
|
-
return {
|
|
7016
|
-
program: input.deployment?.cosignerHookProgram ?? DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID,
|
|
7017
|
-
flags: HF_BEFORE_SWAP2 | HF_FORWARD_READONLY_SIGNERS2,
|
|
7018
|
-
payload: resolveCosignerHookPayload(input),
|
|
7019
|
-
remainingAccounts,
|
|
7020
|
-
remainingAccountsHash: hashRemainingAccounts(remainingAccounts) ?? EMPTY_REMAINING_ACCOUNTS_HASH
|
|
7021
|
-
};
|
|
7022
|
-
}
|
|
7023
|
-
if (hookContext.mode === "dynamicFee") {
|
|
7024
|
-
const hasCosigner = Boolean(input.cosigner);
|
|
7025
|
-
const hasSchedule = Boolean(input.dynamicFee);
|
|
7026
|
-
if (input.cosignGateExpiresAt !== void 0 && input.cosignGateExpiresAt !== null && !input.cosigner) {
|
|
7027
|
-
throw new Error("cosigner is required when cosignGateExpiresAt is set");
|
|
7028
|
-
}
|
|
7029
|
-
if (hasCosigner && !hookContext.dynamicFeeConfig) {
|
|
7030
|
-
throw new Error("dynamic fee hook config could not be derived");
|
|
7031
|
-
}
|
|
7032
|
-
const remainingAccounts = getDynamicFeeHookRemainingAccounts({
|
|
7033
|
-
namespace,
|
|
7034
|
-
config: hookContext.dynamicFeeConfig,
|
|
7035
|
-
cosigner: input.cosigner
|
|
7036
|
-
});
|
|
7037
|
-
return {
|
|
7038
|
-
program: input.deployment?.dynamicFeeHookProgram ?? DYNAMIC_FEE_HOOK_PROGRAM_ID,
|
|
7039
|
-
flags: HF_BEFORE_SWAP2 | (hasSchedule ? HF_BEFORE_CREATE : 0) | (hasCosigner ? HF_FORWARD_READONLY_SIGNERS2 : 0),
|
|
7040
|
-
payload: resolveDynamicFeeHookPayload(input),
|
|
7041
|
-
remainingAccounts: remainingAccounts.signedHookRemainingAccounts,
|
|
7042
|
-
remainingAccountsHash: remainingAccounts.hookRemainingAccountsHash
|
|
7043
|
-
};
|
|
7044
|
-
}
|
|
6486
|
+
const hasCosigner = Boolean(input.cosigner);
|
|
6487
|
+
const hasSchedule = Boolean(input.dynamicFee);
|
|
6488
|
+
const remainingAccounts = getCpmmHookRemainingAccounts({
|
|
6489
|
+
namespace,
|
|
6490
|
+
config: hookContext.config,
|
|
6491
|
+
cosigner: input.cosigner
|
|
6492
|
+
});
|
|
7045
6493
|
return {
|
|
7046
|
-
program:
|
|
7047
|
-
flags: HF_BEFORE_SWAP2,
|
|
7048
|
-
payload:
|
|
7049
|
-
remainingAccountsHash:
|
|
6494
|
+
program: hookContext.program,
|
|
6495
|
+
flags: HF_BEFORE_SWAP2 | (hasSchedule ? HF_BEFORE_CREATE : 0) | (hasCosigner ? HF_FORWARD_READONLY_SIGNERS2 : 0),
|
|
6496
|
+
payload: resolveCpmmHookPayload(input),
|
|
6497
|
+
remainingAccountsHash: remainingAccounts.hookRemainingAccountsHash
|
|
7050
6498
|
};
|
|
7051
6499
|
}
|
|
7052
6500
|
async function getAssociatedTokenAddress({
|
|
@@ -7184,7 +6632,7 @@ async function createLaunch(input) {
|
|
|
7184
6632
|
const programId = getInitializerProgramId(input);
|
|
7185
6633
|
const launchId = input.launchId ?? createLaunchId();
|
|
7186
6634
|
const hookContext = await getCreateLaunchHookContext(input);
|
|
7187
|
-
const namespace = input.namespace ??
|
|
6635
|
+
const namespace = input.namespace ?? SYSTEM_PROGRAM_ADDRESS;
|
|
7188
6636
|
const tokenPrograms = {
|
|
7189
6637
|
...launchTokenPrograms.splToken(),
|
|
7190
6638
|
...input.tokenPrograms
|
|
@@ -7231,7 +6679,7 @@ async function createLaunch(input) {
|
|
|
7231
6679
|
baseTokenProgram: tokenPrograms.baseTokenProgram,
|
|
7232
6680
|
quoteTokenProgram: tokenPrograms.quoteTokenProgram,
|
|
7233
6681
|
systemProgram: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS,
|
|
7234
|
-
rent: input.rent ?? SYSVAR_RENT_ADDRESS,
|
|
6682
|
+
rent: input.rent ?? SYSVAR_RENT_ADDRESS$1,
|
|
7235
6683
|
metadataAccount: addresses.metadataAccount,
|
|
7236
6684
|
metadataProgram: input.metadataProgram ?? TOKEN_METADATA_PROGRAM_ID
|
|
7237
6685
|
},
|
|
@@ -7250,7 +6698,7 @@ async function createLaunch(input) {
|
|
|
7250
6698
|
allowBuy: input.allowBuy ?? true,
|
|
7251
6699
|
allowSell: input.allowSell ?? true,
|
|
7252
6700
|
hookFlags: hook.flags,
|
|
7253
|
-
hookPayload: hook.payload
|
|
6701
|
+
hookPayload: hook.payload,
|
|
7254
6702
|
migratorInitPayload: migration?.initPayload ?? new Uint8Array(),
|
|
7255
6703
|
migratorMigratePayload: migration?.migratePayload ?? new Uint8Array(),
|
|
7256
6704
|
hookRemainingAccountsHash: hook.remainingAccountsHash,
|
|
@@ -7384,9 +6832,9 @@ function assertTransactionMessageFitsWithLookupTable(transactionMessage, lookupT
|
|
|
7384
6832
|
);
|
|
7385
6833
|
return assertTransactionMessageFits(compressedMessage, options);
|
|
7386
6834
|
}
|
|
7387
|
-
var
|
|
7388
|
-
async function fetchLaunch2(rpc,
|
|
7389
|
-
const response = await rpc.getAccountInfo(
|
|
6835
|
+
var addressCodec6 = getAddressCodec();
|
|
6836
|
+
async function fetchLaunch2(rpc, address6, config) {
|
|
6837
|
+
const response = await rpc.getAccountInfo(address6, {
|
|
7390
6838
|
encoding: "base64",
|
|
7391
6839
|
commitment: config?.commitment
|
|
7392
6840
|
}).send();
|
|
@@ -7438,7 +6886,7 @@ async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
|
7438
6886
|
const authorityFilter = {
|
|
7439
6887
|
memcmp: {
|
|
7440
6888
|
offset: 8n,
|
|
7441
|
-
bytes: bytesToBase64EncodedBytes(
|
|
6889
|
+
bytes: bytesToBase64EncodedBytes(addressCodec6.encode(authority)),
|
|
7442
6890
|
encoding: "base64"
|
|
7443
6891
|
}
|
|
7444
6892
|
};
|
|
@@ -7573,7 +7021,7 @@ __export(predictionMigrator_exports, {
|
|
|
7573
7021
|
getInitConfigDecoder: () => getInitConfigDecoder2,
|
|
7574
7022
|
getInitConfigDiscriminatorBytes: () => getInitConfigDiscriminatorBytes,
|
|
7575
7023
|
getInitConfigEncoder: () => getInitConfigEncoder2,
|
|
7576
|
-
getInitConfigSize: () =>
|
|
7024
|
+
getInitConfigSize: () => getInitConfigSize2,
|
|
7577
7025
|
getLaunchCodec: () => getLaunchCodec2,
|
|
7578
7026
|
getLaunchDecoder: () => getLaunchDecoder2,
|
|
7579
7027
|
getLaunchDiscriminatorBytes: () => getLaunchDiscriminatorBytes,
|
|
@@ -7791,13 +7239,13 @@ function decodeOracleState3(encodedAccount) {
|
|
|
7791
7239
|
getOracleStateDecoder2()
|
|
7792
7240
|
);
|
|
7793
7241
|
}
|
|
7794
|
-
async function fetchOracleState2(rpc,
|
|
7795
|
-
const maybeAccount = await fetchMaybeOracleState2(rpc,
|
|
7242
|
+
async function fetchOracleState2(rpc, address6, config) {
|
|
7243
|
+
const maybeAccount = await fetchMaybeOracleState2(rpc, address6, config);
|
|
7796
7244
|
assertAccountExists(maybeAccount);
|
|
7797
7245
|
return maybeAccount;
|
|
7798
7246
|
}
|
|
7799
|
-
async function fetchMaybeOracleState2(rpc,
|
|
7800
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
7247
|
+
async function fetchMaybeOracleState2(rpc, address6, config) {
|
|
7248
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address6, config);
|
|
7801
7249
|
return decodeOracleState3(maybeAccount);
|
|
7802
7250
|
}
|
|
7803
7251
|
async function fetchAllOracleState2(rpc, addresses, config) {
|
|
@@ -7881,9 +7329,9 @@ function parseFinalizeInstruction(instruction) {
|
|
|
7881
7329
|
}
|
|
7882
7330
|
let accountIndex = 0;
|
|
7883
7331
|
const getNextAccount = () => {
|
|
7884
|
-
const
|
|
7332
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
7885
7333
|
accountIndex += 1;
|
|
7886
|
-
return
|
|
7334
|
+
return accountMeta2;
|
|
7887
7335
|
};
|
|
7888
7336
|
return {
|
|
7889
7337
|
programAddress: instruction.programAddress,
|
|
@@ -7969,9 +7417,9 @@ function parseInitializeOracleInstruction2(instruction) {
|
|
|
7969
7417
|
}
|
|
7970
7418
|
let accountIndex = 0;
|
|
7971
7419
|
const getNextAccount = () => {
|
|
7972
|
-
const
|
|
7420
|
+
const accountMeta2 = instruction.accounts[accountIndex];
|
|
7973
7421
|
accountIndex += 1;
|
|
7974
|
-
return
|
|
7422
|
+
return accountMeta2;
|
|
7975
7423
|
};
|
|
7976
7424
|
return {
|
|
7977
7425
|
programAddress: instruction.programAddress,
|
|
@@ -8231,7 +7679,7 @@ async function curveSwapExactIn(input) {
|
|
|
8231
7679
|
baseMint: input.baseMint,
|
|
8232
7680
|
quoteMint: input.quoteMint,
|
|
8233
7681
|
user,
|
|
8234
|
-
hookProgram: input.
|
|
7682
|
+
hookProgram: input.deployment?.cpmmHookProgram ?? CPMM_HOOK_PROGRAM_ID,
|
|
8235
7683
|
baseTokenProgram,
|
|
8236
7684
|
quoteTokenProgram,
|
|
8237
7685
|
remainingAccounts: input.remainingAccounts ? [...input.remainingAccounts] : void 0
|
|
@@ -8394,7 +7842,7 @@ function migrateLaunch(input) {
|
|
|
8394
7842
|
baseTokenProgram,
|
|
8395
7843
|
quoteTokenProgram,
|
|
8396
7844
|
systemProgram: input.systemProgram ?? SYSTEM_PROGRAM_ADDRESS,
|
|
8397
|
-
rent: input.rent ?? SYSVAR_RENT_ADDRESS
|
|
7845
|
+
rent: input.rent ?? SYSVAR_RENT_ADDRESS$1
|
|
8398
7846
|
},
|
|
8399
7847
|
input.programId ?? input.deployment?.initializerProgram ?? INITIALIZER_PROGRAM_ID
|
|
8400
7848
|
);
|
|
@@ -8464,9 +7912,7 @@ var DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES = {
|
|
|
8464
7912
|
cpmmProgram: CPMM_PROGRAM_ID,
|
|
8465
7913
|
initializerProgram: INITIALIZER_PROGRAM_ID,
|
|
8466
7914
|
cpmmMigratorProgram: CPMM_MIGRATOR_PROGRAM_ID,
|
|
8467
|
-
cpmmHookProgram: CPMM_HOOK_PROGRAM_ID
|
|
8468
|
-
cosignerHookProgram: DOPPLER_NATIVE_COSIGNER_HOOK_PROGRAM_ID,
|
|
8469
|
-
dynamicFeeHookProgram: DYNAMIC_FEE_HOOK_PROGRAM_ID
|
|
7915
|
+
cpmmHookProgram: CPMM_HOOK_PROGRAM_ID
|
|
8470
7916
|
};
|
|
8471
7917
|
async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES) {
|
|
8472
7918
|
const [cpmmConfig] = await getConfigAddress(programs.cpmmProgram);
|
|
@@ -8480,6 +7926,6 @@ async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGR
|
|
|
8480
7926
|
};
|
|
8481
7927
|
}
|
|
8482
7928
|
|
|
8483
|
-
export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES, assertMigrationQuoteThreshold,
|
|
7929
|
+
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 };
|
|
8484
7930
|
//# sourceMappingURL=index.js.map
|
|
8485
7931
|
//# sourceMappingURL=index.js.map
|