# Collateral cannot be claimed due to inverted comparison condition

Inverted comparison in GMX MarketUtils.claimCollateral blocks all collateral claims, causing permanent principal loss for users owed capped-price-impact refunds.

- Payout: Contest reward
- Severity: high
- Program: Gmx
- Credited: IllIllI
- Disclosed: 2022-09-22
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-02-gmx-judging/issues/136
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-02-gmx%3AH-11
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:business-logic

**Target:** Solidity smart contract (MarketUtils.claimCollateral)
**Root cause:** The guard `if (adjustedClaimableAmount >= claimedAmount) revert` is inverted; it should revert when claimable <= claimed, but instead reverts whenever any amount is claimable, so claims always fail.
**Steps:**
1. Call `MarketUtils.claimCollateral()` for a market/token/timeKey/account with a nonzero claimable amount.
2. Observe `adjustedClaimableAmount >= claimedAmount` (claimedAmount starts at 0) triggers `CollateralAlreadyClaimed` revert.
3. User can never claim; fix flips operator to `<=`.
**How found:** Code review of the claimCollateral guard comparing adjustedClaimableAmount against claimedAmount; noticed the comparison direction contradicts the intended 'already claimed' semantics.
**Insight:** When auditing claim/withdraw guards, check the direction of the comparison against the revert's meaning: a 'already claimed' check should revert when claimed >= claimable, not the reverse.
