Skip to content

Commit

Permalink
add burn cost to position_delta/pnl
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbigz committed Jan 10, 2024
1 parent bd9f363 commit 9806a3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions programs/drift/src/controller/lp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ pub fn burn_lp_shares(
oracle_price: i64,
) -> DriftResult<(PositionDelta, i64)> {
// settle
let (position_delta, pnl) = settle_lp_position(position, market)?;
let (mut position_delta, mut pnl) = settle_lp_position(position, market)?;

// clean up
let unsettled_remainder = market
Expand Down Expand Up @@ -328,7 +328,12 @@ pub fn burn_lp_shares(
"perp {} remainder_base_asset_amount burn fee= {}",
position.market_index,
dust_base_asset_value
)
);

position_delta.quote_asset_amount = position_delta
.quote_asset_amount
.safe_sub(dust_base_asset_value.cast()?)?;
pnl = pnl.safe_sub(dust_base_asset_value.cast()?)?;
}

// update last_ metrics
Expand Down

0 comments on commit 9806a3b

Please sign in to comment.