sol-parser-sdk 0.5.17 → 0.5.19
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/README.md +46 -31
- package/README_CN.md +45 -30
- package/dist/accounts/pumpfun.js +15 -0
- package/dist/accounts/pumpswap.js +2 -0
- package/dist/core/account_dispatcher_rpc.d.ts +2 -1
- package/dist/core/account_dispatcher_rpc.js +94 -9
- package/dist/core/account_fill_pumpfun.js +20 -0
- package/dist/core/account_fill_pumpswap.d.ts +2 -0
- package/dist/core/account_fill_pumpswap.js +55 -6
- package/dist/core/account_fill_raydium.js +4 -0
- package/dist/core/dex_event.d.ts +149 -0
- package/dist/grpc/client.js +2 -0
- package/dist/grpc/log_instr_dedup.js +75 -7
- package/dist/grpc/order_buffer.d.ts +5 -0
- package/dist/grpc/order_buffer.js +53 -17
- package/dist/grpc/types.d.ts +4 -1
- package/dist/grpc/types.js +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/instr/inner.js +28 -1
- package/dist/instr/meteora_damm_ix.js +26 -0
- package/dist/instr/meteora_pools_ix.js +17 -9
- package/dist/instr/orca_whirlpool_ix.js +13 -9
- package/dist/instr/pumpfun_ix.js +84 -0
- package/dist/instr/pumpswap_ix.js +85 -10
- package/dist/instr/raydium_clmm_ix.js +5 -3
- package/dist/instr/raydium_cpmm_ix.js +11 -8
- package/dist/logs/meteora_damm.d.ts +7 -0
- package/dist/logs/meteora_damm.js +211 -0
- package/dist/logs/meteora_dbc.d.ts +3 -0
- package/dist/logs/meteora_dbc.js +23 -0
- package/dist/logs/meteora_dlmm.js +16 -4
- package/dist/logs/optimized_matcher.js +93 -10
- package/dist/logs/program_log_discriminators.d.ts +11 -0
- package/dist/logs/program_log_discriminators.js +11 -0
- package/dist/logs/pump.js +6 -3
- package/dist/logs/pump_amm.js +8 -2
- package/dist/logs/pump_upgrade.d.ts +68 -0
- package/dist/logs/pump_upgrade.js +128 -0
- package/dist/logs/raydium_cpmm.js +7 -3
- package/dist/rpc_transaction.js +84 -7
- package/dist/shredstream/alt_cache.d.ts +26 -0
- package/dist/shredstream/alt_cache.js +138 -0
- package/dist/shredstream/client.d.ts +11 -3
- package/dist/shredstream/client.js +76 -72
- package/dist/shredstream/config.d.ts +7 -3
- package/dist/shredstream/index.d.ts +3 -2
- package/dist/shredstream/index.js +5 -3
- package/dist/shredstream/instruction_parse.d.ts +1 -1
- package/dist/shredstream/instruction_parse.js +1 -0
- package/dist/simulation_route.d.ts +1 -1
- package/dist/simulation_route.js +17 -4
- package/dist/transaction_route.js +20 -1
- package/dist/wire_transaction.js +9 -10
- package/docs/USAGE.md +161 -0
- package/package.json +2 -5
- package/NATIVE_ALIGNMENT.md +0 -312
- package/NATIVE_DAMM_FACTORY_ALIGNMENT_20261004.md +0 -16
- package/NATIVE_DAMM_FACTORY_EVIDENCE_20261004.json +0 -55
- package/NATIVE_MIGRATION.md +0 -38
- package/NATIVE_PUMPFUN_NATIVE_DEBIT_ALIGNMENT_20261004.md +0 -18
- package/NATIVE_PUMPFUN_NATIVE_DEBIT_EVIDENCE_20261004.json +0 -57
- package/NATIVE_PUMPFUN_SETTLEMENT_ALIGNMENT_20261004.md +0 -11
- package/NATIVE_PUMPFUN_SETTLEMENT_EVIDENCE_20261004.json +0 -70
|
@@ -120,6 +120,81 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
120
120
|
const head = instructionData.subarray(0, 8);
|
|
121
121
|
const data = instructionData.subarray(8);
|
|
122
122
|
const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
123
|
+
if (discEq(head, Uint8Array.from([184, 23, 238, 97, 103, 197, 211, 61]))) {
|
|
124
|
+
if (accounts.length !== 17 || data.length !== 16)
|
|
125
|
+
return null;
|
|
126
|
+
const mapped = Array(26).fill(Z);
|
|
127
|
+
mapped[0] = accounts[0];
|
|
128
|
+
mapped[1] = accounts[1];
|
|
129
|
+
mapped[2] = accounts[2];
|
|
130
|
+
mapped[3] = accounts[3];
|
|
131
|
+
mapped[4] = accounts[4];
|
|
132
|
+
mapped[5] = accounts[5];
|
|
133
|
+
mapped[6] = accounts[6];
|
|
134
|
+
mapped[7] = accounts[7];
|
|
135
|
+
mapped[8] = accounts[8];
|
|
136
|
+
mapped[11] = accounts[9];
|
|
137
|
+
mapped[12] = accounts[10];
|
|
138
|
+
mapped[13] = accounts[11];
|
|
139
|
+
mapped[15] = accounts[15];
|
|
140
|
+
mapped[16] = accounts[16];
|
|
141
|
+
mapped[20] = accounts[12];
|
|
142
|
+
mapped[21] = accounts[13];
|
|
143
|
+
mapped[25] = accounts[14];
|
|
144
|
+
const legacy = new Uint8Array(instructionData);
|
|
145
|
+
legacy.set(PS.BUY, 0);
|
|
146
|
+
return parsePumpswapInstruction(legacy, mapped, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
147
|
+
}
|
|
148
|
+
if (discEq(head, Uint8Array.from([194, 171, 28, 70, 104, 77, 91, 47]))) {
|
|
149
|
+
if (accounts.length !== 17 || data.length !== 16)
|
|
150
|
+
return null;
|
|
151
|
+
const mapped = Array(26).fill(Z);
|
|
152
|
+
mapped[0] = accounts[0];
|
|
153
|
+
mapped[1] = accounts[1];
|
|
154
|
+
mapped[2] = accounts[2];
|
|
155
|
+
mapped[3] = accounts[3];
|
|
156
|
+
mapped[4] = accounts[4];
|
|
157
|
+
mapped[5] = accounts[5];
|
|
158
|
+
mapped[6] = accounts[6];
|
|
159
|
+
mapped[7] = accounts[7];
|
|
160
|
+
mapped[8] = accounts[8];
|
|
161
|
+
mapped[11] = accounts[9];
|
|
162
|
+
mapped[12] = accounts[10];
|
|
163
|
+
mapped[13] = accounts[11];
|
|
164
|
+
mapped[15] = accounts[15];
|
|
165
|
+
mapped[16] = accounts[16];
|
|
166
|
+
mapped[20] = accounts[12];
|
|
167
|
+
mapped[21] = accounts[13];
|
|
168
|
+
mapped[25] = accounts[14];
|
|
169
|
+
const legacy = new Uint8Array(instructionData);
|
|
170
|
+
legacy.set(PS.BUY_EXACT_QUOTE_IN, 0);
|
|
171
|
+
return parsePumpswapInstruction(legacy, mapped, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
172
|
+
}
|
|
173
|
+
if (discEq(head, Uint8Array.from([93, 246, 130, 60, 231, 233, 64, 178]))) {
|
|
174
|
+
if (accounts.length !== 17 || data.length !== 16)
|
|
175
|
+
return null;
|
|
176
|
+
const mapped = Array(26).fill(Z);
|
|
177
|
+
mapped[0] = accounts[0];
|
|
178
|
+
mapped[1] = accounts[1];
|
|
179
|
+
mapped[2] = accounts[2];
|
|
180
|
+
mapped[3] = accounts[3];
|
|
181
|
+
mapped[4] = accounts[4];
|
|
182
|
+
mapped[5] = accounts[5];
|
|
183
|
+
mapped[6] = accounts[6];
|
|
184
|
+
mapped[7] = accounts[7];
|
|
185
|
+
mapped[8] = accounts[8];
|
|
186
|
+
mapped[11] = accounts[9];
|
|
187
|
+
mapped[12] = accounts[10];
|
|
188
|
+
mapped[13] = accounts[11];
|
|
189
|
+
mapped[15] = accounts[15];
|
|
190
|
+
mapped[16] = accounts[16];
|
|
191
|
+
mapped[20] = accounts[12];
|
|
192
|
+
mapped[21] = accounts[13];
|
|
193
|
+
mapped[25] = accounts[14];
|
|
194
|
+
const legacy = new Uint8Array(instructionData);
|
|
195
|
+
legacy.set(PS.SELL, 0);
|
|
196
|
+
return parsePumpswapInstruction(legacy, mapped, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
197
|
+
}
|
|
123
198
|
if (discEq(head, PS.BUY)) {
|
|
124
199
|
if (accounts.length < 13)
|
|
125
200
|
return null;
|
|
@@ -219,7 +294,7 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
219
294
|
return { PumpSwapCreatePool: ev };
|
|
220
295
|
}
|
|
221
296
|
if (discEq(head, PS.DEPOSIT)) {
|
|
222
|
-
if (accounts.length <
|
|
297
|
+
if (accounts.length < 15 || data.length < 24)
|
|
223
298
|
return null;
|
|
224
299
|
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
225
300
|
let lp_out = 0n;
|
|
@@ -244,15 +319,15 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
244
319
|
quote_amount_in: 0n,
|
|
245
320
|
lp_mint_supply: 0n,
|
|
246
321
|
pool: g(0),
|
|
247
|
-
user: g(
|
|
248
|
-
user_base_token_account: g(
|
|
249
|
-
user_quote_token_account: g(
|
|
250
|
-
user_pool_token_account: g(
|
|
322
|
+
user: g(2),
|
|
323
|
+
user_base_token_account: g(6),
|
|
324
|
+
user_quote_token_account: g(7),
|
|
325
|
+
user_pool_token_account: g(8),
|
|
251
326
|
};
|
|
252
327
|
return { PumpSwapLiquidityAdded: ev };
|
|
253
328
|
}
|
|
254
329
|
if (discEq(head, PS.WITHDRAW)) {
|
|
255
|
-
if (accounts.length <
|
|
330
|
+
if (accounts.length < 15 || data.length < 24)
|
|
256
331
|
return null;
|
|
257
332
|
const g = (i) => (0, utils_js_1.getAccount)(accounts, i) ?? Z;
|
|
258
333
|
let lp_in = 0n;
|
|
@@ -277,10 +352,10 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
277
352
|
quote_amount_out: 0n,
|
|
278
353
|
lp_mint_supply: 0n,
|
|
279
354
|
pool: g(0),
|
|
280
|
-
user: g(
|
|
281
|
-
user_base_token_account: g(
|
|
282
|
-
user_quote_token_account: g(
|
|
283
|
-
user_pool_token_account: g(
|
|
355
|
+
user: g(2),
|
|
356
|
+
user_base_token_account: g(6),
|
|
357
|
+
user_quote_token_account: g(7),
|
|
358
|
+
user_pool_token_account: g(8),
|
|
284
359
|
};
|
|
285
360
|
return { PumpSwapLiquidityRemoved: ev };
|
|
286
361
|
}
|
|
@@ -63,7 +63,8 @@ function parseRaydiumClmmInstruction(instructionData, accounts, signature, slot,
|
|
|
63
63
|
RaydiumClmmIncreaseLiquidity: {
|
|
64
64
|
metadata: meta,
|
|
65
65
|
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
66
|
-
position_nft_mint:
|
|
66
|
+
position_nft_mint: Z, // Account 1 is the NFT token account.
|
|
67
|
+
personal_position: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
|
|
67
68
|
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
68
69
|
liquidity,
|
|
69
70
|
amount_0: 0n,
|
|
@@ -85,7 +86,8 @@ function parseRaydiumClmmInstruction(instructionData, accounts, signature, slot,
|
|
|
85
86
|
RaydiumClmmDecreaseLiquidity: {
|
|
86
87
|
metadata: meta,
|
|
87
88
|
pool: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
|
|
88
|
-
position_nft_mint:
|
|
89
|
+
position_nft_mint: Z, // Account 1 is the NFT token account.
|
|
90
|
+
personal_position: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
89
91
|
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
90
92
|
liquidity,
|
|
91
93
|
decrease_amount_0: 0n,
|
|
@@ -123,7 +125,7 @@ function parseRaydiumClmmInstruction(instructionData, accounts, signature, slot,
|
|
|
123
125
|
};
|
|
124
126
|
}
|
|
125
127
|
if (discEq(instructionData, DISC.CREATE_CUSTOMIZABLE_POOL)) {
|
|
126
|
-
if (instructionData.length <
|
|
128
|
+
if (instructionData.length !== 26 || accounts.length < 13 || instructionData[24] > 2 || instructionData[25] > 1)
|
|
127
129
|
return null;
|
|
128
130
|
const sqrt_price_x64 = (0, binary_js_1.readU128LE)(instructionData, 8) ?? 0n;
|
|
129
131
|
return {
|
|
@@ -8,6 +8,7 @@ const Z = (0, dex_event_js_1.defaultPubkey)();
|
|
|
8
8
|
const DISC = {
|
|
9
9
|
SWAP_BASE_IN: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_SWAP_BASE_IN,
|
|
10
10
|
SWAP_BASE_OUT: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_SWAP_BASE_OUT,
|
|
11
|
+
INITIALIZE_PERMISSION: (0, program_log_discriminators_js_1.u64leDiscriminator)([63, 55, 254, 65, 49, 178, 89, 121]),
|
|
11
12
|
INITIALIZE: (0, program_log_discriminators_js_1.u64leDiscriminator)([175, 175, 109, 31, 13, 152, 155, 237]),
|
|
12
13
|
DEPOSIT: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_DEPOSIT,
|
|
13
14
|
WITHDRAW: program_log_discriminators_js_1.PROGRAM_LOG_DISC.RAYDIUM_CPMM_WITHDRAW,
|
|
@@ -56,21 +57,23 @@ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot,
|
|
|
56
57
|
},
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
|
-
if (discEq(instructionData, DISC.INITIALIZE)) {
|
|
60
|
-
|
|
60
|
+
if (discEq(instructionData, DISC.INITIALIZE) || discEq(instructionData, DISC.INITIALIZE_PERMISSION)) {
|
|
61
|
+
const permission = discEq(instructionData, DISC.INITIALIZE_PERMISSION);
|
|
62
|
+
if (instructionData.length < (permission ? 33 : 32) || accounts.length < (permission ? 21 : 20))
|
|
61
63
|
return null;
|
|
62
64
|
const init_amount0 = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
|
|
63
65
|
const init_amount1 = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
|
|
64
66
|
return {
|
|
65
67
|
RaydiumCpmmInitialize: {
|
|
66
68
|
metadata: meta,
|
|
67
|
-
pool: (0, utils_js_1.getAccount)(accounts,
|
|
68
|
-
creator: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
|
|
69
|
+
pool: (0, utils_js_1.getAccount)(accounts, permission ? 4 : 3) ?? Z,
|
|
70
|
+
creator: (0, utils_js_1.getAccount)(accounts, permission ? 1 : 0) ?? Z,
|
|
69
71
|
init_amount0,
|
|
70
72
|
init_amount1,
|
|
71
73
|
},
|
|
72
74
|
};
|
|
73
75
|
}
|
|
76
|
+
// Instruction token amounts are deposit maxima / withdrawal minima, not executed fills.
|
|
74
77
|
if (discEq(instructionData, DISC.DEPOSIT)) {
|
|
75
78
|
if (instructionData.length < 8 + 8 + 8 + 8)
|
|
76
79
|
return null;
|
|
@@ -80,8 +83,8 @@ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot,
|
|
|
80
83
|
return {
|
|
81
84
|
RaydiumCpmmDeposit: {
|
|
82
85
|
metadata: meta,
|
|
83
|
-
pool: (0, utils_js_1.getAccount)(accounts,
|
|
84
|
-
user: (0, utils_js_1.getAccount)(accounts,
|
|
86
|
+
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
87
|
+
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
85
88
|
lp_token_amount,
|
|
86
89
|
token0_amount,
|
|
87
90
|
token1_amount,
|
|
@@ -97,8 +100,8 @@ function parseRaydiumCpmmInstruction(instructionData, accounts, signature, slot,
|
|
|
97
100
|
return {
|
|
98
101
|
RaydiumCpmmWithdraw: {
|
|
99
102
|
metadata: meta,
|
|
100
|
-
pool: (0, utils_js_1.getAccount)(accounts,
|
|
101
|
-
user: (0, utils_js_1.getAccount)(accounts,
|
|
103
|
+
pool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
|
|
104
|
+
user: (0, utils_js_1.getAccount)(accounts, 0) ?? Z,
|
|
102
105
|
lp_token_amount,
|
|
103
106
|
token0_amount,
|
|
104
107
|
token1_amount,
|
|
@@ -13,9 +13,16 @@ export declare function parseRemoveLiquidityFromData(data: Uint8Array, meta: Eve
|
|
|
13
13
|
export declare function parseLiquidityChangeFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
14
14
|
export declare function parseUpdateDelegatePermissionFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
15
15
|
export declare function parseWithdrawDeadLiquidityRewardFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
16
|
+
export declare function parseWithdrawIneligibleRewardFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
17
|
+
export declare function parseUpdateRewardFunderFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
18
|
+
export declare function parseUpdateRewardDurationFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
19
|
+
export declare function parseInitializeRewardFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
20
|
+
export declare function parseFundRewardFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
16
21
|
export declare function parseCreateConfigFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
17
22
|
export declare function parseCreateDynamicConfigFromData(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
18
23
|
/**
|
|
19
24
|
* Meteora DAMM Program data 入口;与 Rust `logs/meteora_damm.rs` 一致。
|
|
20
25
|
*/
|
|
21
26
|
export declare function parseMeteoraDammLog(log: string, signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
|
|
27
|
+
export declare function parseClaimPositionFee(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
28
|
+
export declare function parseClaimReward(data: Uint8Array, meta: EventMetadata): DexEvent | null;
|
|
@@ -7,9 +7,16 @@ exports.parseRemoveLiquidityFromData = parseRemoveLiquidityFromData;
|
|
|
7
7
|
exports.parseLiquidityChangeFromData = parseLiquidityChangeFromData;
|
|
8
8
|
exports.parseUpdateDelegatePermissionFromData = parseUpdateDelegatePermissionFromData;
|
|
9
9
|
exports.parseWithdrawDeadLiquidityRewardFromData = parseWithdrawDeadLiquidityRewardFromData;
|
|
10
|
+
exports.parseWithdrawIneligibleRewardFromData = parseWithdrawIneligibleRewardFromData;
|
|
11
|
+
exports.parseUpdateRewardFunderFromData = parseUpdateRewardFunderFromData;
|
|
12
|
+
exports.parseUpdateRewardDurationFromData = parseUpdateRewardDurationFromData;
|
|
13
|
+
exports.parseInitializeRewardFromData = parseInitializeRewardFromData;
|
|
14
|
+
exports.parseFundRewardFromData = parseFundRewardFromData;
|
|
10
15
|
exports.parseCreateConfigFromData = parseCreateConfigFromData;
|
|
11
16
|
exports.parseCreateDynamicConfigFromData = parseCreateDynamicConfigFromData;
|
|
12
17
|
exports.parseMeteoraDammLog = parseMeteoraDammLog;
|
|
18
|
+
exports.parseClaimPositionFee = parseClaimPositionFee;
|
|
19
|
+
exports.parseClaimReward = parseClaimReward;
|
|
13
20
|
const metadata_js_1 = require("../core/metadata.js");
|
|
14
21
|
const metadata_js_2 = require("../core/metadata.js");
|
|
15
22
|
const dex_event_js_1 = require("../core/dex_event.js");
|
|
@@ -28,9 +35,16 @@ const REMOVE_LIQUIDITY = discOf([87, 46, 88, 98, 175, 96, 34, 91]);
|
|
|
28
35
|
const LIQUIDITY_CHANGE = discOf([197, 171, 78, 127, 224, 211, 87, 13]);
|
|
29
36
|
const INITIALIZE_POOL = discOf([228, 50, 246, 85, 203, 66, 134, 37]);
|
|
30
37
|
const CREATE_POSITION = discOf([156, 15, 119, 198, 29, 181, 221, 55]);
|
|
38
|
+
const CLAIM_POSITION_FEE = discOf([198, 182, 183, 52, 97, 12, 49, 56]);
|
|
39
|
+
const CLAIM_REWARD = discOf([218, 86, 147, 200, 235, 188, 215, 231]);
|
|
31
40
|
const CLOSE_POSITION = discOf([20, 145, 144, 68, 143, 142, 214, 178]);
|
|
32
41
|
const UPDATE_DELEGATE_PERMISSION = discOf([66, 188, 75, 151, 150, 232, 87, 93]);
|
|
33
42
|
const WITHDRAW_DEAD_LIQUIDITY_REWARD = discOf([228, 66, 150, 195, 42, 62, 163, 13]);
|
|
43
|
+
const WITHDRAW_INELIGIBLE_REWARD = discOf([248, 215, 184, 78, 31, 180, 179, 168]);
|
|
44
|
+
const UPDATE_REWARD_FUNDER = discOf([76, 154, 208, 13, 40, 115, 246, 146]);
|
|
45
|
+
const UPDATE_REWARD_DURATION = discOf([149, 135, 65, 231, 129, 153, 65, 57]);
|
|
46
|
+
const INITIALIZE_REWARD = discOf([129, 91, 188, 3, 246, 52, 185, 249]);
|
|
47
|
+
const FUND_REWARD = discOf([104, 233, 237, 122, 199, 191, 121, 85]);
|
|
34
48
|
const CREATE_CONFIG = discOf([131, 207, 180, 174, 180, 73, 165, 54]);
|
|
35
49
|
const CREATE_DYNAMIC_CONFIG = discOf([231, 197, 13, 164, 248, 213, 133, 152]);
|
|
36
50
|
/**
|
|
@@ -554,6 +568,155 @@ function parseWithdrawDeadLiquidityRewardFromData(data, meta) {
|
|
|
554
568
|
};
|
|
555
569
|
return { MeteoraDammV2WithdrawDeadLiquidityReward: ev };
|
|
556
570
|
}
|
|
571
|
+
function parseWithdrawIneligibleRewardFromData(data, meta) {
|
|
572
|
+
let o = 0;
|
|
573
|
+
const pool = (0, binary_js_1.readPubkey)(data, o);
|
|
574
|
+
if (!pool)
|
|
575
|
+
return null;
|
|
576
|
+
o += 32;
|
|
577
|
+
const reward_mint = (0, binary_js_1.readPubkey)(data, o);
|
|
578
|
+
if (!reward_mint)
|
|
579
|
+
return null;
|
|
580
|
+
o += 32;
|
|
581
|
+
const amount = (0, binary_js_1.readU64LE)(data, o);
|
|
582
|
+
if (amount === null)
|
|
583
|
+
return null;
|
|
584
|
+
const ev = {
|
|
585
|
+
metadata: meta,
|
|
586
|
+
pool,
|
|
587
|
+
reward_mint,
|
|
588
|
+
amount,
|
|
589
|
+
};
|
|
590
|
+
return { MeteoraDammV2WithdrawIneligibleReward: ev };
|
|
591
|
+
}
|
|
592
|
+
function parseUpdateRewardFunderFromData(data, meta) {
|
|
593
|
+
if (data.length < 97)
|
|
594
|
+
return null;
|
|
595
|
+
const pool = (0, binary_js_1.readPubkey)(data, 0);
|
|
596
|
+
if (pool === null)
|
|
597
|
+
return null;
|
|
598
|
+
const reward_index = (0, binary_js_1.readU8)(data, 32);
|
|
599
|
+
if (reward_index === null)
|
|
600
|
+
return null;
|
|
601
|
+
const old_funder = (0, binary_js_1.readPubkey)(data, 33);
|
|
602
|
+
if (old_funder === null)
|
|
603
|
+
return null;
|
|
604
|
+
const new_funder = (0, binary_js_1.readPubkey)(data, 65);
|
|
605
|
+
if (new_funder === null)
|
|
606
|
+
return null;
|
|
607
|
+
return {
|
|
608
|
+
MeteoraDammV2UpdateRewardFunder: {
|
|
609
|
+
metadata: meta,
|
|
610
|
+
pool,
|
|
611
|
+
reward_index,
|
|
612
|
+
old_funder,
|
|
613
|
+
new_funder,
|
|
614
|
+
},
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function parseUpdateRewardDurationFromData(data, meta) {
|
|
618
|
+
if (data.length < 49)
|
|
619
|
+
return null;
|
|
620
|
+
const pool = (0, binary_js_1.readPubkey)(data, 0);
|
|
621
|
+
if (pool === null)
|
|
622
|
+
return null;
|
|
623
|
+
const reward_index = (0, binary_js_1.readU8)(data, 32);
|
|
624
|
+
if (reward_index === null)
|
|
625
|
+
return null;
|
|
626
|
+
const old_reward_duration = (0, binary_js_1.readU64LE)(data, 33);
|
|
627
|
+
if (old_reward_duration === null)
|
|
628
|
+
return null;
|
|
629
|
+
const new_reward_duration = (0, binary_js_1.readU64LE)(data, 41);
|
|
630
|
+
if (new_reward_duration === null)
|
|
631
|
+
return null;
|
|
632
|
+
return {
|
|
633
|
+
MeteoraDammV2UpdateRewardDuration: {
|
|
634
|
+
metadata: meta,
|
|
635
|
+
pool,
|
|
636
|
+
reward_index,
|
|
637
|
+
old_reward_duration,
|
|
638
|
+
new_reward_duration,
|
|
639
|
+
},
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function parseInitializeRewardFromData(data, meta) {
|
|
643
|
+
if (data.length < 137)
|
|
644
|
+
return null;
|
|
645
|
+
const pool = (0, binary_js_1.readPubkey)(data, 0);
|
|
646
|
+
if (pool === null)
|
|
647
|
+
return null;
|
|
648
|
+
const reward_mint = (0, binary_js_1.readPubkey)(data, 32);
|
|
649
|
+
if (reward_mint === null)
|
|
650
|
+
return null;
|
|
651
|
+
const funder = (0, binary_js_1.readPubkey)(data, 64);
|
|
652
|
+
if (funder === null)
|
|
653
|
+
return null;
|
|
654
|
+
const creator = (0, binary_js_1.readPubkey)(data, 96);
|
|
655
|
+
if (creator === null)
|
|
656
|
+
return null;
|
|
657
|
+
const reward_index = (0, binary_js_1.readU8)(data, 128);
|
|
658
|
+
if (reward_index === null)
|
|
659
|
+
return null;
|
|
660
|
+
const reward_duration = (0, binary_js_1.readU64LE)(data, 129);
|
|
661
|
+
if (reward_duration === null)
|
|
662
|
+
return null;
|
|
663
|
+
return {
|
|
664
|
+
MeteoraDammV2InitializeReward: {
|
|
665
|
+
metadata: meta,
|
|
666
|
+
pool,
|
|
667
|
+
reward_mint,
|
|
668
|
+
funder,
|
|
669
|
+
creator,
|
|
670
|
+
reward_index,
|
|
671
|
+
reward_duration,
|
|
672
|
+
},
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function parseFundRewardFromData(data, meta) {
|
|
676
|
+
if (data.length < 153)
|
|
677
|
+
return null;
|
|
678
|
+
const pool = (0, binary_js_1.readPubkey)(data, 0);
|
|
679
|
+
if (pool === null)
|
|
680
|
+
return null;
|
|
681
|
+
const funder = (0, binary_js_1.readPubkey)(data, 32);
|
|
682
|
+
if (funder === null)
|
|
683
|
+
return null;
|
|
684
|
+
const mint_reward = (0, binary_js_1.readPubkey)(data, 64);
|
|
685
|
+
if (mint_reward === null)
|
|
686
|
+
return null;
|
|
687
|
+
const reward_index = (0, binary_js_1.readU8)(data, 96);
|
|
688
|
+
if (reward_index === null)
|
|
689
|
+
return null;
|
|
690
|
+
const amount = (0, binary_js_1.readU64LE)(data, 97);
|
|
691
|
+
if (amount === null)
|
|
692
|
+
return null;
|
|
693
|
+
const transfer_fee_excluded_amount_in = (0, binary_js_1.readU64LE)(data, 105);
|
|
694
|
+
if (transfer_fee_excluded_amount_in === null)
|
|
695
|
+
return null;
|
|
696
|
+
const reward_duration_end = (0, binary_js_1.readU64LE)(data, 113);
|
|
697
|
+
if (reward_duration_end === null)
|
|
698
|
+
return null;
|
|
699
|
+
const pre_reward_rate = (0, binary_js_1.readU128LE)(data, 121);
|
|
700
|
+
if (pre_reward_rate === null)
|
|
701
|
+
return null;
|
|
702
|
+
const post_reward_rate = (0, binary_js_1.readU128LE)(data, 137);
|
|
703
|
+
if (post_reward_rate === null)
|
|
704
|
+
return null;
|
|
705
|
+
return {
|
|
706
|
+
MeteoraDammV2FundReward: {
|
|
707
|
+
metadata: meta,
|
|
708
|
+
pool,
|
|
709
|
+
funder,
|
|
710
|
+
mint_reward,
|
|
711
|
+
reward_index,
|
|
712
|
+
amount,
|
|
713
|
+
transfer_fee_excluded_amount_in,
|
|
714
|
+
reward_duration_end,
|
|
715
|
+
pre_reward_rate,
|
|
716
|
+
post_reward_rate,
|
|
717
|
+
},
|
|
718
|
+
};
|
|
719
|
+
}
|
|
557
720
|
function parseDynamicFeeParameters(data, offset) {
|
|
558
721
|
let o = offset;
|
|
559
722
|
const bin_step = (0, binary_js_1.readU16LE)(data, o);
|
|
@@ -724,6 +887,10 @@ function parseMeteoraDammLog(log, signature, slot, txIndex, blockTimeUs, grpcRec
|
|
|
724
887
|
return parseLiquidityChangeFromData(data, meta);
|
|
725
888
|
if (disc === INITIALIZE_POOL)
|
|
726
889
|
return parseInitializePoolEvent(data, meta);
|
|
890
|
+
if (disc === CLAIM_POSITION_FEE)
|
|
891
|
+
return parseClaimPositionFee(data, meta);
|
|
892
|
+
if (disc === CLAIM_REWARD)
|
|
893
|
+
return parseClaimReward(data, meta);
|
|
727
894
|
if (disc === CREATE_POSITION)
|
|
728
895
|
return parseCreatePositionEvent(data, meta);
|
|
729
896
|
if (disc === CLOSE_POSITION)
|
|
@@ -733,9 +900,53 @@ function parseMeteoraDammLog(log, signature, slot, txIndex, blockTimeUs, grpcRec
|
|
|
733
900
|
if (disc === WITHDRAW_DEAD_LIQUIDITY_REWARD) {
|
|
734
901
|
return parseWithdrawDeadLiquidityRewardFromData(data, meta);
|
|
735
902
|
}
|
|
903
|
+
if (disc === WITHDRAW_INELIGIBLE_REWARD) {
|
|
904
|
+
return parseWithdrawIneligibleRewardFromData(data, meta);
|
|
905
|
+
}
|
|
906
|
+
if (disc === UPDATE_REWARD_FUNDER) {
|
|
907
|
+
return parseUpdateRewardFunderFromData(data, meta);
|
|
908
|
+
}
|
|
909
|
+
if (disc === UPDATE_REWARD_DURATION) {
|
|
910
|
+
return parseUpdateRewardDurationFromData(data, meta);
|
|
911
|
+
}
|
|
912
|
+
if (disc === INITIALIZE_REWARD) {
|
|
913
|
+
return parseInitializeRewardFromData(data, meta);
|
|
914
|
+
}
|
|
915
|
+
if (disc === FUND_REWARD) {
|
|
916
|
+
return parseFundRewardFromData(data, meta);
|
|
917
|
+
}
|
|
736
918
|
if (disc === CREATE_CONFIG)
|
|
737
919
|
return parseCreateConfigFromData(data, meta);
|
|
738
920
|
if (disc === CREATE_DYNAMIC_CONFIG)
|
|
739
921
|
return parseCreateDynamicConfigFromData(data, meta);
|
|
740
922
|
return null;
|
|
741
923
|
}
|
|
924
|
+
function parseClaimPositionFee(data, meta) {
|
|
925
|
+
if (data.length < 112)
|
|
926
|
+
return null;
|
|
927
|
+
return {
|
|
928
|
+
MeteoraDammV2ClaimPositionFee: {
|
|
929
|
+
metadata: meta,
|
|
930
|
+
pool: (0, binary_js_1.readPubkey)(data, 0),
|
|
931
|
+
position: (0, binary_js_1.readPubkey)(data, 32),
|
|
932
|
+
owner: (0, binary_js_1.readPubkey)(data, 64),
|
|
933
|
+
fee_a_claimed: (0, binary_js_1.readU64LE)(data, 96),
|
|
934
|
+
fee_b_claimed: (0, binary_js_1.readU64LE)(data, 104),
|
|
935
|
+
},
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function parseClaimReward(data, meta) {
|
|
939
|
+
if (data.length < 137)
|
|
940
|
+
return null;
|
|
941
|
+
return {
|
|
942
|
+
MeteoraDammV2ClaimReward: {
|
|
943
|
+
metadata: meta,
|
|
944
|
+
pool: (0, binary_js_1.readPubkey)(data, 0),
|
|
945
|
+
position: (0, binary_js_1.readPubkey)(data, 32),
|
|
946
|
+
owner: (0, binary_js_1.readPubkey)(data, 64),
|
|
947
|
+
mint_reward: (0, binary_js_1.readPubkey)(data, 96),
|
|
948
|
+
reward_index: data[128],
|
|
949
|
+
total_reward: (0, binary_js_1.readU64LE)(data, 129),
|
|
950
|
+
},
|
|
951
|
+
};
|
|
952
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { DexEvent } from "../core/dex_event.js";
|
|
2
2
|
import type { EventMetadata } from "../core/metadata.js";
|
|
3
3
|
export declare const METEORA_DBC_DISC: {
|
|
4
|
+
readonly SWAP2: bigint;
|
|
5
|
+
readonly SWAP2_TRANSFER_HOOK: bigint;
|
|
4
6
|
readonly SWAP: bigint;
|
|
5
7
|
readonly INITIALIZE_POOL: bigint;
|
|
6
8
|
readonly CURVE_COMPLETE: bigint;
|
|
@@ -9,3 +11,4 @@ export declare function parseMeteoraDbcSwapFromData(data: Uint8Array, metadata:
|
|
|
9
11
|
export declare function parseMeteoraDbcInitializePoolFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
10
12
|
export declare function parseMeteoraDbcCurveCompleteFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
11
13
|
export declare function parseMeteoraDbcFromDiscriminator(discriminator: bigint, data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
14
|
+
export declare function parseMeteoraDbcSwap2FromData(data: Uint8Array, metadata: EventMetadata, has_transfer_hook: boolean): DexEvent | null;
|
package/dist/logs/meteora_dbc.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.parseMeteoraDbcSwapFromData = parseMeteoraDbcSwapFromData;
|
|
|
5
5
|
exports.parseMeteoraDbcInitializePoolFromData = parseMeteoraDbcInitializePoolFromData;
|
|
6
6
|
exports.parseMeteoraDbcCurveCompleteFromData = parseMeteoraDbcCurveCompleteFromData;
|
|
7
7
|
exports.parseMeteoraDbcFromDiscriminator = parseMeteoraDbcFromDiscriminator;
|
|
8
|
+
exports.parseMeteoraDbcSwap2FromData = parseMeteoraDbcSwap2FromData;
|
|
8
9
|
const binary_js_1 = require("../util/binary.js");
|
|
9
10
|
function disc(bytes) {
|
|
10
11
|
const u8 = new Uint8Array(8);
|
|
@@ -13,6 +14,8 @@ function disc(bytes) {
|
|
|
13
14
|
return new DataView(u8.buffer).getBigUint64(0, true);
|
|
14
15
|
}
|
|
15
16
|
exports.METEORA_DBC_DISC = {
|
|
17
|
+
SWAP2: disc([189, 66, 51, 168, 38, 80, 117, 153]),
|
|
18
|
+
SWAP2_TRANSFER_HOOK: disc([134, 59, 168, 120, 94, 51, 114, 231]),
|
|
16
19
|
SWAP: disc([27, 60, 21, 213, 138, 170, 187, 147]),
|
|
17
20
|
INITIALIZE_POOL: disc([228, 50, 246, 85, 203, 66, 134, 37]),
|
|
18
21
|
CURVE_COMPLETE: disc([229, 231, 86, 84, 156, 134, 75, 24]),
|
|
@@ -130,6 +133,8 @@ function parseMeteoraDbcCurveCompleteFromData(data, metadata) {
|
|
|
130
133
|
return { MeteoraDbcCurveComplete: ev };
|
|
131
134
|
}
|
|
132
135
|
function parseMeteoraDbcFromDiscriminator(discriminator, data, metadata) {
|
|
136
|
+
if (discriminator === exports.METEORA_DBC_DISC.SWAP2 || discriminator === exports.METEORA_DBC_DISC.SWAP2_TRANSFER_HOOK)
|
|
137
|
+
return parseMeteoraDbcSwap2FromData(data, metadata, discriminator === exports.METEORA_DBC_DISC.SWAP2_TRANSFER_HOOK);
|
|
133
138
|
if (discriminator === exports.METEORA_DBC_DISC.SWAP)
|
|
134
139
|
return parseMeteoraDbcSwapFromData(data, metadata);
|
|
135
140
|
if (discriminator === exports.METEORA_DBC_DISC.INITIALIZE_POOL) {
|
|
@@ -140,3 +145,21 @@ function parseMeteoraDbcFromDiscriminator(discriminator, data, metadata) {
|
|
|
140
145
|
}
|
|
141
146
|
return null;
|
|
142
147
|
}
|
|
148
|
+
function parseMeteoraDbcSwap2FromData(data, metadata, has_transfer_hook) {
|
|
149
|
+
if (data.length < 179 || data[82] > 2 || data[64] > 1 || data[65] > 1)
|
|
150
|
+
return null;
|
|
151
|
+
const swap_mode = data[82];
|
|
152
|
+
const u64 = (offset) => (0, binary_js_1.readU64LE)(data, offset);
|
|
153
|
+
const amount_0 = u64(66), amount_1 = u64(74), included_fee_input_amount = u64(83);
|
|
154
|
+
return { MeteoraDbcSwap: {
|
|
155
|
+
metadata, pool: (0, binary_js_1.readPubkey)(data, 0), config: (0, binary_js_1.readPubkey)(data, 32),
|
|
156
|
+
trade_direction: data[64], has_referral: Boolean(data[65]), event_version: 2,
|
|
157
|
+
swap_mode, amount_0, amount_1, has_transfer_hook,
|
|
158
|
+
amount_in: included_fee_input_amount, minimum_amount_out: swap_mode === 2 ? 0n : amount_1,
|
|
159
|
+
maximum_amount_in: swap_mode === 2 ? amount_1 : 0n,
|
|
160
|
+
included_fee_input_amount, actual_input_amount: u64(91), amount_left: u64(99),
|
|
161
|
+
output_amount: u64(107), next_sqrt_price: (0, binary_js_1.readU128LE)(data, 115),
|
|
162
|
+
trading_fee: u64(131), protocol_fee: u64(139), referral_fee: u64(147),
|
|
163
|
+
quote_reserve_amount: u64(155), migration_threshold: u64(163), current_timestamp: u64(171),
|
|
164
|
+
} };
|
|
165
|
+
}
|
|
@@ -92,7 +92,7 @@ function parseDlmmEventFromData(discriminator, data, metadata) {
|
|
|
92
92
|
return { MeteoraDlmmSwap: ev };
|
|
93
93
|
}
|
|
94
94
|
if (discriminator === DLMM.SWAP2) {
|
|
95
|
-
if (data.length < 147)
|
|
95
|
+
if (data.length < 147 || data[72] > 1 || data[145] > 1 || data[146] > 1)
|
|
96
96
|
return null;
|
|
97
97
|
let o = 0;
|
|
98
98
|
const pool = (0, binary_js_1.readPubkey)(data, o);
|
|
@@ -109,17 +109,24 @@ function parseDlmmEventFromData(discriminator, data, metadata) {
|
|
|
109
109
|
o += 16;
|
|
110
110
|
const amount_in = bn64((0, binary_js_1.readU64LE)(data, o));
|
|
111
111
|
o += 8;
|
|
112
|
-
|
|
112
|
+
const amount_left = bn64((0, binary_js_1.readU64LE)(data, o));
|
|
113
|
+
o += 8;
|
|
113
114
|
const amount_out = bn64((0, binary_js_1.readU64LE)(data, o));
|
|
114
115
|
o += 8;
|
|
115
|
-
const
|
|
116
|
+
const mm_fee = bn64((0, binary_js_1.readU64LE)(data, o));
|
|
116
117
|
o += 8;
|
|
117
118
|
const protocol_fee = bn64((0, binary_js_1.readU64LE)(data, o));
|
|
118
119
|
o += 8;
|
|
119
|
-
|
|
120
|
+
const limit_order_fee = bn64((0, binary_js_1.readU64LE)(data, o));
|
|
121
|
+
o += 8;
|
|
120
122
|
const host_fee = bn64((0, binary_js_1.readU64LE)(data, o));
|
|
123
|
+
const fee = mm_fee + protocol_fee + limit_order_fee;
|
|
124
|
+
if (fee > 0xffffffffffffffffn)
|
|
125
|
+
return null;
|
|
121
126
|
const ev = {
|
|
122
127
|
metadata,
|
|
128
|
+
event_version: 2, amount_left, mm_fee, limit_order_fee,
|
|
129
|
+
fees_on_input: data[145] !== 0, fees_on_token_x: data[146] !== 0,
|
|
123
130
|
token_x_mint: (0, dex_event_js_1.defaultPubkey)(),
|
|
124
131
|
token_y_mint: (0, dex_event_js_1.defaultPubkey)(),
|
|
125
132
|
user_token_in: (0, dex_event_js_1.defaultPubkey)(),
|
|
@@ -306,6 +313,11 @@ function parseDlmmEventFromData(discriminator, data, metadata) {
|
|
|
306
313
|
const ev = { metadata, pool, position, owner };
|
|
307
314
|
return { MeteoraDlmmClosePosition: ev };
|
|
308
315
|
}
|
|
316
|
+
if (discriminator === disc([27, 143, 244, 33, 80, 43, 110, 146])) {
|
|
317
|
+
if (data.length < 116)
|
|
318
|
+
return null;
|
|
319
|
+
return { MeteoraDlmmClaimReward: { metadata, pool: (0, binary_js_1.readPubkey)(data, 0), position: (0, binary_js_1.readPubkey)(data, 32), owner: (0, binary_js_1.readPubkey)(data, 64), reward_index: (0, binary_js_1.readU64LE)(data, 96), total_reward: (0, binary_js_1.readU64LE)(data, 104), active_bin_id: new DataView(data.buffer, data.byteOffset, data.byteLength).getInt32(112, true) } };
|
|
320
|
+
}
|
|
309
321
|
if (discriminator === DLMM.CLAIM_FEE || discriminator === DLMM.CLAIM_FEE2 || discriminator === DLMM.LEGACY_CLAIM_FEE) {
|
|
310
322
|
const requiredLength = discriminator === DLMM.CLAIM_FEE2 ? 116 : 112;
|
|
311
323
|
if (data.length < requiredLength)
|