Skip to the article
Token Trail

News from across crypto

How to buy collateral before a DeFi vault liquidation

To avoid a vault liquidation you need to add collateral quickly, and the steps are simple, but timing and transaction fees decide whether you make it.

By The Token Trail Desk3 min read

How to buy collateral before a DeFi vault liquidation

You buy the collateral token the vault already holds and deposit it into the vault contract before the health ratio falls below the liquidation threshold. A vault is a smart-contract position where you lock collateral, like ETH, and borrow a stablecoin against it. If the collateral's price drops, the health ratio falls. Drop below the protocol's minimum and liquidators can repay your debt, take your collateral, and add a penalty on top. The buying part is usually straightforward; the timing is the hard part.

Most people buy the collateral on a decentralized exchange, because the trade and the deposit happen from the same wallet. A centralized exchange works too, but you then have to withdraw to the vault's wallet, which adds minutes. The fastest route depends on the exchange you use and whether you get the token through a direct swap or a pool trade; the fuller comparison of swaps, pools, and staking on biswap covers the trade-offs.

What makes a vault liquidation happen?

A liquidation happens when the collateral's value is no longer enough to cover the borrowed amount at the protocol's minimum ratio. The health ratio measures the distance to that moment: it compares the value of the collateral to the debt. When the ratio approaches the protocol's minimum, you are running out of room. Each protocol sets its own number, and each has a penalty for getting caught. The protocol keeps a small margin of safety, so the moment price dips through the threshold, liquidators compete to close the position. They do it because they keep part of the collateral as a reward.

Where should you buy the collateral?

Buy it on a decentralized exchange so the tokens arrive in the wallet that owns the vault. You also need the exact token version the vault accepts. Wrapped ETH, for instance, is not the same as regular ETH on a smart contract. Check the vault's collateral list before you trade. Slippage is the difference between the price you expect and the price you get; smaller trades usually slip less. After the swap, approve the vault contract to spend the token, then send the deposit transaction.

How do you beat the liquidators?

You beat them by getting your deposit transaction mined before their liquidation transaction. A higher gas price helps, because miners confirm it sooner. Price alerts on the collateral are a cheap early warning; set one before the price gets close to the liquidation level. But a better plan is to keep a reserve of collateral in the vault before the price moves. Most liquidations are a race, and the safest way to win it is to never be racing.

To make the whole process clean, follow the same order every time:

  • Check the vault's health ratio and the protocol's minimum ratio.
  • Swap stablecoins for the collateral token, keeping the trade small to limit slippage.
  • Move the token to the vault's wallet if it isn't already there.
  • Approve the vault contract, then deposit and confirm the new health ratio.

Buying collateral before a liquidation is a race against bots, so the practical answer is preparation. Keep a buffer of collateral in the vault, or at least have stablecoins ready in the wallet, and know the protocol's minimum ratio before the price moves.