sol-parser-sdk 0.5.14 → 0.5.16
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/NATIVE_ALIGNMENT.md +312 -0
- package/NATIVE_DAMM_FACTORY_ALIGNMENT_20261004.md +16 -0
- package/NATIVE_DAMM_FACTORY_EVIDENCE_20261004.json +55 -0
- package/NATIVE_MIGRATION.md +38 -0
- package/NATIVE_PUMPFUN_NATIVE_DEBIT_ALIGNMENT_20261004.md +18 -0
- package/NATIVE_PUMPFUN_NATIVE_DEBIT_EVIDENCE_20261004.json +57 -0
- package/NATIVE_PUMPFUN_SETTLEMENT_ALIGNMENT_20261004.md +11 -0
- package/NATIVE_PUMPFUN_SETTLEMENT_EVIDENCE_20261004.json +70 -0
- package/README.md +24 -1
- package/README_CN.md +21 -1
- package/dist/accounts/mod.js +7 -0
- package/dist/accounts/pumpfun.js +17 -0
- package/dist/accounts/pumpswap.js +18 -3
- package/dist/core/account_dispatcher_rpc.js +24 -4
- package/dist/core/account_fill_meteora.d.ts +1 -1
- package/dist/core/account_fill_meteora.js +12 -1
- package/dist/core/account_fill_raydium.js +12 -2
- package/dist/core/account_fill_raydium_launchlab.js +54 -0
- package/dist/core/clock.js +1 -1
- package/dist/core/common_filler_rpc.d.ts +2 -2
- package/dist/core/common_filler_rpc.js +66 -0
- package/dist/core/dex_event.d.ts +157 -0
- package/dist/core/metadata.d.ts +9 -5
- package/dist/core/metadata.js +28 -4
- package/dist/core/unified_parser.d.ts +7 -7
- package/dist/grpc/block_meta.d.ts +9 -0
- package/dist/grpc/block_meta.js +26 -0
- package/dist/grpc/client.d.ts +24 -9
- package/dist/grpc/client.js +129 -67
- package/dist/grpc/geyser_connect.d.ts +3 -3
- package/dist/grpc/geyser_connect.js +13 -15
- package/dist/grpc/log_instr_dedup.js +6 -0
- package/dist/grpc/native_client.d.ts +26 -0
- package/dist/grpc/native_client.js +101 -0
- package/dist/grpc/order_buffer.d.ts +1 -1
- package/dist/grpc/order_buffer.js +10 -9
- package/dist/grpc/program_ids.js +2 -0
- package/dist/grpc/protocol/LICENSE +202 -0
- package/dist/grpc/protocol/NOTICE +4 -0
- package/dist/grpc/protocol/geyser.d.ts +342 -0
- package/dist/grpc/protocol/geyser.js +37 -0
- package/dist/grpc/protocol/geyser.proto +326 -0
- package/dist/grpc/protocol/solana-storage.d.ts +139 -0
- package/dist/grpc/protocol/solana-storage.js +14 -0
- package/dist/grpc/protocol/solana-storage.proto +151 -0
- package/dist/grpc/rpc_to_grpc.d.ts +1 -1
- package/dist/grpc/subscribe_builder.d.ts +5 -3
- package/dist/grpc/subscribe_builder.js +11 -3
- package/dist/grpc/transaction_meta.d.ts +1 -1
- package/dist/grpc/types.d.ts +8 -8
- package/dist/grpc/types.js +15 -2
- package/dist/grpc/yellowstone_parse.d.ts +3 -3
- package/dist/grpc/yellowstone_parse.js +6 -8
- package/dist/grpc/yellowstone_transaction_adapter.d.ts +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +23 -5
- package/dist/instr/inner.d.ts +2 -2
- package/dist/instr/inner.js +1 -1
- package/dist/instr/meteora_damm_ix.d.ts +1 -1
- package/dist/instr/meteora_damm_ix.js +41 -79
- package/dist/instr/meteora_dlmm_ix.d.ts +1 -1
- package/dist/instr/meteora_dlmm_ix.js +10 -0
- package/dist/instr/meteora_pools_ix.d.ts +1 -1
- package/dist/instr/mod.d.ts +1 -1
- package/dist/instr/orca_whirlpool_ix.d.ts +1 -1
- package/dist/instr/pump_fees_ix.d.ts +1 -1
- package/dist/instr/pumpfun_ix.d.ts +1 -1
- package/dist/instr/pumpfun_ix.js +16 -0
- package/dist/instr/pumpswap_ix.d.ts +1 -1
- package/dist/instr/pumpswap_ix.js +13 -5
- package/dist/instr/raydium_amm_v4_ix.d.ts +1 -1
- package/dist/instr/raydium_amm_v4_ix.js +9 -5
- package/dist/instr/raydium_clmm_ix.d.ts +1 -1
- package/dist/instr/raydium_cpmm_ix.d.ts +1 -1
- package/dist/instr/raydium_launchlab_ix.d.ts +1 -1
- package/dist/instr/raydium_launchlab_ix.js +62 -2
- package/dist/instr/utils.d.ts +2 -2
- package/dist/instr/utils.js +2 -7
- package/dist/liquidity_snapshot.d.ts +54 -0
- package/dist/liquidity_snapshot.js +85 -0
- package/dist/logs/meteora_damm.d.ts +17 -1
- package/dist/logs/meteora_damm.js +386 -12
- package/dist/logs/meteora_dlmm.d.ts +1 -1
- package/dist/logs/meteora_dlmm.js +10 -0
- package/dist/logs/optimized_matcher.d.ts +3 -3
- package/dist/logs/optimized_matcher.js +35 -1
- package/dist/logs/program_log_discriminators.d.ts +5 -0
- package/dist/logs/program_log_discriminators.js +5 -0
- package/dist/logs/pump.js +10 -0
- package/dist/logs/pump_amm.js +22 -1
- package/dist/logs/raydium_launchlab.js +19 -1
- package/dist/rpc_transaction.d.ts +4 -3
- package/dist/rpc_transaction.js +3 -2
- package/dist/shredstream/client.js +3 -7
- package/dist/shredstream/entries_decode.js +9 -85
- package/dist/shredstream/instruction_parse.d.ts +3 -3
- package/dist/shredstream/proto_types.d.ts +1 -1
- package/dist/shredstream/wire_to_shred_tx.d.ts +1 -1
- package/dist/shredstream/wire_to_shred_tx.js +9 -44
- package/dist/simulation_route.d.ts +6 -0
- package/dist/simulation_route.js +242 -0
- package/dist/stonkfun_registry.d.ts +30 -0
- package/dist/stonkfun_registry.js +137 -0
- package/dist/transaction_route.d.ts +84 -0
- package/dist/transaction_route.js +477 -0
- package/dist/wire_transaction.d.ts +35 -0
- package/dist/wire_transaction.js +191 -0
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -32,12 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
40
|
-
exports.high_throughput_shred_stream_config = exports.low_latency_shred_stream_config = exports.default_shred_stream_config = exports.highThroughputShredStreamConfig = exports.lowLatencyShredStreamConfig = exports.defaultShredStreamConfig = exports.wireBytesToShredWasmTx = exports.decodeShredstreamEntriesBincode = exports.decodeEntriesBincodeNested = exports.decodeEntriesBincodeFlat = exports.bincodeVecEntryCount = exports.loadAddressLookupTableAccounts = exports.fullAccountKeyStringsFromShredTx = exports.dexEventsFromShredWasmTxWithFullKeys = exports.dexEventsFromShredWasmTx = exports.ShredEventQueue = exports.ShredStreamClient = void 0;
|
|
39
|
+
exports.pubkeyBytesToBs58 = exports.grpcTxIndexFromInfo = exports.parseDexEventsFromGrpcTransactionInfo = exports.convert_rpc_to_grpc = exports.convertRpcToGrpc = exports.applyAccountFillsToLogEvents = exports.fillDataRpc = exports.fillAccountsFromTransactionDataRpc = exports.parseRpcTransaction = exports.parseTransactionFromRpc = exports.isWarmedUp = exports.warmupParser = exports.build_account_pubkeys_with_cache = exports.buildAccountPubkeysWithCache = exports.AccountPubkeyCache = exports.normalizeBuySellFromInputMint = exports.normalizeBuySellFromTokenDelta = exports.vaultPriceFromBalances = exports.sqrtPriceX64ToPrice = exports.elapsedMicrosSince = exports.nowNanos = exports.nowMicros = exports.nowUs = exports.parse_log = exports.parseLog = exports.parseTransactionWithStreamingListener = exports.parseLogsStreaming = exports.parseTransactionEventsStreaming = exports.parseTransactionWithListener = exports.parseLogsOnly = exports.parseTransactionEvents = exports.enrichPumpfunSameTxPostMerge = exports.enrichPumpfunTradesFromCreateInstructions = exports.enrichCreateV2ObservedFeeRecipient = exports.enrichCreateV2FromCreateEvents = exports.formatParseError = exports.exactI64 = exports.exactU64 = exports.exactInteger = exports.dexEventToJsonString = exports.bigintToJsonReplacer = exports.defaultPubkey = exports.metadataForDexEvent = exports.SLOW_PROCESSING_THRESHOLD_US = exports.DEFAULT_REQUEST_TIMEOUT = exports.DEFAULT_METRICS_WINDOW_SECONDS = exports.DEFAULT_METRICS_PRINT_INTERVAL_SECONDS = exports.DEFAULT_MAX_DECODING_MESSAGE_SIZE = exports.DEFAULT_CONNECT_TIMEOUT = exports.DEFAULT_CHANNEL_SIZE = void 0;
|
|
40
|
+
exports.RAYDIUM_CPMM_PROGRAM_ID = exports.RAYDIUM_LAUNCHLAB_PROGRAM_ID = exports.PUMP_FEES_PROGRAM_ID = exports.PUMPSWAP_FEES_PROGRAM_ID = exports.PUMPSWAP_PROGRAM_ID = exports.PUMPFUN_PROGRAM_ID = exports.PROTOCOL_PROGRAM_IDS = exports.all_event_types = exports.ALL_EVENT_TYPES = exports.eventTypeFilterAllowsInstructionParsing = exports.eventTypeFilterIncludesPumpFees = exports.eventTypeFilterIncludesRaydiumLaunchlab = exports.eventTypeFilterIncludesOrcaWhirlpool = exports.eventTypeFilterIncludesRaydiumAmmV4 = exports.eventTypeFilterIncludesRaydiumCpmm = exports.eventTypeFilterIncludesRaydiumClmm = exports.eventTypeFilterIncludesMeteoraDlmm = exports.eventTypeFilterIncludesMeteoraPools = exports.eventTypeFilterIncludesMeteoraDbc = exports.eventTypeFilterIncludesMeteoraDammV2 = exports.eventTypeFilterIncludesPumpswap = exports.eventTypeFilterIncludesPumpfun = exports.eventTypeFilterExclude = exports.eventTypeFilterIncludeOnly = exports.accountFilterMemcmp = exports.accountFilterFromProgramOwners = exports.slotFilterMaxSlot = exports.slotFilterMinSlot = exports.newSlotFilter = exports.newAccountFilter = exports.transactionFilterFromProgramIds = exports.newTransactionFilter = exports.highThroughputClientConfig = exports.lowLatencyClientConfig = exports.defaultClientConfig = exports.try_yellowstone_signature = exports.collect_watch_transfer_counterparty_pairs = exports.spl_token_counterparty_by_owner = exports.token_balance_raw_amount = exports.heuristic_sol_counterparties_for_watched_keys = exports.lamport_balance_deltas = exports.collect_account_keys_bs58 = exports.pubkey_bytes_to_bs58 = exports.tryYellowstoneSignature = exports.collectWatchTransferCounterpartyPairs = exports.splTokenCounterpartyByOwner = exports.tokenBalanceRawAmount = exports.heuristicSolCounterpartiesForWatchedKeys = exports.lamportBalanceDeltas = exports.collectAccountKeysBs58 = void 0;
|
|
41
|
+
exports.discriminatorToProtocol = exports.discriminator_to_name = exports.discriminatorToName = exports.parse_log_unified = exports.parse_log_optimized = exports.parse_meteora_dlmm_log = exports.parse_meteora_damm_log = exports.parseProgramCompleteInfo = exports.parseLogUnified = exports.parseLogOptimizedWithProgramId = exports.parseLogOptimized = exports.parseInvokeInfo = exports.build_subscribe_transaction_filters_named = exports.build_subscribe_request_with_commitment = exports.build_subscribe_request = exports.CommitmentLevel = exports.buildSubscribeTransactionFiltersNamed = exports.buildSubscribeRequestWithCommitment = exports.buildSubscribeRequest = exports.exclude_types = exports.include_only = exports.event_type_filter_exclude = exports.event_type_filter_include_only = exports.account_filter_memcmp = exports.account_filter_from_program_owners = exports.slot_filter_max_slot = exports.slot_filter_min_slot = exports.new_slot_filter = exports.new_account_filter = exports.transaction_filter_from_program_ids = exports.new_transaction_filter = exports.high_throughput_client_config = exports.low_latency_client_config = exports.default_client_config = exports.account_filter_for_protocols = exports.transaction_filter_for_protocol_accounts = exports.transaction_filter_for_protocols = exports.get_program_ids_for_protocols = exports.protocol_program_ids = exports.accountFilterForProtocols = exports.transactionFilterForProtocolAccounts = exports.transactionFilterForProtocols = exports.getProgramIdsForProtocols = exports.METEORA_DBC_PROGRAM_ID = exports.METEORA_DLMM_PROGRAM_ID = exports.METEORA_DAMM_V2_PROGRAM_ID = exports.METEORA_POOLS_PROGRAM_ID = exports.ORCA_WHIRLPOOL_PROGRAM_ID = exports.RAYDIUM_AMM_V4_PROGRAM_ID = exports.RAYDIUM_CLMM_PROGRAM_ID = void 0;
|
|
42
|
+
exports.event_parser = exports.geyserGrpcChannelOptions = exports.defaultGeyserConnectConfig = exports.connectYellowstoneGeyser = exports.YellowstoneGrpc = exports.programIds = exports.parse_pump_fees_instruction = exports.parse_meteora_pools_instruction = exports.parse_meteora_dlmm_instruction = exports.parse_meteora_damm_instruction = exports.parse_pumpswap_instruction = exports.parse_pumpfun_instruction = exports.parse_instruction_unified = exports.parsePumpFeesInstruction = exports.parseMeteoraPoolsInstruction = exports.parseMeteoraDlmmInstruction = exports.parseMeteoraDammInstruction = exports.parsePumpswapInstruction = exports.parsePumpfunInstruction = exports.parseInstructionUnified = exports.user_wallet_pubkey_for_onchain_account = exports.rpc_resolve_user_wallet_pubkey = exports.parse_pumpswap_pool = exports.parse_pumpswap_global_config = exports.parse_pumpfun_global = exports.parse_token_account = exports.parse_nonce_account = exports.parse_account_unified = exports.rpcResolveUserWalletPubkey = exports.userWalletPubkeyForOnchainAccount = exports.hasDiscriminator = exports.isPoolAccount = exports.isGlobalConfigAccount = exports.parsePumpswapAccount = exports.parsePumpswapPool = exports.parsePumpswapGlobalConfig = exports.isPumpfunGlobalAccount = exports.parsePumpfunAccount = exports.parsePumpfunGlobal = exports.parseTokenAccount = exports.isNonceAccount = exports.parseNonceAccount = exports.parseAccountUnified = exports.u64leDiscriminator = exports.PUMPSWAP_DISC = exports.PROGRAM_LOG_DISC = exports.parseMeteoraDammLog = exports.lookup_discriminator = exports.lookupDiscriminator = exports.discriminator_to_protocol = void 0;
|
|
43
|
+
exports.buildSubscribeRequestWithEventFilter = exports.parseBlockMetaUpdate = exports.analyzeSimulationRoutes = exports.decodeWireTransaction = exports.high_throughput_shred_stream_config = exports.low_latency_shred_stream_config = exports.default_shred_stream_config = exports.highThroughputShredStreamConfig = exports.lowLatencyShredStreamConfig = exports.defaultShredStreamConfig = exports.wireBytesToShredWasmTx = exports.decodeShredstreamEntriesBincode = exports.decodeEntriesBincodeNested = exports.decodeEntriesBincodeFlat = exports.bincodeVecEntryCount = exports.loadAddressLookupTableAccounts = exports.fullAccountKeyStringsFromShredTx = exports.dexEventsFromShredWasmTxWithFullKeys = exports.dexEventsFromShredWasmTx = exports.ShredEventQueue = exports.ShredStreamClient = exports.geyser_grpc_channel_options = exports.default_geyser_connect_config = exports.connect_yellowstone_geyser = void 0;
|
|
41
44
|
var constants_js_1 = require("./common/constants.js");
|
|
42
45
|
Object.defineProperty(exports, "DEFAULT_CHANNEL_SIZE", { enumerable: true, get: function () { return constants_js_1.DEFAULT_CHANNEL_SIZE; } });
|
|
43
46
|
Object.defineProperty(exports, "DEFAULT_CONNECT_TIMEOUT", { enumerable: true, get: function () { return constants_js_1.DEFAULT_CONNECT_TIMEOUT; } });
|
|
@@ -52,6 +55,10 @@ Object.defineProperty(exports, "defaultPubkey", { enumerable: true, get: functio
|
|
|
52
55
|
var json_utils_js_1 = require("./core/json_utils.js");
|
|
53
56
|
Object.defineProperty(exports, "bigintToJsonReplacer", { enumerable: true, get: function () { return json_utils_js_1.bigintToJsonReplacer; } });
|
|
54
57
|
Object.defineProperty(exports, "dexEventToJsonString", { enumerable: true, get: function () { return json_utils_js_1.dexEventToJsonString; } });
|
|
58
|
+
var metadata_js_1 = require("./core/metadata.js");
|
|
59
|
+
Object.defineProperty(exports, "exactInteger", { enumerable: true, get: function () { return metadata_js_1.exactInteger; } });
|
|
60
|
+
Object.defineProperty(exports, "exactU64", { enumerable: true, get: function () { return metadata_js_1.exactU64; } });
|
|
61
|
+
Object.defineProperty(exports, "exactI64", { enumerable: true, get: function () { return metadata_js_1.exactI64; } });
|
|
55
62
|
var error_js_1 = require("./core/error.js");
|
|
56
63
|
Object.defineProperty(exports, "formatParseError", { enumerable: true, get: function () { return error_js_1.formatParseError; } });
|
|
57
64
|
var pumpfun_fee_enrich_js_1 = require("./core/pumpfun_fee_enrich.js");
|
|
@@ -298,3 +305,14 @@ var index_js_2 = require("./shredstream/index.js");
|
|
|
298
305
|
Object.defineProperty(exports, "default_shred_stream_config", { enumerable: true, get: function () { return index_js_2.defaultShredStreamConfig; } });
|
|
299
306
|
Object.defineProperty(exports, "low_latency_shred_stream_config", { enumerable: true, get: function () { return index_js_2.lowLatencyShredStreamConfig; } });
|
|
300
307
|
Object.defineProperty(exports, "high_throughput_shred_stream_config", { enumerable: true, get: function () { return index_js_2.highThroughputShredStreamConfig; } });
|
|
308
|
+
var wire_transaction_js_1 = require("./wire_transaction.js");
|
|
309
|
+
Object.defineProperty(exports, "decodeWireTransaction", { enumerable: true, get: function () { return wire_transaction_js_1.decodeWireTransaction; } });
|
|
310
|
+
__exportStar(require("./transaction_route.js"), exports);
|
|
311
|
+
__exportStar(require("./stonkfun_registry.js"), exports);
|
|
312
|
+
__exportStar(require("./liquidity_snapshot.js"), exports);
|
|
313
|
+
var simulation_route_js_1 = require("./simulation_route.js");
|
|
314
|
+
Object.defineProperty(exports, "analyzeSimulationRoutes", { enumerable: true, get: function () { return simulation_route_js_1.analyzeSimulationRoutes; } });
|
|
315
|
+
var block_meta_js_1 = require("./grpc/block_meta.js");
|
|
316
|
+
Object.defineProperty(exports, "parseBlockMetaUpdate", { enumerable: true, get: function () { return block_meta_js_1.parseBlockMetaUpdate; } });
|
|
317
|
+
var subscribe_builder_js_3 = require("./grpc/subscribe_builder.js");
|
|
318
|
+
Object.defineProperty(exports, "buildSubscribeRequestWithEventFilter", { enumerable: true, get: function () { return subscribe_builder_js_3.buildSubscribeRequestWithEventFilter; } });
|
package/dist/instr/inner.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DexEvent } from "../core/dex_event.js";
|
|
2
2
|
import type { EventTypeFilter } from "../grpc/types.js";
|
|
3
|
-
export declare function parseInnerCompiledInstructionIfSupported(data: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, filter: EventTypeFilter | undefined, programId: string): DexEvent | null;
|
|
4
|
-
export declare function parseInnerInstructionUnified(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, filter: EventTypeFilter | undefined, programId: string, isCreatedBuy?: boolean): DexEvent | null;
|
|
3
|
+
export declare function parseInnerCompiledInstructionIfSupported(data: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string, filter: EventTypeFilter | undefined, programId: string): DexEvent | null;
|
|
4
|
+
export declare function parseInnerInstructionUnified(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string, filter: EventTypeFilter | undefined, programId: string, isCreatedBuy?: boolean): DexEvent | null;
|
package/dist/instr/inner.js
CHANGED
|
@@ -235,7 +235,7 @@ function normalInstructionDataMayParse(programId, data) {
|
|
|
235
235
|
if (data.length === 0)
|
|
236
236
|
return false;
|
|
237
237
|
if (programId === program_ids_js_1.RAYDIUM_AMM_V4_PROGRAM_ID)
|
|
238
|
-
return firstByteIn(data, [1, 3, 4, 7, 9, 11]);
|
|
238
|
+
return firstByteIn(data, [1, 3, 4, 7, 9, 11, 16, 17]);
|
|
239
239
|
if (programId === program_ids_js_1.METEORA_DLMM_PROGRAM_ID)
|
|
240
240
|
return headIn(data, IX.METEORA_DLMM);
|
|
241
241
|
if (programId === program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID) {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* 2) **CPI 事件形**:前 8 字节为外层 Anchor discriminator,8..16 为 `emit!` 事件 disc,16.. 为载荷。
|
|
6
6
|
*/
|
|
7
7
|
import type { DexEvent } from "../core/dex_event.js";
|
|
8
|
-
export declare function parseMeteoraDammInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
8
|
+
export declare function parseMeteoraDammInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMeteoraDammInstruction = parseMeteoraDammInstruction;
|
|
4
4
|
const dex_event_js_1 = require("../core/dex_event.js");
|
|
5
|
+
const meteora_damm_js_1 = require("../logs/meteora_damm.js");
|
|
5
6
|
const utils_js_1 = require("./utils.js");
|
|
6
7
|
const Z = (0, dex_event_js_1.defaultPubkey)();
|
|
7
8
|
function disc8(a) {
|
|
@@ -14,6 +15,11 @@ const CPI = {
|
|
|
14
15
|
CLOSE_POSITION_LOG: disc8([20, 145, 144, 68, 143, 142, 214, 178]),
|
|
15
16
|
ADD_LIQUIDITY_LOG: disc8([175, 242, 8, 157, 30, 247, 185, 169]),
|
|
16
17
|
REMOVE_LIQUIDITY_LOG: disc8([87, 46, 88, 98, 175, 96, 34, 91]),
|
|
18
|
+
LIQUIDITY_CHANGE_LOG: disc8([197, 171, 78, 127, 224, 211, 87, 13]),
|
|
19
|
+
UPDATE_DELEGATE_PERMISSION_LOG: disc8([66, 188, 75, 151, 150, 232, 87, 93]),
|
|
20
|
+
WITHDRAW_DEAD_LIQUIDITY_REWARD_LOG: disc8([228, 66, 150, 195, 42, 62, 163, 13]),
|
|
21
|
+
CREATE_CONFIG_LOG: disc8([131, 207, 180, 174, 180, 73, 165, 54]),
|
|
22
|
+
CREATE_DYNAMIC_CONFIG_LOG: disc8([231, 197, 13, 164, 248, 213, 133, 152]),
|
|
17
23
|
};
|
|
18
24
|
/** 与 cp_amm Anchor IDL `instructions[].discriminator` 一致(用户直接调用的外层指令) */
|
|
19
25
|
const ANCHOR = {
|
|
@@ -107,13 +113,28 @@ function parseOuterSwap2Ix(instructionData, accounts, meta) {
|
|
|
107
113
|
const swap_mode = (0, utils_js_1.readU8)(instructionData, 24);
|
|
108
114
|
if (swap_mode === null)
|
|
109
115
|
return null;
|
|
110
|
-
|
|
116
|
+
let amount_in;
|
|
117
|
+
let minimum_amount_out;
|
|
118
|
+
if (swap_mode === 0 || swap_mode === 1) {
|
|
119
|
+
amount_in = amount_0;
|
|
120
|
+
minimum_amount_out = amount_1;
|
|
121
|
+
}
|
|
122
|
+
else if (swap_mode === 2) {
|
|
123
|
+
amount_in = amount_1;
|
|
124
|
+
minimum_amount_out = amount_0;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
111
129
|
const pool = (0, utils_js_1.getAccount)(accounts, 1) ?? Z;
|
|
112
130
|
const ev = {
|
|
113
131
|
metadata: meta,
|
|
114
132
|
pool,
|
|
115
133
|
trade_direction: 0,
|
|
116
134
|
has_referral: false,
|
|
135
|
+
amount_0,
|
|
136
|
+
amount_1,
|
|
137
|
+
swap_mode,
|
|
117
138
|
amount_in,
|
|
118
139
|
minimum_amount_out,
|
|
119
140
|
output_amount: 0n,
|
|
@@ -335,85 +356,11 @@ function parseSwapCpi(data, accounts, meta) {
|
|
|
335
356
|
return { MeteoraDammV2Swap: ev };
|
|
336
357
|
}
|
|
337
358
|
function parseSwap2Cpi(data, accounts, meta) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (!pool)
|
|
341
|
-
return null;
|
|
342
|
-
o += 32;
|
|
343
|
-
const trade_direction = (0, utils_js_1.readU8)(data, o);
|
|
344
|
-
if (trade_direction === null)
|
|
345
|
-
return null;
|
|
346
|
-
o += 1;
|
|
347
|
-
const _cfm = (0, utils_js_1.readU8)(data, o);
|
|
348
|
-
if (_cfm === null)
|
|
349
|
-
return null;
|
|
350
|
-
o += 1;
|
|
351
|
-
const has_referral = (0, utils_js_1.readBool)(data, o);
|
|
352
|
-
if (has_referral === null)
|
|
353
|
-
return null;
|
|
354
|
-
o += 1;
|
|
355
|
-
const amount_0 = (0, utils_js_1.readU64LE)(data, o);
|
|
356
|
-
if (amount_0 === null)
|
|
357
|
-
return null;
|
|
358
|
-
o += 8;
|
|
359
|
-
const amount_1 = (0, utils_js_1.readU64LE)(data, o);
|
|
360
|
-
if (amount_1 === null)
|
|
361
|
-
return null;
|
|
362
|
-
o += 8;
|
|
363
|
-
const swap_mode = (0, utils_js_1.readU8)(data, o);
|
|
364
|
-
if (swap_mode === null)
|
|
365
|
-
return null;
|
|
366
|
-
o += 1;
|
|
367
|
-
const included_fee_input_amount = (0, utils_js_1.readU64LE)(data, o);
|
|
368
|
-
if (included_fee_input_amount === null)
|
|
369
|
-
return null;
|
|
370
|
-
o += 8;
|
|
371
|
-
o += 8;
|
|
372
|
-
o += 8;
|
|
373
|
-
const output_amount = (0, utils_js_1.readU64LE)(data, o);
|
|
374
|
-
if (output_amount === null)
|
|
375
|
-
return null;
|
|
376
|
-
o += 8;
|
|
377
|
-
const next_sqrt_price = (0, utils_js_1.readU128LE)(data, o);
|
|
378
|
-
if (next_sqrt_price === null)
|
|
379
|
-
return null;
|
|
380
|
-
o += 16;
|
|
381
|
-
const lp_fee = (0, utils_js_1.readU64LE)(data, o);
|
|
382
|
-
if (lp_fee === null)
|
|
383
|
-
return null;
|
|
384
|
-
o += 8;
|
|
385
|
-
const protocol_fee = (0, utils_js_1.readU64LE)(data, o);
|
|
386
|
-
if (protocol_fee === null)
|
|
387
|
-
return null;
|
|
388
|
-
o += 8;
|
|
389
|
-
const referral_fee = (0, utils_js_1.readU64LE)(data, o);
|
|
390
|
-
if (referral_fee === null)
|
|
359
|
+
const ev = (0, meteora_damm_js_1.parseSwap2FromData)(data, meta);
|
|
360
|
+
if (!ev || !("MeteoraDammV2Swap" in ev))
|
|
391
361
|
return null;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
o += 8;
|
|
395
|
-
const current_timestamp = (0, utils_js_1.readU64LE)(data, o);
|
|
396
|
-
if (current_timestamp === null)
|
|
397
|
-
return null;
|
|
398
|
-
const [amount_in, minimum_amount_out] = swap_mode === 0 ? [amount_0, amount_1] : [amount_1, amount_0];
|
|
399
|
-
const ev = {
|
|
400
|
-
metadata: meta,
|
|
401
|
-
pool,
|
|
402
|
-
trade_direction,
|
|
403
|
-
has_referral,
|
|
404
|
-
amount_in,
|
|
405
|
-
minimum_amount_out,
|
|
406
|
-
output_amount,
|
|
407
|
-
next_sqrt_price,
|
|
408
|
-
lp_fee,
|
|
409
|
-
protocol_fee,
|
|
410
|
-
partner_fee: 0n,
|
|
411
|
-
referral_fee,
|
|
412
|
-
actual_amount_in: included_fee_input_amount,
|
|
413
|
-
current_timestamp,
|
|
414
|
-
...meteoraSwapVaultsFromAccounts(accounts),
|
|
415
|
-
};
|
|
416
|
-
return { MeteoraDammV2Swap: ev };
|
|
362
|
+
Object.assign(ev.MeteoraDammV2Swap, meteoraSwapVaultsFromAccounts(accounts));
|
|
363
|
+
return ev;
|
|
417
364
|
}
|
|
418
365
|
function parseMeteoraDammInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
|
|
419
366
|
if (instructionData.length < 8)
|
|
@@ -597,5 +544,20 @@ function parseMeteoraDammInstruction(instructionData, accounts, signature, slot,
|
|
|
597
544
|
},
|
|
598
545
|
};
|
|
599
546
|
}
|
|
547
|
+
if (discEq(cpiHead, CPI.LIQUIDITY_CHANGE_LOG)) {
|
|
548
|
+
return (0, meteora_damm_js_1.parseLiquidityChangeFromData)(cpiData, meta);
|
|
549
|
+
}
|
|
550
|
+
if (discEq(cpiHead, CPI.UPDATE_DELEGATE_PERMISSION_LOG)) {
|
|
551
|
+
return (0, meteora_damm_js_1.parseUpdateDelegatePermissionFromData)(cpiData, meta);
|
|
552
|
+
}
|
|
553
|
+
if (discEq(cpiHead, CPI.WITHDRAW_DEAD_LIQUIDITY_REWARD_LOG)) {
|
|
554
|
+
return (0, meteora_damm_js_1.parseWithdrawDeadLiquidityRewardFromData)(cpiData, meta);
|
|
555
|
+
}
|
|
556
|
+
if (discEq(cpiHead, CPI.CREATE_CONFIG_LOG)) {
|
|
557
|
+
return (0, meteora_damm_js_1.parseCreateConfigFromData)(cpiData, meta);
|
|
558
|
+
}
|
|
559
|
+
if (discEq(cpiHead, CPI.CREATE_DYNAMIC_CONFIG_LOG)) {
|
|
560
|
+
return (0, meteora_damm_js_1.parseCreateDynamicConfigFromData)(cpiData, meta);
|
|
561
|
+
}
|
|
600
562
|
return null;
|
|
601
563
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DexEvent } from "../core/dex_event.js";
|
|
2
|
-
export declare function parseMeteoraDlmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
2
|
+
export declare function parseMeteoraDlmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -151,6 +151,11 @@ function parseMeteoraDlmmInstruction(instructionData, accounts, signature, slot,
|
|
|
151
151
|
return {
|
|
152
152
|
MeteoraDlmmSwap: {
|
|
153
153
|
metadata,
|
|
154
|
+
token_x_mint: Z,
|
|
155
|
+
token_y_mint: Z,
|
|
156
|
+
user_token_in: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
|
|
157
|
+
user_token_out: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
|
|
158
|
+
min_amount_out: (0, binary_js_1.readU64LE)(data, 8) ?? 0n,
|
|
154
159
|
pool,
|
|
155
160
|
from: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
|
|
156
161
|
start_bin_id: 0,
|
|
@@ -175,6 +180,11 @@ function parseMeteoraDlmmInstruction(instructionData, accounts, signature, slot,
|
|
|
175
180
|
return {
|
|
176
181
|
MeteoraDlmmSwap: {
|
|
177
182
|
metadata,
|
|
183
|
+
token_x_mint: Z,
|
|
184
|
+
token_y_mint: Z,
|
|
185
|
+
user_token_in: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
|
|
186
|
+
user_token_out: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
|
|
187
|
+
min_amount_out: 0n,
|
|
178
188
|
pool,
|
|
179
189
|
from: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
|
|
180
190
|
start_bin_id: 0,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DexEvent } from "../core/dex_event.js";
|
|
2
|
-
export declare function parseMeteoraPoolsInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
2
|
+
export declare function parseMeteoraPoolsInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
package/dist/instr/mod.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export { parseOrcaWhirlpoolInstruction } from "./orca_whirlpool_ix.js";
|
|
|
15
15
|
export { parseRaydiumLaunchlabInstruction } from "./raydium_launchlab_ix.js";
|
|
16
16
|
export { parsePumpFeesInstruction } from "./pump_fees_ix.js";
|
|
17
17
|
export * from "./program_ids.js";
|
|
18
|
-
export declare function parseInstructionUnified(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, eventTypeFilter: EventTypeFilter | undefined, programId: string): DexEvent | null;
|
|
18
|
+
export declare function parseInstructionUnified(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string, eventTypeFilter: EventTypeFilter | undefined, programId: string): DexEvent | null;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Whirlpool 的 `swap` / `increase_liquidity_v2` / `decrease_liquidity` 与 Raydium CLMM 同源,复用同一组 Anchor 前 8 字节。
|
|
6
6
|
*/
|
|
7
7
|
import type { DexEvent } from "../core/dex_event.js";
|
|
8
|
-
export declare function parseOrcaWhirlpoolInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
8
|
+
export declare function parseOrcaWhirlpoolInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DexEvent } from "../core/dex_event.js";
|
|
2
|
-
export declare function parsePumpFeesInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
2
|
+
export declare function parsePumpFeesInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { DexEvent } from "../core/dex_event.js";
|
|
5
5
|
export declare const PUMPFUN_SOL_QUOTE_MINT = "So11111111111111111111111111111111111111111";
|
|
6
|
-
export declare function parsePumpfunInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
6
|
+
export declare function parsePumpfunInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
package/dist/instr/pumpfun_ix.js
CHANGED
|
@@ -39,6 +39,8 @@ function createNumericDefaults() {
|
|
|
39
39
|
quote_vault: Z,
|
|
40
40
|
quote_token_program: Z,
|
|
41
41
|
virtual_quote_reserves: 0n,
|
|
42
|
+
creator_fee_bps: 0n,
|
|
43
|
+
is_holder_reward: false,
|
|
42
44
|
ix_name: "",
|
|
43
45
|
};
|
|
44
46
|
}
|
|
@@ -89,6 +91,8 @@ function parsePumpfunTradeV2Instruction(ixName, data, accounts, metadata) {
|
|
|
89
91
|
mayhem_mode: false,
|
|
90
92
|
cashback_fee_basis_points: 0n,
|
|
91
93
|
cashback: 0n,
|
|
94
|
+
holder_rewards_bps: 0n,
|
|
95
|
+
holder_rewards: 0n,
|
|
92
96
|
is_cashback_coin: false,
|
|
93
97
|
associated_bonding_curve: accounts[11] ?? Z,
|
|
94
98
|
associated_user: accounts[14] ?? Z,
|
|
@@ -175,6 +179,8 @@ function parsePumpfunLegacyBuyInstruction(ixName, data, accounts, metadata) {
|
|
|
175
179
|
mayhem_mode: false,
|
|
176
180
|
cashback_fee_basis_points: 0n,
|
|
177
181
|
cashback: 0n,
|
|
182
|
+
holder_rewards_bps: 0n,
|
|
183
|
+
holder_rewards: 0n,
|
|
178
184
|
is_cashback_coin: false,
|
|
179
185
|
quote_mint: exports.PUMPFUN_SOL_QUOTE_MINT,
|
|
180
186
|
quote_token_program: Z,
|
|
@@ -269,6 +275,8 @@ function parsePumpfunLegacySellInstruction(data, accounts, metadata) {
|
|
|
269
275
|
mayhem_mode: false,
|
|
270
276
|
cashback_fee_basis_points: 0n,
|
|
271
277
|
cashback: 0n,
|
|
278
|
+
holder_rewards_bps: 0n,
|
|
279
|
+
holder_rewards: 0n,
|
|
272
280
|
is_cashback_coin: false,
|
|
273
281
|
...(legacyBuybackFeeRecipient !== Z ? { account: legacyBuybackFeeRecipient } : {}),
|
|
274
282
|
};
|
|
@@ -307,6 +315,12 @@ function parsePumpfunInstruction(instructionData, accounts, signature, slot, txI
|
|
|
307
315
|
return null;
|
|
308
316
|
o += 1;
|
|
309
317
|
const isCashbackEnabled = (0, utils_js_1.readBool)(data, o) ?? false;
|
|
318
|
+
if (o < data.length)
|
|
319
|
+
o += 1;
|
|
320
|
+
const creatorFeeBps = (0, utils_js_1.readU64LE)(data, o) ?? 0n;
|
|
321
|
+
if (o + 8 <= data.length)
|
|
322
|
+
o += 8;
|
|
323
|
+
const isHolderReward = (0, utils_js_1.readBool)(data, o) ?? false;
|
|
310
324
|
const mint = accounts[0];
|
|
311
325
|
const ev = {
|
|
312
326
|
metadata: meta,
|
|
@@ -338,6 +352,8 @@ function parsePumpfunInstruction(instructionData, accounts, signature, slot, txI
|
|
|
338
352
|
ix_name: "create_v2",
|
|
339
353
|
is_mayhem_mode: isMayhemMode,
|
|
340
354
|
is_cashback_enabled: isCashbackEnabled,
|
|
355
|
+
creator_fee_bps: creatorFeeBps,
|
|
356
|
+
is_holder_reward: isHolderReward,
|
|
341
357
|
};
|
|
342
358
|
return { PumpFunCreateV2: ev };
|
|
343
359
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* PumpSwap 指令解析
|
|
3
3
|
*/
|
|
4
4
|
import type { DexEvent } from "../core/dex_event.js";
|
|
5
|
-
export declare function parsePumpswapInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs?: number): DexEvent | null;
|
|
5
|
+
export declare function parsePumpswapInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs?: number | bigint | string): DexEvent | null;
|
|
@@ -99,6 +99,8 @@ function buyLike(data, accounts, meta, swapOrder) {
|
|
|
99
99
|
virtual_quote_reserves: 0n,
|
|
100
100
|
can_boost: false,
|
|
101
101
|
base_supply: 0n,
|
|
102
|
+
holder_rewards_bps: 0n,
|
|
103
|
+
holder_rewards: 0n,
|
|
102
104
|
is_pump_pool: false,
|
|
103
105
|
base_mint: g(3),
|
|
104
106
|
quote_mint: g(4),
|
|
@@ -167,6 +169,8 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
167
169
|
virtual_quote_reserves: 0n,
|
|
168
170
|
can_boost: false,
|
|
169
171
|
base_supply: 0n,
|
|
172
|
+
holder_rewards_bps: 0n,
|
|
173
|
+
holder_rewards: 0n,
|
|
170
174
|
is_pump_pool: false,
|
|
171
175
|
base_mint: g(3),
|
|
172
176
|
quote_mint: g(4),
|
|
@@ -187,15 +191,15 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
187
191
|
const ev = {
|
|
188
192
|
metadata: meta,
|
|
189
193
|
timestamp: 0n,
|
|
190
|
-
index: 0,
|
|
194
|
+
index: Number(data.length >= 2 ? data[0] | (data[1] << 8) : 0),
|
|
191
195
|
pool: g(0),
|
|
192
196
|
creator: g(2),
|
|
193
197
|
base_mint: g(3),
|
|
194
198
|
quote_mint: g(4),
|
|
195
199
|
base_mint_decimals: 0,
|
|
196
200
|
quote_mint_decimals: 0,
|
|
197
|
-
base_amount_in: 0n,
|
|
198
|
-
quote_amount_in: 0n,
|
|
201
|
+
base_amount_in: (0, utils_js_1.readU64LE)(data, 2) ?? 0n,
|
|
202
|
+
quote_amount_in: (0, utils_js_1.readU64LE)(data, 10) ?? 0n,
|
|
199
203
|
pool_base_amount: 0n,
|
|
200
204
|
pool_quote_amount: 0n,
|
|
201
205
|
minimum_liquidity: 0n,
|
|
@@ -205,8 +209,12 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
205
209
|
lp_mint: g(5),
|
|
206
210
|
user_base_token_account: g(6),
|
|
207
211
|
user_quote_token_account: g(7),
|
|
208
|
-
coin_creator: g(1),
|
|
209
|
-
is_mayhem_mode:
|
|
212
|
+
coin_creator: (0, utils_js_1.readPubkeyIx)(data, 18) ?? g(1),
|
|
213
|
+
is_mayhem_mode: data[50] === 1,
|
|
214
|
+
is_cashback_coin: data[51] === 1,
|
|
215
|
+
creator_fee_bps: (0, utils_js_1.readU64LE)(data, 52) ?? 0n,
|
|
216
|
+
can_edit_creator_fee: data[60] === 1,
|
|
217
|
+
is_holder_reward: data[61] === 1,
|
|
210
218
|
};
|
|
211
219
|
return { PumpSwapCreatePool: ev };
|
|
212
220
|
}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* 单字节 discriminator;Swap 账户顺序与链上 `SwapBaseIn`/`SwapBaseOut` 一致(18 个账户)。
|
|
4
4
|
*/
|
|
5
5
|
import type { DexEvent } from "../core/dex_event.js";
|
|
6
|
-
export declare function parseRaydiumAmmV4Instruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
6
|
+
export declare function parseRaydiumAmmV4Instruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -29,7 +29,9 @@ const SWAP = {
|
|
|
29
29
|
USER_DEST_TOKEN: 16,
|
|
30
30
|
USER_OWNER: 17,
|
|
31
31
|
};
|
|
32
|
-
function swapAccountIndexes(accountCount) {
|
|
32
|
+
function swapAccountIndexes(accountCount, modern) {
|
|
33
|
+
if (modern)
|
|
34
|
+
return { ...SWAP, AMM_OPEN_ORDERS: -1, AMM_TARGET_ORDERS: -1, POOL_COIN_TOKEN: 3, POOL_PC_TOKEN: 4, SERUM_PROGRAM: -1, SERUM_MARKET: -1, SERUM_BIDS: -1, SERUM_ASKS: -1, SERUM_EVENT_QUEUE: -1, SERUM_COIN_VAULT: -1, SERUM_PC_VAULT: -1, SERUM_VAULT_SIGNER: -1, USER_SOURCE_TOKEN: 5, USER_DEST_TOKEN: 6, USER_OWNER: 7 };
|
|
33
35
|
if (accountCount !== 17)
|
|
34
36
|
return SWAP;
|
|
35
37
|
return {
|
|
@@ -56,7 +58,7 @@ function swapBaseInFromIx(instructionData, accounts, meta) {
|
|
|
56
58
|
const amount_in = (0, utils_js_1.readU64LE)(instructionData, 1) ?? 0n;
|
|
57
59
|
const minimum_amount_out = (0, utils_js_1.readU64LE)(instructionData, 9) ?? 0n;
|
|
58
60
|
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
59
|
-
const indexes = swapAccountIndexes(accounts.length);
|
|
61
|
+
const indexes = swapAccountIndexes(accounts.length, instructionData[0] === 16 || instructionData[0] === 17);
|
|
60
62
|
return {
|
|
61
63
|
RaydiumAmmV4Swap: {
|
|
62
64
|
metadata: meta,
|
|
@@ -91,7 +93,7 @@ function swapBaseOutFromIx(instructionData, accounts, meta) {
|
|
|
91
93
|
const max_amount_in = (0, utils_js_1.readU64LE)(instructionData, 1) ?? 0n;
|
|
92
94
|
const amount_out = (0, utils_js_1.readU64LE)(instructionData, 9) ?? 0n;
|
|
93
95
|
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
94
|
-
const indexes = swapAccountIndexes(accounts.length);
|
|
96
|
+
const indexes = swapAccountIndexes(accounts.length, instructionData[0] === 16 || instructionData[0] === 17);
|
|
95
97
|
return {
|
|
96
98
|
RaydiumAmmV4Swap: {
|
|
97
99
|
metadata: meta,
|
|
@@ -124,11 +126,13 @@ function parseRaydiumAmmV4Instruction(instructionData, accounts, signature, slot
|
|
|
124
126
|
if (instructionData.length < 1)
|
|
125
127
|
return null;
|
|
126
128
|
const instrType = instructionData[0];
|
|
129
|
+
if ((instrType === 16 || instrType === 17) && accounts.length < 8)
|
|
130
|
+
return null;
|
|
127
131
|
const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
128
|
-
if (instrType === INSTR_TYPE.SWAP_BASE_IN) {
|
|
132
|
+
if (instrType === INSTR_TYPE.SWAP_BASE_IN || instrType === 16) {
|
|
129
133
|
return swapBaseInFromIx(instructionData, accounts, meta);
|
|
130
134
|
}
|
|
131
|
-
if (instrType === INSTR_TYPE.SWAP_BASE_OUT) {
|
|
135
|
+
if (instrType === INSTR_TYPE.SWAP_BASE_OUT || instrType === 17) {
|
|
132
136
|
return swapBaseOutFromIx(instructionData, accounts, meta);
|
|
133
137
|
}
|
|
134
138
|
return null;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Raydium CLMM 指令解析(与 Orca Whirlpool 同源 Anchor 布局:swap / 增减流动性)
|
|
3
3
|
*/
|
|
4
4
|
import type { DexEvent } from "../core/dex_event.js";
|
|
5
|
-
export declare function parseRaydiumClmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
5
|
+
export declare function parseRaydiumClmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Raydium CPMM 指令解析(Anchor:8 字节 discriminator + Borsh 参数)
|
|
3
3
|
*/
|
|
4
4
|
import type { DexEvent } from "../core/dex_event.js";
|
|
5
|
-
export declare function parseRaydiumCpmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
5
|
+
export declare function parseRaydiumCpmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* 2) **Anchor 外层指令**:`global:buy` / `sell` / `create_pool` / `migrate_to_amm` 等(sha256 前 8 字节),参数多为 Borsh u64。
|
|
6
6
|
*/
|
|
7
7
|
import type { DexEvent } from "../core/dex_event.js";
|
|
8
|
-
export declare function parseRaydiumLaunchlabInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
8
|
+
export declare function parseRaydiumLaunchlabInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
@@ -51,6 +51,8 @@ function parseMintParams(payload) {
|
|
|
51
51
|
return { symbol: symbol.s, name: name.s, uri: uri.s, decimals };
|
|
52
52
|
}
|
|
53
53
|
function tradeFromTwoU64(payload, accounts, meta, isBuy, exactIn) {
|
|
54
|
+
if (payload.length < 16 || accounts.length < 5)
|
|
55
|
+
return null;
|
|
54
56
|
const first = (0, utils_js_1.readU64LE)(payload, 0) ?? 0n;
|
|
55
57
|
const second = (0, utils_js_1.readU64LE)(payload, 8) ?? 0n;
|
|
56
58
|
const amount_in = exactIn ? first : second;
|
|
@@ -66,6 +68,31 @@ function tradeFromTwoU64(payload, accounts, meta, isBuy, exactIn) {
|
|
|
66
68
|
amount_out,
|
|
67
69
|
is_buy: isBuy,
|
|
68
70
|
trade_direction: isBuy ? "Buy" : "Sell",
|
|
71
|
+
total_base_sell: 0n,
|
|
72
|
+
virtual_base: 0n,
|
|
73
|
+
virtual_quote: 0n,
|
|
74
|
+
real_base_before: 0n,
|
|
75
|
+
real_quote_before: 0n,
|
|
76
|
+
real_base_after: 0n,
|
|
77
|
+
real_quote_after: 0n,
|
|
78
|
+
protocol_fee: 0n,
|
|
79
|
+
platform_fee: 0n,
|
|
80
|
+
creator_fee: 0n,
|
|
81
|
+
share_fee: 0n,
|
|
82
|
+
pool_status: "Fund",
|
|
83
|
+
global_config: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
84
|
+
platform_config: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
85
|
+
user_base_token: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
|
|
86
|
+
user_quote_token: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
|
|
87
|
+
base_vault: (0, utils_js_1.getAccount)(accounts, 7) ?? Z,
|
|
88
|
+
quote_vault: (0, utils_js_1.getAccount)(accounts, 8) ?? Z,
|
|
89
|
+
base_mint: (0, utils_js_1.getAccount)(accounts, 9) ?? Z,
|
|
90
|
+
quote_mint: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
|
|
91
|
+
base_token_program: (0, utils_js_1.getAccount)(accounts, 11) ?? Z,
|
|
92
|
+
quote_token_program: (0, utils_js_1.getAccount)(accounts, 12) ?? Z,
|
|
93
|
+
system_program: (0, utils_js_1.getAccount)(accounts, 15) ?? Z,
|
|
94
|
+
platform_associated_account: (0, utils_js_1.getAccount)(accounts, 16) ?? Z,
|
|
95
|
+
creator_associated_account: (0, utils_js_1.getAccount)(accounts, 17) ?? Z,
|
|
69
96
|
exact_in: exactIn,
|
|
70
97
|
},
|
|
71
98
|
};
|
|
@@ -106,6 +133,8 @@ function parseRaydiumLaunchlabInstruction(instructionData, accounts, signature,
|
|
|
106
133
|
if (headEq(instructionData, ANCHOR.INITIALIZE) ||
|
|
107
134
|
headEq(instructionData, ANCHOR.INITIALIZE_V2) ||
|
|
108
135
|
headEq(instructionData, ANCHOR.INITIALIZE_WITH_TOKEN_2022)) {
|
|
136
|
+
if (accounts.length < 6)
|
|
137
|
+
return null;
|
|
109
138
|
const base_mint_param = parseMintParams(rest);
|
|
110
139
|
if (!base_mint_param)
|
|
111
140
|
return null;
|
|
@@ -115,11 +144,42 @@ function parseRaydiumLaunchlabInstruction(instructionData, accounts, signature,
|
|
|
115
144
|
base_mint_param,
|
|
116
145
|
pool_state: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
|
|
117
146
|
creator: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
147
|
+
payer: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
148
|
+
global_config: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
149
|
+
platform_config: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
150
|
+
base_mint: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
|
|
151
|
+
quote_mint: (0, utils_js_1.getAccount)(accounts, 7) ?? Z,
|
|
152
|
+
base_vault: (0, utils_js_1.getAccount)(accounts, 8) ?? Z,
|
|
153
|
+
quote_vault: (0, utils_js_1.getAccount)(accounts, 9) ?? Z,
|
|
154
|
+
base_token_program: (0, utils_js_1.getAccount)(accounts, headEq(instructionData, ANCHOR.INITIALIZE_WITH_TOKEN_2022)
|
|
155
|
+
? 10
|
|
156
|
+
: 11) ?? Z,
|
|
157
|
+
quote_token_program: (0, utils_js_1.getAccount)(accounts, headEq(instructionData, ANCHOR.INITIALIZE_WITH_TOKEN_2022)
|
|
158
|
+
? 11
|
|
159
|
+
: 12) ?? Z,
|
|
118
160
|
},
|
|
119
161
|
};
|
|
120
162
|
}
|
|
121
|
-
if (headEq(instructionData, ANCHOR.MIGRATE_TO_AMM) ||
|
|
122
|
-
|
|
163
|
+
if (headEq(instructionData, ANCHOR.MIGRATE_TO_AMM) ||
|
|
164
|
+
headEq(instructionData, ANCHOR.MIGRATE_TO_CPSWAP)) {
|
|
165
|
+
const cp = headEq(instructionData, ANCHOR.MIGRATE_TO_CPSWAP);
|
|
166
|
+
if (accounts.length < (cp ? 28 : 32) ||
|
|
167
|
+
(!cp && instructionData.length < 17))
|
|
168
|
+
return null;
|
|
169
|
+
return {
|
|
170
|
+
RaydiumLaunchlabMigrateAmm: {
|
|
171
|
+
metadata: meta,
|
|
172
|
+
old_pool: accounts[cp ? 17 : 23],
|
|
173
|
+
new_pool: accounts[cp ? 5 : 13],
|
|
174
|
+
user: accounts[0],
|
|
175
|
+
liquidity_amount: 0n,
|
|
176
|
+
liquidity_amount_known: false,
|
|
177
|
+
base_mint: accounts[1],
|
|
178
|
+
quote_mint: accounts[2],
|
|
179
|
+
platform_config: cp ? accounts[3] : Z,
|
|
180
|
+
destination_program: accounts[cp ? 4 : 12],
|
|
181
|
+
},
|
|
182
|
+
};
|
|
123
183
|
}
|
|
124
184
|
return null;
|
|
125
185
|
}
|
package/dist/instr/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare function ixMeta(signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): EventMetadata;
|
|
1
|
+
import { type EventMetadata } from "../core/metadata.js";
|
|
2
|
+
export declare function ixMeta(signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): EventMetadata;
|
|
3
3
|
export declare function getAccount(accounts: string[], i: number): string | undefined;
|
|
4
4
|
/** Borsh 前缀字符串,返回 (utf8, 下一个 offset);失败返回 null */
|
|
5
5
|
export declare function readBorshStrAt(data: Uint8Array, offset: number): {
|