sol-parser-sdk 0.5.9 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -8
- package/README_CN.md +32 -8
- package/dist/accounts/pumpswap.js +15 -2
- package/dist/core/account_fill_raydium.d.ts +1 -1
- package/dist/core/account_fill_raydium.js +5 -1
- package/dist/core/dex_event.d.ts +11 -0
- package/dist/grpc/async_event_queue.d.ts +19 -0
- package/dist/grpc/async_event_queue.js +73 -0
- package/dist/grpc/client.d.ts +15 -4
- package/dist/grpc/client.js +102 -64
- package/dist/grpc/geyser_connect.d.ts +7 -1
- package/dist/grpc/geyser_connect.js +7 -1
- package/dist/grpc/log_instr_dedup.js +30 -12
- package/dist/grpc/types.d.ts +5 -3
- package/dist/grpc/types.js +5 -2
- package/dist/index.d.ts +1 -1
- package/dist/instr/inner.js +37 -15
- package/dist/instr/meteora_dlmm_ix.js +130 -38
- package/dist/instr/orca_whirlpool_ix.js +2 -1
- package/dist/instr/pumpswap_ix.js +10 -0
- package/dist/instr/raydium_amm_v4_ix.js +59 -36
- package/dist/instr/raydium_cpmm_ix.js +2 -2
- package/dist/logs/discriminator_lut.js +6 -2
- package/dist/logs/meteora_dlmm.d.ts +1 -0
- package/dist/logs/meteora_dlmm.js +135 -11
- package/dist/logs/optimized_matcher.js +25 -10
- package/dist/logs/program_log_discriminators.d.ts +1 -0
- package/dist/logs/program_log_discriminators.js +2 -0
- package/dist/logs/pump_amm.js +90 -22
- package/dist/logs/raydium_amm.d.ts +2 -0
- package/dist/logs/raydium_amm.js +36 -0
- package/dist/logs/raydium_cpmm.d.ts +2 -0
- package/dist/logs/raydium_cpmm.js +43 -0
- package/dist/rpc_transaction.js +118 -26
- package/package.json +2 -1
|
@@ -5,100 +5,157 @@ const dex_event_js_1 = require("../core/dex_event.js");
|
|
|
5
5
|
const binary_js_1 = require("../util/binary.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
const Z = (0, dex_event_js_1.defaultPubkey)();
|
|
8
|
+
function discEq(data, bytes) {
|
|
9
|
+
return data.length >= 8 && bytes.every((b, i) => data[i] === b);
|
|
10
|
+
}
|
|
11
|
+
const IX = {
|
|
12
|
+
ADD_LIQUIDITY: [181, 157, 89, 67, 143, 182, 52, 72],
|
|
13
|
+
ADD_LIQUIDITY2: [228, 162, 78, 28, 70, 219, 116, 115],
|
|
14
|
+
CLAIM_FEE: [169, 32, 79, 137, 136, 232, 70, 137],
|
|
15
|
+
CLAIM_FEE2: [112, 191, 101, 171, 28, 144, 127, 187],
|
|
16
|
+
CLOSE_POSITION: [123, 134, 81, 0, 49, 68, 98, 98],
|
|
17
|
+
CLOSE_POSITION2: [174, 90, 35, 115, 186, 40, 147, 226],
|
|
18
|
+
INITIALIZE_BIN_ARRAY: [35, 86, 19, 185, 78, 212, 75, 211],
|
|
19
|
+
INITIALIZE_LB_PAIR: [45, 154, 237, 210, 221, 15, 166, 92],
|
|
20
|
+
INITIALIZE_LB_PAIR2: [73, 59, 36, 120, 237, 83, 108, 198],
|
|
21
|
+
INITIALIZE_POSITION: [219, 192, 234, 71, 190, 191, 102, 80],
|
|
22
|
+
INITIALIZE_POSITION2: [143, 19, 242, 145, 213, 15, 104, 115],
|
|
23
|
+
INITIALIZE_POSITION_PDA: [46, 82, 125, 146, 85, 141, 228, 153],
|
|
24
|
+
REMOVE_LIQUIDITY: [80, 85, 209, 72, 24, 206, 177, 108],
|
|
25
|
+
REMOVE_LIQUIDITY2: [230, 215, 82, 127, 241, 101, 227, 146],
|
|
26
|
+
SWAP: [248, 198, 158, 145, 225, 117, 135, 200],
|
|
27
|
+
SWAP2: [65, 75, 63, 76, 235, 91, 91, 136],
|
|
28
|
+
SWAP_EXACT_OUT: [250, 73, 101, 33, 38, 207, 75, 184],
|
|
29
|
+
SWAP_EXACT_OUT2: [43, 215, 247, 132, 137, 60, 243, 81],
|
|
30
|
+
SWAP_WITH_PRICE_IMPACT: [56, 173, 230, 208, 173, 228, 156, 205],
|
|
31
|
+
SWAP_WITH_PRICE_IMPACT2: [74, 98, 192, 214, 177, 51, 75, 51],
|
|
32
|
+
};
|
|
8
33
|
function parseMeteoraDlmmInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
|
|
9
|
-
if (instructionData.length
|
|
10
|
-
return null;
|
|
11
|
-
const pool = (0, utils_js_1.getAccount)(accounts, 0);
|
|
12
|
-
if (!pool)
|
|
34
|
+
if (instructionData.length < 8)
|
|
13
35
|
return null;
|
|
14
36
|
const metadata = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
|
|
37
|
+
const data = instructionData.subarray(8);
|
|
38
|
+
if (discEq(instructionData, IX.INITIALIZE_LB_PAIR)) {
|
|
39
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 0);
|
|
40
|
+
if (!pool || data.length < 6)
|
|
18
41
|
return null;
|
|
19
|
-
const active_bin_id = (0, binary_js_1.readI32LE)(
|
|
20
|
-
const bin_step = (0, binary_js_1.readU16LE)(
|
|
42
|
+
const active_bin_id = (0, binary_js_1.readI32LE)(data, 0);
|
|
43
|
+
const bin_step = (0, binary_js_1.readU16LE)(data, 4);
|
|
21
44
|
if (active_bin_id === null || bin_step === null)
|
|
22
45
|
return null;
|
|
23
46
|
return {
|
|
24
47
|
MeteoraDlmmInitializePool: {
|
|
25
48
|
metadata,
|
|
26
49
|
pool,
|
|
27
|
-
creator: (0, utils_js_1.getAccount)(accounts,
|
|
50
|
+
creator: (0, utils_js_1.getAccount)(accounts, 8) ?? Z,
|
|
28
51
|
active_bin_id,
|
|
29
52
|
bin_step,
|
|
30
53
|
},
|
|
31
54
|
};
|
|
32
55
|
}
|
|
33
|
-
if (
|
|
34
|
-
|
|
56
|
+
if (discEq(instructionData, IX.INITIALIZE_LB_PAIR2)) {
|
|
57
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 0);
|
|
58
|
+
if (!pool || data.length < 4)
|
|
59
|
+
return null;
|
|
60
|
+
return {
|
|
61
|
+
MeteoraDlmmInitializePool: {
|
|
62
|
+
metadata,
|
|
63
|
+
pool,
|
|
64
|
+
creator: (0, utils_js_1.getAccount)(accounts, 8) ?? Z,
|
|
65
|
+
active_bin_id: (0, binary_js_1.readI32LE)(data, 0) ?? 0,
|
|
66
|
+
bin_step: 0,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (discEq(instructionData, IX.INITIALIZE_BIN_ARRAY)) {
|
|
71
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 0);
|
|
72
|
+
if (!pool || data.length < 8)
|
|
35
73
|
return null;
|
|
36
74
|
return {
|
|
37
75
|
MeteoraDlmmInitializeBinArray: {
|
|
38
76
|
metadata,
|
|
39
77
|
pool,
|
|
40
78
|
bin_array: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
41
|
-
index: (0, binary_js_1.
|
|
79
|
+
index: (0, binary_js_1.readI64LE)(data, 0) ?? 0n,
|
|
42
80
|
},
|
|
43
81
|
};
|
|
44
82
|
}
|
|
45
|
-
if (
|
|
46
|
-
|
|
83
|
+
if (discEq(instructionData, IX.ADD_LIQUIDITY) || discEq(instructionData, IX.ADD_LIQUIDITY2)) {
|
|
84
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 1);
|
|
85
|
+
if (!pool)
|
|
86
|
+
return null;
|
|
87
|
+
const senderIndex = discEq(instructionData, IX.ADD_LIQUIDITY2) ? 9 : 11;
|
|
88
|
+
const from = (0, utils_js_1.getAccount)(accounts, senderIndex);
|
|
89
|
+
if (!from)
|
|
47
90
|
return null;
|
|
48
91
|
return {
|
|
49
92
|
MeteoraDlmmAddLiquidity: {
|
|
50
93
|
metadata,
|
|
51
94
|
pool,
|
|
52
|
-
from
|
|
53
|
-
position: (0, utils_js_1.getAccount)(accounts,
|
|
95
|
+
from,
|
|
96
|
+
position: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
54
97
|
amounts: [0n, 0n],
|
|
55
98
|
active_bin_id: 0,
|
|
56
99
|
},
|
|
57
100
|
};
|
|
58
101
|
}
|
|
59
|
-
if (
|
|
60
|
-
|
|
102
|
+
if (discEq(instructionData, IX.REMOVE_LIQUIDITY) || discEq(instructionData, IX.REMOVE_LIQUIDITY2)) {
|
|
103
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 1);
|
|
104
|
+
if (!pool)
|
|
105
|
+
return null;
|
|
106
|
+
const senderIndex = discEq(instructionData, IX.REMOVE_LIQUIDITY2) ? 9 : 11;
|
|
107
|
+
const from = (0, utils_js_1.getAccount)(accounts, senderIndex);
|
|
108
|
+
if (!from)
|
|
61
109
|
return null;
|
|
62
110
|
return {
|
|
63
111
|
MeteoraDlmmRemoveLiquidity: {
|
|
64
112
|
metadata,
|
|
65
113
|
pool,
|
|
66
|
-
from
|
|
67
|
-
position: (0, utils_js_1.getAccount)(accounts,
|
|
114
|
+
from,
|
|
115
|
+
position: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
68
116
|
amounts: [0n, 0n],
|
|
69
117
|
active_bin_id: 0,
|
|
70
118
|
},
|
|
71
119
|
};
|
|
72
120
|
}
|
|
73
|
-
if (
|
|
74
|
-
|
|
121
|
+
if (discEq(instructionData, IX.INITIALIZE_POSITION) ||
|
|
122
|
+
discEq(instructionData, IX.INITIALIZE_POSITION2) ||
|
|
123
|
+
discEq(instructionData, IX.INITIALIZE_POSITION_PDA)) {
|
|
124
|
+
if (data.length < 8)
|
|
125
|
+
return null;
|
|
126
|
+
const lower_bin_id = (0, binary_js_1.readI32LE)(data, 0);
|
|
127
|
+
const width = (0, binary_js_1.readI32LE)(data, 4);
|
|
128
|
+
if (lower_bin_id === null || width === null || width < 0)
|
|
75
129
|
return null;
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
130
|
+
const pda = discEq(instructionData, IX.INITIALIZE_POSITION_PDA);
|
|
131
|
+
const position = (0, utils_js_1.getAccount)(accounts, pda ? 2 : 1);
|
|
132
|
+
const pool = (0, utils_js_1.getAccount)(accounts, pda ? 3 : 2);
|
|
133
|
+
const owner = (0, utils_js_1.getAccount)(accounts, pda ? 4 : 3);
|
|
134
|
+
if (!position || !pool || !owner)
|
|
79
135
|
return null;
|
|
80
136
|
return {
|
|
81
137
|
MeteoraDlmmCreatePosition: {
|
|
82
138
|
metadata,
|
|
83
139
|
pool,
|
|
84
|
-
position
|
|
85
|
-
owner
|
|
140
|
+
position,
|
|
141
|
+
owner,
|
|
86
142
|
lower_bin_id,
|
|
87
143
|
width,
|
|
88
144
|
},
|
|
89
145
|
};
|
|
90
146
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
147
|
+
if (discEq(instructionData, IX.SWAP) || discEq(instructionData, IX.SWAP2)) {
|
|
148
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 0);
|
|
149
|
+
if (!pool || data.length < 16)
|
|
93
150
|
return null;
|
|
94
151
|
return {
|
|
95
152
|
MeteoraDlmmSwap: {
|
|
96
153
|
metadata,
|
|
97
154
|
pool,
|
|
98
|
-
from: (0, utils_js_1.getAccount)(accounts,
|
|
155
|
+
from: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
|
|
99
156
|
start_bin_id: 0,
|
|
100
157
|
end_bin_id: 0,
|
|
101
|
-
amount_in: (0, binary_js_1.readU64LE)(
|
|
158
|
+
amount_in: (0, binary_js_1.readU64LE)(data, 0) ?? 0n,
|
|
102
159
|
amount_out: 0n,
|
|
103
160
|
swap_for_y: false,
|
|
104
161
|
fee: 0n,
|
|
@@ -108,25 +165,60 @@ function parseMeteoraDlmmInstruction(instructionData, accounts, signature, slot,
|
|
|
108
165
|
},
|
|
109
166
|
};
|
|
110
167
|
}
|
|
111
|
-
if (
|
|
168
|
+
if (discEq(instructionData, IX.SWAP_EXACT_OUT) ||
|
|
169
|
+
discEq(instructionData, IX.SWAP_EXACT_OUT2) ||
|
|
170
|
+
discEq(instructionData, IX.SWAP_WITH_PRICE_IMPACT) ||
|
|
171
|
+
discEq(instructionData, IX.SWAP_WITH_PRICE_IMPACT2)) {
|
|
172
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 0);
|
|
173
|
+
if (!pool || data.length < 8)
|
|
174
|
+
return null;
|
|
175
|
+
return {
|
|
176
|
+
MeteoraDlmmSwap: {
|
|
177
|
+
metadata,
|
|
178
|
+
pool,
|
|
179
|
+
from: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
|
|
180
|
+
start_bin_id: 0,
|
|
181
|
+
end_bin_id: 0,
|
|
182
|
+
amount_in: (0, binary_js_1.readU64LE)(data, 0) ?? 0n,
|
|
183
|
+
amount_out: discEq(instructionData, IX.SWAP_EXACT_OUT) || discEq(instructionData, IX.SWAP_EXACT_OUT2)
|
|
184
|
+
? (0, binary_js_1.readU64LE)(data, 8) ?? 0n
|
|
185
|
+
: 0n,
|
|
186
|
+
swap_for_y: false,
|
|
187
|
+
fee: 0n,
|
|
188
|
+
protocol_fee: 0n,
|
|
189
|
+
fee_bps: 0n,
|
|
190
|
+
host_fee: 0n,
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (discEq(instructionData, IX.CLAIM_FEE) || discEq(instructionData, IX.CLAIM_FEE2)) {
|
|
195
|
+
const pool = (0, utils_js_1.getAccount)(accounts, 0);
|
|
196
|
+
const owner = (0, utils_js_1.getAccount)(accounts, discEq(instructionData, IX.CLAIM_FEE2) ? 2 : 4);
|
|
197
|
+
if (!pool || !owner)
|
|
198
|
+
return null;
|
|
112
199
|
return {
|
|
113
200
|
MeteoraDlmmClaimFee: {
|
|
114
201
|
metadata,
|
|
115
202
|
pool,
|
|
116
203
|
position: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
117
|
-
owner
|
|
204
|
+
owner,
|
|
118
205
|
fee_x: 0n,
|
|
119
206
|
fee_y: 0n,
|
|
120
207
|
},
|
|
121
208
|
};
|
|
122
209
|
}
|
|
123
|
-
if (
|
|
210
|
+
if (discEq(instructionData, IX.CLOSE_POSITION) || discEq(instructionData, IX.CLOSE_POSITION2)) {
|
|
211
|
+
const position = (0, utils_js_1.getAccount)(accounts, 0);
|
|
212
|
+
const v2 = discEq(instructionData, IX.CLOSE_POSITION2);
|
|
213
|
+
const owner = (0, utils_js_1.getAccount)(accounts, v2 ? 1 : 4);
|
|
214
|
+
if (!position || !owner)
|
|
215
|
+
return null;
|
|
124
216
|
return {
|
|
125
217
|
MeteoraDlmmClosePosition: {
|
|
126
218
|
metadata,
|
|
127
|
-
pool,
|
|
128
|
-
position
|
|
129
|
-
owner
|
|
219
|
+
pool: v2 ? Z : (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
220
|
+
position,
|
|
221
|
+
owner,
|
|
130
222
|
},
|
|
131
223
|
};
|
|
132
224
|
}
|
|
@@ -34,10 +34,11 @@ function parseOrcaWhirlpoolInstruction(instructionData, accounts, signature, slo
|
|
|
34
34
|
return null;
|
|
35
35
|
const input_amount = amount_specified_is_input ? amount : 0n;
|
|
36
36
|
const output_amount = amount_specified_is_input ? other_threshold : amount;
|
|
37
|
+
const whirlpoolIndex = discEq(instructionData, DISC.SWAP_V2) ? 4 : 2;
|
|
37
38
|
return {
|
|
38
39
|
OrcaWhirlpoolSwap: {
|
|
39
40
|
metadata: meta,
|
|
40
|
-
whirlpool: (0, utils_js_1.getAccount)(accounts,
|
|
41
|
+
whirlpool: (0, utils_js_1.getAccount)(accounts, whirlpoolIndex) ?? Z,
|
|
41
42
|
a_to_b,
|
|
42
43
|
pre_sqrt_price: sqrt_price_limit,
|
|
43
44
|
post_sqrt_price: 0n,
|
|
@@ -94,6 +94,11 @@ function buyLike(data, accounts, meta, swapOrder) {
|
|
|
94
94
|
ix_name: "",
|
|
95
95
|
cashback_fee_basis_points: 0n,
|
|
96
96
|
cashback: 0n,
|
|
97
|
+
buyback_fee_basis_points: 0n,
|
|
98
|
+
buyback_fee: 0n,
|
|
99
|
+
virtual_quote_reserves: 0n,
|
|
100
|
+
can_boost: false,
|
|
101
|
+
base_supply: 0n,
|
|
97
102
|
is_pump_pool: false,
|
|
98
103
|
base_mint: g(3),
|
|
99
104
|
quote_mint: g(4),
|
|
@@ -157,6 +162,11 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
157
162
|
coin_creator_fee: 0n,
|
|
158
163
|
cashback_fee_basis_points: 0n,
|
|
159
164
|
cashback: 0n,
|
|
165
|
+
buyback_fee_basis_points: 0n,
|
|
166
|
+
buyback_fee: 0n,
|
|
167
|
+
virtual_quote_reserves: 0n,
|
|
168
|
+
can_boost: false,
|
|
169
|
+
base_supply: 0n,
|
|
160
170
|
is_pump_pool: false,
|
|
161
171
|
base_mint: g(3),
|
|
162
172
|
quote_mint: g(4),
|
|
@@ -29,12 +29,34 @@ const SWAP = {
|
|
|
29
29
|
USER_DEST_TOKEN: 16,
|
|
30
30
|
USER_OWNER: 17,
|
|
31
31
|
};
|
|
32
|
+
function swapAccountIndexes(accountCount) {
|
|
33
|
+
if (accountCount !== 17)
|
|
34
|
+
return SWAP;
|
|
35
|
+
return {
|
|
36
|
+
...SWAP,
|
|
37
|
+
AMM_TARGET_ORDERS: -1,
|
|
38
|
+
POOL_COIN_TOKEN: 4,
|
|
39
|
+
POOL_PC_TOKEN: 5,
|
|
40
|
+
SERUM_PROGRAM: 6,
|
|
41
|
+
SERUM_MARKET: 7,
|
|
42
|
+
SERUM_BIDS: 8,
|
|
43
|
+
SERUM_ASKS: 9,
|
|
44
|
+
SERUM_EVENT_QUEUE: 10,
|
|
45
|
+
SERUM_COIN_VAULT: 11,
|
|
46
|
+
SERUM_PC_VAULT: 12,
|
|
47
|
+
SERUM_VAULT_SIGNER: 13,
|
|
48
|
+
USER_SOURCE_TOKEN: 14,
|
|
49
|
+
USER_DEST_TOKEN: 15,
|
|
50
|
+
USER_OWNER: 16,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
32
53
|
function swapBaseInFromIx(instructionData, accounts, meta) {
|
|
33
54
|
if (instructionData.length < 1 + 8 + 8)
|
|
34
55
|
return null;
|
|
35
56
|
const amount_in = (0, utils_js_1.readU64LE)(instructionData, 1) ?? 0n;
|
|
36
57
|
const minimum_amount_out = (0, utils_js_1.readU64LE)(instructionData, 9) ?? 0n;
|
|
37
58
|
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
59
|
+
const indexes = swapAccountIndexes(accounts.length);
|
|
38
60
|
return {
|
|
39
61
|
RaydiumAmmV4Swap: {
|
|
40
62
|
metadata: meta,
|
|
@@ -42,24 +64,24 @@ function swapBaseInFromIx(instructionData, accounts, meta) {
|
|
|
42
64
|
minimum_amount_out,
|
|
43
65
|
max_amount_in: 0n,
|
|
44
66
|
amount_out: 0n,
|
|
45
|
-
token_program: g(
|
|
46
|
-
amm: g(
|
|
47
|
-
amm_authority: g(
|
|
48
|
-
amm_open_orders: g(
|
|
49
|
-
amm_target_orders: g(
|
|
50
|
-
pool_coin_token_account: g(
|
|
51
|
-
pool_pc_token_account: g(
|
|
52
|
-
serum_program: g(
|
|
53
|
-
serum_market: g(
|
|
54
|
-
serum_bids: g(
|
|
55
|
-
serum_asks: g(
|
|
56
|
-
serum_event_queue: g(
|
|
57
|
-
serum_coin_vault_account: g(
|
|
58
|
-
serum_pc_vault_account: g(
|
|
59
|
-
serum_vault_signer: g(
|
|
60
|
-
user_source_token_account: g(
|
|
61
|
-
user_destination_token_account: g(
|
|
62
|
-
user_source_owner: g(
|
|
67
|
+
token_program: g(indexes.TOKEN_PROGRAM),
|
|
68
|
+
amm: g(indexes.AMM),
|
|
69
|
+
amm_authority: g(indexes.AMM_AUTHORITY),
|
|
70
|
+
amm_open_orders: g(indexes.AMM_OPEN_ORDERS),
|
|
71
|
+
amm_target_orders: g(indexes.AMM_TARGET_ORDERS),
|
|
72
|
+
pool_coin_token_account: g(indexes.POOL_COIN_TOKEN),
|
|
73
|
+
pool_pc_token_account: g(indexes.POOL_PC_TOKEN),
|
|
74
|
+
serum_program: g(indexes.SERUM_PROGRAM),
|
|
75
|
+
serum_market: g(indexes.SERUM_MARKET),
|
|
76
|
+
serum_bids: g(indexes.SERUM_BIDS),
|
|
77
|
+
serum_asks: g(indexes.SERUM_ASKS),
|
|
78
|
+
serum_event_queue: g(indexes.SERUM_EVENT_QUEUE),
|
|
79
|
+
serum_coin_vault_account: g(indexes.SERUM_COIN_VAULT),
|
|
80
|
+
serum_pc_vault_account: g(indexes.SERUM_PC_VAULT),
|
|
81
|
+
serum_vault_signer: g(indexes.SERUM_VAULT_SIGNER),
|
|
82
|
+
user_source_token_account: g(indexes.USER_SOURCE_TOKEN),
|
|
83
|
+
user_destination_token_account: g(indexes.USER_DEST_TOKEN),
|
|
84
|
+
user_source_owner: g(indexes.USER_OWNER),
|
|
63
85
|
},
|
|
64
86
|
};
|
|
65
87
|
}
|
|
@@ -69,6 +91,7 @@ function swapBaseOutFromIx(instructionData, accounts, meta) {
|
|
|
69
91
|
const max_amount_in = (0, utils_js_1.readU64LE)(instructionData, 1) ?? 0n;
|
|
70
92
|
const amount_out = (0, utils_js_1.readU64LE)(instructionData, 9) ?? 0n;
|
|
71
93
|
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
94
|
+
const indexes = swapAccountIndexes(accounts.length);
|
|
72
95
|
return {
|
|
73
96
|
RaydiumAmmV4Swap: {
|
|
74
97
|
metadata: meta,
|
|
@@ -76,24 +99,24 @@ function swapBaseOutFromIx(instructionData, accounts, meta) {
|
|
|
76
99
|
minimum_amount_out: 0n,
|
|
77
100
|
max_amount_in,
|
|
78
101
|
amount_out,
|
|
79
|
-
token_program: g(
|
|
80
|
-
amm: g(
|
|
81
|
-
amm_authority: g(
|
|
82
|
-
amm_open_orders: g(
|
|
83
|
-
amm_target_orders: g(
|
|
84
|
-
pool_coin_token_account: g(
|
|
85
|
-
pool_pc_token_account: g(
|
|
86
|
-
serum_program: g(
|
|
87
|
-
serum_market: g(
|
|
88
|
-
serum_bids: g(
|
|
89
|
-
serum_asks: g(
|
|
90
|
-
serum_event_queue: g(
|
|
91
|
-
serum_coin_vault_account: g(
|
|
92
|
-
serum_pc_vault_account: g(
|
|
93
|
-
serum_vault_signer: g(
|
|
94
|
-
user_source_token_account: g(
|
|
95
|
-
user_destination_token_account: g(
|
|
96
|
-
user_source_owner: g(
|
|
102
|
+
token_program: g(indexes.TOKEN_PROGRAM),
|
|
103
|
+
amm: g(indexes.AMM),
|
|
104
|
+
amm_authority: g(indexes.AMM_AUTHORITY),
|
|
105
|
+
amm_open_orders: g(indexes.AMM_OPEN_ORDERS),
|
|
106
|
+
amm_target_orders: g(indexes.AMM_TARGET_ORDERS),
|
|
107
|
+
pool_coin_token_account: g(indexes.POOL_COIN_TOKEN),
|
|
108
|
+
pool_pc_token_account: g(indexes.POOL_PC_TOKEN),
|
|
109
|
+
serum_program: g(indexes.SERUM_PROGRAM),
|
|
110
|
+
serum_market: g(indexes.SERUM_MARKET),
|
|
111
|
+
serum_bids: g(indexes.SERUM_BIDS),
|
|
112
|
+
serum_asks: g(indexes.SERUM_ASKS),
|
|
113
|
+
serum_event_queue: g(indexes.SERUM_EVENT_QUEUE),
|
|
114
|
+
serum_coin_vault_account: g(indexes.SERUM_COIN_VAULT),
|
|
115
|
+
serum_pc_vault_account: g(indexes.SERUM_PC_VAULT),
|
|
116
|
+
serum_vault_signer: g(indexes.SERUM_VAULT_SIGNER),
|
|
117
|
+
user_source_token_account: g(indexes.USER_SOURCE_TOKEN),
|
|
118
|
+
user_destination_token_account: g(indexes.USER_DEST_TOKEN),
|
|
119
|
+
user_source_owner: g(indexes.USER_OWNER),
|
|
97
120
|
},
|
|
98
121
|
};
|
|
99
122
|
}
|
|
@@ -28,7 +28,7 @@ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot,
|
|
|
28
28
|
return {
|
|
29
29
|
RaydiumCpmmSwap: {
|
|
30
30
|
metadata: meta,
|
|
31
|
-
pool_id: Z,
|
|
31
|
+
pool_id: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
32
32
|
input_amount: 0n,
|
|
33
33
|
output_amount: 0n,
|
|
34
34
|
input_vault_before: 0n,
|
|
@@ -45,7 +45,7 @@ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot,
|
|
|
45
45
|
return {
|
|
46
46
|
RaydiumCpmmSwap: {
|
|
47
47
|
metadata: meta,
|
|
48
|
-
pool_id: Z,
|
|
48
|
+
pool_id: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
49
49
|
input_amount: 0n,
|
|
50
50
|
output_amount: 0n,
|
|
51
51
|
input_vault_before: 0n,
|
|
@@ -33,8 +33,12 @@ function protocolForProgramLogKey(key) {
|
|
|
33
33
|
const NAME_BY_DISC = new Map();
|
|
34
34
|
const PROTOCOL_BY_DISC = new Map();
|
|
35
35
|
for (const [name, disc] of Object.entries(program_log_discriminators_js_1.PROGRAM_LOG_DISC)) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// Some Anchor event names intentionally share a discriminator across programs.
|
|
37
|
+
// Keep the first canonical unscoped entry; program-aware parsing disambiguates them.
|
|
38
|
+
if (!NAME_BY_DISC.has(disc)) {
|
|
39
|
+
NAME_BY_DISC.set(disc, name);
|
|
40
|
+
PROTOCOL_BY_DISC.set(disc, protocolForProgramLogKey(name));
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
/** Rust `discriminator_to_name` */
|
|
40
44
|
function discriminatorToName(discriminator) {
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
import { type EventMetadata } from "../core/metadata.js";
|
|
3
3
|
import type { DexEvent } from "../core/dex_event.js";
|
|
4
4
|
export declare function parseDlmmFromDecoded(programData: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
5
|
+
export declare function parseDlmmEventFromData(discriminator: bigint, data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
5
6
|
/** 从整行日志解析 */
|
|
6
7
|
export declare function parseMeteoraDlmmLog(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
|