Self-liquidation
When a position goes underwater, whoever liquidates it is paid a bonus out of your collateral. Close the position yourself first — in one atomic transaction, funded by a flash loan — and that bonus never leaves your account.
| Your collateral | Liquidation bonus | On $1M | On $10M |
|---|---|---|---|
| wstETH | 6.0% | $60,000 | $600,000 |
| WETH | 5.0% | $50,000 | $500,000 |
| WBTC | 5.0% | $50,000 | $500,000 |
| USDC | 4.5% | $45,000 | $450,000 |
Read live from chain. It is
liquidationBonus on each reserve, and anyone can verify it —
these are not our numbers.
The obvious move is to repay the debt and withdraw the collateral. The obvious problem is that the money to repay it is the collateral — locked behind the debt you are trying to clear. Chicken, meet egg.
So the usual options are to find the cash from somewhere else at short notice, or to sell something in a hurry, or to watch a bot do it for you and take the bonus.
A flash loan removes the deadlock. It lends you the repayment for the length of one transaction, on the condition that the transaction repays it — which yours does, out of the collateral it just freed. No outside capital, no deadline, no bot.
Every step is one transaction. If any part fails, all of it reverts and your position is untouched — you are never left half-closed.
Run on Ethereum mainnet on 4 August 2026, against a real position with real Uniswap liquidity:
The last two lines are the ones that matter. The debt token reading exactly zero proves the repayment cleared an accruing balance rather than leaving a remainder that would have blocked the withdrawal. The contract holding nothing proves the loan was borrowed, used and repaid inside the one call.
There is a Safe App for this. It reads your position, shows what a liquidator would take, and proposes the whole close as a single batched transaction — one signature round instead of two.
Add it under Apps → My custom apps using
https://atomic-close.pages.dev. Nothing executes until your signers
approve it, so you see exactly what it built before anything moves.
It does not rescue an insolvent position. If the collateral is worth less than the debt, no arrangement of transactions fixes that. This wins you the penalty, not the market move.
onBehalfOf parameter
anywhere in it — it can never be pointed at somebody else's account, including by us.