mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-22 13:28:08 +00:00
Merge branch '0xfnzero:main' into main
This commit is contained in:
@@ -31,6 +31,9 @@ pub fn merge(instruction_event: &mut DexEvent, cpi_log_event: DexEvent) {
|
|||||||
e.cashback_fee_basis_points = cpie.cashback_fee_basis_points;
|
e.cashback_fee_basis_points = cpie.cashback_fee_basis_points;
|
||||||
e.cashback = cpie.cashback;
|
e.cashback = cpie.cashback;
|
||||||
e.is_cashback_coin = cpie.is_cashback_coin;
|
e.is_cashback_coin = cpie.is_cashback_coin;
|
||||||
|
if cpie.account.is_some() {
|
||||||
|
e.account = cpie.account;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -295,6 +295,9 @@ pub struct PumpFunTradeEvent {
|
|||||||
pub fee_config: Pubkey,
|
pub fee_config: Pubkey,
|
||||||
#[borsh(skip)]
|
#[borsh(skip)]
|
||||||
pub fee_program: Pubkey,
|
pub fee_program: Pubkey,
|
||||||
|
/// 17th instruction account (index 16), shown as "Account" on block explorers; present on some buy/sell.
|
||||||
|
#[borsh(skip)]
|
||||||
|
pub account: Option<Pubkey>,
|
||||||
|
|
||||||
// === IDL TradeEvent extension fields (aligned with sol-parser-sdk / pumpfun IDL) ===
|
// === IDL TradeEvent extension fields (aligned with sol-parser-sdk / pumpfun IDL) ===
|
||||||
#[borsh(skip)]
|
#[borsh(skip)]
|
||||||
|
|||||||
@@ -268,12 +268,12 @@ fn parse_create_v2_token_instruction(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 解析买入指令事件
|
/// Parse buy instruction event.
|
||||||
/// Buy 指令共 16 个固定账户(与 idl/pumpfun.json 一致):
|
/// Buy has 16 fixed accounts + optional 17th (index 16, "Account" on block explorers):
|
||||||
/// 0: global, 1: fee_recipient, 2: mint, 3: bonding_curve, 4: associated_bonding_curve,
|
/// 0: global, 1: fee_recipient, 2: mint, 3: bonding_curve, 4: associated_bonding_curve,
|
||||||
/// 5: associated_user, 6: user, 7: system_program, 8: token_program, 9: creator_vault,
|
/// 5: associated_user, 6: user, 7: system_program, 8: token_program, 9: creator_vault,
|
||||||
/// 10: event_authority, 11: program, 12: global_volume_accumulator, 13: user_volume_accumulator,
|
/// 10: event_authority, 11: program, 12: global_volume_accumulator, 13: user_volume_accumulator,
|
||||||
/// 14: fee_config, 15: fee_program.
|
/// 14: fee_config, 15: fee_program, 16 (optional): account.
|
||||||
fn parse_buy_instruction(
|
fn parse_buy_instruction(
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
accounts: &[Pubkey],
|
accounts: &[Pubkey],
|
||||||
@@ -304,6 +304,7 @@ fn parse_buy_instruction(
|
|||||||
user_volume_accumulator: accounts[13],
|
user_volume_accumulator: accounts[13],
|
||||||
fee_config: accounts[14],
|
fee_config: accounts[14],
|
||||||
fee_program: accounts[15],
|
fee_program: accounts[15],
|
||||||
|
account: accounts.get(16).copied(),
|
||||||
max_sol_cost,
|
max_sol_cost,
|
||||||
amount,
|
amount,
|
||||||
is_buy: true,
|
is_buy: true,
|
||||||
@@ -311,12 +312,9 @@ fn parse_buy_instruction(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 解析 buy_exact_sol_in 指令事件
|
/// Parse buy_exact_sol_in instruction event.
|
||||||
/// 账户布局与 buy 相同,共 16 个固定账户: 0: global, 1: fee_recipient, 2: mint, 3: bonding_curve,
|
/// Same account layout as buy: 16 fixed + optional 17th (index 16).
|
||||||
/// 4: associated_bonding_curve, 5: associated_user, 6: user, 7: system_program, 8: token_program,
|
/// Args: spendable_sol_in (SOL), min_tokens_out (token).
|
||||||
/// 9: creator_vault, 10: event_authority, 11: program, 12: global_volume_accumulator,
|
|
||||||
/// 13: user_volume_accumulator, 14: fee_config, 15: fee_program.
|
|
||||||
/// 参数顺序与 buy 不同: spendable_sol_in (SOL), min_tokens_out (token).
|
|
||||||
fn parse_buy_exact_sol_in_instruction(
|
fn parse_buy_exact_sol_in_instruction(
|
||||||
data: &[u8], accounts: &[Pubkey],
|
data: &[u8], accounts: &[Pubkey],
|
||||||
mut metadata: EventMetadata,
|
mut metadata: EventMetadata,
|
||||||
@@ -327,7 +325,6 @@ fn parse_buy_exact_sol_in_instruction(
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:buy_exact_sol_in 的参数顺序是先 SOL 再 token
|
|
||||||
let spendable_sol_in = u64::from_le_bytes(data[0..8].try_into().unwrap());
|
let spendable_sol_in = u64::from_le_bytes(data[0..8].try_into().unwrap());
|
||||||
let min_tokens_out = u64::from_le_bytes(data[8..16].try_into().unwrap());
|
let min_tokens_out = u64::from_le_bytes(data[8..16].try_into().unwrap());
|
||||||
|
|
||||||
@@ -349,19 +346,16 @@ fn parse_buy_exact_sol_in_instruction(
|
|||||||
user_volume_accumulator: accounts[13],
|
user_volume_accumulator: accounts[13],
|
||||||
fee_config: accounts[14],
|
fee_config: accounts[14],
|
||||||
fee_program: accounts[15],
|
fee_program: accounts[15],
|
||||||
max_sol_cost: spendable_sol_in, // Map spendable_sol_in to max_sol_cost
|
account: accounts.get(16).copied(),
|
||||||
amount: min_tokens_out, // Map min_tokens_out to amount
|
max_sol_cost: spendable_sol_in,
|
||||||
|
amount: min_tokens_out,
|
||||||
is_buy: true,
|
is_buy: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 解析卖出指令事件
|
/// Parse sell instruction event.
|
||||||
/// Sell 指令共 14 个固定账户(与 idl/pumpfun.json 一致):
|
/// Sell has 14 fixed accounts; some versions pass 17 accounts, index 16 = "Account" on block explorers.
|
||||||
/// 0: global, 1: fee_recipient, 2: mint, 3: bonding_curve, 4: associated_bonding_curve,
|
|
||||||
/// 5: associated_user, 6: user, 7: system_program, 8: creator_vault, 9: token_program,
|
|
||||||
/// 10: event_authority, 11: program, 12: fee_config, 13: fee_program.
|
|
||||||
/// remaining_accounts 可能含 user_volume_accumulator(返现)等。
|
|
||||||
fn parse_sell_instruction(
|
fn parse_sell_instruction(
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
accounts: &[Pubkey],
|
accounts: &[Pubkey],
|
||||||
@@ -392,6 +386,7 @@ fn parse_sell_instruction(
|
|||||||
user_volume_accumulator: Pubkey::default(),
|
user_volume_accumulator: Pubkey::default(),
|
||||||
fee_config: accounts[12],
|
fee_config: accounts[12],
|
||||||
fee_program: accounts[13],
|
fee_program: accounts[13],
|
||||||
|
account: accounts.get(16).copied(),
|
||||||
min_sol_output,
|
min_sol_output,
|
||||||
amount,
|
amount,
|
||||||
is_buy: false,
|
is_buy: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user