Defi overview

From aaronjmars/aeon · View interactive version

Defi overview is an AI agent skill from the GitHub repository aaronjmars/aeon. One-pass crypto read - tracked-protocol positions and health plus macro context, with regime take, DeFi verdict, biggest movers, yields, fees, breadth, Fear & Greed, and prediction markets.

How to use this skill

Skill file

<!-- autoresearch: variation B — sharper output via regime verdict + Market Take + sustainable-vs-incentive yield split + fees fundamentals + per-mover "why it matters". Consolidated: folds in defi-monitor (tracked-protocol positions/health) and market-context (broad crypto macro + memory/topics/market-context.md refresh) so one run covers positions + macro in a single pass. -->

${var} — Scope selector. Empty → full combined overview (tracked-protocol positions + macro context). positions → positions facet only (all watched positions); positions:<label> → a single tracked position by label. macro → macro facet only. Any other value → treat as a chain or protocol focus (e.g. solana, aave, arbitrum) applied to the macro read; positions are filtered to that chain when applicable.

Read memory/MEMORY.md for context. Read the last 2 days of memory/logs/ to avoid repeating numbers, to diff position values over time, and to cite yesterday's figure when flagging today's change. Read memory/on-chain-watches.yml (tracked positions) and the existing memory/topics/market-context.md (prior macro snapshot) — both are inputs below.

Thesis

The original produced a table of numbers. This version produces a read of the market: one verdict line at the top, then only items that changed or matter, each with a one-line reason a reader should care. TVL alone is lagging and emission-subsidized — we pair it with fees/revenue (real fundamentals) and split yields into sustainable (apyBase) vs incentive-driven (apyReward) so readers stop chasing scam-tier APYs. On top of the market read this skill also (a) checks the operator's tracked-protocol positions for health/liquidation/yield-drift risk, and (b) refreshes the decision-ready macro context file that downstream skills (token-pick, narrative-tracker) consume — all in one pass.

Facets & var routing

The skill has two facets. ${var} selects which run and how to scope them:

When both facets run (empty var), send one combined notification (Take → position alerts if any → DeFi read → macro snapshot) and still write memory/topics/market-context.md.


FACET A — Positions (tracked-protocol health)

(Runs when ${var} is empty, positions, positions:<label>, or a chain focus. Skip entirely for macro.)

Position config

Watched contracts and positions live entirely in memory/on-chain-watches.yml — no protocols are hardcoded in this skill. If the file is missing or has no type: pool / type: position entries, log DEFI_MONITOR_NO_CONFIG for this facet and skip it cleanly (no notification — an empty config is not an error; the Macro facet still runs when applicable).

# memory/on-chain-watches.yml
watches:
  - label: My Wallet
    address: "0x1234...abcd"
    chain: ethereum
    rpc_url: https://eth.llamarpc.com
    type: wallet
    threshold: 0.1  # ETH — alert on balance changes above this

  - label: Uniswap Pool
    address: "0xabcd...5678"
    chain: ethereum
    rpc_url: https://eth.llamarpc.com
    type: contract

Steps — Positions

A1. Query each DeFi position

For each DeFi position in memory/on-chain-watches.yml (type: pool or type: position), filtered by ${var} if a label (positions:<label>) or chain focus is set:

```bash

# Example: read slot0 from a Uniswap-style pool

curl -s -X POST "${rpc_url}" \

-H "Content-Type: application/json" \

-d '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"'"$address"'","data":"'"$calldata"'"},"latest"],"id":1}'

```

A2. Compare against last logged values

Compare current values against the last logged values for each position (grep prior runs in memory/logs/).

A3. Flag anything noteworthy

A4. Positions output

Positions block template:

*DeFi Monitor - ${today}*

*Pool/Protocol Label* (chain)
TVL: $X | APR: Y%
Your position: details
Change since last check: summary

FACET B — Macro (DeFi market read + crypto context)

(Runs when ${var} is empty, macro, or a chain/protocol focus. Skip entirely for positions / positions:<label>.)

Steps — Macro

B0. Load prior macro snapshot (for deltas + preserve-on-failure)

Read the existing memory/topics/market-context.md if present. Extract, for delta computation later:

If the file doesn't exist, treat all deltas as n/a on the first run.

B1. Fetch (public, no auth — use WebFetch if curl fails)

