@laitszkin/apollo-toolkit 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -32,6 +32,7 @@ This repository enables users to install and run a curated set of reusable agent
32
32
  - Users can learn new or improved skills from recent Codex conversation history.
33
33
  - Users can audit and maintain the skill catalog itself, including dependency classification and shared-skill extraction decisions.
34
34
  - Users can summarize mistakes into a learning error book and render it to PDF.
35
+ - Users can build or review marginfi protocol integrations using official SDK, CLI, protocol, and The Arena documentation.
35
36
  - Users can create or maintain `AGENTS.md` so project constraints stay aligned with the repository.
36
37
  - Users can turn novel content into a loopable short-form video with generated assets.
37
38
  - Users can publish structured GitHub issues or feature proposals with auth fallbacks.
@@ -42,7 +43,9 @@ This repository enables users to install and run a curated set of reusable agent
42
43
  - Users can process GitHub pull request review comments and resolve addressed threads.
43
44
  - Users can perform repository-wide code reviews and publish confirmed findings as GitHub issues.
44
45
  - Users can schedule a bounded project runtime window, stop it automatically, and analyze module health from captured logs.
46
+ - Users can build and maintain Solana programs and Rust clients using official Solana development workflows.
45
47
  - Users can add focused observability to opaque workflows through targeted logs, metrics, traces, and tests.
48
+ - Users can build against Jupiter's official Solana swap, token, price, lending, trigger, recurring, and portfolio APIs with an evidence-based development guide.
46
49
  - Users can debug software systematically by reproducing causes, validating fixes, and testing outcomes.
47
50
  - Users can generate 30-60 second short videos directly from text prompts.
48
51
  - Users can prepare and publish versioned releases with changelog and tag workflows.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to this repository are documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [v2.6.0] - 2026-03-20
8
+
9
+ ### Added
10
+ - Add `jupiter-development` for building Jupiter-based Solana integrations from current official docs, including swap, token, price, lend, trigger, recurring, and portfolio surfaces.
11
+ - Add `marginfi-development` for building or reviewing marginfi integrations with official SDK, CLI, protocol, and The Arena references.
12
+ - Add `solana-development` for native Solana Rust programs and Rust client workflows grounded in official Solana documentation.
13
+
14
+ ### Changed
15
+ - Update `learn-skill-from-conversations` to prefer inventorying the current skill catalog, weighting user corrections and error-driven lessons more heavily, and tightening when to update an existing skill versus creating a new one.
16
+ - Update `codex-memory-manager` so memory reports include already-stored relevant preferences when users ask what memory exists or why a known preference was omitted.
17
+ - Refresh new protocol reference snapshots against current official Jupiter, marginfi, and Solana docs before release.
18
+
7
19
  ## [v2.5.0] - 2026-03-19
8
20
 
9
21
  ### Changed
package/README.md CHANGED
@@ -21,8 +21,10 @@ A curated skill catalog for Codex, OpenClaw, and Trae with a managed installer t
21
21
  - generate-spec
22
22
  - harden-app-security
23
23
  - improve-observability
24
+ - jupiter-development
24
25
  - learn-skill-from-conversations
25
26
  - learning-error-book
27
+ - marginfi-development
26
28
  - maintain-project-constraints
27
29
  - maintain-skill-catalog
28
30
  - novel-to-short-video
@@ -34,6 +36,7 @@ A curated skill catalog for Codex, OpenClaw, and Trae with a managed installer t
34
36
  - review-change-set
35
37
  - review-codebases
36
38
  - scheduled-runtime-health-check
39
+ - solana-development
37
40
  - systematic-debug
38
41
  - text-to-short-video
39
42
  - version-release
@@ -114,6 +114,8 @@ python3 ~/.codex/skills/codex-memory-manager/scripts/sync_memory_index.py \
114
114
  - which categories were created or updated
115
115
  - whether a new category was introduced
116
116
  - whether the AGENTS memory index changed
117
+ - When the user asks what memory exists or asks why a known preference was not mentioned, include the already-stored preferences that are directly relevant to the question instead of summarizing only newly added entries.
118
+ - When a stable preference already existed and was still reinforced by recent chats, say that it remains stored and point to the category where it lives.
117
119
  - If no durable preferences were found, say so explicitly and avoid creating placeholder memory files.
118
120
 
