@arkade-os/swap 0.1.10 → 0.1.12

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.
Files changed (48) hide show
  1. package/README.md +58 -0
  2. package/dist/advanced.cjs +1058 -414
  3. package/dist/advanced.d.cts +7 -64
  4. package/dist/advanced.d.ts +7 -64
  5. package/dist/advanced.js +29 -5
  6. package/dist/{chunk-AUJDREZN.js → chunk-CIDVLDDM.js} +1 -1
  7. package/dist/{chunk-FWRDAL73.js → chunk-F3BGKWIB.js} +758 -104
  8. package/dist/{chunk-LCO6AJOS.js → chunk-ISKJIONJ.js} +58 -285
  9. package/dist/{chunk-2HQZLIVX.js → chunk-JBTU7Y6M.js} +1 -1
  10. package/dist/chunk-UXK7YDA4.js +568 -0
  11. package/dist/{chunk-6RJVT65W.js → chunk-VPVSSBY2.js} +2 -4
  12. package/dist/index.cjs +1045 -414
  13. package/dist/index.d.cts +6 -4
  14. package/dist/index.d.ts +6 -4
  15. package/dist/index.js +15 -5
  16. package/dist/{lockupContract-BTTRVwOt.d.cts → lockupContract-B1mr672c.d.cts} +1 -1
  17. package/dist/{lockupContract-aFarhlxj.d.ts → lockupContract-BRpk0NxT.d.ts} +1 -1
  18. package/dist/node/index.d.cts +18 -18
  19. package/dist/node/index.d.ts +18 -18
  20. package/dist/nostr.cjs +276 -302
  21. package/dist/nostr.d.cts +20 -2
  22. package/dist/nostr.d.ts +20 -2
  23. package/dist/nostr.js +21 -357
  24. package/dist/{offerFillPlan-CJC5tnEd.d.ts → offerFillPlan-BMZXiVMB.d.ts} +213 -28
  25. package/dist/{offerFillPlan-FmyaQoYT.d.cts → offerFillPlan-CqJerwXd.d.cts} +213 -28
  26. package/dist/openRfq-Dx-vxOzl.d.cts +32 -0
  27. package/dist/openRfq-Dx-vxOzl.d.ts +32 -0
  28. package/dist/openRfqTransport-MQZ7JWYN.js +9 -0
  29. package/dist/protocol.cjs +301 -322
  30. package/dist/protocol.d.cts +5 -5
  31. package/dist/protocol.d.ts +5 -5
  32. package/dist/protocol.js +6 -8
  33. package/dist/repositories/realm/index.d.cts +1 -1
  34. package/dist/repositories/realm/index.d.ts +1 -1
  35. package/dist/repositories/sqlite/index.d.cts +1 -1
  36. package/dist/repositories/sqlite/index.d.ts +1 -1
  37. package/dist/{repository-CwwhIAEd.d.cts → repository-CFC0fHAy.d.cts} +26 -26
  38. package/dist/{repository-DO6QKxBx.d.ts → repository-suGldzOK.d.ts} +26 -26
  39. package/dist/rfq-contract.cjs +3 -6
  40. package/dist/rfq-contract.d.cts +3 -4
  41. package/dist/rfq-contract.d.ts +3 -4
  42. package/dist/rfq-contract.js +3 -5
  43. package/dist/transportErrors-DZuZqnF4.d.cts +8 -0
  44. package/dist/transportErrors-DZuZqnF4.d.ts +8 -0
  45. package/dist/{verify-ENO36VPK.js → verify-HU5COTNO.js} +3 -3
  46. package/dist/{watch-_fZSgx_l.d.ts → watch-C2z6Onak.d.ts} +1 -1
  47. package/dist/{watch-DpDSP2tu.d.cts → watch-CpYjItYX.d.cts} +1 -1
  48. package/package.json +3 -3
package/README.md CHANGED
@@ -15,6 +15,64 @@ const client = createSwapClient({ wallet, repository: new IndexedDbAssetSwapRepo
15
15
  Construction is synchronous and inert: no network, no wallet read, no repository open. The first
16
16
  call that needs one does it.
17
17
 
18
+ ## Compare open RFQ offers
19
+
20
+ `openRfq` is an explicit public search: it broadcasts the asset pair and atomic size.
21
+ It never publishes an invoice, payout address or wallet identity. Replies carry signed
22
+ solver cards and sealed indicative amounts; a discovered card stays local to this auction.
23
+ Open RFQ uses one version-1 wire shape with exact atomic amounts and signed-card bids.
24
+ Open offers require a usable directed Nostr rendezvous; feed-only routing remains separate.
25
+
26
+ ```ts
27
+ import { generateSecretKey } from "nostr-tools";
28
+
29
+ const auction = await client.openRfq(
30
+ { give, take, amount: 25_000n, amountOn: "give" },
31
+ { secretKey: generateSecretKey(), relays, signal },
32
+ );
33
+ // Present auction.bids and let the user choose an offer.
34
+ const quote = await client.quoteBid(auction, auction.bids[selectedIndex]);
35
+ // Present the verified terms before funding.
36
+ const swap = await client.accept(quote);
37
+ ```
38
+
39
+ The application supplies a fresh conversation key for each search. A selected offer is
40
+ verified through the normal directed quote path. Paused solvers and registry restrictions
41
+ still apply. Expired or worsened terms require a fresh selection; selection never fails
42
+ over. Tokens trade on Arkade; external Lightning and Bitcoin routes exchange native BTC only. An EVM
43
+ pair is refused before publication until that settlement corridor exists in the client.
44
+ See [`OpenRfqOptions`](src/client/openRfq.ts) for progress, relay and timing controls.
45
+
46
+ ## Solver priority and failover
47
+
48
+ Opt in with `policy: { solverRouting: {} }`. The
49
+ [`SolverRoutingPolicy` API contract](src/client/solverRouting.ts) documents the defaults,
50
+ quote-only failover boundary and explicit-selection precedence.
51
+
52
+ ```ts
53
+ import { completedSolverUsage, createSolverHealth, createSwapClient } from "@arkade-os/swap";
54
+
55
+ const client = createSwapClient({
56
+ wallet,
57
+ repository,
58
+ policy: {
59
+ solverRouting: {
60
+ health: createSolverHealth({ storage: healthStorage }),
61
+ preferences: async ({ network, direction }) => ({
62
+ mode: "usage", // "manual" | "usage" | "cost"
63
+ priority: savedPriorities[direction] ?? [],
64
+ preferFirst: preferredSolverIds[direction],
65
+ disabled: disabledSolverIds[direction] ?? [],
66
+ usage: completedSolverUsage(await client.swaps(), network, direction),
67
+ }),
68
+ },
69
+ },
70
+ });
71
+ const candidates = await client.candidates({ to: invoice });
72
+ const quote = await client.quote({ to: invoice });
73
+ await client.accept(quote);
74
+ ```
75
+
18
76
  Market discovery needs no configuration either: the client defaults to the reference solver
19
77
  registry's index for the wallet's network (`REGISTRY_URL[network]`, exported). Follow your own
20
78
  registry instead with `discovery: { registryUrl }`, or opt out of registries entirely with