@arkade-os/swap 0.1.0-rc.21 → 0.1.0-rc.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/advanced.cjs +875 -129
- package/dist/advanced.d.cts +158 -14
- package/dist/advanced.d.ts +158 -14
- package/dist/advanced.js +255 -4
- package/dist/{chunk-ITFCQWPG.js → chunk-DQ2DY2L2.js} +223 -11
- package/dist/{chunk-HUQQVBC4.js → chunk-MZX62KMU.js} +220 -12
- package/dist/{chunk-PVB7EBAM.js → chunk-UFJEO4VV.js} +47 -21
- package/dist/{errors-hm7aqnRM.d.cts → errors-5q4e3PnH.d.cts} +48 -16
- package/dist/{errors-C3h8ANmE.d.ts → errors-DQ35FKJf.d.ts} +48 -16
- package/dist/index.cjs +670 -185
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -3
- package/dist/node/index.d.cts +26 -4
- package/dist/node/index.d.ts +26 -4
- package/dist/nostr.cjs +12 -9
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +3 -1
- package/dist/{offer-Bd9Yvd8Z.d.ts → offer--IpfzhIm.d.ts} +1 -1
- package/dist/{offer-F88rtL_I.d.cts → offer-DqTXQeP1.d.cts} +1 -1
- package/dist/protocol.cjs +395 -156
- package/dist/protocol.d.cts +45 -8
- package/dist/protocol.d.ts +45 -8
- package/dist/protocol.js +10 -3
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/{repository-DYnRLPt-.d.ts → repository-B4rQWmS2.d.cts} +88 -20
- package/dist/{repository-BuYWGAKz.d.cts → repository-D_qvJk1S.d.ts} +88 -20
- package/dist/{rfq-60PGpQ_x.d.cts → rfq-BgdgO9OO.d.cts} +16 -7
- package/dist/{rfq-60PGpQ_x.d.ts → rfq-BgdgO9OO.d.ts} +16 -7
- package/dist/{watch-BTyiBLSd.d.ts → watch-BkPz0vf8.d.ts} +1 -1
- package/dist/{watch-M_KY-5ho.d.cts → watch-RRhKuBkh.d.cts} +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
2
2
|
import { IWallet, ProvisionedKey, ProvisionedClaimSecret, ArkProvider, RestIndexerProvider, IContractManager, VHTLC, Identity, Network, NetworkName, asset, PageRequest, PageResult } from '@arkade-os/sdk';
|
|
3
|
-
import { D as RfqStatus, e as RfqTransport, O as OnchainHtlc, l as ChainUtxo, C as ChainSource, y as OnchainHtlcPhase } from './rfq-
|
|
3
|
+
import { D as RfqStatus, e as RfqTransport, O as OnchainHtlc, l as ChainUtxo, C as ChainSource, y as OnchainHtlcPhase } from './rfq-BgdgO9OO.js';
|
|
4
4
|
|
|
5
5
|
/** @deprecated Use `Outcome`. Moved off the package root to `@arkade-os/swap/protocol`. */
|
|
6
6
|
type AssetSwapStatus = "pending" | "cancelling" | "fulfilled" | "cancelled" | "recoverable" | "awaiting_fill" | "claimable" | "claimed" | "refunded_l1";
|
|
@@ -482,7 +482,8 @@ interface RfqSwapCommon {
|
|
|
482
482
|
refundLocktime: number;
|
|
483
483
|
createdAt: number;
|
|
484
484
|
updatedAt: number;
|
|
485
|
-
/**
|
|
485
|
+
/** The trader's own refund: the `refundWithoutReceiver` push that landed, or on
|
|
486
|
+
* `onchain_receive` the L1 HTLC refund. */
|
|
486
487
|
refundTxid?: string;
|
|
487
488
|
/**
|
|
488
489
|
* The ark transactions that SPENT the lockup, from the chain read that ended the swap
|
|
@@ -567,10 +568,31 @@ interface LightningReceiveSwap extends RfqSwapCommon {
|
|
|
567
568
|
* otherwise the caller persists via {@link RfqSwapManagerCallbacks.saveSwap} and hands
|
|
568
569
|
* rebuilt swaps to {@link RfqSwapManager.start}.
|
|
569
570
|
*
|
|
570
|
-
* **`onchain:BTC->arkade:BTC` is deliberately not a member**: monitoring only its lockup
|
|
571
|
-
* half would silently let the trader's own L1 refund window pass.
|
|
572
571
|
*/
|
|
573
|
-
type RfqSwap = LightningSendSwap | OnchainSendSwap | LightningReceiveSwap;
|
|
572
|
+
type RfqSwap = LightningSendSwap | OnchainSendSwap | LightningReceiveSwap | OnchainReceiveSwap;
|
|
573
|
+
/**
|
|
574
|
+
* `onchain:BTC->arkade:BTC`. A {@link LightningReceiveSwap}'s lockup plus an L1
|
|
575
|
+
* HTLC the trader funds and must take back itself. That refund leaf does not
|
|
576
|
+
* expire, so the failure to drive against is the manager finishing the swap
|
|
577
|
+
* while the output still holds the trader's money.
|
|
578
|
+
*/
|
|
579
|
+
interface OnchainReceiveSwap extends RfqSwapCommon {
|
|
580
|
+
kind: "onchain_receive";
|
|
581
|
+
expectedAmount: number;
|
|
582
|
+
/** Its `refundLocktime` is the trader's own, NOT {@link RfqSwapCommon}'s. */
|
|
583
|
+
htlc: OnchainHtlc;
|
|
584
|
+
minConfirmations: number;
|
|
585
|
+
/** Required, unlike the send leg's optional `payoutPkScript`: without it
|
|
586
|
+
* the refund cannot be built at all. */
|
|
587
|
+
refundPkScript: Uint8Array;
|
|
588
|
+
funding?: {
|
|
589
|
+
txid: string;
|
|
590
|
+
vout: number;
|
|
591
|
+
};
|
|
592
|
+
claimTxid?: string;
|
|
593
|
+
}
|
|
594
|
+
/** The two legs sharing one claim path, `expectedAmount` gate included. */
|
|
595
|
+
type ReceiveLockupSwap = LightningReceiveSwap | OnchainReceiveSwap;
|
|
574
596
|
/** What the manager should do next about an onchain-send swap's L1 half.
|
|
575
597
|
*
|
|
576
598
|
* @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
|
|
@@ -606,6 +628,16 @@ declare function nextOnchainAction(input: {
|
|
|
606
628
|
/** Unix seconds. */
|
|
607
629
|
now: number;
|
|
608
630
|
}): OnchainSendAction;
|
|
631
|
+
/** {@link OnchainSendAction}'s mirror, minus `refund_window_closed`: an
|
|
632
|
+
* `nLockTime` refund leaf does not close. */
|
|
633
|
+
type OnchainReceiveAction = "wait" | "refund" | "refunded" | "taken";
|
|
634
|
+
/**
|
|
635
|
+
* Off the SAME phases the send leg reads (see {@link OnchainHtlcPhase}); no
|
|
636
|
+
* clock or margin, `refundable` being the median-time-past verdict itself. */
|
|
637
|
+
declare function nextOnchainReceiveAction(input: {
|
|
638
|
+
phase: OnchainHtlcPhase;
|
|
639
|
+
settled: boolean;
|
|
640
|
+
}): OnchainReceiveAction;
|
|
609
641
|
/** What the trader's own `refundWithoutReceiver` push returned, or `null` when
|
|
610
642
|
* the lockup held nothing to return.
|
|
611
643
|
*/
|
|
@@ -627,6 +659,14 @@ interface RfqSwapManagerCallbacks {
|
|
|
627
659
|
claimOnchain: (swap: OnchainSendSwap, utxo: ChainUtxo) => Promise<{
|
|
628
660
|
txid: string;
|
|
629
661
|
}>;
|
|
662
|
+
/**
|
|
663
|
+
* `buildHtlcRefund` over `swap.refundPkScript`, then `chain.broadcast`. Required for
|
|
664
|
+
* {@link claimOnchain}'s reason: monitoring one of these unwired strands the trader's
|
|
665
|
+
* funding. A throw is retried indefinitely.
|
|
666
|
+
*/
|
|
667
|
+
refundOnchain: (swap: OnchainReceiveSwap, utxo: ChainUtxo) => Promise<{
|
|
668
|
+
txid: string;
|
|
669
|
+
}>;
|
|
630
670
|
/**
|
|
631
671
|
* Claim the solver-funded lockup on a receive leg, revealing `P`. Wire it to
|
|
632
672
|
* `pushClaim` (the outputs are supplied, so `claimReceiveLockup`'s wait is redundant).
|
|
@@ -635,7 +675,7 @@ interface RfqSwapManagerCallbacks {
|
|
|
635
675
|
* value check decides WHEN to act; `pushClaim`'s decides whether `P` is published and
|
|
636
676
|
* is the load-bearing one. Do not drop it because the outer one exists.
|
|
637
677
|
*/
|
|
638
|
-
claimLockup: (swap:
|
|
678
|
+
claimLockup: (swap: ReceiveLockupSwap, vtxos: readonly LockupVtxo[], options: {
|
|
639
679
|
/** A claim of ours is already out, so `P` is public and the value gate has
|
|
640
680
|
* nothing left to protect; lets a piecemeal funding still be swept. */
|
|
641
681
|
partiallyClaimed: boolean;
|
|
@@ -686,8 +726,8 @@ interface RfqSwapManagerCallbacks {
|
|
|
686
726
|
* A kind whose claim is missing blocks at runtime instead: non-terminal, re-evaluated
|
|
687
727
|
* every pass, lifted once `setCallbacks` supplies it.
|
|
688
728
|
*/
|
|
689
|
-
type AvailableRfqSwapManagerCallbacks = Omit<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "saveSwap"> & Partial<Pick<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "saveSwap">>;
|
|
690
|
-
type RfqSwapActionName = "claimOnchain" | "claimLockup" | "refundArkade";
|
|
729
|
+
type AvailableRfqSwapManagerCallbacks = Omit<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "refundOnchain" | "saveSwap"> & Partial<Pick<RfqSwapManagerCallbacks, "claimOnchain" | "claimLockup" | "refundOnchain" | "saveSwap">>;
|
|
730
|
+
type RfqSwapActionName = "claimOnchain" | "claimLockup" | "refundArkade" | "refundOnchain";
|
|
691
731
|
/** @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`. */
|
|
692
732
|
interface RfqSwapManagerEvents {
|
|
693
733
|
/** Every state change, including backwards ones: `claimed -> claimable` is expected on
|
|
@@ -747,6 +787,16 @@ declare class RfqSwapOriginRequired extends Error {
|
|
|
747
787
|
readonly rfqId: string;
|
|
748
788
|
constructor(rfqId: string);
|
|
749
789
|
}
|
|
790
|
+
/** An `onchain_receive` swap reached a manager with no {@link RfqSwapManagerDeps.chain}, so it
|
|
791
|
+
* could watch only half the corridor. Thrown from `addSwap`, normally the last moment before the
|
|
792
|
+
* trader funds.
|
|
793
|
+
*
|
|
794
|
+
* @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
|
|
795
|
+
*/
|
|
796
|
+
declare class OnchainReceiveNeedsChainSource extends Error {
|
|
797
|
+
readonly rfqId: string;
|
|
798
|
+
constructor(rfqId: string);
|
|
799
|
+
}
|
|
750
800
|
/** One stored record that could not be turned back into a live swap.
|
|
751
801
|
*
|
|
752
802
|
* @deprecated Use `createSwapClient` and `client.onUpdate()`. Moved off the package root to `@arkade-os/swap/protocol`.
|
|
@@ -1030,6 +1080,12 @@ declare class RfqSwapManager {
|
|
|
1030
1080
|
/** Claim what the solver funded, once it is enough (the inner gate that matters is
|
|
1031
1081
|
* `pushClaim`'s; see {@link RfqSwapManagerCallbacks.claimLockup}). */
|
|
1032
1082
|
private claimIfFunded;
|
|
1083
|
+
/** `settled` ends the swap; `returned` does NOT, signalling their L1
|
|
1084
|
+
* funding is stranded. */
|
|
1085
|
+
private driveOnchainReceive;
|
|
1086
|
+
/** `resolved`: the HTLC can hold nothing more. `blocked` is a refusal the
|
|
1087
|
+
* caller applies once the Arkade arm has run. No give-up branch. */
|
|
1088
|
+
private driveOnchainRefund;
|
|
1033
1089
|
/** `handled` ends the pass; `continue` falls through to the refund gate. */
|
|
1034
1090
|
private driveOnchain;
|
|
1035
1091
|
private driveArkadeRefund;
|
|
@@ -1095,10 +1151,10 @@ interface RfqSwapOutcome {
|
|
|
1095
1151
|
}
|
|
1096
1152
|
|
|
1097
1153
|
/**
|
|
1098
|
-
* The swap kinds this projection covers — all
|
|
1099
|
-
* ride in
|
|
1154
|
+
* The swap kinds this projection covers — all four the manager monitors. The onchain legs' L1 keys
|
|
1155
|
+
* ride in their profiles, since no contract row or `OnchainHtlc` field can give them back.
|
|
1100
1156
|
*/
|
|
1101
|
-
type PersistableRfqSwap = LightningSendSwap | LightningReceiveSwap | OnchainSendSwap;
|
|
1157
|
+
type PersistableRfqSwap = LightningSendSwap | LightningReceiveSwap | OnchainSendSwap | OnchainReceiveSwap;
|
|
1102
1158
|
/**
|
|
1103
1159
|
* The serialized covenant parameters a rebuild is given: `VHTLCV2ContractHandler`'s own wire shape,
|
|
1104
1160
|
* exactly what a lockup's contract row stores under `params`.
|
|
@@ -1486,7 +1542,7 @@ type Outcome =
|
|
|
1486
1542
|
| "paid" | "cancelling" | "cancelled"
|
|
1487
1543
|
/** A send leg past `refundLocktime` with a refund push in flight. */
|
|
1488
1544
|
| "refunding"
|
|
1489
|
-
/** The trader's value came back
|
|
1545
|
+
/** The trader's value came back: a send leg, or `onchain_receive`'s L1 refund. */
|
|
1490
1546
|
| "refunded"
|
|
1491
1547
|
/** A receive leg the trader never claimed: the solver took the lockup back
|
|
1492
1548
|
* and the incoming payment never arrived. */
|
|
@@ -1555,12 +1611,26 @@ declare const CORRIDOR_PASS: {
|
|
|
1555
1611
|
readonly actions: readonly ["claimOnchain", "refundArkade"];
|
|
1556
1612
|
readonly seams: readonly ["indexer", "chain"];
|
|
1557
1613
|
};
|
|
1614
|
+
readonly onchain_receive: {
|
|
1615
|
+
readonly lockups: readonly [{
|
|
1616
|
+
readonly covenant: "arkade_lockup";
|
|
1617
|
+
readonly owner: "solver";
|
|
1618
|
+
readonly deadline: "refund_locktime";
|
|
1619
|
+
}, {
|
|
1620
|
+
readonly covenant: "onchain_htlc";
|
|
1621
|
+
readonly owner: "trader";
|
|
1622
|
+
readonly deadline: "htlc_refund_locktime";
|
|
1623
|
+
}];
|
|
1624
|
+
readonly actions: readonly ["claimLockup", "refundOnchain"];
|
|
1625
|
+
readonly seams: readonly ["indexer", "chain"];
|
|
1626
|
+
};
|
|
1558
1627
|
};
|
|
1559
1628
|
/** Whose the arkade lockup is, per corridor kind (`lockups[0]` on every pass). */
|
|
1560
1629
|
declare const LOCKUP_OWNER: {
|
|
1561
1630
|
readonly lightning_send: "trader";
|
|
1562
1631
|
readonly lightning_receive: "solver";
|
|
1563
1632
|
readonly onchain_send: "trader";
|
|
1633
|
+
readonly onchain_receive: "solver";
|
|
1564
1634
|
};
|
|
1565
1635
|
/** Whether this kind's drive pass reads L1, i.e. needs the onchain corridor's deps. */
|
|
1566
1636
|
declare const readsChain: (kind: CorridorKind) => boolean;
|
|
@@ -1584,7 +1654,7 @@ declare const ACTIVITY_TOKEN: Record<Outcome, string>;
|
|
|
1584
1654
|
* A route is two endpoints, each an asset on a corridor, plus the instrument that settles it.
|
|
1585
1655
|
*
|
|
1586
1656
|
* Two invariants live in the types: an {@link Endpoint}'s corridor and asset cannot disagree, and
|
|
1587
|
-
*
|
|
1657
|
+
* only the implemented pairs are in {@link Route}, so a resolved misroute is a compile error (before
|
|
1588
1658
|
* resolution it is `UnsupportedRoute`, thrown ahead of RFQ disclosure, persistence and funding).
|
|
1589
1659
|
*/
|
|
1590
1660
|
|
|
@@ -1637,12 +1707,7 @@ type Endpoint<C extends CorridorId = CorridorId> = C extends CorridorId ? {
|
|
|
1637
1707
|
} : never;
|
|
1638
1708
|
/** Shorthand for one corridor's endpoint, as the route union spells it. */
|
|
1639
1709
|
type Ep<C extends CorridorId> = Endpoint<C>;
|
|
1640
|
-
/**
|
|
1641
|
-
* The implemented routes, as a closed union.
|
|
1642
|
-
*
|
|
1643
|
-
* `onchain -> arkade` is deliberately absent until the manager owns the
|
|
1644
|
-
* trader's L1 refund path end to end.
|
|
1645
|
-
*/
|
|
1710
|
+
/** The implemented routes, as a closed union. */
|
|
1646
1711
|
type Route = {
|
|
1647
1712
|
give: Ep<"arkade">;
|
|
1648
1713
|
take: Ep<"arkade">;
|
|
@@ -1655,6 +1720,9 @@ type Route = {
|
|
|
1655
1720
|
} | {
|
|
1656
1721
|
give: Ep<"arkade">;
|
|
1657
1722
|
take: Ep<"onchain">;
|
|
1723
|
+
} | {
|
|
1724
|
+
give: Ep<"onchain">;
|
|
1725
|
+
take: Ep<"arkade">;
|
|
1658
1726
|
};
|
|
1659
1727
|
/**
|
|
1660
1728
|
* The one thing a counterparty must see, when a route has one.
|
|
@@ -2258,4 +2326,4 @@ declare class InMemoryAssetSwapRepository implements AssetSwapRepository {
|
|
|
2258
2326
|
[Symbol.asyncDispose](): Promise<void>;
|
|
2259
2327
|
}
|
|
2260
2328
|
|
|
2261
|
-
export { type Hex as $, type AssetId as A, type AssetScale as B, type Corridor as C, type AssetSwapId as D, type AtomicDecimal as E, type AuctionMarketRef as F, type AuctionProvenance as G, BITCOIN_RAILS as H, type Instrument as I, BTC_ASSET_PART as J, type BitcoinRail as K, type LockupSpendIndexer as L, CORRIDORS as M, type NetworkRef as N, type OfferSwapRecord as O, type PinnedAmount as P, type QuoteId as Q, type Rail as R, type SwapRecord as S, CORRIDOR_PASS as T, type CardMarketRef as U, type CorridorId as V, type CorridorKind as W, type DepositArtifact as X, type DisplayDecimal as Y, type Endpoint as Z, type Ep as _, type RfqSwapRecordStore as a, toRfqAmountSide as a$, LOCKUP_OWNER as a0, type MarketBackend as a1, type MarketRef as a2, OFFER_SWAP_ID_PREFIX as a3, type Outcome as a4, type ParsedAssetId as a5, type Quote as a6, type QuoteLeg as a7, RAILS as a8, RFQ_SWAP_ID_PREFIX as a9, familyOfSwapId as aA, formatAssetId as aB, fromAtomicDecimal as aC, fromRfqAmountSide as aD, fundsFromWallet as aE, instrumentOf as aF, isAssetId as aG, isAtomicDecimal as aH, isBtcAsset as aI, isBtcAssetLenient as aJ, isNetworkRef as aK, issuanceOf as aL, legOf as aM, offerOutcome as aN, parseAssetId as aO, quoteIdOfSwapId as aP, railOf as aQ, railOfCorridor as aR, readsChain as aS, recordArtifact as aT, recordEndpoint as aU, recordInstrument as aV, recordLeg as aW, recordOutcome as aX, sameAsset as aY, swapOf as aZ, toAtomicDecimal as a_, type RailOf as aa, type RankedBid as ab, type RawState as ac, type RecordedArtifact as ad, type RecordedEndpoint as ae, type RecordedInstrument as af, type RecordedLeg as ag, type RestoredMarketRef as ah, type RfqAmountSide as ai, type SnapshotRef as aj, type Swap as ak, type SwapFamily as al, type SwapRecordCommon as am, type SwapUpdate as an, type Unsubscribe as ao, arkadeAsset as ap, artifactOf as aq, assetPartOf as ar, assetSwapIdOf as as, bitcoinNetworkOf as at, btcAssetPart as au, btcOn as av, corridorOfRail as aw, corridorOutcome as ax, decodeRfqAmount as ay, encodeRfqAmount as az, type CorridorSwapRecord as b, toSafeNumber as b0, type MarketsCacheEntry as b1, InMemoryAssetSwapRepository as b2, type RfqSwapState as b3, type SwapContractRegistry as b4, type SwapOperator as b5, isRfqSwapTerminal as b6, type RfqSwapManagerCallbacks as b7, type RfqSwapActionName as b8, type SwapSecretsProjection as b9, type
|
|
2329
|
+
export { type Hex as $, type AssetId as A, type AssetScale as B, type Corridor as C, type AssetSwapId as D, type AtomicDecimal as E, type AuctionMarketRef as F, type AuctionProvenance as G, BITCOIN_RAILS as H, type Instrument as I, BTC_ASSET_PART as J, type BitcoinRail as K, type LockupSpendIndexer as L, CORRIDORS as M, type NetworkRef as N, type OfferSwapRecord as O, type PinnedAmount as P, type QuoteId as Q, type Rail as R, type SwapRecord as S, CORRIDOR_PASS as T, type CardMarketRef as U, type CorridorId as V, type CorridorKind as W, type DepositArtifact as X, type DisplayDecimal as Y, type Endpoint as Z, type Ep as _, type RfqSwapRecordStore as a, toRfqAmountSide as a$, LOCKUP_OWNER as a0, type MarketBackend as a1, type MarketRef as a2, OFFER_SWAP_ID_PREFIX as a3, type Outcome as a4, type ParsedAssetId as a5, type Quote as a6, type QuoteLeg as a7, RAILS as a8, RFQ_SWAP_ID_PREFIX as a9, familyOfSwapId as aA, formatAssetId as aB, fromAtomicDecimal as aC, fromRfqAmountSide as aD, fundsFromWallet as aE, instrumentOf as aF, isAssetId as aG, isAtomicDecimal as aH, isBtcAsset as aI, isBtcAssetLenient as aJ, isNetworkRef as aK, issuanceOf as aL, legOf as aM, offerOutcome as aN, parseAssetId as aO, quoteIdOfSwapId as aP, railOf as aQ, railOfCorridor as aR, readsChain as aS, recordArtifact as aT, recordEndpoint as aU, recordInstrument as aV, recordLeg as aW, recordOutcome as aX, sameAsset as aY, swapOf as aZ, toAtomicDecimal as a_, type RailOf as aa, type RankedBid as ab, type RawState as ac, type RecordedArtifact as ad, type RecordedEndpoint as ae, type RecordedInstrument as af, type RecordedLeg as ag, type RestoredMarketRef as ah, type RfqAmountSide as ai, type SnapshotRef as aj, type Swap as ak, type SwapFamily as al, type SwapRecordCommon as am, type SwapUpdate as an, type Unsubscribe as ao, arkadeAsset as ap, artifactOf as aq, assetPartOf as ar, assetSwapIdOf as as, bitcoinNetworkOf as at, btcAssetPart as au, btcOn as av, corridorOfRail as aw, corridorOutcome as ax, decodeRfqAmount as ay, encodeRfqAmount as az, type CorridorSwapRecord as b, toSafeNumber as b0, type MarketsCacheEntry as b1, InMemoryAssetSwapRepository as b2, type RfqSwapState as b3, type SwapContractRegistry as b4, type SwapOperator as b5, isRfqSwapTerminal as b6, type RfqSwapManagerCallbacks as b7, type RfqSwapActionName as b8, type SwapSecretsProjection as b9, type RfqSwapLockup as bA, RfqSwapManager as bB, type RfqSwapManagerConfig as bC, type RfqSwapManagerDeps as bD, type RfqSwapManagerEvents as bE, type RfqSwapOrigin as bF, RfqSwapOriginRequired as bG, type RfqSwapOutcome as bH, addAssetSwap as bI, awaitRfqResolution as bJ, createRfqSwapRecord as bK, findLockupVtxos as bL, getAssetSwaps as bM, isRfqTerminal as bN, nextOnchainAction as bO, nextOnchainReceiveAction as bP, normalizeRfqSwapRecord as bQ, preimageForSwapRecord as bR, pushRefundWithoutReceiver as bS, readLockupFate as bT, rebuildRfqSwap as bU, refundIfUnresolved as bV, rfqSwapOriginOf as bW, shouldRetainRfqSwap as bX, swapSecretsToRecord as bY, updateAssetSwap as bZ, updateRfqSwapRecord as b_, type LockupContractSource as ba, type RfqSwap as bb, type ArkadeRefundResult as bc, type LockupVtxo as bd, type AvailableRfqSwapManagerCallbacks as be, BTC_ASSET_ID as bf, type LightningReceiveSwap as bg, type LightningSendSwap as bh, type LockupFate as bi, LockupNeedsRecoveryError as bj, type LockupParams as bk, type LockupSpend as bl, type OnchainReceiveAction as bm, OnchainReceiveNeedsChainSource as bn, type OnchainReceiveSwap as bo, type OnchainSendAction as bp, type OnchainSendSwap as bq, type PersistableRfqSwap as br, type PreimageBlockedReason as bs, PreimageNotRecoverableError as bt, RFQ_SWAP_RETENTION_SECONDS as bu, type ReceiveLockupSwap as bv, type RefundOutcome as bw, type RfqRestoreFailure as bx, type RfqRestoreOptions as by, type RfqRestoreResult as bz, type AssetSwapStatus as c, type AssetSwapRepository as d, type RfqSwapRecord as e, type RfqSwapPageFilter as f, type RfqSwapPageCursor as g, type AssetSwap as h, type RouteResolution as i, type ResolvedEndpoint as j, type Route as k, type QuoteInput as l, type Pubkey as m, ACTIVITY_TOKEN as n, ARKADE_ASSET_NAMESPACE as o, Amount as p, AmountFormatError as q, type AmountOn as r, type AmountRefusal as s, type Artifact as t, AssetIdError as u, type AssetIdRefusal as v, type AssetNamespace as w, type AssetOn as x, type AssetPart as y, type AssetRef as z };
|
|
@@ -113,8 +113,12 @@ interface ChainUtxo extends HtlcUtxo {
|
|
|
113
113
|
interface ChainSource {
|
|
114
114
|
/** Confirmed+mempool outputs paying a script; used to detect the fill. */
|
|
115
115
|
getScriptUtxos(pkScript: Uint8Array): Promise<ChainUtxo[]>;
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
116
|
+
/**
|
|
117
|
+
* The spend of an outpoint, if any — where P is extracted from. A provider
|
|
118
|
+
* omitting the spender txid still lists it in `pkScript`'s history.
|
|
119
|
+
*
|
|
120
|
+
* **`txHex` MUST carry the witness**: a legacy serialization parses
|
|
121
|
+
* cleanly without one, so a stripped claim classifies as `swept`. */
|
|
118
122
|
getSpendingTx(txid: string, vout: number, pkScript: Uint8Array): Promise<{
|
|
119
123
|
txHex: string;
|
|
120
124
|
} | null>;
|
|
@@ -152,7 +156,8 @@ declare function claimOnchainFill(chain: ChainSource, input: {
|
|
|
152
156
|
payoutAmount: bigint;
|
|
153
157
|
}>;
|
|
154
158
|
/** Where an onchain HTLC stands, for crash recovery. Persisting the record BEFORE funding is what
|
|
155
|
-
* makes this classification (and the claim) possible after a restart.
|
|
159
|
+
* makes this classification (and the claim) possible after a restart. Each phase names which leaf
|
|
160
|
+
* moved, never whose turn it is: the key roles swap between the legs (module header). */
|
|
156
161
|
type OnchainHtlcPhase = {
|
|
157
162
|
phase: "unfunded";
|
|
158
163
|
} | {
|
|
@@ -163,9 +168,11 @@ type OnchainHtlcPhase = {
|
|
|
163
168
|
utxo: ChainUtxo;
|
|
164
169
|
}
|
|
165
170
|
/**
|
|
166
|
-
* The refund leaf has matured
|
|
167
|
-
*
|
|
168
|
-
* refund
|
|
171
|
+
* The refund leaf has matured. On `arkade->onchain` it is the SOLVER's leaf: the CLAIM WINDOW
|
|
172
|
+
* IS CLOSED and `claimOnchainFill` throws, so do not claim; take the Arkade-side covenant
|
|
173
|
+
* refund instead (on a swap you expected to claim, the claim was missed). On
|
|
174
|
+
* `onchain->arkade` it is the TRADER's own leaf: the act-now signal to refund, and it stays
|
|
175
|
+
* spendable.
|
|
169
176
|
*/
|
|
170
177
|
| {
|
|
171
178
|
phase: "refundable";
|
|
@@ -184,7 +191,7 @@ type OnchainHtlcPhase = {
|
|
|
184
191
|
* already spent": without it a spent HTLC looks unfunded.
|
|
185
192
|
*
|
|
186
193
|
* `claimed` carries the preimage read from the spend's witness — the receipt;
|
|
187
|
-
* `swept` is a spend that reveals no preimage
|
|
194
|
+
* `swept` is a spend that reveals no matching preimage.
|
|
188
195
|
*/
|
|
189
196
|
declare function classifyOnchainHtlc(chain: ChainSource, input: {
|
|
190
197
|
htlc: OnchainHtlc;
|
|
@@ -901,6 +908,8 @@ declare function deriveOnchainReceive(input: {
|
|
|
901
908
|
script: InstanceType<typeof VHTLC.ScriptV2>;
|
|
902
909
|
/** The L1 HTLC the trader funds, derived locally — fund only this. */
|
|
903
910
|
htlc: OnchainHtlc;
|
|
911
|
+
/** The inputs {@link htlc} was derived from; a restore rebuilds it from these. */
|
|
912
|
+
htlcParams: OnchainHtlcParams;
|
|
904
913
|
refundLocktime: number;
|
|
905
914
|
htlcLocktime: number;
|
|
906
915
|
minConfirmations: number;
|
|
@@ -113,8 +113,12 @@ interface ChainUtxo extends HtlcUtxo {
|
|
|
113
113
|
interface ChainSource {
|
|
114
114
|
/** Confirmed+mempool outputs paying a script; used to detect the fill. */
|
|
115
115
|
getScriptUtxos(pkScript: Uint8Array): Promise<ChainUtxo[]>;
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
116
|
+
/**
|
|
117
|
+
* The spend of an outpoint, if any — where P is extracted from. A provider
|
|
118
|
+
* omitting the spender txid still lists it in `pkScript`'s history.
|
|
119
|
+
*
|
|
120
|
+
* **`txHex` MUST carry the witness**: a legacy serialization parses
|
|
121
|
+
* cleanly without one, so a stripped claim classifies as `swept`. */
|
|
118
122
|
getSpendingTx(txid: string, vout: number, pkScript: Uint8Array): Promise<{
|
|
119
123
|
txHex: string;
|
|
120
124
|
} | null>;
|
|
@@ -152,7 +156,8 @@ declare function claimOnchainFill(chain: ChainSource, input: {
|
|
|
152
156
|
payoutAmount: bigint;
|
|
153
157
|
}>;
|
|
154
158
|
/** Where an onchain HTLC stands, for crash recovery. Persisting the record BEFORE funding is what
|
|
155
|
-
* makes this classification (and the claim) possible after a restart.
|
|
159
|
+
* makes this classification (and the claim) possible after a restart. Each phase names which leaf
|
|
160
|
+
* moved, never whose turn it is: the key roles swap between the legs (module header). */
|
|
156
161
|
type OnchainHtlcPhase = {
|
|
157
162
|
phase: "unfunded";
|
|
158
163
|
} | {
|
|
@@ -163,9 +168,11 @@ type OnchainHtlcPhase = {
|
|
|
163
168
|
utxo: ChainUtxo;
|
|
164
169
|
}
|
|
165
170
|
/**
|
|
166
|
-
* The refund leaf has matured
|
|
167
|
-
*
|
|
168
|
-
* refund
|
|
171
|
+
* The refund leaf has matured. On `arkade->onchain` it is the SOLVER's leaf: the CLAIM WINDOW
|
|
172
|
+
* IS CLOSED and `claimOnchainFill` throws, so do not claim; take the Arkade-side covenant
|
|
173
|
+
* refund instead (on a swap you expected to claim, the claim was missed). On
|
|
174
|
+
* `onchain->arkade` it is the TRADER's own leaf: the act-now signal to refund, and it stays
|
|
175
|
+
* spendable.
|
|
169
176
|
*/
|
|
170
177
|
| {
|
|
171
178
|
phase: "refundable";
|
|
@@ -184,7 +191,7 @@ type OnchainHtlcPhase = {
|
|
|
184
191
|
* already spent": without it a spent HTLC looks unfunded.
|
|
185
192
|
*
|
|
186
193
|
* `claimed` carries the preimage read from the spend's witness — the receipt;
|
|
187
|
-
* `swept` is a spend that reveals no preimage
|
|
194
|
+
* `swept` is a spend that reveals no matching preimage.
|
|
188
195
|
*/
|
|
189
196
|
declare function classifyOnchainHtlc(chain: ChainSource, input: {
|
|
190
197
|
htlc: OnchainHtlc;
|
|
@@ -901,6 +908,8 @@ declare function deriveOnchainReceive(input: {
|
|
|
901
908
|
script: InstanceType<typeof VHTLC.ScriptV2>;
|
|
902
909
|
/** The L1 HTLC the trader funds, derived locally — fund only this. */
|
|
903
910
|
htlc: OnchainHtlc;
|
|
911
|
+
/** The inputs {@link htlc} was derived from; a restore rebuilds it from these. */
|
|
912
|
+
htlcParams: OnchainHtlcParams;
|
|
904
913
|
refundLocktime: number;
|
|
905
914
|
htlcLocktime: number;
|
|
906
915
|
minConfirmations: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IWallet } from '@arkade-os/sdk';
|
|
2
|
-
import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-
|
|
2
|
+
import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-D_qvJk1S.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* What this watcher needs to know about an offer swap, narrower than {@link AssetSwap}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IWallet } from '@arkade-os/sdk';
|
|
2
|
-
import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-
|
|
2
|
+
import { c as AssetSwapStatus, d as AssetSwapRepository, h as AssetSwap } from './repository-B4rQWmS2.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* What this watcher needs to know about an offer swap, narrower than {@link AssetSwap}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkade-os/swap",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Client-side Arkade Intents asset swaps: state a route, get an outcome. Pay a bolt11 invoice, receive over Lightning, exchange assets, or withdraw onchain.",
|
|
6
6
|
"repository": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"dist"
|
|
87
87
|
],
|
|
88
88
|
"engines": {
|
|
89
|
-
"node": ">=22.
|
|
89
|
+
"node": ">=22.13.0"
|
|
90
90
|
},
|
|
91
91
|
"keywords": [
|
|
92
92
|
"arkade",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@scure/base": "2.4.0",
|
|
105
105
|
"@scure/btc-signer": "2.4.1",
|
|
106
106
|
"light-bolt11-decoder": "3.2.0",
|
|
107
|
-
"@arkade-os/sdk": "0.5.0-rc.
|
|
107
|
+
"@arkade-os/sdk": "0.5.0-rc.20"
|
|
108
108
|
},
|
|
109
109
|
"peerDependencies": {
|
|
110
110
|
"nostr-tools": "^2.12.0"
|