Advanced: Flash-Mint Liquidation › for liquidator bots & contracts
liquidateWithFlashMint(address user, uint256 repayAmount, bytes data) — a liquidation path that doesn't require pre-holding pSunDAI. The vault sends the liquidator its WPLS collateral reward first, then calls back into msg.sender.onFlashLiquidation(...) so the caller can swap that collateral for pSunDAI (via a DEX router, using its own approvals) and repay by the end of the same transaction. A 0.2% fee on the repaid amount routes into the Stability Pool as yield (or surplus buffer if the pool is empty).
This requires the caller to be a contract implementing the IFlashLiquidationReceiver interface — a plain wallet clicking a button can't use it, since the vault's callback needs somewhere to land. There's no button for this on this page for exactly that reason: it would just revert for every real visitor. For most vaults, Liquidate via Stability Pool above is simpler and needs no capital at all — this flash-mint path exists for the case where the pool can't cover a large position and you don't want to pre-fund pSunDAI yourself.
If you're running a liquidation bot, deploy a small receiver contract that implements onFlashLiquidation(address user, uint256 collateralReceived, uint256 amountOwed, bytes data), call liquidateWithFlashMint from that contract, and settle the swap inside the callback. The regular liquidate() flow above works unchanged if you'd rather pre-fund pSunDAI directly.