@arkade-os/swap 0.0.11 → 0.1.0-rc.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.
- package/README.md +42 -15
- package/dist/{chunk-RIC5ZTZK.js → chunk-AM3NNUMR.js} +59 -53
- package/dist/index.cjs +585 -202
- package/dist/index.d.cts +127 -36
- package/dist/index.d.ts +127 -36
- package/dist/index.js +528 -157
- package/dist/nostr.cjs +4 -1
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +1 -1
- package/dist/repositories/realm/index.d.cts +4 -4
- package/dist/repositories/realm/index.d.ts +4 -4
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/{repository-CfE18Fif.d.ts → repository-BWP1UstE.d.cts} +84 -56
- package/dist/{repository-B02vsgcV.d.cts → repository-DLpH41ZO.d.ts} +84 -56
- package/dist/{rfq-DkckzRKK.d.ts → rfq-CzCGjICq.d.cts} +42 -32
- package/dist/{rfq-DkckzRKK.d.cts → rfq-CzCGjICq.d.ts} +42 -32
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ProvisionedKey, ProvisionedClaimSecret, asset, RelativeTimelock, IWallet, arkade, RestIndexerProvider, Transaction, IContractManager, VHTLC, Identity, ActivityResolver } from '@arkade-os/sdk';
|
|
2
|
-
import { S as SwapSecretsProjection, R as RfqSwapRecord, A as AssetSwapRepository, a as AssetSwap, M as MarketsCacheEntry, b as
|
|
3
|
-
export {
|
|
2
|
+
import { S as SwapSecretsProjection, R as RfqSwapRecord, A as AssetSwapRepository, a as AssetSwap, M as MarketsCacheEntry, b as RefundIndexer, L as LockupVtxo, c as SwapOperator, d as RfqSwap, e as ArkadeRefundResult, f as LockupSpendIndexer, g as RfqSwapState, h as RfqSwapManager, i as RfqSwapManagerCallbacks } from './repository-DLpH41ZO.js';
|
|
3
|
+
export { j as AssetSwapStatus, k as AvailableRfqSwapManagerCallbacks, B as BTC_ASSET_ID, I as InMemoryAssetSwapRepository, l as LightningReceiveSwap, m as LightningSendSwap, n as LockupFate, o as LockupNeedsRecoveryError, p as LockupParams, q as LockupSpend, O as OnchainSendAction, r as OnchainSendSwap, P as PersistableRfqSwap, s as PreimageBlockedReason, t as PreimageNotRecoverableError, u as REFUND_MTP_LAG_SECONDS, v as RFQ_RESOLVED_STATES, w as RFQ_SWAP_RETENTION_SECONDS, x as RFQ_SWAP_TERMINAL_STATES, y as RefundOutcome, z as RfqRestoreFailure, C as RfqRestoreOptions, D as RfqRestoreResult, E as RfqSwapActionName, F as RfqSwapLockup, G as RfqSwapManagerConfig, H as RfqSwapManagerDeps, J as RfqSwapManagerEvents, K as RfqSwapOrigin, N as RfqSwapOriginRequired, Q as RfqSwapOutcome, T as RfqSwapRecordStore, U as SwapContractRegistry, V as addAssetSwap, W as awaitRfqResolution, X as createRfqSwapRecord, Y as findLockupVtxos, Z as getAssetSwaps, _ as getAssetSwapsOrThrow, $ as isRfqSwapTerminal, a0 as isRfqTerminal, a1 as nextOnchainAction, a2 as normalizeRfqSwapRecord, a3 as preimageForSwapRecord, a4 as pushRefundWithoutReceiver, a5 as readLockupFate, a6 as rebuildRfqSwap, a7 as refundIfUnresolved, a8 as rfqSwapOriginOf, a9 as shouldRetainRfqSwap, aa as swapSecretsToRecord, ab as updateAssetSwap, ac as updateAssetSwapBestEffort, ad as updateRfqSwapRecord } from './repository-DLpH41ZO.js';
|
|
4
4
|
import { Network, LocalCardInput, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
5
|
-
import { O as OnchainNetwork, a as OnchainHtlc, b as OnchainHtlcParams } from './rfq-
|
|
6
|
-
export { A as ARKADE_ASSET,
|
|
5
|
+
import { O as OnchainNetwork, a as OnchainHtlc, b as OnchainHtlcParams, r as requestLightningReceive, c as requestLightningSend, d as requestOnchainSend, I as InvoiceFacts, R as RfqTransport, C as ChainSource } from './rfq-CzCGjICq.js';
|
|
6
|
+
export { A as ARKADE_ASSET, e as ARKADE_BTC, f as AddressMismatch, g as ChainUtxo, H as HtlcUtxo, L as LIGHTNING_BTC, h as LIGHTNING_RECEIVE_PAIR, i as LIGHTNING_SEND_PAIR, j as LOCKTIME_THRESHOLD, k as LightningReceiveContractParams, l as LightningSendContractParams, M as MAX_MIN_CONFIRMATIONS, m as MIN_CLAIM_WINDOW_SECONDS, n as MIN_HEADROOM_SECONDS, o as ONCHAIN_BTC, p as ONCHAIN_CLAIM_MARGIN_SECONDS, q as ONCHAIN_DUST_SATS, s as ONCHAIN_ORDER_MARGIN_SECONDS, t as ONCHAIN_RECEIVE_PAIR, u as ONCHAIN_SECONDS_PER_BLOCK, v as ONCHAIN_SEND_PAIR, w as OnchainHtlcPhase, x as RFQ_TERMINAL_STATES, y as RelaySocket, z as RfqQuote, B as RfqRefusalReason, D as RfqStatus, S as SOLO_REFUND_HEADROOM_SECONDS, E as SwapRefusal, F as arkadeAssetLeg, G as arkadeSwapRequest, J as assertFundable, K as assertReceivable, N as awaitOnchainFill, P as buildHtlcClaim, Q as buildHtlcRefund, T as claimOnchainFill, U as classifyOnchainHtlc, V as deriveLightningReceive, W as deriveOnchainReceive, X as deriveOnchainSend, Y as extractPreimage, Z as httpTransport, _ as lightningReceiveContract, $ as lightningReceiveRequest, a0 as lightningSendContract, a1 as lightningSendRequest, a2 as newPreimage, a3 as newRfqId, a4 as offerTermsFromQuote, a5 as onchainHtlcScript, a6 as onchainReceiveRequest, a7 as onchainSendRequest, a8 as paymentHashOf, a9 as relayTransport, aa as requestOnchainReceive, ab as rfqPair, ac as unilateralClaimDelay, ad as unilateralRefundDelay, ae as unilateralRefundWithoutReceiverDelay, af as verifyLockupAddress, ag as verifyReceiveInvoice } from './rfq-CzCGjICq.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Which wallet key signs this leg. Stored at `profile.signer`.
|
|
@@ -111,7 +111,7 @@ interface LightningReceiveProfile extends Record<string, unknown> {
|
|
|
111
111
|
* preimage that is already public, and a swap that did claim is relabelled
|
|
112
112
|
* `needs_counterparty` once its window shuts.
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
claimTxid?: string;
|
|
115
115
|
}
|
|
116
116
|
/** `arkade:BTC->onchain:BTC`. */
|
|
117
117
|
interface OnchainSendProfile extends Record<string, unknown> {
|
|
@@ -224,7 +224,7 @@ interface Offer {
|
|
|
224
224
|
exitDelay?: RelativeTimelock;
|
|
225
225
|
}
|
|
226
226
|
/** Compile the offer's contract: program + args -> taproot tree. */
|
|
227
|
-
declare function
|
|
227
|
+
declare function offerContract(offer: Omit<Offer, "swapPkScript">, operatorPubkey: Uint8Array): InstanceType<typeof arkade.ArkadeProgramScript>;
|
|
228
228
|
/** Extension packet type tag for Arkade Intents offers. */
|
|
229
229
|
declare const OFFER_PACKET_TYPE = 3;
|
|
230
230
|
/** Serialize an offer to TLV bytes (the packet payload). */
|
|
@@ -236,11 +236,11 @@ declare function decodeOffer(data: Uint8Array): Offer;
|
|
|
236
236
|
* you deposit, embedding the returned extension, and the solver does the rest:
|
|
237
237
|
*
|
|
238
238
|
* // BTC -> asset
|
|
239
|
-
* const o = await createOffer(wallet,
|
|
239
|
+
* const o = await createOffer(wallet, { wantAmount: 1000n, wantAsset })
|
|
240
240
|
* await wallet.send({ address: o.address, amount: 1000, extensions: [o.extension] })
|
|
241
241
|
*
|
|
242
242
|
* // asset -> BTC (the sats are the VTXO carrier for the asset)
|
|
243
|
-
* const o = await createOffer(wallet,
|
|
243
|
+
* const o = await createOffer(wallet, { wantAmount: 1000n, offerAsset })
|
|
244
244
|
* await wallet.send({ address: o.address, amount: 500,
|
|
245
245
|
* assets: [{ assetId, amount: 1000n }],
|
|
246
246
|
* extensions: [o.extension] })
|
|
@@ -261,7 +261,7 @@ declare function decodeOffer(data: Uint8Array): Offer;
|
|
|
261
261
|
* so that exposure has no end. `noExit` opts out for a caller who wants the
|
|
262
262
|
* smaller tree and accepts the dependency.
|
|
263
263
|
*/
|
|
264
|
-
declare function createOffer(wallet: IWallet,
|
|
264
|
+
declare function createOffer(wallet: IWallet, params: {
|
|
265
265
|
wantAmount: bigint;
|
|
266
266
|
wantAsset?: asset.AssetId;
|
|
267
267
|
offerAsset?: asset.AssetId;
|
|
@@ -328,8 +328,8 @@ declare function createOffer(wallet: IWallet, arkServerUrl: string, params: {
|
|
|
328
328
|
* Identical offers derive the same address, so `fundingTxid` selects the exact
|
|
329
329
|
* deposit; without it the address must hold exactly one spendable VTXO — with
|
|
330
330
|
* several, cancel refuses to guess and throws.
|
|
331
|
-
* `swapAddress` (the funded address) pins the
|
|
332
|
-
* built with, so cancel keeps working across
|
|
331
|
+
* `swapAddress` (the funded address) pins the operator key the covenant was
|
|
332
|
+
* built with, so cancel keeps working across an operator signer rotation; without
|
|
333
333
|
* it a rotated key is detected and reported rather than reading as a missing
|
|
334
334
|
* VTXO.
|
|
335
335
|
*
|
|
@@ -350,8 +350,13 @@ declare function createOffer(wallet: IWallet, arkServerUrl: string, params: {
|
|
|
350
350
|
* returns, so a spend event that arrives in that window finds a `cancelling`
|
|
351
351
|
* record and classifies the spend by its covenant leaf instead — the same
|
|
352
352
|
* answer, one indexer read more.
|
|
353
|
+
*
|
|
354
|
+
* Takes no server URL, like every other entrypoint here: broadcast comes from
|
|
355
|
+
* `wallet.getArkadeBroadcaster()` and the indexer fallback from
|
|
356
|
+
* `wallet.getArkadeReader()`, so the wallet's own connection is the only one
|
|
357
|
+
* used (#734).
|
|
353
358
|
*/
|
|
354
|
-
declare function cancelOffer(wallet: IWallet,
|
|
359
|
+
declare function cancelOffer(wallet: IWallet, offerHex: string, opts: {
|
|
355
360
|
repository: AssetSwapRepository;
|
|
356
361
|
fundingTxid?: string;
|
|
357
362
|
swapAddress?: string;
|
|
@@ -430,8 +435,7 @@ type PlanError = "insufficient-balance" | "side-disabled" | "below-min" | "above
|
|
|
430
435
|
/** Validate a plan against the user's balance and the server dust limit. */
|
|
431
436
|
declare const validatePlan: (plan: OfferPlan, giveBalance: bigint, dust: bigint) => PlanError | undefined;
|
|
432
437
|
|
|
433
|
-
/** Browser backend over the SDK's shared IndexedDB manager
|
|
434
|
-
* infrastructure the wallet already uses for its Boltz swap repository. */
|
|
438
|
+
/** Browser backend over the SDK's shared IndexedDB manager. */
|
|
435
439
|
declare class IndexedDbAssetSwapRepository implements AssetSwapRepository {
|
|
436
440
|
readonly version: 4;
|
|
437
441
|
private readonly connection;
|
|
@@ -520,12 +524,12 @@ type SpendKind = "cancelled" | "fulfilled" | "indeterminate";
|
|
|
520
524
|
* and they also survive batching: a solver filling several offers in one tx
|
|
521
525
|
* gives each input its own leaf.
|
|
522
526
|
*
|
|
523
|
-
* `
|
|
527
|
+
* `operatorPubkey` must be the key the covenant was *funded* against. If it has
|
|
524
528
|
* rotated since, the rebuilt script will not match the offer's own
|
|
525
529
|
* `swapPkScript` and this returns `indeterminate` rather than guessing —
|
|
526
530
|
* `cancelOffer` diagnoses the same mismatch the same way.
|
|
527
531
|
*/
|
|
528
|
-
declare function classifySpend(offer: Offer,
|
|
532
|
+
declare function classifySpend(offer: Offer, operatorPubkey: Uint8Array, spendTx: Transaction, deposit: {
|
|
529
533
|
txid: string;
|
|
530
534
|
vout: number;
|
|
531
535
|
}): SpendKind;
|
|
@@ -546,7 +550,7 @@ declare const spendTxidsOf: (vtxo: {
|
|
|
546
550
|
* settlement they may be the same id. Try each and take the first definite
|
|
547
551
|
* answer, so the classification does not depend on that distinction.
|
|
548
552
|
*/
|
|
549
|
-
declare function classifyDepositSpend(offer: Offer,
|
|
553
|
+
declare function classifyDepositSpend(offer: Offer, operatorPubkey: Uint8Array, spendTxs: Iterable<Transaction>, deposit: {
|
|
550
554
|
txid: string;
|
|
551
555
|
vout: number;
|
|
552
556
|
}): SpendKind;
|
|
@@ -571,12 +575,12 @@ declare function classifyDepositSpend(offer: Offer, serverPubkey: Uint8Array, sp
|
|
|
571
575
|
* does, so the `existingIds` escape hatch is no longer a correction mechanism
|
|
572
576
|
* for a wrong label — it is only a skip list.
|
|
573
577
|
*
|
|
574
|
-
* `
|
|
578
|
+
* `operatorPubkey` must be the operator key the covenants were funded against; a
|
|
575
579
|
* key that has rotated since makes every affected swap unclassifiable rather
|
|
576
580
|
* than misclassified.
|
|
577
581
|
*/
|
|
578
582
|
declare function restoreAssetSwaps(indexer: RestoreIndexer, txs: Tx[], existingIds: ReadonlySet<string>, opts: {
|
|
579
|
-
|
|
583
|
+
operatorPubkey: Uint8Array;
|
|
580
584
|
scanned?: ReadonlySet<string>;
|
|
581
585
|
}): Promise<{
|
|
582
586
|
restored: AssetSwap[];
|
|
@@ -604,9 +608,6 @@ interface OfferSwapWatcher {
|
|
|
604
608
|
}
|
|
605
609
|
interface WatchOfferSwapsParams {
|
|
606
610
|
wallet: IWallet;
|
|
607
|
-
/** Same URL `createOffer`/`cancelOffer` take; used to read a spending tx
|
|
608
|
-
* when the exact classifier cannot answer. */
|
|
609
|
-
arkServerUrl: string;
|
|
610
611
|
repository: AssetSwapRepository;
|
|
611
612
|
/** Called after a change is persisted. A notification, not a store. */
|
|
612
613
|
onUpdate?: (swap: AssetSwap) => void;
|
|
@@ -622,7 +623,7 @@ interface WatchOfferSwapsParams {
|
|
|
622
623
|
* provide an `EventSource` implementation or use a runtime where it is enabled;
|
|
623
624
|
* otherwise live updates do not arrive and restore remains the fallback.
|
|
624
625
|
*/
|
|
625
|
-
declare function watchOfferSwaps({ wallet,
|
|
626
|
+
declare function watchOfferSwaps({ wallet, repository, onUpdate, }: WatchOfferSwapsParams): Promise<OfferSwapWatcher>;
|
|
626
627
|
|
|
627
628
|
/**
|
|
628
629
|
* Coverage: whether an offer's script is in the wallet's watched set.
|
|
@@ -690,8 +691,6 @@ interface ClaimPacketInput {
|
|
|
690
691
|
*/
|
|
691
692
|
declare function sealClaimPacket(input: ClaimPacketInput): Promise<SealedClaimPacket>;
|
|
692
693
|
|
|
693
|
-
/** The Ark surface the claim push needs — the same seam the refund push uses. */
|
|
694
|
-
type ClaimArkProvider = RefundArkProvider;
|
|
695
694
|
/**
|
|
696
695
|
* The lockup is funded for less than the swap agreed.
|
|
697
696
|
*
|
|
@@ -734,9 +733,9 @@ declare class LockupAmountMismatchError extends Error {
|
|
|
734
733
|
* server at submit — but it turns "reported claimed, nothing landed, the
|
|
735
734
|
* solver refunds hours later" into an immediate failure.
|
|
736
735
|
*/
|
|
737
|
-
declare function pushClaim(
|
|
738
|
-
/** The receive-direction covenant (see `
|
|
739
|
-
|
|
736
|
+
declare function pushClaim(operator: SwapOperator, input: {
|
|
737
|
+
/** The receive-direction covenant (see `lightningReceiveContract`). */
|
|
738
|
+
contract: InstanceType<typeof VHTLC.ScriptV2>;
|
|
740
739
|
/** The trader's `receiver` signer. Build it from the swap's `secrets`
|
|
741
740
|
* with `contractSigner` — on an HD wallet that resolves
|
|
742
741
|
* from the seed, with no stored key bytes anywhere. */
|
|
@@ -756,7 +755,7 @@ declare function pushClaim(ark: ClaimArkProvider, input: {
|
|
|
756
755
|
* the remainder. */
|
|
757
756
|
partiallyClaimed?: boolean;
|
|
758
757
|
}): Promise<{
|
|
759
|
-
|
|
758
|
+
txid: string;
|
|
760
759
|
amount: number;
|
|
761
760
|
}>;
|
|
762
761
|
/**
|
|
@@ -783,13 +782,13 @@ declare function awaitLockupFunding(indexer: RefundIndexer, swapPkScript: Uint8A
|
|
|
783
782
|
* rest lands is safe — and that is also the answer to a genuinely underfunded
|
|
784
783
|
* lockup, which never gets past the gate at all.
|
|
785
784
|
*/
|
|
786
|
-
declare function claimReceiveLockup(indexer: RefundIndexer,
|
|
785
|
+
declare function claimReceiveLockup(indexer: RefundIndexer, operator: SwapOperator, input: Parameters<typeof pushClaim>[1] & {
|
|
787
786
|
/** The covenant's scriptPubKey, from the request flow's `swapPkScript`. */
|
|
788
787
|
swapPkScript: Uint8Array;
|
|
789
788
|
pollMs?: number;
|
|
790
789
|
deadline?: number;
|
|
791
790
|
}): Promise<{
|
|
792
|
-
|
|
791
|
+
txid: string;
|
|
793
792
|
amount: number;
|
|
794
793
|
}>;
|
|
795
794
|
|
|
@@ -856,7 +855,7 @@ declare function senderIdentityForSwapRecord(wallet: IWallet, record: {
|
|
|
856
855
|
*/
|
|
857
856
|
|
|
858
857
|
interface ArkadeRefunderDeps {
|
|
859
|
-
|
|
858
|
+
operator: SwapOperator;
|
|
860
859
|
indexer: RefundIndexer;
|
|
861
860
|
/** Asked for the descriptor's signer; never asked to mint a key. */
|
|
862
861
|
wallet: IWallet;
|
|
@@ -872,7 +871,7 @@ interface ArkadeRefunderDeps {
|
|
|
872
871
|
*
|
|
873
872
|
* @example
|
|
874
873
|
* manager.setCallbacks({
|
|
875
|
-
* refundArkade: arkadeRefunder({
|
|
874
|
+
* refundArkade: arkadeRefunder({ operator, indexer, wallet, repository }),
|
|
876
875
|
* saveSwap,
|
|
877
876
|
* });
|
|
878
877
|
*/
|
|
@@ -1000,7 +999,7 @@ interface RfqSwapActivityDeps {
|
|
|
1000
999
|
repository: Pick<AssetSwapRepository, "getAllRfqSwaps">;
|
|
1001
1000
|
/**
|
|
1002
1001
|
* Consulted only for what a record cannot answer: a record written before
|
|
1003
|
-
* `
|
|
1002
|
+
* `fundingTxid` existed, and the counterparty's spend on a swap that
|
|
1004
1003
|
* ended without a refund of ours.
|
|
1005
1004
|
*
|
|
1006
1005
|
* Optional because the stored fields are the primary source — cheaper, and
|
|
@@ -1014,7 +1013,7 @@ interface RfqSwapActivityDeps {
|
|
|
1014
1013
|
* groups on.
|
|
1015
1014
|
*
|
|
1016
1015
|
* The txids come from four places, in order of preference: the record's own
|
|
1017
|
-
* `
|
|
1016
|
+
* `fundingTxid` and `refundTxid`, the corridor's `activityTxids` (the
|
|
1018
1017
|
* receive leg's Arkade claim, the onchain leg's L1 one), and — only when the
|
|
1019
1018
|
* first two cannot answer — one read of the lockup's VTXOs.
|
|
1020
1019
|
*
|
|
@@ -1024,4 +1023,96 @@ interface RfqSwapActivityDeps {
|
|
|
1024
1023
|
*/
|
|
1025
1024
|
declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
|
|
1026
1025
|
|
|
1027
|
-
|
|
1026
|
+
interface SwapQuoteInput {
|
|
1027
|
+
/** Which side of the market the trader deposits. */
|
|
1028
|
+
give: "base" | "quote";
|
|
1029
|
+
/** Size on the named side ("give" = exact-in, "receive" = exact-out).
|
|
1030
|
+
* Spot: display string or atomic bigint; corridors: sats. A lightning
|
|
1031
|
+
* send takes its amount from the invoice instead. */
|
|
1032
|
+
amount?: string | number | bigint;
|
|
1033
|
+
amountOn?: "give" | "receive";
|
|
1034
|
+
/** Required when the receive side is lightning. */
|
|
1035
|
+
invoice?: InvoiceFacts;
|
|
1036
|
+
/** Trader's x-only L1 claim key; required when the receive side is onchain. */
|
|
1037
|
+
payoutPubkey?: Uint8Array;
|
|
1038
|
+
preimage?: Uint8Array;
|
|
1039
|
+
maxPayAmount?: number;
|
|
1040
|
+
}
|
|
1041
|
+
interface SpotQuote {
|
|
1042
|
+
kind: "spot";
|
|
1043
|
+
market: DiscoveredMarket;
|
|
1044
|
+
plan: OfferPlan;
|
|
1045
|
+
}
|
|
1046
|
+
interface LightningSendQuote {
|
|
1047
|
+
kind: "ln_send";
|
|
1048
|
+
market: DiscoveredMarket;
|
|
1049
|
+
request: Awaited<ReturnType<typeof requestLightningSend>>;
|
|
1050
|
+
}
|
|
1051
|
+
interface LightningReceiveQuote {
|
|
1052
|
+
kind: "ln_receive";
|
|
1053
|
+
market: DiscoveredMarket;
|
|
1054
|
+
request: Awaited<ReturnType<typeof requestLightningReceive>>;
|
|
1055
|
+
/** The solver's hold invoice, for the payer. */
|
|
1056
|
+
invoice: string;
|
|
1057
|
+
}
|
|
1058
|
+
interface OnchainSendQuote {
|
|
1059
|
+
kind: "onchain_send";
|
|
1060
|
+
market: DiscoveredMarket;
|
|
1061
|
+
request: Awaited<ReturnType<typeof requestOnchainSend>>;
|
|
1062
|
+
}
|
|
1063
|
+
type SwapQuote = SpotQuote | LightningSendQuote | LightningReceiveQuote | OnchainSendQuote;
|
|
1064
|
+
type UnifiedSwap = {
|
|
1065
|
+
family: "offer";
|
|
1066
|
+
swap: AssetSwap;
|
|
1067
|
+
} | {
|
|
1068
|
+
family: "rfq";
|
|
1069
|
+
swap: RfqSwap;
|
|
1070
|
+
};
|
|
1071
|
+
interface SwapClientDeps {
|
|
1072
|
+
/** The server connection too: every provider below defaults to this
|
|
1073
|
+
* wallet's own, so no server URL is passed in (arkade-os/ts-sdk#734). */
|
|
1074
|
+
wallet: IWallet;
|
|
1075
|
+
repository: AssetSwapRepository;
|
|
1076
|
+
/** The rendezvous for a corridor market; never called for a spot one.
|
|
1077
|
+
*
|
|
1078
|
+
* The market's own `base_corridor`/`quote_corridor` are what route a swap
|
|
1079
|
+
* here rather than to the offer path, so whoever publishes the market
|
|
1080
|
+
* chooses which backend you are asked to open a transport to. Resolve one
|
|
1081
|
+
* only for markets from an index you trust — this client does not, and
|
|
1082
|
+
* cannot, check that a market named a corridor honestly. */
|
|
1083
|
+
transportFor: (market: DiscoveredMarket) => RfqTransport;
|
|
1084
|
+
discovery: Omit<DiscoverMarketsOptions, "repository">;
|
|
1085
|
+
/** BOLT11 decoder for the solver's hold invoice; required to quote lightning receives. */
|
|
1086
|
+
decodeInvoice?: (bolt11: string) => InvoiceFacts;
|
|
1087
|
+
/** covclaimd's 33-byte compressed pubkey — the lightning-receive claim
|
|
1088
|
+
* packet seals to it; required to quote lightning receives. */
|
|
1089
|
+
covclaimdPubkey?: Uint8Array;
|
|
1090
|
+
/** L1 access; required to quote onchain sends. */
|
|
1091
|
+
chain?: ChainSource;
|
|
1092
|
+
/** L1 claim callback (fee rate and signing are environment-specific);
|
|
1093
|
+
* without it the manager reports onchain claims as blocked. */
|
|
1094
|
+
claimOnchain?: RfqSwapManagerCallbacks["claimOnchain"];
|
|
1095
|
+
emulatorPubkey?: string;
|
|
1096
|
+
/** Overrides the wallet's own connection; for tests and for a caller that
|
|
1097
|
+
* must reach a different operator. */
|
|
1098
|
+
ark?: SwapOperator;
|
|
1099
|
+
indexer?: LockupSpendIndexer;
|
|
1100
|
+
}
|
|
1101
|
+
interface SwapClient {
|
|
1102
|
+
markets(useCache?: boolean): Promise<DiscoveredMarket[]>;
|
|
1103
|
+
quote(market: DiscoveredMarket, input: SwapQuoteInput): Promise<SwapQuote>;
|
|
1104
|
+
accept(quote: SwapQuote): Promise<UnifiedSwap>;
|
|
1105
|
+
/** Spot only: the covenant's cooperative reclaim. */
|
|
1106
|
+
cancel(fundingTxid: string): Promise<void>;
|
|
1107
|
+
/** Every swap this client knows of, both families and both live and ended
|
|
1108
|
+
* — not a live-only view. The RFQ half is bounded by what the manager has
|
|
1109
|
+
* loaded and by `RFQ_SWAP_RETENTION_SECONDS`. */
|
|
1110
|
+
swaps(): Promise<UnifiedSwap[]>;
|
|
1111
|
+
onUpdate(listener: (swap: UnifiedSwap) => void): () => void;
|
|
1112
|
+
start(): Promise<void>;
|
|
1113
|
+
stop(): Promise<void>;
|
|
1114
|
+
readonly manager: RfqSwapManager;
|
|
1115
|
+
}
|
|
1116
|
+
declare function createSwapClient(deps: SwapClientDeps): SwapClient;
|
|
1117
|
+
|
|
1118
|
+
export { ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, ChainSource, type ClaimPacketInput, type DiscoverMarketsOptions, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningReceiveQuote, type LightningSendProfile, type LightningSendQuote, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type OnchainSendQuote, type PlanError, QUOTE_OPTIONS, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RestoreIndexer, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapManager, RfqSwapManagerCallbacks, RfqSwapRecord, RfqSwapState, RfqTransport, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SpendKind, type SpotQuote, type SwapActivityInput, type SwapClient, type SwapClientDeps, SwapOperator, type SwapQuote, type SwapQuoteInput, SwapSecretsProjection, type Tx, type UnifiedSwap, type WatchOfferSwapsParams, arkadeRefunder, awaitLockupFunding, cancelOffer, claimReceiveLockup, classifyDepositSpend, classifySpend, createOffer, createSwapClient, decodeOffer, discoverMarkets, encodeOffer, findMarket, lockupContractParams, makeCachedFeedFetch, offerContract, onchainSendProfile, pushClaim, registerLockupContract, requestLightningReceive, requestLightningSend, requestOnchainSend, restoreAssetSwaps, retireSettledOfferContracts, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
|