@arkade-os/swap 0.1.0-rc.3 → 0.1.0-rc.30

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 (59) hide show
  1. package/README.md +35 -4
  2. package/dist/advanced.cjs +6390 -3002
  3. package/dist/advanced.d.cts +391 -281
  4. package/dist/advanced.d.ts +391 -281
  5. package/dist/advanced.js +444 -26
  6. package/dist/chunk-7V254T53.js +3384 -0
  7. package/dist/chunk-A3SHHRX4.js +104 -0
  8. package/dist/chunk-AEYSMVWU.js +3021 -0
  9. package/dist/{chunk-H5KFNL5O.js → chunk-KIXAIAUC.js} +1596 -609
  10. package/dist/index.cjs +6797 -3666
  11. package/dist/index.d.cts +71 -185
  12. package/dist/index.d.ts +71 -185
  13. package/dist/index.js +146 -47
  14. package/dist/lockupContract-D7NyiHpE.d.ts +144 -0
  15. package/dist/lockupContract-VzLVZPcw.d.cts +144 -0
  16. package/dist/node/index.cjs +61 -10
  17. package/dist/node/index.d.cts +316 -615
  18. package/dist/node/index.d.ts +316 -615
  19. package/dist/node/index.js +65 -10
  20. package/dist/nostr.cjs +504 -52
  21. package/dist/nostr.d.cts +59 -70
  22. package/dist/nostr.d.ts +59 -70
  23. package/dist/nostr.js +268 -36
  24. package/dist/offer-CSMhR5sj.d.cts +269 -0
  25. package/dist/offer-CVnYFj7r.d.ts +269 -0
  26. package/dist/offerFillPlan-D-krqw0z.d.cts +1641 -0
  27. package/dist/offerFillPlan-D4Oy5_yZ.d.ts +1641 -0
  28. package/dist/protocol.cjs +5350 -3699
  29. package/dist/protocol.d.cts +211 -679
  30. package/dist/protocol.d.ts +211 -679
  31. package/dist/protocol.js +212 -226
  32. package/dist/repositories/realm/index.cjs +55 -11
  33. package/dist/repositories/realm/index.d.cts +18 -30
  34. package/dist/repositories/realm/index.d.ts +18 -30
  35. package/dist/repositories/realm/index.js +49 -12
  36. package/dist/repositories/sqlite/index.cjs +61 -10
  37. package/dist/repositories/sqlite/index.d.cts +7 -6
  38. package/dist/repositories/sqlite/index.d.ts +7 -6
  39. package/dist/repositories/sqlite/index.js +57 -11
  40. package/dist/repository-DRlPgbU8.d.cts +2341 -0
  41. package/dist/repository-rbPbJplG.d.ts +2341 -0
  42. package/dist/rfq-BJ8SC_Gp.d.cts +978 -0
  43. package/dist/rfq-BJ8SC_Gp.d.ts +978 -0
  44. package/dist/watch-CeVD4WnY.d.cts +74 -0
  45. package/dist/watch-CrVtt1pC.d.ts +74 -0
  46. package/package.json +12 -12
  47. package/dist/chunk-LYCMM3VB.js +0 -1357
  48. package/dist/chunk-OROIHWXD.js +0 -3162
  49. package/dist/chunk-U7VWWTL6.js +0 -66
  50. package/dist/errors-CcvUMXEF.d.cts +0 -2197
  51. package/dist/errors-Cwz3Xh72.d.ts +0 -2197
  52. package/dist/lockupContract-BvfhGH62.d.cts +0 -108
  53. package/dist/lockupContract-BvfhGH62.d.ts +0 -108
  54. package/dist/repository-B8MJY64N.d.cts +0 -3452
  55. package/dist/repository-BGlWfv3c.d.ts +0 -3452
  56. package/dist/rfq-CSgBQkjl.d.cts +0 -1099
  57. package/dist/rfq-CSgBQkjl.d.ts +0 -1099
  58. package/dist/watch-BjMc3SFo.d.cts +0 -96
  59. package/dist/watch-DkbPNiqf.d.ts +0 -96
package/README.md CHANGED
@@ -27,7 +27,7 @@ Each is one `quote` → `accept` chain. `quote` returns binding, verified terms
27
27
  durable; `accept` writes the record, then funds.