Run each command below as its own Bash call. Each saves its response with curl's own -o (a shell > redirect into a file is refused in this run). CoinGecko key check: read the "Keys set for this run" line in your run notes, never a shell test (those are refused and cost a turn). When COINGECKO_API_KEY is on that line keep the -H "x-cg-demo-api-key: {COINGECKO_API_KEY}" on the four CoinGecko calls below; when it is not, drop that -H (keyless public works at a lower rate limit).

mkdir -p .tmp

# --- DeFiLlama (shared by the DeFi read and the macro snapshot) ---
# TVL
curl -fsS -o .tmp/chains.json "https://api.llama.fi/v2/chains"
curl -fsS -o .tmp/protocols.json "https://api.llama.fi/protocols"
# Volumes & fundamentals
curl -fsS -o .tmp/dexs.json "https://api.llama.fi/overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true"
curl -fsS -o .tmp/fees.json "https://api.llama.fi/overview/fees?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true"
# Stablecoins — includePrices=true (superset; supply totals feed the DeFi read, prices feed the macro snapshot)
curl -fsS -o .tmp/stables.json "https://stablecoins.llama.fi/stablecoins?includePrices=true"
# Yields
curl -fsS -o .tmp/pools.json "https://yields.llama.fi/pools"

# --- CoinGecko (macro majors, breadth, global, trending) ---
# Demo key via ./secretcurl's {ENV_NAME} placeholder; drop the -H when the key is not set (see above).
# Simple price for BTC, ETH, SOL + 24h change + mcap
./secretcurl -s -o .tmp/cg_price.json -H "x-cg-demo-api-key: {COINGECKO_API_KEY}" "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd&include_24hr_change=true&include_market_cap=true"
# Top 20 by mcap (movers + trend, 24h & 7d)
./secretcurl -s -o .tmp/cg_markets.json -H "x-cg-demo-api-key: {COINGECKO_API_KEY}" "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=20&page=1&sparkline=false&price_change_percentage=24h,7d"
# Global stats (total mcap, volume, dominance)
./secretcurl -s -o .tmp/cg_global.json -H "x-cg-demo-api-key: {COINGECKO_API_KEY}" "https://api.coingecko.com/api/v3/global"
# Trending coins
./secretcurl -s -o .tmp/cg_trending.json -H "x-cg-demo-api-key: {COINGECKO_API_KEY}" "https://api.coingecko.com/api/v3/search/trending"

# --- Fear & Greed ---
curl -s -o .tmp/fng.json "https://api.alternative.me/fng/?limit=2"

# --- Polymarket Gamma (prediction markets) ---
curl -s -o .tmp/poly_vol.json "https://gamma-api.polymarket.com/markets?closed=false&order=volume24hr&ascending=false&limit=10"
curl -s -o .tmp/poly_liq.json "https://gamma-api.polymarket.com/markets?closed=false&order=liquidity&ascending=false&limit=10"

For each endpoint, if curl fails or returns non-JSON, retry once with WebFetch against the same URL (for CoinGecko, WebFetch without the API-key header — free tiers work). Mark each source ok or fail and carry it into the footer / Source Status line. Never block the whole run on a single source.

Notes on fields:

B2. WebSearch — macro catalysts (2 queries only; noise is expensive)

Use the built-in WebSearch tool for exactly:

Keep only items that would change a trader's positioning today. Discard recap/explainer articles. Mark websearch=ok|fail.

B3. Compute the DeFi regime verdict (ONE line)

Score three dimensions from the last 24h:

Verdict rules (pick the first that matches):

B4. Compute the Market Take (the macro headline)

The Take is the core macro output — everything else is input to it.

Market Take format (exactly 3 lines):

Take: <regime> - <one-sentence why, citing 2 concrete numbers>.
Conviction: <high | medium | low> - <which signals agree; which disagree>.
Evidence: <one sentence naming the single strongest datum behind this call>.

Example:

Take: risk-on - BTC +3.1% 24h with 17/20 top-cap majors green.
Conviction: high - F&G, breadth, and 7d TVL all point up; only BTC dominance disagrees (flat).
Evidence: DEX 24h volume $7.8B, highest since March and +42% vs 7d avg.

Score the regime using these inputs:

Assign one regime label:

Also emit conviction in {high, medium, low} based on how many signals agree.

B5. Pick what goes in the DeFi read

Each section caps at 3 items. Drop any section whose best item fails its inclusion rule — don't pad.

B6. Compare against yesterday's log

Read memory/logs/${yesterday}.md. If a mover appears today whose direction flipped (e.g. chain was top gainer yesterday, now top loser), prepend ↔ and note the reversal in its "why" line. If a yield pool from yesterday's Real-yield list is missing today, check whether it failed a filter (outlier flipped, APY collapsed) — worth one line under Yields.

