@arkade-os/swap 0.1.0-rc.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +45 -10
  2. package/dist/advanced.cjs +6429 -3083
  3. package/dist/advanced.d.cts +325 -282
  4. package/dist/advanced.d.ts +325 -282
  5. package/dist/advanced.js +343 -34
  6. package/dist/chunk-A3SHHRX4.js +104 -0
  7. package/dist/chunk-FMRAV77W.js +3065 -0
  8. package/dist/{chunk-HV7EIUE2.js → chunk-HRMWBULL.js} +1773 -634
  9. package/dist/chunk-WKJFXXSR.js +3382 -0
  10. package/dist/index.cjs +6868 -3837
  11. package/dist/index.d.cts +71 -243
  12. package/dist/index.d.ts +71 -243
  13. package/dist/index.js +139 -167
  14. package/dist/lockupContract-D7BNjksX.d.ts +148 -0
  15. package/dist/lockupContract-G-9CNRMq.d.cts +148 -0
  16. package/dist/node/index.cjs +61 -10
  17. package/dist/node/index.d.cts +310 -639
  18. package/dist/node/index.d.ts +310 -639
  19. package/dist/node/index.js +65 -10
  20. package/dist/nostr.cjs +428 -49
  21. package/dist/nostr.d.cts +59 -70
  22. package/dist/nostr.d.ts +59 -70
  23. package/dist/nostr.js +268 -36
  24. package/dist/offer-CcJfx5Fj.d.cts +269 -0
  25. package/dist/offer-DdB1M6FZ.d.ts +269 -0
  26. package/dist/offerFillPlan-BII0PW92.d.cts +1642 -0
  27. package/dist/offerFillPlan-CNTLVD7j.d.ts +1642 -0
  28. package/dist/protocol.cjs +5591 -4064
  29. package/dist/protocol.d.cts +258 -355
  30. package/dist/protocol.d.ts +258 -355
  31. package/dist/protocol.js +209 -228
  32. package/dist/repositories/realm/index.cjs +55 -11
  33. package/dist/repositories/realm/index.d.cts +18 -30
  34. package/dist/repositories/realm/index.d.ts +18 -30
  35. package/dist/repositories/realm/index.js +49 -12
  36. package/dist/repositories/sqlite/index.cjs +61 -10
  37. package/dist/repositories/sqlite/index.d.cts +7 -6
  38. package/dist/repositories/sqlite/index.d.ts +7 -6
  39. package/dist/repositories/sqlite/index.js +57 -11
  40. package/dist/repository-DmPzpbd7.d.ts +2342 -0
  41. package/dist/repository-DqdLVrVv.d.cts +2342 -0
  42. package/dist/rfq-C0tHOvn6.d.cts +983 -0
  43. package/dist/rfq-C0tHOvn6.d.ts +983 -0
  44. package/dist/watch-BonYT9af.d.cts +74 -0
  45. package/dist/watch-CmJQDtsy.d.ts +74 -0
  46. package/package.json +12 -12
  47. package/dist/chunk-4PATNGYQ.js +0 -3297
  48. package/dist/chunk-ARYFNDJY.js +0 -1432
  49. package/dist/chunk-U7VWWTL6.js +0 -66
  50. package/dist/errors-CSpOUdCN.d.ts +0 -2216
  51. package/dist/errors-DVn92LQd.d.cts +0 -2216
  52. package/dist/lockupContract-6TYZOBbn.d.ts +0 -490
  53. package/dist/lockupContract-aLCQQiSu.d.cts +0 -490
  54. package/dist/repository-D0gFF_GA.d.cts +0 -3491
  55. package/dist/repository-tDT8p-Nx.d.ts +0 -3491
  56. package/dist/rfq-DhkgiwQ7.d.cts +0 -1126
  57. package/dist/rfq-DhkgiwQ7.d.ts +0 -1126
  58. package/dist/watch-C4cMEeZT.d.cts +0 -96
  59. package/dist/watch-DbWXdpzm.d.ts +0 -96
@@ -1,36 +1,147 @@
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 './errors-DVn92LQd.cjs';
2
- export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AttestingRfqTransport, k as CORRIDOR_FACTORIES, l as CancelInput, m as CancelOutcome, n as ClaimedDestination, o as ClientDisposed, p as CorridorBase, q as CorridorClaim, r as CorridorCovenant, s as CorridorDeadline, t as CorridorDeps, u as CorridorDepsByCorridor, v as CorridorDrive, w as CorridorLockup, x as CorridorModule, y as CorridorOverrides, z as CorridorPass, B as DiscoveryConfig, E as DiscoveryIndexInput, F as DiscoverySnapshotUnavailable, G as DriveMode, H as DriveRefusal, I as ExchangeOptions, J as FEED_TTL_MS, K as FeeCeiling, N as FeedFetch, P as FeedQuoteInput, Q as INDEXED_NETWORKS, R as InconsistentRoute, T as InsufficientFunds, U as LockupOwner, V as Market, W as MaxFeeExceeded, X as MissingCorridorDep, Y as NotCancellable, Z as ONCHAIN_CLAIM_FEE_RATE_SATVB, _ as ObservationSeam, $ as OfferPreparation, a0 as OnchainClaim, a1 as OperatorUnreachable, a2 as ParsedRfqQuote, a3 as PayOptions, a4 as PayResult, a5 as QuoteCheck, a6 as QuoteExpired, a7 as QuotePreparation, a8 as QuoteVerificationFailed, a9 as REGISTRY_URL, aa as ReceiveArtifact, ab as ReceiveOptions, ac as ReceiveRequest, ad as RecoveryResult, ae as RegisteredAsset, af as RfqAuctionPolicy, ag as RfqPreparation, ah as RfqQuoteInput, ai as RfqRendezvous, aj as RfqTransportFactory, ak as RouteSide, al as SWAP_ERROR_NAMES, am as SwapClient, an as SwapClientConfig, ao as SwapDrive, ap as SwapDriveConfig, aq as SwapDriveRefusedError, ar as SwapError, as as SwapErrorName, at as SwapFilter, au as UnsupportedRoute, av as VerbDeps, aw as acceptQuote, ax as attesting, ay as cancelSwap, az as canonicalAssetId, aA as cardMarketOf, aB as chooseMarket, aC as conflictingFields, aD as corridorSet, aE as createSwapClient, aF as createSwapDrive, aG as discoveryIndex, aH as eligibleMarkets, aI as enforceFeeCeiling, aJ as exchange, aK as feedFetch, aL as isAddressable, aM as isCardMarket, aN as isIndexedNetwork, aO as isSwapError, aP as isUsableCard, aQ as liveArkadeInfo, aR as marketBackendOf, aS as marketKeyOf, aT as marketRefOf, aU as nostrTransportFactory, aV as parseRfqQuote, aW as pay, aX as quoteFromFeed, aY as quoteViaRfq, aZ as readableRecord, a_ as receive, a$ as resolveCorridorBase, b0 as resolveCorridorDeps, b1 as rfqLeg, b2 as rfqPairFor, b3 as swapRecordOf, b4 as toDiscoveryLeg, b5 as usableMarkets, b6 as withCanonicalAmount } from './errors-DVn92LQd.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-BII0PW92.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 createNostrTransportFactory, aR as createSwapClient, aS as createSwapDrive, aT as deepFreeze, aU as digestJointGraph, aV as discoveryIndex, aW as eligibleMarkets, aX as enforceFeeCeiling, aY as exchange, aZ as feedFetch, a_ as feedSpread, a$ as isAddressable, b0 as isCardMarket, b1 as isIndexedNetwork, b2 as isSwapError, b3 as isUsableCard, b4 as liveArkadeInfo, b5 as marketBackendOf, b6 as marketKeyOf, b7 as marketRefOf, b8 as nostrTransportFactory, b9 as parseRfqQuote, ba as pay, bb as quoteFromFeed, bc as quoteViaRfq, bd as readableRecord, be as receive, bf as resolveCorridorBase, bg as resolveCorridorDeps, bh as rfqLeg, bi as rfqPairFor, bj as swapRecordOf, bk as toDiscoveryLeg, bl as unsignedPsbtBytes, bm as usableMarkets, bn as verifyJointGraph, bo as verifyOfferFillPlan, bp as verifyPlanLegs, bq as withCanonicalAmount } from './offerFillPlan-BII0PW92.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, S as SwapRecord, O as OfferSwapRecord, c as AssetSwapRepository, d as RfqSwapRecord, L as LockupSpendIndexer, e as AssetSwapStatus, f as RouteResolution, g as ResolvedEndpoint, P as PinnedAmount, I as Instrument, h as Route, i as QuoteInput, j as Pubkey } from './repository-D0gFF_GA.cjs';
5
- export { k as ACTIVITY_TOKEN, l as ARKADE_ASSET_NAMESPACE, m as Amount, n as AmountFormatError, o as AmountOn, p as AmountRefusal, q as Artifact, r as AssetIdError, s as AssetIdRefusal, t as AssetNamespace, u as AssetOn, v as AssetPart, w as AssetRef, x as AssetScale, y as AssetSwapId, z as AtomicDecimal, B as AuctionMarketRef, D as AuctionProvenance, E as BITCOIN_RAILS, F as BTC_ASSET_PART, G as BitcoinRail, H as CORRIDORS, J as CORRIDOR_PASS, K as CardMarketRef, M as CorridorId, T as CorridorKind, U as DepositArtifact, V as DisplayDecimal, W as Endpoint, X as Ep, Y as Hex, Z as LOCKUP_OWNER, _ as MarketBackend, $ as MarketRef, a0 as OFFER_SWAP_ID_PREFIX, a1 as Outcome, a2 as ParsedAssetId, a3 as Quote, a4 as QuoteLeg, a5 as RAILS, a6 as RFQ_SWAP_ID_PREFIX, a7 as RailOf, a8 as RankedBid, a9 as RawState, aa as RecordedArtifact, ab as RecordedEndpoint, ac as RecordedInstrument, ad as RecordedLeg, ae as RfqAmountSide, af as SnapshotRef, ag as Swap, ah as SwapFamily, ai as SwapRecordCommon, aj as SwapUpdate, ak as Unsubscribe, al as arkadeAsset, am as artifactOf, an as assetPartOf, ao as assetSwapIdOf, ap as bitcoinNetworkOf, aq as btcOn, ar as corridorOfRail, as as corridorOutcome, at as decodeRfqAmount, au as encodeRfqAmount, av as familyOfSwapId, aw as formatAssetId, ax as fromAtomicDecimal, ay as fromRfqAmountSide, az as fundsFromWallet, aA as instrumentOf, aB as isAssetId, aC as isAtomicDecimal, aD as isNetworkRef, aE as issuanceOf, aF as legOf, aG as offerOutcome, aH as parseAssetId, aI as quoteIdOfSwapId, aJ as railOf, aK as railOfCorridor, aL as readsChain, aM as recordArtifact, aN as recordEndpoint, aO as recordInstrument, aP as recordLeg, aQ as recordOutcome, aR as sameAsset, aS as swapOf, aT as toAtomicDecimal, aU as toRfqAmountSide, aV as toSafeNumber } from './repository-D0gFF_GA.cjs';
6
- import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-DhkgiwQ7.cjs';
7
- export { S as SwapRefusal } from './rfq-DhkgiwQ7.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-DqdLVrVv.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-DqdLVrVv.cjs';
6
+ import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-C0tHOvn6.cjs';
7
+ export { S as SwapRefusal } from './rfq-C0tHOvn6.cjs';
8
8
  import * as btc from '@scure/btc-signer';