28
28
 
29
29
  ```ts
30
- const BTC = btcOn("arkade", "bitcoin"); // arkade:bitcoin/slip44:0
30
+ const BTC = btcOn("arkade", "bitcoin"); // arkade:bitcoin/slip44:0 (slip44:1 on test networks)
31
31
  const USDT = "arkade:bitcoin/asset:…";
32
32
 
33
33
  // arkade -> lightning: pay an invoice. The amount is the invoice's.
@@ -54,8 +54,13 @@ artifact is an invoice whose claim secret has to be durable before a payer can a
54
54
  off it would show a payer an invoice this client could not yet claim; the verb removes the
55
55
  ordering from the caller.
56
56
 
57
- `onchain -> arkade` is not in the union. It resolves and quotes to `UnsupportedRoute` until the
58
- client owns the trader's L1 refund path end to end.
57
+ `onchain -> arkade` is a receive too: `client.receive({ via: "onchain", amount })` returns a
58
+ `deposit` artifact naming the L1 HTLC to fund, for exactly its `amount`, from any bitcoin wallet.
59
+ The client claims the solver's Arkade lockup once it is funded. If the solver never funds it, the
60
+ client takes the L1 funding back itself once the HTLC's refund leaf matures, paying a boarding
61
+ address of this wallet fixed at quote time and signing with the wallet key the HTLC was derived
62
+ with. The refund is built at the same `claimFeeRateSatVb` as the `arkade -> onchain` claim; wire
63
+ your own with `corridors: { onchain: { refund } }`.
59
64
 
60
65
  An `arkade -> onchain` withdrawal claims the solver's L1 HTLC itself, and that claim's miner fee
61
66
  comes out of the HTLC output — so the client grosses the take leg up by the claim's cost and the
@@ -98,7 +103,7 @@ Asset ids are CAIP-19 with the rail as the CAIP-2 namespace, `<rail>:<network>/<
98
103
  ```ts
99
104
  const asset = canonicalAssetId("BTC", {
100
105
  network: "regtest",
101
- assets: [{ ticker: "BTC", id: "arkade:regtest/slip44:0" }],
106
+ assets: [{ ticker: "BTC", id: "arkade:regtest/slip44:1" }],
102
107
  });
103
108
  ```
104
109
 
@@ -179,6 +184,32 @@ though: a `Date` in a field you added comes back an ISO string, a `Set` or `Map`
179
184
  and a `bigint` throws on save. The package's own records are JSON-safe by design; keep yours that
180
185
  way too.
181
186
 
187
+ For bounded reads, all four backends provide `getAssetSwapsPage`,
188
+ `getRfqSwapsPage`, and `getSwapRecordsPage`. Pass `{ limit, after? }` with a
189
+ limit of 1–500, then use each result's `nextCursor` for the following page.
190
+ Asset swaps and swap records sort by ID. RFQ swaps sort by `(updatedAt, rfqId)`
191
+ and accept `{ state?, since? }`; `since` is inclusive Unix seconds. Keep the
192
+ filter fixed while paging. Repository collection reads use pages directly;
193
+ internal recovery and lifecycle paths consume every page before acting.
194
+ SDK transaction-history page `since` values use Unix milliseconds instead.
195
+ SQLite RFQ pages use a row-value comparison, so they need SQLite 3.15.0 or
196
+ newer.
197
+
198
+ ### Restore an imported wallet
199
+
200
+ Run the core wallet's `restore()` first (addresses, contracts, history), **then** create the client:
201
+
202
+ ```ts
203
+ await wallet.restore();
204
+ const client = createSwapClient({ wallet, repository: new IndexedDbAssetSwapRepository() });
205
+ await client.ready;
206
+ ```
207
+
208
+ `client.ready` rebuilds a record for every offer deposit in that history, with
209
+ `market: { kind: "restored" }`. A client created before `restore()` finishes rebuilds only what
210
+ history held at that moment, until its next construction. Corridor swaps a `0.0.x` client stored
211
+ are adopted the same way, with `backend: "rfq"`.
212
+
182
213
  ## Runtime requirements
183
214
 
184
215
  The one global the core requires is `crypto.getRandomValues`. Node and browsers have it; React