@arkade-os/swap 0.1.0-rc.24 → 0.1.0-rc.25

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/dist/advanced.cjs CHANGED
@@ -4245,7 +4245,8 @@ var nostrCards = {
4245
4245
  }
4246
4246
  };
4247
4247
  var transportCardsOf = (option) => option === void 0 ? nostrCards : option ?? void 0;
4248
- var UNDELIVERED_CARRY_MS = 2 * 60 * 60 * 1e3;
4248
+ var UNDELIVERED_CARRY_MS = import_solver_discovery6.MAX_CARD_AGE_SECONDS * 1e3;
4249
+ var DEGRADED_RETRY_MS = 6e4;
4249
4250
  var trackDelivery = (fetcher) => {
4250
4251
  let undelivered = /* @__PURE__ */ new Set();
4251
4252
  if (!fetcher) return { fetcher, undelivered: () => undelivered };
@@ -4322,7 +4323,6 @@ var readCache = async (repository, network, registry) => {
4322
4323
  return void 0;
4323
4324
  }
4324
4325
  };
4325
- var DEGRADED_RETRY_MS = 6e4;
4326
4326
  var discoveryIndex = (input) => {
4327
4327
  const config = input.config ?? {};
4328
4328
  const network = config.network ?? input.network;
@@ -4371,6 +4371,17 @@ var discoveryIndex = (input) => {
4371
4371
  held = cached;
4372
4372
  return cached;
4373
4373
  }
4374
+ const { network: indexed, registry: url } = sources();
4375
+ if (indexed && url && config.localCards?.length) {
4376
+ const { markets } = await (0, import_solver_discovery7.discover)({
4377
+ registries: [],
4378
+ localCards: [...config.localCards],
4379
+ network: indexed
4380
+ });
4381
+ if (markets.length > 0) {
4382
+ return { markets, ref: { fetchedAt: Date.now(), live: true, source: "local" } };
4383
+ }
4384
+ }
4374
4385
  return unavailable(whyUnavailable());
4375
4386
  };
4376
4387
  const load = async (opts = {}) => {
@@ -1,5 +1,5 @@
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-C0agdsz-.cjs';
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 DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, H as DiscoveryIndexInput, I as DiscoverySnapshotUnavailable, J as DriveMode, K as DriveRefusal, N as ExchangeOptions, P as FEED_TTL_MS, Q as FeeCeiling, R as FeedFetch, T as FeedQuoteInput, U as INDEXED_NETWORKS, V as InconsistentRoute, W as InsufficientFunds, X as LockupOwner, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a0 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a1 as ObservationSeam, a2 as OfferPreparation, a3 as OnchainClaim, a4 as OnchainRefund, a5 as OperatorUnreachable, a6 as ParsedRfqQuote, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ab as QuotePreparation, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, ak as RfqPreparation, al as RfqQuoteInput, am as RfqRendezvous, an as RfqTransportFactory, ao as RouteSide, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, as as SwapDrive, at as SwapDriveConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, ay as UnsupportedRoute, az as VerbDeps, aA as acceptQuote, aB as attesting, aC as cancelSwap, aD as canonicalAssetId, aE as cardMarketOf, aF as chooseMarket, aG as conflictingFields, aH as corridorSet, aI as createSwapClient, aJ as createSwapDrive, aK as discoveryIndex, aL as eligibleMarkets, aM as enforceFeeCeiling, aN as exchange, aO as feedFetch, aP as feedSpread, aQ as isAddressable, aR as isCardMarket, aS as isIndexedNetwork, aT as isSwapError, aU as isUsableCard, aV as liveArkadeInfo, aW as marketBackendOf, aX as marketKeyOf, aY as marketRefOf, aZ as nostrTransportFactory, a_ as parseRfqQuote, a$ as pay, b0 as quoteFromFeed, b1 as quoteViaRfq, b2 as readableRecord, b3 as receive, b4 as resolveCorridorBase, b5 as resolveCorridorDeps, b6 as rfqLeg, b7 as rfqPairFor, b8 as swapRecordOf, b9 as toDiscoveryLeg, ba as usableMarkets, bb as verifyPlanLegs, bc as withCanonicalAmount } from './errors-C0agdsz-.cjs';
1
+ import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './errors-DXjXCHYp.cjs';
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 DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, H as DiscoveryIndexInput, I as DiscoverySnapshotUnavailable, J as DriveMode, K as DriveRefusal, N as ExchangeOptions, P as FEED_TTL_MS, Q as FeeCeiling, R as FeedFetch, T as FeedQuoteInput, U as INDEXED_NETWORKS, V as InconsistentRoute, W as InsufficientFunds, X as LockupOwner, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a0 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a1 as ObservationSeam, a2 as OfferPreparation, a3 as OnchainClaim, a4 as OnchainRefund, a5 as OperatorUnreachable, a6 as ParsedRfqQuote, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ab as QuotePreparation, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, ak as RfqPreparation, al as RfqQuoteInput, am as RfqRendezvous, an as RfqTransportFactory, ao as RouteSide, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, as as SwapDrive, at as SwapDriveConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, ay as UnsupportedRoute, az as VerbDeps, aA as acceptQuote, aB as attesting, aC as cancelSwap, aD as canonicalAssetId, aE as cardMarketOf, aF as chooseMarket, aG as conflictingFields, aH as corridorSet, aI as createSwapClient, aJ as createSwapDrive, aK as discoveryIndex, aL as eligibleMarkets, aM as enforceFeeCeiling, aN as exchange, aO as feedFetch, aP as feedSpread, aQ as isAddressable, aR as isCardMarket, aS as isIndexedNetwork, aT as isSwapError, aU as isUsableCard, aV as liveArkadeInfo, aW as marketBackendOf, aX as marketKeyOf, aY as marketRefOf, aZ as nostrTransportFactory, a_ as parseRfqQuote, a$ as pay, b0 as quoteFromFeed, b1 as quoteViaRfq, b2 as readableRecord, b3 as receive, b4 as resolveCorridorBase, b5 as resolveCorridorDeps, b6 as rfqLeg, b7 as rfqPairFor, b8 as swapRecordOf, b9 as toDiscoveryLeg, ba as usableMarkets, bb as verifyPlanLegs, bc as withCanonicalAmount } from './errors-DXjXCHYp.cjs';
3
3
  import { DiscoveredMarket } from '@arkade-os/solver-discovery';
