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

# Mempool front-run alert

> See large pending Polymarket buys before they land, then reconcile against the confirmed fill.

Get an alert the moment a big order hits the mempool, before it is in a block. Subscribe to [`trading`](/websockets/channels/trading) with `confirmed: false` to stream pending exchange transactions. Pair it with the confirmed `trading` feed to know when the trade actually lands.

<Warning>
  Mempool messages are guesses, not facts. A pending transaction can be dropped,
  replaced, reordered, or reverted. Never treat a mempool alert as a settled
  trade — always confirm against `trading`.
</Warning>

## What you need

* An API key from [radion.app/dashboard](https://radion.app/dashboard).
* A size threshold in whole USD (for example, `10000`).

## Alert on pending, confirm on landing

Subscribe to both feeds. Alert on the pending frame, then match it to the confirmed event by `transaction_hash`. Both arrive on the `trading` channel, so you tell them apart by the `confirmed` flag on the frame.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { Radion } from "@radion-app/sdk";

  const radion = new Radion({ apiKey: process.env.RADION_API_KEY });
  const pending = new Map<string, number>();

  radion.realtime.onChannel("trading", (event) => {
    if (!event.confirmed) {
      const call = event.data.call;
      if (!call?.notional_usd || call.notional_usd < 10_000) return;
      pending.set(event.data.transaction_hash, call.notional_usd);
      console.log(
        `pending $${call.notional_usd} order — ${event.data.transaction_hash}`
      );
      return;
    }

    const hash = event.data.transactionHash;
    if (pending.has(hash)) {
      console.log(`landed — ${hash}`);
      pending.delete(hash);
    }
  });

  radion.realtime.subscribe({
    id: "pending",
    channel: "trading",
    confirmed: false,
  });
  radion.realtime.subscribe({
    id: "confirmed",
    channel: "trading",
    confirmed: true,
    filters: { min_usd: 10_000 },
  });

  await radion.realtime.connect();
  ```

  ```python Python theme={null}
  import asyncio
  from radion import Radion, ChannelFilters, Subscription

  radion = Radion(api_key="YOUR_API_KEY")
  pending = {}

  @radion.realtime.on_channel("trading")
  async def on_trading(event):
      if not event.confirmed:
          call = event.data.get("call")
          if not call or (call.get("notional_usd") or 0) < 10_000:
              return
          pending[event.data["transaction_hash"]] = call["notional_usd"]
          print(f"pending ${call['notional_usd']} order — {event.data['transaction_hash']}")
          return
      tx_hash = event.data.get("transactionHash")
      if tx_hash in pending:
          print(f"landed — {tx_hash}")
          pending.pop(tx_hash)

  async def main():
      await radion.realtime.subscribe(Subscription(id="pending", channel="trading", confirmed=False))
      await radion.realtime.subscribe(
          Subscription(id="confirmed", channel="trading", confirmed=True, filters=ChannelFilters(min_usd=10_000))
      )
      await radion.realtime.connect()

  asyncio.run(main())
  ```
</CodeGroup>

## How the size filter differs

* On the confirmed `trading` feed, `min_usd` measures the **filled** amount.
* On the pending feed (`confirmed: false`), the `call.notional_usd` field is the pending **order** size. It may only partly fill or never land.

So filter the pending side in your own code (as above), and let `min_usd` narrow the confirmed side.

## Read the pending frame

The `call` object holds decoded calldata: `method`, `market_ids`, `token_ids`, `wallets`, `notional_usd`, and an `orders` array (each order is `{ maker, taker, token_id, side, maker_amount, taker_amount }`). `call` is `null` when the calldata is not a known Polymarket call. See [Mempool](/websockets/mempool) for the full frame and filter reach.

## Next steps

<Columns cols={2}>
  <Card title="Mempool reference" icon="clock" href="/websockets/mempool">
    Frame shape, the `call` object, and filter limits.
  </Card>

  <Card title="Copy-trade a whale" icon="user" href="/guides/copy-trade-a-whale">
    Mirror a wallet's trades in real time.
  </Card>
</Columns>
