@oracle-agent/oracle 0.24.1 → 0.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/assets/skills/chain/SKILL.md +34 -0
  2. package/dist/assets/skills/chain-defi-ecosystem-analysis/SKILL.md +181 -0
  3. package/dist/assets/skills/chain-ecosystem-gap-analysis/SKILL.md +162 -0
  4. package/dist/assets/skills/cross-chain-twap-execution/SKILL.md +125 -0
  5. package/dist/assets/skills/defi-protocol-pmf-assessment/SKILL.md +332 -0
  6. package/dist/assets/skills/evm-contract-research.md +8 -3
  7. package/dist/assets/skills/multi-venue-prepare-only-ranking/SKILL.md +93 -0
  8. package/dist/assets/skills/oracle-access-control/SKILL.md +71 -0
  9. package/dist/assets/skills/oracle-action-arming/SKILL.md +99 -0
  10. package/dist/assets/skills/oracle-airdrop-calculator/SKILL.md +111 -0
  11. package/dist/assets/skills/oracle-desk-product/SKILL.md +341 -0
  12. package/dist/assets/skills/oracle-evm/SKILL.md +55 -0
  13. package/dist/assets/skills/oracle-harness/SKILL.md +41 -0
  14. package/dist/assets/skills/oracle-mcp-install/SKILL.md +140 -0
  15. package/dist/assets/skills/oracle-multichain-convert/SKILL.md +87 -0
  16. package/dist/assets/skills/oracle-native-harness/SKILL.md +32 -0
  17. package/dist/assets/skills/oracle-ownership-gate/SKILL.md +42 -0
  18. package/dist/assets/skills/oracle-public-product-ux/SKILL.md +114 -0
  19. package/dist/assets/skills/oracle-tailscale/SKILL.md +32 -0
  20. package/dist/assets/skills/oracle-thin-client/SKILL.md +47 -0
  21. package/dist/assets/skills/perp-venue-funding-research/SKILL.md +161 -0
  22. package/dist/assets/skills/polymarket/SKILL.md +160 -0
  23. package/dist/assets/skills/protocol-api-key-integration/SKILL.md +141 -0
  24. package/dist/assets/skills/self-custodial-onchain-execution/SKILL.md +1284 -0
  25. package/dist/assets/skills/setup/SKILL.md +40 -0
  26. package/dist/assets/skills/stable-launch-ops/SKILL.md +89 -0
  27. package/dist/assets/skills/trade-loop-circuit-breaker/SKILL.md +441 -0
  28. package/dist/assets/skills/venue-capability-boundaries/SKILL.md +32 -0
  29. package/dist/bin/desk-server.mjs +16 -16
  30. package/dist/bin/oracle-data-mcp.mjs +1 -1
  31. package/dist/bin/oracle-equities.mjs +1 -1
  32. package/dist/bin/oracle-init.mjs +9 -9
  33. package/dist/cli/commands/bootstrap.mjs +1 -1
  34. package/dist/cli/commands/chat.mjs +78 -77
  35. package/dist/cli/commands/doctor.mjs +8 -6
  36. package/dist/cli/commands/eval.mjs +1 -1
  37. package/dist/cli/commands/harness.mjs +6 -6
  38. package/dist/cli/commands/model.mjs +82 -81
  39. package/dist/cli/commands/receipt.mjs +5 -0
  40. package/dist/cli/commands/setup.mjs +1 -1
  41. package/dist/cli/commands/venues.mjs +3 -0
  42. package/dist/cli/commands/watch.mjs +16 -0
  43. package/dist/equities/index.mjs +1 -1
  44. package/dist/index.mjs +1 -1
  45. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: chain
