Skip to content

Commit 293f8aa

Browse files
Hiksangclaude
andcommitted
Add mantle-cli: standalone Mantle DeFi CLI for Mantle Squad Bounty
New crate: crates/mantle-cli/ — builds `mantle` binary Reuses defi-core + defi-protocols (shared workspace) 8 commands, all Mantle-hardcoded (no --chain flag): mantle status — 8 protocols, 12 tokens ecosystem overview mantle scan — Oracle divergence + stablecoin depeg + exchange rate mantle swap — ODOS aggregator best-price routing mantle bridge — LI.FI cross-chain (--to/--from other chains) mantle whales — Top token holders via routescan (free API) mantle positions — Wallet token balances + lending positions mantle lending — Aave V3/Lendle rates mantle yield — Cross-protocol rate comparison All commands tested live against Mantle mainnet. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 08d6a4d commit 293f8aa

21 files changed

Lines changed: 2095 additions & 0 deletions

.omc/project-memory.json

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
{
2+
"version": "1.0.0",
3+
"lastScanned": 1773738547892,
4+
"projectRoot": "/Users/hik/Documents/GitHub/defi-cli",
5+
"techStack": {
6+
"languages": [
7+
{
8+
"name": "Rust",
9+
"version": "1.85",
10+
"confidence": "high",
11+
"markers": [
12+
"Cargo.toml"
13+
]
14+
}
15+
],
16+
"frameworks": [],
17+
"packageManager": "cargo",
18+
"runtime": null
19+
},
20+
"build": {
21+
"buildCommand": "cargo build",
22+
"testCommand": "cargo test",
23+
"lintCommand": "cargo clippy",
24+
"devCommand": "cargo run",
25+
"scripts": {}
26+
},
27+
"conventions": {
28+
"namingStyle": null,
29+
"importStyle": null,
30+
"testPattern": null,
31+
"fileOrganization": null
32+
},
33+
"structure": {
34+
"isMonorepo": false,
35+
"workspaces": [],
36+
"mainDirectories": [
37+
"docs",
38+
"src",
39+
"tests"
40+
],
41+
"gitBranches": {
42+
"defaultBranch": "main",
43+
"branchingStrategy": null
44+
}
45+
},
46+
"customNotes": [],
47+
"directoryMap": {
48+
"__pycache__": {
49+
"path": "__pycache__",
50+
"purpose": null,
51+
"fileCount": 1,
52+
"lastAccessed": 1773738547871,
53+
"keyFiles": [
54+
"prepare.cpython-314.pyc"
55+
]
56+
},
57+
"config": {
58+
"path": "config",
59+
"purpose": "Configuration files",
60+
"fileCount": 1,
61+
"lastAccessed": 1773738547872,
62+
"keyFiles": [
63+
"chains.toml"
64+
]
65+
},
66+
"crates": {
67+
"path": "crates",
68+
"purpose": null,
69+
"fileCount": 0,
70+
"lastAccessed": 1773738547872,
71+
"keyFiles": []
72+
},
73+
"docs": {
74+
"path": "docs",
75+
"purpose": "Documentation",
76+
"fileCount": 1,
77+
"lastAccessed": 1773738547872,
78+
"keyFiles": [
79+
"DEFI_CATEGORIES.md"
80+
]
81+
},
82+
"src": {
83+
"path": "src",
84+
"purpose": "Source code",
85+
"fileCount": 0,
86+
"lastAccessed": 1773738547872,
87+
"keyFiles": []
88+
},
89+
"target": {
90+
"path": "target",
91+
"purpose": null,
92+
"fileCount": 2,
93+
"lastAccessed": 1773738547873,
94+
"keyFiles": [
95+
"CACHEDIR.TAG"
96+
]
97+
},
98+
"tests": {
99+
"path": "tests",
100+
"purpose": "Test files",
101+
"fileCount": 0,
102+
"lastAccessed": 1773738547873,
103+
"keyFiles": []
104+
}
105+
},
106+
"hotPaths": [
107+
{
108+
"path": "crates/defi-core/src/registry/mod.rs",
109+
"accessCount": 4,
110+
"lastAccessed": 1773738642077,
111+
"type": "file"
112+
},
113+
{
114+
"path": "Cargo.toml",
115+
"accessCount": 3,
116+
"lastAccessed": 1773739684404,
117+
"type": "file"
118+
},
119+
{
120+
"path": "crates/mantle-cli/src/commands/positions.rs",
121+
"accessCount": 2,
122+
"lastAccessed": 1773739698658,
123+
"type": "file"
124+
},
125+
{
126+
"path": "crates/mantle-cli/src/commands/whales.rs",
127+
"accessCount": 2,
128+
"lastAccessed": 1773739699652,
129+
"type": "file"
130+
},
131+
{
132+
"path": "config/chains.toml",
133+
"accessCount": 1,
134+
"lastAccessed": 1773738612514,
135+
"type": "file"
136+
},
137+
{
138+
"path": "config/tokens/mantle.toml",
139+
"accessCount": 1,
140+
"lastAccessed": 1773738617241,
141+
"type": "file"
142+
},
143+
{
144+
"path": "crates/defi-cli/src/commands/mod.rs",
145+
"accessCount": 1,
146+
"lastAccessed": 1773738626904,
147+
"type": "file"
148+
},
149+
{
150+
"path": "crates/defi-cli/src/main.rs",
151+
"accessCount": 1,
152+
"lastAccessed": 1773738627126,
153+
"type": "file"
154+
},
155+
{
156+
"path": "config/protocols/dex/agni_mantle.toml",
157+
"accessCount": 1,
158+
"lastAccessed": 1773738629679,
159+
"type": "file"
160+
},
161+
{
162+
"path": "config/protocols/lending/aave_v3_mantle.toml",
163+
"accessCount": 1,
164+
"lastAccessed": 1773738630109,
165+
"type": "file"
166+
},
167+
{
168+
"path": "config/protocols/dex/fusionx_v3_mantle.toml",
169+
"accessCount": 1,
170+
"lastAccessed": 1773738634163,
171+
"type": "file"
172+
},
173+
{
174+
"path": "config/protocols/lending/compound_v3_mantle.toml",
175+
"accessCount": 1,
176+
"lastAccessed": 1773738634595,
177+
"type": "file"
178+
},
179+
{
180+
"path": "README.md",
181+
"accessCount": 1,
182+
"lastAccessed": 1773738645266,
183+
"type": "file"
184+
},
185+
{
186+
"path": "crates/mantle-cli/Cargo.toml",
187+
"accessCount": 1,
188+
"lastAccessed": 1773739460764,
189+
"type": "file"
190+
},
191+
{
192+
"path": "crates/mantle-cli/src/main.rs",
193+
"accessCount": 1,
194+
"lastAccessed": 1773739463244,
195+
"type": "file"
196+
},
197+
{
198+
"path": "crates/mantle-cli/src/commands/mod.rs",
199+
"accessCount": 1,
200+
"lastAccessed": 1773739486491,
201+
"type": "file"
202+
},
203+
{
204+
"path": "crates/mantle-cli/src/commands/status.rs",
205+
"accessCount": 1,
206+
"lastAccessed": 1773739497065,
207+
"type": "file"
208+
},
209+
{
210+
"path": "crates/mantle-cli/src/commands/scan.rs",
211+
"accessCount": 1,
212+
"lastAccessed": 1773739552645,
213+
"type": "file"
214+
},
215+
{
216+
"path": "crates/mantle-cli/src/commands/swap.rs",
217+
"accessCount": 1,
218+
"lastAccessed": 1773739586088,
219+
"type": "file"
220+
},
221+
{
222+
"path": "crates/mantle-cli/src/commands/bridge.rs",
223+
"accessCount": 1,
224+
"lastAccessed": 1773739604336,
225+
"type": "file"
226+
},
227+
{
228+
"path": "crates/mantle-cli/src/commands/lending.rs",
229+
"accessCount": 1,
230+
"lastAccessed": 1773739664927,
231+
"type": "file"
232+
},
233+
{
234+
"path": "crates/mantle-cli/src/commands/yield_cmd.rs",
235+
"accessCount": 1,
236+
"lastAccessed": 1773739672863,
237+
"type": "file"
238+
}
239+
],
240+
"userDirectives": []
241+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Deep Interview Spec: Mantle CLI
2+
3+
## Metadata
4+
- Rounds: 4
5+
- Final Ambiguity Score: 19.5%
6+
- Type: brownfield
7+
- Generated: 2026-03-17
8+
- Threshold: 20%
9+
- Status: PASSED
10+
11+
## Clarity Breakdown
12+
| Dimension | Score | Weight | Weighted |
13+
|-----------|-------|--------|----------|
14+
| Goal Clarity | 0.90 | 35% | 0.315 |
15+
| Constraint Clarity | 0.70 | 25% | 0.175 |
16+
| Success Criteria | 0.75 | 25% | 0.1875 |
17+
| Context Clarity | 0.85 | 15% | 0.1275 |
18+
| **Total Clarity** | | | **0.805** |
19+
| **Ambiguity** | | | **19.5%** |
20+
21+
## Goal
22+
Mantle 체인 전용 CLI 바이너리(`mantle`)를 기존 defi-cli workspace에 새 crate로 추가하여, Mantle Squad Bounty(~3/31)에 제출한다. `--chain` 플래그 없이 Mantle 하드코딩된 8개 핵심 커맨드를 제공하고, GitHub repo + X 스레드 + 데모 영상으로 제출한다.
23+
24+
## Constraints
25+
- **마감**: 2026-03-31
26+
- **코드 구조**: defi-cli workspace에 `crates/mantle-cli/` 추가. defi-core + defi-protocols 공유.
27+
- **바이너리명**: `mantle`
28+
- **체인**: Mantle만 (chain_id: 5000). `--chain` 플래그 제거.
29+
- **의존성**: defi-core, defi-protocols, reqwest, clap, serde_json, tokio, alloy
30+
31+
## Non-Goals
32+
- 다른 체인 지원 (Mantle 전용)
33+
- 신규 프로토콜 어댑터 개발
34+
- 웹 UI / TUI 대시보드
35+
- 실제 트랜잭션 브로드캐스트 (dry-run/시뮬레이션 중심)
36+
37+
## Acceptance Criteria
38+
- [ ] `cargo build --bin mantle` 로 별도 바이너리 빌드
39+
- [ ] 8개 커맨드 동작: status, scan, swap, bridge, whales, positions, lending (rates), yield (compare)
40+
- [ ] 모든 커맨드에 `--json` 출력 지원
41+
- [ ] `--chain` 플래그 없이 Mantle 하드코딩
42+
- [ ] README.md: 설치법, 사용법, 스크린샷, Mantle 생태계 소개
43+
- [ ] CI 통과 (clippy, fmt, test, build)
44+
- [ ] 데모 실행 성공: scan→alert, whales→position, swap quote, bridge quote
45+
46+
## Assumptions Exposed & Resolved
47+
| Assumption | Challenge | Resolution |
48+
|------------|-----------|------------|
49+
| 별도 repo 필요 | 유지보수 2배 문제 | 같은 workspace, crate만 분리 |
50+
| 전체 22개 커맨드 | bounty에 불필요한 것 많음 | 핵심 8개만 |
51+
| 코드 복사 필요 | defi-core 공유 가능 | workspace dependency로 해결 |
52+
53+
## Technical Context
54+
- 기존 defi-cli workspace: 4 crates (defi-core, defi-protocols, defi-cli, defi-mcp)
55+
- Mantle 설정: 8 protocols, 12 tokens, chain config 이미 존재
56+
- 핵심 재사용: Registry, multicall_read(), Executor, OutputMode
57+
- 신규 작성: main.rs, commands/mod.rs (8개 커맨드 래퍼), README.md
58+
59+
## Ontology (Key Entities)
60+
61+
| Entity | Type | Fields | Relationships |
62+
|--------|------|--------|---------------|
63+
| MantleCLI | product | binary_name, commands[], version | uses defi-core, targets Bounty |
64+
| defi-cli | source | 22 commands, 11 chains | shares core with MantleCLI |
65+
| Bounty | external | deadline(3/31), prize($10K MNT), criteria[] | receives MantleCLI + XThread + DemoVideo |
66+
| Commands | feature set | scan, swap, bridge, whales, positions, lending, yield, status | belongs to MantleCLI |
67+
| MantleEcosystem | domain | 8 protocols, 12 tokens, chain_id=5000 | queried by Commands |
68+
| XThread | deliverable | text, screenshots, @Mantle_Official tag | part of Bounty submission |
69+
| DemoVideo | deliverable | 1-2min, scan/whales/swap/bridge demo | part of Bounty submission |
70+
| Workspace | architecture | Cargo workspace, shared crates | contains MantleCLI + defi-cli |
71+
72+
## Ontology Convergence
73+
74+
| Round | Entity Count | New | Changed | Stable | Stability Ratio |
75+
|-------|-------------|-----|---------|--------|----------------|
76+
| 1 | 3 | 3 | - | - | N/A |
77+
| 2 | 5 | 2 | 0 | 3 | 60% |
78+
| 3 | 7 | 2 | 0 | 5 | 71% |
79+
| 4 | 8 | 1 | 0 | 7 | 87.5% |
80+
81+
## Implementation Plan
82+
83+
### Phase 1: Crate 생성 (~30min)
84+
1. `crates/mantle-cli/Cargo.toml` 생성
85+
2. `crates/mantle-cli/src/main.rs` — Mantle 하드코딩 entry point
86+
3. `crates/mantle-cli/src/commands/mod.rs` — 8개 커맨드 등록
87+
4. 각 커맨드: defi-cli 로직 재사용, chain을 "mantle"로 고정
88+
89+
### Phase 2: 커맨드 구현 (~1hr)
90+
- `status` → Mantle 프로토콜 현황
91+
- `scan` → Oracle 괴리 + 디페그 + exchange rate
92+
- `swap` → ODOS aggregator (Mantle)
93+
- `bridge` → LI.FI (from/to Mantle)
94+
- `whales` → routescan API (Mantle 무료)
95+
- `positions` → 토큰 잔고 + lending 포지션
96+
- `lending rates` → Aave V3/Lendle 이율
97+
- `yield compare` → 전체 프로토콜 이율 비교
98+
99+
### Phase 3: README + 문서 (~30min)
100+
- README.md: 설치법, 사용법, 스크린샷
101+
- Mantle 생태계 소개 ($748M TVL, 8 protocols)
102+
103+
### Phase 4: CI + 테스트 (~15min)
104+
- cargo build, clippy, fmt, test
105+
- 라이브 테스트 (scan, swap, bridge, whales)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"t":0,"agent":"system","event":"keyword_detected","keyword":"deep-interview"}
2+
{"t":0,"agent":"a74e131","agent_type":"Explore","event":"agent_start","parent_mode":"none"}
3+
{"t":0,"agent":"a74e131","agent_type":"Explore","event":"agent_stop","success":true,"duration_ms":59492}
4+
{"t":0,"agent":"system","event":"skill_invoked","skill_name":"oh-my-claudecode:autopilot"}

