An end-to-end, privacy-aware DeFi execution stack that combines:
- Agents (uAgents) for scanning yields, assessing risk, and executing on-chain strategies
- Smart contracts (Foundry) including an
AgentVaultand protocol adapters - Zero-knowledge circuits (Circom + snarkjs) for strategy proofing and an on-chain Groth16 verifier
- A Next.js frontend for visualizing states and interacting with agents/contracts
packages/agents/: Python agents and orchestrationyield_scanner.py: discovers opportunities and emitsYieldOpportunitiesrisk_assessor.py: ranks opportunities (optionally via ASI:One) and emitsRiskAssessmentscrosschain_executor.py: validates/executes strategies using adapters on Base Sepoliaasi_chat_agent.py: simple chat agent with portfolio contextmodels.py,config.py: shared message schemas and chain/contract configrequirements.txt: pinned deps (Python 3.12)
packages/contracts/: Foundry workspacesrc/AgentVault.sol: ERC20 receipt vault (agUSDC) with ZK strategy proof gatingsrc/adapters/*Adapter.sol: Aave/Compound/Morpho adapter interfaces for supply flowssrc/interfaces/IProtocolAdapter.solsrc/StrategyVerifier.sol: Groth16 verifier (snarkjs-generated)script/andbroadcast/: deployment scripts and artifacts
packages/circuits/: ZK artifacts and verifier sourcesPrivateYieldStrategy.circom,*_js/*.wasm,*_final.zkey,verification_key.jsontest_proof.js: local proof generation/verification scriptStrategyVerifier.sol: snarkjs-generated verifier (reference)
packages/frontend/: Next.js app- Serves UI, integrates with snarkjs and on-chain data
Prereqs: Python 3.12, Node.js 18+, pnpm, Foundry (forge/anvil), jq, git.
- Install root JS deps
pnpm install- Python virtualenv for agents
cd packages/agents
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
# Note: metta-dsl is optional and may not be published for your platform; agents run without it- Environment
Create a .env in packages/agents/ with:
# Agents / API
ASI_ONE_API_KEY=your_asi_api_key
ASI_ONE_URL=https://api.asi1.ai/v1/chat/completions
# Base Sepolia
RPC_URL=https://sepolia.base.org
CHAIN_ID=84532
USDC_ADDRESS=0x036CbD53842c5426634e7929541eC2318f3dCF7e
# Execution key (DO NOT commit real keys)
PRIVATE_KEY=0xabc...dead
# Adapter addresses (must exist on target chain)
AAVE_ADAPTER_BASE_SEPOLIA=0xe64834f0A0764Fe7BD3b96465BF1D95Ec2bB1927
COMPOUND_ADAPTER_BASE_SEPOLIA=0xc61f427e9004aFC8B2905b8761A12D3353e0C5f8
MORPHO_ADAPTER_BASE_SEPOLIA=0xF2c1085F908723Ea3e5B07D7A80c08723Aea6AFc
# Optional UI context
PORTFOLIO_API=http://127.0.0.1:3000/api/portfolio- Contracts (Foundry)
cd packages/contracts
forge install
forge build
# Optionally run tests
forge test -vvv- Circuits: local proof check
cd packages/circuits
pnpm exec node test_proof.js- Frontend
cd packages/frontend
pnpm dev
# App on http://localhost:3000Use the same Python venv for all agents:
source packages/agents/venv/bin/activate- Risk Assessor (port 8001)
python packages/agents/risk_assessor.py- CrossChain Executor (port 8004, retry server 8010)
python packages/agents/crosschain_executor.py- Yield Scanner (port 8000)
python packages/agents/yield_scanner.py- ASI Chat Agent (port 8005)
python packages/agents/asi_chat_agent.pyAgent inspection links are printed on startup (Agentverse).
yield_scanneremitsYieldOpportunitiestorisk_assessorevery 60s.risk_assessorcomputes risk scores (ASI:One or heuristic) and sendsRiskAssessmentstocrosschain_executor.crosschain_executorbuilds a strategy and executes via protocol adapters on Base Sepolia.
Models are defined in packages/agents/models.py and used across agents.
AgentVault.sol:- USDC vault with receipt token
agUSDC(6 decimals) - Requires a recent Groth16 strategy proof via
submitStrategyProof - Standard deposit/redeem/withdraw with ERC4626-like math
- USDC vault with receipt token
StrategyVerifier.sol:- Groth16 verifier generated by snarkjs, used by the vault
adapters:- Minimal adapters for Aave/Compound/Morpho supply flows (demo selectors)
- Circom circuit computes a portfolio hash and public signals
- Artifacts included:
.wasm,.zkey,verification_key.json test_proof.jsdemonstrates fullProve and local verification
- Next.js 15 app (Turbopack) with wagmi/viem integration
- Includes
snarkjsand data visualization libs
- Port in use (8000/8001/8004/8005/8010): stop stale processes and relaunch
- RPC not reachable: ensure
RPC_URLis correct and network is accessible - Missing metta-dsl: optional; agents run without it
This repository bundles multiple components. Each package retains its own license headers. See individual files.