sol-parser-sdk-nodejs 0.4.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.
Files changed (50) hide show
  1. package/README.md +6 -0
  2. package/README_CN.md +6 -0
  3. package/dist/accounts/mod.d.ts +1 -0
  4. package/dist/accounts/mod.js +14 -1
  5. package/dist/accounts/pumpfun.d.ts +6 -0
  6. package/dist/accounts/pumpfun.js +157 -0
  7. package/dist/accounts/rust_aliases.d.ts +1 -0
  8. package/dist/accounts/rust_aliases.js +3 -1
  9. package/dist/core/account_fill_pumpfun.js +17 -0
  10. package/dist/core/dex_event.d.ts +147 -0
  11. package/dist/core/pumpfun_fee_enrich.d.ts +4 -0
  12. package/dist/core/pumpfun_fee_enrich.js +80 -0
  13. package/dist/core/unified_parser.js +2 -0
  14. package/dist/grpc/client.d.ts +26 -1
  15. package/dist/grpc/client.js +279 -0
  16. package/dist/grpc/log_instr_dedup.d.ts +2 -0
  17. package/dist/grpc/log_instr_dedup.js +330 -0
  18. package/dist/grpc/order_buffer.d.ts +27 -0
  19. package/dist/grpc/order_buffer.js +166 -0
  20. package/dist/grpc/program_ids.d.ts +1 -0
  21. package/dist/grpc/program_ids.js +2 -1
  22. package/dist/grpc/types.d.ts +5 -1
  23. package/dist/grpc/types.js +101 -0
  24. package/dist/grpc/yellowstone_parse.d.ts +3 -1
  25. package/dist/grpc/yellowstone_parse.js +13 -10
  26. package/dist/index.d.ts +8 -7
  27. package/dist/index.js +16 -4
  28. package/dist/instr/mod.d.ts +1 -0
  29. package/dist/instr/mod.js +9 -1
  30. package/dist/instr/program_ids.d.ts +1 -1
  31. package/dist/instr/program_ids.js +2 -1
  32. package/dist/instr/pump_fees_ix.d.ts +2 -0
  33. package/dist/instr/pump_fees_ix.js +166 -0
  34. package/dist/instr/pumpfun_ix.js +57 -0
  35. package/dist/instr/raydium_clmm_ix.js +73 -52
  36. package/dist/instr/rust_aliases.d.ts +1 -0
  37. package/dist/instr/rust_aliases.js +3 -1
  38. package/dist/logs/discriminator_lut.d.ts +1 -1
  39. package/dist/logs/discriminator_lut.js +2 -0
  40. package/dist/logs/optimized_matcher.js +120 -20
  41. package/dist/logs/program_log_discriminators.d.ts +10 -0
  42. package/dist/logs/program_log_discriminators.js +10 -0
  43. package/dist/logs/pump.d.ts +2 -0
  44. package/dist/logs/pump.js +51 -4
  45. package/dist/logs/pump_fees.d.ts +23 -0
  46. package/dist/logs/pump_fees.js +364 -0
  47. package/dist/rpc_transaction.d.ts +2 -0
  48. package/dist/rpc_transaction.js +14 -6
  49. package/dist/shredstream/instruction_parse.js +2 -0
  50. package/package.json +1 -1
package/README.md CHANGED
@@ -16,6 +16,12 @@
16
16
  <a href="https://discord.gg/vuazbGkqQE">Discord</a>
17
17
  </p>
18
18
 
19
+ > ☕ **Support This Project**
20
+ >
21
+ > This SDK is completely free and open source. However, maintaining and continuously updating it requires significant AI computing resources and token consumption. If this SDK helps with your development, consider making a monthly SOL donation — any amount is appreciated and helps keep this project alive!
22
+ >
23
+ > **Donation Wallet:** `6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8`
24
+
19
25
  ---
20
26
 
21
27
  ## Other language SDKs
package/README_CN.md CHANGED
@@ -16,6 +16,12 @@
16
16
  <a href="https://discord.gg/vuazbGkqQE">Discord</a>
17
17
  </p>
18
18
 
