Back to Docs

DeFi API

Yield discovery with algorithmic risk scoring and LLM risk assessments. All endpoints require x402 payment in USDC on Base (or Solana).

Risk Scoring

  • Algorithmic — TVL, impermanent loss, APY sustainability, multi-token exposure, stablecoin status
  • Scale — 0-100 (higher = safer). Starts at 100 and deducts for risk factors
  • LLM Assessment — Optional natural language risk analysis for top results (?assess=true)
  • Cache — Pool data cached 5 min, LLM assessments cached 1 hour

Risk Levels

LevelScoreDescription
Low71-100Battle-tested protocol, high TVL, stable yield
Medium40-70Some risk factors — lower TVL, reward-dependent APY, or IL exposure
High0-39Significant risk — very low TVL, extreme APY, or high impermanent loss

Risk Score Deductions

Starts at 100. Each risk factor deducts points:

-30
TVL < $100K
Low liquidity, high manipulation risk
-40
IL > 5% (7d)
Severe impermanent loss
-20
APY > 100%
Suspiciously high — unsustainable
-10
Reward-dependent
>80% of APY from reward tokens
GET

/api/v1/yields

$0.05

DeFi yield pools on Base with risk scoring. Data from DefiLlama, cached 5 minutes.

ParamTypeDescription
minApynumberMinimum APY % (e.g. 5)
maxRiskstringMax risk level: low, medium, high
tokenstringFilter by token symbol (USDC, WETH)
protocolstringFilter by protocol (aave-v3, morpho)
stableOnlybooleanOnly stablecoin pools
assessbooleanInclude LLM risk assessments for top 5
limitnumberMax results (default 20)
Requestbash
curl "https://x402.kodaoracle.com/api/v1/yields?token=USDC&maxRisk=low&assess=true" \
  -H "Payment-Signature: <base64-payment>"
Responsejson
{
  "pools": [
    {
      "id": "747c1d2c-...",
      "protocol": "aave-v3",
      "symbol": "USDC",
      "tokens": ["USDC"],
      "apy": 5.21,
      "apyBase": 5.21,
      "apyReward": null,
      "tvlUsd": 152000000,
      "il7d": null,
      "riskLevel": "low",
      "riskScore": 92,
      "category": "lending",
      "stablecoin": true,
      "updatedAt": "2026-02-15T12:00:00Z"
    }
  ],
  "count": 1,
  "assessments": {
    "747c1d2c-...": {
      "poolId": "747c1d2c-...",
      "assessment": "Aave V3 USDC on Base — battle-tested lending protocol with $152M TVL. Base APY of 5.21% with no reward dependency. Minimal risk for stablecoin deposits.",
      "recommendation": "safe",
      "riskFlags": [],
      "modelUsed": "kimi",
      "generatedAt": "2026-02-15T12:00:00Z",
      "cached": false
    }
  },
  "source": "DefiLlama",
  "chain": "Base",
  "updatedAt": "2026-02-15T12:00:00Z"
}
POST

/api/v1/swap

$0.10

Token swap on Base with safety pipeline. Runs token audit + price impact checks in parallel. Blocks if safety score < 30 or price impact > 5%.

Requestbash
curl -X POST "https://x402.kodaoracle.com/api/v1/swap" \
  -H "Payment-Signature: <base64-payment>" \
  -H "Content-Type: application/json" \
  -d '{
    "tokenIn": "USDC",
    "tokenOut": "WETH",
    "amountIn": "100",
    "sender": "0xYourWallet"
  }'
Responsejson
{
  "success": true,
  "amountOut": "0.028",
  "priceImpact": "0.12",
  "transaction": {
    "to": "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
    "data": "0x...",
    "value": "0",
    "gas": "350000"
  },
  "safety": {
    "score": 85,
    "verdict": "PASS",
    "checks": [
      { "name": "token_audit", "passed": true, "score": 90 },
      { "name": "price_impact", "passed": true, "score": 95 }
    ]
  }
}

ACP Offerings

DeFi execution via the Agent Commerce Protocol. Agents send tokens to KODA, KODA executes on-chain, output returns to the buyer via ACP's payableDetail.

$0.01

yield_deposit

Deposit USDC into yield protocols on Base: Avantis (~12% APY from perp fees), Morpho vaults (~3-4% APY), or Aave V3 (~3-5% APY). Returns yield-bearing tokens (aUSDC, vault shares, or avUSDC) via ACP payableDetail.

Params: amount (required), protocol (aave-v3, morpho, avantis), vault (slug for Morpho/Avantis)
$0.01

yield_withdraw

Withdraw USDC from Aave V3, Morpho vaults, or Avantis on Base. For Aave: send aUSDC. For vaults: send vault shares + specify vault slug. USDC returned via ACP payableDetail.

Params: amount (required), protocol (aave-v3, morpho, avantis), vault (required for Morpho/Avantis)
$0.01

yield_finder

Same as GET /api/v1/yields but accessible via ACP. Returns yield pools with risk scores. No funds required.

$0.01

swap

Token swap on Base. Buyer sends tokenIn, KODA executes swap on-chain, tokenOut returned via payableDetail. Safety pipeline runs on every swap.

Params: tokenIn, tokenOut, amountIn (all required)