sol-parser-sdk 0.5.14 → 0.5.15

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseMeteoraDammInstruction = parseMeteoraDammInstruction;
4
4
  const dex_event_js_1 = require("../core/dex_event.js");
5
+ const meteora_damm_js_1 = require("../logs/meteora_damm.js");
5
6
  const utils_js_1 = require("./utils.js");
6
7
  const Z = (0, dex_event_js_1.defaultPubkey)();
7
8
  function disc8(a) {
@@ -14,6 +15,11 @@ const CPI = {
14
15
  CLOSE_POSITION_LOG: disc8([20, 145, 144, 68, 143, 142, 214, 178]),
15
16
  ADD_LIQUIDITY_LOG: disc8([175, 242, 8, 157, 30, 247, 185, 169]),
16
17
  REMOVE_LIQUIDITY_LOG: disc8([87, 46, 88, 98, 175, 96, 34, 91]),
18
+ LIQUIDITY_CHANGE_LOG: disc8([197, 171, 78, 127, 224, 211, 87, 13]),
19
+ UPDATE_DELEGATE_PERMISSION_LOG: disc8([66, 188, 75, 151, 150, 232, 87, 93]),
20
+ WITHDRAW_DEAD_LIQUIDITY_REWARD_LOG: disc8([228, 66, 150, 195, 42, 62, 163, 13]),
21
+ CREATE_CONFIG_LOG: disc8([131, 207, 180, 174, 180, 73, 165, 54]),
22
+ CREATE_DYNAMIC_CONFIG_LOG: disc8([231, 197, 13, 164, 248, 213, 133, 152]),
17
23
  };
18
24
  /** 与 cp_amm Anchor IDL `instructions[].discriminator` 一致(用户直接调用的外层指令) */
19
25
  const ANCHOR = {
@@ -107,13 +113,28 @@ function parseOuterSwap2Ix(instructionData, accounts, meta) {
107
113
  const swap_mode = (0, utils_js_1.readU8)(instructionData, 24);
108
114
  if (swap_mode === null)
109
115
  return null;
110
- const [amount_in, minimum_amount_out] = swap_mode === 0 ? [amount_0, amount_1] : [amount_1, amount_0];
116
+ let amount_in;
117
+ let minimum_amount_out;
118
+ if (swap_mode === 0 || swap_mode === 1) {
119
+ amount_in = amount_0;
120
+ minimum_amount_out = amount_1;
121
+ }
122
+ else if (swap_mode === 2) {
123
+ amount_in = amount_1;
124
+ minimum_amount_out = amount_0;
125
+ }
126
+ else {
127
+ return null;
128
+ }
111
129
  const pool = (0, utils_js_1.getAccount)(accounts, 1) ?? Z;
112
130
  const ev = {
113
131
  metadata: meta,
114
132
  pool,
115
133
  trade_direction: 0,
116
134
  has_referral: false,
135
+ amount_0,
136
+ amount_1,
137
+ swap_mode,
117
138
  amount_in,
118
139
  minimum_amount_out,
119
140
  output_amount: 0n,
@@ -335,85 +356,11 @@ function parseSwapCpi(data, accounts, meta) {
335
356
  return { MeteoraDammV2Swap: ev };
336
357
  }
337
358
  function parseSwap2Cpi(data, accounts, meta) {
338
- let o = 0;
339
- const pool = (0, utils_js_1.readPubkeyIx)(data, o);
340
- if (!pool)
341
- return null;
342
- o += 32;
343
- const trade_direction = (0, utils_js_1.readU8)(data, o);
344
- if (trade_direction === null)
345
- return null;
346
- o += 1;
347
- const _cfm = (0, utils_js_1.readU8)(data, o);
348
- if (_cfm === null)
349
- return null;
350
- o += 1;
351
- const has_referral = (0, utils_js_1.readBool)(data, o);
352
- if (has_referral === null)
353
- return null;
354
- o += 1;
355
- const amount_0 = (0, utils_js_1.readU64LE)(data, o);
356
- if (amount_0 === null)
357
- return null;
358
- o += 8;
359
- const amount_1 = (0, utils_js_1.readU64LE)(data, o);
360
- if (amount_1 === null)
361
- return null;
362
- o += 8;
363
- const swap_mode = (0, utils_js_1.readU8)(data, o);
364
- if (swap_mode === null)
365
- return null;
366
- o += 1;
367
- const included_fee_input_amount = (0, utils_js_1.readU64LE)(data, o);
368
- if (included_fee_input_amount === null)
369
- return null;
370
- o += 8;
371
- o += 8;
372
- o += 8;
373
- const output_amount = (0, utils_js_1.readU64LE)(data, o);
374
- if (output_amount === null)
375
- return null;
376
- o += 8;
377
- const next_sqrt_price = (0, utils_js_1.readU128LE)(data, o);
378
- if (next_sqrt_price === null)
379
- return null;
380
- o += 16;
381
- const lp_fee = (0, utils_js_1.readU64LE)(data, o);
382
- if (lp_fee === null)
383
- return null;
384
- o += 8;
385
- const protocol_fee = (0, utils_js_1.readU64LE)(data, o);
386
- if (protocol_fee === null)
387
- return null;
388
- o += 8;
389
- const referral_fee = (0, utils_js_1.readU64LE)(data, o);
390
- if (referral_fee === null)
359
+ const ev = (0, meteora_damm_js_1.parseSwap2FromData)(data, meta);
360
+ if (!ev || !("MeteoraDammV2Swap" in ev))
391
361
  return null;
392
- o += 8;
393
- o += 8;
394
- o += 8;
395
- const current_timestamp = (0, utils_js_1.readU64LE)(data, o);
396
- if (current_timestamp === null)
397
- return null;
398
- const [amount_in, minimum_amount_out] = swap_mode === 0 ? [amount_0, amount_1] : [amount_1, amount_0];
399
- const ev = {
400
- metadata: meta,
401
- pool,
402
- trade_direction,
403
- has_referral,
404
- amount_in,
405
- minimum_amount_out,
406
- output_amount,
407
- next_sqrt_price,
408
- lp_fee,
409
- protocol_fee,
410
- partner_fee: 0n,
411
- referral_fee,
412
- actual_amount_in: included_fee_input_amount,
413
- current_timestamp,
414
- ...meteoraSwapVaultsFromAccounts(accounts),
415
- };
416
- return { MeteoraDammV2Swap: ev };
362
+ Object.assign(ev.MeteoraDammV2Swap, meteoraSwapVaultsFromAccounts(accounts));
363
+ return ev;
417
364
  }
418
365
  function parseMeteoraDammInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
419
366
  if (instructionData.length < 8)
@@ -597,5 +544,20 @@ function parseMeteoraDammInstruction(instructionData, accounts, signature, slot,
597
544
  },
598
545
  };
599
546
  }
547
+ if (discEq(cpiHead, CPI.LIQUIDITY_CHANGE_LOG)) {
548
+ return (0, meteora_damm_js_1.parseLiquidityChangeFromData)(cpiData, meta);
549
+ }
550
+ if (discEq(cpiHead, CPI.UPDATE_DELEGATE_PERMISSION_LOG)) {
551
+ return (0, meteora_damm_js_1.parseUpdateDelegatePermissionFromData)(cpiData, meta);
552
+ }
553
+ if (discEq(cpiHead, CPI.WITHDRAW_DEAD_LIQUIDITY_REWARD_LOG)) {
554
+ return (0, meteora_damm_js_1.parseWithdrawDeadLiquidityRewardFromData)(cpiData, meta);
555
+ }
556
+ if (discEq(cpiHead, CPI.CREATE_CONFIG_LOG)) {
557
+ return (0, meteora_damm_js_1.parseCreateConfigFromData)(cpiData, meta);
558
+ }
559
+ if (discEq(cpiHead, CPI.CREATE_DYNAMIC_CONFIG_LOG)) {
560
+ return (0, meteora_damm_js_1.parseCreateDynamicConfigFromData)(cpiData, meta);
561
+ }
600
562
  return null;
601
563
  }
@@ -151,6 +151,11 @@ function parseMeteoraDlmmInstruction(instructionData, accounts, signature, slot,
151
151
  return {
152
152
  MeteoraDlmmSwap: {
153
153
  metadata,
154
+ token_x_mint: Z,
155
+ token_y_mint: Z,
156
+ user_token_in: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
157
+ user_token_out: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
158
+ min_amount_out: (0, binary_js_1.readU64LE)(data, 8) ?? 0n,
154
159
  pool,
155
160
  from: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
156
161
  start_bin_id: 0,
@@ -175,6 +180,11 @@ function parseMeteoraDlmmInstruction(instructionData, accounts, signature, slot,
175
180
  return {
176
181
  MeteoraDlmmSwap: {
177
182
  metadata,
183
+ token_x_mint: Z,
184
+ token_y_mint: Z,
185
+ user_token_in: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
186
+ user_token_out: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
187
+ min_amount_out: 0n,
178
188
  pool,
179
189
  from: (0, utils_js_1.getAccount)(accounts, 10) ?? Z,
180
190
  start_bin_id: 0,
@@ -39,6 +39,8 @@ function createNumericDefaults() {
39
39
  quote_vault: Z,
40
40
  quote_token_program: Z,
41
41
  virtual_quote_reserves: 0n,
42
+ creator_fee_bps: 0n,
43
+ is_holder_reward: false,
42
44
  ix_name: "",
43
45
  };
44
46
  }
@@ -89,6 +91,8 @@ function parsePumpfunTradeV2Instruction(ixName, data, accounts, metadata) {
89
91
  mayhem_mode: false,
90
92
  cashback_fee_basis_points: 0n,
91
93
  cashback: 0n,
94
+ holder_rewards_bps: 0n,
95
+ holder_rewards: 0n,
92
96
  is_cashback_coin: false,
93
97
  associated_bonding_curve: accounts[11] ?? Z,
94
98
  associated_user: accounts[14] ?? Z,
@@ -175,6 +179,8 @@ function parsePumpfunLegacyBuyInstruction(ixName, data, accounts, metadata) {
175
179
  mayhem_mode: false,
176
180
  cashback_fee_basis_points: 0n,
177
181
  cashback: 0n,
182
+ holder_rewards_bps: 0n,
183
+ holder_rewards: 0n,
178
184
  is_cashback_coin: false,
179
185
  quote_mint: exports.PUMPFUN_SOL_QUOTE_MINT,
180
186
  quote_token_program: Z,
@@ -269,6 +275,8 @@ function parsePumpfunLegacySellInstruction(data, accounts, metadata) {
269
275
  mayhem_mode: false,
270
276
  cashback_fee_basis_points: 0n,
271
277
  cashback: 0n,
278
+ holder_rewards_bps: 0n,
279
+ holder_rewards: 0n,
272
280
  is_cashback_coin: false,
273
281
  ...(legacyBuybackFeeRecipient !== Z ? { account: legacyBuybackFeeRecipient } : {}),
274
282
  };
@@ -307,6 +315,12 @@ function parsePumpfunInstruction(instructionData, accounts, signature, slot, txI
307
315
  return null;
308
316
  o += 1;
309
317
  const isCashbackEnabled = (0, utils_js_1.readBool)(data, o) ?? false;
318
+ if (o < data.length)
319
+ o += 1;
320
+ const creatorFeeBps = (0, utils_js_1.readU64LE)(data, o) ?? 0n;
321
+ if (o + 8 <= data.length)
322
+ o += 8;
323
+ const isHolderReward = (0, utils_js_1.readBool)(data, o) ?? false;
310
324
  const mint = accounts[0];
311
325
  const ev = {
312
326
  metadata: meta,
@@ -338,6 +352,8 @@ function parsePumpfunInstruction(instructionData, accounts, signature, slot, txI
338
352
  ix_name: "create_v2",
339
353
  is_mayhem_mode: isMayhemMode,
340
354
  is_cashback_enabled: isCashbackEnabled,
355
+ creator_fee_bps: creatorFeeBps,
356
+ is_holder_reward: isHolderReward,
341
357
  };
342
358
  return { PumpFunCreateV2: ev };
343
359
  }
@@ -99,6 +99,8 @@ function buyLike(data, accounts, meta, swapOrder) {
99
99
  virtual_quote_reserves: 0n,
100
100
  can_boost: false,
101
101
  base_supply: 0n,
102
+ holder_rewards_bps: 0n,
103
+ holder_rewards: 0n,
102
104
  is_pump_pool: false,
103
105
  base_mint: g(3),
104
106
  quote_mint: g(4),
@@ -167,6 +169,8 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
167
169
  virtual_quote_reserves: 0n,
168
170
  can_boost: false,
169
171
  base_supply: 0n,
172
+ holder_rewards_bps: 0n,
173
+ holder_rewards: 0n,
170
174
  is_pump_pool: false,
171
175
  base_mint: g(3),
172
176
  quote_mint: g(4),
@@ -187,15 +191,15 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
187
191
  const ev = {
188
192
  metadata: meta,
189
193
  timestamp: 0n,
190
- index: 0,
194
+ index: Number(data.length >= 2 ? data[0] | (data[1] << 8) : 0),
191
195
  pool: g(0),
192
196
  creator: g(2),
193
197
  base_mint: g(3),
194
198
  quote_mint: g(4),
195
199
  base_mint_decimals: 0,
196
200
  quote_mint_decimals: 0,
197
- base_amount_in: 0n,
198
- quote_amount_in: 0n,
201
+ base_amount_in: (0, utils_js_1.readU64LE)(data, 2) ?? 0n,
202
+ quote_amount_in: (0, utils_js_1.readU64LE)(data, 10) ?? 0n,
199
203
  pool_base_amount: 0n,
200
204
  pool_quote_amount: 0n,
201
205
  minimum_liquidity: 0n,
@@ -205,8 +209,12 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
205
209
  lp_mint: g(5),
206
210
  user_base_token_account: g(6),
207
211
  user_quote_token_account: g(7),
208
- coin_creator: g(1),
209
- is_mayhem_mode: false,
212
+ coin_creator: (0, utils_js_1.readPubkeyIx)(data, 18) ?? g(1),
213
+ is_mayhem_mode: data[50] === 1,
214
+ is_cashback_coin: data[51] === 1,
215
+ creator_fee_bps: (0, utils_js_1.readU64LE)(data, 52) ?? 0n,
216
+ can_edit_creator_fee: data[60] === 1,
217
+ is_holder_reward: data[61] === 1,
210
218
  };
211
219
  return { PumpSwapCreatePool: ev };
212
220
  }
@@ -1,4 +1,20 @@
1
+ import { type EventMetadata } from "../core/metadata.js";
1
2
  import type { DexEvent } from "../core/dex_event.js";
3
+ /**
4
+ * Mainnet upgrade that replaced `trading_fee/partner_fee` in `EvtSwap2` with
5
+ * `claiming_fee/compounding_fee` without changing discriminator or size.
6
+ */
7
+ export declare const COMPOUNDING_FEE_LAYOUT_ACTIVATION_SLOT = 406048752;
8
+ /** Aligns with Rust `parse_swap2_from_data` (full 180-byte EvtSwap2 layout). */
9
+ export declare function parseSwap2FromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
10
+ export declare function parseAddLiquidityFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
11
+ export declare function parseRemoveLiquidityFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
12
+ /** Parse current `EvtLiquidityChange`; `change_type` 0 = add, 1 = remove. */
13
+ export declare function parseLiquidityChangeFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
14
+ export declare function parseUpdateDelegatePermissionFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
15
+ export declare function parseWithdrawDeadLiquidityRewardFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
16
+ export declare function parseCreateConfigFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
17
+ export declare function parseCreateDynamicConfigFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
2
18
  /**
3
19
  * Meteora DAMM Program data 入口;与 Rust `logs/meteora_damm.rs` 一致。
4
20
  */