> ## 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.

# Most-liquidated wallets

> Rank the wallets liquidated for the most this week, and mark the biggest one on each bar with its address.

<Frame caption="BTC on 15-minute bars in the 0xArchive Terminal, 2026-10-15.">
  <img src="https://mintcdn.com/0xarchive-e895b8e7/_p6Z1TtSEb5DBnPX/images/terminal/examples/liquidated-wallets.webp?fit=max&auto=format&n=_p6Z1TtSEb5DBnPX&q=85&s=2f444bc7d5a26281a841d35f45e32a6d" alt="Most-liquidated wallets on a BTC chart" width="1038" height="664" data-path="images/terminal/examples/liquidated-wallets.webp" />
</Frame>

<Card title="Open on a chart" icon="chart-candlestick" href="https://terminal.0xarchive.io/?symbol=BTC&interval=15m&scripts=example%3Aliquidated-wallets" horizontal>
  Load it on BTC 15m in the terminal, then change its settings or open it in the script editor.
</Card>

Hyperliquid names the liquidated wallet on every liquidation, and 0xArchive keeps it. This script ranks the wallets liquidated for the most over the last 7 days, in a table: the USD liquidated, how many separate liquidations, and the side. On the chart, a bar where one wallet lost \$1M or more is marked with that wallet. Rest the pointer on a wallet in the table for its full address.

## How it works

`liquidations()` delivers each liquidation to `onLiquidation`, with its `user`. The totals per wallet live in [`state.map`](/terminal/guides/state#lists-and-maps) with the `'live'` lifetime, because an event handler may change only tallies and live state. One position is often liquidated in several fills a moment apart, so fills of one wallet within a minute count as one liquidation. The table is drawn only on the newest bar (`chart.isLast`), where the totals are complete.

On Lighter the liquidated account is an index, not a wallet, and it is listed as it is.

## Try changing

* Follow particular wallets: add `input.addresses` and skip the others in `onLiquidation`, as [Liquidations](/terminal/examples/liquidations) does.
* Lower **Mark a wallet from** to see smaller accounts.

## The script

```ts liquidated-wallets.ts theme={"theme":"github-dark"}
// The wallets liquidated for the most over the last 7 days, in a table, and the biggest wallet
// liquidated on a bar marked with its address. Hyperliquid names the liquidated wallet on every
// liquidation; Lighter names an account index, shown as it is. One position is often liquidated in
// several fills a moment apart, so fills of one wallet within a minute count as one liquidation.
indicator('Most-liquidated wallets', { overlay: true, shortName: 'Liquidated wallets' });

const rows = input.int('Wallets', 8, { min: 1, max: 20 });
const markUsd = input.float('Mark a wallet from ($)', 1_000_000, { min: 0 });
const position = input.choice('Position', 'top-right', ['top-left', 'top-right', 'bottom-left', 'bottom-right'], { legend: false });

const chart = bars();
const liq = liquidations();
// Per wallet, across every bar. An event handler may change only tallies and live state.
const usdBy = state.map<number>(50_000, 'live');
const timesBy = state.map<number>(50_000, 'live');
const longUsdBy = state.map<number>(50_000, 'live');
const lastSeen = state.map<number>(50_000, 'live');
// This bar's liquidated USD per wallet, for the marker.
const thisBar = tallyBy(2_000);
const marks = plot.markers('Big wallet liquidations');
const table = draw.table({ position, columns: 4, rows: 21, background: color.withAlpha(color.panel, 0.92), border: color.withAlpha(color.neutral, 0.12), frame: color.withAlpha(color.neutral, 0.28) });

const MINUTE = 60_000;
const short = (wallet: string) => (wallet.length > 12 ? `${wallet.slice(0, 6)}…${wallet.slice(-4)}` : wallet);

liq.onLiquidation((l) => {
  if (l.user === null) return;
  const wallet = l.user.toLowerCase();
  const last = lastSeen.get(wallet);
  if (last === undefined || l.time - last > MINUTE) timesBy.set(wallet, (timesBy.get(wallet) ?? 0) + 1);
  lastSeen.set(wallet, l.time);
  usdBy.set(wallet, (usdBy.get(wallet) ?? 0) + l.notional);
  if (l.side === 'long') longUsdBy.set(wallet, (longUsdBy.get(wallet) ?? 0) + l.notional);
  thisBar.add(wallet, l.side === 'long' ? l.notional : -l.notional);
});

chart.onBar(() => {
  let top = '';
  let topUsd = 0;
  for (const [wallet, usd] of thisBar.entries()) {
    if (Math.abs(usd) > Math.abs(topUsd)) { top = wallet; topUsd = usd; }
  }
  // `available` is false on bars older than the history, and on the newest while it can still change.
  if (liq.available && Math.abs(topUsd) >= markUsd) {
    // Longs are liquidated on the way down, so their mark sits under the candle.
    const long = topUsd > 0;
    marks.add({ position: long ? 'below' : 'above', shape: 'circle', text: `${short(top)} ${fmt.usd(Math.abs(topUsd))}`, color: long ? color.down : color.up });
  }
  if (!chart.isLast) return;
  const ranked = [...usdBy.entries()].sort((a, b) => b[1] - a[1]).slice(0, rows);
  const dim = color.withAlpha(color.neutral, 0.7);
  table.clear();
  table.cell(0, 0, 'Wallet', { align: 'left', size: 'small', color: dim });
  table.cell(1, 0, 'Liquidated', { align: 'right', size: 'small', color: dim });
  table.cell(2, 0, 'Times', { align: 'right', size: 'small', color: dim });
  table.cell(3, 0, 'Side', { align: 'left', size: 'small', color: dim });
  ranked.forEach(([wallet, usd], i) => {
    const longShare = (longUsdBy.get(wallet) ?? 0) / usd;
    const side = longShare > 0.5 ? 'Long' : 'Short';
    table.cell(0, i + 1, short(wallet), { align: 'left', tooltip: wallet });
    table.cell(1, i + 1, fmt.usd(usd), { align: 'right' });
    table.cell(2, i + 1, String(timesBy.get(wallet) ?? 0), { align: 'right' });
    table.cell(3, i + 1, side, { align: 'left', color: side === 'Long' ? color.down : color.up });
  });
});
```

## Next step

See the next example, [Liquidation levels ahead](/terminal/examples/liquidation-levels-ahead).


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