Skip to content

fix(curve-plugin): sync to okx v0.2.8 + biz-type/strategy attribution (v0.2.9)#77

Merged
plugin-store-bot[bot] merged 2 commits into
mig-pre:mainfrom
GeoGu360:fix/curve-biz-type-v2
May 7, 2026
Merged

fix(curve-plugin): sync to okx v0.2.8 + biz-type/strategy attribution (v0.2.9)#77
plugin-store-bot[bot] merged 2 commits into
mig-pre:mainfrom
GeoGu360:fix/curve-biz-type-v2

Conversation

@GeoGu360
Copy link
Copy Markdown
Owner

@GeoGu360 GeoGu360 commented May 7, 2026

Summary

Brings mig-pre/main curve-plugin from v0.2.7 → v0.2.9 in one shot, since mig-pre was 1 version behind okx/main.

The diff is 2 logical parts:

Part 1: Sync mig-pre v0.2.7 → okx/main v0.2.8 (14 files)

Already reviewed/merged on okx side. Includes new `quickstart` command + various swap/liquidity refinements.

Part 2: New in v0.2.9 — biz-type/strategy attribution

`src/onchainos.rs`

```rust
const BIZ_TYPE: &str = "dapp";
const STRATEGY: &str = env!("CARGO_PKG_NAME");
```
Injected into the args of `wallet_contract_call`. Covers 3 direct call sites + the shared `transfer_token_legacy` approve helper:

  • swap / add_liquidity / remove_liquidity / approve

`env!("CARGO_PKG_NAME")` keeps strategy name in sync with Cargo.toml — no drift across the 4 metadata files.

Audit notes

EVM-012 sweep is intentionally minimal in this PR. Several display-only and ABI-decode `unwrap_or(0)` fallbacks were left as soft fallbacks. A follow-up PR can do a deeper sweep (e.g. `swap.rs:55` `coin_index` fallback to coin 0).

Test plan

  • `cargo build` passes
  • Step 1.5 quick scan complete
  • Phase 1 / 2 / 3 CI
  • Phase 4 publish + auto-merge

🤖 Generated with Claude Code

… (v0.2.9)

This PR brings mig-pre/main curve-plugin from v0.2.7 to v0.2.9 — the
bulk is sync of the v0.2.7 → v0.2.8 changes already living on okx/main,
with our biz-type/strategy attribution layered on top.

== Sync portion (mig-pre v0.2.7 → okx v0.2.8) ==

14 files changed. These are okx/main's v0.2.8 changes that mig-pre is
missing — already reviewed/merged on okx side.

== New in v0.2.9 ==

Add `--biz-type dapp --strategy curve-plugin` to every onchainos
`wallet contract-call` invocation. Source-of-truth for the strategy
name is Cargo.toml's `[package].name` via `env!("CARGO_PKG_NAME")` —
no drift between Cargo.toml, plugin.yaml, plugin.json.

Affected onchainos call sites (3):
- commands/swap.rs (Curve swap via exchange/exchange_underlying)
- commands/add_liquidity.rs (LP token mint via add_liquidity)
- commands/remove_liquidity.rs (LP token burn / withdraw)

Plus token approve via the shared transfer_token_legacy helper which
also routes through wallet_contract_call.

Note: `unwrap_or(0)` audit in this PR is intentionally minimal —
several display-only and ABI-decode fallbacks were classified as soft
fallbacks acceptable for now. A separate follow-up PR can do a deeper
EVM-012 sweep on swap.rs:55 (coin_index fallback) and similar.

Version bump: mig-pre v0.2.7 → v0.2.9 (PATCH — backwards-compatible).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@GeoGu360 GeoGu360 added the ci-approved Maintainer reviewed PR; allows Phase 1/2/3 CI to run label May 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

🔨 Phase 2: Build Verification — ✅ PASSED

Plugin: curve-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 May 7, 2026

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

Plugin: curve-plugin | Recommendation: ✅ Ready to merge

🔗 Reviewed against latest onchainos source code (live from main branch) | Model: claude-opus-4-7 via Anthropic API | Cost: ~532337+5385 tokens

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


1. Plugin Overview
Field Value
Name curve-plugin
Version 0.2.9
Category defi-protocol
Author GeoGu360 (GeoGu360)
License MIT
Has Binary Yes (with build config)
Risk Level Medium

