@arkade-os/swap 0.1.0 → 0.1.2

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 (31) hide show
  1. package/dist/advanced.cjs +150 -33
  2. package/dist/advanced.d.cts +10 -8
  3. package/dist/advanced.d.ts +10 -8
  4. package/dist/advanced.js +7 -3
  5. package/dist/{chunk-WKJFXXSR.js → chunk-BLECLU5Q.js} +91 -14
  6. package/dist/{chunk-FMRAV77W.js → chunk-ICSREL7N.js} +14 -12
  7. package/dist/{chunk-HRMWBULL.js → chunk-J2PMAQP2.js} +70 -25
  8. package/dist/index.cjs +146 -33
  9. package/dist/index.d.cts +5 -5
  10. package/dist/index.d.ts +5 -5
  11. package/dist/index.js +3 -3
  12. package/dist/{lockupContract-D7BNjksX.d.ts → lockupContract-CIXkJPxV.d.ts} +1 -1
  13. package/dist/{lockupContract-G-9CNRMq.d.cts → lockupContract-CkhWMKCo.d.cts} +1 -1
  14. package/dist/nostr.js +1 -1
  15. package/dist/{offer-DdB1M6FZ.d.ts → offer-BPD2ortO.d.ts} +1 -1
  16. package/dist/{offer-CcJfx5Fj.d.cts → offer-Diff5Flc.d.cts} +1 -1
  17. package/dist/{offerFillPlan-BII0PW92.d.cts → offerFillPlan-B-5ae_gQ.d.cts} +40 -11
  18. package/dist/{offerFillPlan-CNTLVD7j.d.ts → offerFillPlan-CJzneX6F.d.ts} +40 -11
  19. package/dist/protocol.cjs +99 -25
  20. package/dist/protocol.d.cts +6 -6
  21. package/dist/protocol.d.ts +6 -6
  22. package/dist/protocol.js +4 -4
  23. package/dist/repositories/realm/index.d.cts +1 -1
  24. package/dist/repositories/realm/index.d.ts +1 -1
  25. package/dist/repositories/sqlite/index.d.cts +1 -1
  26. package/dist/repositories/sqlite/index.d.ts +1 -1
  27. package/dist/{repository-DmPzpbd7.d.ts → repository-BBVRh9ez.d.ts} +17 -2
  28. package/dist/{repository-DqdLVrVv.d.cts → repository-C4pvymhs.d.cts} +17 -2
  29. package/dist/{watch-CmJQDtsy.d.ts → watch-7BiRa4oB.d.ts} +1 -1
  30. package/dist/{watch-BonYT9af.d.cts → watch-Bxq-lx_6.d.cts} +1 -1
  31. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -2998,7 +2998,8 @@ async function findLockupVtxos(contracts, swapPkScript) {
2998
2998
  txid: vtxo.txid,
2999
2999
  vout: vtxo.vout,
3000
3000
  value: Number(vtxo.value),
3001
- recoverable: vtxo.isSwept
3001
+ recoverable: vtxo.isSwept,
3002
+ ...vtxo.assets?.length ? { assets: vtxo.assets } : {}
3002
3003
  });
3003
3004
  }
3004
3005
  return out;
@@ -3008,17 +3009,17 @@ var candidateWitnessItems = (tx, inputIndex) => [
3008
3009
  ...(0, import_sdk8.getArkPsbtFields)(tx, inputIndex, import_sdk8.ConditionWitness).flat(),
3009
3010
  ...tx.getInput(inputIndex).finalScriptWitness ?? []
3010
3011
  ];
