Skip to main content
Code for the arkade:<asset> → arkade:<asset> route — BTC against an Arkade Asset such as USDT. The SDK and wire format use offer in identifiers such as createOffer; that is the code name for the funded swap. Model: Markets and Execution · reference: Arkade Asset Swaps.
Prerequisites:
  • an initialized Arkade IWalletCreate Your Wallet;
  • a registry URL and the Arkade server URL.

Discover and Price

A card advises the pricing formula — the spot feed and the fee — and only a fill commits the solver to your swap. The quote below is calculated from those at runtime rather than received. No inventory is reserved, so application policy decides which registries and markets are acceptable.
Mind the units. giveAmount is a display amount when passed as a string or number, converted by the asset’s decimals — only bigint is atomic. Passing 100000 meaning sats quotes 100,000 BTC. validatePlan’s two operands are the opposite: both bigint, so wrap the wallet’s settled balance with BigInt(...). Show the deposit, receive amount, and fee before funding.

Fund

createOffer registers the covenant and returns the type 0x03 extension; it broadcasts nothing. Registration marks the contract genericallySpendable: false, which is what stops send, settle or background renewal from forfeiting a live offer behind your back. The swap goes live when wallet.send funds the address and includes the extension — that packet is what makes the funded swap discoverable to solvers watching the transaction stream. Omit it and the deposit sits there, indexed by nobody.
Identical terms derive the same address, which is why the record carries both offerHex and fundingTxid — the txid is what identifies this deposit.

Track and Cancel

watchOfferSwaps subscribes to the wallet’s contract events and drives each swap’s status for you, persisting before it notifies:
Only a registered covenant produces events, which createOffer handles. In Node you need an EventSource implementation for live updates to arrive. restoreAssetSwaps is the fallback, rebuilding records by scanning sent transactions for offer packets. An unfilled swap has no expiry — it stays open until filled or cancelled:
cancelOffer writes the cancellingcancelled transition itself, so do not write it yourself. Cancellation races a fill. If the deposit is already spent the call throws — that means the swap completed. Reconcile the spending transaction before reporting an error to the user.

Lightning

Pay and receive Lightning from an Arkade balance.

Arkade Asset Swaps

Review pricing, funding, lifecycle, and cancellation.