@atomiqlabs/sdk 8.7.5 → 8.7.7
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/swapper/Swapper.js +6 -0
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +1 -1
- package/package.json +1 -1
- package/src/swapper/Swapper.ts +3 -0
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +1 -1
package/dist/swapper/Swapper.js
CHANGED
|
@@ -606,6 +606,8 @@ class Swapper extends events_1.EventEmitter {
|
|
|
606
606
|
async createFromBTCSwapNew(chainIdentifier, recipient, tokenAddress, amount, exactOut = false, additionalParams = this.options.defaultAdditionalParameters, options) {
|
|
607
607
|
if (this._chains[chainIdentifier] == null)
|
|
608
608
|
throw new Error("Invalid chain identifier! Unknown chain: " + chainIdentifier);
|
|
609
|
+
if (this._chains[chainIdentifier].wrappers[SwapType_1.SwapType.SPV_VAULT_FROM_BTC] == null)
|
|
610
|
+
throw new Error("Chain " + chainIdentifier + " doesn't support new BTC swap protocol (spv vault swaps)!");
|
|
609
611
|
if (!this._chains[chainIdentifier].chainInterface.isValidAddress(recipient, true))
|
|
610
612
|
throw new Error("Invalid " + chainIdentifier + " address");
|
|
611
613
|
recipient = this._chains[chainIdentifier].chainInterface.normalizeAddress(recipient);
|
|
@@ -706,6 +708,8 @@ class Swapper extends events_1.EventEmitter {
|
|
|
706
708
|
async createFromBTCLNSwapNew(chainIdentifier, recipient, tokenAddress, amount, exactOut = false, additionalParams = this.options.defaultAdditionalParameters, options) {
|
|
707
709
|
if (this._chains[chainIdentifier] == null)
|
|
708
710
|
throw new Error("Invalid chain identifier! Unknown chain: " + chainIdentifier);
|
|
711
|
+
if (this._chains[chainIdentifier].wrappers[SwapType_1.SwapType.FROM_BTCLN_AUTO] == null)
|
|
712
|
+
throw new Error("Chain " + chainIdentifier + " doesn't support new lightning swap protocol (from btcln auto)!");
|
|
709
713
|
if (!this._chains[chainIdentifier].chainInterface.isValidAddress(recipient, true))
|
|
710
714
|
throw new Error("Invalid " + chainIdentifier + " address");
|
|
711
715
|
recipient = this._chains[chainIdentifier].chainInterface.normalizeAddress(recipient);
|
|
@@ -732,6 +736,8 @@ class Swapper extends events_1.EventEmitter {
|
|
|
732
736
|
async createFromBTCLNSwapNewViaLNURL(chainIdentifier, recipient, tokenAddress, lnurl, amount, exactOut = false, additionalParams = this.options.defaultAdditionalParameters, options) {
|
|
733
737
|
if (this._chains[chainIdentifier] == null)
|
|
734
738
|
throw new Error("Invalid chain identifier! Unknown chain: " + chainIdentifier);
|
|
739
|
+
if (this._chains[chainIdentifier].wrappers[SwapType_1.SwapType.FROM_BTCLN_AUTO] == null)
|
|
740
|
+
throw new Error("Chain " + chainIdentifier + " doesn't support new lightning swap protocol (from btcln auto)!");
|
|
735
741
|
if (typeof (lnurl) === "string" && !this.Utils.isValidLNURL(lnurl))
|
|
736
742
|
throw new Error("Invalid LNURL-withdraw link");
|
|
737
743
|
if (!this._chains[chainIdentifier].chainInterface.isValidAddress(recipient, true))
|
|
@@ -221,7 +221,7 @@ class FromBTCLNWrapper extends IFromBTCLNWrapper_1.IFromBTCLNWrapper {
|
|
|
221
221
|
if (decodedPr.timeExpireDate == null)
|
|
222
222
|
throw new IntermediaryError_1.IntermediaryError("Invalid returned swap invoice, no expiry date field");
|
|
223
223
|
const amountIn = (BigInt(decodedPr.millisatoshis) + 999n) / 1000n;
|
|
224
|
-
const swapFeeBtc = resp.swapFee * amountIn / (resp.total
|
|
224
|
+
const swapFeeBtc = resp.swapFee * amountIn / (resp.total + resp.swapFee);
|
|
225
225
|
try {
|
|
226
226
|
this.verifyReturnedData(resp, amountData, lp, _options, decodedPr, paymentHash);
|
|
227
227
|
const [pricingInfo] = await Promise.all([
|
|
@@ -335,7 +335,7 @@ class FromBTCWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
|
335
335
|
}, undefined, e => e instanceof RequestError_1.RequestError, abortController.signal);
|
|
336
336
|
const data = new (this._swapDataDeserializer(version))(resp.data);
|
|
337
337
|
data.setClaimer(recipient);
|
|
338
|
-
const swapFeeBtc = resp.swapFee * resp.amount / (data.getAmount()
|
|
338
|
+
const swapFeeBtc = resp.swapFee * resp.amount / (data.getAmount() + resp.swapFee);
|
|
339
339
|
this.verifyReturnedData(recipient, resp, amountData, lp, _options, data, sequence, (await claimerBountyPrefetchPromise[version]), nativeTokenAddress);
|
|
340
340
|
const [pricingInfo, signatureExpiry] = await Promise.all([
|
|
341
341
|
//Get intermediary's liquidity
|
package/package.json
CHANGED
package/src/swapper/Swapper.ts
CHANGED
|
@@ -1108,6 +1108,7 @@ export class Swapper<T extends MultiChain> extends EventEmitter<{
|
|
|
1108
1108
|
options?: SpvFromBTCOptions
|
|
1109
1109
|
): Promise<SpvFromBTCSwap<T[ChainIdentifier]>> {
|
|
1110
1110
|
if(this._chains[chainIdentifier]==null) throw new Error("Invalid chain identifier! Unknown chain: "+chainIdentifier);
|
|
1111
|
+
if(this._chains[chainIdentifier].wrappers[SwapType.SPV_VAULT_FROM_BTC]==null) throw new Error("Chain "+chainIdentifier+" doesn't support new BTC swap protocol (spv vault swaps)!");
|
|
1111
1112
|
if(!this._chains[chainIdentifier].chainInterface.isValidAddress(recipient, true)) throw new Error("Invalid "+chainIdentifier+" address");
|
|
1112
1113
|
recipient = this._chains[chainIdentifier].chainInterface.normalizeAddress(recipient);
|
|
1113
1114
|
const amountData = {
|
|
@@ -1285,6 +1286,7 @@ export class Swapper<T extends MultiChain> extends EventEmitter<{
|
|
|
1285
1286
|
options?: FromBTCLNAutoOptions
|
|
1286
1287
|
): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>> {
|
|
1287
1288
|
if(this._chains[chainIdentifier]==null) throw new Error("Invalid chain identifier! Unknown chain: "+chainIdentifier);
|
|
1289
|
+
if(this._chains[chainIdentifier].wrappers[SwapType.FROM_BTCLN_AUTO]==null) throw new Error("Chain "+chainIdentifier+" doesn't support new lightning swap protocol (from btcln auto)!");
|
|
1288
1290
|
if(!this._chains[chainIdentifier].chainInterface.isValidAddress(recipient, true)) throw new Error("Invalid "+chainIdentifier+" address");
|
|
1289
1291
|
recipient = this._chains[chainIdentifier].chainInterface.normalizeAddress(recipient);
|
|
1290
1292
|
const amountData = {
|
|
@@ -1331,6 +1333,7 @@ export class Swapper<T extends MultiChain> extends EventEmitter<{
|
|
|
1331
1333
|
options?: FromBTCLNAutoOptions
|
|
1332
1334
|
): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>> {
|
|
1333
1335
|
if(this._chains[chainIdentifier]==null) throw new Error("Invalid chain identifier! Unknown chain: "+chainIdentifier);
|
|
1336
|
+
if(this._chains[chainIdentifier].wrappers[SwapType.FROM_BTCLN_AUTO]==null) throw new Error("Chain "+chainIdentifier+" doesn't support new lightning swap protocol (from btcln auto)!");
|
|
1334
1337
|
if(typeof(lnurl)==="string" && !this.Utils.isValidLNURL(lnurl)) throw new Error("Invalid LNURL-withdraw link");
|
|
1335
1338
|
if(!this._chains[chainIdentifier].chainInterface.isValidAddress(recipient, true)) throw new Error("Invalid "+chainIdentifier+" address");
|
|
1336
1339
|
recipient = this._chains[chainIdentifier].chainInterface.normalizeAddress(recipient);
|
|
@@ -342,7 +342,7 @@ export class FromBTCLNWrapper<
|
|
|
342
342
|
if(decodedPr.timeExpireDate==null) throw new IntermediaryError("Invalid returned swap invoice, no expiry date field");
|
|
343
343
|
const amountIn = (BigInt(decodedPr.millisatoshis) + 999n) / 1000n;
|
|
344
344
|
|
|
345
|
-
const swapFeeBtc = resp.swapFee * amountIn / (resp.total
|
|
345
|
+
const swapFeeBtc = resp.swapFee * amountIn / (resp.total + resp.swapFee);
|
|
346
346
|
|
|
347
347
|
try {
|
|
348
348
|
this.verifyReturnedData(resp, amountData, lp, _options, decodedPr, paymentHash);
|
|
@@ -528,7 +528,7 @@ export class FromBTCWrapper<
|
|
|
528
528
|
const data: T["Data"] = new (this._swapDataDeserializer(version))(resp.data);
|
|
529
529
|
data.setClaimer(recipient);
|
|
530
530
|
|
|
531
|
-
const swapFeeBtc = resp.swapFee * resp.amount / (data.getAmount()
|
|
531
|
+
const swapFeeBtc = resp.swapFee * resp.amount / (data.getAmount() + resp.swapFee);
|
|
532
532
|
|
|
533
533
|
this.verifyReturnedData(recipient, resp, amountData, lp, _options, data, sequence, (await claimerBountyPrefetchPromise[version])!, nativeTokenAddress);
|
|
534
534
|
const [pricingInfo, signatureExpiry] = await Promise.all([
|