What changes
| Hot market (99%+) | Cold market | |
|---|---|---|
| Quoting | No change | No change |
| Swap instruction | No change | No change |
| Transaction | No change | Prepend create_load_instructions |
Detecting cold accounts
Add a cache for cold accounts. This can be separate from your regular account cache.| Subscription | Detects |
|---|---|
Account sub (owner: cToken...) | Hot state + cold-to-hot |
Transaction sub (account_include: cToken...) | Hot-to-cold |
AccountInterface
(which includes the ColdContext needed for load instructions):
find_closed_accounts checks pre_balances[i] > 0 && post_balances[i] == 0 across all transaction
keys (including ALT-loaded addresses). See full implementation.
Cold-to-hot — your existing account subscription picks up the hot account again. No cache changes needed because account state does not change while cold.
get_multiple_account_interfaces at swap time and check is_cold() to detect cold accounts.
Building swap transactions with cold accounts
When you detect cold accounts in a market (via yourcold_set or via is_cold() on fetched accounts),
fetch their ColdContext via get_account_interface and build load instructions.
The LightProgramInterface trait
Each rent-free AMM SDK exposes this trait. It tells you which accounts an instruction touches and how to build load specs for cold ones.instruction_accounts— returns the pubkeys the instruction reads/writes.load_specs— given coldAccountInterfaces (withColdContext), returns theAccountSpecs thatcreate_load_instructionsneeds to bring them back on-chain.
Full example
Dependencies
Code
Key types
| Type | Source | Purpose |
|---|---|---|
AccountInterface | light-client | Account data with optional ColdContext |
LightProgramInterface | light-client | Trait that AMM SDKs implement |
AccountSpec | light-client | Input to create_load_instructions |
Reference implementation
| Resource | Link |
|---|---|
| AMM Program | cp-swap-reference |
| LightProgramInterface Trait Impl | CpSwapSdk |
Hot vs Cold
| Hot | Cold | |
|---|---|---|
| On-chain | Yes | Ledger (compressed) |
| Quote | Works | Works |
| Swap | Direct | Load first / Bundle |
| Latency | Normal | +0-200ms* |
| Tx size | Normal | +100-2400 bytes* |
| CU | Normal | +15k-400k CU* |
When does a market go cold?
Accounts go cold after extended inactivity. Their virtual rent balance drops below a threshold and miners compress them onto the Solana ledger. They stay cold until any client loads them back in-flight viacreate_load_instructions.
Touching cold markets is rare. The hot path has zero overhead.
FAQ
Do I need to change my swap instructions?
Do I need to change my swap instructions?
No. Swap instructions are identical. If the market is hot, the transaction
is the same as today. If cold, you prepend
create_load_instructions.Can I quote cold markets?
Can I quote cold markets?
Yes.
get_account_interface returns full account data regardless of hot/cold.
Quoting works the same.Do rent-free markets increase latency?
Do rent-free markets increase latency?
Hot (common path): No.Cold: Loading accounts adds 1-200ms depending on whether a validity proof
is needed. If load + swap exceed Solana’s 1232 byte limit, use Jito bundles.
How long do accounts stay hot after loading?
How long do accounts stay hot after loading?
Until they go inactive again. Each write resets the timer. The inactivity
threshold is configurable by the program owner (e.g. 24h of no writes).
What if load + swap exceed Solana's tx size limit?
What if load + swap exceed Solana's tx size limit?
Send as a Jito bundle:
Do RPC providers support get_account_interface?
Do RPC providers support get_account_interface?
Yes. Supported by Helius and Triton. Can also be self-hosted via the
open-source Photon indexer.
What if the indexer is down?
What if the indexer is down?
Hot markets work as long as Solana is up. Cold accounts can’t be loaded until
the indexer recovers. Compression is cryptographically verifiable — integrity
doesn’t depend on the indexer.
I don't stream. Can I still support cold markets?
I don't stream. Can I still support cold markets?
Yes. At swap time, call
get_multiple_account_interfaces for the instruction’s
accounts and check is_cold(). This adds a round-trip per swap but requires
no streaming setup.