4
4
  import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-yN-i_u-0.cjs';
5
5
  export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as Artifact, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetRef, B as AssetScale, D as AssetSwapId, E as AtomicDecimal, F as AuctionMarketRef, G as AuctionProvenance, H as BITCOIN_RAILS, J as BTC_ASSET_PART, K as BitcoinRail, M as CORRIDORS, T as CORRIDOR_PASS, U as CardMarketRef, V as CorridorId, W as CorridorKind, X as DepositArtifact, Y as DisplayDecimal, Z as Endpoint, _ as Ep, $ as Hex, a0 as LOCKUP_OWNER, a1 as MarketBackend, a2 as MarketRef, a3 as OFFER_SWAP_ID_PREFIX, a4 as Outcome, a5 as ParsedAssetId, a6 as Quote, a7 as QuoteLeg, a8 as RAILS, a9 as RFQ_SWAP_ID_PREFIX, aa as RailOf, ab as RankedBid, ac as RawState, ad as RecordedArtifact, ae as RecordedEndpoint, af as RecordedInstrument, ag as RecordedLeg, ah as RestoredMarketRef, ai as RfqAmountSide, aj as SnapshotRef, ak as Swap, al as SwapFamily, am as SwapRecordCommon, an as SwapUpdate, ao as Unsubscribe, ap as arkadeAsset, aq as artifactOf, ar as assetPartOf, as as assetSwapIdOf, at as bitcoinNetworkOf, au as btcAssetPart, av as btcOn, aw as corridorOfRail, ax as corridorOutcome, ay as decodeRfqAmount, az as encodeRfqAmount, aA as familyOfSwapId, aB as formatAssetId, aC as fromAtomicDecimal, aD as fromRfqAmountSide, aE as fundsFromWallet, aF as instrumentOf, aG as isAssetId, aH as isAtomicDecimal, aI as isBtcAsset, aJ as isBtcAssetLenient, aK as isNetworkRef, aL as issuanceOf, aM as legOf, aN as offerOutcome, aO as parseAssetId, aP as quoteIdOfSwapId, aQ as railOf, aR as railOfCorridor, aS as readsChain, aT as recordArtifact, aU as recordEndpoint, aV as recordInstrument, aW as recordLeg, aX as recordOutcome, aY as sameAsset, aZ as swapOf, a_ as toAtomicDecimal, a$ as toRfqAmountSide, b0 as toSafeNumber } from './repository-yN-i_u-0.cjs';
