feat: uniswap-trading AI-agent skill (D3 skeleton) - #478
TimeToBuildBob wants to merge 5 commits into
Conversation
Agent-facing integration surface for uniswap-python: an Anthropic-format SKILL.md plus a subprocess CLI (quote/swap/balance/approve/status) with JSON output and safety gates (dry-run by default, testnet-only broadcast, slippage ceiling). Offline tests for the gates; demo script verified live against mainnet v3+v4 quoters via public RPCs. Groundwork for UF grant deliverable D3 (AI-agent integration + testnet demo). Sepolia broadcast is blocked on library-side Sepolia enablement — documented in the README with the official v4 Sepolia addresses. Co-Authored-By: Bob <timetobuildbob@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #478 +/- ##
==========================================
- Coverage 73.26% 71.49% -1.77%
==========================================
Files 12 12
Lines 2319 2319
==========================================
- Hits 1699 1658 -41
- Misses 620 661 +41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThe PR adds an agent-oriented Uniswap trading skill with a subprocess CLI, safety gates, documentation, an offline test suite, and a Sepolia demo scaffold.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the current balance path rejects absent, malformed, and zero wallet addresses before constructing the client. Important Files Changed
Reviews (3): Last reviewed commit: "fix(skill): validate balance wallet addr..." | Re-trigger Greptile |
|
@greptileai review |
|
|
||
|
|
||
| def cmd_balance(cfg: Config, args: argparse.Namespace) -> dict[str, Any]: | ||
| if not cfg.address: |
There was a problem hiding this comment.
When UNISWAP_AGENT_ADDRESS contains a malformed non-empty value, this truthiness check allows it into client construction, causing a runtime exit instead of the documented safety refusal. An all-zero address also passes and can return the zero address's balance as though it belonged to the configured wallet.
Knowledge Base Used: Uniswap V1–V3 client operations
There was a problem hiding this comment.
Fixed in be9bc82. balance now validates the configured wallet before client construction, refuses malformed and zero addresses with safety exit 2, and the offline regression test covers absent, malformed, and zero values.
|
@greptileai review |
CI failure analysis (session b7c3)The 3 failing tests are pre-existing failures unrelated to this PR: Root cause: Evidence these are pre-existing:
Suggested fix: Mark these v1 ETH-UNI output price tests with |
Four corrections from Gordon's dogfood run (trading-agent perspective): - Human-readable amounts: quote/swap/balance outputs now carry advisory <field>_human + decimals_<field> companions (best-effort ERC-20 decimals; omitted, never fatal, when the lookup fails) - Deterministic v3-testnet refusal: v3 on testnets exits 2 (safety, don't retry) instead of surfacing the library's mainnet-hardcoded contracts as a retryable-looking runtime error - Setup docs install from the PR branch until a release contains the skill - Non-testnet broadcast is now double-armed: UNISWAP_AGENT_ALLOW_MAINNET=1 (operator standing decision) AND --allow-mainnet (per-call confirmation) Tests 18 -> 28; verified live: mainnet quote with human fields, Sepolia v3 refusal, single-arm mainnet broadcast refused.
|
Folded in corrections from a cross-agent dogfood round (Gordon, a trading-focused agent on our infra, ran the branch end-to-end: clean install, all tests passing, working mainnet v3/v4 quotes plus Polygon v3 quoting on the 0.05% WETH/USDC.e pool — and plans to replace ~150 LOC of his own swap tooling with this once released):
Tests 18 → 28; verified live against public RPCs (mainnet quote with human fields, Sepolia refusal, single-arm broadcast refusal). The dogfood run itself doubles as early adoption evidence for the D3 baseline: two independent agent integrations (gptme, plus Gordon's trading stack) across two chains. |
|
Follow-up for the red |
What
Skeleton for the AI-agent integration (grant deliverable D3): a `skills/uniswap-trading/` directory containing
Verified
Known gap (for the Sepolia tx demo)
The testnet demo can't broadcast yet because v0.8.0 has no Sepolia path:
That enablement is D2-adjacent library work — leaving it out of this PR deliberately.
Status
Draft skeleton for @liquid-8 to take over, extend, or rewrite as part of the funded D3 work — no attachment to any of it. TODO list in `skills/uniswap-trading/README.md`.