@arkade-os/swap 0.1.0-rc.26 → 0.1.0-rc.27

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 (38) hide show
  1. package/dist/advanced.cjs +199 -49
  2. package/dist/advanced.d.cts +8 -8
  3. package/dist/advanced.d.ts +8 -8
  4. package/dist/advanced.js +3 -3
  5. package/dist/{chunk-DHFKCTER.js → chunk-4X56MN56.js} +11 -2
  6. package/dist/{chunk-6O3L4AVI.js → chunk-BWUC2LDD.js} +28 -6
  7. package/dist/{chunk-XBMWEK43.js → chunk-VFZJNU27.js} +170 -120
  8. package/dist/index.cjs +199 -49
  9. package/dist/index.d.cts +6 -6
  10. package/dist/index.d.ts +6 -6
  11. package/dist/index.js +3 -3
  12. package/dist/{lockupContract-BTCE7g83.d.ts → lockupContract-CAjvaCVw.d.ts} +1 -1
  13. package/dist/{lockupContract-BTCGwjRH.d.cts → lockupContract-DZaNiqP-.d.cts} +1 -1
  14. package/dist/node/index.d.cts +9 -3
  15. package/dist/node/index.d.ts +9 -3
  16. package/dist/nostr.cjs +1 -0
  17. package/dist/nostr.d.cts +1 -1
  18. package/dist/nostr.d.ts +1 -1
  19. package/dist/nostr.js +1 -1
  20. package/dist/{offer-CsXgroM0.d.cts → offer-BwUhEawd.d.cts} +1 -1
  21. package/dist/{offer-DYCiKDm6.d.ts → offer-v7vBCPmQ.d.ts} +1 -1
  22. package/dist/{offerFillPlan-BQnzburi.d.ts → offerFillPlan-BGeAXIna.d.ts} +3 -3
  23. package/dist/{offerFillPlan-CFT8qgTV.d.cts → offerFillPlan-BYw1EWEj.d.cts} +3 -3
  24. package/dist/protocol.cjs +173 -118
  25. package/dist/protocol.d.cts +25 -39
  26. package/dist/protocol.d.ts +25 -39
  27. package/dist/protocol.js +8 -8
  28. package/dist/repositories/realm/index.d.cts +2 -2
  29. package/dist/repositories/realm/index.d.ts +2 -2
  30. package/dist/repositories/sqlite/index.d.cts +2 -2
  31. package/dist/repositories/sqlite/index.d.ts +2 -2
  32. package/dist/{repository-CSJXRd5N.d.ts → repository-D2emdY6f.d.cts} +51 -98
  33. package/dist/{repository-Bgn0apiL.d.cts → repository-YEQaxJro.d.ts} +51 -98
  34. package/dist/{rfq-m9tCbQx7.d.cts → rfq-CRiAHBBH.d.cts} +14 -2
  35. package/dist/{rfq-m9tCbQx7.d.ts → rfq-CRiAHBBH.d.ts} +14 -2
  36. package/dist/{watch-CLJXFpMq.d.cts → watch-BwbZkceT.d.cts} +1 -1
  37. package/dist/{watch-D0R7YhYg.d.ts → watch-CjEsO0Qh.d.ts} +1 -1
  38. package/package.json +2 -2
package/dist/advanced.cjs CHANGED
@@ -1399,6 +1399,13 @@ function onchainHtlcScript(params, network) {
1399
1399
  refundLocktime: params.refundLocktime
1400
1400
  };
1401
1401
  }
