@shapeshiftoss/swapper 7.3.1 → 7.4.0
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.
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
|
|
2
|
+
import { Asset } from '@shapeshiftoss/types';
|
|
3
|
+
import { QuoteFeeData } from '../../../../../api';
|
|
4
|
+
import { ThorchainSwapperDeps } from '../../../types';
|
|
5
|
+
export declare const getBtcTxFees: ({ deps, opReturnData, vault, buyAsset, sellAmount, adapterManager, pubkey }: {
|
|
6
|
+
deps: ThorchainSwapperDeps;
|
|
7
|
+
opReturnData: string;
|
|
8
|
+
vault: string;
|
|
9
|
+
buyAsset: Asset;
|
|
10
|
+
sellAmount: string;
|
|
11
|
+
adapterManager: ChainAdapterManager;
|
|
12
|
+
pubkey: string;
|
|
13
|
+
}) => Promise<QuoteFeeData<'bip122:000000000019d6689c085ae165831e93'>>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBtcTxFees = void 0;
|
|
4
|
+
const api_1 = require("../../../../../api");
|
|
5
|
+
const bignumber_1 = require("../../../../utils/bignumber");
|
|
6
|
+
const estimateTradeFee_1 = require("../../estimateTradeFee/estimateTradeFee");
|
|
7
|
+
const getBtcTxFees = async ({ deps, opReturnData, vault, buyAsset, sellAmount, adapterManager, pubkey }) => {
|
|
8
|
+
try {
|
|
9
|
+
const adapter = adapterManager.get('bip122:000000000019d6689c085ae165831e93');
|
|
10
|
+
if (!adapter)
|
|
11
|
+
throw new api_1.SwapError(`[getBtcTxFees] - No chain adapter found for ${'bip122:000000000019d6689c085ae165831e93'}.`, {
|
|
12
|
+
code: api_1.SwapErrorTypes.UNSUPPORTED_CHAIN,
|
|
13
|
+
details: { chainId: 'bip122:000000000019d6689c085ae165831e93' }
|
|
14
|
+
});
|
|
15
|
+
const feeDataOptions = await adapter.getFeeData({
|
|
16
|
+
to: vault,
|
|
17
|
+
value: sellAmount,
|
|
18
|
+
chainSpecific: { pubkey, opReturnData }
|
|
19
|
+
});
|
|
20
|
+
const feeData = feeDataOptions['fast'];
|
|
21
|
+
const tradeFee = await (0, estimateTradeFee_1.estimateTradeFee)(deps, buyAsset.assetId);
|
|
22
|
+
return {
|
|
23
|
+
fee: feeData.txFee,
|
|
24
|
+
tradeFee,
|
|
25
|
+
chainSpecific: {
|
|
26
|
+
satsPerByte: feeData.chainSpecific.satoshiPerByte,
|
|
27
|
+
byteCount: (0, bignumber_1.bn)(feeData.txFee)
|
|
28
|
+
.dividedBy(feeData.chainSpecific.satoshiPerByte)
|
|
29
|
+
.dp(0)
|
|
30
|
+
.toString()
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
if (e instanceof api_1.SwapError)
|
|
36
|
+
throw e;
|
|
37
|
+
throw new api_1.SwapError('[getBtcTxFeess]', { cause: e, code: api_1.SwapErrorTypes.TRADE_QUOTE_FAILED });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.getBtcTxFees = getBtcTxFees;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/swapper",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "An interface and implementations to trade coins via various protocols",
|
|
5
5
|
"repository": "https://github.com/shapeshift/lib",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@shapeshiftoss/asset-service": "^5.0.0",
|
|
34
34
|
"@shapeshiftoss/caip": "^6.0.1",
|
|
35
|
-
"@shapeshiftoss/chain-adapters": "^
|
|
35
|
+
"@shapeshiftoss/chain-adapters": "^7.0.3",
|
|
36
36
|
"@shapeshiftoss/errors": "^1.1.1",
|
|
37
37
|
"@shapeshiftoss/hdwallet-core": "^1.23.0",
|
|
38
38
|
"@shapeshiftoss/types": "^5.0.0"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@shapeshiftoss/asset-service": "^5.0.0",
|
|
42
42
|
"@shapeshiftoss/caip": "^6.0.1",
|
|
43
|
-
"@shapeshiftoss/chain-adapters": "^
|
|
43
|
+
"@shapeshiftoss/chain-adapters": "^7.0.3",
|
|
44
44
|
"@shapeshiftoss/errors": "^1.1.1",
|
|
45
45
|
"@shapeshiftoss/hdwallet-core": "^1.23.0",
|
|
46
46
|
"@shapeshiftoss/types": "^5.0.0",
|