diff --git a/programs/openbook-v2/src/logs.rs b/programs/openbook-v2/src/logs.rs index 24c0ad732..f8c9be1dd 100644 --- a/programs/openbook-v2/src/logs.rs +++ b/programs/openbook-v2/src/logs.rs @@ -20,14 +20,14 @@ pub struct FillLog { pub maker: Pubkey, pub maker_client_order_id: u64, - pub maker_fee: i64, + pub maker_fee: u64, // native quote // Timestamp of when the maker order was placed; copied over from the LeafNode pub maker_timestamp: u64, pub taker: Pubkey, pub taker_client_order_id: u64, - pub taker_fee: i64, + pub taker_fee: u64, // native quote pub price: i64, pub quantity: i64, // number of base lots diff --git a/programs/openbook-v2/src/state/open_orders_account.rs b/programs/openbook-v2/src/state/open_orders_account.rs index 66a8d0767..88bc49934 100644 --- a/programs/openbook-v2/src/state/open_orders_account.rs +++ b/programs/openbook-v2/src/state/open_orders_account.rs @@ -187,6 +187,13 @@ impl OpenOrdersAccount { } } + // calculate taker fee for logging, ignoring self trades + let taker_fees = if quote_native > 0 && fill.maker != fill.taker { + market.taker_fees_ceil(quote_native) + } else { + 0 + }; + emit!(FillLog { market: self.market, taker_side: fill.taker_side, @@ -196,11 +203,11 @@ impl OpenOrdersAccount { seq_num: fill.seq_num, maker: fill.maker, maker_client_order_id: fill.maker_client_order_id, - maker_fee: market.maker_fee, + maker_fee: maker_fees, maker_timestamp: fill.maker_timestamp, taker: fill.taker, taker_client_order_id: fill.taker_client_order_id, - taker_fee: market.taker_fee, + taker_fee: taker_fees, price: fill.price, quantity: fill.quantity, });