@@ -1,5 +1,5 @@
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-ByFSFU1B.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 DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, H as DiscoveryIndexInput, I as DiscoverySnapshotUnavailable, J as DriveMode, K as DriveRefusal, N as ExchangeOptions, P as FEED_TTL_MS, Q as FeeCeiling, R as FeedFetch, T as FeedQuoteInput, U as INDEXED_NETWORKS, V as InconsistentRoute, W as InsufficientFunds, X as LockupOwner, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a0 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a1 as ObservationSeam, a2 as OfferPreparation, a3 as OnchainClaim, a4 as OnchainRefund, a5 as OperatorUnreachable, a6 as ParsedRfqQuote, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ab as QuotePreparation, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, ak as RfqPreparation, al as RfqQuoteInput, am as RfqRendezvous, an as RfqTransportFactory, ao as RouteSide, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, as as SwapDrive, at as SwapDriveConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, ay as UnsupportedRoute, az as VerbDeps, aA as acceptQuote, aB as attesting, aC as cancelSwap, aD as canonicalAssetId, aE as cardMarketOf, aF as chooseMarket, aG as conflictingFields, aH as corridorSet, aI as createSwapClient, aJ as createSwapDrive, aK as discoveryIndex, aL as eligibleMarkets, aM as enforceFeeCeiling, aN as exchange, aO as feedFetch, aP as feedSpread, aQ as isAddressable, aR as isCardMarket, aS as isIndexedNetwork, aT as isSwapError, aU as isUsableCard, aV as liveArkadeInfo, aW as marketBackendOf, aX as marketKeyOf, aY as marketRefOf, aZ as nostrTransportFactory, a_ as parseRfqQuote, a$ as pay, b0 as quoteFromFeed, b1 as quoteViaRfq, b2 as readableRecord, b3 as receive, b4 as resolveCorridorBase, b5 as resolveCorridorDeps, b6 as rfqLeg, b7 as rfqPairFor, b8 as swapRecordOf, b9 as toDiscoveryLeg, ba as usableMarkets, bb as verifyPlanLegs, bc as withCanonicalAmount } from './errors-ByFSFU1B.js';
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-Ckp_FRdo.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 DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, H as DiscoveryIndexInput, I as DiscoverySnapshotUnavailable, J as DriveMode, K as DriveRefusal, N as ExchangeOptions, P as FEED_TTL_MS, Q as FeeCeiling, R as FeedFetch, T as FeedQuoteInput, U as INDEXED_NETWORKS, V as InconsistentRoute, W as InsufficientFunds, X as LockupOwner, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a0 as ONCHAIN_CLAIM_FEE_RATE_SATVB, a1 as ObservationSeam, a2 as OfferPreparation, a3 as OnchainClaim, a4 as OnchainRefund, a5 as OperatorUnreachable, a6 as ParsedRfqQuote, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ab as QuotePreparation, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, ak as RfqPreparation, al as RfqQuoteInput, am as RfqRendezvous, an as RfqTransportFactory, ao as RouteSide, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, as as SwapDrive, at as SwapDriveConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, ay as UnsupportedRoute, az as VerbDeps, aA as acceptQuote, aB as attesting, aC as cancelSwap, aD as canonicalAssetId, aE as cardMarketOf, aF as chooseMarket, aG as conflictingFields, aH as corridorSet, aI as createSwapClient, aJ as createSwapDrive, aK as discoveryIndex, aL as eligibleMarkets, aM as enforceFeeCeiling, aN as exchange, aO as feedFetch, aP as feedSpread, aQ as isAddressable, aR as isCardMarket, aS as isIndexedNetwork, aT as isSwapError, aU as isUsableCard, aV as liveArkadeInfo, aW as marketBackendOf, aX as marketKeyOf, aY as marketRefOf, aZ as nostrTransportFactory, a_ as parseRfqQuote, a$ as pay, b0 as quoteFromFeed, b1 as quoteViaRfq, b2 as readableRecord, b3 as receive, b4 as resolveCorridorBase, b5 as resolveCorridorDeps, b6 as rfqLeg, b7 as rfqPairFor, b8 as swapRecordOf, b9 as toDiscoveryLeg, ba as usableMarkets, bb as verifyPlanLegs, bc as withCanonicalAmount } from './errors-Ckp_FRdo.js';
3
3
  import { DiscoveredMarket } from '@arkade-os/solver-discovery';
4
4
  import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-DITDhUdX.js';
