@arkade-os/swap 0.1.0-rc.13 → 0.1.0-rc.15
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.
- package/README.md +11 -0
- package/dist/advanced.cjs +1028 -1006
- package/dist/advanced.d.cts +145 -279
- package/dist/advanced.d.ts +145 -279
- package/dist/advanced.js +14 -8
- package/dist/{chunk-SC3SAY3X.js → chunk-4WPDXLXH.js} +501 -271
- package/dist/chunk-A3SHHRX4.js +104 -0
- package/dist/{chunk-KRXPQQJ7.js → chunk-BBP25BWH.js} +198 -218
- package/dist/{chunk-ZDFMD4FA.js → chunk-RX3WPV5D.js} +356 -584
- package/dist/errors-BcOgFV-F.d.ts +1559 -0
- package/dist/errors-n6IHTG-Z.d.cts +1559 -0
- package/dist/index.cjs +1406 -1331
- package/dist/index.d.cts +69 -186
- package/dist/index.d.ts +69 -186
- package/dist/index.js +102 -158
- package/dist/lockupContract-B_jNbjrG.d.ts +215 -0
- package/dist/lockupContract-ZsftgqMc.d.cts +215 -0
- package/dist/node/index.cjs +61 -10
- package/dist/node/index.d.cts +227 -600
- package/dist/node/index.d.ts +227 -600
- package/dist/node/index.js +65 -10
- package/dist/nostr.cjs +11 -11
- package/dist/nostr.d.cts +23 -68
- package/dist/nostr.d.ts +23 -68
- package/dist/nostr.js +3 -4
- package/dist/offer--1zVkNsV.d.ts +261 -0
- package/dist/offer-DsP1q6GE.d.cts +261 -0
- package/dist/protocol.cjs +747 -1012
- package/dist/protocol.d.cts +120 -255
- package/dist/protocol.d.ts +120 -255
- package/dist/protocol.js +146 -149
- package/dist/repositories/realm/index.cjs +55 -11
- package/dist/repositories/realm/index.d.cts +18 -30
- package/dist/repositories/realm/index.d.ts +18 -30
- package/dist/repositories/realm/index.js +49 -12
- package/dist/repositories/sqlite/index.cjs +61 -10
- package/dist/repositories/sqlite/index.d.cts +7 -6
- package/dist/repositories/sqlite/index.d.ts +7 -6
- package/dist/repositories/sqlite/index.js +57 -11
- package/dist/repository-BY6GUQiW.d.ts +2233 -0
- package/dist/repository-C32GKpR5.d.cts +2233 -0
- package/dist/{rfq-BWE8qkV2.d.ts → rfq-60PGpQ_x.d.cts} +178 -408
- package/dist/{rfq-BWE8qkV2.d.cts → rfq-60PGpQ_x.d.ts} +178 -408
- package/dist/{watch-D8Z78RAV.d.ts → watch-Cejw5cNQ.d.cts} +12 -30
- package/dist/{watch-C4ReJR5z.d.cts → watch-D8uzWrHc.d.ts} +12 -30
- package/package.json +2 -2
- package/dist/chunk-U7VWWTL6.js +0 -66
- package/dist/errors-LXMcNhNS.d.ts +0 -2222
- package/dist/errors-XUs8r0LT.d.cts +0 -2222
- package/dist/lockupContract-BhMebZCb.d.cts +0 -650
- package/dist/lockupContract-CAiN97fX.d.ts +0 -650
- package/dist/repository-BJLuVFQ0.d.ts +0 -3436
- package/dist/repository-DsR3b0JJ.d.cts +0 -3436
package/dist/advanced.d.ts
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
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-
|
|
2
|
-
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as
|
|
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-BcOgFV-F.js';
|
|
2
|
+
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AssetRfqPreparation, k as AttestingRfqTransport, l as CORRIDOR_FACTORIES, m as CancelInput, n as CancelOutcome, o as ClaimedDestination, p as ClientDisposed, q as CorridorBase, r as CorridorClaim, s as CorridorCovenant, t as CorridorDeadline, u as CorridorDeps, v as CorridorDepsByCorridor, w as CorridorDrive, x as CorridorLockup, y as CorridorModule, z as CorridorOverrides, B as CorridorPass, E as CorridorRfqPreparation, F as DiscoveryConfig, G as DiscoveryIndexInput, H as DiscoverySnapshotUnavailable, I as DriveMode, J as DriveRefusal, K as ExchangeOptions, N as FEED_TTL_MS, P as FeeCeiling, Q as FeedFetch, R as FeedQuoteInput, T as INDEXED_NETWORKS, U as InconsistentRoute, V as InsufficientFunds, W as LockupOwner, X as Market, Y as MaxFeeExceeded, Z as MissingCorridorDep, _ as NotCancellable, $ as ONCHAIN_CLAIM_FEE_RATE_SATVB, a0 as ObservationSeam, a1 as OfferPreparation, a2 as OnchainClaim, a3 as OperatorUnreachable, a4 as ParsedRfqQuote, a5 as PayOptions, a6 as PayResult, a7 as QuoteCheck, a8 as QuoteExpired, a9 as QuotePreparation, aa as QuoteVerificationFailed, ab as REGISTRY_URL, ac as ReceiveArtifact, ad as ReceiveOptions, ae as ReceiveRequest, af as RecoveryResult, ag as RegisteredAsset, ah as RfqAuctionPolicy, ai as RfqPreparation, aj as RfqQuoteInput, ak as RfqRendezvous, al as RfqTransportFactory, am as RouteSide, an as SWAP_ERROR_NAMES, ao as SwapClient, ap as SwapClientConfig, aq as SwapDrive, ar as SwapDriveConfig, as as SwapDriveRefusedError, at as SwapError, au as SwapErrorName, av as SwapFilter, aw as UnsupportedRoute, ax as VerbDeps, ay as acceptQuote, az as attesting, aA as cancelSwap, aB as canonicalAssetId, aC as cardMarketOf, aD as chooseMarket, aE as conflictingFields, aF as corridorSet, aG as createSwapClient, aH as createSwapDrive, aI as discoveryIndex, aJ as eligibleMarkets, aK as enforceFeeCeiling, aL as exchange, aM as feedFetch, aN as feedSpread, aO as isAddressable, aP as isCardMarket, aQ as isIndexedNetwork, aR as isSwapError, aS as isUsableCard, aT as liveArkadeInfo, aU as marketBackendOf, aV as marketKeyOf, aW as marketRefOf, aX as nostrTransportFactory, aY as parseRfqQuote, aZ as pay, a_ as quoteFromFeed, a$ as quoteViaRfq, b0 as readableRecord, b1 as receive, b2 as resolveCorridorBase, b3 as resolveCorridorDeps, b4 as rfqLeg, b5 as rfqPairFor, b6 as swapRecordOf, b7 as toDiscoveryLeg, b8 as usableMarkets, b9 as verifyPlanLegs, ba as withCanonicalAmount } from './errors-BcOgFV-F.js';
|
|
3
3
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
4
|
-
import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as AssetSwap, f as RfqSwapRecord, L as LockupSpendIndexer, g as RouteResolution, h as ResolvedEndpoint, P as PinnedAmount, I as Instrument, i as Route, j as QuoteInput, k as Pubkey } from './repository-
|
|
5
|
-
export { l as ACTIVITY_TOKEN, m as ARKADE_ASSET_NAMESPACE, n as Amount, o as AmountFormatError, p as AmountOn, q as AmountRefusal, r as Artifact, s as AssetIdError, t as AssetIdRefusal, u as AssetNamespace, v as AssetOn, w as AssetPart, x as AssetRef, y as AssetScale, z as AssetSwapId, B as AtomicDecimal, D as AuctionMarketRef, E as AuctionProvenance, F as BITCOIN_RAILS, G as BTC_ASSET_PART, H as BitcoinRail, J as CORRIDORS, K as CORRIDOR_PASS, M as CardMarketRef, T as CorridorId, U as CorridorKind, V as DepositArtifact, W as DisplayDecimal, X as Endpoint, Y as Ep, Z as Hex, _ as LOCKUP_OWNER, $ as MarketBackend, a0 as MarketRef, a1 as OFFER_SWAP_ID_PREFIX, a2 as Outcome, a3 as ParsedAssetId, a4 as Quote, a5 as QuoteLeg, a6 as RAILS, a7 as RFQ_SWAP_ID_PREFIX, a8 as RailOf, a9 as RankedBid, aa as RawState, ab as RecordedArtifact, ac as RecordedEndpoint, ad as RecordedInstrument, ae as RecordedLeg, af as RestoredMarketRef, ag as RfqAmountSide, ah as SnapshotRef, ai as Swap, aj as SwapFamily, ak as SwapRecordCommon, al as SwapUpdate, am as Unsubscribe, an as arkadeAsset, ao as artifactOf, ap as assetPartOf, aq as assetSwapIdOf, ar as bitcoinNetworkOf, as as btcOn, at as corridorOfRail, au as corridorOutcome, av as decodeRfqAmount, aw as encodeRfqAmount, ax as familyOfSwapId, ay as formatAssetId, az as fromAtomicDecimal, aA as fromRfqAmountSide, aB as fundsFromWallet, aC as instrumentOf, aD as isAssetId, aE as isAtomicDecimal, aF as isNetworkRef, aG as issuanceOf, aH as legOf, aI as offerOutcome, aJ as parseAssetId, aK as quoteIdOfSwapId, aL as railOf, aM as railOfCorridor, aN as readsChain, aO as recordArtifact, aP as recordEndpoint, aQ as recordInstrument, aR as recordLeg, aS as recordOutcome, aT as sameAsset, aU as swapOf, aV as toAtomicDecimal, aW as toRfqAmountSide, aX as toSafeNumber } from './repository-
|
|
6
|
-
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-
|
|
7
|
-
export { S as SwapRefusal } from './rfq-
|
|
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 AssetSwap, f as RfqSwapRecord, L as LockupSpendIndexer, g as RouteResolution, h as ResolvedEndpoint, P as PinnedAmount, I as Instrument, i as Route, j as QuoteInput, k as Pubkey } from './repository-BY6GUQiW.js';
|
|
5
|
+
export { l as ACTIVITY_TOKEN, m as ARKADE_ASSET_NAMESPACE, n as Amount, o as AmountFormatError, p as AmountOn, q as AmountRefusal, r as Artifact, s as AssetIdError, t as AssetIdRefusal, u as AssetNamespace, v as AssetOn, w as AssetPart, x as AssetRef, y as AssetScale, z as AssetSwapId, B as AtomicDecimal, D as AuctionMarketRef, E as AuctionProvenance, F as BITCOIN_RAILS, G as BTC_ASSET_PART, H as BitcoinRail, J as CORRIDORS, K as CORRIDOR_PASS, M as CardMarketRef, T as CorridorId, U as CorridorKind, V as DepositArtifact, W as DisplayDecimal, X as Endpoint, Y as Ep, Z as Hex, _ as LOCKUP_OWNER, $ as MarketBackend, a0 as MarketRef, a1 as OFFER_SWAP_ID_PREFIX, a2 as Outcome, a3 as ParsedAssetId, a4 as Quote, a5 as QuoteLeg, a6 as RAILS, a7 as RFQ_SWAP_ID_PREFIX, a8 as RailOf, a9 as RankedBid, aa as RawState, ab as RecordedArtifact, ac as RecordedEndpoint, ad as RecordedInstrument, ae as RecordedLeg, af as RestoredMarketRef, ag as RfqAmountSide, ah as SnapshotRef, ai as Swap, aj as SwapFamily, ak as SwapRecordCommon, al as SwapUpdate, am as Unsubscribe, an as arkadeAsset, ao as artifactOf, ap as assetPartOf, aq as assetSwapIdOf, ar as bitcoinNetworkOf, as as btcOn, at as corridorOfRail, au as corridorOutcome, av as decodeRfqAmount, aw as encodeRfqAmount, ax as familyOfSwapId, ay as formatAssetId, az as fromAtomicDecimal, aA as fromRfqAmountSide, aB as fundsFromWallet, aC as instrumentOf, aD as isAssetId, aE as isAtomicDecimal, aF as isNetworkRef, aG as issuanceOf, aH as legOf, aI as offerOutcome, aJ as parseAssetId, aK as quoteIdOfSwapId, aL as railOf, aM as railOfCorridor, aN as readsChain, aO as recordArtifact, aP as recordEndpoint, aQ as recordInstrument, aR as recordLeg, aS as recordOutcome, aT as sameAsset, aU as swapOf, aV as toAtomicDecimal, aW as toRfqAmountSide, aX as toSafeNumber } from './repository-BY6GUQiW.js';
|
|
6
|
+
import { I as InvoiceFacts, C as ChainSource, R as RfqQuote } from './rfq-60PGpQ_x.js';
|
|
7
|
+
export { S as SwapRefusal } from './rfq-60PGpQ_x.js';
|
|
8
8
|
import * as btc from '@scure/btc-signer';
|
|
9
9
|
import { OnchainProvider, NetworkName, IWallet, VHTLC } from '@arkade-os/sdk';
|
|
10
|
-
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-
|
|
10
|
+
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-D8uzWrHc.js';
|
|
11
|
+
import './offer--1zVkNsV.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* The alias table, filled from discovery
|
|
14
|
+
* The alias table, filled from discovery: the inverse of `toDiscoveryLeg`, mapping a card's
|
|
15
|
+
* corridor and `AssetInfo` back to the public id a caller may write, plus its ticker.
|
|
14
16
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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.
|
|
17
|
+
* Tickers are display metadata, never identity, so `canonicalAssetId` refuses a ticker naming two
|
|
18
|
+
* assets. Rows dedupe by id and ticker, so nine solvers listing one asset is one row.
|
|
26
19
|
*/
|
|
27
20
|
|
|
28
21
|
/**
|
|
29
|
-
* The public id for one side of a card
|
|
30
|
-
*
|
|
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.
|
|
22
|
+
* The public id for one side of a card, or `undefined` when not expressible: an arkade-issued
|
|
23
|
+
* asset on lightning or L1, or an id that is neither BTC nor the identity form.
|
|
34
24
|
*/
|
|
35
25
|
declare const publicAssetId: (corridor: Corridor, assetId: string, network: NetworkRef) => AssetId | undefined;
|
|
36
26
|
/** Every asset the snapshot names, as caller-writable ids and their tickers. */
|
|
@@ -38,15 +28,9 @@ declare const aliasTableFrom: (markets: readonly DiscoveredMarket[], network: Ne
|
|
|
38
28
|
/**
|
|
39
29
|
* The table narrowed to one rail.
|
|
40
30
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
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.
|
|
31
|
+
* BTC has one id per rail (Q12), so a whole-table lookup of `"BTC"` would collide and refuse. The
|
|
32
|
+
* leg's rail is already fixed (by destination, `via`, or being the wallet's side), so resolving on
|
|
33
|
+
* it is a fact, not a preference. Collisions within a rail (two arkade `USDT`s) still refuse.
|
|
50
34
|
*/
|
|
51
35
|
declare const scopedToRail: (table: AssetAliasTable, rail: Rail) => AssetAliasTable;
|
|
52
36
|
|
|
@@ -55,9 +39,8 @@ declare const DEFAULT_INVOICE_EXPIRY_SECONDS = 3600;
|
|
|
55
39
|
/**
|
|
56
40
|
* Decode a BOLT11 invoice into the facts the corridor needs.
|
|
57
41
|
*
|
|
58
|
-
* Signature-blind, like the library:
|
|
59
|
-
*
|
|
60
|
-
* corridor will compare against is the one the payer would pay to.
|
|
42
|
+
* Signature-blind, like the library: it does not prove who issued the invoice, only that the
|
|
43
|
+
* payment hash compared downstream is the one the payer would pay to.
|
|
61
44
|
*
|
|
62
45
|
* @throws when the string is not a decodable BOLT11 invoice, or decodes without
|
|
63
46
|
* the timestamp or payment hash BOLT11 requires.
|
|
@@ -80,20 +63,13 @@ interface ChainSourceBackend {
|
|
|
80
63
|
* core's `Network` and `L1_NETWORKS`' entries both satisfy it directly. */
|
|
81
64
|
type AddressParams = typeof btc.NETWORK;
|
|
82
65
|
/**
|
|
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.
|
|
66
|
+
* A {@link ChainSource} over an arbitrary L1 backend, so a caller with its own `OnchainProvider`
|
|
67
|
+
* can reuse the adapter logic, and tests can run it without a server.
|
|
89
68
|
*/
|
|
90
69
|
declare const chainSourceOver: (backend: ChainSourceBackend, network: AddressParams) => ChainSource;
|
|
91
70
|
/**
|
|
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.
|
|
71
|
+
* Tip height and median-time-past off Esplora's `/blocks`. Not `/blocks/tip`: that is not in the
|
|
72
|
+
* Esplora spec (electrs aliases it, mempool answers an empty array).
|
|
97
73
|
*/
|
|
98
74
|
declare const esploraTip: (esploraUrl: string, fetchImpl?: typeof fetch) => Promise<L1Tip>;
|
|
99
75
|
/** The default: core's Esplora provider at `esploraUrl`, with the tip read off
|
|
@@ -113,44 +89,27 @@ declare const arkadeCorridor: CorridorFactory<ArkadeCorridorDeps>;
|
|
|
113
89
|
/**
|
|
114
90
|
* The lightning corridor: a BOLT11 invoice, on this wallet's network.
|
|
115
91
|
*
|
|
116
|
-
* Core
|
|
117
|
-
* and
|
|
118
|
-
*
|
|
119
|
-
*
|
|
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.
|
|
92
|
+
* Core's `isLightningInvoice` checks shape only (no checksum, no decode), so the network
|
|
93
|
+
* match and decode happen here. `lntbs` is both signet and mutinynet, so a
|
|
94
|
+
* signet-versus-mutinynet mismatch is not detectable; `lnsb` (simnet) passes core's regex
|
|
95
|
+
* but names no `NetworkName`, so it is refused rather than mapped to a neighbour.
|
|
128
96
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* headroom check needs `quote.refund_locktime` and no parse has a quote — and
|
|
132
|
-
* belong to the quote path.
|
|
97
|
+
* Gates owned here: HRP, invoice expiry, amountless refusal. Gates that need the quote
|
|
98
|
+
* (e.g. headroom vs `quote.refund_locktime`) belong to the quote path.
|
|
133
99
|
*/
|
|
134
100
|
|
|
135
101
|
/**
|
|
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.
|
|
102
|
+
* Which networks an invoice HRP can belong to. Ordered, not a record: `lnbcrt` must be
|
|
103
|
+
* tested before `lnbc` and `lntbs` before `lntb`.
|
|
141
104
|
*/
|
|
142
105
|
declare const INVOICE_HRPS: readonly [readonly ["lnbcrt", readonly ["regtest"]], readonly ["lntbs", readonly ["signet", "mutinynet"]], readonly ["lnbc", readonly ["bitcoin"]], readonly ["lntb", readonly ["testnet"]]];
|
|
143
106
|
/** The networks `raw`'s HRP names, or `undefined` for one no network claims. */
|
|
144
107
|
declare const networksOfInvoiceHrp: (raw: string) => readonly NetworkName[] | undefined;
|
|
145
108
|
/**
|
|
146
|
-
* Both directions,
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
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.
|
|
109
|
+
* Both directions, with ownership inverted. `arkade -> lightning`: the trader funds the
|
|
110
|
+
* lockup, so `refundLocktime` is a moment to refund AFTER (the solver claims with the
|
|
111
|
+
* preimage it learns by paying). `lightning -> arkade`: the solver funds it, the trader
|
|
112
|
+
* has no refund, and the deadline is a moment to have claimed BEFORE.
|
|
154
113
|
*/
|
|
155
114
|
declare const LIGHTNING_DRIVE: {
|
|
156
115
|
readonly give: {
|
|
@@ -175,20 +134,13 @@ declare const LIGHTNING_DRIVE: {
|
|
|
175
134
|
declare const lightningCorridor: CorridorFactory<LightningCorridorDeps>;
|
|
176
135
|
|
|
177
136
|
/**
|
|
178
|
-
* One direction only
|
|
179
|
-
*
|
|
180
|
-
*
|
|
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.
|
|
137
|
+
* One direction only. `onchain -> arkade` is deliberately absent: it adds an L1 half the
|
|
138
|
+
* trader funds and must refund itself, and declaring only the lockup half would yield a
|
|
139
|
+
* manager that silently lets the trader's L1 refund window pass.
|
|
186
140
|
*
|
|
187
|
-
* On `arkade -> onchain` the
|
|
188
|
-
*
|
|
189
|
-
* 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.
|
|
141
|
+
* On `arkade -> onchain` the two covenants have different owners: the Arkade lockup is
|
|
142
|
+
* the trader's (`refundLocktime` = money comes back), but the L1 HTLC's refund leaf is
|
|
143
|
+
* the solver's, so reaching `htlc.refundLocktime` means the claim was missed.
|
|
192
144
|
*/
|
|
193
145
|
declare const ONCHAIN_DRIVE: {
|
|
194
146
|
readonly take: {
|
|
@@ -208,35 +160,21 @@ declare const ONCHAIN_DRIVE: {
|
|
|
208
160
|
declare const onchainCorridor: CorridorFactory<OnchainCorridorDeps>;
|
|
209
161
|
|
|
210
162
|
/**
|
|
211
|
-
* The
|
|
163
|
+
* The seams between the v2 record store and v1's drive machinery.
|
|
212
164
|
*
|
|
213
|
-
* **The record bridge is the load-bearing one.** `RfqSwapManager` restores from
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* whole drive — `ready`, arm-on-live-work, the outcome projections, recovery —
|
|
218
|
-
* rests on an empty set.
|
|
165
|
+
* **The record bridge is the load-bearing one.** `RfqSwapManager` restores from `getRfqSwapsPage()`,
|
|
166
|
+
* while `accept()` writes `saveSwapRecord` into a disjoint keyspace, so without this file the
|
|
167
|
+
* manager's restore returns nothing for every v2-accepted swap. {@link CorridorSwapRecord} carries
|
|
168
|
+
* every {@link RfqSwapRecord} field but the ignored display `amount`, which keeps the bridge cheap.
|
|
219
169
|
*
|
|
220
|
-
* The
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* -
|
|
226
|
-
*
|
|
227
|
-
*
|
|
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.
|
|
170
|
+
* - **The store is wired as the manager's `repository` dep**: `restoreFromRepository` opens with
|
|
171
|
+
* `requireRepository`, so leaving it unwired would mean a hand-rolled restore.
|
|
172
|
+
* - **It carries an `rfqId -> QuoteId` index**: manager callbacks key on `rfqId`. Without it
|
|
173
|
+
* `arkadeRefunder` misses its record and throws `RefundNotLocallyPossibleError` — which the
|
|
174
|
+
* manager reads as PERMANENT — blocking every v2 send leg for its refund window with funds locked.
|
|
175
|
+
* - **`removeRfqSwap` is inert**: `restoreFromRepository` runs `dropRetired` first, which would
|
|
176
|
+
* hard-delete v2 records under v1's thirty-day retention before `client.ready` resolves. v2
|
|
177
|
+
* retention is still undecided. The manager still drops its in-memory copy; the record survives.
|
|
240
178
|
*/
|
|
241
179
|
|
|
242
180
|
/** Every stored corridor record, and every offer record, in one read. */
|
|
@@ -244,23 +182,14 @@ declare const splitRecords: (records: readonly SwapRecord[]) => {
|
|
|
244
182
|
corridor: CorridorSwapRecord[];
|
|
245
183
|
offer: OfferSwapRecord[];
|
|
246
184
|
};
|
|
247
|
-
/**
|
|
248
|
-
*
|
|
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
|
-
*/
|
|
185
|
+
/** A v2 corridor record as the manager's own record type, minus the display `amount`
|
|
186
|
+
* (`rebuildRfqSwap` reads none, and inventing one would record a number no request produced). */
|
|
254
187
|
declare const rfqRecordOf: (record: CorridorSwapRecord) => RfqSwapRecord;
|
|
255
188
|
/**
|
|
256
|
-
* The manager's mutable half, written back onto the v2 record.
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
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.
|
|
189
|
+
* The manager's mutable half, written back onto the v2 record. REPLACED, not merged (as
|
|
190
|
+
* `updateRfqSwapRecord` does): the manager clears `blockedReason`/`claimFailure`, and a spread could
|
|
191
|
+
* never clear them, leaving a stale refusal reading as live. The origin half, `fundingTxid`
|
|
192
|
+
* included, is carried through untouched — the manager never learns it.
|
|
264
193
|
*/
|
|
265
194
|
declare const withRfqState: (record: CorridorSwapRecord, state: RfqSwapRecord) => CorridorSwapRecord;
|
|
266
195
|
/** What a bridge or source hands back to the drive after a write. */
|
|
@@ -273,31 +202,17 @@ interface CorridorRecordStore extends RfqSwapRecordStore {
|
|
|
273
202
|
quoteIdOf(rfqId: string): QuoteId | undefined;
|
|
274
203
|
}
|
|
275
204
|
/**
|
|
276
|
-
* The v2 record store, as the manager's `repository` dep.
|
|
277
|
-
*
|
|
278
|
-
*
|
|
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.
|
|
205
|
+
* The v2 record store, as the manager's `repository` dep. Every read goes to the repository (the
|
|
206
|
+
* system of record), so a consumer's edit is never overwritten by a boot-time copy. Only the index
|
|
207
|
+
* is in memory; a miss costs one scan, never a wrong answer.
|
|
283
208
|
*/
|
|
284
209
|
declare const corridorRecordStore: (repository: AssetSwapRepository, onRecord?: RecordSink,
|
|
285
210
|
/**
|
|
286
|
-
* Which stored records the restore may hand to the manager.
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
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.
|
|
211
|
+
* Which stored records the restore may hand to the manager. Two cases:
|
|
212
|
+
* - an `arkade -> onchain` record on a client whose chain source was refused — the manager would
|
|
213
|
+
* fail it TERMINALLY on its first pass; excluded, it stays durable, undriven and self-reporting;
|
|
214
|
+
* - a terminal record, which the manager would rebuild only to file as finished (a covenant
|
|
215
|
+
* derivation and row lookup for nothing). It stays readable in the drive's registry.
|
|
301
216
|
*/
|
|
302
217
|
admits?: (record: CorridorSwapRecord) => boolean) => CorridorRecordStore;
|
|
303
218
|
/** A v2 offer record as the watcher and coverage read one. */
|
|
@@ -323,43 +238,27 @@ declare const withDepositFate: (record: OfferSwapRecord, fate: DepositFate, now:
|
|
|
323
238
|
/** Whether the fate says anything the record does not; the write it gates re-emits the swap. */
|
|
324
239
|
declare const fateMoved: (record: OfferSwapRecord, fate: DepositFate) => boolean;
|
|
325
240
|
/**
|
|
326
|
-
* An offer record for a deposit the restore scan found and no record claims.
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* spread and deadline it does not, hence `market.kind: "restored"` and a
|
|
330
|
-
* zero fee.
|
|
241
|
+
* An offer record for a deposit the restore scan found and no record claims. Keyed on the funding
|
|
242
|
+
* txid so a re-scan updates rather than duplicates. The chain lacks the market, solver, spread and
|
|
243
|
+
* deadline, hence `market.kind: "restored"` and a zero fee.
|
|
331
244
|
*/
|
|
332
245
|
declare const restoredOfferRecord: (swap: AssetSwap, network: NetworkRef, now: number) => OfferSwapRecord;
|
|
333
246
|
/**
|
|
334
|
-
* The wallet's own reader, as the manager's
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* neither scripts nor outpoints is a caller bug rather than a query. Built from
|
|
339
|
-
* the wallet rather than injected on `SwapClientConfig`, because the wallet is
|
|
340
|
-
* where every other connection in this client comes from — a client takes no
|
|
341
|
-
* server URL and no provider. The drive layer still takes it as an input, which
|
|
342
|
-
* is what lets a unit test double one without a wallet behind it.
|
|
247
|
+
* The wallet's own reader, as the manager's required observation seam. The reader reads NAMED
|
|
248
|
+
* foreign scripts and has no "own wallet" default, so a call with neither scripts nor outpoints is a
|
|
249
|
+
* caller bug. Built from the wallet (the client takes no server URL or provider); the drive still
|
|
250
|
+
* takes it as an input so unit tests can double it.
|
|
343
251
|
*/
|
|
344
252
|
declare const walletLockupIndexer: (wallet: IWallet) => LockupSpendIndexer;
|
|
345
253
|
|
|
346
254
|
/**
|
|
347
|
-
* Route resolution: the single place `to` is parsed, the corridor pair
|
|
348
|
-
*
|
|
349
|
-
* to happen before a solver is told anything.
|
|
255
|
+
* Route resolution: the single place `to` is parsed, the corridor pair decided, the
|
|
256
|
+
* amount pinned and the market chosen — everything before a solver is told anything.
|
|
350
257
|
*
|
|
351
|
-
* The order
|
|
352
|
-
*
|
|
353
|
-
* market
|
|
354
|
-
*
|
|
355
|
-
* `Route` variant — a pair outside the union is `UnsupportedRoute` here, before
|
|
356
|
-
* an RFQ round trip, an artifact or a record. Only then does the market index
|
|
357
|
-
* come in, and only then can a ticker be canonicalized, since the table a ticker
|
|
358
|
-
* resolves against is built out of the cards themselves.
|
|
359
|
-
*
|
|
360
|
-
* The amount is pinned last and before any network call: exactly one may be
|
|
361
|
-
* pinned, by the caller or by an invoice, and two is `AmountMismatch` — thrown
|
|
362
|
-
* with nothing disclosed, which is the whole reason it is thrown here.
|
|
258
|
+
* The order (§3.1) is load-bearing: `to` first (needs no market data); the pair selects
|
|
259
|
+
* the `Route` variant, refusing unsupported pairs before any round trip or record; only
|
|
260
|
+
* then the market index, since tickers resolve against the cards themselves. Exactly one
|
|
261
|
+
* amount may be pinned; two is `AmountMismatch`, thrown here so nothing is disclosed.
|
|
363
262
|
*/
|
|
364
263
|
|
|
365
264
|
/** The four implemented corridor pairs, spelled as the route union spells them. */
|
|
@@ -372,12 +271,8 @@ interface ResolveDeps {
|
|
|
372
271
|
readonly discovery: DiscoveryIndex;
|
|
373
272
|
readonly policy?: SwapPolicy;
|
|
374
273
|
/**
|
|
375
|
-
* `resolve()` reads what is in hand; `quote()` may fetch.
|
|
376
|
-
*
|
|
377
|
-
* The one difference between the two paths, and the reason it is a flag
|
|
378
|
-
* rather than two functions: everything else about resolution — the parse,
|
|
379
|
-
* the pair, the pin, the veto — has to be identical, or the resolution a
|
|
380
|
-
* caller vetoed would not be the one they quoted.
|
|
274
|
+
* `resolve()` reads what is in hand; `quote()` may fetch. A flag, not two functions,
|
|
275
|
+
* so the resolution a caller vetoed is exactly the one they quote.
|
|
381
276
|
*/
|
|
382
277
|
readonly mode: "resolve" | "quote";
|
|
383
278
|
}
|
|
@@ -403,12 +298,9 @@ interface ResolvedRoute {
|
|
|
403
298
|
/**
|
|
404
299
|
* Assemble the closed `Route` from two fully-instrumented legs.
|
|
405
300
|
*
|
|
406
|
-
* The one cast
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
* asset went through `toDiscoveryLeg`, which is what decided the corridor. The
|
|
410
|
-
* runtime re-check is cheap and turns a broken invariant into a throw at the
|
|
411
|
-
* boundary rather than a covenant built against the wrong rail.
|
|
301
|
+
* The quote path's one cast: the type checker cannot correlate `corridor` and `asset`,
|
|
302
|
+
* so the runtime re-check turns a broken invariant into a throw rather than a covenant
|
|
303
|
+
* built against the wrong rail.
|
|
412
304
|
*/
|
|
413
305
|
declare const assembleRoute: (give: ResolvedEndpoint & {
|
|
414
306
|
instrument: Instrument;
|
|
@@ -421,46 +313,25 @@ declare const resolveRoute: (input: QuoteInput, deps: ResolveDeps) => Promise<Re
|
|
|
421
313
|
declare const satsOf: (value: bigint, field: string) => number;
|
|
422
314
|
|
|
423
315
|
/**
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
* v1 spreads these checks across four request entrypoints and reaches the offer
|
|
427
|
-
* path with none of them: `expectQuote` compares type, id and pair;
|
|
428
|
-
* `verifyLockupAddress` compares the derived address; `assertFundable`,
|
|
429
|
-
* `verifyReceiveInvoice` and `assertReceivable` gate expiry, headroom and the
|
|
430
|
-
* claim window on some legs and not others; and the docs push the rest — plan
|
|
431
|
-
* validation, the rendezvous choice, the invoice decode — onto the caller. This
|
|
432
|
-
* module runs the whole set, once, on both backends, before any quote is
|
|
433
|
-
* returned, and every failure is one error class with the check named on it.
|
|
316
|
+
* Quote verification as one invariant: every check runs once, on both backends, before any quote
|
|
317
|
+
* is returned, and every failure is one error class naming the check.
|
|
434
318
|
*
|
|
435
|
-
* The gates themselves
|
|
436
|
-
* constants
|
|
437
|
-
* covenant's own timing, and re-implementing them here would be a second
|
|
438
|
-
* opinion where the whole point is that there is one. What this adds is the
|
|
439
|
-
* mapping: a gate's stable `reason` becomes a {@link QuoteCheck}, so a caller
|
|
440
|
-
* switches on the check rather than on a string the wire's own vocabulary
|
|
441
|
-
* leaked.
|
|
319
|
+
* The gates themselves stay `rfq.ts`'s (audited, and carrying the covenant-mirroring timing
|
|
320
|
+
* constants); this only maps a gate's stable `reason` to a {@link QuoteCheck}.
|
|
442
321
|
*
|
|
443
|
-
* Two failures deliberately
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* the problem, and the remedy is a fresh quote rather than a different solver.
|
|
322
|
+
* Two failures are deliberately NOT verification failures: a solver declining is `SwapRefusal`,
|
|
323
|
+
* and an expired or expiring quote is `QuoteExpired` (the remedy is a fresh quote, not a
|
|
324
|
+
* different solver).
|
|
447
325
|
*/
|
|
448
326
|
|
|
449
327
|
/**
|
|
450
328
|
* The fifth check: who answered.
|
|
451
329
|
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* caller can turn off by handing in a different transport, and verification that
|
|
455
|
-
* configuration can disable is not an invariant. So the transport delivers the
|
|
456
|
-
* attestation and this runs it, in addressed mode only: published RFQ has N
|
|
457
|
-
* unknown responders and attributes each bid by its own signature instead.
|
|
330
|
+
* Run here, not left to the transport, so swapping in a different transport cannot disable it.
|
|
331
|
+
* Addressed mode only: published RFQ attributes each bid by its own signature.
|
|
458
332
|
*
|
|
459
|
-
* `pinnable` is the trust boundary
|
|
460
|
-
*
|
|
461
|
-
* unvalidated — so a snapshot read back out of local storage cannot supply it,
|
|
462
|
-
* and the check fails closed rather than pinning against content anyone with
|
|
463
|
-
* write access to the browser's storage could have chosen.
|
|
333
|
+
* `pinnable` is the trust boundary: a cached card's `discovery_pubkey` is unvalidated (anyone with
|
|
334
|
+
* write access to browser storage could choose it), so a cache-sourced key fails closed.
|
|
464
335
|
*/
|
|
465
336
|
declare const verifyResponder: (input: {
|
|
466
337
|
/** The key this transport proves every reply came from, if it proves one. */
|
|
@@ -471,24 +342,15 @@ declare const verifyResponder: (input: {
|
|
|
471
342
|
readonly pinnable: boolean;
|
|
472
343
|
}) => void;
|
|
473
344
|
/**
|
|
474
|
-
* The pair check, run here as well as in the transport
|
|
475
|
-
*
|
|
476
|
-
* `expectQuote` already compares it — this is not a gap being filled but the
|
|
477
|
-
* layer that OWNS the string doing its own comparison, so a transport that
|
|
478
|
-
* skips the check (or one a caller injected) cannot make the quote path skip it
|
|
479
|
-
* too. v1 documented this one as the caller's job, in bold.
|
|
345
|
+
* The pair check, run here as well as in the transport's `expectQuote`, so a transport that skips
|
|
346
|
+
* it (or one a caller injected) cannot make the quote path skip it too.
|
|
480
347
|
*/
|
|
481
348
|
declare const verifyPair: (quoted: unknown, requested: string) => void;
|
|
482
349
|
/**
|
|
483
|
-
* Derive the covenant, and fold every way that can fail into
|
|
350
|
+
* Derive the covenant, and fold every way that can fail into the `lockup_address` check.
|
|
484
351
|
*
|
|
485
|
-
* `AddressMismatch` is
|
|
486
|
-
*
|
|
487
|
-
* error would leave two classes for one condition across the v1/v2 seam. The
|
|
488
|
-
* other failures — a missing binding field, malformed hex from the solver — are
|
|
489
|
-
* the same check reached from further back: an address that cannot be derived
|
|
490
|
-
* cannot be compared, and both mean the same thing to a caller, which is do not
|
|
491
|
-
* fund this.
|
|
352
|
+
* `AddressMismatch` is that check under its v1 name; a missing binding field or malformed solver
|
|
353
|
+
* hex is the same check reached earlier. All mean "do not fund this".
|
|
492
354
|
*/
|
|
493
355
|
declare const verifyingDerivation: <T>(derive: () => T) => T;
|
|
494
356
|
/**
|
|
@@ -511,10 +373,8 @@ declare const verifySendWindow: (input: {
|
|
|
511
373
|
* The receive legs' window gate, measured from the pay deadline rather than
|
|
512
374
|
* from now.
|
|
513
375
|
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* what can actually run out is the hold invoice. The window that matters is
|
|
517
|
-
* therefore the one left after a payer pays at the last possible moment.
|
|
376
|
+
* `refund_locktime` is the SOLVER's here, so BIP-113 lag extends the trader's claim window; what
|
|
377
|
+
* can run out is the hold invoice, so the window that matters is after a last-moment payment.
|
|
518
378
|
*/
|
|
519
379
|
declare const verifyReceiveWindow: (input: {
|
|
520
380
|
readonly quote: RfqQuote;
|
|
@@ -523,13 +383,8 @@ declare const verifyReceiveWindow: (input: {
|
|
|
523
383
|
readonly now: number;
|
|
524
384
|
}) => void;
|
|
525
385
|
/**
|
|
526
|
-
* The invoice check on a send:
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
* Both halves matter. A quote whose `to_amount` is not the invoice's amount is
|
|
530
|
-
* not a quote for this invoice — the BOLT11 profile is exact-out and the
|
|
531
|
-
* invoice is the amount pin. A `from_amount` below it is a negative spread,
|
|
532
|
-
* which is not a quote at all.
|
|
386
|
+
* The invoice check on a send: `to_amount` must equal the invoice amount (BOLT11 is exact-out),
|
|
387
|
+
* and `from_amount` below it is a negative spread.
|
|
533
388
|
*/
|
|
534
389
|
declare const verifySendInvoice: (input: {
|
|
535
390
|
/** The amount the trader's own decode read off the invoice. */
|
|
@@ -541,15 +396,10 @@ declare const verifySendInvoice: (input: {
|
|
|
541
396
|
* The invoice check on a receive: bind the SOLVER's hold invoice to this swap's
|
|
542
397
|
* hash and to the quote.
|
|
543
398
|
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
* reason: that gate compares the decoded amount against `quote.from_amount` as a
|
|
549
|
-
* JS number, and under the amount migration that field arrives as either a
|
|
550
|
-
* number or a string. A `!==` between a string and a number is always true, and
|
|
551
|
-
* a check that always fails is not safer than one that compares the decoded
|
|
552
|
-
* bigint — it just refuses every quote from a solver that already migrated.
|
|
399
|
+
* The one attack on this corridor with no on-chain trace: an invoice on another payment hash is
|
|
400
|
+
* paid to the solver in full and no lockup on `H` is ever funded. Not delegated to
|
|
401
|
+
* `verifyReceiveInvoice`, which compares against `quote.from_amount` as a JS number; mid amount
|
|
402
|
+
* migration that field may be a string, and `!==` would refuse every migrated solver.
|
|
553
403
|
*/
|
|
554
404
|
declare const verifyReceiveInvoiceFacts: (input: {
|
|
555
405
|
readonly invoice: string;
|
|
@@ -563,13 +413,8 @@ declare const verifyReceiveInvoiceFacts: (input: {
|
|
|
563
413
|
payDeadline: number;
|
|
564
414
|
};
|
|
565
415
|
/**
|
|
566
|
-
* The policy floor on a quote's remaining life
|
|
567
|
-
*
|
|
568
|
-
* One layer above the wire's own refusal of a quote already past `valid_until`:
|
|
569
|
-
* that one says the terms are dead, this one says they will be before the caller
|
|
570
|
-
* can use them. Only the caller knows how long their flow takes between seeing
|
|
571
|
-
* terms and accepting them, so the floor is theirs to set — and with none set,
|
|
572
|
-
* only expiry itself refuses.
|
|
416
|
+
* The policy floor on a quote's remaining life: refuses terms that will expire before the caller
|
|
417
|
+
* can use them. With no floor set, only expiry itself refuses.
|
|
573
418
|
*/
|
|
574
419
|
declare const verifyQuoteTtl: (input: {
|
|
575
420
|
readonly quoteId: QuoteId;
|
|
@@ -578,18 +423,10 @@ declare const verifyQuoteTtl: (input: {
|
|
|
578
423
|
readonly floorSeconds?: number;
|
|
579
424
|
}) => void;
|
|
580
425
|
/**
|
|
581
|
-
* The quote answers the request that was made.
|
|
426
|
+
* The quote answers the request that was made: the pinned side must not be repriced.
|
|
582
427
|
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* quote that reprices the side the caller pinned is a quote for a different
|
|
586
|
-
* size — v1 checks it on two legs out of four and calls it `assertQuotedAmount`.
|
|
587
|
-
*
|
|
588
|
-
* It reports as the `pair` check rather than as a fifth-and-a-half one, because
|
|
589
|
-
* what it establishes is the same thing: the identity of the trade being
|
|
590
|
-
* quoted, which on the wire is the pair plus the pinned side. The closed
|
|
591
|
-
* {@link QuoteCheck} union gains no member for it, and the strings say exactly
|
|
592
|
-
* what disagreed.
|
|
428
|
+
* Reported as the `pair` check, since the trade's identity on the wire is the pair plus the pinned
|
|
429
|
+
* side; {@link QuoteCheck} gains no member for it.
|
|
593
430
|
*/
|
|
594
431
|
declare const verifyQuotedAmount: (input: {
|
|
595
432
|
readonly pair: string;
|
|
@@ -600,6 +437,35 @@ declare const verifyQuotedAmount: (input: {
|
|
|
600
437
|
readonly give: bigint;
|
|
601
438
|
readonly take: bigint;
|
|
602
439
|
}) => void;
|
|
440
|
+
/**
|
|
441
|
+
* The quote answers the request, on a pair whose two legs carry **different
|
|
442
|
+
* assets**.
|
|
443
|
+
*
|
|
444
|
+
* Everything {@link verifyQuotedAmount} establishes except the one check that
|
|
445
|
+
* does not survive the change of asset: `take > give` is a mispricing when both
|
|
446
|
+
* legs are BTC and is the normal shape of a trade when they are not — 10_000
|
|
447
|
+
* sats for 1_000 cents reads one way round, and the reverse trade reads the
|
|
448
|
+
* other. Comparing them would refuse a correct quote on one direction of every
|
|
449
|
+
* asset market, which is why this is a separate function rather than a flag.
|
|
450
|
+
*
|
|
451
|
+
* What replaces it is positivity on both legs: a zero payout is not a trade,
|
|
452
|
+
* and it is the only cross-asset statement about the two numbers that means
|
|
453
|
+
* anything without a price.
|
|
454
|
+
*/
|
|
455
|
+
declare const verifyCrossAssetAmount: (input: {
|
|
456
|
+
readonly pair: string;
|
|
457
|
+
readonly pinned: {
|
|
458
|
+
on: "give" | "take";
|
|
459
|
+
value: bigint;
|
|
460
|
+
};
|
|
461
|
+
readonly give: bigint;
|
|
462
|
+
readonly take: bigint;
|
|
463
|
+
}) => void;
|
|
464
|
+
/**
|
|
465
|
+
* The solver's carrier for an asset deposit, well-formed. Reported as the `pair` check, like the
|
|
466
|
+
* amounts: it is sats the trader funds on top of the quoted give leg.
|
|
467
|
+
*/
|
|
468
|
+
declare const verifiedCarrierSats: (quote: RfqQuote) => bigint;
|
|
603
469
|
|
|
604
470
|
/**
|
|
605
471
|
* `retryable` is the point of the type: a 400 says the packet does not bind to
|
|
@@ -672,4 +538,4 @@ declare function revealClaimPacket(client: CovclaimdClient, input: {
|
|
|
672
538
|
ciphertext: string;
|
|
673
539
|
}>;
|
|
674
540
|
|
|
675
|
-
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, 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, fateMoved, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, publicAssetId, resolveRoute, restoredOfferRecord, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyingDerivation, walletLockupIndexer, withDepositFate, withRfqState };
|
|
541
|
+
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, 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, fateMoved, lightningCorridor, networksOfInvoiceHrp, offerFactsOf, offerRecordSource, onchainCorridor, publicAssetId, resolveRoute, restoredOfferRecord, revealClaimPacket, revealFieldsFromScript, rfqRecordOf, satsOf, scopedToRail, splitRecords, verifiedCarrierSats, verifyCrossAssetAmount, verifyPair, verifyQuoteTtl, verifyQuotedAmount, verifyReceiveInvoiceFacts, verifyReceiveWindow, verifyResponder, verifySendInvoice, verifySendWindow, verifyingDerivation, walletLockupIndexer, withDepositFate, withRfqState };
|