58742 sc high liquidators will not earn fees in some cases

Submitted on Nov 4th 2025 at 11:10:34 UTC by @Lion47624 for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #58742

  • Report Type: Smart Contract

  • Report severity: High

  • Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/AlchemistV3.sol

  • Impacts:

    • Permanent freezing of unclaimed yield

Description

Brief/Intro

A logical flaw exists within the _doLiquidation function in the AlchemistV3.sol contract. The check to determine if a liquidator's fee can be paid is incorrectly performed against the liquidated user's remaining collateral after the seized collateral has already been deducted. In scenarios where a liquidation leaves the user with little or no collateral, this check fails, preventing the liquidator from receiving their rightful fee and potentially disincentivizing the liquidation process.

Vulnerability Details

When a position is liquidated, the _doLiquidation function is called. The sequence of operations is as follows:

  1. calculateLiquidation is called to determine amountLiquidated (the total collateral to seize, including the fee) and feeInYield (the portion of the seized collateral that serves as the liquidator's fee).

  2. The user's collateral balance is reduced by the full amountLiquidated:

    account.collateralBalance = account.collateralBalance > amountLiquidated ? account.collateralBalance - amountLiquidated : 0;
  3. The contract then attempts to pay the liquidator's fee with the following check:

    if (feeInYield > 0 && account.collateralBalance >= feeInYield)

The vulnerability lies in this check. It compares feeInYield to the user's collateralBalance after it has been debited. If the liquidation consumes most or all of the user's collateral, the remaining balance will be less than feeInYield, causing the check to fail and the fee transfer to be skipped. The fee is part of the amountLiquidated that was already seized by the contract and should be paid from that amount, not from the user's remaining balance.

Impact Details

This bug leads to a loss of funds for liquidators. By failing to pay the fee, the protocol disincentivizes liquidators from maintaining the health of the system. A lack of liquidators could lead to an accumulation of undercollateralized debt, increasing the overall risk to the protocol. The unpaid fees remain locked within the Alchemist contract.

References

https://github.com/alchemix-finance/v3-poc/blob/a192ab313c81ba3ab621d9ca1ee000110fbdd1e9/src/AlchemistV3.sol#L867-L880

Proof of Concept

Proof of Concept

This test demonstrates the liquidation fee vulnerability by creating a position that is almost entirely wiped out, and then asserts that the liquidator is not paid their fee despite one being calculated. Copy and add the following test in the AlchemixV3.t.sol file and run forge test --mt testLiquidate_POC_Check -vvv to view the logs.

Was this helpful?