9
- import { OnchainProvider, NetworkName, IWallet, VHTLC } from '@arkade-os/sdk';
10
- import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-C4cMEeZT.cjs';
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-BonYT9af.cjs';
11
+ import './offer-CcJfx5Fj.cjs';
12
+ import 'nostr-tools';
11
13
 
14
+ /** The EVM leg's namespace. Which chain is the quote's `evm_chain_id`, not the pair. */
15
+ declare const EVM_CHAIN = "ethereum";
16
+ /** `ethereum:<token>`, lowercased: the solver's pair regex is lowercase-only while its profile
17
+ * address fields accept a checksum, so normalising only one of them yields `unsupported_pair`. */
18
+ declare const evmTokenLeg: (tokenAddress: string) => string;
19
+ /** `arkade:BTC->ethereum:<token>`: the client locks sats, the solver pays tokens. */
20
+ declare const evmSendPair: (tokenAddress: string) => string;
21
+ /** `ethereum:<token>->arkade:BTC`: the client locks tokens, the solver pays sats. */
22
+ declare const evmReceivePair: (tokenAddress: string) => string;
23
+ declare const evmDirectionOf: (pair: string) => "send" | "receive" | null;
24
+ /** The lowercase ERC20 an EVM pair names, or `null`. */
25
+ declare const evmTokenOf: (pair: string) => string | null;
26
+ declare const evmAmountToWire: (units: bigint) => string;
27
+ /** Refuses a JSON number outright: by the time it is here the parser may already have rounded it. */
28
+ declare const evmAmountFromWire: (value: unknown, field: string) => bigint;
29
+ /** Exact-in only: `amount` is sats, and the solver's schema pins `amount_side: "from"`. */
30
+ declare const evmSendRequest: (input: {
31
+ rfqId: string;
32
+ tokenAddress: string;
33
+ /** `sha256(P)`, hex. */
34
+ paymentHash: string;
35
+ /** Where the client takes the tokens; sent as given, keeping any EIP-55 checksum. */
36
+ evmClaimAddress: string;
37
+ /** The client's Arkade address, where the covenant refund pays. */
38
+ refundAddress: string;
39
+ /** The client's x-only key for the covenant's refund leaves. */
40
+ senderPubkey: Uint8Array;
41
+ amountSats: number;
42
+ }) => Record<string, unknown>;
43
+ /** The token amount rides the profile as `evm_amount`; the envelope has no `amount`, and the
44
+ * solver's strict schema refuses one. No `claim_packet`: the client must be online to claim. */
45
+ declare const evmReceiveRequest: (input: {
46
+ rfqId: string;
47
+ tokenAddress: string;
48
+ paymentHash: string;
49
+ evmAmount: bigint;
50
+ /** The client's own lock deadline, as a block height. */
51
+ evmTimeoutBlock: number;
52
+ evmRefundAddress: string;
53
+ payoutAddress: string;
54
+ /** The covenant's `receiver` role. */
55
+ payoutPubkey: Uint8Array;
56
+ }) => Record<string, unknown>;
57
+ interface EvmQuoteProfileCommon {
58
+ payment_hash: string;
59
+ /** Compare-only: never fund it without deriving the covenant locally. */
60
+ lockup_address: string;
61
+ evm_contract_address: string;
62
+ evm_chain_id: number;
63
+ /** Wait for both: a rollup can bury a lock in seconds before its L1 batch finalizes. */
64
+ min_confirmations: number;
65
+ min_age_seconds: number;
66
+ [key: string]: unknown;
67
+ }
68
+ interface EvmSendQuoteProfile extends EvmQuoteProfileCommon {
69
+ /** The solver's claim pkScript, needed to rebuild the covenant's merkle root. */
70
+ receiver_pk_script: string;
71
+ /** The solver's address, the refund role of its lock: the sixth swap-key field, and an
72
+ * explicit argument to `claim`. */
73
+ evm_refund_address: string;
74
+ /** A block height, unlike the unix-seconds `refund_locktime` beside it. */
75
+ evm_timeout_block: number;
76
+ }
77
+ interface EvmReceiveQuoteProfile extends EvmQuoteProfileCommon {
78
+ /** The solver's refund pkScript, needed to rebuild the covenant's merkle root. */
79
+ solver_refund_pk_script: string;
80
+ /** The `claimAddress` the client must lock to. */
81
+ evm_claim_address: string;
82
+ }
83
+ interface EvmSendQuote {
84
+ v: 1;
85
+ type: "rfq_quote";
86
+ rfq_id: string;
87
+ pair: string;
88
+ from_amount: number;
89
+ to_amount: string;
90
+ solver_pubkey: string;
91
+ valid_until: number;
92
+ refund_locktime: number;
93
+ profile: EvmSendQuoteProfile;
94
+ [key: string]: unknown;
95
+ }
96
+ interface EvmReceiveQuote {
97
+ v: 1;
98
+ type: "rfq_quote";
99
+ rfq_id: string;
100
+ pair: string;
101
+ from_amount: string;
102
+ to_amount: number;
103
+ solver_pubkey: string;
104
+ valid_until: number;
105
+ refund_locktime: number;
106
+ profile: EvmReceiveQuoteProfile;
107
+ [key: string]: unknown;
108
+ }
109
+ type EvmRfqQuote = EvmSendQuote | EvmReceiveQuote;
12
110
  /**
13
- * The alias table, filled from discovery.
14
- *
15
- * M1 declared {@link AssetAliasTable} and left it injected: the alias layer owns
16
- * no network, and the table's only real source is the market index, which is
17
- * this milestone's. So this is the inverse of `toDiscoveryLeg` -- a card's
18
- * corridor and `AssetInfo` back up to the public id a caller may write, plus the
19
- * ticker that id answers to.
20
- *
21
- * Tickers are display metadata on a card and identity nowhere, which is why the
22
- * table carries both and `canonicalAssetId` refuses a ticker that names two
23
- * assets rather than picking one. Rows are deduplicated by id and ticker, so a
24
- * ticker listed by nine solvers for the same asset is one row and not an
25
- * ambiguity.
111
+ * Checks a reply's shape and binds it to the request (rfq id, token, payment hash, chain, exact
112
+ * input). It does not make `lockup_address` safe to fund. Unknown fields are tolerated.
26
113
  */
