Skip to content

Commit

Permalink
fix calculation of estimatedRemainingCollateralUsd
Browse files Browse the repository at this point in the history
  • Loading branch information
xdev10 committed May 3, 2023
1 parent ac2b1dc commit f8f2dd6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contracts/position/DecreasePositionUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ library DecreasePositionUtils {
// the estimatedRemainingCollateralUsd subtracts the initialCollateralDeltaAmount
// since the initialCollateralDeltaAmount will be set to zero, the initialCollateralDeltaAmount
// should be added back to the estimatedRemainingCollateralUsd
estimatedRemainingCollateralUsd += params.order.initialCollateralDeltaAmount().toInt256();
Price.Props memory collateralTokenPrice = MarketUtils.getCachedTokenPrice(
params.position.collateralToken(),
params.market,
cache.prices
);
estimatedRemainingCollateralUsd += (params.order.initialCollateralDeltaAmount() * collateralTokenPrice.min).toInt256();
params.order.setInitialCollateralDeltaAmount(0);
}

Expand Down

0 comments on commit f8f2dd6

Please sign in to comment.