@atomiqlabs/sdk-lib
Advanced tools
Comparing version 10.2.6 to 10.2.7
@@ -166,5 +166,7 @@ "use strict"; | ||
getCommitAndClaimFee() { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const commitFee = yield this.wrapper.contract.getCommitFee(this.data, this.feeRate); | ||
const claimFee = yield this.wrapper.contract.getClaimFee(this.getInitiator(), this.data, this.feeRate); | ||
const feeRate = (_a = this.feeRate) !== null && _a !== void 0 ? _a : yield this.wrapper.contract.getInitFeeRate(this.data.getOfferer(), this.data.getClaimer(), this.data.getToken(), this.data.getHash()); | ||
const commitFee = yield this.wrapper.contract.getCommitFee(this.data, feeRate); | ||
const claimFee = yield this.wrapper.contract.getClaimFee(this.getInitiator(), this.data, feeRate); | ||
return commitFee.add(claimFee); | ||
@@ -171,0 +173,0 @@ }); |
@@ -62,3 +62,2 @@ /// <reference types="node" /> | ||
getClaimerBounty(): TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>; | ||
getSmartChainNetworkFee(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>>; | ||
/** | ||
@@ -65,0 +64,0 @@ * Waits till the bitcoin transaction confirms and swap becomes claimable |
@@ -154,7 +154,2 @@ "use strict"; | ||
} | ||
getSmartChainNetworkFee() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return (0, Tokens_1.toTokenAmount)(yield this.getCommitFee(), this.wrapper.getNativeToken(), this.wrapper.prices); | ||
}); | ||
} | ||
////////////////////////////// | ||
@@ -161,0 +156,0 @@ //// Bitcoin tx |
@@ -213,3 +213,3 @@ /// <reference types="node" /> | ||
*/ | ||
abstract getSmartChainNetworkFee?(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>>; | ||
getSmartChainNetworkFee(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>>; | ||
serialize(): any; | ||
@@ -216,0 +216,0 @@ _save(): Promise<void>; |
@@ -20,2 +20,3 @@ "use strict"; | ||
const Utils_1 = require("../utils/Utils"); | ||
const Tokens_1 = require("./Tokens"); | ||
const SwapDirection_1 = require("./SwapDirection"); | ||
@@ -292,2 +293,12 @@ function isISwapInit(obj) { | ||
} | ||
/** | ||
* Returns the transaction fee paid on the smart chain | ||
*/ | ||
getSmartChainNetworkFee() { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const swapContract = this.wrapper.contract; | ||
return (0, Tokens_1.toTokenAmount)(yield ((_a = swapContract.getRawCommitFee) !== null && _a !== void 0 ? _a : swapContract.getCommitFee)(this.data, this.feeRate), this.wrapper.getNativeToken(), this.wrapper.prices); | ||
}); | ||
} | ||
////////////////////////////// | ||
@@ -294,0 +305,0 @@ //// Storage |
@@ -73,3 +73,2 @@ import { IToBTCWrapper } from "./IToBTCWrapper"; | ||
getRefundFee(): Promise<BN>; | ||
getSmartChainNetworkFee(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>>; | ||
/** | ||
@@ -76,0 +75,0 @@ * Commits the swap on-chain, initiating the swap |
@@ -172,7 +172,2 @@ "use strict"; | ||
} | ||
getSmartChainNetworkFee() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return (0, Tokens_1.toTokenAmount)(yield this.getCommitFee(), this.wrapper.getNativeToken(), this.wrapper.prices); | ||
}); | ||
} | ||
////////////////////////////// | ||
@@ -179,0 +174,0 @@ //// Commit |
{ | ||
"name": "@atomiqlabs/sdk-lib", | ||
"version": "10.2.6", | ||
"version": "10.2.7", | ||
"description": "Basic SDK functionality library for atomiq", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -200,4 +200,10 @@ import {decode as bolt11Decode} from "bolt11"; | ||
async getCommitAndClaimFee(): Promise<BN> { | ||
const commitFee = await this.wrapper.contract.getCommitFee(this.data, this.feeRate); | ||
const claimFee = await this.wrapper.contract.getClaimFee(this.getInitiator(), this.data, this.feeRate); | ||
const feeRate = this.feeRate ?? await this.wrapper.contract.getInitFeeRate( | ||
this.data.getOfferer(), | ||
this.data.getClaimer(), | ||
this.data.getToken(), | ||
this.data.getHash() | ||
); | ||
const commitFee = await this.wrapper.contract.getCommitFee(this.data, feeRate); | ||
const claimFee = await this.wrapper.contract.getClaimFee(this.getInitiator(), this.data, feeRate); | ||
return commitFee.add(claimFee); | ||
@@ -204,0 +210,0 @@ } |
@@ -178,6 +178,2 @@ import {IFromBTCSwap} from "../IFromBTCSwap"; | ||
async getSmartChainNetworkFee(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>> { | ||
return toTokenAmount(await this.getCommitFee(), this.wrapper.getNativeToken(), this.wrapper.prices); | ||
} | ||
////////////////////////////// | ||
@@ -184,0 +180,0 @@ //// Bitcoin tx |
@@ -9,3 +9,3 @@ import {SwapType} from "./SwapType"; | ||
import {getLogger, LoggerType, timeoutPromise, tryWithRetries} from "../utils/Utils"; | ||
import {SCToken, Token, TokenAmount} from "./Tokens"; | ||
import {SCToken, Token, TokenAmount, toTokenAmount} from "./Tokens"; | ||
import {SwapDirection} from "./SwapDirection"; | ||
@@ -442,5 +442,11 @@ | ||
*/ | ||
abstract getSmartChainNetworkFee?(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>>; | ||
async getSmartChainNetworkFee(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>> { | ||
const swapContract: T["Contract"] & {getRawCommitFee?: (data: T["Data"], feeRate?: string) => Promise<BN>} = this.wrapper.contract; | ||
return toTokenAmount( | ||
await (swapContract.getRawCommitFee ?? swapContract.getCommitFee)(this.data, this.feeRate), | ||
this.wrapper.getNativeToken(), | ||
this.wrapper.prices | ||
); | ||
} | ||
////////////////////////////// | ||
@@ -447,0 +453,0 @@ //// Storage |
@@ -235,5 +235,2 @@ import {IToBTCWrapper} from "./IToBTCWrapper"; | ||
async getSmartChainNetworkFee(): Promise<TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>> { | ||
return toTokenAmount(await this.getCommitFee(), this.wrapper.getNativeToken(), this.wrapper.prices); | ||
} | ||
@@ -240,0 +237,0 @@ ////////////////////////////// |
1151076
25861