sol-parser-sdk-nodejs 0.4.0 → 0.5.5
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 +22 -4
- package/README_CN.md +22 -4
- package/dist/accounts/mod.d.ts +1 -0
- package/dist/accounts/mod.js +53 -6
- package/dist/accounts/pumpfun.d.ts +16 -0
- package/dist/accounts/pumpfun.js +538 -0
- package/dist/accounts/rust_aliases.d.ts +1 -0
- package/dist/accounts/rust_aliases.js +3 -1
- package/dist/core/account_dispatcher_rpc.js +5 -26
- package/dist/core/account_fill_meteora.d.ts +1 -2
- package/dist/core/account_fill_meteora.js +0 -2
- package/dist/core/account_fill_pumpfun.js +92 -13
- package/dist/core/account_fill_pumpswap.js +50 -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/dex_event.d.ts +283 -17
- package/dist/core/pumpfun_fee_enrich.d.ts +5 -0
- package/dist/core/pumpfun_fee_enrich.js +131 -0
- package/dist/core/unified_parser.js +2 -0
- package/dist/grpc/client.d.ts +26 -1
- package/dist/grpc/client.js +279 -0
- package/dist/grpc/log_instr_dedup.d.ts +2 -0
- package/dist/grpc/log_instr_dedup.js +378 -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 +5 -3
- package/dist/grpc/program_ids.js +12 -5
- package/dist/grpc/types.d.ts +17 -6
- package/dist/grpc/types.js +265 -153
- package/dist/grpc/yellowstone_parse.d.ts +3 -1
- package/dist/grpc/yellowstone_parse.js +13 -10
- package/dist/index.d.ts +9 -7
- package/dist/index.js +33 -7
- package/dist/instr/meteora_damm_ix.js +4 -1
- 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 +4 -1
- package/dist/instr/mod.js +45 -18
- package/dist/instr/program_ids.d.ts +1 -5
- package/dist/instr/program_ids.js +4 -6
- package/dist/instr/pump_fees_ix.d.ts +2 -0
- package/dist/instr/pump_fees_ix.js +166 -0
- package/dist/instr/pumpfun_ix.js +272 -1
- package/dist/instr/pumpswap_ix.js +36 -2
- package/dist/instr/raydium_clmm_ix.js +73 -52
- 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 +3 -0
- package/dist/instr/rust_aliases.js +7 -1
- package/dist/logs/discriminator_lut.d.ts +1 -1
- package/dist/logs/discriminator_lut.js +2 -0
- package/dist/logs/optimized_matcher.js +130 -25
- package/dist/logs/program_log_discriminators.d.ts +10 -0
- package/dist/logs/program_log_discriminators.js +10 -0
- package/dist/logs/pump.d.ts +2 -0
- package/dist/logs/pump.js +122 -2
- package/dist/logs/pump_amm.js +1 -1
- package/dist/logs/pump_fees.d.ts +23 -0
- package/dist/logs/pump_fees.js +364 -0
- package/dist/logs/raydium_launchlab.d.ts +10 -0
- package/dist/logs/raydium_launchlab.js +84 -0
- package/dist/rpc_transaction.d.ts +2 -0
- package/dist/rpc_transaction.js +14 -6
- package/dist/shredstream/client.d.ts +4 -1
- package/dist/shredstream/client.js +18 -14
- package/dist/shredstream/index.d.ts +1 -1
- package/dist/shredstream/index.js +1 -1
- package/dist/shredstream/instruction_parse.d.ts +3 -3
- package/dist/shredstream/instruction_parse.js +38 -13
- package/dist/util/market.d.ts +18 -0
- package/dist/util/market.js +54 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.METEORA_DBC_PROGRAM_ID = exports.METEORA_DLMM_PROGRAM_ID = exports.METEORA_DAMM_V2_PROGRAM_ID = exports.METEORA_POOLS_PROGRAM_ID = exports.ORCA_WHIRLPOOL_PROGRAM_ID = exports.RAYDIUM_AMM_V4_PROGRAM_ID = exports.RAYDIUM_CLMM_PROGRAM_ID = exports.RAYDIUM_CPMM_PROGRAM_ID = exports.RAYDIUM_LAUNCHLAB_PROGRAM_ID = exports.PUMP_FEES_PROGRAM_ID = exports.PUMPSWAP_FEES_PROGRAM_ID = exports.PUMPSWAP_PROGRAM_ID = exports.PUMPFUN_PROGRAM_ID = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 各 DEX 程序 ID(Base58)。与 Rust 对齐的常量来自 `grpc/program_ids.ts`。
|
|
6
6
|
*/
|
|
@@ -8,7 +8,8 @@ var program_ids_js_1 = require("../grpc/program_ids.js");
|
|
|
8
8
|
Object.defineProperty(exports, "PUMPFUN_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMPFUN_PROGRAM_ID; } });
|
|
9
9
|
Object.defineProperty(exports, "PUMPSWAP_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMPSWAP_PROGRAM_ID; } });
|
|
10
10
|
Object.defineProperty(exports, "PUMPSWAP_FEES_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMPSWAP_FEES_PROGRAM_ID; } });
|
|
11
|
-
Object.defineProperty(exports, "
|
|
11
|
+
Object.defineProperty(exports, "PUMP_FEES_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMP_FEES_PROGRAM_ID; } });
|
|
12
|
+
Object.defineProperty(exports, "RAYDIUM_LAUNCHLAB_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_LAUNCHLAB_PROGRAM_ID; } });
|
|
12
13
|
Object.defineProperty(exports, "RAYDIUM_CPMM_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_CPMM_PROGRAM_ID; } });
|
|
13
14
|
Object.defineProperty(exports, "RAYDIUM_CLMM_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_CLMM_PROGRAM_ID; } });
|
|
14
15
|
Object.defineProperty(exports, "RAYDIUM_AMM_V4_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_AMM_V4_PROGRAM_ID; } });
|
|
@@ -16,7 +17,4 @@ Object.defineProperty(exports, "ORCA_WHIRLPOOL_PROGRAM_ID", { enumerable: true,
|
|
|
16
17
|
Object.defineProperty(exports, "METEORA_POOLS_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_POOLS_PROGRAM_ID; } });
|
|
17
18
|
Object.defineProperty(exports, "METEORA_DAMM_V2_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID; } });
|
|
18
19
|
Object.defineProperty(exports, "METEORA_DLMM_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_DLMM_PROGRAM_ID; } });
|
|
19
|
-
|
|
20
|
-
exports.BONK_LAUNCHPAD_PROGRAM_ID = "LanCh3hDdY7M6x8urBSLJhsQBgPNGKHNqJqGwzAEmBm";
|
|
21
|
-
/** 旧版 TS 包中的 Bonk ID,仅作兼容保留 */
|
|
22
|
-
exports.BONK_PROGRAM_ID_LEGACY = "DjVE6JNiYqPL2QXyCUUh8rNjHrbz9hXHNYt99MQ59qw1";
|
|
20
|
+
Object.defineProperty(exports, "METEORA_DBC_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_DBC_PROGRAM_ID; } });
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePumpFeesInstruction = parsePumpFeesInstruction;
|
|
4
|
+
const metadata_js_1 = require("../core/metadata.js");
|
|
5
|
+
const dex_event_js_1 = require("../core/dex_event.js");
|
|
6
|
+
const binary_js_1 = require("../util/binary.js");
|
|
7
|
+
const pump_fees_js_1 = require("../logs/pump_fees.js");
|
|
8
|
+
const program_log_discriminators_js_1 = require("../logs/program_log_discriminators.js");
|
|
9
|
+
const CREATE_FEE_SHARING_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([195, 78, 86, 76, 111, 52, 251, 213]);
|
|
10
|
+
const INITIALIZE_FEE_CONFIG_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([62, 162, 20, 133, 121, 65, 145, 27]);
|
|
11
|
+
const RESET_FEE_SHARING_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([10, 2, 182, 95, 16, 127, 129, 186]);
|
|
12
|
+
const REVOKE_FEE_SHARING_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([18, 233, 158, 39, 185, 207, 58, 104]);
|
|
13
|
+
const TRANSFER_FEE_SHARING_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([202, 10, 75, 200, 164, 34, 210, 96]);
|
|
14
|
+
const UPDATE_ADMIN_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([161, 176, 40, 213, 60, 184, 179, 228]);
|
|
15
|
+
const UPDATE_FEE_CONFIG_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([104, 184, 103, 242, 88, 151, 107, 20]);
|
|
16
|
+
const UPDATE_FEE_SHARES_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([189, 13, 136, 99, 187, 164, 237, 35]);
|
|
17
|
+
const UPSERT_FEE_TIERS_IX = (0, program_log_discriminators_js_1.u64leDiscriminator)([227, 23, 150, 12, 77, 86, 94, 4]);
|
|
18
|
+
function account(accounts, index) {
|
|
19
|
+
return accounts[index] ?? null;
|
|
20
|
+
}
|
|
21
|
+
function accountOrDefault(accounts, index) {
|
|
22
|
+
return accounts[index] ?? (0, dex_event_js_1.defaultPubkey)();
|
|
23
|
+
}
|
|
24
|
+
function parsePumpFeesInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
|
|
25
|
+
const disc = (0, binary_js_1.readDiscriminatorU64)(instructionData);
|
|
26
|
+
if (disc === null)
|
|
27
|
+
return null;
|
|
28
|
+
const metadata = (0, metadata_js_1.makeMetadata)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
|
|
29
|
+
if (disc === CREATE_FEE_SHARING_IX) {
|
|
30
|
+
const admin = account(accounts, 2);
|
|
31
|
+
const mint = account(accounts, 4);
|
|
32
|
+
if (!admin || !mint)
|
|
33
|
+
return null;
|
|
34
|
+
return {
|
|
35
|
+
PumpFeesCreateFeeSharingConfig: {
|
|
36
|
+
metadata,
|
|
37
|
+
timestamp: 0n,
|
|
38
|
+
mint,
|
|
39
|
+
bonding_curve: accountOrDefault(accounts, 7),
|
|
40
|
+
pool: account(accounts, 10) ?? undefined,
|
|
41
|
+
sharing_config: accountOrDefault(accounts, 5),
|
|
42
|
+
admin,
|
|
43
|
+
initial_shareholders: [],
|
|
44
|
+
status: "Active",
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (disc === UPDATE_FEE_SHARES_IX) {
|
|
49
|
+
const admin = account(accounts, 2);
|
|
50
|
+
const mint = account(accounts, 4);
|
|
51
|
+
const sharing_config = account(accounts, 5);
|
|
52
|
+
if (!admin || !mint || !sharing_config)
|
|
53
|
+
return null;
|
|
54
|
+
const shareholders = (0, pump_fees_js_1.readShareholdersVec)(instructionData, 8);
|
|
55
|
+
if (!shareholders || shareholders.next !== instructionData.length)
|
|
56
|
+
return null;
|
|
57
|
+
return {
|
|
58
|
+
PumpFeesUpdateFeeShares: {
|
|
59
|
+
metadata,
|
|
60
|
+
timestamp: 0n,
|
|
61
|
+
mint,
|
|
62
|
+
sharing_config,
|
|
63
|
+
admin,
|
|
64
|
+
bonding_curve: accountOrDefault(accounts, 6),
|
|
65
|
+
pump_creator_vault: accountOrDefault(accounts, 7),
|
|
66
|
+
new_shareholders: shareholders.value,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (disc === INITIALIZE_FEE_CONFIG_IX) {
|
|
71
|
+
const admin = account(accounts, 0);
|
|
72
|
+
const fee_config = account(accounts, 1);
|
|
73
|
+
if (!admin || !fee_config)
|
|
74
|
+
return null;
|
|
75
|
+
return { PumpFeesInitializeFeeConfig: { metadata, timestamp: 0n, admin, fee_config } };
|
|
76
|
+
}
|
|
77
|
+
if (disc === RESET_FEE_SHARING_IX) {
|
|
78
|
+
const old_admin = account(accounts, 0);
|
|
79
|
+
const new_admin = account(accounts, 2);
|
|
80
|
+
const mint = account(accounts, 3);
|
|
81
|
+
const sharing_config = account(accounts, 4);
|
|
82
|
+
if (!old_admin || !new_admin || !mint || !sharing_config)
|
|
83
|
+
return null;
|
|
84
|
+
return {
|
|
85
|
+
PumpFeesResetFeeSharingConfig: {
|
|
86
|
+
metadata,
|
|
87
|
+
timestamp: 0n,
|
|
88
|
+
mint,
|
|
89
|
+
sharing_config,
|
|
90
|
+
old_admin,
|
|
91
|
+
old_shareholders: [],
|
|
92
|
+
new_admin,
|
|
93
|
+
new_shareholders: [],
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (disc === REVOKE_FEE_SHARING_IX) {
|
|
98
|
+
const admin = account(accounts, 0);
|
|
99
|
+
const mint = account(accounts, 2);
|
|
100
|
+
const sharing_config = account(accounts, 3);
|
|
101
|
+
if (!admin || !mint || !sharing_config)
|
|
102
|
+
return null;
|
|
103
|
+
return { PumpFeesRevokeFeeSharingAuthority: { metadata, timestamp: 0n, mint, sharing_config, admin } };
|
|
104
|
+
}
|
|
105
|
+
if (disc === TRANSFER_FEE_SHARING_IX) {
|
|
106
|
+
const old_admin = account(accounts, 0);
|
|
107
|
+
const mint = account(accounts, 2);
|
|
108
|
+
const sharing_config = account(accounts, 3);
|
|
109
|
+
const new_admin = account(accounts, 4);
|
|
110
|
+
if (!old_admin || !mint || !sharing_config || !new_admin)
|
|
111
|
+
return null;
|
|
112
|
+
return {
|
|
113
|
+
PumpFeesTransferFeeSharingAuthority: {
|
|
114
|
+
metadata,
|
|
115
|
+
timestamp: 0n,
|
|
116
|
+
mint,
|
|
117
|
+
sharing_config,
|
|
118
|
+
old_admin,
|
|
119
|
+
new_admin,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (disc === UPDATE_ADMIN_IX) {
|
|
124
|
+
const old_admin = account(accounts, 0);
|
|
125
|
+
const new_admin = account(accounts, 2);
|
|
126
|
+
if (!old_admin || !new_admin)
|
|
127
|
+
return null;
|
|
128
|
+
return { PumpFeesUpdateAdmin: { metadata, timestamp: 0n, old_admin, new_admin } };
|
|
129
|
+
}
|
|
130
|
+
if (disc === UPDATE_FEE_CONFIG_IX) {
|
|
131
|
+
const fee_config = account(accounts, 0);
|
|
132
|
+
const admin = account(accounts, 1);
|
|
133
|
+
if (!fee_config || !admin)
|
|
134
|
+
return null;
|
|
135
|
+
const fee_tiers = (0, pump_fees_js_1.readFeeTiersVec)(instructionData, 8);
|
|
136
|
+
if (!fee_tiers)
|
|
137
|
+
return null;
|
|
138
|
+
const flat_fees = (0, pump_fees_js_1.readFeesAt)(instructionData, fee_tiers.next);
|
|
139
|
+
if (!flat_fees || flat_fees.next !== instructionData.length)
|
|
140
|
+
return null;
|
|
141
|
+
return {
|
|
142
|
+
PumpFeesUpdateFeeConfig: {
|
|
143
|
+
metadata,
|
|
144
|
+
timestamp: 0n,
|
|
145
|
+
admin,
|
|
146
|
+
fee_config,
|
|
147
|
+
fee_tiers: fee_tiers.value,
|
|
148
|
+
flat_fees: flat_fees.value,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (disc === UPSERT_FEE_TIERS_IX) {
|
|
153
|
+
const fee_config = account(accounts, 0);
|
|
154
|
+
const admin = account(accounts, 1);
|
|
155
|
+
if (!fee_config || !admin)
|
|
156
|
+
return null;
|
|
157
|
+
const fee_tiers = (0, pump_fees_js_1.readFeeTiersVec)(instructionData, 8);
|
|
158
|
+
if (!fee_tiers)
|
|
159
|
+
return null;
|
|
160
|
+
const offset = (0, binary_js_1.readU8)(instructionData, fee_tiers.next);
|
|
161
|
+
if (offset === null || fee_tiers.next + 1 !== instructionData.length)
|
|
162
|
+
return null;
|
|
163
|
+
return { PumpFeesUpsertFeeTiers: { metadata, timestamp: 0n, admin, fee_config, fee_tiers: fee_tiers.value, offset } };
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
package/dist/instr/pumpfun_ix.js
CHANGED
|
@@ -6,8 +6,14 @@ const utils_js_1 = require("./utils.js");
|
|
|
6
6
|
const binary_js_1 = require("../util/binary.js");
|
|
7
7
|
const Z = (0, dex_event_js_1.defaultPubkey)();
|
|
8
8
|
const DISC = {
|
|
9
|
+
BUY: Uint8Array.from([102, 6, 61, 18, 1, 218, 235, 234]),
|
|
10
|
+
SELL: Uint8Array.from([51, 230, 133, 164, 1, 127, 131, 173]),
|
|
9
11
|
CREATE: Uint8Array.from([24, 30, 200, 40, 5, 28, 7, 119]),
|
|
10
12
|
CREATE_V2: Uint8Array.from([214, 144, 76, 236, 95, 139, 49, 180]),
|
|
13
|
+
BUY_EXACT_SOL_IN: Uint8Array.from([56, 252, 116, 8, 158, 223, 205, 95]),
|
|
14
|
+
BUY_V2: Uint8Array.from([184, 23, 238, 97, 103, 197, 211, 61]),
|
|
15
|
+
SELL_V2: Uint8Array.from([93, 246, 130, 60, 231, 233, 64, 178]),
|
|
16
|
+
BUY_EXACT_QUOTE_IN_V2: Uint8Array.from([194, 171, 28, 70, 104, 77, 91, 47]),
|
|
11
17
|
MIGRATE_EVENT_LOG: Uint8Array.from([189, 233, 93, 185, 92, 148, 234, 148]),
|
|
12
18
|
};
|
|
13
19
|
function discEq(data, disc) {
|
|
@@ -27,8 +33,242 @@ function createNumericDefaults() {
|
|
|
27
33
|
token_total_supply: 0n,
|
|
28
34
|
is_mayhem_mode: false,
|
|
29
35
|
is_cashback_enabled: false,
|
|
36
|
+
quote_mint: Z,
|
|
37
|
+
virtual_quote_reserves: 0n,
|
|
30
38
|
};
|
|
31
39
|
}
|
|
40
|
+
function parsePumpfunTradeV2Instruction(ixName, data, accounts, metadata) {
|
|
41
|
+
if (!accounts[1])
|
|
42
|
+
return null;
|
|
43
|
+
const normalizedIxName = ixName === "buy_v2" ? "buy" : ixName === "sell_v2" ? "sell" : "buy_exact_quote_in";
|
|
44
|
+
const first = data.length >= 8 ? (0, utils_js_1.readU64LE)(data, 0) ?? 0n : 0n;
|
|
45
|
+
const second = data.length >= 16 ? (0, utils_js_1.readU64LE)(data, 8) ?? 0n : 0n;
|
|
46
|
+
const tokenAmount = ixName === "buy_exact_quote_in_v2" ? second : first;
|
|
47
|
+
const solAmount = ixName === "buy_exact_quote_in_v2" ? first : second;
|
|
48
|
+
const trade = {
|
|
49
|
+
metadata,
|
|
50
|
+
mint: accounts[1] ?? Z,
|
|
51
|
+
quote_mint: accounts[2] ?? Z,
|
|
52
|
+
global: accounts[0] ?? Z,
|
|
53
|
+
bonding_curve: accounts[10] ?? Z,
|
|
54
|
+
bonding_curve_v2: Z,
|
|
55
|
+
user: accounts[13] ?? Z,
|
|
56
|
+
sol_amount: solAmount,
|
|
57
|
+
token_amount: tokenAmount,
|
|
58
|
+
amount: ixName === "buy_exact_quote_in_v2" ? second : first,
|
|
59
|
+
max_sol_cost: ixName === "buy_exact_quote_in_v2" ? 0n : ixName === "sell_v2" ? 0n : second,
|
|
60
|
+
min_sol_output: ixName === "sell_v2" ? second : 0n,
|
|
61
|
+
spendable_sol_in: 0n,
|
|
62
|
+
spendable_quote_in: ixName === "buy_exact_quote_in_v2" ? first : 0n,
|
|
63
|
+
min_tokens_out: ixName === "buy_exact_quote_in_v2" ? second : 0n,
|
|
64
|
+
quote_amount: ixName === "buy_exact_quote_in_v2" ? first : 0n,
|
|
65
|
+
fee_recipient: accounts[6] ?? Z,
|
|
66
|
+
is_buy: ixName !== "sell_v2",
|
|
67
|
+
is_created_buy: false,
|
|
68
|
+
timestamp: 0n,
|
|
69
|
+
virtual_sol_reserves: 0n,
|
|
70
|
+
virtual_token_reserves: 0n,
|
|
71
|
+
real_sol_reserves: 0n,
|
|
72
|
+
real_token_reserves: 0n,
|
|
73
|
+
fee_basis_points: 0n,
|
|
74
|
+
fee: 0n,
|
|
75
|
+
creator: Z,
|
|
76
|
+
creator_fee_basis_points: 0n,
|
|
77
|
+
creator_fee: 0n,
|
|
78
|
+
track_volume: false,
|
|
79
|
+
total_unclaimed_tokens: 0n,
|
|
80
|
+
total_claimed_tokens: 0n,
|
|
81
|
+
current_sol_volume: 0n,
|
|
82
|
+
last_update_timestamp: 0n,
|
|
83
|
+
ix_name: normalizedIxName,
|
|
84
|
+
mayhem_mode: false,
|
|
85
|
+
cashback_fee_basis_points: 0n,
|
|
86
|
+
cashback: 0n,
|
|
87
|
+
is_cashback_coin: false,
|
|
88
|
+
associated_bonding_curve: accounts[11] ?? Z,
|
|
89
|
+
associated_user: accounts[14] ?? Z,
|
|
90
|
+
system_program: accounts[ixName === "sell_v2" ? 23 : 24] ?? Z,
|
|
91
|
+
token_program: accounts[3] ?? Z,
|
|
92
|
+
quote_token_program: accounts[4] ?? Z,
|
|
93
|
+
associated_token_program: accounts[5] ?? Z,
|
|
94
|
+
creator_vault: accounts[16] ?? Z,
|
|
95
|
+
associated_quote_fee_recipient: accounts[7] ?? Z,
|
|
96
|
+
buyback_fee_recipient: accounts[8] ?? Z,
|
|
97
|
+
associated_quote_buyback_fee_recipient: accounts[9] ?? Z,
|
|
98
|
+
associated_quote_bonding_curve: accounts[12] ?? Z,
|
|
99
|
+
associated_quote_user: accounts[15] ?? Z,
|
|
100
|
+
associated_creator_vault: accounts[17] ?? Z,
|
|
101
|
+
sharing_config: accounts[18] ?? Z,
|
|
102
|
+
event_authority: accounts[ixName === "sell_v2" ? 24 : 25] ?? Z,
|
|
103
|
+
program: accounts[ixName === "sell_v2" ? 25 : 26] ?? Z,
|
|
104
|
+
global_volume_accumulator: ixName === "sell_v2" ? Z : accounts[19] ?? Z,
|
|
105
|
+
user_volume_accumulator: accounts[ixName === "sell_v2" ? 19 : 20] ?? Z,
|
|
106
|
+
associated_user_volume_accumulator: accounts[ixName === "sell_v2" ? 20 : 21] ?? Z,
|
|
107
|
+
fee_config: accounts[ixName === "sell_v2" ? 21 : 22] ?? Z,
|
|
108
|
+
fee_program: accounts[ixName === "sell_v2" ? 22 : 23] ?? Z,
|
|
109
|
+
};
|
|
110
|
+
if (normalizedIxName === "buy")
|
|
111
|
+
return { PumpFunBuy: trade };
|
|
112
|
+
if (normalizedIxName === "sell")
|
|
113
|
+
return { PumpFunSell: trade };
|
|
114
|
+
return { PumpFunBuy: trade };
|
|
115
|
+
}
|
|
116
|
+
function parsePumpfunLegacyBuyInstruction(ixName, data, accounts, metadata) {
|
|
117
|
+
if (accounts.length < 16)
|
|
118
|
+
return null;
|
|
119
|
+
const first = data.length >= 8 ? (0, utils_js_1.readU64LE)(data, 0) ?? 0n : 0n;
|
|
120
|
+
const second = data.length >= 16 ? (0, utils_js_1.readU64LE)(data, 8) ?? 0n : 0n;
|
|
121
|
+
const exactSolIn = ixName === "buy_exact_sol_in";
|
|
122
|
+
const buybackFeeRecipient = accounts[17] ?? Z;
|
|
123
|
+
const trade = {
|
|
124
|
+
metadata,
|
|
125
|
+
mint: accounts[2] ?? Z,
|
|
126
|
+
global: accounts[0] ?? Z,
|
|
127
|
+
bonding_curve: accounts[3] ?? Z,
|
|
128
|
+
bonding_curve_v2: accounts[16] ?? Z,
|
|
129
|
+
associated_bonding_curve: accounts[4] ?? Z,
|
|
130
|
+
associated_user: accounts[5] ?? Z,
|
|
131
|
+
user: accounts[6] ?? Z,
|
|
132
|
+
system_program: accounts[7] ?? Z,
|
|
133
|
+
token_program: accounts[8] ?? Z,
|
|
134
|
+
creator_vault: accounts[9] ?? Z,
|
|
135
|
+
event_authority: accounts[10] ?? Z,
|
|
136
|
+
program: accounts[11] ?? Z,
|
|
137
|
+
global_volume_accumulator: accounts[12] ?? Z,
|
|
138
|
+
user_volume_accumulator: accounts[13] ?? Z,
|
|
139
|
+
fee_config: accounts[14] ?? Z,
|
|
140
|
+
fee_program: accounts[15] ?? Z,
|
|
141
|
+
buyback_fee_recipient: buybackFeeRecipient,
|
|
142
|
+
is_buy: true,
|
|
143
|
+
is_created_buy: false,
|
|
144
|
+
sol_amount: exactSolIn ? first : second,
|
|
145
|
+
token_amount: exactSolIn ? second : first,
|
|
146
|
+
amount: exactSolIn ? second : first,
|
|
147
|
+
max_sol_cost: exactSolIn ? first : second,
|
|
148
|
+
spendable_sol_in: exactSolIn ? first : 0n,
|
|
149
|
+
spendable_quote_in: 0n,
|
|
150
|
+
min_tokens_out: exactSolIn ? second : 0n,
|
|
151
|
+
min_sol_output: 0n,
|
|
152
|
+
quote_amount: 0n,
|
|
153
|
+
fee_recipient: accounts[1] ?? Z,
|
|
154
|
+
timestamp: 0n,
|
|
155
|
+
virtual_sol_reserves: 0n,
|
|
156
|
+
virtual_token_reserves: 0n,
|
|
157
|
+
real_sol_reserves: 0n,
|
|
158
|
+
real_token_reserves: 0n,
|
|
159
|
+
fee_basis_points: 0n,
|
|
160
|
+
fee: 0n,
|
|
161
|
+
creator: Z,
|
|
162
|
+
creator_fee_basis_points: 0n,
|
|
163
|
+
creator_fee: 0n,
|
|
164
|
+
track_volume: (data[16] ?? 0) !== 0,
|
|
165
|
+
total_unclaimed_tokens: 0n,
|
|
166
|
+
total_claimed_tokens: 0n,
|
|
167
|
+
current_sol_volume: 0n,
|
|
168
|
+
last_update_timestamp: 0n,
|
|
169
|
+
ix_name: ixName,
|
|
170
|
+
mayhem_mode: false,
|
|
171
|
+
cashback_fee_basis_points: 0n,
|
|
172
|
+
cashback: 0n,
|
|
173
|
+
is_cashback_coin: false,
|
|
174
|
+
quote_mint: Z,
|
|
175
|
+
quote_token_program: Z,
|
|
176
|
+
associated_token_program: Z,
|
|
177
|
+
associated_quote_fee_recipient: Z,
|
|
178
|
+
associated_quote_buyback_fee_recipient: Z,
|
|
179
|
+
associated_quote_bonding_curve: Z,
|
|
180
|
+
associated_quote_user: Z,
|
|
181
|
+
associated_creator_vault: Z,
|
|
182
|
+
sharing_config: Z,
|
|
183
|
+
associated_user_volume_accumulator: Z,
|
|
184
|
+
...(buybackFeeRecipient !== Z ? { account: buybackFeeRecipient } : {}),
|
|
185
|
+
};
|
|
186
|
+
if (exactSolIn)
|
|
187
|
+
return { PumpFunBuyExactSolIn: trade };
|
|
188
|
+
return { PumpFunBuy: trade };
|
|
189
|
+
}
|
|
190
|
+
function parsePumpfunLegacySellInstruction(data, accounts, metadata) {
|
|
191
|
+
if (accounts.length < 14)
|
|
192
|
+
return null;
|
|
193
|
+
const amount = data.length >= 8 ? (0, utils_js_1.readU64LE)(data, 0) ?? 0n : 0n;
|
|
194
|
+
const minSolOutput = data.length >= 16 ? (0, utils_js_1.readU64LE)(data, 8) ?? 0n : 0n;
|
|
195
|
+
let legacyUserVolumeAccumulator = Z;
|
|
196
|
+
let legacyBondingCurveV2 = accounts[14] ?? Z;
|
|
197
|
+
let legacyBuybackFeeRecipient = Z;
|
|
198
|
+
if (accounts.length >= 17) {
|
|
199
|
+
legacyUserVolumeAccumulator = accounts[14] ?? Z;
|
|
200
|
+
legacyBondingCurveV2 = accounts[15] ?? Z;
|
|
201
|
+
legacyBuybackFeeRecipient = accounts[16] ?? Z;
|
|
202
|
+
}
|
|
203
|
+
else if (accounts.length >= 16) {
|
|
204
|
+
legacyBondingCurveV2 = accounts[14] ?? Z;
|
|
205
|
+
legacyBuybackFeeRecipient = accounts[15] ?? Z;
|
|
206
|
+
}
|
|
207
|
+
const trade = {
|
|
208
|
+
metadata,
|
|
209
|
+
mint: accounts[2] ?? Z,
|
|
210
|
+
quote_mint: Z,
|
|
211
|
+
is_buy: false,
|
|
212
|
+
is_created_buy: false,
|
|
213
|
+
global: accounts[0] ?? Z,
|
|
214
|
+
bonding_curve: accounts[3] ?? Z,
|
|
215
|
+
bonding_curve_v2: legacyBondingCurveV2,
|
|
216
|
+
associated_bonding_curve: accounts[4] ?? Z,
|
|
217
|
+
associated_user: accounts[5] ?? Z,
|
|
218
|
+
user: accounts[6] ?? Z,
|
|
219
|
+
system_program: accounts[7] ?? Z,
|
|
220
|
+
fee_recipient: accounts[1] ?? Z,
|
|
221
|
+
token_program: accounts[9] ?? Z,
|
|
222
|
+
quote_token_program: Z,
|
|
223
|
+
associated_token_program: Z,
|
|
224
|
+
creator_vault: accounts[8] ?? Z,
|
|
225
|
+
associated_quote_fee_recipient: Z,
|
|
226
|
+
buyback_fee_recipient: legacyBuybackFeeRecipient,
|
|
227
|
+
associated_quote_buyback_fee_recipient: Z,
|
|
228
|
+
associated_quote_bonding_curve: Z,
|
|
229
|
+
associated_quote_user: Z,
|
|
230
|
+
associated_creator_vault: Z,
|
|
231
|
+
sharing_config: Z,
|
|
232
|
+
event_authority: accounts[10] ?? Z,
|
|
233
|
+
program: accounts[11] ?? Z,
|
|
234
|
+
global_volume_accumulator: Z,
|
|
235
|
+
user_volume_accumulator: legacyUserVolumeAccumulator,
|
|
236
|
+
associated_user_volume_accumulator: Z,
|
|
237
|
+
fee_config: accounts[12] ?? Z,
|
|
238
|
+
fee_program: accounts[13] ?? Z,
|
|
239
|
+
sol_amount: minSolOutput,
|
|
240
|
+
token_amount: amount,
|
|
241
|
+
amount,
|
|
242
|
+
max_sol_cost: 0n,
|
|
243
|
+
min_sol_output: minSolOutput,
|
|
244
|
+
spendable_sol_in: 0n,
|
|
245
|
+
spendable_quote_in: 0n,
|
|
246
|
+
min_tokens_out: 0n,
|
|
247
|
+
quote_amount: 0n,
|
|
248
|
+
timestamp: 0n,
|
|
249
|
+
virtual_sol_reserves: 0n,
|
|
250
|
+
virtual_token_reserves: 0n,
|
|
251
|
+
real_sol_reserves: 0n,
|
|
252
|
+
real_token_reserves: 0n,
|
|
253
|
+
fee_basis_points: 0n,
|
|
254
|
+
fee: 0n,
|
|
255
|
+
creator: Z,
|
|
256
|
+
creator_fee_basis_points: 0n,
|
|
257
|
+
creator_fee: 0n,
|
|
258
|
+
track_volume: false,
|
|
259
|
+
total_unclaimed_tokens: 0n,
|
|
260
|
+
total_claimed_tokens: 0n,
|
|
261
|
+
current_sol_volume: 0n,
|
|
262
|
+
last_update_timestamp: 0n,
|
|
263
|
+
ix_name: "sell",
|
|
264
|
+
mayhem_mode: false,
|
|
265
|
+
cashback_fee_basis_points: 0n,
|
|
266
|
+
cashback: 0n,
|
|
267
|
+
is_cashback_coin: false,
|
|
268
|
+
...(legacyBuybackFeeRecipient !== Z ? { account: legacyBuybackFeeRecipient } : {}),
|
|
269
|
+
};
|
|
270
|
+
return { PumpFunSell: trade };
|
|
271
|
+
}
|
|
32
272
|
function parsePumpfunInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
|
|
33
273
|
if (instructionData.length < 8)
|
|
34
274
|
return null;
|
|
@@ -51,7 +291,17 @@ function parsePumpfunInstruction(instructionData, accounts, signature, slot, txI
|
|
|
51
291
|
if (!n3)
|
|
52
292
|
return null;
|
|
53
293
|
o = n3.next;
|
|
54
|
-
|
|
294
|
+
if (o + 33 > data.length)
|
|
295
|
+
return null;
|
|
296
|
+
const creator = (0, utils_js_1.readPubkeyIx)(data, o);
|
|
297
|
+
if (!creator)
|
|
298
|
+
return null;
|
|
299
|
+
o += 32;
|
|
300
|
+
const isMayhemMode = (0, utils_js_1.readBool)(data, o);
|
|
301
|
+
if (isMayhemMode === null)
|
|
302
|
+
return null;
|
|
303
|
+
o += 1;
|
|
304
|
+
const isCashbackEnabled = (0, utils_js_1.readBool)(data, o) ?? false;
|
|
55
305
|
const mint = accounts[0];
|
|
56
306
|
const ev = {
|
|
57
307
|
metadata: meta,
|
|
@@ -75,10 +325,31 @@ function parsePumpfunInstruction(instructionData, accounts, signature, slot, txI
|
|
|
75
325
|
mayhem_token_vault: accounts[13] ?? Z,
|
|
76
326
|
event_authority: accounts[14] ?? Z,
|
|
77
327
|
program: accounts[15] ?? Z,
|
|
328
|
+
observed_fee_recipient: Z,
|
|
78
329
|
...createNumericDefaults(),
|
|
330
|
+
is_mayhem_mode: isMayhemMode,
|
|
331
|
+
is_cashback_enabled: isCashbackEnabled,
|
|
79
332
|
};
|
|
80
333
|
return { PumpFunCreateV2: ev };
|
|
81
334
|
}
|
|
335
|
+
if (discEq(outer, DISC.BUY)) {
|
|
336
|
+
return parsePumpfunLegacyBuyInstruction("buy", data, accounts, meta);
|
|
337
|
+
}
|
|
338
|
+
if (discEq(outer, DISC.BUY_EXACT_SOL_IN)) {
|
|
339
|
+
return parsePumpfunLegacyBuyInstruction("buy_exact_sol_in", data, accounts, meta);
|
|
340
|
+
}
|
|
341
|
+
if (discEq(outer, DISC.SELL)) {
|
|
342
|
+
return parsePumpfunLegacySellInstruction(data, accounts, meta);
|
|
343
|
+
}
|
|
344
|
+
if (discEq(outer, DISC.BUY_V2)) {
|
|
345
|
+
return parsePumpfunTradeV2Instruction("buy_v2", data, accounts, meta);
|
|
346
|
+
}
|
|
347
|
+
if (discEq(outer, DISC.BUY_EXACT_QUOTE_IN_V2)) {
|
|
348
|
+
return parsePumpfunTradeV2Instruction("buy_exact_quote_in_v2", data, accounts, meta);
|
|
349
|
+
}
|
|
350
|
+
if (discEq(outer, DISC.SELL_V2)) {
|
|
351
|
+
return parsePumpfunTradeV2Instruction("sell_v2", data, accounts, meta);
|
|
352
|
+
}
|
|
82
353
|
if (discEq(outer, DISC.CREATE)) {
|
|
83
354
|
if (accounts.length < 8)
|
|
84
355
|
return null;
|
|
@@ -5,6 +5,38 @@ const dex_event_js_1 = require("../core/dex_event.js");
|
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
6
|
const ZP = (0, dex_event_js_1.defaultPubkey)();
|
|
7
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
|
+
}
|
|
8
40
|
function disc8(a) {
|
|
9
41
|
return Uint8Array.from(a);
|
|
10
42
|
}
|
|
@@ -50,7 +82,7 @@ function buyLike(data, accounts, meta, swapOrder) {
|
|
|
50
82
|
user_quote_token_account: g(6),
|
|
51
83
|
protocol_fee_recipient: g(9),
|
|
52
84
|
protocol_fee_recipient_token_account: g(10),
|
|
53
|
-
coin_creator:
|
|
85
|
+
coin_creator: Z,
|
|
54
86
|
coin_creator_fee_basis_points: 0n,
|
|
55
87
|
coin_creator_fee: 0n,
|
|
56
88
|
track_volume: false,
|
|
@@ -72,6 +104,7 @@ function buyLike(data, accounts, meta, swapOrder) {
|
|
|
72
104
|
base_token_program: g(11),
|
|
73
105
|
quote_token_program: g(12),
|
|
74
106
|
};
|
|
107
|
+
fillBuyUpgradeAccounts(ev, accounts);
|
|
75
108
|
return ev;
|
|
76
109
|
}
|
|
77
110
|
function parsePumpswapInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs = 0) {
|
|
@@ -119,7 +152,7 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
119
152
|
user_quote_token_account: g(6),
|
|
120
153
|
protocol_fee_recipient: g(9),
|
|
121
154
|
protocol_fee_recipient_token_account: g(10),
|
|
122
|
-
coin_creator:
|
|
155
|
+
coin_creator: Z,
|
|
123
156
|
coin_creator_fee_basis_points: 0n,
|
|
124
157
|
coin_creator_fee: 0n,
|
|
125
158
|
cashback_fee_basis_points: 0n,
|
|
@@ -134,6 +167,7 @@ function parsePumpswapInstruction(instructionData, accounts, signature, slot, tx
|
|
|
134
167
|
base_token_program: g(11),
|
|
135
168
|
quote_token_program: g(12),
|
|
136
169
|
};
|
|
170
|
+
fillSellUpgradeAccounts(ev, accounts);
|
|
137
171
|
return { PumpSwapSell: ev };
|
|
138
172
|
}
|
|
139
173
|
if (discEq(head, PS.CREATE_POOL)) {
|