Skip to content

Commit

Permalink
fix bug in close
Browse files Browse the repository at this point in the history
  • Loading branch information
caglavol committed Jan 30, 2024
1 parent e5327ce commit cea6fbe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contracts/src/market/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,13 @@ pub mod market {
.checked_div(100)
.ok_or(MarketError::Overflow(String::from("close_4")))?;

let rest_collateral_usd: u128 = position
.collateral_usd
.checked_add(pnl_usd as u128)
let rest_collateral_usd: i128 = (position
.collateral_usd as i128)
.checked_add(pnl_usd)
.ok_or(MarketError::Overflow(String::from("close_5")))?;

let rest_collateral_amount = self.calculate_asset_amount_from_usd(
rest_collateral_usd,
rest_collateral_usd as u128,
collateral_price,
collateral_asset_decimals,
)?;
Expand Down

0 comments on commit cea6fbe

Please sign in to comment.