Skip to content

feat(spark-savings-plugin): cross-chain Sky Savings Rate skill (v0.1.0)#37

Open
GeoGu360 wants to merge 2 commits intomig-pre:testfrom
GeoGu360:feat/spark-savings-plugin
Open

feat(spark-savings-plugin): cross-chain Sky Savings Rate skill (v0.1.0)#37
GeoGu360 wants to merge 2 commits intomig-pre:testfrom
GeoGu360:feat/spark-savings-plugin

Conversation

@GeoGu360
Copy link
Copy Markdown

Summary

New skill: spark-savings-plugin — earn Sky Savings Rate (SSR) on USDS via the sUSDS yield-bearing vault. Supports Ethereum (native ERC-4626 vault) and Base / Arbitrum (Spark PSM swapExactIn). 6 commands + onboarding.

Why

No existing skill covers Sky/Spark stablecoin savings. Sky Protocol (rebranded MakerDAO) is one of the largest stablecoin issuers ($5.4B sUSDS TVL); the SSR is currently 3.65% APY at zero collateral risk (no liquidation, no leverage). Adding it gives Agents a canonical safe-yield path for USDS / DAI holders.

6 commands

# Command Type Purpose
0 quickstart read 3-chain parallel scan + 5-status enum + ready-to-run next_command
1 apy read live SSR + chi cumulative index + TVL via direct Ethereum RPC
2 balance read USDS / sUSDS / DAI per chain + sUSDS underlying USDS value
3 deposit write (--confirm) USDS → sUSDS (ERC-4626 on ETH, Spark PSM on Base/Arb)
4 withdraw write (--confirm) sUSDS → USDS (--amount / --shares-amount / --all)
5 upgrade-dai write (--confirm) legacy DAI → USDS 1:1 via official Sky DaiUsds migrator (ETH only)

Chain scope (v0.1.0)

Chain Mechanism
Ethereum Native ERC-4626 vault (deposit/redeem on sUSDS contract)
Base Spark PSM swapExactIn (cross-chain sUSDS is NOT a vault)
Arbitrum Spark PSM swapExactIn

Optimism / Unichain / Avalanche / Gnosis: have sUSDS deployed but no PSM yet (or native conversion still pending Q2 2026 for Avalanche). Will add in v0.2.0 once underlying mechanism ships.

Knowledge-base compliance

Rule Implementation
GEN-001 All 6 commands emit structured JSON on stdout
ONB-001 quickstart skeleton + SUMMARY.md written FIRST (per CLAUDE.md mandatory order)
ONC-001 wallet contract-call always invoked with --force (defensive)
EVM-001 Pre-flight token balance check before approve
EVM-002 Every amount field paired (display + _raw)
EVM-006 approve followed by wait_for_tx polling, no blind sleep
EVM-012 RPC failures surface explicitly (no unwrap_or(0) on native_balance)
EVM-014 Retry-on-allowance-revert with 3 patterns (ERC-20 standard, DAI custom, OZ v5)
EVM-015 (new) Explicit --gas-limit override; approve 60k, main writes 250k
TX-001 (new) wait_for_tx after main submit confirms status=0x1 before reporting success
GAS-001 Native gas balance check before write

4 real bugs surfaced + fixed during real-money testing

  1. EVM-012 violation: native_balance().unwrap_or(0) silently zeroed RPC failures → confusing INSUFFICIENT_GAS when wallet actually had 0.094 ETH
  2. EVM-014 extension: DAI uses non-standard Dai/insufficient-allowance revert string; existing retry pattern only matched standard ERC-20 message → no retry → wasted approve gas
  3. EVM-015 (new entry): onchainos eth_estimateGas + 1.4× buffer under-estimates ERC-4626 redeem (estimated 70k → 100k limit → actual 130k → OOG revert with status=0x0)
  4. TX-001 (new entry): plugin reported ok:true after onchainos broadcast even when on-chain tx reverted (status=0x0); witnessed via OOG redeem above. Fix: always wait_for_tx after main submit

All 3 new/extended entries written into common-bugs-knowledge-base.md with scope, fix templates, gas-limit empirical thresholds per operation type, and grep commands for retroactive scanning of existing skills.

Verified end-to-end on Ethereum mainnet

