Skip to content

Commit

Permalink
account for no taker limit price
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Jan 23, 2024
1 parent 300d826 commit 7a85ff4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion programs/jit-proxy/src/instructions/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,23 @@ pub fn jit<'info>(ctx: Context<'_, '_, '_, 'info, Jit<'info>>, params: JitParams
};

let taker_price =
taker_order.force_get_limit_price(Some(oracle_price), None, slot, tick_size)?;
match taker_order.get_limit_price(Some(oracle_price), None, slot, tick_size)? {
Some(price) => price,
None if market_type == DriftMarketType::Perp => {
// if the order doesn't have a price, drift users amm price for taker price
let perp_market = perp_market_map.get_ref(&market_index)?;
let reserve_price = perp_market.amm.reserve_price()?;
match taker_direction {
PositionDirection::Long => perp_market.amm.ask_price(reserve_price)?,
PositionDirection::Short => perp_market.amm.bid_price(reserve_price)?,
}
}
None => {
// Shouldnt be possible for spot
msg!("taker order didnt have price");
return Err(ErrorCode::TakerOrderNotFound.into());
}
};

let maker_direction = taker_direction.opposite();
let maker_worst_price = params.get_worst_price(oracle_price, taker_direction)?;
Expand Down

0 comments on commit 7a85ff4

Please sign in to comment.