@arkade-os/swap 0.1.10 → 0.1.12
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 +58 -0
- package/dist/advanced.cjs +1058 -414
- package/dist/advanced.d.cts +7 -64
- package/dist/advanced.d.ts +7 -64
- package/dist/advanced.js +29 -5
- package/dist/{chunk-AUJDREZN.js → chunk-CIDVLDDM.js} +1 -1
- package/dist/{chunk-FWRDAL73.js → chunk-F3BGKWIB.js} +758 -104
- package/dist/{chunk-LCO6AJOS.js → chunk-ISKJIONJ.js} +58 -285
- package/dist/{chunk-2HQZLIVX.js → chunk-JBTU7Y6M.js} +1 -1
- package/dist/chunk-UXK7YDA4.js +568 -0
- package/dist/{chunk-6RJVT65W.js → chunk-VPVSSBY2.js} +2 -4
- package/dist/index.cjs +1045 -414
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +15 -5
- package/dist/{lockupContract-BTTRVwOt.d.cts → lockupContract-B1mr672c.d.cts} +1 -1
- package/dist/{lockupContract-aFarhlxj.d.ts → lockupContract-BRpk0NxT.d.ts} +1 -1
- package/dist/node/index.d.cts +18 -18
- package/dist/node/index.d.ts +18 -18
- package/dist/nostr.cjs +276 -302
- package/dist/nostr.d.cts +20 -2
- package/dist/nostr.d.ts +20 -2
- package/dist/nostr.js +21 -357
- package/dist/{offerFillPlan-CJC5tnEd.d.ts → offerFillPlan-BMZXiVMB.d.ts} +213 -28
- package/dist/{offerFillPlan-FmyaQoYT.d.cts → offerFillPlan-CqJerwXd.d.cts} +213 -28
- package/dist/openRfq-Dx-vxOzl.d.cts +32 -0
- package/dist/openRfq-Dx-vxOzl.d.ts +32 -0
- package/dist/openRfqTransport-MQZ7JWYN.js +9 -0
- package/dist/protocol.cjs +301 -322
- package/dist/protocol.d.cts +5 -5
- package/dist/protocol.d.ts +5 -5
- package/dist/protocol.js +6 -8
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/{repository-CwwhIAEd.d.cts → repository-CFC0fHAy.d.cts} +26 -26
- package/dist/{repository-DO6QKxBx.d.ts → repository-suGldzOK.d.ts} +26 -26
- package/dist/rfq-contract.cjs +3 -6
- package/dist/rfq-contract.d.cts +3 -4
- package/dist/rfq-contract.d.ts +3 -4
- package/dist/rfq-contract.js +3 -5
- package/dist/transportErrors-DZuZqnF4.d.cts +8 -0
- package/dist/transportErrors-DZuZqnF4.d.ts +8 -0
- package/dist/{verify-ENO36VPK.js → verify-HU5COTNO.js} +3 -3
- package/dist/{watch-_fZSgx_l.d.ts → watch-C2z6Onak.d.ts} +1 -1
- package/dist/{watch-DpDSP2tu.d.cts → watch-CpYjItYX.d.cts} +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IWallet, NetworkName, Network, SignerSet, OnchainProvider, OperatorInfo, VHTLC, ProvisionedKey, ProvisionedClaimSecret, Transaction } from '@arkade-os/sdk';
|
|
2
|
-
import { bb as SwapOperator, d as AssetSwapRepository, bd as RfqSwapManagerCallbacks, C as Corridor,
|
|
2
|
+
import { bb as SwapOperator, d as AssetSwapRepository, bd as RfqSwapManagerCallbacks, C as Corridor, W as Instrument, be as RfqSwapActionName, N as NetworkRef, A as AssetId, am as SnapshotRef, Y as MarketBackend, J as CardMarketRef, Z as MarketRef, x as AssetRef, m as AmountOn, an as Swap, K as CorridorId, P as DepositArtifact, a4 as QuoteInput, a3 as Quote, al as RouteResolution, ah as ResolvedEndpoint, a2 as PinnedAmount, ak as Route, aq as SwapUpdate, as as Unsubscribe, S as SwapRecord, Q as QuoteId, a0 as Outcome, L as LockupSpendIndexer, ba as SwapContractRegistry, w as AssetPaymentTerms, bf as DerivedOffer, v as AssetPaymentInput, O as OfferSwapRecord, z as AssetSwapId, ao as SwapFamily, bg as FillFunding, bh as FillOutpoint, bi as FillInputOwner, bj as OfferBinding } from './repository-CFC0fHAy.cjs';
|
|
3
3
|
import { I as InvoiceFacts, P as Pubkey, C as ChainSource, R as RfqQuote, L as LightningSendContractParams, j as LightningReceiveContractParams, O as OnchainHtlc, k as OnchainHtlcParams, l as OnchainNetwork, A as AttestingRfqTransport, b as RfqTransportFactory, S as SwapRefusal } from './rfq-nMGywkqI.cjs';
|
|
4
|
-
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, OfferPlan } from '@arkade-os/solver-discovery';
|
|
4
|
+
import { Network as Network$1, LocalCardInput, TransportCardFetcher, DiscoveredMarket, Side, SolverRoutingPreferences, OfferPlan, QuoteOfferOptions, Card } from '@arkade-os/solver-discovery';
|
|
5
|
+
import { O as OpenRfqBid } from './openRfq-Dx-vxOzl.cjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* What a corridor is given, what a caller may replace, and where "overridden to nothing" is refused.
|
|
@@ -668,6 +669,139 @@ declare const receive: <C extends CorridorId = CorridorId>(deps: VerbDeps, optio
|
|
|
668
669
|
/** Swap one Arkade asset for another. */
|
|
669
670
|
declare const exchange: (deps: VerbDeps, options: ExchangeOptions) => Promise<Swap>;
|
|
670
671
|
|
|
672
|
+
/**
|
|
673
|
+
* Route resolution: the single place `to` is parsed, the corridor pair decided, the
|
|
674
|
+
* amount pinned and the market chosen — everything before a solver is told anything.
|
|
675
|
+
*
|
|
676
|
+
* The order (§3.1) is load-bearing: `to` first (needs no market data); the pair selects
|
|
677
|
+
* the `Route` variant, refusing unsupported pairs before any round trip or record; only
|
|
678
|
+
* then the market index, since tickers resolve against the cards themselves. Exactly one
|
|
679
|
+
* amount may be pinned; two is `AmountMismatch`, thrown here so nothing is disclosed.
|
|
680
|
+
*/
|
|
681
|
+
|
|
682
|
+
/** The five implemented corridor pairs, spelled as the route union spells them. */
|
|
683
|
+
declare const SUPPORTED_PAIRS: readonly ["arkade->arkade", "arkade->lightning", "lightning->arkade", "arkade->onchain", "onchain->arkade"];
|
|
684
|
+
type SupportedPair = (typeof SUPPORTED_PAIRS)[number];
|
|
685
|
+
interface ResolveDeps {
|
|
686
|
+
readonly corridors: CorridorSet;
|
|
687
|
+
/** The network the wallet reported; every defaulted asset id is on it. */
|
|
688
|
+
readonly network: NetworkName;
|
|
689
|
+
readonly discovery: DiscoveryIndex;
|
|
690
|
+
readonly policy?: SwapPolicy;
|
|
691
|
+
/**
|
|
692
|
+
* `resolve()` reads what is in hand; `quote()` may fetch. A flag, not two functions,
|
|
693
|
+
* so the resolution a caller vetoed is exactly the one they quote.
|
|
694
|
+
*/
|
|
695
|
+
readonly mode: "resolve" | "quote";
|
|
696
|
+
}
|
|
697
|
+
/** What the quote path needs from a resolution, over what a caller sees. */
|
|
698
|
+
interface ResolvedRoute {
|
|
699
|
+
readonly resolution: RouteResolution;
|
|
700
|
+
/** Both legs in discovery's vocabulary — what the market lookup matched on. */
|
|
701
|
+
readonly legs: {
|
|
702
|
+
readonly give: DiscoveryLeg;
|
|
703
|
+
readonly take: DiscoveryLeg;
|
|
704
|
+
};
|
|
705
|
+
readonly give: ResolvedEndpoint;
|
|
706
|
+
readonly take: ResolvedEndpoint;
|
|
707
|
+
readonly pair: SupportedPair;
|
|
708
|
+
readonly candidates: readonly MarketCandidate[];
|
|
709
|
+
/** The chosen card, absent when nothing eligible survived. */
|
|
710
|
+
readonly market?: MarketCandidate;
|
|
711
|
+
readonly snapshot: DiscoverySnapshot;
|
|
712
|
+
readonly amount?: PinnedAmount;
|
|
713
|
+
/** The alias table the snapshot produced, so the quote path can reuse it. */
|
|
714
|
+
readonly aliases: AssetAliasTable;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Assemble the closed `Route` from two fully-instrumented legs.
|
|
718
|
+
*
|
|
719
|
+
* The quote path's one cast: the type checker cannot correlate `corridor` and `asset`,
|
|
720
|
+
* so the runtime re-check turns a broken invariant into a throw rather than a covenant
|
|
721
|
+
* built against the wrong rail.
|
|
722
|
+
*/
|
|
723
|
+
declare const assembleRoute: (give: ResolvedEndpoint & {
|
|
724
|
+
instrument: Instrument;
|
|
725
|
+
}, take: ResolvedEndpoint & {
|
|
726
|
+
instrument: Instrument;
|
|
727
|
+
}) => Route;
|
|
728
|
+
declare const resolveRoute: (input: QuoteInput, deps: ResolveDeps) => Promise<ResolvedRoute>;
|
|
729
|
+
|
|
730
|
+
interface SolverHealthScope {
|
|
731
|
+
readonly network: string;
|
|
732
|
+
readonly direction: string;
|
|
733
|
+
}
|
|
734
|
+
interface SolverHealthEntry {
|
|
735
|
+
readonly failures: number;
|
|
736
|
+
readonly lastFailureAt: number;
|
|
737
|
+
}
|
|
738
|
+
interface SolverHealthStorage {
|
|
739
|
+
load(scope: SolverHealthScope): unknown | Promise<unknown>;
|
|
740
|
+
save(scope: SolverHealthScope, records: Readonly<Record<string, SolverHealthEntry>>): void | Promise<void>;
|
|
741
|
+
}
|
|
742
|
+
interface SolverHealth {
|
|
743
|
+
deprioritized(scope: SolverHealthScope): Promise<string[]>;
|
|
744
|
+
record(scope: SolverHealthScope, solverId: string, outcome: "success" | "failure"): Promise<void>;
|
|
745
|
+
}
|
|
746
|
+
/** Session-local by default; inject storage to retain per-network/direction quote reliability.
|
|
747
|
+
* Two failures demote for one minute, doubling to fifteen; thirty quiet minutes forget the streak.
|
|
748
|
+
* onChange reports active demotion changes, so one failure need not restart a live preview.
|
|
749
|
+
* A verified quote clears it. Storage errors are advisory; acceptance never updates this state. */
|
|
750
|
+
declare function createSolverHealth(options?: {
|
|
751
|
+
storage?: SolverHealthStorage;
|
|
752
|
+
now?: () => number;
|
|
753
|
+
onChange?: () => void;
|
|
754
|
+
}): SolverHealth;
|
|
755
|
+
|
|
756
|
+
interface SolverCandidate extends MarketCandidate {
|
|
757
|
+
readonly solverId: string;
|
|
758
|
+
readonly direction: string;
|
|
759
|
+
}
|
|
760
|
+
interface SolverRoutingContext {
|
|
761
|
+
readonly network: NetworkName;
|
|
762
|
+
readonly direction: string;
|
|
763
|
+
readonly candidates: readonly SolverCandidate[];
|
|
764
|
+
}
|
|
765
|
+
/** Optional direction-specific policy for quote preparation; accepted swaps keep their solver. */
|
|
766
|
+
interface SolverRoutingPolicy {
|
|
767
|
+
/** Shared reliability tracker; defaults to per-client memory when routing is enabled. */
|
|
768
|
+
readonly health?: SolverHealth;
|
|
769
|
+
/** Try another candidate on solver-local quote failure; defaults to true. Every candidate
|
|
770
|
+
* passes full verification before funding. Custom transports throw {@link SolverUnavailable}
|
|
771
|
+
* for retryable failures; exhausted attempts throw {@link SolverRoutesUnavailable}.
|
|
772
|
+
* Each attempt discloses the request to that solver: a Lightning send's BOLT11 (payment
|
|
773
|
+
* hash, amount, route hints) reaches every solver tried before a verified quote lands. Set
|
|
774
|
+
* false to limit that to one solver.
|
|
775
|
+
* Feed/fetchImpl failures are retryable; AbortError stops the operation. Authenticate before
|
|
776
|
+
* quoting, or set false to surface feed errors. Explicit `selectMarket` disables failover. */
|
|
777
|
+
readonly failover?: boolean;
|
|
778
|
+
/** Read current preferences before selection. Absent means discovery order; rejection stops
|
|
779
|
+
* the operation before negotiation. Modes, priority, usage and disabled solver IDs follow
|
|
780
|
+
* {@link SolverRoutingPreferences}. `preferFirst` precedes heuristic ordering without disabling
|
|
781
|
+
* failover. Cost estimates include directional flat fees, feed prices and carrier charges:
|
|
782
|
+
* most received for exact give, least deposited for exact take; unavailable estimates follow.
|
|
783
|
+
* They do not poll every RFQ solver or guarantee the cheapest final quote. Pauses affect new
|
|
784
|
+
* selection; issued quotes and accepted swaps retain their selected solver. */
|
|
785
|
+
readonly preferences?: (context: SolverRoutingContext) => SolverRoutingPreferences | Promise<SolverRoutingPreferences>;
|
|
786
|
+
}
|
|
787
|
+
declare const orderedSolverCandidates: (route: ResolvedRoute, network: NetworkName, policy: SwapPolicy | undefined, fetchImpl: typeof fetch, estimate?: boolean, health?: SolverHealth) => Promise<SolverCandidate[]>;
|
|
788
|
+
declare const canFailoverQuote: (error: unknown) => boolean;
|
|
789
|
+
declare const isSolverReliabilityFailure: (error: unknown) => boolean;
|
|
790
|
+
/** Exhausted candidates, outside the closed SwapError taxonomy; narrow with instanceof. */
|
|
791
|
+
declare class SolverRoutesUnavailable extends AggregateError {
|
|
792
|
+
readonly attempts: readonly {
|
|
793
|
+
solverId: string;
|
|
794
|
+
error: unknown;
|
|
795
|
+
}[];
|
|
796
|
+
readonly name = "SolverRoutesUnavailable";
|
|
797
|
+
constructor(attempts: readonly {
|
|
798
|
+
solverId: string;
|
|
799
|
+
error: unknown;
|
|
800
|
+
}[]);
|
|
801
|
+
}
|
|
802
|
+
/** Count unique successful swap IDs for a `solverDirectionKey` or `SolverRoutingContext.direction`. */
|
|
803
|
+
declare const completedSolverUsage: (swaps: readonly Swap[], network: string, direction: string) => Record<string, number>;
|
|
804
|
+
|
|
671
805
|
/**
|
|
672
806
|
* Application policy: the vetoes and floors a client applies before it discloses anything.
|
|
673
807
|
*
|
|
@@ -678,16 +812,13 @@ declare const exchange: (deps: VerbDeps, options: ExchangeOptions) => Promise<Sw
|
|
|
678
812
|
/**
|
|
679
813
|
* A published-RFQ auction's parameters (§10, Q9).
|
|
680
814
|
*
|
|
681
|
-
*
|
|
682
|
-
* by something narrower meanwhile.
|
|
815
|
+
* Defaults for explicit openRfq calls. Ordinary quote() remains addressed.
|
|
683
816
|
*/
|
|
684
817
|
interface RfqAuctionPolicy {
|
|
685
818
|
/** How long to hold the bid window open, in ms. */
|
|
686
819
|
readonly windowMs: number;
|
|
687
|
-
/**
|
|
820
|
+
/** Default relays for explicit openRfq calls; absent means the current cards or public defaults. */
|
|
688
821
|
readonly relays?: readonly string[];
|
|
689
|
-
/** §4.6's SHOULD: a fresh transport key per open, so bids are unlinkable. */
|
|
690
|
-
readonly freshTransportKey?: boolean;
|
|
691
822
|
}
|
|
692
823
|
/**
|
|
693
824
|
* How much the client drives on its own, so a consumer can inspect its swaps without being made to
|
|
@@ -709,6 +840,8 @@ type DriveMode =
|
|
|
709
840
|
/** Default {@link SwapPolicy.maxRefundWindowSeconds}: 30 days. */
|
|
710
841
|
declare const DEFAULT_MAX_REFUND_WINDOW_SECONDS: number;
|
|
711
842
|
interface SwapPolicy {
|
|
843
|
+
/** Opt in to direction-specific ordering and quote-only failover. Explicit selectMarket stays pinned. */
|
|
844
|
+
readonly solverRouting?: SolverRoutingPolicy;
|
|
712
845
|
/** How much the client drives on its own. Default `"auto"`. */
|
|
713
846
|
readonly drive?: DriveMode;
|
|
714
847
|
/**
|
|
@@ -720,13 +853,9 @@ interface SwapPolicy {
|
|
|
720
853
|
* asset than the quoted fee is refused, not converted.
|
|
721
854
|
*/
|
|
722
855
|
readonly maxFee?: FeeCeiling;
|
|
723
|
-
/**
|
|
724
|
-
* The
|
|
725
|
-
*
|
|
726
|
-
* Called with every eligible candidate, best-ranked first; `undefined` vetoes them all
|
|
727
|
-
* (surfacing as `UnsupportedRoute`). The answer must be one of the candidates: a card from
|
|
728
|
-
* elsewhere has not passed the pair, corridor and addressability checks.
|
|
729
|
-
*/
|
|
856
|
+
/** Choose from eligible candidates in discovery order, before routing preferences; `undefined` vetoes all.
|
|
857
|
+
* The answer must be one of those candidates, which passed pair, corridor and addressability
|
|
858
|
+
* checks. An explicit selection disables quote failover; routing pauses can still veto it. */
|
|
730
859
|
readonly selectMarket?: (candidates: readonly MarketCandidate[]) => MarketCandidate | undefined;
|
|
731
860
|
/**
|
|
732
861
|
* The registries whose cards may price a swap, matched exactly against
|
|
@@ -749,13 +878,9 @@ interface SwapPolicy {
|
|
|
749
878
|
*/
|
|
750
879
|
readonly maxRefundWindowSeconds?: number;
|
|
751
880
|
/**
|
|
752
|
-
*
|
|
881
|
+
* Defaults for explicit openRfq calls; never makes quote() public.
|
|
753
882
|
*/
|
|
754
883
|
readonly rfq?: RfqAuctionPolicy;
|
|
755
|
-
/**
|
|
756
|
-
* §10, reserved and inert: which bid to close a published auction with.
|
|
757
|
-
*/
|
|
758
|
-
readonly selectBid?: (bids: readonly RankedBid[]) => RankedBid | undefined;
|
|
759
884
|
}
|
|
760
885
|
|
|
761
886
|
/**
|
|
@@ -931,6 +1056,7 @@ interface FeedQuoteInput {
|
|
|
931
1056
|
/** Unix seconds. */
|
|
932
1057
|
readonly now: number;
|
|
933
1058
|
}
|
|
1059
|
+
declare const quoteAdvertisedPlan: (card: DiscoveredMarket, options: QuoteOfferOptions, policy?: SwapPolicy) => Promise<OfferPlan>;
|
|
934
1060
|
declare const quoteFromFeed: (input: FeedQuoteInput) => Promise<{
|
|
935
1061
|
quote: Quote;
|
|
936
1062
|
preparation: OfferPreparation;
|
|
@@ -1144,6 +1270,21 @@ declare const quoteViaRfq: (input: RfqQuoteInput) => Promise<{
|
|
|
1144
1270
|
quote: Quote;
|
|
1145
1271
|
preparation: RfqPreparation;
|
|
1146
1272
|
}>;
|
|
1273
|
+
/**
|
|
1274
|
+
* The pin a solver is shown, and the claim fee folded into it. Open RFQ broadcasts the same
|
|
1275
|
+
* figure, so a bid and its directed quote price one amount.
|
|
1276
|
+
*
|
|
1277
|
+
* **An onchain send's take pin is recipient-EXACT.** The claim's miner fee comes out of the HTLC
|
|
1278
|
+
* output (`payout = utxo.amount - fee`), so with a resolvable
|
|
1279
|
+
* {@link OnchainCorridorDeps.claimFeeRateSatVb} the solver is asked for `pinned.value + claimFee`
|
|
1280
|
+
* (same arithmetic as the `onchain-swap` rail). No rate: verbatim, no invented fee. A give pin is
|
|
1281
|
+
* untouched: the take leg is the solver's to size. The recipient's own number never reaches the
|
|
1282
|
+
* wire: a solver who knew it would know what to short us by.
|
|
1283
|
+
*/
|
|
1284
|
+
declare const solverFacingAmount: (route: RfqQuoteInput["route"], pinned: PinnedAmount, corridors: CorridorSet) => {
|
|
1285
|
+
quoted: PinnedAmount;
|
|
1286
|
+
claimFee?: bigint;
|
|
1287
|
+
};
|
|
1147
1288
|
|
|
1148
1289
|
/** What a quote derived, kept in memory for the accept that may follow. */
|
|
1149
1290
|
type QuotePreparation = RfqPreparation | OfferPreparation;
|
|
@@ -1204,6 +1345,42 @@ declare const cancelSwap: (input: CancelInput) => Promise<{
|
|
|
1204
1345
|
outcome: CancelOutcome;
|
|
1205
1346
|
}>;
|
|
1206
1347
|
|
|
1348
|
+
interface OpenRfqOffer {
|
|
1349
|
+
readonly id: string;
|
|
1350
|
+
readonly solverPubkey: string;
|
|
1351
|
+
readonly solverName: string;
|
|
1352
|
+
readonly market: DiscoveredMarket;
|
|
1353
|
+
readonly signedCard: Card;
|
|
1354
|
+
readonly fromAmount: bigint;
|
|
1355
|
+
readonly toAmount: bigint;
|
|
1356
|
+
readonly expiresAt: number;
|
|
1357
|
+
}
|
|
1358
|
+
interface OpenRfqAuction {
|
|
1359
|
+
readonly id: string;
|
|
1360
|
+
readonly input: QuoteInput;
|
|
1361
|
+
readonly pair: string;
|
|
1362
|
+
readonly bids: readonly OpenRfqOffer[];
|
|
1363
|
+
readonly closedAt: number;
|
|
1364
|
+
}
|
|
1365
|
+
/** Public pair and size discovery. Bids are indicative until quoteBid verifies binding terms. */
|
|
1366
|
+
interface OpenRfqOptions {
|
|
1367
|
+
/** Conversation-only key supplied by the application; use a fresh key for every request. */
|
|
1368
|
+
readonly secretKey: Uint8Array;
|
|
1369
|
+
/** Shared rendezvous with bidders. Absent means card relays, then opportunistic public defaults;
|
|
1370
|
+
* no relay discovers operators that do not listen there. */
|
|
1371
|
+
readonly relays?: readonly string[];
|
|
1372
|
+
readonly windowMs?: number;
|
|
1373
|
+
readonly signal?: AbortSignal;
|
|
1374
|
+
readonly onBids?: (bids: readonly OpenRfqOffer[]) => void;
|
|
1375
|
+
}
|
|
1376
|
+
declare const DEFAULT_OPEN_RFQ_RELAYS: readonly ["wss://relay.damus.io", "wss://nos.lol"];
|
|
1377
|
+
declare const freezeOpenRfqValue: <T>(value: T) => T;
|
|
1378
|
+
declare const openBidCandidates: (bid: OpenRfqBid, route: ResolvedRoute, network: string, policy?: SwapPolicy) => {
|
|
1379
|
+
signedCard: Card;
|
|
1380
|
+
candidates: MarketCandidate[];
|
|
1381
|
+
} | undefined;
|
|
1382
|
+
declare const hasPausedKnownBidder: (signer: string, name: string, route: ResolvedRoute, network: NetworkName, policy?: SwapPolicy) => Promise<boolean>;
|
|
1383
|
+
|
|
1207
1384
|
interface SwapClientConfig {
|
|
1208
1385
|
/** The wallet, and through it the operator: operator info, chain reads and broadcast all come from
|
|
1209
1386
|
* it; no operator URL is accepted anywhere. */
|
|
@@ -1237,6 +1414,13 @@ interface AcceptOptions {
|
|
|
1237
1414
|
readonly attachOfferPacket?: boolean;
|
|
1238
1415
|
}
|
|
1239
1416
|
interface SwapClient {
|
|
1417
|
+
/** Public pair/size discovery; no destination, invoice or wallet identity is broadcast. */
|
|
1418
|
+
openRfq(input: QuoteInput, options: OpenRfqOptions): Promise<OpenRfqAuction>;
|
|
1419
|
+
/** Verify binding terms with the explicitly chosen bidder; never routes to another solver. */
|
|
1420
|
+
quoteBid(auction: OpenRfqAuction, bid: OpenRfqOffer): Promise<Quote>;
|
|
1421
|
+
/** Eligible solvers in routing order, without negotiating or accepting a swap.
|
|
1422
|
+
* Cost estimates may fetch advertised feeds; debounce frequent UI calls. */
|
|
1423
|
+
candidates(input: QuoteInput): Promise<readonly SolverCandidate[]>;
|
|
1240
1424
|
/**
|
|
1241
1425
|
* The restore-read, and — when it armed — the first pass after it. Under `drive: "auto"` the
|
|
1242
1426
|
* read arms the loop on live work; arming runs a pass immediately since a resumed swap may be
|
|
@@ -1258,7 +1442,7 @@ interface SwapClient {
|
|
|
1258
1442
|
*/
|
|
1259
1443
|
stop(): Promise<void>;
|
|
1260
1444
|
/**
|
|
1261
|
-
* Terminal cleanup: {@link stop}, drain in-flight work
|
|
1445
|
+
* Terminal cleanup: {@link stop}, abort open auctions, drain in-flight work, drop
|
|
1262
1446
|
* every listener. Durable state survives; an injected repository is never closed. Afterwards
|
|
1263
1447
|
* members refuse with {@link ClientDisposed}, except teardown: a second dispose and an issued
|
|
1264
1448
|
* {@link Unsubscribe} are no-ops, so React-effect teardown never throws.
|
|
@@ -1320,7 +1504,9 @@ interface SwapClient {
|
|
|
1320
1504
|
* veto before an RFQ round trip discloses an invoice or amount.
|
|
1321
1505
|
*/
|
|
1322
1506
|
resolve(input: QuoteInput): Promise<RouteResolution>;
|
|
1323
|
-
/** Verified, binding terms
|
|
1507
|
+
/** Verified, binding terms; no swap is persisted, funded or watched. Advisory health may update.
|
|
1508
|
+
* Routing errors include SolverUnavailable, SolverResponseInvalid and SolverRoutesUnavailable;
|
|
1509
|
+
* narrow them with instanceof, separately from the closed SwapError taxonomy. */
|
|
1324
1510
|
quote(input: QuoteInput): Promise<Quote>;
|
|
1325
1511
|
/**
|
|
1326
1512
|
* Make the quote durable, then move the value: record and secrets are at rest before anything
|
|
@@ -1388,7 +1574,7 @@ declare const createSwapClient: (config: SwapClientConfig) => SwapClient;
|
|
|
1388
1574
|
* transport but *run* as a check, so verification cannot be skipped by configuring a dev
|
|
1389
1575
|
* transport that authenticates nobody. Published RFQ (§10) attributes bids by signature instead.
|
|
1390
1576
|
*/
|
|
1391
|
-
type QuoteCheck = "pair" | "lockup_address" | "invoice" | "refund_window" | "responder";
|
|
1577
|
+
type QuoteCheck = "pair" | "lockup_address" | "invoice" | "refund_window" | "responder" | "amount";
|
|
1392
1578
|
/**
|
|
1393
1579
|
* `to` is underdetermined — it parses as nothing, as more than one thing, or as one thing the
|
|
1394
1580
|
* corridor that owns it refuses (a `tb1…` on mainnet, another operator's Arkade address, a
|
|
@@ -1444,11 +1630,10 @@ declare class AmountMismatch extends Error {
|
|
|
1444
1630
|
constructor(sources: readonly [string, string]);
|
|
1445
1631
|
}
|
|
1446
1632
|
/**
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1451
|
-
* Boundary: the RFQ adapter, both directions; core's payment rails.
|
|
1633
|
+
* An unsafe amount encoding: a JSON number past 2^53, non-canonical decimal string,
|
|
1634
|
+
* or bigint too large for a foreign number. Applies to RFQ adapters and core payment rails.
|
|
1635
|
+
* With solver routing, malformed incoming RFQ replies wrap this error in
|
|
1636
|
+
* `SolverResponseInvalid.cause` so the client can try another solver.
|
|
1452
1637
|
*/
|
|
1453
1638
|
declare class AmountEncodingUnsupported extends Error {
|
|
1454
1639
|
readonly field: string;
|
|
@@ -1641,4 +1826,4 @@ interface BuildOfferFillPlanOpts {
|
|
|
1641
1826
|
declare function buildOfferFillPlan(wallet: IWallet, arkServerUrl: string, offerHex: string | OfferBinding, opts: BuildOfferFillPlanOpts): Promise<JointGraph>;
|
|
1642
1827
|
declare function verifyOfferFillPlan(plan: JointGraph): boolean;
|
|
1643
1828
|
|
|
1644
|
-
export { type
|
|
1829
|
+
export { type Market as $, type AssetAliasTable as A, type BuildOfferFillPlanOpts as B, type CorridorFactory as C, DEFAULT_MAX_REFUND_WINDOW_SECONDS as D, DEFAULT_OPEN_RFQ_RELAYS as E, type DiscoveryConfig as F, type DiscoveryIndex as G, type DiscoveryIndexInput as H, type DiscoveryLeg as I, type DiscoverySnapshot as J, DiscoverySnapshotUnavailable as K, type LightningCorridorDeps as L, type DriveMode as M, type DriveRefusal as N, type OnchainCorridorDeps as O, type ExchangeOptions as P, FEED_TTL_MS as Q, type FeeCeiling as R, type FeedFetch as S, type FeedQuoteInput as T, type FillSponsor as U, type FillSponsorFare as V, INDEXED_NETWORKS as W, InconsistentRoute as X, InsufficientFunds as Y, type JointGraph as Z, type LockupOwner as _, type ArkadeCorridorDeps as a, completedSolverUsage as a$, type MarketCandidate as a0, type MarketLeg as a1, MaxFeeExceeded as a2, MissingCorridorDep as a3, NotCancellable as a4, OFFER_FILL_OWNERS as a5, OFFER_FILL_TEMPLATE as a6, ONCHAIN_CLAIM_FEE_RATE_SATVB as a7, type ObservationSeam as a8, type OfferPreparation as a9, type SolverCandidate as aA, type SolverHealth as aB, type SolverHealthEntry as aC, type SolverHealthScope as aD, type SolverHealthStorage as aE, SolverRoutesUnavailable as aF, type SolverRoutingContext as aG, type SolverRoutingPolicy as aH, type SwapClient as aI, type SwapClientConfig as aJ, type SwapDrive as aK, type SwapDriveConfig as aL, SwapDriveRefusedError as aM, type SwapError as aN, type SwapErrorName as aO, type SwapFilter as aP, type SwapPolicy as aQ, UnsupportedRoute as aR, type VerbDeps as aS, acceptQuote as aT, assembleRoute as aU, buildOfferFillPlan as aV, canFailoverQuote as aW, cancelSwap as aX, canonicalAssetId as aY, cardMarketOf as aZ, chooseMarket as a_, type OnchainClaim as aa, type OnchainRefund as ab, type OpenRfqAuction as ac, type OpenRfqOffer as ad, type OpenRfqOptions as ae, OperatorUnreachable as af, type ParsedRfqQuote as ag, type PayOptions as ah, type PayResult as ai, type QuoteCheck as aj, QuoteExpired as ak, type QuotePreparation as al, QuoteVerificationFailed as am, REGISTRY_URL as an, type ReceiveArtifact as ao, type ReceiveOptions as ap, type ReceiveRequest as aq, type RecoveryResult as ar, type RegisteredAsset as as, type ResolveDeps as at, type ResolvedRoute as au, type RfqAuctionPolicy as av, type RfqPreparation as aw, type RfqQuoteInput as ax, type RouteSide as ay, SWAP_ERROR_NAMES as az, AcceptConflict as b, conflictingFields as b0, corridorSet as b1, createSolverHealth as b2, createSwapClient as b3, createSwapDrive as b4, deepFreeze as b5, digestJointGraph as b6, discoveryIndex as b7, eligibleMarkets as b8, enforceFeeCeiling as b9, resolveCorridorBase as bA, resolveCorridorDeps as bB, resolveRoute as bC, rfqLeg as bD, rfqPairFor as bE, solverFacingAmount as bF, swapRecordOf as bG, toDiscoveryLeg as bH, unsignedPsbtBytes as bI, usableMarkets as bJ, verifyJointGraph as bK, verifyOfferFillPlan as bL, verifyPlanLegs as bM, withCanonicalAmount as bN, exchange as ba, feedFetch as bb, feedSpread as bc, freezeOpenRfqValue as bd, hasPausedKnownBidder as be, isAddressable as bf, isCardMarket as bg, isIndexedNetwork as bh, isSolverReliabilityFailure as bi, isSwapError as bj, isUsableCard as bk, liveArkadeInfo as bl, liveOperatorInfo as bm, marketBackendOf as bn, marketKeyOf as bo, marketOf as bp, marketRefOf as bq, openBidCandidates as br, orderedSolverCandidates as bs, parseRfqQuote as bt, pay as bu, quoteAdvertisedPlan as bv, quoteFromFeed as bw, quoteViaRfq as bx, readableRecord as by, receive as bz, type AcceptInput as c, type AcceptOptions as d, AmbiguousDestination as e, AmountEncodingUnsupported as f, AmountMismatch as g, type AssetRfqPreparation as h, CORRIDOR_FACTORIES as i, type CancelInput as j, type CancelOutcome as k, type ClaimedDestination as l, ClientDisposed as m, type CorridorBase as n, type CorridorClaim as o, type CorridorCovenant as p, type CorridorDeadline as q, type CorridorDeps as r, type CorridorDepsByCorridor as s, type CorridorDrive as t, type CorridorLockup as u, type CorridorModule as v, type CorridorOverrides as w, type CorridorPass as x, type CorridorRfqPreparation as y, type CorridorSet as z };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const RFQ_BROADCAST_KIND = 24860;
|
|
2
|
+
interface OpenRfqRequest {
|
|
3
|
+
readonly openId: string;
|
|
4
|
+
readonly pair: string;
|
|
5
|
+
readonly amountSide: "from" | "to";
|
|
6
|
+
readonly amount: bigint;
|
|
7
|
+
readonly bidsUntil: number;
|
|
8
|
+
}
|
|
9
|
+
interface OpenRfqBid {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly solverPubkey: string;
|
|
12
|
+
readonly openId: string;
|
|
13
|
+
readonly pair: string;
|
|
14
|
+
readonly amountSide: "from" | "to";
|
|
15
|
+
readonly fromAmount: bigint;
|
|
16
|
+
readonly toAmount: bigint;
|
|
17
|
+
readonly validUntil: number;
|
|
18
|
+
readonly card: unknown;
|
|
19
|
+
}
|
|
20
|
+
declare const openRfqPayload: (request: OpenRfqRequest) => {
|
|
21
|
+
readonly v: 1;
|
|
22
|
+
readonly type: "rfq_open";
|
|
23
|
+
readonly open_id: string;
|
|
24
|
+
readonly pair: string;
|
|
25
|
+
readonly amount_side: "from" | "to";
|
|
26
|
+
readonly amount: string;
|
|
27
|
+
readonly bids_until: number;
|
|
28
|
+
};
|
|
29
|
+
declare const parseOpenRfqBid: (payload: unknown, solverPubkey: string, eventId: string) => OpenRfqBid | null;
|
|
30
|
+
declare const rankOpenRfqBids: (bids: readonly OpenRfqBid[], amountSide: "from" | "to") => OpenRfqBid[];
|
|
31
|
+
|
|
32
|
+
export { type OpenRfqBid as O, RFQ_BROADCAST_KIND as R, type OpenRfqRequest as a, openRfqPayload as o, parseOpenRfqBid as p, rankOpenRfqBids as r };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const RFQ_BROADCAST_KIND = 24860;
|
|
2
|
+
interface OpenRfqRequest {
|
|
3
|
+
readonly openId: string;
|
|
4
|
+
readonly pair: string;
|
|
5
|
+
readonly amountSide: "from" | "to";
|
|
6
|
+
readonly amount: bigint;
|
|
7
|
+
readonly bidsUntil: number;
|
|
8
|
+
}
|
|
9
|
+
interface OpenRfqBid {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly solverPubkey: string;
|
|
12
|
+
readonly openId: string;
|
|
13
|
+
readonly pair: string;
|
|
14
|
+
readonly amountSide: "from" | "to";
|
|
15
|
+
readonly fromAmount: bigint;
|
|
16
|
+
readonly toAmount: bigint;
|
|
17
|
+
readonly validUntil: number;
|
|
18
|
+
readonly card: unknown;
|
|
19
|
+
}
|
|
20
|
+
declare const openRfqPayload: (request: OpenRfqRequest) => {
|
|
21
|
+
readonly v: 1;
|
|
22
|
+
readonly type: "rfq_open";
|
|
23
|
+
readonly open_id: string;
|
|
24
|
+
readonly pair: string;
|
|
25
|
+
readonly amount_side: "from" | "to";
|
|
26
|
+
readonly amount: string;
|
|
27
|
+
readonly bids_until: number;
|
|
28
|
+
};
|
|
29
|
+
declare const parseOpenRfqBid: (payload: unknown, solverPubkey: string, eventId: string) => OpenRfqBid | null;
|
|
30
|
+
declare const rankOpenRfqBids: (bids: readonly OpenRfqBid[], amountSide: "from" | "to") => OpenRfqBid[];
|
|
31
|
+
|
|
32
|
+
export { type OpenRfqBid as O, RFQ_BROADCAST_KIND as R, type OpenRfqRequest as a, openRfqPayload as o, parseOpenRfqBid as p, rankOpenRfqBids as r };
|