Skip to main content
Your existing quoting, routing, and swap logic stays the same. The only addition: when a market has cold accounts, detect them, and prepend load instructions before the swap.

What changes


Use the light-sdk agent skill to integrate rent-free markets into your router:
For orchestration, install the general skill:

Detecting cold accounts

Add a cache for cold accounts. This can be independent from your regular account cache.
If you stream, subscribe to accounts and transactions with the Light Token Program.Hot-to-cold — in your transaction handler, listen to accounts whose balance dropped to zero. Async-fetch the 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.
For the full streaming guide, see Streaming Token Accounts and Streaming Mints.If you don’t stream, call 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 your cold_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 cold AccountInterfaces (with ColdContext), returns the AccountSpecs that create_load_instructions needs to load them.

Full example

Dependencies

Code

Key types

Reference implementation


Hot vs Cold

Depends on the number and type of cold accounts.

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 via create_load_instructions.Touching cold markets is rare. The hot path has zero overhead.

FAQ

No. Swap instructions are identical. If the market is hot, the transaction is the same as today. If cold, you prepend create_load_instructions.
Yes. You regular account cache stays the same even if a market is cold, so you can keep quoting with it.
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.
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).
Send as a Jito bundle:
Yes. Supported by Helius and Triton. Can also be self-hosted via the open-source Photon indexer.
Hot markets work all the same as long as Solana is up. Cold accounts can’t be loaded until the indexer recovers. Compression is cryptographically verifiable, and safety does not depend on the indexer.
Yes. To read state, and to build txns, simply use get_multiple_account_interfaces for the instruction’s accounts and check is_cold(). This adds a RPC round-trip but requires no streaming setup.

Questions or need hands-on support? Telegram | email | Discord