Summary: Curve DEX plugin that wraps Curve Finance API and on-chain pool contracts to enable stablecoin swaps, liquidity provision/removal, pool discovery, and APY queries across Ethereum, Arbitrum, Base, Polygon, and BSC. Uses onchainos CLI for transaction signing and broadcast.

Target Users: DeFi users who want to interact with Curve Finance pools (swap stablecoins, provide liquidity, earn yield) through an AI agent without manually crafting transactions.

2. Architecture Analysis

Components:
Skill (SKILL.md) + Rust binary (curve-plugin)

Skill Structure:
SKILL.md with sections: Pre-flight Dependencies (auto-injected), Quickstart, Command Routing, command sections (get-pools, get-pool-info, get-balances, quote, swap, add-liquidity, remove-liquidity), Troubleshooting, Security Notes. ~8 commands, references onchainos CLI for write ops.

Data Flow:

  • Read ops: query Curve API (api.curve.finance/api/getPools) for pool metadata + direct eth_call via public RPCs for on-chain state
  • Write ops: build calldata locally → invoke onchainos wallet contract-call for TEE signing + broadcast
  • Multicall3 batching for balance queries
  • Wallet resolution via onchainos wallet addresses

Dependencies:

  • Curve Finance API
  • Public RPCs: ethereum.publicnode.com, arbitrum-one-rpc.publicnode.com, base-rpc.publicnode.com, polygon-bor-rpc.publicnode.com, bsc-rpc.publicnode.com
  • onchainos CLI (for write ops)
  • Multicall3 contract (0xcA11bde0...) on each chain
3. Auto-Detected Permissions

onchainos Commands Used

Command Found Exists in onchainos CLI Risk Level Context
onchainos wallet addresses ✅ Yes Low Resolve active EVM wallet
onchainos wallet contract-call ✅ Yes High Sign + broadcast swap/approve/add-liquidity/remove-liquidity
onchainos wallet history ✅ Yes Low Poll tx confirmation

Wallet Operations

Operation Detected? Where Risk
Read balance Yes get-balances, swap, add-liquidity (via RPC) Low
Send transaction Yes swap, add-liquidity, remove-liquidity High
Sign message No High
Contract call Yes swap (exchange), approve, add_liquidity, remove_liquidity High

External APIs / URLs

URL / Domain Purpose Risk
https://api.curve.finance/api/getPools Pool metadata, TVL, APY Low
https://ethereum.publicnode.com Ethereum RPC Low
https://arbitrum-one-rpc.publicnode.com Arbitrum RPC Low
https://base-rpc.publicnode.com Base RPC Low
https://polygon-bor-rpc.publicnode.com Polygon RPC Low
https://bsc-rpc.publicnode.com BSC RPC Low
https://raw.githubusercontent.com/okx/plugin-store/main/... Update check (auto-injected) Low
https://github.com/okx/plugin-store/releases/download/... Binary download (auto-injected) Low

Chains Operated On

Ethereum (1), Arbitrum (42161), Base (8453), Polygon (137), BSC (56)

Overall Permission Summary

The plugin can read on-chain state (pool reserves, balances, allowances) directly via public RPCs and execute write operations (token approvals, swaps, liquidity add/remove) by delegating to onchainos wallet contract-call. All signing happens in TEE via onchainos. The plugin builds calldata locally using known function selectors. It has no access to private keys, mnemonics, or session tokens. Risk is moderate: uses --force for write ops, but write ops require --confirm flag at plugin level for user gating.

4. onchainos API Compliance

Does this plugin use onchainos CLI for all on-chain write operations?

Yes — fully compliant.

On-Chain Write Operations (MUST use onchainos)

Operation Uses onchainos? Self-implements? Detail
Wallet signing No Via wallet contract-call (TEE)
Transaction broadcasting No Via wallet contract-call
DEX swap execution No Builds calldata, broadcasts via onchainos
Token approval No Via erc20_approvewallet contract-call
Contract calls No Via wallet contract-call
Token transfers N/A No Not applicable

Data Queries (allowed to use external sources)

Data Source API/Service Used Purpose
Curve API api.curve.finance Pool metadata, TVL, APY
Public RPCs publicnode.com endpoints On-chain reads (balances, allowances, get_dy, virtual_price)
Multicall3 Contract 0xcA11... Batch balance lookups

