Liquidity-layer failure fallback stores owed payouts under `to_`, making withdrawals/borrows/fees permanently unclaimable for EOAs
The Liquidity-layer failure fallback in FluidDexV2.settle() credits owed payouts to the recipient address (to_) while all redemption of stored balances is keyed to msg.sender and gated behind startOperation. As a result, when the Liquidity layer reverts during a net-out settlement, the payout is stored under an address that cannot claim it, so users and liquidators permanently lose withdrawn principal, borrowed assets, or fees.
0xastronatey Follow with 4Nescient, AV and 33 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2026-01-fluid-dex-v2-judging/issues/1111
Found by
0xastronatey, 4Nescient, AV, Bizarro, Diavolo, Draxen, Emmanuel, ExtraCaterpillar, Harry-Elite, Jiberish, Kenn.eth, Leaningone, LeoGold, Pelz, Proof-of-Spirit, SarveshLimaye, Waydou, ZeroTrust, botdidy, edantes, fullcounterhunter, fuzious, gabkov, gh0xt, jo13, jongwon, legat, lodelux, natachi, neeloy, nitinaimshigh, rajatbeladiya, thimthor, uba, xiaoming90, yaioxy
Summary
The Liquidity-layer failure fallback in FluidDexV2.settle() credits _userStoredTokenAmount to to_ while all redemption is keyed to msg.sender and gated behind startOperation, which will cause a permanent loss of owed payouts for recipients as any Liquidity-layer revert during a net-out settlement will silently replace the transfer with an unclaimable “stored” balance.
Root Cause
- In
contracts/contracts/protocols/dexV2/base/core/main.sol:189the Liquidity-failure fallback credits stored balances toto_instead of the only redeemable key (msg.sender):_userStoredTokenAmount[BASE_SLOT][to_][token_] += uint256(-netAmount_);
- In
contracts/contracts/protocols/dexV2/base/core/helpers.sol:60-67stored-balance accounting (store/unstore) is exclusively keyed tomsg.sender, meaning onlymsg.sendercan ever reduce/withdraw a stored balance:int256(_userStoredTokenAmount[BASE_SLOT][msg.sender][token_]) + storeAmount_
- In
contracts/contracts/protocols/dexV2/base/core/main.sol:20-33andcontracts/contracts/protocols/dexV2/base/core/main.sol:80the only callable path tosettle()is via callback-gatedstartOperation()+_onlyAfterOperationStarted, preventing EOAs (and most non-callback contracts) from redeeming any stored credit keyed to their address.
Internal Pre-conditions
External Pre-conditions
Attack Path
FluidDexV2.settle() is designed to support “store instead of transfer” behavior when the Liquidity layer interaction fails. Concretely, settle() computes:
netSupplyAmount_ = supplyAmount_ + storeAmount_netAmount_ = netSupplyAmount_ - borrowAmount_
When netAmount_ < 0, the DEX is supposed to pay tokens out to to_.
If the contract has enough on-hand balance, it transfers directly. Otherwise it calls _callLiquidityLayer(...), which wraps LIQUIDITY.operate(...) in a try/catch and returns false on revert. When _callLiquidityLayer(...) returns false, settle() enters a fallback branch.
The intended behavior vs. actual behavior
In the fallback branch for netAmount_ < 0, the code explicitly states it will “store the amount in the contract so the user can withdraw later”, but it stores it under:
_userStoredTokenAmount[...][to_][token_]
This is incompatible with how stored balances are ever consumed:
- Stored balances are only updated/consumed for
_userStoredTokenAmount[...][msg.sender][token_]inside_updateSettledAmountsOnStorage().
There is no separate withdrawal function for _userStoredTokenAmount[...][addr][token_], and there are no other code paths that debit _userStoredTokenAmount for an arbitrary owner.
Why this permanently strands funds for typical recipients
Even if the storage key were correct, redemption is further constrained by access pattern:
settle()is protected by_onlyAfterOperationStarted(must be within an active operation).- The only way to create an active operation is
startOperation(), which calls back intomsg.senderviaIDexV2Callbacks(msg.sender).startOperationCallback(data_).
As a result:
- EOAs cannot successfully use
startOperation()(they do not implement the callback ABI), so they cannot reach a state where they can callsettle(). - Even callback-capable routers (e.g., MoneyMarket) cannot redeem balances stored under the recipient key, because redemption is keyed to
msg.sender, notto_.
So when Liquidity fails and a payout is stored to to_ (commonly an EOA), the system produces an internal IOU that the credited address cannot practically claim, and no other party can claim on their behalf.
Realistic triggering contexts in this codebase
MoneyMarket is built around a router/callback pattern where the router (MoneyMarket) is the msg.sender to DexV2, and the end recipient to_ is user-provided (usually an EOA). In multiple core flows, MoneyMarket calls DEX_V2.settle(..., to_=to_):
- Fee collection (
_feeSettle, called from callback module) - Withdraw settlements (
_withdrawSettle) - Borrow settlements (
_borrowSettle) - Liquidation withdrawals and fee claims (LiquidateModule sets
params_.toas the payout recipient)
Because DexV2.settle() does not revert on Liquidity failure (it stores instead), the higher-level MoneyMarket flow will continue executing and update its own bookkeeping (e.g., stored fee accounting, position deletion, debt changes), while the recipient never receives tokens and cannot redeem the stored credit. This silently converts “success” into unrecoverable loss.
Attack Path
Path 1 — Any net-out DexV2.settle() where Liquidity reverts and to_ is an EOA
- A callback-capable integrator contract calls
FluidDexV2.startOperation(...). (contracts/contracts/protocols/dexV2/base/core/main.sol:20-33) - Inside
startOperationCallback, the integrator callsFluidDexV2.settle(..., to_ = recipientEOA, ...)in a context wherenetAmount_ < 0(protocol must pay tokens out). (.../dexV2/base/core/main.sol:117-119) _callLiquidityLayer(...)attemptsLIQUIDITY.operate(...)but reverts; thetry/catchreturnsfalse. (.../dexV2/base/core/helpers.sol:70+)settle()enters the fallback branch and skips the transfer, instead incrementing_userStoredTokenAmount[...][recipientEOA][token_]. (.../dexV2/base/core/main.sol:181-193)- The operation completes successfully, but
recipientEOAcannot later run the callback-gated flow required to callsettle()asmsg.sender, so the credited amount is effectively permanently unclaimable.
Path 2 — MoneyMarket fee collection converts earned fees into an unclaimable stored balance
- User triggers fee collection and sets
to_ = userEOAinactionData. (contracts/contracts/protocols/moneyMarket/core/callbackModule/main.sol:48-114) - MoneyMarket updates
_positionFeeStoredby subtracting the user’s requestedfeeCollectionAmount(fees are considered “collected” in MoneyMarket accounting). (.../moneyMarket/core/callbackModule/helpers.sol:69-91) - MoneyMarket calls
_feeSettle(...), which callsDEX_V2.settle(token, -feeAccrued, 0, feeAccrued-feeCollected, to_=userEOA, ...)makingnetAmount = -feeCollected(net-out payout). (.../moneyMarket/core/callbackModule/helpers.sol:9-14) - If Liquidity reverts, DexV2 stores
feeCollectedunderuserEOAand skips the transfer. (.../dexV2/base/core/main.sol:181-193) - User’s fees are now decremented in MoneyMarket and the DexV2 credit is unredeemable, so the user loses their fee payout.
Path 3 — MoneyMarket D3 withdraw: principal + accrued fees can be “withdrawn” on-chain but never delivered
- User withdraws from a D3 position and sets
to_ = userEOA. (.../moneyMarket/core/callbackModule/main.sol:256-327) - MoneyMarket executes the DEX withdraw (
DEX_V2.operate(...)) then calls_withdrawSettle(...)for each token. (.../moneyMarket/core/callbackModule/main.sol:263-297) _withdrawSettlecallsDEX_V2.settle(token, -(amount+feeAccrued), 0, feeAccrued, to_=userEOA, ...)producing a net-out payout. (.../moneyMarket/core/callbackModule/helpers.sol:17-21)- If Liquidity reverts, DexV2 stores the owed payout under
userEOAand skips the transfer. (.../dexV2/base/core/main.sol:181-193) - MoneyMarket continues execution (fee storage update, caps update, potential position deletion), so the withdrawal cannot be simply retried and the user never receives the withdrawn assets.
Path 4 — MoneyMarket D4 borrow: debt can be increased without the borrower receiving the borrowed tokens
- User borrows from a D4 position with
to_ = userEOA. (.../moneyMarket/core/callbackModule/main.sol:331-403) - MoneyMarket executes the borrow (
DEX_V2.operate(...)) then calls_borrowSettle(...). (.../moneyMarket/core/callbackModule/main.sol:340-375) _borrowSettlecallsDEX_V2.settle(token, -feeAccrued, amount, feeAccrued, to_=userEOA, ...)resulting innetAmount = -amount(net-out borrowed tokens). (.../moneyMarket/core/callbackModule/helpers.sol:23-27)- If Liquidity reverts, DexV2 stores the owed borrowed amount under
userEOAand skips the transfer. (.../dexV2/base/core/main.sol:181-193) - The borrow-side state changes remain, but the borrower does not receive the borrowed funds and cannot redeem them, potentially cascading into liquidations due to increased debt without corresponding assets.
Path 5 — Liquidation payouts can be silently converted into unclaimable credits, breaking liquidation incentives
- A liquidator calls
LiquidateModuleand setsparams_.to(defaults tomsg.sender, typically an EOA). (contracts/contracts/protocols/moneyMarket/core/liquidateModule/main.sol:50) - Liquidation performs withdraw and/or fee-collection operations where
actionDataincludesparams_.to, causing the callback module to ultimately call settlement helpers that pay out to thatto_. (.../liquidateModule/main.sol:468-494,.../liquidateModule/main.sol:610-611) - If Liquidity reverts during the resulting net-out
DexV2.settle(...), DexV2 stores the liquidator’s payout under their EOA and skips the transfer. (.../dexV2/base/core/main.sol:181-193) - The liquidation flow can proceed updating protocol state, while the liquidator never receives the payout and cannot redeem it, making liquidations unreliable and potentially non-functional under the exact failure conditions this fallback was meant to handle.
Impact
Affected users and liquidators can suffer an approximate loss of up to 100% of any net-out token amount that hits the Liquidity-failure fallback (withdrawn principal, borrowed assets, and/or collected fees), because the protocol records the payout under _userStoredTokenAmount[to_] but provides no viable redemption path for EOAs (or non-callback recipients).
- Users can lose withdrawal proceeds (principal + any included fee accrual) when a D3 withdraw settlement hits the fallback.
- Users can lose borrowed assets (while still taking on the debt-side state changes) when a D4 borrow settlement hits the fallback.
- Users can lose accrued fee payouts because MoneyMarket debits
_positionFeeStoredbefore callingDexV2.settle(), and the fallback does not revert—so the fee entitlement is reduced even though the payout is never delivered. - Liquidators can lose liquidation proceeds (and therefore liquidation incentives collapse under these failure conditions), which can break the protocol’s ability to resolve unhealthy positions whenever the Liquidity layer reverts.
PoC
No response
Mitigation
No response
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 fallback branch in settle() stores the owed amount under to_ while the store/unstore accounting and the only callable redemption path are keyed to msg.sender and gated by startOperation, so the credit is unreachable.
Impact
Affected users and liquidators could lose up to 100% of any net-out amount that hits the fallback, including withdrawn principal, borrowed assets, and collected fees, and liquidations may become unreliable under those conditions.
What the attacker needed
Liquidity layer call reverts; Callback-capable integrator (e.g. MoneyMarket); Recipient is an EOA or non-callback address
How it was found
- A callback-capable integrator calls startOperation on FluidDexV2.
- Inside the callback, the integrator calls settle with to_ set to a recipient EOA and a net-out amount.
- The call to the Liquidity layer reverts and the try/catch returns false.
- settle enters the fallback branch and increments the stored balance under the recipient EOA instead of transferring.
- The operation completes, but the recipient EOA cannot run the callback-gated flow to redeem the stored credit.
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.
When the DEX needs to pay tokens out but its connection to the liquidity pool fails, it does not send the tokens; instead it writes an IOU in its internal ledger. The problem is that it writes the IOU under the recipient's address, but the only code that can ever cash an IOU looks it up under the caller's address. So the IOU exists but nobody can ever redeem it, and the user's money is effectively gone.
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.