19
+ > ☕ **支持本项目**
20
+ >
21
+ > 本 SDK 完全免费且开源。但维护和持续更新需要消耗大量 AI 算力与 Token。如果这个 SDK 对您的开发有帮助,欢迎每月捐赠任意数量的 SOL,您的支持将帮助这个项目持续运行!
22
+ >
23
+ > **捐赠钱包:** `6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8`
24
+
19
25
  ---
20
26
 
21
27
  ## 其他语言 SDK
@@ -5,6 +5,7 @@ import type { EventTypeFilter } from "../grpc/types.js";
5
5
  export type { AccountData } from "./types.js";
6
6
  export { parseNonceAccount, isNonceAccount } from "./nonce.js";
7
7
  export { parseTokenAccount } from "./token.js";
8
+ export { parsePumpfunGlobal, parsePumpfunAccount, isPumpfunGlobalAccount, } from "./pumpfun.js";
8
9
  export { parsePumpswapGlobalConfig, parsePumpswapPool, parsePumpswapAccount, isGlobalConfigAccount, isPoolAccount, } from "./pumpswap.js";
9
10
  export { hasDiscriminator } from "./utils.js";
10
11
  export { userWalletPubkeyForOnchainAccount } from "./wallet_resolve.js";
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rpcResolveUserWalletPubkey = exports.userWalletPubkeyForOnchainAccount = exports.hasDiscriminator = exports.isPoolAccount = exports.isGlobalConfigAccount = exports.parsePumpswapAccount = exports.parsePumpswapPool = exports.parsePumpswapGlobalConfig = exports.parseTokenAccount = exports.isNonceAccount = exports.parseNonceAccount = void 0;
3
+ exports.rpcResolveUserWalletPubkey = exports.userWalletPubkeyForOnchainAccount = exports.hasDiscriminator = exports.isPoolAccount = exports.isGlobalConfigAccount = exports.parsePumpswapAccount = exports.parsePumpswapPool = exports.parsePumpswapGlobalConfig = exports.isPumpfunGlobalAccount = exports.parsePumpfunAccount = exports.parsePumpfunGlobal = exports.parseTokenAccount = exports.isNonceAccount = exports.parseNonceAccount = void 0;
4
4
  exports.parseAccountUnified = parseAccountUnified;
5
5
  const program_ids_js_1 = require("../instr/program_ids.js");
6
6
  const nonce_js_1 = require("./nonce.js");
7
7
  const token_js_1 = require("./token.js");
8
8
  const pumpswap_js_1 = require("./pumpswap.js");
9
+ const pumpfun_js_1 = require("./pumpfun.js");
9
10
  var nonce_js_2 = require("./nonce.js");
10
11
  Object.defineProperty(exports, "parseNonceAccount", { enumerable: true, get: function () { return nonce_js_2.parseNonceAccount; } });
11
12
  Object.defineProperty(exports, "isNonceAccount", { enumerable: true, get: function () { return nonce_js_2.isNonceAccount; } });
12
13
  var token_js_2 = require("./token.js");
13
14
  Object.defineProperty(exports, "parseTokenAccount", { enumerable: true, get: function () { return token_js_2.parseTokenAccount; } });
15
+ var pumpfun_js_2 = require("./pumpfun.js");
16
+ Object.defineProperty(exports, "parsePumpfunGlobal", { enumerable: true, get: function () { return pumpfun_js_2.parsePumpfunGlobal; } });
17
+ Object.defineProperty(exports, "parsePumpfunAccount", { enumerable: true, get: function () { return pumpfun_js_2.parsePumpfunAccount; } });
18
+ Object.defineProperty(exports, "isPumpfunGlobalAccount", { enumerable: true, get: function () { return pumpfun_js_2.isPumpfunGlobalAccount; } });
14
19
  var pumpswap_js_2 = require("./pumpswap.js");
15
20
  Object.defineProperty(exports, "parsePumpswapGlobalConfig", { enumerable: true, get: function () { return pumpswap_js_2.parsePumpswapGlobalConfig; } });
16
21
  Object.defineProperty(exports, "parsePumpswapPool", { enumerable: true, get: function () { return pumpswap_js_2.parsePumpswapPool; } });