.omc/state/hud-state.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"timestamp": "2026-03-17T08:52:16.882Z",
3+
"backgroundTasks": [],
4+
"sessionStartTimestamp": "2026-03-17T08:11:52.256Z",
5+
"sessionId": "2c019e77-806b-4a72-b477-db1f3b13fa91"
6+
}

.omc/state/hud-stdin-cache.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"session_id":"2c019e77-806b-4a72-b477-db1f3b13fa91","transcript_path":"/Users/hik/.claude/projects/-Users-hik-Documents-GitHub-defi-cli/2c019e77-806b-4a72-b477-db1f3b13fa91.jsonl","cwd":"/Users/hik/Documents/GitHub/defi-cli","model":{"id":"claude-opus-4-6[1m]","display_name":"Opus 4.6 (1M context)"},"workspace":{"current_dir":"/Users/hik/Documents/GitHub/defi-cli","project_dir":"/Users/hik/Documents/GitHub/defi-cli","added_dirs":[]},"version":"2.1.77","output_style":{"name":"default"},"cost":{"total_cost_usd":332.6627781500007,"total_duration_ms":95349070,"total_api_duration_ms":27594030,"total_lines_added":8521,"total_lines_removed":1085},"context_window":{"total_input_tokens":9141228,"total_output_tokens":1152114,"context_window_size":1000000,"current_usage":{"input_tokens":3,"output_tokens":1,"cache_creation_input_tokens":294,"cache_read_input_tokens":403160},"used_percentage":40,"remaining_percentage":60},"exceeds_200k_tokens":true}

.omc/state/last-tool-error.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"tool_name": "Bash",
3+
"tool_input_preview": "{\"command\":\"cargo build --bin mantle 2>&1\",\"timeout\":120000,\"description\":\"Build mantle-cli\"}",
4+
"error": "Exit code 101\n Compiling mantle-cli v0.1.0 (/Users/hik/Documents/GitHub/defi-cli/crates/mantle-cli)\nerror[E0560]: struct `positions::IPool::getUserAccountDataCall` has no field named `_0`\n --> crates/mantle-cli/src/commands/positions.rs:69:60\n |\n69 | calls.push((*pool, IPool::getUserAccountDataCall { _0: user }.abi_encode()));\n | ^^ `positions::IPool::getUserAccountDataCall` does not have this field\n |\n = note: availab...",
5+
"timestamp": "2026-03-17T09:28:12.854Z",
6+
"retry_count": 1
7+
}

0 commit comments

Comments
 (0)