119
121
  ## Guardrails
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: jupiter-development
3
+ description: Build integrations against Jupiter's official Solana APIs and SDKs, including Ultra Swap, Metis Swap, Tokens API V2, Price API V3, Lend, Trigger, Recurring, and Portfolio. Use when implementing Jupiter-based swaps, token search, pricing, lending, DCA, limit-order, or portfolio features, or when updating code that depends on Jupiter official developer docs.
4
+ ---
5
+
6
+ # Jupiter Development
7
+
8
+ ## Dependencies
9
+
10
+ - Required: none.
11
+ - Conditional: none.
12
+ - Optional: none.
13
+ - Fallback: If official Jupiter docs are unavailable, stop and report the missing source instead of guessing endpoint behavior.
14
+
15
+ ## Standards
16
+
17
+ - Evidence: Treat `https://dev.jup.ag/llms.txt` and linked official pages as the source of truth; re-check them when the task depends on current API behavior.
18
+ - Execution: Identify the exact Jupiter product first, then implement against the narrowest official API or SDK that fits the job.
19
+ - Quality: Prefer the default happy-path integrations before custom transaction assembly, and call out routing, auth, fee, and rate-limit tradeoffs explicitly.
20
+ - Output: Leave the user with working integration changes plus a short note covering which Jupiter surface was used and which official docs were followed.
21
+
22
+ ## Goal
23
+
24
+ Implement Jupiter-backed Solana features safely by following the current official developer documentation instead of relying on stale examples or assumptions.
25
+
26
+ ## Required Workflow
27
+
28
+ ### 1) Reconfirm the official surface before coding
29
+
30
+ - Start from `https://dev.jup.ag/llms.txt` to discover the current product map and page URLs.
31
+ - Read only the product pages needed for the task.
32
+ - If the task depends on exact request or response fields, follow through to the linked API reference or OpenAPI page before editing code.
33
+
34
+ ### 2) Choose the right Jupiter integration path
35
+
36
+ - For token swaps, default to Ultra Swap.
37
+ - Use `GET /ultra/v1/order` plus `POST /ultra/v1/execute` for the standard path with the least integration work.
38
+ - Use Metis Swap only when the app must own quote-to-transaction construction, compose instructions, or integrate through CPI/Flash Fill style flows.
39
+ - For token discovery and token metadata, use Tokens API V2.
40
+ - Use search for symbol, name, or mint lookup.
41
+ - Use tag/category/recent endpoints for discovery experiences such as verified lists, trending tokens, or newly tradable assets.
42
+ - For USD token pricing, use Price API V3.
43
+ - Expect `null` or missing prices for assets that Jupiter considers unreliable.
44
+ - Do not invent fallback prices without telling the user.
45
+ - For lending, use Jupiter Lend.
46
+ - Use the REST API for Earn when HTTP access is enough.
47
+ - Use `@jup-ag/lend` and `@jup-ag/lend-read` when the task needs instruction building, on-chain composition, flashloans, Borrow flows, or read-side analytics.
48
+ - For advanced trading automations, use the product-specific APIs instead of overloading Swap.
49
+ - Trigger for limit-order and stop-style flows.
50
+ - Recurring for DCA.
51
+ - Portfolio for wallet position aggregation.
52
+
53
+ ### 3) Apply Jupiter-specific guardrails while implementing
54
+
55
+ - Treat Jupiter hostnames and auth rules as time-sensitive.
56
+ - Current official docs still show some `lite-api.jup.ag` quick-start examples.
57
+ - Current migration and Portal docs recommend `api.jup.ag` with `x-api-key`.
58
+ - Reconfirm the exact hostname and auth rule for the chosen product before coding.
59
+ - Respect Jupiter Portal rate limits and keep API keys in configuration rather than source control.
60
+ - Do not add optional swap parameters blindly.
61
+ - Payer, referral, fee, and router-selection fields can change routing, fee behavior, or gasless support.
62
+ - Re-read the exact product page before shipping these options.
63
+ - Match the fee model to the integration path.
64
+ - Ultra handles the quote and execution flow end to end.
65
+ - Metis gives more transaction control but also pushes more assembly responsibility onto the integrator.
66
+ - Treat Jupiter token and price data as curated but evolving.
67
+ - Tokens V2 responses can change as Jupiter improves the schema.
68
+ - Price V3 intentionally withholds unreliable prices.
69
+ - For Jupiter Lend advanced recipes, expect versioned transactions, address lookup tables, and sometimes extra compute budget.
70
+ - Never commit private keys. Use environment variables, wallet adapters, secure signers, or managed key systems.
71
+
72
+ ### 4) Verify the integration path end to end
73
+
74
+ - Confirm the base URL, auth header, and required parameters match the official docs you used.
75
+ - Verify that any routing, payer, referral, or fee assumptions still hold after optional parameters are added.
76
+ - When building transactions manually, verify quote endpoint compatibility, instruction order, compute budget, address lookup tables, and signing flow.
77
+ - When the task involves on-chain actions, report any remaining environment needs clearly, such as API keys, RPC endpoints, or wallet secrets that were intentionally not embedded.
78
+
79
+ ## Reference Files
80
+
81
+ - Read `references/official-docs.md` for the condensed official guidance and page map before diving into deeper Jupiter pages.
82
+
83
+ ## Output Expectations
84
+
85
+ When finishing a Jupiter task:
86
+
87
+ - state which Jupiter product surface was used
88
+ - mention the main official pages consulted
89
+ - call out any known tradeoffs such as rate limits, routing restrictions, null prices, or SDK versus REST constraints
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Jupiter Development"
3
+ short_description: "Build against Jupiter's official Solana APIs and SDKs."
4
+ default_prompt: "Use $jupiter-development to build or update this Jupiter integration by confirming the current official docs first, choosing the correct Jupiter API or SDK surface, and implementing with the right routing, auth, rate-limit, and transaction-construction guardrails."
@@ -0,0 +1,157 @@
1
+ # Jupiter Official Docs Reference
2
+
3
+ Snapshot source: official Jupiter developer docs reviewed on 2026-03-20 from `https://dev.jup.ag/llms.txt` and linked first-party pages.
4
+
5
+ ## 1. Always refresh from these official entry points
6
+
7
+ - Docs index: `https://dev.jup.ag/llms.txt`
8
+ - Get started: `https://dev.jup.ag/get-started`
9
+ - Developer portal and API keys: `https://dev.jup.ag/portal/setup.md`
10
+ - Rate limits: `https://dev.jup.ag/portal/rate-limit.md`
11
+ - Ultra docs root: `https://dev.jup.ag/docs/ultra-api`
12
+ - Swap docs root: `https://dev.jup.ag/docs/swap/index.md`
13
+ - Tokens docs root: `https://dev.jup.ag/docs/tokens/v2/token-information.md`
14
+ - Price docs root: `https://dev.jup.ag/docs/price/index.md`
15
+ - Lend docs root: `https://dev.jup.ag/docs/lend/index.md`
16
+
17
+ If a task depends on exact schemas, jump from those pages into the matching OpenAPI reference before coding.
18
+
19
+ ## 2. Product selection cheatsheet
20
+
21
+ | Need | Official Jupiter surface | Notes |
22
+ | --- | --- | --- |
23
+ | Best default swap flow | Ultra API `/ultra/v1/order` + `/ultra/v1/execute` | Current get-started docs point new integrators here first. |
24
+ | Custom swap transaction or CPI composition | Metis Swap API | Use the lower-level swap docs only when the app must own quote/build behavior or compose instructions manually. |
25
+ | Token search, metadata, verification, discovery | Tokens API V2 | Search by symbol, name, mint, tag, category, or recency. |
26
+ | USD token prices | Price API V3 | Heuristic price engine; unreliable tokens may return `null`. |
27
+ | Deposit-and-earn yield | Jupiter Lend Earn API or SDK | REST is enough for simple Earn flows; SDK gives instruction-level control. |
28
+ | Borrow, repay, flashloan, or CPI lending | `@jup-ag/lend` plus `@jup-ag/lend-read` | Use SDK and product docs for instruction building and analytics. |
29
+ | Limit orders / TP-SL style automation | Trigger API | Trigger V2 uses JWT auth; Trigger V1 remains documented for legacy flows. |
30
+ | DCA | Recurring API | Time-based recurring orders. |
31
+ | Wallet position aggregation | Portfolio API | Beta status. |
32
+
33
+ ## 3. Auth and operational rules
34
+
35
+ - Current official docs say `api.jup.ag` requires `x-api-key`.
36
+ - Current get-started examples still show public `lite-api.jup.ag` usage for some flows, while Jupiter's update/migration docs say deprecation was postponed and migration toward `api.jup.ag` is in progress.
37
+ - Treat hostname choice as a time-sensitive implementation detail and refresh the exact product page before coding.
38
+ - Generate keys at `https://portal.jup.ag`.
39
+ - Rate limits are per account, not per key.
40
+ - Free tier: 60 requests per 60 seconds.
41
+ - Pro tiers: 10-second sliding windows; the Price API gets its own bucket on Pro.
42
+ - Do not assume that creating more API keys increases throughput.
43
+
44
+ ## 4. Ultra and Metis swap essentials
45
+
46
+ Primary docs:
47
+
48
+ - `https://dev.jup.ag/get-started`
49
+ - `https://dev.jup.ag/docs/ultra-api`
50
+ - `https://dev.jup.ag/docs/swap/index.md`
51
+ - `https://dev.jup.ag/docs/swap/get-quote`
52
+ - `https://dev.jup.ag/docs/swap/build-swap-transaction`
53
+ - `https://dev.jup.ag/docs/swap/build-swap-transaction#build-your-own-transaction-with-flash-fill-or-cpi`
54
+
55
+ ### Default path: Ultra API
56
+
57
+ - Current get-started guidance points integrators to `GET /ultra/v1/order` and `POST /ultra/v1/execute`.
58
+ - Use this path for the least integration work and the official default trade flow.
59
+
60
+ ### Advanced path: Metis Swap API
61
+
62
+ - Use the lower-level swap docs when the integrator must own quote handling, transaction assembly, CPI composition, or Flash Fill style flows.
63
+ - Reconfirm the current endpoint family on the exact swap page you use because Jupiter has been migrating between public and Portal-backed hosts.
64
+
65
+ ### Routing and option guardrails
66
+
67
+ - Optional payer, referral, fee, or router-selection parameters are not neutral.
68
+ - Re-read the exact product page before enabling them because they can affect routing, fees, or gasless support.
69
+ - Do not assume all examples on older swap pages still describe the default production path.
70
+
71
+ ## 5. Tokens API V2 essentials
72
+
73
+ Base URL: `https://api.jup.ag/tokens/v2`
74
+
75
+ Primary docs:
76
+
77
+ - `https://dev.jup.ag/docs/tokens/v2/token-information.md`
78
+ - `https://dev.jup.ag/docs/tokens/organic-score.md`
79
+
80
+ Important behaviors:
81
+
82
+ - Search supports symbol, name, and mint-address lookup.
83
+ - Tag queries support curated groups such as `verified` and `lst`.
84
+ - Category queries support discovery sets such as `toporganicscore`, `toptraded`, and `toptrending`.
85
+ - Recent tokens are keyed off first pool creation time, not token mint time.
86
+ - Responses include metadata and market-quality signals such as organic score, holder count, market cap, liquidity, and trading stats.
87
+ - The docs explicitly warn that the response schema may change as the API evolves.
88
+
89
+ Organic score is meant to represent genuine token activity and health using wallet, liquidity, and trading signals while filtering out bot-like or wash-trade patterns.
90
+
91
+ ## 6. Price API V3 essentials
92
+
93
+ Base URL: `https://api.jup.ag/price/v3`
94
+
95
+ Primary docs:
96
+
97
+ - `https://dev.jup.ag/docs/price/index.md`
98
+ - `https://dev.jup.ag/docs/price/v3.md`
99
+ - `https://dev.jup.ag/guides/how-to-get-token-price.md`
100
+
101
+ Important behaviors:
102
+
103
+ - Price V3 derives prices from the last swapped price and validates them with liquidity and market-health heuristics.
104
+ - Up to 50 mint addresses can be queried per request according to the official guide.
105
+ - Missing or `null` prices are expected for tokens that fail Jupiter's reliability checks.
106
+ - Do not treat missing prices as transient transport errors by default.
107
+
108
+ ## 7. Jupiter Lend essentials
109
+
110
+ Primary docs:
111
+
112
+ - `https://dev.jup.ag/docs/lend/index.md`
113
+ - `https://dev.jup.ag/docs/lend/api-vs-sdk.md`
114
+ - `https://dev.jup.ag/docs/lend/program-addresses.md`
115
+ - `https://dev.jup.ag/docs/lend/advanced/index.md`
116
+
117
+ Packages mentioned by the official docs:
118
+
119
+ - `@jup-ag/lend`
120
+ - `@jup-ag/lend-read`
121
+ - `@solana/web3.js`
122
+
123
+ Practical split:
124
+
125
+ - Use the REST API for straightforward Earn deposit and withdrawal flows.
126
+ - Use the SDK when you need Borrow flows, CPI, flashloans, batched operations, address lookup tables, or read-side analytics.
127
+ - For advanced recipes such as multiply, unwind, vault swap, and flashloans, expect large multi-instruction transactions and add compute budget when needed.
128
+ - Public RPC endpoints are not recommended for production; the docs suggest dedicated providers.
129
+
130
+ ## 8. Other important Jupiter APIs
131
+
132
+ ### Trigger
133
+
134
+ - Docs root: `https://dev.jup.ag/docs/trigger/index.md`
135
+ - Trigger V2 uses a challenge-response auth flow and returns a JWT for subsequent requests.
136
+ - Use it for single price orders, OCO, and OTOCO flows.
137
+
138
+ ### Recurring
139
+
140
+ - Docs root: `https://dev.jup.ag/docs/recurring/index.md`
141
+ - Use it for time-based DCA orders.
142
+ - Jupiter keeper bots handle recurring execution after setup.
143
+
144
+ ### Portfolio
145
+
146
+ - Docs root: `https://dev.jup.ag/docs/portfolio/index.md`
147
+ - Beta API for wallet positions across Solana protocols, including Jupiter-specific positions.
148
+
149
+ ## 9. Implementation checklist
150
+
151
+ - Confirm the exact Jupiter product surface first.
152
+ - Confirm the latest official page and API version before editing code.
153
+ - Confirm whether the chosen host requires `x-api-key`, and keep any key out of source control.
154
+ - Preserve the default routing path unless the product requirement truly needs advanced payer, fee, or router controls.
155
+ - Treat `null` token prices as a valid product outcome.
156
+ - Use SDK flows for Jupiter Lend borrow, CPI, flashloan, and analytics work.
157
+ - Report any remaining API-key, RPC, or wallet requirements explicitly.
@@ -15,7 +15,7 @@ description: Learn and evolve the local skill library from recent Codex conversa
15
15
  ## Standards
