This guide is for teams building custom data pipelines (aggregators, market makers).
If you just need account lookups, use
get_account_interface instead.Architecture
Light token accounts share the same base layout as SPL Token (165 bytes), so you can use your existing parser. The streaming setup requires two gRPC subscriptions, both targeting the Light Token Program:| Subscription | Detects | How |
|---|---|---|
Account sub (owner: cToken...) | Hot state + cold-to-hot | Pubkey cache lookup |
Transaction sub (account_include: cToken...) | Hot-to-cold | Balance heuristic (pre > 0, post == 0) |
compress_and_close changes the owner to System Program, which the account
subscription no longer matches).
Parsing
Streaming
Cargo.toml
Detecting transitions
Hot-to-cold
For each transaction update, find accounts whose lamport balance dropped to zero. Thecache.remove call ensures only accounts you’re already tracking are processed:
Two data structures:
cache: HashMap<[u8; 32], T>— hot account state (for quoting/routing)cold_cache: HashMap<[u8; 32], AccountInterface>— cold accounts withColdContext(for building load instructions)
cache.remove filters out unrelated closures in the same transaction. No discriminator
check is needed — compress_and_close always drains lamports to zero.
To build transactions that decompress cold accounts, see
Router Integration.
Cold-to-hot
When a token account is decompressed, the account subscription delivers the re-created account. Match its pubkey againstcold_cache:
Point queries
getAccountInfo returns null for cold accounts. get_account_interface() races
hot and cold lookups and returns raw account bytes that work with your standard SPL parser:
Data layout
165 bytes base, identical to SPL Token Account.| Field | Offset | Size |
|---|---|---|
mint | 0 | 32 |
owner | 32 | 32 |
amount | 64 | 8 |
delegate | 72 | 36 |
state | 108 | 1 |
is_native | 109 | 12 |
delegated_amount | 121 | 8 |
close_authority | 129 | 36 |
account_type | 165 | 1 |
account_type = 2 at byte 165 indicates extensions follow (borsh-encoded Option<Vec<ExtensionStruct>>).