Skip to main content
When a market becomes inactive, its token accounts and related PDAs will be compressed - their state is committed and effectively frozen until a client decompresses it. While compressed, pure on-chain lookups will return uninitialized. Your indexer should keep tracking, quoting, and routing markets even if the on-chain account shows is_initialized: false, is_compressed: true. To trade a cold market, the first client must prepend an idempotent decompress “warm up” instruction.
Find the source code here.
1

Load Compressed Tokens to Hot Balance

import { Keypair } from "@solana/web3.js";
import { createRpc, bn } from "@lightprotocol/stateless.js";
import {
  createMint,
  mintTo,
  loadAta,
  getAssociatedTokenAddressInterface,
} from "@lightprotocol/compressed-token";

async function main() {
  const rpc = createRpc();
  const payer = Keypair.generate();
  await rpc.requestAirdrop(payer.publicKey, 10e9);

  const owner = Keypair.generate();
  await rpc.requestAirdrop(owner.publicKey, 1e9);

  const mintAuthority = Keypair.generate();
  const mintKeypair = Keypair.generate();
  const { mint } = await createMint(
    rpc,
    payer,
    mintAuthority.publicKey,
    9,
    mintKeypair,
  );

  await mintTo(rpc, payer, mint, owner.publicKey, mintAuthority, bn(1000));

  // Get c-token ATA address
  const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey);

  // Load compressed tokens to hot balance
  // Creates ATA if needed, returns null if nothing to load
  const signature = await loadAta(rpc, ctokenAta, owner, mint, payer);

  if (signature) {
    console.log("Loaded tokens to hot balance");
    console.log("Transaction:", signature);
  } else {
    console.log("Nothing to load");
  }
}

main().catch(console.error);

Stream Light-Mint Accounts

Toolkit to stream light-mints