@dhedge/backend-flatcoin-core 0.3.0 → 0.3.1
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 +4 -0
- package/dist/constants/enum.js +6 -1
- package/dist/entity/apy-history.d.ts +1 -0
- package/dist/entity/apy-history.js +5 -0
- package/dist/entity/apy.d.ts +1 -0
- package/dist/entity/apy.js +5 -0
- package/dist/entity/borrowing-rate-apy-history.d.ts +1 -0
- package/dist/entity/borrowing-rate-apy-history.js +5 -0
- package/dist/entity/flatcoin-pnl.d.ts +1 -0
- package/dist/entity/flatcoin-pnl.js +5 -0
- package/dist/entity/flatcoin.price.parent.d.ts +1 -0
- package/dist/entity/flatcoin.price.parent.js +5 -0
- package/dist/entity/leverage-leaderboard.d.ts +1 -0
- package/dist/entity/leverage-leaderboard.js +5 -0
- package/dist/entity/leverage-monthly-pnl.d.ts +1 -0
- package/dist/entity/leverage-monthly-pnl.js +5 -0
- package/dist/entity/leverageBalanceChart/leverage-balance-parent.d.ts +1 -0
- package/dist/entity/leverageBalanceChart/leverage-balance-parent.js +5 -0
- package/dist/entity/limit-order.entity.d.ts +1 -0
- package/dist/entity/limit-order.entity.js +4 -0
- package/dist/entity/order-execution.d.ts +1 -0
- package/dist/entity/order-execution.js +4 -0
- package/dist/entity/period-performance.d.ts +1 -0
- package/dist/entity/period-performance.js +5 -0
- package/dist/entity/position-entity.d.ts +1 -0
- package/dist/entity/position-entity.js +4 -0
- package/dist/entity/protocol-metrics.d.ts +1 -0
- package/dist/entity/protocol-metrics.js +8 -3
- package/dist/entity/unitBalanceChart/unit-balance-parent.d.ts +1 -0
- package/dist/entity/unitBalanceChart/unit-balance-parent.js +5 -0
- package/dist/repository/apy-history.repository.d.ts +1 -1
- package/dist/repository/apy-history.repository.js +3 -3
- package/dist/repository/apy.repository.d.ts +1 -1
- package/dist/repository/apy.repository.js +5 -2
- package/dist/repository/borrowing-rate-apy-history.repository.d.ts +1 -1
- package/dist/repository/borrowing-rate-apy-history.repository.js +3 -3
- package/dist/repository/flatcoin-pnl.repository.d.ts +3 -3
- package/dist/repository/flatcoin-pnl.repository.js +15 -5
- package/dist/repository/leverage-balance.repository.d.ts +1 -1
- package/dist/repository/leverage-balance.repository.js +3 -3
- package/dist/repository/leverage-leaderboard.repository.d.ts +3 -3
- package/dist/repository/leverage-leaderboard.repository.js +6 -3
- package/dist/repository/leverage-monthly-pnl.repository.d.ts +3 -3
- package/dist/repository/leverage-monthly-pnl.repository.js +14 -14
- package/dist/repository/limit-order.repository.d.ts +2 -2
- package/dist/repository/limit-order.repository.js +5 -4
- package/dist/repository/order-execution.repository.d.ts +1 -1
- package/dist/repository/order-execution.repository.js +8 -2
- package/dist/repository/position.repository.d.ts +4 -4
- package/dist/repository/position.repository.js +9 -6
- package/dist/repository/price.repository.d.ts +4 -4
- package/dist/repository/price.repository.js +26 -7
- package/dist/repository/protocol-metrics.repository.d.ts +1 -1
- package/dist/repository/protocol-metrics.repository.js +6 -2
- package/dist/repository/unit-balance.repository.d.ts +1 -1
- package/dist/repository/unit-balance.repository.js +3 -3
- package/dist/service/blockscan.service.d.ts +3 -2
- package/dist/service/blockscan.service.js +10 -3
- 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.PERIODS = void 0;
|
|
3
|
+
exports.LimitOrderStatus = exports.LimitOrderExecutionType = exports.OrderType = exports.LeveragePositionStatus = exports.getChartPeriod = exports.PERIOD_IN_SECONDS = exports.HistoricalPeriod = exports.BlockchainCode = exports.PERIODS = void 0;
|
|
4
4
|
var PERIODS;
|
|
5
5
|
(function (PERIODS) {
|
|
6
6
|
PERIODS["DAY"] = "DAY";
|
|
@@ -10,6 +10,11 @@ var PERIODS;
|
|
|
10
10
|
PERIODS["HALF_YEAR"] = "HALF_YEAR";
|
|
11
11
|
PERIODS["YEAR"] = "YEAR";
|
|
12
12
|
})(PERIODS || (exports.PERIODS = PERIODS = {}));
|
|
13
|
+
var BlockchainCode;
|
|
14
|
+
(function (BlockchainCode) {
|
|
15
|
+
BlockchainCode["BASE"] = "BASE";
|
|
16
|
+
BlockchainCode["ARBITRUM"] = "ARBITRUM";
|
|
17
|
+
})(BlockchainCode || (exports.BlockchainCode = BlockchainCode = {}));
|
|
13
18
|
var HistoricalPeriod;
|
|
14
19
|
(function (HistoricalPeriod) {
|
|
15
20
|
HistoricalPeriod["ONE_DAY"] = "1d";
|
|
@@ -24,6 +24,11 @@ __decorate([
|
|
|
24
24
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
25
25
|
__metadata("design:type", Number)
|
|
26
26
|
], ApyHistory.prototype, "id", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
29
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], ApyHistory.prototype, "blockchainCode", void 0);
|
|
27
32
|
__decorate([
|
|
28
33
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
29
34
|
(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
|
@@ -20,6 +20,11 @@ __decorate([
|
|
|
20
20
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
21
21
|
__metadata("design:type", Number)
|
|
22
22
|
], Apy.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], Apy.prototype, "blockchainCode", void 0);
|
|
23
28
|
__decorate([
|
|
24
29
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
25
30
|
(0, typeorm_1.Column)({ name: 'monthly', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
@@ -25,6 +25,11 @@ __decorate([
|
|
|
25
25
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
26
26
|
__metadata("design:type", Number)
|
|
27
27
|
], BorrowingRateApyHistory.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
30
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], BorrowingRateApyHistory.prototype, "blockchainCode", void 0);
|
|
28
33
|
__decorate([
|
|
29
34
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
30
35
|
(0, typeorm_1.Column)({ name: 'daily', type: 'decimal', precision: 30, scale: 2, nullable: false, transformer: utils_1.numericTransformer }),
|
|
@@ -21,6 +21,11 @@ __decorate([
|
|
|
21
21
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], FlatcoinPnl.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], FlatcoinPnl.prototype, "blockchainCode", void 0);
|
|
24
29
|
__decorate([
|
|
25
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
31
|
(0, typeorm_1.Column)({ name: 'account' }),
|
|
@@ -20,6 +20,11 @@ __decorate([
|
|
|
20
20
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
21
21
|
__metadata("design:type", Number)
|
|
22
22
|
], FlatcoinPriceParent.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], FlatcoinPriceParent.prototype, "blockchainCode", void 0);
|
|
23
28
|
__decorate([
|
|
24
29
|
(0, graphql_1.Field)(),
|
|
25
30
|
(0, typeorm_1.Column)({ name: 'price_usd', type: 'numeric', precision: 30 }),
|
|
@@ -21,6 +21,11 @@ __decorate([
|
|
|
21
21
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], LeverageLeaderboard.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], LeverageLeaderboard.prototype, "blockchainCode", void 0);
|
|
24
29
|
__decorate([
|
|
25
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
31
|
(0, typeorm_1.Column)({ name: 'account', unique: true, nullable: false }),
|
|
@@ -21,6 +21,11 @@ __decorate([
|
|
|
21
21
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], LeverageMonthlyPnl.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], LeverageMonthlyPnl.prototype, "blockchainCode", void 0);
|
|
24
29
|
__decorate([
|
|
25
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
31
|
(0, typeorm_1.Column)({ name: 'account', unique: true, nullable: false }),
|
|
@@ -21,6 +21,11 @@ __decorate([
|
|
|
21
21
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], LeverageBalanceParent.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], LeverageBalanceParent.prototype, "blockchainCode", void 0);
|
|
24
29
|
__decorate([
|
|
25
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
31
|
(0, typeorm_1.Column)({ name: 'account' }),
|
|
@@ -21,6 +21,10 @@ __decorate([
|
|
|
21
21
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], LimitOrderEntity.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], LimitOrderEntity.prototype, "blockchainCode", void 0);
|
|
24
28
|
__decorate([
|
|
25
29
|
(0, typeorm_1.Column)({ name: 'status', nullable: false }),
|
|
26
30
|
__metadata("design:type", String)
|
|
@@ -19,6 +19,10 @@ __decorate([
|
|
|
19
19
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
20
20
|
__metadata("design:type", Number)
|
|
21
21
|
], OrderExecution.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], OrderExecution.prototype, "blockchainCode", void 0);
|
|
22
26
|
__decorate([
|
|
23
27
|
(0, typeorm_1.Column)({ name: 'tx_hash' }),
|
|
24
28
|
__metadata("design:type", String)
|
|
@@ -20,6 +20,11 @@ __decorate([
|
|
|
20
20
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
21
21
|
__metadata("design:type", Number)
|
|
22
22
|
], PeriodPerformance.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], PeriodPerformance.prototype, "blockchainCode", void 0);
|
|
23
28
|
__decorate([
|
|
24
29
|
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: false }),
|
|
25
30
|
(0, typeorm_1.Column)({ name: 'day', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
@@ -21,6 +21,10 @@ __decorate([
|
|
|
21
21
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], PositionEntity.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], PositionEntity.prototype, "blockchainCode", void 0);
|
|
24
28
|
__decorate([
|
|
25
29
|
(0, typeorm_1.Column)({
|
|
26
30
|
name: 'token_id',
|
|
@@ -14,7 +14,7 @@ const typeorm_1 = require("typeorm");
|
|
|
14
14
|
const utils_1 = require("../utils");
|
|
15
15
|
const ethers_1 = require("ethers");
|
|
16
16
|
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
-
const
|
|
17
|
+
const utils_2 = require("../utils");
|
|
18
18
|
let ProtocolMetrics = class ProtocolMetrics {
|
|
19
19
|
};
|
|
20
20
|
exports.ProtocolMetrics = ProtocolMetrics;
|
|
@@ -23,12 +23,17 @@ __decorate([
|
|
|
23
23
|
__metadata("design:type", Number)
|
|
24
24
|
], ProtocolMetrics.prototype, "id", void 0);
|
|
25
25
|
__decorate([
|
|
26
|
-
(0, graphql_1.Field)(() =>
|
|
26
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], ProtocolMetrics.prototype, "blockchainCode", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, graphql_1.Field)(() => utils_2.CustomBigNumberScalar, { nullable: false }),
|
|
27
32
|
(0, typeorm_1.Column)({ name: 'unit_deposits_volume', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
28
33
|
__metadata("design:type", ethers_1.BigNumber)
|
|
29
34
|
], ProtocolMetrics.prototype, "unitDepositsVolume", void 0);
|
|
30
35
|
__decorate([
|
|
31
|
-
(0, graphql_1.Field)(() =>
|
|
36
|
+
(0, graphql_1.Field)(() => utils_2.CustomBigNumberScalar, { nullable: false }),
|
|
32
37
|
(0, typeorm_1.Column)({ name: 'unit_withdrawals_volume', type: 'bigint', precision: 30, transformer: utils_1.bigNumberTransformer }),
|
|
33
38
|
__metadata("design:type", ethers_1.BigNumber)
|
|
34
39
|
], ProtocolMetrics.prototype, "unitWithdrawalsVolume", void 0);
|
|
@@ -21,6 +21,11 @@ __decorate([
|
|
|
21
21
|
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], UnitBalanceParent.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'blockchain_code' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], UnitBalanceParent.prototype, "blockchainCode", void 0);
|
|
24
29
|
__decorate([
|
|
25
30
|
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
26
31
|
(0, typeorm_1.Column)({ name: 'account' }),
|
|
@@ -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(fromTimestamp: number): Promise<ApyHistory[]>;
|
|
8
|
+
getAllFromTimestamp(blockchainCode: string, fromTimestamp: number): Promise<ApyHistory[]>;
|
|
9
9
|
save(apyHistory: ApyHistory): void;
|
|
10
10
|
}
|
|
@@ -22,12 +22,12 @@ let ApyHistoryRepository = class ApyHistoryRepository {
|
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
}
|
|
25
|
-
async getAllFromTimestamp(fromTimestamp) {
|
|
25
|
+
async getAllFromTimestamp(blockchainCode, fromTimestamp) {
|
|
26
26
|
return await this.repository
|
|
27
27
|
.createQueryBuilder('apy_history')
|
|
28
|
-
.where('timestamp > :fromTimestamp')
|
|
28
|
+
.where('timestamp > :fromTimestamp', { fromTimestamp: fromTimestamp })
|
|
29
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
29
30
|
.orderBy('apy_history.timestamp', 'ASC')
|
|
30
|
-
.setParameter('fromTimestamp', fromTimestamp)
|
|
31
31
|
.getMany();
|
|
32
32
|
}
|
|
33
33
|
save(apyHistory) {
|
|
@@ -22,8 +22,11 @@ let ApyRepository = class ApyRepository {
|
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
}
|
|
25
|
-
async getApy() {
|
|
26
|
-
return this.repository
|
|
25
|
+
async getApy(blockchainCode) {
|
|
26
|
+
return this.repository
|
|
27
|
+
.createQueryBuilder()
|
|
28
|
+
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
29
|
+
.getOne();
|
|
27
30
|
}
|
|
28
31
|
save(apy) {
|
|
29
32
|
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(fromTimestamp: number): Promise<BorrowingRateApyHistory[]>;
|
|
6
|
+
getAllFromTimestamp(blockchainCode: string, fromTimestamp: number): Promise<BorrowingRateApyHistory[]>;
|
|
7
7
|
save(apyHistory: BorrowingRateApyHistory): Promise<void>;
|
|
8
8
|
}
|
|
@@ -21,12 +21,12 @@ let BorrowingRateApyHistoryRepository = class BorrowingRateApyHistoryRepository
|
|
|
21
21
|
constructor(repository) {
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
}
|
|
24
|
-
async getAllFromTimestamp(fromTimestamp) {
|
|
24
|
+
async getAllFromTimestamp(blockchainCode, fromTimestamp) {
|
|
25
25
|
return await this.repository
|
|
26
26
|
.createQueryBuilder()
|
|
27
|
-
.where('timestamp > :fromTimestamp')
|
|
27
|
+
.where('timestamp > :fromTimestamp', { fromTimestamp: fromTimestamp })
|
|
28
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
28
29
|
.orderBy('timestamp', 'ASC')
|
|
29
|
-
.setParameter('fromTimestamp', fromTimestamp)
|
|
30
30
|
.getMany();
|
|
31
31
|
}
|
|
32
32
|
async save(apyHistory) {
|
|
@@ -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(): Promise<FlatcoinPnl[]>;
|
|
8
|
+
getAll(blockchainCode: string): Promise<FlatcoinPnl[]>;
|
|
9
9
|
save(flatcoinPnl: FlatcoinPnl): void;
|
|
10
10
|
saveAll(flatcoinPnls: FlatcoinPnl[]): void;
|
|
11
|
-
getLastUpdatedAt(): Promise<FlatcoinPnl | null>;
|
|
12
|
-
findByAccount(account: string): Promise<FlatcoinPnl | null>;
|
|
11
|
+
getLastUpdatedAt(blockchainCode: string): Promise<FlatcoinPnl | null>;
|
|
12
|
+
findByAccount(account: string, blockchainCode: string): Promise<FlatcoinPnl | null>;
|
|
13
13
|
}
|
|
@@ -22,8 +22,11 @@ let FlatcoinPnlRepository = class FlatcoinPnlRepository {
|
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
}
|
|
25
|
-
async getAll() {
|
|
26
|
-
return this.repository
|
|
25
|
+
async getAll(blockchainCode) {
|
|
26
|
+
return this.repository
|
|
27
|
+
.createQueryBuilder()
|
|
28
|
+
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
29
|
+
.getMany();
|
|
27
30
|
}
|
|
28
31
|
save(flatcoinPnl) {
|
|
29
32
|
this.repository.save(flatcoinPnl).catch((error) => this.logger.error('Error while saving flatcoin pnl', error));
|
|
@@ -31,13 +34,20 @@ let FlatcoinPnlRepository = class FlatcoinPnlRepository {
|
|
|
31
34
|
saveAll(flatcoinPnls) {
|
|
32
35
|
this.repository.save(flatcoinPnls).catch((error) => this.logger.error('Error while saving flatcoin pnl', error));
|
|
33
36
|
}
|
|
34
|
-
async getLastUpdatedAt() {
|
|
35
|
-
return await this.repository
|
|
37
|
+
async getLastUpdatedAt(blockchainCode) {
|
|
38
|
+
return await this.repository
|
|
39
|
+
.createQueryBuilder('pnl')
|
|
40
|
+
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
41
|
+
.orderBy('pnl.block_updated_at', 'DESC')
|
|
42
|
+
.take(1)
|
|
43
|
+
.getOne();
|
|
36
44
|
}
|
|
37
|
-
async findByAccount(account) {
|
|
45
|
+
async findByAccount(account, blockchainCode) {
|
|
38
46
|
return await this.repository
|
|
39
47
|
.createQueryBuilder('pnl')
|
|
40
48
|
.where('pnl.account = :account')
|
|
49
|
+
.andWhere('blockchain_code = :blockchainCode')
|
|
50
|
+
.setParameter('blockchainCode', blockchainCode)
|
|
41
51
|
.setParameter('account', account)
|
|
42
52
|
.take(1)
|
|
43
53
|
.getOne();
|
|
@@ -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, period: string): Promise<UnitBalanceParent[]>;
|
|
15
|
+
findAllByPeriod(account: string, blockchainCode: 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, period) {
|
|
33
|
+
async findAllByPeriod(account, blockchainCode, period) {
|
|
34
34
|
return this.getRepository(period)
|
|
35
35
|
.createQueryBuilder()
|
|
36
|
-
.where('account = :account')
|
|
37
|
-
.
|
|
36
|
+
.where('account = :account', { account: account })
|
|
37
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
38
38
|
.orderBy('timestamp', 'ASC')
|
|
39
39
|
.getMany();
|
|
40
40
|
}
|
|
@@ -3,8 +3,8 @@ import { LeverageLeaderboard } from '../entity';
|
|
|
3
3
|
export declare class LeverageLeaderboardRepository {
|
|
4
4
|
private repository;
|
|
5
5
|
constructor(repository: Repository<LeverageLeaderboard>);
|
|
6
|
-
findByLastTimestamp(): Promise<LeverageLeaderboard | null>;
|
|
7
|
-
findByAccount(account: string): Promise<LeverageLeaderboard | null>;
|
|
8
|
-
findAllOrderedByPnl(): Promise<LeverageLeaderboard[]>;
|
|
6
|
+
findByLastTimestamp(blockchainCode: string): Promise<LeverageLeaderboard | null>;
|
|
7
|
+
findByAccount(account: string, blockchainCode: string): Promise<LeverageLeaderboard | null>;
|
|
8
|
+
findAllOrderedByPnl(blockchainCode: string): Promise<LeverageLeaderboard[]>;
|
|
9
9
|
saveAll(leverageLeaderboard: LeverageLeaderboard[]): Promise<void>;
|
|
10
10
|
}
|
|
@@ -21,24 +21,27 @@ let LeverageLeaderboardRepository = class LeverageLeaderboardRepository {
|
|
|
21
21
|
constructor(repository) {
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
}
|
|
24
|
-
async findByLastTimestamp() {
|
|
24
|
+
async findByLastTimestamp(blockchainCode) {
|
|
25
25
|
return await this.repository
|
|
26
26
|
.createQueryBuilder('leverageLeaderboard')
|
|
27
|
+
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
27
28
|
.orderBy('leverageLeaderboard.last_closed_position_timestamp', 'DESC')
|
|
28
29
|
.take(1)
|
|
29
30
|
.getOne();
|
|
30
31
|
}
|
|
31
|
-
async findByAccount(account) {
|
|
32
|
+
async findByAccount(account, blockchainCode) {
|
|
32
33
|
return await this.repository
|
|
33
34
|
.createQueryBuilder('leverageLeaderboard')
|
|
34
35
|
.where('leverageLeaderboard.account = :account')
|
|
36
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
35
37
|
.setParameter('account', account)
|
|
36
38
|
.take(1)
|
|
37
39
|
.getOne();
|
|
38
40
|
}
|
|
39
|
-
async findAllOrderedByPnl() {
|
|
41
|
+
async findAllOrderedByPnl(blockchainCode) {
|
|
40
42
|
return this.repository
|
|
41
43
|
.createQueryBuilder('leverageLeaderboard')
|
|
44
|
+
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
42
45
|
.orderBy('leverageLeaderboard.total_pnl_reth', 'DESC')
|
|
43
46
|
.getMany();
|
|
44
47
|
}
|
|
@@ -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): Promise<LeverageMonthlyPnl[]>;
|
|
7
|
-
findByLastTimestamp(): Promise<LeverageMonthlyPnl | null>;
|
|
8
|
-
findByAccountAndTimestamp(account: string, timestamp: number): Promise<LeverageMonthlyPnl | null>;
|
|
6
|
+
findAllByAccount(account: string, blockchainCode: string): Promise<LeverageMonthlyPnl[]>;
|
|
7
|
+
findByLastTimestamp(blockchainCode: string): Promise<LeverageMonthlyPnl | null>;
|
|
8
|
+
findByAccountAndTimestamp(account: string, timestamp: number, blockchainCode: 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, blockchainCode) {
|
|
25
25
|
return await this.repository
|
|
26
|
-
.createQueryBuilder(
|
|
27
|
-
.where('
|
|
28
|
-
.
|
|
29
|
-
.
|
|
26
|
+
.createQueryBuilder()
|
|
27
|
+
.where('account = :account', { account: account })
|
|
28
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
29
|
+
.orderBy('timestamp', 'ASC')
|
|
30
30
|
.getMany();
|
|
31
31
|
}
|
|
32
|
-
async findByLastTimestamp() {
|
|
32
|
+
async findByLastTimestamp(blockchainCode) {
|
|
33
33
|
return await this.repository
|
|
34
|
-
.createQueryBuilder(
|
|
35
|
-
.
|
|
34
|
+
.createQueryBuilder()
|
|
35
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
36
|
+
.orderBy('last_closed_position_timestamp', 'DESC')
|
|
36
37
|
.take(1)
|
|
37
38
|
.getOne();
|
|
38
39
|
}
|
|
39
|
-
async findByAccountAndTimestamp(account, timestamp) {
|
|
40
|
+
async findByAccountAndTimestamp(account, timestamp, blockchainCode) {
|
|
40
41
|
return await this.repository
|
|
41
|
-
.createQueryBuilder(
|
|
42
|
-
.where('
|
|
43
|
-
.andWhere('
|
|
44
|
-
.
|
|
45
|
-
.setParameter('timestamp', timestamp)
|
|
42
|
+
.createQueryBuilder()
|
|
43
|
+
.where('account = :account', { account: account })
|
|
44
|
+
.andWhere('timestamp = :timestamp', { timestamp: timestamp })
|
|
45
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
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(): Promise<LimitOrderEntity[]>;
|
|
9
|
-
getByTokenId(tokenId: number): Promise<LimitOrderEntity | null>;
|
|
8
|
+
getAllByStatusOpen(blockchainCode: string): Promise<LimitOrderEntity[]>;
|
|
9
|
+
getByTokenId(tokenId: number, blockchainCode: string): Promise<LimitOrderEntity | null>;
|
|
10
10
|
}
|
|
@@ -28,18 +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(blockchainCode) {
|
|
32
32
|
return this.repository
|
|
33
33
|
.createQueryBuilder()
|
|
34
34
|
.where('status = :status', { status: constants_1.LimitOrderStatus.OPEN })
|
|
35
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
35
36
|
.orderBy('liquidation_price', 'DESC')
|
|
36
37
|
.getMany();
|
|
37
38
|
}
|
|
38
|
-
async getByTokenId(tokenId) {
|
|
39
|
+
async getByTokenId(tokenId, blockchainCode) {
|
|
39
40
|
return await this.repository
|
|
40
41
|
.createQueryBuilder()
|
|
41
|
-
.where('
|
|
42
|
-
.
|
|
42
|
+
.where('token_id = :tokenId', { tokenId: tokenId })
|
|
43
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
43
44
|
.where('status = :status', { status: constants_1.LimitOrderStatus.OPEN })
|
|
44
45
|
.take(1)
|
|
45
46
|
.getOne();
|
|
@@ -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(): Promise<OrderExecution | null>;
|
|
8
|
+
getLatestRecord(blockchainCode: string): Promise<OrderExecution | null>;
|
|
9
9
|
}
|
|
@@ -27,8 +27,14 @@ let OrderExecutionRepository = class OrderExecutionRepository {
|
|
|
27
27
|
async saveAll(orderExecutions) {
|
|
28
28
|
return this.repository.save(orderExecutions);
|
|
29
29
|
}
|
|
30
|
-
async getLatestRecord() {
|
|
31
|
-
return this.repository
|
|
30
|
+
async getLatestRecord(blockchainCode) {
|
|
31
|
+
return this.repository
|
|
32
|
+
.createQueryBuilder()
|
|
33
|
+
.where('blockchain_code = :blockchainCode')
|
|
34
|
+
.setParameter('blockchainCode', blockchainCode)
|
|
35
|
+
.orderBy('executed_at', 'DESC')
|
|
36
|
+
.limit(1)
|
|
37
|
+
.getOne();
|
|
32
38
|
}
|
|
33
39
|
};
|
|
34
40
|
exports.OrderExecutionRepository = OrderExecutionRepository;
|
|
@@ -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(): Promise<PositionEntity[]>;
|
|
10
|
-
updateLiquidationPrice(tokenId: number, liqPrice: BigNumber): Promise<void>;
|
|
11
|
-
getOneByTokenId(tokenId: number): Promise<PositionEntity | null>;
|
|
12
|
-
getLatestUpdateAtBlock(): Promise<number>;
|
|
9
|
+
getAllByStatusOpen(blockchainCode: string): Promise<PositionEntity[]>;
|
|
10
|
+
updateLiquidationPrice(tokenId: number, blockchainCode: string, liqPrice: BigNumber): Promise<void>;
|
|
11
|
+
getOneByTokenId(tokenId: number, blockchainCode: string): Promise<PositionEntity | null>;
|
|
12
|
+
getLatestUpdateAtBlock(blockchainCode: string): Promise<number>;
|
|
13
13
|
}
|
|
@@ -28,33 +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(blockchainCode) {
|
|
32
32
|
return this.repository
|
|
33
33
|
.createQueryBuilder()
|
|
34
34
|
.where('status = :status', { status: constants_1.LeveragePositionStatus.OPEN })
|
|
35
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
35
36
|
.orderBy('liquidation_price', 'DESC')
|
|
36
37
|
.getMany();
|
|
37
38
|
}
|
|
38
|
-
async updateLiquidationPrice(tokenId, liqPrice) {
|
|
39
|
+
async updateLiquidationPrice(tokenId, blockchainCode, liqPrice) {
|
|
39
40
|
await this.repository
|
|
40
41
|
.createQueryBuilder()
|
|
41
42
|
.update(entity_1.PositionEntity)
|
|
42
43
|
.set({ liquidationPrice: liqPrice })
|
|
43
44
|
.where('token_id = :tokenId', { tokenId: tokenId })
|
|
45
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
44
46
|
.execute();
|
|
45
47
|
}
|
|
46
|
-
async getOneByTokenId(tokenId) {
|
|
48
|
+
async getOneByTokenId(tokenId, blockchainCode) {
|
|
47
49
|
return await this.repository
|
|
48
50
|
.createQueryBuilder()
|
|
49
|
-
.where('token_id = :tokenId')
|
|
50
|
-
.
|
|
51
|
+
.where('token_id = :tokenId', { tokenId: tokenId })
|
|
52
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
51
53
|
.take(1)
|
|
52
54
|
.getOne();
|
|
53
55
|
}
|
|
54
|
-
async getLatestUpdateAtBlock() {
|
|
56
|
+
async getLatestUpdateAtBlock(blockchainCode) {
|
|
55
57
|
const p = await this.repository
|
|
56
58
|
.createQueryBuilder('position')
|
|
57
59
|
.select(['position.block_updated_at'])
|
|
60
|
+
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
58
61
|
.orderBy('block_updated_at', 'DESC')
|
|
59
62
|
.getRawOne();
|
|
60
63
|
return p ? parseInt(p.block_updated_at) : 0;
|
|
@@ -7,9 +7,9 @@ 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): Promise<FlatcoinPriceParent[]>;
|
|
11
|
-
findLast(): Promise<FlatcoinPrice | null>;
|
|
12
|
-
findFirstByTimestamp(fromTimestamp: number): Promise<FlatcoinPrice | null>;
|
|
13
|
-
findFirst(): Promise<FlatcoinPrice | null>;
|
|
10
|
+
findAllByPeriod(period: string, blockchainCode: string): Promise<FlatcoinPriceParent[]>;
|
|
11
|
+
findLast(blockchainCode: string): Promise<FlatcoinPrice | null>;
|
|
12
|
+
findFirstByTimestamp(fromTimestamp: number, blockchainCode: string): Promise<FlatcoinPrice | null>;
|
|
13
|
+
findFirst(blockchainCode: string): Promise<FlatcoinPrice | null>;
|
|
14
14
|
private getRepository;
|
|
15
15
|
}
|
|
@@ -26,23 +26,42 @@ let PriceRepository = class PriceRepository {
|
|
|
26
26
|
this.flatcoinPriceOneYearRepository = flatcoinPriceOneYearRepository;
|
|
27
27
|
this.repository = repository;
|
|
28
28
|
}
|
|
29
|
-
async findAllByPeriod(period) {
|
|
30
|
-
return this.getRepository(period)
|
|
29
|
+
async findAllByPeriod(period, blockchainCode) {
|
|
30
|
+
return this.getRepository(period)
|
|
31
|
+
.createQueryBuilder('price')
|
|
32
|
+
.where('blockchain_code = :blockchainCode')
|
|
33
|
+
.setParameter('blockchainCode', blockchainCode)
|
|
34
|
+
.orderBy('price.timestamp', 'ASC')
|
|
35
|
+
.getMany();
|
|
31
36
|
}
|
|
32
|
-
async findLast() {
|
|
33
|
-
return this.repository
|
|
37
|
+
async findLast(blockchainCode) {
|
|
38
|
+
return this.repository
|
|
39
|
+
.createQueryBuilder('price')
|
|
40
|
+
.where('blockchain_code = :blockchainCode')
|
|
41
|
+
.setParameter('blockchainCode', blockchainCode)
|
|
42
|
+
.orderBy('price.timestamp', 'DESC')
|
|
43
|
+
.take(1)
|
|
44
|
+
.getOne();
|
|
34
45
|
}
|
|
35
|
-
async findFirstByTimestamp(fromTimestamp) {
|
|
46
|
+
async findFirstByTimestamp(fromTimestamp, blockchainCode) {
|
|
36
47
|
return await this.repository
|
|
37
48
|
.createQueryBuilder('price')
|
|
38
49
|
.where('timestamp > :fromTimestamp')
|
|
50
|
+
.andWhere('blockchain_code = :blockchainCode')
|
|
51
|
+
.setParameter('blockchainCode', blockchainCode)
|
|
39
52
|
.orderBy('price.timestamp', 'ASC')
|
|
40
53
|
.setParameter('fromTimestamp', fromTimestamp)
|
|
41
54
|
.take(1)
|
|
42
55
|
.getOne();
|
|
43
56
|
}
|
|
44
|
-
async findFirst() {
|
|
45
|
-
return await this.repository
|
|
57
|
+
async findFirst(blockchainCode) {
|
|
58
|
+
return await this.repository
|
|
59
|
+
.createQueryBuilder('price')
|
|
60
|
+
.where('blockchain_code = :blockchainCode')
|
|
61
|
+
.setParameter('blockchainCode', blockchainCode)
|
|
62
|
+
.orderBy('price.timestamp', 'ASC')
|
|
63
|
+
.take(1)
|
|
64
|
+
.getOne();
|
|
46
65
|
}
|
|
47
66
|
getRepository(period) {
|
|
48
67
|
switch (period) {
|
|
@@ -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(): Promise<ProtocolMetrics | null>;
|
|
7
|
+
getLatestRecord(blockchainCode: string): Promise<ProtocolMetrics | null>;
|
|
8
8
|
}
|
|
@@ -24,8 +24,12 @@ let ProtocolMetricsRepository = class ProtocolMetricsRepository {
|
|
|
24
24
|
async save(protocolMetrics) {
|
|
25
25
|
return this.repository.save(protocolMetrics);
|
|
26
26
|
}
|
|
27
|
-
async getLatestRecord() {
|
|
28
|
-
return this.repository
|
|
27
|
+
async getLatestRecord(blockchainCode) {
|
|
28
|
+
return this.repository
|
|
29
|
+
.createQueryBuilder()
|
|
30
|
+
.where('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
31
|
+
.limit(1)
|
|
32
|
+
.getOne();
|
|
29
33
|
}
|
|
30
34
|
};
|
|
31
35
|
exports.ProtocolMetricsRepository = ProtocolMetricsRepository;
|
|
@@ -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): Promise<UnitBalanceParent[]>;
|
|
15
|
+
findAllByPeriod(account: string, period: string, blockchainCode: 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, blockchainCode) {
|
|
34
34
|
return this.getRepository(period)
|
|
35
35
|
.createQueryBuilder()
|
|
36
|
-
.where('account = :account')
|
|
37
|
-
.
|
|
36
|
+
.where('account = :account', { account: account })
|
|
37
|
+
.andWhere('blockchain_code = :blockchainCode', { blockchainCode: blockchainCode })
|
|
38
38
|
.orderBy('timestamp', 'ASC')
|
|
39
39
|
.getMany();
|
|
40
40
|
}
|
|
@@ -2,7 +2,8 @@ import { Logger } from '@nestjs/common';
|
|
|
2
2
|
import { TokenTransfer } from '../dto';
|
|
3
3
|
export declare class BlockscanService {
|
|
4
4
|
private readonly logger;
|
|
5
|
-
private readonly
|
|
5
|
+
private readonly baseBlockscanUri;
|
|
6
6
|
constructor(logger: Logger);
|
|
7
|
-
getTokenTransfers(contractAddress: string, startBlock: number, endBlock: number): Promise<TokenTransfer[]>;
|
|
7
|
+
getTokenTransfers(contractAddress: string, startBlock: number, endBlock: number, blockChainCode: string): Promise<TokenTransfer[]>;
|
|
8
|
+
private getUri;
|
|
8
9
|
}
|
|
@@ -17,16 +17,17 @@ const common_1 = require("@nestjs/common");
|
|
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
18
|
const ethers_1 = require("ethers");
|
|
19
19
|
const dto_1 = require("../dto");
|
|
20
|
+
const constants_1 = require("../constants");
|
|
20
21
|
let BlockscanService = class BlockscanService {
|
|
21
22
|
constructor(logger) {
|
|
22
23
|
this.logger = logger;
|
|
23
24
|
if (process.env.BASE_BLOCKSCAN_URI) {
|
|
24
|
-
this.
|
|
25
|
+
this.baseBlockscanUri = process.env.BASE_BLOCKSCAN_URI;
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
async getTokenTransfers(contractAddress, startBlock, endBlock) {
|
|
28
|
+
async getTokenTransfers(contractAddress, startBlock, endBlock, blockChainCode) {
|
|
28
29
|
try {
|
|
29
|
-
const response = await axios_1.default.get(`${this.
|
|
30
|
+
const response = await axios_1.default.get(`${this.getUri(blockChainCode)}&module=account&action=tokentx&contractaddress=${contractAddress}&startblock=${startBlock}&endblock=${endBlock}&page=1&offset=10000&sort=asc`);
|
|
30
31
|
const result = response.data.result.map((r) => {
|
|
31
32
|
const tokenTransfer = new dto_1.TokenTransfer();
|
|
32
33
|
tokenTransfer.blockNumber = +r.blockNumber;
|
|
@@ -45,6 +46,12 @@ let BlockscanService = class BlockscanService {
|
|
|
45
46
|
throw error;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
getUri(blockChainCode) {
|
|
50
|
+
if (constants_1.BlockchainCode.BASE == blockChainCode) {
|
|
51
|
+
return this.baseBlockscanUri;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`BlockscanService -> blockchain code ${blockChainCode} is not supported`);
|
|
54
|
+
}
|
|
48
55
|
};
|
|
49
56
|
exports.BlockscanService = BlockscanService;
|
|
50
57
|
exports.BlockscanService = BlockscanService = __decorate([
|