sol-parser-sdk 0.5.9
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/LICENSE +21 -0
- package/README.md +236 -0
- package/README_CN.md +236 -0
- package/dist/accounts/mod.d.ts +15 -0
- package/dist/accounts/mod.js +173 -0
- package/dist/accounts/nonce.d.ts +5 -0
- package/dist/accounts/nonce.js +32 -0
- package/dist/accounts/pumpfun.d.ts +16 -0
- package/dist/accounts/pumpfun.js +538 -0
- package/dist/accounts/pumpswap.d.ts +8 -0
- package/dist/accounts/pumpswap.js +192 -0
- package/dist/accounts/raydium_orca.d.ts +26 -0
- package/dist/accounts/raydium_orca.js +453 -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/token.d.ts +5 -0
- package/dist/accounts/token.js +98 -0
- package/dist/accounts/types.d.ts +9 -0
- package/dist/accounts/types.js +2 -0
- package/dist/accounts/utils.d.ts +1 -0
- package/dist/accounts/utils.js +12 -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.d.ts +11 -0
- package/dist/core/account_dispatcher_rpc.js +155 -0
- package/dist/core/account_fill_bonk.d.ts +4 -0
- package/dist/core/account_fill_bonk.js +20 -0
- package/dist/core/account_fill_meteora.d.ts +15 -0
- package/dist/core/account_fill_meteora.js +27 -0
- package/dist/core/account_fill_orca.d.ts +5 -0
- package/dist/core/account_fill_orca.js +18 -0
- package/dist/core/account_fill_pumpfun.d.ts +7 -0
- package/dist/core/account_fill_pumpfun.js +167 -0
- package/dist/core/account_fill_pumpswap.d.ts +10 -0
- package/dist/core/account_fill_pumpswap.js +128 -0
- package/dist/core/account_fill_raydium.d.ts +20 -0
- package/dist/core/account_fill_raydium.js +104 -0
- package/dist/core/account_fill_raydium_launchlab.d.ts +4 -0
- package/dist/core/account_fill_raydium_launchlab.js +20 -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 +8 -0
- package/dist/core/clock.js +20 -0
- package/dist/core/common_filler_rpc.d.ts +6 -0
- package/dist/core/common_filler_rpc.js +21 -0
- package/dist/core/dex_event.d.ts +1704 -0
- package/dist/core/dex_event.js +14 -0
- package/dist/core/error.d.ts +43 -0
- package/dist/core/error.js +16 -0
- package/dist/core/json_utils.d.ts +8 -0
- package/dist/core/json_utils.js +18 -0
- package/dist/core/metadata.d.ts +11 -0
- package/dist/core/metadata.js +13 -0
- package/dist/core/pumpfun_fee_enrich.d.ts +6 -0
- package/dist/core/pumpfun_fee_enrich.js +159 -0
- package/dist/core/rpc_invoke_map.d.ts +23 -0
- package/dist/core/rpc_invoke_map.js +157 -0
- package/dist/core/unified_parser.d.ts +19 -0
- package/dist/core/unified_parser.js +50 -0
- package/dist/grpc/client.d.ts +83 -0
- package/dist/grpc/client.js +645 -0
- package/dist/grpc/client_stub.d.ts +5 -0
- package/dist/grpc/client_stub.js +5 -0
- 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 +402 -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 +27 -0
- package/dist/grpc/program_ids.js +61 -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 +195 -0
- package/dist/grpc/types.js +551 -0
- package/dist/grpc/yellowstone_parse.d.ts +16 -0
- package/dist/grpc/yellowstone_parse.js +62 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +298 -0
- package/dist/instr/bonk_ix.d.ts +8 -0
- package/dist/instr/bonk_ix.js +131 -0
- package/dist/instr/inner.d.ts +4 -0
- package/dist/instr/inner.js +453 -0
- package/dist/instr/meteora_damm_ix.d.ts +8 -0
- package/dist/instr/meteora_damm_ix.js +601 -0
- package/dist/instr/meteora_dlmm_ix.d.ts +2 -0
- package/dist/instr/meteora_dlmm_ix.js +134 -0
- package/dist/instr/meteora_pools_ix.d.ts +2 -0
- package/dist/instr/meteora_pools_ix.js +78 -0
- package/dist/instr/mod.d.ts +18 -0
- package/dist/instr/mod.js +129 -0
- package/dist/instr/orca_whirlpool_ix.d.ts +8 -0
- package/dist/instr/orca_whirlpool_ix.js +119 -0
- package/dist/instr/program_ids.d.ts +4 -0
- package/dist/instr/program_ids.js +20 -0
- package/dist/instr/pump_fees_ix.d.ts +2 -0
- package/dist/instr/pump_fees_ix.js +168 -0
- package/dist/instr/pumpfun_ix.d.ts +6 -0
- package/dist/instr/pumpfun_ix.js +448 -0
- package/dist/instr/pumpswap_ix.d.ts +5 -0
- package/dist/instr/pumpswap_ix.js +270 -0
- package/dist/instr/raydium_amm_v4_ix.d.ts +6 -0
- package/dist/instr/raydium_amm_v4_ix.js +112 -0
- package/dist/instr/raydium_clmm_ix.d.ts +5 -0
- package/dist/instr/raydium_clmm_ix.js +184 -0
- package/dist/instr/raydium_cpmm_ix.d.ts +5 -0
- package/dist/instr/raydium_cpmm_ix.js +109 -0
- package/dist/instr/raydium_launchlab_ix.d.ts +8 -0
- package/dist/instr/raydium_launchlab_ix.js +125 -0
- package/dist/instr/rust_aliases.d.ts +10 -0
- package/dist/instr/rust_aliases.js +20 -0
- package/dist/instr/utils.d.ts +10 -0
- package/dist/instr/utils.js +35 -0
- package/dist/logs/discriminator_lut.d.ts +19 -0
- package/dist/logs/discriminator_lut.js +62 -0
- package/dist/logs/meteora_amm.d.ts +8 -0
- package/dist/logs/meteora_amm.js +113 -0
- package/dist/logs/meteora_damm.d.ts +5 -0
- package/dist/logs/meteora_damm.js +367 -0
- package/dist/logs/meteora_dbc.d.ts +11 -0
- package/dist/logs/meteora_dbc.js +142 -0
- package/dist/logs/meteora_dlmm.d.ts +6 -0
- package/dist/logs/meteora_dlmm.js +201 -0
- package/dist/logs/optimized_matcher.d.ts +11 -0
- package/dist/logs/optimized_matcher.js +941 -0
- package/dist/logs/orca.d.ts +6 -0
- package/dist/logs/orca.js +148 -0
- package/dist/logs/program_data.d.ts +2 -0
- package/dist/logs/program_data.js +20 -0
- package/dist/logs/program_log_discriminators.d.ts +80 -0
- package/dist/logs/program_log_discriminators.js +88 -0
- package/dist/logs/pump.d.ts +14 -0
- package/dist/logs/pump.js +378 -0
- package/dist/logs/pump_amm.d.ts +9 -0
- package/dist/logs/pump_amm.js +418 -0
- package/dist/logs/pump_fees.d.ts +23 -0
- package/dist/logs/pump_fees.js +364 -0
- package/dist/logs/raydium_amm.d.ts +9 -0
- package/dist/logs/raydium_amm.js +224 -0
- package/dist/logs/raydium_clmm.d.ts +17 -0
- package/dist/logs/raydium_clmm.js +624 -0
- package/dist/logs/raydium_cpmm.d.ts +7 -0
- package/dist/logs/raydium_cpmm.js +121 -0
- package/dist/logs/raydium_launchlab.d.ts +10 -0
- package/dist/logs/raydium_launchlab.js +84 -0
- package/dist/logs/raydium_launchpad.d.ts +12 -0
- package/dist/logs/raydium_launchpad.js +92 -0
- package/dist/logs/rust_aliases.d.ts +7 -0
- package/dist/logs/rust_aliases.js +16 -0
- package/dist/parser_alias.d.ts +3 -0
- package/dist/parser_alias.js +2 -0
- package/dist/rpc_parser.d.ts +17 -0
- package/dist/rpc_parser.js +39 -0
- package/dist/rpc_transaction.d.ts +27 -0
- package/dist/rpc_transaction.js +416 -0
- package/dist/shredstream/alt_lookup.d.ts +9 -0
- package/dist/shredstream/alt_lookup.js +70 -0
- package/dist/shredstream/client.d.ts +65 -0
- package/dist/shredstream/client.js +403 -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 +79 -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/dist/util/binary.d.ts +14 -0
- package/dist/util/binary.js +82 -0
- package/dist/util/market.d.ts +18 -0
- package/dist/util/market.js +54 -0
- package/dist/warmup.d.ts +3 -0
- package/dist/warmup.js +23 -0
- package/package.json +61 -0
|
@@ -0,0 +1,270 @@
|
|
|
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 fillBuyUpgradeAccounts(ev, accounts) {
|
|
9
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? ZP;
|
|
10
|
+
if (accounts.length >= 27) {
|
|
11
|
+
ev.pool_v2 = g(24);
|
|
12
|
+
ev.fee_recipient = g(25);
|
|
13
|
+
ev.fee_recipient_quote_token_account = g(26);
|
|
14
|
+
}
|
|
15
|
+
else if (accounts.length >= 26) {
|
|
16
|
+
ev.pool_v2 = g(23);
|
|
17
|
+
ev.fee_recipient = g(24);
|
|
18
|
+
ev.fee_recipient_quote_token_account = g(25);
|
|
19
|
+
}
|
|
20
|
+
else if (accounts.length >= 24) {
|
|
21
|
+
ev.pool_v2 = g(23);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function fillSellUpgradeAccounts(ev, accounts) {
|
|
25
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? ZP;
|
|
26
|
+
if (accounts.length >= 26) {
|
|
27
|
+
ev.pool_v2 = g(23);
|
|
28
|
+
ev.fee_recipient = g(24);
|
|
29
|
+
ev.fee_recipient_quote_token_account = g(25);
|
|
30
|
+
}
|
|
31
|
+
else if (accounts.length >= 24) {
|
|
32
|
+
ev.pool_v2 = g(21);
|
|
33
|
+
ev.fee_recipient = g(22);
|
|
34
|
+
ev.fee_recipient_quote_token_account = g(23);
|
|
35
|
+
}
|
|
36
|
+
else if (accounts.length >= 22) {
|
|
37
|
+
ev.pool_v2 = g(21);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function disc8(a) {
|
|
41
|
+
return Uint8Array.from(a);
|
|
42
|
+
}
|
|
43
|
+
const PS = {
|
|
44
|
+
BUY: disc8([102, 6, 61, 18, 1, 218, 235, 234]),
|
|
45
|
+
SELL: disc8([51, 230, 133, 164, 1, 127, 131, 173]),
|
|
46
|
+
CREATE_POOL: disc8([233, 146, 209, 142, 207, 104, 64, 188]),
|
|
47
|
+
BUY_EXACT_QUOTE_IN: disc8([198, 46, 21, 82, 180, 217, 232, 112]),
|
|
48
|
+
DEPOSIT: disc8([242, 35, 198, 137, 82, 225, 242, 182]),
|
|
49
|
+
WITHDRAW: disc8([183, 18, 70, 156, 148, 109, 161, 34]),
|
|
50
|
+
};
|
|
51
|
+
function discEq(h, d) {
|
|
52
|
+
for (let i = 0; i < 8; i++)
|
|
53
|
+
if (h[i] !== d[i])
|
|
54
|
+
return false;
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
function buyLike(data, accounts, meta, swapOrder) {
|
|
58
|
+
const [a0, a1] = data.length >= 16
|
|
59
|
+
? [(0, utils_js_1.readU64LE)(data, 0) ?? 0n, (0, utils_js_1.readU64LE)(data, 8) ?? 0n]
|
|
60
|
+
: [0n, 0n];
|
|
61
|
+
const [base_amount_out, max_quote_amount_in] = swapOrder === "buy" ? [a0, a1] : [a1, a0];
|
|
62
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? ZP;
|
|
63
|
+
const ev = {
|
|
64
|
+
metadata: meta,
|
|
65
|
+
timestamp: 0n,
|
|
66
|
+
base_amount_out,
|
|
67
|
+
max_quote_amount_in,
|
|
68
|
+
user_base_token_reserves: 0n,
|
|
69
|
+
user_quote_token_reserves: 0n,
|
|
70
|
+
pool_base_token_reserves: 0n,
|
|
71
|
+
pool_quote_token_reserves: 0n,
|
|
72
|
+
quote_amount_in: 0n,
|
|
73
|
+
lp_fee_basis_points: 0n,
|
|
74
|
+
lp_fee: 0n,
|
|
75
|
+
protocol_fee_basis_points: 0n,
|
|
76
|
+
protocol_fee: 0n,
|
|
77
|
+
quote_amount_in_with_lp_fee: 0n,
|
|
78
|
+
user_quote_amount_in: 0n,
|
|
79
|
+
pool: g(0),
|
|
80
|
+
user: g(1),
|
|
81
|
+
user_base_token_account: g(5),
|
|
82
|
+
user_quote_token_account: g(6),
|
|
83
|
+
protocol_fee_recipient: g(9),
|
|
84
|
+
protocol_fee_recipient_token_account: g(10),
|
|
85
|
+
coin_creator: Z,
|
|
86
|
+
coin_creator_fee_basis_points: 0n,
|
|
87
|
+
coin_creator_fee: 0n,
|
|
88
|
+
track_volume: false,
|
|
89
|
+
total_unclaimed_tokens: 0n,
|
|
90
|
+
total_claimed_tokens: 0n,
|
|
91
|
+
current_sol_volume: 0n,
|
|
92
|
+
last_update_timestamp: 0n,
|
|
93
|
+
min_base_amount_out: 0n,
|
|
94
|
+
ix_name: "",
|
|
95
|
+
cashback_fee_basis_points: 0n,
|
|
96
|
+
cashback: 0n,
|
|
97
|
+
is_pump_pool: false,
|
|
98
|
+
base_mint: g(3),
|
|
99
|
+
quote_mint: g(4),
|
|
100
|
+
pool_base_token_account: g(7),
|
|
101
|
+
pool_quote_token_account: g(8),
|
|
102
|
+
coin_creator_vault_ata: accounts.length > 17 ? g(17) : ZP,
|
|
103
|
+
coin_creator_vault_authority: accounts.length > 18 ? g(18) : ZP,
|
|
104
|
+
base_token_program: g(11),
|
|
105
|
+
quote_token_program: g(12),
|
|
106
|
+
};
|
|
107
|
+
fillBuyUpgradeAccounts(ev, accounts);
|
|
108
|
+
return ev;
|
|
109
|
+
}
|
|
110
|
+
function parsePumpswapInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs = 0) {
|
|
111
|
+
if (instructionData.length < 8)
|
|
112
|
+
return null;
|
|
113
|
+
const head = instructionData.subarray(0, 8);
|
|
114
|
+
const data = instructionData.subarray(8);
|
|
115
|
+
const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
116
|
+
if (discEq(head, PS.BUY)) {
|
|
117
|
+
if (accounts.length < 13)
|
|
118
|
+
return null;
|
|
119
|
+
return { PumpSwapBuy: buyLike(data, accounts, meta, "buy") };
|
|
120
|
+
}
|
|
121
|
+
if (discEq(head, PS.BUY_EXACT_QUOTE_IN)) {
|
|
122
|
+
if (accounts.length < 13)
|
|
123
|
+
return null;
|
|
124
|
+
return { PumpSwapBuy: buyLike(data, accounts, meta, "buy_exact") };
|
|
125
|
+
}
|
|
126
|
+
if (discEq(head, PS.SELL)) {
|
|
127
|
+
if (accounts.length < 13)
|
|
128
|
+
return null;
|
|
129
|
+
const [base_amount_in, min_quote_amount_out] = data.length >= 16
|
|
130
|
+
? [(0, utils_js_1.readU64LE)(data, 0) ?? 0n, (0, utils_js_1.readU64LE)(data, 8) ?? 0n]
|
|
131
|
+
: [0n, 0n];
|
|
132
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? ZP;
|
|
133
|
+
const ev = {
|
|
134
|
+
metadata: meta,
|
|
135
|
+
timestamp: 0n,
|
|
136
|
+
base_amount_in,
|
|
137
|
+
min_quote_amount_out,
|
|
138
|
+
user_base_token_reserves: 0n,
|
|
139
|
+
user_quote_token_reserves: 0n,
|
|
140
|
+
pool_base_token_reserves: 0n,
|
|
141
|
+
pool_quote_token_reserves: 0n,
|
|
142
|
+
quote_amount_out: 0n,
|
|
143
|
+
lp_fee_basis_points: 0n,
|
|
144
|
+
lp_fee: 0n,
|
|
145
|
+
protocol_fee_basis_points: 0n,
|
|
146
|
+
protocol_fee: 0n,
|
|
147
|
+
quote_amount_out_without_lp_fee: 0n,
|
|
148
|
+
user_quote_amount_out: 0n,
|
|
149
|
+
pool: g(0),
|
|
150
|
+
user: g(1),
|
|
151
|
+
user_base_token_account: g(5),
|
|
152
|
+
user_quote_token_account: g(6),
|
|
153
|
+
protocol_fee_recipient: g(9),
|
|
154
|
+
protocol_fee_recipient_token_account: g(10),
|
|
155
|
+
coin_creator: Z,
|
|
156
|
+
coin_creator_fee_basis_points: 0n,
|
|
157
|
+
coin_creator_fee: 0n,
|
|
158
|
+
cashback_fee_basis_points: 0n,
|
|
159
|
+
cashback: 0n,
|
|
160
|
+
is_pump_pool: false,
|
|
161
|
+
base_mint: g(3),
|
|
162
|
+
quote_mint: g(4),
|
|
163
|
+
pool_base_token_account: g(7),
|
|
164
|
+
pool_quote_token_account: g(8),
|
|
165
|
+
coin_creator_vault_ata: accounts.length > 17 ? g(17) : ZP,
|
|
166
|
+
coin_creator_vault_authority: accounts.length > 18 ? g(18) : ZP,
|
|
167
|
+
base_token_program: g(11),
|
|
168
|
+
quote_token_program: g(12),
|
|
169
|
+
};
|
|
170
|
+
fillSellUpgradeAccounts(ev, accounts);
|
|
171
|
+
return { PumpSwapSell: ev };
|
|
172
|
+
}
|
|
173
|
+
if (discEq(head, PS.CREATE_POOL)) {
|
|
174
|
+
if (accounts.length < 8)
|
|
175
|
+
return null;
|
|
176
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
177
|
+
const ev = {
|
|
178
|
+
metadata: meta,
|
|
179
|
+
timestamp: 0n,
|
|
180
|
+
index: 0,
|
|
181
|
+
pool: g(0),
|
|
182
|
+
creator: g(2),
|
|
183
|
+
base_mint: g(3),
|
|
184
|
+
quote_mint: g(4),
|
|
185
|
+
base_mint_decimals: 0,
|
|
186
|
+
quote_mint_decimals: 0,
|
|
187
|
+
base_amount_in: 0n,
|
|
188
|
+
quote_amount_in: 0n,
|
|
189
|
+
pool_base_amount: 0n,
|
|
190
|
+
pool_quote_amount: 0n,
|
|
191
|
+
minimum_liquidity: 0n,
|
|
192
|
+
initial_liquidity: 0n,
|
|
193
|
+
lp_token_amount_out: 0n,
|
|
194
|
+
pool_bump: 0,
|
|
195
|
+
lp_mint: g(5),
|
|
196
|
+
user_base_token_account: g(6),
|
|
197
|
+
user_quote_token_account: g(7),
|
|
198
|
+
coin_creator: g(1),
|
|
199
|
+
is_mayhem_mode: false,
|
|
200
|
+
};
|
|
201
|
+
return { PumpSwapCreatePool: ev };
|
|
202
|
+
}
|
|
203
|
+
if (discEq(head, PS.DEPOSIT)) {
|
|
204
|
+
if (accounts.length < 8)
|
|
205
|
+
return null;
|
|
206
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
207
|
+
let lp_out = 0n;
|
|
208
|
+
let max_base = 0n;
|
|
209
|
+
let max_quote = 0n;
|
|
210
|
+
if (data.length >= 24) {
|
|
211
|
+
lp_out = (0, utils_js_1.readU64LE)(data, 0) ?? 0n;
|
|
212
|
+
max_base = (0, utils_js_1.readU64LE)(data, 8) ?? 0n;
|
|
213
|
+
max_quote = (0, utils_js_1.readU64LE)(data, 16) ?? 0n;
|
|
214
|
+
}
|
|
215
|
+
const ev = {
|
|
216
|
+
metadata: meta,
|
|
217
|
+
timestamp: 0n,
|
|
218
|
+
lp_token_amount_out: lp_out,
|
|
219
|
+
max_base_amount_in: max_base,
|
|
220
|
+
max_quote_amount_in: max_quote,
|
|
221
|
+
user_base_token_reserves: 0n,
|
|
222
|
+
user_quote_token_reserves: 0n,
|
|
223
|
+
pool_base_token_reserves: 0n,
|
|
224
|
+
pool_quote_token_reserves: 0n,
|
|
225
|
+
base_amount_in: 0n,
|
|
226
|
+
quote_amount_in: 0n,
|
|
227
|
+
lp_mint_supply: 0n,
|
|
228
|
+
pool: g(0),
|
|
229
|
+
user: g(1),
|
|
230
|
+
user_base_token_account: g(4),
|
|
231
|
+
user_quote_token_account: g(5),
|
|
232
|
+
user_pool_token_account: g(6),
|
|
233
|
+
};
|
|
234
|
+
return { PumpSwapLiquidityAdded: ev };
|
|
235
|
+
}
|
|
236
|
+
if (discEq(head, PS.WITHDRAW)) {
|
|
237
|
+
if (accounts.length < 8)
|
|
238
|
+
return null;
|
|
239
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
240
|
+
let lp_in = 0n;
|
|
241
|
+
let min_base = 0n;
|
|
242
|
+
let min_quote = 0n;
|
|
243
|
+
if (data.length >= 24) {
|
|
244
|
+
lp_in = (0, utils_js_1.readU64LE)(data, 0) ?? 0n;
|
|
245
|
+
min_base = (0, utils_js_1.readU64LE)(data, 8) ?? 0n;
|
|
246
|
+
min_quote = (0, utils_js_1.readU64LE)(data, 16) ?? 0n;
|
|
247
|
+
}
|
|
248
|
+
const ev = {
|
|
249
|
+
metadata: meta,
|
|
250
|
+
timestamp: 0n,
|
|
251
|
+
lp_token_amount_in: lp_in,
|
|
252
|
+
min_base_amount_out: min_base,
|
|
253
|
+
min_quote_amount_out: min_quote,
|
|
254
|
+
user_base_token_reserves: 0n,
|
|
255
|
+
user_quote_token_reserves: 0n,
|
|
256
|
+
pool_base_token_reserves: 0n,
|
|
257
|
+
pool_quote_token_reserves: 0n,
|
|
258
|
+
base_amount_out: 0n,
|
|
259
|
+
quote_amount_out: 0n,
|
|
260
|
+
lp_mint_supply: 0n,
|
|
261
|
+
pool: g(0),
|
|
262
|
+
user: g(1),
|
|
263
|
+
user_base_token_account: g(4),
|
|
264
|
+
user_quote_token_account: g(5),
|
|
265
|
+
user_pool_token_account: g(6),
|
|
266
|
+
};
|
|
267
|
+
return { PumpSwapLiquidityRemoved: ev };
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raydium AMM V4 指令解析
|
|
3
|
+
* 单字节 discriminator;Swap 账户顺序与链上 `SwapBaseIn`/`SwapBaseOut` 一致(18 个账户)。
|
|
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,112 @@
|
|
|
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
|
+
const INSTR_TYPE = {
|
|
8
|
+
SWAP_BASE_IN: 9,
|
|
9
|
+
SWAP_BASE_OUT: 11,
|
|
10
|
+
};
|
|
11
|
+
/** 指令内账户顺序(与 Raydium AMM V4 swap 一致) */
|
|
12
|
+
const SWAP = {
|
|
13
|
+
TOKEN_PROGRAM: 0,
|
|
14
|
+
AMM: 1,
|
|
15
|
+
AMM_AUTHORITY: 2,
|
|
16
|
+
AMM_OPEN_ORDERS: 3,
|
|
17
|
+
AMM_TARGET_ORDERS: 4,
|
|
18
|
+
POOL_COIN_TOKEN: 5,
|
|
19
|
+
POOL_PC_TOKEN: 6,
|
|
20
|
+
SERUM_PROGRAM: 7,
|
|
21
|
+
SERUM_MARKET: 8,
|
|
22
|
+
SERUM_BIDS: 9,
|
|
23
|
+
SERUM_ASKS: 10,
|
|
24
|
+
SERUM_EVENT_QUEUE: 11,
|
|
25
|
+
SERUM_COIN_VAULT: 12,
|
|
26
|
+
SERUM_PC_VAULT: 13,
|
|
27
|
+
SERUM_VAULT_SIGNER: 14,
|
|
28
|
+
USER_SOURCE_TOKEN: 15,
|
|
29
|
+
USER_DEST_TOKEN: 16,
|
|
30
|
+
USER_OWNER: 17,
|
|
31
|
+
};
|
|
32
|
+
function swapBaseInFromIx(instructionData, accounts, meta) {
|
|
33
|
+
if (instructionData.length < 1 + 8 + 8)
|
|
34
|
+
return null;
|
|
35
|
+
const amount_in = (0, utils_js_1.readU64LE)(instructionData, 1) ?? 0n;
|
|
36
|
+
const minimum_amount_out = (0, utils_js_1.readU64LE)(instructionData, 9) ?? 0n;
|
|
37
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
38
|
+
return {
|
|
39
|
+
RaydiumAmmV4Swap: {
|
|
40
|
+
metadata: meta,
|
|
41
|
+
amount_in,
|
|
42
|
+
minimum_amount_out,
|
|
43
|
+
max_amount_in: 0n,
|
|
44
|
+
amount_out: 0n,
|
|
45
|
+
token_program: g(SWAP.TOKEN_PROGRAM),
|
|
46
|
+
amm: g(SWAP.AMM),
|
|
47
|
+
amm_authority: g(SWAP.AMM_AUTHORITY),
|
|
48
|
+
amm_open_orders: g(SWAP.AMM_OPEN_ORDERS),
|
|
49
|
+
amm_target_orders: g(SWAP.AMM_TARGET_ORDERS),
|
|
50
|
+
pool_coin_token_account: g(SWAP.POOL_COIN_TOKEN),
|
|
51
|
+
pool_pc_token_account: g(SWAP.POOL_PC_TOKEN),
|
|
52
|
+
serum_program: g(SWAP.SERUM_PROGRAM),
|
|
53
|
+
serum_market: g(SWAP.SERUM_MARKET),
|
|
54
|
+
serum_bids: g(SWAP.SERUM_BIDS),
|
|
55
|
+
serum_asks: g(SWAP.SERUM_ASKS),
|
|
56
|
+
serum_event_queue: g(SWAP.SERUM_EVENT_QUEUE),
|
|
57
|
+
serum_coin_vault_account: g(SWAP.SERUM_COIN_VAULT),
|
|
58
|
+
serum_pc_vault_account: g(SWAP.SERUM_PC_VAULT),
|
|
59
|
+
serum_vault_signer: g(SWAP.SERUM_VAULT_SIGNER),
|
|
60
|
+
user_source_token_account: g(SWAP.USER_SOURCE_TOKEN),
|
|
61
|
+
user_destination_token_account: g(SWAP.USER_DEST_TOKEN),
|
|
62
|
+
user_source_owner: g(SWAP.USER_OWNER),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function swapBaseOutFromIx(instructionData, accounts, meta) {
|
|
67
|
+
if (instructionData.length < 1 + 8 + 8)
|
|
68
|
+
return null;
|
|
69
|
+
const max_amount_in = (0, utils_js_1.readU64LE)(instructionData, 1) ?? 0n;
|
|
70
|
+
const amount_out = (0, utils_js_1.readU64LE)(instructionData, 9) ?? 0n;
|
|
71
|
+
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
72
|
+
return {
|
|
73
|
+
RaydiumAmmV4Swap: {
|
|
74
|
+
metadata: meta,
|
|
75
|
+
amount_in: 0n,
|
|
76
|
+
minimum_amount_out: 0n,
|
|
77
|
+
max_amount_in,
|
|
78
|
+
amount_out,
|
|
79
|
+
token_program: g(SWAP.TOKEN_PROGRAM),
|
|
80
|
+
amm: g(SWAP.AMM),
|
|
81
|
+
amm_authority: g(SWAP.AMM_AUTHORITY),
|
|
82
|
+
amm_open_orders: g(SWAP.AMM_OPEN_ORDERS),
|
|
83
|
+
amm_target_orders: g(SWAP.AMM_TARGET_ORDERS),
|
|
84
|
+
pool_coin_token_account: g(SWAP.POOL_COIN_TOKEN),
|
|
85
|
+
pool_pc_token_account: g(SWAP.POOL_PC_TOKEN),
|
|
86
|
+
serum_program: g(SWAP.SERUM_PROGRAM),
|
|
87
|
+
serum_market: g(SWAP.SERUM_MARKET),
|
|
88
|
+
serum_bids: g(SWAP.SERUM_BIDS),
|
|
89
|
+
serum_asks: g(SWAP.SERUM_ASKS),
|
|
90
|
+
serum_event_queue: g(SWAP.SERUM_EVENT_QUEUE),
|
|
91
|
+
serum_coin_vault_account: g(SWAP.SERUM_COIN_VAULT),
|
|
92
|
+
serum_pc_vault_account: g(SWAP.SERUM_PC_VAULT),
|
|
93
|
+
serum_vault_signer: g(SWAP.SERUM_VAULT_SIGNER),
|
|
94
|
+
user_source_token_account: g(SWAP.USER_SOURCE_TOKEN),
|
|
95
|
+
user_destination_token_account: g(SWAP.USER_DEST_TOKEN),
|
|
96
|
+
user_source_owner: g(SWAP.USER_OWNER),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function parseRaydiumAmmV4Instruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
|
|
101
|
+
if (instructionData.length < 1)
|
|
102
|
+
return null;
|
|
103
|
+
const instrType = instructionData[0];
|
|
104
|
+
const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
105
|
+
if (instrType === INSTR_TYPE.SWAP_BASE_IN) {
|
|
106
|
+
return swapBaseInFromIx(instructionData, accounts, meta);
|
|
107
|
+
}
|
|
108
|
+
if (instrType === INSTR_TYPE.SWAP_BASE_OUT) {
|
|
109
|
+
return swapBaseOutFromIx(instructionData, accounts, meta);
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raydium CLMM 指令解析(与 Orca Whirlpool 同源 Anchor 布局:swap / 增减流动性)
|
|
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,184 @@
|
|
|
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 program_log_discriminators_js_1 = require("../logs/program_log_discriminators.js");
|
|
6
|
+
const binary_js_1 = require("../util/binary.js");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
8
|
+
const Z = (0, dex_event_js_1.defaultPubkey)();
|
|
9
|
+
const DISC = {
|
|
10
|
+
SWAP: (0, program_log_discriminators_js_1.u64leDiscriminator)([248, 198, 158, 145, 225, 117, 135, 200]),
|
|
11
|
+
SWAP_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([43, 4, 237, 11, 26, 201, 30, 98]),
|
|
12
|
+
INCREASE_LIQUIDITY_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([133, 29, 89, 223, 69, 238, 176, 10]),
|
|
13
|
+
DECREASE_LIQUIDITY_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([58, 127, 188, 62, 79, 82, 196, 96]),
|
|
14
|
+
CREATE_POOL: (0, program_log_discriminators_js_1.u64leDiscriminator)([233, 146, 209, 142, 207, 104, 64, 188]),
|
|
15
|
+
CREATE_CUSTOMIZABLE_POOL: (0, program_log_discriminators_js_1.u64leDiscriminator)([43, 68, 212, 167, 89, 47, 164, 1]),
|
|
16
|
+
OPEN_POSITION: (0, program_log_discriminators_js_1.u64leDiscriminator)([135, 128, 47, 77, 15, 152, 240, 49]),
|
|
17
|
+
OPEN_POSITION_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([77, 184, 74, 214, 112, 86, 241, 199]),
|
|
18
|
+
OPEN_POSITION_WITH_TOKEN_22_NFT: (0, program_log_discriminators_js_1.u64leDiscriminator)([77, 255, 174, 82, 125, 29, 201, 46]),
|
|
19
|
+
CLOSE_POSITION: (0, program_log_discriminators_js_1.u64leDiscriminator)([123, 134, 81, 0, 49, 68, 98, 98]),
|
|
20
|
+
};
|
|
21
|
+
function discEq(data, disc) {
|
|
22
|
+
if (data.length < 8)
|
|
23
|
+
return false;
|
|
24
|
+
const v = (0, utils_js_1.readU64LE)(data, 0);
|
|
25
|
+
return v === disc;
|
|
26
|
+
}
|
|
27
|
+
function parseRaydiumClmmInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
|
|
28
|
+
if (instructionData.length < 8)
|
|
29
|
+
return null;
|
|
30
|
+
const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
31
|
+
if (discEq(instructionData, DISC.SWAP) || discEq(instructionData, DISC.SWAP_V2)) {
|
|
32
|
+
if (instructionData.length < 8 + 8 + 8 + 16 + 1)
|
|
33
|
+
return null;
|
|
34
|
+
const sqrt_limit = (0, binary_js_1.readU128LE)(instructionData, 24) ?? 0n;
|
|
35
|
+
const is_base_input = (0, utils_js_1.readBool)(instructionData, 40);
|
|
36
|
+
if (is_base_input === null)
|
|
37
|
+
return null;
|
|
38
|
+
return {
|
|
39
|
+
RaydiumClmmSwap: {
|
|
40
|
+
metadata: meta,
|
|
41
|
+
pool_state: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
42
|
+
sender: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
43
|
+
token_account_0: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
44
|
+
token_account_1: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
|
|
45
|
+
amount_0: 0n,
|
|
46
|
+
amount_1: 0n,
|
|
47
|
+
zero_for_one: is_base_input,
|
|
48
|
+
sqrt_price_x64: sqrt_limit,
|
|
49
|
+
liquidity: 0n,
|
|
50
|
+
transfer_fee_0: 0n,
|
|
51
|
+
transfer_fee_1: 0n,
|
|
52
|
+
tick: 0,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (discEq(instructionData, DISC.INCREASE_LIQUIDITY_V2)) {
|
|
57
|
+
if (instructionData.length < 8 + 16 + 8 + 8)
|
|
58
|
+
return null;
|
|
59
|
+
const liquidity = (0, binary_js_1.readU128LE)(instructionData, 8) ?? 0n;
|
|
60
|
+
const amount0_max = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
61
|
+
const amount1_max = (0, utils_js_1.readU64LE)(instructionData, 32) ?? 0n;
|
|
62
|
+
return {
|
|
63
|
+
RaydiumClmmIncreaseLiquidity: {
|
|
64
|
+
metadata: meta,
|
|
65
|
+
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
66
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
67
|
+
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
68
|
+
liquidity,
|
|
69
|
+
amount_0: 0n,
|
|
70
|
+
amount_1: 0n,
|
|
71
|
+
amount_0_transfer_fee: 0n,
|
|
72
|
+
amount_1_transfer_fee: 0n,
|
|
73
|
+
amount0_max,
|
|
74
|
+
amount1_max,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (discEq(instructionData, DISC.DECREASE_LIQUIDITY_V2)) {
|
|
79
|
+
if (instructionData.length < 8 + 16 + 8 + 8)
|
|
80
|
+
return null;
|
|
81
|
+
const liquidity = (0, binary_js_1.readU128LE)(instructionData, 8) ?? 0n;
|
|
82
|
+
const amount0_min = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
83
|
+
const amount1_min = (0, utils_js_1.readU64LE)(instructionData, 32) ?? 0n;
|
|
84
|
+
return {
|
|
85
|
+
RaydiumClmmDecreaseLiquidity: {
|
|
86
|
+
metadata: meta,
|
|
87
|
+
pool: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
88
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
89
|
+
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
90
|
+
liquidity,
|
|
91
|
+
decrease_amount_0: 0n,
|
|
92
|
+
decrease_amount_1: 0n,
|
|
93
|
+
fee_amount_0: 0n,
|
|
94
|
+
fee_amount_1: 0n,
|
|
95
|
+
reward_amounts: [0n, 0n, 0n],
|
|
96
|
+
transfer_fee_0: 0n,
|
|
97
|
+
transfer_fee_1: 0n,
|
|
98
|
+
amount0_min,
|
|
99
|
+
amount1_min,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (discEq(instructionData, DISC.CREATE_POOL)) {
|
|
104
|
+
if (instructionData.length < 8 + 16 + 8)
|
|
105
|
+
return null;
|
|
106
|
+
const sqrt_price_x64 = (0, binary_js_1.readU128LE)(instructionData, 8) ?? 0n;
|
|
107
|
+
const open_time = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
|
|
108
|
+
return {
|
|
109
|
+
RaydiumClmmCreatePool: {
|
|
110
|
+
metadata: meta,
|
|
111
|
+
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
112
|
+
token_0_mint: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
113
|
+
token_1_mint: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
|
|
114
|
+
tick_spacing: 0,
|
|
115
|
+
fee_rate: 0,
|
|
116
|
+
creator: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
117
|
+
sqrt_price_x64,
|
|
118
|
+
tick: 0,
|
|
119
|
+
token_vault_0: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
|
|
120
|
+
token_vault_1: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
|
|
121
|
+
open_time,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (discEq(instructionData, DISC.CREATE_CUSTOMIZABLE_POOL)) {
|
|
126
|
+
if (instructionData.length < 8 + 16)
|
|
127
|
+
return null;
|
|
128
|
+
const sqrt_price_x64 = (0, binary_js_1.readU128LE)(instructionData, 8) ?? 0n;
|
|
129
|
+
return {
|
|
130
|
+
RaydiumClmmCreatePool: {
|
|
131
|
+
metadata: meta,
|
|
132
|
+
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
133
|
+
token_0_mint: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
134
|
+
token_1_mint: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
|
|
135
|
+
tick_spacing: 0,
|
|
136
|
+
fee_rate: 0,
|
|
137
|
+
creator: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
138
|
+
sqrt_price_x64,
|
|
139
|
+
tick: 0,
|
|
140
|
+
token_vault_0: (0, utils_js_1.getAccount)(accounts, 5) ?? Z,
|
|
141
|
+
token_vault_1: (0, utils_js_1.getAccount)(accounts, 6) ?? Z,
|
|
142
|
+
open_time: 0n,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (discEq(instructionData, DISC.OPEN_POSITION)) {
|
|
147
|
+
return parseOpenPosition(instructionData, accounts, meta, 5);
|
|
148
|
+
}
|
|
149
|
+
if (discEq(instructionData, DISC.OPEN_POSITION_V2) || discEq(instructionData, DISC.OPEN_POSITION_WITH_TOKEN_22_NFT)) {
|
|
150
|
+
const poolIndex = discEq(instructionData, DISC.OPEN_POSITION_WITH_TOKEN_22_NFT) ? 4 : 5;
|
|
151
|
+
return parseOpenPosition(instructionData, accounts, meta, poolIndex);
|
|
152
|
+
}
|
|
153
|
+
if (discEq(instructionData, DISC.CLOSE_POSITION)) {
|
|
154
|
+
return {
|
|
155
|
+
RaydiumClmmClosePosition: {
|
|
156
|
+
metadata: meta,
|
|
157
|
+
pool: Z,
|
|
158
|
+
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
159
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
function parseOpenPosition(instructionData, accounts, metadata, poolIndex) {
|
|
166
|
+
if (instructionData.length < 8 + 4 + 4 + 4 + 4 + 16 + 8 + 8)
|
|
167
|
+
return null;
|
|
168
|
+
const tick_lower_index = (0, utils_js_1.readI32LE)(instructionData, 8);
|
|
169
|
+
const tick_upper_index = (0, utils_js_1.readI32LE)(instructionData, 12);
|
|
170
|
+
const liquidity = (0, binary_js_1.readU128LE)(instructionData, 24) ?? 0n;
|
|
171
|
+
if (tick_lower_index === null || tick_upper_index === null)
|
|
172
|
+
return null;
|
|
173
|
+
return {
|
|
174
|
+
RaydiumClmmOpenPosition: {
|
|
175
|
+
metadata,
|
|
176
|
+
pool: (0, utils_js_1.getAccount)(accounts, poolIndex) ?? Z,
|
|
177
|
+
user: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
178
|
+
position_nft_mint: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
179
|
+
tick_lower_index,
|
|
180
|
+
tick_upper_index,
|
|
181
|
+
liquidity,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raydium CPMM 指令解析(Anchor:8 字节 discriminator + Borsh 参数)
|
|
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;
|