@riocrypto/common-server 1.0.1283 → 1.0.1285
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.
|
@@ -9,6 +9,7 @@ declare class FireblocksClient {
|
|
|
9
9
|
getVaultCryptoBalance(vaultId: string, crypto: Crypto): Promise<number>;
|
|
10
10
|
getVaultCryptoAddress(vaultId: string, crypto: Crypto): Promise<string>;
|
|
11
11
|
getTotalVaultUSDBalance(vaultId: string): Promise<number>;
|
|
12
|
+
getTotalExchangesUSDBalance(): Promise<number>;
|
|
12
13
|
getExchangeCryptoBalance(crypto: Crypto): Promise<number>;
|
|
13
14
|
getExchangeFiatBalance(): Promise<number>;
|
|
14
15
|
getTransactions(vaultId: string, crypto: Crypto, nextPage?: string): Promise<any>;
|
|
@@ -110,6 +110,28 @@ class FireblocksClient {
|
|
|
110
110
|
return balance;
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
+
getTotalExchangesUSDBalance() {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
let exchanges = yield this.fireblocks.getExchangeAccounts();
|
|
116
|
+
let balance = 0;
|
|
117
|
+
exchanges.forEach((exchange) => {
|
|
118
|
+
exchange.assets.forEach((asset) => {
|
|
119
|
+
if ([
|
|
120
|
+
common_1.Crypto.USDC,
|
|
121
|
+
common_1.Crypto.USDCPolygon,
|
|
122
|
+
common_1.Crypto.USDCPolygonBridged,
|
|
123
|
+
common_1.Crypto.USDCSolana,
|
|
124
|
+
common_1.Crypto.USDTEthereum,
|
|
125
|
+
common_1.Crypto.USDTPolygon,
|
|
126
|
+
common_1.Crypto.USDTTron,
|
|
127
|
+
].includes(asset.id)) {
|
|
128
|
+
balance += Number(asset.available);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
return balance;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
113
135
|
getExchangeCryptoBalance(crypto) {
|
|
114
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
137
|
let exchanges = yield this.fireblocks.getExchangeAccounts();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { User } from "@riocrypto/common";
|
|
2
2
|
import { Mongoose } from "mongoose";
|
|
3
|
-
export declare const calculateAggregateVolumeAndRevenue: (mongoose: Mongoose, days: number, user?: User) => Promise<{
|
|
3
|
+
export declare const calculateAggregateVolumeAndRevenue: (mongoose: Mongoose, days: number, user?: User, excludeBrokerCustomerOrders?: boolean) => Promise<{
|
|
4
4
|
volume: number;
|
|
5
5
|
revenue: number;
|
|
6
6
|
}>;
|
|
@@ -12,14 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.calculateAggregateVolumeAndRevenue = void 0;
|
|
13
13
|
const common_1 = require("@riocrypto/common");
|
|
14
14
|
const order_1 = require("../models/order");
|
|
15
|
-
const calculateAggregateVolumeAndRevenue = (mongoose, days, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const calculateAggregateVolumeAndRevenue = (mongoose, days, user, excludeBrokerCustomerOrders) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
var _a;
|
|
17
17
|
const startDate = new Date();
|
|
18
18
|
startDate.setDate(startDate.getDate() - days); // Subtract 14 days from current date
|
|
19
19
|
const Order = (0, order_1.buildOrder)(mongoose);
|
|
20
20
|
let orders;
|
|
21
21
|
if (user) {
|
|
22
|
-
if ((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.broker))
|
|
22
|
+
if (((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.broker)) &&
|
|
23
|
+
!excludeBrokerCustomerOrders) {
|
|
23
24
|
orders = yield Order.find({
|
|
24
25
|
$or: [{ userId: user.id }, { brokerId: user.id }],
|
|
25
26
|
status: common_1.OrderStatus.Complete,
|
|
@@ -47,7 +48,6 @@ const calculateAggregateVolumeAndRevenue = (mongoose, days, user) => __awaiter(v
|
|
|
47
48
|
const fiatAmount = order.amountFiat || 0;
|
|
48
49
|
const conversionRate = order.conversionRateUSD;
|
|
49
50
|
const platformFee = ((_a = order.fees) === null || _a === void 0 ? void 0 : _a.platformFeeFiat) || 0;
|
|
50
|
-
const price = order.price || 0;
|
|
51
51
|
const amountCrypto = order.amountCrypto || 0;
|
|
52
52
|
let orderVolume = 0;
|
|
53
53
|
let orderRevenue = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1285",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
28
28
|
"@google-cloud/storage": "^6.9.5",
|
|
29
29
|
"@google-cloud/vision": "^4.0.2",
|
|
30
|
-
"@riocrypto/common": "^1.0.
|
|
30
|
+
"@riocrypto/common": "^1.0.1164",
|
|
31
31
|
"@types/express": "^4.17.13",
|
|
32
32
|
"axios": "^0.27.2",
|
|
33
33
|
"ccxt": "^3.0.30",
|