@arkade-os/swap 0.1.0-rc.26 → 0.1.0-rc.27
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 +199 -49
- package/dist/advanced.d.cts +8 -8
- package/dist/advanced.d.ts +8 -8
- package/dist/advanced.js +3 -3
- package/dist/{chunk-DHFKCTER.js → chunk-4X56MN56.js} +11 -2
- package/dist/{chunk-6O3L4AVI.js → chunk-BWUC2LDD.js} +28 -6
- package/dist/{chunk-XBMWEK43.js → chunk-VFZJNU27.js} +170 -120
- package/dist/index.cjs +199 -49
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -3
- package/dist/{lockupContract-BTCE7g83.d.ts → lockupContract-CAjvaCVw.d.ts} +1 -1
- package/dist/{lockupContract-BTCGwjRH.d.cts → lockupContract-DZaNiqP-.d.cts} +1 -1
- package/dist/node/index.d.cts +9 -3
- package/dist/node/index.d.ts +9 -3
- package/dist/nostr.cjs +1 -0
- package/dist/nostr.d.cts +1 -1
- package/dist/nostr.d.ts +1 -1
- package/dist/nostr.js +1 -1
- package/dist/{offer-CsXgroM0.d.cts → offer-BwUhEawd.d.cts} +1 -1
- package/dist/{offer-DYCiKDm6.d.ts → offer-v7vBCPmQ.d.ts} +1 -1
- package/dist/{offerFillPlan-BQnzburi.d.ts → offerFillPlan-BGeAXIna.d.ts} +3 -3
- package/dist/{offerFillPlan-CFT8qgTV.d.cts → offerFillPlan-BYw1EWEj.d.cts} +3 -3
- package/dist/protocol.cjs +173 -118
- package/dist/protocol.d.cts +25 -39
- package/dist/protocol.d.ts +25 -39
- package/dist/protocol.js +8 -8
- 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-CSJXRd5N.d.ts → repository-D2emdY6f.d.cts} +51 -98
- package/dist/{repository-Bgn0apiL.d.cts → repository-YEQaxJro.d.ts} +51 -98
- package/dist/{rfq-m9tCbQx7.d.cts → rfq-CRiAHBBH.d.cts} +14 -2
- package/dist/{rfq-m9tCbQx7.d.ts → rfq-CRiAHBBH.d.ts} +14 -2
- package/dist/{watch-CLJXFpMq.d.cts → watch-BwbZkceT.d.cts} +1 -1
- package/dist/{watch-D0R7YhYg.d.ts → watch-CjEsO0Qh.d.ts} +1 -1
- package/package.json +2 -2
|
@@ -1323,6 +1323,7 @@ import * as btc from "@scure/btc-signer";
|
|
|
1323
1323
|
import { assertTimerMs } from "@arkade-os/sdk";
|
|
1324
1324
|
var ONCHAIN_ORDER_MARGIN_SECONDS = 2 * 60 * 60;
|
|
1325
1325
|
var ONCHAIN_CLAIM_MARGIN_SECONDS = 90 * 60;
|
|
1326
|
+
var ONCHAIN_CLAIM_BUMP_SECONDS = 20 * 60;
|
|
1326
1327
|
var MAX_MIN_CONFIRMATIONS = 6;
|
|
1327
1328
|
var LOCKTIME_THRESHOLD = 5e8;
|
|
1328
1329
|
var ONCHAIN_SECONDS_PER_BLOCK = 600;
|
|
@@ -1495,6 +1496,13 @@ var buildHtlcRefund = (input) => buildLeafSpend({
|
|
|
1495
1496
|
// any value below 0xffffffff enables nLockTime enforcement
|
|
1496
1497
|
sequence: 4294967294
|
|
1497
1498
|
});
|
|
1499
|
+
function nextClaimFeeRate(input) {
|
|
1500
|
+
const last = input.lastSatVb;
|
|
1501
|
+
const estimate = Number.isFinite(input.estimateSatVb) ? input.estimateSatVb : 0;
|
|
1502
|
+
const wanted = last === void 0 ? Math.max(input.configuredSatVb, estimate) : input.bump ? Math.max(Math.ceil(last * 1.5), last + 1, estimate) : Math.max(last, estimate);
|
|
1503
|
+
const affordable = Number((input.utxoAmount - ONCHAIN_DUST_SATS) / BigInt(ONCHAIN_CLAIM_VSIZE));
|
|
1504
|
+
return Math.max(last ?? input.configuredSatVb, Math.min(wanted, affordable));
|
|
1505
|
+
}
|
|
1498
1506
|
function extractPreimage(txHex, paymentHash) {
|
|
1499
1507
|
let raw;
|
|
1500
1508
|
try {
|
|
@@ -1522,7 +1530,7 @@ async function awaitOnchainFill(chain, htlc, minConfirmations, options = {}) {
|
|
|
1522
1530
|
}
|
|
1523
1531
|
async function claimOnchainFill(chain, input) {
|
|
1524
1532
|
const now = input.now ?? Math.floor(Date.now() / 1e3);
|
|
1525
|
-
if (input.htlc.refundLocktime - now < ONCHAIN_CLAIM_MARGIN_SECONDS) {
|
|
1533
|
+
if (!input.republish && input.htlc.refundLocktime - now < ONCHAIN_CLAIM_MARGIN_SECONDS) {
|
|
1526
1534
|
throw gateError(
|
|
1527
1535
|
"claim_window_closed",
|
|
1528
1536
|
"refund leaf opens too soon to claim safely \u2014 take the covenant refund instead"
|
|
@@ -2932,6 +2940,7 @@ export {
|
|
|
2932
2940
|
lockupContractParams,
|
|
2933
2941
|
ONCHAIN_ORDER_MARGIN_SECONDS,
|
|
2934
2942
|
ONCHAIN_CLAIM_MARGIN_SECONDS,
|
|
2943
|
+
ONCHAIN_CLAIM_BUMP_SECONDS,
|
|
2935
2944
|
MAX_MIN_CONFIRMATIONS,
|
|
2936
2945
|
LOCKTIME_THRESHOLD,
|
|
2937
2946
|
ONCHAIN_SECONDS_PER_BLOCK,
|
|
@@ -2941,13 +2950,13 @@ export {
|
|
|
2941
2950
|
paymentHashOf,
|
|
2942
2951
|
assertPreimageMatches,
|
|
2943
2952
|
gateError,
|
|
2944
|
-
sleep,
|
|
2945
2953
|
pollUntil,
|
|
2946
2954
|
L1_NETWORKS,
|
|
2947
2955
|
l1ScriptForAddress,
|
|
2948
2956
|
onchainHtlcScript,
|
|
2949
2957
|
buildHtlcClaim,
|
|
2950
2958
|
buildHtlcRefund,
|
|
2959
|
+
nextClaimFeeRate,
|
|
2951
2960
|
extractPreimage,
|
|
2952
2961
|
awaitOnchainFill,
|
|
2953
2962
|
claimOnchainFill,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
undeliveredCarry,
|
|
58
58
|
walletOperator,
|
|
59
59
|
watchOfferSwaps
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-VFZJNU27.js";
|
|
61
61
|
import {
|
|
62
62
|
ARKADE_BTC,
|
|
63
63
|
ASSET_CARRIER_SATS,
|
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
lightningSendRequest,
|
|
96
96
|
lockupContractParams,
|
|
97
97
|
newRfqId,
|
|
98
|
+
nextClaimFeeRate,
|
|
98
99
|
offerTermsFromQuote,
|
|
99
100
|
onchainReceiveRequest,
|
|
100
101
|
onchainSendRequest,
|
|
@@ -117,7 +118,7 @@ import {
|
|
|
117
118
|
sealClaimPacket,
|
|
118
119
|
unilateralClaimDelay,
|
|
119
120
|
verifyOfferAddress
|
|
120
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-4X56MN56.js";
|
|
121
122
|
import {
|
|
122
123
|
assertRfqSwapPageFilter,
|
|
123
124
|
collectAssetSwaps,
|
|
@@ -1126,6 +1127,12 @@ var chainSourceOver = (backend, network) => {
|
|
|
1126
1127
|
},
|
|
1127
1128
|
async getMtp() {
|
|
1128
1129
|
return (await backend.tip()).mtp;
|
|
1130
|
+
},
|
|
1131
|
+
async getTxStatus(txid) {
|
|
1132
|
+
return (await backend.provider.getTxStatus(txid)).confirmed ? "confirmed" : "unconfirmed";
|
|
1133
|
+
},
|
|
1134
|
+
getFeeRate() {
|
|
1135
|
+
return backend.provider.getFeeRate();
|
|
1129
1136
|
}
|
|
1130
1137
|
};
|
|
1131
1138
|
};
|
|
@@ -2108,8 +2115,15 @@ var createSwapDrive = (config) => {
|
|
|
2108
2115
|
touch(swap.rfqId, swap);
|
|
2109
2116
|
});
|
|
2110
2117
|
let onchainSeams;
|
|
2118
|
+
const liveFeeRate = async (chain) => {
|
|
2119
|
+
try {
|
|
2120
|
+
return await chain.getFeeRate?.();
|
|
2121
|
+
} catch {
|
|
2122
|
+
return void 0;
|
|
2123
|
+
}
|
|
2124
|
+
};
|
|
2111
2125
|
const defaultOnchainClaim = (chain, feeRateSatVb) => {
|
|
2112
|
-
return async (swap, utxo) => {
|
|
2126
|
+
return async (swap, utxo, options) => {
|
|
2113
2127
|
const record = await corridorStore().getRfqSwap(swap.rfqId);
|
|
2114
2128
|
if (!record) {
|
|
2115
2129
|
throw new Error(`rfq swap ${swap.rfqId} has no stored record to claim from`);
|
|
@@ -2130,17 +2144,25 @@ var createSwapDrive = (config) => {
|
|
|
2130
2144
|
if (!swap.payoutPkScript) {
|
|
2131
2145
|
throw new Error(`rfq swap ${swap.rfqId} carries no claim payout script`);
|
|
2132
2146
|
}
|
|
2147
|
+
const rate = nextClaimFeeRate({
|
|
2148
|
+
configuredSatVb: feeRateSatVb,
|
|
2149
|
+
utxoAmount: utxo.amount,
|
|
2150
|
+
estimateSatVb: await liveFeeRate(chain),
|
|
2151
|
+
...swap.claimFeeRateSatVb === void 0 ? {} : { lastSatVb: swap.claimFeeRateSatVb },
|
|
2152
|
+
...options?.bump ? { bump: true } : {}
|
|
2153
|
+
});
|
|
2133
2154
|
const { txid } = await track(
|
|
2134
2155
|
claimOnchainFill(chain, {
|
|
2135
2156
|
htlc: swap.htlc,
|
|
2136
2157
|
utxo,
|
|
2137
2158
|
preimage,
|
|
2138
2159
|
payoutPkScript: swap.payoutPkScript,
|
|
2139
|
-
feeRateSatVb,
|
|
2140
|
-
sign: (sighash) => signer.signMessage(sighash, "schnorr")
|
|
2160
|
+
feeRateSatVb: rate,
|
|
2161
|
+
sign: (sighash) => signer.signMessage(sighash, "schnorr"),
|
|
2162
|
+
...swap.claimTxid ? { republish: true } : {}
|
|
2141
2163
|
})
|
|
2142
2164
|
);
|
|
2143
|
-
return { txid };
|
|
2165
|
+
return { txid, feeRateSatVb: rate };
|
|
2144
2166
|
};
|
|
2145
2167
|
};
|
|
2146
2168
|
const defaultOnchainRefund = (chain, feeRateSatVb) => {
|