B7. Classify active narratives (phase + evidence)

For each of 3-5 current meta-narratives (derived from trending coins + top movers + macro catalyst scan), assign a phase and a one-line evidence anchor:

No narrative without an evidence anchor. If you cannot point to a number or concrete signal, drop it.

B8. Polymarket parsing

For each market: outcomes and outcomePrices are JSON-encoded arrays that map 1:1. YES% = parseFloat(outcomePrices[0]) * 100 (first element is always YES). Skip any market where YES% is <3% or >97% (effectively settled — no signal). Take the top few by 24h volume and by liquidity.

B9. Write the updated `memory/topics/market-context.md`

Overwrite memory/topics/market-context.md with this exact structure. Lead with the Take so downstream skills get the conclusion in the first ~150 chars:

# Market Context (as of ${today})

> **Take:** [regime] - [one-sentence why, citing 2 concrete numbers]. Conviction: [high|medium|low].

## Signal Snapshot
- BTC $X (±X% 24h, ±X% 7d) · dominance X% (±X pp 24h)
- ETH $X (±X% 24h, ±X% 7d) · ETH/BTC X.XXX
- SOL $X (±X% 24h, ±X% 7d)
- Total mcap $XT (±X% 24h) · DEX vol $XB 24h
- Breadth: N/20 green 24h · N/20 green 7d
- Fear & Greed: X (label) - yesterday X

## What Changed Since Last Refresh
- [Delta or event 1 - e.g. "F&G jumped 12 pts into Greed, first time in 14 days"]
- [Delta 2]
- [Delta 3]
Only real deltas. If no material change, write: "Quiet - all majors within ±1%, regime unchanged."

## Active Narratives
- **[Narrative]** - phase: [emerging|rising|peak|fading]. Evidence: [concrete signal].
- **[Narrative]** - phase: [...]. Evidence: [...].
- **[Narrative]** - phase: [...]. Evidence: [...].

## Top DeFi Protocols (TVL, 7d change)
- [Protocol]: $XB ([+/-X%])
- [Protocol]: $XB ([+/-X%])
- [Protocol]: $XB ([+/-X%])
- [Protocol]: $XB ([+/-X%])
- [Protocol]: $XB ([+/-X%])

## Chain Flow (top 3 by TVL, 7d)
- [Chain]: $XB ([+/-X%])
- [Chain]: $XB ([+/-X%])
- [Chain]: $XB ([+/-X%])

## Stablecoins
Total: $XB (±X% 7d). USDT $XB · USDC $XB · [next two] · combined share of mcap X%.

## Trending (CoinGecko)
- [COIN] - [why trending, price + 24h%]
- [COIN] - [...]
- [COIN] - [...]

## Prediction Markets (Polymarket, top by 24h vol)
| Market | YES% | 24h Vol | Liquidity |
|--------|------|---------|-----------|
| [question] | X% | $Xm | $Xm |
| [question] | X% | $Xm | $Xm |
| [question] | X% | $Xm | $Xm |

## Macro Catalysts (next 48h)
- [Catalyst + positioning implication]
- [...]
Omit this section entirely if nothing material. Do not pad with generic headlines.

## Implications for Downstream Skills
- **token-pick:** [e.g. "favor [narrative] exposure; avoid [sector] on weak breadth"]
- **narrative-tracker:** [e.g. "monitor [narrative] for phase transition emerging→rising"]
Keep to 1-2 lines per skill. Only write implications that follow from the Take and deltas - don't generate generic advice.

