@arkade-os/swap 0.1.0-rc.21 → 0.1.0-rc.23

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 (37) hide show
  1. package/README.md +7 -2
  2. package/dist/advanced.cjs +875 -129
  3. package/dist/advanced.d.cts +158 -14
  4. package/dist/advanced.d.ts +158 -14
  5. package/dist/advanced.js +255 -4
  6. package/dist/{chunk-ITFCQWPG.js → chunk-DQ2DY2L2.js} +223 -11
  7. package/dist/{chunk-HUQQVBC4.js → chunk-MZX62KMU.js} +220 -12
  8. package/dist/{chunk-PVB7EBAM.js → chunk-UFJEO4VV.js} +47 -21
  9. package/dist/{errors-hm7aqnRM.d.cts → errors-5q4e3PnH.d.cts} +48 -16
  10. package/dist/{errors-C3h8ANmE.d.ts → errors-DQ35FKJf.d.ts} +48 -16
  11. package/dist/index.cjs +670 -185
  12. package/dist/index.d.cts +5 -5
  13. package/dist/index.d.ts +5 -5
  14. package/dist/index.js +5 -3
  15. package/dist/node/index.d.cts +26 -4
  16. package/dist/node/index.d.ts +26 -4
  17. package/dist/nostr.cjs +12 -9
  18. package/dist/nostr.d.cts +1 -1
  19. package/dist/nostr.d.ts +1 -1
  20. package/dist/nostr.js +3 -1
  21. package/dist/{offer-Bd9Yvd8Z.d.ts → offer--IpfzhIm.d.ts} +1 -1
  22. package/dist/{offer-F88rtL_I.d.cts → offer-DqTXQeP1.d.cts} +1 -1
  23. package/dist/protocol.cjs +395 -156
  24. package/dist/protocol.d.cts +45 -8
  25. package/dist/protocol.d.ts +45 -8
  26. package/dist/protocol.js +10 -3
  27. package/dist/repositories/realm/index.d.cts +2 -2
  28. package/dist/repositories/realm/index.d.ts +2 -2
  29. package/dist/repositories/sqlite/index.d.cts +2 -2
  30. package/dist/repositories/sqlite/index.d.ts +2 -2
  31. package/dist/{repository-DYnRLPt-.d.ts → repository-B4rQWmS2.d.cts} +88 -20
  32. package/dist/{repository-BuYWGAKz.d.cts → repository-D_qvJk1S.d.ts} +88 -20
  33. package/dist/{rfq-60PGpQ_x.d.cts → rfq-BgdgO9OO.d.cts} +16 -7
  34. package/dist/{rfq-60PGpQ_x.d.ts → rfq-BgdgO9OO.d.ts} +16 -7
  35. package/dist/{watch-BTyiBLSd.d.ts → watch-BkPz0vf8.d.ts} +1 -1
  36. package/dist/{watch-M_KY-5ho.d.cts → watch-RRhKuBkh.d.cts} +1 -1
  37. package/package.json +3 -3
@@ -1,8 +1,8 @@
1
1
  import { IWallet, NetworkName, Network, SignerSet, ArkadeInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret } from '@arkade-os/sdk';
