@kaleidorg/mind 0.5.1 → 0.6.1
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.
- package/dist/autonomy/index.d.ts +21 -0
- package/dist/autonomy/index.d.ts.map +1 -0
- package/dist/autonomy/index.js +16 -0
- package/dist/autonomy/index.js.map +1 -0
- package/dist/autonomy/prompt.d.ts +21 -0
- package/dist/autonomy/prompt.d.ts.map +1 -0
- package/dist/autonomy/prompt.js +37 -0
- package/dist/autonomy/prompt.js.map +1 -0
- package/dist/autonomy/risk.d.ts +53 -0
- package/dist/autonomy/risk.d.ts.map +1 -0
- package/dist/autonomy/risk.js +74 -0
- package/dist/autonomy/risk.js.map +1 -0
- package/dist/autonomy/run-state.d.ts +39 -0
- package/dist/autonomy/run-state.d.ts.map +1 -0
- package/dist/autonomy/run-state.js +118 -0
- package/dist/autonomy/run-state.js.map +1 -0
- package/dist/autonomy/scheduler.d.ts +18 -0
- package/dist/autonomy/scheduler.d.ts.map +1 -0
- package/dist/autonomy/scheduler.js +113 -0
- package/dist/autonomy/scheduler.js.map +1 -0
- package/dist/autonomy/task-store.d.ts +44 -0
- package/dist/autonomy/task-store.d.ts.map +1 -0
- package/dist/autonomy/task-store.js +139 -0
- package/dist/autonomy/task-store.js.map +1 -0
- package/dist/autonomy/types.d.ts +164 -0
- package/dist/autonomy/types.d.ts.map +1 -0
- package/dist/autonomy/types.js +20 -0
- package/dist/autonomy/types.js.map +1 -0
- package/dist/bitrefill/contract.d.ts +60 -0
- package/dist/bitrefill/contract.d.ts.map +1 -0
- package/dist/bitrefill/contract.js +119 -0
- package/dist/bitrefill/contract.js.map +1 -0
- package/dist/context/compress.d.ts +65 -0
- package/dist/context/compress.d.ts.map +1 -0
- package/dist/context/compress.js +181 -0
- package/dist/context/compress.js.map +1 -0
- package/dist/engine.d.ts +20 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +23 -4
- package/dist/engine.js.map +1 -1
- package/dist/evidence.d.ts +62 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +47 -0
- package/dist/evidence.js.map +1 -0
- package/dist/flashnet/contract.d.ts +56 -0
- package/dist/flashnet/contract.d.ts.map +1 -0
- package/dist/flashnet/contract.js +100 -0
- package/dist/flashnet/contract.js.map +1 -0
- package/dist/funnel.d.ts +11 -0
- package/dist/funnel.d.ts.map +1 -1
- package/dist/funnel.js +62 -7
- package/dist/funnel.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/kaleidoswap/contract.js +1 -1
- package/dist/kaleidoswap/contract.js.map +1 -1
- package/dist/knowledge/bitcoin-copilot.d.ts.map +1 -1
- package/dist/knowledge/bitcoin-copilot.js +85 -2
- package/dist/knowledge/bitcoin-copilot.js.map +1 -1
- package/dist/providers/types.d.ts +17 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/qvac/index.d.ts +1 -1
- package/dist/qvac/index.d.ts.map +1 -1
- package/dist/qvac/index.js.map +1 -1
- package/dist/qvac/parse.d.ts +18 -0
- package/dist/qvac/parse.d.ts.map +1 -1
- package/dist/qvac/parse.js +1 -0
- package/dist/qvac/parse.js.map +1 -1
- package/dist/qvac/provider.d.ts +16 -0
- package/dist/qvac/provider.d.ts.map +1 -1
- package/dist/qvac/provider.js +40 -1
- package/dist/qvac/provider.js.map +1 -1
- package/dist/qvac/stream.d.ts +22 -0
- package/dist/qvac/stream.d.ts.map +1 -1
- package/dist/qvac/stream.js +33 -1
- package/dist/qvac/stream.js.map +1 -1
- package/dist/recipe/buy-asset-channel.d.ts +1 -1
- package/dist/recipe/buy-asset-channel.d.ts.map +1 -1
- package/dist/recipe/buy-asset-channel.js +4 -3
- package/dist/recipe/buy-asset-channel.js.map +1 -1
- package/dist/recipe/flashnet-swap.d.ts +35 -0
- package/dist/recipe/flashnet-swap.d.ts.map +1 -0
- package/dist/recipe/flashnet-swap.js +239 -0
- package/dist/recipe/flashnet-swap.js.map +1 -0
- package/dist/recipe/kaleidoswap-atomic.d.ts +1 -1
- package/dist/recipe/kaleidoswap-atomic.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-atomic.js +42 -20
- package/dist/recipe/kaleidoswap-atomic.js.map +1 -1
- package/dist/recipe/kaleidoswap-channel-order.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-channel-order.js +31 -10
- package/dist/recipe/kaleidoswap-channel-order.js.map +1 -1
- package/dist/recipe/kaleidoswap-price.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-price.js +7 -1
- package/dist/recipe/kaleidoswap-price.js.map +1 -1
- package/dist/recipe/runner.d.ts.map +1 -1
- package/dist/recipe/runner.js +43 -3
- package/dist/recipe/runner.js.map +1 -1
- package/dist/recipe/swap.d.ts.map +1 -1
- package/dist/recipe/swap.js +14 -1
- package/dist/recipe/swap.js.map +1 -1
- package/dist/tools/mcp.d.ts +19 -0
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mcp.js +51 -9
- package/dist/tools/mcp.js.map +1 -1
- package/dist/wallet/confirm.d.ts.map +1 -1
- package/dist/wallet/confirm.js +1 -0
- package/dist/wallet/confirm.js.map +1 -1
- package/dist/wallet/contract.d.ts.map +1 -1
- package/dist/wallet/contract.js +20 -4
- package/dist/wallet/contract.js.map +1 -1
- package/package.json +5 -4
- package/skills/bitrefill/SKILL.md +152 -52
- package/skills/channel-manager/SKILL.md +59 -0
- package/skills/dca/SKILL.md +48 -0
- package/skills/flashnet-swaps/SKILL.md +158 -0
- package/skills/kaleido-lsps/SKILL.md +34 -17
- package/skills/kaleido-trading/SKILL.md +37 -13
- package/skills/liquidity-optimizer/SKILL.md +91 -0
- package/skills/merchant-finder/SKILL.md +2 -2
- package/skills/portfolio-manager/SKILL.md +67 -0
- package/skills/rgb-lightning-node/SKILL.md +38 -11
- package/skills/spark-wallet/SKILL.md +235 -0
- package/skills/wallet-assistant/SKILL.md +2 -2
- package/src/autonomy/autonomy.test.ts +348 -0
- package/src/autonomy/index.ts +50 -0
- package/src/autonomy/prompt.ts +48 -0
- package/src/autonomy/risk.ts +139 -0
- package/src/autonomy/run-state.ts +144 -0
- package/src/autonomy/scheduler.ts +120 -0
- package/src/autonomy/task-store.ts +167 -0
- package/src/autonomy/types.ts +186 -0
- package/src/bitrefill/contract.test.ts +89 -0
- package/src/bitrefill/contract.ts +190 -0
- package/src/context/compress.test.ts +120 -0
- package/src/context/compress.ts +230 -0
- package/src/engine.test.ts +34 -0
- package/src/engine.ts +35 -4
- package/src/evidence.test.ts +80 -0
- package/src/evidence.ts +114 -0
- package/src/flashnet/contract.test.ts +101 -0
- package/src/flashnet/contract.ts +164 -0
- package/src/funnel.mind.test.ts +390 -0
- package/src/funnel.ts +73 -8
- package/src/index.ts +92 -1
- package/src/kaleidoswap/contract.ts +1 -1
- package/src/knowledge/bitcoin-copilot.ts +96 -2
- package/src/providers/types.ts +18 -0
- package/src/qvac/index.ts +1 -0
- package/src/qvac/parse.ts +20 -0
- package/src/qvac/provider.test.ts +17 -0
- package/src/qvac/provider.ts +62 -2
- package/src/qvac/stream.test.ts +36 -0
- package/src/qvac/stream.ts +54 -1
- package/src/recipe/buy-asset-channel.test.ts +5 -0
- package/src/recipe/buy-asset-channel.ts +6 -3
- package/src/recipe/flashnet-swap.test.ts +114 -0
- package/src/recipe/flashnet-swap.ts +266 -0
- package/src/recipe/kaleidoswap-atomic.test.ts +24 -3
- package/src/recipe/kaleidoswap-atomic.ts +39 -20
- package/src/recipe/kaleidoswap-channel-order.test.ts +38 -0
- package/src/recipe/kaleidoswap-channel-order.ts +27 -9
- package/src/recipe/kaleidoswap-price.ts +7 -1
- package/src/recipe/recipe.test.ts +21 -0
- package/src/recipe/runner.ts +46 -3
- package/src/recipe/swap.ts +16 -1
- package/src/tools/mcp.live.test.ts +116 -0
- package/src/tools/mcp.parse.test.ts +37 -0
- package/src/tools/mcp.ts +55 -9
- package/src/wallet/confirm.test.ts +8 -0
- package/src/wallet/confirm.ts +1 -0
- package/src/wallet/contract.test.ts +10 -0
- package/src/wallet/contract.ts +26 -4
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flashnet-swaps
|
|
3
|
+
description: "Swap between BTC and Spark tokens (e.g. USDB) using Flashnet — a Spark-native AMM. Run by quoting `flashnet_simulate_swap` first, then `flashnet_execute_swap` on confirmation. Pairs with the spark-wallet skill: the same Spark wallet that holds your BTC is what signs the swap. Triggers on swap/exchange/convert/trade phrasings involving BTC + a Spark token, or explicit mention of Flashnet."
|
|
4
|
+
tools: flashnet_list_pools, flashnet_get_pool, flashnet_simulate_swap, flashnet_execute_swap, flashnet_get_balance, spark_get_balance, spark_get_address, get_price, fiat_to_sats
|
|
5
|
+
triggers: flashnet, swap, exchange, convert, trade, usdb, amm, pool, liquidity, btc to usdb, usdb to btc, spark swap
|
|
6
|
+
metadata:
|
|
7
|
+
author: kaleidoswap
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
venue: flashnet
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Flashnet swaps
|
|
13
|
+
|
|
14
|
+
Flashnet is a Spark-native AMM. The user's Spark wallet IS the swap account —
|
|
15
|
+
there's no separate exchange balance. A swap takes one asset from the wallet,
|
|
16
|
+
sends it through a pool, and returns the other asset to the same wallet, in
|
|
17
|
+
seconds. Two pool curve types exist (constant-product and V3 concentrated
|
|
18
|
+
liquidity) — the model doesn't need to care; the pool id is enough.
|
|
19
|
+
|
|
20
|
+
## What Flashnet trades (and what it does NOT)
|
|
21
|
+
|
|
22
|
+
**Flashnet trades:**
|
|
23
|
+
- **BTC** ↔ **Spark-native tokens**. The canonical example is **USDB**.
|
|
24
|
+
- Whatever pools `flashnet_list_pools` returns — that list is the
|
|
25
|
+
authoritative answer to "what can I trade here?".
|
|
26
|
+
|
|
27
|
+
**Flashnet does NOT trade:**
|
|
28
|
+
- **RGB assets** (USDT, XAUT, …). RGB assets live on the RLN layer and
|
|
29
|
+
trade via the **KaleidoSwap maker** (`kaleido-trading` skill), not here.
|
|
30
|
+
USDT on Flashnet does not exist — never offer it.
|
|
31
|
+
- Assets the user holds on Arkade, on-chain BTC reserves, or any external
|
|
32
|
+
chain. The trade-account is the Spark wallet.
|
|
33
|
+
|
|
34
|
+
If the user asks for an asset you can't see in `flashnet_list_pools`, tell
|
|
35
|
+
them so plainly and (if it's a known RGB asset like USDT/XAUT) point them
|
|
36
|
+
at the kaleido-trading skill rather than inventing a Flashnet pool.
|
|
37
|
+
|
|
38
|
+
## Critical rules (read first)
|
|
39
|
+
|
|
40
|
+
1. **Never invent a pool id, asset address, or amount.** Every `pool_id`,
|
|
41
|
+
`asset_in_address`, `asset_out_address`, `amount_in` you pass MUST come
|
|
42
|
+
from `flashnet_list_pools` / `flashnet_simulate_swap` / a tool-returned
|
|
43
|
+
value in the CURRENT turn — never from history, never guessed.
|
|
44
|
+
**ALWAYS start a swap by calling `flashnet_list_pools`** to get the real
|
|
45
|
+
pool id + asset addresses. You may pass `BTC` as a literal asset (the
|
|
46
|
+
host resolves it), but for any TOKEN you must use the exact
|
|
47
|
+
`asset_a_address` / `asset_b_address` the pool returned. Token tickers
|
|
48
|
+
(e.g. `USDB`) only resolve if the network publishes them or the host is
|
|
49
|
+
configured; if a ticker doesn't resolve, the result rows carry the
|
|
50
|
+
addresses — use those. Each pool row includes `asset_a_symbol` /
|
|
51
|
+
`asset_b_symbol` when known (e.g. `"BTC"`); pick the pool whose pair
|
|
52
|
+
matches the user's intent and read its addresses from that row.
|
|
53
|
+
2. **Always simulate before executing.** Call `flashnet_simulate_swap` to
|
|
54
|
+
get `amount_out` + `price_impact_pct`, show the user the rate in plain
|
|
55
|
+
English, get explicit confirmation, then call `flashnet_execute_swap`.
|
|
56
|
+
The host fires one extra confirmation gate on execute — that's the
|
|
57
|
+
safety net, not the primary one.
|
|
58
|
+
3. **Compute `min_amount_out` yourself.** Never pass the simulated
|
|
59
|
+
`amount_out` directly to execute. The standard formula is
|
|
60
|
+
`min_amount_out = floor(amount_out × (1 − max_slippage_bps / 10000))`.
|
|
61
|
+
Default `max_slippage_bps: 50` (0.5%). Use 100 for volatile pairs or
|
|
62
|
+
high price impact (>0.5%); ask the user before going higher than 1%.
|
|
63
|
+
4. **Smallest units, as strings.** `amount_in` / `min_amount_out` are in
|
|
64
|
+
the asset's smallest unit (sats for BTC; the token's smallest decimal
|
|
65
|
+
place for tokens). Pass them as JSON strings so BigInt-sized values
|
|
66
|
+
survive round-trip. e.g. `amount_in: "100000"` for 100k sats, NOT
|
|
67
|
+
`amount_in: 100000`.
|
|
68
|
+
5. **High price impact = stop and ask.** If
|
|
69
|
+
`simulate_swap.price_impact_pct > 1.0`, surface it explicitly:
|
|
70
|
+
"This trade would move the price by 1.7%. Continue?" Don't auto-execute
|
|
71
|
+
anything with >2% impact without a clear user yes.
|
|
72
|
+
6. **Get the direction right — `asset_in` is what the user SPENDS,
|
|
73
|
+
`asset_out` is what they GET.** Parse the request literally:
|
|
74
|
+
- "spend 2000 sats to get USDB" → asset_in = BTC, asset_out = USDB,
|
|
75
|
+
amount_in = 2000 (the sats spent).
|
|
76
|
+
- "swap 10 USDB to BTC" / "sell 10 USDB for sats" → asset_in = USDB,
|
|
77
|
+
asset_out = BTC, amount_in = the USDB amount.
|
|
78
|
+
- "buy USDB with 2000 sats" → asset_in = BTC, asset_out = USDB.
|
|
79
|
+
`amount_in` is ALWAYS denominated in `asset_in`. Double-check before
|
|
80
|
+
simulating: if the user said "spend N sats", asset_in MUST be BTC and
|
|
81
|
+
amount_in MUST be N.
|
|
82
|
+
|
|
83
|
+
## Happy-path playbook
|
|
84
|
+
|
|
85
|
+
For a typical "swap 100k sats to USDB":
|
|
86
|
+
|
|
87
|
+
1. **`flashnet_list_pools({ asset_a: <BTC>, asset_b: <USDB> })`** — find a
|
|
88
|
+
pool. Pick the first result (already sorted by TVL desc). Save its
|
|
89
|
+
`pool_id`, `asset_a_address`, `asset_b_address`.
|
|
90
|
+
|
|
91
|
+
- If the user named a specific asset by *symbol* (e.g. "USDB"), the host
|
|
92
|
+
fills in the token address based on the active Spark network. The
|
|
93
|
+
model just passes the symbol or whatever address the prior tool
|
|
94
|
+
returned.
|
|
95
|
+
|
|
96
|
+
2. **`flashnet_simulate_swap({ pool_id, asset_in_address, asset_out_address, amount_in })`**
|
|
97
|
+
— get `amount_out`, `execution_price`, `price_impact_pct`,
|
|
98
|
+
`fee_paid_asset_in`. Show the user one short line:
|
|
99
|
+
|
|
100
|
+
`Swap 100,000 sats → ~497,500 USDB (0.5% pool fee, 0.18% price impact).
|
|
101
|
+
Proceed?`
|
|
102
|
+
|
|
103
|
+
3. **Compute `min_amount_out`** from the simulated `amount_out` and the
|
|
104
|
+
chosen slippage tolerance (default 0.5% / 50 bps). Don't trust the
|
|
105
|
+
simulated value as-is.
|
|
106
|
+
|
|
107
|
+
4. **`flashnet_execute_swap({ pool_id, asset_in_address, asset_out_address,
|
|
108
|
+
amount_in, min_amount_out, max_slippage_bps })`** — SPEND, gated. On
|
|
109
|
+
success returns the swap `request_id` and the actual `amount_out`.
|
|
110
|
+
Surface the realised amount on a single line.
|
|
111
|
+
|
|
112
|
+
## When to use which tool
|
|
113
|
+
|
|
114
|
+
| Tool | Use when |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `flashnet_list_pools` | First step of any swap; or when the user asks "what pools exist for X/Y". |
|
|
117
|
+
| `flashnet_get_pool` | User wants pool depth / current price / TVL before swapping. |
|
|
118
|
+
| `flashnet_simulate_swap` | EVERY swap, before execute. Also for "what would I get if I swapped 5k sats?" — read-only quote. |
|
|
119
|
+
| `flashnet_execute_swap` | After user confirms the simulated quote. Confirmation-gated. |
|
|
120
|
+
| `flashnet_get_balance` | Pre-swap balance check, or "what do I have on Spark/Flashnet". (Reads from the same wallet `spark_get_balance` reads — they are not separate accounts.) |
|
|
121
|
+
|
|
122
|
+
## Cross-skill flow with spark-wallet
|
|
123
|
+
|
|
124
|
+
The Spark wallet and Flashnet share the same on-device account. Common
|
|
125
|
+
chains:
|
|
126
|
+
|
|
127
|
+
- **Pre-swap balance check.** `spark_get_balance` (or
|
|
128
|
+
`flashnet_get_balance`) → confirm the user has enough sats → quote →
|
|
129
|
+
execute.
|
|
130
|
+
- **Deposit then swap.** User has on-chain BTC → `spark_get_address` to
|
|
131
|
+
receive into Spark → wait for confirmation (the user does that
|
|
132
|
+
externally) → swap.
|
|
133
|
+
- **Swap then pay invoice.** User has USDB but needs to pay a BOLT11
|
|
134
|
+
invoice → swap USDB → BTC (this skill) → `spark_pay_invoice` (the
|
|
135
|
+
spark-wallet skill) → done.
|
|
136
|
+
|
|
137
|
+
## Failure handling
|
|
138
|
+
|
|
139
|
+
Tool errors arrive as `Error.message`. Common ones:
|
|
140
|
+
|
|
141
|
+
- **`Insufficient balance`** — the wallet doesn't hold enough
|
|
142
|
+
`asset_in`. Surface the deficit. Suggest depositing or swapping less.
|
|
143
|
+
- **`Slippage exceeded` / `min_amount_out not met`** — the pool moved
|
|
144
|
+
between simulate and execute. Re-simulate and try again (the host can
|
|
145
|
+
do this; don't loop more than 2× automatically — ask the user after
|
|
146
|
+
that).
|
|
147
|
+
- **`Pool not found` / `Asset not allowed`** — pool id stale or wrong
|
|
148
|
+
network. Re-list pools.
|
|
149
|
+
- **Authentication / connection errors** — the Spark wallet isn't
|
|
150
|
+
initialized. Say so plainly; don't fake a result.
|
|
151
|
+
|
|
152
|
+
## Reply style
|
|
153
|
+
|
|
154
|
+
- Quote line: amount in, amount out, fee, price impact — all on one line.
|
|
155
|
+
- After execute: one-line result with realised amount and tx id.
|
|
156
|
+
- Never paste a multi-line JSON of the simulate/execute response.
|
|
157
|
+
- Don't echo `amount_in` / `min_amount_out` raw numbers in subsequent
|
|
158
|
+
turns; the model isn't a ledger.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kaleido-lsps
|
|
3
3
|
description: "Buy inbound Lightning channel capacity from a Lightning Service Provider (LSPS1). Quote a channel, estimate fees, place a channel order, and check order status. Triggers when the user wants inbound liquidity, says they can't receive a payment, needs a channel, asks about LSP fees, or wants to check the status of a channel order / LSP order."
|
|
4
|
-
tools: lsp_get_info, lsp_get_network_info, lsp_estimate_fees, lsp_create_order, lsp_get_order, rln_get_node_info, rln_pay_invoice
|
|
5
|
-
triggers: inbound, liquidity, channel order, lsp, lsps1, receive limit, can't receive, open channel, channel from, check status, order status, check the order, channel status, lsp status, check my channel
|
|
4
|
+
tools: lsp_get_info, lsp_get_network_info, lsp_estimate_fees, lsp_create_order, lsp_get_order, kaleidoswap_lsp_get_info, kaleidoswap_lsp_estimate_fees, kaleidoswap_lsp_create_order, kaleidoswap_lsp_get_order, kaleidoswap_lsp_quote_asset_channel, kaleidoswap_lsp_create_asset_channel, rln_get_node_info, rln_list_channels, rln_pay_invoice
|
|
5
|
+
triggers: inbound, liquidity, channel order, lsp, lsps1, receive limit, can't receive, open channel, channel from, check status, order status, check the order, channel status, lsp status, check my channel, check lsp order, did the channel open, lsp order status, list my channels, my channels, channel capacity
|
|
6
6
|
metadata:
|
|
7
7
|
author: kaleidoswap
|
|
8
8
|
version: "0.2.0"
|
|
@@ -21,11 +21,11 @@ talks to — the KaleidoSwap maker by default. Tool names are LSP-agnostic
|
|
|
21
21
|
You have **no knowledge** of LSP capabilities, fees, channel sizes, or order
|
|
22
22
|
status. Every number, capacity, fee, order id, or invoice in your reply MUST
|
|
23
23
|
come from a tool result returned in the CURRENT turn. Never quote a fee from
|
|
24
|
-
memory. Never claim an order completed without calling `
|
|
24
|
+
memory. Never claim an order completed without calling `kaleidoswap_lsp_get_order`.
|
|
25
25
|
Never reuse a number from a previous turn.
|
|
26
26
|
|
|
27
27
|
**Calling the tool IS the answer.** Don't write "the LSP info is fetched with
|
|
28
|
-
`
|
|
28
|
+
`kaleidoswap_lsp_get_info`" — call it. Don't reveal tool names in your reply; describe
|
|
29
29
|
what you're doing in plain language.
|
|
30
30
|
|
|
31
31
|
If a tool needs a required argument the user didn't give (e.g. `client_pubkey`
|
|
@@ -40,7 +40,7 @@ The same conventions as trading apply:
|
|
|
40
40
|
|
|
41
41
|
## Tools and the flow
|
|
42
42
|
|
|
43
|
-
### Step 1 — `
|
|
43
|
+
### Step 1 — `kaleidoswap_lsp_get_info`
|
|
44
44
|
No args. Returns the LSP's `OrderOptions` (min/max channel size, min/max
|
|
45
45
|
expiry, etc.) and the `assets` list. **Call it once before estimating** so you
|
|
46
46
|
can validate the user's request against the LSP's limits.
|
|
@@ -49,7 +49,7 @@ If the user wants 1M sats inbound but `max_initial_lsp_balance_sat` is 500k,
|
|
|
49
49
|
say so plainly and offer the maximum — don't push through and let the maker
|
|
50
50
|
reject it.
|
|
51
51
|
|
|
52
|
-
### Step 2 — `
|
|
52
|
+
### Step 2 — `kaleidoswap_lsp_estimate_fees` (read-only)
|
|
53
53
|
Required args: `lsp_balance_sat`, `client_balance_sat`, `channel_expiry_blocks`.
|
|
54
54
|
|
|
55
55
|
Defaults you can use silently if the user didn't specify:
|
|
@@ -60,10 +60,10 @@ Returns `{setup_fee, capacity_fee, duration_fee, total_fee}` — surface
|
|
|
60
60
|
`total_fee` to the user and the breakdown when relevant.
|
|
61
61
|
|
|
62
62
|
### Step 3 — `rln_get_node_info`
|
|
63
|
-
No args. Returns `{pubkey, ...}`. **Pubkey is required by `
|
|
63
|
+
No args. Returns `{pubkey, ...}`. **Pubkey is required by `kaleidoswap_lsp_create_order` —
|
|
64
64
|
fetch it deterministically. Never invent a pubkey.**
|
|
65
65
|
|
|
66
|
-
### Step 4 — `
|
|
66
|
+
### Step 4 — `kaleidoswap_lsp_create_order` 🔒 spend
|
|
67
67
|
Required args: `client_pubkey` (from step 3), `lsp_balance_sat`. The maker
|
|
68
68
|
also expects `client_balance_sat`, `required_channel_confirmations`,
|
|
69
69
|
`funding_confirms_within_blocks`, `channel_expiry_blocks`, `announce_channel`
|
|
@@ -72,7 +72,7 @@ didn't specify, so just pass the values the user actually named.
|
|
|
72
72
|
|
|
73
73
|
Returns:
|
|
74
74
|
- `order_id`
|
|
75
|
-
- `access_token` (save it — required for `
|
|
75
|
+
- `access_token` (save it — required for `kaleidoswap_lsp_get_order`)
|
|
76
76
|
- `payment.bolt11.invoice` — Lightning invoice to pay
|
|
77
77
|
- `payment.bolt11.order_total_sat` — the sats that need to flow
|
|
78
78
|
- `payment.onchain.address` — optional on-chain fallback
|
|
@@ -82,11 +82,26 @@ Returns:
|
|
|
82
82
|
Hand the `payment.bolt11.invoice` to `rln_pay_invoice`. This is a separate
|
|
83
83
|
spend gate at the wallet contract; the user confirms paying the LSP.
|
|
84
84
|
|
|
85
|
-
###
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
### Verify the opened channel — `rln_list_channels`
|
|
86
|
+
After an order completes (or when the user asks "do I have a channel with X
|
|
87
|
+
inbound?", "list my channels", "did my channel open?"), call
|
|
88
|
+
`rln_list_channels`. It returns each channel's `capacity_sat`, `inbound_sat`,
|
|
89
|
+
`outbound_sat`, `ready`/`status`, and RGB `asset_*` amounts. Match the
|
|
90
|
+
requested capacity against an actual channel to confirm it opened correctly.
|
|
91
|
+
A freshly-bought channel opens ASYNCHRONOUSLY — if it isn't listed yet, say
|
|
92
|
+
it's still opening, don't claim failure. Do NOT use `rln_get_node_info` for
|
|
93
|
+
this (it only has counts + aggregate balance, not per-channel capacity).
|
|
94
|
+
|
|
95
|
+
### Step 6 — poll the order (`lsp_get_order` / `kaleidoswap_lsp_get_order`)
|
|
96
|
+
Use `lsp_get_order` on CLI hosts, `kaleidoswap_lsp_get_order` on desktop —
|
|
97
|
+
whichever your host exposes. **Args: `order_id`, `access_token` (BOTH
|
|
98
|
+
required — never omit either).** `order_state` progresses
|
|
99
|
+
`CREATED → CHANNEL_OPENING → COMPLETED` (or `FAILED`). Poll until terminal.
|
|
100
|
+
Always pass the exact order_id and access_token from the previous
|
|
101
|
+
create-order result **or from the most recent assistant message/summary**
|
|
102
|
+
(the one that said something like "order_id=xxx access_token=yyy" or "To
|
|
103
|
+
check status use: lsp_get_order(order_id=..., access_token=...)"). If
|
|
104
|
+
memory/remember is available, first recall the last LSPS1 order details.
|
|
90
105
|
Report the outcome plainly with the new channel id from `channel.channel_id` if present.
|
|
91
106
|
|
|
92
107
|
## Don'ts
|
|
@@ -97,11 +112,13 @@ Report the outcome plainly with the new channel id from `channel.channel_id` if
|
|
|
97
112
|
- Don't describe how a tool works — call it.
|
|
98
113
|
- Don't pay a Lightning invoice without confirming the amount + LSP — the
|
|
99
114
|
spend gate at `rln_pay_invoice` shows the user the destination.
|
|
100
|
-
- Don't claim an order completed without polling `
|
|
115
|
+
- Don't claim an order completed without polling `kaleidoswap_lsp_get_order` with BOTH
|
|
101
116
|
`order_id` and `access_token` and seeing `order_state: COMPLETED`.
|
|
102
|
-
- Never call `
|
|
117
|
+
- Never call `kaleidoswap_lsp_get_order` with only the access_token or only the order_id.
|
|
103
118
|
Always extract the exact values from the previous turn's summary (the one that
|
|
104
|
-
said "order_id=... access_token=..."
|
|
119
|
+
said "order_id=... access_token=..." or the explicit "To check status use..." line)
|
|
120
|
+
and pass them as separate arguments. If using the `remember` tool, first recall
|
|
121
|
+
the last channel/LSPS1 order details.
|
|
105
122
|
- Don't ask the user for their node pubkey — fetch it from `rln_get_node_info`.
|
|
106
123
|
|
|
107
124
|
## When the deterministic recipe handles it
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kaleido-trading
|
|
3
|
-
description: "Trade on KaleidoSwap — quote and execute swaps between BTC and RGB assets (USDT, XAUT). Get assets and pairs, pull an executable quote, place a market order, or
|
|
4
|
-
tools: kaleidoswap_get_assets, kaleidoswap_get_pairs, kaleidoswap_get_quote,
|
|
5
|
-
triggers: quote, swap, trade, rebalance, slippage, pair, pairs, usdt, xaut, kaleidoswap, rfq
|
|
3
|
+
description: "Trade on KaleidoSwap — quote and execute swaps between BTC and RGB assets (USDT, XAUT). Get assets and pairs, pull an executable quote, place a market order, track orders, or run/poll an atomic swap end-to-end. Triggers when the user wants a quote, to swap or trade assets, to rebalance between BTC and stablecoins, or to check the status of an order / swap / atomic swap."
|
|
4
|
+
tools: kaleidoswap_get_assets, kaleidoswap_get_pairs, kaleidoswap_get_quote, kaleidoswap_place_order, kaleidoswap_get_order_status, kaleidoswap_atomic_init, kaleidoswap_atomic_execute, kaleidoswap_atomic_status, rln_get_node_info, rln_atomic_taker
|
|
5
|
+
triggers: quote, swap, trade, rebalance, slippage, pair, pairs, usdt, xaut, kaleidoswap, rfq, check status, order status, check the order, swap status, check my swap, atomic status
|
|
6
6
|
metadata:
|
|
7
7
|
author: kaleidoswap
|
|
8
8
|
version: "0.4.0"
|
|
@@ -40,15 +40,28 @@ which pair + amount.
|
|
|
40
40
|
|
|
41
41
|
## Asset codes (canonical)
|
|
42
42
|
|
|
43
|
+
KaleidoSwap is the maker for **BTC ↔ RGB asset** atomic swaps. The asset
|
|
44
|
+
family is **RGB**: USDT, XAUT, and any other RGB asset the maker prices.
|
|
45
|
+
The RGB assets live on the user's **RLN** (RGB Lightning Node) — NOT on
|
|
46
|
+
Spark, Arkade, or any other chain.
|
|
47
|
+
|
|
43
48
|
Only these codes are accepted:
|
|
44
49
|
|
|
45
50
|
- `BTC` (Bitcoin, amounts always in satoshis)
|
|
46
|
-
- `USDT` (Tether) — **not** `USD`, **not** `tether`
|
|
47
|
-
- `XAUT` (Tether Gold) — **not** `XAU`, **not** `gold`
|
|
51
|
+
- `USDT` (Tether, the RGB asset) — **not** `USD`, **not** `tether`
|
|
52
|
+
- `XAUT` (Tether Gold, the RGB asset) — **not** `XAU`, **not** `gold`
|
|
48
53
|
|
|
49
54
|
When the user types `USD` they almost always mean `USDT` — confirm before
|
|
50
55
|
quoting. Same for `gold` → `XAUT`. Don't silently substitute.
|
|
51
56
|
|
|
57
|
+
**Do NOT trade here:**
|
|
58
|
+
|
|
59
|
+
- `USDB` and any other **Spark-native token** — those are on the Spark
|
|
60
|
+
layer and trade on **Flashnet** (skill: `flashnet-swaps`), not on
|
|
61
|
+
KaleidoSwap. Route the user there instead of inventing a maker pair.
|
|
62
|
+
- Tokens from external chains (Ethereum USDT, Solana, etc.). They are
|
|
63
|
+
not in the maker's catalog and the wallet does not custody them.
|
|
64
|
+
|
|
52
65
|
## Tools
|
|
53
66
|
|
|
54
67
|
### `kaleidoswap_get_pairs` — no args
|
|
@@ -113,13 +126,16 @@ Only after `kaleidoswap_get_quote` returned an `rfq_id` THIS turn, and only when
|
|
|
113
126
|
the user has explicitly approved the amount + direction. Pass the `rfq_id` as
|
|
114
127
|
`quote_id`.
|
|
115
128
|
|
|
116
|
-
**Save the `order_id` AND `access_token` from the result** —
|
|
117
|
-
for polling status later.
|
|
129
|
+
**Save the `order_id` AND `access_token` from the result** (BOTH required — never omit either). Extract them verbatim from the tool result (or the most recent assistant summary that listed "order_id=... access_token=..."). If memory/remember is available, first recall the last order details before polling status. You will need both for `kaleidoswap_get_order_status` later.
|
|
118
130
|
|
|
119
131
|
### `kaleidoswap_get_order_status(order_id, access_token)`
|
|
120
|
-
|
|
121
|
-
(
|
|
122
|
-
|
|
132
|
+
**Args: `order_id`, `access_token` (BOTH required — never omit either).**
|
|
133
|
+
Poll after placing an order (or atomic). `order_state` (or equivalent) progresses
|
|
134
|
+
to terminal states. Always pass the exact values from the previous
|
|
135
|
+
`kaleidoswap_place_order` result **or from the most recent assistant message/summary**
|
|
136
|
+
(the one that said something like "order_id=xxx access_token=yyy" or "To check status use: kaleidoswap_get_order_status(order_id=..., access_token=...)").
|
|
137
|
+
If memory/remember is available, first recall the last order/swap details.
|
|
138
|
+
Report the outcome plainly.
|
|
123
139
|
|
|
124
140
|
## Flow
|
|
125
141
|
|
|
@@ -128,11 +144,11 @@ completed, failed.
|
|
|
128
144
|
3. **Read + present** — compute the receive amount + fee from the response (see
|
|
129
145
|
"Reading the quote response"). **Never hide cost.**
|
|
130
146
|
4. **Place** — spend-gated by the engine. The host pauses for the user.
|
|
131
|
-
5. **Track** — poll `kaleidoswap_get_order_status(order_id, access_token)` (use both values saved from place_order) until it terminates.
|
|
147
|
+
5. **Track** — poll `kaleidoswap_get_order_status(order_id, access_token)` (use both values saved from place_order or the explicit "To check status..." template) until it terminates. For atomic swaps the status tool is `kaleidoswap_atomic_status(atomic_id)`.
|
|
132
148
|
|
|
133
149
|
## Don'ts
|
|
134
150
|
|
|
135
|
-
- Don't invent prices, quotes, rfq_ids, or
|
|
151
|
+
- Don't invent prices, quotes, rfq_ids, order_ids, or access_tokens.
|
|
136
152
|
- Don't reuse a number from a previous turn.
|
|
137
153
|
- Don't describe how a tool works — call it.
|
|
138
154
|
- Don't call `kaleidoswap_get_quote` with from/to only — ask for the amount.
|
|
@@ -142,7 +158,15 @@ completed, failed.
|
|
|
142
158
|
- Don't accept `XAU` as `XAUT` or `USD` as `USDT` silently — confirm.
|
|
143
159
|
- Don't retry the same failing tool call in a loop. If a call fails, read the
|
|
144
160
|
error and either ask the user, fix the args, or stop.
|
|
161
|
+
- Don't claim an order completed without polling the status tool with BOTH
|
|
162
|
+
required ids/tokens and seeing a terminal state.
|
|
163
|
+
- Never call `kaleidoswap_get_order_status` with only the access_token or only
|
|
164
|
+
the order_id. Always extract the exact values from the previous turn's summary
|
|
165
|
+
(the one that said "order_id=... access_token=..." or the explicit "To check
|
|
166
|
+
status use..." line) and pass them as separate arguments. If using the
|
|
167
|
+
`remember` tool, first recall the last order details.
|
|
145
168
|
|
|
146
169
|
For the full atomic-swap flow (init → whitelist on the RGB node → execute), a
|
|
147
170
|
deterministic recipe drives the chain — the agentic loop is not safe to plan a
|
|
148
|
-
multi-step, two-service swap on a small model.
|
|
171
|
+
multi-step, two-service swap on a small model. Status for atomics uses the
|
|
172
|
+
`atomic_id` (or payment_hash) surfaced in the recipe summary.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: liquidity-optimizer
|
|
3
|
+
description: "Analyze and optimize the node's Lightning liquidity. Reads channels, balances and payment history, then explains the node's liquidity health and recommends concrete actions: buy inbound, open/close channels, rebalance BTC↔assets, or tune routing fees. Triggers when the user wants to rebalance, optimize liquidity, fix inbound/outbound balance, free up capital, lower fees, or asks 'how healthy is my node?' / 'where is my liquidity?'."
|
|
4
|
+
tools: rln_list_channels, rln_get_balances, rln_get_node_info, rln_list_payments, kaleidoswap_lsp_get_info, kaleidoswap_lsp_estimate_fees, kaleidoswap_lsp_quote_asset_channel, rln_open_channel, rln_close_channel
|
|
5
|
+
triggers: rebalance, rebalancing, optimize liquidity, liquidity, inbound, outbound, lopsided, depleted channel, free up capital, stuck funds, channel balance, routing fee, lower fees, fee optimization, node health, healthy node, where is my liquidity, capacity
|
|
6
|
+
metadata:
|
|
7
|
+
author: kaleidoswap
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Liquidity optimizer
|
|
12
|
+
|
|
13
|
+
Help the user keep their RGB Lightning node's liquidity healthy: balanced
|
|
14
|
+
inbound/outbound, capital not stuck in dead channels, and fees set so the node
|
|
15
|
+
can actually route and receive. You **analyze real channel state and recommend
|
|
16
|
+
actions** — you never move funds without an explicit, confirmed instruction.
|
|
17
|
+
|
|
18
|
+
## Critical rules — these override everything else
|
|
19
|
+
|
|
20
|
+
You have **no knowledge** of the node's channels, balances, or capacity. Every
|
|
21
|
+
number, channel id, ratio, or fee in your reply MUST come from a tool result
|
|
22
|
+
returned in the CURRENT turn. Never quote a balance from memory or reuse a
|
|
23
|
+
number from a previous turn — re-read it.
|
|
24
|
+
|
|
25
|
+
**Calling the tool IS the analysis.** Don't say "I'd check your channels with
|
|
26
|
+
`rln_list_channels`" — call it, then report what it returned in plain language.
|
|
27
|
+
Don't reveal raw tool names in your reply.
|
|
28
|
+
|
|
29
|
+
**Read freely, spend never (without confirmation).** `rln_list_channels`,
|
|
30
|
+
`rln_get_balances`, `rln_get_node_info`, `rln_list_payments`,
|
|
31
|
+
`kaleidoswap_lsp_get_info`, and `kaleidoswap_lsp_estimate_fees` are read-only —
|
|
32
|
+
use them as much as you need. `rln_open_channel`, `rln_close_channel`, and
|
|
33
|
+
buying a channel are **spends**: only call them when the user explicitly asked
|
|
34
|
+
for that action this turn, and each goes through the wallet's confirmation gate.
|
|
35
|
+
When you merely *recommend* an action, describe it — do not execute it.
|
|
36
|
+
|
|
37
|
+
## How to assess liquidity
|
|
38
|
+
|
|
39
|
+
### 1 — Read the state (always start here)
|
|
40
|
+
- `rln_list_channels` → `channel_count`, `total_outbound_msat`,
|
|
41
|
+
`total_inbound_msat`, and per-channel `outbound_balance_msat`,
|
|
42
|
+
`inbound_balance_msat`, `is_usable`, capacity, peer, and any RGB asset
|
|
43
|
+
allocation. **Balances are in millisats (msat); divide by 1000 for sats.**
|
|
44
|
+
- `rln_get_balances` → on-chain (vanilla/colored) + Lightning balance, to see
|
|
45
|
+
uncommitted capital that could open a channel.
|
|
46
|
+
- `rln_get_node_info` → pubkey, peer/channel counts, sync state.
|
|
47
|
+
- `rln_list_payments` (optional) → recent flow direction, to infer whether the
|
|
48
|
+
node mostly sends or receives.
|
|
49
|
+
|
|
50
|
+
### 2 — Compute the picture (per channel and overall)
|
|
51
|
+
For each channel, the **outbound ratio** = `outbound / (outbound + inbound)`:
|
|
52
|
+
- **~0% (all inbound):** can receive but can't send — depleted outbound.
|
|
53
|
+
- **~100% (all outbound):** can send but can't receive — no inbound liquidity.
|
|
54
|
+
- **40–60%:** balanced and healthy.
|
|
55
|
+
Then look at the totals: is the node short on **inbound** (can't receive) or
|
|
56
|
+
short on **outbound** (can't send)? Flag channels that are `is_usable: false`
|
|
57
|
+
(offline/pending peer) or that hold meaningful capital but never route.
|
|
58
|
+
|
|
59
|
+
### 3 — Recommend, prioritized
|
|
60
|
+
Lead with a one-line health verdict, then a short ordered action list. Match the
|
|
61
|
+
remedy to the problem:
|
|
62
|
+
- **Low inbound / "can't receive":** buy inbound from the LSP. Use
|
|
63
|
+
`kaleidoswap_lsp_get_info` for limits and `kaleidoswap_lsp_estimate_fees`
|
|
64
|
+
(or `kaleidoswap_lsp_quote_asset_channel` for an asset channel) to give a real
|
|
65
|
+
fee, then hand off to the channel-order flow. Don't invent the fee.
|
|
66
|
+
- **Low outbound / "can't send":** open a channel to a well-connected peer with
|
|
67
|
+
spare on-chain BTC (`rln_open_channel`), or fund the wallet first.
|
|
68
|
+
- **Lopsided but funded both ways:** rebalance instead of opening new channels —
|
|
69
|
+
for BTC↔asset imbalance, suggest a swap (the trading flow), since circular
|
|
70
|
+
rebalancing may not be available on this node.
|
|
71
|
+
- **Dead/offline channels with stuck capital:** consider closing
|
|
72
|
+
(`rln_close_channel`) to reclaim funds, but only if the user confirms — note
|
|
73
|
+
on-chain fees and the ~hours for funds to settle.
|
|
74
|
+
- **Fees:** if the node should route more, suggest lower routing fees; if it's
|
|
75
|
+
draining outbound cheaply, suggest raising them. If no fee-setting tool is
|
|
76
|
+
available this turn, give the recommendation and tell the user where to set it
|
|
77
|
+
rather than pretending you changed it.
|
|
78
|
+
|
|
79
|
+
## Output style
|
|
80
|
+
Concise and scannable. A verdict line, then "Top actions" as a short numbered
|
|
81
|
+
list with the concrete number behind each (e.g. "Channel abc12… is 97% outbound
|
|
82
|
+
— buy ~200k inbound, est. fee from the LSP"). No walls of JSON.
|
|
83
|
+
|
|
84
|
+
## Don'ts
|
|
85
|
+
- Don't invent channels, balances, ratios, capacities, or fees — read them.
|
|
86
|
+
- Don't forget msat→sat conversion when reporting channel balances.
|
|
87
|
+
- Don't open or close a channel, or buy liquidity, unless the user asked for
|
|
88
|
+
that action this turn — recommendations are not actions.
|
|
89
|
+
- Don't claim you changed fees or rebalanced if no tool did it — say what the
|
|
90
|
+
user should do.
|
|
91
|
+
- Don't reuse last turn's numbers — re-read before advising again.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: merchant-finder
|
|
3
3
|
description: "Find Bitcoin-accepting merchants near the user using live BTC Map data and the device's real location. Triggers when the user asks where to spend Bitcoin, buy pizza/food with sats or bitcoin, eat at restaurants/cafes paying with sats, for a shop, store, restaurant, cafe, bar, or ATM that accepts Bitcoin, or for merchants nearby or in a city like turin."
|
|
4
|
-
tools: find_merchant_locations
|
|
5
|
-
triggers: merchant, merchants, shop, shops, store, stores, restaurant, restaurants, cafe, cafes, bar, bars, atm, atms, accept, accepts, accepting, nearby, near me, around
|
|
4
|
+
tools: find_merchant_locations, search_knowledge
|
|
5
|
+
triggers: merchant, merchants, shop, shops, store, stores, restaurant, restaurants, cafe, cafes, bar, bars, atm, atms, accept, accepts, accepting, nearby, near me, around me, where can i spend, pizza, pizz, food, coffee, eat, dinner, lunch, bitcoin map, btcmap
|
|
6
6
|
metadata:
|
|
7
7
|
author: kaleidoswap
|
|
8
8
|
version: "0.3.0"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: portfolio-manager
|
|
3
|
+
description: "Keep a BTC / USDT / XAUT portfolio near its target allocation. Read live balances and prices, detect drift versus targets, and (when allowed) rebalance via an atomic swap on KaleidoSwap. Triggers when the user asks to rebalance, check allocation, review the portfolio, or optimize holdings — and is the skill the scheduled 'rebalance' loop runs."
|
|
4
|
+
tools: rln_get_balances, rln_list_assets, kaleidoswap_get_pairs, kaleidoswap_get_quote, kaleidoswap_atomic_init, kaleidoswap_atomic_execute, kaleidoswap_atomic_status, get_price, get_market_data
|
|
5
|
+
triggers: rebalance, allocation, portfolio, drift, optimize, target, weighting, holdings
|
|
6
|
+
metadata:
|
|
7
|
+
author: kaleidoswap
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Portfolio manager
|
|
12
|
+
|
|
13
|
+
Keep the holdings near their target weights across **BTC**, **USDT**, and
|
|
14
|
+
**XAUT**. You fetch everything live — never assume a balance, price, or target.
|
|
15
|
+
|
|
16
|
+
## Critical rules — these override everything else
|
|
17
|
+
|
|
18
|
+
- **Read before you act.** Get balances (`rln_get_balances`) and prices
|
|
19
|
+
(`get_price`) every run. Never reuse a number from a previous turn.
|
|
20
|
+
- **Respect `dry_run`.** When `dry_run` is true you describe the rebalance you
|
|
21
|
+
*would* make — you do NOT call `kaleidoswap_atomic_init`/`_execute`. This is
|
|
22
|
+
non-negotiable.
|
|
23
|
+
- **Respect fund safety.** Never propose a swap that breaches the BTC reserve or
|
|
24
|
+
stop-loss floor passed in the task parameters. The host's risk gate is the
|
|
25
|
+
final word, but don't even suggest a breach.
|
|
26
|
+
- **Below-minimum drift = do nothing.** If every asset is within the drift
|
|
27
|
+
threshold, say so and stop. Churn is a cost, not a feature.
|
|
28
|
+
|
|
29
|
+
## How to think about a rebalance
|
|
30
|
+
|
|
31
|
+
1. **Snapshot.** `rln_get_balances` → BTC sats + each RGB asset (raw units).
|
|
32
|
+
2. **Value it.** Convert each holding to a common denomination using
|
|
33
|
+
`get_price`. Do NOT do arithmetic free-hand on raw RGB units — use the
|
|
34
|
+
display fields the tools return; only convert sats↔USD with the live BTC
|
|
35
|
+
price.
|
|
36
|
+
3. **Compare to targets.** Targets come in the task parameters (e.g.
|
|
37
|
+
`BTC 70 / USDT 20 / XAUT 10`). Compute each asset's current weight and its
|
|
38
|
+
drift = current − target.
|
|
39
|
+
4. **Decide.** If the largest drift exceeds the threshold, the over-weight asset
|
|
40
|
+
sells into the most under-weight asset. One swap per run — smallest trade
|
|
41
|
+
that brings the worst drift back inside the band.
|
|
42
|
+
5. **Quote.** `kaleidoswap_get_quote(from, to, amount)` for that single leg.
|
|
43
|
+
6. **Execute** (only when `dry_run` is false and the size is within limits): the
|
|
44
|
+
atomic swap recipe drives `kaleidoswap_atomic_init` → `_execute`; then poll
|
|
45
|
+
`kaleidoswap_atomic_status`.
|
|
46
|
+
|
|
47
|
+
## Asset codes (canonical)
|
|
48
|
+
|
|
49
|
+
`BTC` (satoshis), `USDT` (not `USD`), `XAUT` (not `XAU`/gold).
|
|
50
|
+
|
|
51
|
+
## Scheduled (background) runs
|
|
52
|
+
|
|
53
|
+
When run by the `rebalance` loop, after deciding, return STRICT JSON only:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
{"task":"rebalance","timestamp":"<ISO8601>","action":"rebalance|noop","dry_run":<bool>,"reason":"<why>","details":{"from":"<asset>","to":"<asset>","amount":"<n>","drift":{}}}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`action` is `noop` when within band. Put the human explanation in `reason`.
|
|
60
|
+
|
|
61
|
+
## Don'ts
|
|
62
|
+
|
|
63
|
+
- Don't invent prices, quotes, or balances — call the tool.
|
|
64
|
+
- Don't rebalance on noise — honor the drift threshold.
|
|
65
|
+
- Don't place more than one swap per run.
|
|
66
|
+
- Don't breach the reserve / stop-loss, ever.
|
|
67
|
+
- Don't execute anything when `dry_run` is true.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: rgb-lightning-node
|
|
3
|
-
description: "Drive the user's local RGB Lightning Node (RLN) — read its pubkey/status, whitelist a swap, or create Lightning/RGB receive invoices. Triggers when the user asks about the node, needs an invoice, or is mid-atomic-swap and the maker needs the node pubkey or a swapstring whitelisted."
|
|
4
|
-
tools: rln_get_node_info, rln_whitelist_swap, rln_create_ln_invoice, rln_create_rgb_invoice
|
|
5
|
-
triggers: node, nodeinfo, pubkey, peer, channels, whitelist, taker, swapstring, invoice, receive, rgb invoice, ln invoice
|
|
3
|
+
description: "Drive the user's local RGB Lightning Node (RLN) — read its pubkey/status, list channels and their capacities, check RGB asset balances, manage channels/peers, whitelist a swap, or create Lightning/RGB receive invoices. Triggers when the user asks about the node, their channels or capacities, needs an invoice, or is mid-atomic-swap and the maker needs the node pubkey or a swapstring whitelisted."
|
|
4
|
+
tools: rln_get_node_info, rln_get_balances, rln_list_channels, rln_list_assets, rln_get_asset_balance, rln_open_channel, rln_close_channel, rln_connect_peer, rln_get_channel_id, rln_whitelist_swap, rln_atomic_taker, rln_list_payments, rln_create_ln_invoice, rln_create_rgb_invoice
|
|
5
|
+
triggers: node, nodeinfo, pubkey, peer, channels, channel capacity, list channels, inbound, capacity, asset balance, whitelist, taker, swapstring, invoice, receive, rgb invoice, ln invoice
|
|
6
6
|
metadata:
|
|
7
7
|
author: kaleidoswap
|
|
8
8
|
version: "0.1.0"
|
|
@@ -47,12 +47,39 @@ Call this when:
|
|
|
47
47
|
`kaleidoswap_atomic_execute`.
|
|
48
48
|
|
|
49
49
|
**Do NOT** use this tool's `local_balance_sat` to answer a question about
|
|
50
|
-
**inbound liquidity / receive capacity** — that is a different quantity
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
**inbound liquidity / receive capacity** — that is a different quantity (the
|
|
51
|
+
peer's side of each channel). For per-channel inbound/outbound and total
|
|
52
|
+
capacity, use `rln_list_channels` (below), NOT this tool.
|
|
53
|
+
|
|
54
|
+
### `rln_list_channels` — no args
|
|
55
|
+
Returns `{ channels: [...], count }`. Each channel carries:
|
|
56
|
+
- `channel_id`, `peer_alias`, `status`, `ready`, `is_usable`
|
|
57
|
+
- `capacity_sat` — total channel size.
|
|
58
|
+
- `outbound_sat` — what YOU can send (your local balance).
|
|
59
|
+
- `inbound_sat` — what you can RECEIVE on this channel (the peer's side).
|
|
60
|
+
- `asset_id`, `asset_local_amount`, `asset_remote_amount` — for RGB asset
|
|
61
|
+
channels: the asset and how much is on each side.
|
|
62
|
+
|
|
63
|
+
Call this when the user asks to **list channels**, asks about **per-channel
|
|
64
|
+
capacity**, **inbound/receive capacity**, or wants to **verify a channel they
|
|
65
|
+
just bought** opened with the requested size. Report each channel as one line:
|
|
66
|
+
`capacity_sat total — outbound_sat / inbound_sat (asset if present), status`.
|
|
67
|
+
|
|
68
|
+
When verifying a freshly-bought channel: a channel order opens
|
|
69
|
+
ASYNCHRONOUSLY (seconds to minutes after payment). If the new channel isn't
|
|
70
|
+
listed yet, say it's still opening and suggest checking again — don't claim
|
|
71
|
+
failure.
|
|
72
|
+
|
|
73
|
+
### `rln_list_assets` — no args
|
|
74
|
+
Lists RGB assets known to the node with per-asset balances (settled, future,
|
|
75
|
+
spendable, offchain_outbound, offchain_inbound). Use for "what assets do I
|
|
76
|
+
hold / what's my USDT balance".
|
|
77
|
+
|
|
78
|
+
### `rln_get_asset_balance` — { asset_id }
|
|
79
|
+
Balance for one RGB asset by id. Use after `rln_list_assets` gave you the id,
|
|
80
|
+
or when the user names a specific asset.
|
|
81
|
+
|
|
82
|
+
### `rln_atomic_taker` — { swapstring } — 🔒 confirm-gated
|
|
56
83
|
Tell the node "I accept this swap." Args: the `swapstring` returned by
|
|
57
84
|
`kaleidoswap_atomic_init`. The node validates and stores it; **no funds move
|
|
58
85
|
here**, but the user is committing to the swap so the engine pauses for
|
|
@@ -90,9 +117,9 @@ A user-driven swap on KaleidoSwap is a two-service flow. Keep them straight:
|
|
|
90
117
|
| Quote | maker | `kaleidoswap_get_quote` |
|
|
91
118
|
| Init | maker | `kaleidoswap_atomic_init` (returns swapstring + payment_hash) |
|
|
92
119
|
| Pubkey | **node** | `rln_get_node_info` (read `pubkey`) |
|
|
93
|
-
| Whitelist | **node** | `
|
|
120
|
+
| Whitelist | **node** | `rln_atomic_taker` (pass the swapstring) |
|
|
94
121
|
| Execute | maker | `kaleidoswap_atomic_execute` (needs swapstring + taker_pubkey + payment_hash) |
|
|
95
|
-
| Status | maker | `kaleidoswap_atomic_status` |
|
|
122
|
+
| Status | maker | `kaleidoswap_atomic_status` (pass atomic_id or payment_hash from the atomic recipe summary or prior init result; see "remember" line in history) |
|
|
96
123
|
|
|
97
124
|
The node's two contributions to the swap are the **pubkey** and the
|
|
98
125
|
**whitelist ack** — nothing more. Don't reach for `/makerinit` or
|