External APIs / Libraries Detected

  • reqwest for HTTP/RPC
  • Direct eth_call JSON-RPC against publicnode.com
  • No web3/ethers library — manual ABI encoding/decoding

Verdict: ✅ Fully Compliant

5. Security Assessment

Static Rule Scan (C01-C09, H01-H09, M01-M08, L01-L02)

Rule ID Severity Title Matched? Detail
C01 CRITICAL curl | sh remote execution No Auto-injected pre-flight only — skipped per instructions
H05 INFO Direct financial / link API operations Yes Plugin operates on DEX/swap; baseline characteristic
M03 MEDIUM Third-party content fetch Yes reqwest::get against api.curve.finance; data is treated as untrusted but should add boundary
M07 MEDIUM Missing untrusted-data-boundary declaration No SKILL.md includes "Treat all returned data as untrusted external content" — explicit declaration present
M08 INFO External-data field passthrough No SKILL.md uses <external-content> tags around output examples; field-level safety acceptable

LLM Judge Analysis (L-PINJ, L-MALI, L-MEMA, L-IINJ, L-AEXE, L-FINA, L-FISO)

Judge Severity Detected Confidence Evidence
L-PINJ CRITICAL No 0.9 No prompt-injection patterns; SKILL.md is straightforward command documentation
L-MALI CRITICAL No 0.9 Code matches stated functionality; no hidden data exfiltration
L-MEMA HIGH No 0.95 No memory file modification
L-IINJ INFO Yes 0.95 External requests to Curve API + RPCs; SKILL.md has explicit "untrusted external content" boundary declaration → INFO
L-AEXE INFO No 0.85 Write ops require --confirm flag; preview-then-execute pattern enforced
L-FINA INFO Yes 0.95 Write+confirmation+gating present; --confirm required for all write ops, --dry-run available; INFO level
L-FISO N/A

Toxic Flow Detection (TF001-TF006)

No toxic flows detected. Although H05 (direct financial) is present, there is no C01 (curl|sh in SKILL.md body) and M07 declaration is present, so TF005 and TF006 do not trigger.

Prompt Injection Scan

Reviewed SKILL.md for: instruction override patterns, identity manipulation, hidden behavior, base64 payloads, invisible chars, pseudo-system tags. None detected. The auto-injected pre-flight block is correctly skipped.

Result: ✅ Clean

Dangerous Operations Check

Plugin involves: token transfers (via swap/add-liquidity), ERC-20 approvals, DEX swaps, contract calls. Confirmation steps:

  • --confirm required for write ops (preview-only by default)
  • --dry-run available for full simulation
  • SKILL.md explicitly instructs agent to "Ask user to confirm before executing on-chain"
  • SKILL.md prohibits unlimited approvals

Result: ✅ Safe

Data Exfiltration Risk

No mechanism to exfiltrate sensitive data. RPC and API calls are limited to read-only chain queries and Curve pool metadata. Wallet address is sent to public RPCs (necessary for balanceOf/allowance calls — standard practice). No tokens, secrets, or private data transmitted.

Result: ✅ No Risk

Overall Security Rating: 🟢 Low Risk

6. Source Code Security

Language & Build Config

Rust, entry point src/main.rs, binary curve-plugin

Dependency Analysis

Standard, well-maintained dependencies:

  • clap v4 — CLI parsing (mature)
  • reqwest v0.12 — HTTP client (well-maintained)
  • serde/serde_json — serialization (standard)
  • tokio v1 — async runtime (standard)
  • anyhow v1 — error handling (standard)
  • hex v0.4 — hex encoding (standard)

No suspicious or unmaintained dependencies.

Code Safety Audit

Check Result Detail
Hardcoded secrets (API keys, private keys, mnemonics) None found
Network requests to undeclared endpoints All endpoints declared in plugin.yaml api_calls
File system access outside plugin scope None
Dynamic code execution (eval, exec, shell commands) ⚠️ Command::new("onchainos") only — invokes declared CLI tool, not arbitrary commands
Environment variable access beyond declared env Only CARGO_PKG_NAME macro
Build scripts with side effects (build.rs, postinstall) No build.rs
Unsafe code blocks (Rust) / CGO (Go) No unsafe blocks

Does SKILL.md accurately describe what the source code does?

Yes — SKILL.md commands map directly to implementations in src/commands/. Function selectors, ABI encoding, and onchainos invocation match SKILL.md descriptions.