1402
+ function nextClaimFeeRate(input) {
1403
+ const last = input.lastSatVb;
1404
+ const estimate = Number.isFinite(input.estimateSatVb) ? input.estimateSatVb : 0;
1405
+ const wanted = last === void 0 ? Math.max(input.configuredSatVb, estimate) : input.bump ? Math.max(Math.ceil(last * 1.5), last + 1, estimate) : Math.max(last, estimate);
1406
+ const affordable = Number((input.utxoAmount - ONCHAIN_DUST_SATS) / BigInt(ONCHAIN_CLAIM_VSIZE));
1407
+ return Math.max(last ?? input.configuredSatVb, Math.min(wanted, affordable));
1408
+ }
1402
1409
  function extractPreimage(txHex, paymentHash) {
1403
1410
  let raw;
1404
1411
  try {
@@ -1415,7 +1422,7 @@ function extractPreimage(txHex, paymentHash) {
1415
1422
  }
1416
1423
  async function claimOnchainFill(chain, input) {
1417
1424
  const now = input.now ?? Math.floor(Date.now() / 1e3);
1418
- if (input.htlc.refundLocktime - now < ONCHAIN_CLAIM_MARGIN_SECONDS) {
1425
+ if (!input.republish && input.htlc.refundLocktime - now < ONCHAIN_CLAIM_MARGIN_SECONDS) {
1419
1426
  throw gateError(
1420
1427
  "claim_window_closed",
1421
1428
  "refund leaf opens too soon to claim safely \u2014 take the covenant refund instead"
@@ -1449,7 +1456,7 @@ async function classifyOnchainHtlc(chain, input) {
1449
1456
  if (mtp >= input.htlc.refundLocktime) return { phase: "refundable", utxo: best };
1450
1457
  return { phase: "claimable", utxo: best };
1451
1458
  }
1452
- var import_base4, import_sha22, import_legacy, btc, import_sdk5, ONCHAIN_ORDER_MARGIN_SECONDS, ONCHAIN_CLAIM_MARGIN_SECONDS, MAX_MIN_CONFIRMATIONS, LOCKTIME_THRESHOLD, ONCHAIN_SECONDS_PER_BLOCK, ONCHAIN_DUST_SATS, ONCHAIN_CLAIM_VSIZE, paymentHashOf, h160FromPaymentHash, assertPreimageMatches, gateError, L1_NETWORKS, l1ScriptForAddress, buildLeafSpend, buildHtlcClaim, buildHtlcRefund;
1459
+ var import_base4, import_sha22, import_legacy, btc, import_sdk5, ONCHAIN_ORDER_MARGIN_SECONDS, ONCHAIN_CLAIM_MARGIN_SECONDS, ONCHAIN_CLAIM_BUMP_SECONDS, MAX_MIN_CONFIRMATIONS, LOCKTIME_THRESHOLD, ONCHAIN_SECONDS_PER_BLOCK, ONCHAIN_DUST_SATS, ONCHAIN_CLAIM_VSIZE, paymentHashOf, h160FromPaymentHash, assertPreimageMatches, gateError, L1_NETWORKS, l1ScriptForAddress, buildLeafSpend, buildHtlcClaim, buildHtlcRefund;
1453
1460
  var init_onchainHtlc = __esm({
1454
1461
  "src/onchainHtlc.ts"() {
1455
1462
  "use strict";
@@ -1460,6 +1467,7 @@ var init_onchainHtlc = __esm({
1460
1467
  import_sdk5 = require("@arkade-os/sdk");
1461
1468
  ONCHAIN_ORDER_MARGIN_SECONDS = 2 * 60 * 60;
1462
1469
  ONCHAIN_CLAIM_MARGIN_SECONDS = 90 * 60;
1470
+ ONCHAIN_CLAIM_BUMP_SECONDS = 20 * 60;
1463
1471
  MAX_MIN_CONFIRMATIONS = 6;
1464
1472
  LOCKTIME_THRESHOLD = 5e8;
1465
1473
  ONCHAIN_SECONDS_PER_BLOCK = 600;
@@ -2780,7 +2788,9 @@ var OnchainSendCorridor = {
2780
2788
  return {
2781
2789
  expectedAmount: send.expectedAmount,
2782
2790
  ...send.funding ? { funding: send.funding } : {},
2783
- ...send.claimTxid ? { claimTxid: send.claimTxid } : {}
2791
+ ...send.claimTxid ? { claimTxid: send.claimTxid } : {},
2792
+ ...send.claimFeeRateSatVb === void 0 ? {} : { claimFeeRateSatVb: send.claimFeeRateSatVb },
2793
+ ...send.claimBroadcastAt === void 0 ? {} : { claimBroadcastAt: send.claimBroadcastAt }
2784
2794
  };
2785
2795
  },
2786
2796
  hydrate(profile) {
@@ -2825,7 +2835,9 @@ var OnchainSendCorridor = {
2825
2835
  // record would strand the refund it is still owed.
2826
2836
  ...profile.payoutPkScript ? { payoutPkScript: import_base5.hex.decode(profile.payoutPkScript) } : {},
2827
2837
  ...profile.funding ? { funding: profile.funding } : {},
2828
- ...profile.claimTxid ? { claimTxid: profile.claimTxid } : {}
2838
+ ...profile.claimTxid ? { claimTxid: profile.claimTxid } : {},
2839
+ ...typeof profile.claimFeeRateSatVb === "number" ? { claimFeeRateSatVb: profile.claimFeeRateSatVb } : {},
2840
+ ...typeof profile.claimBroadcastAt === "number" ? { claimBroadcastAt: profile.claimBroadcastAt } : {}
2829
2841
  };
2830
2842
  },
2831
2843
  // The trader claims the L1 HTLC with P, so this leg's preimage material is
@@ -4626,8 +4638,13 @@ async function readLockupFate(indexer, input) {
4626
4638
  }
4627
4639
  const spentBy = /* @__PURE__ */ new Map();
4628
4640
  let everySpendNamed = true;
4641
+ let sweptLeft = false;
4629
4642
  for (const vtxo of all) {
4630
- if (!(0, import_sdk14.isVtxoSpent)(vtxo)) return { fate: "open" };
4643
+ if (!(0, import_sdk14.isVtxoSpent)(vtxo)) {
4644
+ if (!(input.receiver && vtxo.isSwept)) return { fate: "open" };
4645
+ sweptLeft = true;
4646
+ continue;
4647
+ }
4631
4648
  if (vtxo.spentBy)
4632
4649
  spentBy.set(vtxo.spentBy, {
4633
4650
  checkpointTxid: vtxo.spentBy,
@@ -4658,6 +4675,7 @@ async function readLockupFate(indexer, input) {
4658
4675
  }
4659
4676
  }
4660
4677
  }
4678
+ if (sweptLeft) return { fate: "open" };
4661
4679
  return everySpendNamed && observed.size === spentBy.size ? { fate: "returned", spends } : { fate: "unknown" };
4662
4680
  }
4663
4681
  var assertNoneSwept = (vtxos, contract) => {
@@ -4678,6 +4696,8 @@ var operatorUnrollScript = async (operator, network) => {
4678
4696
  })
4679
4697
  );
4680
4698
  };
4699
+ var MAX_LOCKUP_SPEND_INPUTS = 16;
4700
+ var boundedLockupSpend = (vtxos) => [...vtxos].sort((a, b) => b.value - a.value).slice(0, MAX_LOCKUP_SPEND_INPUTS);
4681
4701
  var lockupInputs = (vtxos, contract, leaf) => {
4682
4702
  const tapTree = contract.encode();
4683
4703
  return vtxos.map((vtxo) => ({
@@ -4699,9 +4719,10 @@ async function pushRefundWithoutReceiver(operator, input) {
4699
4719
  }
4700
4720
  const serverUnrollScript = await operatorUnrollScript(operator, input.network);
4701
4721
  const leaf = input.contract.refundWithoutReceiver();
4702
- const amount = input.vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
4722
+ const vtxos = boundedLockupSpend(input.vtxos);
4723
+ const amount = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
4703
4724
  const { arkTx: tx, checkpoints } = (0, import_sdk14.buildOffchainTx)(
4704
- lockupInputs(input.vtxos, input.contract, leaf),
4725
+ lockupInputs(vtxos, input.contract, leaf),
4705
4726
  [{ script: refundPkScript, amount: BigInt(amount) }],
4706
4727
  serverUnrollScript
4707
4728
  );
@@ -4722,7 +4743,12 @@ async function pushRefundWithoutReceiver(operator, input) {
4722
4743
  )
4723
4744
  );
4724
4745
  await operator.finalizeTx(submitted.arkTxid, finalCheckpoints);
4725
- return { txid: submitted.arkTxid, amount };
4746
+ return {
4747
+ txid: submitted.arkTxid,
4748
+ amount,
4749
+ left: input.vtxos.length - vtxos.length,
4750
+ spent: vtxos
4751
+ };
4726
4752
  }
4727
4753
  var REFUND_MTP_LAG_SECONDS = 2 * 60 * 60;
4728
4754
 
@@ -4835,6 +4861,12 @@ var chainSourceOver = (backend, network) => {
4835
4861
  },
4836
4862
  async getMtp() {
4837
4863
  return (await backend.tip()).mtp;
4864
+ },
4865
+ async getTxStatus(txid) {
4866
+ return (await backend.provider.getTxStatus(txid)).confirmed ? "confirmed" : "unconfirmed";
4867
+ },
4868
+ getFeeRate() {
4869
+ return backend.provider.getFeeRate();
4838
4870
  }
4839
4871
  };
4840
4872
  };
@@ -6047,28 +6079,31 @@ var assertFiniteAmount = (value, reason, label) => {
6047
6079
  };
6048
6080
  async function pushClaim(operator, input) {
6049
6081
  if (input.vtxos.length === 0) throw new Error("nothing to claim: no funded outputs");
6050
- assertNoneSwept(input.vtxos, input.contract);
6051
- const locked = input.vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
6052
- assertFiniteAmount(locked, "lockup_malformed", "the lockup's summed value");
6082
+ const live = input.vtxos.filter((vtxo) => !vtxo.recoverable);
6083
+ if (live.length === 0) assertNoneSwept(input.vtxos, input.contract);
6084
+ const funded = live.reduce((sum, vtxo) => sum + vtxo.value, 0);
6085
+ assertFiniteAmount(funded, "lockup_malformed", "the lockup's summed value");
6053
6086
  if (!input.partiallyClaimed) {
6054
6087
  assertFiniteAmount(input.expectedAmount, "invalid_gate_input", "expectedAmount");
6055
- if (locked < input.expectedAmount) {
6056
- throw new LockupAmountMismatchError(input.expectedAmount, locked);
6088
+ if (funded < input.expectedAmount) {
6089
+ throw new LockupAmountMismatchError(input.expectedAmount, funded);
6057
6090
  }
6058
6091
  }
6092
+ const vtxos = boundedLockupSpend(live);
6093
+ const locked = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
6059
6094
  assertPreimageMatches(input.preimage, input.contract.options.preimageHash);
6060
6095
  const serverUnrollScript = await operatorUnrollScript(operator, input.network);
6061
6096
  const leaf = input.contract.claim();
6062
6097
  const txid = await (0, import_sdk25.signAndSubmitOffchainTx)({
6063
6098
  identity: (0, import_sdk25.claimWithPreimageIdentity)(input.receiver, input.preimage),
6064
6099
  provider: operator,
6065
- inputs: lockupInputs(input.vtxos, input.contract, leaf),
6100
+ inputs: lockupInputs(vtxos, input.contract, leaf),
6066
6101
  // One aggregate output: this leaf inspects nothing about the output set.
6067
6102
  outputs: [{ script: input.destinationPkScript, amount: BigInt(locked) }],
6068
6103
  serverUnrollScript,
6069
6104
  verifyServerSignatures: { serverPubkey: input.contract.options.server }
6070
6105
  });
6071
- return { txid, amount: locked };
6106
+ return { txid, amount: locked, left: live.length - vtxos.length, spent: vtxos };
6072
6107
  }
6073
6108
 
6074
6109
  // src/client/drive.ts
@@ -6118,6 +6153,8 @@ async function senderIdentityForSwapRecord(wallet, record) {
6118
6153
  // src/arkadeRefunder.ts
6119
6154
  init_rfqProfileParts();
6120
6155
  function arkadeRefunder(deps) {
6156
+ const spentBy = /* @__PURE__ */ new Map();
6157
+ const keyOf = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
6121
6158
  return async (swap) => {
6122
6159
  const contract = swap.lockup?.script;
6123
6160
  if (!contract) {
@@ -6125,7 +6162,10 @@ function arkadeRefunder(deps) {
6125
6162
  `swap ${swap.rfqId} carries no lockup covenant, so its refund cannot be built`
6126
6163
  );
6127
6164
  }
6128
- const vtxos = await findLockupVtxos(deps.contracts, swap.lockupPkScript);
6165
+ const done = spentBy.get(swap.rfqId);
6166
+ const vtxos = (await findLockupVtxos(deps.contracts, swap.lockupPkScript)).filter(
6167
+ (vtxo) => !done?.has(keyOf(vtxo))
6168
+ );
6129
6169
  if (vtxos.length === 0) return null;
6130
6170
  const record = await deps.repository.getRfqSwap(swap.rfqId);
6131
6171
  if (!record) {
@@ -6135,12 +6175,16 @@ function arkadeRefunder(deps) {
6135
6175
  );
6136
6176
  }
6137
6177
  const sender = await senderIdentityForSwapRecord(deps.wallet, rfqSignerOf(record) ?? {});
6138
- return pushRefundWithoutReceiver(deps.operator, {
6178
+ const result = await pushRefundWithoutReceiver(deps.operator, {
6139
6179
  contract,
6140
6180
  sender,
6141
6181
  vtxos,
6142
6182
  network: await deps.network?.()
6143
6183
  });
6184
+ if (result.left > 0 || done) {
6185
+ spentBy.set(swap.rfqId, /* @__PURE__ */ new Set([...done ?? [], ...result.spent.map(keyOf)]));
6186
+ }
6187
+ return result;
6144
6188
  };
6145
6189
  }
6146
6190
 
@@ -6587,7 +6631,7 @@ var RfqSwapManager = class _RfqSwapManager {
6587
6631
  }
6588
6632
  if (!swap) throw new Error(`swap ${rfqId} is not monitored`);
6589
6633
  if (swap.state === "failed") throw new Error(swap.failure ?? `swap ${rfqId} failed`);
6590
- if (isPayoutDecided(swap)) return outcomeOf(swap);
6634
+ if (isPayoutDecided(swap, this.reportsConfirmations)) return outcomeOf(swap);
6591
6635
  return new Promise((resolve, reject) => {
6592
6636
  const set = this.waiters.get(rfqId) ?? /* @__PURE__ */ new Set();
6593
6637
  set.add({ resolve, reject });
@@ -6739,7 +6783,8 @@ var RfqSwapManager = class _RfqSwapManager {
6739
6783
  try {
6740
6784
  fate = await readLockupFate(this.deps.indexer, {
6741
6785
  swapPkScript: swap.lockupPkScript,
6742
- paymentHash: swap.paymentHash
6786
+ paymentHash: swap.paymentHash,
6787
+ receiver: swap.kind === "lightning_receive" || swap.kind === "onchain_receive"
6743
6788
  });
6744
6789
  } catch {
6745
6790
  fate = { fate: "unknown" };
@@ -6748,6 +6793,9 @@ var RfqSwapManager = class _RfqSwapManager {
6748
6793
  if (fate.fate === "claimed" || fate.fate === "returned") {
6749
6794
  this.stampLockupSpends(swap, fate.spends);
6750
6795
  if (fate.fate === "claimed") this.stampSettlementPreimage(swap, fate.preimage);
6796
+ if (swap.kind === "onchain_send" && fate.fate === "claimed" && this.deps.chain) {
6797
+ return this.driveOnchainPayout(swap);
6798
+ }
6751
6799
  this.setState(swap, fate.fate === "claimed" ? "settled" : "refunded");
6752
6800
  return;
6753
6801
  }
@@ -6757,7 +6805,7 @@ var RfqSwapManager = class _RfqSwapManager {
6757
6805
  if (this.config.now() >= swap.refundLocktime) return this.driveReceiveClaim(swap);
6758
6806
  return;
6759
6807
  }
6760
- if (swap.kind === "onchain_send" && swap.state !== "claimed") {
6808
+ if (swap.kind === "onchain_send") {
6761
6809
  if (await this.driveOnchain(swap) === "handled") return;
6762
6810
  }
6763
6811
  if (fate.fate === "exited") {
@@ -6819,7 +6867,8 @@ var RfqSwapManager = class _RfqSwapManager {
6819
6867
  async claimIfFunded(swap, vtxos) {
6820
6868
  if (vtxos.length === 0) return this.unblock(swap);
6821
6869
  const partiallyClaimed = swap.claimTxid !== void 0;
6822
- if (partiallyClaimed && !this.hasUnclaimedOutpoint(swap.rfqId, vtxos)) {
6870
+ const toClaim = partiallyClaimed ? this.unclaimed(swap.rfqId, vtxos) : vtxos;
6871
+ if (toClaim.length === 0) {
6823
6872
  return;
6824
6873
  }
6825
6874
  if (!partiallyClaimed) {
@@ -6846,9 +6895,11 @@ var RfqSwapManager = class _RfqSwapManager {
6846
6895
  this.setState(swap, "claimable");
6847
6896
  if (!this.config.enableAutoActions) return;
6848
6897
  try {
6849
- const { txid } = await this.callbacks.claimLockup(swap, vtxos, { partiallyClaimed });
6898
+ const { txid, spent } = await this.callbacks.claimLockup(swap, toClaim, {
6899
+ partiallyClaimed
6900
+ });
6850
6901
  delete swap.claimFailure;
6851
- this.rememberClaimed(swap.rfqId, vtxos);
6902
+ this.rememberClaimed(swap.rfqId, spent ?? toClaim);
6852
6903
  swap.claimTxid = txid;
6853
6904
  this.touch(swap);
6854
6905
  this.setState(swap, "claimed");
@@ -6955,7 +7006,51 @@ var RfqSwapManager = class _RfqSwapManager {
6955
7006
  }
6956
7007
  return { verdict: "live", attempted: true };
6957
7008
  }
6958
- /** `handled` ends the pass; `continue` falls through to the refund gate. */
7009
+ /** The solver has `P` and the lockup; the trader's payout is the L1 claim alone. */
7010
+ async driveOnchainPayout(swap) {
7011
+ const l1 = await this.driveOnchain(swap);
7012
+ if (isRfqSwapTerminal(swap.state)) return;
7013
+ if (l1 === "swept") {
7014
+ return this.fail(
7015
+ swap,
7016
+ new Error(
7017
+ `the solver claimed the Arkade lockup and its L1 refund took the fill \u2014 the claim ${swap.claimTxid ?? ""} was replaced before it confirmed`
7018
+ )
7019
+ );
7020
+ }
7021
+ const confirmed = await this.readClaimConfirmed(swap);
7022
+ if (this.reportsConfirmations ? confirmed !== true : confirmed === false) return;
7023
+ this.setState(swap, "settled");
7024
+ }
7025
+ get reportsConfirmations() {
7026
+ return this.deps.chain?.getTxStatus !== void 0;
7027
+ }
7028
+ async claimVanished(txid) {
7029
+ const chain = this.deps.chain;
7030
+ if (!chain?.getTxStatus) return false;
7031
+ try {
7032
+ return await chain.getTxStatus(txid) === "missing";
7033
+ } catch {
7034
+ return true;
7035
+ }
7036
+ }
7037
+ /** Stamped on the swap for {@link isPayoutDecided}; `undefined` when it cannot be read. */
7038
+ async readClaimConfirmed(swap) {
7039
+ const chain = this.deps.chain;
7040
+ if (!chain?.getTxStatus || !swap.claimTxid) return void 0;
7041
+ let confirmed;
7042
+ try {
7043
+ confirmed = await chain.getTxStatus(swap.claimTxid) === "confirmed";
7044
+ } catch {
7045
+ confirmed = false;
7046
+ }
7047
+ if (confirmed !== swap.claimConfirmed) {
7048
+ swap.claimConfirmed = confirmed;
7049
+ this.touch(swap);
7050
+ }
7051
+ return confirmed;
7052
+ }
7053
+ /** `handled` ends the pass; `continue` and `swept` fall through to the refund gate. */
6959
7054
  async driveOnchain(swap) {
6960
7055
  if (!this.deps.chain) {
6961
7056
  this.fail(
@@ -6976,17 +7071,27 @@ var RfqSwapManager = class _RfqSwapManager {
6976
7071
  } catch {
6977
7072
  return "continue";
6978
7073
  }
6979
- if ("utxo" in phase && !swap.funding) {
6980
- swap.funding = { txid: phase.utxo.txid, vout: phase.utxo.vout };
7074
+ if ("utxo" in phase && swap.funding?.amount === void 0) {
7075
+ swap.funding = {
7076
+ txid: phase.utxo.txid,
7077
+ vout: phase.utxo.vout,
7078
+ amount: Number(phase.utxo.amount)
7079
+ };
6981
7080
  this.touch(swap);
6982
7081
  }
7082
+ if (swap.claimTxid && (phase.phase === "claimable" || phase.phase === "refundable")) {
7083
+ const due = this.reportsConfirmations && this.config.now() - (swap.claimBroadcastAt ?? 0) >= ONCHAIN_CLAIM_BUMP_SECONDS;
7084
+ if (due || await this.claimVanished(swap.claimTxid)) {
7085
+ await this.pushOnchainClaim(swap, phase.utxo, due);
7086
+ }
7087
+ return "continue";
7088
+ }
6983
7089
  const action = nextOnchainAction({
6984
7090
  phase,
6985
7091
  htlcLocktime: swap.htlc.refundLocktime,
6986
7092
  now: this.config.now()
6987
7093
  });
6988
7094
  if (action === "claim" && phase.phase === "claimable") {
6989
- if (swap.claimTxid) return "continue";
6990
7095
  if (!Number.isSafeInteger(swap.expectedAmount) || swap.expectedAmount <= 0) {
6991
7096
  this.block(
6992
7097
  swap,
@@ -7007,26 +7112,55 @@ var RfqSwapManager = class _RfqSwapManager {
7007
7112
  return "handled";
7008
7113
  }
7009
7114
  this.setOnchainState(swap, "claimable");
7010
- if (!this.config.enableAutoActions || !this.callbacks?.claimOnchain) return "handled";
7011
- try {
7012
- const { txid } = await this.callbacks.claimOnchain(swap, phase.utxo);
7013
- swap.claimTxid = txid;
7014
- this.setOnchainState(swap, "claimed");
7015
- this.emitAction(swap, "claimOnchain");
7016
- } catch (error) {
7017
- this.emitFailed(swap, error);
7018
- }
7019
- return "handled";
7115
+ return this.pushOnchainClaim(swap, phase.utxo, false);
7020
7116
  }
7021
7117
  if (action === "claimed" && phase.phase === "claimed") {
7022
- if (!swap.claimTxid) {
7118
+ if (swap.claimTxid !== phase.txid) {
7023
7119
  swap.claimTxid = phase.txid;
7024
7120
  this.touch(swap);
7025
7121
  }
7026
7122
  this.setOnchainState(swap, "claimed");
7123
+ await this.bumpOnchainClaim(swap);
7124
+ return "continue";
7027
7125
  }
7126
+ if (phase.phase === "swept") return "swept";
7028
7127
  return "continue";
7029
7128
  }
7129
+ /** Build and broadcast a claim. The bump clock restarts on every broadcast, same-txid
7130
+ * re-publications included, or a claim at the dust ceiling would go out every pass. */
7131
+ async pushOnchainClaim(swap, utxo, bump) {
7132
+ if (!this.config.enableAutoActions || !this.callbacks?.claimOnchain) return "handled";
7133
+ try {
7134
+ const { txid, feeRateSatVb } = await this.callbacks.claimOnchain(
7135
+ swap,
7136
+ utxo,
7137
+ bump ? { bump } : void 0
7138
+ );
7139
+ swap.claimTxid = txid;
7140
+ swap.claimBroadcastAt = this.config.now();
7141
+ delete swap.claimConfirmed;
7142
+ if (feeRateSatVb !== void 0) swap.claimFeeRateSatVb = feeRateSatVb;
7143
+ this.touch(swap);
7144
+ this.setOnchainState(swap, "claimed");
7145
+ this.emitAction(swap, "claimOnchain");
7146
+ } catch (error) {
7147
+ this.emitFailed(swap, error);
7148
+ }
7149
+ return "handled";
7150
+ }
7151
+ /** Replace a claim that is not confirming, before median-time-past opens the solver's
7152
+ * refund leaf. Needs `getTxStatus`: blind, it would replace claims that already landed. */
7153
+ async bumpOnchainClaim(swap) {
7154
+ if (await this.readClaimConfirmed(swap) !== false) return;
7155
+ const funding = swap.funding;
7156
+ if (funding?.amount === void 0) return;
7157
+ if (this.config.now() - (swap.claimBroadcastAt ?? 0) < ONCHAIN_CLAIM_BUMP_SECONDS) return;
7158
+ await this.pushOnchainClaim(
7159
+ swap,
7160
+ { ...funding, amount: BigInt(funding.amount), confirmations: 0 },
7161
+ true
7162
+ );
7163
+ }
7030
7164
  async driveArkadeRefund(swap) {
7031
7165
  const now = this.config.now();
7032
7166
  const refusal = await this.probeRefusal(swap);
@@ -7052,6 +7186,7 @@ var RfqSwapManager = class _RfqSwapManager {
7052
7186
  if (pushed) {
7053
7187
  swap.refundTxid = pushed.txid;
7054
7188
  this.touch(swap);
7189
+ if (pushed.left) return;
7055
7190
  } else if (now < swap.refundLocktime + REFUND_MTP_LAG_SECONDS) {
7056
7191
  return;
7057
7192
  }
@@ -7062,6 +7197,8 @@ var RfqSwapManager = class _RfqSwapManager {
7062
7197
  this.refundRefused.add(swap.rfqId);
7063
7198
  return this.block(swap, error.message);
7064
7199
  }
7200
+ const ark = (0, import_sdk27.isArkError)(error) ? error : (0, import_sdk27.maybeArkError)(error);
7201
+ if ((0, import_sdk27.isArkError)(ark, import_sdk27.ArkErrorName.VTXO_ALREADY_SPENT)) return;
7065
7202
  this.emitFailed(swap, error);
7066
7203
  if (now >= swap.refundLocktime + REFUND_MTP_LAG_SECONDS) {
7067
7204
  swap.failure = errorMessage(error);
@@ -7069,12 +7206,10 @@ var RfqSwapManager = class _RfqSwapManager {
7069
7206
  }
7070
7207
  }
7071
7208
  }
7072
- /** Whether any output was never handed to the claim callback (the only reason to
7073
- * claim twice). */
7074
- hasUnclaimedOutpoint(rfqId, vtxos) {
7209
+ /** The outputs no claim of ours has taken yet (the only reason to claim twice). */
7210
+ unclaimed(rfqId, vtxos) {
7075
7211
  const claimed = this.claimedOutpoints.get(rfqId);
7076
- if (!claimed) return true;
7077
- return vtxos.some((vtxo) => !claimed.has(outpointKey(vtxo)));
7212
+ return claimed ? vtxos.filter((vtxo) => !claimed.has(outpointKey(vtxo))) : vtxos;
7078
7213
  }
7079
7214
  rememberClaimed(rfqId, vtxos) {
7080
7215
  const claimed = this.claimedOutpoints.get(rfqId) ?? /* @__PURE__ */ new Set();
@@ -7224,7 +7359,7 @@ var RfqSwapManager = class _RfqSwapManager {
7224
7359
  if (swap.state === "failed") {
7225
7360
  const error = new Error(swap.failure ?? `swap ${swap.rfqId} failed`);
7226
7361
  for (const waiter of waiting) waiter.reject(error);
7227
- } else if (isPayoutDecided(swap)) {
7362
+ } else if (isPayoutDecided(swap, this.reportsConfirmations)) {
7228
7363
  const outcome = outcomeOf(swap);
7229
7364
  for (const waiter of waiting) waiter.resolve(outcome);
7230
7365
  } else {
@@ -7234,7 +7369,7 @@ var RfqSwapManager = class _RfqSwapManager {
7234
7369
  }
7235
7370
  };
7236
7371
  var traderClaimTxid = (swap) => swap.kind === "lightning_send" ? void 0 : swap.claimTxid;
7237
- var isPayoutDecided = (swap) => swap.state === "settled" || swap.state === "refunded" || swap.kind === "onchain_send" && swap.claimTxid !== void 0;
7372
+ var isPayoutDecided = (swap, confirmations = false) => swap.state === "settled" || swap.state === "refunded" || swap.kind === "onchain_send" && swap.claimTxid !== void 0 && (confirmations ? swap.claimConfirmed === true : true);
7238
7373
  var outcomeOf = (swap) => {
7239
7374
  const lostReceive = (swap.kind === "lightning_receive" || swap.kind === "onchain_receive") && swap.state === "refunded";
7240
7375
  return {
@@ -7599,8 +7734,15 @@ var createSwapDrive = (config) => {
7599
7734
  touch(swap.rfqId, swap);
7600
7735
  });
7601
7736
  let onchainSeams;
7737
+ const liveFeeRate = async (chain) => {
7738
+ try {
7739
+ return await chain.getFeeRate?.();
7740
+ } catch {
7741
+ return void 0;
7742
+ }
7743
+ };
7602
7744
  const defaultOnchainClaim = (chain, feeRateSatVb) => {
7603
- return async (swap, utxo) => {
7745
+ return async (swap, utxo, options) => {
7604
7746
  const record = await corridorStore().getRfqSwap(swap.rfqId);
7605
7747
  if (!record) {
7606
7748
  throw new Error(`rfq swap ${swap.rfqId} has no stored record to claim from`);
@@ -7621,17 +7763,25 @@ var createSwapDrive = (config) => {
7621
7763
  if (!swap.payoutPkScript) {
7622
7764
  throw new Error(`rfq swap ${swap.rfqId} carries no claim payout script`);
7623
7765
  }
7766
+ const rate = nextClaimFeeRate({
7767
+ configuredSatVb: feeRateSatVb,
7768
+ utxoAmount: utxo.amount,
7769
+ estimateSatVb: await liveFeeRate(chain),
7770
+ ...swap.claimFeeRateSatVb === void 0 ? {} : { lastSatVb: swap.claimFeeRateSatVb },
7771
+ ...options?.bump ? { bump: true } : {}
7772
+ });
7624
7773
  const { txid } = await track(
7625
7774
  claimOnchainFill(chain, {
7626
7775
  htlc: swap.htlc,
7627
7776
  utxo,
7628
7777
  preimage,
7629
7778
  payoutPkScript: swap.payoutPkScript,
7630
- feeRateSatVb,
7631
- sign: (sighash) => signer.signMessage(sighash, "schnorr")
7779
+ feeRateSatVb: rate,
7780
+ sign: (sighash) => signer.signMessage(sighash, "schnorr"),
7781
+ ...swap.claimTxid ? { republish: true } : {}
7632
7782
  })
7633
7783
  );
7634
- return { txid };
7784
+ return { txid, feeRateSatVb: rate };
7635
7785
  };
7636
7786
  };
7637
7787
  const defaultOnchainRefund = (chain, feeRateSatVb) => {
@@ -1,14 +1,14 @@
1
- import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './offerFillPlan-CFT8qgTV.cjs';
2
- export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, a7 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a8 as ObservationSeam, a9 as OfferPreparation, aa as OnchainClaim, ab as OnchainRefund, ac as OperatorUnreachable, ad as ParsedRfqQuote, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, ai as QuotePreparation, 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, ar as RfqPreparation, as as RfqQuoteInput, at as RfqRendezvous, au as RfqTransportFactory, av as RouteSide, aw as SWAP_ERROR_NAMES, ax as SwapClient, ay as SwapClientConfig, az as SwapDrive, aA as SwapDriveConfig, aB as SwapDriveRefusedError, aC as SwapError, aD as SwapErrorName, aE as SwapFilter, aF as UnsupportedRoute, aG as VerbDeps, aH as acceptQuote, aI as attesting, aJ as buildOfferFillPlan, aK as cancelSwap, aL as canonicalAssetId, aM as cardMarketOf, aN as chooseMarket, aO as conflictingFields, aP as corridorSet, aQ as createSwapClient, aR as createSwapDrive, aS as deepFreeze, aT as digestJointGraph, aU as discoveryIndex, aV as eligibleMarkets, aW as enforceFeeCeiling, aX as exchange, aY as feedFetch, aZ as feedSpread, a_ as isAddressable, a$ as isCardMarket, b0 as isIndexedNetwork, b1 as isSwapError, b2 as isUsableCard, b3 as liveArkadeInfo, b4 as marketBackendOf, b5 as marketKeyOf, b6 as marketRefOf, b7 as nostrTransportFactory, b8 as parseRfqQuote, b9 as pay, ba as quoteFromFeed, bb as quoteViaRfq, bc as readableRecord, bd as receive, be as resolveCorridorBase, bf as resolveCorridorDeps, bg as rfqLeg, bh as rfqPairFor, bi as swapRecordOf, bj as toDiscoveryLeg, bk as unsignedPsbtBytes, bl as usableMarkets, bm as verifyJointGraph, bn as verifyOfferFillPlan, bo as verifyPlanLegs, bp as withCanonicalAmount } from './offerFillPlan-CFT8qgTV.cjs';
1
+ import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './offerFillPlan-BYw1EWEj.cjs';
2
+ export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, a7 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a8 as ObservationSeam, a9 as OfferPreparation, aa as OnchainClaim, ab as OnchainRefund, ac as OperatorUnreachable, ad as ParsedRfqQuote, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, ai as QuotePreparation, 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, ar as RfqPreparation, as as RfqQuoteInput, at as RfqRendezvous, au as RfqTransportFactory, av as RouteSide, aw as SWAP_ERROR_NAMES, ax as SwapClient, ay as SwapClientConfig, az as SwapDrive, aA as SwapDriveConfig, aB as SwapDriveRefusedError, aC as SwapError, aD as SwapErrorName, aE as SwapFilter, aF as UnsupportedRoute, aG as VerbDeps, aH as acceptQuote, aI as attesting, aJ as buildOfferFillPlan, aK as cancelSwap, aL as canonicalAssetId, aM as cardMarketOf, aN as chooseMarket, aO as conflictingFields, aP as corridorSet, aQ as createSwapClient, aR as createSwapDrive, aS as deepFreeze, aT as digestJointGraph, aU as discoveryIndex, aV as eligibleMarkets, aW as enforceFeeCeiling, aX as exchange, aY as feedFetch, aZ as feedSpread, a_ as isAddressable, a$ as isCardMarket, b0 as isIndexedNetwork, b1 as isSwapError, b2 as isUsableCard, b3 as liveArkadeInfo, b4 as marketBackendOf, b5 as marketKeyOf, b6 as marketRefOf, b7 as nostrTransportFactory, b8 as parseRfqQuote, b9 as pay, ba as quoteFromFeed, bb as quoteViaRfq, bc as readableRecord, bd as receive, be as resolveCorridorBase, bf as resolveCorridorDeps, bg as rfqLeg, bh as rfqPairFor, bi as swapRecordOf, bj as toDiscoveryLeg, bk as unsignedPsbtBytes, bl as usableMarkets, bm as verifyJointGraph, bn as verifyOfferFillPlan, bo as verifyPlanLegs, bp as withCanonicalAmount } from './offerFillPlan-BYw1EWEj.cjs';
3
3
  import { DiscoveredMarket } from '@arkade-os/solver-discovery';
4
- import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-Bgn0apiL.cjs';
5
- export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, 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, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-Bgn0apiL.cjs';
6
- import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-m9tCbQx7.cjs';
7
- export { S as SwapRefusal } from './rfq-m9tCbQx7.cjs';
4
+ import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-D2emdY6f.cjs';
5
+ export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, 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, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-D2emdY6f.cjs';
6
+ import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-CRiAHBBH.cjs';
7
+ export { S as SwapRefusal } from './rfq-CRiAHBBH.cjs';
8
8
  import * as btc from '@scure/btc-signer';
9
9
  import { OnchainProvider, NetworkName, PageRequest, PageResult, IWallet, VHTLC } from '@arkade-os/sdk';
10
- import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-CLJXFpMq.cjs';
11
- import './offer-CsXgroM0.cjs';
10
+ import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-BwbZkceT.cjs';
11
+ import './offer-BwUhEawd.cjs';
12
12
 
13
13
  /** The EVM leg's namespace. Which chain is the quote's `evm_chain_id`, not the pair. */
14
14
  declare const EVM_CHAIN = "ethereum";
@@ -1,14 +1,14 @@
1
- import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './offerFillPlan-BQnzburi.js';
2
- export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, a7 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a8 as ObservationSeam, a9 as OfferPreparation, aa as OnchainClaim, ab as OnchainRefund, ac as OperatorUnreachable, ad as ParsedRfqQuote, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, ai as QuotePreparation, 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, ar as RfqPreparation, as as RfqQuoteInput, at as RfqRendezvous, au as RfqTransportFactory, av as RouteSide, aw as SWAP_ERROR_NAMES, ax as SwapClient, ay as SwapClientConfig, az as SwapDrive, aA as SwapDriveConfig, aB as SwapDriveRefusedError, aC as SwapError, aD as SwapErrorName, aE as SwapFilter, aF as UnsupportedRoute, aG as VerbDeps, aH as acceptQuote, aI as attesting, aJ as buildOfferFillPlan, aK as cancelSwap, aL as canonicalAssetId, aM as cardMarketOf, aN as chooseMarket, aO as conflictingFields, aP as corridorSet, aQ as createSwapClient, aR as createSwapDrive, aS as deepFreeze, aT as digestJointGraph, aU as discoveryIndex, aV as eligibleMarkets, aW as enforceFeeCeiling, aX as exchange, aY as feedFetch, aZ as feedSpread, a_ as isAddressable, a$ as isCardMarket, b0 as isIndexedNetwork, b1 as isSwapError, b2 as isUsableCard, b3 as liveArkadeInfo, b4 as marketBackendOf, b5 as marketKeyOf, b6 as marketRefOf, b7 as nostrTransportFactory, b8 as parseRfqQuote, b9 as pay, ba as quoteFromFeed, bb as quoteViaRfq, bc as readableRecord, bd as receive, be as resolveCorridorBase, bf as resolveCorridorDeps, bg as rfqLeg, bh as rfqPairFor, bi as swapRecordOf, bj as toDiscoveryLeg, bk as unsignedPsbtBytes, bl as usableMarkets, bm as verifyJointGraph, bn as verifyOfferFillPlan, bo as verifyPlanLegs, bp as withCanonicalAmount } from './offerFillPlan-BQnzburi.js';
1
+ import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './offerFillPlan-BGeAXIna.js';
2
+ export { e as AcceptConflict, f as AcceptInput, g as AcceptOptions, h as AmbiguousDestination, i as AmountEncodingUnsupported, j as AmountMismatch, k as AssetRfqPreparation, l as AttestingRfqTransport, B as BuildOfferFillPlanOpts, m as CORRIDOR_FACTORIES, n as CancelInput, o as CancelOutcome, p as ClaimedDestination, q as ClientDisposed, r as CorridorBase, s as CorridorClaim, t as CorridorCovenant, u as CorridorDeadline, v as CorridorDeps, w as CorridorDepsByCorridor, x as CorridorDrive, y as CorridorLockup, z as CorridorModule, E as CorridorOverrides, F as CorridorPass, G as CorridorRfqPreparation, H as DEFAULT_MAX_REFUND_WINDOW_SECONDS, I as DiscoveryConfig, J as DiscoveryIndexInput, K as DiscoverySnapshotUnavailable, N as DriveMode, P as DriveRefusal, Q as ExchangeOptions, R as FEED_TTL_MS, T as FeeCeiling, U as FeedFetch, V as FeedQuoteInput, W as FillSponsor, X as FillSponsorFare, Y as INDEXED_NETWORKS, Z as InconsistentRoute, _ as InsufficientFunds, $ as JointGraph, a0 as LockupOwner, a1 as Market, a2 as MaxFeeExceeded, a3 as MissingCorridorDep, a4 as NotCancellable, a5 as OFFER_FILL_OWNERS, a6 as OFFER_FILL_TEMPLATE, a7 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a8 as ObservationSeam, a9 as OfferPreparation, aa as OnchainClaim, ab as OnchainRefund, ac as OperatorUnreachable, ad as ParsedRfqQuote, ae as PayOptions, af as PayResult, ag as QuoteCheck, ah as QuoteExpired, ai as QuotePreparation, 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, ar as RfqPreparation, as as RfqQuoteInput, at as RfqRendezvous, au as RfqTransportFactory, av as RouteSide, aw as SWAP_ERROR_NAMES, ax as SwapClient, ay as SwapClientConfig, az as SwapDrive, aA as SwapDriveConfig, aB as SwapDriveRefusedError, aC as SwapError, aD as SwapErrorName, aE as SwapFilter, aF as UnsupportedRoute, aG as VerbDeps, aH as acceptQuote, aI as attesting, aJ as buildOfferFillPlan, aK as cancelSwap, aL as canonicalAssetId, aM as cardMarketOf, aN as chooseMarket, aO as conflictingFields, aP as corridorSet, aQ as createSwapClient, aR as createSwapDrive, aS as deepFreeze, aT as digestJointGraph, aU as discoveryIndex, aV as eligibleMarkets, aW as enforceFeeCeiling, aX as exchange, aY as feedFetch, aZ as feedSpread, a_ as isAddressable, a$ as isCardMarket, b0 as isIndexedNetwork, b1 as isSwapError, b2 as isUsableCard, b3 as liveArkadeInfo, b4 as marketBackendOf, b5 as marketKeyOf, b6 as marketRefOf, b7 as nostrTransportFactory, b8 as parseRfqQuote, b9 as pay, ba as quoteFromFeed, bb as quoteViaRfq, bc as readableRecord, bd as receive, be as resolveCorridorBase, bf as resolveCorridorDeps, bg as rfqLeg, bh as rfqPairFor, bi as swapRecordOf, bj as toDiscoveryLeg, bk as unsignedPsbtBytes, bl as usableMarkets, bm as verifyJointGraph, bn as verifyOfferFillPlan, bo as verifyPlanLegs, bp as withCanonicalAmount } from './offerFillPlan-BGeAXIna.js';
3
3
  import { DiscoveredMarket } from '@arkade-os/solver-discovery';
4
- import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-CSJXRd5N.js';
5
- export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, 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, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-CSJXRd5N.js';
6
- import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-m9tCbQx7.js';
7
- export { S as SwapRefusal } from './rfq-m9tCbQx7.js';
4
+ import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-YEQaxJro.js';
5
+ export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as ArkadeCarrierChoice, u as Artifact, 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, V as CORRIDORS, W as CORRIDOR_PASS, X as CardMarketRef, Y as CorridorId, Z as CorridorKind, _ as DepositArtifact, $ as DisplayDecimal, a0 as Endpoint, a1 as Ep, a2 as Hex, a3 as LOCKUP_OWNER, a4 as MarketBackend, a5 as MarketRef, a6 as OFFER_SWAP_ID_PREFIX, a7 as Outcome, a8 as ParsedAssetId, a9 as Quote, aa as QuoteLeg, ab as RAILS, ac as RFQ_SWAP_ID_PREFIX, ad as RailOf, ae as RankedBid, af as RawState, ag as ReceiverPaidCarrierQuote, ah as RecordedArtifact, ai as RecordedAssetPayment, aj as RecordedEndpoint, ak as RecordedInstrument, al as RecordedLeg, am as RestoredMarketRef, an as RfqAmountSide, ao as SnapshotRef, ap as Swap, aq as SwapFamily, ar as SwapRecordCommon, as as SwapUpdate, at as TaxiIdentity, au as Unsubscribe, av as VerifiedCarrierTerms, aw as arkadeAsset, ax as artifactOf, ay as assetPartOf, az as assetSwapIdOf, aA as bitcoinNetworkOf, aB as btcAssetPart, aC as btcOn, aD as corridorOfRail, aE as corridorOutcome, aF as decodeRfqAmount, aG as encodeRfqAmount, aH as familyOfSwapId, aI as formatAssetId, aJ as fromAtomicDecimal, aK as fromRfqAmountSide, aL as fundingWasNotSubmitted, aM as fundsFromWallet, aN as instrumentOf, aO as isAssetId, aP as isAtomicDecimal, aQ as isBtcAsset, aR as isBtcAssetLenient, aS as isNetworkRef, aT as issuanceOf, aU as legOf, aV as offerOutcome, aW as parseAssetId, aX as quoteIdOfSwapId, aY as railOf, aZ as railOfCorridor, a_ as readsChain, a$ as recordArtifact, b0 as recordEndpoint, b1 as recordInstrument, b2 as recordLeg, b3 as recordOutcome, b4 as sameAsset, b5 as swapOf, b6 as toAtomicDecimal, b7 as toRfqAmountSide, b8 as toSafeNumber } from './repository-YEQaxJro.js';
6
+ import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-CRiAHBBH.js';
7
+ export { S as SwapRefusal } from './rfq-CRiAHBBH.js';
8
8
  import * as btc from '@scure/btc-signer';
9
9
  import { OnchainProvider, NetworkName, PageRequest, PageResult, IWallet, VHTLC } from '@arkade-os/sdk';
10
- import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-D0R7YhYg.js';
11
- import './offer-DYCiKDm6.js';
10
+ import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-CjEsO0Qh.js';
11
+ import './offer-v7vBCPmQ.js';
12
12
 
13
13
  /** The EVM leg's namespace. Which chain is the quote's `evm_chain_id`, not the pair. */
14
14
  declare const EVM_CHAIN = "ethereum";
package/dist/advanced.js CHANGED
@@ -135,7 +135,7 @@ import {
135
135
  withCanonicalAmount,
136
136
  withDepositFate,
137
137
  withRfqState
138
- } from "./chunk-6O3L4AVI.js";
138
+ } from "./chunk-BWUC2LDD.js";
139
139
  import {
140
140
  ACTIVITY_TOKEN,
141
141
  Amount,
@@ -170,7 +170,7 @@ import {
170
170
  recordOutcome,
171
171
  swapOf,
172
172
  toAtomicDecimal
173
- } from "./chunk-XBMWEK43.js";
173
+ } from "./chunk-VFZJNU27.js";
174
174
  import {
175
175
  ARKADE_BTC,
176
176
  SwapRefusal,
@@ -178,7 +178,7 @@ import {
178
178
  assertPreimageMatches,
179
179
  rfqPair,
180
180
  sealClaimPacket
181
- } from "./chunk-DHFKCTER.js";
181
+ } from "./chunk-4X56MN56.js";
182
182
  import "./chunk-A3SHHRX4.js";
183
183
 
184
184
  // src/reveal.ts