> For the complete documentation index, see [llms.txt](https://docs.manka.wtf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.manka.wtf/preconfirmations/filters.md).

# Filters

Every subscription names at least one filter. You only receive, and only pay for, transactions that match.

```json
{
  "filters": {
    "my-pools":  { "writes":   ["<pool>", "<pool>"] },
    "jupiter":   { "accounts": ["<JUP6...>"] },
    "my-desk":   { "signers":  ["<wallet>"] },
    "launches":  { "actions":  ["create"] },
    "pump-buys": { "actions":  ["pump_fun.buy", "pump_swap.buy"] },
    "my-amm":    { "instructions": [{ "program": "<program>", "discriminator": "<first bytes of the data>" }] }
  }
}
```

**What a filter matches**

A filter matches a transaction when **any** of these is true:

<table><thead><tr><th width="147.08203125">List</th><th>Matches when the transaction</th></tr></thead><tbody><tr><td><code>writes</code></td><td>takes one of these accounts as writable</td></tr><tr><td><code>accounts</code></td><td>mentions one of these accounts in any position, read or write</td></tr><tr><td><code>signers</code></td><td>is signed by one of these keys</td></tr><tr><td><code>instructions</code></td><td>has a top-level instruction that calls this program with data starting with this discriminator</td></tr><tr><td><code>actions</code></td><td>has a top-level instruction named here, from the catalog</td></tr></tbody></table>

The five lists are OR'ed, and a filter must name at least one entry. To narrow by more than one condition, use separate filters and combine their names on your side.

Only accounts listed in the transaction itself are matched. Accounts loaded through an address lookup table are not, because resolving them needs account state the leader's stream does not carry. Version 1 transactions have no lookup tables, so all of their accounts are matched.

**Instructions: top level only**

`instructions` and `actions` see the instructions written in the transaction. When a router, an aggregator or your own program trades on a venue for you, that trade is a cross-program invocation that only happens when the transaction runs, so it is not in the preconfirmation yet. Such a transaction still lists the venue's program among its accounts: match it with `accounts` when you need it, knowing that this does not tell you whether it buys or sells.

**Actions**

`actions` takes names from our catalog of the venues where tokens launch and trade. A name can be:

<table><thead><tr><th width="164.62109375">Form</th><th width="134.81640625">Example</th><th>Matches</th></tr></thead><tbody><tr><td><code>&#x3C;venue>.&#x3C;action></code></td><td><code>pump_fun.buy</code></td><td>That action on that venue</td></tr><tr><td><code>&#x3C;action></code></td><td><code>sell</code></td><td>That action on every venue that has it</td></tr><tr><td><code>&#x3C;venue></code></td><td><code>pump_swap</code></td><td>Every catalogued instruction of the venue</td></tr></tbody></table>

<table><thead><tr><th width="130.2890625">Action</th><th>Meaning</th></tr></thead><tbody><tr><td><code>create</code></td><td>A new token: a launchpad's create, or a mint or metadata created by hand</td></tr><tr><td><code>buy</code></td><td>Quote in, token out, on a venue with its own buy instruction</td></tr><tr><td><code>sell</code></td><td>Token in, quote out, likewise</td></tr><tr><td><code>swap</code></td><td>A swap whose direction is set by its accounts, so it is neither <code>buy</code> nor <code>sell</code></td></tr><tr><td><code>create_pool</code></td><td>A new pool</td></tr><tr><td><code>migrate</code></td><td>A bonding curve graduating to a pool</td></tr></tbody></table>

`buy` and `sell` exist only where the program has separate instructions for them: pump.fun, PumpSwap and Raydium LaunchLab. On AMMs and aggregators the direction is chosen by the accounts, so those are `swap`.\
A pump.fun launch usually carries the creator's first buy in the same transaction, so it matches both `pump_fun.create` and `pump_fun.buy`.

The catalog at a glance. Each cell is a name you can pass in `actions`:

<table data-header-hidden><thead><tr><th></th><th width="87.69140625"></th><th width="60.51171875"></th><th width="75.4765625"></th><th width="65.98046875"></th><th width="122.48046875"></th><th width="98.03515625"></th></tr></thead><tbody><tr><td>Venue</td><td><code>create</code></td><td><code>buy</code></td><td><code>sell</code></td><td><code>swap</code></td><td><code>create_pool</code></td><td><code>migrate</code></td></tr><tr><td><code>pump_fun</code></td><td>✓</td><td>✓</td><td>✓</td><td>✓</td><td></td><td>✓</td></tr><tr><td><code>pump_swap</code></td><td></td><td>✓</td><td>✓</td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>raydium_amm_v4</code></td><td></td><td></td><td></td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>raydium_cpmm</code></td><td></td><td></td><td></td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>raydium_clmm</code></td><td></td><td></td><td></td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>raydium_launchlab</code></td><td>✓</td><td>✓</td><td>✓</td><td></td><td></td><td>✓</td></tr><tr><td><code>meteora_dbc</code></td><td>✓</td><td></td><td></td><td>✓</td><td></td><td>✓</td></tr><tr><td><code>meteora_damm_v2</code></td><td></td><td></td><td></td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>meteora_damm_v1</code></td><td></td><td></td><td></td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>meteora_dlmm</code></td><td></td><td></td><td></td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>orca_whirlpool</code></td><td></td><td></td><td></td><td>✓</td><td>✓</td><td></td></tr><tr><td><code>jupiter</code></td><td></td><td></td><td></td><td>✓</td><td></td><td></td></tr><tr><td><code>spl_token</code></td><td>✓</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td><code>token_2022</code></td><td>✓</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td><code>token_metadata</code></td><td>✓</td><td></td><td></td><td></td><td></td><td></td></tr></tbody></table>

What each name covers, venue by venue:

**Launchpads**

**pump.fun**, `pump_fun`, program `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P`

<table><thead><tr><th width="96.3515625">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>create</code></td><td><code>create</code>, <code>create_v2</code></td></tr><tr><td><code>buy</code></td><td><code>buy</code>, <code>buy_v2</code>, <code>buy_v3</code>, <code>buy_exact_sol_in</code>, <code>buy_exact_quote_in_v2</code>, <code>buy_exact_quote_in_v3</code></td></tr><tr><td><code>sell</code></td><td><code>sell</code>, <code>sell_v2</code>, <code>sell_v3</code></td></tr><tr><td><code>swap</code></td><td><code>multi_hop_curve_swap</code></td></tr><tr><td><code>migrate</code></td><td><code>migrate</code>, <code>migrate_v2</code></td></tr></tbody></table>

**Raydium LaunchLab**, `raydium_launchlab`, program `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj`

<table><thead><tr><th width="99.9921875">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>create</code></td><td><code>initialize</code>, <code>initialize_v2</code>, <code>initialize_with_token_2022</code></td></tr><tr><td><code>buy</code></td><td><code>buy_exact_in</code>, <code>buy_exact_out</code></td></tr><tr><td><code>sell</code></td><td><code>sell_exact_in</code>, <code>sell_exact_out</code></td></tr><tr><td><code>migrate</code></td><td><code>migrate_to_amm</code>, <code>migrate_to_cpswap</code></td></tr></tbody></table>

**Meteora DBC**, `meteora_dbc`, program `dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN`

<table><thead><tr><th width="111.640625">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>create</code></td><td><code>initialize_virtual_pool_with_spl_token</code>, <code>initialize_virtual_pool_with_token2022</code>, <code>initialize_virtual_pool_with_token2022_transfer_hook</code></td></tr><tr><td><code>swap</code></td><td><code>swap</code>, <code>swap2</code>, <code>swap2_with_transfer_hook</code></td></tr><tr><td><code>migrate</code></td><td><code>migration_damm_v2</code>, <code>migrate_meteora_damm</code></td></tr></tbody></table>

**Pools**

**PumpSwap**, `pump_swap`, program `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA`

<table><thead><tr><th width="128.53125">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>buy</code></td><td><code>buy</code>, <code>buy_v2</code>, <code>buy_exact_quote_in</code>, <code>buy_exact_quote_in_v2</code></td></tr><tr><td><code>sell</code></td><td><code>sell</code>, <code>sell_v2</code></td></tr><tr><td><code>swap</code></td><td><code>multi_hop_swap</code></td></tr><tr><td><code>create_pool</code></td><td><code>create_pool</code></td></tr></tbody></table>

**Raydium AMM v4**, `raydium_amm_v4`, program `675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8`

<table><thead><tr><th width="141.85546875">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>swap_base_in</code>, <code>swap_base_out</code>, <code>swap_base_in_v2</code>, <code>swap_base_out_v2</code></td></tr><tr><td><code>create_pool</code></td><td><code>initialize2</code></td></tr></tbody></table>

**Raydium CPMM**, `raydium_cpmm`, program `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`

<table><thead><tr><th width="127.76171875">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>swap_base_input</code>, <code>swap_base_output</code></td></tr><tr><td><code>create_pool</code></td><td><code>initialize</code>, <code>initialize_with_permission</code></td></tr></tbody></table>

**Raydium CLMM**, `raydium_clmm`, program `CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK`

<table><thead><tr><th width="129.60546875">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>swap</code>, <code>swap_v2</code>, <code>swap_router_base_in</code></td></tr><tr><td><code>create_pool</code></td><td><code>create_pool</code>, <code>create_customizable_pool</code></td></tr></tbody></table>

**Meteora DAMM v2**, `meteora_damm_v2`, program `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG`

<table><thead><tr><th width="136.6796875">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>swap</code>, <code>swap2</code></td></tr><tr><td><code>create_pool</code></td><td><code>initialize_pool</code>, <code>initialize_customizable_pool</code>, <code>initialize_pool_with_dynamic_config</code></td></tr></tbody></table>

**Meteora DAMM v1**, `meteora_damm_v1`, program `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB`

<table><thead><tr><th width="140.7734375">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>swap</code></td></tr><tr><td><code>create_pool</code></td><td><code>initialize_permissionless_pool</code>, <code>initialize_permissionless_pool_with_fee_tier</code>, <code>initialize_permissionless_constant_product_pool_with_config</code>, <code>initialize_permissionless_constant_product_pool_with_config2</code>, <code>initialize_customizable_permissionless_constant_product_pool</code></td></tr></tbody></table>

**Meteora DLMM**, `meteora_dlmm`, program `LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo`

<table><thead><tr><th width="131.42578125">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>swap</code>, <code>swap2</code>, <code>swap_exact_out</code>, <code>swap_exact_out2</code>, <code>swap_with_price_impact</code>, <code>swap_with_price_impact2</code></td></tr><tr><td><code>create_pool</code></td><td><code>initialize_lb_pair</code>, <code>initialize_lb_pair2</code>, <code>initialize_customizable_permissionless_lb_pair</code>, <code>initialize_customizable_permissionless_lb_pair2</code></td></tr></tbody></table>

**Orca Whirlpool**, `orca_whirlpool`, program `whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc`

<table><thead><tr><th width="134.66796875">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>swap</code>, <code>swap_v2</code>, <code>two_hop_swap</code>, <code>two_hop_swap_v2</code></td></tr><tr><td><code>create_pool</code></td><td><code>initialize_pool</code>, <code>initialize_pool_v2</code></td></tr></tbody></table>

**Aggregators**

**Jupiter v6**, `jupiter`, program `JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4`

<table><thead><tr><th width="84.96875">Action</th><th>Instructions</th></tr></thead><tbody><tr><td><code>swap</code></td><td><code>route</code>, <code>route_v2</code>, <code>route_with_token_ledger</code>, <code>shared_accounts_route</code>, <code>shared_accounts_route_v2</code>, <code>shared_accounts_route_with_token_ledger</code>, <code>shared_accounts_exact_out_route</code></td></tr></tbody></table>

**Token programs**

Their `create` catches a token minted or described by hand, outside any launchpad.

<table data-header-hidden><thead><tr><th width="129.41015625"></th><th width="283.50390625"></th><th></th></tr></thead><tbody><tr><td>Venue</td><td>Program</td><td><code>create</code> instructions</td></tr><tr><td><code>spl_token</code></td><td><code>TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA</code></td><td><code>initialize_mint</code>, <code>initialize_mint2</code></td></tr><tr><td><code>token_2022</code></td><td><code>TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb</code></td><td><code>initialize_mint</code>, <code>initialize_mint2</code></td></tr><tr><td><code>token_metadata</code></td><td><code>metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s</code></td><td><code>create_metadata_account_v3</code>, <code>create</code></td></tr></tbody></table>

An unknown name is refused with `INVALID_ARGUMENT`. Tell us about a venue you want in the catalog; until then, use `instructions`.

**Instructions by discriminator**

`instructions` works for any program, catalogued or not. Each entry is:

<table><thead><tr><th width="160.140625">Field</th><th>Value</th></tr></thead><tbody><tr><td><code>program</code></td><td>The program id, 32 bytes</td></tr><tr><td><code>discriminator</code></td><td>The first bytes of the instruction data, up to 32. Empty matches any instruction of the program</td></tr></tbody></table>

Most programs are built with Anchor, whose discriminator is the first 8 bytes of `sha256("global:<instruction_name>")`, with the instruction name in snake\_case. It is also in the program's IDL, as `discriminator`. Other programs usually start their data with a one byte tag. Longer prefixes are allowed, so you can also match the start of the arguments.

Like keys, both fields are `bytes`: raw in gRPC code, base64 in JSON. This prints the Anchor discriminator of an instruction in base64:

```shellscript
python3 -c "import hashlib,base64,sys;print(base64.b64encode(hashlib.sha256(('global:'+sys.argv[1]).encode()).digest()[:8]).decode())" buy
```

For example, pump.fun `buy`, without using the catalog:

```json
{
  "filters": {
    "pump-buy": {
      "instructions": [
        {
          "program": "AVbg9pNmWs9E2xVovxdbqlGJy5f10v87ZV0rtv1tGLA=",
          "discriminator": "ZgY9EgHa6+o="
        }
      ]
    }
  }
}
```

**Which filter matched**

Each `Transaction` carries `filters`, the names of every filter it matched. A transaction that matches several filters is sent **once** and billed once.

**Limits**

| Limit                                  | Value                 |
| -------------------------------------- | --------------------- |
| Filters per stream                     | 16                    |
| Entries across all filters of a stream | 1,024                 |
| Discriminator                          | Up to 32 bytes        |
| Filter name                            | 1 to 64 bytes (UTF-8) |
| Open streams per API key, per region   | 8                     |

Every key, instruction and action name counts as one entry. A request over a limit, with no filters, with an empty filter, with a key or program that is not 32 bytes, or with an unknown action is refused with `INVALID_ARGUMENT`. The message says which rule it broke; see Errors.

{% hint style="info" %}
Keys, programs and discriminators are raw bytes. In gRPC code pass the bytes; in JSON tools such as grpcurl, base64-encode them. Action names are plain strings.
{% endhint %}
