Skip to content

feat: Approval Risk Auditor agent (Bounty #5)#187

Open
597226617 wants to merge 2 commits into
daydreamsai:masterfrom
597226617:bounty-5-approval-risk-auditor
Open

feat: Approval Risk Auditor agent (Bounty #5)#187
597226617 wants to merge 2 commits into
daydreamsai:masterfrom
597226617:bounty-5-approval-risk-auditor

Conversation

@597226617
Copy link
Copy Markdown

@597226617 597226617 commented May 13, 2026

Bounty Submission

Related Issue: #5


Submission File

File Path: submissions/approval-risk-auditor.md


Agent Description

The Approval Risk Auditor is a DeFi security agent that scans Ethereum wallet addresses for risky ERC-20 token approvals across multiple EVM chains.

Key Features

  • Multi-chain scanning: Supports Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, Avalanche, Fantom, and Gnosis
  • Comprehensive risk detection:
    • Unlimited (MAX_UINT256) allowances → critical
    • Stale approvals (not used in 6+ months of blocks) → medium
    • Suspicious unverified contract spenders → high
    • Non-zero allowances to unknown EOAs → low
  • Revocation data: Generates valid approve(spender, 0) calldata for each approval
  • Built with @lucid-dreams/agent-kit: Uses createAgentApp with Hono, Zod validation, and x402 payment middleware

Architecture

  • Single entrypoint: audit - accepts { wallet, chains } input
  • Dual scanning strategy: Batched JSON-RPC allowance checks + Etherscan API fallback
  • Contract verification: Checks spender addresses for bytecode and known protocol status
  • Type-safe: Full TypeScript with Zod input/output schemas

Live Deployment

Deployment URL: https://rpm-wonderful-eyes-ownership.trycloudflare.com

The agent is live and reachable via x402 protocol. Endpoints:

  • GET /health - Health check → {"ok":true,"version":"1.0.0"}
  • GET /.well-known/agent.json - Agent manifest (agent card with x402 payment config)
  • POST /entrypoints/audit/invoke - Audit endpoint (x402 payment required)

Acceptance Criteria

  • Matches Etherscan approval data for top tokens
  • Identifies unlimited and stale approvals
  • Provides valid revocation transaction data
  • Deployed on a domain and reachable via x402
  • Submission file added to submissions/ directory
  • All tests passing (10 unit + mock integration tests)

Other Resources

  • Code Directory: approval-risk-auditor/ (in this repo)
  • Tech Stack: TypeScript, Bun, @lucid-dreams/agent-kit, Hono, Zod, viem
  • Run locally: cd approval-risk-auditor && bun install && bun run src/index.ts
  • Run tests: cd approval-risk-auditor && bun test

Solana Wallet

Wallet Address: 14XeLRYzRwyzwXGMDCdjoQmnUQHy5HdEfg6XwbpV7opp


Technical Details

The agent uses a two-pronged approach for approval detection:

  1. Primary: Batched JSON-RPC calls to check allowance() on known popular tokens against known DEX/DeFi spender addresses per chain
  2. Fallback: Etherscan-compatible API (tokenapprovalcheck endpoint) for comprehensive coverage

Risk analysis evaluates each approval for 5 categories:

  • unlimited_allowance (critical) - MAX_UINT256 approvals
  • stale_approval (medium) - Approvals older than ~6 months of blocks
  • suspicious_contract (high) - Spending contracts not in known protocol lists
  • unknown_spender (low) - Approvals granted to EOA addresses
  • high_value_allowance (medium) - Any non-zero allowance amount

Revocation data is encoded as proper ERC-20 approve(spender, 0) transactions with correct function selector 0x095ea7b3 and ABI-encoded parameters.

孙备 added 2 commits May 13, 2026 08:37
Implement an ERC-20 approval risk auditor that scans wallet addresses
across multiple EVM chains to detect risky token approvals.

Features:
- Multi-chain support (Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, Avalanche)
- RPC-based approval scanning with batched JSON-RPC calls
- Etherscan API fallback for comprehensive data
- Risk flag detection: unlimited allowances, stale approvals, suspicious contracts
- Valid revocation transaction data generation (approve(spender, 0))
- Built with @lucid-dreams/agent-kit with x402 payment integration
- 10 unit/integration tests (all passing)

Acceptance criteria met:
- Matches Etherscan approval data for top tokens
- Identifies unlimited and stale approvals
- Provides valid revocation transaction data
- Deployed and reachable via x402 protocol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant