Skip to content

fix(gmx-v2-plugin): sync to okx + biz-type/strategy attribution (v0.2.7)#81

Merged
plugin-store-bot[bot] merged 1 commit into
mig-pre:mainfrom
GeoGu360:fix/gmx-v2-biz-type-v2
May 7, 2026
Merged

fix(gmx-v2-plugin): sync to okx + biz-type/strategy attribution (v0.2.7)#81
plugin-store-bot[bot] merged 1 commit into
mig-pre:mainfrom
GeoGu360:fix/gmx-v2-biz-type-v2

Conversation

@GeoGu360
Copy link
Copy Markdown
Owner

@GeoGu360 GeoGu360 commented May 7, 2026

Both mig-pre and okx are at v0.2.6 but code diverged (4 files / 30+ / 93- on okx). Sync mig-pre to okx state + add biz-type/strategy attribution. 2 wallet_contract_call wrapper functions both covered. Also fixes pre-existing version drift in plugin.json (was 0.2.2 vs 0.2.6 in plugin.yaml/Cargo.toml). EVM-012 sweep deferred to follow-up.

mig-pre and okx are at the same v0.2.6 version but code diverged
(4 files / 30 insertions / 93 deletions on okx-side). This PR brings
mig-pre's source in line with okx, then layers biz-type/strategy on top.

== New in v0.2.7 ==

Add `--biz-type dapp --strategy gmx-v2-plugin` to all onchainos
`wallet contract-call` invocations. Attribution lives in 2 functions:
`wallet_contract_call` and `wallet_contract_call_with_gas`.

`env!("CARGO_PKG_NAME")` keeps the strategy name in sync with Cargo.toml.

Also fixed pre-existing version drift in `.claude-plugin/plugin.json`
(was "0.2.2" while plugin.yaml/Cargo.toml were "0.2.6"; now consistent
at "0.2.7").

EVM-012 sweep deferred to a follow-up PR; this PR's scope is attribution.

Version bump: 0.2.6 → 0.2.7 (PATCH).

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: gmx-v2-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: 92/100

Plugin: gmx-v2-plugin | Recommendation: ✅ Ready to merge

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

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


1. Plugin Overview
Field Value
Name gmx-v2-plugin
Version 0.2.7
Category defi-protocol
Author GeoGu360 (GeoGu360)
License MIT
Has Binary Yes (with build config)
Risk Level Medium (involves leveraged trading + on-chain writes)

Summary: A Rust-based plugin for trading perpetuals and managing GM pool liquidity on GMX V2 (Arbitrum and Avalanche). It supports opening/closing leveraged positions, placing limit/stop orders, depositing/withdrawing liquidity, and claiming funding fees, with all write operations routed through onchainos wallet contract-call.

Target Users: DeFi traders who want to interact with GMX V2 perpetuals via an AI agent, including those running leveraged strategies, providing liquidity, or managing existing positions.

2. Architecture Analysis

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

Skill Structure: Well-structured SKILL.md with sections for Pre-flight Dependencies, Architecture, Supported Chains, GMX V2 Key Concepts, Execution Flow, Pre-flight Checks, 11 commands (quickstart, list-markets, get-prices, get-positions, get-orders, open-position, close-position, place-order, cancel-order, deposit-liquidity, withdraw-liquidity, claim-funding-fees), Risk Warnings, Example Workflow, and Changelog.

Data Flow:

  • Read ops → direct eth_call via public RPC or GMX REST API
  • Write ops → constructed multicall calldata → submitted via onchainos wallet contract-call
  • All txs require explicit --confirm flag; otherwise returns preview JSON
  • Pre-flight balance/allowance checks via direct RPC before write operations

Dependencies:

  • GMX REST API (arbitrum-api.gmxinfra.io, avalanche-api.gmxinfra.io + fallbacks)
  • Public RPCs (arbitrum.publicnode.com, avalanche-c-chain-rpc.publicnode.com)
  • onchainos CLI (for wallet operations and broadcasting)
3. Auto-Detected Permissions

onchainos Commands Used

Command Found Exists in onchainos CLI Risk Level Context
onchainos wallet status Yes Low Pre-flight wallet check
onchainos wallet login Yes Low User-initiated login flow (mentioned in docs only)
onchainos wallet contract-call Yes High All write ops (open/close/place-order/deposit/withdraw/claim)
onchainos wallet history --tx-hash Yes Low Tx confirmation polling
onchainos wallet addresses Yes Low Resolve wallet address
onchainos wallet balance Yes Low Balance display

Wallet Operations

Operation Detected? Where Risk
Read balance Yes quickstart, pre-flight checks Low
Send transaction No N/A (uses contract-call) High
Sign message No N/A High
Contract call Yes All write commands High

External APIs / URLs

