sol-parser-sdk 0.5.15 → 0.5.17

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 (96) hide show
  1. package/NATIVE_ALIGNMENT.md +312 -0
  2. package/NATIVE_DAMM_FACTORY_ALIGNMENT_20261004.md +16 -0
  3. package/NATIVE_DAMM_FACTORY_EVIDENCE_20261004.json +55 -0
  4. package/NATIVE_MIGRATION.md +38 -0
  5. package/NATIVE_PUMPFUN_NATIVE_DEBIT_ALIGNMENT_20261004.md +18 -0
  6. package/NATIVE_PUMPFUN_NATIVE_DEBIT_EVIDENCE_20261004.json +57 -0
  7. package/NATIVE_PUMPFUN_SETTLEMENT_ALIGNMENT_20261004.md +11 -0
  8. package/NATIVE_PUMPFUN_SETTLEMENT_EVIDENCE_20261004.json +70 -0
  9. package/README.md +24 -1
  10. package/README_CN.md +21 -1
  11. package/dist/accounts/mod.js +7 -0
  12. package/dist/core/account_dispatcher_rpc.js +50 -6
  13. package/dist/core/account_fill_pumpfun.js +7 -16
  14. package/dist/core/account_fill_raydium.js +12 -2
  15. package/dist/core/account_fill_raydium_launchlab.js +6 -0
  16. package/dist/core/clock.js +1 -1
  17. package/dist/core/dex_event.d.ts +30 -0
  18. package/dist/core/metadata.d.ts +9 -5
  19. package/dist/core/metadata.js +28 -4
  20. package/dist/core/unified_parser.d.ts +7 -7
  21. package/dist/grpc/block_meta.d.ts +9 -0
  22. package/dist/grpc/block_meta.js +26 -0
  23. package/dist/grpc/client.d.ts +24 -9
  24. package/dist/grpc/client.js +129 -67
  25. package/dist/grpc/geyser_connect.d.ts +3 -3
  26. package/dist/grpc/geyser_connect.js +13 -15
  27. package/dist/grpc/native_client.d.ts +26 -0
  28. package/dist/grpc/native_client.js +101 -0
  29. package/dist/grpc/order_buffer.d.ts +1 -1
  30. package/dist/grpc/order_buffer.js +10 -9
  31. package/dist/grpc/program_ids.js +2 -0
  32. package/dist/grpc/protocol/LICENSE +202 -0
  33. package/dist/grpc/protocol/NOTICE +4 -0
  34. package/dist/grpc/protocol/geyser.d.ts +342 -0
  35. package/dist/grpc/protocol/geyser.js +37 -0
  36. package/dist/grpc/protocol/geyser.proto +326 -0
  37. package/dist/grpc/protocol/solana-storage.d.ts +139 -0
  38. package/dist/grpc/protocol/solana-storage.js +14 -0
  39. package/dist/grpc/protocol/solana-storage.proto +151 -0
  40. package/dist/grpc/rpc_to_grpc.d.ts +1 -1
  41. package/dist/grpc/rpc_to_grpc.js +3 -2
  42. package/dist/grpc/subscribe_builder.d.ts +5 -3
  43. package/dist/grpc/subscribe_builder.js +11 -3
  44. package/dist/grpc/transaction_meta.d.ts +1 -1
  45. package/dist/grpc/types.d.ts +8 -8
  46. package/dist/grpc/types.js +7 -2
  47. package/dist/grpc/yellowstone_parse.d.ts +3 -3
  48. package/dist/grpc/yellowstone_parse.js +6 -8
  49. package/dist/grpc/yellowstone_transaction_adapter.d.ts +1 -1
  50. package/dist/grpc/yellowstone_transaction_adapter.js +1 -1
  51. package/dist/index.d.ts +11 -1
  52. package/dist/index.js +23 -5
  53. package/dist/instr/inner.d.ts +2 -2
  54. package/dist/instr/inner.js +1 -1
  55. package/dist/instr/meteora_damm_ix.d.ts +1 -1
  56. package/dist/instr/meteora_dlmm_ix.d.ts +1 -1
  57. package/dist/instr/meteora_pools_ix.d.ts +1 -1
  58. package/dist/instr/mod.d.ts +1 -1
  59. package/dist/instr/orca_whirlpool_ix.d.ts +1 -1
  60. package/dist/instr/pump_fees_ix.d.ts +1 -1
  61. package/dist/instr/pumpfun_ix.d.ts +1 -1
  62. package/dist/instr/pumpfun_ix.js +3 -3
  63. package/dist/instr/pumpswap_ix.d.ts +1 -1
  64. package/dist/instr/raydium_amm_v4_ix.d.ts +1 -1
  65. package/dist/instr/raydium_amm_v4_ix.js +9 -5
  66. package/dist/instr/raydium_clmm_ix.d.ts +1 -1
  67. package/dist/instr/raydium_cpmm_ix.d.ts +1 -1
  68. package/dist/instr/raydium_launchlab_ix.d.ts +1 -1
  69. package/dist/instr/raydium_launchlab_ix.js +62 -2
  70. package/dist/instr/utils.d.ts +2 -2
  71. package/dist/instr/utils.js +2 -7
  72. package/dist/liquidity_snapshot.d.ts +54 -0
  73. package/dist/liquidity_snapshot.js +85 -0
  74. package/dist/logs/meteora_damm.d.ts +1 -1
  75. package/dist/logs/meteora_damm.js +4 -2
  76. package/dist/logs/meteora_dlmm.d.ts +1 -1
  77. package/dist/logs/optimized_matcher.d.ts +3 -3
  78. package/dist/logs/pump.js +11 -0
  79. package/dist/logs/raydium_launchlab.js +19 -1
  80. package/dist/rpc_transaction.d.ts +4 -3
  81. package/dist/rpc_transaction.js +6 -2
  82. package/dist/shredstream/client.js +3 -7
  83. package/dist/shredstream/entries_decode.js +9 -85
  84. package/dist/shredstream/instruction_parse.d.ts +3 -3
  85. package/dist/shredstream/proto_types.d.ts +1 -1
  86. package/dist/shredstream/wire_to_shred_tx.d.ts +1 -1
  87. package/dist/shredstream/wire_to_shred_tx.js +9 -44
  88. package/dist/simulation_route.d.ts +6 -0
  89. package/dist/simulation_route.js +242 -0
  90. package/dist/stonkfun_registry.d.ts +30 -0
  91. package/dist/stonkfun_registry.js +137 -0
  92. package/dist/transaction_route.d.ts +84 -0
  93. package/dist/transaction_route.js +477 -0
  94. package/dist/wire_transaction.d.ts +35 -0
  95. package/dist/wire_transaction.js +191 -0
  96. package/package.json +7 -4
