sol-parser-sdk-nodejs 0.3.0 → 0.4.4
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/.env.example +24 -0
- package/README.md +100 -352
- package/README_CN.md +107 -253
- package/dist/accounts/mod.d.ts +3 -0
- package/dist/accounts/mod.js +18 -1
- package/dist/accounts/pumpfun.d.ts +6 -0
- package/dist/accounts/pumpfun.js +157 -0
- package/dist/accounts/rpc_wallet.d.ts +5 -0
- package/dist/accounts/rpc_wallet.js +18 -0
- package/dist/accounts/rust_aliases.d.ts +10 -0
- package/dist/accounts/rust_aliases.js +21 -0
- package/dist/accounts/wallet_resolve.d.ts +1 -0
- package/dist/accounts/wallet_resolve.js +28 -0
- package/dist/common/constants.d.ts +10 -0
- package/dist/common/constants.js +13 -0
- package/dist/core/account_dispatcher_rpc.js +26 -5
- package/dist/core/account_fill_meteora.d.ts +4 -2
- package/dist/core/account_fill_meteora.js +5 -2
- package/dist/core/account_fill_pumpfun.js +17 -0
- package/dist/core/account_pubkey_cache.d.ts +12 -0
- package/dist/core/account_pubkey_cache.js +26 -0
- package/dist/core/clock.d.ts +6 -0
- package/dist/core/clock.js +13 -0
- package/dist/core/dex_event.d.ts +172 -44
- package/dist/core/metadata.d.ts +1 -0
- package/dist/core/pumpfun_fee_enrich.d.ts +4 -0
- package/dist/core/pumpfun_fee_enrich.js +80 -0
- package/dist/core/unified_parser.d.ts +2 -2
- package/dist/core/unified_parser.js +8 -6
- package/dist/grpc/client.d.ts +32 -1
- package/dist/grpc/client.js +400 -64
- package/dist/grpc/event_parser.d.ts +6 -0
- package/dist/grpc/event_parser.js +15 -0
- package/dist/grpc/geyser_connect.d.ts +30 -0
- package/dist/grpc/geyser_connect.js +40 -0
- package/dist/grpc/log_instr_dedup.d.ts +2 -0
- package/dist/grpc/log_instr_dedup.js +330 -0
- package/dist/grpc/order_buffer.d.ts +27 -0
- package/dist/grpc/order_buffer.js +166 -0
- package/dist/grpc/program_ids.d.ts +26 -0
- package/dist/grpc/program_ids.js +55 -0
- package/dist/grpc/rpc_to_grpc.d.ts +18 -0
- package/dist/grpc/rpc_to_grpc.js +127 -0
- package/dist/grpc/subscribe_builder.d.ts +13 -0
- package/dist/grpc/subscribe_builder.js +66 -0
- package/dist/grpc/transaction_meta.d.ts +29 -0
- package/dist/grpc/transaction_meta.js +208 -0
- package/dist/grpc/types.d.ts +57 -2
- package/dist/grpc/types.js +199 -7
- package/dist/grpc/yellowstone_parse.d.ts +8 -1
- package/dist/grpc/yellowstone_parse.js +27 -11
- package/dist/index.d.ts +39 -8
- package/dist/index.js +184 -2
- package/dist/instr/bonk_ix.d.ts +4 -1
- package/dist/instr/bonk_ix.js +106 -27
- package/dist/instr/meteora_damm_ix.d.ts +4 -2
- package/dist/instr/meteora_damm_ix.js +248 -13
- package/dist/instr/mod.d.ts +1 -0
- package/dist/instr/mod.js +16 -3
- package/dist/instr/orca_whirlpool_ix.d.ts +4 -1
- package/dist/instr/orca_whirlpool_ix.js +45 -16
- package/dist/instr/program_ids.d.ts +7 -13
- package/dist/instr/program_ids.js +20 -15
- package/dist/instr/pump_fees_ix.d.ts +2 -0
- package/dist/instr/pump_fees_ix.js +166 -0
- package/dist/instr/pumpfun_ix.js +57 -0
- package/dist/instr/pumpswap_ix.d.ts +1 -1
- package/dist/instr/pumpswap_ix.js +78 -57
- package/dist/instr/raydium_amm_v4_ix.d.ts +1 -1
- package/dist/instr/raydium_amm_v4_ix.js +94 -28
- package/dist/instr/raydium_clmm_ix.d.ts +1 -1
- package/dist/instr/raydium_clmm_ix.js +84 -30
- package/dist/instr/raydium_cpmm_ix.d.ts +1 -1
- package/dist/instr/raydium_cpmm_ix.js +46 -12
- package/dist/instr/rust_aliases.d.ts +8 -0
- package/dist/instr/rust_aliases.js +16 -0
- package/dist/instr/utils.d.ts +1 -1
- package/dist/instr/utils.js +2 -1
- package/dist/logs/discriminator_lut.d.ts +19 -0
- package/dist/logs/discriminator_lut.js +62 -0
- package/dist/logs/meteora_damm.d.ts +3 -4
- package/dist/logs/meteora_damm.js +3 -369
- package/dist/logs/optimized_matcher.d.ts +2 -2
- package/dist/logs/optimized_matcher.js +123 -23
- package/dist/logs/program_log_discriminators.d.ts +10 -0
- package/dist/logs/program_log_discriminators.js +10 -0
- package/dist/logs/pump.d.ts +2 -0
- package/dist/logs/pump.js +51 -4
- package/dist/logs/pump_fees.d.ts +23 -0
- package/dist/logs/pump_fees.js +364 -0
- package/dist/logs/rust_aliases.d.ts +6 -0
- package/dist/logs/rust_aliases.js +13 -0
- package/dist/rpc_parser.d.ts +1 -0
- package/dist/rpc_parser.js +4 -1
- package/dist/rpc_transaction.d.ts +2 -0
- package/dist/rpc_transaction.js +14 -6
- package/dist/shredstream/alt_lookup.d.ts +9 -0
- package/dist/shredstream/alt_lookup.js +70 -0
- package/dist/shredstream/client.d.ts +62 -0
- package/dist/shredstream/client.js +399 -0
- package/dist/shredstream/config.d.ts +30 -0
- package/dist/shredstream/config.js +34 -0
- package/dist/shredstream/entries_decode.d.ts +28 -0
- package/dist/shredstream/entries_decode.js +251 -0
- package/dist/shredstream/index.d.ts +17 -0
- package/dist/shredstream/index.js +33 -0
- package/dist/shredstream/instruction_parse.d.ts +34 -0
- package/dist/shredstream/instruction_parse.js +49 -0
- package/dist/shredstream/proto_types.d.ts +9 -0
- package/dist/shredstream/proto_types.js +2 -0
- package/dist/shredstream/shredstream.proto +15 -0
- package/dist/shredstream/wire_to_shred_tx.d.ts +2 -0
- package/dist/shredstream/wire_to_shred_tx.js +59 -0
- package/package.json +28 -11
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseRaydiumClmmInstruction = parseRaydiumClmmInstruction;
|
|
4
4
|
const dex_event_js_1 = require("../core/dex_event.js");
|
|
5
|
+
const program_log_discriminators_js_1 = require("../logs/program_log_discriminators.js");
|
|
5
6
|
const utils_js_1 = require("./utils.js");
|
|
6
7
|
const Z = (0, dex_event_js_1.defaultPubkey)();
|
|
7
|
-
// Discriminators (little-endian u64)
|
|
8
8
|
const DISC = {
|
|
9
|
-
SWAP:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
SWAP: (0, program_log_discriminators_js_1.u64leDiscriminator)([248, 198, 158, 145, 225, 117, 135, 200]),
|
|
10
|
+
SWAP_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([43, 4, 237, 11, 26, 201, 30, 98]),
|
|
11
|
+
INCREASE_LIQUIDITY_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([133, 29, 89, 223, 69, 238, 176, 10]),
|
|
12
|
+
DECREASE_LIQUIDITY_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([58, 127, 188, 62, 79, 82, 196, 96]),
|
|
13
|
+
CREATE_POOL: (0, program_log_discriminators_js_1.u64leDiscriminator)([233, 146, 209, 142, 207, 104, 64, 188]),
|
|
14
|
+
OPEN_POSITION_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([77, 184, 74, 214, 112, 86, 241, 199]),
|
|
15
|
+
OPEN_POSITION_WITH_TOKEN_22_NFT: (0, program_log_discriminators_js_1.u64leDiscriminator)([77, 255, 174, 82, 125, 29, 201, 46]),
|
|
16
|
+
CLOSE_POSITION: (0, program_log_discriminators_js_1.u64leDiscriminator)([123, 134, 81, 0, 49, 68, 98, 98]),
|
|
13
17
|
};
|
|
14
18
|
function discEq(data, disc) {
|
|
15
19
|
if (data.length < 8)
|
|
@@ -21,18 +25,24 @@ function parseRaydiumClmmInstruction(instructionData, accounts, signature, slot,
|
|
|
21
25
|
if (instructionData.length < 8)
|
|
22
26
|
return null;
|
|
23
27
|
const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
24
|
-
if (discEq(instructionData, DISC.SWAP)) {
|
|
28
|
+
if (discEq(instructionData, DISC.SWAP) || discEq(instructionData, DISC.SWAP_V2)) {
|
|
29
|
+
if (instructionData.length < 8 + 8 + 8 + 8 + 1)
|
|
30
|
+
return null;
|
|
31
|
+
const sqrt_limit = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
32
|
+
const is_base_input = (0, utils_js_1.readBool)(instructionData, 32);
|
|
33
|
+
if (is_base_input === null)
|
|
34
|
+
return null;
|
|
25
35
|
return {
|
|
26
36
|
RaydiumClmmSwap: {
|
|
27
37
|
metadata: meta,
|
|
28
|
-
pool_state: (0, utils_js_1.getAccount)(accounts,
|
|
29
|
-
sender: (0, utils_js_1.getAccount)(accounts,
|
|
38
|
+
pool_state: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
39
|
+
sender: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
30
40
|
token_account_0: Z,
|
|
31
41
|
token_account_1: Z,
|
|
32
42
|
amount_0: 0n,
|
|
33
43
|
amount_1: 0n,
|
|
34
|
-
zero_for_one:
|
|
35
|
-
sqrt_price_x64:
|
|
44
|
+
zero_for_one: is_base_input,
|
|
45
|
+
sqrt_price_x64: sqrt_limit,
|
|
36
46
|
liquidity: 0n,
|
|
37
47
|
transfer_fee_0: 0n,
|
|
38
48
|
transfer_fee_1: 0n,
|
|
@@ -40,44 +50,88 @@ function parseRaydiumClmmInstruction(instructionData, accounts, signature, slot,
|
|
|
40
50
|
},
|
|
41
51
|
};
|
|
42
52
|
}
|
|
43
|
-
if (discEq(instructionData, DISC.
|
|
53
|
+
if (discEq(instructionData, DISC.INCREASE_LIQUIDITY_V2)) {
|
|
54
|
+
if (instructionData.length < 8 + 8 + 8 + 8)
|
|
55
|
+
return null;
|
|
56
|
+
const liquidity = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
57
|
+
const amount0_max = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
58
|
+
const amount1_max = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
44
59
|
return {
|
|
45
60
|
RaydiumClmmIncreaseLiquidity: {
|
|
46
61
|
metadata: meta,
|
|
47
|
-
pool: (0, utils_js_1.getAccount)(accounts,
|
|
48
|
-
position_nft_mint: Z,
|
|
49
|
-
user: (0, utils_js_1.getAccount)(accounts,
|
|
50
|
-
liquidity
|
|
51
|
-
amount0_max
|
|
52
|
-
amount1_max
|
|
62
|
+
pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
63
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
64
|
+
user: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
65
|
+
liquidity,
|
|
66
|
+
amount0_max,
|
|
67
|
+
amount1_max,
|
|
53
68
|
},
|
|
54
69
|
};
|
|
55
70
|
}
|
|
56
|
-
if (discEq(instructionData, DISC.
|
|
71
|
+
if (discEq(instructionData, DISC.DECREASE_LIQUIDITY_V2)) {
|
|
72
|
+
if (instructionData.length < 8 + 8 + 8 + 8)
|
|
73
|
+
return null;
|
|
74
|
+
const liquidity = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
75
|
+
const amount0_min = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
76
|
+
const amount1_min = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
57
77
|
return {
|
|
58
78
|
RaydiumClmmDecreaseLiquidity: {
|
|
59
79
|
metadata: meta,
|
|
60
|
-
pool: (0, utils_js_1.getAccount)(accounts,
|
|
61
|
-
position_nft_mint: Z,
|
|
62
|
-
user: (0, utils_js_1.getAccount)(accounts,
|
|
63
|
-
liquidity
|
|
64
|
-
amount0_min
|
|
65
|
-
amount1_min
|
|
80
|
+
pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
81
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
82
|
+
user: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
83
|
+
liquidity,
|
|
84
|
+
amount0_min,
|
|
85
|
+
amount1_min,
|
|
66
86
|
},
|
|
67
87
|
};
|
|
68
88
|
}
|
|
69
89
|
if (discEq(instructionData, DISC.CREATE_POOL)) {
|
|
90
|
+
if (instructionData.length < 8 + 8 + 8)
|
|
91
|
+
return null;
|
|
92
|
+
const sqrt_price_x64 = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
93
|
+
const open_time = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
70
94
|
return {
|
|
71
95
|
RaydiumClmmCreatePool: {
|
|
72
96
|
metadata: meta,
|
|
73
|
-
pool: (0, utils_js_1.getAccount)(accounts,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
token_1_mint: Z,
|
|
97
|
+
pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
98
|
+
token_0_mint: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
99
|
+
token_1_mint: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
77
100
|
tick_spacing: 0,
|
|
78
101
|
fee_rate: 0,
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
creator: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
103
|
+
sqrt_price_x64,
|
|
104
|
+
open_time,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (discEq(instructionData, DISC.OPEN_POSITION_V2) || discEq(instructionData, DISC.OPEN_POSITION_WITH_TOKEN_22_NFT)) {
|
|
109
|
+
if (instructionData.length < 8 + 4 + 4 + 4 + 4 + 8 + 8 + 8)
|
|
110
|
+
return null;
|
|
111
|
+
const tick_lower_index = (0, utils_js_1.readI32LE)(instructionData, 8);
|
|
112
|
+
const tick_upper_index = (0, utils_js_1.readI32LE)(instructionData, 12);
|
|
113
|
+
const liquidity = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
114
|
+
if (tick_lower_index === null || tick_upper_index === null)
|
|
115
|
+
return null;
|
|
116
|
+
return {
|
|
117
|
+
RaydiumClmmOpenPosition: {
|
|
118
|
+
metadata: meta,
|
|
119
|
+
pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
120
|
+
user: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
121
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
122
|
+
tick_lower_index,
|
|
123
|
+
tick_upper_index,
|
|
124
|
+
liquidity,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (discEq(instructionData, DISC.CLOSE_POSITION)) {
|
|
129
|
+
return {
|
|
130
|
+
RaydiumClmmClosePosition: {
|
|
131
|
+
metadata: meta,
|
|
132
|
+
pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
133
|
+
user: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
134
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
81
135
|
},
|
|
82
136
|
};
|
|
83
137
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Raydium CPMM
|
|
2
|
+
* Raydium CPMM 指令解析(Anchor:8 字节 discriminator + Borsh 参数)
|
|
3
3
|
*/
|
|
4
4
|
import type { DexEvent } from "../core/dex_event.js";
|
|
5
5
|
export declare function parseRaydiumCpmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseRaydiumCpmmInstruction = parseRaydiumCpmmInstruction;
|
|
4
4
|
const dex_event_js_1 = require("../core/dex_event.js");
|
|
5
|
+
const program_log_discriminators_js_1 = require("../logs/program_log_discriminators.js");
|
|
5
6
|
const utils_js_1 = require("./utils.js");
|
|
6
7
|
const Z = (0, dex_event_js_1.defaultPubkey)();
|
|
7
|
-
// Discriminators (little-endian u64)
|
|
8
8
|
const DISC = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
SWAP_BASE_IN: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_SWAP_BASE_IN,
|
|
10
|
+
SWAP_BASE_OUT: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_SWAP_BASE_OUT,
|
|
11
|
+
DEPOSIT: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_DEPOSIT,
|
|
12
|
+
WITHDRAW: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_WITHDRAW,
|
|
12
13
|
};
|
|
13
14
|
function discEq(data, disc) {
|
|
14
15
|
if (data.length < 8)
|
|
@@ -20,12 +21,16 @@ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot,
|
|
|
20
21
|
if (instructionData.length < 8)
|
|
21
22
|
return null;
|
|
22
23
|
const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
23
|
-
if (discEq(instructionData, DISC.
|
|
24
|
+
if (discEq(instructionData, DISC.SWAP_BASE_IN)) {
|
|
25
|
+
if (instructionData.length < 8 + 8 + 8)
|
|
26
|
+
return null;
|
|
27
|
+
const amount_in = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
28
|
+
const minimum_amount_out = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
24
29
|
return {
|
|
25
30
|
RaydiumCpmmSwap: {
|
|
26
31
|
metadata: meta,
|
|
27
32
|
pool_id: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
28
|
-
input_amount:
|
|
33
|
+
input_amount: amount_in,
|
|
29
34
|
output_amount: 0n,
|
|
30
35
|
input_vault_before: 0n,
|
|
31
36
|
output_vault_before: 0n,
|
|
@@ -35,27 +40,56 @@ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot,
|
|
|
35
40
|
},
|
|
36
41
|
};
|
|
37
42
|
}
|
|
43
|
+
if (discEq(instructionData, DISC.SWAP_BASE_OUT)) {
|
|
44
|
+
if (instructionData.length < 8 + 8 + 8)
|
|
45
|
+
return null;
|
|
46
|
+
const max_amount_in = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
47
|
+
const amount_out = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
48
|
+
return {
|
|
49
|
+
RaydiumCpmmSwap: {
|
|
50
|
+
metadata: meta,
|
|
51
|
+
pool_id: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
52
|
+
input_amount: max_amount_in,
|
|
53
|
+
output_amount: amount_out,
|
|
54
|
+
input_vault_before: 0n,
|
|
55
|
+
output_vault_before: 0n,
|
|
56
|
+
input_transfer_fee: 0n,
|
|
57
|
+
output_transfer_fee: 0n,
|
|
58
|
+
base_input: false,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
38
62
|
if (discEq(instructionData, DISC.DEPOSIT)) {
|
|
63
|
+
if (instructionData.length < 8 + 8 + 8 + 8)
|
|
64
|
+
return null;
|
|
65
|
+
const lp_token_amount = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
66
|
+
const token0_amount = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
67
|
+
const token1_amount = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
39
68
|
return {
|
|
40
69
|
RaydiumCpmmDeposit: {
|
|
41
70
|
metadata: meta,
|
|
42
71
|
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
43
72
|
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
44
|
-
lp_token_amount
|
|
45
|
-
token0_amount
|
|
46
|
-
token1_amount
|
|
73
|
+
lp_token_amount,
|
|
74
|
+
token0_amount,
|
|
75
|
+
token1_amount,
|
|
47
76
|
},
|
|
48
77
|
};
|
|
49
78
|
}
|
|
50
79
|
if (discEq(instructionData, DISC.WITHDRAW)) {
|
|
80
|
+
if (instructionData.length < 8 + 8 + 8 + 8)
|
|
81
|
+
return null;
|
|
82
|
+
const lp_token_amount = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
83
|
+
const token0_amount = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
84
|
+
const token1_amount = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
51
85
|
return {
|
|
52
86
|
RaydiumCpmmWithdraw: {
|
|
53
87
|
metadata: meta,
|
|
54
88
|
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
55
89
|
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
56
|
-
lp_token_amount
|
|
57
|
-
token0_amount
|
|
58
|
-
token1_amount
|
|
90
|
+
lp_token_amount,
|
|
91
|
+
token0_amount,
|
|
92
|
+
token1_amount,
|
|
59
93
|
},
|
|
60
94
|
};
|
|
61
95
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust `instr` 根模块 re-export 的蛇形命名(与 `parse_pumpfun_instruction` 等对应)。
|
|
3
|
+
*/
|
|
4
|
+
export { parseInstructionUnified as parse_instruction_unified } from "./mod.js";
|
|
5
|
+
export { parsePumpfunInstruction as parse_pumpfun_instruction } from "./pumpfun_ix.js";
|
|
6
|
+
export { parsePumpswapInstruction as parse_pumpswap_instruction } from "./pumpswap_ix.js";
|
|
7
|
+
export { parseMeteoraDammInstruction as parse_meteora_damm_instruction } from "./meteora_damm_ix.js";
|
|
8
|
+
export { parsePumpFeesInstruction as parse_pump_fees_instruction } from "./pump_fees_ix.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parse_pump_fees_instruction = exports.parse_meteora_damm_instruction = exports.parse_pumpswap_instruction = exports.parse_pumpfun_instruction = exports.parse_instruction_unified = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Rust `instr` 根模块 re-export 的蛇形命名(与 `parse_pumpfun_instruction` 等对应)。
|
|
6
|
+
*/
|
|
7
|
+
var mod_js_1 = require("./mod.js");
|
|
8
|
+
Object.defineProperty(exports, "parse_instruction_unified", { enumerable: true, get: function () { return mod_js_1.parseInstructionUnified; } });
|
|
9
|
+
var pumpfun_ix_js_1 = require("./pumpfun_ix.js");
|
|
10
|
+
Object.defineProperty(exports, "parse_pumpfun_instruction", { enumerable: true, get: function () { return pumpfun_ix_js_1.parsePumpfunInstruction; } });
|
|
11
|
+
var pumpswap_ix_js_1 = require("./pumpswap_ix.js");
|
|
12
|
+
Object.defineProperty(exports, "parse_pumpswap_instruction", { enumerable: true, get: function () { return pumpswap_ix_js_1.parsePumpswapInstruction; } });
|
|
13
|
+
var meteora_damm_ix_js_1 = require("./meteora_damm_ix.js");
|
|
14
|
+
Object.defineProperty(exports, "parse_meteora_damm_instruction", { enumerable: true, get: function () { return meteora_damm_ix_js_1.parseMeteoraDammInstruction; } });
|
|
15
|
+
var pump_fees_ix_js_1 = require("./pump_fees_ix.js");
|
|
16
|
+
Object.defineProperty(exports, "parse_pump_fees_instruction", { enumerable: true, get: function () { return pump_fees_ix_js_1.parsePumpFeesInstruction; } });
|
package/dist/instr/utils.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare function readBorshStrAt(data: Uint8Array, offset: number): {
|
|
|
7
7
|
next: number;
|
|
8
8
|
} | null;
|
|
9
9
|
export declare function readPubkeyIx(data: Uint8Array, o: number): string | null;
|
|
10
|
-
export { readU64LE, readU128LE, readU8, readBool, readI64LE, } from "../util/binary.js";
|
|
10
|
+
export { readU64LE, readU128LE, readU8, readBool, readI64LE, readI32LE, } from "../util/binary.js";
|
package/dist/instr/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readI64LE = exports.readBool = exports.readU8 = exports.readU128LE = exports.readU64LE = void 0;
|
|
3
|
+
exports.readI32LE = exports.readI64LE = exports.readBool = exports.readU8 = exports.readU128LE = exports.readU64LE = void 0;
|
|
4
4
|
exports.ixMeta = ixMeta;
|
|
5
5
|
exports.getAccount = getAccount;
|
|
6
6
|
exports.readBorshStrAt = readBorshStrAt;
|
|
@@ -31,3 +31,4 @@ Object.defineProperty(exports, "readU128LE", { enumerable: true, get: function (
|
|
|
31
31
|
Object.defineProperty(exports, "readU8", { enumerable: true, get: function () { return binary_js_2.readU8; } });
|
|
32
32
|
Object.defineProperty(exports, "readBool", { enumerable: true, get: function () { return binary_js_2.readBool; } });
|
|
33
33
|
Object.defineProperty(exports, "readI64LE", { enumerable: true, get: function () { return binary_js_2.readI64LE; } });
|
|
34
|
+
Object.defineProperty(exports, "readI32LE", { enumerable: true, get: function () { return binary_js_2.readI32LE; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** 与 Rust `discriminator_lut::Protocol` 变体名一致(字符串联合,便于 JSON / 日志)。 */
|
|
2
|
+
export type LogProtocol = "PumpFun" | "PumpFees" | "PumpSwap" | "RaydiumClmm" | "RaydiumCpmm" | "RaydiumAmm" | "OrcaWhirlpool" | "MeteoraAmm" | "MeteoraDamm";
|
|
3
|
+
/** Rust `discriminator_to_name` */
|
|
4
|
+
export declare function discriminatorToName(discriminator: bigint): string | undefined;
|
|
5
|
+
/** Rust `discriminator_to_protocol` */
|
|
6
|
+
export declare function discriminatorToProtocol(discriminator: bigint): LogProtocol | undefined;
|
|
7
|
+
export type LutDiscriminatorInfo = {
|
|
8
|
+
discriminator: bigint;
|
|
9
|
+
name: string;
|
|
10
|
+
protocol: LogProtocol;
|
|
11
|
+
};
|
|
12
|
+
/** Rust `lookup_discriminator`(无 parser 函数指针;含 `protocol`) */
|
|
13
|
+
export declare function lookupDiscriminator(discriminator: bigint): LutDiscriminatorInfo | undefined;
|
|
14
|
+
/** Rust `discriminator_to_name` */
|
|
15
|
+
export declare const discriminator_to_name: typeof discriminatorToName;
|
|
16
|
+
/** Rust `discriminator_to_protocol` */
|
|
17
|
+
export declare const discriminator_to_protocol: typeof discriminatorToProtocol;
|
|
18
|
+
/** Rust `lookup_discriminator` */
|
|
19
|
+
export declare const lookup_discriminator: typeof lookupDiscriminator;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lookup_discriminator = exports.discriminator_to_protocol = exports.discriminator_to_name = void 0;
|
|
4
|
+
exports.discriminatorToName = discriminatorToName;
|
|
5
|
+
exports.discriminatorToProtocol = discriminatorToProtocol;
|
|
6
|
+
exports.lookupDiscriminator = lookupDiscriminator;
|
|
7
|
+
/**
|
|
8
|
+
* 与 Rust `logs::discriminator_lut` 中的名称 / 协议查询对齐(基于 `PROGRAM_LOG_DISC`,含 PumpSwap 子表)。
|
|
9
|
+
* 不含 `parse_with_discriminator`:完整数据路径请用 `parseLogOptimized` / `parse_log_optimized`。
|
|
10
|
+
*/
|
|
11
|
+
const program_log_discriminators_js_1 = require("./program_log_discriminators.js");
|
|
12
|
+
function protocolForProgramLogKey(key) {
|
|
13
|
+
if (key.startsWith("PUMPFUN_"))
|
|
14
|
+
return "PumpFun";
|
|
15
|
+
if (key.startsWith("PUMP_FEES_"))
|
|
16
|
+
return "PumpFees";
|
|
17
|
+
if (key.startsWith("PUMPSWAP_"))
|
|
18
|
+
return "PumpSwap";
|
|
19
|
+
if (key.startsWith("RAYDIUM_CLMM_"))
|
|
20
|
+
return "RaydiumClmm";
|
|
21
|
+
if (key.startsWith("RAYDIUM_CPMM_"))
|
|
22
|
+
return "RaydiumCpmm";
|
|
23
|
+
if (key.startsWith("RAYDIUM_AMM_"))
|
|
24
|
+
return "RaydiumAmm";
|
|
25
|
+
if (key.startsWith("ORCA_"))
|
|
26
|
+
return "OrcaWhirlpool";
|
|
27
|
+
if (key.startsWith("METEORA_AMM_"))
|
|
28
|
+
return "MeteoraAmm";
|
|
29
|
+
if (key.startsWith("METEORA_DAMM_"))
|
|
30
|
+
return "MeteoraDamm";
|
|
31
|
+
throw new Error(`discriminator_lut: 无法从键推断协议: ${key}`);
|
|
32
|
+
}
|
|
33
|
+
const NAME_BY_DISC = new Map();
|
|
34
|
+
const PROTOCOL_BY_DISC = new Map();
|
|
35
|
+
for (const [name, disc] of Object.entries(program_log_discriminators_js_1.PROGRAM_LOG_DISC)) {
|
|
36
|
+
NAME_BY_DISC.set(disc, name);
|
|
37
|
+
PROTOCOL_BY_DISC.set(disc, protocolForProgramLogKey(name));
|
|
38
|
+
}
|
|
39
|
+
/** Rust `discriminator_to_name` */
|
|
40
|
+
function discriminatorToName(discriminator) {
|
|
41
|
+
return NAME_BY_DISC.get(discriminator);
|
|
42
|
+
}
|
|
43
|
+
/** Rust `discriminator_to_protocol` */
|
|
44
|
+
function discriminatorToProtocol(discriminator) {
|
|
45
|
+
return PROTOCOL_BY_DISC.get(discriminator);
|
|
46
|
+
}
|
|
47
|
+
/** Rust `lookup_discriminator`(无 parser 函数指针;含 `protocol`) */
|
|
48
|
+
function lookupDiscriminator(discriminator) {
|
|
49
|
+
const name = NAME_BY_DISC.get(discriminator);
|
|
50
|
+
if (name === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
const protocol = PROTOCOL_BY_DISC.get(discriminator);
|
|
53
|
+
if (protocol === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
return { discriminator, name, protocol };
|
|
56
|
+
}
|
|
57
|
+
/** Rust `discriminator_to_name` */
|
|
58
|
+
exports.discriminator_to_name = discriminatorToName;
|
|
59
|
+
/** Rust `discriminator_to_protocol` */
|
|
60
|
+
exports.discriminator_to_protocol = discriminatorToProtocol;
|
|
61
|
+
/** Rust `lookup_discriminator` */
|
|
62
|
+
exports.lookup_discriminator = lookupDiscriminator;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type EventMetadata } from "../core/metadata.js";
|
|
2
1
|
import type { DexEvent } from "../core/dex_event.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Meteora DAMM Program data 入口;与 Rust `logs/meteora_damm.rs` 一致,仅解析 Swap / Swap2(其余 discriminator 不产出事件)。
|
|
4
|
+
*/
|
|
6
5
|
export declare function parseMeteoraDammLog(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|