16
16
 
17
17
  - Evidence: Extract recent Codex session history first and derive reusable lessons only from actual conversation patterns.
18
- - Execution: Prefer creating a new skill unless the overlap with an existing skill is clearly strong, then apply the change through `skill-creator`.
18
+ - Execution: Inventory the current skill catalog before editing, prioritize repeated requests, user corrections, and reported errors, then prefer a focused update to the strongest related skill or create a new skill only when the overlap is weak.
19
19
  - Quality: Take no action when there are no recent sessions, avoid unrelated broad refactors, and validate every changed skill.
20
20
  - Output: Report the analyzed sessions, extracted lessons, created or updated skills, and the reasoning behind each decision.
21
21
 
@@ -46,16 +46,25 @@ python3 ~/.codex/skills/learn-skill-from-conversations/scripts/extract_recent_co
46
46
  ### 2) Derive reusable lessons
47
47
 
48
48
  - Identify repeated user needs, recurring friction, and repeated manual workflows.
49
+ - Give extra weight to moments where the user corrected the agent, rejected an earlier interpretation, or pointed out a missing preference or requirement.
50
+ - Give extra weight to user-reported errors, regressions, or avoidable mistakes, then ask how a skill can prevent repeating that failure mode.
49
51
  - Ignore one-off issues that do not provide reusable value.
52
+ - Distinguish between:
53
+ - repeated trigger intent that deserves a new skill
54
+ - repeated workflow fragments across multiple skills that should be extracted into a shared skill
55
+ - skill gaps that are better handled by tightening an existing skill's guardrails
50
56
 
51
57
  ### 3) Decide new skill vs existing skill (default: new skill)
52
58
 
59
+ - First read the relevant skills already present in the working repository so you do not create a duplicate under a different name.
53
60
  - Prefer creating a new skill.
54
61
  - Edit an existing skill only when the lesson is strongly related.
55
62
  - Treat relation as strong only when all three conditions hold:
56
63
  - Same primary trigger intent.
57
64
  - At least 70% workflow overlap.
