@dhedge/backend-flatcoin-core 0.3.16 → 0.3.18
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.
- package/dist/constants/enum.d.ts +3 -0
- package/dist/constants/enum.js +5 -1
- package/dist/entity/apy-history.d.ts +2 -2
- package/dist/entity/apy-history.js +4 -4
- package/dist/entity/apy.d.ts +1 -1
- package/dist/entity/apy.js +2 -2
- package/dist/entity/borrowing-rate-apy-history.d.ts +2 -2
- package/dist/entity/borrowing-rate-apy-history.js +4 -4
- package/dist/entity/flatcoin-pnl.d.ts +1 -1
- package/dist/entity/flatcoin-pnl.js +2 -2
- package/dist/entity/flatcoin.price.parent.d.ts +1 -1
- package/dist/entity/flatcoin.price.parent.js +2 -2
- package/dist/entity/leverage-leaderboard.d.ts +5 -1
- package/dist/entity/leverage-leaderboard.js +25 -2
- package/dist/entity/leverage-monthly-pnl.d.ts +3 -1
- package/dist/entity/leverage-monthly-pnl.js +17 -2
- package/dist/entity/limit-order.entity.d.ts +1 -1
- package/dist/entity/limit-order.entity.js +2 -2
- package/dist/entity/multichain-config.d.ts +1 -1
- package/dist/entity/multichain-config.js +2 -2
- package/dist/entity/order-execution.d.ts +1 -1
- package/dist/entity/order-execution.js +2 -2
- package/dist/entity/period-performance.d.ts +1 -1
- package/dist/entity/period-performance.js +2 -2
- package/dist/entity/position-entity.d.ts +1 -1
- package/dist/entity/position-entity.js +2 -2
- package/dist/entity/protocol-metrics.d.ts +1 -1
- package/dist/entity/protocol-metrics.js +2 -2
- package/dist/repository/apy-history.repository.d.ts +1 -1
- package/dist/repository/apy-history.repository.js +2 -2
- package/dist/repository/apy.repository.d.ts +1 -1
- package/dist/repository/apy.repository.js +2 -5
- package/dist/repository/borrowing-rate-apy-history.repository.d.ts +1 -1
- package/dist/repository/borrowing-rate-apy-history.repository.js +2 -2
- package/dist/repository/flatcoin-pnl.repository.d.ts +3 -3
- package/dist/repository/flatcoin-pnl.repository.js +7 -12
- package/dist/repository/leverage-balance.repository.d.ts +1 -1
- package/dist/repository/leverage-balance.repository.js +2 -2
- package/dist/repository/leverage-leaderboard.repository.d.ts +4 -4
- package/dist/repository/leverage-leaderboard.repository.js +8 -8
- package/dist/repository/leverage-monthly-pnl.repository.d.ts +3 -3
- package/dist/repository/leverage-monthly-pnl.repository.js +6 -6
- package/dist/repository/limit-order.repository.d.ts +2 -2
- package/dist/repository/limit-order.repository.js +4 -4
- package/dist/repository/multichain-config.repository.d.ts +1 -1
- package/dist/repository/multichain-config.repository.js +3 -5
- package/dist/repository/order-execution.repository.d.ts +1 -1
- package/dist/repository/order-execution.repository.js +2 -3
- package/dist/repository/position.repository.d.ts +4 -4
- package/dist/repository/position.repository.js +8 -8
- package/dist/repository/price.repository.d.ts +5 -5
- package/dist/repository/price.repository.js +10 -15
- package/dist/repository/protocol-metrics.repository.d.ts +1 -1
- package/dist/repository/protocol-metrics.repository.js +2 -2
- package/dist/repository/unit-balance.repository.d.ts +1 -1
- package/dist/repository/unit-balance.repository.js +2 -2
- package/package.json +1 -1
package/dist/constants/enum.d.ts
CHANGED
package/dist/constants/enum.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LimitOrderStatus = exports.LimitOrderExecutionType = exports.OrderType = exports.LeveragePositionStatus = exports.getChartPeriod = exports.PERIOD_IN_SECONDS = exports.HistoricalPeriod = exports.BlockchainCode = exports.PERIODS = void 0;
|
|
3
|
+
exports.LimitOrderStatus = exports.LimitOrderExecutionType = exports.OrderType = exports.LeveragePositionStatus = exports.getChartPeriod = exports.PERIOD_IN_SECONDS = exports.HistoricalPeriod = exports.Market = exports.BlockchainCode = exports.PERIODS = void 0;
|
|
4
4
|
var PERIODS;
|
|
5
5
|
(function (PERIODS) {
|
|
6
6
|
PERIODS["DAY"] = "DAY";
|
|
@@ -15,6 +15,10 @@ var BlockchainCode;
|
|
|
15
15
|
BlockchainCode["BASE"] = "BASE";
|
|
16
16
|
BlockchainCode["ARBITRUM"] = "ARBITRUM";
|
|
17
17
|
})(BlockchainCode || (exports.BlockchainCode = BlockchainCode = {}));
|
|
18
|
+
var Market;
|
|
19
|
+
(function (Market) {
|
|
20
|
+
Market["RETH_BASE"] = "RETH_BASE";
|
|
21
|
+
})(Market || (exports.Market = Market = {}));
|
|
18
22
|
var HistoricalPeriod;
|
|
19
23
|
(function (HistoricalPeriod) {
|
|
20
24
|
HistoricalPeriod["ONE_DAY"] = "1d";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare class ApyHistory {
|
|
2
2
|
id: number;
|
|
3
|
-
|
|
3
|
+
marketId: string;
|
|
4
4
|
daily: number;
|
|
5
5
|
weekly: number;
|
|
6
6
|
timestamp: number;
|
|
7
|
-
constructor(daily: number, weekly: number, timestamp: number,
|
|
7
|
+
constructor(daily: number, weekly: number, timestamp: number, marketId: string);
|
|
8
8
|
}
|
|
@@ -14,11 +14,11 @@ const typeorm_1 = require("typeorm");
|
|
|
14
14
|
const graphql_1 = require("@nestjs/graphql");
|
|
15
15
|
const utils_1 = require("../utils");
|
|
16
16
|
let ApyHistory = class ApyHistory {
|
|
17
|
-
constructor(daily, weekly, timestamp,
|
|
17
|
+
constructor(daily, weekly, timestamp, marketId) {
|
|
18
18
|
this.daily = daily;
|
|
19
19
|
this.weekly = weekly;
|
|
20
20
|
this.timestamp = timestamp;
|
|
21
|
-
this.
|
|
21
|
+
this.marketId = marketId;
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
exports.ApyHistory = ApyHistory;
|
|
@@ -28,9 +28,9 @@ __decorate([
|
|
|
28
28
|
], ApyHistory.prototype, "id", void 0);
|
|
29
29
|
__decorate([
|
|
30
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
31
|
-
(0, typeorm_1.Column)({ name: '
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
32
32
|
__metadata("design:type", String)
|
|
33
|
-
], ApyHistory.prototype, "
|
|
33
|
+
], ApyHistory.prototype, "marketId", void 0);
|
|
34
34
|
__decorate([
|
|
35
35
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
36
36
|
(0, typeorm_1.Column)({ name: 'daily', type: 'decimal', precision: 30, scale: 2, nullable: false, transformer: utils_1.numericTransformer }),
|
package/dist/entity/apy.d.ts
CHANGED
package/dist/entity/apy.js
CHANGED
|
@@ -22,9 +22,9 @@ __decorate([
|
|
|
22
22
|
], Apy.prototype, "id", void 0);
|
|
23
23
|
__decorate([
|
|
24
24
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
25
|
-
(0, typeorm_1.Column)({ name: '
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
|
-
], Apy.prototype, "
|
|
27
|
+
], Apy.prototype, "marketId", void 0);
|
|
28
28
|
__decorate([
|
|
29
29
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
30
30
|
(0, typeorm_1.Column)({ name: 'monthly', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare class BorrowingRateApyHistory {
|
|
2
2
|
id: number;
|
|
3
|
-
|
|
3
|
+
marketId: string;
|
|
4
4
|
daily: number;
|
|
5
5
|
eightHour: number;
|
|
6
6
|
timestamp: number;
|
|
7
|
-
constructor(daily: number, eightHour: number, timestamp: number,
|
|
7
|
+
constructor(daily: number, eightHour: number, timestamp: number, marketId: string);
|
|
8
8
|
}
|
|
@@ -14,11 +14,11 @@ const typeorm_1 = require("typeorm");
|
|
|
14
14
|
const graphql_1 = require("@nestjs/graphql");
|
|
15
15
|
const utils_1 = require("../utils");
|
|
16
16
|
let BorrowingRateApyHistory = class BorrowingRateApyHistory {
|
|
17
|
-
constructor(daily, eightHour, timestamp,
|
|
17
|
+
constructor(daily, eightHour, timestamp, marketId) {
|
|
18
18
|
this.daily = daily;
|
|
19
19
|
this.eightHour = eightHour;
|
|
20
20
|
this.timestamp = timestamp;
|
|
21
|
-
this.
|
|
21
|
+
this.marketId = marketId;
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
exports.BorrowingRateApyHistory = BorrowingRateApyHistory;
|
|
@@ -28,9 +28,9 @@ __decorate([
|
|
|
28
28
|
], BorrowingRateApyHistory.prototype, "id", void 0);
|
|
29
29
|
__decorate([
|
|
30
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
31
|
-
(0, typeorm_1.Column)({ name: '
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
32
32
|
__metadata("design:type", String)
|
|
33
|
-
], BorrowingRateApyHistory.prototype, "
|
|
33
|
+
], BorrowingRateApyHistory.prototype, "marketId", void 0);
|
|
34
34
|
__decorate([
|
|
35
35
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
36
36
|
(0, typeorm_1.Column)({ name: 'daily', type: 'decimal', precision: 30, scale: 2, nullable: false, transformer: utils_1.numericTransformer }),
|
|
@@ -23,9 +23,9 @@ __decorate([
|
|
|
23
23
|
], FlatcoinPnl.prototype, "id", void 0);
|
|
24
24
|
__decorate([
|
|
25
25
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
-
(0, typeorm_1.Column)({ name: '
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
27
27
|
__metadata("design:type", String)
|
|
28
|
-
], FlatcoinPnl.prototype, "
|
|
28
|
+
], FlatcoinPnl.prototype, "marketId", void 0);
|
|
29
29
|
__decorate([
|
|
30
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
31
31
|
(0, typeorm_1.Column)({ name: 'account' }),
|
|
@@ -22,9 +22,9 @@ __decorate([
|
|
|
22
22
|
], FlatcoinPriceParent.prototype, "id", void 0);
|
|
23
23
|
__decorate([
|
|
24
24
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
25
|
-
(0, typeorm_1.Column)({ name: '
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
|
-
], FlatcoinPriceParent.prototype, "
|
|
27
|
+
], FlatcoinPriceParent.prototype, "marketId", void 0);
|
|
28
28
|
__decorate([
|
|
29
29
|
(0, graphql_1.Field)(),
|
|
30
30
|
(0, typeorm_1.Column)({ name: 'price_usd', type: 'numeric', precision: 30 }),
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
2
|
export declare class LeverageLeaderboard {
|
|
3
3
|
id: number;
|
|
4
|
-
|
|
4
|
+
marketId: string;
|
|
5
5
|
account: string;
|
|
6
6
|
period: string;
|
|
7
7
|
totalPnlReth: BigNumber;
|
|
8
|
+
totalPnlCollateral: BigNumber;
|
|
8
9
|
totalPnlRethFormatted: number;
|
|
10
|
+
totalPnlCollateralFormatted: number;
|
|
9
11
|
totalTradedVolumeReth: BigNumber;
|
|
10
12
|
totalTradedVolumeRethFormatted: number;
|
|
13
|
+
totalTradedVolumeCollateral: BigNumber;
|
|
14
|
+
totalTradedVolumeCollateralFormatted: number;
|
|
11
15
|
closedTradesCount: number;
|
|
12
16
|
lastClosedPositionTimestamp: number;
|
|
13
17
|
}
|
|
@@ -23,9 +23,9 @@ __decorate([
|
|
|
23
23
|
], LeverageLeaderboard.prototype, "id", void 0);
|
|
24
24
|
__decorate([
|
|
25
25
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
-
(0, typeorm_1.Column)({ name: '
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
27
27
|
__metadata("design:type", String)
|
|
28
|
-
], LeverageLeaderboard.prototype, "
|
|
28
|
+
], LeverageLeaderboard.prototype, "marketId", void 0);
|
|
29
29
|
__decorate([
|
|
30
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
31
31
|
(0, typeorm_1.Column)({ name: 'account', unique: true, nullable: false }),
|
|
@@ -40,6 +40,10 @@ __decorate([
|
|
|
40
40
|
(0, typeorm_1.Column)({ name: 'total_pnl_reth', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
41
41
|
__metadata("design:type", ethers_1.BigNumber)
|
|
42
42
|
], LeverageLeaderboard.prototype, "totalPnlReth", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ name: 'total_pnl_collateral', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
45
|
+
__metadata("design:type", ethers_1.BigNumber)
|
|
46
|
+
], LeverageLeaderboard.prototype, "totalPnlCollateral", void 0);
|
|
43
47
|
__decorate([
|
|
44
48
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
45
49
|
(0, typeorm_1.Column)({
|
|
@@ -51,6 +55,17 @@ __decorate([
|
|
|
51
55
|
}),
|
|
52
56
|
__metadata("design:type", Number)
|
|
53
57
|
], LeverageLeaderboard.prototype, "totalPnlRethFormatted", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
60
|
+
(0, typeorm_1.Column)({
|
|
61
|
+
name: 'total_pnl_collateral_formatted',
|
|
62
|
+
type: 'decimal',
|
|
63
|
+
precision: 30,
|
|
64
|
+
scale: 2,
|
|
65
|
+
transformer: utils_1.numericTransformer,
|
|
66
|
+
}),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], LeverageLeaderboard.prototype, "totalPnlCollateralFormatted", void 0);
|
|
54
69
|
__decorate([
|
|
55
70
|
(0, typeorm_1.Column)({ name: 'total_traded_volume_reth', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
56
71
|
__metadata("design:type", ethers_1.BigNumber)
|
|
@@ -59,6 +74,14 @@ __decorate([
|
|
|
59
74
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
60
75
|
__metadata("design:type", Number)
|
|
61
76
|
], LeverageLeaderboard.prototype, "totalTradedVolumeRethFormatted", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, typeorm_1.Column)({ name: 'total_traded_volume_collateral', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
79
|
+
__metadata("design:type", ethers_1.BigNumber)
|
|
80
|
+
], LeverageLeaderboard.prototype, "totalTradedVolumeCollateral", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
83
|
+
__metadata("design:type", Number)
|
|
84
|
+
], LeverageLeaderboard.prototype, "totalTradedVolumeCollateralFormatted", void 0);
|
|
62
85
|
__decorate([
|
|
63
86
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
64
87
|
(0, typeorm_1.Column)({ name: 'closed_trades_count', type: 'numeric', precision: 25, transformer: utils_1.numericTransformer }),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
2
|
export declare class LeverageMonthlyPnl {
|
|
3
3
|
id: number;
|
|
4
|
-
|
|
4
|
+
marketId: string;
|
|
5
5
|
account: string;
|
|
6
6
|
pnlReth: BigNumber;
|
|
7
|
+
pnlCollateral: BigNumber;
|
|
7
8
|
pnlRethFormatted: number;
|
|
9
|
+
pnlCollateralFormatted: number;
|
|
8
10
|
timestamp: number;
|
|
9
11
|
lastClosedPositionTimestamp: number;
|
|
10
12
|
}
|
|
@@ -23,9 +23,9 @@ __decorate([
|
|
|
23
23
|
], LeverageMonthlyPnl.prototype, "id", void 0);
|
|
24
24
|
__decorate([
|
|
25
25
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
-
(0, typeorm_1.Column)({ name: '
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
27
27
|
__metadata("design:type", String)
|
|
28
|
-
], LeverageMonthlyPnl.prototype, "
|
|
28
|
+
], LeverageMonthlyPnl.prototype, "marketId", void 0);
|
|
29
29
|
__decorate([
|
|
30
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
31
31
|
(0, typeorm_1.Column)({ name: 'account', unique: true, nullable: false }),
|
|
@@ -35,11 +35,26 @@ __decorate([
|
|
|
35
35
|
(0, typeorm_1.Column)({ name: 'pnl_reth', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
36
36
|
__metadata("design:type", ethers_1.BigNumber)
|
|
37
37
|
], LeverageMonthlyPnl.prototype, "pnlReth", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'pnl_collateral', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
40
|
+
__metadata("design:type", ethers_1.BigNumber)
|
|
41
|
+
], LeverageMonthlyPnl.prototype, "pnlCollateral", void 0);
|
|
38
42
|
__decorate([
|
|
39
43
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
40
44
|
(0, typeorm_1.Column)({ name: 'pnl_reth_formatted', type: 'decimal', precision: 30, scale: 4, transformer: utils_1.numericTransformer }),
|
|
41
45
|
__metadata("design:type", Number)
|
|
42
46
|
], LeverageMonthlyPnl.prototype, "pnlRethFormatted", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
49
|
+
(0, typeorm_1.Column)({
|
|
50
|
+
name: 'pnl_collateral_formatted',
|
|
51
|
+
type: 'decimal',
|
|
52
|
+
precision: 30,
|
|
53
|
+
scale: 4,
|
|
54
|
+
transformer: utils_1.numericTransformer,
|
|
55
|
+
}),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], LeverageMonthlyPnl.prototype, "pnlCollateralFormatted", void 0);
|
|
43
58
|
__decorate([
|
|
44
59
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
45
60
|
(0, typeorm_1.Column)({ name: 'timestamp', type: 'numeric', precision: 25, transformer: utils_1.numericTransformer }),
|
|
@@ -2,7 +2,7 @@ import { BigNumber } from 'ethers';
|
|
|
2
2
|
import { PositionEntity } from './position-entity';
|
|
3
3
|
export declare class LimitOrderEntity {
|
|
4
4
|
id: number;
|
|
5
|
-
|
|
5
|
+
marketId: string;
|
|
6
6
|
status: string;
|
|
7
7
|
priceLowerThreshold: BigNumber;
|
|
8
8
|
priceUpperThreshold: BigNumber;
|
|
@@ -22,9 +22,9 @@ __decorate([
|
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], LimitOrderEntity.prototype, "id", void 0);
|
|
24
24
|
__decorate([
|
|
25
|
-
(0, typeorm_1.Column)({ name: '
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
|
-
], LimitOrderEntity.prototype, "
|
|
27
|
+
], LimitOrderEntity.prototype, "marketId", void 0);
|
|
28
28
|
__decorate([
|
|
29
29
|
(0, typeorm_1.Column)({ name: 'status', nullable: false }),
|
|
30
30
|
__metadata("design:type", String)
|
|
@@ -19,9 +19,9 @@ __decorate([
|
|
|
19
19
|
__metadata("design:type", Number)
|
|
20
20
|
], MultichainConfig.prototype, "id", void 0);
|
|
21
21
|
__decorate([
|
|
22
|
-
(0, typeorm_1.Column)({ name: '
|
|
22
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
23
23
|
__metadata("design:type", String)
|
|
24
|
-
], MultichainConfig.prototype, "
|
|
24
|
+
], MultichainConfig.prototype, "marketId", void 0);
|
|
25
25
|
__decorate([
|
|
26
26
|
(0, typeorm_1.Column)({ name: 'app_name', nullable: false }),
|
|
27
27
|
__metadata("design:type", String)
|
|
@@ -20,9 +20,9 @@ __decorate([
|
|
|
20
20
|
__metadata("design:type", Number)
|
|
21
21
|
], OrderExecution.prototype, "id", void 0);
|
|
22
22
|
__decorate([
|
|
23
|
-
(0, typeorm_1.Column)({ name: '
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
24
24
|
__metadata("design:type", String)
|
|
25
|
-
], OrderExecution.prototype, "
|
|
25
|
+
], OrderExecution.prototype, "marketId", void 0);
|
|
26
26
|
__decorate([
|
|
27
27
|
(0, typeorm_1.Column)({ name: 'tx_hash' }),
|
|
28
28
|
__metadata("design:type", String)
|
|
@@ -22,9 +22,9 @@ __decorate([
|
|
|
22
22
|
], PeriodPerformance.prototype, "id", void 0);
|
|
23
23
|
__decorate([
|
|
24
24
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
25
|
-
(0, typeorm_1.Column)({ name: '
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
|
-
], PeriodPerformance.prototype, "
|
|
27
|
+
], PeriodPerformance.prototype, "marketId", void 0);
|
|
28
28
|
__decorate([
|
|
29
29
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
30
30
|
(0, typeorm_1.Column)({ name: 'day', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
@@ -22,9 +22,9 @@ __decorate([
|
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], PositionEntity.prototype, "id", void 0);
|
|
24
24
|
__decorate([
|
|
25
|
-
(0, typeorm_1.Column)({ name: '
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
|
-
], PositionEntity.prototype, "
|
|
27
|
+
], PositionEntity.prototype, "marketId", void 0);
|
|
28
28
|
__decorate([
|
|
29
29
|
(0, typeorm_1.Column)({
|
|
30
30
|
name: 'token_id',
|
|
@@ -24,9 +24,9 @@ __decorate([
|
|
|
24
24
|
], ProtocolMetrics.prototype, "id", void 0);
|
|
25
25
|
__decorate([
|
|
26
26
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
27
|
-
(0, typeorm_1.Column)({ name: '
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'market_id' }),
|
|
28
28
|
__metadata("design:type", String)
|
|
29
|
-
], ProtocolMetrics.prototype, "
|
|
29
|
+
], ProtocolMetrics.prototype, "marketId", void 0);
|
|
30
30
|
__decorate([
|
|
31
31
|
(0, graphql_1.Field)(() => utils_2.CustomBigNumberScalar, { nullable: false }),
|
|
32
32
|
(0, typeorm_1.Column)({ name: 'unit_deposits_volume', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
@@ -5,6 +5,6 @@ export declare class ApyHistoryRepository {
|
|
|
5
5
|
private readonly repository;
|
|
6
6
|
private readonly logger;
|
|
7
7
|
constructor(repository: Repository<ApyHistory>, logger: Logger);
|
|
8
|
-
getAllFromTimestamp(
|
|
8
|
+
getAllFromTimestamp(marketId: string, fromTimestamp: number): Promise<ApyHistory[]>;
|
|
9
9
|
save(apyHistory: ApyHistory): void;
|
|
10
10
|
}
|
|
@@ -22,11 +22,11 @@ let ApyHistoryRepository = class ApyHistoryRepository {
|
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
}
|
|
25
|
-
async getAllFromTimestamp(
|
|
25
|
+
async getAllFromTimestamp(marketId, fromTimestamp) {
|
|
26
26
|
return await this.repository
|
|
27
27
|
.createQueryBuilder('apy_history')
|
|
28
28
|
.where('timestamp > :fromTimestamp', { fromTimestamp: fromTimestamp })
|
|
29
|
-
.andWhere('
|
|
29
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
30
30
|
.orderBy('apy_history.timestamp', 'ASC')
|
|
31
31
|
.getMany();
|
|
32
32
|
}
|
|
@@ -5,6 +5,6 @@ export declare class ApyRepository {
|
|
|
5
5
|
private repository;
|
|
6
6
|
private readonly logger;
|
|
7
7
|
constructor(repository: Repository<Apy>, logger: Logger);
|
|
8
|
-
getApy(
|
|
8
|
+
getApy(marketId: string): Promise<Apy | null>;
|
|
9
9
|
save(apy: Apy): void;
|
|
10
10
|
}
|
|
@@ -22,11 +22,8 @@ let ApyRepository = class ApyRepository {
|
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
}
|
|
25
|
-
async getApy(
|
|
26
|
-
return this.repository
|
|
27
|
-
.createQueryBuilder()
|
|
28
|
-
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
29
|
-
.getOne();
|
|
25
|
+
async getApy(marketId) {
|
|
26
|
+
return this.repository.createQueryBuilder().where('market_id = :marketId', { marketId: marketId }).getOne();
|
|
30
27
|
}
|
|
31
28
|
save(apy) {
|
|
32
29
|
this.repository.save(apy).catch((error) => this.logger.error('Error while saving apy', error));
|
|
@@ -3,6 +3,6 @@ import { BorrowingRateApyHistory } from '../entity';
|
|
|
3
3
|
export declare class BorrowingRateApyHistoryRepository {
|
|
4
4
|
private readonly repository;
|
|
5
5
|
constructor(repository: Repository<BorrowingRateApyHistory>);
|
|
6
|
-
getAllFromTimestamp(
|
|
6
|
+
getAllFromTimestamp(marketId: string, fromTimestamp: number): Promise<BorrowingRateApyHistory[]>;
|
|
7
7
|
save(apyHistory: BorrowingRateApyHistory): Promise<void>;
|
|
8
8
|
}
|
|
@@ -21,11 +21,11 @@ let BorrowingRateApyHistoryRepository = class BorrowingRateApyHistoryRepository
|
|
|
21
21
|
constructor(repository) {
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
}
|
|
24
|
-
async getAllFromTimestamp(
|
|
24
|
+
async getAllFromTimestamp(marketId, fromTimestamp) {
|
|
25
25
|
return await this.repository
|
|
26
26
|
.createQueryBuilder()
|
|
27
27
|
.where('timestamp > :fromTimestamp', { fromTimestamp: fromTimestamp })
|
|
28
|
-
.andWhere('
|
|
28
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
29
29
|
.orderBy('timestamp', 'ASC')
|
|
30
30
|
.getMany();
|
|
31
31
|
}
|
|
@@ -5,9 +5,9 @@ export declare class FlatcoinPnlRepository {
|
|
|
5
5
|
private readonly repository;
|
|
6
6
|
private readonly logger;
|
|
7
7
|
constructor(repository: Repository<FlatcoinPnl>, logger: Logger);
|
|
8
|
-
getAll(
|
|
8
|
+
getAll(marketId: string): Promise<FlatcoinPnl[]>;
|
|
9
9
|
save(flatcoinPnl: FlatcoinPnl): void;
|
|
10
10
|
saveAll(flatcoinPnls: FlatcoinPnl[]): void;
|
|
11
|
-
getLastUpdatedAt(
|
|
12
|
-
findByAccount(account: string,
|
|
11
|
+
getLastUpdatedAt(marketId: string): Promise<FlatcoinPnl | null>;
|
|
12
|
+
findByAccount(account: string, marketId: string): Promise<FlatcoinPnl | null>;
|
|
13
13
|
}
|
|
@@ -22,11 +22,8 @@ let FlatcoinPnlRepository = class FlatcoinPnlRepository {
|
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
}
|
|
25
|
-
async getAll(
|
|
26
|
-
return this.repository
|
|
27
|
-
.createQueryBuilder()
|
|
28
|
-
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
29
|
-
.getMany();
|
|
25
|
+
async getAll(marketId) {
|
|
26
|
+
return this.repository.createQueryBuilder().where('market_id = :marketId', { marketId: marketId }).getMany();
|
|
30
27
|
}
|
|
31
28
|
save(flatcoinPnl) {
|
|
32
29
|
this.repository.save(flatcoinPnl).catch((error) => this.logger.error('Error while saving flatcoin pnl', error));
|
|
@@ -34,21 +31,19 @@ let FlatcoinPnlRepository = class FlatcoinPnlRepository {
|
|
|
34
31
|
saveAll(flatcoinPnls) {
|
|
35
32
|
this.repository.save(flatcoinPnls).catch((error) => this.logger.error('Error while saving flatcoin pnl', error));
|
|
36
33
|
}
|
|
37
|
-
async getLastUpdatedAt(
|
|
34
|
+
async getLastUpdatedAt(marketId) {
|
|
38
35
|
return await this.repository
|
|
39
36
|
.createQueryBuilder('pnl')
|
|
40
|
-
.where('
|
|
37
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
41
38
|
.orderBy('pnl.block_updated_at', 'DESC')
|
|
42
39
|
.take(1)
|
|
43
40
|
.getOne();
|
|
44
41
|
}
|
|
45
|
-
async findByAccount(account,
|
|
42
|
+
async findByAccount(account, marketId) {
|
|
46
43
|
return await this.repository
|
|
47
44
|
.createQueryBuilder('pnl')
|
|
48
|
-
.where('pnl.account = :account')
|
|
49
|
-
.andWhere('
|
|
50
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
51
|
-
.setParameter('account', account)
|
|
45
|
+
.where('pnl.account = :account', { account: account })
|
|
46
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
52
47
|
.take(1)
|
|
53
48
|
.getOne();
|
|
54
49
|
}
|
|
@@ -12,6 +12,6 @@ export declare class LeverageBalanceRepository {
|
|
|
12
12
|
private leverageBalanceThreeMonthsRepository;
|
|
13
13
|
private leverageBalanceOneYearRepository;
|
|
14
14
|
constructor(leverageBalanceOneDayRepository: Repository<LeverageBalanceOneDay>, leverageBalanceOneWeekRepository: Repository<LeverageBalanceOneWeek>, leverageBalanceOneMonthRepository: Repository<LeverageBalanceOneMonth>, leverageBalanceThreeMonthsRepository: Repository<LeverageBalanceThreeMonths>, leverageBalanceOneYearRepository: Repository<LeverageBalanceOneYear>);
|
|
15
|
-
findAllByPeriod(account: string,
|
|
15
|
+
findAllByPeriod(account: string, marketId: string, period: string): Promise<UnitBalanceParent[]>;
|
|
16
16
|
getRepository(period: string): Repository<any>;
|
|
17
17
|
}
|
|
@@ -30,11 +30,11 @@ let LeverageBalanceRepository = class LeverageBalanceRepository {
|
|
|
30
30
|
this.leverageBalanceThreeMonthsRepository = leverageBalanceThreeMonthsRepository;
|
|
31
31
|
this.leverageBalanceOneYearRepository = leverageBalanceOneYearRepository;
|
|
32
32
|
}
|
|
33
|
-
async findAllByPeriod(account,
|
|
33
|
+
async findAllByPeriod(account, marketId, period) {
|
|
34
34
|
return this.getRepository(period)
|
|
35
35
|
.createQueryBuilder()
|
|
36
36
|
.where('account = :account', { account: account })
|
|
37
|
-
.andWhere('
|
|
37
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
38
38
|
.orderBy('timestamp', 'ASC')
|
|
39
39
|
.getMany();
|
|
40
40
|
}
|
|
@@ -3,9 +3,9 @@ import { LeverageLeaderboard } from '../entity';
|
|
|
3
3
|
export declare class LeverageLeaderboardRepository {
|
|
4
4
|
private repository;
|
|
5
5
|
constructor(repository: Repository<LeverageLeaderboard>);
|
|
6
|
-
findByLastTimestamp(
|
|
7
|
-
findByAccount(account: string,
|
|
8
|
-
findAllOrderedByPnl(
|
|
6
|
+
findByLastTimestamp(marketId: string, period: string): Promise<LeverageLeaderboard | null>;
|
|
7
|
+
findByAccount(account: string, marketId: string, period: string): Promise<LeverageLeaderboard | null>;
|
|
8
|
+
findAllOrderedByPnl(marketId: string, period: string): Promise<LeverageLeaderboard[]>;
|
|
9
9
|
saveAll(leverageLeaderboard: LeverageLeaderboard[]): Promise<void>;
|
|
10
|
-
deleteByCodeAndPeriod(
|
|
10
|
+
deleteByCodeAndPeriod(marketId: string, period: string): Promise<void>;
|
|
11
11
|
}
|
|
@@ -21,28 +21,28 @@ let LeverageLeaderboardRepository = class LeverageLeaderboardRepository {
|
|
|
21
21
|
constructor(repository) {
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
}
|
|
24
|
-
async findByLastTimestamp(
|
|
24
|
+
async findByLastTimestamp(marketId, period) {
|
|
25
25
|
return await this.repository
|
|
26
26
|
.createQueryBuilder('leverageLeaderboard')
|
|
27
|
-
.where('
|
|
27
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
28
28
|
.andWhere('period = :period', { period: period })
|
|
29
29
|
.orderBy('leverageLeaderboard.last_closed_position_timestamp', 'DESC')
|
|
30
30
|
.take(1)
|
|
31
31
|
.getOne();
|
|
32
32
|
}
|
|
33
|
-
async findByAccount(account,
|
|
33
|
+
async findByAccount(account, marketId, period) {
|
|
34
34
|
return await this.repository
|
|
35
35
|
.createQueryBuilder('leverageLeaderboard')
|
|
36
36
|
.where('leverageLeaderboard.account = :account', { account: account })
|
|
37
|
-
.andWhere('
|
|
37
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
38
38
|
.andWhere('period = :period', { period: period })
|
|
39
39
|
.take(1)
|
|
40
40
|
.getOne();
|
|
41
41
|
}
|
|
42
|
-
async findAllOrderedByPnl(
|
|
42
|
+
async findAllOrderedByPnl(marketId, period) {
|
|
43
43
|
return this.repository
|
|
44
44
|
.createQueryBuilder('leverageLeaderboard')
|
|
45
|
-
.where('
|
|
45
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
46
46
|
.andWhere('period = :period', { period: period })
|
|
47
47
|
.orderBy('leverageLeaderboard.total_pnl_reth', 'DESC')
|
|
48
48
|
.getMany();
|
|
@@ -50,10 +50,10 @@ let LeverageLeaderboardRepository = class LeverageLeaderboardRepository {
|
|
|
50
50
|
async saveAll(leverageLeaderboard) {
|
|
51
51
|
await this.repository.save(leverageLeaderboard);
|
|
52
52
|
}
|
|
53
|
-
async deleteByCodeAndPeriod(
|
|
53
|
+
async deleteByCodeAndPeriod(marketId, period) {
|
|
54
54
|
await this.repository
|
|
55
55
|
.createQueryBuilder()
|
|
56
|
-
.where('
|
|
56
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
57
57
|
.andWhere('period = :period', { period: period })
|
|
58
58
|
.delete();
|
|
59
59
|
}
|
|
@@ -3,8 +3,8 @@ import { Repository } from 'typeorm';
|
|
|
3
3
|
export declare class LeverageMonthlyPnlRepository {
|
|
4
4
|
private repository;
|
|
5
5
|
constructor(repository: Repository<LeverageMonthlyPnl>);
|
|
6
|
-
findAllByAccount(account: string,
|
|
7
|
-
findByLastTimestamp(
|
|
8
|
-
findByAccountAndTimestamp(account: string, timestamp: number,
|
|
6
|
+
findAllByAccount(account: string, marketId: string): Promise<LeverageMonthlyPnl[]>;
|
|
7
|
+
findByLastTimestamp(marketId: string): Promise<LeverageMonthlyPnl | null>;
|
|
8
|
+
findByAccountAndTimestamp(account: string, timestamp: number, marketId: string): Promise<LeverageMonthlyPnl | null>;
|
|
9
9
|
saveAll(leverageLeaderboard: LeverageMonthlyPnl[]): Promise<void>;
|
|
10
10
|
}
|
|
@@ -21,28 +21,28 @@ let LeverageMonthlyPnlRepository = class LeverageMonthlyPnlRepository {
|
|
|
21
21
|
constructor(repository) {
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
}
|
|
24
|
-
async findAllByAccount(account,
|
|
24
|
+
async findAllByAccount(account, marketId) {
|
|
25
25
|
return await this.repository
|
|
26
26
|
.createQueryBuilder()
|
|
27
27
|
.where('account = :account', { account: account })
|
|
28
|
-
.andWhere('
|
|
28
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
29
29
|
.orderBy('timestamp', 'ASC')
|
|
30
30
|
.getMany();
|
|
31
31
|
}
|
|
32
|
-
async findByLastTimestamp(
|
|
32
|
+
async findByLastTimestamp(marketId) {
|
|
33
33
|
return await this.repository
|
|
34
34
|
.createQueryBuilder()
|
|
35
|
-
.
|
|
35
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
36
36
|
.orderBy('last_closed_position_timestamp', 'DESC')
|
|
37
37
|
.take(1)
|
|
38
38
|
.getOne();
|
|
39
39
|
}
|
|
40
|
-
async findByAccountAndTimestamp(account, timestamp,
|
|
40
|
+
async findByAccountAndTimestamp(account, timestamp, marketId) {
|
|
41
41
|
return await this.repository
|
|
42
42
|
.createQueryBuilder()
|
|
43
43
|
.where('account = :account', { account: account })
|
|
44
44
|
.andWhere('timestamp = :timestamp', { timestamp: timestamp })
|
|
45
|
-
.andWhere('
|
|
45
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
46
46
|
.take(1)
|
|
47
47
|
.getOne();
|
|
48
48
|
}
|
|
@@ -5,6 +5,6 @@ export declare class LimitOrderRepository {
|
|
|
5
5
|
constructor(repository: Repository<LimitOrderEntity>);
|
|
6
6
|
save(limitOrder: LimitOrderEntity): Promise<LimitOrderEntity>;
|
|
7
7
|
saveAll(limitOrder: LimitOrderEntity[]): Promise<LimitOrderEntity[]>;
|
|
8
|
-
getAllByStatusOpen(
|
|
9
|
-
getByTokenId(tokenId: number,
|
|
8
|
+
getAllByStatusOpen(marketId: string): Promise<LimitOrderEntity[]>;
|
|
9
|
+
getByTokenId(tokenId: number, marketId: string): Promise<LimitOrderEntity | null>;
|
|
10
10
|
}
|
|
@@ -28,19 +28,19 @@ let LimitOrderRepository = class LimitOrderRepository {
|
|
|
28
28
|
async saveAll(limitOrder) {
|
|
29
29
|
return this.repository.save(limitOrder);
|
|
30
30
|
}
|
|
31
|
-
async getAllByStatusOpen(
|
|
31
|
+
async getAllByStatusOpen(marketId) {
|
|
32
32
|
return this.repository
|
|
33
33
|
.createQueryBuilder()
|
|
34
34
|
.where('status = :status', { status: constants_1.LimitOrderStatus.OPEN })
|
|
35
|
-
.andWhere('
|
|
35
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
36
36
|
.orderBy('liquidation_price', 'DESC')
|
|
37
37
|
.getMany();
|
|
38
38
|
}
|
|
39
|
-
async getByTokenId(tokenId,
|
|
39
|
+
async getByTokenId(tokenId, marketId) {
|
|
40
40
|
return await this.repository
|
|
41
41
|
.createQueryBuilder()
|
|
42
42
|
.where('token_id = :tokenId', { tokenId: tokenId })
|
|
43
|
-
.andWhere('
|
|
43
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
44
44
|
.where('status = :status', { status: constants_1.LimitOrderStatus.OPEN })
|
|
45
45
|
.take(1)
|
|
46
46
|
.getOne();
|
|
@@ -4,5 +4,5 @@ export declare class MultichainConfigRepository {
|
|
|
4
4
|
private repository;
|
|
5
5
|
constructor(repository: Repository<MultichainConfig>);
|
|
6
6
|
getById(id: number): Promise<MultichainConfig | null>;
|
|
7
|
-
getByAppAndCode(appName: string,
|
|
7
|
+
getByAppAndCode(appName: string, marketId: string): Promise<MultichainConfig | null>;
|
|
8
8
|
}
|
|
@@ -24,13 +24,11 @@ let MultichainConfigRepository = class MultichainConfigRepository {
|
|
|
24
24
|
async getById(id) {
|
|
25
25
|
return this.repository.createQueryBuilder().where('id = :id').setParameter('id', id).take(1).getOne();
|
|
26
26
|
}
|
|
27
|
-
async getByAppAndCode(appName,
|
|
27
|
+
async getByAppAndCode(appName, marketId) {
|
|
28
28
|
return this.repository
|
|
29
29
|
.createQueryBuilder()
|
|
30
|
-
.where('app_name = :appName')
|
|
31
|
-
.andWhere('
|
|
32
|
-
.setParameter('appName', appName)
|
|
33
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
30
|
+
.where('app_name = :appName', { appName: appName })
|
|
31
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
34
32
|
.take(1)
|
|
35
33
|
.getOne();
|
|
36
34
|
}
|
|
@@ -5,5 +5,5 @@ export declare class OrderExecutionRepository {
|
|
|
5
5
|
constructor(repository: Repository<OrderExecution>);
|
|
6
6
|
save(orderExecution: OrderExecution): Promise<OrderExecution>;
|
|
7
7
|
saveAll(orderExecutions: OrderExecution[]): Promise<OrderExecution[]>;
|
|
8
|
-
getLatestRecord(
|
|
8
|
+
getLatestRecord(marketId: string): Promise<OrderExecution | null>;
|
|
9
9
|
}
|
|
@@ -27,11 +27,10 @@ let OrderExecutionRepository = class OrderExecutionRepository {
|
|
|
27
27
|
async saveAll(orderExecutions) {
|
|
28
28
|
return this.repository.save(orderExecutions);
|
|
29
29
|
}
|
|
30
|
-
async getLatestRecord(
|
|
30
|
+
async getLatestRecord(marketId) {
|
|
31
31
|
return this.repository
|
|
32
32
|
.createQueryBuilder()
|
|
33
|
-
.where('
|
|
34
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
33
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
35
34
|
.orderBy('executed_at', 'DESC')
|
|
36
35
|
.limit(1)
|
|
37
36
|
.getOne();
|
|
@@ -6,8 +6,8 @@ export declare class PositionRepository {
|
|
|
6
6
|
constructor(repository: Repository<PositionEntity>);
|
|
7
7
|
save(position: PositionEntity): Promise<PositionEntity>;
|
|
8
8
|
saveAll(positions: PositionEntity[]): Promise<PositionEntity[]>;
|
|
9
|
-
getAllByStatusOpen(
|
|
10
|
-
updateLiquidationPrice(tokenId: number,
|
|
11
|
-
getOneByTokenId(tokenId: number,
|
|
12
|
-
getLatestUpdateAtBlock(
|
|
9
|
+
getAllByStatusOpen(marketId: string): Promise<PositionEntity[]>;
|
|
10
|
+
updateLiquidationPrice(tokenId: number, marketId: string, liqPrice: BigNumber): Promise<void>;
|
|
11
|
+
getOneByTokenId(tokenId: number, marketId: string): Promise<PositionEntity | null>;
|
|
12
|
+
getLatestUpdateAtBlock(marketId: string): Promise<number>;
|
|
13
13
|
}
|
|
@@ -28,36 +28,36 @@ let PositionRepository = class PositionRepository {
|
|
|
28
28
|
async saveAll(positions) {
|
|
29
29
|
return this.repository.save(positions);
|
|
30
30
|
}
|
|
31
|
-
async getAllByStatusOpen(
|
|
31
|
+
async getAllByStatusOpen(marketId) {
|
|
32
32
|
return this.repository
|
|
33
33
|
.createQueryBuilder()
|
|
34
34
|
.where('status = :status', { status: constants_1.LeveragePositionStatus.OPEN })
|
|
35
|
-
.andWhere('
|
|
35
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
36
36
|
.orderBy('liquidation_price', 'DESC')
|
|
37
37
|
.getMany();
|
|
38
38
|
}
|
|
39
|
-
async updateLiquidationPrice(tokenId,
|
|
39
|
+
async updateLiquidationPrice(tokenId, marketId, liqPrice) {
|
|
40
40
|
await this.repository
|
|
41
41
|
.createQueryBuilder()
|
|
42
42
|
.update(entity_1.PositionEntity)
|
|
43
43
|
.set({ liquidationPrice: liqPrice })
|
|
44
44
|
.where('token_id = :tokenId', { tokenId: tokenId })
|
|
45
|
-
.andWhere('
|
|
45
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
46
46
|
.execute();
|
|
47
47
|
}
|
|
48
|
-
async getOneByTokenId(tokenId,
|
|
48
|
+
async getOneByTokenId(tokenId, marketId) {
|
|
49
49
|
return await this.repository
|
|
50
50
|
.createQueryBuilder()
|
|
51
51
|
.where('token_id = :tokenId', { tokenId: tokenId })
|
|
52
|
-
.andWhere('
|
|
52
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
53
53
|
.take(1)
|
|
54
54
|
.getOne();
|
|
55
55
|
}
|
|
56
|
-
async getLatestUpdateAtBlock(
|
|
56
|
+
async getLatestUpdateAtBlock(marketId) {
|
|
57
57
|
const p = await this.repository
|
|
58
58
|
.createQueryBuilder('position')
|
|
59
59
|
.select(['position.block_updated_at'])
|
|
60
|
-
.where('
|
|
60
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
61
61
|
.orderBy('block_updated_at', 'DESC')
|
|
62
62
|
.getRawOne();
|
|
63
63
|
return p ? parseInt(p.block_updated_at) : 0;
|
|
@@ -7,10 +7,10 @@ export declare class PriceRepository {
|
|
|
7
7
|
private flatcoinPriceOneYearRepository;
|
|
8
8
|
private readonly repository;
|
|
9
9
|
constructor(flatcoinPriceOneDayRepository: Repository<FlatcoinPriceOneDay>, flatcoinPriceOneWeekRepository: Repository<FlatcoinPriceOneWeek>, flatcoinPriceOneMonthRepository: Repository<FlatcoinPriceOneMonth>, flatcoinPriceOneYearRepository: Repository<FlatcoinPriceOneYear>, repository: Repository<FlatcoinPrice>);
|
|
10
|
-
findAllByPeriod(period: string,
|
|
11
|
-
findLast(
|
|
12
|
-
findFirstByTimestamp(fromTimestamp: number,
|
|
13
|
-
findFirstByBlock(fromBlock: number,
|
|
14
|
-
findFirst(
|
|
10
|
+
findAllByPeriod(period: string, marketId: string): Promise<FlatcoinPriceParent[]>;
|
|
11
|
+
findLast(marketId: string): Promise<FlatcoinPrice | null>;
|
|
12
|
+
findFirstByTimestamp(fromTimestamp: number, marketId: string): Promise<FlatcoinPrice | null>;
|
|
13
|
+
findFirstByBlock(fromBlock: number, marketId: string): Promise<FlatcoinPrice | null>;
|
|
14
|
+
findFirst(marketId: string): Promise<FlatcoinPrice | null>;
|
|
15
15
|
private getRepository;
|
|
16
16
|
}
|
|
@@ -26,50 +26,45 @@ let PriceRepository = class PriceRepository {
|
|
|
26
26
|
this.flatcoinPriceOneYearRepository = flatcoinPriceOneYearRepository;
|
|
27
27
|
this.repository = repository;
|
|
28
28
|
}
|
|
29
|
-
async findAllByPeriod(period,
|
|
29
|
+
async findAllByPeriod(period, marketId) {
|
|
30
30
|
return this.getRepository(period)
|
|
31
31
|
.createQueryBuilder('price')
|
|
32
|
-
.where('
|
|
33
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
32
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
34
33
|
.orderBy('price.timestamp', 'ASC')
|
|
35
34
|
.getMany();
|
|
36
35
|
}
|
|
37
|
-
async findLast(
|
|
36
|
+
async findLast(marketId) {
|
|
38
37
|
return this.repository
|
|
39
38
|
.createQueryBuilder()
|
|
40
|
-
.where('
|
|
41
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
39
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
42
40
|
.orderBy('timestamp', 'DESC')
|
|
43
41
|
.take(1)
|
|
44
42
|
.getOne();
|
|
45
43
|
}
|
|
46
|
-
async findFirstByTimestamp(fromTimestamp,
|
|
44
|
+
async findFirstByTimestamp(fromTimestamp, marketId) {
|
|
47
45
|
return await this.repository
|
|
48
46
|
.createQueryBuilder('price')
|
|
49
47
|
.where('timestamp > :fromTimestamp')
|
|
50
|
-
.andWhere('
|
|
51
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
48
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
52
49
|
.orderBy('price.timestamp', 'ASC')
|
|
53
50
|
.setParameter('fromTimestamp', fromTimestamp)
|
|
54
51
|
.take(1)
|
|
55
52
|
.getOne();
|
|
56
53
|
}
|
|
57
|
-
async findFirstByBlock(fromBlock,
|
|
54
|
+
async findFirstByBlock(fromBlock, marketId) {
|
|
58
55
|
return await this.repository
|
|
59
56
|
.createQueryBuilder()
|
|
60
57
|
.where('block_number > :fromBlock')
|
|
61
|
-
.andWhere('
|
|
62
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
58
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
63
59
|
.setParameter('fromBlock', fromBlock)
|
|
64
60
|
.orderBy('timestamp', 'ASC')
|
|
65
61
|
.take(1)
|
|
66
62
|
.getOne();
|
|
67
63
|
}
|
|
68
|
-
async findFirst(
|
|
64
|
+
async findFirst(marketId) {
|
|
69
65
|
return await this.repository
|
|
70
66
|
.createQueryBuilder('price')
|
|
71
|
-
.where('
|
|
72
|
-
.setParameter('blockchainCode', blockchainCode)
|
|
67
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
73
68
|
.orderBy('price.timestamp', 'ASC')
|
|
74
69
|
.take(1)
|
|
75
70
|
.getOne();
|
|
@@ -4,5 +4,5 @@ export declare class ProtocolMetricsRepository {
|
|
|
4
4
|
private repository;
|
|
5
5
|
constructor(repository: Repository<ProtocolMetrics>);
|
|
6
6
|
save(protocolMetrics: ProtocolMetrics): Promise<ProtocolMetrics>;
|
|
7
|
-
getLatestRecord(
|
|
7
|
+
getLatestRecord(marketId: string): Promise<ProtocolMetrics | null>;
|
|
8
8
|
}
|
|
@@ -24,10 +24,10 @@ let ProtocolMetricsRepository = class ProtocolMetricsRepository {
|
|
|
24
24
|
async save(protocolMetrics) {
|
|
25
25
|
return this.repository.save(protocolMetrics);
|
|
26
26
|
}
|
|
27
|
-
async getLatestRecord(
|
|
27
|
+
async getLatestRecord(marketId) {
|
|
28
28
|
return this.repository
|
|
29
29
|
.createQueryBuilder()
|
|
30
|
-
.where('
|
|
30
|
+
.where('market_id = :marketId', { marketId: marketId })
|
|
31
31
|
.limit(1)
|
|
32
32
|
.getOne();
|
|
33
33
|
}
|
|
@@ -12,6 +12,6 @@ export declare class UnitBalanceRepository {
|
|
|
12
12
|
private unitBalanceHalfYearRepository;
|
|
13
13
|
private unitBalanceOneYearRepository;
|
|
14
14
|
constructor(unitBalanceOneWeekRepository: Repository<UnitBalanceOneWeek>, unitBalanceOneMonthRepository: Repository<UnitBalanceOneMonth>, unitBalanceThreeMonthsRepository: Repository<UnitBalanceThreeMonths>, unitBalanceHalfYearRepository: Repository<UnitBalanceHalfYear>, unitBalanceOneYearRepository: Repository<UnitBalanceOneYear>);
|
|
15
|
-
findAllByPeriod(account: string, period: string,
|
|
15
|
+
findAllByPeriod(account: string, period: string, marketId: string): Promise<UnitBalanceParent[]>;
|
|
16
16
|
getRepository(period: string): Repository<any>;
|
|
17
17
|
}
|
|
@@ -30,11 +30,11 @@ let UnitBalanceRepository = class UnitBalanceRepository {
|
|
|
30
30
|
this.unitBalanceHalfYearRepository = unitBalanceHalfYearRepository;
|
|
31
31
|
this.unitBalanceOneYearRepository = unitBalanceOneYearRepository;
|
|
32
32
|
}
|
|
33
|
-
async findAllByPeriod(account, period,
|
|
33
|
+
async findAllByPeriod(account, period, marketId) {
|
|
34
34
|
return this.getRepository(period)
|
|
35
35
|
.createQueryBuilder()
|
|
36
36
|
.where('account = :account', { account: account })
|
|
37
|
-
.andWhere('
|
|
37
|
+
.andWhere('market_id = :marketId', { marketId: marketId })
|
|
38
38
|
.orderBy('timestamp', 'ASC')
|
|
39
39
|
.getMany();
|
|
40
40
|
}
|