# Auctions succeeding condition does not take into account the claimable fees in the pool. It can result of a drastical reduction of claimable fees if auction succeeds, or cause an auction to fail if the fees are claimed

Auction success check ignores claimable pool fees, so ending an auction slashes beneficiary fees or claiming fees first makes a near-limit auction fail.

- Payout: Audit contest
- Severity: medium
- Program: Plaza Finance
- Found by: 0xadrii
- Disclosed: 2024-12-16
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/891
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-plaza-finance%3AM-15
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Auction.sol endAuction pool sale limit vs Pool claimable fees
**Root cause:** The auction success condition compares total reserveToken bid against poolSaleLimit% of the pool's reserveToken balance without accounting for fees claimable by the beneficiary, which are derived from that same balance.
**Steps:**
1. Set poolSaleLimit to 90% and fee to 10% via `Pool.setFee(100000)`
2. Bid `maxReserveTokenClaimable/2` reserveToken worth of USDC, warp to endTime
3. Record `Pool.getFeeAmount()` before, call `auction.endAuction()`, observe state SUCCEEDED and fees drop
4. Second test: bid `maxReserveTokenClaimable - 10`, call `Pool.claimFees()` as governance, then `endAuction()` returns FAILED_POOL_SALE_LIMIT
**How found:** Reading the endAuction sale-limit check and noticing the pool balance it references also backs claimable fees, then testing both orderings (end-then-claim vs claim-then-end).
**Exploitation:** No attacker profit path; a beneficiary claiming fees before endAuction, or a successful auction draining reserveToken, shifts the pool balance so the 90% limit check no longer matches, causing fee reduction or auction failure.
**Insight:** When a limit check reads a live balance that also backs accrued fees or other liabilities, test both orderings of claim vs settle; the check can pass or fail depending on who moves funds first.

## Proof of concept (copied exactly from the original report)

**Test showing auction success reduces claimable fees**

```
function test_auction_fees_1() public {
        // We need to set the poolSaleLimit to 90% because it is set to 110% in the setUp
        uint256 poolSaleLimitSlot = 6;
        vm.store(address(auction), bytes32(poolSaleLimitSlot), bytes32(uint256(90)));
        console.log(auction.poolSaleLimit());

        // Set the fees at 10%
        vm.prank(governance);
        Pool(pool).setFee(100000);

        uint256 maxUSDCToBid = auction.totalBuyCouponAmount();
        // If we go beyond this value, endAuction will end in a failed state (FAILED_POOL_SALE_LIMIT)
        uint256 maxReserveTokenClaimable =
            (IERC20(auction.sellReserveToken()).balanceOf(pool) * auction.poolSaleLimit()) / 100;

        // 1. The auction can succeed, and will rewards users for half of the pool's claimable amount
        vm.startPrank(bidder);

        usdc.mint(bidder, maxUSDCToBid);
        usdc.approve(address(auction), maxUSDCToBid);

        auction.bid(maxReserveTokenClaimable / 2, maxUSDCToBid);

        vm.stopPrank();

        vm.warp(auction.endTime());

        // 2. Amount of fees claimable are equal to X
        // Set `getFeeAmount` to public to see its result value
        uint256 claimableFeesBefore = Pool(pool).getFeeAmount();
        console.log("claimableFeesBefore", claimableFeesBefore);

        // 3. `endAuction` put the auction in the succeed state
        auction.endAuction();
        assert(Auction.State.SUCCEEDED == auction.state());

        // 4. The amount of fees claimable are now lower than X
        uint256 claimableFeesAfter = Pool(pool).getFeeAmount();
        console.log("claimableFeesAfter ", claimableFeesAfter);

        assert(claimableFeesBefore > claimableFeesAfter);
    }
```

**Test showing claimed fees cause auction failure**

```
function test_auction_fees_2() public {
        // We need to set the poolSaleLimit to 90% because it is set to 110% in the setUp
        uint256 poolSaleLimitSlot = 6;
        vm.store(address(auction), bytes32(poolSaleLimitSlot), bytes32(uint256(90)));
        console.log(auction.poolSaleLimit());

        // Set the fees at 10%
        vm.startPrank(governance);
        Pool(pool).setFee(100000);
        Pool(pool).setFeeBeneficiary(governance);
        vm.stopPrank();

        uint256 maxUSDCToBid = auction.totalBuyCouponAmount();
        // If we go beyond this value, endAuction will end in a failed state (FAILED_POOL_SALE_LIMIT)
        uint256 maxReserveTokenClaimable = (IERC20(auction.sellReserveToken()).balanceOf(pool) * auction.poolSaleLimit()) / 100;

        // 1. The auction can succeed, and will rewards users for almost the pool's claimable amount
        vm.startPrank(bidder);

        usdc.mint(bidder, maxUSDCToBid);
        usdc.approve(address(auction), maxUSDCToBid);

        auction.bid(maxReserveTokenClaimable - 10, maxUSDCToBid);

        vm.stopPrank();

        vm.warp(auction.endTime());

        // 2. The fees are claimed
        vm.prank(governance);
        Pool(pool).claimFees();

        // 3. Ending the auction fails it
        auction.endAuction();
        assert(Auction.State.FAILED_POOL_SALE_LIMIT == auction.state());

        // Note that without the governance claiming fees, the auction would succeed
    }
```

