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

Wrong event emission

Summary

In the Runaction function the contract returns the usd amount of a position during emission instead of the token amount of the size.

Vulnerability Details

Wrong event emission

event GmxPositionUpdated(
bytes32 positionKey,
address market,
bool isOpen,
bool isLong,
@audit>> uint256 sizeInTokens,
uint256 indexTokenPrice
);

But we incorrect return the usd value of this size

if (flow == FLOW.SIGNAL_CHANGE) {
emit GmxPositionUpdated(
positionKey,
market,
orderResultData.orderType == Order.OrderType.MarketIncrease,
orderResultData.isLong,
@audit>> orderResultData.sizeDeltaUsd, // BUG LOW
prices.indexTokenPrice.min
);

Usd valuation is different from the token value

see

function afterLiquidationExecution() external {
if (msg.sender != address(gmxProxy)) {
revert Error.InvalidCall();
}
depositPaused = true;
@audit>> uint256 sizeInTokens = vaultReader.getPositionSizeInTokens(curPositionKey);
if (sizeInTokens == 0) {
delete curPositionKey;
}
if (flow == FLOW.DEPOSIT) {
uint256 amount = depositInfo[counter].amount;
uint256 feeAmount = vaultReader.getPositionFeeUsd(market, orderResultData.sizeDeltaUsd, false) / prices.shortTokenPrice.min; // fee is removed twice why
@audit>> uint256 prevSizeInTokens = flowData;
@audit>> int256 priceImpact = vaultReader.getPriceImpactInCollateral(curPositionKey, orderResultData.sizeDeltaUsd, prevSizeInTokens, prices);
uint256 increased;
struct OrderResultData {
Order.OrderType orderType;
bool isLong;
uint256 sizeDeltaUsd;
address outputToken;
uint256 outputAmount;
bool isSettle;
}

Impact

Wrong event emission token uint expected, usd returned.

Tools Used

Manual Review

Recommendations

Return and emit the size of the token not usd size.

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!