@satora/swap 1.6.1 → 1.7.1
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/index.cjs +90 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +90 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -639,6 +639,8 @@ declare class Client {
|
|
|
639
639
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
640
640
|
getChainConfig(...args: Parameters<Client$1["getChainConfig"]>): ReturnType<Client$1["getChainConfig"]>;
|
|
641
641
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
642
|
+
getRifRelay(...args: Parameters<Client$1["getRifRelay"]>): ReturnType<Client$1["getRifRelay"]>;
|
|
643
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
642
644
|
getReferralFee(...args: Parameters<Client$1["getReferralFee"]>): ReturnType<Client$1["getReferralFee"]>;
|
|
643
645
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
644
646
|
getNetworkFees(...args: Parameters<Client$1["getNetworkFees"]>): ReturnType<Client$1["getNetworkFees"]>;
|
|
@@ -703,6 +705,10 @@ declare class Client {
|
|
|
703
705
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
704
706
|
createArkadeToLightningSwap(...args: Parameters<Client$1["createArkadeToLightningSwap"]>): ReturnType<Client$1["createArkadeToLightningSwap"]>;
|
|
705
707
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
708
|
+
createLightningToBitcoinSwap(...args: Parameters<Client$1["createLightningToBitcoinSwap"]>): ReturnType<Client$1["createLightningToBitcoinSwap"]>;
|
|
709
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
710
|
+
createBitcoinToLightningSwap(...args: Parameters<Client$1["createBitcoinToLightningSwap"]>): ReturnType<Client$1["createBitcoinToLightningSwap"]>;
|
|
711
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
706
712
|
createEvmToLightningSwap(...args: Parameters<Client$1["createEvmToLightningSwap"]>): ReturnType<Client$1["createEvmToLightningSwap"]>;
|
|
707
713
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
708
714
|
createEvmToArkadeSwapGeneric(...args: Parameters<Client$1["createEvmToArkadeSwapGeneric"]>): ReturnType<Client$1["createEvmToArkadeSwapGeneric"]>;
|
|
@@ -715,8 +721,14 @@ declare class Client {
|
|
|
715
721
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
716
722
|
fundSwap(...args: Parameters<Client$1["fundSwap"]>): ReturnType<Client$1["fundSwap"]>;
|
|
717
723
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
724
|
+
fundSwapFromSolana(...args: Parameters<Client$1["fundSwapFromSolana"]>): ReturnType<Client$1["fundSwapFromSolana"]>;
|
|
725
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
726
|
+
getSolanaUsdcBalance(...args: Parameters<Client$1["getSolanaUsdcBalance"]>): ReturnType<Client$1["getSolanaUsdcBalance"]>;
|
|
727
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
718
728
|
refundEvmWithSigner(...args: Parameters<Client$1["refundEvmWithSigner"]>): ReturnType<Client$1["refundEvmWithSigner"]>;
|
|
719
729
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
730
|
+
refundEvmSponsored(...args: Parameters<Client$1["refundEvmSponsored"]>): ReturnType<Client$1["refundEvmSponsored"]>;
|
|
731
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
720
732
|
collabRefundEvmWithSigner(...args: Parameters<Client$1["collabRefundEvmWithSigner"]>): ReturnType<Client$1["collabRefundEvmWithSigner"]>;
|
|
721
733
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
722
734
|
fundSwapGasless(...args: Parameters<Client$1["fundSwapGasless"]>): ReturnType<Client$1["fundSwapGasless"]>;
|
|
@@ -729,6 +741,8 @@ declare class Client {
|
|
|
729
741
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
730
742
|
continueRefundedEvmSwap(...args: Parameters<Client$1["continueRefundedEvmSwap"]>): ReturnType<Client$1["continueRefundedEvmSwap"]>;
|
|
731
743
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
744
|
+
recoverCctpInboundSwap(...args: Parameters<Client$1["recoverCctpInboundSwap"]>): ReturnType<Client$1["recoverCctpInboundSwap"]>;
|
|
745
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
732
746
|
recoverGaslessFunds(...args: Parameters<Client$1["recoverGaslessFunds"]>): ReturnType<Client$1["recoverGaslessFunds"]>;
|
|
733
747
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
734
748
|
hasReceivedVtxo(...args: Parameters<Client$1["hasReceivedVtxo"]>): ReturnType<Client$1["hasReceivedVtxo"]>;
|
|
@@ -847,6 +861,7 @@ declare class ClientBuilder {
|
|
|
847
861
|
withMnemonic(...args: Parameters<ClientBuilder$1["withMnemonic"]>): this;
|
|
848
862
|
withXprv(...args: Parameters<ClientBuilder$1["withXprv"]>): this;
|
|
849
863
|
withAa(...args: Parameters<ClientBuilder$1["withAa"]>): this;
|
|
864
|
+
withSolanaRpcUrl(...args: Parameters<ClientBuilder$1["withSolanaRpcUrl"]>): this;
|
|
850
865
|
withLogger(...args: Parameters<ClientBuilder$1["withLogger"]>): this;
|
|
851
866
|
withLogLevel(...args: Parameters<ClientBuilder$1["withLogLevel"]>): this;
|
|
852
867
|
build(): Promise<Client>;
|
package/dist/index.d.ts
CHANGED
|
@@ -639,6 +639,8 @@ declare class Client {
|
|
|
639
639
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
640
640
|
getChainConfig(...args: Parameters<Client$1["getChainConfig"]>): ReturnType<Client$1["getChainConfig"]>;
|
|
641
641
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
642
|
+
getRifRelay(...args: Parameters<Client$1["getRifRelay"]>): ReturnType<Client$1["getRifRelay"]>;
|
|
643
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
642
644
|
getReferralFee(...args: Parameters<Client$1["getReferralFee"]>): ReturnType<Client$1["getReferralFee"]>;
|
|
643
645
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
644
646
|
getNetworkFees(...args: Parameters<Client$1["getNetworkFees"]>): ReturnType<Client$1["getNetworkFees"]>;
|
|
@@ -703,6 +705,10 @@ declare class Client {
|
|
|
703
705
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
704
706
|
createArkadeToLightningSwap(...args: Parameters<Client$1["createArkadeToLightningSwap"]>): ReturnType<Client$1["createArkadeToLightningSwap"]>;
|
|
705
707
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
708
|
+
createLightningToBitcoinSwap(...args: Parameters<Client$1["createLightningToBitcoinSwap"]>): ReturnType<Client$1["createLightningToBitcoinSwap"]>;
|
|
709
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
710
|
+
createBitcoinToLightningSwap(...args: Parameters<Client$1["createBitcoinToLightningSwap"]>): ReturnType<Client$1["createBitcoinToLightningSwap"]>;
|
|
711
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
706
712
|
createEvmToLightningSwap(...args: Parameters<Client$1["createEvmToLightningSwap"]>): ReturnType<Client$1["createEvmToLightningSwap"]>;
|
|
707
713
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
708
714
|
createEvmToArkadeSwapGeneric(...args: Parameters<Client$1["createEvmToArkadeSwapGeneric"]>): ReturnType<Client$1["createEvmToArkadeSwapGeneric"]>;
|
|
@@ -715,8 +721,14 @@ declare class Client {
|
|
|
715
721
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
716
722
|
fundSwap(...args: Parameters<Client$1["fundSwap"]>): ReturnType<Client$1["fundSwap"]>;
|
|
717
723
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
724
|
+
fundSwapFromSolana(...args: Parameters<Client$1["fundSwapFromSolana"]>): ReturnType<Client$1["fundSwapFromSolana"]>;
|
|
725
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
726
|
+
getSolanaUsdcBalance(...args: Parameters<Client$1["getSolanaUsdcBalance"]>): ReturnType<Client$1["getSolanaUsdcBalance"]>;
|
|
727
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
718
728
|
refundEvmWithSigner(...args: Parameters<Client$1["refundEvmWithSigner"]>): ReturnType<Client$1["refundEvmWithSigner"]>;
|
|
719
729
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
730
|
+
refundEvmSponsored(...args: Parameters<Client$1["refundEvmSponsored"]>): ReturnType<Client$1["refundEvmSponsored"]>;
|
|
731
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
720
732
|
collabRefundEvmWithSigner(...args: Parameters<Client$1["collabRefundEvmWithSigner"]>): ReturnType<Client$1["collabRefundEvmWithSigner"]>;
|
|
721
733
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
722
734
|
fundSwapGasless(...args: Parameters<Client$1["fundSwapGasless"]>): ReturnType<Client$1["fundSwapGasless"]>;
|
|
@@ -729,6 +741,8 @@ declare class Client {
|
|
|
729
741
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
730
742
|
continueRefundedEvmSwap(...args: Parameters<Client$1["continueRefundedEvmSwap"]>): ReturnType<Client$1["continueRefundedEvmSwap"]>;
|
|
731
743
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
744
|
+
recoverCctpInboundSwap(...args: Parameters<Client$1["recoverCctpInboundSwap"]>): ReturnType<Client$1["recoverCctpInboundSwap"]>;
|
|
745
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
732
746
|
recoverGaslessFunds(...args: Parameters<Client$1["recoverGaslessFunds"]>): ReturnType<Client$1["recoverGaslessFunds"]>;
|
|
733
747
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
734
748
|
hasReceivedVtxo(...args: Parameters<Client$1["hasReceivedVtxo"]>): ReturnType<Client$1["hasReceivedVtxo"]>;
|
|
@@ -847,6 +861,7 @@ declare class ClientBuilder {
|
|
|
847
861
|
withMnemonic(...args: Parameters<ClientBuilder$1["withMnemonic"]>): this;
|
|
848
862
|
withXprv(...args: Parameters<ClientBuilder$1["withXprv"]>): this;
|
|
849
863
|
withAa(...args: Parameters<ClientBuilder$1["withAa"]>): this;
|
|
864
|
+
withSolanaRpcUrl(...args: Parameters<ClientBuilder$1["withSolanaRpcUrl"]>): this;
|
|
850
865
|
withLogger(...args: Parameters<ClientBuilder$1["withLogger"]>): this;
|
|
851
866
|
withLogLevel(...args: Parameters<ClientBuilder$1["withLogLevel"]>): this;
|
|
852
867
|
build(): Promise<Client>;
|
package/dist/index.js
CHANGED
|
@@ -1439,6 +1439,11 @@ var SwapWorker = class {
|
|
|
1439
1439
|
#executing = /* @__PURE__ */ new Set();
|
|
1440
1440
|
/** Swaps with a scheduled auto-claim retry (backoff timer + attempt count). */
|
|
1441
1441
|
#retries = /* @__PURE__ */ new Map();
|
|
1442
|
+
/**
|
|
1443
|
+
* Swaps whose claim needs the user's wallet (RIF Relay): handed to
|
|
1444
|
+
* `onActionRequired` once and not auto-run while the claim is recommended.
|
|
1445
|
+
*/
|
|
1446
|
+
#needsUser = /* @__PURE__ */ new Set();
|
|
1442
1447
|
#unsubs = [];
|
|
1443
1448
|
#started = false;
|
|
1444
1449
|
constructor(options) {
|
|
@@ -1481,6 +1486,7 @@ var SwapWorker = class {
|
|
|
1481
1486
|
this.#hintSource.stop();
|
|
1482
1487
|
for (const { timer } of this.#retries.values()) clearTimeout(timer);
|
|
1483
1488
|
this.#retries.clear();
|
|
1489
|
+
this.#needsUser.clear();
|
|
1484
1490
|
this.#executing.clear();
|
|
1485
1491
|
}
|
|
1486
1492
|
/** Chain-reconcile every tracked swap (the post-outage catch-up sweep). */
|
|
@@ -1503,9 +1509,11 @@ var SwapWorker = class {
|
|
|
1503
1509
|
}
|
|
1504
1510
|
this.#hintSource.subscribe([swapId]);
|
|
1505
1511
|
if (recommended && AUTO_EXECUTABLE.has(recommended) && this.#execute) {
|
|
1512
|
+
if (this.#needsUser.has(swapId)) return;
|
|
1506
1513
|
this.#autoExecute(swapId, actions);
|
|
1507
1514
|
return;
|
|
1508
1515
|
}
|
|
1516
|
+
this.#needsUser.delete(swapId);
|
|
1509
1517
|
this.#cancelRetry(swapId);
|
|
1510
1518
|
if (!recommended) return;
|
|
1511
1519
|
const automation = actions.actions.find(
|
|
@@ -1522,6 +1530,12 @@ var SwapWorker = class {
|
|
|
1522
1530
|
if (!actionId) return;
|
|
1523
1531
|
this.#executing.add(swapId);
|
|
1524
1532
|
void execute(swapId, actionId).then(() => this.#cancelRetry(swapId)).catch((error) => {
|
|
1533
|
+
if (needsWallet(error)) {
|
|
1534
|
+
this.#cancelRetry(swapId);
|
|
1535
|
+
this.#needsUser.add(swapId);
|
|
1536
|
+
this.#onActionRequired?.(swapId, actions);
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1525
1539
|
console.warn(`SwapWorker: ${actionId}(${swapId}) failed:`, error);
|
|
1526
1540
|
this.#scheduleRetry(swapId, actions);
|
|
1527
1541
|
}).finally(() => this.#executing.delete(swapId));
|
|
@@ -1569,6 +1583,9 @@ var SwapWorker = class {
|
|
|
1569
1583
|
if (existing) clearTimeout(existing.timer);
|
|
1570
1584
|
}
|
|
1571
1585
|
};
|
|
1586
|
+
function needsWallet(error) {
|
|
1587
|
+
return error instanceof Error && error.name === "WalletClaimRequiredError";
|
|
1588
|
+
}
|
|
1572
1589
|
|
|
1573
1590
|
// src/hints/ws-status-source.ts
|
|
1574
1591
|
var MAX_ARGS_PER_FRAME = 64;
|
|
@@ -1819,6 +1836,12 @@ function buildArkadeVhtlcRef(input) {
|
|
|
1819
1836
|
|
|
1820
1837
|
// src/tracker/from-swap.ts
|
|
1821
1838
|
var ms = (seconds2) => seconds2 * 1e3;
|
|
1839
|
+
var ONCHAIN_CLAIM_MARGIN_SECONDS = 30 * 60;
|
|
1840
|
+
function onchainClaimDeadline(refundLocktime, network) {
|
|
1841
|
+
const net = network?.toLowerCase();
|
|
1842
|
+
const mainnet = net === "bitcoin" || net === "mainnet";
|
|
1843
|
+
return ms(refundLocktime - (mainnet ? ONCHAIN_CLAIM_MARGIN_SECONDS : 0));
|
|
1844
|
+
}
|
|
1822
1845
|
var MAINNET_LOCKED_TOKEN = {
|
|
1823
1846
|
1: "0x18084fba666a33d37592fa2633fd49a74dd93a88",
|
|
1824
1847
|
// tBTC
|
|
@@ -2093,6 +2116,37 @@ function swapToTracked(stored) {
|
|
|
2093
2116
|
serverRefundLocktime: 0
|
|
2094
2117
|
// no on-chain server leg
|
|
2095
2118
|
};
|
|
2119
|
+
// The user's payment is held off-chain; the server funds the BTC HTLC
|
|
2120
|
+
// the client claims.
|
|
2121
|
+
case "lightning_to_bitcoin":
|
|
2122
|
+
return {
|
|
2123
|
+
swapId: r.id,
|
|
2124
|
+
serverHtlc: bitcoinLeg(
|
|
2125
|
+
r.btc_htlc_address,
|
|
2126
|
+
r.hash_lock,
|
|
2127
|
+
Number(r.target_amount)
|
|
2128
|
+
),
|
|
2129
|
+
clientRefundLocktime: 0,
|
|
2130
|
+
// no on-chain client leg
|
|
2131
|
+
serverRefundLocktime: onchainClaimDeadline(
|
|
2132
|
+
r.btc_refund_locktime,
|
|
2133
|
+
r.network
|
|
2134
|
+
)
|
|
2135
|
+
};
|
|
2136
|
+
// Client funds the BTC HTLC; the server pays the invoice and sweeps it.
|
|
2137
|
+
case "bitcoin_to_lightning":
|
|
2138
|
+
return {
|
|
2139
|
+
swapId: r.id,
|
|
2140
|
+
clientHtlc: bitcoinLeg(
|
|
2141
|
+
r.btc_htlc_address,
|
|
2142
|
+
r.hash_lock,
|
|
2143
|
+
Number(r.source_amount),
|
|
2144
|
+
CLIENT_FUNDING_MIN_CONFIRMATIONS
|
|
2145
|
+
),
|
|
2146
|
+
clientRefundLocktime: ms(r.btc_refund_locktime),
|
|
2147
|
+
serverRefundLocktime: 0
|
|
2148
|
+
// no on-chain server leg
|
|
2149
|
+
};
|
|
2096
2150
|
default:
|
|
2097
2151
|
return void 0;
|
|
2098
2152
|
}
|
|
@@ -2588,6 +2642,10 @@ var Client = class {
|
|
|
2588
2642
|
return this.#legacy.getChainConfig(...args);
|
|
2589
2643
|
}
|
|
2590
2644
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
2645
|
+
getRifRelay(...args) {
|
|
2646
|
+
return this.#legacy.getRifRelay(...args);
|
|
2647
|
+
}
|
|
2648
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2591
2649
|
getReferralFee(...args) {
|
|
2592
2650
|
return this.#legacy.getReferralFee(...args);
|
|
2593
2651
|
}
|
|
@@ -2724,6 +2782,18 @@ var Client = class {
|
|
|
2724
2782
|
);
|
|
2725
2783
|
}
|
|
2726
2784
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
2785
|
+
createLightningToBitcoinSwap(...args) {
|
|
2786
|
+
return this.#trackAfterCreate(
|
|
2787
|
+
this.#legacy.createLightningToBitcoinSwap(...args)
|
|
2788
|
+
);
|
|
2789
|
+
}
|
|
2790
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2791
|
+
createBitcoinToLightningSwap(...args) {
|
|
2792
|
+
return this.#trackAfterCreate(
|
|
2793
|
+
this.#legacy.createBitcoinToLightningSwap(...args)
|
|
2794
|
+
);
|
|
2795
|
+
}
|
|
2796
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2727
2797
|
createEvmToLightningSwap(...args) {
|
|
2728
2798
|
return this.#trackAfterCreate(
|
|
2729
2799
|
this.#legacy.createEvmToLightningSwap(...args)
|
|
@@ -2752,10 +2822,22 @@ var Client = class {
|
|
|
2752
2822
|
return this.#legacy.fundSwap(...args);
|
|
2753
2823
|
}
|
|
2754
2824
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
2825
|
+
fundSwapFromSolana(...args) {
|
|
2826
|
+
return this.#legacy.fundSwapFromSolana(...args);
|
|
2827
|
+
}
|
|
2828
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2829
|
+
getSolanaUsdcBalance(...args) {
|
|
2830
|
+
return this.#legacy.getSolanaUsdcBalance(...args);
|
|
2831
|
+
}
|
|
2832
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2755
2833
|
refundEvmWithSigner(...args) {
|
|
2756
2834
|
return this.#legacy.refundEvmWithSigner(...args);
|
|
2757
2835
|
}
|
|
2758
2836
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
2837
|
+
refundEvmSponsored(...args) {
|
|
2838
|
+
return this.#legacy.refundEvmSponsored(...args);
|
|
2839
|
+
}
|
|
2840
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2759
2841
|
collabRefundEvmWithSigner(...args) {
|
|
2760
2842
|
return this.#legacy.collabRefundEvmWithSigner(...args);
|
|
2761
2843
|
}
|
|
@@ -2780,6 +2862,10 @@ var Client = class {
|
|
|
2780
2862
|
return this.#trackAfterRetry(this.#legacy.continueRefundedEvmSwap(...args));
|
|
2781
2863
|
}
|
|
2782
2864
|
/** Delegated to the legacy client (migration checkpoint). */
|
|
2865
|
+
recoverCctpInboundSwap(...args) {
|
|
2866
|
+
return this.#legacy.recoverCctpInboundSwap(...args);
|
|
2867
|
+
}
|
|
2868
|
+
/** Delegated to the legacy client (migration checkpoint). */
|
|
2783
2869
|
recoverGaslessFunds(...args) {
|
|
2784
2870
|
return this.#legacy.recoverGaslessFunds(...args);
|
|
2785
2871
|
}
|
|
@@ -3208,6 +3294,10 @@ var ClientBuilder = class {
|
|
|
3208
3294
|
this.#inner.withAa(...args);
|
|
3209
3295
|
return this;
|
|
3210
3296
|
}
|
|
3297
|
+
withSolanaRpcUrl(...args) {
|
|
3298
|
+
this.#inner.withSolanaRpcUrl(...args);
|
|
3299
|
+
return this;
|
|
3300
|
+
}
|
|
3211
3301
|
withLogger(...args) {
|
|
3212
3302
|
this.#inner.withLogger(...args);
|
|
3213
3303
|
return this;
|