3
+ description: "Use when the user types /chain or wants to list/select oracle working chains (hyperliquid, base, solana, bitcoin, ...)."
4
+ version: 1.0.0
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ > Oracle native tools: `oracle_cli` (read/prepare), `vault_status`, `signer_status`, `signer_execute` (needs human confirmationNonce), `skill_load`. No generic shell. No fleet SSH.
9
+
10
+
11
+ # /chain
12
+
13
+ Run the local oracle chain selector. Do not invent chains.
14
+
15
+ ```bash
16
+ # list
17
+ oracle chain list
18
+
19
+ # select build surface
20
+ oracle chain use {{arg1}}
21
+
22
+ # show / clear
23
+ oracle chain show
24
+ oracle chain clear
25
+ ```
26
+
27
+ If `{{arg1}}` is empty, run `oracle chain list`.
28
+ If `{{arg1}}` is `show`, `status`, `clear`, `list`, or a chain key, pass it through:
29
+
30
+ ```bash
31
+ oracle chain {{arg1}} {{arg2}}
32
+ ```
33
+
34
+ After selection, confirm active chain key + id + agent in lowercase.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: chain-defi-ecosystem-analysis
3
+ description: "Size a chain's DeFi ecosystem, TVL, gaps, and build PMF."
4
+ version: 1.0.0
5
+ author: agent
6
+ license: MIT
7
+ platforms: [linux, macos, windows]
8
+ metadata:
9
+ hermes:
10
+ tags: [defi, tvl, defillama, ecosystem, pmf, chain-research, morpho, perps]
11
+ related_skills: [evm-contract-research, oracle-desk, verification-gate, retrieval-first-answering]
12
+ ---
13
+
14
+ > Oracle native tools: `oracle_cli` (read/prepare), `vault_status`, `signer_status`, `signer_execute` (needs human confirmationNonce), `skill_load`. No generic shell. No fleet SSH.
15
+
16
+
17
+ # Chain DeFi Ecosystem Analysis
18
+
19
+ Use when the question is about a **chain**, not a token or a contract:
20
+
21
+ - "what DeFi protocols are on chain X" / "top TVL on X"
22
+ - "which are native to X vs just deployed there"
23
+ - "what's missing / where's the gap in X's ecosystem"
24
+ - "is there product-market fit for building X on this chain"
25
+ - "is this chain's TVL real or rented"
26
+
27
+ Sibling lanes: contract/router/calldata work → `evm-contract-research`.
28
+ Swap and bridge cost comparison → `oracle-desk`.
29
+
30
+ ## Non-negotiables
31
+
32
+ 1. **Every number comes from a live API pull this turn.** No memory, no search
33
+ snippets. Chain facts go stale in days on a young chain.
34
+ 2. **Reconcile sum-of-parts against the headline before publishing any table.**
35
+ If they disagree, you have a double-count and must explain it.
36
+ 3. **Falsify before you recommend.** A build recommendation you did not try to
37
+ kill is a guess with a table attached. See "The falsification pass".
38
+ 4. State confidence per claim: high / moderate / low / unknown. Separate
39
+ "the numbers" (usually high) from "the judgment" (usually moderate).
40
+
41
+ ## Workflow
42
+
43
+ ### 1. Chain totals first
44
+ Establish the frame before naming a single protocol:
45
+
46
+ | Metric | Endpoint |
47
+ |---|---|
48
+ | Chain TVL | `api.llama.fi/v2/chains` (match on `name`/`chainId`) |
49
+ | TVL history | `api.llama.fi/v2/historicalChainTvl/<Chain%20Name>` |
50
+ | DEX volume | `api.llama.fi/overview/dexs/<Chain%20Name>` |
51
+ | Chain fees | `api.llama.fi/overview/fees/<Chain%20Name>` |
52
+ | Stablecoins | `stablecoins.llama.fi/stablecoinchains` |
53
+
54
+ **Fees are the strongest realness signal.** TVL can be farmed and volume can be
55
+ wash-traded; fees paid are revealed willingness to pay. Also read fees for *who*
56
+ earns them — a launchpad ranking #3 chain-wide tells you extraction, not utility,
57
+ is the economy.
58
+
59
+ **Always pull both TVL trend and volume trend.** TVL rising while volume falls is
60
+ capital rotating in for yield, not users arriving. Reporting only the rising one is
61
+ how a dying chain gets written up as growing.
62
+
63
+ ### 2. Protocol census + double-count reconciliation
64
+ Pull `api.llama.fi/protocols` once (~8MB), filter in Python, never print raw.
65
+ Select protocols whose `chainTvls` has a plain key for the chain (exclude
66
+ `-borrowed`, `-staking`, `-pool2` suffixed keys).
67
+
68
+ Then **reconcile**: sum of per-protocol TVL vs the chain headline. A large gap is
69
+ normal and must be explained, not smoothed over. Curators, vault wrappers, yield
70
+ frontends and capital allocators sit *on top of* a base venue and re-count the same
71
+ deposits. DefiLlama does **not** reliably set the `doublecounted` flag, so infer the
72
+ overlap from the gap and name the specific offenders.
73
+
74
+ Recipe and reconciliation worked example: `references/defillama-chain-census.md`.
75
+ Re-runnable: `scripts/chain-census.py "<Chain Name>"`.
76
+
77
+ ### 3. Native vs multichain split
78
+ `len(protocol["chains"]) == 1` ⇒ built only for this chain. This one line separates
79
+ "the chain has an ecosystem" from "the chain has deployments." Report both sums.
80
+ A chain can hold hundreds of millions while its entire native builder scene is
81
+ low-single-digit millions.
82
+
83
+ ### 4. Category gap diff
84
+ Aggregate category → (TVL, count) for the target chain and for two mature
85
+ comparators (Base, Arbitrum). Diff the category sets into three tables:
86
+ **absent entirely**, **present but dead (<$100k)**, **healthy**.
87
+
88
+ ### 5. Concentration analysis on whichever number carries the thesis
89
+ Never let a headline TVL number stand unexamined. For the dominant venue pull
90
+ depositor/position distribution: holder counts, median position, top-1/5/10 share,
91
+ and whether large holders are EOAs or contracts.
92
+
93
+ Supply and borrow sides routinely have **opposite** distributions — a broad retail
94
+ supply base with a handful of whales levered on top. Those imply different things
95
+ about stickiness, so measure them separately.
96
+
97
+ ### 6. The falsification pass
98
+ Before recommending anything be built, spend the tool calls to kill it:
99
+
100
+ - Pull the **venue's own docs** for the mechanism you plan to exploit.
101
+ - Pull **historical data** and test the effect empirically, split by the condition
102
+ you claim creates it.
103
+ - If a market for your idea already exists, check whether it exists **and is empty**.
104
+
105
+ Only then write the recommendation.
106
+
107
+ ## Pitfalls
108
+
109
+ - **Sum of protocols ≠ chain TVL.** Curator / risk-manager / yield-wrapper /
110
+ capital-allocator rows re-count base-venue deposits. Never add a curator's TVL to
111
+ the venue it curates. Reconcile the delta out loud.
112
+ - **"Absent category" and "built and rejected" are opposite conclusions.** An empty
113
+ category may be whitespace. A *deployed market sitting at near-zero* is a demand
114
+ refusal — capital looked and declined. Check which one you have before calling it
115
+ an opportunity; the second one means you must first solve why it was refused.
116
+ - **Category false positives in any DefiLlama diff.** `CEX` is exchange
117
+ proof-of-reserve wallets, not deployable protocols — it is the single biggest
118
+ fake opportunity in a category diff. `Chain` and `Bug Bounty` are bookkeeping
119
+ rows. Strike them explicitly.
120
+ - **Always compute top-2 concentration per category before calling it a market.**
121
+ A category can show large TVL and be one protocol's book; the real addressable
122
+ market is then ~1% of the headline.
123
+ - **Protocol count is a mirage.** Count the long tail's combined TVL. Thirty DEXes
124
+ where three hold 92% is one DEX plus twenty-seven forks.
125
+ - **Never call TVL "mercenary" without measuring it.** Distribution decides:
126
+ tens of thousands of holders with a four-figure median is retail and sticky;
127
+ ten addresses holding most of it is not. Check whether top holders are smart
128
+ accounts belonging to an app's wallet infrastructure — that is a distribution
129
+ asset, and often the most valuable thing on a young chain.
130
+ - **Markets can exist and never launch.** Filter for zero price / zero volume before
131
+ quoting a venue's market count. "43 markets" including seven that never opened and
132
+ sixteen doing under $25k/day is a different venue than the headline.
133
+ - **DefiLlama per-chain `overview/derivatives/<chain>` is paywalled** ("Upgrade to
134
+ the paid API plan") while `overview/dexs/` and `overview/fees/` are free. Use the
135
+ full URL-encoded chain name (`Robinhood%20Chain`), not a lowercase slug — a slug
136
+ returns the paywall string for every category and looks like a plan limit.
137
+ - **Do not loop a public data API inside one Python process** when sweeping many
138
+ symbols; you get uniform errors for every symbol and it reads like the API is
139
+ down. Fetch with `curl` into files with a small sleep, then parse the files in a
140
+ separate pass. This turned 20 failures into 20 successes.
141
+
142
+ ## Venue docs discovery
143
+
144
+ Modern docs sites (Mintlify and similar) publish a machine index and a markdown
145
+ twin of every page. This is the fastest path to a venue's real API and mechanism
146
+ docs:
147
+
148
+ ```
149
+ curl -sL https://docs.<venue>/llms.txt # full page index w/ descriptions
150
+ grep -iE "funding|oracle|margin|liquidat" llms.txt
151
+ curl -sL https://docs.<venue>/<path>.md # markdown twin of a page
152
+ ```
153
+
154
+ The bare HTML page URL may 404 while the `.md` twin returns 200. The `llms.txt`
155
+ index also reveals REST/WS hostnames and endpoint paths without reverse-engineering
156
+ JS bundles.
157
+
158
+ ## Reporting shape (DEMI)
159
+
160
+ - Lead with the verdict or the number. Tables over paragraphs.
161
+ - Give the de-duplicated view, not just the raw one — show what the chain
162
+ *actually* is once wrappers are collapsed.
163
+ - Name what is dead: zero-TVL protocols, never-launched markets, empty categories.
164
+ - Say plainly when your own earlier claim was overturned by new data, and why.
165
+ - End with the risk that would flip the answer.
166
+
167
+ ## References
168
+
169
+ - `references/defillama-chain-census.md` — endpoint map, Python filtering patterns,
170
+ double-count reconciliation worked example, category-diff false positives.
171
+ - `references/morpho-blue-graphql.md` — Morpho Blue API schema quirks that cost
172
+ ~8 failed round trips: `vaults` vs `vaultV2s`, field-name traps, pagination.
173
+ - `references/perp-venue-funding-regimes.md` — how to read a perp venue's funding
174
+ mechanism before trading it, incl. RWA off-hours rate locks and price bands, and
175
+ the worked falsification of a weekend-basis thesis.
176
+
177
+ ## Scripts
178
+
179
+ - `scripts/chain-census.py` — re-runnable census: chain totals, protocol list,
180
+ native/multichain split, category rollup, and sum-vs-headline reconciliation.
181
+ `python3 scripts/chain-census.py "Robinhood Chain"`
@@ -0,0 +1,162 @@
1
+ ---
2
+ name: chain-ecosystem-gap-analysis
3
+ description: Use when surveying a chain's protocols, gaps, or build PMF.
4
+ ---
5
+
6
+ > Oracle native tools: `oracle_cli` (read/prepare), `vault_status`, `signer_status`, `signer_execute` (needs human confirmationNonce), `skill_load`. No generic shell. No fleet SSH.
7
+
8
+
9
+ # Chain ecosystem and gap analysis
10
+
11
+ Use when the question is about a **chain's whole landscape** rather than one contract or
12
+ one trade: "what DeFi is on X", "what's the top TVL", "what's missing", "is there PMF for
13
+ building Y here". For single-contract verification use `evm-contract-research`; for
14
+ routing one trade use `oracle-desk`.
15
+
16
+ The deliverable is a **decision**, not a protocol catalog. Most of the work is separating
17
+ real capital from double-counted, rented, or fake-wide numbers, and then trying hard to
18
+ disprove whatever build thesis emerges.
19
+
20
+ ## Step 1 — Chain-level totals from live APIs
21
+
22
+ Pull these in parallel; each answers a different question.
23
+
24
+ | Source | Endpoint | Answers |
25
+ |---|---|---|
26
+ | DefiLlama chains | `api.llama.fi/v2/chains` | headline chain TVL |
27
+ | DefiLlama protocols | `api.llama.fi/protocols` (~8MB) | every protocol + `chainTvls` |
28
+ | DefiLlama DEX overview | `api.llama.fi/overview/dexs/<Chain>` | volume, per-DEX and daily series |
29
+ | DefiLlama fees | `api.llama.fi/overview/fees/<Chain>` | **real willingness to pay** |
30
+ | Stablecoins | `stablecoins.llama.fi/stablecoinchains` | idle capital sitting on chain |
31
+
32
+ Filter the 8MB protocol list **in Python**, never print it raw. Match chains by scanning
33
+ each protocol's `chainTvls` for a key starting with the chain name, excluding the
34
+ `-borrowed` / `-staking` / `-pool2` suffixed keys.
35
+
36
+ Use the **URL-encoded display name** (`Robinhood%20Chain`), not a slug. Slugs return
37
+ `Upgrade to the paid API plan`, which is a naming error, not a paywall — the
38
+ derivatives-by-chain breakdown genuinely is paywalled, so report perps as TVL-only.
39
+
40
+ **Fees are the strongest single signal.** TVL can be farmed and volume can be washed;
41
+ fees are money users chose to hand over. A five-week-old chain doing $1.5M/day in fees is
42
+ telling you something TVL cannot.
43
+
44
+ ## Step 2 — Correct the four ways TVL lies
45
+
46
+ Do this before quoting any number to the user.
47
+
48
+ 1. **Curator double-counting.** Sum-of-protocols will exceed chain TVL. On RH 4663 the
49
+ parts summed to $784M against a $422M chain. The gap was Steakhouse Financial
50
+ ($331M, "Risk Curators") sitting *on top of* Morpho Blue's $318M — the same deposits
51
+ counted twice. DefiLlama does **not** always set the `doublecounted` flag. Treat
52
+ `Risk Curators`, `Liquidity Manager`, and `Onchain Capital Allocator` as re-counts of
53
+ an underlying venue, and reconcile sum-of-parts against the headline explicitly.
54
+ 2. **Category counts that are one incumbent.** "30 DEXes" was Uniswap at 92.6% and 27
55
+ others splitting $5.3M. "19 launchpads" was one at 98%. Always report the top-2
56
+ concentration share next to any category total.
57
+ 3. **Single-chain ≠ native.** Split protocols by `len(chains) == 1`. On RH, 52 protocols
58
+ were single-chain but two perp venues held 92% of that TVL; every other "native"
59
+ project combined was ~$2.7M. This is the difference between a real builder scene and
60
+ a wall of forks.
61
+ 4. **Rented vs sticky capital.** Query the dominant protocol's own API for market-level
62
+ detail. Uniform high LLTV plus ~90% utilization across a few stablecoin collaterals is
63
+ a **leveraged carry loop**, not organic demand — capital that leaves when an external
64
+ yield compresses.
65
+
66
+ ## Step 3 — Separate the supply side from the borrow side
67
+
68
+ The single highest-value check, and the one that overturned a wrong conclusion this
69
+ session. Concentration on one side says nothing about the other.
70
+
71
+ On RH Morpho: **47,060 depositors**, median position $7,506, top-1 only 3.5%, and steakUSDG
72
+ holders (46,856) ≈ USDG holders (46,828) — meaning essentially everyone holding the
73
+ stablecoin had it in the vault. Every large holder was a `SemiModularAccount7702` contract,
74
+ i.e. an EIP-7702 smart account = **the app's own retail wallet**. Meanwhile the borrow side
75
+ was 542 positions with top-10 at 68.7% and two addresses holding $103M.
76
+
77
+ Read: **retail supplies, a handful of whales lever.** Retail deposits are sticky (they are
78
+ app users, not yield tourists); the leverage on top is not. Calling the whole stack
79
+ "mercenary capital" was wrong.
80
+
81
+ Method: pull vault positions with pagination (`positions(first:1000, skip:N)`), sort, and
82
+ report top-1 / top-5 / top-N shares plus median — then cross-check depositor count against
83
+ the underlying token's `holders_count` on the explorer. Identify what the top holders
84
+ *are* (`implementations[]` on the address record names the contract).
85
+
86
+ ## Step 4 — Diff categories against mature L2s
87
+
88
+ Aggregate category → (TVL, protocol count) for the target chain and for Base and Arbitrum,
89
+ then bucket: **absent entirely**, **present but dead (<$100k)**, **healthy**.
90
+
91
+ Two mandatory corrections:
92
+ - **Strip false positives.** `CEX` is exchange proof-of-reserve wallets, not deployable
93
+ protocols; it will top any naive diff at >$1B. `Chain` and `Bug Bounty` are bookkeeping
94
+ rows. Exclude them and say why.
95
+ - **Rank by concentration, not just size.** A category worth $100M where one protocol holds
96
+ 100% is a ~$0 addressable market. A smaller category at 40% top-2 concentration is
97
+ genuinely competitive and a better target.
98
+
99
+ "Present but dead" is often more informative than "absent" — it means someone tried and
100
+ capital declined.
101
+
102
+ ## Step 5 — Try to KILL the thesis before recommending it
103
+
104
+ This is the part that separates analysis from pitch. **Fetch the incumbent venue's actual
105
+ docs and API and attempt to disprove your own idea.**
106
+
107
+ A worked example from this session. Thesis: equity perps trade 24/7 while the underlying
108
+ trades 6.5h/day, so weekend funding should dislocate — build a basis vault.
109
+
110
+ - The venue's docs stated funding is **locked to a base rate (SOFR + 0.5%) when the
111
+ underlying is dark**, explicitly to remove weekend uncertainty.
112
+ - Confirmed live: 20 of 28 RWA perps pinned to the byte-identical hourly rate.
113
+ - Confirmed historically: 1,000 hourly points x 41.6 days showed dark-window mean funding
114
+ **below** lit-window on 2 of 3 names, with variance collapsing (stdev 0.85-5.28 dark vs
115
+ 7.87-18.20 lit).
116
+
117
+ The thesis was dead — the venue engineered the gap away by design. **Run a control**:
118
+ crypto perps over the identical window varied normally, proving the flatness was a real
119
+ regime and not an API artifact. A flat series with no control is indistinguishable from a
120
+ broken query.
121
+
122
+ Also check whether the "gap" is actually **built-and-rejected** rather than unbuilt. Equity
123
+ collateral markets existed on Morpho and held $2,789 total against $315M of stablecoin
124
+ collateral. That is not a hole to fill; it is a demonstrated capital-side refusal you would
125
+ have to overturn. Those are very different difficulty levels and the distinction must reach
126
+ the user.
127
+
128
+ **Salvage the insight, change the instrument.** When a thesis dies, ask what *is* still true.
129
+ Weekend volatility was real; only the funding channel was closed. That points at options
130
+ (sell the gamma) rather than basis (harvest the funding) — same underlying observation,
131
+ different product.
132
+
133
+ ## Step 6 — Report
134
+
135
+ - Lead with the corrected, de-duplicated picture, not the raw table.
136
+ - Show concentration next to every total.
137
+ - State confidence separately for **data** (high, from live APIs) and **judgment**
138
+ (usually moderate — a 5-week-old chain cannot distinguish "wave dying" from
139
+ "post-launch normalization").
140
+ - Name what would invalidate the read.
141
+ - When you were wrong earlier in the session, say so plainly and show the number that
142
+ overturned it. Do not quietly revise.
143
+
144
+ ## Pitfalls
145
+
146
+ - Trailing-volume trend matters more than the TVL snapshot. TVL at an all-time high while
147
+ volume is down 28% fortnight-over-fortnight is a stablecoin loop growing while users
148
+ leave, not adoption.
149
+ - Count only markets with real state. Filter out zero-price / never-launched markets before
150
+ computing venue totals, and mention them separately as a signal.
151
+ - A venue can be "an equities exchange" by market count and a crypto exchange by flow. RH's
152
+ Arcus had 34 of 43 markets in RWA but RWA was only 12.9% of volume.
153
+ - Aggregate liquidity across many pools hides that most are dust. 226 equity pools, 194
154
+ under $50k. Report the count above a meaningful threshold, not the sum.
155
+ - Verify subagent findings independently before folding them into a conclusion — and run a
156
+ control when a result looks suspiciously uniform.
157
+
158
+ ## References
159
+
160
+ - `references/rh-4663-worked-example.md` — the full Robinhood Chain 4663 pass: corrected
161
+ TVL table, category diff vs Base/Arbitrum, the Morpho depositor-vs-borrower split, the
162
+ killed basis thesis with its control, and the Arcus API endpoint map.
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: cross-chain-twap-execution
3
+ description: Use when TWAPing token buys or sells across chains.
4
+ created_by: agent
5
+ ---
6
+
7
+ > Oracle native tools: `oracle_cli` (read/prepare), `vault_status`, `signer_status`, `signer_execute` (needs human confirmationNonce), `skill_load`. No generic shell. No fleet SSH.
8
+
9
+
10
+ # Cross-chain TWAP execution
11
+
12
+ Use when DEMI asks to TWAP buy, TWAP sell, ladder in/out, or chunk an order across one or more chains.
13
+
14
+ ## Core rule
15
+
16
+ "TWAP anything across chains" means **any supported fungible asset with a live quoteable + executable route inside a bounded owner-approved order envelope**. It does **not** mean blind arbitrary-token authority or reusable scanner-wide trading permission.
17
+
18
+ ## Required order envelope
19
+
20
+ Before live execution, require the exact:
21
+
22
+ - side: `buy` / `sell`
23
+ - token(s): contract + chain, or a precise portfolio slice
24
+ - source wallet / signer lane
25
+ - total size: raw amount, notional, or % balance
26
+ - allowed source/destination chains
27
+ - duration and interval/chunk count
28
+ - max slippage cap and max price impact
29
+ - max gas / bridge fee budget
30
+ - min receive / limit-price guard
31
+ - deadline
32
+ - kill switch / cancel path
33
+
34
+ `paper` and `prepare` can run without live authority. Live chunks require DEMI confirmation of this exact envelope.
35
+
36
+ ## Per-chunk loop
37
+
38
+ Each chunk must repeat the full protection stack; do not reuse stale quote data from an earlier chunk.
39
+
40
+ 1. Resolve token + chain identity.
41
+ 2. Check balance, allowance, native gas, and venue support tier.
42
+ 3. Quote best route ranked **net of gas and fees**, not gross amount out.
43
+ 4. Split smaller or skip if price impact/liquidity is outside bounds.
44
+ 5. Re-quote immediately before prepare.
45
+ 6. Prepare exact artifact and simulate it when the path supports simulation.
46
+ 7. Execute only if quote age, min receive, slippage, gas, chain, destination, spender, and deadline still match the envelope.
47
+ 8. Record tx/order id, receipt status, balance delta, chunk price, cumulative average price, and remaining notional.
48
+ 9. Stop or pause on drift, failed simulation, missing allowance, missing gas, provider failure, bridge ambiguity, or DEMI cancel.
49
+
50
+ ## Cross-chain chunking
51
+
52
+ - If funds must bridge before a swap, prove **every leg** quotes executable before firing leg 1.
53
+ - Bridge destination native gas when the destination leg needs gas; token-only bridges can leave the executor unable to continue.
54
+ - Track pending bridge state. Origin confirmation is not destination arrival.
55
+ - Never double-send a pending bridge leg because the next chunk timer fired.
56
+ - Multi-hop is allowed only when every hop has fresh quote/prepare support and a bounded failure plan.
57
+
58
+ ## Sell path
59
+
60
+ Selling is stricter than buying because unsupported exits strand risk.
61
+
62
+ - Run sellability / sell-sim first for illiquid, honeypot-prone, custom-router, or custom-pool tokens.
63
+ - Unsupported exits are `blocked`, not guessed or routed through an unverified contract.
64
+ - Custom pools may need a separate raw-pair or venue-native adapter; do not pretend a generic aggregator failure is a working sell route.
65
+
66
+ ## Asset boundaries
67
+
68
+ This skill covers fungible token swaps/bridges. Do not reuse the same engine unchanged for:
69
+
70
+ - NFTs / marketplace laddering
71
+ - Bitcoin UTXOs, inscriptions, runes, rare sats
72
+ - Solana/Jupiter transactions
73
+ - Hyperliquid orders
74
+
75
+ Those lanes can share the chunking concept but need their own signer, settlement, receipt, and asset-safety rules.
76
+
77
+ ## Reporting
78
+
79
+ For every run or prepared schedule, report:
80
+
81
+ - mode: `paper`, `prepare`, or `live`
82
+ - envelope summary
83
+ - chunks completed / pending / skipped / failed
84
+ - realized average price and cumulative balance delta
85
+ - hashes / order ids for completed chunks
86
+ - current blocker or next scheduled chunk
87
+ - confidence: high / moderate / low / unknown
88
+
89
+ ## Pitfalls
90
+
91
+ - Treating a broad phrase like "anything" as reusable authority. It is a routing universe, not a signing grant.
92
+ - Computing a TWAP schedule once and reusing stale quotes for every chunk.
93
+ - Firing bridge leg 1 before proving leg 2 is executable.
94
+ - Forgetting destination native gas after a token bridge.
95
+ - Letting a timer continue after a failed chunk without checking why it failed.
96
+ - Reporting a prepared chunk as executed. Prepared != signed != broadcast != filled.
97
+ - Applying EVM fungible assumptions to NFTs, BTC inscriptions/runes, Solana, or venue orderbooks.
98
+
99
+ ## Related skills
100
+
101
+ - `oracle-best-execution` — route ranking net of gas and fees. **Same-chain over-time swaps use Li.Fi directly** (`https://li.quest/v1/quote`, keyless, returns `transactionRequest` with calldata), not the public server's risk pipeline (which requires on-chain data probes — sellability/approval/liquidity — unsuitable for aggregator quotes). Cross-chain still uses `/public/convert`.
102
+ - `multichain-exec-desk` — Oracle desk execution surfaces and provider guardrails.
103
+ - `trade-loop-circuit-breaker` — live-money loop halts, caps, and deploy discipline.
104
+ - `oracle-action-semantics` — watch / prepare / arm / sign / send vocabulary.
105
+
106
+ ## Oracle App over-time (primary surface)
107
+
108
+ The live implementation ships in `~/projects/oracle-app/` with a full engine, durable store, background worker, and API routes. See `references/oracle-app-over-time.md` for architecture, endpoints, env vars, and desk API contract.
109
+
110
+ Quick dev loop:
111
+ ```bash
112
+ # Terminal 1: desk server (required for live quotes)
113
+ cd ~/projects/multiagent-desk && node bin/oracle-public-server.mjs
114
+
115
+ # Terminal 2: Oracle app dev server
116
+ cd ~/projects/oracle-app && ORACLE_DESK_URL=http://127.0.0.1:8799 npm run dev
117
+
118
+ # Test paper mode end-to-end:
119
+ curl -X POST http://localhost:3000/api/oracle/over-time \
120
+ -H 'Content-Type: application/json' \
121
+ -d '{"side":"buy","mode":"paper","ownerAddress":"0x1111111111111111111111111111111111111111","chainId":"base","sellSymbol":"USDC","buySymbol":"ETH","totalAmount":"100","durationMs":120000,"chunkCount":4}'
122
+
123
+ # Check activity + receipts:
124
+ curl http://localhost:3000/api/oracle/over-time/activity?owner=0x1111111111111111111111111111111111111111
125
+ ```