Step Tx Result
C1 upgrade-dai 0.45 0x91d3ffb6...11ba97bb0f 0.45 DAI → 0.45 USDS via DaiUsds migrator ✓
C2 deposit 1 USDS 0x87255dfc...bf1faf2e5 1 USDS → 0.913 sUSDS (chi=1.094 reflected); EVM-014 retry triggered + saved this one ✓
C3 first redeem 0x893db475...c1d0b1eb REVERT (status=0x0, OOG) — discovered EVM-015
C3 retry redeem 0x9c93710a...8d2d03ac 0.5 sUSDS → 0.547 USDS, gasUsed 130k/250k ✓
TX-001 verification 0x43f78b75...d2dbb8fb Plugin shows [deposit] On-chain confirmed (status 0x1) + "on_chain_status": "0x1" field ✓

Read paths verified: apy returns SSR=3.65% / TVL=$5.4B / chi=1.094 ray on Ethereum; balance correctly aggregates 3-chain holdings.

Outstanding for v0.1.1

L2 Spark PSM path (Base / Arbitrum) NOT yet validated end-to-end. Selectors verified by keccak256 + dry-run produces correct calldata shape, but real bridge to Base + deposit on PSM was blocked by LI.FI 36-min rate-limit cooldown during testing. Will validate in v0.1.1 follow-up.

Test plan

  • cargo build — clean compile, no warnings
  • --help flag audit vs SKILL.md (perfect match for all 6 commands)
  • ONB-001 quickstart + SUMMARY.md three-section template; status enum src ↔ doc fully aligned
  • quickstart real wallet → status has_susds_earning, recommends correct next_command
  • apy reads live SSR/chi/TVL from Ethereum RPC
  • balance aggregates 3-chain real holdings correctly
  • deposit --dry-run produces correct ERC-4626 calldata + previewed shares
  • withdraw --dry-run produces correct redeem calldata + previewed assets
  • upgrade-dai --dry-run produces correct DaiUsds migrator calldata
  • 3 real on-chain writes succeeded (upgrade-dai + deposit + withdraw)
  • 4 real bugs surfaced + fixed + entered into knowledge base
  • git diff upstream/test --name-only — only skills/spark-savings-plugin/ files
  • plugin.yaml api_calls matches all https:// source domains (3 RPCs)

🤖 Generated with Claude Code

New skill: spark-savings-plugin — earn Sky Savings Rate (SSR) on USDS via
the sUSDS yield-bearing vault. Supports Ethereum (native ERC-4626 vault)
and Base / Arbitrum (Spark PSM swapExactIn). 6 commands.

Commands:
- quickstart   3-chain parallel scan + 5-status enum + ready-to-run next_command
- apy          live SSR + chi + TVL via direct RPC (no API dependency)
- balance      USDS / sUSDS / DAI per chain + sUSDS underlying USDS value
- deposit      USDS → sUSDS (ERC-4626 on ETH, Spark PSM on Base/Arb)
- withdraw     sUSDS → USDS (--amount / --shares-amount / --all)
- upgrade-dai  legacy DAI → USDS 1:1 via official Sky DaiUsds migrator (ETH only)

Chain scope (v0.1.0):
- Ethereum: full ERC-4626 vault (deposit/redeem on sUSDS contract)
- Base:     Spark PSM at 0x1601843c5E9bC251A3272907010AFa41Fa18347E
- Arbitrum: Spark PSM at 0x2B05F8e1cACC6974fD79A673a341Fe1f58d27266

Optimism / Unichain / Avalanche / Gnosis: have sUSDS but no PSM yet (or
native conversion still pending Q2 2026). Will add in v0.2.0 once the
underlying mechanism ships.

Knowledge-base compliance (verified during development):
- GEN-001  all 6 commands emit structured JSON on stdout
- ONB-001  quickstart skeleton + SUMMARY.md three-section template (first)
- ONC-001  wallet contract-call always invoked with --force
- EVM-001  pre-flight token balance check before approve
- EVM-002  every amount field paired (display + _raw)
- EVM-006  approve followed by wait_for_tx polling, no blind sleep
- EVM-012  surface RPC errors explicitly (no unwrap_or(0) on native_balance)
- EVM-014  retry-on-allowance-revert with 3 patterns: ERC-20 standard,
           DAI custom format, OZ v5 ERC20InsufficientAllowance
