@riocrypto/common-server 1.0.712 → 1.0.714
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.
|
@@ -17,34 +17,38 @@ const common_1 = require("@riocrypto/common");
|
|
|
17
17
|
const order_1 = require("../models/order");
|
|
18
18
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
19
19
|
const calculateAggregateVolume = (user, days) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
let volume;
|
|
20
21
|
const startDate = new Date();
|
|
21
22
|
startDate.setDate(startDate.getDate() - days); // Subtract 14 days from current date
|
|
22
23
|
const Order = (0, order_1.buildOrder)(mongoose_1.default);
|
|
23
|
-
const
|
|
24
|
+
const buyOrders = yield Order.find({
|
|
24
25
|
userId: user.id,
|
|
26
|
+
type: common_1.Side.Buy,
|
|
25
27
|
status: common_1.OrderStatus.Complete,
|
|
26
28
|
createdAt: { $gte: startDate },
|
|
27
29
|
});
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
const sellOrders = yield Order.find({
|
|
31
|
+
userId: user.id,
|
|
32
|
+
type: common_1.Side.Sell,
|
|
33
|
+
status: common_1.OrderStatus.Complete,
|
|
34
|
+
createdAt: { $gte: startDate },
|
|
35
|
+
});
|
|
36
|
+
volume =
|
|
37
|
+
sellOrders.reduce((sum, order) => {
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
39
|
+
return sum +
|
|
40
|
+
(order.amountFiat +
|
|
41
|
+
((((_a = order.fees) === null || _a === void 0 ? void 0 : _a.partnerFeeFiat) || 0) +
|
|
42
|
+
(((_b = order.fees) === null || _b === void 0 ? void 0 : _b.platformFeeFiat) || 0) +
|
|
43
|
+
(((_c = order.fees) === null || _c === void 0 ? void 0 : _c.platformFeeFiatTax) || 0) +
|
|
44
|
+
(((_d = order.fees) === null || _d === void 0 ? void 0 : _d.processingFeeFiat) || 0) +
|
|
45
|
+
(((_e = order.fees) === null || _e === void 0 ? void 0 : _e.transferFeeFiat) || 0)) || 0) *
|
|
46
|
+
(order.conversionRateToUSD || 0);
|
|
47
|
+
}, 0) +
|
|
48
|
+
buyOrders.reduce((sum, order) => sum + order.amountFiat * (order.conversionRateToUSD || 0), 0);
|
|
49
|
+
if (!volume) {
|
|
50
|
+
volume = 0;
|
|
51
|
+
}
|
|
52
|
+
return volume;
|
|
49
53
|
});
|
|
50
54
|
exports.calculateAggregateVolume = calculateAggregateVolume;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.714",
|
|
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.637",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|