@@ -26,6 +31,7 @@ Object.defineProperty(exports, "rpcResolveUserWalletPubkey", { enumerable: true,
26
31
  const ACCOUNT_EVENT_TYPES = [
27
32
  "TokenAccount",
28
33
  "NonceAccount",
34
+ "AccountPumpFunGlobal",
29
35
  "AccountPumpSwapGlobalConfig",
30
36
  "AccountPumpSwapPool",
31
37
  ];
@@ -46,6 +52,13 @@ function parseAccountUnified(account, metadata, eventTypeFilter) {
46
52
  return ev;
47
53
  }
48
54
  }
55
+ if (account.owner === program_ids_js_1.PUMPFUN_PROGRAM_ID && eventTypeFilter) {
56
+ if (eventTypeFilter.shouldInclude("AccountPumpFunGlobal")) {
57
+ const ev = (0, pumpfun_js_1.parsePumpfunAccount)(account, metadata);
58
+ if (ev)
59
+ return ev;
60
+ }
61
+ }
49
62
  if ((0, nonce_js_1.isNonceAccount)(account.data)) {
50
63
  if (eventTypeFilter && !eventTypeFilter.shouldInclude("NonceAccount"))
51
64
  return null;
@@ -0,0 +1,6 @@
1
+ import type { EventMetadata } from "../core/metadata.js";
2
+ import type { DexEvent } from "../core/dex_event.js";
3
+ import type { AccountData } from "./types.js";
4
+ export declare function isPumpfunGlobalAccount(data: Uint8Array): boolean;
5
+ export declare function parsePumpfunGlobal(account: AccountData, metadata: EventMetadata): DexEvent | null;
6
+ export declare function parsePumpfunAccount(account: AccountData, metadata: EventMetadata): DexEvent | null;
@@ -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
+ }
@@ -4,6 +4,7 @@
4
4
  export { parseAccountUnified as parse_account_unified } from "./mod.js";
5
5
  export { parseNonceAccount as parse_nonce_account } from "./nonce.js";
6
6
  export { parseTokenAccount as parse_token_account } from "./token.js";
7
+ export { parsePumpfunGlobal as parse_pumpfun_global } from "./pumpfun.js";
7
8
  export { parsePumpswapGlobalConfig as parse_pumpswap_global_config, parsePumpswapPool as parse_pumpswap_pool, } from "./pumpswap.js";
8
9
  export { rpcResolveUserWalletPubkey as rpc_resolve_user_wallet_pubkey } from "./rpc_wallet.js";
9
10
  export { userWalletPubkeyForOnchainAccount as user_wallet_pubkey_for_onchain_account } from "./wallet_resolve.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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_token_account = exports.parse_nonce_account = exports.parse_account_unified = void 0;
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
4
  /**
5
5
  * Rust `accounts` 模块蛇形命名别名(与 `parse_nonce_account` 等对应)。
6
6
  */
@@ -10,6 +10,8 @@ var nonce_js_1 = require("./nonce.js");
10
10
  Object.defineProperty(exports, "parse_nonce_account", { enumerable: true, get: function () { return nonce_js_1.parseNonceAccount; } });
11
11
  var token_js_1 = require("./token.js");
12
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; } });
13
15
  var pumpswap_js_1 = require("./pumpswap.js");
14
16
  Object.defineProperty(exports, "parse_pumpswap_global_config", { enumerable: true, get: function () { return pumpswap_js_1.parsePumpswapGlobalConfig; } });
15
17
  Object.defineProperty(exports, "parse_pumpswap_pool", { enumerable: true, get: function () { return pumpswap_js_1.parsePumpswapPool; } });