114
+ declare const readEvmSendQuote: (payload: unknown, expected: {
115
+ tokenAddress: string;
116
+ rfqId: string;
117
+ paymentHash: string;
118
+ chainId: number;
119
+ amountSats: number;
120
+ }) => EvmSendQuote;
121
+ /** The receive-direction counterpart of {@link readEvmSendQuote}. */
122
+ declare const readEvmReceiveQuote: (payload: unknown, expected: {
123
+ tokenAddress: string;
124
+ rfqId: string;
125
+ paymentHash: string;
126
+ chainId: number;
127
+ evmAmount: bigint;
128
+ }) => EvmReceiveQuote;
129
+ /** The token leg of a quote, picked by its pair so the sats leg can never be read as tokens. */
130
+ declare const evmQuoteTokenAmount: (quote: EvmRfqQuote) => bigint;
131
+ /** The sats leg of a quote; see {@link evmQuoteTokenAmount}. */
132
+ declare const evmQuoteSats: (quote: EvmRfqQuote) => number;
27
133
 
28
134
  /**
29
- * The public id for one side of a card.
135
+ * The alias table, filled from discovery: the inverse of `toDiscoveryLeg`, mapping a card's
136
+ * corridor and `AssetInfo` back to the public id a caller may write, plus its ticker.
30
137
  *
31
- * `undefined` where the pair is not expressible as a public id: an
32
- * arkade-issued asset on lightning or L1, which no corridor carries, and an id
33
- * that is neither BTC nor the identity form.
138
+ * Tickers are display metadata, never identity, so `canonicalAssetId` refuses a ticker naming two
139
+ * assets. Rows dedupe by id and ticker, so nine solvers listing one asset is one row.
140
+ */
141
+
142
+ /**
143
+ * The public id for one side of a card, or `undefined` when not expressible: an arkade-issued
144
+ * asset on lightning or L1, or an id that is neither BTC nor the identity form.
34
145
  */
35
146
  declare const publicAssetId: (corridor: Corridor, assetId: string, network: NetworkRef) => AssetId | undefined;
36
147
  /** Every asset the snapshot names, as caller-writable ids and their tickers. */
