sol-parser-sdk-nodejs 0.3.0

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +449 -0
  3. package/README_CN.md +343 -0
  4. package/dist/accounts/mod.d.ts +11 -0
  5. package/dist/accounts/mod.js +53 -0
  6. package/dist/accounts/nonce.d.ts +5 -0
  7. package/dist/accounts/nonce.js +32 -0
  8. package/dist/accounts/pumpswap.d.ts +8 -0
  9. package/dist/accounts/pumpswap.js +192 -0
  10. package/dist/accounts/token.d.ts +5 -0
  11. package/dist/accounts/token.js +98 -0
  12. package/dist/accounts/types.d.ts +9 -0
  13. package/dist/accounts/types.js +2 -0
  14. package/dist/accounts/utils.d.ts +1 -0
  15. package/dist/accounts/utils.js +12 -0
  16. package/dist/core/account_dispatcher_rpc.d.ts +11 -0
  17. package/dist/core/account_dispatcher_rpc.js +155 -0
  18. package/dist/core/account_fill_bonk.d.ts +4 -0
  19. package/dist/core/account_fill_bonk.js +20 -0
  20. package/dist/core/account_fill_meteora.d.ts +14 -0
  21. package/dist/core/account_fill_meteora.js +26 -0
  22. package/dist/core/account_fill_orca.d.ts +5 -0
  23. package/dist/core/account_fill_orca.js +18 -0
  24. package/dist/core/account_fill_pumpfun.d.ts +7 -0
  25. package/dist/core/account_fill_pumpfun.js +75 -0
  26. package/dist/core/account_fill_pumpswap.d.ts +10 -0
  27. package/dist/core/account_fill_pumpswap.js +78 -0
  28. package/dist/core/account_fill_raydium.d.ts +20 -0
  29. package/dist/core/account_fill_raydium.js +104 -0
  30. package/dist/core/clock.d.ts +2 -0
  31. package/dist/core/clock.js +7 -0
  32. package/dist/core/common_filler_rpc.d.ts +6 -0
  33. package/dist/core/common_filler_rpc.js +21 -0
  34. package/dist/core/dex_event.d.ts +1009 -0
  35. package/dist/core/dex_event.js +14 -0
  36. package/dist/core/error.d.ts +43 -0
  37. package/dist/core/error.js +16 -0
  38. package/dist/core/json_utils.d.ts +8 -0
  39. package/dist/core/json_utils.js +18 -0
  40. package/dist/core/metadata.d.ts +10 -0
  41. package/dist/core/metadata.js +13 -0
  42. package/dist/core/rpc_invoke_map.d.ts +23 -0
  43. package/dist/core/rpc_invoke_map.js +157 -0
  44. package/dist/core/unified_parser.d.ts +19 -0
  45. package/dist/core/unified_parser.js +48 -0
  46. package/dist/grpc/client.d.ts +52 -0
  47. package/dist/grpc/client.js +309 -0
  48. package/dist/grpc/client_stub.d.ts +5 -0
  49. package/dist/grpc/client_stub.js +5 -0
  50. package/dist/grpc/types.d.ts +132 -0
  51. package/dist/grpc/types.js +304 -0
  52. package/dist/grpc/yellowstone_parse.d.ts +9 -0
  53. package/dist/grpc/yellowstone_parse.js +46 -0
  54. package/dist/index.d.ts +18 -0
  55. package/dist/index.js +99 -0
  56. package/dist/instr/bonk_ix.d.ts +5 -0
  57. package/dist/instr/bonk_ix.js +52 -0
  58. package/dist/instr/meteora_damm_ix.d.ts +6 -0
  59. package/dist/instr/meteora_damm_ix.js +349 -0
  60. package/dist/instr/mod.d.ts +15 -0
  61. package/dist/instr/mod.js +95 -0
  62. package/dist/instr/orca_whirlpool_ix.d.ts +5 -0
  63. package/dist/instr/orca_whirlpool_ix.js +73 -0
  64. package/dist/instr/program_ids.d.ts +14 -0
  65. package/dist/instr/program_ids.js +18 -0
  66. package/dist/instr/pumpfun_ix.d.ts +5 -0
  67. package/dist/instr/pumpfun_ix.js +167 -0
  68. package/dist/instr/pumpswap_ix.d.ts +5 -0
  69. package/dist/instr/pumpswap_ix.js +215 -0
  70. package/dist/instr/raydium_amm_v4_ix.d.ts +6 -0
  71. package/dist/instr/raydium_amm_v4_ix.js +46 -0
  72. package/dist/instr/raydium_clmm_ix.d.ts +5 -0
  73. package/dist/instr/raydium_clmm_ix.js +85 -0
  74. package/dist/instr/raydium_cpmm_ix.d.ts +5 -0
  75. package/dist/instr/raydium_cpmm_ix.js +63 -0
  76. package/dist/instr/utils.d.ts +10 -0
  77. package/dist/instr/utils.js +33 -0
  78. package/dist/logs/meteora_amm.d.ts +8 -0
  79. package/dist/logs/meteora_amm.js +113 -0
  80. package/dist/logs/meteora_damm.d.ts +6 -0
  81. package/dist/logs/meteora_damm.js +509 -0
  82. package/dist/logs/meteora_dlmm.d.ts +6 -0
  83. package/dist/logs/meteora_dlmm.js +201 -0
  84. package/dist/logs/optimized_matcher.d.ts +5 -0
  85. package/dist/logs/optimized_matcher.js +194 -0
  86. package/dist/logs/orca.d.ts +6 -0
  87. package/dist/logs/orca.js +148 -0
  88. package/dist/logs/program_data.d.ts +2 -0
  89. package/dist/logs/program_data.js +22 -0
  90. package/dist/logs/program_log_discriminators.d.ts +59 -0
  91. package/dist/logs/program_log_discriminators.js +67 -0
  92. package/dist/logs/pump.d.ts +12 -0
  93. package/dist/logs/pump.js +251 -0
  94. package/dist/logs/pump_amm.d.ts +9 -0
  95. package/dist/logs/pump_amm.js +418 -0
  96. package/dist/logs/raydium_amm.d.ts +9 -0
  97. package/dist/logs/raydium_amm.js +224 -0
  98. package/dist/logs/raydium_clmm.d.ts +8 -0
  99. package/dist/logs/raydium_clmm.js +141 -0
  100. package/dist/logs/raydium_cpmm.d.ts +7 -0
  101. package/dist/logs/raydium_cpmm.js +121 -0
  102. package/dist/logs/raydium_launchpad.d.ts +12 -0
  103. package/dist/logs/raydium_launchpad.js +92 -0
  104. package/dist/parser_alias.d.ts +3 -0
  105. package/dist/parser_alias.js +2 -0
  106. package/dist/rpc_parser.d.ts +16 -0
  107. package/dist/rpc_parser.js +36 -0
  108. package/dist/rpc_transaction.d.ts +25 -0
  109. package/dist/rpc_transaction.js +111 -0
  110. package/dist/util/binary.d.ts +14 -0
  111. package/dist/util/binary.js +82 -0
  112. package/dist/warmup.d.ts +3 -0
  113. package/dist/warmup.js +23 -0
  114. package/package.json +44 -0
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parsePumpfunInstruction = parsePumpfunInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ const binary_js_1 = require("../util/binary.js");
7
+ const Z = (0, dex_event_js_1.defaultPubkey)();
8
+ const DISC = {
9
+ CREATE: Uint8Array.from([24, 30, 200, 40, 5, 28, 7, 119]),
10
+ CREATE_V2: Uint8Array.from([214, 144, 76, 236, 95, 139, 49, 180]),
11
+ MIGRATE_EVENT_LOG: Uint8Array.from([189, 233, 93, 185, 92, 148, 234, 148]),
12
+ };
13
+ function discEq(data, disc) {
14
+ if (data.length < 8)
15
+ return false;
16
+ for (let i = 0; i < 8; i++)
17
+ if (data[i] !== disc[i])
18
+ return false;
19
+ return true;
20
+ }
21
+ function createNumericDefaults() {
22
+ return {
23
+ timestamp: 0n,
24
+ virtual_token_reserves: 0n,
25
+ virtual_sol_reserves: 0n,
26
+ real_token_reserves: 0n,
27
+ token_total_supply: 0n,
28
+ is_mayhem_mode: false,
29
+ is_cashback_enabled: false,
30
+ };
31
+ }
32
+ function parsePumpfunInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
33
+ if (instructionData.length < 8)
34
+ return null;
35
+ const outer = instructionData.subarray(0, 8);
36
+ const data = instructionData.subarray(8);
37
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
38
+ if (discEq(outer, DISC.CREATE_V2)) {
39
+ if (accounts.length < 16)
40
+ return null;
41
+ let o = 0;
42
+ const n1 = (0, utils_js_1.readBorshStrAt)(data, o);
43
+ if (!n1)
44
+ return null;
45
+ o = n1.next;
46
+ const n2 = (0, utils_js_1.readBorshStrAt)(data, o);
47
+ if (!n2)
48
+ return null;
49
+ o = n2.next;
50
+ const n3 = (0, utils_js_1.readBorshStrAt)(data, o);
51
+ if (!n3)
52
+ return null;
53
+ o = n3.next;
54
+ const creator = o + 32 <= data.length ? (0, utils_js_1.readPubkeyIx)(data, o) ?? Z : Z;
55
+ const mint = accounts[0];
56
+ const ev = {
57
+ metadata: meta,
58
+ name: n1.s,
59
+ symbol: n2.s,
60
+ uri: n3.s,
61
+ mint,
62
+ bonding_curve: accounts[2] ?? Z,
63
+ user: accounts[5] ?? Z,
64
+ creator,
65
+ mint_authority: accounts[1] ?? Z,
66
+ associated_bonding_curve: accounts[3] ?? Z,
67
+ global: accounts[4] ?? Z,
68
+ system_program: accounts[6] ?? Z,
69
+ token_program: accounts[7] ?? Z,
70
+ associated_token_program: accounts[8] ?? Z,
71
+ mayhem_program_id: accounts[9] ?? Z,
72
+ global_params: accounts[10] ?? Z,
73
+ sol_vault: accounts[11] ?? Z,
74
+ mayhem_state: accounts[12] ?? Z,
75
+ mayhem_token_vault: accounts[13] ?? Z,
76
+ event_authority: accounts[14] ?? Z,
77
+ program: accounts[15] ?? Z,
78
+ ...createNumericDefaults(),
79
+ };
80
+ return { PumpFunCreateV2: ev };
81
+ }
82
+ if (discEq(outer, DISC.CREATE)) {
83
+ if (accounts.length < 8)
84
+ return null;
85
+ let o = 0;
86
+ const n1 = (0, utils_js_1.readBorshStrAt)(data, o);
87
+ if (!n1)
88
+ return null;
89
+ o = n1.next;
90
+ const n2 = (0, utils_js_1.readBorshStrAt)(data, o);
91
+ if (!n2)
92
+ return null;
93
+ o = n2.next;
94
+ const n3 = (0, utils_js_1.readBorshStrAt)(data, o);
95
+ if (!n3)
96
+ return null;
97
+ o = n3.next;
98
+ const creator = o + 32 <= data.length ? (0, utils_js_1.readPubkeyIx)(data, o) ?? Z : Z;
99
+ const mint = accounts[0];
100
+ return {
101
+ PumpFunCreate: {
102
+ metadata: meta,
103
+ name: n1.s,
104
+ symbol: n2.s,
105
+ uri: n3.s,
106
+ mint,
107
+ bonding_curve: accounts[2] ?? Z,
108
+ user: accounts[7] ?? Z,
109
+ creator,
110
+ token_program: Z,
111
+ ...createNumericDefaults(),
112
+ },
113
+ };
114
+ }
115
+ if (instructionData.length >= 16) {
116
+ const cpi = instructionData.subarray(8, 16);
117
+ if (discEq(cpi, DISC.MIGRATE_EVENT_LOG)) {
118
+ const payload = instructionData.subarray(16);
119
+ let o = 0;
120
+ const user = (0, utils_js_1.readPubkeyIx)(payload, o);
121
+ if (!user)
122
+ return null;
123
+ o += 32;
124
+ const mint = (0, utils_js_1.readPubkeyIx)(payload, o);
125
+ if (!mint)
126
+ return null;
127
+ o += 32;
128
+ const mint_amount = (0, utils_js_1.readU64LE)(payload, o);
129
+ if (mint_amount === null)
130
+ return null;
131
+ o += 8;
132
+ const sol_amount = (0, utils_js_1.readU64LE)(payload, o);
133
+ if (sol_amount === null)
134
+ return null;
135
+ o += 8;
136
+ const pool_migration_fee = (0, utils_js_1.readU64LE)(payload, o);
137
+ if (pool_migration_fee === null)
138
+ return null;
139
+ o += 8;
140
+ const bonding_curve = (0, utils_js_1.readPubkeyIx)(payload, o);
141
+ if (!bonding_curve)
142
+ return null;
143
+ o += 32;
144
+ const ts = (0, binary_js_1.readI64LE)(payload, o);
145
+ if (ts === null)
146
+ return null;
147
+ o += 8;
148
+ const pool = (0, utils_js_1.readPubkeyIx)(payload, o);
149
+ if (!pool)
150
+ return null;
151
+ return {
152
+ PumpFunMigrate: {
153
+ metadata: meta,
154
+ user,
155
+ mint,
156
+ mint_amount,
157
+ sol_amount,
158
+ pool_migration_fee,
159
+ bonding_curve,
160
+ timestamp: BigInt(ts),
161
+ pool,
162
+ },
163
+ };
164
+ }
165
+ }
166
+ return null;
167
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * PumpSwap 指令解析
3
+ */
4
+ import type { DexEvent } from "../core/dex_event.js";
5
+ export declare function parsePumpswapInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined): DexEvent | null;
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parsePumpswapInstruction = parsePumpswapInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ const ZP = (0, dex_event_js_1.defaultPubkey)();
7
+ const Z = ZP;
8
+ function disc8(a) {
9
+ return Uint8Array.from(a);
10
+ }
11
+ const PS = {
12
+ BUY: disc8([102, 6, 61, 18, 1, 218, 235, 234]),
13
+ SELL: disc8([51, 230, 133, 164, 1, 127, 131, 173]),
14
+ CREATE_POOL: disc8([233, 146, 209, 142, 207, 104, 64, 188]),
15
+ BUY_EXACT_QUOTE_IN: disc8([198, 46, 21, 82, 180, 217, 232, 112]),
16
+ DEPOSIT: disc8([242, 35, 198, 137, 82, 225, 242, 182]),
17
+ WITHDRAW: disc8([183, 18, 70, 156, 148, 109, 161, 34]),
18
+ };
19
+ function discEq(h, d) {
20
+ for (let i = 0; i < 8; i++)
21
+ if (h[i] !== d[i])
22
+ return false;
23
+ return true;
24
+ }
25
+ function buyLike(data, accounts, meta, swapOrder) {
26
+ const [a0, a1] = data.length >= 16
27
+ ? [(0, utils_js_1.readU64LE)(data, 0) ?? 0n, (0, utils_js_1.readU64LE)(data, 8) ?? 0n]
28
+ : [0n, 0n];
29
+ const [base_amount_out, max_quote_amount_in] = swapOrder === "buy" ? [a0, a1] : [a1, a0];
30
+ const ev = {
31
+ metadata: meta,
32
+ timestamp: 0n,
33
+ base_amount_out,
34
+ max_quote_amount_in,
35
+ user_base_token_reserves: 0n,
36
+ user_quote_token_reserves: 0n,
37
+ pool_base_token_reserves: 0n,
38
+ pool_quote_token_reserves: 0n,
39
+ quote_amount_in: 0n,
40
+ lp_fee_basis_points: 0n,
41
+ lp_fee: 0n,
42
+ protocol_fee_basis_points: 0n,
43
+ protocol_fee: 0n,
44
+ quote_amount_in_with_lp_fee: 0n,
45
+ user_quote_amount_in: 0n,
46
+ pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
47
+ user: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
48
+ user_base_token_account: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
49
+ user_quote_token_account: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
50
+ protocol_fee_recipient: (0, utils_js_1.getAccount)(accounts, 9) ?? Z,
51
+ protocol_fee_recipient_token_account: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
52
+ coin_creator: Z,
53
+ coin_creator_fee_basis_points: 0n,
54
+ coin_creator_fee: 0n,
55
+ track_volume: false,
56
+ total_unclaimed_tokens: 0n,
57
+ total_claimed_tokens: 0n,
58
+ current_sol_volume: 0n,
59
+ last_update_timestamp: 0n,
60
+ min_base_amount_out: 0n,
61
+ ix_name: "",
62
+ cashback_fee_basis_points: 0n,
63
+ cashback: 0n,
64
+ is_pump_pool: false,
65
+ base_mint: ZP,
66
+ quote_mint: ZP,
67
+ pool_base_token_account: ZP,
68
+ pool_quote_token_account: ZP,
69
+ coin_creator_vault_ata: ZP,
70
+ coin_creator_vault_authority: ZP,
71
+ base_token_program: ZP,
72
+ quote_token_program: ZP,
73
+ };
74
+ return ev;
75
+ }
76
+ function parsePumpswapInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs) {
77
+ if (instructionData.length < 8)
78
+ return null;
79
+ const head = instructionData.subarray(0, 8);
80
+ const data = instructionData.subarray(8);
81
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, 0);
82
+ if (discEq(head, PS.BUY)) {
83
+ if (accounts.length < 13)
84
+ return null;
85
+ return { PumpSwapBuy: buyLike(data, accounts, meta, "buy") };
86
+ }
87
+ if (discEq(head, PS.BUY_EXACT_QUOTE_IN)) {
88
+ if (accounts.length < 13)
89
+ return null;
90
+ return { PumpSwapBuy: buyLike(data, accounts, meta, "buy_exact") };
91
+ }
92
+ if (discEq(head, PS.SELL)) {
93
+ if (accounts.length < 13)
94
+ return null;
95
+ const [base_amount_in, min_quote_amount_out] = data.length >= 16
96
+ ? [(0, utils_js_1.readU64LE)(data, 0) ?? 0n, (0, utils_js_1.readU64LE)(data, 8) ?? 0n]
97
+ : [0n, 0n];
98
+ const ev = {
99
+ metadata: meta,
100
+ timestamp: 0n,
101
+ base_amount_in,
102
+ min_quote_amount_out,
103
+ user_base_token_reserves: 0n,
104
+ user_quote_token_reserves: 0n,
105
+ pool_base_token_reserves: 0n,
106
+ pool_quote_token_reserves: 0n,
107
+ quote_amount_out: 0n,
108
+ lp_fee_basis_points: 0n,
109
+ lp_fee: 0n,
110
+ protocol_fee_basis_points: 0n,
111
+ protocol_fee: 0n,
112
+ quote_amount_out_without_lp_fee: 0n,
113
+ user_quote_amount_out: 0n,
114
+ pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
115
+ user: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
116
+ user_base_token_account: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
117
+ user_quote_token_account: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
118
+ protocol_fee_recipient: (0, utils_js_1.getAccount)(accounts, 9) ?? Z,
119
+ protocol_fee_recipient_token_account: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
120
+ coin_creator: Z,
121
+ coin_creator_fee_basis_points: 0n,
122
+ coin_creator_fee: 0n,
123
+ cashback_fee_basis_points: 0n,
124
+ cashback: 0n,
125
+ is_pump_pool: false,
126
+ base_mint: ZP,
127
+ quote_mint: ZP,
128
+ pool_base_token_account: ZP,
129
+ pool_quote_token_account: ZP,
130
+ coin_creator_vault_ata: ZP,
131
+ coin_creator_vault_authority: ZP,
132
+ base_token_program: ZP,
133
+ quote_token_program: ZP,
134
+ };
135
+ return { PumpSwapSell: ev };
136
+ }
137
+ if (discEq(head, PS.CREATE_POOL)) {
138
+ if (accounts.length < 5)
139
+ return null;
140
+ const ev = {
141
+ metadata: meta,
142
+ timestamp: 0n,
143
+ index: 0,
144
+ creator: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
145
+ base_mint: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
146
+ quote_mint: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
147
+ base_mint_decimals: 0,
148
+ quote_mint_decimals: 0,
149
+ base_amount_in: 0n,
150
+ quote_amount_in: 0n,
151
+ pool_base_amount: 0n,
152
+ pool_quote_amount: 0n,
153
+ minimum_liquidity: 0n,
154
+ initial_liquidity: 0n,
155
+ lp_token_amount_out: 0n,
156
+ pool_bump: 0,
157
+ pool: Z,
158
+ lp_mint: Z,
159
+ user_base_token_account: Z,
160
+ user_quote_token_account: Z,
161
+ coin_creator: Z,
162
+ is_mayhem_mode: false,
163
+ };
164
+ return { PumpSwapCreatePool: ev };
165
+ }
166
+ if (discEq(head, PS.DEPOSIT)) {
167
+ if (accounts.length < 8)
168
+ return null;
169
+ const ev = {
170
+ metadata: meta,
171
+ timestamp: 0n,
172
+ lp_token_amount_out: 0n,
173
+ max_base_amount_in: 0n,
174
+ max_quote_amount_in: 0n,
175
+ user_base_token_reserves: 0n,
176
+ user_quote_token_reserves: 0n,
177
+ pool_base_token_reserves: 0n,
178
+ pool_quote_token_reserves: 0n,
179
+ base_amount_in: 0n,
180
+ quote_amount_in: 0n,
181
+ lp_mint_supply: 0n,
182
+ pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
183
+ user: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
184
+ user_base_token_account: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
185
+ user_quote_token_account: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
186
+ user_pool_token_account: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
187
+ };
188
+ return { PumpSwapLiquidityAdded: ev };
189
+ }
190
+ if (discEq(head, PS.WITHDRAW)) {
191
+ if (accounts.length < 8)
192
+ return null;
193
+ const ev = {
194
+ metadata: meta,
195
+ timestamp: 0n,
196
+ lp_token_amount_in: 0n,
197
+ min_base_amount_out: 0n,
198
+ min_quote_amount_out: 0n,
199
+ user_base_token_reserves: 0n,
200
+ user_quote_token_reserves: 0n,
201
+ pool_base_token_reserves: 0n,
202
+ pool_quote_token_reserves: 0n,
203
+ base_amount_out: 0n,
204
+ quote_amount_out: 0n,
205
+ lp_mint_supply: 0n,
206
+ pool: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
207
+ user: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
208
+ user_base_token_account: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
209
+ user_quote_token_account: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
210
+ user_pool_token_account: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
211
+ };
212
+ return { PumpSwapLiquidityRemoved: ev };
213
+ }
214
+ return null;
215
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Raydium AMM V4 指令解析
3
+ * 注意:Raydium AMM V4 使用单字节 instruction discriminator
4
+ */
5
+ import type { DexEvent } from "../core/dex_event.js";
6
+ export declare function parseRaydiumAmmV4Instruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRaydiumAmmV4Instruction = parseRaydiumAmmV4Instruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ const Z = (0, dex_event_js_1.defaultPubkey)();
7
+ // Raydium AMM V4 使用单字节指令类型
8
+ const INSTR_TYPE = {
9
+ SWAP_BASE_IN: 9,
10
+ SWAP_BASE_OUT: 11,
11
+ };
12
+ function parseRaydiumAmmV4Instruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
13
+ if (instructionData.length < 1)
14
+ return null;
15
+ const instrType = instructionData[0];
16
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
17
+ if (instrType === INSTR_TYPE.SWAP_BASE_IN || instrType === INSTR_TYPE.SWAP_BASE_OUT) {
18
+ return {
19
+ RaydiumAmmV4Swap: {
20
+ metadata: meta,
21
+ amm: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
22
+ user_source_owner: (0, utils_js_1.getAccount)(accounts, 17) ?? Z,
23
+ amount_in: 0n,
24
+ minimum_amount_out: 0n,
25
+ max_amount_in: 0n,
26
+ amount_out: 0n,
27
+ token_program: Z,
28
+ amm_authority: Z,
29
+ amm_open_orders: Z,
30
+ pool_coin_token_account: Z,
31
+ pool_pc_token_account: Z,
32
+ serum_program: Z,
33
+ serum_market: Z,
34
+ serum_bids: Z,
35
+ serum_asks: Z,
36
+ serum_event_queue: Z,
37
+ serum_coin_vault_account: Z,
38
+ serum_pc_vault_account: Z,
39
+ serum_vault_signer: Z,
40
+ user_source_token_account: Z,
41
+ user_destination_token_account: Z,
42
+ },
43
+ };
44
+ }
45
+ return null;
46
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Raydium CLMM 指令解析
3
+ */
4
+ import type { DexEvent } from "../core/dex_event.js";
5
+ export declare function parseRaydiumClmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRaydiumClmmInstruction = parseRaydiumClmmInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ const Z = (0, dex_event_js_1.defaultPubkey)();
7
+ // Discriminators (little-endian u64)
8
+ const DISC = {
9
+ SWAP: 14494794552504610216n, // disc8(248, 198, 158, 145, 225, 117, 135, 200)
10
+ INCREASE_LIQUIDITY: 746211110853564037n, // disc8(133, 29, 89, 223, 69, 238, 176, 10)
11
+ DECREASE_LIQUIDITY: 100389049586398241n, // disc8(160, 38, 208, 111, 104, 91, 44, 1)
12
+ CREATE_POOL: 13543951572834378153n, // disc8(233, 146, 209, 142, 207, 104, 64, 188)
13
+ };
14
+ function discEq(data, disc) {
15
+ if (data.length < 8)
16
+ return false;
17
+ const v = (0, utils_js_1.readU64LE)(data, 0);
18
+ return v === disc;
19
+ }
20
+ function parseRaydiumClmmInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
21
+ if (instructionData.length < 8)
22
+ return null;
23
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
24
+ if (discEq(instructionData, DISC.SWAP)) {
25
+ return {
26
+ RaydiumClmmSwap: {
27
+ metadata: meta,
28
+ pool_state: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
29
+ sender: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
30
+ token_account_0: Z,
31
+ token_account_1: Z,
32
+ amount_0: 0n,
33
+ amount_1: 0n,
34
+ zero_for_one: false,
35
+ sqrt_price_x64: 0n,
36
+ liquidity: 0n,
37
+ transfer_fee_0: 0n,
38
+ transfer_fee_1: 0n,
39
+ tick: 0,
40
+ },
41
+ };
42
+ }
43
+ if (discEq(instructionData, DISC.INCREASE_LIQUIDITY)) {
44
+ return {
45
+ RaydiumClmmIncreaseLiquidity: {
46
+ metadata: meta,
47
+ pool: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
48
+ position_nft_mint: Z,
49
+ user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
50
+ liquidity: 0n,
51
+ amount0_max: 0n,
52
+ amount1_max: 0n,
53
+ },
54
+ };
55
+ }
56
+ if (discEq(instructionData, DISC.DECREASE_LIQUIDITY)) {
57
+ return {
58
+ RaydiumClmmDecreaseLiquidity: {
59
+ metadata: meta,
60
+ pool: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
61
+ position_nft_mint: Z,
62
+ user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
63
+ liquidity: 0n,
64
+ amount0_min: 0n,
65
+ amount1_min: 0n,
66
+ },
67
+ };
68
+ }
69
+ if (discEq(instructionData, DISC.CREATE_POOL)) {
70
+ return {
71
+ RaydiumClmmCreatePool: {
72
+ metadata: meta,
73
+ pool: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
74
+ creator: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
75
+ token_0_mint: Z,
76
+ token_1_mint: Z,
77
+ tick_spacing: 0,
78
+ fee_rate: 0,
79
+ sqrt_price_x64: 0n,
80
+ open_time: 0n,
81
+ },
82
+ };
83
+ }
84
+ return null;
85
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Raydium CPMM 指令解析
3
+ */
4
+ import type { DexEvent } from "../core/dex_event.js";
5
+ export declare function parseRaydiumCpmmInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRaydiumCpmmInstruction = parseRaydiumCpmmInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ const Z = (0, dex_event_js_1.defaultPubkey)();
7
+ // Discriminators (little-endian u64)
8
+ const DISC = {
9
+ SWAP: 16066630856980634287n, // disc8(143, 190, 90, 218, 196, 30, 51, 222)
10
+ DEPOSIT: 13142033090605164850n, // disc8(242, 35, 198, 137, 82, 225, 242, 182)
11
+ WITHDRAW: 2464928621593348407n, // disc8(183, 18, 70, 156, 148, 109, 161, 34)
12
+ };
13
+ function discEq(data, disc) {
14
+ if (data.length < 8)
15
+ return false;
16
+ const v = (0, utils_js_1.readU64LE)(data, 0);
17
+ return v === disc;
18
+ }
19
+ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
20
+ if (instructionData.length < 8)
21
+ return null;
22
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
23
+ if (discEq(instructionData, DISC.SWAP)) {
24
+ return {
25
+ RaydiumCpmmSwap: {
26
+ metadata: meta,
27
+ pool_id: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
28
+ input_amount: 0n,
29
+ output_amount: 0n,
30
+ input_vault_before: 0n,
31
+ output_vault_before: 0n,
32
+ input_transfer_fee: 0n,
33
+ output_transfer_fee: 0n,
34
+ base_input: true,
35
+ },
36
+ };
37
+ }
38
+ if (discEq(instructionData, DISC.DEPOSIT)) {
39
+ return {
40
+ RaydiumCpmmDeposit: {
41
+ metadata: meta,
42
+ pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
43
+ user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
44
+ lp_token_amount: 0n,
45
+ token0_amount: 0n,
46
+ token1_amount: 0n,
47
+ },
48
+ };
49
+ }
50
+ if (discEq(instructionData, DISC.WITHDRAW)) {
51
+ return {
52
+ RaydiumCpmmWithdraw: {
53
+ metadata: meta,
54
+ pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
55
+ user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
56
+ lp_token_amount: 0n,
57
+ token0_amount: 0n,
58
+ token1_amount: 0n,
59
+ },
60
+ };
61
+ }
62
+ return null;
63
+ }
@@ -0,0 +1,10 @@
1
+ import type { EventMetadata } from "../core/metadata.js";
2
+ export declare function ixMeta(signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): EventMetadata;
3
+ export declare function getAccount(accounts: string[], i: number): string | undefined;
4
+ /** Borsh 前缀字符串,返回 (utf8, 下一个 offset);失败返回 null */
5
+ export declare function readBorshStrAt(data: Uint8Array, offset: number): {
6
+ s: string;
7
+ next: number;
8
+ } | null;
9
+ export declare function readPubkeyIx(data: Uint8Array, o: number): string | null;
10
+ export { readU64LE, readU128LE, readU8, readBool, readI64LE, } from "../util/binary.js";
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readI64LE = exports.readBool = exports.readU8 = exports.readU128LE = exports.readU64LE = void 0;
4
+ exports.ixMeta = ixMeta;
5
+ exports.getAccount = getAccount;
6
+ exports.readBorshStrAt = readBorshStrAt;
7
+ exports.readPubkeyIx = readPubkeyIx;
8
+ const binary_js_1 = require("../util/binary.js");
9
+ function ixMeta(signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
10
+ return {
11
+ signature,
12
+ slot,
13
+ tx_index: txIndex,
14
+ block_time_us: blockTimeUs ?? 0,
15
+ grpc_recv_us: grpcRecvUs,
16
+ };
17
+ }
18
+ function getAccount(accounts, i) {
19
+ return accounts[i];
20
+ }
21
+ /** Borsh 前缀字符串,返回 (utf8, 下一个 offset);失败返回 null */
22
+ function readBorshStrAt(data, offset) {
23
+ return (0, binary_js_1.readBorshString)(data, offset);
24
+ }
25
+ function readPubkeyIx(data, o) {
26
+ return (0, binary_js_1.readPubkey)(data, o);
27
+ }
28
+ var binary_js_2 = require("../util/binary.js");
29
+ Object.defineProperty(exports, "readU64LE", { enumerable: true, get: function () { return binary_js_2.readU64LE; } });
30
+ Object.defineProperty(exports, "readU128LE", { enumerable: true, get: function () { return binary_js_2.readU128LE; } });
31
+ Object.defineProperty(exports, "readU8", { enumerable: true, get: function () { return binary_js_2.readU8; } });
32
+ Object.defineProperty(exports, "readBool", { enumerable: true, get: function () { return binary_js_2.readBool; } });
33
+ Object.defineProperty(exports, "readI64LE", { enumerable: true, get: function () { return binary_js_2.readI64LE; } });
@@ -0,0 +1,8 @@
1
+ import type { EventMetadata } from "../core/metadata.js";
2
+ import type { DexEvent } from "../core/dex_event.js";
3
+ export declare function parseSwapFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
4
+ export declare function parseAddLiquidityFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
5
+ export declare function parseRemoveLiquidityFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
6
+ export declare function parseBootstrapLiquidityFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
7
+ export declare function parseSetPoolFeesFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
8
+ export declare function parsePoolCreatedFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;