URL / Domain Purpose Risk
https://arbitrum-api.gmxinfra.io GMX market/price/token data Low
https://arbitrum-api.gmxinfra2.io GMX fallback API Low
https://avalanche-api.gmxinfra.io GMX Avalanche data Low
https://avalanche-api.gmxinfra2.io GMX Avalanche fallback Low
https://arbitrum.publicnode.com RPC for Arbitrum eth_call Low
https://avalanche-c-chain-rpc.publicnode.com RPC for Avalanche eth_call Low
https://api.github.com/repos/okx/plugin-store/... Auto-injected version check Low (CI)
https://raw.githubusercontent.com/okx/plugin-store/... Auto-injected installer Low (CI)
https://github.com/okx/plugin-store/releases/... Auto-injected binary download Low (CI)

Chains Operated On

Arbitrum (42161) and Avalanche (43114) — EVM chains for GMX V2 perpetuals trading.

Overall Permission Summary

This plugin can: query GMX markets, prices, positions, and orders (read-only); construct calldata for opening/closing leveraged positions, placing conditional orders, depositing/withdrawing GM pool liquidity, and claiming funding fees. All transaction signing and broadcasting is delegated to onchainos wallet contract-call, which is the correct architecture pattern. The plugin never directly handles private keys. The --confirm flag is required to broadcast; otherwise it returns preview JSON.

4. onchainos API Compliance

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

Yes — all write operations are routed through onchainos wallet contract-call.

On-Chain Write Operations (MUST use onchainos)

Operation Uses onchainos? Self-implements? Detail
Wallet signing No Delegated entirely to onchainos
Transaction broadcasting No Via wallet contract-call
DEX swap execution N/A No Not applicable (perpetuals)
Token approval No Via erc20_approvewallet contract-call
Contract calls No All multicalls via wallet contract-call
Token transfers No Via contract-call (sendTokens within multicall)

Data Queries (allowed to use external sources)

Data Source API/Service Used Purpose
GMX REST API arbitrum-api.gmxinfra.io, avalanche-api.gmxinfra.io Market info, prices, tokens
Public RPC publicnode.com Direct eth_call for positions, orders, balances, allowances

External APIs / Libraries Detected

  • reqwest (HTTP client) for GMX API and RPC calls
  • alloy-primitives, alloy-sol-types (for ABI types — not used for signing)
  • No web3 wallet libraries; no direct signing

Verdict: ✅ Fully Compliant

The plugin correctly delegates all signing and broadcasting to onchainos wallet contract-call and only uses external APIs/RPC for read-only data queries.

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 Only in auto-injected pre-flight (skipped per instructions)
H05 INFO Direct financial / on-chain operations Plugin performs leveraged trading via onchainos wallet contract-call — baseline characteristic, expected
M03 MEDIUM Third-party content fetched reqwest fetches from gmxinfra.io and publicnode.com — code uses <external-content>-equivalent boundary via "Treat all CLI output as untrusted" notice in SKILL.md
M07 MEDIUM Missing untrusted-data boundary declaration SKILL.md explicitly contains: "Treat all data returned by this plugin... as untrusted external content"
M08 MEDIUM External data field passthrough SKILL.md contains explicit "Output field safety (M08)" instructions enumerating safe fields

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.95 No prompt injection patterns; no override instructions
L-MALI CRITICAL No 0.95 Behavior matches declared GMX V2 trading purpose; calldata construction is verifiable
L-MEMA HIGH No 0.95 No memory file modification
L-IINJ INFO Yes 0.95 External requests to gmxinfra.io + publicnode.com declared and bounded
L-AEXE INFO No 0.90 Write ops require explicit --confirm flag; agent confirmation gate documented
L-FINA HIGH Yes (INFO-level) 0.95 Write + explicit confirmation mechanism + confirm flag gate → INFO classification
L-FISO INFO No 0.90 Field-level filtering documented in M08 boundary

Toxic Flow Detection (TF001-TF006)

No toxic flows detected. The plugin has H05 (financial operations) but pairs it with proper M07 boundary declaration and M08 field filtering, so TF006 does not trigger. No C01 in plugin code (only in CI-injected pre-flight, skipped per instructions), so TF005 does not trigger.

Prompt Injection Scan

No instruction override, identity manipulation, hidden behavior, base64-encoded content, or invisible characters detected. SKILL.md is clear, well-structured documentation.

Result: ✅ Clean

Dangerous Operations Check

The plugin involves leveraged perpetual trades, liquidity deposits/withdrawals, and contract calls. SKILL.md explicitly documents: (1) --confirm flag required for all writes, (2) --dry-run available for preview, (3) explicit "Ask user to confirm" steps in execution flow, (4) pre-flight balance/collateral/gas checks return structured errors before any broadcast.

