> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xarchive.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Liquidations

> Read every liquidation with the wallet liquidated, and where open positions would be liquidated next.

Follow liquidations two ways: the ones that happened, with the account liquidated, and the ones waiting, as the price levels where open positions would be liquidated.

## Liquidations that happened

`liquidations()` delivers each liquidation to `onLiquidation`: `time`, `price`, `size`, `notional`, `side` (the side of the position liquidated, `'long'` or `'short'`) and `user`, the account. On Hyperliquid `user` is the wallet, lower-case; on Lighter it is an account index. Liquidations reach back 7 days.

```ts theme={"theme":"github-dark"}
indicator('Liquidations', { precision: 0 });

const chart = bars();
const liq = liquidations({ minNotional: 10_000 });
const longs = tally();
const shorts = tally();
const longBars = plot.histogram('Longs liquidated $');
const shortBars = plot.histogram('Shorts liquidated $');

liq.onLiquidation((l) => (l.side === 'long' ? longs : shorts).add(l.notional));

chart.onBar(() => {
  if (!liq.available) return;
  longBars.set(-longs.value, color.down);
  shortBars.set(shorts.value, color.up);
});
```

## Follow wallets

`input.addresses` gives the settings panel a wallet list, which keeps only valid addresses, lower-case. Skip the others in the handler:

```ts theme={"theme":"github-dark"}
const wallets = input.addresses('Only these wallets', []);

liq.onLiquidation((l) => {
  if (wallets.length > 0 && !(l.user !== null && wallets.includes(l.user.toLowerCase()))) return;
  (l.side === 'long' ? longs : shorts).add(l.notional);
});
```

Lighter names an account index rather than a wallet, which no address matches. One position is often liquidated in several fills a moment apart. To count liquidations rather than fills, treat a wallet's fills within a minute as one, as [Most-liquidated wallets](/terminal/examples/liquidated-wallets) does.

## Where liquidations would happen next

`liquidationLevels()` is 0xArchive's estimate of where open positions would be liquidated: 40 levels over 10% either side of the mark, each with the USD of longs and of shorts liquidated there, about every 5 minutes. Read it in any handler; `levels()` is the snapshot as of that bar, sorted by price.

```ts theme={"theme":"github-dark"}
const map = liquidationLevels();

chart.onBar(() => {
  if (!map.available) return;
  let shortsAbove = 0;
  for (const level of map.levels()) if (level.price > chart.close) shortsAbove += level.shortUsd;
});
```

Levels are Hyperliquid's, from 27 July 2026, kept for 7 days, and never interpolated between snapshots: a bar between two snapshots reads the earlier one. Levels far from the price stretch the price scale and squash the candles; plot them with `autoscale: false` so they are drawn where they fall without moving the scale. [Liquidation levels ahead](/terminal/examples/liquidation-levels-ahead) and [Liquidation clusters](/terminal/examples/liquidation-clusters) draw them.

## Next step

Draw what a script found with [outputs](/terminal/guides/outputs).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.