# Bidders' funds may become locked due to inconsistent price order checks in MaxPriorityQueue and the _claimBid function.

Inconsistent rounding between MaxPriorityQueue ordering and _claimBid price check lets a non-winning bid claim base tokens, locking another winner's funds.

- Payout: Contest reward
- Severity: high
- Program: Axis Finance
- Credited: ether_sky
- Disclosed: 2024-03-14
- Write-up quality: 8/10
- Original: https://github.com/sherlock-audit/2024-03-axis-finance-judging/issues/83
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-03-axis-finance%3AH-6
- Tags: domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:high technique:source-review vuln:accounting-error vuln:business-logic vuln:precision-loss

**Target:** EMPAM auction module and MaxPriorityQueue
**Root cause:** MaxPriorityQueue orders bids by cross-multiplied amountIn/minAmountOut, while _claimBid compares mulDivUp(amount, baseScale, minAmountOut) to marginalPrice; rounding can make a bid appear at marginal price despite being ordered after the marginal bid.
**Steps:**
1. Create lot with capacity 10e18 and baseScale such that mulDivUp rounds.
2. Place bid 1: amountIn=4e18+1, minAmountOut=2e18.
3. Place bids 2-6: amountIn=4e18+2, minAmountOut=2e18.
4. Conclude, decrypt, settle; marginalPrice=2e18+1, marginalBidId=6.
5. Call claimBids for bid 1; it succeeds because price==marginalPrice and bidId<=marginalBidId.
6. Call claimBids for bids 2-6; one fails due to insufficient base tokens, leaving quote locked.
**How found:** Noticed that MaxPriorityQueue uses cross-multiplication for ordering while _claimBid uses rounded division for price comparison; hypothesized rounding could cause a bid to be considered at marginal price but ordered after the marginal bid.
**Exploitation:** An early bidder with a slightly lower amountIn but same minAmountOut can claim base tokens despite not being a winner, consuming base tokens and preventing a legitimate winner from claiming; the loser's quote tokens remain locked in the auction house.
**Insight:** When a priority queue orders by ratio and a separate check compares rounded ratios, rounding can create a mismatch; test with amounts that produce different rounded quotients for the same ratio.
