diff --git a/programs/clobby/src/instructions/place_order.rs b/programs/clobby/src/instructions/place_order.rs index 4f2e05d..edb8a12 100644 --- a/programs/clobby/src/instructions/place_order.rs +++ b/programs/clobby/src/instructions/place_order.rs @@ -8,6 +8,7 @@ const MAX_ORDERS_TO_MATCH:usize = 5; struct EditOrders { pub order_id : u64, pub base_amount_to_set: u64, + pub base_amount_matched: u64, // FIX: Added field to track matched amount pub total_quote_amount: u64 } @@ -104,7 +105,13 @@ pub fn place_order(ctx:Context, args:PlaceOrderArgs) -> Result<()> { } else{ let base_amount_to_set = opposing_order.base_amount - base_amount_eaten; - orders_to_edit.push(EditOrders { order_id: opposing_order.order_id, base_amount_to_set, total_quote_amount}); + // FIX: Store base_amount_eaten for correct event recording + orders_to_edit.push(EditOrders { + order_id: opposing_order.order_id, + base_amount_to_set, + base_amount_matched: base_amount_eaten, // FIX: Track matched amount + total_quote_amount + }); } match taker_side.get_side_in_enum()? { @@ -170,7 +177,8 @@ pub fn place_order(ctx:Context, args:PlaceOrderArgs) -> Result<()> { partial_matched_order.base_amount = order.base_amount_to_set; market_events.add_event(EventParams{ - base_amount: order.base_amount_to_set, + // FIX: Use base_amount_matched (actual matched amount) instead of base_amount_to_set (remaining) + base_amount: order.base_amount_matched, order_id: partial_matched_order.order_id, maker: partial_matched_order.order_authority, quote_amount: order.total_quote_amount, @@ -344,4 +352,4 @@ pub struct PlaceOrderArgs { pub base_lots: u16, // Number of base lots to buy or sell pub quote_amount: u64, pub ioc: bool, // ImmediateOrCancel -} \ No newline at end of file +}