Skip to content

Commit

Permalink
arb perp: check base unchanged
Browse files Browse the repository at this point in the history
check base unchanged
  • Loading branch information
crispheaney authored Nov 10, 2023
2 parents 1ee266d + 4dcebd4 commit c297803
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions programs/jit-proxy/src/instructions/arb_perp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub fn arb_perp<'info>(

let taker = ctx.accounts.user.load()?;

let quote_init = taker
let (base_init, quote_init) = taker
.get_perp_position(market_index)
.map_or(0, |p| p.quote_asset_amount);
.map_or((0, 0), |p| (p.base_asset_amount, p.quote_asset_amount));

let remaining_accounts_iter = &mut ctx.remaining_accounts.iter().peekable();
let AccountMaps {
Expand Down Expand Up @@ -90,11 +90,11 @@ pub fn arb_perp<'info>(
place_and_take(&ctx, order_params)?;

let taker = ctx.accounts.user.load()?;
let quote_end = taker
let (base_end, quote_end) = taker
.get_perp_position(market_index)
.map_or(0, |p| p.quote_asset_amount);
.map_or((0, 0), |p| (p.base_asset_amount, p.quote_asset_amount));

if quote_end <= quote_init {
if base_end != base_init || quote_end <= quote_init {
return Err(ErrorCode::NoArbOpportunity.into());
}

Expand Down

0 comments on commit c297803

Please sign in to comment.