| name | kaleidoswap |
| description | Trade RGB assets on Bitcoin Lightning using the KaleidoSwap protocol. Use when quoting a swap, executing an atomic swap, placing a REST order, checking order status, or managing open orders. Requires kaleido-mcp.
|
| license | Apache-2.0 |
| metadata | {"author":"kaleidoswap","version":"1.1","networks":"bitcoin-lightning, rgb"} |
KaleidoSwap Trading Skill
KaleidoSwap is a non-custodial DEX for RGB assets on Bitcoin Lightning Network.
Trades are settled via atomic HTLC swaps or REST deposit-based orders.
Required MCP Server
- kaleido-mcp â quotes, orders, atomic execution, RLN node: balances, invoices, HTLC signing
Core Concepts
- Assets: RGB tokens identified by
asset_id (BTC or rgb:...). Discover via kaleidoswap_get_assets() â never hard-code IDs.
- Pairs & Layers: Call
kaleidoswap_get_pairs() to find trading pairs and their routes (each route has from_layer/to_layer). Always use layer values from here.
- Amounts for
get_quote tool: pass display units (human-readable):
- BTC: decimal BTC (e.g.
0.001 = 100,000 sats). Internally msat (precision=11).
- RGB assets: decimal (e.g.
65.0 USDT with precision=6, 1.0 XAUT with precision=9).
- Raw amounts for
atomic_init: use amount_raw from the quote response directly.
- Show users: always convert raw â display using
raw / 10^precision.
Step 1: Discover Pairs and Layers
kaleidoswap_get_pairs()
â [{
base: { ticker, precision },
quote: { ticker, precision },
routes: [{ from_layer, to_layer }] â use these layer values
}]
kaleidoswap_get_assets()
â [{ ticker, asset_id, precision, name }] â resolve asset_id by ticker
Example â swap BTCâUSDT on Lightning:
- Find pair where
base.ticker="BTC" and quote.ticker="USDT"
- Pick route
{ from_layer: "BTC_LN", to_layer: "RGB_LN" }
- Resolve
USDT asset_id from assets list
Step 2: Get a Quote
kaleidoswap_get_quote({
from_asset_id: "BTC",
from_layer: "BTC_LN",
from_amount: 0.001, // display BTC (= 100,000 sats = 100M msat internally)
to_asset_id: "<USDT_ID>",
to_layer: "RGB_LN"
})
â {
rfq_id, expires_at,
from_asset: { ticker, layer, amount_raw, amount_display },
to_asset: { ticker, layer, amount_raw, amount_display },
price
}
Show the user: amount in â amount out â effective rate. Ask confirmation before executing.
Step 3a: Execute â Atomic Swap (preferred)
1. kaleidoswap_atomic_init({
rfq_id,
from_asset_id,
from_amount_raw, // = quote.from_asset.amount_raw
to_asset_id,
to_amount_raw // = quote.to_asset.amount_raw
})
â { swapstring, payment_hash }
2. rln_atomic_taker({ swapstring })
â {} (whitelist HTLC on RLN node â MUST happen before execute)
3. rln_get_node_info()
â { pubkey } (needed as taker_pubkey)
4. kaleidoswap_atomic_execute({
swapstring, taker_pubkey: pubkey, payment_hash
})
â { status, message }
5. kaleidoswap_atomic_status({ payment_hash })
â { swap: { status: "Waiting"|"Pending"|"Succeeded"|"Expired"|"Failed" } }
Poll every 2s until terminal state.
If Succeeded â done. If Expired/Failed â fall back to REST.
Step 3b: Execute â REST Order (fallback)
BTC â RGB (e.g. BTC â USDT):
1. rln_create_rgb_invoice({ asset_id: <USDT_ID> }) â rgb_invoice
2. kaleidoswap_place_order({
from_asset_id, to_asset_id, from_layer, to_layer, from_amount,
receiver_address: rgb_invoice, receiver_address_format: "RGB_INVOICE"
}) â { order_id, deposit_address: { address: bolt11 } }
3. rln_pay_invoice({ invoice: bolt11 })
4. Poll kaleidoswap_get_order_status({ order_id }) until "FILLED"
RGB â BTC (e.g. USDT â BTC):
1. rln_create_ln_invoice({ amount_msat }) â bolt11
2. kaleidoswap_place_order({ ..., receiver_address: bolt11, receiver_address_format: "BOLT11" })
â { order_id, deposit_address: { address: rgb_invoice } }
3. rln_send_asset({ asset_id, recipient_id: rgb_invoice, amount: display_amount })
4. Poll kaleidoswap_get_order_status({ order_id }) until "FILLED"
Order states: OPEN â PENDING_PAYMENT â PAID â EXECUTING â FILLED | EXPIRED | FAILED
Safety Rules
- Pairs first â
kaleidoswap_get_pairs() gives valid layers and min amounts.
- Quote first â never execute without a fresh
rfq_id.
- Confirm before executing â show amounts and rate; wait for user approval.
- Respect dry_run â describe action only; do not call execute.
- Check balances â verify sufficient funds before placing.
- Respect min amounts â check pair minimums from
get_pairs() before quoting.
- Handle expiry â get a fresh quote if
rfq_id has expired.