@riocrypto/common-server 1.0.1304 → 1.0.1306

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.
@@ -3,7 +3,7 @@ import { Crypto } from "@riocrypto/common";
3
3
  declare class FireblocksClient {
4
4
  fireblocks: FireblocksSDK;
5
5
  constructor(privateKey: string, apiKey: string);
6
- estimateWithdrawFee(crypto: Crypto, address: string, amountCrypto: number): Promise<number | undefined>;
6
+ estimateWithdrawFee(crypto: Crypto, address: string, amountCrypto: number): Promise<string | number | undefined>;
7
7
  withdrawFromExchange(crypto: Crypto, address: string, amountCrypto: number): Promise<void>;
8
8
  withdrawFromVault(crypto: Crypto, address: string, amountCrypto: number): Promise<string>;
9
9
  getVaultCryptoBalance(vaultId: string, crypto: Crypto): Promise<number>;
@@ -47,7 +47,7 @@ class FireblocksClient {
47
47
  amount: amountCrypto,
48
48
  operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
49
49
  });
50
- let fee = estimate.medium.networkFee;
50
+ fee = estimate.medium.networkFee;
51
51
  console.log("fee", fee);
52
52
  cache.set(`estimateWithdrawFee(${crypto}, ${address}, ${amountCrypto})`, fee);
53
53
  }
@@ -1,5 +1,4 @@
1
1
  import { Crypto } from "@riocrypto/common";
2
2
  export declare const getNetworkFees: (crypto: Crypto, conversionRateToUSD: number) => Promise<{
3
3
  withdrawFeeInBaseFiat: number;
4
- withdrawFeeInBaseCrypto: number | undefined;
5
4
  }>;
@@ -11,27 +11,56 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getNetworkFees = void 0;
13
13
  const common_1 = require("@riocrypto/common");
14
- const ccxt_client_1 = require("../clients/ccxt-client");
15
- const fireblocks_client_1 = require("../clients/fireblocks-client");
16
14
  const getNetworkFees = (crypto, conversionRateToUSD) => __awaiter(void 0, void 0, void 0, function* () {
17
- const address = crypto === common_1.Crypto.USDCSolana
18
- ? "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH"
19
- : "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
20
- const fireblocksClient = yield (0, fireblocks_client_1.buildFireblocksClient)();
21
- // Hacky way bc ccxt doesn't support TRON, so quote in MATIC
22
- const cryptoToWithdraw = crypto === common_1.Crypto.USDTTron ? common_1.Crypto.USDCPolygon : crypto;
23
- const withdrawFee = yield fireblocksClient.estimateWithdrawFee(cryptoToWithdraw, address, 100);
24
- if (!withdrawFee) {
25
- console.log("No withdraw fee");
26
- throw new common_1.GenericInternalError();
15
+ // const address =
16
+ // crypto === Crypto.USDCSolana
17
+ // ? "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH"
18
+ // : "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
19
+ // const fireblocksClient = await buildFireblocksClient();
20
+ // // Hacky way bc ccxt doesn't support TRON, so quote in MATIC
21
+ // const cryptoToWithdraw =
22
+ // crypto === Crypto.USDTTron ? Crypto.USDCPolygon : crypto;
23
+ // const withdrawFee = await fireblocksClient.estimateWithdrawFee(
24
+ // cryptoToWithdraw,
25
+ // address,
26
+ // 100
27
+ // );
28
+ // if (!withdrawFee) {
29
+ // console.log("No withdraw fee");
30
+ // throw new GenericInternalError();
31
+ // }
32
+ // // Hacky way bc ccxt doesn't support TRON, so quote in MATIC
33
+ // const gasSymbol =
34
+ // crypto === Crypto.USDTTron
35
+ // ? "MATIC"
36
+ // : new CryptoAsset(crypto).getGasSymbol();
37
+ // const withdrawFeeUSDResponse = await ccxtWrapper.getSellQuote(
38
+ // gasSymbol as Crypto,
39
+ // Fiat.USD,
40
+ // undefined,
41
+ // Number(withdrawFee)
42
+ // );
43
+ // const withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
44
+ // const withdrawFeeInBaseFiat =
45
+ // Number(withdrawFeeUSDResponse.amountFiat) * (1 / conversionRateToUSD);
46
+ let withdrawFeeInUSD = 0;
47
+ if (crypto === common_1.Crypto.USDTTron) {
48
+ withdrawFeeInUSD = 3;
27
49
  }
28
- // Hacky way bc ccxt doesn't support TRON, so quote in MATIC
29
- const gasSymbol = crypto === common_1.Crypto.USDTTron
30
- ? "MATIC"
31
- : new common_1.CryptoAsset(crypto).getGasSymbol();
32
- const withdrawFeeUSDResponse = yield ccxt_client_1.ccxtWrapper.getSellQuote(gasSymbol, common_1.Fiat.USD, undefined, Number(withdrawFee));
33
- const withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
34
- const withdrawFeeInBaseFiat = Number(withdrawFeeUSDResponse.amountFiat) * (1 / conversionRateToUSD);
35
- return { withdrawFeeInBaseFiat, withdrawFeeInBaseCrypto };
50
+ else if (crypto === common_1.Crypto.USDCSolana) {
51
+ withdrawFeeInUSD = 0.01;
52
+ }
53
+ else if (crypto === common_1.Crypto.USDCPolygon) {
54
+ withdrawFeeInUSD = 0.01;
55
+ }
56
+ else if (crypto === common_1.Crypto.USDC || crypto === common_1.Crypto.USDTEthereum) {
57
+ withdrawFeeInUSD = 20;
58
+ }
59
+ else {
60
+ withdrawFeeInUSD = 0.01;
61
+ }
62
+ return {
63
+ withdrawFeeInBaseFiat: withdrawFeeInUSD * (1 / conversionRateToUSD),
64
+ };
36
65
  });
37
66
  exports.getNetworkFees = getNetworkFees;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1304",
3
+ "version": "1.0.1306",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",