5
5
  export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as Artifact, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetRef, B as AssetScale, D as AssetSwapId, E as AtomicDecimal, F as AuctionMarketRef, G as AuctionProvenance, H as BITCOIN_RAILS, J as BTC_ASSET_PART, K as BitcoinRail, M as CORRIDORS, T as CORRIDOR_PASS, U as CardMarketRef, V as CorridorId, W as CorridorKind, X as DepositArtifact, Y as DisplayDecimal, Z as Endpoint, _ as Ep, $ as Hex, a0 as LOCKUP_OWNER, a1 as MarketBackend, a2 as MarketRef, a3 as OFFER_SWAP_ID_PREFIX, a4 as Outcome, a5 as ParsedAssetId, a6 as Quote, a7 as QuoteLeg, a8 as RAILS, a9 as RFQ_SWAP_ID_PREFIX, aa as RailOf, ab as RankedBid, ac as RawState, ad as RecordedArtifact, ae as RecordedEndpoint, af as RecordedInstrument, ag as RecordedLeg, ah as RestoredMarketRef, ai as RfqAmountSide, aj as SnapshotRef, ak as Swap, al as SwapFamily, am as SwapRecordCommon, an as SwapUpdate, ao as Unsubscribe, ap as arkadeAsset, aq as artifactOf, ar as assetPartOf, as as assetSwapIdOf, at as bitcoinNetworkOf, au as btcAssetPart, av as btcOn, aw as corridorOfRail, ax as corridorOutcome, ay as decodeRfqAmount, az as encodeRfqAmount, aA as familyOfSwapId, aB as formatAssetId, aC as fromAtomicDecimal, aD as fromRfqAmountSide, aE as fundsFromWallet, aF as instrumentOf, aG as isAssetId, aH as isAtomicDecimal, aI as isBtcAsset, aJ as isBtcAssetLenient, aK as isNetworkRef, aL as issuanceOf, aM as legOf, aN as offerOutcome, aO as parseAssetId, aP as quoteIdOfSwapId, aQ as railOf, aR as railOfCorridor, aS as readsChain, aT as recordArtifact, aU as recordEndpoint, aV as recordInstrument, aW as recordLeg, aX as recordOutcome, aY as sameAsset, aZ as swapOf, a_ as toAtomicDecimal, a$ as toRfqAmountSide, b0 as toSafeNumber } from './repository-DITDhUdX.js';
