@riocrypto/common-server 1.0.661 → 1.0.663
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,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getNetworkFees = void 0;
|
|
13
|
+
const fireblocks_client_1 = require("../clients/fireblocks-client");
|
|
14
|
+
const common_1 = require("@riocrypto/common");
|
|
15
|
+
const ccxt_client_1 = require("../clients/ccxt-client");
|
|
16
|
+
const getNetworkFees = (crypto, cryptoPrice, conversionRateToUSD) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
let withdrawFee;
|
|
18
|
+
const fireblocksClient = yield (0, fireblocks_client_1.buildFireblocksClient)();
|
|
19
|
+
if (crypto === common_1.Crypto.USDCPolygon || crypto === common_1.Crypto.USDCSolana) {
|
|
20
|
+
const address = crypto === common_1.Crypto.USDCPolygon
|
|
21
|
+
? "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608"
|
|
22
|
+
: "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH";
|
|
23
|
+
withdrawFee = yield fireblocksClient.estimateWithdrawFee(crypto, address, 100);
|
|
24
|
+
if (!withdrawFee) {
|
|
25
|
+
throw new Error("Withdraw fee not set");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
withdrawFee = yield fireblocksClient.estimateWithdrawFee(crypto, crypto === common_1.Crypto.BTC
|
|
30
|
+
? "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy"
|
|
31
|
+
: "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608", 1);
|
|
32
|
+
if (!withdrawFee) {
|
|
33
|
+
throw new Error("Withdraw fee not set");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let withdrawFeeInBaseCrypto;
|
|
37
|
+
let withdrawFeeInBaseFiat;
|
|
38
|
+
const cryptoAsset = new common_1.CryptoAsset(crypto);
|
|
39
|
+
if (cryptoAsset.getSymbol() !== cryptoAsset.getGasSymbol()) {
|
|
40
|
+
const withdrawFeeUSDResponse = yield ccxt_client_1.ccxtWrapper.getSellQuote(Number(withdrawFee), new common_1.CryptoAsset(crypto).getGasSymbol(), common_1.Fiat.USD);
|
|
41
|
+
if (cryptoAsset.getSymbol().includes("USDC")) {
|
|
42
|
+
withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const withdrawFeeCryptoResponse = yield ccxt_client_1.ccxtWrapper.getBuyQuote(Number(withdrawFeeUSDResponse.amountFiat), crypto, common_1.Fiat.USD);
|
|
46
|
+
withdrawFeeInBaseCrypto = withdrawFeeCryptoResponse.amountCrypto;
|
|
47
|
+
}
|
|
48
|
+
withdrawFeeInBaseFiat =
|
|
49
|
+
Number(withdrawFeeUSDResponse.amountFiat) * (1 / conversionRateToUSD);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
withdrawFeeInBaseCrypto = withdrawFee;
|
|
53
|
+
withdrawFeeInBaseFiat = Number(withdrawFee) * cryptoPrice;
|
|
54
|
+
}
|
|
55
|
+
return { withdrawFeeInBaseFiat, withdrawFeeInBaseCrypto };
|
|
56
|
+
});
|
|
57
|
+
exports.getNetworkFees = getNetworkFees;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -59,3 +59,4 @@ __exportStar(require("./clients/gcloud-storage-client"), exports);
|
|
|
59
59
|
__exportStar(require("./clients/currency-api-client"), exports);
|
|
60
60
|
__exportStar(require("./helpers/get-user-helper"), exports);
|
|
61
61
|
__exportStar(require("./helpers/get-platform-and-partner-fees"), exports);
|
|
62
|
+
__exportStar(require("./helpers/get-network-fees"), exports);
|
package/build/models/partner.js
CHANGED