-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Context
Some DEX protocols (e.g., Boop, Raydium) emit actual trade results as events/logs rather than storing them in instruction data. To properly parse these swaps, we need to correlate the instruction with its corresponding event logs.
Problem
Currently there's no straightforward way to:
- Know which logs belong to which instruction
- Match an instruction with its emitted events before sending to handler
Proposed Solution
Add log assignment to InstructionUpdate:
pub struct InstructionUpdate {
// ... existing fields
/// Indices into `shared.log_messages` for logs emitted by this instruction
pub log_indices: Vec<usize>,
}Use Case Example
async fn handle(&self, ix: &SwapInstruction, input: &InstructionUpdate) -> HandlerResult<()> {
// Get logs belonging to this specific instruction
let logs: Vec<&str> = input.log_indices
.iter()
.filter_map(|&i| input.shared.log_messages.get(i))
.collect();
// Parse event from logs (e.g., PumpFun TradeEvent)
let trade_event = parse_trade_event_from_logs(&logs)?;
// Now we have both instruction data AND event data
let swap = Swap {
amount_in: trade_event.sol_amount,
amount_out: trade_event.token_amount,
// ...
};
}Notes
This is similar to how ix_path (PR #180) tracks instruction hierarchy, but for log assignment instead. The mapping can be derived from log messages like "Program XXX invoke [N]" and "Program XXX success".
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels