DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

The `willPositionCollateralBeSufficient` function uses incorrect parameter

Summary

The willPositionCollateralBeSufficient function uses incorrect parameter.

Vulnerability Details

contracts/libraries/gmx/MarketUtils.sol#L31

The willPositionCollateralBeSufficient function uses prices.shortTokenPrice as collateralTokenPrice. It should actually be prices.indexTokenPrice.

function willPositionCollateralBeSufficient(
IDataStore dataStore,
MarketProps memory market,
MarketPrices memory prices,
bool isLong,
WillPositionCollateralBeSufficientValues memory values
) external view returns (bool, int256) {
PriceProps memory collateralTokenPrice = prices.shortTokenPrice; // @audit shortTokenPrice -> indexTokenPrice
int256 remainingCollateralUsd = values.positionCollateralAmount.toInt256() * collateralTokenPrice.min.toInt256();
...
}

Impact

Errors in calculating the willPositionCollateralBeSufficient function return value may cause the user to read the wrong position status during the position reduction operation, which may result in asset losses for the user.

Tools Used

Recommendations


Recommended fix:

function willPositionCollateralBeSufficient(
IDataStore dataStore,
MarketProps memory market,
MarketPrices memory prices,
bool isLong,
WillPositionCollateralBeSufficientValues memory values
) external view returns (bool, int256) {
PriceProps memory collateralTokenPrice = prices.indexTokenPrice;
int256 remainingCollateralUsd = values.positionCollateralAmount.toInt256() * collateralTokenPrice.min.toInt256();
...
}
Updates

Lead Judging Commences

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality
Assigned finding tags:

Suppositions

There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.