- EVM-015  explicit --gas-limit override on wallet_contract_call
           (approve 60k, main writes 250k) — onchainos eth_estimateGas
           under-estimates ERC-4626 / PSM cold-storage operations
- TX-001   wait_for_tx after main submit confirms on-chain status=0x1
           before reporting success (prevents broadcast≠success false-positive)
- GAS-001  native gas balance check before write

Bugs surfaced + fixed during real-money testing:
1. (EVM-012) native_balance().unwrap_or(0) silently zeroed RPC failures
   → confusing INSUFFICIENT_GAS when wallet actually had 0.094 ETH
2. (EVM-014 ext) DAI uses non-standard "Dai/insufficient-allowance" revert
   string; existing retry pattern only matched standard ERC-20 message
3. (EVM-015) onchainos eth_estimateGas + 1.4× buffer under-estimated
   ERC-4626 redeem (estimated 70k → 100k limit → actual 130k → OOG revert)
4. (TX-001) plugin reported ok:true after onchainos broadcast even when
   on-chain tx reverted (status=0x0); witnessed via OOG redeem above

Each bug also written into common-bugs-knowledge-base.md as new entries
EVM-014 (extended), EVM-015 (new), TX-001 (new) so future skills don't
repeat them.

Verified end-to-end on Ethereum mainnet:
- C1 upgrade-dai 0.45 DAI → 0.45 USDS via DaiUsds migrator
  tx 0x91d3ffb619c1338ed850e68d457eec0ef7d6314eae65e8002aa13011ba97bb0f
- C2 deposit 1 USDS → 0.913 sUSDS via ERC-4626 (chi=1.094 reflected)
  tx 0x87255dfc3f3735a642e618398dda81851539f0d333bea423f8409edbf1faf2e5
  (EVM-014 retry triggered + saved this one; first submit had stale RPC
   allowance view, retried after 5s and succeeded)
- C3 redeem 0.5 sUSDS → 0.547 USDS (chi accrual realized)
  tx 0x9c93710a4cc4d73808d17970fa841a48e19dda3c73fb14f80fddef548d2d03ac
  (first attempt 0x893db475... reverted with status=0x0 due to OOG;
   added explicit gas-limit 250k → succeeded; gasUsed 130829 / 250000)
- TX-001 fix verified: subsequent deposit 0.5 USDS shows
  "[deposit] On-chain confirmed (status 0x1)" + "on_chain_status: 0x1"
  field in JSON output

Read paths verified: apy returns SSR=3.65% / TVL=$5.4B / chi=1.094 ray
on Ethereum; balance correctly aggregates 3-chain holdings.

L2 Spark PSM path (Base / Arbitrum) NOT yet validated end-to-end —
selectors verified by keccak256 + dry-run produces correct calldata
shape, but real bridge to Base then deposit on PSM blocked by LI.FI
36-min rate-limit cooldown during testing. Will validate in v0.1.1
follow-up after rate-limit clears.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

🔨 Phase 2: Build Verification — ✅ PASSED

Plugin: spark-savings-plugin | Language: rust
Source: @

Compiled from developer source code by our CI. Users install our build artifacts.

Build succeeded. Compiled artifact uploaded as workflow artifact.


Source integrity: commit SHA `` is the content fingerprint.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

📋 Phase 3: AI Code Review Report — Score: N/A/100

Plugin: spark-savings-plugin | Recommendation: 👤 Manual review required

🔗 Reviewed against latest onchainos source code (live from main branch) | Model: unavailable via Anthropic API | Cost: N/A

This is an advisory report. It does NOT block merging. Final decision is made by human reviewers.


AI review FAILED (HTTP 400): Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits.. Request size: 1055996 bytes, plugin content: 143614 bytes.


Generated by Claude AI via Anthropic API — review the full report before approving.

@github-actions
Copy link
Copy Markdown

🔨 Phase 2: Build Verification — ✅ PASSED

Plugin: spark-savings-plugin | Language: rust
Source: @

Compiled from developer source code by our CI. Users install our build artifacts.

Build succeeded. Compiled artifact uploaded as workflow artifact.


Source integrity: commit SHA `` is the content fingerprint.

Same E041 fix applied proactively for PR mig-pre#37 (spark-savings) — saw it
fail on PR mig-pre#34 (lifi-plugin) so apply the same MIT license here before
the CI catches it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant