Unnecessary computation of lockedCollateral in _addDebt() and _subDebt()
The contract recalculates locked collateral inside two internal debt functions even though a prior sync step already stored the up-to-date value. This is a gas inefficiency, not an exploitable vulnerability, and the report claims no security impact.
- Disclosed after under an hour
57448 sc insight unnecessary computation of lockedcollateral in adddebt and subdebt
Submitted on Oct 26th 2025 at 10:01:53 UTC by @algiz for Audit Comp | Alchemix V3
- Report ID: #57448
- 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
Locked collateral is computed in both _addDebt() and _subDebt(), although it has already been updated by the _sync()
Vulnerability Details
Both _addDebt() and _subDebt() calculate the locked collateral:
uint256 lockedCollateral = convertDebtTokensToYield(account.debt) * minimumCollateralization / FIXED_POINT_SCALAR;
which makes an external call to the Morpho vault.
_addDebt()is called from_mint(), which is called in_mint()and_mintFrom()_subDebt()is called fromburn(),repay(),_forceRepay()and_doLiquidation()(which is called from_liquidate())
In any of those cases the _sync() function has been called prior, hence the locked collateral has been already calculated and up to date in rawLocked:
// Update locked collateral
account.rawLocked = convertDebtTokensToYield(account.debt) * minimumCollateralization / FIXED_POINT_SCALAR;
Impact Details
Unnecessary calculation with external call that costs additional gas.
References
n/a
Proof of Concept
Proof of Concept
provided in the Impact details section
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 debt functions recompute locked collateral instead of reusing the value already written to storage by the earlier sync step.
What the attacker needed
None
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 is a program on a blockchain, and every operation costs a small fee called gas. This report points out that the code does the same calculation twice, including a call to another contract, which wastes gas. It is a code-quality note rather than a way for someone to steal funds or break the system.
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.