@@ -0,0 +1,35 @@
1
+ export interface WireInstruction {
2
+ programIdIndex: number;
3
+ accounts: number[];
4
+ data: string;
5
+ }
6
+ export interface WireMessage {
7
+ header: {
8
+ numRequiredSignatures: number;
9
+ numReadonlySignedAccounts: number;
10
+ numReadonlyUnsignedAccounts: number;
11
+ };
12
+ accountKeys: string[];
13
+ recentBlockhash: string;
14
+ instructions: WireInstruction[];
15
+ addressTableLookups: {
16
+ accountKey: string;
17
+ writableIndexes: number[];
18
+ readonlyIndexes: number[];
19
+ }[];
20
+ config?: {
21
+ priorityFee?: bigint;
22
+ computeUnitLimit?: number;
23
+ loadedAccountsDataSizeLimit?: number;
24
+ heapSize?: number;
25
+ };
26
+ }
27
+ export interface DecodedWireTransaction {
28
+ signatures: string[];
29
+ message: WireMessage;
30
+ version: "legacy" | 0 | 1;
31
+ }
32
+ export declare function decodeWireTransaction(data: Uint8Array, offset?: number, requireComplete?: boolean): {
33
+ transaction: DecodedWireTransaction;
34
+ length: number;
35
+ };
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.decodeWireTransaction = decodeWireTransaction;
7
+ /** Native canonical Solana Legacy, V0 and V1 decoder; no Rust runtime. */
8
+ const bs58_1 = __importDefault(require("bs58"));
9
+ class Reader {
10
+ data;
11
+ pos;
12
+ constructor(data, offset) {
13
+ this.data = data;
14
+ this.pos = offset;
15
+ }
16
+ take(n) {
17
+ if (!Number.isSafeInteger(n) || n < 0 || this.pos + n > this.data.length)
18
+ throw new Error("Truncated transaction");
19
+ const value = this.data.slice(this.pos, this.pos + n);
20
+ this.pos += n;
21
+ return value;
22
+ }
23
+ uint(n = 1) {
24
+ const bytes = this.take(n);
25
+ let value = 0;
26
+ for (let i = n - 1; i >= 0; i--)
27
+ value = value * 256 + bytes[i];
28
+ return value;
29
+ }
30
+ u64() {
31
+ const b = this.take(8);
32
+ let value = 0n;
33
+ for (let i = 7; i >= 0; i--)
34
+ value = value * 256n + BigInt(b[i]);
35
+ return value;
36
+ }
37
+ short() {
38
+ let value = 0;
39
+ for (let i = 0; i < 3; i++) {
40
+ const b = this.uint();
41
+ if (i === 2 && b > 3)
42
+ throw new Error("Invalid short-u16");
43
+ value |= (b & 127) << (7 * i);
44
+ if (!(b & 128)) {
45
+ if (i && b === 0)
46
+ throw new Error("Noncanonical short-u16");
47
+ return value;
48
+ }
49
+ }
50
+ throw new Error("Invalid short-u16");
51
+ }
52
+ }
53
+ function decodeWireTransaction(data, offset = 0, requireComplete = true) {
54
+ if (!Number.isInteger(offset) || offset < 0 || offset >= data.length)
55
+ throw new Error("Invalid wire offset");
56
+ const r = new Reader(data, offset);
57
+ let version = "legacy";
58
+ let signatures = [];
59
+ let header;
60
+ let keys;
61
+ let hash;
62
+ let instructions = [];
63
+ const lookups = [];
64
+ let config;
65
+ if (data[offset] === 129) {
66
+ r.take(1);
67
+ version = 1;
68
+ header = r.take(3);
69
+ const mask = r.uint(4);
70
+ hash = r.take(32);
71
+ if (mask & ~31 || ((mask & 3) !== 0 && (mask & 3) !== 3))
72
+ throw new Error("Invalid V1 config mask");
73
+ const count = r.uint(), keyCount = r.uint();
74
+ if (count > 64 || keyCount > 64 || header[0] > 12)
75
+ throw new Error("V1 transaction limit exceeded");
76
+ keys = Array.from({ length: keyCount }, () => r.take(32));
77
+ config = {};
78
+ if (mask & 3)
79
+ config.priorityFee = r.u64();
80
+ if (mask & 4)
81
+ config.computeUnitLimit = r.uint(4);
82
+ if (mask & 8)
83
+ config.loadedAccountsDataSizeLimit = r.uint(4);
84
+ if (mask & 16)
85
+ config.heapSize = r.uint(4);
86
+ if (config.heapSize !== undefined &&
87
+ (config.heapSize < 32768 ||
88
+ config.heapSize > 262144 ||
89
+ config.heapSize % 1024))
90
+ throw new Error("Invalid heap size");
91
+ const headers = Array.from({ length: count }, () => [r.uint(), r.uint(), r.uint(2)]);
92
+ instructions = headers.map(([programIdIndex, n, length]) => ({
93
+ programIdIndex,
94
+ accounts: Array.from(r.take(n)),
95
+ data: bs58_1.default.encode(r.take(length)),
96
+ }));
97
+ signatures = Array.from({ length: header[0] }, () => r.take(64));
98
+ if (r.pos - offset > 4096)
99
+ throw new Error("V1 transaction exceeds 4096 bytes");
100
+ }
101
+ else {
102
+ const sigCount = r.short();
103
+ if (sigCount > 127)
104
+ throw new Error("Too many signatures");
105
+ signatures = Array.from({ length: sigCount }, () => r.take(64));
106
+ const first = r.uint();
107
+ if (first & 128) {
108
+ if (first !== 128)
109
+ throw new Error("Unknown transaction version");
110
+ version = 0;
111
+ header = r.take(3);
112
+ }
113
+ else
114
+ header = Uint8Array.from([first, ...r.take(2)]);
115
+ const keyCount = r.short();
116
+ if (keyCount > 256)
117
+ throw new Error("Too many account keys");
118
+ keys = Array.from({ length: keyCount }, () => r.take(32));
119
+ hash = r.take(32);
120
+ const count = r.short();
121
+ for (let i = 0; i < count; i++) {
122
+ const programIdIndex = r.uint();
123
+ const accounts = Array.from(r.take(r.short()));
124
+ const payload = r.take(r.short());
125
+ instructions.push({
126
+ programIdIndex,
127
+ accounts,
128
+ data: bs58_1.default.encode(payload),
129
+ });
130
+ }
131
+ if (version === 0) {
132
+ const count = r.short();
133
+ for (let i = 0; i < count; i++) {
134
+ const key = r.take(32);
135
+ const writableIndexes = Array.from(r.take(r.short()));
136
+ const readonlyIndexes = Array.from(r.take(r.short()));
137
+ lookups.push({
138
+ accountKey: bs58_1.default.encode(key),
139
+ writableIndexes,
140
+ readonlyIndexes,
141
+ });
142
+ }
143
+ }
144
+ if (signatures.length !== header[0])
145
+ throw new Error("Signature count does not match header");
146
+ }
147
+ if (header[0] > keys.length ||
148
+ header[1] > header[0] ||
149
+ header[2] > keys.length - header[0])
150
+ throw new Error("Invalid message header");
151
+ if (version === 1) {
152
+ if (header[1] >= header[0])
153
+ throw new Error("V1 requires a writable fee payer");
154
+ if (new Set(keys.map((k) => bs58_1.default.encode(k))).size !== keys.length)
155
+ throw new Error("Duplicate V1 accounts");
156
+ for (const ix of instructions)
157
+ if (ix.programIdIndex === 0 ||
158
+ ix.programIdIndex >= keys.length ||
159
+ ix.accounts.some((i) => i >= keys.length))
160
+ throw new Error("Invalid V1 instruction index");
161
+ }
162
+ const accountCount = keys.length + lookups.reduce((n, l) => n + l.writableIndexes.length + l.readonlyIndexes.length, 0);
163
+ if (accountCount > 256)
164
+ throw new Error("Too many resolved account keys");
165
+ for (const ix of instructions)
166
+ if (ix.programIdIndex >= keys.length || ix.accounts.some(i => i >= accountCount))
167
+ throw new Error("Invalid instruction index");
168
+ if (requireComplete && r.pos !== data.length)
169
+ throw new Error("Trailing transaction bytes");
170
+ const message = {
171
+ header: {
172
+ numRequiredSignatures: header[0],
173
+ numReadonlySignedAccounts: header[1],
174
+ numReadonlyUnsignedAccounts: header[2],
175
+ },
176
+ accountKeys: keys.map((k) => bs58_1.default.encode(k)),
177
+ recentBlockhash: bs58_1.default.encode(hash),
178
+ instructions,
179
+ addressTableLookups: lookups,
180
+ };
181
+ if (config)
182
+ message.config = config;
183
+ return {
184
+ transaction: {
185
+ signatures: signatures.map((s) => bs58_1.default.encode(s)),
186
+ message,
187
+ version,
188
+ },
189
+ length: r.pos - offset,
190
+ };
191
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sol-parser-sdk",
3
- "version": "0.5.15",
3
+ "version": "0.5.17",
4
4
  "description": "High-performance Solana DEX event parser for Node.js/TypeScript (Yellowstone gRPC, log parsing)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,11 @@
9
9
  "README.md",
10
10
  "README_CN.md",
11
11
  "LICENSE",
12
- ".env.example"
12
+ ".env.example",
13
+ "NATIVE_ALIGNMENT.md",
14
+ "NATIVE_MIGRATION.md",
15
+ "NATIVE_*_ALIGNMENT_*.md",
16
+ "NATIVE_*_EVIDENCE_*.json"
13
17
  ],
14
18
  "repository": {
15
19
  "type": "git",
@@ -23,7 +27,7 @@
23
27
  "node": ">=20.18.0"
24
28
  },
25
29
  "scripts": {
26
- "build": "tsc && mkdir -p dist/shredstream && cp src/shredstream/shredstream.proto dist/shredstream/",
30
+ "build": "tsc && mkdir -p dist/shredstream && cp src/shredstream/shredstream.proto dist/shredstream/ && mkdir -p dist/grpc/protocol && cp src/grpc/protocol/*.proto src/grpc/protocol/NOTICE src/grpc/protocol/LICENSE dist/grpc/protocol/",
27
31
  "prepublishOnly": "npm run build",
28
32
  "check:dex-events": "tsx scripts/check-dex-event-parity.ts",
29
33
  "verify:discriminators": "tsx scripts/verify-program-log-discriminators.ts",
@@ -58,7 +62,6 @@
58
62
  "@grpc/grpc-js": "^1.12.4",
59
63
  "@grpc/proto-loader": "^0.7.13",
60
64
  "@solana/web3.js": "^1.95.4",
61
- "@triton-one/yellowstone-grpc": "7.0.0",
62
65
  "bs58": "^6.0.0"
63
66
  }
64
67
  }