58
65
  - The update does not dilute the existing skill's scope.
66
+ - When the recurring lesson is mainly about preventing a known mistake, prefer updating the existing skill that should have prevented it instead of creating a parallel skill.
67
+ - When several skills repeat the same narrow workflow fragment, prefer extracting that fragment into a dedicated shared skill instead of copying the same guidance again.
59
68
  - If uncertain, create a new skill instead of expanding an old one.
60
69
 
61
70
  ### 4) Apply changes through skill-creator
@@ -76,7 +85,7 @@ python3 ~/.codex/skills/.system/skill-creator/scripts/quick_validate.py <skill-p
76
85
 
77
86
  ### 6) Report result
78
87
 
79
- - Summarize analyzed sessions, extracted lessons, created/updated skills, and why each decision was made.
88
+ - Summarize analyzed sessions, repeated needs, user corrections, error-driven lessons, created/updated skills, and why each decision was made.
80
89
 
81
90
  ## Guardrails
82
91
 
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LaiTszKin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Marginfi Development
2
+
3
+ `marginfi-development` is a reusable skill for building or reviewing integrations on the marginfi protocol with official documentation as the source of truth.
4
+
5
+ It helps an agent:
6
+
7
+ 1. Choose the correct marginfi development surface.
8
+ 2. Reconfirm official addresses, groups, and environment details.
9
+ 3. Implement or explain deposits, borrows, repayments, withdrawals, flash loans, liquidations, or permissionless banks.
10
+ 4. Map raw `mfi-v2` instructions and errors when SDK helpers are not enough.
11
+
12
+ ## Repository layout
13
+
14
+ - `SKILL.md`: trigger rules, workflow, and guardrails
15
+ - `agents/openai.yaml`: agent-facing metadata
16
+ - `references/official-development-notes.md`: condensed official development guidance
17
+ - `references/source-index.md`: quick source routing for official docs
18
+
19
+ ## Main use cases
20
+
21
+ Use this skill for:
22
+
23
+ - marginfi SDK integration work
24
+ - Solana bots or backends that interact with marginfi
25
+ - bank configuration and The Arena permissionless-bank flows
26
+ - flash-loan or liquidation implementation reviews
27
+ - raw instruction or error mapping against `mfi-v2`
28
+
29
+ ## License
30
+
31
+ MIT. See `LICENSE`.
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: marginfi-development
3
+ description: Build or analyze integrations on the Solana-based marginfi protocol using the official TypeScript SDK, Rust CLI, and protocol docs. Use when implementing or reviewing marginfi deposits, withdrawals, borrows, repayments, flash loans, liquidations, permissionless banks, bank configuration, account-health logic, or raw instruction mapping, and ground the work in official marginfi documentation before coding.
4
+ ---
5
+
6
+ # Marginfi Development
7
+
8
+ ## Dependencies
9
+
10
+ - Required: none.
11
+ - Conditional: `answering-questions-with-research` when the user needs marginfi guidance combined with fresh external verification or local repository discovery.
12
+ - Optional: none.
13
+ - Fallback: If official docs do not confirm a requested parameter, address, or workflow, say so explicitly instead of guessing.
14
+
15
+ ## Standards
16
+
17
+ - Evidence: Start from official marginfi docs and official source links, and re-check time-sensitive values before hardcoding them.
18
+ - Execution: Pick the correct integration surface first (TypeScript SDK, Rust CLI, or raw program instructions), then scope the exact bank, group, account, and environment involved.
19
+ - Quality: Preserve Solana and Anchor conventions, validate margin account health assumptions, and never invent bank config or oracle defaults.
20
+ - Output: Provide copy-pastable implementation steps, the exact official source pages consulted, and concrete caveats for unresolved risks.
21
+
22
+ ## Goal
23
+
24
+ Build or review marginfi integrations with the smallest correct implementation that still respects the protocol's account model, bank risk parameters, oracle rules, and operational constraints.
25
+
26
+ ## Workflow
27
+
28
+ ### 1) Classify the task before coding
29
+
30
+ Map the request to one of these paths:
31
+
32
+ - application integration with the TypeScript SDK
33
+ - operational/admin work with the Rust CLI
34
+ - raw on-chain instruction work against `mfi-v2`
35
+ - permissionless bank creation in The Arena
36
+ - liquidations, health, or risk-model analysis
37
+ - flash loan composition
38
+
39
+ Then load only the matching reference sections from `references/official-development-notes.md`.
40
+
41
+ ### 2) Reconfirm official docs when values can drift
42
+
43
+ Re-check live official docs when the task depends on:
44
+
45
+ - current program or group addresses
46
+ - package names or environment configs
47
+ - current bank parameters or listing rules
48
+ - The Arena flows or permissionless-bank requirements
49
+
50
+ Use `references/source-index.md` to jump to the right official page quickly.
51
+
52
+ ### 3) Choose the correct development surface
53
+
54
+ #### TypeScript SDK
55
+
56
+ Use for frontends, bots, services, scripts, or integration tests.
57
+
58
+ - Start with `MarginfiClient.fetch(getConfig(...), wallet, connection)`.
59
+ - Fetch or create the authority's marginfi account before user actions.
60
+ - Resolve banks by token symbol, mint, or public key before depositing, borrowing, repaying, or withdrawing.
61
+ - Prefer SDK helpers for instruction construction, transaction processing, flash loans, and account reloads.
62
+
63
+ #### Rust CLI
64
+
65
+ Use for operator workflows, group or bank administration, and quick protocol interaction from the terminal.
66
+
67
+ - Configure the correct profile and environment first.
68
+ - Use the CLI for account creation, deposits, borrows, repayments, withdrawals, transfers, emissions setup, and bank-management flows.
69
+ - When creating or updating banks, provide explicit config values; do not infer hidden defaults.
70
+
71
+ #### Raw program work
72
+
73
+ Use when you need exact instruction names, account constraints, or error mapping.
74
+
75
+ - Read the `mfi-v2` instruction and error sections first.
76
+ - Keep flash-loan state transitions and end-instruction indexing exact.
77
+ - Map protocol errors back to the user-visible cause instead of returning opaque Solana failures.
78
+
79
+ ### 4) Apply the task-specific playbook
80
+
81
+ #### Deposits / borrows / withdrawals / repayments
82
+
83
+ - Confirm the target group and bank.
84
+ - Load or create the user's marginfi account.
85
+ - Fetch fresh bank data and oracle-backed pricing before reasoning about health.
86
+ - Use SDK or CLI helpers instead of hand-writing instructions unless the task explicitly needs raw instruction control.
87
+
88
+ #### Flash loans
89
+
90
+ - Treat flash loans as a begin/end instruction pair or use the SDK helper that builds the full transaction.
91
+ - Ensure the end instruction index is correct and that every temporary borrow is repaid within the same transaction.
92
+ - Watch for flash-loan-specific errors such as illegal nesting or missing end instructions.
93
+
94
+ #### Permissionless banks / The Arena
95
+
96
+ - Collect the mint, oracle setup, risk tier, asset/liability weights, deposit and borrow limits, operational state, and rate configuration before coding.
97
+ - Use the official The Arena guidance and listing criteria as the source of truth.
98
+ - Surface any missing config explicitly; never invent safe-looking defaults.
99
+
100
+ #### Liquidations and health analysis
101
+
102
+ - Distinguish collateral, borrow-only, and isolated assets.
103
+ - Explain how asset weights, liability weights, utilization-based rates, and oracle staleness checks affect account health.
104
+ - Use official terminology when describing liquidatable states and liquidation flows.
105
+
106
+ ### 5) Respect protocol guardrails
107
+
108
+ - marginfi relies on Pyth and Switchboard oracle feeds with confidence and staleness checks; do not assume any quoted price is always usable.
109
+ - Interest rates are utilization-based and piecewise; account economics depend on bank config, not just spot balances.
110
+ - Current docs describe verified builds, audits, fuzz testing, and bug-bounty coverage; do not bypass those assumptions when proposing deployment or upgrade steps.
111
+
112
+ ### 6) Output expectations
113
+
114
+ When finishing marginfi work:
115
+
116
+ - name the exact official pages consulted
117
+ - state the chosen integration surface
118
+ - list the concrete accounts, banks, and env values the implementation needs
119
+ - call out any unverified addresses, parameters, or bank settings
120
+ - keep examples minimal and directly runnable when possible
121
+
122
+ ## References
123
+
124
+ - `references/official-development-notes.md`: condensed marginfi development guidance from official docs.
125
+ - `references/source-index.md`: official page index and when to consult each source.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Marginfi Development"
3
+ short_description: "Build or review integrations on the marginfi protocol"
4
+ default_prompt: "Use $marginfi-development to ground the task in official marginfi docs, choose the correct development surface (TypeScript SDK, Rust CLI, or raw program instructions), load the relevant reference sections, and then implement or explain the smallest correct marginfi integration without guessing bank config, oracle setup, or protocol addresses."
@@ -0,0 +1,191 @@
1
+ # Official Marginfi Development Notes
2
+
3
+ Checked against official marginfi docs on 2026-03-20.
4
+
5
+ ## Canonical official sources
6
+
7
+ - Docs home: `https://docs.marginfi.com/`
8
+ - TypeScript SDK docs: `https://docs.marginfi.com/ts-sdk`
9
+ - Rust CLI docs: `https://docs.marginfi.com/rust-sdk`
10
+ - Protocol design: `https://docs.marginfi.com/protocol-design`
11
+ - Program docs (`mfi-v2`): `https://docs.marginfi.com/mfi-v2`
12
+ - The Arena docs: `https://docs.marginfi.com/the-arena`
13
+
14
+ ## 1. Protocol model to keep in mind
15
+
16
+ marginfi is a pooled-balance lending protocol on Solana. The main developer objects are:
17
+
18
+ - `MarginfiGroup`: protocol-wide configuration and shared state for a deployment.
19
+ - `Bank`: the per-asset pool with oracle config, risk weights, limits, and utilization-driven rates.
20
+ - `MarginfiAccount`: the user's margin account that holds deposits and liabilities across banks.
21
+
22
+ Important protocol-design facts from the official docs:
23
+
24
+ - Risk is controlled by asset weights, liability weights, and loan-to-value style constraints.
25
+ - Oracles come from Pyth and Switchboard, with confidence and staleness checks before prices are accepted.
26
+ - Docs mention a maximum oracle staleness of 60 seconds and a 95% confidence interval requirement.
27
+ - Pyth EMA pricing is described as roughly 5,921 slots (about 1 hour) for smoothing.
28
+ - Interest rates use a two-segment utilization curve: rates rise with utilization, then increase more aggressively after the optimal-utilization threshold.
29
+ - Asset risk tiers include collateral-style assets, borrow-only assets, and isolated assets.
30
+
31
+ Use these facts when reasoning about account health, liquidations, and bank config; do not reduce health checks to simple spot-price math.
32
+
33
+ ## 2. Official addresses and environments
34
+
35
+ The official docs currently expose these environment values across the docs home and protocol-design pages:
36
+
37
+ - Mainnet program: `MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA`
38
+ - Mainnet group: `FCPfpHAjHn9R6vWQbtyzcN8PjjobJABQj9rChmC6Cv5j`
39
+ - Staging program: `stag8sTKDs4Df2RehcgddBVAtDx6gbDp7YkA94R6HvK`
40
+ - Staging group: `2rpQwP4ofD6P2AojSeyjc9kUCzjscX4oMtd2N4eySe7W`
41
+
42
+ Treat these as time-sensitive. Re-check the docs page before hardcoding them in new work.
43
+
44
+ ## 3. TypeScript SDK essentials
45
+
46
+ Official docs point to the npm package `@mrgnlabs/marginfi-client-v2` plus `@mrgnlabs/mrgn-common` helpers.
47
+
48
+ Core setup flow from the docs:
49
+
50
+ 1. Create a Solana `Connection`.
51
+ 2. Build a wallet adapter or `NodeWallet`.
52
+ 3. Load `getConfig("production")` or another environment config.
53
+ 4. Call `MarginfiClient.fetch(config, wallet, connection)`.
54
+ 5. Fetch existing marginfi accounts for the authority, or create one.
55
+ 6. Resolve the target bank, then perform actions.
56
+
57
+ Minimal example pattern:
58
+
59
+ ```ts
60
+ import { Connection } from "@solana/web3.js";
61
+ import { MarginfiClient, getConfig } from "@mrgnlabs/marginfi-client-v2";
62
+ import { NodeWallet } from "@mrgnlabs/mrgn-common";
63
+
64
+ const connection = new Connection(process.env.RPC_URL!, "confirmed");
65
+ const wallet = NodeWallet.local();
66
+ const config = getConfig("production");
67
+ const client = await MarginfiClient.fetch(config, wallet, connection);
68
+
69
+ const accounts = await client.getMarginfiAccountsForAuthority();
70
+ const account = accounts[0] ?? (await client.createMarginfiAccount());
71
+ const bank = client.getBankByTokenSymbol("SOL");
72
+ if (!bank) throw new Error("SOL bank not found");
73
+
74
+ await account.deposit(1, bank.address);
75
+ ```
76
+
77
+ Useful SDK objects and methods called out in the docs:
78
+
79
+ - Client bootstrap: `MarginfiClient.fetch`, `getConfig`
80
+ - Bank lookup: `getBankByTokenSymbol`, `getBankByMint`, `getBankByPk`
81
+ - Oracle helpers: `getOraclePriceByBank`
82
+ - Account discovery: `getMarginfiAccountsForAuthority`
83
+ - Account creation: `createMarginfiAccount`
84
+ - Permissionless-bank support: `createLendingPool`
85
+ - Transaction helper: `processTransaction`
86
+ - Margin-account actions on `MarginfiAccountWrapper`: `deposit`, `withdraw`, `borrow`, `repay`, `reload`
87
+
88
+ Prefer these helpers before assembling raw instructions manually.
89
+
90
+ ## 4. Flash-loan development notes
91
+
92
+ Official TS SDK docs describe `buildFlashLoanTx` as the preferred helper for building full flash-loan transactions.
93
+
94
+ The program docs describe flash loans as:
95
+
96
+ - `lending_account_start_flashloan`
97
+ - user instructions that consume the temporary liquidity
98
+ - `lending_account_end_flashloan`
99
+
100
+ Important implementation rules:
101
+
102
+ - Flash loans must begin and end in the same transaction.
103
+ - The end instruction must reference the correct end index.
104
+ - Nested or malformed flash-loan flows are rejected.
105
+ - Relevant program errors include `AccountInFlashloan`, `IllegalFlashloan`, `IllegalFlag`, and `NoFlashloanInProgress`.
106
+
107
+ If you need raw control, mirror the exact begin/end instruction ordering from the official docs.
108
+
109
+ ## 5. Rust CLI essentials
110
+
111
+ The Rust CLI docs describe profile-based configuration through `marginfi profile` and account or bank operations through `marginfi group` and `marginfi account` subcommands.
112
+
113
+ Representative CLI flows from the docs:
114
+
115
+ - profile and authority setup: `marginfi profile create`, `marginfi profile set`
116
+ - account flows: `marginfi account create`, `deposit`, `borrow`, `withdraw`, `repay`
117
+ - bank and admin flows: `marginfi group add-bank`, `configure-bank`, `collect-fees`, `setup-emissions`, `update-emissions`
118
+ - permissionless-bank creation: `marginfi group add-bank-permissionless`
119
+
120
+ Use the CLI when the job is operational, administrative, or quick to script from the terminal. Use the TS SDK when embedding marginfi into apps or bots.
121
+
122
+ ## 6. Permissionless banks and The Arena
123
+
124
+ The Arena docs describe a permissionless flow where developers can create marginfi banks from listed tokens.
125
+
126
+ Important configuration areas surfaced in the official docs:
127
+
128
+ - `asset_weight_init` / `asset_weight_maint`
129
+ - `liability_weight_init` / `liability_weight_maint`
130
+ - deposit and borrow limits
131
+ - interest-rate curve parameters such as optimal utilization, plateau rate, max rate, and fees
132
+ - `risk_tier`
133
+ - `operational_state`
134
+ - `oracle_setup`
135
+
136
+ The official TS docs also show `BankConfigOpt`, `InterestRateConfigOpt`, `OracleSetup`, `RiskTier`, and `OperationalState` in the permissionless-bank example.
137
+
138
+ When implementing bank creation:
139
+
140
+ - treat every config field as an explicit input
141
+ - validate the oracle source and required feed accounts
142
+ - keep listing-criteria and The Arena docs open while coding
143
+ - do not fabricate safe defaults for weights or limits
144
+
145
+ ## 7. Program instruction map
146
+
147
+ The `mfi-v2` docs expose the on-chain instruction set and typed errors.
148
+
149
+ Key instruction families to consult before raw program work:
150
+
151
+ - marginfi-group initialization and configuration
152
+ - bank creation and configuration
153
+ - margin-account creation
154
+ - deposit / withdraw
155
+ - borrow / repay
156
+ - emissions setup and update
157
+ - liquidate
158
+ - flash-loan begin / end
159
+ - account transfer flows
160
+
161
+ Useful error names exposed in the docs include:
162
+
163
+ - `Unauthorized`
164
+ - `BankNotFound`
165
+ - `MarginfiAccountNotFound`
166
+ - `OperationWithdrawOnly`
167
+ - `IllegalLiquidation`
168
+ - `IllegalFlashloan`
169
+ - `AccountInFlashloan`
170
+ - `NoFlashloanInProgress`
171
+ - `SwitchboardStalePrice`
172
+ - `CannotCloseOutstandingEmissions`
173
+
174
+ When surfacing failures to users, translate these into the failed business condition instead of echoing raw Solana logs only.
175
+
176
+ ## 8. Security and operational notes
177
+
178
+ The docs highlight:
179
+
180
+ - Halborn and Sec3 audits
181
+ - fuzz testing
182
+ - a bug-bounty program
183
+ - verifiable-build support via `solana-verify`
184
+
185
+ The official verification example is:
186
+
187
+ ```bash
188
+ solana-verify verify-from-repo -um --program-id MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA https://github.com/mrgnlabs/marginfi-v2
189
+ ```
190
+
191
+ Use these references when the task touches deployment verification, trust assumptions, or upgrade review.
@@ -0,0 +1,31 @@
1
+ # Marginfi Official Source Index
2
+
3
+ Use this file to jump to the official page that matches the task.
4
+
5
+ ## Primary docs
6
+
7
+ - `https://docs.marginfi.com/`
8
+ - Read for current program IDs, group IDs, lookup-table references, and top-level navigation.
9
+ - `https://docs.marginfi.com/ts-sdk`
10
+ - Read for TypeScript integration, SDK classes, helper methods, and flash-loan or permissionless-bank examples.
11
+ - `https://docs.marginfi.com/rust-sdk`
12
+ - Read for CLI workflows, operator tasks, profiles, group commands, and bank administration.
13
+ - `https://docs.marginfi.com/protocol-design`
14
+ - Read for risk model, oracle rules, utilization-based interest design, and liquidation reasoning.
15
+ - `https://docs.marginfi.com/mfi-v2`
16
+ - Read for raw instruction names, account schemas, and error definitions.
17
+ - `https://docs.marginfi.com/the-arena`
18
+ - Read for permissionless-bank flows and links to listing criteria.
19
+
20
+ ## When to open which source
21
+
22
+ - App, bot, backend, or frontend integration: start with `ts-sdk`, then `protocol-design`.
23
+ - CLI or ops automation: start with `rust-sdk`.
24
+ - Custom Anchor or raw Solana instruction work: start with `mfi-v2`.
25
+ - Health checks, liquidation analysis, or risk explanations: start with `protocol-design`, then confirm relevant instruction behavior in `mfi-v2`.
26
+ - Permissionless bank creation: start with `the-arena`, then open `ts-sdk` or `rust-sdk` depending on the chosen toolchain.
27
+ - Address or deployment verification: start with the docs home page, then follow its linked source or verification references.
28
+
29
+ ## Working rule
30
+
31
+ If the request depends on a value that can change over time, reopen the live official page even if this skill already contains a summary.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laitszkin/apollo-toolkit",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Apollo Toolkit npm installer for managed skill linking across Codex, OpenClaw, and Trae.",
5
5
  "license": "MIT",
