Skip to content

Commit

Permalink
bigz/end-swap-taker-volume-calc (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbigz authored Dec 19, 2023
1 parent 71f86f6 commit 31fc415
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions programs/drift/src/instructions/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2748,13 +2748,15 @@ pub fn handle_end_swap(
user.update_cumulative_spot_fees(-fee_value.cast()?)?;
user_stats.increment_total_fees(fee_value.cast()?)?;

// update taker volume
let amount_out_value = get_token_value(
amount_out.cast()?,
out_spot_market.decimals,
out_oracle_price,
)?;
user_stats.update_taker_volume_30d(amount_out_value.cast()?, now)?;
if fee != 0 {
// update taker volume
let amount_out_value = get_token_value(
amount_out.cast()?,
out_spot_market.decimals,
out_oracle_price,
)?;
user_stats.update_taker_volume_30d(amount_out_value.cast()?, now)?;
}

validate!(
amount_out != 0,
Expand Down

0 comments on commit 31fc415

Please sign in to comment.