NFTManager `burnAsset` always triggers JIT penalty on removal
The NFTManager.burnAsset function calls collectFees, which resets the asset's timestamp, before removeMaker, which uses that timestamp to calculate the holding duration for a JIT penalty. As a result, any maker who burns their NFT is penalised as if they had held the position for zero time, losing part of their principal even if they held it longer than the JIT lifetime.
Source: https://github.com/sherlock-audit/2025-09-ammplify-judging/issues/365
Found by
0xHexed, 0xKemah, 0xapple, 0xnija, Edoscoba, HeckerTrieuTien, OxNoble, Slayer, VCeb, Ziusz, anonymousjoe, blockace, davuka, gh0xt, neeloy, r1ver, roshark, t.aksoy, theholymarvycodes, vtim
Summary
Updating the asset’s timestamp inside MakerFacet.collectFees will cause an undue JIT penalty on removal for makers as NFTManager.burnAsset first calls collectFees (which resets timestamp) and then removeMaker. removeMaker computes lifetime from that just-reset timestamp, so the user loses a portion of principal upon burn even if the position has been held longer than jitLifetime.
Root Cause
In Maker.sol:147, collectFees() calls:
function collectFees(...) {
// [...]
AssetLib.updateTimestamp(asset); // <-- Resets to block.timestamp
// [...]
}
function updateTimestamp(Asset storage asset) internal {
asset.timestamp = uint128(block.timestamp);
}
In Maker.sol:117, removeMaker() applies JIT penalty based on asset.timestamp:
function removeMaker(...) {
// [...]
removedX = uint256(-data.xBalance); // These are definitely negative.
removedY = uint256(-data.yBalance);
(removedX, removedY) = FeeLib.applyJITPenalties(asset, removedX, removedY);
AssetLib.removeAsset(assetId);
// [...]
}
In NFTManager.sol, burnAsset() is implemented as:
function burnAsset(...) {
// [...]
(fees0, fees1) = MAKER_FACET.collectFees(...); // <-- Effectively resets timestamp
(token0, token1, removedX, removedY) = MAKER_FACET.removeMaker(...); // <-- Uses just-reset timestamp
// [...]
_burn(tokenId);
emit AssetBurned(assetId, tokenId, msg.sender);
}
This ordering guarantees duration < jitLifetime during removal in the same tx, applying penalty even for long-held positions.
Internal Pre-conditions
- Admin has set
jitLifetime > 0andjitPenaltyX64 > 0. - A maker position exists and has been held longer than
jitLifetime.
External Pre-conditions
None.
Attack Path
- User holds a long-lived Maker NFT and wants to close via
NFTManager.burnAsset(). burnAssetfirst callsMakerFacet.collectFees(), which updatesasset.timestampto now.burnAssetthen callsMakerFacet.removeMaker(), which checksduration = now - asset.timestamp = 0.FeeLib.applyJITPenaltiesapplies the penalty to removedX/removedY even though the position was not JIT.
Impact
The user suffers loss equal to the configured JIT penalty fraction on their withdrawn principal.
PoC
No response
Mitigation
Don't update the timestamp inside collectFees().
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/itos-finance/Ammplify/pull/27
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
Impact
The user loses a portion of their principal equal to the configured JIT penalty fraction when burning their NFT, even if the position was held longer than the JIT lifetime.
What the attacker needed
Admin sets jitLifetime > 0 and jitPenaltyX64 > 0; A maker position held longer than jitLifetime
The fix
The timestamp update inside collectFees should be removed so that removeMaker can correctly calculate the holding duration.
How it was found
- A user holds a Maker NFT for longer than the JIT lifetime.
- The user calls NFTManager.burnAsset to close the position.
- burnAsset calls MakerFacet.collectFees, which updates the asset timestamp to the current block time.
- burnAsset then calls MakerFacet.removeMaker, which calculates the holding duration as zero.
- FeeLib.applyJITPenalties applies the JIT penalty to the withdrawn amounts.
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 JIT penalty is a fee charged when someone provides liquidity for only a very short time. The contract tracks how long a position has been held by storing a timestamp. When a user closes their position, the code first collects fees, which accidentally updates that timestamp to the current time, and then checks the holding period. Because the timestamp was just reset, the contract thinks the position was held for zero time and charges the penalty even for long-held positions.
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.