@@ -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)
@@ -14,6 +14,26 @@ export type DexEvent = {
14
14
  PumpFunBuyExactSolIn: PumpFunTradeEvent;
15
15
  } | {
16
16
  PumpFunMigrate: PumpFunMigrateEvent;
17
+ } | {
18
+ PumpFeesCreateFeeSharingConfig: PumpFeesCreateFeeSharingConfigEvent;
19
+ } | {
20
+ PumpFeesInitializeFeeConfig: PumpFeesInitializeFeeConfigEvent;
21
+ } | {
22
+ PumpFeesResetFeeSharingConfig: PumpFeesResetFeeSharingConfigEvent;
23
+ } | {
24
+ PumpFeesRevokeFeeSharingAuthority: PumpFeesRevokeFeeSharingAuthorityEvent;
25
+ } | {
26
+ PumpFeesTransferFeeSharingAuthority: PumpFeesTransferFeeSharingAuthorityEvent;
27
+ } | {
28
+ PumpFeesUpdateAdmin: PumpFeesUpdateAdminEvent;
29
+ } | {
30
+ PumpFeesUpdateFeeConfig: PumpFeesUpdateFeeConfigEvent;
31
+ } | {
32
+ PumpFeesUpdateFeeShares: PumpFeesUpdateFeeSharesEvent;
33
+ } | {
34
+ PumpFeesUpsertFeeTiers: PumpFeesUpsertFeeTiersEvent;
35
+ } | {
36
+ PumpFunMigrateBondingCurveCreator: PumpFunMigrateBondingCurveCreatorEvent;
17
37
  } | {
18
38
  PumpSwapTrade: PumpSwapTradeEvent;
19
39
  } | {
@@ -122,6 +142,8 @@ export type DexEvent = {
122
142
  TokenAccount: TokenAccountEvent;
123
143
  } | {
124
144
  NonceAccount: NonceAccountEvent;
145
+ } | {
146
+ PumpFunGlobalAccount: PumpFunGlobalAccountEvent;
125
147
  } | {
126
148
  PumpSwapGlobalConfigAccount: PumpSwapGlobalConfigAccountEvent;
127
149
  } | {
@@ -162,6 +184,7 @@ export interface PumpFunCreateV2TokenEvent extends PumpFunCreateTokenEvent {
162
184
  mayhem_token_vault: string;
163
185
  event_authority: string;
164
186
  program: string;
187
+ observed_fee_recipient: string;
165
188
  }
166
189
  export interface PumpFunTradeEvent {
167
190
  metadata: EventMetadata;
@@ -209,6 +232,103 @@ export interface PumpFunMigrateEvent {
209
232
  timestamp: bigint;
210
233
  pool: string;
211
234
  }
235
+ export interface PumpFeesShareholder {
236
+ address: string;
237
+ share_bps: number;
238
+ }
239
+ export type PumpFeesConfigStatus = "Paused" | "Active";
240
+ export interface PumpFeesFees {
241
+ lp_fee_bps: bigint;
242
+ protocol_fee_bps: bigint;
243
+ creator_fee_bps: bigint;
244
+ }
245
+ export interface PumpFeesFeeTier {
246
+ market_cap_lamports_threshold: bigint;
247
+ fees: PumpFeesFees;
248
+ }
249
+ export interface PumpFeesCreateFeeSharingConfigEvent {
250
+ metadata: EventMetadata;
251
+ timestamp: bigint;
252
+ mint: string;
253
+ bonding_curve: string;
254
+ pool?: string;
255
+ sharing_config: string;
256
+ admin: string;
257
+ initial_shareholders: PumpFeesShareholder[];
258
+ status: PumpFeesConfigStatus;
259
+ }
260
+ export interface PumpFeesInitializeFeeConfigEvent {
261
+ metadata: EventMetadata;
262
+ timestamp: bigint;
263
+ admin: string;
264
+ fee_config: string;
265
+ }
266
+ export interface PumpFeesResetFeeSharingConfigEvent {
267
+ metadata: EventMetadata;
268
+ timestamp: bigint;
269
+ mint: string;
270
+ sharing_config: string;
271
+ old_admin: string;
272
+ old_shareholders: PumpFeesShareholder[];
273
+ new_admin: string;
274
+ new_shareholders: PumpFeesShareholder[];
275
+ }
276
+ export interface PumpFeesRevokeFeeSharingAuthorityEvent {
277
+ metadata: EventMetadata;
278
+ timestamp: bigint;
279
+ mint: string;
280
+ sharing_config: string;
281
+ admin: string;
282
+ }
283
+ export interface PumpFeesTransferFeeSharingAuthorityEvent {
284
+ metadata: EventMetadata;
285
+ timestamp: bigint;
286
+ mint: string;
287
+ sharing_config: string;
288
+ old_admin: string;
289
+ new_admin: string;
290
+ }
291
+ export interface PumpFeesUpdateAdminEvent {
292
+ metadata: EventMetadata;
293
+ timestamp: bigint;
294
+ old_admin: string;
295
+ new_admin: string;
296
+ }
297
+ export interface PumpFeesUpdateFeeConfigEvent {
298
+ metadata: EventMetadata;
299
+ timestamp: bigint;
300
+ admin: string;
301
+ fee_config: string;
302
+ fee_tiers: PumpFeesFeeTier[];
303
+ flat_fees: PumpFeesFees;
304
+ }
305
+ export interface PumpFeesUpdateFeeSharesEvent {
306
+ metadata: EventMetadata;
307
+ timestamp: bigint;
308
+ mint: string;
309
+ sharing_config: string;
310
+ admin: string;
311
+ bonding_curve: string;
312
+ pump_creator_vault: string;
313
+ new_shareholders: PumpFeesShareholder[];
314
+ }
315
+ export interface PumpFeesUpsertFeeTiersEvent {
316
+ metadata: EventMetadata;
317
+ timestamp: bigint;
318
+ admin: string;
319
+ fee_config: string;
320
+ fee_tiers: PumpFeesFeeTier[];
321
+ offset: number;
322
+ }
323
+ export interface PumpFunMigrateBondingCurveCreatorEvent {
324
+ metadata: EventMetadata;
325
+ timestamp: bigint;
326
+ mint: string;
327
+ bonding_curve: string;
328
+ sharing_config: string;
329
+ old_creator: string;
330
+ new_creator: string;
331
+ }
212
332
  /** 与 `PumpSwapTradeEvent`(IDL TradeEvent)对齐 */
213
333
  export interface PumpSwapTradeEvent {
214
334
  metadata: EventMetadata;
@@ -938,6 +1058,33 @@ export interface NonceAccountEvent {
938
1058
  nonce: string;
939
1059
  authority: string;
940
1060
  }
1061
+ export interface PumpFunGlobal {
1062
+ initialized: boolean;
1063
+ authority: string;
1064
+ fee_recipient: string;
1065
+ initial_virtual_token_reserves: bigint;
1066
+ initial_virtual_sol_reserves: bigint;
1067
+ initial_real_token_reserves: bigint;
1068
+ token_total_supply: bigint;
1069
+ fee_basis_points: bigint;
1070
+ withdraw_authority: string;
1071
+ enable_migrate: boolean;
1072
+ pool_migration_fee: bigint;
1073
+ creator_fee_basis_points: bigint;
1074
+ fee_recipients: string[];
1075
+ set_creator_authority: string;
1076
+ admin_set_creator_authority: string;
1077
+ create_v2_enabled: boolean;
1078
+ whitelist_pda: string;
1079
+ reserved_fee_recipient: string;
1080
+ mayhem_mode_enabled: boolean;
1081
+ reserved_fee_recipients: string[];
1082
+ }
1083
+ export interface PumpFunGlobalAccountEvent {
1084
+ metadata: EventMetadata;
1085
+ pubkey: string;
1086
+ global: PumpFunGlobal;
1087
+ }
941
1088
  export interface PumpSwapGlobalConfig {
942
1089
  admin: string;
943
1090
  lp_fee_basis_points: bigint;
@@ -0,0 +1,4 @@
1
+ import type { DexEvent } from "./dex_event.js";
2
+ export declare function enrichCreateV2ObservedFeeRecipient(events: DexEvent[]): void;
3
+ export declare function enrichPumpfunTradesFromCreateInstructions(events: DexEvent[]): void;
4
+ export declare function enrichPumpfunSameTxPostMerge(events: DexEvent[]): void;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enrichCreateV2ObservedFeeRecipient = enrichCreateV2ObservedFeeRecipient;
4
+ exports.enrichPumpfunTradesFromCreateInstructions = enrichPumpfunTradesFromCreateInstructions;
5
+ exports.enrichPumpfunSameTxPostMerge = enrichPumpfunSameTxPostMerge;
6
+ const dex_event_js_1 = require("./dex_event.js");
7
+ function pumpfunTradeEvent(ev) {
8
+ if ("PumpFunTrade" in ev)
9
+ return ev.PumpFunTrade;
10
+ if ("PumpFunBuy" in ev)
11
+ return ev.PumpFunBuy;
12
+ if ("PumpFunSell" in ev)
13
+ return ev.PumpFunSell;
14
+ if ("PumpFunBuyExactSolIn" in ev)
15
+ return ev.PumpFunBuyExactSolIn;
16
+ return null;
17
+ }
18
+ function pumpfunCreateFlags(ev) {
19
+ let c = null;
20
+ if ("PumpFunCreate" in ev)
21
+ c = ev.PumpFunCreate;
22
+ if ("PumpFunCreateV2" in ev)
23
+ c = ev.PumpFunCreateV2;
24
+ if (!c || !c.mint || c.mint === (0, dex_event_js_1.defaultPubkey)())
25
+ return null;
26
+ return [c.mint, c.is_cashback_enabled, c.is_mayhem_mode];
27
+ }
28
+ function enrichCreateV2ObservedFeeRecipient(events) {
29
+ const zero = (0, dex_event_js_1.defaultPubkey)();
30
+ const mintToFee = new Map();
31
+ for (const ev of events) {
32
+ const t = pumpfunTradeEvent(ev);
33
+ if (!t || !t.mint || t.mint === zero || !t.fee_recipient || t.fee_recipient === zero) {
34
+ continue;
35
+ }
36
+ const buyLike = ("PumpFunTrade" in ev && t.is_buy) ||
37
+ "PumpFunBuy" in ev ||
38
+ "PumpFunBuyExactSolIn" in ev;
39
+ if (buyLike && !mintToFee.has(t.mint)) {
40
+ mintToFee.set(t.mint, t.fee_recipient);
41
+ }
42
+ }
43
+ if (mintToFee.size === 0)
44
+ return;
45
+ for (const ev of events) {
46
+ if (!("PumpFunCreateV2" in ev))
47
+ continue;
48
+ const c = ev.PumpFunCreateV2;
49
+ if (!c.observed_fee_recipient || c.observed_fee_recipient === zero) {
50
+ c.observed_fee_recipient = mintToFee.get(c.mint) ?? c.observed_fee_recipient;
51
+ }
52
+ }
53
+ }
54
+ function enrichPumpfunTradesFromCreateInstructions(events) {
55
+ const flags = new Map();
56
+ for (const ev of events) {
57
+ const f = pumpfunCreateFlags(ev);
58
+ if (f && !flags.has(f[0]))
59
+ flags.set(f[0], [f[1], f[2]]);
60
+ }
61
+ if (flags.size === 0)
62
+ return;
63
+ for (const ev of events) {
64
+ const t = pumpfunTradeEvent(ev);
65
+ if (!t || !t.mint || t.mint === (0, dex_event_js_1.defaultPubkey)())
66
+ continue;
67
+ const f = flags.get(t.mint);
68
+ if (!f)
69
+ continue;
70
+ const [cashbackEnabled, mayhemMode] = f;
71
+ t.is_cashback_coin ||= cashbackEnabled;
72
+ t.mayhem_mode ||= mayhemMode;
73
+ if (cashbackEnabled)
74
+ t.track_volume = true;
75
+ }
76
+ }
77
+ function enrichPumpfunSameTxPostMerge(events) {
78
+ enrichCreateV2ObservedFeeRecipient(events);
79
+ enrichPumpfunTradesFromCreateInstructions(events);
80
+ }
@@ -8,6 +8,7 @@ exports.parseTransactionEventsStreaming = parseTransactionEventsStreaming;
8
8
  exports.parseLogsStreaming = parseLogsStreaming;
9
9
  exports.parseTransactionWithStreamingListener = parseTransactionWithStreamingListener;
10
10
  exports.parseLog = parseLog;
11
+ const pumpfun_fee_enrich_js_1 = require("./pumpfun_fee_enrich.js");
11
12
  const optimized_matcher_js_1 = require("../logs/optimized_matcher.js");
12
13
  const clock_js_1 = require("./clock.js");
13
14
  Object.defineProperty(exports, "nowUs", { enumerable: true, get: function () { return clock_js_1.nowUs; } });
@@ -22,6 +23,7 @@ function parseLogsOnly(logs, signature, slot, blockTimeUs, txIndex = 0) {
22
23
  if (e)
23
24
  out.push(e);
24
25
  }
26
+ (0, pumpfun_fee_enrich_js_1.enrichPumpfunSameTxPostMerge)(out);
25
27
  return out;
26
28
  }
27
29
  function parseTransactionWithListener(instructionData, accounts, logs, signature, slot, txIndex, blockTimeUs, programId, listener) {
@@ -2,14 +2,22 @@
2
2
  * Yellowstone gRPC 客户端实现 - 基于 @triton-one/yellowstone-grpc
3
3
  */
4
4
  import { CommitmentLevel } from "@triton-one/yellowstone-grpc";
5
- import { type ClientConfig, type TransactionFilter, type SubscribeCallbacks } from "./types.js";
5
+ import type { DexEvent } from "../core/dex_event.js";
6
+ import { type AccountFilter, type ClientConfig, type EventTypeFilter, type TransactionFilter, type SubscribeCallbacks } from "./types.js";
6
7
  export { SubscribeCallbacks };
8
+ export interface DexEventSubscription extends AsyncIterable<DexEvent> {
9
+ id: string;
10
+ errors: AsyncIterable<Error>;
11
+ cancel(): void;
12
+ next(): Promise<IteratorResult<DexEvent>>;
13
+ }
7
14
  /** Yellowstone gRPC 客户端包装器 */
8
15
  export declare class YellowstoneGrpc {
9
16
  private client;
10
17
  private config;
11
18
  private connected;
12
19
  private subscribers;
20
+ private dexSubscribers;
13
21
  constructor(endpoint: string, xToken: string, config?: ClientConfig);
14
22
  /** 连接到 gRPC 服务器 */
15
23
  connect(): Promise<void>;
@@ -28,14 +36,31 @@ export declare class YellowstoneGrpc {
28
36
  * 若不回复,公共节点或 LB 可能在超时后 RST_STREAM(HTTP/2 CANCEL)。
29
37
  */
30
38
  private subscribePingPongRequest;
39
+ private static toBytes;
40
+ private static toBigInt;
41
+ private static protobufNumber;
42
+ private static timestampToMicros;
43
+ private parseAccountEvent;
31
44
  private initialSubscribeRequest;
32
45
  /** 订阅交易 */
33
46
  subscribeTransactions(filter: TransactionFilter, callbacks: SubscribeCallbacks): Promise<{
34
47
  id: string;
35
48
  cancel: () => void;
36
49
  }>;
50
+ /**
51
+ * 订阅并直接产出 `DexEvent`。
52
+ *
53
+ * 交易更新走统一交易解析(外层/内层指令 + 日志 + 数据填充);账户更新走 `parseAccountUnified`。
54
+ * 事件队列满时丢弃新事件,避免回调阻塞 gRPC 读循环,保持低延迟。
55
+ */
56
+ subscribeDexEvents(transactionFilters?: TransactionFilter[], accountFilters?: AccountFilter[], eventTypeFilter?: EventTypeFilter, options?: {
57
+ autoReconnect?: boolean;
58
+ }): Promise<DexEventSubscription>;
37
59
  /** 取消订阅 */
38
60
  unsubscribe(subId: string): void;
61
+ /** 动态更新当前 DEX 订阅过滤器(与 Rust update_subscription 语义对齐)。 */
62
+ updateSubscription(transactionFilters: TransactionFilter[], accountFilters: AccountFilter[]): Promise<void>;
63
+ update_subscription(transactionFilters: TransactionFilter[], accountFilters: AccountFilter[]): Promise<void>;
39
64
  /** 获取最新区块哈希 */
40
65
  getLatestBlockhash(commitment?: CommitmentLevel): Promise<{
41
66
  slot: number;