6
6
  "author": "LaiTszKin",
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: solana-development
3
+ description: Build or maintain Solana applications in Rust using official Solana development docs. Use when users ask for native Solana programs, Rust SDK clients, account modeling, instruction design, PDAs, CPIs, local testing, deployment, upgrades, or Solana-specific debugging in Rust codebases.
4
+ ---
5
+
6
+ # Solana Development
7
+
8
+ ## Dependencies
9
+
10
+ - Required: none.
11
+ - Conditional: `systematic-debug` when the task is about failing Solana tests, runtime errors, or observed-vs-expected on-chain behavior.
12
+ - Optional: none.
13
+ - Fallback: If the repository pins Solana crates or CLI behavior that differs from the latest official docs, follow the repository's pinned versions and document the mismatch explicitly.
14
+
15
+ ## Standards
16
+
17
+ - Evidence: Ground commands, crate choices, and account-model decisions in the current repository plus official Solana docs under `solana.com/docs`.
18
+ - Execution: Classify the task as on-chain Rust, off-chain Rust client work, or both before changing code.
19
+ - Quality: Prefer minimal account surfaces, explicit instruction schemas, deterministic PDA seeds, and tests for every state transition or authority check.
20
+ - Output: Deliver Rust-focused changes with touched accounts, instructions, test commands, deployment notes, and any cluster or authority assumptions.
21
+
22
+ ## Goal
23
+
24
+ Implement Solana Rust work in a way that matches the official execution model: accounts and instructions first, then PDAs/CPIs, then testing and deployment safety.
25
+
26
+ ## Required Reference
27
+
28
+ - Read `references/official-solana-rust.md` before making non-trivial Solana changes.
29
+ - Refresh the linked official pages when crate versions, CLI commands, or deployment behavior appear different from the reference snapshot.
30
+
31
+ ## Use This Skill For
32
+
33
+ - Native Solana programs written directly in Rust
34
+ - Rust clients, indexers, or operational tools built with the Solana Rust SDK
35
+ - Account modeling, authority rules, PDA design, and CPI orchestration
36
+ - Local validator workflows, Rust-native tests, build/deploy/upgrade flows
37
+ - Solana-specific debugging such as signer, owner, writable, rent, compute, and instruction-data issues
38
+
39
+ ## Workflow
40
+
41
+ ### 1) Classify the repository shape first
42
+
43
+ - Identify whether the codebase contains on-chain programs, Rust clients, or both.
44
+ - Detect whether the repository uses native Solana Rust or a higher-level framework already. Do not rewrite framework conventions unless the user asks.
45
+ - Locate program IDs, deploy scripts, test harnesses, keypair handling, and cluster configuration before editing.
46
+
47
+ ### 2) Design the instruction and account contract up front
48
+
49
+ - List each instruction, the accounts it needs, which accounts must be signer or writable, and which program owns each account.
50
+ - Record PDA seeds, bump handling, rent expectations, realloc rules, and close authorities before implementing handlers.
51
+ - Reject invalid ownership, signer, and writable assumptions explicitly instead of relying on downstream runtime failures.
52
+
53
+ ### 3) Keep native Rust program structure explicit
54
+
55
+ - Follow the official native Rust flow: `entrypoint` receives the program call, instruction parsing is explicit, and processor logic is separated from account data definitions.
56
+ - Keep serialization and versioning explicit for any state stored inside accounts.
57
+ - Prefer custom program errors over panics so failures remain diagnosable.
58
+
59
+ ### 4) Use PDAs and CPIs deliberately
60
+
61
+ - Use PDAs for program-controlled state or authorities that should not require a private key.
62
+ - Use `invoke` for regular cross-program calls and `invoke_signed` only when the current program must sign as one of its PDAs.
63
+ - Treat signer and writable privileges as inherited, not escalated; verify every CPI account list carefully.
64
+
65
+ ### 5) Choose the correct Rust crates for the job
66
+
67
+ - For on-chain code, center the implementation around `solana-program`.
68
+ - For off-chain Rust clients and tooling, use `solana-sdk` for transaction primitives and `solana-client` for RPC access.
69
+ - When a project mirrors CLI behavior, inspect whether it also depends on `solana-cli-config` or `solana-clap-utils`.
70
+
71
+ ### 6) Validate locally before deploy
72
+
73
+ - Prefer fast Rust-native tests first, then run the repository's validator or end-to-end flow if available.
74
+ - Build with the repository's pinned toolchain when present; otherwise use the current official Solana build/deploy workflow from the reference.
75
+ - Exercise account initialization, authority checks, PDA signing, and failure paths instead of only happy-path success.
76
+
77
+ ### 7) Deploy and upgrade safely
78
+
79
+ - Confirm target cluster, payer, program ID, and upgrade authority before deploy.
80
+ - Call out any action that makes a program immutable or permanently closes program state.
81
+ - When deployment changes operational assumptions, summarize the exact commands and authority implications in the final handoff.
82
+
83
+ ## Final Checklist
84
+
85
+ - Account ownership, signer, writable, and PDA assumptions are explicit
86
+ - Instruction data and state serialization are version-aware where needed
87
+ - Local tests cover success and failure paths for state transitions
88
+ - Deployment or upgrade commands match the target cluster and authority setup
89
+ - Any mismatch between repo-pinned Solana versions and current docs is documented
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Solana Development"
3
+ short_description: "Build Solana Rust programs and clients from official docs"
4
+ default_prompt: "Use $solana-development to inspect the repository, determine whether the task is on-chain Rust, off-chain Rust client work, or both, follow the official Solana model for accounts, instructions, PDAs, CPIs, testing, and deployment, and deliver concise Rust-focused implementation notes grounded in current Solana docs."
@@ -0,0 +1,199 @@
1
+ # Official Solana Rust Development Reference
2
+
3
+ Snapshot date: 2026-03-20 (Asia/Hong_Kong).
4
+
5
+ Use this file when building, reviewing, or debugging Solana work in Rust. It condenses the most important development guidance from the official Solana documentation so the main skill can stay concise.
6
+
7
+ ## Official source map
8
+
9
+ - Core accounts: `https://solana.com/docs/core/accounts`
10
+ - Core instructions: `https://solana.com/docs/core/instructions`
11
+ - Core transactions: `https://solana.com/docs/core/transactions`
12
+ - Core fees: `https://solana.com/docs/core/fees`
13
+ - Program Derived Addresses: `https://solana.com/docs/core/pda`
14
+ - Cross Program Invocation: `https://solana.com/docs/core/cpi`
15
+ - Native Rust programs overview: `https://solana.com/docs/programs/rust`
16
+ - Native Rust program structure: `https://solana.com/docs/programs/rust/program-structure`
17
+ - Program deployment and upgrades: `https://solana.com/docs/programs/deploying`
18
+ - Official Rust SDK overview: `https://solana.com/docs/clients/official/rust`
19
+
20
+ If any page changes structure, search `site:solana.com/docs <topic>` and refresh this reference before locking in version-sensitive commands.
21
+
22
+ ## 1. Core execution model you must preserve
23
+
24
+ - Solana programs operate by receiving instruction data plus an ordered account list. Most implementation mistakes are really account-contract mistakes.
25
+ - Accounts are the durable storage boundary. Before editing logic, identify each account's owner, mutability, signer requirement, lamports behavior, and serialized data layout.
26
+ - Transactions package one or more instructions and execute atomically. Design instruction handlers with atomic state transitions in mind.
27
+ - The official fees model separates:
28
+ - base fee, currently documented as `5000` lamports per signature
29
+ - prioritization fee, computed from compute-unit limit and compute-unit price
30
+ - When performance or cost matters, review compute usage per instruction and avoid unnecessary account writes.
31
+
32
+ ## 2. Native Rust program structure
33
+
34
+ The official native Rust docs and program-structure page emphasize a small, explicit layout:
35
+
36
+ - `entrypoint.rs`: Solana entrypoint and handoff into program logic
37
+ - `instruction.rs`: instruction enum / decoding
38
+ - `processor.rs`: instruction handlers and business logic
39
+ - `state.rs`: account data structs and serialization
40
+ - `error.rs`: custom program errors
41
+
42
+ Keep the logic readable and explicit:
43
+
44
+ - parse instruction data up front
45
+ - validate account shape before mutation
46
+ - separate state serialization from business logic
47
+ - return `ProgramError`-compatible failures instead of panicking
48
+
49
+ The official Rust-program walkthrough currently documents these setup details:
50
+
51
+ - create a library crate
52
+ - add `solana-program` as the primary on-chain dependency
53
+ - set `[lib] crate-type = ["cdylib", "lib"]`
54
+ - build SBF output with the Solana build flow documented on the page
55
+
56
+ As of the 2026-03-20 snapshot, the official examples show `solana-program@2.2.0` in native Rust setup examples. Re-check before pinning new projects because Solana crate versions move.
57
+
58
+ ## 3. Instruction and account design checklist
59
+
60
+ Before writing handlers, lock down:
61
+
62
+ - instruction enum and binary format
63
+ - per-instruction account list order
64
+ - which accounts are signer
65
+ - which accounts are writable
66
+ - which program owns each account
67
+ - PDA seeds and bump strategy
68
+ - account initialization, realloc, close, and rent expectations
69
+
70
+ Useful rule: every handler should be reviewable from a table with columns for account, owner, signer, writable, PDA seeds, and failure conditions.
71
+
72
+ ## 4. Program Derived Addresses (PDAs)
73
+
74
+ Official PDA guidance centers on these ideas:
75
+
76
+ - A PDA is a deterministic address derived from seeds plus a program ID.
77
+ - PDAs are intentionally off the Ed25519 curve, so they have no private key.
78
+ - Programs use PDAs for program-controlled authorities and state accounts.
79
+ - The same seeds plus the same program ID must derive the same PDA every time.
80
+ - The bump seed exists to find a valid off-curve address.
81
+
82
+ The official PDA page also documents practical limits to remember:
83
+
84
+ - up to 16 seeds per derivation
85
+ - each seed can be up to 32 bytes
86
+
87
+ Design advice:
88
+
89
+ - Use stable, domain-specific seeds such as fixed prefixes plus relevant public keys.
90
+ - Keep seed schemes obvious and documented near the instruction that consumes them.
91
+ - Prefer one clear PDA purpose per seed scheme instead of overloading one PDA for unrelated roles.
92
+
93
+ ## 5. Cross Program Invocation (CPI)
94
+
95
+ Official CPI guidance highlights:
96
+
97
+ - Solana programs can invoke instructions in other programs.
98
+ - Use `invoke` when no PDA signature is required.
99
+ - Use `invoke_signed` when the current program must sign on behalf of one of its PDAs.
100
+ - Signer and writable privileges extend from the caller into the callee; CPI does not create new privileges.
101
+
102
+ Practical implications:
103
+
104
+ - Validate the entire downstream account list before the CPI.
105
+ - Never assume a callee can write to an account unless the outer instruction passed it as writable.
106
+ - When debugging CPI failures, inspect signer propagation, writable flags, PDA seed correctness, and program ownership first.
107
+
108
+ The official page notes a practical limit of 16 PDA signers in `invoke_signed`.
109
+
110
+ ## 6. Fees and compute-budget awareness
111
+
112
+ The official fees page is the baseline for performance-sensitive work:
113
+
114
+ - base fee is charged per signature
115
+ - prioritization fee depends on compute-unit limit and compute-unit price
116
+ - transactions can set compute budget explicitly when needed
117
+
118
+ When implementing Rust clients or relayers:
119
+
120
+ - size transaction account lists carefully
121
+ - avoid unnecessary signatures
122
+ - consider compute budget instructions only when the workflow truly needs them
123
+
124
+ When implementing programs:
125
+
126
+ - keep account validation linear and obvious
127
+ - avoid redundant serialization passes
128
+ - separate expensive CPIs from cheap pure-validation paths when possible
129
+
130
+ ## 7. Local testing workflow
131
+
132
+ Official Solana docs currently show a Rust-native local test flow for native programs.
133
+
134
+ From the current documentation snapshot:
135
+
136
+ - official examples show `litesvm@0.6.1` and `solana-sdk@2.2.0` as dev dependencies in the Rust testing walkthrough
137
+ - the docs position LiteSVM as a fast local execution harness for native Rust programs
138
+
139
+ Recommended execution order:
140
+
141
+ 1. unit-test pure helpers and serialization logic
142
+ 2. run Rust-native program tests for instruction/state behavior
143
+ 3. run validator-backed integration flow only when the repository or task needs cluster realism
144
+
145
+ Test the following explicitly:
146
+
147
+ - initialization and duplicate-initialization rejection
148
+ - authority checks
149
+ - signer and writable enforcement
150
+ - PDA derivation and PDA signing flows
151
+ - state transitions, close flows, and realloc paths
152
+ - failure paths for malformed instruction data or wrong account order
153
+
154
+ ## 8. Deployment, upgrades, and irreversible operations
155
+
156
+ The official deployment docs cover the core operational loop:
157
+
158
+ - local development often starts with `solana-test-validator`
159
+ - deploy with `solana program deploy ...`
160
+ - visibility can lag by roughly one slot after deployment
161
+ - a program becomes immutable when its upgrade authority is removed
162
+ - `solana program close` permanently closes the program and the same program ID cannot be reused for redeployment
163
+
164
+ Before any deploy or upgrade:
165
+
166
+ - confirm cluster URL
167
+ - confirm payer keypair
168
+ - confirm intended program ID
169
+ - confirm upgrade authority ownership
170
+ - confirm whether the deploy changes any downstream configuration or address registry
171
+
172
+ For production-facing tasks, always surface immutable or close operations as explicit risk points in the handoff.
173
+
174
+ ## 9. Official Rust SDK crate roles
175
+
176
+ The official Rust SDK overview maps the common crates this way:
177
+
178
+ - `solana-program`: on-chain program primitives
179
+ - `solana-sdk`: transactions, instructions, keypairs, signatures, and shared primitives for Rust clients
180
+ - `solana-client`: RPC access for off-chain Rust applications
181
+ - `solana-cli-config`: reuse CLI config from Rust tools
182
+ - `solana-clap-utils`: CLI-oriented helper utilities
183
+
184
+ Default crate choice:
185
+
186
+ - on-chain program logic: `solana-program`
187
+ - Rust service/tool that talks to RPC: `solana-sdk` + `solana-client`
188
+ - Rust CLI that should mirror Solana CLI config behavior: add `solana-cli-config`
189
+
190
+ ## 10. When to refresh the official docs before coding
191
+
192
+ Refresh the linked pages instead of relying on this snapshot when:
193
+
194
+ - the repository pins newer or older Solana crate versions
195
+ - CLI subcommands or flags differ from this reference
196
+ - the task depends on recently changed runtime features
197
+ - the repository uses Anchor or another framework that wraps native Solana APIs
198
+
199
+ When docs and code disagree, preserve the repository's actual pinned behavior and note the divergence.