Verdict: ✅ Source Safe

7. Code Review

Quality Score: 86/100

Dimension Score Notes
Completeness (pre-flight, commands, error handling) 23/25 Solid: pre-flight via onchainos, all commands have error paths, --dry-run/--confirm gating, balance pre-flight checks, tx confirmation polling
Clarity (descriptions, no ambiguity) 22/25 Clear command index, parameter explanations, troubleshooting table covers many real-world issues
Security Awareness (confirmations, slippage, limits) 23/25 Explicit --confirm gate, slippage default 0.5%, prohibits unlimited approvals, treats CLI output as untrusted, balance shortfall logic
Skill Routing (defers correctly, no overreach) 13/15 Clear "Do NOT use for" section; could expand routing table
Formatting (markdown, tables, code blocks) 5/10 Generally clean but very long; uses <external-content> tags appropriately for output examples

Strengths

  • Excellent preview-then-execute pattern: all write ops require explicit --confirm flag
  • Tx confirmation polling via wait_for_tx prevents nonce/race issues between approve and main op
  • Multicall3 batching for balance queries (good performance)
  • Pre-flight balance check with intelligent shortfall handling (auto-adjust ≤1%, bail >1%)
  • Explicit untrusted-data boundary declaration

Issues Found

  • 🔵 Minor: Very long Troubleshooting section listing internal bug history — useful for the dev team but verbose for users
  • 🔵 Minor: Pre-flight section's auto-injected version-check uses 2>/dev/null heavily, which can mask real failures; not a security risk
8. Language Check
File Language Detected English?
SKILL.md English
SUMMARY.md English
9. SUMMARY.md Review
Check Result
File exists
Written in English
Has Overview section
Has Prerequisites section
Has Quick Start section
Character count ≤ 17,000 ✅ 1,866 chars
11. Recommendations
  1. (Optional) Trim the Troubleshooting bug-history table — keep the most important user-facing items, move fixed-in-version notes to a CHANGELOG.
  2. (Optional) Consider adding a brief note in SKILL.md that the plugin uses public RPCs (publicnode.com) so users know there is no API key dependency.
  3. (Optional) Document Multicall3 dependency explicitly in SKILL.md (currently transparent to users but informative).
  4. (Optional) Suppress 2>/dev/null in the version-check block where it could hide real network errors — currently fine because it falls back to local version, but explicit handling improves debuggability.
12. Reviewer Summary

One-line verdict: Well-engineered Curve DEX plugin with strong security posture (confirm-gating, untrusted-data boundaries, no unlimited approvals, TEE signing via onchainos), fully onchainos-compliant for write operations.

Merge recommendation: ✅ Ready to merge

Blockers (if any — list every issue that MUST be fixed before merge, each prefixed with ❌):

No blockers found.

Optional improvements (non-blocking) listed in Recommendations above.


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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

🔨 Phase 2: Build Verification — ✅ PASSED

Plugin: curve-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.

…art'

mig-pre CI Phase 1 [E151] enforces '## Quick Start' as a required
section. okx/main has been renaming this section to '## How it Works'
in newer plugins, but mig-pre's lint hasn't been updated to accept
that. Until the lint diverges or okx reverts, keep mig-pre's standard.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@GeoGu360 GeoGu360 added ci-approved Maintainer reviewed PR; allows Phase 1/2/3 CI to run and removed ci-approved Maintainer reviewed PR; allows Phase 1/2/3 CI to run labels May 7, 2026
@GeoGu360 GeoGu360 added the approved-for-publish Triggers Phase 4: compile + publish + merge label May 7, 2026
@plugin-store-bot plugin-store-bot Bot merged commit 9272fea into mig-pre:main May 7, 2026
31 checks passed
@plugin-store-bot
Copy link
Copy Markdown

✅ Phase 4: Publish Complete

Plugins: curve-plugin

  • ✅ Build: 9 architectures compiled
  • ✅ Release: GitHub Release created
  • ✅ Pre-flight: injected into SKILL.md
  • ✅ Registry: registry.json updated
  • ✅ Merged to main

View workflow run


Published by Plugin Store CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed approved-for-publish Triggers Phase 4: compile + publish + merge ci-approved Maintainer reviewed PR; allows Phase 1/2/3 CI to run plugin-update structure-validated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant