@arkade-os/swap 0.1.7 → 0.1.9
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 +653 -262
- package/dist/advanced.d.cts +9 -8
- package/dist/advanced.d.ts +9 -8
- package/dist/advanced.js +4 -3
- package/dist/{chunk-7BBQ74BG.js → chunk-552GDPBU.js} +484 -128
- package/dist/chunk-5QPJWOCN.js +16 -0
- package/dist/{chunk-QFM55KP2.js → chunk-FQNG4XMF.js} +9 -3
- package/dist/{chunk-SDPNWPGY.js → chunk-I7WEXXZX.js} +27 -16
- package/dist/index.cjs +669 -278
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +4 -3
- package/dist/{lockupContract-CKPFpIt9.d.ts → lockupContract-BUOsghl1.d.ts} +1 -1
- package/dist/{lockupContract-CpJXTjX_.d.cts → lockupContract-DguuT7NK.d.cts} +1 -1
- package/dist/nostr.cjs +290 -17
- package/dist/nostr.d.cts +2 -1
- package/dist/nostr.d.ts +2 -1
- package/dist/nostr.js +2 -1
- package/dist/{offer-Drw1k_jt.d.ts → offer-BhonWuKR.d.ts} +22 -17
- package/dist/{offer-Boxive2u.d.cts → offer-D_qHpWo2.d.cts} +22 -17
- package/dist/{offerFillPlan-BxNkWLtw.d.cts → offerFillPlan-Bp6-z6dS.d.cts} +3 -3
- package/dist/{offerFillPlan-D2N4s7Xe.d.ts → offerFillPlan-_AOLo6kh.d.ts} +3 -3
- package/dist/protocol.cjs +594 -198
- package/dist/protocol.d.cts +9 -8
- package/dist/protocol.d.ts +9 -8
- package/dist/protocol.js +14 -2
- package/dist/repositories/realm/index.d.cts +3 -2
- package/dist/repositories/realm/index.d.ts +3 -2
- package/dist/repositories/sqlite/index.d.cts +3 -2
- package/dist/repositories/sqlite/index.d.ts +3 -2
- package/dist/{repository-DFDNvcZ7.d.cts → repository--pfikw2R.d.cts} +1 -1
- package/dist/{repository-Dn1V17T2.d.ts → repository-CkKK0dGO.d.ts} +1 -1
- package/dist/{rfq-CP-P0PSL.d.ts → rfq-BRpo5uWU.d.cts} +14 -2
- package/dist/{rfq-CP-P0PSL.d.cts → rfq-IzhOCG02.d.ts} +14 -2
- package/dist/rfq-contract.cjs +45 -0
- package/dist/rfq-contract.d.cts +9 -0
- package/dist/rfq-contract.d.ts +9 -0
- package/dist/rfq-contract.js +16 -0
- package/dist/{watch-D-mc_wfD.d.ts → watch-DDNycuUa.d.ts} +1 -1
- package/dist/{watch-DFNMY2K-.d.cts → watch-pvTVFp6-.d.cts} +1 -1
- package/package.json +13 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/rfq-contract.ts
|
|
2
|
+
var RFQ_CONTRACT_VERSIONS_KEY = "contract_versions";
|
|
3
|
+
var RFQ_CONTRACT_VERSION_KEY = "contract_version";
|
|
4
|
+
var RFQ_CONTRACT_VERSION_UNSUPPORTED = "contract_version_unsupported";
|
|
5
|
+
var ASSET_SWAP_V2 = "asset-swap-v2";
|
|
6
|
+
var ASSET_SWAP_V3 = "asset-swap-v3";
|
|
7
|
+
var ASSET_SWAP_BASELINE = ASSET_SWAP_V2;
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
RFQ_CONTRACT_VERSIONS_KEY,
|
|
11
|
+
RFQ_CONTRACT_VERSION_KEY,
|
|
12
|
+
RFQ_CONTRACT_VERSION_UNSUPPORTED,
|
|
13
|
+
ASSET_SWAP_V2,
|
|
14
|
+
ASSET_SWAP_V3,
|
|
15
|
+
ASSET_SWAP_BASELINE
|
|
16
|
+
};
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
rfqCorridorHandlers,
|
|
25
25
|
rfqSignerOf,
|
|
26
26
|
updateAssetSwapBestEffort
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-552GDPBU.js";
|
|
28
28
|
import {
|
|
29
29
|
collectRfqSwaps
|
|
30
30
|
} from "./chunk-A3SHHRX4.js";
|
|
@@ -1932,6 +1932,9 @@ async function pushClaim(operator, input) {
|
|
|
1932
1932
|
assertFiniteAmount(funded, "lockup_malformed", "the lockup's summed value");
|
|
1933
1933
|
if (!input.partiallyClaimed) {
|
|
1934
1934
|
assertFiniteAmount(input.expectedAmount, "invalid_gate_input", "expectedAmount");
|
|
1935
|
+
if (input.expectedAmount <= 0) {
|
|
1936
|
+
throw gateError("invalid_gate_input", "expectedAmount is not positive");
|
|
1937
|
+
}
|
|
1935
1938
|
if (funded < input.expectedAmount) {
|
|
1936
1939
|
throw new LockupAmountMismatchError(input.expectedAmount, funded);
|
|
1937
1940
|
}
|
|
@@ -2882,10 +2885,10 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
2882
2885
|
return;
|
|
2883
2886
|
}
|
|
2884
2887
|
if (!partiallyClaimed) {
|
|
2885
|
-
if (!Number.
|
|
2888
|
+
if (!Number.isSafeInteger(swap.expectedAmount) || swap.expectedAmount <= 0) {
|
|
2886
2889
|
return this.block(
|
|
2887
2890
|
swap,
|
|
2888
|
-
`expectedAmount is not a
|
|
2891
|
+
`expectedAmount is not a positive number of sats (${String(swap.expectedAmount)}), so the funded value cannot be checked \u2014 refusing to publish the preimage`
|
|
2889
2892
|
);
|
|
2890
2893
|
}
|
|
2891
2894
|
const locked = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
@@ -3146,6 +3149,9 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
3146
3149
|
utxo,
|
|
3147
3150
|
bump ? { bump } : void 0
|
|
3148
3151
|
);
|
|
3152
|
+
if (swap.funding?.txid !== utxo.txid || swap.funding.vout !== utxo.vout || swap.funding.amount === void 0) {
|
|
3153
|
+
swap.funding = { txid: utxo.txid, vout: utxo.vout, amount: Number(utxo.amount) };
|
|
3154
|
+
}
|
|
3149
3155
|
swap.claimTxid = txid;
|
|
3150
3156
|
swap.claimBroadcastAt = this.config.now();
|
|
3151
3157
|
delete swap.claimConfirmed;
|
|
@@ -62,10 +62,11 @@ import {
|
|
|
62
62
|
undeliveredCarry,
|
|
63
63
|
walletOperator,
|
|
64
64
|
watchOfferSwaps
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-FQNG4XMF.js";
|
|
66
66
|
import {
|
|
67
67
|
ARKADE_BTC,
|
|
68
68
|
ASSET_CARRIER_SATS,
|
|
69
|
+
ASSET_SWAP_CONTRACT_VERSIONS,
|
|
69
70
|
AddressMismatch,
|
|
70
71
|
BTC_ASSET_ID,
|
|
71
72
|
L1_NETWORKS,
|
|
@@ -98,6 +99,7 @@ import {
|
|
|
98
99
|
deriveOnchainSend,
|
|
99
100
|
l1NetworkFromArk,
|
|
100
101
|
l1ScriptForAddress,
|
|
102
|
+
legacySwapPrograms,
|
|
101
103
|
lightningReceiveRequest,
|
|
102
104
|
lightningSendRequest,
|
|
103
105
|
lockupContractParams,
|
|
@@ -112,6 +114,7 @@ import {
|
|
|
112
114
|
quoteCarrierSats,
|
|
113
115
|
registerDerivedOffer,
|
|
114
116
|
registerLockupContract,
|
|
117
|
+
requestVersionedQuote,
|
|
115
118
|
resolveDeposit,
|
|
116
119
|
resolveReceivePkScript,
|
|
117
120
|
restoreOfferCoverage,
|
|
@@ -123,11 +126,10 @@ import {
|
|
|
123
126
|
rfqSecretsProfile,
|
|
124
127
|
rfqSignerOf,
|
|
125
128
|
sealClaimPacket,
|
|
126
|
-
swapPrograms,
|
|
127
129
|
unilateralClaimDelay,
|
|
128
130
|
verifyOfferAddress,
|
|
129
131
|
withExitClosure
|
|
130
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-552GDPBU.js";
|
|
131
133
|
import {
|
|
132
134
|
assertRfqSwapPageFilter,
|
|
133
135
|
collectAssetSwaps,
|
|
@@ -1974,8 +1976,8 @@ function withExitV0(program, exit) {
|
|
|
1974
1976
|
}
|
|
1975
1977
|
var V0_TO_V1 = /* @__PURE__ */ new Map();
|
|
1976
1978
|
for (const [v0, v1] of [
|
|
1977
|
-
[swap_want_btc_program_v0_default,
|
|
1978
|
-
[swap_want_asset_program_v0_default,
|
|
1979
|
+
[swap_want_btc_program_v0_default, legacySwapPrograms.wantBtc],
|
|
1980
|
+
[swap_want_asset_program_v0_default, legacySwapPrograms.wantAsset]
|
|
1979
1981
|
]) {
|
|
1980
1982
|
for (const exit of [void 0, "blocks", "seconds"]) {
|
|
1981
1983
|
const timelock = exit && { type: exit, value: BigInt(0) };
|
|
@@ -3806,7 +3808,6 @@ var quoteArkadeAsset = async (input) => {
|
|
|
3806
3808
|
);
|
|
3807
3809
|
}
|
|
3808
3810
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
3809
|
-
const rfqId = newRfqId();
|
|
3810
3811
|
const maker = await makerPosition(input.wallet);
|
|
3811
3812
|
const receiveAddress = payment?.receiveAddress;
|
|
3812
3813
|
const receivePkScript = resolveReceivePkScript(
|
|
@@ -3831,20 +3832,29 @@ var quoteArkadeAsset = async (input) => {
|
|
|
3831
3832
|
throw new Error("carrier quote expired before RFQ");
|
|
3832
3833
|
}
|
|
3833
3834
|
const request = arkadeSwapRequest({
|
|
3834
|
-
rfqId,
|
|
3835
|
+
rfqId: newRfqId(),
|
|
3835
3836
|
...sides,
|
|
3836
3837
|
amount: pinned.value,
|
|
3837
3838
|
amountSide: toRfqAmountSide(pinned.on),
|
|
3838
3839
|
makerPkScript: receivePkScript,
|
|
3839
|
-
makerPublicKey: maker.publicKey
|
|
3840
|
-
|
|
3841
|
-
const wire = await input.transport.requestQuote({
|
|
3842
|
-
...request,
|
|
3843
|
-
profile: {
|
|
3844
|
-
...request.profile,
|
|
3845
|
-
...carrierRequest === void 0 ? {} : { carrier: encodeCarrierRequest(carrierRequest) }
|
|
3846
|
-
}
|
|
3840
|
+
makerPublicKey: maker.publicKey,
|
|
3841
|
+
contractVersions: ASSET_SWAP_CONTRACT_VERSIONS
|
|
3847
3842
|
});
|
|
3843
|
+
const {
|
|
3844
|
+
quote: wire,
|
|
3845
|
+
rfqId,
|
|
3846
|
+
contractVersion
|
|
3847
|
+
} = await requestVersionedQuote(
|
|
3848
|
+
input.transport,
|
|
3849
|
+
{
|
|
3850
|
+
...request,
|
|
3851
|
+
profile: {
|
|
3852
|
+
...request.profile,
|
|
3853
|
+
...carrierRequest === void 0 ? {} : { carrier: encodeCarrierRequest(carrierRequest) }
|
|
3854
|
+
}
|
|
3855
|
+
},
|
|
3856
|
+
ASSET_SWAP_CONTRACT_VERSIONS
|
|
3857
|
+
);
|
|
3848
3858
|
verifyPair(wire.pair, pair);
|
|
3849
3859
|
const parsed = parseRfqQuote(wire);
|
|
3850
3860
|
verifyCrossAssetAmount({ pair, pinned, give: parsed.give, take: parsed.take });
|
|
@@ -3905,7 +3915,8 @@ var quoteArkadeAsset = async (input) => {
|
|
|
3905
3915
|
emulatorPubkey: input.corridors.get("arkade").deps.emulatorPubkey,
|
|
3906
3916
|
maker,
|
|
3907
3917
|
...receiveAddress === void 0 ? {} : { receiveAddress },
|
|
3908
|
-
info: input.info
|
|
3918
|
+
info: input.info,
|
|
3919
|
+
contractVersion
|
|
3909
3920
|
});
|
|
3910
3921
|
verifyingDerivation(() => verifyOfferAddress(wire, offer));
|
|
3911
3922
|
return {
|