## Token Picks Made
| Date | Token | Price | Thesis |
|------|-------|-------|--------|
[Rebuild verbatim from the prior file. Do not truncate or reorder. Append any new picks found in the last 7 days of memory/logs/ that aren't already in the table.]

---
*Sources - btc/eth: CoinGecko · defi: DeFiLlama · sentiment: alternative.me · markets: Polymarket*
*Source status: coingecko=[ok|fail] defillama=[ok|fail] fng=[ok|fail] polymarket=[ok|fail] websearch=[ok|fail]*

Preserve-on-failure rule: If 3+ sources fail, do not overwrite market-context.md. Instead, append a one-line staleness note to the existing file's Source Status line (last attempt ${today} failed: sources [...]) and skip the overwrite. A stale-but-valid file is strictly better than a broken one. Use the last known value from the prior file for any single failed source (do not fabricate).


Notify

Send via ./notify (single call, plain markdown). Cap the message at 4000 chars — trim lowest-signal sections first (order: Stablecoins, DEX top-3, Top chains #3, Prediction Markets).

Combined (empty var): one notification, leading with the Take, then the positions alert block only if any position flagged, then the DeFi read, then the macro snapshot:

*Crypto - ${today}* - <Take regime> (conviction <level>) | DeFi <Verdict>: <≤12-word regime read>

<positions alert block - include ONLY if ≥1 position flagged (see Facet A template)>

*TVL:* $X.XXT (+X.X% 24h, +X.X% 7d)

*Top chains*
1. Ethereum - $XXXB (+X.X%)
2. Solana - $XXB (+X.X%)
3. Tron - $XXB

*Movers*
↑ Sui +12% ($1.8B → $2.0B) - <≤15-word why>
↓ Base −7%  ($9.2B → $8.6B) - <≤15-word why>
↑ Pendle +18% ($4.0B → $4.7B) - <≤15-word why>
↓ Ethena −11% ($5.1B → $4.5B) - <≤15-word why>

*Fees leaders (24h)*
1. Tether - $XXM (+X% vs 7d avg)
2. Circle - $XXM (flat)
3. Uniswap - $XXM (−X%)

*Fees beating TVL*
• Hyperliquid - fees +42% / TVL +3% (7d) - demand outrunning deposits

*DEX vol (24h):* $X.XB (+X%)  top: Uniswap $XB, PancakeSwap $XB, Jupiter $XB

*Stables:* $XXXB (+0.X%)  - USDe +1.2% only notable single-issuer move

*Real yield (sustainable, ≥$10M, filtered)*
• stETH (Lido, ETH) - 3.2% apyBase ($21B TVL)
• sUSDS (Sky, ETH) - 6.1% apyBase ($2.1B TVL)
• GHO savings (Aave, ETH) - 7.0% apyBase ($400M TVL)

*Incentive yield (points / emissions, ≥$25M)*
• <pool> - 18% apy via $XYZ rewards ($80M TVL)
• <pool> - 14% apy via $ABC rewards ($60M TVL)

*Macro:* BTC $X (±X%) / ETH $X (±X%) · F&G X (label) · breadth N/20 · hot market: "[polymarket q]" YES X%
_sources: llama_tvl=ok llama_dex=ok llama_fees=ok llama_stables=ok llama_yields=ok coingecko=ok fng=ok polymarket=ok websearch=ok | var: ${var:-none}_

macro-only or focus run: same as above without the positions block.

positions / positions:<label> run: send the Facet A positions template only if flagged; otherwise send nothing.

Short macro-only alternative (when you prefer the terse market-context ping, e.g. a macro focus with no DeFi movers surviving filters, under 500 chars):

market context - ${today}

take: [regime] (conviction [level])
BTC $X (±X%) / ETH $X (±X%) · F&G X ([label])
breadth N/20 · TVL $XB (±X% 7d)
top narrative: [name] ([phase])
hot market: "[polymarket q]" YES X%

Edit rules before sending:

Log

Append to memory/logs/${today}.md. Include the blocks for whichever facets ran.

Positions facet — per-position current values and any flags raised (the next run's diff depends on these lines being present). If no DeFi positions configured, log DEFI_MONITOR_NO_CONFIG; on a quiet run with positions present, log DEFI_MONITOR_OK:

### defi-overview (positions)
- <Label> (chain): TVL $X | APR Y% | position <details> | flag: <none|yield Δ / TVL drop / liquidation / IL>
- ...
- Status: DEFI_MONITOR_OK | DEFI_MONITOR_NO_CONFIG

Macro facet:

### defi-overview
- Var: ${var:-none}
- Take: <regime> (conviction <level>) - <regime read>
- Verdict: <Risk-on|Risk-off|Sideways|Mixed> - <regime read>
- TVL: $X.XXT (+X.X% 24h) | BTC $X (±X%) ETH $X (±X%) F&G X (label)
- Breadth: N/20 green
- Top mover up: <chain/protocol> +X%   Top mover down: <chain/protocol> −X%
- Fees leader: <protocol> $XXM
- Top narrative: <name> (<phase>)
- Polymarket highlight: "<question>" YES X%
- Real-yield count: N   Incentive-yield count: N
- Sources: tvl=ok dex=ok fees=ok stables=ok yields=ok coingecko=ok fng=ok polymarket=ok websearch=ok
- Updated memory/topics/market-context.md: yes|no (preserve-on-failure)

Network note

Environment Variables

Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.