Skip to main content Accueil Créateurs kaleidoswap kaleido-agent portfolio-manager
portfolio-manager Autonomous portfolio rebalancing for Bitcoin L2 assets. Use when running a scheduled rebalancing loop: check current allocation, detect drift from targets, and execute the minimum swap needed to restore balance. Requires kaleidoswap-mcp and wdk-wallet-rln-mcp.
Aller à l'installation Skills Marketplace Découvrez et explorez les compétences IA créées par la communauté.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Copier le promptAfficher les détails du prompt Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
npx skills add https://github.com/kaleidoswap/kaleido-agent --skill portfolio-managerLa commande reste sur une seule ligne. Faites défiler horizontalement pour la vérifier avant de la copier.
Vous préférez une copie locale ? Téléchargez les fichiers actuellement disponibles dans SkillsMP.
Télécharger Zip Téléchargement...
Explorateur de fichiers
2 fichiers name portfolio-manager description Autonomous portfolio rebalancing for Bitcoin L2 assets. Use when running a scheduled rebalancing loop: check current allocation, detect drift from targets, and execute the minimum swap needed to restore balance. Requires kaleidoswap-mcp and wdk-wallet-rln-mcp.
license Apache-2.0 metadata {"author":"kaleidoswap","version":"1.1","networks":"bitcoin-lightning, rgb"}
Portfolio Manager Skill
Live State (injected at runtime)
Node status:
!kaleido --json node status
BTC wallet balance:
!kaleido --json wallet balance
RGB assets held:
!kaleido --json asset list
Lightning channels:
!kaleido --json channel list
Open/pending swap orders:
!kaleido --json swap history --status PENDING --limit 10
Available Tool (Skill Mode)
run_kaleido_command({ command }) — runs kaleido --json <command>.
Quotes & market:
"market quote BTC/USDT --from-amount <sats> --from-layer BTC_LN --to-layer RGB_LN" — get swap quote
"market quote XAUT/USDT --from-amount 1 --from-layer RGB_LN --to-layer RGB_LN" — XAUT price
"market assets" — list tradeable assets with precision
"market pairs" — available trading pairs
"market routes BTC/USDT" — available swap routes for a pair
"market info" — maker node info (pubkey, version)Swap execution (high-level — preferred):
"swap execute BTC/USDT --from-amount <sats> --from-layer BTC_LN --to-layer RGB_LN --yes" — full market swap (quote → order → execute)
"swap execute USDT/BTC --from-amount <raw> --from-layer RGB_LN --to-layer BTC_LN --yes" — sell USDT
"swap atomic-status --payment-hash <hash>" — check atomic swap status
Atomic node-level swap (low-level):
"swap run --qty-from <n> --qty-to <n> --to-asset <rgb:...> --yes" — BTC → RGB (maker-init → taker → execute in one command)
"swap run --from-asset <rgb:...> --qty-from <n> --qty-to <n> --yes" — RGB → BTC
"maker init --qty-from <n> --qty-to <n> [--from-asset <rgb:...>] [--to-asset <rgb:...>] [--timeout 100]" — init maker side, returns swapstring
"taker whitelist <swapstring>" — whitelist swap on taker side
"taker pubkey" — get taker pubkey
"maker execute --swapstring <s> --payment-secret <s> --taker-pubkey <pk>" — finalise maker side
"swap history --status PENDING" — open orders
"swap history --limit 20" — recent swaps
"swap node-swaps" — list node-level atomic swaps
"asset list" — RGB assets held
"asset sync" — sync RGB wallet with blockchain (run after swaps)
"asset fail-transfers" — mark stuck pending transfers as failed
"asset invoice <asset-id> --amount <raw>" — create RGB invoice
"asset send <asset-id> <raw-amount> <rgb-invoice>" — send RGB asset
"asset transfers [--limit 20]" — asset transfer history
"asset refresh [--asset-id <id>]" — refresh asset state (alternative to asset sync)
"payment invoice --amount-msat <msat>" — create LN invoice
"payment send <bolt11>" — pay LN invoice
"payment keysend <pubkey> <msat>" — direct keysend payment
"payment decode <invoice>" — decode BOLT11 or RGB invoice
You are an autonomous portfolio rebalancer. Each time you run, you:
Measure the current portfolio allocation
Compare to the configured target allocation
Determine if rebalancing is needed (drift > threshold)
Execute the minimum swap to bring the portfolio back in balance
Output a structured JSON report
Configuration (read from context or config block) {
"targets" : { "BTC" : 70 , "USDT" : 20 , "XAUT" : 10 } ,
"rebalance_threshold_pct" : 5 ,
"max_swap_usd" : 200 ,
"min_btc_reserve_sats" : 50000 ,
"max_concurrent_orders" : 3 ,
"stop_loss_btc_sats" : 30000 ,
"trading_mode" : "atomic" ,
"dry_run" : true
}
Step 1: Assess Current State wdk_get_node_info() → verify node is online
wdk_get_balances() → BTC offchain (outbound sats) + RGB asset balances
kaleidoswap_get_pairs() → discover trading pairs + layers
kaleidoswap_get_assets() → resolve asset IDs + precisions by ticker
Derive BTC price in USDT from a live quote (display units):
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"
})
btc_price_usdt = quote.to_asset.amount_display / 0.001
For each asset, compute USDT value:
btc_sats = offchain_outbound_sat (from wdk_get_balances)
btc_usdt = (btc_sats / 1e8) × btc_price_usdt
usdt_val = usdt_raw / 10^usdt_precision
xaut_usdt = xaut_raw / 10^xaut_precision × xaut_price_usdt
where xaut_price_usdt = from XAUT→USDT quote:
kaleidoswap_get_quote({ from_asset_id: "<XAUT_ID>", from_layer: "RGB_LN",
from_amount: 1.0, to_asset_id: "<USDT_ID>", to_layer: "RGB_LN" })
xaut_price_usdt = quote.to_asset.amount_display / 1.0
Total portfolio = sum of all USDT values.
Step 2: Detect Drift current_pct[asset] = (asset_usdt / total_usdt) × 100
drift[asset] = current_pct[asset] - target_pct[asset]
Trigger rebalance if : any |drift[asset]| > rebalance_threshold_pct
If no drift exceeds threshold → exit with "action": "balanced".
Step 3: Decide the Swap Rebalance toward the asset that is most underweight:
Overweight asset = sell (from)
Underweight asset = buy (to)
swap_usdt = min(|drift_pct| × total_usdt / 100, max_swap_usd)
Convert to from-asset display amount using the quote rate.
Always check before swapping (see risk.md):
BTC balance after swap > min_btc_reserve_sats
BTC balance > stop_loss_btc_sats → else halt
Open orders < max_concurrent_orders
dry_run is false → else describe only
Step 4: Execute the Swap In skill mode, prefer the high-level CLI swap commands:
swap execute BTC/USDT --from-amount <sats> --from-layer BTC_LN --to-layer RGB_LN --yes
→ executes full flow: quote → order → atomic execute
swap atomic-status --payment-hash <hash>
→ poll until status Succeeded / Expired / Failed
Execute per trading_mode:
"atomic" → use swap execute <PAIR> --from-amount <n> --yes (handles maker-init, taker whitelist, execute, status internally)
If you need full control of the atomic steps:
swap run --qty-from <n> --qty-to <n> [--from-asset] [--to-asset] --yes — handles all 3 steps in one call
OR manually:
maker init --qty-from <n> --qty-to <n> [--from-asset] [--to-asset] → swapstring, payment_hash
taker whitelist <swapstring>
taker pubkey → pubkey
maker execute --swapstring <s> --payment-secret <s> --taker-pubkey <pk>
swap atomic-status --payment-hash <hash> — poll until Succeeded
"rest" → use market quote + payment send / asset send flow
"both" → try swap execute --yes; if Expired/Failed, fall back to REST
After any swap: run asset sync to update RGB wallet state.
Step 5: Output Report {
"loop" : "rebalance" ,
"timestamp" : "2024-01-01T00:05:00Z" ,
"dry_run" : false ,
"action" : "swap" ,
"reason" : "USDT drift: +8.2% (target 20%, actual 28.2%)" ,
"btc_price_usdt" : 65763.00 ,
"portfolio" : {
"total_usdt" : 524.00 ,
"assets" : {
"BTC" : { "amount_sat" : 280000 , "usdt" : 266.00 , "pct" : 50.8 , "target_pct" : 70 } ,
"USDT" : { "amount" : 200.0 , "usdt" : 200.00 , "pct" : 38.2 , "target_pct" : 20 } ,
"XAUT" : { "amount" : 0.05 , "usdt" : 58.00 , "pct" : 11.1 , "target_pct" : 10 }
}
} ,
"swap_executed" : {
"from" : "USDT" ,
"to" : "BTC" ,
"from_amount_usdt" : 43.00 ,
"to_amount_sat" : 65400 ,
"payment_hash" : "abc123..." ,
"status" : "Succeeded"
}
}
Safety Rules
Verify node is online before doing anything: wdk_get_node_info()
Halt all trading if BTC < stop_loss_btc_sats
Skip if result puts BTC < min_btc_reserve_sats
Cap each swap at max_swap_usd
Skip cycle if open orders ≥ max_concurrent_orders
In dry_run mode: compute and log, never execute