@riocrypto/common-server 1.0.812 → 1.0.814
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Crypto } from "@riocrypto/common";
|
|
2
|
-
export declare const getNetworkFees: (crypto: Crypto,
|
|
2
|
+
export declare const getNetworkFees: (crypto: Crypto, conversionRateToUSD: number) => Promise<{
|
|
3
3
|
withdrawFeeInBaseFiat: number;
|
|
4
|
-
withdrawFeeInBaseCrypto:
|
|
4
|
+
withdrawFeeInBaseCrypto: number | undefined;
|
|
5
5
|
}>;
|
|
@@ -13,51 +13,18 @@ exports.getNetworkFees = void 0;
|
|
|
13
13
|
const fireblocks_client_1 = require("../clients/fireblocks-client");
|
|
14
14
|
const common_1 = require("@riocrypto/common");
|
|
15
15
|
const ccxt_client_1 = require("../clients/ccxt-client");
|
|
16
|
-
const getNetworkFees = (crypto,
|
|
17
|
-
|
|
16
|
+
const getNetworkFees = (crypto, conversionRateToUSD) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const address = crypto === common_1.Crypto.USDCSolana
|
|
18
|
+
? "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH"
|
|
19
|
+
: "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
|
|
18
20
|
const fireblocksClient = yield (0, fireblocks_client_1.buildFireblocksClient)();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
common_1.Crypto.USDTPolygon,
|
|
23
|
-
common_1.Crypto.USDTEthereum,
|
|
24
|
-
common_1.Crypto.USDTEthereum,
|
|
25
|
-
].includes(crypto)) {
|
|
26
|
-
const address = crypto === common_1.Crypto.USDCSolana
|
|
27
|
-
? "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH"
|
|
28
|
-
: "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
|
|
29
|
-
withdrawFee = yield fireblocksClient.estimateWithdrawFee(crypto, address, 100);
|
|
30
|
-
if (!withdrawFee) {
|
|
31
|
-
throw new Error("Withdraw fee not set");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
withdrawFee = yield fireblocksClient.estimateWithdrawFee(crypto, crypto === common_1.Crypto.BTC
|
|
36
|
-
? "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy"
|
|
37
|
-
: "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608", 1);
|
|
38
|
-
if (!withdrawFee) {
|
|
39
|
-
throw new Error("Withdraw fee not set");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let withdrawFeeInBaseCrypto;
|
|
43
|
-
let withdrawFeeInBaseFiat;
|
|
44
|
-
const cryptoAsset = new common_1.CryptoAsset(crypto);
|
|
45
|
-
if (cryptoAsset.getSymbol() !== cryptoAsset.getGasSymbol()) {
|
|
46
|
-
const withdrawFeeUSDResponse = yield ccxt_client_1.ccxtWrapper.getSellQuote(new common_1.CryptoAsset(crypto).getGasSymbol(), common_1.Fiat.USD, undefined, Number(withdrawFee));
|
|
47
|
-
if (cryptoAsset.getSymbol().includes("USDC")) {
|
|
48
|
-
withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
const withdrawFeeCryptoResponse = yield ccxt_client_1.ccxtWrapper.getBuyQuote(crypto, common_1.Fiat.USD, Number(withdrawFeeUSDResponse.amountFiat), undefined);
|
|
52
|
-
withdrawFeeInBaseCrypto = withdrawFeeCryptoResponse.amountCrypto;
|
|
53
|
-
}
|
|
54
|
-
withdrawFeeInBaseFiat =
|
|
55
|
-
Number(withdrawFeeUSDResponse.amountFiat) * (1 / conversionRateToUSD);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
withdrawFeeInBaseCrypto = withdrawFee;
|
|
59
|
-
withdrawFeeInBaseFiat = Number(withdrawFee) * cryptoPrice;
|
|
21
|
+
const withdrawFee = yield fireblocksClient.estimateWithdrawFee(crypto, address, 100);
|
|
22
|
+
if (!withdrawFee) {
|
|
23
|
+
throw new Error("Withdraw fee not set");
|
|
60
24
|
}
|
|
25
|
+
const withdrawFeeUSDResponse = yield ccxt_client_1.ccxtWrapper.getSellQuote(new common_1.CryptoAsset(crypto).getGasSymbol(), common_1.Fiat.USD, undefined, Number(withdrawFee));
|
|
26
|
+
const withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
|
|
27
|
+
const withdrawFeeInBaseFiat = Number(withdrawFeeUSDResponse.amountFiat) * (1 / conversionRateToUSD);
|
|
61
28
|
return { withdrawFeeInBaseFiat, withdrawFeeInBaseCrypto };
|
|
62
29
|
});
|
|
63
30
|
exports.getNetworkFees = getNetworkFees;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.814",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@aws-sdk/client-s3": "^3.297.0",
|
|
25
25
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
26
26
|
"@google-cloud/storage": "^6.9.5",
|
|
27
|
-
"@riocrypto/common": "^1.0.
|
|
27
|
+
"@riocrypto/common": "^1.0.702",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|