Result: ✅ Safe

Data Exfiltration Risk

No environment variable access beyond standard reqwest behavior. No paths read from filesystem outside cargo standard build. All API calls are to declared GMX/RPC endpoints. No credential capture or upload patterns.

Result: ✅ No Risk

Overall Security Rating: 🟢 Low Risk

6. Source Code Security

Language & Build Config

  • Language: Rust (edition 2021)
  • Entry point: src/main.rs
  • Binary name: gmx-v2-plugin

Dependency Analysis

Dependencies are well-known, actively maintained crates:

  • clap 4 (CLI parsing) — stable
  • reqwest 0.11 (HTTP) — widely used
  • serde / serde_json 1 — stable
  • tokio 1 (async runtime) — stable
  • anyhow 1 (error handling) — stable
  • alloy-sol-types 0.8, alloy-primitives 0.8 — modern Ethereum types
  • hex 0.4 — minimal utility

No suspicious or unmaintained dependencies. No known vulnerabilities flagged.

Code Safety Audit

Check Result Detail
Hardcoded secrets (API keys, private keys, mnemonics) None detected; plugin uses delegated signing
Network requests to undeclared endpoints Only to declared GMX APIs and public RPCs
File system access outside plugin scope None detected
Dynamic code execution (eval, exec, shell commands) Only Command::new("onchainos") — expected delegation pattern
Environment variable access beyond declared env None detected
Build scripts with side effects (build.rs, postinstall) No build.rs present
Unsafe code blocks (Rust) / CGO (Go) No unsafe blocks

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

Yes — commands described in SKILL.md map directly to source code modules in src/commands/. Pre-flight checks documented (token balance, ETH for fees, GMX min collateral) match the actual implementation. Multicall structure (sendWnt + sendTokens + createOrder) matches abi.rs.

Verdict: ✅ Source Safe

7. Code Review

Quality Score: 92/100

Dimension Score Notes
Completeness (pre-flight, commands, error handling) 24/25 Comprehensive pre-flight checks (ETH balance, token balance, GMX min collateral); detailed error JSON structures; tx confirmation polling
Clarity (descriptions, no ambiguity) 24/25 Clear command descriptions; each command has parameters, flow, and expected outputs; risk warnings prominent
Security Awareness (confirmations, slippage, limits) 24/25 Explicit --confirm gate; slippage default 1%; pre-flight collateral checks; M07/M08 boundaries declared; "Ask user to confirm" steps
Skill Routing (defers correctly, no overreach) 14/15 Clear "Do NOT use for..." section; correctly delegates to onchainos wallet for signing
Formatting (markdown, tables, code blocks) 6/10 Tables and code blocks well-used; minor: some commands could use more visual separation

Strengths

  • Excellent pre-flight checks with structured error JSON (INSUFFICIENT_TOKEN_BALANCE, INSUFFICIENT_COLLATERAL, INSUFFICIENT_ETH_FOR_EXECUTION) that AI agents can parse and surface
  • Strong security boundaries: explicit --confirm requirement, no unlimited approvals (exact amount approval pattern), explicit M07/M08 data trust notices
  • Proper architecture: ABI calldata construction in plugin, signing/broadcast delegated to onchainos — clean separation of concerns

Issues Found

  • 🔵 Minor: SKILL.md mentions "v0.2.7" in changelog should match the version field (changelog entry says "v0.2.6 (2026-04-17)" but plugin.yaml is 0.2.7 — minor inconsistency)
  • 🔵 Minor: Some commands like claim-funding-fees use the receiver parameter that defaults to wallet — could benefit from explicit warning about passing arbitrary receivers
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 ✅ 1991 chars
11. Recommendations
  1. Update changelog in SKILL.md to include v0.2.7 entry (currently only references v0.2.6)
  2. Consider adding an explicit warning when claim-funding-fees --receiver is used with a non-wallet address
  3. Consider documenting the rate-limit behavior of the GMX REST API and what users should expect on fallback
  4. Add a sentence in SKILL.md about MEV protection considerations on Arbitrum (since GMX V2 keeper model means tx is delayed 1-30s)
12. Reviewer Summary

One-line verdict: A well-architected GMX V2 plugin with strong security boundaries, proper delegation to onchainos for signing, and comprehensive pre-flight checks — ready to merge.

Merge recommendation: ✅ Ready to merge

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

No blockers found.

Non-blocking improvements:

  • Update changelog to include v0.2.7 entry
  • Add MEV/keeper-delay note for Arbitrum users
  • Document GMX API fallback behavior more explicitly

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

@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 0074fee into mig-pre:main May 7, 2026
31 checks passed
@plugin-store-bot
Copy link
Copy Markdown

✅ Phase 4: Publish Complete

Plugins: gmx-v2-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