sol-parser-sdk-nodejs 0.4.0 → 0.5.5
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 +22 -4
- package/README_CN.md +22 -4
- package/dist/accounts/mod.d.ts +1 -0
- package/dist/accounts/mod.js +53 -6
- package/dist/accounts/pumpfun.d.ts +16 -0
- package/dist/accounts/pumpfun.js +538 -0
- package/dist/accounts/rust_aliases.d.ts +1 -0
- package/dist/accounts/rust_aliases.js +3 -1
- package/dist/core/account_dispatcher_rpc.js +5 -26
- package/dist/core/account_fill_meteora.d.ts +1 -2
- package/dist/core/account_fill_meteora.js +0 -2
- package/dist/core/account_fill_pumpfun.js +92 -13
- package/dist/core/account_fill_pumpswap.js +50 -0
- package/dist/core/account_fill_raydium_launchlab.d.ts +4 -0
- package/dist/core/account_fill_raydium_launchlab.js +20 -0
- package/dist/core/dex_event.d.ts +283 -17
- package/dist/core/pumpfun_fee_enrich.d.ts +5 -0
- package/dist/core/pumpfun_fee_enrich.js +131 -0
- package/dist/core/unified_parser.js +2 -0
- package/dist/grpc/client.d.ts +26 -1
- package/dist/grpc/client.js +279 -0
- package/dist/grpc/log_instr_dedup.d.ts +2 -0
- package/dist/grpc/log_instr_dedup.js +378 -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 +5 -3
- package/dist/grpc/program_ids.js +12 -5
- package/dist/grpc/types.d.ts +17 -6
- package/dist/grpc/types.js +265 -153
- package/dist/grpc/yellowstone_parse.d.ts +3 -1
- package/dist/grpc/yellowstone_parse.js +13 -10
- package/dist/index.d.ts +9 -7
- package/dist/index.js +33 -7
- package/dist/instr/meteora_damm_ix.js +4 -1
- package/dist/instr/meteora_dlmm_ix.d.ts +2 -0
- package/dist/instr/meteora_dlmm_ix.js +134 -0
- package/dist/instr/meteora_pools_ix.d.ts +2 -0
- package/dist/instr/meteora_pools_ix.js +78 -0
- package/dist/instr/mod.d.ts +4 -1
- package/dist/instr/mod.js +45 -18
- package/dist/instr/program_ids.d.ts +1 -5
- package/dist/instr/program_ids.js +4 -6
- 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 +272 -1
- package/dist/instr/pumpswap_ix.js +36 -2
- package/dist/instr/raydium_clmm_ix.js +73 -52
- package/dist/instr/raydium_launchlab_ix.d.ts +8 -0
- package/dist/instr/raydium_launchlab_ix.js +125 -0
- package/dist/instr/rust_aliases.d.ts +3 -0
- package/dist/instr/rust_aliases.js +7 -1
- package/dist/logs/discriminator_lut.d.ts +1 -1
- package/dist/logs/discriminator_lut.js +2 -0
- package/dist/logs/optimized_matcher.js +130 -25
- 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 +122 -2
- package/dist/logs/pump_amm.js +1 -1
- package/dist/logs/pump_fees.d.ts +23 -0
- package/dist/logs/pump_fees.js +364 -0
- package/dist/logs/raydium_launchlab.d.ts +10 -0
- package/dist/logs/raydium_launchlab.js +84 -0
- package/dist/rpc_transaction.d.ts +2 -0
- package/dist/rpc_transaction.js +14 -6
- package/dist/shredstream/client.d.ts +4 -1
- package/dist/shredstream/client.js +18 -14
- package/dist/shredstream/index.d.ts +1 -1
- package/dist/shredstream/index.js +1 -1
- package/dist/shredstream/instruction_parse.d.ts +3 -3
- package/dist/shredstream/instruction_parse.js +38 -13
- package/dist/util/market.d.ts +18 -0
- package/dist/util/market.js +54 -0
- package/package.json +1 -1
package/dist/logs/pump.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.parsePumpFunLogDecoded = parsePumpFunLogDecoded;
|
|
|
4
4
|
exports.parseTradeFromData = parseTradeFromData;
|
|
5
5
|
exports.parseCreateFromData = parseCreateFromData;
|
|
6
6
|
exports.parseMigrateFromData = parseMigrateFromData;
|
|
7
|
+
exports.parseMigrateBondingCurveCreatorFromData = parseMigrateBondingCurveCreatorFromData;
|
|
7
8
|
exports.pumpDiscriminators = pumpDiscriminators;
|
|
8
9
|
const dex_event_js_1 = require("../core/dex_event.js");
|
|
9
10
|
const binary_js_1 = require("../util/binary.js");
|
|
@@ -16,12 +17,59 @@ function disc(bytes) {
|
|
|
16
17
|
const DISC_CREATE = disc([27, 114, 169, 77, 222, 235, 99, 118]);
|
|
17
18
|
const DISC_TRADE = disc([189, 219, 127, 211, 78, 230, 97, 238]);
|
|
18
19
|
const DISC_MIGRATE = disc([189, 233, 93, 185, 92, 148, 234, 148]);
|
|
20
|
+
const DISC_MIGRATE_BONDING_CURVE_CREATOR = disc([155, 167, 104, 220, 213, 108, 243, 3]);
|
|
21
|
+
function normalizePumpfunIxName(ixName) {
|
|
22
|
+
if (ixName === "buy_v2")
|
|
23
|
+
return "buy";
|
|
24
|
+
if (ixName === "sell_v2")
|
|
25
|
+
return "sell";
|
|
26
|
+
if (ixName === "buy_exact_quote_in_v2")
|
|
27
|
+
return "buy_exact_quote_in";
|
|
28
|
+
return ixName;
|
|
29
|
+
}
|
|
19
30
|
function bnU64(v) {
|
|
20
31
|
return v ?? 0n;
|
|
21
32
|
}
|
|
22
33
|
function bnI64(v) {
|
|
23
34
|
return v ?? 0n;
|
|
24
35
|
}
|
|
36
|
+
function readOptionalU64(data, offset) {
|
|
37
|
+
if (offset.value + 8 > data.length)
|
|
38
|
+
return 0n;
|
|
39
|
+
const value = bnU64((0, binary_js_1.readU64LE)(data, offset.value));
|
|
40
|
+
offset.value += 8;
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
function readOptionalPubkey(data, offset) {
|
|
44
|
+
if (offset.value + 32 > data.length)
|
|
45
|
+
return (0, dex_event_js_1.defaultPubkey)();
|
|
46
|
+
const value = (0, binary_js_1.readPubkey)(data, offset.value) ?? (0, dex_event_js_1.defaultPubkey)();
|
|
47
|
+
offset.value += 32;
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
function readTradeShareholders(data, offset) {
|
|
51
|
+
if (offset.value + 4 > data.length)
|
|
52
|
+
return [];
|
|
53
|
+
const n = (0, binary_js_1.readU32LE)(data, offset.value);
|
|
54
|
+
if (n === null || n > 64)
|
|
55
|
+
return null;
|
|
56
|
+
offset.value += 4;
|
|
57
|
+
if (offset.value + n * 34 > data.length)
|
|
58
|
+
return null;
|
|
59
|
+
const out = [];
|
|
60
|
+
for (let i = 0; i < n; i++) {
|
|
61
|
+
const address = (0, binary_js_1.readPubkey)(data, offset.value);
|
|
62
|
+
if (!address)
|
|
63
|
+
return null;
|
|
64
|
+
offset.value += 32;
|
|
65
|
+
const share_bps = (0, binary_js_1.readU16LE)(data, offset.value);
|
|
66
|
+
if (share_bps === null)
|
|
67
|
+
return null;
|
|
68
|
+
offset.value += 2;
|
|
69
|
+
out.push({ address, share_bps });
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
25
73
|
function parsePumpFunLogDecoded(programData, metadata) {
|
|
26
74
|
const disc = (0, binary_js_1.readDiscriminatorU64)(programData);
|
|
27
75
|
if (disc === null)
|
|
@@ -33,6 +81,9 @@ function parsePumpFunLogDecoded(programData, metadata) {
|
|
|
33
81
|
return parseTradeFromData(data, metadata, false);
|
|
34
82
|
if (disc === DISC_MIGRATE)
|
|
35
83
|
return parseMigrateFromData(data, metadata);
|
|
84
|
+
if (disc === DISC_MIGRATE_BONDING_CURVE_CREATOR) {
|
|
85
|
+
return parseMigrateBondingCurveCreatorFromData(data, metadata);
|
|
86
|
+
}
|
|
36
87
|
return null;
|
|
37
88
|
}
|
|
38
89
|
function parseTradeFromData(data, metadata, isCreatedBuy) {
|
|
@@ -99,11 +150,23 @@ function parseTradeFromData(data, metadata, isCreatedBuy) {
|
|
|
99
150
|
o = rs.next;
|
|
100
151
|
}
|
|
101
152
|
}
|
|
153
|
+
ix_name = normalizePumpfunIxName(ix_name);
|
|
102
154
|
const mayhem_mode = (0, binary_js_1.readBool)(data, o) ?? false;
|
|
103
155
|
o += 1;
|
|
104
156
|
const cashback_fee_basis_points = o + 8 <= data.length ? bnU64((0, binary_js_1.readU64LE)(data, o)) : 0n;
|
|
105
157
|
o += 8;
|
|
106
158
|
const cashback = o + 8 <= data.length ? bnU64((0, binary_js_1.readU64LE)(data, o)) : 0n;
|
|
159
|
+
o += 8;
|
|
160
|
+
const tail = { value: o };
|
|
161
|
+
const buyback_fee_basis_points = readOptionalU64(data, tail);
|
|
162
|
+
const buyback_fee = readOptionalU64(data, tail);
|
|
163
|
+
const shareholders = readTradeShareholders(data, tail);
|
|
164
|
+
if (shareholders === null)
|
|
165
|
+
return null;
|
|
166
|
+
const quote_mint = readOptionalPubkey(data, tail);
|
|
167
|
+
const quote_amount = readOptionalU64(data, tail);
|
|
168
|
+
const virtual_quote_reserves = readOptionalU64(data, tail);
|
|
169
|
+
const real_quote_reserves = readOptionalU64(data, tail);
|
|
107
170
|
const trade = {
|
|
108
171
|
metadata,
|
|
109
172
|
mint,
|
|
@@ -132,6 +195,13 @@ function parseTradeFromData(data, metadata, isCreatedBuy) {
|
|
|
132
195
|
mayhem_mode,
|
|
133
196
|
cashback_fee_basis_points,
|
|
134
197
|
cashback,
|
|
198
|
+
buyback_fee_basis_points,
|
|
199
|
+
buyback_fee,
|
|
200
|
+
shareholders,
|
|
201
|
+
quote_mint,
|
|
202
|
+
quote_amount,
|
|
203
|
+
virtual_quote_reserves,
|
|
204
|
+
real_quote_reserves,
|
|
135
205
|
is_cashback_coin: cashback_fee_basis_points > 0n,
|
|
136
206
|
bonding_curve: (0, dex_event_js_1.defaultPubkey)(),
|
|
137
207
|
associated_bonding_curve: (0, dex_event_js_1.defaultPubkey)(),
|
|
@@ -142,8 +212,11 @@ function parseTradeFromData(data, metadata, isCreatedBuy) {
|
|
|
142
212
|
return { PumpFunBuy: trade };
|
|
143
213
|
if (ix_name === "sell")
|
|
144
214
|
return { PumpFunSell: trade };
|
|
145
|
-
if (ix_name === "buy_exact_sol_in")
|
|
215
|
+
if (ix_name === "buy_exact_sol_in") {
|
|
146
216
|
return { PumpFunBuyExactSolIn: trade };
|
|
217
|
+
}
|
|
218
|
+
if (ix_name === "buy_exact_quote_in")
|
|
219
|
+
return { PumpFunBuy: trade };
|
|
147
220
|
return { PumpFunTrade: trade };
|
|
148
221
|
}
|
|
149
222
|
function parseCreateFromData(data, metadata) {
|
|
@@ -193,6 +266,10 @@ function parseCreateFromData(data, metadata) {
|
|
|
193
266
|
const is_mayhem_mode = (0, binary_js_1.readBool)(data, o) ?? false;
|
|
194
267
|
o += 1;
|
|
195
268
|
const is_cashback_enabled = (0, binary_js_1.readBool)(data, o) ?? false;
|
|
269
|
+
o += 1;
|
|
270
|
+
const quote_mint = o + 32 <= data.length ? (0, binary_js_1.readPubkey)(data, o) : (0, dex_event_js_1.defaultPubkey)();
|
|
271
|
+
o += 32;
|
|
272
|
+
const virtual_quote_reserves = o + 8 <= data.length ? bnU64((0, binary_js_1.readU64LE)(data, o)) : 0n;
|
|
196
273
|
const ev = {
|
|
197
274
|
metadata,
|
|
198
275
|
name: n1.s,
|
|
@@ -210,6 +287,8 @@ function parseCreateFromData(data, metadata) {
|
|
|
210
287
|
token_program,
|
|
211
288
|
is_mayhem_mode,
|
|
212
289
|
is_cashback_enabled,
|
|
290
|
+
quote_mint,
|
|
291
|
+
virtual_quote_reserves,
|
|
213
292
|
};
|
|
214
293
|
return { PumpFunCreate: ev };
|
|
215
294
|
}
|
|
@@ -245,7 +324,48 @@ function parseMigrateFromData(data, metadata) {
|
|
|
245
324
|
};
|
|
246
325
|
return { PumpFunMigrate: ev };
|
|
247
326
|
}
|
|
327
|
+
function parseMigrateBondingCurveCreatorFromData(data, metadata) {
|
|
328
|
+
if (data.length < 8 + 32 * 5)
|
|
329
|
+
return null;
|
|
330
|
+
let o = 0;
|
|
331
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
332
|
+
o += 8;
|
|
333
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
334
|
+
if (!mint)
|
|
335
|
+
return null;
|
|
336
|
+
o += 32;
|
|
337
|
+
const bonding_curve = (0, binary_js_1.readPubkey)(data, o);
|
|
338
|
+
if (!bonding_curve)
|
|
339
|
+
return null;
|
|
340
|
+
o += 32;
|
|
341
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
342
|
+
if (!sharing_config)
|
|
343
|
+
return null;
|
|
344
|
+
o += 32;
|
|
345
|
+
const old_creator = (0, binary_js_1.readPubkey)(data, o);
|
|
346
|
+
if (!old_creator)
|
|
347
|
+
return null;
|
|
348
|
+
o += 32;
|
|
349
|
+
const new_creator = (0, binary_js_1.readPubkey)(data, o);
|
|
350
|
+
if (!new_creator)
|
|
351
|
+
return null;
|
|
352
|
+
const ev = {
|
|
353
|
+
metadata,
|
|
354
|
+
timestamp,
|
|
355
|
+
mint,
|
|
356
|
+
bonding_curve,
|
|
357
|
+
sharing_config,
|
|
358
|
+
old_creator,
|
|
359
|
+
new_creator,
|
|
360
|
+
};
|
|
361
|
+
return { PumpFunMigrateBondingCurveCreator: ev };
|
|
362
|
+
}
|
|
248
363
|
/** u64 discriminator little-endian */
|
|
249
364
|
function pumpDiscriminators() {
|
|
250
|
-
return {
|
|
365
|
+
return {
|
|
366
|
+
CREATE: DISC_CREATE,
|
|
367
|
+
TRADE: DISC_TRADE,
|
|
368
|
+
MIGRATE: DISC_MIGRATE,
|
|
369
|
+
MIGRATE_BONDING_CURVE_CREATOR: DISC_MIGRATE_BONDING_CURVE_CREATOR,
|
|
370
|
+
};
|
|
251
371
|
}
|
package/dist/logs/pump_amm.js
CHANGED
|
@@ -18,7 +18,7 @@ function bnI64(v) {
|
|
|
18
18
|
}
|
|
19
19
|
const ZP = (0, dex_event_js_1.defaultPubkey)();
|
|
20
20
|
function parseBuyFromData(data, metadata) {
|
|
21
|
-
const MIN =
|
|
21
|
+
const MIN = 16 * 8 + 7 * 32 + 1 + 5 * 8 + 4;
|
|
22
22
|
if (data.length < MIN)
|
|
23
23
|
return null;
|
|
24
24
|
let o = 0;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EventMetadata } from "../core/metadata.js";
|
|
2
|
+
import type { DexEvent, PumpFeesFeeTier, PumpFeesFees, PumpFeesShareholder } from "../core/dex_event.js";
|
|
3
|
+
export declare function readFeesAt(data: Uint8Array, offset: number): {
|
|
4
|
+
value: PumpFeesFees;
|
|
5
|
+
next: number;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function readShareholdersVec(data: Uint8Array, offset: number): {
|
|
8
|
+
value: PumpFeesShareholder[];
|
|
9
|
+
next: number;
|
|
10
|
+
} | null;
|
|
11
|
+
export declare function readFeeTiersVec(data: Uint8Array, offset: number): {
|
|
12
|
+
value: PumpFeesFeeTier[];
|
|
13
|
+
next: number;
|
|
14
|
+
} | null;
|
|
15
|
+
export declare function parseCreateFeeSharingConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
16
|
+
export declare function parseInitializeFeeConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
17
|
+
export declare function parseResetFeeSharingConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
18
|
+
export declare function parseRevokeFeeSharingAuthorityFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
19
|
+
export declare function parseTransferFeeSharingAuthorityFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
20
|
+
export declare function parseUpdateAdminFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
21
|
+
export declare function parseUpdateFeeConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
22
|
+
export declare function parseUpdateFeeSharesFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
23
|
+
export declare function parseUpsertFeeTiersFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readFeesAt = readFeesAt;
|
|
4
|
+
exports.readShareholdersVec = readShareholdersVec;
|
|
5
|
+
exports.readFeeTiersVec = readFeeTiersVec;
|
|
6
|
+
exports.parseCreateFeeSharingConfigFromData = parseCreateFeeSharingConfigFromData;
|
|
7
|
+
exports.parseInitializeFeeConfigFromData = parseInitializeFeeConfigFromData;
|
|
8
|
+
exports.parseResetFeeSharingConfigFromData = parseResetFeeSharingConfigFromData;
|
|
9
|
+
exports.parseRevokeFeeSharingAuthorityFromData = parseRevokeFeeSharingAuthorityFromData;
|
|
10
|
+
exports.parseTransferFeeSharingAuthorityFromData = parseTransferFeeSharingAuthorityFromData;
|
|
11
|
+
exports.parseUpdateAdminFromData = parseUpdateAdminFromData;
|
|
12
|
+
exports.parseUpdateFeeConfigFromData = parseUpdateFeeConfigFromData;
|
|
13
|
+
exports.parseUpdateFeeSharesFromData = parseUpdateFeeSharesFromData;
|
|
14
|
+
exports.parseUpsertFeeTiersFromData = parseUpsertFeeTiersFromData;
|
|
15
|
+
const dex_event_js_1 = require("../core/dex_event.js");
|
|
16
|
+
const binary_js_1 = require("../util/binary.js");
|
|
17
|
+
const MAX_SHAREHOLDERS = 64;
|
|
18
|
+
const MAX_FEE_TIERS = 64;
|
|
19
|
+
function bnI64(v) {
|
|
20
|
+
return v ?? 0n;
|
|
21
|
+
}
|
|
22
|
+
function bnU64(v) {
|
|
23
|
+
return v ?? 0n;
|
|
24
|
+
}
|
|
25
|
+
function readFeesAt(data, offset) {
|
|
26
|
+
if (offset + 24 > data.length)
|
|
27
|
+
return null;
|
|
28
|
+
const lp_fee_bps = bnU64((0, binary_js_1.readU64LE)(data, offset));
|
|
29
|
+
offset += 8;
|
|
30
|
+
const protocol_fee_bps = bnU64((0, binary_js_1.readU64LE)(data, offset));
|
|
31
|
+
offset += 8;
|
|
32
|
+
const creator_fee_bps = bnU64((0, binary_js_1.readU64LE)(data, offset));
|
|
33
|
+
offset += 8;
|
|
34
|
+
return { value: { lp_fee_bps, protocol_fee_bps, creator_fee_bps }, next: offset };
|
|
35
|
+
}
|
|
36
|
+
function readShareholdersVec(data, offset) {
|
|
37
|
+
const n = (0, binary_js_1.readU32LE)(data, offset);
|
|
38
|
+
if (n === null || n > MAX_SHAREHOLDERS)
|
|
39
|
+
return null;
|
|
40
|
+
offset += 4;
|
|
41
|
+
const value = [];
|
|
42
|
+
for (let i = 0; i < n; i++) {
|
|
43
|
+
const address = (0, binary_js_1.readPubkey)(data, offset);
|
|
44
|
+
if (!address)
|
|
45
|
+
return null;
|
|
46
|
+
offset += 32;
|
|
47
|
+
const share_bps = (0, binary_js_1.readU16LE)(data, offset);
|
|
48
|
+
if (share_bps === null)
|
|
49
|
+
return null;
|
|
50
|
+
offset += 2;
|
|
51
|
+
value.push({ address, share_bps });
|
|
52
|
+
}
|
|
53
|
+
return { value, next: offset };
|
|
54
|
+
}
|
|
55
|
+
function readFeeTiersVec(data, offset) {
|
|
56
|
+
const n = (0, binary_js_1.readU32LE)(data, offset);
|
|
57
|
+
if (n === null || n > MAX_FEE_TIERS)
|
|
58
|
+
return null;
|
|
59
|
+
offset += 4;
|
|
60
|
+
const value = [];
|
|
61
|
+
for (let i = 0; i < n; i++) {
|
|
62
|
+
const market_cap_lamports_threshold = (0, binary_js_1.readU128LE)(data, offset);
|
|
63
|
+
if (market_cap_lamports_threshold === null)
|
|
64
|
+
return null;
|
|
65
|
+
offset += 16;
|
|
66
|
+
const fees = readFeesAt(data, offset);
|
|
67
|
+
if (!fees)
|
|
68
|
+
return null;
|
|
69
|
+
offset = fees.next;
|
|
70
|
+
value.push({ market_cap_lamports_threshold, fees: fees.value });
|
|
71
|
+
}
|
|
72
|
+
return { value, next: offset };
|
|
73
|
+
}
|
|
74
|
+
function readOptionPubkeyAt(data, offset) {
|
|
75
|
+
const tag = (0, binary_js_1.readU8)(data, offset);
|
|
76
|
+
if (tag === null)
|
|
77
|
+
return null;
|
|
78
|
+
offset += 1;
|
|
79
|
+
if (tag === 0)
|
|
80
|
+
return { value: undefined, next: offset };
|
|
81
|
+
if (tag !== 1)
|
|
82
|
+
return null;
|
|
83
|
+
const value = (0, binary_js_1.readPubkey)(data, offset);
|
|
84
|
+
if (!value)
|
|
85
|
+
return null;
|
|
86
|
+
return { value, next: offset + 32 };
|
|
87
|
+
}
|
|
88
|
+
function readConfigStatusAt(data, offset) {
|
|
89
|
+
const tag = (0, binary_js_1.readU8)(data, offset);
|
|
90
|
+
if (tag === null)
|
|
91
|
+
return null;
|
|
92
|
+
if (tag === 0)
|
|
93
|
+
return { value: "Paused", next: offset + 1 };
|
|
94
|
+
if (tag === 1)
|
|
95
|
+
return { value: "Active", next: offset + 1 };
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function parseCreateFeeSharingConfigFromData(data, metadata) {
|
|
99
|
+
let o = 0;
|
|
100
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
101
|
+
if (o + 8 > data.length)
|
|
102
|
+
return null;
|
|
103
|
+
o += 8;
|
|
104
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
105
|
+
if (!mint)
|
|
106
|
+
return null;
|
|
107
|
+
o += 32;
|
|
108
|
+
const bonding_curve = (0, binary_js_1.readPubkey)(data, o);
|
|
109
|
+
if (!bonding_curve)
|
|
110
|
+
return null;
|
|
111
|
+
o += 32;
|
|
112
|
+
const pool = readOptionPubkeyAt(data, o);
|
|
113
|
+
if (!pool)
|
|
114
|
+
return null;
|
|
115
|
+
o = pool.next;
|
|
116
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
117
|
+
if (!sharing_config)
|
|
118
|
+
return null;
|
|
119
|
+
o += 32;
|
|
120
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
121
|
+
if (!admin)
|
|
122
|
+
return null;
|
|
123
|
+
o += 32;
|
|
124
|
+
const initial_shareholders = readShareholdersVec(data, o);
|
|
125
|
+
if (!initial_shareholders)
|
|
126
|
+
return null;
|
|
127
|
+
o = initial_shareholders.next;
|
|
128
|
+
const status = readConfigStatusAt(data, o);
|
|
129
|
+
if (!status)
|
|
130
|
+
return null;
|
|
131
|
+
o = status.next;
|
|
132
|
+
if (o !== data.length)
|
|
133
|
+
return null;
|
|
134
|
+
return {
|
|
135
|
+
PumpFeesCreateFeeSharingConfig: {
|
|
136
|
+
metadata,
|
|
137
|
+
timestamp,
|
|
138
|
+
mint,
|
|
139
|
+
bonding_curve,
|
|
140
|
+
pool: pool.value,
|
|
141
|
+
sharing_config,
|
|
142
|
+
admin,
|
|
143
|
+
initial_shareholders: initial_shareholders.value,
|
|
144
|
+
status: status.value,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function parseInitializeFeeConfigFromData(data, metadata) {
|
|
149
|
+
if (data.length !== 8 + 32 + 32)
|
|
150
|
+
return null;
|
|
151
|
+
let o = 0;
|
|
152
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
153
|
+
o += 8;
|
|
154
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
155
|
+
if (!admin)
|
|
156
|
+
return null;
|
|
157
|
+
o += 32;
|
|
158
|
+
const fee_config = (0, binary_js_1.readPubkey)(data, o);
|
|
159
|
+
if (!fee_config)
|
|
160
|
+
return null;
|
|
161
|
+
return { PumpFeesInitializeFeeConfig: { metadata, timestamp, admin, fee_config } };
|
|
162
|
+
}
|
|
163
|
+
function parseResetFeeSharingConfigFromData(data, metadata) {
|
|
164
|
+
let o = 0;
|
|
165
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
166
|
+
if (o + 8 > data.length)
|
|
167
|
+
return null;
|
|
168
|
+
o += 8;
|
|
169
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
170
|
+
if (!mint)
|
|
171
|
+
return null;
|
|
172
|
+
o += 32;
|
|
173
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
174
|
+
if (!sharing_config)
|
|
175
|
+
return null;
|
|
176
|
+
o += 32;
|
|
177
|
+
const old_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
178
|
+
if (!old_admin)
|
|
179
|
+
return null;
|
|
180
|
+
o += 32;
|
|
181
|
+
const old_shareholders = readShareholdersVec(data, o);
|
|
182
|
+
if (!old_shareholders)
|
|
183
|
+
return null;
|
|
184
|
+
o = old_shareholders.next;
|
|
185
|
+
const new_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
186
|
+
if (!new_admin)
|
|
187
|
+
return null;
|
|
188
|
+
o += 32;
|
|
189
|
+
const new_shareholders = readShareholdersVec(data, o);
|
|
190
|
+
if (!new_shareholders)
|
|
191
|
+
return null;
|
|
192
|
+
o = new_shareholders.next;
|
|
193
|
+
if (o !== data.length)
|
|
194
|
+
return null;
|
|
195
|
+
return {
|
|
196
|
+
PumpFeesResetFeeSharingConfig: {
|
|
197
|
+
metadata,
|
|
198
|
+
timestamp,
|
|
199
|
+
mint,
|
|
200
|
+
sharing_config,
|
|
201
|
+
old_admin,
|
|
202
|
+
old_shareholders: old_shareholders.value,
|
|
203
|
+
new_admin,
|
|
204
|
+
new_shareholders: new_shareholders.value,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function parseRevokeFeeSharingAuthorityFromData(data, metadata) {
|
|
209
|
+
if (data.length !== 8 + 32 + 32 + 32)
|
|
210
|
+
return null;
|
|
211
|
+
let o = 0;
|
|
212
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
213
|
+
o += 8;
|
|
214
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
215
|
+
if (!mint)
|
|
216
|
+
return null;
|
|
217
|
+
o += 32;
|
|
218
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
219
|
+
if (!sharing_config)
|
|
220
|
+
return null;
|
|
221
|
+
o += 32;
|
|
222
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
223
|
+
if (!admin)
|
|
224
|
+
return null;
|
|
225
|
+
return { PumpFeesRevokeFeeSharingAuthority: { metadata, timestamp, mint, sharing_config, admin } };
|
|
226
|
+
}
|
|
227
|
+
function parseTransferFeeSharingAuthorityFromData(data, metadata) {
|
|
228
|
+
if (data.length !== 8 + 32 + 32 + 32 + 32)
|
|
229
|
+
return null;
|
|
230
|
+
let o = 0;
|
|
231
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
232
|
+
o += 8;
|
|
233
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
234
|
+
if (!mint)
|
|
235
|
+
return null;
|
|
236
|
+
o += 32;
|
|
237
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
238
|
+
if (!sharing_config)
|
|
239
|
+
return null;
|
|
240
|
+
o += 32;
|
|
241
|
+
const old_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
242
|
+
if (!old_admin)
|
|
243
|
+
return null;
|
|
244
|
+
o += 32;
|
|
245
|
+
const new_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
246
|
+
if (!new_admin)
|
|
247
|
+
return null;
|
|
248
|
+
return {
|
|
249
|
+
PumpFeesTransferFeeSharingAuthority: { metadata, timestamp, mint, sharing_config, old_admin, new_admin },
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function parseUpdateAdminFromData(data, metadata) {
|
|
253
|
+
if (data.length !== 8 + 32 + 32)
|
|
254
|
+
return null;
|
|
255
|
+
let o = 0;
|
|
256
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
257
|
+
o += 8;
|
|
258
|
+
const old_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
259
|
+
if (!old_admin)
|
|
260
|
+
return null;
|
|
261
|
+
o += 32;
|
|
262
|
+
const new_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
263
|
+
if (!new_admin)
|
|
264
|
+
return null;
|
|
265
|
+
return { PumpFeesUpdateAdmin: { metadata, timestamp, old_admin, new_admin } };
|
|
266
|
+
}
|
|
267
|
+
function parseUpdateFeeConfigFromData(data, metadata) {
|
|
268
|
+
let o = 0;
|
|
269
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
270
|
+
if (o + 8 > data.length)
|
|
271
|
+
return null;
|
|
272
|
+
o += 8;
|
|
273
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
274
|
+
if (!admin)
|
|
275
|
+
return null;
|
|
276
|
+
o += 32;
|
|
277
|
+
const fee_config = (0, binary_js_1.readPubkey)(data, o);
|
|
278
|
+
if (!fee_config)
|
|
279
|
+
return null;
|
|
280
|
+
o += 32;
|
|
281
|
+
const fee_tiers = readFeeTiersVec(data, o);
|
|
282
|
+
if (!fee_tiers)
|
|
283
|
+
return null;
|
|
284
|
+
o = fee_tiers.next;
|
|
285
|
+
const flat_fees = readFeesAt(data, o);
|
|
286
|
+
if (!flat_fees)
|
|
287
|
+
return null;
|
|
288
|
+
o = flat_fees.next;
|
|
289
|
+
if (o !== data.length)
|
|
290
|
+
return null;
|
|
291
|
+
return {
|
|
292
|
+
PumpFeesUpdateFeeConfig: {
|
|
293
|
+
metadata,
|
|
294
|
+
timestamp,
|
|
295
|
+
admin,
|
|
296
|
+
fee_config,
|
|
297
|
+
fee_tiers: fee_tiers.value,
|
|
298
|
+
flat_fees: flat_fees.value,
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function parseUpdateFeeSharesFromData(data, metadata) {
|
|
303
|
+
let o = 0;
|
|
304
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
305
|
+
if (o + 8 > data.length)
|
|
306
|
+
return null;
|
|
307
|
+
o += 8;
|
|
308
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
309
|
+
if (!mint)
|
|
310
|
+
return null;
|
|
311
|
+
o += 32;
|
|
312
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
313
|
+
if (!sharing_config)
|
|
314
|
+
return null;
|
|
315
|
+
o += 32;
|
|
316
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
317
|
+
if (!admin)
|
|
318
|
+
return null;
|
|
319
|
+
o += 32;
|
|
320
|
+
const new_shareholders = readShareholdersVec(data, o);
|
|
321
|
+
if (!new_shareholders)
|
|
322
|
+
return null;
|
|
323
|
+
o = new_shareholders.next;
|
|
324
|
+
if (o !== data.length)
|
|
325
|
+
return null;
|
|
326
|
+
return {
|
|
327
|
+
PumpFeesUpdateFeeShares: {
|
|
328
|
+
metadata,
|
|
329
|
+
timestamp,
|
|
330
|
+
mint,
|
|
331
|
+
sharing_config,
|
|
332
|
+
admin,
|
|
333
|
+
bonding_curve: (0, dex_event_js_1.defaultPubkey)(),
|
|
334
|
+
pump_creator_vault: (0, dex_event_js_1.defaultPubkey)(),
|
|
335
|
+
new_shareholders: new_shareholders.value,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function parseUpsertFeeTiersFromData(data, metadata) {
|
|
340
|
+
let o = 0;
|
|
341
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
342
|
+
if (o + 8 > data.length)
|
|
343
|
+
return null;
|
|
344
|
+
o += 8;
|
|
345
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
346
|
+
if (!admin)
|
|
347
|
+
return null;
|
|
348
|
+
o += 32;
|
|
349
|
+
const fee_config = (0, binary_js_1.readPubkey)(data, o);
|
|
350
|
+
if (!fee_config)
|
|
351
|
+
return null;
|
|
352
|
+
o += 32;
|
|
353
|
+
const fee_tiers = readFeeTiersVec(data, o);
|
|
354
|
+
if (!fee_tiers)
|
|
355
|
+
return null;
|
|
356
|
+
o = fee_tiers.next;
|
|
357
|
+
const offset = (0, binary_js_1.readU8)(data, o);
|
|
358
|
+
if (offset === null)
|
|
359
|
+
return null;
|
|
360
|
+
o += 1;
|
|
361
|
+
if (o !== data.length)
|
|
362
|
+
return null;
|
|
363
|
+
return { PumpFeesUpsertFeeTiers: { metadata, timestamp, admin, fee_config, fee_tiers: fee_tiers.value, offset } };
|
|
364
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Raydium LaunchLab 日志解析 */
|
|
2
|
+
import type { EventMetadata } from "../core/metadata.js";
|
|
3
|
+
import type { DexEvent } from "../core/dex_event.js";
|
|
4
|
+
export declare const RAYDIUM_LAUNCHLAB_DISC: {
|
|
5
|
+
TRADE: bigint;
|
|
6
|
+
POOL_CREATE: bigint;
|
|
7
|
+
};
|
|
8
|
+
export declare function parseRaydiumLaunchlabTradeFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
9
|
+
export declare function parseRaydiumLaunchlabPoolCreateFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
10
|
+
export declare function parseRaydiumLaunchlabFromDiscriminator(discriminator: bigint, data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RAYDIUM_LAUNCHLAB_DISC = void 0;
|
|
4
|
+
exports.parseRaydiumLaunchlabTradeFromData = parseRaydiumLaunchlabTradeFromData;
|
|
5
|
+
exports.parseRaydiumLaunchlabPoolCreateFromData = parseRaydiumLaunchlabPoolCreateFromData;
|
|
6
|
+
exports.parseRaydiumLaunchlabFromDiscriminator = parseRaydiumLaunchlabFromDiscriminator;
|
|
7
|
+
const binary_js_1 = require("../util/binary.js");
|
|
8
|
+
function disc(bytes) {
|
|
9
|
+
const u8 = new Uint8Array(8);
|
|
10
|
+
for (let i = 0; i < 8; i++)
|
|
11
|
+
u8[i] = bytes[i];
|
|
12
|
+
return new DataView(u8.buffer).getBigUint64(0, true);
|
|
13
|
+
}
|
|
14
|
+
exports.RAYDIUM_LAUNCHLAB_DISC = {
|
|
15
|
+
TRADE: disc([189, 219, 127, 211, 78, 230, 97, 238]),
|
|
16
|
+
POOL_CREATE: disc([151, 215, 226, 9, 118, 161, 115, 174]),
|
|
17
|
+
};
|
|
18
|
+
function bn64(v) {
|
|
19
|
+
return v ?? 0n;
|
|
20
|
+
}
|
|
21
|
+
function parseRaydiumLaunchlabTradeFromData(data, metadata) {
|
|
22
|
+
const pool_state = (0, binary_js_1.readPubkey)(data, 0);
|
|
23
|
+
const amount_in = (0, binary_js_1.readU64LE)(data, 88);
|
|
24
|
+
const amount_out = (0, binary_js_1.readU64LE)(data, 96);
|
|
25
|
+
const trade_direction = (0, binary_js_1.readU8)(data, 136);
|
|
26
|
+
const exact_in = (0, binary_js_1.readBool)(data, 138);
|
|
27
|
+
if (!pool_state || amount_in === null || amount_out === null || trade_direction === null || exact_in === null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const is_buy = trade_direction === 0;
|
|
31
|
+
const ev = {
|
|
32
|
+
metadata,
|
|
33
|
+
pool_state,
|
|
34
|
+
user: "11111111111111111111111111111111",
|
|
35
|
+
amount_in: bn64(amount_in),
|
|
36
|
+
amount_out: bn64(amount_out),
|
|
37
|
+
is_buy,
|
|
38
|
+
trade_direction: is_buy ? "Buy" : "Sell",
|
|
39
|
+
exact_in,
|
|
40
|
+
};
|
|
41
|
+
return { RaydiumLaunchlabTrade: ev };
|
|
42
|
+
}
|
|
43
|
+
function parseRaydiumLaunchlabPoolCreateFromData(data, metadata) {
|
|
44
|
+
if (data.length < 97)
|
|
45
|
+
return null;
|
|
46
|
+
let o = 0;
|
|
47
|
+
const pool_state = (0, binary_js_1.readPubkey)(data, o);
|
|
48
|
+
o += 32;
|
|
49
|
+
const creator = (0, binary_js_1.readPubkey)(data, o);
|
|
50
|
+
o += 32;
|
|
51
|
+
const config = (0, binary_js_1.readPubkey)(data, o);
|
|
52
|
+
if (!pool_state || !creator || !config)
|
|
53
|
+
return null;
|
|
54
|
+
o += 32;
|
|
55
|
+
const decimals = (0, binary_js_1.readU8)(data, o);
|
|
56
|
+
if (decimals === null)
|
|
57
|
+
return null;
|
|
58
|
+
o += 1;
|
|
59
|
+
const name = (0, binary_js_1.readBorshString)(data, o);
|
|
60
|
+
if (!name)
|
|
61
|
+
return null;
|
|
62
|
+
o = name.next;
|
|
63
|
+
const symbol = (0, binary_js_1.readBorshString)(data, o);
|
|
64
|
+
if (!symbol)
|
|
65
|
+
return null;
|
|
66
|
+
o = symbol.next;
|
|
67
|
+
const uri = (0, binary_js_1.readBorshString)(data, o);
|
|
68
|
+
if (!uri)
|
|
69
|
+
return null;
|
|
70
|
+
const ev = {
|
|
71
|
+
metadata,
|
|
72
|
+
base_mint_param: { symbol: symbol.s, name: name.s, uri: uri.s, decimals },
|
|
73
|
+
pool_state,
|
|
74
|
+
creator,
|
|
75
|
+
};
|
|
76
|
+
return { RaydiumLaunchlabPoolCreate: ev };
|
|
77
|
+
}
|
|
78
|
+
function parseRaydiumLaunchlabFromDiscriminator(discriminator, data, metadata) {
|
|
79
|
+
if (discriminator === exports.RAYDIUM_LAUNCHLAB_DISC.TRADE)
|
|
80
|
+
return parseRaydiumLaunchlabTradeFromData(data, metadata);
|
|
81
|
+
if (discriminator === exports.RAYDIUM_LAUNCHLAB_DISC.POOL_CREATE)
|
|
82
|
+
return parseRaydiumLaunchlabPoolCreateFromData(data, metadata);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
@@ -14,6 +14,8 @@ export declare function applyAccountFillsToLogEvents(events: DexEvent[], msg: Me
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function parseRpcTransaction(tx: VersionedTransactionResponse, signature: string, filter?: EventTypeFilter, options?: {
|
|
16
16
|
grpcRecvUs?: number;
|
|
17
|
+
txIndex?: number;
|
|
18
|
+
blockTimeUs?: number;
|
|
17
19
|
}): {
|
|
18
20
|
ok: true;
|
|
19
21
|
events: DexEvent[];
|