This calculator works out the full cost of swapping the collateral behind a DeFi loan — protocol fees, slippage, and gas — then shows how the swap changes your health factor and how long it takes to break even against the risk-reduction benefit.
How it works
The total cost of a collateral swap has three parts:
protocol cost = collateral value × protocol fee %
slippage cost = collateral value × slippage %
gas cost = fixed USD estimate
total cost = protocol + slippage + gas
Those costs come out of your collateral, so your post-swap collateral is the original value minus the total cost. The health factor (Aave-style) is:
health factor = collateral × liquidation threshold ÷ debt
A factor above 1 is safe; the higher the better. Because the swap consumes collateral, moving to a higher-threshold asset does not always raise the health factor — the cost can offset the gain.
Break-even
If the swap delivers a daily benefit (a lower borrow rate, or an amortised reduction in expected liquidation penalty), the break-even is:
break-even days = total cost ÷ daily benefit
Below that horizon the swap is not worth it; above it, the swap pays for itself.
Illustrative example
A borrower has $10,000 of ETH as collateral and $5,000 of stablecoin debt.
ETH’s liquidation threshold on the protocol is 82.5%. Current health factor:
$10,000 × 0.825 ÷ $5,000 = 1.65.
They want to swap to wstETH, which has an 80% liquidation threshold — slightly lower per dollar but with a lower borrow rate. The swap costs:
- Protocol fee: 0.10% × $10,000 = $10
- Slippage: 0.15% × $10,000 = $15
- Gas: $8 estimated
- Total cost: $33
Post-swap collateral: $10,000 − $33 = $9,967. New health factor:
$9,967 × 0.80 ÷ $5,000 = 1.59 — slightly lower than before the swap,
because the cost offset the threshold difference.
If the wstETH position saves $0.50/day in borrow interest versus ETH:
$33 ÷ $0.50 = 66 days to break even. Whether the risk profile change and
interest saving over that window justifies the swap is a judgement call, but
the calculator makes the numbers explicit rather than leaving them to intuition.
When a collateral swap makes sense
- Moving to a more stable asset (volatile token → stablecoin or LST) when you expect market volatility and want to raise your health factor margin. Note that if the new asset has a lower liquidation threshold, the health factor benefit depends on the magnitude of the volatility reduction.
- Switching to a lower-rate collateral when the borrow-rate saving exceeds the swap cost within your intended holding period.
- Avoiding a liquidation penalty when the health factor is approaching 1.0 — the swap cost is often far smaller than a liquidation penalty of 5–15%.
Notes
Slippage and gas are estimates — confirm a live DEX aggregator quote and a current gas oracle reading before you sign the transaction, especially during volatile markets or network congestion. Liquidation thresholds vary by protocol, asset tier, and sometimes by borrow amount; always read them from the protocol’s published risk parameters. All calculation runs locally in your browser; nothing is sent anywhere.