Skip to content
Business logic Audit finding Beginner

Wrong amount variable in repay event

The repay function emits a Repay event using the input amount rather than the credit actually applied to the user's debt. An attacker could not exploit this directly, but off-chain systems relying on the event would record an incorrect repaid amount.

Anirruth Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

57028 sc insight wrong amount variable in repay event

Submitted on Oct 22nd 2025 at 19:37:09 UTC by @Anirruth for Audit Comp | Alchemix V3

Description

Brief/Intro

The event emitted for repay function is wrong.

Vulnerability Details

The event emitted when a user calls repay function is the following:

emit Repay(msg.sender, amount, recipientTokenId, creditToYield);

The following is the event Repay:

/// @notice Emitted when `amount` of `underlyingToken` are repaid to grant credit to account owned by `recipientId`.
    ///
    /// @param sender          The address which is repaying tokens.
    /// @param amount          The amount of the underlying token that was used to repay debt.
    /// @param recipientId     The id of account that received credit for the repaid tokens.
    /// @param credit          The amount of debt that was paid-off to the account owned by owner.
    event Repay(address indexed sender, uint256 amount, uint256 indexed recipientId, uint256 credit);

https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/AlchemistV3.sol?utm\\_source=immunefi#L517-L519

In the repay function, when emitting the event, in the amount column its supposed to be the credit/creditToYeild variable which gets reduced and not the inputted amount variable, Since the amount variable gets converted or reduced according to the debt and the credit/creditToYield variable is the one which gets subtracted from user. Therefore the variable to be used either the credit or the creditToYield variable. Similar to the burn function : https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/AlchemistV3.sol?utm\\_source=immunefi#L492

Impact Details

Wrong amount in the event is emitted.

References

https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/AlchemistV3.sol?utm\\_source=immunefi#L543

Proof of Concept

Proof of Concept

Not required for insights.

The original report as published on Immunefi, by Anirruth. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the event argument was taken from the function input instead of the computed credit variable that is actually subtracted from the user's debt.

Impact

The event reports an incorrect repaid amount, which could mislead off-chain accounting or monitoring that trusts it.

What the attacker needed

None

The fix

The event should be emitted with the credit or creditToYield variable rather than the input amount, matching how the burn function does it.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract can announce what happened by emitting an event, which off-chain software reads. Here the announcement used the amount the user typed in, not the smaller amount that was actually taken off their debt, so anyone watching would see the wrong figure.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Anirruth

View all

6 more disclosed reports, best first.

More from Alchemix V3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.