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
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPumpfunGlobalAccount = isPumpfunGlobalAccount;
|
|
4
|
+
exports.parsePumpfunGlobal = parsePumpfunGlobal;
|
|
5
|
+
exports.parsePumpfunAccount = parsePumpfunAccount;
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
const binary_js_1 = require("../util/binary.js");
|
|
8
|
+
const program_ids_js_1 = require("../instr/program_ids.js");
|
|
9
|
+
const GLOBAL_DISC = Uint8Array.from([167, 232, 232, 177, 200, 108, 114, 127]);
|
|
10
|
+
const GLOBAL_BODY = 1021;
|
|
11
|
+
function isPumpfunGlobalAccount(data) {
|
|
12
|
+
return (0, utils_js_1.hasDiscriminator)(data, GLOBAL_DISC);
|
|
13
|
+
}
|
|
14
|
+
function readPubkeyArray(data, offset, len) {
|
|
15
|
+
const value = [];
|
|
16
|
+
let o = offset;
|
|
17
|
+
for (let i = 0; i < len; i++) {
|
|
18
|
+
const pubkey = (0, binary_js_1.readPubkey)(data, o);
|
|
19
|
+
if (pubkey === null)
|
|
20
|
+
return null;
|
|
21
|
+
value.push(pubkey);
|
|
22
|
+
o += 32;
|
|
23
|
+
}
|
|
24
|
+
return { value, next: o };
|
|
25
|
+
}
|
|
26
|
+
function parsePumpfunGlobal(account, metadata) {
|
|
27
|
+
if (account.data.length < 8 + GLOBAL_BODY)
|
|
28
|
+
return null;
|
|
29
|
+
if (!isPumpfunGlobalAccount(account.data))
|
|
30
|
+
return null;
|
|
31
|
+
const d = account.data.subarray(8);
|
|
32
|
+
let o = 0;
|
|
33
|
+
const initializedByte = (0, binary_js_1.readU8)(d, o);
|
|
34
|
+
if (initializedByte === null)
|
|
35
|
+
return null;
|
|
36
|
+
const initialized = initializedByte !== 0;
|
|
37
|
+
o += 1;
|
|
38
|
+
const authority = (0, binary_js_1.readPubkey)(d, o);
|
|
39
|
+
if (authority === null)
|
|
40
|
+
return null;
|
|
41
|
+
o += 32;
|
|
42
|
+
const fee_recipient = (0, binary_js_1.readPubkey)(d, o);
|
|
43
|
+
if (fee_recipient === null)
|
|
44
|
+
return null;
|
|
45
|
+
o += 32;
|
|
46
|
+
const initial_virtual_token_reserves = (0, binary_js_1.readU64LE)(d, o);
|
|
47
|
+
if (initial_virtual_token_reserves === null)
|
|
48
|
+
return null;
|
|
49
|
+
o += 8;
|
|
50
|
+
const initial_virtual_sol_reserves = (0, binary_js_1.readU64LE)(d, o);
|
|
51
|
+
if (initial_virtual_sol_reserves === null)
|
|
52
|
+
return null;
|
|
53
|
+
o += 8;
|
|
54
|
+
const initial_real_token_reserves = (0, binary_js_1.readU64LE)(d, o);
|
|
55
|
+
if (initial_real_token_reserves === null)
|
|
56
|
+
return null;
|
|
57
|
+
o += 8;
|
|
58
|
+
const token_total_supply = (0, binary_js_1.readU64LE)(d, o);
|
|
59
|
+
if (token_total_supply === null)
|
|
60
|
+
return null;
|
|
61
|
+
o += 8;
|
|
62
|
+
const fee_basis_points = (0, binary_js_1.readU64LE)(d, o);
|
|
63
|
+
if (fee_basis_points === null)
|
|
64
|
+
return null;
|
|
65
|
+
o += 8;
|
|
66
|
+
const withdraw_authority = (0, binary_js_1.readPubkey)(d, o);
|
|
67
|
+
if (withdraw_authority === null)
|
|
68
|
+
return null;
|
|
69
|
+
o += 32;
|
|
70
|
+
const enableMigrateByte = (0, binary_js_1.readU8)(d, o);
|
|
71
|
+
if (enableMigrateByte === null)
|
|
72
|
+
return null;
|
|
73
|
+
const enable_migrate = enableMigrateByte !== 0;
|
|
74
|
+
o += 1;
|
|
75
|
+
const pool_migration_fee = (0, binary_js_1.readU64LE)(d, o);
|
|
76
|
+
if (pool_migration_fee === null)
|
|
77
|
+
return null;
|
|
78
|
+
o += 8;
|
|
79
|
+
const creator_fee_basis_points = (0, binary_js_1.readU64LE)(d, o);
|
|
80
|
+
if (creator_fee_basis_points === null)
|
|
81
|
+
return null;
|
|
82
|
+
o += 8;
|
|
83
|
+
const feeRecipients = readPubkeyArray(d, o, 8);
|
|
84
|
+
if (feeRecipients === null)
|
|
85
|
+
return null;
|
|
86
|
+
const fee_recipients = feeRecipients.value;
|
|
87
|
+
o = feeRecipients.next;
|
|
88
|
+
const set_creator_authority = (0, binary_js_1.readPubkey)(d, o);
|
|
89
|
+
if (set_creator_authority === null)
|
|
90
|
+
return null;
|
|
91
|
+
o += 32;
|
|
92
|
+
const admin_set_creator_authority = (0, binary_js_1.readPubkey)(d, o);
|
|
93
|
+
if (admin_set_creator_authority === null)
|
|
94
|
+
return null;
|
|
95
|
+
o += 32;
|
|
96
|
+
const createV2EnabledByte = (0, binary_js_1.readU8)(d, o);
|
|
97
|
+
if (createV2EnabledByte === null)
|
|
98
|
+
return null;
|
|
99
|
+
const create_v2_enabled = createV2EnabledByte !== 0;
|
|
100
|
+
o += 1;
|
|
101
|
+
const whitelist_pda = (0, binary_js_1.readPubkey)(d, o);
|
|
102
|
+
if (whitelist_pda === null)
|
|
103
|
+
return null;
|
|
104
|
+
o += 32;
|
|
105
|
+
const reserved_fee_recipient = (0, binary_js_1.readPubkey)(d, o);
|
|
106
|
+
if (reserved_fee_recipient === null)
|
|
107
|
+
return null;
|
|
108
|
+
o += 32;
|
|
109
|
+
const mayhemModeEnabledByte = (0, binary_js_1.readU8)(d, o);
|
|
110
|
+
if (mayhemModeEnabledByte === null)
|
|
111
|
+
return null;
|
|
112
|
+
const mayhem_mode_enabled = mayhemModeEnabledByte !== 0;
|
|
113
|
+
o += 1;
|
|
114
|
+
const reservedFeeRecipients = readPubkeyArray(d, o, 7);
|
|
115
|
+
if (reservedFeeRecipients === null)
|
|
116
|
+
return null;
|
|
117
|
+
const reserved_fee_recipients = reservedFeeRecipients.value;
|
|
118
|
+
o = reservedFeeRecipients.next;
|
|
119
|
+
const cashbackEnabledByte = (0, binary_js_1.readU8)(d, o);
|
|
120
|
+
if (cashbackEnabledByte === null)
|
|
121
|
+
return null;
|
|
122
|
+
o += 1;
|
|
123
|
+
const buybackFeeRecipients = readPubkeyArray(d, o, 8);
|
|
124
|
+
if (buybackFeeRecipients === null)
|
|
125
|
+
return null;
|
|
126
|
+
const global = {
|
|
127
|
+
initialized,
|
|
128
|
+
authority,
|
|
129
|
+
fee_recipient,
|
|
130
|
+
initial_virtual_token_reserves,
|
|
131
|
+
initial_virtual_sol_reserves,
|
|
132
|
+
initial_real_token_reserves,
|
|
133
|
+
token_total_supply,
|
|
134
|
+
fee_basis_points,
|
|
135
|
+
withdraw_authority,
|
|
136
|
+
enable_migrate,
|
|
137
|
+
pool_migration_fee,
|
|
138
|
+
creator_fee_basis_points,
|
|
139
|
+
fee_recipients,
|
|
140
|
+
set_creator_authority,
|
|
141
|
+
admin_set_creator_authority,
|
|
142
|
+
create_v2_enabled,
|
|
143
|
+
whitelist_pda,
|
|
144
|
+
reserved_fee_recipient,
|
|
145
|
+
mayhem_mode_enabled,
|
|
146
|
+
reserved_fee_recipients,
|
|
147
|
+
};
|
|
148
|
+
const ev = { metadata, pubkey: account.pubkey, global };
|
|
149
|
+
return { PumpFunGlobalAccount: ev };
|
|
150
|
+
}
|
|
151
|
+
function parsePumpfunAccount(account, metadata) {
|
|
152
|
+
if (account.owner !== program_ids_js_1.PUMPFUN_PROGRAM_ID)
|
|
153
|
+
return null;
|
|
154
|
+
if (isPumpfunGlobalAccount(account.data))
|
|
155
|
+
return parsePumpfunGlobal(account, metadata);
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rpcResolveUserWalletPubkey = rpcResolveUserWalletPubkey;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const wallet_resolve_js_1 = require("./wallet_resolve.js");
|
|
6
|
+
async function rpcResolveUserWalletPubkey(connection, addressBs58) {
|
|
7
|
+
let pk;
|
|
8
|
+
try {
|
|
9
|
+
pk = new web3_js_1.PublicKey(addressBs58);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const acc = await connection.getAccountInfo(pk);
|
|
15
|
+
if (!acc)
|
|
16
|
+
return null;
|
|
17
|
+
return (0, wallet_resolve_js_1.userWalletPubkeyForOnchainAccount)(addressBs58, acc.owner.toBase58(), acc.data, acc.executable);
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust `accounts` 模块蛇形命名别名(与 `parse_nonce_account` 等对应)。
|
|
3
|
+
*/
|
|
4
|
+
export { parseAccountUnified as parse_account_unified } from "./mod.js";
|
|
5
|
+
export { parseNonceAccount as parse_nonce_account } from "./nonce.js";
|
|
6
|
+
export { parseTokenAccount as parse_token_account } from "./token.js";
|
|
7
|
+
export { parsePumpfunGlobal as parse_pumpfun_global } from "./pumpfun.js";
|
|
8
|
+
export { parsePumpswapGlobalConfig as parse_pumpswap_global_config, parsePumpswapPool as parse_pumpswap_pool, } from "./pumpswap.js";
|
|
9
|
+
export { rpcResolveUserWalletPubkey as rpc_resolve_user_wallet_pubkey } from "./rpc_wallet.js";
|
|
10
|
+
export { userWalletPubkeyForOnchainAccount as user_wallet_pubkey_for_onchain_account } from "./wallet_resolve.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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 = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Rust `accounts` 模块蛇形命名别名(与 `parse_nonce_account` 等对应)。
|
|
6
|
+
*/
|
|
7
|
+
var mod_js_1 = require("./mod.js");
|
|
8
|
+
Object.defineProperty(exports, "parse_account_unified", { enumerable: true, get: function () { return mod_js_1.parseAccountUnified; } });
|
|
9
|
+
var nonce_js_1 = require("./nonce.js");
|
|
10
|
+
Object.defineProperty(exports, "parse_nonce_account", { enumerable: true, get: function () { return nonce_js_1.parseNonceAccount; } });
|
|
11
|
+
var token_js_1 = require("./token.js");
|
|
12
|
+
Object.defineProperty(exports, "parse_token_account", { enumerable: true, get: function () { return token_js_1.parseTokenAccount; } });
|
|
13
|
+
var pumpfun_js_1 = require("./pumpfun.js");
|
|
14
|
+
Object.defineProperty(exports, "parse_pumpfun_global", { enumerable: true, get: function () { return pumpfun_js_1.parsePumpfunGlobal; } });
|
|
15
|
+
var pumpswap_js_1 = require("./pumpswap.js");
|
|
16
|
+
Object.defineProperty(exports, "parse_pumpswap_global_config", { enumerable: true, get: function () { return pumpswap_js_1.parsePumpswapGlobalConfig; } });
|
|
17
|
+
Object.defineProperty(exports, "parse_pumpswap_pool", { enumerable: true, get: function () { return pumpswap_js_1.parsePumpswapPool; } });
|
|
18
|
+
var rpc_wallet_js_1 = require("./rpc_wallet.js");
|
|
19
|
+
Object.defineProperty(exports, "rpc_resolve_user_wallet_pubkey", { enumerable: true, get: function () { return rpc_wallet_js_1.rpcResolveUserWalletPubkey; } });
|
|
20
|
+
var wallet_resolve_js_1 = require("./wallet_resolve.js");
|
|
21
|
+
Object.defineProperty(exports, "user_wallet_pubkey_for_onchain_account", { enumerable: true, get: function () { return wallet_resolve_js_1.userWalletPubkeyForOnchainAccount; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function userWalletPubkeyForOnchainAccount(address: string, owner: string, data: Uint8Array, executable: boolean): string | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userWalletPubkeyForOnchainAccount = userWalletPubkeyForOnchainAccount;
|
|
4
|
+
/**
|
|
5
|
+
* 与 Rust `accounts/utils::user_wallet_pubkey_for_onchain_account` 对齐:
|
|
6
|
+
* 由链上账户 owner / data / executable 推断「用户钱包」公钥(Base58)。
|
|
7
|
+
*/
|
|
8
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
9
|
+
const binary_js_1 = require("../util/binary.js");
|
|
10
|
+
const TOKEN_PROGRAM = new web3_js_1.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").toBase58();
|
|
11
|
+
const TOKEN_2022 = new web3_js_1.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb").toBase58();
|
|
12
|
+
const SYSTEM = web3_js_1.SystemProgram.programId.toBase58();
|
|
13
|
+
/** SPL Token `Account` 布局长度(与 `spl_token::state::Account::LEN` 一致) */
|
|
14
|
+
const SPL_TOKEN_ACCOUNT_LEN = 165;
|
|
15
|
+
function isTokenProgramOwner(owner) {
|
|
16
|
+
return owner === TOKEN_PROGRAM || owner === TOKEN_2022;
|
|
17
|
+
}
|
|
18
|
+
function userWalletPubkeyForOnchainAccount(address, owner, data, executable) {
|
|
19
|
+
if (executable)
|
|
20
|
+
return null;
|
|
21
|
+
if (owner === SYSTEM) {
|
|
22
|
+
return data.length === 0 ? address : null;
|
|
23
|
+
}
|
|
24
|
+
if (isTokenProgramOwner(owner) && data.length === SPL_TOKEN_ACCOUNT_LEN) {
|
|
25
|
+
return (0, binary_js_1.readPubkey)(data, 32);
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 与 Rust `sol-parser-sdk/src/common/constants.rs` 对齐的流处理默认值。
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_CONNECT_TIMEOUT = 10;
|
|
5
|
+
export declare const DEFAULT_REQUEST_TIMEOUT = 60;
|
|
6
|
+
export declare const DEFAULT_CHANNEL_SIZE = 1000;
|
|
7
|
+
export declare const DEFAULT_MAX_DECODING_MESSAGE_SIZE: number;
|
|
8
|
+
export declare const DEFAULT_METRICS_WINDOW_SECONDS = 5;
|
|
9
|
+
export declare const DEFAULT_METRICS_PRINT_INTERVAL_SECONDS = 10;
|
|
10
|
+
export declare const SLOW_PROCESSING_THRESHOLD_US = 3000;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SLOW_PROCESSING_THRESHOLD_US = exports.DEFAULT_METRICS_PRINT_INTERVAL_SECONDS = exports.DEFAULT_METRICS_WINDOW_SECONDS = exports.DEFAULT_MAX_DECODING_MESSAGE_SIZE = exports.DEFAULT_CHANNEL_SIZE = exports.DEFAULT_REQUEST_TIMEOUT = exports.DEFAULT_CONNECT_TIMEOUT = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 与 Rust `sol-parser-sdk/src/common/constants.rs` 对齐的流处理默认值。
|
|
6
|
+
*/
|
|
7
|
+
exports.DEFAULT_CONNECT_TIMEOUT = 10;
|
|
8
|
+
exports.DEFAULT_REQUEST_TIMEOUT = 60;
|
|
9
|
+
exports.DEFAULT_CHANNEL_SIZE = 1000;
|
|
10
|
+
exports.DEFAULT_MAX_DECODING_MESSAGE_SIZE = 1024 * 1024 * 10;
|
|
11
|
+
exports.DEFAULT_METRICS_WINDOW_SECONDS = 5;
|
|
12
|
+
exports.DEFAULT_METRICS_PRINT_INTERVAL_SECONDS = 10;
|
|
13
|
+
exports.SLOW_PROCESSING_THRESHOLD_US = 3000;
|
|
@@ -18,6 +18,24 @@ function tryFill(programId, programInvokes, message, meta, resolver, fn) {
|
|
|
18
18
|
return;
|
|
19
19
|
fn(get);
|
|
20
20
|
}
|
|
21
|
+
const BONK_PROGRAM_FILL_ORDER = [
|
|
22
|
+
program_ids_js_1.BONK_PROGRAM_ID,
|
|
23
|
+
program_ids_js_1.BONK_LAUNCHPAD_PROGRAM_ID,
|
|
24
|
+
program_ids_js_1.BONK_PROGRAM_ID_LEGACY,
|
|
25
|
+
];
|
|
26
|
+
/** Bonk 多程序 ID:按 Rust 主网 ID → Launchpad → 旧 TS 兼容顺序尝试 CPI 账户填充 */
|
|
27
|
+
function tryFillBonk(programInvokes, message, meta, resolver, fn) {
|
|
28
|
+
for (const programId of BONK_PROGRAM_FILL_ORDER) {
|
|
29
|
+
const invoke = (0, rpc_invoke_map_js_1.findMaxAccountsInvoke)(programId, programInvokes, message, meta);
|
|
30
|
+
if (!invoke)
|
|
31
|
+
continue;
|
|
32
|
+
const get = (0, rpc_invoke_map_js_1.makeInvokeAccountGetter)(resolver, invoke, message, meta);
|
|
33
|
+
if (!get)
|
|
34
|
+
continue;
|
|
35
|
+
fn(get);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
21
39
|
/** 就地修改事件体内字段 */
|
|
22
40
|
function fillAccountsFromTransactionDataRpc(ev, message, meta, programInvokes, resolver) {
|
|
23
41
|
if ("PumpFunTrade" in ev) {
|
|
@@ -116,18 +134,21 @@ function fillAccountsFromTransactionDataRpc(ev, message, meta, programInvokes, r
|
|
|
116
134
|
else if ("MeteoraDammV2CreatePosition" in ev) {
|
|
117
135
|
tryFill(program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDammV2CreatePositionAccounts)(ev.MeteoraDammV2CreatePosition, g));
|
|
118
136
|
}
|
|
137
|
+
else if ("MeteoraDammV2InitializePool" in ev) {
|
|
138
|
+
tryFill(program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDammV2InitializePoolAccounts)(ev.MeteoraDammV2InitializePool, g));
|
|
139
|
+
}
|
|
119
140
|
else if ("MeteoraDammV2ClosePosition" in ev) {
|
|
120
141
|
tryFill(program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDammV2ClosePositionAccounts)(ev.MeteoraDammV2ClosePosition, g));
|
|
121
142
|
}
|
|
122
143
|
else if ("MeteoraDammV2AddLiquidity" in ev) {
|
|
123
144
|
tryFill(program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDammV2AddLiquidityAccounts)(ev.MeteoraDammV2AddLiquidity, g));
|
|
124
145
|
}
|
|
146
|
+
else if ("MeteoraDammV2RemoveAllLiquidity" in ev) {
|
|
147
|
+
tryFill(program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDammV2RemoveAllLiquidityAccounts)(ev.MeteoraDammV2RemoveAllLiquidity, g));
|
|
148
|
+
}
|
|
125
149
|
else if ("MeteoraDammV2RemoveLiquidity" in ev) {
|
|
126
150
|
tryFill(program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDammV2RemoveLiquidityAccounts)(ev.MeteoraDammV2RemoveLiquidity, g));
|
|
127
151
|
}
|
|
128
|
-
else if ("MeteoraDammV2InitializePool" in ev) {
|
|
129
|
-
tryFill(program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDammV2InitializePoolAccounts)(ev.MeteoraDammV2InitializePool, g));
|
|
130
|
-
}
|
|
131
152
|
else if ("MeteoraPoolsSwap" in ev) {
|
|
132
153
|
tryFill(program_ids_js_1.METEORA_POOLS_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraPoolsSwapAccounts)(ev.MeteoraPoolsSwap, g));
|
|
133
154
|
}
|
|
@@ -147,9 +168,9 @@ function fillAccountsFromTransactionDataRpc(ev, message, meta, programInvokes, r
|
|
|
147
168
|
tryFill(program_ids_js_1.METEORA_DLMM_PROGRAM_ID, programInvokes, message, meta, resolver, (g) => (0, account_fill_meteora_js_1.fillMeteoraDlmmRemoveLiquidityAccounts)(ev.MeteoraDlmmRemoveLiquidity, g));
|
|
148
169
|
}
|
|
149
170
|
else if ("BonkTrade" in ev) {
|
|
150
|
-
|
|
171
|
+
tryFillBonk(programInvokes, message, meta, resolver, (g) => (0, account_fill_bonk_js_1.fillBonkTradeAccounts)(ev.BonkTrade, g));
|
|
151
172
|
}
|
|
152
173
|
else if ("BonkPoolCreate" in ev) {
|
|
153
|
-
|
|
174
|
+
tryFillBonk(programInvokes, message, meta, resolver, (g) => (0, account_fill_bonk_js_1.fillBonkPoolCreateAccounts)(ev.BonkPoolCreate, g));
|
|
154
175
|
}
|
|
155
176
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/** Meteora DAMM V2 / Pools / DLMM 账户填充(部分占位) */
|
|
2
|
-
import type { MeteoraDammV2AddLiquidityEvent, MeteoraDammV2ClosePositionEvent, MeteoraDammV2CreatePositionEvent, MeteoraDammV2InitializePoolEvent, MeteoraDammV2RemoveLiquidityEvent, MeteoraDammV2SwapEvent, MeteoraDlmmAddLiquidityEvent, MeteoraDlmmRemoveLiquidityEvent, MeteoraDlmmSwapEvent, MeteoraPoolsAddLiquidityEvent, MeteoraPoolsRemoveLiquidityEvent, MeteoraPoolsSwapEvent } from "./dex_event.js";
|
|
2
|
+
import type { MeteoraDammV2AddLiquidityEvent, MeteoraDammV2ClosePositionEvent, MeteoraDammV2CreatePositionEvent, MeteoraDammV2InitializePoolEvent, MeteoraDammV2RemoveAllLiquidityEvent, MeteoraDammV2RemoveLiquidityEvent, MeteoraDammV2SwapEvent, MeteoraDlmmAddLiquidityEvent, MeteoraDlmmRemoveLiquidityEvent, MeteoraDlmmSwapEvent, MeteoraPoolsAddLiquidityEvent, MeteoraPoolsRemoveLiquidityEvent, MeteoraPoolsSwapEvent } from "./dex_event.js";
|
|
3
|
+
/** 预留:gRPC+meta 全量路径若需从 account_keys 补 vault,应对齐 cp_amm `swap` 账户顺序(IDL 中 vault/mint/token program 下标) */
|
|
3
4
|
export declare function fillMeteoraDammV2SwapAccounts(_e: MeteoraDammV2SwapEvent, _get: (i: number) => string): void;
|
|
4
5
|
export declare function fillMeteoraDammV2CreatePositionAccounts(_e: MeteoraDammV2CreatePositionEvent, _get: (i: number) => string): void;
|
|
6
|
+
export declare function fillMeteoraDammV2InitializePoolAccounts(_e: MeteoraDammV2InitializePoolEvent, _get: (i: number) => string): void;
|
|
5
7
|
export declare function fillMeteoraDammV2ClosePositionAccounts(_e: MeteoraDammV2ClosePositionEvent, _get: (i: number) => string): void;
|
|
6
8
|
export declare function fillMeteoraDammV2AddLiquidityAccounts(_e: MeteoraDammV2AddLiquidityEvent, _get: (i: number) => string): void;
|
|
7
9
|
export declare function fillMeteoraDammV2RemoveLiquidityAccounts(_e: MeteoraDammV2RemoveLiquidityEvent, _get: (i: number) => string): void;
|
|
8
|
-
export declare function
|
|
10
|
+
export declare function fillMeteoraDammV2RemoveAllLiquidityAccounts(_e: MeteoraDammV2RemoveAllLiquidityEvent, _get: (i: number) => string): void;
|
|
9
11
|
export declare function fillMeteoraPoolsSwapAccounts(_e: MeteoraPoolsSwapEvent, _get: (i: number) => string): void;
|
|
10
12
|
export declare function fillMeteoraPoolsAddLiquidityAccounts(_e: MeteoraPoolsAddLiquidityEvent, _get: (i: number) => string): void;
|
|
11
13
|
export declare function fillMeteoraPoolsRemoveLiquidityAccounts(_e: MeteoraPoolsRemoveLiquidityEvent, _get: (i: number) => string): void;
|
|
@@ -2,22 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fillMeteoraDammV2SwapAccounts = fillMeteoraDammV2SwapAccounts;
|
|
4
4
|
exports.fillMeteoraDammV2CreatePositionAccounts = fillMeteoraDammV2CreatePositionAccounts;
|
|
5
|
+
exports.fillMeteoraDammV2InitializePoolAccounts = fillMeteoraDammV2InitializePoolAccounts;
|
|
5
6
|
exports.fillMeteoraDammV2ClosePositionAccounts = fillMeteoraDammV2ClosePositionAccounts;
|
|
6
7
|
exports.fillMeteoraDammV2AddLiquidityAccounts = fillMeteoraDammV2AddLiquidityAccounts;
|
|
7
8
|
exports.fillMeteoraDammV2RemoveLiquidityAccounts = fillMeteoraDammV2RemoveLiquidityAccounts;
|
|
8
|
-
exports.
|
|
9
|
+
exports.fillMeteoraDammV2RemoveAllLiquidityAccounts = fillMeteoraDammV2RemoveAllLiquidityAccounts;
|
|
9
10
|
exports.fillMeteoraPoolsSwapAccounts = fillMeteoraPoolsSwapAccounts;
|
|
10
11
|
exports.fillMeteoraPoolsAddLiquidityAccounts = fillMeteoraPoolsAddLiquidityAccounts;
|
|
11
12
|
exports.fillMeteoraPoolsRemoveLiquidityAccounts = fillMeteoraPoolsRemoveLiquidityAccounts;
|
|
12
13
|
exports.fillMeteoraDlmmSwapAccounts = fillMeteoraDlmmSwapAccounts;
|
|
13
14
|
exports.fillMeteoraDlmmAddLiquidityAccounts = fillMeteoraDlmmAddLiquidityAccounts;
|
|
14
15
|
exports.fillMeteoraDlmmRemoveLiquidityAccounts = fillMeteoraDlmmRemoveLiquidityAccounts;
|
|
16
|
+
/** 预留:gRPC+meta 全量路径若需从 account_keys 补 vault,应对齐 cp_amm `swap` 账户顺序(IDL 中 vault/mint/token program 下标) */
|
|
15
17
|
function fillMeteoraDammV2SwapAccounts(_e, _get) { }
|
|
16
18
|
function fillMeteoraDammV2CreatePositionAccounts(_e, _get) { }
|
|
19
|
+
function fillMeteoraDammV2InitializePoolAccounts(_e, _get) { }
|
|
17
20
|
function fillMeteoraDammV2ClosePositionAccounts(_e, _get) { }
|
|
18
21
|
function fillMeteoraDammV2AddLiquidityAccounts(_e, _get) { }
|
|
19
22
|
function fillMeteoraDammV2RemoveLiquidityAccounts(_e, _get) { }
|
|
20
|
-
function
|
|
23
|
+
function fillMeteoraDammV2RemoveAllLiquidityAccounts(_e, _get) { }
|
|
21
24
|
function fillMeteoraPoolsSwapAccounts(_e, _get) { }
|
|
22
25
|
function fillMeteoraPoolsAddLiquidityAccounts(_e, _get) { }
|
|
23
26
|
function fillMeteoraPoolsRemoveLiquidityAccounts(_e, _get) { }
|
|
@@ -8,6 +8,23 @@ const dex_event_js_1 = require("./dex_event.js");
|
|
|
8
8
|
const Z = () => (0, dex_event_js_1.defaultPubkey)();
|
|
9
9
|
function fillPumpfunTradeAccounts(e, get) {
|
|
10
10
|
const zero = Z();
|
|
11
|
+
const isV2 = e.ix_name === "buy_v2" ||
|
|
12
|
+
e.ix_name === "sell_v2" ||
|
|
13
|
+
e.ix_name === "buy_exact_quote_in_v2";
|
|
14
|
+
if (isV2) {
|
|
15
|
+
if (!e.user || e.user === zero)
|
|
16
|
+
e.user = get(13);
|
|
17
|
+
if (!e.bonding_curve || e.bonding_curve === zero)
|
|
18
|
+
e.bonding_curve = get(10);
|
|
19
|
+
if (!e.associated_bonding_curve || e.associated_bonding_curve === zero) {
|
|
20
|
+
e.associated_bonding_curve = get(11);
|
|
21
|
+
}
|
|
22
|
+
if (!e.creator_vault || e.creator_vault === zero)
|
|
23
|
+
e.creator_vault = get(16);
|
|
24
|
+
if (!e.token_program || e.token_program === zero)
|
|
25
|
+
e.token_program = get(3);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
11
28
|
if (!e.user || e.user === zero)
|
|
12
29
|
e.user = get(6);
|
|
13
30
|
if (!e.bonding_curve || e.bonding_curve === zero)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 与 Rust `sol-parser-sdk/src/core/cache.rs` 对齐:账户公钥索引解析缓存。
|
|
3
|
+
* JS 主线程单线程,使用模块级单例代替 Rust `thread_local`。
|
|
4
|
+
*/
|
|
5
|
+
import { PublicKey } from "@solana/web3.js";
|
|
6
|
+
export declare class AccountPubkeyCache {
|
|
7
|
+
private readonly cache;
|
|
8
|
+
/** 与 Rust `AccountPubkeyCache::build_account_pubkeys` 一致 */
|
|
9
|
+
buildAccountPubkeys(instructionAccounts: Uint8Array | readonly number[], allAccounts: readonly PublicKey[]): PublicKey[];
|
|
10
|
+
}
|
|
11
|
+
/** 与 Rust `build_account_pubkeys_with_cache` 一致(返回 `Vec` 拷贝,与 Rust `.to_vec()` 相同) */
|
|
12
|
+
export declare function buildAccountPubkeysWithCache(instructionAccounts: Uint8Array | readonly number[], allAccounts: readonly PublicKey[]): PublicKey[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountPubkeyCache = void 0;
|
|
4
|
+
exports.buildAccountPubkeysWithCache = buildAccountPubkeysWithCache;
|
|
5
|
+
class AccountPubkeyCache {
|
|
6
|
+
cache = [];
|
|
7
|
+
/** 与 Rust `AccountPubkeyCache::build_account_pubkeys` 一致 */
|
|
8
|
+
buildAccountPubkeys(instructionAccounts, allAccounts) {
|
|
9
|
+
this.cache.length = 0;
|
|
10
|
+
for (let i = 0; i < instructionAccounts.length; i++) {
|
|
11
|
+
const idx = instructionAccounts[i];
|
|
12
|
+
if (idx < allAccounts.length) {
|
|
13
|
+
this.cache.push(allAccounts[idx]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return this.cache;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AccountPubkeyCache = AccountPubkeyCache;
|
|
20
|
+
let threadLocalLike;
|
|
21
|
+
/** 与 Rust `build_account_pubkeys_with_cache` 一致(返回 `Vec` 拷贝,与 Rust `.to_vec()` 相同) */
|
|
22
|
+
function buildAccountPubkeysWithCache(instructionAccounts, allAccounts) {
|
|
23
|
+
if (!threadLocalLike)
|
|
24
|
+
threadLocalLike = new AccountPubkeyCache();
|
|
25
|
+
return [...threadLocalLike.buildAccountPubkeys(instructionAccounts, allAccounts)];
|
|
26
|
+
}
|
package/dist/core/clock.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
/** 当前时间微秒戳(用于 `grpc_recv_us`) */
|
|
2
2
|
export declare function nowUs(): number;
|
|
3
|
+
/** 与 Rust `now_micros` 一致(别名) */
|
|
4
|
+
export declare const nowMicros: typeof nowUs;
|
|
5
|
+
/** 与 Rust `now_nanos` 同语义:墙钟纳秒(`Date` 精度为毫秒,纳秒位为推算值) */
|
|
6
|
+
export declare function nowNanos(): bigint;
|
|
7
|
+
/** 与 Rust `elapsed_micros_since` 一致 */
|
|
8
|
+
export declare function elapsedMicrosSince(startUs: number): number;
|
package/dist/core/clock.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nowMicros = void 0;
|
|
3
4
|
exports.nowUs = nowUs;
|
|
5
|
+
exports.nowNanos = nowNanos;
|
|
6
|
+
exports.elapsedMicrosSince = elapsedMicrosSince;
|
|
4
7
|
/** 当前时间微秒戳(用于 `grpc_recv_us`) */
|
|
5
8
|
function nowUs() {
|
|
6
9
|
return Math.floor(Date.now() * 1000);
|
|
7
10
|
}
|
|
11
|
+
/** 与 Rust `now_micros` 一致(别名) */
|
|
12
|
+
exports.nowMicros = nowUs;
|
|
13
|
+
/** 与 Rust `now_nanos` 同语义:墙钟纳秒(`Date` 精度为毫秒,纳秒位为推算值) */
|
|
14
|
+
function nowNanos() {
|
|
15
|
+
return BigInt(Math.floor(Date.now() * 1_000_000));
|
|
16
|
+
}
|
|
17
|
+
/** 与 Rust `elapsed_micros_since` 一致 */
|
|
18
|
+
function elapsedMicrosSince(startUs) {
|
|
19
|
+
return nowUs() - startUs;
|
|
20
|
+
}
|