package/dist/advanced.js CHANGED
@@ -146,7 +146,7 @@ import {
146
146
  withCanonicalAmount,
147
147
  withDepositFate,
148
148
  withRfqState
149
- } from "./chunk-J6MXF4GQ.js";
149
+ } from "./chunk-5PI54AVY.js";
150
150
  import {
151
151
  ACTIVITY_TOKEN,
152
152
  CORRIDOR_PASS,
@@ -161,7 +161,7 @@ import {
161
161
  onchainCorridor,
162
162
  readsChain,
163
163
  recordOutcome
164
- } from "./chunk-MSVRO7ZS.js";
164
+ } from "./chunk-CZHB3ZDG.js";
165
165
  import {
166
166
  ARKADE_BTC,
167
167
  SwapRefusal,
@@ -1,4 +1,5 @@
1
1
  import {
2
+ DEGRADED_RETRY_MS,
2
3
  LOCKUP_OWNER,
3
4
  LockupNeedsRecoveryError,
4
5
  MARKETS_CACHE_TTL_MS,
@@ -41,7 +42,7 @@ import {
41
42
  undeliveredCarry,
42
43
  walletOperator,
43
44
  watchOfferSwaps
44
- } from "./chunk-MSVRO7ZS.js";
45
+ } from "./chunk-CZHB3ZDG.js";
45
46
  import {
46
47
  ARKADE_BTC,
47
48
  ASSET_CARRIER_SATS,
@@ -1409,7 +1410,6 @@ var readCache = async (repository, network, registry) => {
1409
1410
  return void 0;
1410
1411
  }
1411
1412
  };
1412
- var DEGRADED_RETRY_MS = 6e4;
1413
1413
  var discoveryIndex = (input) => {
1414
1414
  const config = input.config ?? {};
1415
1415
  const network = config.network ?? input.network;
@@ -1458,6 +1458,17 @@ var discoveryIndex = (input) => {
1458
1458
  held = cached;
1459
1459
  return cached;
1460
1460
  }
1461
+ const { network: indexed, registry: url } = sources();
1462
+ if (indexed && url && config.localCards?.length) {
1463
+ const { markets } = await discover({
1464
+ registries: [],
1465
+ localCards: [...config.localCards],
1466
+ network: indexed
1467
+ });
1468
+ if (markets.length > 0) {
1469
+ return { markets, ref: { fetchedAt: Date.now(), live: true, source: "local" } };
1470
+ }
1471
+ }
1461
1472
  return unavailable(whyUnavailable());
1462
1473
  };
1463
1474
  const load = async (opts = {}) => {
@@ -788,6 +788,7 @@ import {
788
788
  bestMarket,
789
789
  discover,
790
790
  isNetwork,
791
+ MAX_CARD_AGE_SECONDS,
791
792
  marketLegKey,
792
793
  marketPairKey,
793
794
  registryIndexUrl,
@@ -902,7 +903,9 @@ var nostrCards = {
902
903
  }
903
904
  };
904
905
  var transportCardsOf = (option) => option === void 0 ? nostrCards : option ?? void 0;
905
- var UNDELIVERED_CARRY_MS = 2 * 60 * 60 * 1e3;
906
+ var UNDELIVERED_CARRY_MS = MAX_CARD_AGE_SECONDS * 1e3;
907
+ var DEGRADED_RETRY_MS = 6e4;
908
+ var carriedHolds = /* @__PURE__ */ new WeakMap();
906
909
  var trackDelivery = (fetcher) => {
907
910
  let undelivered = /* @__PURE__ */ new Set();
908
911
  if (!fetcher) return { fetcher, undelivered: () => undelivered };
@@ -977,6 +980,9 @@ var discoverMarkets = async (options) => {
977
980
  const cached = repository && await readMarketsCache(repository, network, registryKey);
978
981
  if (useCache && cached && Date.now() - cached.fetchedAt < MARKETS_CACHE_TTL_MS)
979
982
  return cached.markets;
983
+ const holdKey = `${network} ${registryKey}`;
984
+ const hold = repository && carriedHolds.get(repository)?.get(holdKey);
985
+ if (useCache && hold && Date.now() < hold.until) return hold.markets;
980
986
  const delivery = trackDelivery(transportCardsOf(options.transportCards));
981
987
  const { markets, sources, warnings } = await discover({
982
988
  registries,
@@ -989,7 +995,13 @@ var discoverMarkets = async (options) => {
989
995
  const reachable = registryAnswered(sources);
990
996
  if (!reachable && cached) return cached.markets;
991
997
  const carried = reachable ? undeliveredCarry(markets, delivery.undelivered(), cached) : [];
992
- if (carried.length > 0) return ranked([...markets, ...carried]);
998
+ if (carried.length > 0 && repository) {
999
+ const merged = ranked([...markets, ...carried]);
1000
+ const holds = carriedHolds.get(repository) ?? /* @__PURE__ */ new Map();
1001
+ holds.set(holdKey, { until: Date.now() + DEGRADED_RETRY_MS, markets: merged });
1002
+ carriedHolds.set(repository, holds);
1003
+ return merged;
1004
+ }
993
1005
  if (reachable && repository) {
994
1006
  try {
995
1007
  await repository.saveCachedMarkets(network, registryKey, {
@@ -2813,6 +2825,7 @@ export {
2813
2825
  MARKETS_CACHE_TTL_MS,
2814
2826
  registryAnswered,
2815
2827
  transportCardsOf,
2828
+ DEGRADED_RETRY_MS,
2816
2829
  trackDelivery,
2817
2830
  undeliveredCarry,
2818
2831
  discoverMarkets,
@@ -404,7 +404,7 @@ interface DiscoverySnapshot {
404
404
  interface DiscoveryIndex {
405
405
  /**
406
406
  * The snapshot in hand, without touching the network — an injected one, one
407
- * this client already loaded, or the repository's cache.
407
+ * this client already loaded, the repository's cache, or the pinned cards alone.
408
408
  *
409
409
  * @throws {DiscoverySnapshotUnavailable} when there is none.
410
410
  */
@@ -404,7 +404,7 @@ interface DiscoverySnapshot {
404
404
  interface DiscoveryIndex {
405
405
  /**
406
406
  * The snapshot in hand, without touching the network — an injected one, one
407
- * this client already loaded, or the repository's cache.
407
+ * this client already loaded, the repository's cache, or the pinned cards alone.
408
408
  *
409
409
  * @throws {DiscoverySnapshotUnavailable} when there is none.
410
410
  */
package/dist/index.cjs CHANGED
@@ -3104,7 +3104,8 @@ var nostrCards = {
3104
3104
  }
3105
3105
  };
3106
3106
  var transportCardsOf = (option) => option === void 0 ? nostrCards : option ?? void 0;
3107
- var UNDELIVERED_CARRY_MS = 2 * 60 * 60 * 1e3;
3107
+ var UNDELIVERED_CARRY_MS = import_solver_discovery3.MAX_CARD_AGE_SECONDS * 1e3;
3108
+ var DEGRADED_RETRY_MS = 6e4;
3108
3109
  var trackDelivery = (fetcher) => {
3109
3110
  let undelivered = /* @__PURE__ */ new Set();
3110
3111
  if (!fetcher) return { fetcher, undelivered: () => undelivered };
@@ -3391,7 +3392,6 @@ var readCache = async (repository, network, registry) => {
3391
3392
  return void 0;
3392
3393
  }
3393
3394
  };
3394
- var DEGRADED_RETRY_MS = 6e4;
3395
3395
  var discoveryIndex = (input) => {
3396
3396
  const config = input.config ?? {};
3397
3397
  const network = config.network ?? input.network;
@@ -3440,6 +3440,17 @@ var discoveryIndex = (input) => {
3440
3440
  held = cached;
3441
3441
  return cached;
3442
3442
  }
3443
+ const { network: indexed, registry: url } = sources();
3444
+ if (indexed && url && config.localCards?.length) {
3445
+ const { markets } = await (0, import_solver_discovery5.discover)({
3446
+ registries: [],
3447
+ localCards: [...config.localCards],
3448
+ network: indexed
3449
+ });
3450
+ if (markets.length > 0) {
3451
+ return { markets, ref: { fetchedAt: Date.now(), live: true, source: "local" } };
3452
+ }
3453
+ }
3443
3454
  return unavailable(whyUnavailable());
3444
3455
  };
3445
3456
  const load = async (opts = {}) => {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { e as AcceptConflict, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, A as AssetAliasTable, n as CancelOutcome, p as ClientDisposed, z as CorridorOverrides, F as DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, d as DiscoverySnapshot, I as DiscoverySnapshotUnavailable, J as DriveMode, N as ExchangeOptions, Q as FeeCeiling, V as InconsistentRoute, W as InsufficientFunds, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a5 as OperatorUnreachable, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, an as RfqTransportFactory, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, S as SwapPolicy, ay as UnsupportedRoute, az as VerbDeps, aD as canonicalAssetId, aI as createSwapClient, aN as exchange, aT as isSwapError, a$ as pay, b3 as receive } from './errors-C0agdsz-.cjs';
1
+ export { e as AcceptConflict, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, A as AssetAliasTable, n as CancelOutcome, p as ClientDisposed, z as CorridorOverrides, F as DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, d as DiscoverySnapshot, I as DiscoverySnapshotUnavailable, J as DriveMode, N as ExchangeOptions, Q as FeeCeiling, V as InconsistentRoute, W as InsufficientFunds, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a5 as OperatorUnreachable, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, an as RfqTransportFactory, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, S as SwapPolicy, ay as UnsupportedRoute, az as VerbDeps, aD as canonicalAssetId, aI as createSwapClient, aN as exchange, aT as isSwapError, a$ as pay, b3 as receive } from './errors-DXjXCHYp.cjs';
2
2
  import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry, a4 as Outcome, ak as Swap, l as QuoteInput, i as RouteResolution, a6 as Quote, an as SwapUpdate, ao as Unsubscribe } from './repository-yN-i_u-0.cjs';
3
3
  export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as Artifact, A as AssetId, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetRef, B as AssetScale, D as AssetSwapId, E as AtomicDecimal, F as AuctionMarketRef, G as AuctionProvenance, H as BITCOIN_RAILS, J as BTC_ASSET_PART, K as BitcoinRail, U as CardMarketRef, V as CorridorId, W as CorridorKind, b as CorridorSwapRecord, X as DepositArtifact, Y as DisplayDecimal, Z as Endpoint, _ as Ep, b2 as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a1 as MarketBackend, a2 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a5 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, a7 as QuoteLeg, a8 as RAILS, R as Rail, ab as RankedBid, ac as RawState, ad as RecordedArtifact, ae as RecordedEndpoint, af as RecordedInstrument, ag as RecordedLeg, j as ResolvedEndpoint, ah as RestoredMarketRef, b3 as RfqSwapState, k as Route, aj as SnapshotRef, b4 as SwapContractRegistry, al as SwapFamily, b5 as SwapOperator, am as SwapRecordCommon, ap as arkadeAsset, ar as assetPartOf, as as assetSwapIdOf, at as bitcoinNetworkOf, au as btcAssetPart, av as btcOn, aA as familyOfSwapId, aB as formatAssetId, aC as fromAtomicDecimal, aG as isAssetId, aH as isAtomicDecimal, aI as isBtcAsset, aJ as isBtcAssetLenient, aK as isNetworkRef, b6 as isRfqSwapTerminal, aL as issuanceOf, aO as parseAssetId, aP as quoteIdOfSwapId, aQ as railOf, aY as sameAsset, a_ as toAtomicDecimal } from './repository-yN-i_u-0.cjs';
4
4
  export { C as ChainSource, I as InvoiceFacts, a as RFQ_REFUSAL_ERROR_CODES, b as RfqRefusalDetail, c as RfqRefusalErrorCode, d as RfqRefusalUnit, S as SwapRefusal, i as isRfqRefusalErrorCode } from './rfq-BgdgO9OO.cjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { e as AcceptConflict, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, A as AssetAliasTable, n as CancelOutcome, p as ClientDisposed, z as CorridorOverrides, F as DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, d as DiscoverySnapshot, I as DiscoverySnapshotUnavailable, J as DriveMode, N as ExchangeOptions, Q as FeeCeiling, V as InconsistentRoute, W as InsufficientFunds, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a5 as OperatorUnreachable, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, an as RfqTransportFactory, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, S as SwapPolicy, ay as UnsupportedRoute, az as VerbDeps, aD as canonicalAssetId, aI as createSwapClient, aN as exchange, aT as isSwapError, a$ as pay, b3 as receive } from './errors-ByFSFU1B.js';
1
+ export { e as AcceptConflict, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, A as AssetAliasTable, n as CancelOutcome, p as ClientDisposed, z as CorridorOverrides, F as DEFAULT_MAX_REFUND_WINDOW_SECONDS, G as DiscoveryConfig, d as DiscoverySnapshot, I as DiscoverySnapshotUnavailable, J as DriveMode, N as ExchangeOptions, Q as FeeCeiling, V as InconsistentRoute, W as InsufficientFunds, Y as Market, Z as MaxFeeExceeded, _ as MissingCorridorDep, $ as NotCancellable, a5 as OperatorUnreachable, a7 as PayOptions, a8 as PayResult, a9 as QuoteCheck, aa as QuoteExpired, ac as QuoteVerificationFailed, ad as REGISTRY_URL, ae as ReceiveArtifact, af as ReceiveOptions, ag as ReceiveRequest, ah as RecoveryResult, ai as RegisteredAsset, aj as RfqAuctionPolicy, an as RfqTransportFactory, ap as SWAP_ERROR_NAMES, aq as SwapClient, ar as SwapClientConfig, au as SwapDriveRefusedError, av as SwapError, aw as SwapErrorName, ax as SwapFilter, S as SwapPolicy, ay as UnsupportedRoute, az as VerbDeps, aD as canonicalAssetId, aI as createSwapClient, aN as exchange, aT as isSwapError, a$ as pay, b3 as receive } from './errors-Ckp_FRdo.js';
2
2
  import { d as AssetSwapRepository, h as AssetSwap, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, S as SwapRecord, b1 as MarketsCacheEntry, a4 as Outcome, ak as Swap, l as QuoteInput, i as RouteResolution, a6 as Quote, an as SwapUpdate, ao as Unsubscribe } from './repository-DITDhUdX.js';
3
3
  export { o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, s as AmountRefusal, t as Artifact, A as AssetId, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetRef, B as AssetScale, D as AssetSwapId, E as AtomicDecimal, F as AuctionMarketRef, G as AuctionProvenance, H as BITCOIN_RAILS, J as BTC_ASSET_PART, K as BitcoinRail, U as CardMarketRef, V as CorridorId, W as CorridorKind, b as CorridorSwapRecord, X as DepositArtifact, Y as DisplayDecimal, Z as Endpoint, _ as Ep, b2 as InMemoryAssetSwapRepository, I as Instrument, L as LockupSpendIndexer, a1 as MarketBackend, a2 as MarketRef, N as NetworkRef, O as OfferSwapRecord, a5 as ParsedAssetId, P as PinnedAmount, Q as QuoteId, a7 as QuoteLeg, a8 as RAILS, R as Rail, ab as RankedBid, ac as RawState, ad as RecordedArtifact, ae as RecordedEndpoint, af as RecordedInstrument, ag as RecordedLeg, j as ResolvedEndpoint, ah as RestoredMarketRef, b3 as RfqSwapState, k as Route, aj as SnapshotRef, b4 as SwapContractRegistry, al as SwapFamily, b5 as SwapOperator, am as SwapRecordCommon, ap as arkadeAsset, ar as assetPartOf, as as assetSwapIdOf, at as bitcoinNetworkOf, au as btcAssetPart, av as btcOn, aA as familyOfSwapId, aB as formatAssetId, aC as fromAtomicDecimal, aG as isAssetId, aH as isAtomicDecimal, aI as isBtcAsset, aJ as isBtcAssetLenient, aK as isNetworkRef, b6 as isRfqSwapTerminal, aL as issuanceOf, aO as parseAssetId, aP as quoteIdOfSwapId, aQ as railOf, aY as sameAsset, a_ as toAtomicDecimal } from './repository-DITDhUdX.js';
4
4
  export { C as ChainSource, I as InvoiceFacts, a as RFQ_REFUSAL_ERROR_CODES, b as RfqRefusalDetail, c as RfqRefusalErrorCode, d as RfqRefusalUnit, S as SwapRefusal, i as isRfqRefusalErrorCode } from './rfq-BgdgO9OO.js';
package/dist/index.js CHANGED
@@ -62,10 +62,10 @@ import {
62
62
  sameAsset,
63
63
  swapHandle,
64
64
  toAtomicDecimal
65
- } from "./chunk-J6MXF4GQ.js";
65
+ } from "./chunk-5PI54AVY.js";
66
66
  import {
67
67
  isRfqSwapTerminal
68
- } from "./chunk-MSVRO7ZS.js";
68
+ } from "./chunk-CZHB3ZDG.js";
69
69
  import {
70
70
  CLAIM_PACKET_TYPE,
71
71
  LockupRegistrationFailed,
package/dist/protocol.cjs CHANGED
@@ -5093,7 +5093,9 @@ var nostrCards = {
5093
5093
  }
5094
5094
  };
5095
5095
  var transportCardsOf = (option) => option === void 0 ? nostrCards : option ?? void 0;
5096
- var UNDELIVERED_CARRY_MS = 2 * 60 * 60 * 1e3;
5096
+ var UNDELIVERED_CARRY_MS = import_solver_discovery3.MAX_CARD_AGE_SECONDS * 1e3;
5097
+ var DEGRADED_RETRY_MS = 6e4;
5098
+ var carriedHolds = /* @__PURE__ */ new WeakMap();
5097
5099
  var trackDelivery = (fetcher) => {
5098
5100
  let undelivered = /* @__PURE__ */ new Set();
5099
5101
  if (!fetcher) return { fetcher, undelivered: () => undelivered };
@@ -5168,6 +5170,9 @@ var discoverMarkets = async (options) => {
5168
5170
  const cached = repository && await readMarketsCache(repository, network, registryKey);
5169
5171
  if (useCache && cached && Date.now() - cached.fetchedAt < MARKETS_CACHE_TTL_MS)
5170
5172
  return cached.markets;
5173
+ const holdKey = `${network} ${registryKey}`;
5174
+ const hold = repository && carriedHolds.get(repository)?.get(holdKey);
5175
+ if (useCache && hold && Date.now() < hold.until) return hold.markets;
5171
5176
  const delivery = trackDelivery(transportCardsOf(options.transportCards));
5172
5177
  const { markets, sources, warnings } = await (0, import_solver_discovery3.discover)({
5173
5178
  registries,
@@ -5180,7 +5185,13 @@ var discoverMarkets = async (options) => {
5180
5185
  const reachable = registryAnswered(sources);
5181
5186
  if (!reachable && cached) return cached.markets;
5182
5187
  const carried = reachable ? undeliveredCarry(markets, delivery.undelivered(), cached) : [];
5183
- if (carried.length > 0) return ranked([...markets, ...carried]);
5188
+ if (carried.length > 0 && repository) {
5189
+ const merged = ranked([...markets, ...carried]);
5190
+ const holds = carriedHolds.get(repository) ?? /* @__PURE__ */ new Map();
5191
+ holds.set(holdKey, { until: Date.now() + DEGRADED_RETRY_MS, markets: merged });
5192
+ carriedHolds.set(repository, holds);
5193
+ return merged;
5194
+ }
5184
5195
  if (reachable && repository) {
5185
5196
  try {
5186
5197
  await repository.saveCachedMarkets(network, registryKey, {
package/dist/protocol.js CHANGED
@@ -47,7 +47,7 @@ import {
47
47
  validatePlan,
48
48
  watchMarkets,
49
49
  watchOfferSwaps
50
- } from "./chunk-MSVRO7ZS.js";
50
+ } from "./chunk-CZHB3ZDG.js";
51
51
  import {
52
52
  ARKADE_BTC,
53
53
  ASSET_CARRIER_SATS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/swap",
3
- "version": "0.1.0-rc.24",
3
+ "version": "0.1.0-rc.25",
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": {
@@ -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.21"
107
+ "@arkade-os/sdk": "0.5.0-rc.22"
108
108
  },
109
109
  "peerDependencies": {
110
110
  "nostr-tools": "^2.12.0"