@@ -38,15 +149,9 @@ declare const aliasTableFrom: (markets: readonly DiscoveredMarket[], network: Ne
38
149
  /**
39
150
  * The table narrowed to one rail.
40
151
  *
41
- * Q12 gives BTC one id per rail, so `"BTC"` names three assets the moment a
42
- * snapshot carries a corridor market — and the alias layer refuses a colliding
43
- * ticker rather than guessing, which is the right rule and would make the
44
- * spec's own `exchange({ give: "BTC", ... })` unresolvable if the table were
45
- * consulted whole. A ticker is therefore resolved on the leg's own rail: the
46
- * leg's corridor is already fixed by the destination, by `via`, or by being the
47
- * wallet's side, so the scope is a fact rather than a preference. Collisions
48
- * WITHIN a rail — two arkade assets both called `USDT` — still refuse, which is
49
- * the case the rule exists for.
152
+ * BTC has one id per rail (Q12), so a whole-table lookup of `"BTC"` would collide and refuse. The
153
+ * leg's rail is already fixed (by destination, `via`, or being the wallet's side), so resolving on
154
+ * it is a fact, not a preference. Collisions within a rail (two arkade `USDT`s) still refuse.
50
155
  */
51
156
  declare const scopedToRail: (table: AssetAliasTable, rail: Rail) => AssetAliasTable;
52
157
 
@@ -55,9 +160,8 @@ declare const DEFAULT_INVOICE_EXPIRY_SECONDS = 3600;
55
160
  /**
56
161
  * Decode a BOLT11 invoice into the facts the corridor needs.
57
162
  *
58
- * Signature-blind, like the library: nothing here proves the invoice was issued
59
- * by whoever offered it. What it does prove is that the payment hash the
60
- * corridor will compare against is the one the payer would pay to.
163
+ * Signature-blind, like the library: it does not prove who issued the invoice, only that the
164
+ * payment hash compared downstream is the one the payer would pay to.
61
165
  *
62
166
  * @throws when the string is not a decodable BOLT11 invoice, or decodes without
63
167
  * the timestamp or payment hash BOLT11 requires.
@@ -80,20 +184,13 @@ interface ChainSourceBackend {
80
184
  * core's `Network` and `L1_NETWORKS`' entries both satisfy it directly. */
81
185
  type AddressParams = typeof btc.NETWORK;
82
186
  /**
83
- * A {@link ChainSource} over an arbitrary L1 backend.
84
- *
85
- * Separate from {@link esploraChainSource} so the adapter's logic — the
86
- * confirmations arithmetic, the script-to-address encode, the missing-spender
87
- * fallback — is exercisable without a server, and so a caller with its own
88
- * `OnchainProvider` can reuse it.
187
+ * A {@link ChainSource} over an arbitrary L1 backend, so a caller with its own `OnchainProvider`
188
+ * can reuse the adapter logic, and tests can run it without a server.
89
189
  */
90
190
  declare const chainSourceOver: (backend: ChainSourceBackend, network: AddressParams) => ChainSource;
91
191
  /**
92
- * Tip height and median-time-past off Esplora's `/blocks`.
93
- *
94
- * `/blocks` rather than `/blocks/tip`, for the reason core already records:
95
- * the latter is not part of the Esplora spec — electrs serves it as an alias,
96
- * a strict backend like mempool answers an empty array.
192
+ * Tip height and median-time-past off Esplora's `/blocks`. Not `/blocks/tip`: that is not in the
193
+ * Esplora spec (electrs aliases it, mempool answers an empty array).
97
194
  */
98
195
  declare const esploraTip: (esploraUrl: string, fetchImpl?: typeof fetch) => Promise<L1Tip>;
99
196
  /** The default: core's Esplora provider at `esploraUrl`, with the tip read off
@@ -113,44 +210,27 @@ declare const arkadeCorridor: CorridorFactory<ArkadeCorridorDeps>;
113
210
  /**
114
211
  * The lightning corridor: a BOLT11 invoice, on this wallet's network.
115
212
  *
116
- * Core settles the shape and stops there — `isLightningInvoice` matches the HRP
117
- * and a bech32 tail, strips a `lightning:` prefix, and by its own comment
118
- * carries no bolt11 dependency and so no checksum and no decode. The two gaps
119
- * are this module's, and §6 puts both at the parse boundary.
120
- *
121
- * The HRP-to-network table exists in neither package, so it is authored here.
122
- * Two of its facts are worth stating because a test could otherwise claim more
123
- * than the vocabulary can express: `lntbs` is signet AND mutinynet, which share
124
- * an HRP exactly as they share `tark`, so a signet-versus-mutinynet rejection is
125
- * not expressible; and `lnsb` (simnet) is admitted by core's regex — five
126
- * prefixes, where §6 names four — and named by no `NetworkName`, so it is
127
- * refused rather than mapped to a neighbour.
213
+ * Core's `isLightningInvoice` checks shape only (no checksum, no decode), so the network
214
+ * match and decode happen here. `lntbs` is both signet and mutinynet, so a
215
+ * signet-versus-mutinynet mismatch is not detectable; `lnsb` (simnet) passes core's regex
216
+ * but names no `NetworkName`, so it is refused rather than mapped to a neighbour.
128
217
  *
129
- * Of §6's parse-boundary gates, this module owns three: the HRP check, the
130
- * invoice expiry, and the amountless refusal. The rest read the quote — the
131
- * headroom check needs `quote.refund_locktime` and no parse has a quote — and
132
- * belong to the quote path.
218
+ * Gates owned here: HRP, invoice expiry, amountless refusal. Gates that need the quote
219
+ * (e.g. headroom vs `quote.refund_locktime`) belong to the quote path.
133
220
  */
134
221
 
135
222
  /**
136
- * Which networks an invoice HRP can belong to.
137
- *
138
- * An ordered list rather than a record, because the order is load-bearing:
139
- * `lnbcrt` has to be tested before `lnbc` and `lntbs` before `lntb`, and a
140
- * record would leave that to key-iteration order.
223
+ * Which networks an invoice HRP can belong to. Ordered, not a record: `lnbcrt` must be
224
+ * tested before `lnbc` and `lntbs` before `lntb`.
141
225
  */
142
226
  declare const INVOICE_HRPS: readonly [readonly ["lnbcrt", readonly ["regtest"]], readonly ["lntbs", readonly ["signet", "mutinynet"]], readonly ["lnbc", readonly ["bitcoin"]], readonly ["lntb", readonly ["testnet"]]];
143
227
  /** The networks `raw`'s HRP names, or `undefined` for one no network claims. */
144
228
  declare const networksOfInvoiceHrp: (raw: string) => readonly NetworkName[] | undefined;
145
229
  /**
146
- * Both directions, and the ownership inverts between them.
147
- *
148
- * On `arkade -> lightning` the trader funds the lockup, so `refundLocktime` is
149
- * the trader's and is a moment to act AFTER — the only action is the Arkade
150
- * refund, since the solver claims the lockup with the preimage it learns by
151
- * paying. On `lightning -> arkade` the solver funds it: every non-claim leaf is
152
- * the solver's, the trader has no refund at all, and the deadline is a moment to
153
- * have claimed BEFORE.
230
+ * Both directions, with ownership inverted. `arkade -> lightning`: the trader funds the
231
+ * lockup, so `refundLocktime` is a moment to refund AFTER (the solver claims with the
232
+ * preimage it learns by paying). `lightning -> arkade`: the solver funds it, the trader
233
+ * has no refund, and the deadline is a moment to have claimed BEFORE.
154
234
  */
155
235
  declare const LIGHTNING_DRIVE: {
156
236
  readonly give: {
@@ -175,20 +255,13 @@ declare const LIGHTNING_DRIVE: {
175
255
  declare const lightningCorridor: CorridorFactory<LightningCorridorDeps>;
176
256
 
177
257
  /**
178
- * One direction only, and the absence is the decision.
258
+ * On `onchain -> arkade` the Arkade lockup is the solver's and the L1 HTLC's refund leaf the
259
+ * trader's own: the trader claims the lockup, or takes its L1 funding back after
260
+ * `htlc.refundLocktime`.
179
261
  *
180
- * `onchain -> arkade` gets no entry because it is outside the `Route` union:
181
- * its Arkade half is the same solver-funded lockup a lightning receive has, but
182
- * it adds an L1 half the trader funds and must take back itself — a second
183
- * deadline, a second observation seam AND a second action callback. Declaring
184
- * the lockup half alone is what would produce a manager that silently lets the
185
- * trader's L1 refund window pass.
186
- *
187
- * On `arkade -> onchain` the pass reads two covenants and they have different
188
- * owners. The Arkade lockup is the trader's, and `refundLocktime` is the moment
189
- * the money comes back. The L1 HTLC is the solver's on its refund leaf — the
190
- * trader holds only the claim key — so reaching `htlc.refundLocktime` does not
191
- * mean "refund the HTLC", it means the claim was missed.
262
+ * On `arkade -> onchain` the two covenants have different owners: the Arkade lockup is
263
+ * the trader's (`refundLocktime` = money comes back), but the L1 HTLC's refund leaf is
264
+ * the solver's, so reaching `htlc.refundLocktime` means the claim was missed.
192
265
  */
193
266
  declare const ONCHAIN_DRIVE: {
194
267
  readonly take: {
@@ -204,39 +277,38 @@ declare const ONCHAIN_DRIVE: {
204
277
  readonly actions: readonly ["claimOnchain", "refundArkade"];
205
278
  readonly seams: readonly ["indexer", "chain"];
206
279
  };
280
+ readonly give: {
281
+ readonly lockups: readonly [{
282
+ readonly covenant: "arkade_lockup";
283
+ readonly owner: "solver";
284
+ readonly deadline: "refund_locktime";
285
+ }, {
286
+ readonly covenant: "onchain_htlc";
287
+ readonly owner: "trader";
288
+ readonly deadline: "htlc_refund_locktime";
289
+ }];
290
+ readonly actions: readonly ["claimLockup", "refundOnchain"];
291
+ readonly seams: readonly ["indexer", "chain"];
292
+ };
207
293
  };
208
294
  declare const onchainCorridor: CorridorFactory<OnchainCorridorDeps>;
209
295
 
210
296
  /**
211
- * The three seams between the v2 record store and v1's drive machinery.
212
- *
213
- * **The record bridge is the load-bearing one.** `RfqSwapManager` restores from
214
- * `getAllRfqSwaps()`, while `accept()` writes `saveSwapRecord` into a keyspace
215
- * `repository.ts` rules disjoint from it by design. So without this file the
216
- * manager's restore-read returns nothing for every v2-accepted swap, and the
217
- * whole drive — `ready`, arm-on-live-work, the outcome projections, recovery —
218
- * rests on an empty set.
219
- *
220
- * The bridge is cheap because M4 designed the record to admit it:
221
- * {@link CorridorSwapRecord} carries every {@link RfqSwapRecord} field but the
222
- * optional display `amount` the rebuild ignores, and `RfqSwapRecordStore` is a
223
- * four-method structural seam. Three rulings come with it.
224
- *
225
- * - **The store is wired as the manager's `repository` dep**, not left unwired.
226
- * `restoreFromRepository` opens with `requireRepository`, so the unwired
227
- * branch costs a hand-rolled restore rather than a storage-shape choice.
228
- * - **It carries an `rfqId -> QuoteId` index**, because the manager keys every
229
- * callback on `rfqId` while the v2 store keys on `QuoteId`. Without it
230
- * `arkadeRefunder` misses its record and throws
231
- * `RefundNotLocallyPossibleError` — the one refusal the manager reads as
232
- * PERMANENT — leaving every v2 send leg blocked for its whole refund window
233
- * with the lockup funded.
234
- * - **`removeRfqSwap` is inert.** `restoreFromRepository` runs `dropRetired`
235
- * before the rebuild, which would hard-delete v2 records under v1's
236
- * thirty-day retention before `client.ready` resolves. v2 retention is M6's
237
- * open question, and settling it here by side effect is not M5's to do. The
238
- * manager still drops its in-memory copies, so an aged terminal record is not
239
- * rebuilt; the record itself survives.
297
+ * The seams between the v2 record store and v1's drive machinery.
298
+ *
299
+ * **The record bridge is the load-bearing one.** `RfqSwapManager` restores from `getRfqSwapsPage()`,
300
+ * while `accept()` writes `saveSwapRecord` into a disjoint keyspace, so without this file the
301
+ * manager's restore returns nothing for every v2-accepted swap. {@link CorridorSwapRecord} carries
302
+ * every {@link RfqSwapRecord} field but the ignored display `amount`, which keeps the bridge cheap.
303
+ *
304
+ * - **The store is wired as the manager's `repository` dep**: `restoreFromRepository` opens with
305
+ * `requireRepository`, so leaving it unwired would mean a hand-rolled restore.
306
+ * - **It carries an `rfqId -> QuoteId` index**: manager callbacks key on `rfqId`. Without it
307
+ * `arkadeRefunder` misses its record and throws `RefundNotLocallyPossibleError` — which the
308
+ * manager reads as PERMANENT — blocking every v2 send leg for its refund window with funds locked.
309
+ * - **`removeRfqSwap` is inert**: `restoreFromRepository` runs `dropRetired` first, which would
310
+ * hard-delete v2 records under v1's thirty-day retention before `client.ready` resolves. v2
311
+ * retention is still undecided. The manager still drops its in-memory copy; the record survives.
240
312
  */
241
313
 
242
314
  /** Every stored corridor record, and every offer record, in one read. */
@@ -244,25 +316,18 @@ declare const splitRecords: (records: readonly SwapRecord[]) => {
244
316
  corridor: CorridorSwapRecord[];
245
317
  offer: OfferSwapRecord[];
246
318
  };
247
- /**
248
- * A v2 corridor record as the manager's own record type.
249
- *
250
- * Field for field, minus the display `amount` — `rebuildRfqSwap` reads none of
251
- * it, and inventing one would put a number on the record that no request result
252
- * produced.
253
- */
319
+ /** A v2 corridor record as the manager's own record type, minus the display `amount`
320
+ * (`rebuildRfqSwap` reads none, and inventing one would record a number no request produced). */
254
321
  declare const rfqRecordOf: (record: CorridorSwapRecord) => RfqSwapRecord;
255
322
  /**
256
- * The manager's mutable half, written back onto the v2 record.
257
- *
258
- * REPLACED, not merged, exactly as `updateRfqSwapRecord` replaces it: the
259
- * manager clears `blockedReason` when a swap leaves `needs_counterparty` and
260
- * `claimFailure` when it becomes terminal, and a spread would only ever set
261
- * these fields, never clear them — leaving a stale refusal reading as a live
262
- * one. The origin half is carried through untouched, `fundingTxid` included:
263
- * the manager never learns it, so it can only be the accept path's.
323
+ * The manager's mutable half, written back onto the v2 record. REPLACED, not merged (as
324
+ * `updateRfqSwapRecord` does): the manager clears `blockedReason`/`claimFailure`, and a spread could
325
+ * never clear them, leaving a stale refusal reading as live. The origin half, `fundingTxid`
326
+ * included, is carried through untouched — the manager never learns it.
264
327
  */
265
328
  declare const withRfqState: (record: CorridorSwapRecord, state: RfqSwapRecord) => CorridorSwapRecord;
329
+ /** One keyset page over records already in memory, in the repository's `(updatedAt, rfqId)` order. */
330
+ declare const pageRfqRecords: (records: readonly RfqSwapRecord[], filter: RfqSwapPageFilter, page: PageRequest<RfqSwapPageCursor>) => PageResult<RfqSwapRecord, RfqSwapPageCursor>;
266
331
  /** What a bridge or source hands back to the drive after a write. */
267
332
  type RecordSink = (record: SwapRecord) => void;
268
333
  interface CorridorRecordStore extends RfqSwapRecordStore {
@@ -273,36 +338,23 @@ interface CorridorRecordStore extends RfqSwapRecordStore {
273
338
  quoteIdOf(rfqId: string): QuoteId | undefined;
274
339
  }
275
340
  /**
276
- * The v2 record store, as the manager's `repository` dep.
277
- *
278
- * Every read goes to the repository rather than to a cache: the store is the
279
- * system of record, and the manager's own read-then-write per pass exists so a
280
- * consumer's edit is not overwritten by a copy taken at boot. The index is the
281
- * only thing held in memory, and it is a pure lookup — a miss costs one full
282
- * scan and never a wrong answer.
341
+ * The v2 record store, as the manager's `repository` dep. Every read goes to the repository (the
342
+ * system of record), so a consumer's edit is never overwritten by a boot-time copy. Only the index
343
+ * is in memory; a miss costs one scan, never a wrong answer.
283
344
  */
284
345
  declare const corridorRecordStore: (repository: AssetSwapRepository, onRecord?: RecordSink,
285
346
  /**
286
- * Which stored records the restore may hand to the manager.
287
- *
288
- * The filter exists for two cases. An `arkade -> onchain` record on a client
289
- * whose chain source was refused: `restoreFromRepository` restores
290
- * everything it reads, and the manager fails an onchain-send swap
291
- * TERMINALLY on its first pass without a `ChainSource` — a deliberate
292
- * refusal to watch that corridor blind. Excluding the record here leaves it
293
- * durable, undriven and reporting off itself, which is the honest answer to
294
- * "this client cannot drive this swap".
295
- *
296
- * And a record in a terminal state, which the drive excludes: the manager
297
- * would rebuild it only to file it in `finished`, so handing it over pays
298
- * a covenant derivation and a contract row lookup per record for nothing.
299
- * The record itself stays readable — it is still in the drive's registry
300
- * and still answers off its own stored state.
347
+ * Which stored records the restore may hand to the manager. Two cases:
348
+ * - an `arkade -> onchain` record on a client whose chain source was refused — the manager would
349
+ * fail it TERMINALLY on its first pass; excluded, it stays durable, undriven and self-reporting;
350
+ * - a terminal record, which the manager would rebuild only to file as finished (a covenant
351
+ * derivation and row lookup for nothing). It stays readable in the drive's registry.
301
352
  */
302
353
  admits?: (record: CorridorSwapRecord) => boolean) => CorridorRecordStore;
303
354
  /** A v2 offer record as the watcher and coverage read one. */
304
355
  declare const offerFactsOf: (record: OfferSwapRecord) => OfferSwapFacts & {
305
356
  id: QuoteId;
357
+ coverageId: QuoteId;
306
358
  };
307
359
  /** The v2 offer half of the record store, as the watcher's source. */
308
360
  declare const offerRecordSource: (repository: AssetSwapRepository, onRecord?: RecordSink, now?: () => number) => OfferSwapSource<OfferSwapFacts & {
@@ -310,42 +362,51 @@ declare const offerRecordSource: (repository: AssetSwapRepository, onRecord?: Re
310
362
  }>;
311
363
  /** One classified spend, written onto a v2 offer record. */
312
364
  declare const applyOfferSpend: (record: OfferSwapRecord, changes: OfferSpendChanges, now: number) => OfferSwapRecord;
313
- /** A restored deposit's status, written onto a v2 offer record. */
314
- declare const withOfferStatus: (record: OfferSwapRecord, status: AssetSwapStatus, now: number) => OfferSwapRecord;
365
+ /** What the restore scan learned about one deposit. */
366
+ interface DepositFate {
367
+ readonly status: AssetSwapStatus;
368
+ readonly spentTxid?: string;
369
+ /** Unix milliseconds, as `AssetSwap` carries it. */
370
+ readonly completedAt?: number;
371
+ }
372
+ /** A deposit's fate written onto its record. The spend too: the watcher only
373
+ * writes a spend it saw, and it sees nothing between two clients. */
374
+ declare const withDepositFate: (record: OfferSwapRecord, fate: DepositFate, now: number) => OfferSwapRecord;
375
+ /** Whether the fate says anything the record does not; the write it gates re-emits the swap. */
376
+ declare const fateMoved: (record: OfferSwapRecord, fate: DepositFate) => boolean;
315
377
  /**
316
- * The wallet's own reader, as the manager's one required observation seam.
317
- *
318
- * Lifted from the v1 facade unchanged, guard included: the reader reads for
319
- * NAMED foreign scripts and has no "the wallet's own" default, so a call with
320
- * neither scripts nor outpoints is a caller bug rather than a query. Built from
321
- * the wallet rather than injected on `SwapClientConfig`, because the wallet is
322
- * where every other connection in this client comes from — a client takes no
323
- * server URL and no provider. The drive layer still takes it as an input, which
324
- * is what lets a unit test double one without a wallet behind it.
378
+ * An offer record for a deposit the restore scan found and no record claims. Keyed on the funding
379
+ * txid so a re-scan updates rather than duplicates. The chain lacks the market, solver, spread and
380
+ * deadline, hence `market.kind: "restored"` and a zero fee.
381
+ */
382
+ declare const restoredOfferRecord: (swap: AssetSwap, network: NetworkRef, now: number) => OfferSwapRecord;
383
+ /**
384
+ * A corridor record for a v1 `rfqSwaps` row. v1 kept one display `amount` and no quote, invoice or
385
+ * solver key, so both legs carry that amount, the fee is zero, Lightning legs stand in as
386
+ * `wallet`, and `market.kind` is `"restored"`. Throws when the row has no payment hash or its
387
+ * lockup address does not decode.
388
+ */
389
+ declare const restoredCorridorRecord: (stored: RfqSwapRecord, network: NetworkRef, refundLocktime: number) => CorridorSwapRecord;
390
+ /**
391
+ * The wallet's own reader, as the manager's required observation seam. The reader reads NAMED
392
+ * foreign scripts and has no "own wallet" default, so a call with neither scripts nor outpoints is a
393
+ * caller bug. Built from the wallet (the client takes no server URL or provider); the drive still
394
+ * takes it as an input so unit tests can double it.
325
395
  */
326
396
  declare const walletLockupIndexer: (wallet: IWallet) => LockupSpendIndexer;
327
397
 
328
398
  /**
329
- * Route resolution: the single place `to` is parsed, the corridor pair is
330
- * decided, the amount is pinned and the market is chosen — everything that has
331
- * to happen before a solver is told anything.
399
+ * Route resolution: the single place `to` is parsed, the corridor pair decided, the
400
+ * amount pinned and the market chosen — everything before a solver is told anything.
332
401
  *
333
- * The order is §3.1's and it is load-bearing. `to` is parsed first, because a
334
- * destination fault is the caller's most likely mistake and the parse needs no
335
- * market data. The corridor pair follows from the parse (or from `via` on a
336
- * receive, the one flow where no instrument can exist yet), and it selects the
337
- * `Route` variant — a pair outside the union is `UnsupportedRoute` here, before
338
- * an RFQ round trip, an artifact or a record. Only then does the market index
339
- * come in, and only then can a ticker be canonicalized, since the table a ticker
340
- * resolves against is built out of the cards themselves.
341
- *
342
- * The amount is pinned last and before any network call: exactly one may be
343
- * pinned, by the caller or by an invoice, and two is `AmountMismatch` — thrown
344
- * with nothing disclosed, which is the whole reason it is thrown here.
402
+ * The order (§3.1) is load-bearing: `to` first (needs no market data); the pair selects
403
+ * the `Route` variant, refusing unsupported pairs before any round trip or record; only
404
+ * then the market index, since tickers resolve against the cards themselves. Exactly one
405
+ * amount may be pinned; two is `AmountMismatch`, thrown here so nothing is disclosed.
345
406
  */
346
407
 
347
- /** The four implemented corridor pairs, spelled as the route union spells them. */
348
- declare const SUPPORTED_PAIRS: readonly ["arkade->arkade", "arkade->lightning", "lightning->arkade", "arkade->onchain"];
408
+ /** The five implemented corridor pairs, spelled as the route union spells them. */
409
+ declare const SUPPORTED_PAIRS: readonly ["arkade->arkade", "arkade->lightning", "lightning->arkade", "arkade->onchain", "onchain->arkade"];
349
410
  type SupportedPair = (typeof SUPPORTED_PAIRS)[number];
350
411
  interface ResolveDeps {
351
412
  readonly corridors: CorridorSet;
@@ -354,12 +415,8 @@ interface ResolveDeps {
354
415
  readonly discovery: DiscoveryIndex;
355
416
  readonly policy?: SwapPolicy;
356
417
  /**
357
- * `resolve()` reads what is in hand; `quote()` may fetch.
358
- *
359
- * The one difference between the two paths, and the reason it is a flag
360
- * rather than two functions: everything else about resolution — the parse,
361
- * the pair, the pin, the veto — has to be identical, or the resolution a
362
- * caller vetoed would not be the one they quoted.
418
+ * `resolve()` reads what is in hand; `quote()` may fetch. A flag, not two functions,
419
+ * so the resolution a caller vetoed is exactly the one they quote.
363
420
  */
364
421
  readonly mode: "resolve" | "quote";
365
422
  }
@@ -385,12 +442,9 @@ interface ResolvedRoute {
385
442
  /**
386
443
  * Assemble the closed `Route` from two fully-instrumented legs.
387
444
  *
388
- * The one cast in the quote path, and it is confined to this function. The
389
- * checker cannot correlate `corridor` and `asset` across two independently
390
- * resolved values, but the pairing is a fact by the time we are here: every
391
- * asset went through `toDiscoveryLeg`, which is what decided the corridor. The
392
- * runtime re-check is cheap and turns a broken invariant into a throw at the
393
- * boundary rather than a covenant built against the wrong rail.
445
+ * The quote path's one cast: the type checker cannot correlate `corridor` and `asset`,
446
+ * so the runtime re-check turns a broken invariant into a throw rather than a covenant
447
+ * built against the wrong rail.
394
448
  */
395
449
  declare const assembleRoute: (give: ResolvedEndpoint & {
396
450
  instrument: Instrument;
@@ -403,46 +457,25 @@ declare const resolveRoute: (input: QuoteInput, deps: ResolveDeps) => Promise<Re
403
457
  declare const satsOf: (value: bigint, field: string) => number;
404
458
 
405
459
  /**
406
- * Verification, as one invariant instead of four scattered habits.
407
- *
408
- * v1 spreads these checks across four request entrypoints and reaches the offer
409
- * path with none of them: `expectQuote` compares type, id and pair;
410
- * `verifyLockupAddress` compares the derived address; `assertFundable`,
411
- * `verifyReceiveInvoice` and `assertReceivable` gate expiry, headroom and the
412
- * claim window on some legs and not others; and the docs push the rest — plan
413
- * validation, the rendezvous choice, the invoice decode — onto the caller. This
414
- * module runs the whole set, once, on both backends, before any quote is
415
- * returned, and every failure is one error class with the check named on it.
460
+ * Quote verification as one invariant: every check runs once, on both backends, before any quote
461
+ * is returned, and every failure is one error class naming the check.
416
462
  *
417
- * The gates themselves are still `rfq.ts`'s. They are audited, they carry the
418
- * constants (`MIN_HEADROOM_SECONDS`, `MIN_CLAIM_WINDOW_SECONDS`) that mirror the
419
- * covenant's own timing, and re-implementing them here would be a second
420
- * opinion where the whole point is that there is one. What this adds is the
421
- * mapping: a gate's stable `reason` becomes a {@link QuoteCheck}, so a caller
422
- * switches on the check rather than on a string the wire's own vocabulary
423
- * leaked.
463
+ * The gates themselves stay `rfq.ts`'s (audited, and carrying the covenant-mirroring timing
464
+ * constants); this only maps a gate's stable `reason` to a {@link QuoteCheck}.
424
465
  *
425
- * Two failures deliberately do NOT become verification failures. A solver
426
- * declining is `SwapRefusal` — a decision, not a fault. And a quote that has
427
- * expired, or is about to, is `QuoteExpired`: the terms were fine, the clock is
428
- * the problem, and the remedy is a fresh quote rather than a different solver.
466
+ * Two failures are deliberately NOT verification failures: a solver declining is `SwapRefusal`,
467
+ * and an expired or expiring quote is `QuoteExpired` (the remedy is a fresh quote, not a
468
+ * different solver).
429
469
  */
430
470
 
431
471
  /**
432
472
  * The fifth check: who answered.
433
473
  *
434
- * §3.1 calls this a transport property rather than one of the four, and it is —
435
- * but a property only the production transport happens to have is a check the
436
- * caller can turn off by handing in a different transport, and verification that
437
- * configuration can disable is not an invariant. So the transport delivers the
438
- * attestation and this runs it, in addressed mode only: published RFQ has N
439
- * unknown responders and attributes each bid by its own signature instead.
474
+ * Run here, not left to the transport, so swapping in a different transport cannot disable it.
475
+ * Addressed mode only: published RFQ attributes each bid by its own signature.
440
476
  *
441
- * `pinnable` is the trust boundary the cache leaves. The key this compares
442
- * against is the card's `discovery_pubkey`, which a cached card carries
443
- * unvalidated — so a snapshot read back out of local storage cannot supply it,
444
- * and the check fails closed rather than pinning against content anyone with
445
- * write access to the browser's storage could have chosen.
477
+ * `pinnable` is the trust boundary: a cached card's `discovery_pubkey` is unvalidated (anyone with
478
+ * write access to browser storage could choose it), so a cache-sourced key fails closed.
446
479
  */
447
480
  declare const verifyResponder: (input: {
448
481
  /** The key this transport proves every reply came from, if it proves one. */
@@ -453,24 +486,15 @@ declare const verifyResponder: (input: {
453
486
  readonly pinnable: boolean;
454
487
  }) => void;
455
488
  /**
456
- * The pair check, run here as well as in the transport.
457
- *
458
- * `expectQuote` already compares it — this is not a gap being filled but the
459
- * layer that OWNS the string doing its own comparison, so a transport that
460
- * skips the check (or one a caller injected) cannot make the quote path skip it
461
- * too. v1 documented this one as the caller's job, in bold.
489
+ * The pair check, run here as well as in the transport's `expectQuote`, so a transport that skips
490
+ * it (or one a caller injected) cannot make the quote path skip it too.
462
491
  */
463
492
  declare const verifyPair: (quoted: unknown, requested: string) => void;
464
493
  /**
465
- * Derive the covenant, and fold every way that can fail into one check.
494
+ * Derive the covenant, and fold every way that can fail into the `lockup_address` check.
466
495
  *
467
- * `AddressMismatch` is the case §8 promised would fold in here: it is the
468
- * `lockup_address` check under its v1 name, and keeping it as a seventeenth
469
- * error would leave two classes for one condition across the v1/v2 seam. The
470
- * other failures — a missing binding field, malformed hex from the solver — are
471
- * the same check reached from further back: an address that cannot be derived
472
- * cannot be compared, and both mean the same thing to a caller, which is do not
473
- * fund this.
496
+ * `AddressMismatch` is that check under its v1 name; a missing binding field or malformed solver
497
+ * hex is the same check reached earlier. All mean "do not fund this".
474
498
  */
475
499
  declare const verifyingDerivation: <T>(derive: () => T) => T;
476
500
  /**
@@ -493,10 +517,8 @@ declare const verifySendWindow: (input: {
493
517
  * The receive legs' window gate, measured from the pay deadline rather than
494
518
  * from now.
495
519
  *
496
- * The semantics invert on these legs: `refund_locktime` is the SOLVER's, so
497
- * BIP-113's lag extends the trader's claim window instead of shrinking it, and
498
- * what can actually run out is the hold invoice. The window that matters is
499
- * therefore the one left after a payer pays at the last possible moment.
520
+ * `refund_locktime` is the SOLVER's here, so BIP-113 lag extends the trader's claim window; what
521
+ * can run out is the hold invoice, so the window that matters is after a last-moment payment.
500
522
  */
501
523
  declare const verifyReceiveWindow: (input: {
502
524
  readonly quote: RfqQuote;
@@ -505,13 +527,8 @@ declare const verifyReceiveWindow: (input: {
505
527
  readonly now: number;
506
528
  }) => void;
507
529
  /**
508
- * The invoice check on a send: the solver quoted THIS invoice, and quoted it at
509
- * a price that is a price.
510
- *
511
- * Both halves matter. A quote whose `to_amount` is not the invoice's amount is
512
- * not a quote for this invoice — the BOLT11 profile is exact-out and the
513
- * invoice is the amount pin. A `from_amount` below it is a negative spread,
514
- * which is not a quote at all.
530
+ * The invoice check on a send: `to_amount` must equal the invoice amount (BOLT11 is exact-out),
531
+ * and `from_amount` below it is a negative spread.
515
532
  */
516
533
  declare const verifySendInvoice: (input: {
517
534
  /** The amount the trader's own decode read off the invoice. */
@@ -523,15 +540,10 @@ declare const verifySendInvoice: (input: {
523
540
  * The invoice check on a receive: bind the SOLVER's hold invoice to this swap's
524
541
  * hash and to the quote.
525
542
  *
526
- * This is the only field the trader hands to a third party and the only attack
527
- * on this corridor with no on-chain trace — an invoice on some other payment
528
- * hash is paid to the solver in full and no lockup on `H` is ever funded. It is
529
- * re-implemented here rather than delegated to `verifyReceiveInvoice` for one
530
- * reason: that gate compares the decoded amount against `quote.from_amount` as a
531
- * JS number, and under the amount migration that field arrives as either a
532
- * number or a string. A `!==` between a string and a number is always true, and
533
- * a check that always fails is not safer than one that compares the decoded
534
- * bigint — it just refuses every quote from a solver that already migrated.
543
+ * The one attack on this corridor with no on-chain trace: an invoice on another payment hash is
544
+ * paid to the solver in full and no lockup on `H` is ever funded. Not delegated to
545
+ * `verifyReceiveInvoice`, which compares against `quote.from_amount` as a JS number; mid amount
546
+ * migration that field may be a string, and `!==` would refuse every migrated solver.
535
547
  */
536
548
  declare const verifyReceiveInvoiceFacts: (input: {
537
549
  readonly invoice: string;
@@ -545,13 +557,8 @@ declare const verifyReceiveInvoiceFacts: (input: {
545
557
  payDeadline: number;
546
558
  };
547
559
  /**
548
- * The policy floor on a quote's remaining life.
549
- *
550
- * One layer above the wire's own refusal of a quote already past `valid_until`:
551
- * that one says the terms are dead, this one says they will be before the caller
552
- * can use them. Only the caller knows how long their flow takes between seeing
553
- * terms and accepting them, so the floor is theirs to set — and with none set,
554
- * only expiry itself refuses.
560
+ * The policy floor on a quote's remaining life: refuses terms that will expire before the caller
561
+ * can use them. With no floor set, only expiry itself refuses.
555
562
  */
556
563
  declare const verifyQuoteTtl: (input: {
557
564
  readonly quoteId: QuoteId;
@@ -560,18 +567,21 @@ declare const verifyQuoteTtl: (input: {
560
567
  readonly floorSeconds?: number;
561
568
  }) => void;
562
569
  /**
563
- * The quote answers the request that was made.
564
- *
565
- * `expectQuote` compares the pair, which says the quote is for this market;
566
- * this says it is for this trade. The request names a side and an amount, and a
567
- * quote that reprices the side the caller pinned is a quote for a different
568
- * size — v1 checks it on two legs out of four and calls it `assertQuotedAmount`.
570
+ * The policy ceiling on how long a send's funds stay locked: a solver that never pays could
571
+ * otherwise hold them for as long as it quotes.
572
+ */
573
+ declare const verifyRefundWindow: (input: {
574
+ readonly refundLocktime: number;
575
+ /** A send's solo-refund CSV delay. */
576
+ readonly refundWithoutReceiverDelay?: number;
577
+ readonly now: number;
578
+ readonly maxSeconds?: number;
579
+ }) => void;
580
+ /**
581
+ * The quote answers the request that was made: the pinned side must not be repriced.
569
582
  *
570
- * It reports as the `pair` check rather than as a fifth-and-a-half one, because
571
- * what it establishes is the same thing: the identity of the trade being
572
- * quoted, which on the wire is the pair plus the pinned side. The closed
573
- * {@link QuoteCheck} union gains no member for it, and the strings say exactly
574
- * what disagreed.
583
+ * Reported as the `pair` check, since the trade's identity on the wire is the pair plus the pinned
584
+ * side; {@link QuoteCheck} gains no member for it.
575
585
  */
576
586
  declare const verifyQuotedAmount: (input: {
577
587
  readonly pair: string;
@@ -582,6 +592,35 @@ declare const verifyQuotedAmount: (input: {
582
592
  readonly give: bigint;
583
593
  readonly take: bigint;
584
594
  }) => void;
595
+ /**
596
+ * The quote answers the request, on a pair whose two legs carry **different
597
+ * assets**.
598
+ *
599
+ * Everything {@link verifyQuotedAmount} establishes except the one check that
600
+ * does not survive the change of asset: `take > give` is a mispricing when both
601
+ * legs are BTC and is the normal shape of a trade when they are not — 10_000
602
+ * sats for 1_000 cents reads one way round, and the reverse trade reads the
603
+ * other. Comparing them would refuse a correct quote on one direction of every
604
+ * asset market, which is why this is a separate function rather than a flag.
605
+ *
606
+ * What replaces it is positivity on both legs: a zero payout is not a trade,
607
+ * and it is the only cross-asset statement about the two numbers that means
608
+ * anything without a price.
609
+ */
610
+ declare const verifyCrossAssetAmount: (input: {
611
+ readonly pair: string;
612
+ readonly pinned: {
613
+ on: "give" | "take";
614
+ value: bigint;
615
+ };
616
+ readonly give: bigint;
617
+ readonly take: bigint;
618
+ }) => void;
619
+ /**
620
+ * The solver's carrier for an asset deposit, well-formed. Reported as the `pair` check, like the
621
+ * amounts: it is sats the trader funds on top of the quoted give leg.
622
+ */
623
+ declare const verifiedCarrierSats: (quote: RfqQuote) => bigint;
585
624
 
586
625
  /**
587
626
  * `retryable` is the point of the type: a 400 says the packet does not bind to
@@ -602,7 +641,7 @@ interface CovclaimdInfo {
602
641
  /** Compressed hex — feeds `requestLightningReceive`'s `emulatorPubkey`. */
603
642
  emulatorPubkey: string;
604
643
  }
605
- /** The four fields `POST /v1/reveal` takes. */
644
+ /** The fields `POST /v1/reveal` takes. */
606
645
  interface RevealParams {
607
646
  /** The funded lockup's Arkade address, bech32m. */
608
647
  swapAddress: string;
@@ -610,6 +649,8 @@ interface RevealParams {
610
649
  ciphertext: string;
611
650
  /** The covenant's `enforcePayTo` ArkadeScript, base64. */
612
651
  arkadeScript: string;
652
+ /** The `minAmount` {@link ciphertext} was sealed with, in sats; omit for an unbound one. */
653
+ minAmount?: bigint;
613
654
  /** The lockup's serialized taptree, hex. */
614
655
  taptree: string;
615
656
  }
@@ -650,8 +691,10 @@ declare function revealClaimPacket(client: CovclaimdClient, input: {
650
691
  address: string;
651
692
  /** `P`, 32 bytes, from the swap's `secrets`. */
652
693
  preimage: Uint8Array;
694
+ /** Sats the lockup must carry, e.g. the record's `expectedAmount`. */
695
+ minAmount: bigint;
653
696
  }): Promise<{
654
697
  ciphertext: string;
655
698
  }>;
656
699
 
657
- export { type AddressParams, ArkadeCorridorDeps, AssetAliasTable, AssetId, type ChainSourceBackend, Corridor, CorridorFactory, type CorridorRecordStore, CorridorSet, CorridorSwapRecord, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, DEFAULT_INVOICE_EXPIRY_SECONDS, DiscoveryIndex, DiscoveryLeg, DiscoverySnapshot, INVOICE_HRPS, Instrument, type L1Tip, LIGHTNING_DRIVE, LightningCorridorDeps, MarketCandidate, NetworkRef, ONCHAIN_DRIVE, OfferSwapRecord, OnchainCorridorDeps, PinnedAmount, Pubkey, QuoteId, QuoteInput, Rail, type RecordSink, type ResolveDeps, ResolvedEndpoint, type ResolvedRoute, type RevealParams, Route, RouteResolution, SwapPolicy, SwapRecord, aliasTableFrom, applyOfferSpend, arkadeCorridor, assembleRoute, chainSourceOver, corridorRecordStore, covclaimdClient, decodeBolt11, esploraChainSource, esploraTip, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, publicAssetId, resolveRoute, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyingDerivation, walletLockupIndexer, withOfferStatus, withRfqState };
700
+ export { type AddressParams, ArkadeCorridorDeps, AssetAliasTable, AssetId, type ChainSourceBackend, Corridor, CorridorFactory, type CorridorRecordStore, CorridorSet, CorridorSwapRecord, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, DEFAULT_INVOICE_EXPIRY_SECONDS, type DepositFate, DiscoveryIndex, DiscoveryLeg, DiscoverySnapshot, EVM_CHAIN, type EvmReceiveQuote, type EvmReceiveQuoteProfile, type EvmRfqQuote, type EvmSendQuote, type EvmSendQuoteProfile, INVOICE_HRPS, Instrument, type L1Tip, LIGHTNING_DRIVE, LightningCorridorDeps, MarketCandidate, NetworkRef, ONCHAIN_DRIVE, OfferSwapRecord, OnchainCorridorDeps, PinnedAmount, Pubkey, QuoteId, QuoteInput, Rail, type RecordSink, type ResolveDeps, ResolvedEndpoint, type ResolvedRoute, type RevealParams, Route, RouteResolution, SwapPolicy, SwapRecord, aliasTableFrom, applyOfferSpend, arkadeCorridor, assembleRoute, chainSourceOver, corridorRecordStore, covclaimdClient, decodeBolt11, esploraChainSource, esploraTip, evmAmountFromWire, evmAmountToWire, evmDirectionOf, evmQuoteSats, evmQuoteTokenAmount, evmReceivePair, evmReceiveRequest, evmSendPair, evmSendRequest, evmTokenLeg, evmTokenOf, fateMoved, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, pageRfqRecords, publicAssetId, readEvmReceiveQuote, readEvmSendQuote, resolveRoute, restoredCorridorRecord, restoredOfferRecord, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifiedCarrierSats, verifyCrossAssetAmount, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyRefundWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyingDerivation, walletLockupIndexer, withDepositFate, withRfqState };