From cf1191883f3a5835863f9e9aad1504dfec847128 Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Wed, 24 Jan 2024 21:41:48 -0500 Subject: [PATCH 1/3] program: improved logging --- programs/jit-proxy/src/instructions/jit.rs | 52 +++++++++++++++------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/programs/jit-proxy/src/instructions/jit.rs b/programs/jit-proxy/src/instructions/jit.rs index da04a23f..73f6db3e 100644 --- a/programs/jit-proxy/src/instructions/jit.rs +++ b/programs/jit-proxy/src/instructions/jit.rs @@ -29,12 +29,11 @@ pub fn jit<'info>(ctx: Context<'_, '_, '_, 'info, Jit<'info>>, params: JitParams let market_index = taker_order.market_index; let taker_direction = taker_order.direction; - let slots_left = slot.cast::()?.safe_sub( - taker_order - .slot - .safe_add(taker_order.auction_duration.cast()?)? - .cast()?, - )?; + let slots_left = taker_order + .slot + .safe_add(taker_order.auction_duration.cast()?)? + .cast::()? + .safe_sub(slot.cast()?)?; msg!( "slot = {} auction duration = {} slots_left = {}", slot, @@ -42,13 +41,23 @@ pub fn jit<'info>(ctx: Context<'_, '_, '_, 'info, Jit<'info>>, params: JitParams slots_left ); - msg!( - "order type {:?} auction start {} auction end {} limit price {}", - taker_order.order_type, - taker_order.auction_start_price, - taker_order.auction_end_price, - taker_order.price - ); + if taker_order.order_type == OrderType::Oracle { + msg!( + "order type {:?} auction start {} auction end {} oracle price offset {}", + taker_order.order_type, + taker_order.auction_start_price, + taker_order.auction_end_price, + taker_order.oracle_price_offset + ); + } else { + msg!( + "order type {:?} auction start {} auction end {} limit price {}", + taker_order.order_type, + taker_order.auction_start_price, + taker_order.auction_end_price, + taker_order.price + ); + } let remaining_accounts_iter = &mut ctx.remaining_accounts.iter().peekable(); let AccountMaps { @@ -175,7 +184,7 @@ pub fn jit<'info>(ctx: Context<'_, '_, '_, 'info, Jit<'info>>, params: JitParams reduce_only: false, post_only: params .post_only - .unwrap_or(PostOnlyParam::Slide) + .unwrap_or(PostOnlyParam::MustPostOnly) .to_drift_param(), immediate_or_cancel: true, max_ts: None, @@ -201,13 +210,22 @@ pub fn jit<'info>(ctx: Context<'_, '_, '_, 'info, Jit<'info>>, params: JitParams if taker_base_asset_amount_unfilled_after == taker_base_asset_amount_unfilled { // taker order failed to fill - msg!("taker order failed to fill"); msg!( - "taker price = {} maker price = {} oracle price = {}", + "taker price = {} oracle price = {}", taker_price, - maker_price, oracle_price ); + msg!("jit params {:?}", params); + if market_type == DriftMarketType::Perp { + let perp_market = perp_market_map.get_ref(&market_index)?; + let reserve_price = perp_market.amm.reserve_price()?; + let (bid_price, ask_price) = perp_market.amm.bid_ask_price(reserve_price)?; + msg!( + "vamm bid price = {} vamm ask price = {}", + bid_price, + ask_price + ); + } return Err(ErrorCode::NoFill.into()); } From df90f30d6ad2a7d27baa01577aa9bffd1bb2285a Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Thu, 25 Jan 2024 18:22:32 -0500 Subject: [PATCH 2/3] tweak logs --- programs/jit-proxy/src/instructions/jit.rs | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/programs/jit-proxy/src/instructions/jit.rs b/programs/jit-proxy/src/instructions/jit.rs index 73f6db3e..60257d08 100644 --- a/programs/jit-proxy/src/instructions/jit.rs +++ b/programs/jit-proxy/src/instructions/jit.rs @@ -41,23 +41,14 @@ pub fn jit<'info>(ctx: Context<'_, '_, '_, 'info, Jit<'info>>, params: JitParams slots_left ); - if taker_order.order_type == OrderType::Oracle { - msg!( - "order type {:?} auction start {} auction end {} oracle price offset {}", - taker_order.order_type, - taker_order.auction_start_price, - taker_order.auction_end_price, - taker_order.oracle_price_offset - ); - } else { - msg!( - "order type {:?} auction start {} auction end {} limit price {}", - taker_order.order_type, - taker_order.auction_start_price, - taker_order.auction_end_price, - taker_order.price - ); - } + msg!( + "order type {:?} auction start {} auction end {} limit price {} oracle price offset {}", + taker_order.order_type, + taker_order.auction_start_price, + taker_order.auction_end_price, + taker_order.price, + taker_order.oracle_price_offset + ); let remaining_accounts_iter = &mut ctx.remaining_accounts.iter().peekable(); let AccountMaps { From a4815bb83ddabe76bf112874f657413e18ce07c2 Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Thu, 25 Jan 2024 19:38:05 -0500 Subject: [PATCH 3/3] make taker log explicit --- programs/jit-proxy/src/instructions/jit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/jit-proxy/src/instructions/jit.rs b/programs/jit-proxy/src/instructions/jit.rs index 60257d08..7052b495 100644 --- a/programs/jit-proxy/src/instructions/jit.rs +++ b/programs/jit-proxy/src/instructions/jit.rs @@ -42,7 +42,7 @@ pub fn jit<'info>(ctx: Context<'_, '_, '_, 'info, Jit<'info>>, params: JitParams ); msg!( - "order type {:?} auction start {} auction end {} limit price {} oracle price offset {}", + "taker order type {:?} auction start {} auction end {} limit price {} oracle price offset {}", taker_order.order_type, taker_order.auction_start_price, taker_order.auction_end_price,