@arkade-os/swap 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { VHTLC, asset, IWallet, ProvisionedClaimSecret, ProvisionedKey } from '@arkade-os/sdk';
1
+ import { VHTLC, IWallet, ProvisionedKey, ProvisionedClaimSecret, asset } from '@arkade-os/sdk';
2
2
 
3
3
  /** L1 confirmation-depth and reorg margin between dependent timelocks. */
4
4
  declare const ONCHAIN_ORDER_MARGIN_SECONDS: number;
@@ -46,6 +46,13 @@ declare const newPreimage: () => Uint8Array;
46
46
  /** `sha256(P)`, hex — the wire `payment_hash`, same convention as BOLT11. */
47
47
  declare const paymentHashOf: (preimage: Uint8Array) => string;
48
48
  type OnchainNetwork = "bitcoin" | "testnet" | "regtest";
49
+ /**
50
+ * The `payoutPkScript` {@link buildHtlcClaim} pays the fill to. Resolved EARLY:
51
+ * the claim's output is the spender's own choice, so nothing that survives a
52
+ * send screen names it, and a destination that cannot be encoded must be
53
+ * refused before the swap is negotiated rather than at claim time.
54
+ */
55
+ declare const l1ScriptForAddress: (address: string, network: OnchainNetwork) => Uint8Array;
49
56
  interface OnchainHtlcParams {
50
57
  /** `sha256(P)`, hex; the HASH160 commitment is derived internally. */
51
58
  paymentHash: string;
@@ -129,8 +136,9 @@ interface ChainUtxo extends HtlcUtxo {
129
136
  interface ChainSource {
130
137
  /** Confirmed+mempool outputs paying a script; used to detect the fill. */
131
138
  getScriptUtxos(pkScript: Uint8Array): Promise<ChainUtxo[]>;
132
- /** The spend of an outpoint, if any — where P is extracted from. */
133
- getSpendingTx(txid: string, vout: number): Promise<{
139
+ /** The spend of an outpoint, if any — where P is extracted from. A
140
+ * provider omitting the spender txid still lists it in `pkScript`'s history. */
141
+ getSpendingTx(txid: string, vout: number, pkScript: Uint8Array): Promise<{
134
142
  txHex: string;
135
143
  } | null>;
136
144
  broadcast(txHex: string): Promise<string>;
@@ -367,6 +375,25 @@ declare const assertFundable: (input: {
367
375
  /** "send" = arkade->onchain (the L1 timelock-order gate applies). */
368
376
  direction: "send" | "receive";
369
377
  };
378
+ /**
379
+ * The most this client will pay: the GREATER of the two bounds, because a
380
+ * flat fee is a large proportion of a small swap (420 sats is 8.4% of
381
+ * 5_000, 0.084% of 500_000). Absent means no ceiling. OMIT a bound rather
382
+ * than zeroing it: `{ bps: 0 }` alone is a ceiling of zero, indistinguishable
383
+ * from "free or nothing". `{}` IS refused.
384
+ */
385
+ maxFee?: {
386
+ /** Integer, 0..10_000 (10_000 = 100%). Out of range throws `max_fee_out_of_range`. */
387
+ bps?: number;
388
+ /** Non-negative integer. Out of range throws `max_fee_out_of_range`. */
389
+ sats?: number;
390
+ /**
391
+ * To-units per from-unit, required for a CROSS-ASSET pair. Must come
392
+ * from a source of YOUR OWN — the solver's own feed would check it
393
+ * against its own number. Needs a looser tolerance than same-asset.
394
+ */
395
+ referenceRate?: number;
396
+ };
370
397
  }) => void;
371
398
  interface RfqTransport {
372
399
  requestQuote(payload: Record<string, unknown>): Promise<RfqQuote>;
@@ -1030,4 +1057,4 @@ declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, tr
1030
1057
  secrets: ProvisionedClaimSecret;
1031
1058
  }>;
1032
1059
 
1033
- export { newRfqId as $, ARKADE_ASSET as A, arkadeAssetLeg as B, type ChainSource as C, arkadeSwapRequest as D, assertFundable as E, assertReceivable as F, awaitOnchainFill as G, type HtlcUtxo as H, type InvoiceFacts as I, buildHtlcClaim as J, buildHtlcRefund as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, claimOnchainFill as N, type OnchainNetwork as O, classifyOnchainHtlc as P, deriveLightningReceive as Q, RFQ_TERMINAL_STATES as R, SOLO_REFUND_HEADROOM_SECONDS as S, deriveOnchainReceive as T, deriveOnchainSend as U, extractPreimage as V, httpTransport as W, lightningReceiveRequest as X, lightningSendRequest as Y, lightningSendVtxoScript as Z, newPreimage as _, type OnchainHtlc as a, offerTermsFromQuote as a0, onchainHtlcScript as a1, onchainReceiveRequest as a2, onchainSendRequest as a3, paymentHashOf as a4, receiveVtxoScript as a5, relayTransport as a6, requestLightningReceive as a7, requestLightningSend as a8, requestOnchainReceive as a9, requestOnchainSend as aa, rfqPair as ab, unilateralClaimDelay as ac, unilateralRefundDelay as ad, unilateralRefundWithoutReceiverDelay as ae, verifyLockupAddress as af, verifyReceiveInvoice as ag, type OnchainHtlcParams as b, ARKADE_BTC as c, AddressMismatch as d, type ChainUtxo as e, LIGHTNING_RECEIVE_PAIR as f, LIGHTNING_SEND_PAIR as g, LOCKTIME_THRESHOLD as h, type LightningReceiveTreeParams as i, type LightningSendTreeParams as j, MIN_CLAIM_WINDOW_SECONDS as k, MIN_HEADROOM_SECONDS as l, ONCHAIN_BTC as m, ONCHAIN_CLAIM_MARGIN_SECONDS as n, ONCHAIN_DUST_SATS as o, ONCHAIN_ORDER_MARGIN_SECONDS as p, ONCHAIN_RECEIVE_PAIR as q, ONCHAIN_SECONDS_PER_BLOCK as r, ONCHAIN_SEND_PAIR as s, type OnchainHtlcPhase as t, type RelaySocket as u, type RfqQuote as v, type RfqRefusalReason as w, type RfqStatus as x, type RfqTransport as y, SwapRefusal as z };
1060
+ export { lightningSendRequest as $, ARKADE_ASSET as A, type RfqStatus as B, type ChainSource as C, SwapRefusal as D, arkadeAssetLeg as E, arkadeSwapRequest as F, assertFundable as G, type HtlcUtxo as H, type InvoiceFacts as I, assertReceivable as J, awaitOnchainFill as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, buildHtlcClaim as N, type OnchainNetwork as O, buildHtlcRefund as P, claimOnchainFill as Q, type RfqTransport as R, SOLO_REFUND_HEADROOM_SECONDS as S, classifyOnchainHtlc as T, deriveLightningReceive as U, deriveOnchainReceive as V, deriveOnchainSend as W, extractPreimage as X, httpTransport as Y, l1ScriptForAddress as Z, lightningReceiveRequest as _, type OnchainHtlc as a, lightningSendVtxoScript as a0, newPreimage as a1, newRfqId as a2, offerTermsFromQuote as a3, onchainHtlcScript as a4, onchainReceiveRequest as a5, onchainSendRequest as a6, paymentHashOf as a7, receiveVtxoScript as a8, relayTransport as a9, requestLightningReceive as aa, requestOnchainReceive as ab, rfqPair as ac, unilateralClaimDelay as ad, unilateralRefundDelay as ae, unilateralRefundWithoutReceiverDelay as af, verifyLockupAddress as ag, verifyReceiveInvoice as ah, type OnchainHtlcParams as b, requestLightningSend as c, ARKADE_BTC as d, AddressMismatch as e, type ChainUtxo as f, LIGHTNING_RECEIVE_PAIR as g, LIGHTNING_SEND_PAIR as h, LOCKTIME_THRESHOLD as i, type LightningReceiveTreeParams as j, type LightningSendTreeParams as k, MIN_CLAIM_WINDOW_SECONDS as l, MIN_HEADROOM_SECONDS as m, ONCHAIN_BTC as n, ONCHAIN_CLAIM_MARGIN_SECONDS as o, ONCHAIN_DUST_SATS as p, ONCHAIN_ORDER_MARGIN_SECONDS as q, requestOnchainSend as r, ONCHAIN_RECEIVE_PAIR as s, ONCHAIN_SECONDS_PER_BLOCK as t, ONCHAIN_SEND_PAIR as u, type OnchainHtlcPhase as v, RFQ_TERMINAL_STATES as w, type RelaySocket as x, type RfqQuote as y, type RfqRefusalReason as z };
@@ -1,4 +1,4 @@
1
- import { VHTLC, asset, IWallet, ProvisionedClaimSecret, ProvisionedKey } from '@arkade-os/sdk';
1
+ import { VHTLC, IWallet, ProvisionedKey, ProvisionedClaimSecret, asset } from '@arkade-os/sdk';
2
2
 
3
3
  /** L1 confirmation-depth and reorg margin between dependent timelocks. */
4
4
  declare const ONCHAIN_ORDER_MARGIN_SECONDS: number;
@@ -46,6 +46,13 @@ declare const newPreimage: () => Uint8Array;
46
46
  /** `sha256(P)`, hex — the wire `payment_hash`, same convention as BOLT11. */
47
47
  declare const paymentHashOf: (preimage: Uint8Array) => string;
48
48
  type OnchainNetwork = "bitcoin" | "testnet" | "regtest";
49
+ /**
50
+ * The `payoutPkScript` {@link buildHtlcClaim} pays the fill to. Resolved EARLY:
51
+ * the claim's output is the spender's own choice, so nothing that survives a
52
+ * send screen names it, and a destination that cannot be encoded must be
53
+ * refused before the swap is negotiated rather than at claim time.
54
+ */
55
+ declare const l1ScriptForAddress: (address: string, network: OnchainNetwork) => Uint8Array;
49
56
  interface OnchainHtlcParams {
50
57
  /** `sha256(P)`, hex; the HASH160 commitment is derived internally. */
51
58
  paymentHash: string;
@@ -129,8 +136,9 @@ interface ChainUtxo extends HtlcUtxo {
129
136
  interface ChainSource {
130
137
  /** Confirmed+mempool outputs paying a script; used to detect the fill. */
131
138
  getScriptUtxos(pkScript: Uint8Array): Promise<ChainUtxo[]>;
132
- /** The spend of an outpoint, if any — where P is extracted from. */
133
- getSpendingTx(txid: string, vout: number): Promise<{
139
+ /** The spend of an outpoint, if any — where P is extracted from. A
140
+ * provider omitting the spender txid still lists it in `pkScript`'s history. */
141
+ getSpendingTx(txid: string, vout: number, pkScript: Uint8Array): Promise<{
134
142
  txHex: string;
135
143
  } | null>;
136
144
  broadcast(txHex: string): Promise<string>;
@@ -367,6 +375,25 @@ declare const assertFundable: (input: {
367
375
  /** "send" = arkade->onchain (the L1 timelock-order gate applies). */
368
376
  direction: "send" | "receive";
369
377
  };
378
+ /**
379
+ * The most this client will pay: the GREATER of the two bounds, because a
380
+ * flat fee is a large proportion of a small swap (420 sats is 8.4% of
381
+ * 5_000, 0.084% of 500_000). Absent means no ceiling. OMIT a bound rather
382
+ * than zeroing it: `{ bps: 0 }` alone is a ceiling of zero, indistinguishable
383
+ * from "free or nothing". `{}` IS refused.
384
+ */
385
+ maxFee?: {
386
+ /** Integer, 0..10_000 (10_000 = 100%). Out of range throws `max_fee_out_of_range`. */
387
+ bps?: number;
388
+ /** Non-negative integer. Out of range throws `max_fee_out_of_range`. */
389
+ sats?: number;
390
+ /**
391
+ * To-units per from-unit, required for a CROSS-ASSET pair. Must come
392
+ * from a source of YOUR OWN — the solver's own feed would check it
393
+ * against its own number. Needs a looser tolerance than same-asset.
394
+ */
395
+ referenceRate?: number;
396
+ };
370
397
  }) => void;
371
398
  interface RfqTransport {
372
399
  requestQuote(payload: Record<string, unknown>): Promise<RfqQuote>;
@@ -1030,4 +1057,4 @@ declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, tr
1030
1057
  secrets: ProvisionedClaimSecret;
1031
1058
  }>;
1032
1059
 
1033
- export { newRfqId as $, ARKADE_ASSET as A, arkadeAssetLeg as B, type ChainSource as C, arkadeSwapRequest as D, assertFundable as E, assertReceivable as F, awaitOnchainFill as G, type HtlcUtxo as H, type InvoiceFacts as I, buildHtlcClaim as J, buildHtlcRefund as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, claimOnchainFill as N, type OnchainNetwork as O, classifyOnchainHtlc as P, deriveLightningReceive as Q, RFQ_TERMINAL_STATES as R, SOLO_REFUND_HEADROOM_SECONDS as S, deriveOnchainReceive as T, deriveOnchainSend as U, extractPreimage as V, httpTransport as W, lightningReceiveRequest as X, lightningSendRequest as Y, lightningSendVtxoScript as Z, newPreimage as _, type OnchainHtlc as a, offerTermsFromQuote as a0, onchainHtlcScript as a1, onchainReceiveRequest as a2, onchainSendRequest as a3, paymentHashOf as a4, receiveVtxoScript as a5, relayTransport as a6, requestLightningReceive as a7, requestLightningSend as a8, requestOnchainReceive as a9, requestOnchainSend as aa, rfqPair as ab, unilateralClaimDelay as ac, unilateralRefundDelay as ad, unilateralRefundWithoutReceiverDelay as ae, verifyLockupAddress as af, verifyReceiveInvoice as ag, type OnchainHtlcParams as b, ARKADE_BTC as c, AddressMismatch as d, type ChainUtxo as e, LIGHTNING_RECEIVE_PAIR as f, LIGHTNING_SEND_PAIR as g, LOCKTIME_THRESHOLD as h, type LightningReceiveTreeParams as i, type LightningSendTreeParams as j, MIN_CLAIM_WINDOW_SECONDS as k, MIN_HEADROOM_SECONDS as l, ONCHAIN_BTC as m, ONCHAIN_CLAIM_MARGIN_SECONDS as n, ONCHAIN_DUST_SATS as o, ONCHAIN_ORDER_MARGIN_SECONDS as p, ONCHAIN_RECEIVE_PAIR as q, ONCHAIN_SECONDS_PER_BLOCK as r, ONCHAIN_SEND_PAIR as s, type OnchainHtlcPhase as t, type RelaySocket as u, type RfqQuote as v, type RfqRefusalReason as w, type RfqStatus as x, type RfqTransport as y, SwapRefusal as z };
1060
+ export { lightningSendRequest as $, ARKADE_ASSET as A, type RfqStatus as B, type ChainSource as C, SwapRefusal as D, arkadeAssetLeg as E, arkadeSwapRequest as F, assertFundable as G, type HtlcUtxo as H, type InvoiceFacts as I, assertReceivable as J, awaitOnchainFill as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, buildHtlcClaim as N, type OnchainNetwork as O, buildHtlcRefund as P, claimOnchainFill as Q, type RfqTransport as R, SOLO_REFUND_HEADROOM_SECONDS as S, classifyOnchainHtlc as T, deriveLightningReceive as U, deriveOnchainReceive as V, deriveOnchainSend as W, extractPreimage as X, httpTransport as Y, l1ScriptForAddress as Z, lightningReceiveRequest as _, type OnchainHtlc as a, lightningSendVtxoScript as a0, newPreimage as a1, newRfqId as a2, offerTermsFromQuote as a3, onchainHtlcScript as a4, onchainReceiveRequest as a5, onchainSendRequest as a6, paymentHashOf as a7, receiveVtxoScript as a8, relayTransport as a9, requestLightningReceive as aa, requestOnchainReceive as ab, rfqPair as ac, unilateralClaimDelay as ad, unilateralRefundDelay as ae, unilateralRefundWithoutReceiverDelay as af, verifyLockupAddress as ag, verifyReceiveInvoice as ah, type OnchainHtlcParams as b, requestLightningSend as c, ARKADE_BTC as d, AddressMismatch as e, type ChainUtxo as f, LIGHTNING_RECEIVE_PAIR as g, LIGHTNING_SEND_PAIR as h, LOCKTIME_THRESHOLD as i, type LightningReceiveTreeParams as j, type LightningSendTreeParams as k, MIN_CLAIM_WINDOW_SECONDS as l, MIN_HEADROOM_SECONDS as m, ONCHAIN_BTC as n, ONCHAIN_CLAIM_MARGIN_SECONDS as o, ONCHAIN_DUST_SATS as p, ONCHAIN_ORDER_MARGIN_SECONDS as q, requestOnchainSend as r, ONCHAIN_RECEIVE_PAIR as s, ONCHAIN_SECONDS_PER_BLOCK as t, ONCHAIN_SEND_PAIR as u, type OnchainHtlcPhase as v, RFQ_TERMINAL_STATES as w, type RelaySocket as x, type RfqQuote as y, type RfqRefusalReason as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/swap",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "description": "Client-side Arkade Intents asset swaps: discover markets, quote, create/track/cancel offers, restore from chain.",
6
6
  "repository": {
@@ -70,7 +70,7 @@
70
70
  "@noble/hashes": "2.0.1",
71
71
  "@scure/base": "2.0.0",
72
72
  "@scure/btc-signer": "2.0.1",
73
- "@arkade-os/sdk": "0.4.68"
73
+ "@arkade-os/sdk": "0.4.69"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "nostr-tools": "^2.12.0"