@riocrypto/common-server 1.0.1121 → 1.0.1123
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.
|
@@ -4,7 +4,7 @@ declare class ClusterClient {
|
|
|
4
4
|
private clusterApiKey;
|
|
5
5
|
private axios;
|
|
6
6
|
constructor(baseUrl: string, clusterApiKey: string);
|
|
7
|
-
getNewQuote(orderId: string, quote: Quote): Promise<Quote>;
|
|
7
|
+
getNewQuote(orderId: string, quote: Quote, newAmountFiat?: number): Promise<Quote>;
|
|
8
8
|
createBitsoBankAccount(userId: string): Promise<BitsoBankAccount>;
|
|
9
9
|
getBalance(asset: Crypto | Fiat): Promise<number>;
|
|
10
10
|
}
|
|
@@ -33,15 +33,23 @@ class ClusterClient {
|
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
getNewQuote(orderId, quote) {
|
|
36
|
+
getNewQuote(orderId, quote, newAmountFiat) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
let amountFiat = undefined;
|
|
39
|
+
if (!quote.quoteInCrypto || newAmountFiat) {
|
|
40
|
+
amountFiat = newAmountFiat ? newAmountFiat : quote.amountFiat;
|
|
41
|
+
}
|
|
42
|
+
let amountCrypto = undefined;
|
|
43
|
+
if (quote.quoteInCrypto && !newAmountFiat) {
|
|
44
|
+
amountCrypto = quote.amountCrypto;
|
|
45
|
+
}
|
|
38
46
|
const response = yield this.axios.post(`${this.baseUrl}/api/quotes`, {
|
|
39
47
|
orderId,
|
|
40
48
|
userId: quote.userId,
|
|
41
49
|
side: quote.side,
|
|
42
50
|
crypto: quote.crypto,
|
|
43
51
|
fiat: quote.fiat,
|
|
44
|
-
amountFiat
|
|
52
|
+
amountFiat,
|
|
45
53
|
amountCrypto: quote.quoteInCrypto ? quote.amountCrypto : undefined,
|
|
46
54
|
country: quote.country,
|
|
47
55
|
discount: quote.discount,
|
|
@@ -7,6 +7,7 @@ declare class FireblocksClient {
|
|
|
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>;
|
|
10
|
+
getTotalVaultUSDBalance(vaultId: string): Promise<number>;
|
|
10
11
|
getExchangeCryptoBalance(crypto: Crypto): Promise<number>;
|
|
11
12
|
getExchangeFiatBalance(): Promise<number>;
|
|
12
13
|
getTransactions(vaultId: string, crypto: Crypto, nextPage?: string): Promise<any>;
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.buildFireblocksClient = void 0;
|
|
13
13
|
const fireblocks_sdk_1 = require("fireblocks-sdk");
|
|
14
|
+
const common_1 = require("@riocrypto/common");
|
|
14
15
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
15
16
|
class FireblocksClient {
|
|
16
17
|
constructor(privateKey, apiKey) {
|
|
@@ -81,6 +82,27 @@ class FireblocksClient {
|
|
|
81
82
|
return Number(vaultAsset.available) || 0;
|
|
82
83
|
});
|
|
83
84
|
}
|
|
85
|
+
getTotalVaultUSDBalance(vaultId) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const vaultAccount = yield this.fireblocks.getVaultAccountById(vaultId);
|
|
88
|
+
let balance = 0;
|
|
89
|
+
if (vaultAccount.assets) {
|
|
90
|
+
for (const asset of vaultAccount.assets) {
|
|
91
|
+
if ([
|
|
92
|
+
common_1.Crypto.USDC,
|
|
93
|
+
common_1.Crypto.USDCPolygon,
|
|
94
|
+
common_1.Crypto.USDCSolana,
|
|
95
|
+
common_1.Crypto.USDTEthereum,
|
|
96
|
+
common_1.Crypto.USDTPolygon,
|
|
97
|
+
common_1.Crypto.USDTTron,
|
|
98
|
+
].includes(asset.id)) {
|
|
99
|
+
balance += Number(asset.available || 0);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return balance;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
84
106
|
getExchangeCryptoBalance(crypto) {
|
|
85
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
108
|
let exchanges = yield this.fireblocks.getExchangeAccounts();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1123",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@aws-sdk/client-s3": "^3.297.0",
|
|
27
27
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
28
28
|
"@google-cloud/storage": "^6.9.5",
|
|
29
|
-
"@riocrypto/common": "^1.0.
|
|
29
|
+
"@riocrypto/common": "^1.0.972",
|
|
30
30
|
"@types/express": "^4.17.13",
|
|
31
31
|
"axios": "^0.27.2",
|
|
32
32
|
"ccxt": "^3.0.30",
|