Trade Log
Instruction data (ABI)
pub struct TradeLogData {
pub pool: Pubkey,
pub trader: Pubkey,
pub base_mint: Pubkey,
pub quote_mint: Pubkey,
/// Quote in (e.g., lamports or WSOL base units) charged by the pool for this trade
pub base_amount: u64,
/// Base tokens sent out to the trader (raw units)
pub quote_amount: u64,
/// Fees (quote units unless otherwise documented)
pub creator_fee: u64,
pub protocol_fee: u64,
pub lp_fee: u64,
/// true = buy, false = sell
pub is_buy: bool,
/// Balances around trade (pool vault balances, not "virtual" unless stated)
pub base_balance_after: u64,
pub quote_balance_after: u64,
pub base_balance_before: u64,
pub quote_balance_before: u64,
/// Unix timestamp (seconds)
pub timestamp: i64,
}
Where to find it (indexer checklist)
Locate parent ix: a
buy
orsell
Scan inner instructions for the same program id.
Match discriminator: first 8 bytes of
data
equalsha256("log_trade_internal")[:8]
.Accounts: first account must be the
event_authority
PDA (["event_authority"]
) and appear as a signer on the inner ix.Decode the remaining
data[8..]
as BorshTradeLogData
.
Suggested validations (indexer)
Asset sanity: Verify
(base_mint, quote_mint)
match the pool you track.Delta check:
Compute
Δbase = after_base − before_base
andΔquote = after_quote − before_quote
.For
is_buy = true
, expectΔquote > 0
into pool andΔbase < 0
from pool.
Fee conservation:
creator_fee + protocol_fee + lp_fee
should equal total fees implied by your fee schedule and amounts.Monotonic time:
timestamp
should not go backwards for the same pool.
Last updated