3011
- var spendsRefundLeaf = (tx, inputIndex) => {
3012
+ var refundLeafScript = (tx, inputIndex) => {
3012
3013
  const input = tx.getInput(inputIndex);
3013
3014
  const witness = input.finalScriptWitness;
3014
3015
  const leaves = input.tapLeafScript ?? [];
3015
3016
  const script = witness && witness.length >= 2 ? witness[witness.length - 2] : leaves.length === 1 ? (0, import_sdk8.scriptFromTapLeafScript)(leaves[0]) : void 0;
3016
- if (!script) return false;
3017
+ if (!script) return void 0;
3017
3018
  try {
3018
3019
  const { type } = (0, import_sdk8.decodeTapscript)(script);
3019
- return type === "multisig" || type === "csv-multisig" || type === "cltv-multisig";
3020
+ return type === "multisig" || type === "csv-multisig" || type === "cltv-multisig" ? script : void 0;
3020
3021
  } catch {
3021
- return false;
3022
+ return void 0;
3022
3023
  }
3023
3024
  };
3024
3025
  async function readLockupFate(indexer, input) {
@@ -3051,6 +3052,7 @@ async function readLockupFate(indexer, input) {
3051
3052
  const spends = [...spentBy.values()];
3052
3053
  const { txs } = await indexer.getVirtualTxs([...spentBy.keys()]);
3053
3054
  const refunded = /* @__PURE__ */ new Set();
3055
+ const leafScripts = /* @__PURE__ */ new Set();
3054
3056
  for (const raw of txs) {
3055
3057
  let tx;
3056
3058
  try {
@@ -3072,11 +3074,15 @@ async function readLockupFate(indexer, input) {
3072
3074
  return { fate: "claimed", preimage: candidate, spends };
3073
3075
  }
3074
3076
  }
3075
- if (spendsRefundLeaf(tx, i)) refunded.add(`${vtxo.txid}:${vtxo.vout}`);
3077
+ const leafScript = refundLeafScript(tx, i);
3078
+ if (leafScript) {
3079
+ refunded.add(`${vtxo.txid}:${vtxo.vout}`);
3080
+ leafScripts.add(import_base7.hex.encode(leafScript));
3081
+ }
3076
3082
  }
3077
3083
  }
3078
3084
  if (sweptLeft) return { fate: "open" };
3079
- return everySpendNamed && all.every((vtxo) => refunded.has(`${vtxo.txid}:${vtxo.vout}`)) ? { fate: "returned", spends } : { fate: "unknown" };
3085
+ return everySpendNamed && all.every((vtxo) => refunded.has(`${vtxo.txid}:${vtxo.vout}`)) ? { fate: "returned", spends, leafScripts: [...leafScripts] } : { fate: "unknown" };
3080
3086
  }
3081
3087
  var assertNoneSwept = (vtxos, contract) => {
3082
3088
  const swept = vtxos.filter((vtxo) => vtxo.recoverable);
@@ -3097,6 +3103,23 @@ var operatorUnrollScript = async (operator, network) => {
3097
3103
  };
3098
3104
  var MAX_LOCKUP_SPEND_INPUTS = 16;
3099
3105
  var boundedLockupSpend = (vtxos) => [...vtxos].sort((a, b) => b.value - a.value).slice(0, MAX_LOCKUP_SPEND_INPUTS);
3106
+ var lockupAssetOutputs = (vtxos) => {
3107
+ const inputs = /* @__PURE__ */ new Map();
3108
+ const totals = /* @__PURE__ */ new Map();
3109
+ vtxos.forEach((vtxo, vin) => {
3110
+ if (!vtxo.assets?.length) return;
3111
+ inputs.set(vin, [...vtxo.assets]);
3112
+ for (const { assetId, amount } of vtxo.assets) {
3113
+ totals.set(assetId, (totals.get(assetId) ?? 0n) + amount);
3114
+ }
3115
+ });
3116
+ if (inputs.size === 0) return [];
3117
+ const receiver = {
3118
+ address: "",
3119
+ assets: [...totals].map(([assetId, amount]) => ({ assetId, amount }))
3120
+ };
3121
+ return [import_sdk8.Extension.create([(0, import_sdk8.createAssetPacket)(inputs, [receiver])]).txOut()];
3122
+ };
3100
3123
  var lockupInputs = (vtxos, contract, leaf) => {
3101
3124
  const tapTree = contract.encode();
3102
3125
  return vtxos.map((vtxo) => ({
@@ -3122,7 +3145,7 @@ async function pushRefundWithoutReceiver(operator, input) {
3122
3145
  const amount = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
3123
3146
  const { arkTx: tx, checkpoints } = (0, import_sdk8.buildOffchainTx)(
3124
3147
  lockupInputs(vtxos, input.contract, leaf),
3125
- [{ script: refundPkScript, amount: BigInt(amount) }],
3148
+ [{ script: refundPkScript, amount: BigInt(amount) }, ...lockupAssetOutputs(vtxos)],
3126
3149
  serverUnrollScript
3127
3150
  );
3128
3151
  const signedTx = await input.sender.sign(tx);
@@ -3405,8 +3428,7 @@ var chainSourceFrom = (provider, network) => {
3405
3428
  }));
3406
3429
  },
3407
3430
  async getSpendingTx(txid, vout, pkScript) {
3408
- const outspends = await provider.getTxOutspends(txid);
3409
- const outspend = outspends[vout];
3431
+ const outspend = provider.getTxOutspend ? await provider.getTxOutspend(txid, vout) : (await provider.getTxOutspends(txid))[vout];
3410
3432
  if (!outspend?.spent) return null;
3411
3433
  const spender = outspend.txid || await spenderFromHistory(txid, vout, pkScript);
3412
3434
  if (!spender) return null;
@@ -3576,8 +3598,7 @@ var chainSourceOver = (backend, network) => {
3576
3598
  }));
3577
3599
  },
3578
3600
  async getSpendingTx(txid, vout, pkScript) {
3579
- const outspends = await backend.provider.getTxOutspends(txid);
3580
- const outspend = outspends[vout];
3601
+ const outspend = backend.provider.getTxOutspend ? await backend.provider.getTxOutspend(txid, vout) : (await backend.provider.getTxOutspends(txid))[vout];
3581
3602
  if (!outspend?.spent) return null;
3582
3603
  const spender = outspend.txid || await spenderFromVins(txid, vout, pkScript);
3583
3604
  if (!spender) return null;
@@ -5804,6 +5825,8 @@ var RFQ_SWAP_ACTIVE_STATES = [
5804
5825
  "needs_counterparty"
5805
5826
  ];
5806
5827
  var isRfqSwapTerminal = (state) => RFQ_SWAP_TERMINAL_STATES.includes(state);
5828
+ var isRecheckableRefundedSend = (record) => record.kind === "lightning_send" && record.state === "refunded" && !record.refundTxid;
5829
+ var isRfqSwapRestorable = (record) => !isRfqSwapTerminal(record.state) || isRecheckableRefundedSend(record);
5807
5830
 
5808
5831
  // src/rfqRecord.ts
5809
5832
  init_rfqCorridor();
@@ -6343,7 +6366,10 @@ async function pushClaim(operator, input) {
6343
6366
  provider: operator,
6344
6367
  inputs: lockupInputs(vtxos, input.contract, leaf),
6345
6368
  // One aggregate output: this leaf inspects nothing about the output set.
6346
- outputs: [{ script: input.destinationPkScript, amount: BigInt(locked) }],
6369
+ outputs: [
6370
+ { script: input.destinationPkScript, amount: BigInt(locked) },
6371
+ ...lockupAssetOutputs(vtxos)
6372
+ ],
6347
6373
  serverUnrollScript,
6348
6374
  verifyServerSignatures: { serverPubkey: input.contract.options.server }
6349
6375
  });
@@ -6792,6 +6818,46 @@ var RfqSwapManager = class _RfqSwapManager {
6792
6818
  }
6793
6819
  return { restored, failed, pruned: [] };
6794
6820
  }
6821
+ /**
6822
+ * Re-read stored `refunded` Lightning sends with no refund txid, one at a time. A misread
6823
+ * could have ended a settled send this way: a `claimed` read settles the record, any other
6824
+ * answer, or a failure, leaves it untouched. Returns the swaps it settled in every sink; one
6825
+ * a sink refused stays monitored for the poll to retry. `stopped` is checked before each
6826
+ * record and before each write, so a caller can walk away mid-run.
6827
+ */
6828
+ async recheckRefundedSends(options = {}) {
6829
+ const repository = this.requireRepository("recheckRefundedSends");
6830
+ const params = options.params ?? this.paramsFromContracts();
6831
+ const settled = [];
6832
+ for (const record of await collectRfqSwaps(repository, { state: "refunded" })) {
6833
+ if (options.stopped?.()) break;
6834
+ if (!isRecheckableRefundedSend(record) || this.monitored.has(record.rfqId)) continue;
6835
+ const removedAt = this.removed.get(record.rfqId);
6836
+ try {
6837
+ const swap = rebuildRfqSwap(record, await params(record));
6838
+ const fate = await readLockupFate(this.deps.indexer, {
6839
+ swapPkScript: swap.lockupPkScript,
6840
+ paymentHash: swap.paymentHash
6841
+ });
6842
+ if (options.stopped?.()) break;
6843
+ if (fate.fate !== "claimed") continue;
6844
+ if (this.monitored.has(record.rfqId)) continue;
6845
+ if (this.removed.get(record.rfqId) !== removedAt) continue;
6846
+ delete swap.lockupSpendTxids;
6847
+ this.stampLockupSpends(swap, fate.spends);
6848
+ this.stampSettlementPreimage(swap, fate.preimage);
6849
+ this.setState(swap, "settled");
6850
+ if (await this.save(swap)) {
6851
+ this.dirty.delete(swap.rfqId);
6852
+ settled.push(swap);
6853
+ } else {
6854
+ this.track(swap);
6855
+ }
6856
+ } catch {
6857
+ }
6858
+ }
6859
+ return settled;
6860
+ }
6795
6861
  /**
6796
6862
  * Drop stored records that are terminal and past `RFQ_SWAP_RETENTION_SECONDS` (per
6797
6863
  * `shouldRetainRfqSwap`), and return their ids. Explicit only: restore keeps history.
@@ -7158,6 +7224,7 @@ var RfqSwapManager = class _RfqSwapManager {
7158
7224
  * finalization and the per-swap lock belong to `pollSwap`.
7159
7225
  */
7160
7226
  async runPass(swap) {
7227
+ if (isRfqSwapTerminal(swap.state)) return;
7161
7228
  await this.ensureRegistered(swap);
7162
7229
  let fate;
7163
7230
  try {
@@ -7169,6 +7236,11 @@ var RfqSwapManager = class _RfqSwapManager {
7169
7236
  } catch {
7170
7237
  fate = { fate: "unknown" };
7171
7238
  }
7239
+ if ((swap.kind === "lightning_send" || swap.kind === "onchain_send") && fate.fate === "returned" && this.config.now() < swap.refundLocktime && !fate.leafScripts.every(
7240
+ (script) => script === swap.lockup?.script.nonInteractiveRefundScript
7241
+ )) {
7242
+ fate = { fate: "unknown" };
7243
+ }
7172
7244
  if (swap.kind === "onchain_receive") return this.driveOnchainReceive(swap, fate);
7173
7245
  if (fate.fate === "claimed" || fate.fate === "returned") {
7174
7246
  this.stampLockupSpends(swap, fate.spends);
@@ -7982,6 +8054,7 @@ var createSwapDrive = (config) => {
7982
8054
  let readyPromise;
7983
8055
  const inFlight2 = /* @__PURE__ */ new Set();
7984
8056
  let queue = Promise.resolve();
8057
+ let recheck;
7985
8058
  const track = (work) => {
7986
8059
  inFlight2.add(work);
7987
8060
  void work.then(
@@ -7999,6 +8072,7 @@ var createSwapDrive = (config) => {
7999
8072
  do {
8000
8073
  await queue;
8001
8074
  await Promise.allSettled([...inFlight2]);
8075
+ if (!disposed) await recheck;
8002
8076
  await watcher?.idle();
8003
8077
  } while (inFlight2.size > 0);
8004
8078
  };
@@ -8021,12 +8095,12 @@ var createSwapDrive = (config) => {
8021
8095
  storage(),
8022
8096
  remember,
8023
8097
  // Terminal records stay readable but are excluded from the manager's read, sparing
8024
- // a rebuild per record just to file it `finished`. The index still learns their
8025
- // `rfqId` (see `getRfqSwapsPage`).
8026
- (r) => !undrivable.has(r.id) && !isRfqSwapTerminal(r.state)
8098
+ // a rebuild per record just to file it `finished`, except a refunded send restore
8099
+ // re-reads. The index still learns their `rfqId` (see `getRfqSwapsPage`).
8100
+ (r) => !undrivable.has(r.id) && isRfqSwapRestorable(r)
8027
8101
  ),
8028
8102
  storage(),
8029
- (r) => !undrivableLegacy.has(r.rfqId) && !isRfqSwapTerminal(r.state)
8103
+ (r) => !undrivableLegacy.has(r.rfqId) && isRfqSwapRestorable(r)
8030
8104
  )
8031
8105
  );
8032
8106
  const effectiveState = (swap) => {
@@ -8475,8 +8549,9 @@ var createSwapDrive = (config) => {
8475
8549
  }
8476
8550
  }
8477
8551
  const liveCorridor = corridor.filter((record) => !isRfqSwapTerminal(record.state));
8552
+ const recheckable = corridor.filter(isRecheckableRefundedSend);
8478
8553
  const store = corridorStore();
8479
- for (const record of liveCorridor) store.index(record);
8554
+ for (const record of [...liveCorridor, ...recheckable]) store.index(record);
8480
8555
  const liveLegacy = await legacyLiveRfqSwaps(repository);
8481
8556
  if (liveCorridor.length > 0 || liveLegacy.length > 0) {
8482
8557
  try {
@@ -8523,6 +8598,17 @@ var createSwapDrive = (config) => {
8523
8598
  }
8524
8599
  }
8525
8600
  emitAll();
8601
+ if (mode !== "readonly" && recheckable.length > 0) {
8602
+ recheck = (async () => {
8603
+ try {
8604
+ await contractsOf();
8605
+ managerDeps.repository = store;
8606
+ await manager.recheckRefundedSends({ stopped: () => disposed });
8607
+ } catch (error) {
8608
+ console.warn("[swap] the refunded send re-read did not complete", error);
8609
+ }
8610
+ })();
8611
+ }
8526
8612
  };
8527
8613
  const ready = () => readyPromise ??= restore();
8528
8614
  const stop = async () => {
@@ -8706,14 +8792,22 @@ var publicAssetId = (corridor, assetId, network) => {
8706
8792
  if (!ARKADE_ASSET_IDENTITY.test(assetId)) return void 0;
8707
8793
  return `arkade:${network}/${ARKADE_ASSET_NAMESPACE}:${assetId}`;
8708
8794
  };
8795
+ var cardLegAssetId = (card, side, network) => {
8796
+ const corridor = corridorOfRail(marketCorridor(card, side));
8797
+ if (corridor === void 0) return void 0;
8798
+ const canonical = marketAssetId(card, side);
8799
+ if (canonical !== void 0 && isAssetId(canonical)) return canonical;
8800
+ return publicAssetId(
8801
+ corridor,
8802
+ (side === "base" ? card.base_asset : card.quote_asset).id,
8803
+ network
8804
+ );
8805
+ };
8709
8806
  var aliasTableFrom = (markets, network) => {
8710
8807
  const rows = /* @__PURE__ */ new Map();
8711
8808
  const add = (card, side) => {
8712
8809
  const info = side === "base" ? card.base_asset : card.quote_asset;
8713
- const corridor = corridorOfRail(marketCorridor(card, side));
8714
- if (corridor === void 0) return;
8715
- const canonical = marketAssetId(card, side);
8716
- const id = canonical !== void 0 && isAssetId(canonical) ? canonical : publicAssetId(corridor, info.id, network);
8810
+ const id = cardLegAssetId(card, side, network);
8717
8811
  if (id === void 0 || typeof info.ticker !== "string" || info.ticker === "") return;
8718
8812
  rows.set(`${id} ${info.ticker.toLowerCase()}`, { id, ticker: info.ticker });
8719
8813
  };
@@ -8801,6 +8895,18 @@ var cardMarketOf = (card, snapshot, key, backend) => ({
8801
8895
  pair: card.pair ?? marketPairLabel(card),
8802
8896
  snapshot
8803
8897
  });
8898
+ var marketLegOf = (card, side, network) => {
8899
+ const asset8 = cardLegAssetId(card, side, network);
8900
+ return {
8901
+ ...asset8 === void 0 ? {} : { asset: asset8 },
8902
+ decimals: (side === "base" ? card.base_asset : card.quote_asset).decimals,
8903
+ limits: (0, import_solver_discovery10.sideLimits)(card, side)
8904
+ };
8905
+ };
8906
+ var marketOf = (card, snapshot, network) => ({
8907
+ ...cardMarketOf(card, snapshot, marketKeyOf(card), marketBackendOf(card)),
8908
+ legs: [marketLegOf(card, "base", network), marketLegOf(card, "quote", network)]
8909
+ });
8804
8910
 
8805
8911
  // src/client/resolve.ts
8806
8912
  var SUPPORTED_PAIRS = [
@@ -9774,7 +9880,7 @@ var assetSidesOf = (legs) => {
9774
9880
  const giveIsBtc = legs.give.assetId === BTC_ASSET_ID;
9775
9881
  const takeIsBtc = legs.take.assetId === BTC_ASSET_ID;
9776
9882
  if (giveIsBtc && takeIsBtc) {
9777
- throw new UnsupportedRoute("arkade:BTC -> arkade:BTC moves one asset, it swaps nothing", {
9883
+ throw new UnsupportedRoute("give and take are both BTC, so the route swaps nothing", {
9778
9884
  give: "arkade",
9779
9885
  take: "arkade"
9780
9886
  });
@@ -9876,9 +9982,11 @@ var quoteLightningReceive = async (input) => {
9876
9982
  const pinned = pinnedFor(input);
9877
9983
  const pair = rfqPairFor(input.legs.give, input.legs.take);
9878
9984
  const rfqId = newRfqId();
9879
- const secrets = await (0, import_sdk35.provisionClaimSecret)(input.wallet);
9985
+ const [secrets, payoutAddress] = await Promise.all([
9986
+ (0, import_sdk35.provisionClaimSecret)(input.wallet),
9987
+ input.wallet.getAddress()
9988
+ ]);
9880
9989
  const paymentHash = import_base21.hex.encode(secrets.paymentHash);
9881
- const payoutAddress = await input.wallet.getAddress();
9882
9990
  const lightning = input.corridors.get("lightning").deps;
9883
9991
  const sealTo = sealingKey(lightning);
9884
9992
  const sealsAmount = pinned.on === "take" && input.legs.take.assetId === BTC_ASSET_ID;
@@ -9994,8 +10102,10 @@ var quoteOnchainSend = async (input) => {
9994
10102
  claimVsize: onchain.claimVsize
9995
10103
  }) : void 0;
9996
10104
  const quoted = claimFee === void 0 ? pinned : { on: pinned.on, value: pinned.value + claimFee, source: pinned.source };
9997
- const secrets = await (0, import_sdk35.provisionClaimSecret)(input.wallet);
9998
- const payoutKey = await (0, import_sdk35.provisionRefundKey)(input.wallet);
10105
+ const [secrets, payoutKey] = await Promise.all([
10106
+ (0, import_sdk35.provisionClaimSecret)(input.wallet),
10107
+ (0, import_sdk35.provisionRefundKey)(input.wallet)
10108
+ ]);
9999
10109
  const paymentHash = import_base21.hex.encode(secrets.paymentHash);
10000
10110
  const wire = await input.transport.requestQuote(
10001
10111
  withCanonicalAmount(
@@ -10101,11 +10211,14 @@ var quoteOnchainReceive = async (input) => {
10101
10211
  const pair = rfqPairFor(input.legs.give, input.legs.take);
10102
10212
  const rfqId = newRfqId();
10103
10213
  const l1Network = l1NetworkFromArk(input.info.network);
10104
- const secrets = await (0, import_sdk35.provisionClaimSecret)(input.wallet);
10105
- const refundKey = await (0, import_sdk35.provisionRefundKey)(input.wallet);
10214
+ const [secrets, refundKey, payoutAddress, boardingAddress] = await Promise.all([
10215
+ (0, import_sdk35.provisionClaimSecret)(input.wallet),
10216
+ (0, import_sdk35.provisionRefundKey)(input.wallet),
10217
+ input.wallet.getAddress(),
10218
+ input.wallet.getBoardingAddress()
10219
+ ]);
10106
10220
  const paymentHash = import_base21.hex.encode(secrets.paymentHash);
10107
- const payoutAddress = await input.wallet.getAddress();
10108
- const refundPkScript = l1ScriptForAddress(await input.wallet.getBoardingAddress(), l1Network);
10221
+ const refundPkScript = l1ScriptForAddress(boardingAddress, l1Network);
10109
10222
  const wire = await input.transport.requestQuote(
10110
10223
  withCanonicalAmount(
10111
10224
  onchainReceiveRequest({
@@ -10500,10 +10613,10 @@ var createSwapClient = (config) => {
10500
10613
  },
10501
10614
  markets: async () => {
10502
10615
  ensureLive("markets");
10503
- const { discovery } = await resolved();
10616
+ const { base, discovery } = await resolved();
10504
10617
  const snapshot = await discovery.load();
10505
10618
  return usableMarkets(snapshot, config.policy).map(
10506
- (card) => cardMarketOf(card, snapshot.ref, marketKeyOf(card), marketBackendOf(card))
10619
+ (card) => marketOf(card, snapshot.ref, base.networkName)
10507
10620
  );
10508
10621
  },
10509
10622
  pay: async (destination, options) => {
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, ac as OperatorUnreachable, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, aj as QuoteVerificationFailed, ak as REGISTRY_URL, al as ReceiveArtifact, am as ReceiveOptions, an as ReceiveRequest, ao as RecoveryResult, ap as RegisteredAsset, aq as RfqAuctionPolicy, au as RfqTransportFactory, aw as SWAP_ERROR_NAMES, ax as SwapClient, ay as SwapClientConfig, aB as SwapDriveRefusedError, aC as SwapError, aD as SwapErrorName, aE as SwapFilter, S as SwapPolicy, aF as UnsupportedRoute, aG as VerbDeps, aJ as buildOfferFillPlan, aL as canonicalAssetId, aR as createSwapClient, aT as deepFreeze, aU as digestJointGraph, aY as exchange, b2 as isSwapError, ba as pay, be as receive, bl as unsignedPsbtBytes, bn as verifyJointGraph, bo as verifyOfferFillPlan } from './offerFillPlan-BII0PW92.cjs';
2
- import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-DqdLVrVv.cjs';
3
- export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-DqdLVrVv.cjs';
1
+ export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, ad as OperatorUnreachable, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, av as RfqTransportFactory, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, S as SwapPolicy, aG as UnsupportedRoute, aH as VerbDeps, aK as buildOfferFillPlan, aM as canonicalAssetId, aS as createSwapClient, aU as deepFreeze, aV as digestJointGraph, aZ as exchange, b3 as isSwapError, bc as pay, bg as receive, bn as unsignedPsbtBytes, bp as verifyJointGraph, bq as verifyOfferFillPlan } from './offerFillPlan-B-5ae_gQ.cjs';
2
+ import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-C4pvymhs.cjs';
3
+ export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-C4pvymhs.cjs';
4
4
  export { C as ChainSource, I as InvoiceFacts, a as RFQ_REFUSAL_ERROR_CODES, b as RfqRefusalDetail, c as RfqRefusalErrorCode, d as RfqRefusalUnit, S as SwapRefusal, T as TxStatus, i as isRfqRefusalErrorCode } from './rfq-C0tHOvn6.cjs';
5
5
  import { PageRequest, PageResult, PaymentHandle, PaymentRail, RouterPreferences, Wallet, PaymentRouter, PaymentStatus } from '@arkade-os/sdk';
6
- export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-G-9CNRMq.cjs';
6
+ export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-CkhWMKCo.cjs';
7
7
  import '@arkade-os/solver-discovery';
8
- import './offer-CcJfx5Fj.cjs';
8
+ import './offer-Diff5Flc.cjs';
9
9
  import 'nostr-tools';
10
10
 
11
11
  /** Browser backend over the SDK's shared IndexedDB manager. */
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, ac as OperatorUnreachable, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, aj as QuoteVerificationFailed, ak as REGISTRY_URL, al as ReceiveArtifact, am as ReceiveOptions, an as ReceiveRequest, ao as RecoveryResult, ap as RegisteredAsset, aq as RfqAuctionPolicy, au as RfqTransportFactory, aw as SWAP_ERROR_NAMES, ax as SwapClient, ay as SwapClientConfig, aB as SwapDriveRefusedError, aC as SwapError, aD as SwapErrorName, aE as SwapFilter, S as SwapPolicy, aF as UnsupportedRoute, aG as VerbDeps, aJ as buildOfferFillPlan, aL as canonicalAssetId, aR as createSwapClient, aT as deepFreeze, aU as digestJointGraph, aY as exchange, b2 as isSwapError, ba as pay, be as receive, bl as unsignedPsbtBytes, bn as verifyJointGraph, bo as verifyOfferFillPlan } from './offerFillPlan-CNTLVD7j.js';
2
- import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-DmPzpbd7.js';
3
- export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-DmPzpbd7.js';
1
+ export { e as AcceptConflict, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, A as AssetAliasTable, B as BuildOfferFillPlanOpts, o as CancelOutcome, q as ClientDisposed, E as CorridorOverrides, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, d as DiscoverySnapshot, K as DiscoverySnapshotUnavailable, N as DriveMode, Q as ExchangeOptions, T as FeeCeiling, W as FillSponsor, X as FillSponsorFare, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a1 as Market, a2 as MarketLeg, a3 as MaxFeeExceeded, a4 as MissingCorridorDep, a5 as NotCancellable, a6 as OFFER_FILL_OWNERS, a7 as OFFER_FILL_TEMPLATE, ad as OperatorUnreachable, af as PayOptions, ag as PayResult, ah as QuoteCheck, ai as QuoteExpired, ak as QuoteVerificationFailed, al as REGISTRY_URL, am as ReceiveArtifact, an as ReceiveOptions, ao as ReceiveRequest, ap as RecoveryResult, aq as RegisteredAsset, ar as RfqAuctionPolicy, av as RfqTransportFactory, ax as SWAP_ERROR_NAMES, ay as SwapClient, az as SwapClientConfig, aC as SwapDriveRefusedError, aD as SwapError, aE as SwapErrorName, aF as SwapFilter, S as SwapPolicy, aG as UnsupportedRoute, aH as VerbDeps, aK as buildOfferFillPlan, aM as canonicalAssetId, aS as createSwapClient, aU as deepFreeze, aV as digestJointGraph, aZ as exchange, b3 as isSwapError, bc as pay, bg as receive, bn as unsignedPsbtBytes, bp as verifyJointGraph, bq as verifyOfferFillPlan } from './offerFillPlan-CJzneX6F.js';
2
+ import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b9 as MarketsCacheEntry, a7 as Outcome, ap as Swap, l as QuoteInput, i as RouteResolution, a9 as Quote, as as SwapUpdate, au as Unsubscribe } from './repository-BBVRh9ez.js';
3
+ export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, A as AssetId, v as AssetIdError, w as AssetIdRefusal, x as AssetNamespace, y as AssetOn, z as AssetPart, B as AssetPaymentInput, D as AssetPaymentTerms, E as AssetRef, F as AssetScale, G as AssetSwapId, H as AtomicDecimal, J as AuctionMarketRef, K as AuctionProvenance, M as BITCOIN_RAILS, T as BTC_ASSET_PART, U as BitcoinRail, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, b as CorridorSwapRecord, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, ba as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a4 as MarketBackend, a5 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a8 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, aa as QuoteLeg, ab as RAILS, R as Rail, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, j as ResolvedEndpoint, am as RestoredMarketRef, bb as RfqSwapState, k as Route, ao as SnapshotRef, bc as SwapContractRegistry, aq as SwapFamily, bd as SwapOperator, ar as SwapRecordCommon, at as TaxiIdentity, av as VerifiedCarrierTerms, aw as arkadeAsset, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, be as isRfqSwapTerminal, aT as issuanceOf, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, b4 as sameAsset, b6 as toAtomicDecimal } from './repository-BBVRh9ez.js';
4
4
  export { C as ChainSource, I as InvoiceFacts, a as RFQ_REFUSAL_ERROR_CODES, b as RfqRefusalDetail, c as RfqRefusalErrorCode, d as RfqRefusalUnit, S as SwapRefusal, T as TxStatus, i as isRfqRefusalErrorCode } from './rfq-C0tHOvn6.js';
5
5
  import { PageRequest, PageResult, PaymentHandle, PaymentRail, RouterPreferences, Wallet, PaymentRouter, PaymentStatus } from '@arkade-os/sdk';
6
- export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-D7BNjksX.js';
6
+ export { C as CLAIM_PACKET_TYPE, a as ClaimPacketShape, L as LockupRegistrationFailed, S as SEALED_CIPHERTEXT_LENGTH, b as appendArkadeScript, c as claimPacketShape } from './lockupContract-CIXkJPxV.js';
7
7
  import '@arkade-os/solver-discovery';
8
- import './offer-DdB1M6FZ.js';
8
+ import './offer-BPD2ortO.js';
9
9
  import 'nostr-tools';
10
10
 
11
11
  /** Browser backend over the SDK's shared IndexedDB manager. */
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  unsignedPsbtBytes,
63
63
  verifyJointGraph,
64
64
  verifyOfferFillPlan
65
- } from "./chunk-HRMWBULL.js";
65
+ } from "./chunk-J2PMAQP2.js";
66
66
  import {
67
67
  Amount,
68
68
  AmountFormatError,
@@ -73,7 +73,7 @@ import {
73
73
  isRfqSwapTerminal,
74
74
  quoteIdOfSwapId,
75
75
  toAtomicDecimal
76
- } from "./chunk-WKJFXXSR.js";
76
+ } from "./chunk-BLECLU5Q.js";
77
77
  import {
78
78
  CLAIM_PACKET_TYPE,
79
79
  LockupRegistrationFailed,
@@ -83,7 +83,7 @@ import {
83
83
  appendArkadeScript,
84
84
  claimPacketShape,
85
85
  isRfqRefusalErrorCode
86
- } from "./chunk-FMRAV77W.js";
86
+ } from "./chunk-ICSREL7N.js";
87
87
  import {
88
88
  InMemoryAssetSwapRepository,
89
89
  assertRfqSwapPageFilter,
@@ -1,4 +1,4 @@
1
- import { C as CoverageRegistrationOptions } from './offer-DdB1M6FZ.js';
1
+ import { C as CoverageRegistrationOptions } from './offer-BPD2ortO.js';
2
2
  import { VHTLC, IContractManager } from '@arkade-os/sdk';
3
3
 
4
4
  interface SealedClaimPacket {
@@ -1,4 +1,4 @@
1
- import { C as CoverageRegistrationOptions } from './offer-CcJfx5Fj.cjs';
1
+ import { C as CoverageRegistrationOptions } from './offer-Diff5Flc.cjs';
2
2
  import { VHTLC, IContractManager } from '@arkade-os/sdk';
3
3
 
4
4
  interface SealedClaimPacket {
package/dist/nostr.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  expectQuote,
3
3
  pairOf
4
- } from "./chunk-FMRAV77W.js";
4
+ } from "./chunk-ICSREL7N.js";
5
5
  import "./chunk-A3SHHRX4.js";
6
6
 
7
7
  // src/nostr.ts
@@ -1,5 +1,5 @@
1
1
  import { asset, RelativeTimelock, ArkadeInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
2
- import { d as AssetSwapRepository } from './repository-DmPzpbd7.js';
2
+ import { d as AssetSwapRepository } from './repository-BBVRh9ez.js';
3
3
 
4
4
  /**
5
5
  * Coverage: whether an offer's script is in the wallet's watched set. `createOffer` promotes; the
@@ -1,5 +1,5 @@
1
1
  import { asset, RelativeTimelock, ArkadeInfo, ArkTxInput, Outpoint, IWallet, EmulatorProvider, arkade } from '@arkade-os/sdk';
2
- import { d as AssetSwapRepository } from './repository-DqdLVrVv.cjs';
2
+ import { d as AssetSwapRepository } from './repository-C4pvymhs.cjs';
3
3
 
4
4
  /**
5
5
  * Coverage: whether an offer's script is in the wallet's watched set. `createOffer` promotes; the
@@ -1,8 +1,8 @@
1
1
  import { IWallet, NetworkName, Network, SignerSet, OnchainProvider, ArkadeInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret, Transaction } from '@arkade-os/sdk';
2
- import { bd as SwapOperator, d as AssetSwapRepository, m as Pubkey, bf as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, bg as RfqSwapActionName, N as NetworkRef, A as AssetId, ao as SnapshotRef, a4 as MarketBackend, X as CardMarketRef, a5 as MarketRef, E as AssetRef, r as AmountOn, ap as Swap, Y as CorridorId, _ as DepositArtifact, l as QuoteInput, a9 as Quote, ae as RankedBid, as as SwapUpdate, au as Unsubscribe, S as SwapRecord, Q as QuoteId, a7 as Outcome, L as LockupSpendIndexer, bc as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, D as AssetPaymentTerms, B as AssetPaymentInput, O as OfferSwapRecord, G as AssetSwapId, aq as SwapFamily, i as RouteResolution } from './repository-DqdLVrVv.cjs';
2
+ import { bd as SwapOperator, d as AssetSwapRepository, m as Pubkey, bf as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, bg as RfqSwapActionName, N as NetworkRef, A as AssetId, ao as SnapshotRef, a4 as MarketBackend, X as CardMarketRef, a5 as MarketRef, E as AssetRef, r as AmountOn, ap as Swap, Y as CorridorId, _ as DepositArtifact, l as QuoteInput, a9 as Quote, ae as RankedBid, as as SwapUpdate, au as Unsubscribe, S as SwapRecord, Q as QuoteId, a7 as Outcome, L as LockupSpendIndexer, bc as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, D as AssetPaymentTerms, B as AssetPaymentInput, O as OfferSwapRecord, G as AssetSwapId, aq as SwapFamily, i as RouteResolution } from './repository-C4pvymhs.cjs';
3
3
  import { I as InvoiceFacts, C as ChainSource, R as RfqQuote, e as RfqTransport, L as LightningSendContractParams, f as LightningReceiveContractParams, O as OnchainHtlc, g as OnchainHtlcParams, h as OnchainNetwork, S as SwapRefusal } from './rfq-C0tHOvn6.cjs';
4
4
  import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
5
- import { D as DerivedOffer, F as FillFunding, a as FillOutpoint, b as FillInputOwner } from './offer-CcJfx5Fj.cjs';
5
+ import { D as DerivedOffer, F as FillFunding, a as FillOutpoint, b as FillInputOwner } from './offer-Diff5Flc.cjs';
6
6
  import * as nostr_tools from 'nostr-tools';
7
7
 
8
8
  /**
@@ -498,7 +498,8 @@ declare const isAddressable: (card: DiscoveredMarket) => boolean;
498
498
  declare const marketBackendOf: (card: DiscoveredMarket) => MarketBackend;
499
499
  /**
500
500
  * The cards on a snapshot this client may act on at all: the policy's registry allowlist, then
501
- * addressability. Shared with `markets()` so it cannot offer a card the quote path would refuse.
501
+ * addressability. Shared with `markets()`; eligibility is not, so `markets()` can list a card
502
+ * `quote()` refuses.
502
503
  */
503
504
  declare const usableMarkets: (snapshot: DiscoverySnapshot, policy?: SwapPolicy) => DiscoveredMarket[];
504
505
  /**
@@ -529,12 +530,34 @@ declare const marketRefOf: (candidate: MarketCandidate, snapshot: SnapshotRef) =
529
530
  declare const cardMarketOf: (card: DiscoveredMarket, snapshot: SnapshotRef, key: string, backend: MarketBackend) => CardMarketRef;
530
531
  /** Narrow a `MarketRef` to the card arm — the only one `quote()` mints. */
531
532
  declare const isCardMarket: (market: MarketRef) => market is CardMarketRef;
533
+ /** One side of a {@link Market}. */
534
+ interface MarketLeg {
535
+ /** Absent when the leg has no public id, e.g. an `eip155:` leg. */
536
+ readonly asset?: AssetId;
537
+ /** For `Amount.format`. */
538
+ readonly decimals: number;
539
+ /**
540
+ * The card's announced bounds, in atomic units. Indicative: the solver can still refuse.
541
+ * `null`: the solver will not pay this leg out; a one-way card still routes it as the give leg.
542
+ * Only an amount pinned with `amountOn: "take"` is checked: a give-pinned amount still resolves,
543
+ * and a feed card still quotes it, even if the resulting take is out of range.
544
+ */
545
+ readonly limits: {
546
+ readonly min: bigint;
547
+ readonly max: bigint;
548
+ } | null;
549
+ }
532
550
  /**
533
- * A market as the v2 client publishes it — the same {@link CardMarketRef} a quote cites, so a
534
- * caller picking a market for a custom `quote()` reads the provenance the quote will carry.
535
- * Discovery's `DiscoveredMarket` never crosses the v2 root, so this carries no discovery asset id.
551
+ * A market as the v2 client publishes it: the {@link CardMarketRef} a quote would cite, plus its
552
+ * legs. Find a leg by `asset`, not position: they are in card order. The legs stay off
553
+ * `CardMarketRef` because that is written into durable records, which forbid `bigint`.
536
554
  */
537
- type Market = CardMarketRef;
555
+ interface Market extends CardMarketRef {
556
+ readonly legs: readonly [MarketLeg, MarketLeg];
557
+ }
558
+ /** A card as {@link Market}. `network` is the wallet's, as routing uses, so a legacy leg's id
559
+ * matches `resolve()` under a `DiscoveryConfig.network` override. */
560
+ declare const marketOf: (card: DiscoveredMarket, snapshot: SnapshotRef, network: NetworkRef) => Market;
538
561
 
539
562
  /**
540
563
  * The three product-facing verbs: `pay`, `receive` and `exchange` each compile a
@@ -1304,9 +1327,15 @@ interface SwapClient {
1304
1327
  */
1305
1328
  swaps(filter?: SwapFilter): Promise<Swap[]>;
1306
1329
  /**
1307
- * The markets a `quote()` could be priced against, in the `Quote.market` shape and under the same
1308
- * filters, so it cannot offer one `quote()` would refuse. Fetches when no snapshot is in hand, as
1309
- * `quote()` does, since callers reach for it BEFORE quoting.
1330
+ * The markets on the active snapshot, in the `Quote.market` shape plus each leg's announced
1331
+ * limits, with no RFQ and no disclosure. Shares `quote()`'s registry allowlist and addressability
1332
+ * filter but not its eligibility, so it can list a card `quote()` refuses. Fetches when no
1333
+ * snapshot is in hand, as `quote()` does, since callers reach for it BEFORE quoting.
1334
+ *
1335
+ * `key` is not unique: correlate with `resolve().market` on `key` + `source` + `discoveryPubkey`,
1336
+ * or `solver` on spot cards, which have no `discoveryPubkey`. These fields identify a solver's
1337
+ * market, not one card. A solver may publish several with different limits: `pair` separates a
1338
+ * flipped card, but nothing public separates fee tiers.
1310
1339
  *
1311
1340
  * @throws {DiscoverySnapshotUnavailable} when the fetch leaves it with
1312
1341
  * nothing either.
@@ -1639,4 +1668,4 @@ interface BuildOfferFillPlanOpts {
1639
1668
  declare function buildOfferFillPlan(wallet: IWallet, arkServerUrl: string, offerHex: string, opts: BuildOfferFillPlanOpts): Promise<JointGraph>;
1640
1669
  declare function verifyOfferFillPlan(plan: JointGraph): boolean;
1641
1670
 
1642
- export { type JointGraph as $, type AssetAliasTable as A, type BuildOfferFillPlanOpts as B, type CorridorFactory as C, type DiscoveryIndex as D, type CorridorOverrides as E, type CorridorPass as F, type CorridorRfqPreparation as G, DEFAULT_MAX_REFUND_WINDOW_SECONDS as H, type DiscoveryConfig as I, type DiscoveryIndexInput as J, DiscoverySnapshotUnavailable as K, type LightningCorridorDeps as L, type MarketCandidate as M, type DriveMode as N, type OnchainCorridorDeps as O, type DriveRefusal as P, type ExchangeOptions as Q, FEED_TTL_MS as R, type SwapPolicy as S, type FeeCeiling as T, type FeedFetch as U, type FeedQuoteInput as V, type FillSponsor as W, type FillSponsorFare as X, INDEXED_NETWORKS as Y, InconsistentRoute as Z, InsufficientFunds as _, type ArkadeCorridorDeps as a, isAddressable as a$, type LockupOwner as a0, type Market as a1, MaxFeeExceeded as a2, MissingCorridorDep as a3, NotCancellable as a4, OFFER_FILL_OWNERS as a5, OFFER_FILL_TEMPLATE as a6, ONCHAIN_CLAIM_FEE_RATE_SATVB as a7, type ObservationSeam as a8, type OfferPreparation as a9, type SwapDriveConfig as aA, SwapDriveRefusedError as aB, type SwapError as aC, type SwapErrorName as aD, type SwapFilter as aE, UnsupportedRoute as aF, type VerbDeps as aG, acceptQuote as aH, attesting as aI, buildOfferFillPlan as aJ, cancelSwap as aK, canonicalAssetId as aL, cardMarketOf as aM, chooseMarket as aN, conflictingFields as aO, corridorSet as aP, createNostrTransportFactory as aQ, createSwapClient as aR, createSwapDrive as aS, deepFreeze as aT, digestJointGraph as aU, discoveryIndex as aV, eligibleMarkets as aW, enforceFeeCeiling as aX, exchange as aY, feedFetch as aZ, feedSpread as a_, type OnchainClaim as aa, type OnchainRefund as ab, OperatorUnreachable as ac, type ParsedRfqQuote as ad, type PayOptions as ae, type PayResult as af, type QuoteCheck as ag, QuoteExpired as ah, type QuotePreparation as ai, QuoteVerificationFailed as aj, REGISTRY_URL as ak, type ReceiveArtifact as al, type ReceiveOptions as am, type ReceiveRequest as an, type RecoveryResult as ao, type RegisteredAsset as ap, type RfqAuctionPolicy as aq, type RfqPreparation as ar, type RfqQuoteInput as as, type RfqRendezvous as at, type RfqTransportFactory as au, type RouteSide as av, SWAP_ERROR_NAMES as aw, type SwapClient as ax, type SwapClientConfig as ay, type SwapDrive as az, type CorridorSet as b, isCardMarket as b0, isIndexedNetwork as b1, isSwapError as b2, isUsableCard as b3, liveArkadeInfo as b4, marketBackendOf as b5, marketKeyOf as b6, marketRefOf as b7, nostrTransportFactory as b8, parseRfqQuote as b9, pay as ba, quoteFromFeed as bb, quoteViaRfq as bc, readableRecord as bd, receive as be, resolveCorridorBase as bf, resolveCorridorDeps as bg, rfqLeg as bh, rfqPairFor as bi, swapRecordOf as bj, toDiscoveryLeg as bk, unsignedPsbtBytes as bl, usableMarkets as bm, verifyJointGraph as bn, verifyOfferFillPlan as bo, verifyPlanLegs as bp, withCanonicalAmount as bq, type DiscoveryLeg as c, type DiscoverySnapshot as d, AcceptConflict as e, type AcceptInput as f, type AcceptOptions as g, AmbiguousDestination as h, AmountEncodingUnsupported as i, AmountMismatch as j, type AssetRfqPreparation as k, type AttestingRfqTransport as l, CORRIDOR_FACTORIES as m, type CancelInput as n, type CancelOutcome as o, type ClaimedDestination as p, ClientDisposed as q, type CorridorBase as r, type CorridorClaim as s, type CorridorCovenant as t, type CorridorDeadline as u, type CorridorDeps as v, type CorridorDepsByCorridor as w, type CorridorDrive as x, type CorridorLockup as y, type CorridorModule as z };
1671
+ export { type JointGraph as $, type AssetAliasTable as A, type BuildOfferFillPlanOpts as B, type CorridorFactory as C, type DiscoveryIndex as D, type CorridorOverrides as E, type CorridorPass as F, type CorridorRfqPreparation as G, DEFAULT_MAX_REFUND_WINDOW_SECONDS as H, type DiscoveryConfig as I, type DiscoveryIndexInput as J, DiscoverySnapshotUnavailable as K, type LightningCorridorDeps as L, type MarketCandidate as M, type DriveMode as N, type OnchainCorridorDeps as O, type DriveRefusal as P, type ExchangeOptions as Q, FEED_TTL_MS as R, type SwapPolicy as S, type FeeCeiling as T, type FeedFetch as U, type FeedQuoteInput as V, type FillSponsor as W, type FillSponsorFare as X, INDEXED_NETWORKS as Y, InconsistentRoute as Z, InsufficientFunds as _, type ArkadeCorridorDeps as a, feedSpread as a$, type LockupOwner as a0, type Market as a1, type MarketLeg as a2, MaxFeeExceeded as a3, MissingCorridorDep as a4, NotCancellable as a5, OFFER_FILL_OWNERS as a6, OFFER_FILL_TEMPLATE as a7, ONCHAIN_CLAIM_FEE_RATE_SATVB as a8, type ObservationSeam as a9, type SwapDrive as aA, type SwapDriveConfig as aB, SwapDriveRefusedError as aC, type SwapError as aD, type SwapErrorName as aE, type SwapFilter as aF, UnsupportedRoute as aG, type VerbDeps as aH, acceptQuote as aI, attesting as aJ, buildOfferFillPlan as aK, cancelSwap as aL, canonicalAssetId as aM, cardMarketOf as aN, chooseMarket as aO, conflictingFields as aP, corridorSet as aQ, createNostrTransportFactory as aR, createSwapClient as aS, createSwapDrive as aT, deepFreeze as aU, digestJointGraph as aV, discoveryIndex as aW, eligibleMarkets as aX, enforceFeeCeiling as aY, exchange as aZ, feedFetch as a_, type OfferPreparation as aa, type OnchainClaim as ab, type OnchainRefund as ac, OperatorUnreachable as ad, type ParsedRfqQuote as ae, type PayOptions as af, type PayResult as ag, type QuoteCheck as ah, QuoteExpired as ai, type QuotePreparation as aj, QuoteVerificationFailed as ak, REGISTRY_URL as al, type ReceiveArtifact as am, type ReceiveOptions as an, type ReceiveRequest as ao, type RecoveryResult as ap, type RegisteredAsset as aq, type RfqAuctionPolicy as ar, type RfqPreparation as as, type RfqQuoteInput as at, type RfqRendezvous as au, type RfqTransportFactory as av, type RouteSide as aw, SWAP_ERROR_NAMES as ax, type SwapClient as ay, type SwapClientConfig as az, type CorridorSet as b, isAddressable as b0, isCardMarket as b1, isIndexedNetwork as b2, isSwapError as b3, isUsableCard as b4, liveArkadeInfo as b5, marketBackendOf as b6, marketKeyOf as b7, marketOf as b8, marketRefOf as b9, nostrTransportFactory as ba, parseRfqQuote as bb, pay as bc, quoteFromFeed as bd, quoteViaRfq as be, readableRecord as bf, receive as bg, resolveCorridorBase as bh, resolveCorridorDeps as bi, rfqLeg as bj, rfqPairFor as bk, swapRecordOf as bl, toDiscoveryLeg as bm, unsignedPsbtBytes as bn, usableMarkets as bo, verifyJointGraph as bp, verifyOfferFillPlan as bq, verifyPlanLegs as br, withCanonicalAmount as bs, type DiscoveryLeg as c, type DiscoverySnapshot as d, AcceptConflict as e, type AcceptInput as f, type AcceptOptions as g, AmbiguousDestination as h, AmountEncodingUnsupported as i, AmountMismatch as j, type AssetRfqPreparation as k, type AttestingRfqTransport as l, CORRIDOR_FACTORIES as m, type CancelInput as n, type CancelOutcome as o, type ClaimedDestination as p, ClientDisposed as q, type CorridorBase as r, type CorridorClaim as s, type CorridorCovenant as t, type CorridorDeadline as u, type CorridorDeps as v, type CorridorDepsByCorridor as w, type CorridorDrive as x, type CorridorLockup as y, type CorridorModule as z };