2
- import { b5 as SwapOperator, d as AssetSwapRepository, m as Pubkey, b7 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b8 as RfqSwapActionName, N as NetworkRef, A as AssetId, aj as SnapshotRef, a1 as MarketBackend, U as CardMarketRef, a2 as MarketRef, z as AssetRef, r as AmountOn, ak as Swap, V as CorridorId, X as DepositArtifact, l as QuoteInput, a6 as Quote, ab as RankedBid, an as SwapUpdate, ao as Unsubscribe, S as SwapRecord, Q as QuoteId, a4 as Outcome, L as LockupSpendIndexer, b4 as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, D as AssetSwapId, al as SwapFamily, i as RouteResolution } from './repository-BuYWGAKz.cjs';
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-60PGpQ_x.cjs';
2
+ import { b5 as SwapOperator, d as AssetSwapRepository, m as Pubkey, b7 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b8 as RfqSwapActionName, N as NetworkRef, A as AssetId, aj as SnapshotRef, a1 as MarketBackend, U as CardMarketRef, a2 as MarketRef, z as AssetRef, r as AmountOn, ak as Swap, V as CorridorId, X as DepositArtifact, l as QuoteInput, a6 as Quote, ab as RankedBid, an as SwapUpdate, ao as Unsubscribe, S as SwapRecord, Q as QuoteId, a4 as Outcome, L as LockupSpendIndexer, b4 as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, D as AssetSwapId, al as SwapFamily, i as RouteResolution } from './repository-B4rQWmS2.cjs';
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-BgdgO9OO.cjs';
4
4
  import { Network as Network$1, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
5
- import { D as DerivedOffer } from './offer-F88rtL_I.cjs';
5
+ import { D as DerivedOffer } from './offer-DqTXQeP1.cjs';
6
6
 
7
7
  /**
8
8
  * What a corridor is given, what a caller may replace, and where "overridden to nothing" is refused.
@@ -63,8 +63,12 @@ interface CorridorOverrides {
63
63
  /** How the trader's L1 claim is built and broadcast. Default: synthesized from
64
64
  * {@link claimFeeRateSatVb} when resolvable (see {@link OnchainCorridorDeps.claim}). */
65
65
  claim?: OnchainClaim | null;
66
+ /** How the trader's L1 refund of an `onchain -> arkade` funding is built and broadcast.
67
+ * Default: synthesized from {@link claimFeeRateSatVb} when resolvable (see
68
+ * {@link OnchainCorridorDeps.refund}). */
69
+ refund?: OnchainRefund | null;
66
70
  /**
67
- * Sat/vB the trader's L1 claim is built at, and the rate the take leg is grossed up by so the
71
+ * Sat/vB the trader's L1 claim (and refund) is built at, and the rate the take leg is grossed up by so the
68
72
  * recipient nets the requested amount. Default: {@link ONCHAIN_CLAIM_FEE_RATE_SATVB}.
69
73
  *
70
74
  * `null` is NOT a refusal here: it is "no default claim" — manual mode. The corridor still
@@ -78,6 +82,8 @@ interface CorridorOverrides {
78
82
  }
79
83
  /** Build and broadcast the L1 claim of an `arkade -> onchain` fill (the manager's own type). */
80
84
  type OnchainClaim = RfqSwapManagerCallbacks["claimOnchain"];
85
+ /** Build and broadcast the L1 refund of an `onchain -> arkade` funding (the manager's own type). */
86
+ type OnchainRefund = RfqSwapManagerCallbacks["refundOnchain"];
81
87
  /**
82
88
  * Per-network default L1 claim fee rate, sat/vB — deliberately the RELAY FLOOR, since it both builds
83
89
  * the claim and prices the gross-up. On mainnet override UPWARD in congestion: the claim has a
@@ -115,9 +121,14 @@ interface OnchainCorridorDeps {
115
121
  * {@link claimFeeRateSatVb}; with neither, the L1 half reports blocked while the Arkade lockup is
116
122
  * still driven and refunded. */
117
123
  readonly claim?: OnchainClaim;
124
+ /** The caller's L1 refund callback, verbatim. The default refund is built in the drive from
125
+ * {@link claimFeeRateSatVb}; with neither, an `onchain -> arkade` swap whose solver never
126
+ * funds reports blocked until one is wired. */
127
+ readonly refund?: OnchainRefund;
118
128
  /**
119
129
  * The one fee rate both recipient-exact halves share: the quote's gross-up (`claimFeeSats`) and
120
130
  * the default claim build. Two numbers would short the recipient. `undefined` = manual mode.
131
+ * The default refund is built at it too.
121
132
  */
122
133
  readonly claimFeeRateSatVb?: number;
123
134
  /**
@@ -189,7 +200,7 @@ type ObservationSeam =
189
200
  type CorridorCovenant =
190
201
  /** The Arkade-side VHTLC every corridor route has exactly one of. */
191
202
  "arkade_lockup"
192
- /** The L1 HTLC, which only `arkade -> onchain` adds. */
203
+ /** The L1 HTLC, which the onchain corridor adds in either direction. */
193
204
  | "onchain_htlc";
194
205
  /** Whose covenant it is. Ownership inverts the deadline: a TRADER lockup's deadline is a moment to
195
206
  * act after, a SOLVER lockup's a moment to have acted before. */
@@ -198,7 +209,7 @@ type LockupOwner = "trader" | "solver";
198
209
  type CorridorDeadline =
199
210
  /** `RfqSwapCommon.refundLocktime`, on every kind. */
200
211
  "refund_locktime"
201
- /** `OnchainSendSwap.htlc.refundLocktime`, on `arkade -> onchain` alone. */
212
+ /** The L1 HTLC's `htlc.refundLocktime`, on the onchain corridor alone. */
202
213
  | "htlc_refund_locktime";
203
214
  /** One covenant a pass reads, with its owner and the deadline it runs against. */
204
215
  interface CorridorLockup {
@@ -218,10 +229,8 @@ interface CorridorPass {
218
229
  readonly seams: readonly ObservationSeam[];
219
230
  }
220
231
  /**
221
- * A corridor's drive facts, per side. Partial on purpose: `onchain` has no `give` entry because
222
- * `onchain -> arkade` is outside the `Route` union (covering only its Arkade half would silently let
223
- * the trader's L1 refund window pass); `arkade` has neither, since `arkade -> arkade` is an offer
224
- * covenant with no lockup. The arkade leg's lockup is declared by the counter-corridor's entry.
232
+ * A corridor's drive facts, per side. Partial on purpose: `arkade` has neither, since
233
+ * `arkade -> arkade` is an offer covenant with no lockup. The arkade leg's lockup is declared by the counter-corridor's entry.
225
234
  */
226
235
  type CorridorDrive = Partial<Record<RouteSide, CorridorPass>>;
227
236
  /** One corridor. `deps` are closed over at construction because the parse needs them (network,
@@ -666,6 +675,8 @@ type DriveMode =
666
675
  * round, and nothing new is discovered.
667
676
  */
668
677
  | "readonly";
678
+ /** Default {@link SwapPolicy.maxRefundWindowSeconds}: 30 days. */
679
+ declare const DEFAULT_MAX_REFUND_WINDOW_SECONDS: number;
669
680
  interface SwapPolicy {
670
681
  /** How much the client drives on its own. Default `"auto"`. */
671
682
  readonly drive?: DriveMode;
@@ -700,6 +711,12 @@ interface SwapPolicy {
700
711
  * `QuoteExpired`, rather than handing back terms that would fail at `accept()`.
701
712
  */
702
713
  readonly quoteTtlFloorSeconds?: number;
714
+ /**
715
+ * The longest a send's funds may stay locked before the trader can refund, in seconds.
716
+ * Caps `refund_locktime` and the solo-refund delay; above it `quote()` throws
717
+ * `QuoteVerificationFailed("refund_window")`. Default {@link DEFAULT_MAX_REFUND_WINDOW_SECONDS}.
718
+ */
719
+ readonly maxRefundWindowSeconds?: number;
703
720
  /**
704
721
  * §10, reserved and inert: the published-RFQ auction's parameters.
705
722
  */
@@ -773,8 +790,8 @@ interface SwapDriveConfig {
773
790
  * `accept()` keeps its own refusal. */
774
791
  readonly repository?: AssetSwapRepository;
775
792
  /**
776
- * The client's corridors, for the L1 chain source and claim callback a drive pass needs.
777
- * Lazy, so a client with `null` onchain deps that never drives `arkade -> onchain` never
793
+ * The client's corridors, for the L1 chain source and claim/refund callbacks a drive pass
794
+ * needs. Lazy, so a client with `null` onchain deps that never drives an onchain swap never
778
795
  * resolves them.
779
796
  */
780
797
  readonly corridors: () => Promise<CorridorSet>;
@@ -1077,10 +1094,26 @@ type CorridorRfqPreparation = (CommonPreparation & {
1077
1094
  readonly htlcParams: OnchainHtlcParams;
1078
1095
  readonly l1Network: OnchainNetwork;
1079
1096
  readonly minConfirmations: number;
1097
+ }) | (CommonPreparation & {
1098
+ readonly route: "onchain->arkade";
1099
+ /** The Arkade claim: the key the solver's lockup pays, and the P that unlocks it. */
1100
+ readonly secrets: ProvisionedClaimSecret;
1101
+ readonly payoutAddress: string;
1102
+ /** What the solver's lockup must carry — the claim refuses less. */
1103
+ readonly expectedAmount: bigint;
1104
+ /** The HTLC's refund key, provisioned by the wallet like every other key. */
1105
+ readonly refundKey: ProvisionedKey;
1106
+ /** Where the L1 refund PAYS: a boarding address of this wallet. */
1107
+ readonly refundPkScript: Uint8Array;
1108
+ /** The L1 HTLC the trader funds, derived locally. */
1109
+ readonly htlc: OnchainHtlc;
1110
+ readonly htlcParams: OnchainHtlcParams;
1111
+ readonly l1Network: OnchainNetwork;
1112
+ readonly minConfirmations: number;
1080
1113
  });
1081
1114
  interface RfqQuoteInput {
1082
1115
  readonly quoteId: QuoteId;
1083
- readonly route: "arkade->arkade" | "arkade->lightning" | "lightning->arkade" | "arkade->onchain";
1116
+ readonly route: "arkade->arkade" | "arkade->lightning" | "lightning->arkade" | "arkade->onchain" | "onchain->arkade";
1084
1117
  readonly candidate: MarketCandidate;
1085
1118
  readonly market: CardMarketRef;
1086
1119
  readonly legs: {
@@ -1361,8 +1394,7 @@ declare class AmbiguousDestination extends Error {
1361
1394
  constructor(destination: string, detail: string);
1362
1395
  }
1363
1396
  /**
1364
- * The corridor pair is not in the implemented route union — `onchain -> arkade`
1365
- * included, until the manager owns the trader's L1 refund path end to end.
1397
+ * The corridor pair is not in the implemented route union.
1366
1398
  *
1367
1399
  * Boundary: route resolution, before RFQ disclosure, artifact creation, persistence or funding.
1368
1400
  * Also the alias layer (a rail no corridor serves), and `quote()` when no discovered market
@@ -1557,4 +1589,4 @@ declare function isSwapError<N extends SwapErrorName>(e: unknown, name: N): e is
1557
1589
  name: N;
1558
1590
  }>;
1559
1591
 
1560
- export { ONCHAIN_CLAIM_FEE_RATE_SATVB as $, type AssetAliasTable as A, type CorridorPass as B, type CorridorFactory as C, type DiscoveryIndex as D, type CorridorRfqPreparation as E, type DiscoveryConfig as F, type DiscoveryIndexInput as G, DiscoverySnapshotUnavailable as H, type DriveMode as I, type DriveRefusal as J, type ExchangeOptions as K, type LightningCorridorDeps as L, type MarketCandidate as M, FEED_TTL_MS as N, type OnchainCorridorDeps as O, type FeeCeiling as P, type FeedFetch as Q, type FeedQuoteInput as R, type SwapPolicy as S, INDEXED_NETWORKS as T, InconsistentRoute as U, InsufficientFunds as V, type LockupOwner as W, type Market as X, MaxFeeExceeded as Y, MissingCorridorDep as Z, NotCancellable as _, type ArkadeCorridorDeps as a, quoteViaRfq as a$, type ObservationSeam as a0, type OfferPreparation as a1, type OnchainClaim as a2, OperatorUnreachable as a3, type ParsedRfqQuote as a4, type PayOptions as a5, type PayResult as a6, type QuoteCheck as a7, QuoteExpired as a8, type QuotePreparation as a9, cancelSwap as aA, canonicalAssetId as aB, cardMarketOf as aC, chooseMarket as aD, conflictingFields as aE, corridorSet as aF, createSwapClient as aG, createSwapDrive as aH, discoveryIndex as aI, eligibleMarkets as aJ, enforceFeeCeiling as aK, exchange as aL, feedFetch as aM, feedSpread as aN, isAddressable as aO, isCardMarket as aP, isIndexedNetwork as aQ, isSwapError as aR, isUsableCard as aS, liveArkadeInfo as aT, marketBackendOf as aU, marketKeyOf as aV, marketRefOf as aW, nostrTransportFactory as aX, parseRfqQuote as aY, pay as aZ, quoteFromFeed as a_, QuoteVerificationFailed as aa, REGISTRY_URL as ab, type ReceiveArtifact as ac, type ReceiveOptions as ad, type ReceiveRequest as ae, type RecoveryResult as af, type RegisteredAsset as ag, type RfqAuctionPolicy as ah, type RfqPreparation as ai, type RfqQuoteInput as aj, type RfqRendezvous as ak, type RfqTransportFactory as al, type RouteSide as am, SWAP_ERROR_NAMES as an, type SwapClient as ao, type SwapClientConfig as ap, type SwapDrive as aq, type SwapDriveConfig as ar, SwapDriveRefusedError as as, type SwapError as at, type SwapErrorName as au, type SwapFilter as av, UnsupportedRoute as aw, type VerbDeps as ax, acceptQuote as ay, attesting as az, type CorridorSet as b, readableRecord as b0, receive as b1, resolveCorridorBase as b2, resolveCorridorDeps as b3, rfqLeg as b4, rfqPairFor as b5, swapRecordOf as b6, toDiscoveryLeg as b7, usableMarkets as b8, verifyPlanLegs as b9, withCanonicalAmount as ba, type DiscoveryLeg as c, type DiscoverySnapshot as d, AcceptConflict as e, type AcceptInput as f, AmbiguousDestination as g, AmountEncodingUnsupported as h, AmountMismatch as i, type AssetRfqPreparation as j, type AttestingRfqTransport as k, CORRIDOR_FACTORIES as l, type CancelInput as m, type CancelOutcome as n, type ClaimedDestination as o, ClientDisposed as p, type CorridorBase as q, type CorridorClaim as r, type CorridorCovenant as s, type CorridorDeadline as t, type CorridorDeps as u, type CorridorDepsByCorridor as v, type CorridorDrive as w, type CorridorLockup as x, type CorridorModule as y, type CorridorOverrides as z };
1592
+ export { NotCancellable as $, type AssetAliasTable as A, type CorridorPass as B, type CorridorFactory as C, type DiscoveryIndex as D, type CorridorRfqPreparation as E, DEFAULT_MAX_REFUND_WINDOW_SECONDS as F, type DiscoveryConfig as G, type DiscoveryIndexInput as H, DiscoverySnapshotUnavailable as I, type DriveMode as J, type DriveRefusal as K, type LightningCorridorDeps as L, type MarketCandidate as M, type ExchangeOptions as N, type OnchainCorridorDeps as O, FEED_TTL_MS as P, type FeeCeiling as Q, type FeedFetch as R, type SwapPolicy as S, type FeedQuoteInput as T, INDEXED_NETWORKS as U, InconsistentRoute as V, InsufficientFunds as W, type LockupOwner as X, type Market as Y, MaxFeeExceeded as Z, MissingCorridorDep as _, type ArkadeCorridorDeps as a, pay as a$, ONCHAIN_CLAIM_FEE_RATE_SATVB as a0, type ObservationSeam as a1, type OfferPreparation as a2, type OnchainClaim as a3, type OnchainRefund as a4, OperatorUnreachable as a5, type ParsedRfqQuote as a6, type PayOptions as a7, type PayResult as a8, type QuoteCheck as a9, acceptQuote as aA, attesting as aB, cancelSwap as aC, canonicalAssetId as aD, cardMarketOf as aE, chooseMarket as aF, conflictingFields as aG, corridorSet as aH, createSwapClient as aI, createSwapDrive as aJ, discoveryIndex as aK, eligibleMarkets as aL, enforceFeeCeiling as aM, exchange as aN, feedFetch as aO, feedSpread as aP, isAddressable as aQ, isCardMarket as aR, isIndexedNetwork as aS, isSwapError as aT, isUsableCard as aU, liveArkadeInfo as aV, marketBackendOf as aW, marketKeyOf as aX, marketRefOf as aY, nostrTransportFactory as aZ, parseRfqQuote as a_, QuoteExpired as aa, type QuotePreparation as ab, QuoteVerificationFailed as ac, REGISTRY_URL as ad, type ReceiveArtifact as ae, type ReceiveOptions as af, type ReceiveRequest as ag, type RecoveryResult as ah, type RegisteredAsset as ai, type RfqAuctionPolicy as aj, type RfqPreparation as ak, type RfqQuoteInput as al, type RfqRendezvous as am, type RfqTransportFactory as an, type RouteSide as ao, SWAP_ERROR_NAMES as ap, type SwapClient as aq, type SwapClientConfig as ar, type SwapDrive as as, type SwapDriveConfig as at, SwapDriveRefusedError as au, type SwapError as av, type SwapErrorName as aw, type SwapFilter as ax, UnsupportedRoute as ay, type VerbDeps as az, type CorridorSet as b, quoteFromFeed as b0, quoteViaRfq as b1, readableRecord as b2, receive as b3, resolveCorridorBase as b4, resolveCorridorDeps as b5, rfqLeg as b6, rfqPairFor as b7, swapRecordOf as b8, toDiscoveryLeg as b9, usableMarkets as ba, verifyPlanLegs as bb, withCanonicalAmount as bc, type DiscoveryLeg as c, type DiscoverySnapshot as d, AcceptConflict as e, type AcceptInput as f, AmbiguousDestination as g, AmountEncodingUnsupported as h, AmountMismatch as i, type AssetRfqPreparation as j, type AttestingRfqTransport as k, CORRIDOR_FACTORIES as l, type CancelInput as m, type CancelOutcome as n, type ClaimedDestination as o, ClientDisposed as p, type CorridorBase as q, type CorridorClaim as r, type CorridorCovenant as s, type CorridorDeadline as t, type CorridorDeps as u, type CorridorDepsByCorridor as v, type CorridorDrive as w, type CorridorLockup as x, type CorridorModule as y, type CorridorOverrides as z };
@@ -1,8 +1,8 @@
1
1
  import { IWallet, NetworkName, Network, SignerSet, ArkadeInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret } from '@arkade-os/sdk';
2
- import { b5 as SwapOperator, d as AssetSwapRepository, m as Pubkey, b7 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b8 as RfqSwapActionName, N as NetworkRef, A as AssetId, aj as SnapshotRef, a1 as MarketBackend, U as CardMarketRef, a2 as MarketRef, z as AssetRef, r as AmountOn, ak as Swap, V as CorridorId, X as DepositArtifact, l as QuoteInput, a6 as Quote, ab as RankedBid, an as SwapUpdate, ao as Unsubscribe, S as SwapRecord, Q as QuoteId, a4 as Outcome, L as LockupSpendIndexer, b4 as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, D as AssetSwapId, al as SwapFamily, i as RouteResolution } from './repository-DYnRLPt-.js';
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-60PGpQ_x.js';
2
+ import { b5 as SwapOperator, d as AssetSwapRepository, m as Pubkey, b7 as RfqSwapManagerCallbacks, C as Corridor, I as Instrument, b8 as RfqSwapActionName, N as NetworkRef, A as AssetId, aj as SnapshotRef, a1 as MarketBackend, U as CardMarketRef, a2 as MarketRef, z as AssetRef, r as AmountOn, ak as Swap, V as CorridorId, X as DepositArtifact, l as QuoteInput, a6 as Quote, ab as RankedBid, an as SwapUpdate, ao as Unsubscribe, S as SwapRecord, Q as QuoteId, a4 as Outcome, L as LockupSpendIndexer, b4 as SwapContractRegistry, j as ResolvedEndpoint, P as PinnedAmount, O as OfferSwapRecord, D as AssetSwapId, al as SwapFamily, i as RouteResolution } from './repository-D_qvJk1S.js';
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-BgdgO9OO.js';
4
4
  import { Network as Network$1, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
5
- import { D as DerivedOffer } from './offer-Bd9Yvd8Z.js';
5
+ import { D as DerivedOffer } from './offer--IpfzhIm.js';
6
6
 
7
7
  /**
8
8
  * What a corridor is given, what a caller may replace, and where "overridden to nothing" is refused.
@@ -63,8 +63,12 @@ interface CorridorOverrides {
63
63
  /** How the trader's L1 claim is built and broadcast. Default: synthesized from
64
64
  * {@link claimFeeRateSatVb} when resolvable (see {@link OnchainCorridorDeps.claim}). */
65
65
  claim?: OnchainClaim | null;
66
+ /** How the trader's L1 refund of an `onchain -> arkade` funding is built and broadcast.
67
+ * Default: synthesized from {@link claimFeeRateSatVb} when resolvable (see
68
+ * {@link OnchainCorridorDeps.refund}). */
69
+ refund?: OnchainRefund | null;
66
70
  /**
67
- * Sat/vB the trader's L1 claim is built at, and the rate the take leg is grossed up by so the
71
+ * Sat/vB the trader's L1 claim (and refund) is built at, and the rate the take leg is grossed up by so the
68
72
  * recipient nets the requested amount. Default: {@link ONCHAIN_CLAIM_FEE_RATE_SATVB}.
69
73
  *
70
74
  * `null` is NOT a refusal here: it is "no default claim" — manual mode. The corridor still
@@ -78,6 +82,8 @@ interface CorridorOverrides {
78
82
  }
79
83
  /** Build and broadcast the L1 claim of an `arkade -> onchain` fill (the manager's own type). */
80
84
  type OnchainClaim = RfqSwapManagerCallbacks["claimOnchain"];
85
+ /** Build and broadcast the L1 refund of an `onchain -> arkade` funding (the manager's own type). */
86
+ type OnchainRefund = RfqSwapManagerCallbacks["refundOnchain"];
81
87
  /**
82
88
  * Per-network default L1 claim fee rate, sat/vB — deliberately the RELAY FLOOR, since it both builds
83
89
  * the claim and prices the gross-up. On mainnet override UPWARD in congestion: the claim has a
@@ -115,9 +121,14 @@ interface OnchainCorridorDeps {
115
121
  * {@link claimFeeRateSatVb}; with neither, the L1 half reports blocked while the Arkade lockup is
116
122
  * still driven and refunded. */
117
123
  readonly claim?: OnchainClaim;
124
+ /** The caller's L1 refund callback, verbatim. The default refund is built in the drive from
125
+ * {@link claimFeeRateSatVb}; with neither, an `onchain -> arkade` swap whose solver never
126
+ * funds reports blocked until one is wired. */
127
+ readonly refund?: OnchainRefund;
118
128
  /**
119
129
  * The one fee rate both recipient-exact halves share: the quote's gross-up (`claimFeeSats`) and
120
130
  * the default claim build. Two numbers would short the recipient. `undefined` = manual mode.
131
+ * The default refund is built at it too.
121
132
  */
122
133
  readonly claimFeeRateSatVb?: number;
123
134
  /**
@@ -189,7 +200,7 @@ type ObservationSeam =
189
200
  type CorridorCovenant =
190
201
  /** The Arkade-side VHTLC every corridor route has exactly one of. */
191
202
  "arkade_lockup"
192
- /** The L1 HTLC, which only `arkade -> onchain` adds. */
203
+ /** The L1 HTLC, which the onchain corridor adds in either direction. */
193
204
  | "onchain_htlc";
194
205
  /** Whose covenant it is. Ownership inverts the deadline: a TRADER lockup's deadline is a moment to
195
206
  * act after, a SOLVER lockup's a moment to have acted before. */
@@ -198,7 +209,7 @@ type LockupOwner = "trader" | "solver";
198
209
  type CorridorDeadline =
199
210
  /** `RfqSwapCommon.refundLocktime`, on every kind. */
200
211
  "refund_locktime"
201
- /** `OnchainSendSwap.htlc.refundLocktime`, on `arkade -> onchain` alone. */
212
+ /** The L1 HTLC's `htlc.refundLocktime`, on the onchain corridor alone. */
202
213
  | "htlc_refund_locktime";
203
214
  /** One covenant a pass reads, with its owner and the deadline it runs against. */
204
215
  interface CorridorLockup {
@@ -218,10 +229,8 @@ interface CorridorPass {
218
229
  readonly seams: readonly ObservationSeam[];
219
230
  }
220
231
  /**
221
- * A corridor's drive facts, per side. Partial on purpose: `onchain` has no `give` entry because
222
- * `onchain -> arkade` is outside the `Route` union (covering only its Arkade half would silently let
223
- * the trader's L1 refund window pass); `arkade` has neither, since `arkade -> arkade` is an offer
224
- * covenant with no lockup. The arkade leg's lockup is declared by the counter-corridor's entry.
232
+ * A corridor's drive facts, per side. Partial on purpose: `arkade` has neither, since
233
+ * `arkade -> arkade` is an offer covenant with no lockup. The arkade leg's lockup is declared by the counter-corridor's entry.
225
234
  */
226
235
  type CorridorDrive = Partial<Record<RouteSide, CorridorPass>>;
227
236
  /** One corridor. `deps` are closed over at construction because the parse needs them (network,
@@ -666,6 +675,8 @@ type DriveMode =
666
675
  * round, and nothing new is discovered.
667
676
  */
668
677
  | "readonly";
678
+ /** Default {@link SwapPolicy.maxRefundWindowSeconds}: 30 days. */
679
+ declare const DEFAULT_MAX_REFUND_WINDOW_SECONDS: number;
669
680
  interface SwapPolicy {
670
681
  /** How much the client drives on its own. Default `"auto"`. */
671
682
  readonly drive?: DriveMode;
@@ -700,6 +711,12 @@ interface SwapPolicy {
700
711
  * `QuoteExpired`, rather than handing back terms that would fail at `accept()`.
701
712
  */
702
713
  readonly quoteTtlFloorSeconds?: number;
714
+ /**
715
+ * The longest a send's funds may stay locked before the trader can refund, in seconds.
716
+ * Caps `refund_locktime` and the solo-refund delay; above it `quote()` throws
717
+ * `QuoteVerificationFailed("refund_window")`. Default {@link DEFAULT_MAX_REFUND_WINDOW_SECONDS}.
718
+ */
719
+ readonly maxRefundWindowSeconds?: number;
703
720
  /**
704
721
  * §10, reserved and inert: the published-RFQ auction's parameters.
705
722
  */
@@ -773,8 +790,8 @@ interface SwapDriveConfig {
773
790
  * `accept()` keeps its own refusal. */
774
791
  readonly repository?: AssetSwapRepository;
775
792
  /**
776
- * The client's corridors, for the L1 chain source and claim callback a drive pass needs.
777
- * Lazy, so a client with `null` onchain deps that never drives `arkade -> onchain` never
793
+ * The client's corridors, for the L1 chain source and claim/refund callbacks a drive pass
794
+ * needs. Lazy, so a client with `null` onchain deps that never drives an onchain swap never
778
795
  * resolves them.
779
796
  */
780
797
  readonly corridors: () => Promise<CorridorSet>;
@@ -1077,10 +1094,26 @@ type CorridorRfqPreparation = (CommonPreparation & {
1077
1094
  readonly htlcParams: OnchainHtlcParams;
1078
1095
  readonly l1Network: OnchainNetwork;
1079
1096
  readonly minConfirmations: number;
1097
+ }) | (CommonPreparation & {
1098
+ readonly route: "onchain->arkade";
1099
+ /** The Arkade claim: the key the solver's lockup pays, and the P that unlocks it. */
1100
+ readonly secrets: ProvisionedClaimSecret;
1101
+ readonly payoutAddress: string;
1102
+ /** What the solver's lockup must carry — the claim refuses less. */
1103
+ readonly expectedAmount: bigint;
1104
+ /** The HTLC's refund key, provisioned by the wallet like every other key. */
1105
+ readonly refundKey: ProvisionedKey;
1106
+ /** Where the L1 refund PAYS: a boarding address of this wallet. */
1107
+ readonly refundPkScript: Uint8Array;
1108
+ /** The L1 HTLC the trader funds, derived locally. */
1109
+ readonly htlc: OnchainHtlc;
1110
+ readonly htlcParams: OnchainHtlcParams;
1111
+ readonly l1Network: OnchainNetwork;
1112
+ readonly minConfirmations: number;
1080
1113
  });
1081
1114
  interface RfqQuoteInput {
1082
1115
  readonly quoteId: QuoteId;
1083
- readonly route: "arkade->arkade" | "arkade->lightning" | "lightning->arkade" | "arkade->onchain";
1116
+ readonly route: "arkade->arkade" | "arkade->lightning" | "lightning->arkade" | "arkade->onchain" | "onchain->arkade";
1084
1117
  readonly candidate: MarketCandidate;
1085
1118
  readonly market: CardMarketRef;
1086
1119
  readonly legs: {
@@ -1361,8 +1394,7 @@ declare class AmbiguousDestination extends Error {
1361
1394
  constructor(destination: string, detail: string);
1362
1395
  }
1363
1396
  /**
1364
- * The corridor pair is not in the implemented route union — `onchain -> arkade`
1365
- * included, until the manager owns the trader's L1 refund path end to end.
1397
+ * The corridor pair is not in the implemented route union.
1366
1398
  *
1367
1399
  * Boundary: route resolution, before RFQ disclosure, artifact creation, persistence or funding.
1368
1400
  * Also the alias layer (a rail no corridor serves), and `quote()` when no discovered market
@@ -1557,4 +1589,4 @@ declare function isSwapError<N extends SwapErrorName>(e: unknown, name: N): e is
1557
1589
  name: N;
1558
1590
  }>;
1559
1591
 
1560
- export { ONCHAIN_CLAIM_FEE_RATE_SATVB as $, type AssetAliasTable as A, type CorridorPass as B, type CorridorFactory as C, type DiscoveryIndex as D, type CorridorRfqPreparation as E, type DiscoveryConfig as F, type DiscoveryIndexInput as G, DiscoverySnapshotUnavailable as H, type DriveMode as I, type DriveRefusal as J, type ExchangeOptions as K, type LightningCorridorDeps as L, type MarketCandidate as M, FEED_TTL_MS as N, type OnchainCorridorDeps as O, type FeeCeiling as P, type FeedFetch as Q, type FeedQuoteInput as R, type SwapPolicy as S, INDEXED_NETWORKS as T, InconsistentRoute as U, InsufficientFunds as V, type LockupOwner as W, type Market as X, MaxFeeExceeded as Y, MissingCorridorDep as Z, NotCancellable as _, type ArkadeCorridorDeps as a, quoteViaRfq as a$, type ObservationSeam as a0, type OfferPreparation as a1, type OnchainClaim as a2, OperatorUnreachable as a3, type ParsedRfqQuote as a4, type PayOptions as a5, type PayResult as a6, type QuoteCheck as a7, QuoteExpired as a8, type QuotePreparation as a9, cancelSwap as aA, canonicalAssetId as aB, cardMarketOf as aC, chooseMarket as aD, conflictingFields as aE, corridorSet as aF, createSwapClient as aG, createSwapDrive as aH, discoveryIndex as aI, eligibleMarkets as aJ, enforceFeeCeiling as aK, exchange as aL, feedFetch as aM, feedSpread as aN, isAddressable as aO, isCardMarket as aP, isIndexedNetwork as aQ, isSwapError as aR, isUsableCard as aS, liveArkadeInfo as aT, marketBackendOf as aU, marketKeyOf as aV, marketRefOf as aW, nostrTransportFactory as aX, parseRfqQuote as aY, pay as aZ, quoteFromFeed as a_, QuoteVerificationFailed as aa, REGISTRY_URL as ab, type ReceiveArtifact as ac, type ReceiveOptions as ad, type ReceiveRequest as ae, type RecoveryResult as af, type RegisteredAsset as ag, type RfqAuctionPolicy as ah, type RfqPreparation as ai, type RfqQuoteInput as aj, type RfqRendezvous as ak, type RfqTransportFactory as al, type RouteSide as am, SWAP_ERROR_NAMES as an, type SwapClient as ao, type SwapClientConfig as ap, type SwapDrive as aq, type SwapDriveConfig as ar, SwapDriveRefusedError as as, type SwapError as at, type SwapErrorName as au, type SwapFilter as av, UnsupportedRoute as aw, type VerbDeps as ax, acceptQuote as ay, attesting as az, type CorridorSet as b, readableRecord as b0, receive as b1, resolveCorridorBase as b2, resolveCorridorDeps as b3, rfqLeg as b4, rfqPairFor as b5, swapRecordOf as b6, toDiscoveryLeg as b7, usableMarkets as b8, verifyPlanLegs as b9, withCanonicalAmount as ba, type DiscoveryLeg as c, type DiscoverySnapshot as d, AcceptConflict as e, type AcceptInput as f, AmbiguousDestination as g, AmountEncodingUnsupported as h, AmountMismatch as i, type AssetRfqPreparation as j, type AttestingRfqTransport as k, CORRIDOR_FACTORIES as l, type CancelInput as m, type CancelOutcome as n, type ClaimedDestination as o, ClientDisposed as p, type CorridorBase as q, type CorridorClaim as r, type CorridorCovenant as s, type CorridorDeadline as t, type CorridorDeps as u, type CorridorDepsByCorridor as v, type CorridorDrive as w, type CorridorLockup as x, type CorridorModule as y, type CorridorOverrides as z };
1592
+ export { NotCancellable as $, type AssetAliasTable as A, type CorridorPass as B, type CorridorFactory as C, type DiscoveryIndex as D, type CorridorRfqPreparation as E, DEFAULT_MAX_REFUND_WINDOW_SECONDS as F, type DiscoveryConfig as G, type DiscoveryIndexInput as H, DiscoverySnapshotUnavailable as I, type DriveMode as J, type DriveRefusal as K, type LightningCorridorDeps as L, type MarketCandidate as M, type ExchangeOptions as N, type OnchainCorridorDeps as O, FEED_TTL_MS as P, type FeeCeiling as Q, type FeedFetch as R, type SwapPolicy as S, type FeedQuoteInput as T, INDEXED_NETWORKS as U, InconsistentRoute as V, InsufficientFunds as W, type LockupOwner as X, type Market as Y, MaxFeeExceeded as Z, MissingCorridorDep as _, type ArkadeCorridorDeps as a, pay as a$, ONCHAIN_CLAIM_FEE_RATE_SATVB as a0, type ObservationSeam as a1, type OfferPreparation as a2, type OnchainClaim as a3, type OnchainRefund as a4, OperatorUnreachable as a5, type ParsedRfqQuote as a6, type PayOptions as a7, type PayResult as a8, type QuoteCheck as a9, acceptQuote as aA, attesting as aB, cancelSwap as aC, canonicalAssetId as aD, cardMarketOf as aE, chooseMarket as aF, conflictingFields as aG, corridorSet as aH, createSwapClient as aI, createSwapDrive as aJ, discoveryIndex as aK, eligibleMarkets as aL, enforceFeeCeiling as aM, exchange as aN, feedFetch as aO, feedSpread as aP, isAddressable as aQ, isCardMarket as aR, isIndexedNetwork as aS, isSwapError as aT, isUsableCard as aU, liveArkadeInfo as aV, marketBackendOf as aW, marketKeyOf as aX, marketRefOf as aY, nostrTransportFactory as aZ, parseRfqQuote as a_, QuoteExpired as aa, type QuotePreparation as ab, QuoteVerificationFailed as ac, REGISTRY_URL as ad, type ReceiveArtifact as ae, type ReceiveOptions as af, type ReceiveRequest as ag, type RecoveryResult as ah, type RegisteredAsset as ai, type RfqAuctionPolicy as aj, type RfqPreparation as ak, type RfqQuoteInput as al, type RfqRendezvous as am, type RfqTransportFactory as an, type RouteSide as ao, SWAP_ERROR_NAMES as ap, type SwapClient as aq, type SwapClientConfig as ar, type SwapDrive as as, type SwapDriveConfig as at, SwapDriveRefusedError as au, type SwapError as av, type SwapErrorName as aw, type SwapFilter as ax, UnsupportedRoute as ay, type VerbDeps as az, type CorridorSet as b, quoteFromFeed as b0, quoteViaRfq as b1, readableRecord as b2, receive as b3, resolveCorridorBase as b4, resolveCorridorDeps as b5, rfqLeg as b6, rfqPairFor as b7, swapRecordOf as b8, toDiscoveryLeg as b9, usableMarkets as ba, verifyPlanLegs as bb, withCanonicalAmount as bc, type DiscoveryLeg as c, type DiscoverySnapshot as d, AcceptConflict as e, type AcceptInput as f, AmbiguousDestination as g, AmountEncodingUnsupported as h, AmountMismatch as i, type AssetRfqPreparation as j, type AttestingRfqTransport as k, CORRIDOR_FACTORIES as l, type CancelInput as m, type CancelOutcome as n, type ClaimedDestination as o, ClientDisposed as p, type CorridorBase as q, type CorridorClaim as r, type CorridorCovenant as s, type CorridorDeadline as t, type CorridorDeps as u, type CorridorDepsByCorridor as v, type CorridorDrive as w, type CorridorLockup as x, type CorridorModule as y, type CorridorOverrides as z };