All Agent Setups
DeFi opportunity executionLow complexitySolo operators

OpenClaw + DeFiLlama + RiskState + Uniswap

DeFi research and allocation agent. DeFiLlama provides free TVL, yield, and protocol data. RiskState enforces position limits before any deployment. Uniswap executes via UniswapX intents — gasless and MEV-protected.

How it works

1

DeFiLlama provides market intelligence

Your agent queries DeFiLlama for real-time market data — TVL, yield opportunities, protocol metrics, and DEX volumes. No API key required, unlimited calls.

2

RiskState gates the decision

Before any execution, your agent calls POST /v1/risk-state. The response contains max_size_fraction (position ceiling), allowed_actions (what’s permitted), and structural_blockers (hard stops). If blockers exist, the agent halts. Otherwise, it sizes the trade within the policy limit. 30+ signals scored in real-time, 60-second cache, SHA-256 audit hash.

3

Uniswap executes within limits

The trade is submitted to Uniswap via UniswapX intents — gasless and MEV-protected. Fillers compete to give your agent the best price. Position size never exceeds what RiskState permitted.

Integration code

Copy this into your project. Replace the API keys with your own.

openclaw_riskstate_uniswap.py
import requests

# 1. Get DeFi yields from DeFiLlama (free, no key)
pools = requests.get(
    "https://yields.llama.fi/pools"
).json()["data"]

# Filter top ETH yield opportunities
eth_pools = [p for p in pools if p["chain"] == "Ethereum"
             and p["tvlUsd"] > 1_000_000
             and p["apy"] > 3.0]

# 2. Get risk policy from RiskState
policy = requests.post(
    "https://riskstate.netlify.app/v1/risk-state",
    headers={"Authorization": f"Bearer {RISKSTATE_KEY}"},
    json={"asset": "ETH"}
).json()

max_size = policy["exposure_policy"]["max_size_fraction"]
allowed = policy["exposure_policy"]["allowed_actions"]

# 3. Enforce governance
if "DCA" not in allowed and "LONG_SHORT_CONFIRMED" not in allowed:
    print(f"Action not permitted. Allowed: {allowed}")
else:
    # 4. Allocate within policy limits
    allocation = portfolio_value * max_size
    print(f"Deploy up to ${allocation:.0f} across {len(eth_pools)} pools")
    # Execute via Uniswap UniswapX intents (gasless, MEV-protected)

What your agent receives from RiskState

Every call to /v1/risk-state returns these three blocks. Your agent reads them in order.

Exposure Policy

Binding
  • max_size_fraction — hard ceiling
  • leverage_allowed — boolean
  • allowed_actions — enum list
  • blocked_actions — enum list

Market Intelligence

Context
  • tactical_state — LEAN BULL, etc.
  • market_regime — TREND, RANGE...
  • binding_constraint — source + why
  • risk_flags — blockers + risks

Auditability

Trust
  • policy_hash — SHA-256
  • confidence_score — 0-100
  • data_sources — per-signal
  • ttl_seconds — cache hint

Start building

Get an API key in under a minute. Free during beta.