AgentSkillsCN

Skill

技能

SKILL.md

mostro-trading

Trade Bitcoin P2P on Mostro — a censorship-resistant exchange over Lightning Network and Nostr.

When to Use

Use this skill when the user wants to:

  • Buy or sell Bitcoin peer-to-peer
  • View available P2P orders on Mostro
  • Check Mostro exchange info (fees, limits, currencies)
  • Manage trades (create, take, cancel, confirm, dispute)
  • Check trade status or history

Setup

  1. Install dependencies: cd <skill-dir> && npm install
  2. Copy config.example.json to config.json
  3. Set mostro_pubkey to the hex public key of the target Mostro instance
  4. Optionally adjust relays, limits, and other settings

Keys are auto-generated on first use (BIP-39 mnemonic). The mnemonic is saved to ~/.mostro-skill/seed. Back it up!

Tools

All scripts are in scripts/ and run with tsx:

Read-Only (Safe)

ScriptDescriptionExample
get-info.tsMostro instance info (version, fees, currencies, limits)tsx scripts/get-info.ts
list-orders.tsList order booktsx scripts/list-orders.ts --currency USD --kind sell --status pending
trade-status.tsCheck own trade statustsx scripts/trade-status.ts --order-id <uuid> or --all

Trading (Requires Confirmation)

ScriptDescriptionExample
create-order.tsCreate buy/sell ordertsx scripts/create-order.ts --kind buy --currency USD --fiat-amount 50 --payment-method "bank transfer"
take-order.tsTake an existing ordertsx scripts/take-order.ts --order-id <uuid> --action take-sell --invoice <lnbc...>
cancel-order.tsCancel own ordertsx scripts/cancel-order.ts --order-id <uuid>
fiat-sent.tsBuyer confirms fiat senttsx scripts/fiat-sent.ts --order-id <uuid>
release.tsSeller releases satstsx scripts/release.ts --order-id <uuid>
rate-user.tsRate counterparty (1-5)tsx scripts/rate-user.ts --order-id <uuid> --rating 5
dispute.tsOpen a disputetsx scripts/dispute.ts --order-id <uuid>

create-order.ts Options

FlagRequiredDescription
--kindbuy or sell
--currencyFiat currency code (USD, EUR, ARS, VES, etc.)
--fiat-amountAmount in fiat (set 0 for range orders)
--payment-methodPayment method (e.g., "bank transfer", "face to face")
--premiumPremium percentage (default: 0)
--amountFixed sats amount (default: 0 = market price)
--min-amountMin fiat for range orders
--max-amountMax fiat for range orders
--invoiceLightning address for buy orders (e.g., user@ln.tips)

take-order.ts Options

FlagRequiredDescription
--order-idUUID of the order to take
--actiontake-sell (buyer) or take-buy (seller)
--invoiceLN invoice or address (for take-sell)
--amountFiat amount (required for range orders)

Advanced Tools

ScriptDescriptionExample
add-invoice.tsSend LN invoice after taking a sell ordertsx scripts/add-invoice.ts --order-id <uuid> --invoice <lnbc...>
dispute-chat.tsSend messages during a disputetsx scripts/dispute-chat.ts --order-id <uuid> --message "proof attached"
restore-session.tsImport mnemonic and restore active orderstsx scripts/restore-session.ts --mnemonic "word1 word2 ..."
analytics.tsTrade history and statisticstsx scripts/analytics.ts or --recent 10 or --csv
multi-mostro.tsQuery multiple Mostro instancestsx scripts/multi-mostro.ts --currency USD --kind sell --best
auto-trade.tsAutomated trading strategiestsx scripts/auto-trade.ts --strategy strategies/dca-weekly.json [--dry-run]

auto-trade.ts Strategies

StrategyConfig ExampleDescription
DCAstrategies/dca-weekly.jsonBuy/sell fixed amount at regular intervals
Limitstrategies/limit-buy.jsonTake orders matching specific criteria (premium, rating)
Market Makerstrategies/market-maker.jsonMaintain buy and sell orders with a spread

All strategies support --dry-run for testing. Set "enabled": true in the strategy JSON to activate.

analytics.ts Options

FlagDescriptionExample
--recent NShow last N audit entries--recent 10
--csvExport all trades to CSV file--csv
--days NStats for last N days only--days 30
--outputOutput file for CSV export--output trades.csv

multi-mostro.ts Options

FlagDescriptionExample
--currencyFilter by fiat currency--currency USD
--kindFilter by order type--kind sell
--bestShow only the single best order--best
--list-instancesList configured Mostro instances--list-instances

Configure multiple instances in config.json under mostro_instances array.

Trade Flow

Buying BTC

  1. list-orders.ts --kind sell --currency USD — Find sell orders
  2. take-order.ts --order-id <id> --action take-sell --invoice <lnbc...> — Take order
  3. Wait for seller to pay hold invoice
  4. Send fiat payment to seller via agreed method
  5. fiat-sent.ts --order-id <id> — Confirm fiat sent
  6. Wait for seller to release sats → you receive BTC!
  7. rate-user.ts --order-id <id> --rating 5 — Rate the seller

Selling BTC

  1. create-order.ts --kind sell --currency USD --fiat-amount 50 --payment-method "bank transfer" — Create sell order
  2. Wait for buyer to take the order
  3. Pay the hold invoice Mostro sends you
  4. Wait for buyer to confirm fiat sent
  5. Verify fiat received in your account
  6. release.ts --order-id <id> — Release sats to buyer
  7. rate-user.ts --order-id <id> --rating 5 — Rate the buyer

Safety

  • Confirmation mode is ON by default — always present trade details to the user and ask for explicit approval before executing
  • Trade limits are configured in config.json (max amount, daily volume, cooldown)
  • Audit log at ~/.mostro-skill/audit.log records all actions
  • Never log or expose private keys or mnemonics
  • When in doubt about a trade, advise the user to verify manually

Configuration

Edit config.json:

json
{
  "mostro_pubkey": "<hex pubkey>",
  "relays": ["wss://relay.mostro.network"],
  "network": "mainnet",
  "limits": {
    "max_trade_amount_fiat": 100,
    "max_daily_volume_fiat": 500,
    "max_trades_per_day": 10,
    "cooldown_seconds": 300,
    "require_confirmation": true
  }
}

Protocol Reference

Mostro uses Nostr events for communication:

  • Kind 38383: Order book (addressable events with tags for filtering)
  • Kind 38385: Mostro instance info
  • Kind 38386: Disputes
  • Kind 1059: Gift wrap messages (NIP-59) for private communication

All messages are encrypted using NIP-44 and wrapped in NIP-59 gift wrap for privacy.

See docs/IMPLEMENTATION.md for full protocol details.