- Use
get_account_interfaceinstead ofget_account - Store
AccountInterfacein your cache - Prepend
create_load_instructionswhen accounts are cold
Step 1: Use get_account_interface
get_account_interface is a new RPC endpoint that returns a superset of get_account. AccountInterface stores additional info Option<ColdContext> that you will need later.
Step 2: Store Account Interfaces in your cache.
All rent-free programs implement theLightProgramInterface trait.
This trait helps you:
- Maintain a cache of
&[AccountInterface] - Load cold accounts into the onchain account space when building Swap transactions.
Step 3: Load cold accounts when building Swap instructions
When building Swap instructions, prepend acreate_load_instructions call.
This only adds latency if accounts are cold.
Full Example
Dependencies
Code
Key Types
| Type | Source | Purpose |
|---|---|---|
Rpc trait | light-client | RPC client with get_account_interface methods |
AccountInterface | light-client | Unified hot/cold account type |
LightProgramInterface | light-client | Trait that program SDKs implement |
AccountSpec | light-client | Specifies account load requirements |
Reference Implementation
| Resource | Link |
|---|---|
| AMM Program | cp-swap-reference |
| LightProgramInterface Trait Impl | CpSwapSdk |
| Client Test | program.rs |
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?
A market is “cold” after it has been compressed by a miner. Accounts become eligible for compression when inactive (e.g., after 24h without lamport bumps from fee payers), causing the virtual rent balance to fall below threshold. To ensure swaps execute regardless of whether the market is hot or cold, always prependcreate_load_instructions to the swap transaction. This no-ops
if the market is hot.
Error Handling
FAQ
Do I need to change my swap instructions?
Do I need to change my swap instructions?
No. In all cases swap instructions stay the same.
If the market is hot (active), the transaction is identical to today (UX, CU, latency, txn size,…).
If the market is cold (inactive) you additionally prepend
create_load_instructions.Can I quote cold markets?
Can I quote cold markets?
Yes.
get_account_interface is a
superset of get_account and returns full account state via the same Account
type, regardless of whether the account is hot or cold. Quoting works all the same. Do rent-free markets increase latency?
Do rent-free markets increase latency?
On hot path: No. On
cold path: Yes, +0-200ms for fetching validity proof. Depending on the number of
cold accounts, and the type of accounts, load instructions may exceed Solana’s
current txn size limit. In this case we recommend creating Jito bundles to
reduce latency. Future updates will continue to reduce txn size and CU usage
for loading cold accounts.
Does loading cold accounts exceed Solana's txn size limit?
Does loading cold accounts exceed Solana's txn size limit?
In some cases, yes. You can detect this at runtime by inspecting the Instructions returned by
create_load_instructions.Note that the SDK deduplicates many of the account keys over the wire, so
instructions that may appear large in isolation will be incremental when
combined with other instructions, such as Swap and Deposit.If load instructions + swap instructions exceed Solana’s 1232 byte limit, send as a Jito bundle:Do RPC providers support these interface endpoints?
Do RPC providers support these interface endpoints?
The relevant RPC methods are supported by providers such as Helius and Triton and can also be self-hosted via the open source Photon indexer. Helius Labs maintains the Photon indexer implementation.
What if the indexer is down?
What if the indexer is down?
Hot markets work all the same as long as Solana is up. Cold accounts cannot be loaded into hot state until your indexer or RPC provider recovers.
Note that compression is cryptographically verifiable, so integrity and safety are not dependent on the indexer or any other external service beyond the onchain protocol.