Rent-Free DeFi Programs
The Light SDK pays rent-exemption for PDAs, token accounts, and mints (98% cost savings). Program logic stays the same.
Workflow
- •Clarify intent
- •Recommend plan mode, if it's not activated
- •Use
AskUserQuestionto resolve blind spots - •All questions must be resolved before execution
- •Identify references and skills
- •Match task to domain references below
- •Locate relevant documentation and examples
- •Write plan file (YAML task format)
- •Use
AskUserQuestionfor anything unclear — never guess or assume - •Identify blockers: permissions, dependencies, unknowns
- •Plan must be complete before execution begins
- •Use
- •Execute
- •Use
Tasktool with subagents for parallel research - •Subagents load skills via
Skilltool - •Track progress with
TodoWrite
- •Use
- •When stuck: spawn subagent with
Read,Glob,Grep, DeepWiki MCP access and loadskills/ask-mcp
Domain References
| Audience | Reference |
|---|---|
| Anchor pattern | references/anchor.md |
| Pinocchio pattern | references/pinocchio.md |
| Client SDK (LightProgramInterface) | references/client-sdk.md |
| Testing | references/testing.md |
| CPI instructions | references/instructions.md |
| FAQ | references/faq.md |
When to use which
| Criteria | Anchor | Pinocchio |
|---|---|---|
| Framework | anchor-lang 0.31, #[light_program] macro | pinocchio 0.9, LightProgramPinocchio derive |
| State struct | Option<CompressionInfo> + LightAccount derive | CompressionInfo (non-optional) + bytemuck::Pod + Zeroable + #[repr(C)] |
| Account creation | #[light_account(init, ...)] attribute or CreateTokenAccountCpi | CreateTokenAccountCpi, CreateMints batch pattern |
| Compress/decompress handlers | Auto-generated by #[light_program] macro | Route ProgramAccounts::COMPRESS_ACCOUNTS_IDEMPOTENT etc. in entrypoint |
| Program ID constant | Not needed (macro derives it) | pub const ID: Pubkey = pubkey_array!(...) + LIGHT_CPI_SIGNER required |
| Dependencies | light-sdk, light-sdk-macros, light-token, light-anchor-spl | light-account-pinocchio, light-token-pinocchio, bytemuck |
Hot vs Cold Model
After extended inactivity (multiple epochs without writes), accounts auto-compress to cold state. Programs only interact with hot accounts. Clients load cold accounts back on-chain via create_load_instructions.
| Hot (active) | Cold (inactive) | |
|---|---|---|
| Storage | On-chain | Compressed |
| Latency | Normal | +0-200ms |
| Tx size | Normal | +100-2400 bytes |
| CU | Normal | +15k-400k CU |
| Program code | No change | No change |
The hot path has zero overhead.
External References
| Resource | Link |
|---|---|
| Anchor AMM reference | cp-swap-reference |
| Pinocchio swap reference | pinocchio-swap |