@laitszkin/apollo-toolkit 2.4.3 → 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 +4 -2
- package/CHANGELOG.md +23 -0
- package/README.md +5 -2
- package/{specs-to-project-docs → archive-specs}/README.md +3 -3
- package/{specs-to-project-docs → archive-specs}/SKILL.md +10 -10
- package/archive-specs/agents/openai.yaml +4 -0
- package/codex-memory-manager/SKILL.md +2 -0
- package/commit-and-push/README.md +3 -3
- package/commit-and-push/SKILL.md +16 -15
- package/commit-and-push/agents/openai.yaml +1 -1
- package/develop-new-features/README.md +2 -2
- package/develop-new-features/SKILL.md +4 -3
- package/develop-new-features/agents/openai.yaml +1 -1
- package/enhance-existing-features/README.md +1 -1
- package/enhance-existing-features/SKILL.md +3 -1
- package/enhance-existing-features/agents/openai.yaml +1 -1
- package/jupiter-development/SKILL.md +89 -0
- package/jupiter-development/agents/openai.yaml +4 -0
- package/jupiter-development/references/official-docs.md +157 -0
- package/learn-skill-from-conversations/SKILL.md +11 -2
- package/lib/cli.js +2 -1
- package/lib/installer.js +7 -1
- package/{codex-subagent-orchestration → marginfi-development}/LICENSE +1 -1
- package/marginfi-development/README.md +31 -0
- package/marginfi-development/SKILL.md +125 -0
- package/marginfi-development/agents/openai.yaml +4 -0
- package/marginfi-development/references/official-development-notes.md +191 -0
- package/marginfi-development/references/source-index.md +31 -0
- package/package.json +1 -1
- package/solana-development/SKILL.md +89 -0
- package/solana-development/agents/openai.yaml +4 -0
- package/solana-development/references/official-solana-rust.md +199 -0
- package/version-release/README.md +3 -3
- package/version-release/SKILL.md +16 -15
- package/version-release/agents/openai.yaml +1 -1
- package/codex-subagent-orchestration/README.md +0 -39
- package/codex-subagent-orchestration/SKILL.md +0 -224
- package/codex-subagent-orchestration/agents/openai.yaml +0 -6
- package/codex-subagent-orchestration/references/custom-agent-template.toml +0 -40
- package/codex-subagent-orchestration/references/routing-rubric.md +0 -100
- package/specs-to-project-docs/agents/openai.yaml +0 -4
- /package/{specs-to-project-docs → archive-specs}/LICENSE +0 -0
- /package/{specs-to-project-docs → archive-specs}/references/templates/architecture.md +0 -0
- /package/{specs-to-project-docs → archive-specs}/references/templates/configuration.md +0 -0
- /package/{specs-to-project-docs → archive-specs}/references/templates/developer-guide.md +0 -0
- /package/{specs-to-project-docs → archive-specs}/references/templates/docs-index.md +0 -0
- /package/{specs-to-project-docs → archive-specs}/references/templates/features.md +0 -0
- /package/{specs-to-project-docs → archive-specs}/references/templates/getting-started.md +0 -0
- /package/{specs-to-project-docs → archive-specs}/references/templates/readme.md +0 -0
|
@@ -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:
|
|
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,
|
|
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
|
|
package/lib/cli.js
CHANGED
|
@@ -371,7 +371,7 @@ async function run(argv, context = {}) {
|
|
|
371
371
|
return 1;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
await syncToolkitHome({
|
|
374
|
+
const syncResult = await syncToolkitHome({
|
|
375
375
|
sourceRoot,
|
|
376
376
|
toolkitHome,
|
|
377
377
|
version: packageJson.version,
|
|
@@ -380,6 +380,7 @@ async function run(argv, context = {}) {
|
|
|
380
380
|
const installResult = await installLinks({
|
|
381
381
|
toolkitHome,
|
|
382
382
|
modes,
|
|
383
|
+
previousSkillNames: syncResult.previousSkillNames,
|
|
383
384
|
env: {
|
|
384
385
|
...env,
|
|
385
386
|
APOLLO_TOOLKIT_HOME: toolkitHome,
|
package/lib/installer.js
CHANGED
|
@@ -112,6 +112,7 @@ async function stageToolkitContents({ sourceRoot, destinationRoot, version }) {
|
|
|
112
112
|
async function syncToolkitHome({ sourceRoot, toolkitHome, version }) {
|
|
113
113
|
const parentDir = path.dirname(toolkitHome);
|
|
114
114
|
const tempDir = path.join(parentDir, `.apollo-toolkit.tmp-${process.pid}-${Date.now()}`);
|
|
115
|
+
const previousSkillNames = await listSkillNames(toolkitHome).catch(() => []);
|
|
115
116
|
|
|
116
117
|
await fsp.rm(tempDir, { recursive: true, force: true });
|
|
117
118
|
await stageToolkitContents({ sourceRoot, destinationRoot: tempDir, version });
|
|
@@ -127,6 +128,7 @@ async function syncToolkitHome({ sourceRoot, toolkitHome, version }) {
|
|
|
127
128
|
|
|
128
129
|
return {
|
|
129
130
|
toolkitHome,
|
|
131
|
+
previousSkillNames,
|
|
130
132
|
skillNames: await listSkillNames(toolkitHome),
|
|
131
133
|
};
|
|
132
134
|
}
|
|
@@ -191,13 +193,17 @@ async function replaceWithSymlink(sourcePath, targetPath) {
|
|
|
191
193
|
await fsp.symlink(sourcePath, targetPath, type);
|
|
192
194
|
}
|
|
193
195
|
|
|
194
|
-
async function installLinks({ toolkitHome, modes, env = process.env }) {
|
|
196
|
+
async function installLinks({ toolkitHome, modes, env = process.env, previousSkillNames = [] }) {
|
|
195
197
|
const skillNames = await listSkillNames(toolkitHome);
|
|
196
198
|
const targets = await getTargetRoots(modes, env);
|
|
197
199
|
const linkedPaths = [];
|
|
200
|
+
const staleSkillNames = previousSkillNames.filter((skillName) => !skillNames.includes(skillName));
|
|
198
201
|
|
|
199
202
|
for (const target of targets) {
|
|
200
203
|
await ensureDirectory(target.root);
|
|
204
|
+
for (const staleSkillName of staleSkillNames) {
|
|
205
|
+
await fsp.rm(path.join(target.root, staleSkillName), { recursive: true, force: true });
|
|
206
|
+
}
|
|
201
207
|
for (const skillName of skillNames) {
|
|
202
208
|
const sourcePath = path.join(toolkitHome, skillName);
|
|
203
209
|
const targetPath = path.join(target.root, skillName);
|
|
@@ -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.
|