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.
- 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
- Report ID: #57028
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/AlchemistV3.sol
- Impacts:
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);
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
Proof of Concept
Proof of Concept
Not required for insights.
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.