@dhedge/backend-flatcoin-core 0.1.18 → 0.1.19
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/entity/apy.d.ts +12 -0
- package/dist/entity/apy.js +48 -0
- package/dist/entity/competitionBoardAccount.d.ts +14 -0
- package/dist/entity/competitionBoardAccount.js +80 -0
- package/dist/entity/flatcoin.price.parent.js +4 -3
- package/dist/entity/index.d.ts +1 -0
- package/dist/entity/index.js +1 -0
- package/dist/repository/apy-history.repository.d.ts +4 -1
- package/dist/repository/apy-history.repository.js +7 -2
- package/dist/repository/apy.repository.d.ts +4 -1
- package/dist/repository/apy.repository.js +7 -2
- package/dist/repository/flatcoin-pnl.repository.d.ts +12 -0
- package/dist/repository/flatcoin-pnl.repository.js +49 -0
- package/dist/repository/index.d.ts +1 -0
- package/dist/repository/index.js +1 -0
- package/dist/repository/price.repository.d.ts +6 -2
- package/dist/repository/price.repository.js +20 -6
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/shared-types.d.ts +24 -0
- package/dist/utils/shared-types.js +6 -0
- package/package.json +4 -2
- /package/dist/utils/{price.util.d.ts → util.d.ts} +0 -0
- /package/dist/utils/{price.util.js → util.js} +0 -0
package/dist/entity/apy.d.ts
CHANGED
|
@@ -3,4 +3,16 @@ export declare class Apy {
|
|
|
3
3
|
monthly: number;
|
|
4
4
|
weekly: number;
|
|
5
5
|
daily: number;
|
|
6
|
+
monthly1: number;
|
|
7
|
+
weekly1: number;
|
|
8
|
+
daily1: number;
|
|
9
|
+
monthly2: number;
|
|
10
|
+
weekly2: number;
|
|
11
|
+
daily2: number;
|
|
12
|
+
monthly3: number;
|
|
13
|
+
weekly3: number;
|
|
14
|
+
daily3: number;
|
|
15
|
+
monthly4: number;
|
|
16
|
+
weekly4: number;
|
|
17
|
+
daily4: number;
|
|
6
18
|
}
|
package/dist/entity/apy.js
CHANGED
|
@@ -35,6 +35,54 @@ __decorate([
|
|
|
35
35
|
(0, typeorm_1.Column)({ name: 'daily', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
36
36
|
__metadata("design:type", Number)
|
|
37
37
|
], Apy.prototype, "daily", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'monthly_1', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], Apy.prototype, "monthly1", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: 'weekly_1', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], Apy.prototype, "weekly1", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ name: 'daily_1', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], Apy.prototype, "daily1", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ name: 'monthly_2', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], Apy.prototype, "monthly2", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ name: 'weekly_2', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], Apy.prototype, "weekly2", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ name: 'daily_2', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], Apy.prototype, "daily2", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.Column)({ name: 'monthly_3', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], Apy.prototype, "monthly3", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.Column)({ name: 'weekly_3', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
68
|
+
__metadata("design:type", Number)
|
|
69
|
+
], Apy.prototype, "weekly3", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.Column)({ name: 'daily_3', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
72
|
+
__metadata("design:type", Number)
|
|
73
|
+
], Apy.prototype, "daily3", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({ name: 'monthly_4', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
76
|
+
__metadata("design:type", Number)
|
|
77
|
+
], Apy.prototype, "monthly4", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ name: 'weekly_4', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
80
|
+
__metadata("design:type", Number)
|
|
81
|
+
], Apy.prototype, "weekly4", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({ name: 'daily_4', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
84
|
+
__metadata("design:type", Number)
|
|
85
|
+
], Apy.prototype, "daily4", void 0);
|
|
38
86
|
exports.Apy = Apy = __decorate([
|
|
39
87
|
(0, graphql_1.ObjectType)(),
|
|
40
88
|
(0, typeorm_1.Entity)({ name: 'apy' })
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class CompetitionBoardAccount {
|
|
2
|
+
id: number;
|
|
3
|
+
account: string;
|
|
4
|
+
twitterAccount: string;
|
|
5
|
+
twitterProfileImage: string;
|
|
6
|
+
emailAddress: string;
|
|
7
|
+
wethBalanceFormatted: number;
|
|
8
|
+
flatcoinBalanceFormatted: number;
|
|
9
|
+
marginBalanceWethFormatted: number;
|
|
10
|
+
totalWethValueFormatted: number;
|
|
11
|
+
totalUsdValueFormatted: number;
|
|
12
|
+
performanceFormatted: number;
|
|
13
|
+
statusOfCalculation: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CompetitionBoardAccount = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
15
|
+
let CompetitionBoardAccount = class CompetitionBoardAccount {
|
|
16
|
+
};
|
|
17
|
+
exports.CompetitionBoardAccount = CompetitionBoardAccount;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], CompetitionBoardAccount.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
24
|
+
(0, typeorm_1.Column)({ name: 'account', unique: true, nullable: false }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], CompetitionBoardAccount.prototype, "account", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
29
|
+
(0, typeorm_1.Column)({ name: 'twitter_account' }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], CompetitionBoardAccount.prototype, "twitterAccount", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
34
|
+
(0, typeorm_1.Column)({ name: 'twitter_profile_image' }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], CompetitionBoardAccount.prototype, "twitterProfileImage", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'email_address' }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], CompetitionBoardAccount.prototype, "emailAddress", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
44
|
+
(0, typeorm_1.Column)({ name: 'weth_balance_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], CompetitionBoardAccount.prototype, "wethBalanceFormatted", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
49
|
+
(0, typeorm_1.Column)({ name: 'flatcoin_balance_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
50
|
+
__metadata("design:type", Number)
|
|
51
|
+
], CompetitionBoardAccount.prototype, "flatcoinBalanceFormatted", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
54
|
+
(0, typeorm_1.Column)({ name: 'margin_balance_weth_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
55
|
+
__metadata("design:type", Number)
|
|
56
|
+
], CompetitionBoardAccount.prototype, "marginBalanceWethFormatted", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
59
|
+
(0, typeorm_1.Column)({ name: 'total_weth_value_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], CompetitionBoardAccount.prototype, "totalWethValueFormatted", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
64
|
+
(0, typeorm_1.Column)({ name: 'total_usd_value_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
65
|
+
__metadata("design:type", Number)
|
|
66
|
+
], CompetitionBoardAccount.prototype, "totalUsdValueFormatted", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
69
|
+
(0, typeorm_1.Column)({ name: 'performance_formatted', type: 'decimal', precision: 20, scale: 2 }),
|
|
70
|
+
__metadata("design:type", Number)
|
|
71
|
+
], CompetitionBoardAccount.prototype, "performanceFormatted", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
74
|
+
(0, typeorm_1.Column)({ name: 'status_of_calculation' }),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], CompetitionBoardAccount.prototype, "statusOfCalculation", void 0);
|
|
77
|
+
exports.CompetitionBoardAccount = CompetitionBoardAccount = __decorate([
|
|
78
|
+
(0, graphql_1.ObjectType)(),
|
|
79
|
+
(0, typeorm_1.Entity)({ name: 'account_competition_board' })
|
|
80
|
+
], CompetitionBoardAccount);
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.FlatcoinPriceParent = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const graphql_1 = require("@nestjs/graphql");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
15
16
|
let FlatcoinPriceParent = class FlatcoinPriceParent {
|
|
16
17
|
};
|
|
17
18
|
exports.FlatcoinPriceParent = FlatcoinPriceParent;
|
|
@@ -26,16 +27,16 @@ __decorate([
|
|
|
26
27
|
], FlatcoinPriceParent.prototype, "priceUsd", void 0);
|
|
27
28
|
__decorate([
|
|
28
29
|
(0, graphql_1.Field)(),
|
|
29
|
-
(0, typeorm_1.Column)({ name: 'price_usd_formatted', type: 'decimal', precision: 10, scale: 2 }),
|
|
30
|
+
(0, typeorm_1.Column)({ name: 'price_usd_formatted', type: 'decimal', precision: 10, scale: 2, transformer: utils_1.numericTransformer }),
|
|
30
31
|
__metadata("design:type", Number)
|
|
31
32
|
], FlatcoinPriceParent.prototype, "priceUsdFormatted", void 0);
|
|
32
33
|
__decorate([
|
|
33
34
|
(0, graphql_1.Field)(),
|
|
34
|
-
(0, typeorm_1.Column)({ name: 'timestamp', type: 'numeric', precision: 25 }),
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'timestamp', type: 'numeric', precision: 25, transformer: utils_1.numericTransformer }),
|
|
35
36
|
__metadata("design:type", Number)
|
|
36
37
|
], FlatcoinPriceParent.prototype, "timestamp", void 0);
|
|
37
38
|
__decorate([
|
|
38
|
-
(0, typeorm_1.Column)({ name: 'block_number', type: 'numeric', precision: 25 }),
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'block_number', type: 'numeric', precision: 25, transformer: utils_1.numericTransformer }),
|
|
39
40
|
__metadata("design:type", Number)
|
|
40
41
|
], FlatcoinPriceParent.prototype, "blockNumber", void 0);
|
|
41
42
|
exports.FlatcoinPriceParent = FlatcoinPriceParent = __decorate([
|
package/dist/entity/index.d.ts
CHANGED
package/dist/entity/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
1
2
|
import { Repository } from 'typeorm';
|
|
2
3
|
import { ApyHistory } from '../entity';
|
|
3
4
|
export declare class ApyHistoryRepository {
|
|
4
5
|
private readonly repository;
|
|
5
|
-
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repository: Repository<ApyHistory>, logger: Logger);
|
|
6
8
|
getAllFromTimestamp(fromTimestamp: number): Promise<ApyHistory[]>;
|
|
9
|
+
save(apyHistory: ApyHistory): void;
|
|
7
10
|
}
|
|
@@ -18,8 +18,9 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
18
18
|
const typeorm_2 = require("typeorm");
|
|
19
19
|
const entity_1 = require("../entity");
|
|
20
20
|
let ApyHistoryRepository = class ApyHistoryRepository {
|
|
21
|
-
constructor(repository) {
|
|
21
|
+
constructor(repository, logger) {
|
|
22
22
|
this.repository = repository;
|
|
23
|
+
this.logger = logger;
|
|
23
24
|
}
|
|
24
25
|
async getAllFromTimestamp(fromTimestamp) {
|
|
25
26
|
return await this.repository
|
|
@@ -29,10 +30,14 @@ let ApyHistoryRepository = class ApyHistoryRepository {
|
|
|
29
30
|
.setParameter('fromTimestamp', fromTimestamp)
|
|
30
31
|
.getMany();
|
|
31
32
|
}
|
|
33
|
+
save(apyHistory) {
|
|
34
|
+
this.repository.save(apyHistory).catch((error) => this.logger.error('Error while saving apy history', error));
|
|
35
|
+
}
|
|
32
36
|
};
|
|
33
37
|
exports.ApyHistoryRepository = ApyHistoryRepository;
|
|
34
38
|
exports.ApyHistoryRepository = ApyHistoryRepository = __decorate([
|
|
35
39
|
(0, common_1.Injectable)(),
|
|
36
40
|
__param(0, (0, typeorm_1.InjectRepository)(entity_1.ApyHistory)),
|
|
37
|
-
__metadata("design:paramtypes", [typeorm_2.Repository
|
|
41
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
42
|
+
common_1.Logger])
|
|
38
43
|
], ApyHistoryRepository);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
1
2
|
import { Repository } from 'typeorm';
|
|
2
3
|
import { Apy } from '../entity';
|
|
3
4
|
export declare class ApyRepository {
|
|
4
5
|
private repository;
|
|
5
|
-
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repository: Repository<Apy>, logger: Logger);
|
|
6
8
|
getApy(): Promise<Apy | null>;
|
|
9
|
+
save(apy: Apy): void;
|
|
7
10
|
}
|
|
@@ -18,16 +18,21 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
18
18
|
const typeorm_2 = require("typeorm");
|
|
19
19
|
const entity_1 = require("../entity");
|
|
20
20
|
let ApyRepository = class ApyRepository {
|
|
21
|
-
constructor(repository) {
|
|
21
|
+
constructor(repository, logger) {
|
|
22
22
|
this.repository = repository;
|
|
23
|
+
this.logger = logger;
|
|
23
24
|
}
|
|
24
25
|
async getApy() {
|
|
25
26
|
return this.repository.createQueryBuilder().getOne();
|
|
26
27
|
}
|
|
28
|
+
save(apy) {
|
|
29
|
+
this.repository.save(apy).catch((error) => this.logger.error('Error while saving apy', error));
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
exports.ApyRepository = ApyRepository;
|
|
29
33
|
exports.ApyRepository = ApyRepository = __decorate([
|
|
30
34
|
(0, common_1.Injectable)(),
|
|
31
35
|
__param(0, (0, typeorm_1.InjectRepository)(entity_1.Apy)),
|
|
32
|
-
__metadata("design:paramtypes", [typeorm_2.Repository
|
|
36
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
37
|
+
common_1.Logger])
|
|
33
38
|
], ApyRepository);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { FlatcoinPnl } from '../entity/flatcoin-pnl';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
export declare class FlatcoinPnlRepository {
|
|
5
|
+
private readonly repository;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repository: Repository<FlatcoinPnl>, logger: Logger);
|
|
8
|
+
getAll(): Promise<FlatcoinPnl[]>;
|
|
9
|
+
save(flatcoinPnls: FlatcoinPnl[]): void;
|
|
10
|
+
getLastUpdatedAt(): Promise<FlatcoinPnl | null>;
|
|
11
|
+
findByAccount(account: string): Promise<FlatcoinPnl | null>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FlatcoinPnlRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const flatcoin_pnl_1 = require("../entity/flatcoin-pnl");
|
|
19
|
+
const typeorm_2 = require("typeorm");
|
|
20
|
+
let FlatcoinPnlRepository = class FlatcoinPnlRepository {
|
|
21
|
+
constructor(repository, logger) {
|
|
22
|
+
this.repository = repository;
|
|
23
|
+
this.logger = logger;
|
|
24
|
+
}
|
|
25
|
+
async getAll() {
|
|
26
|
+
return this.repository.createQueryBuilder().getMany();
|
|
27
|
+
}
|
|
28
|
+
save(flatcoinPnls) {
|
|
29
|
+
this.repository.save(flatcoinPnls).catch((error) => this.logger.error('Error while saving flatcoin pnl', error));
|
|
30
|
+
}
|
|
31
|
+
async getLastUpdatedAt() {
|
|
32
|
+
return await this.repository.createQueryBuilder('pnl').orderBy('pnl.block_updated_at', 'DESC').take(1).getOne();
|
|
33
|
+
}
|
|
34
|
+
async findByAccount(account) {
|
|
35
|
+
return await this.repository
|
|
36
|
+
.createQueryBuilder('pnl')
|
|
37
|
+
.where('pnl.account = :account')
|
|
38
|
+
.setParameter('account', account)
|
|
39
|
+
.take(1)
|
|
40
|
+
.getOne();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.FlatcoinPnlRepository = FlatcoinPnlRepository;
|
|
44
|
+
exports.FlatcoinPnlRepository = FlatcoinPnlRepository = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__param(0, (0, typeorm_1.InjectRepository)(flatcoin_pnl_1.FlatcoinPnl)),
|
|
47
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
48
|
+
common_1.Logger])
|
|
49
|
+
], FlatcoinPnlRepository);
|
package/dist/repository/index.js
CHANGED
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./apy-history.repository"), exports);
|
|
18
18
|
__exportStar(require("./apy.repository"), exports);
|
|
19
19
|
__exportStar(require("./price.repository"), exports);
|
|
20
|
+
__exportStar(require("./flatcoin-pnl.repository"), exports);
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Repository } from 'typeorm';
|
|
2
|
-
import { FlatcoinPriceOneDay, FlatcoinPriceOneMonth, FlatcoinPriceOneWeek, FlatcoinPriceOneYear, FlatcoinPriceParent } from '../entity';
|
|
2
|
+
import { FlatcoinPrice, FlatcoinPriceOneDay, FlatcoinPriceOneMonth, FlatcoinPriceOneWeek, FlatcoinPriceOneYear, FlatcoinPriceParent } from '../entity';
|
|
3
3
|
export declare class PriceRepository {
|
|
4
4
|
private flatcoinPriceOneDayRepository;
|
|
5
5
|
private flatcoinPriceOneWeekRepository;
|
|
6
6
|
private flatcoinPriceOneMonthRepository;
|
|
7
7
|
private flatcoinPriceOneYearRepository;
|
|
8
|
-
|
|
8
|
+
private readonly repository;
|
|
9
|
+
constructor(flatcoinPriceOneDayRepository: Repository<FlatcoinPriceOneDay>, flatcoinPriceOneWeekRepository: Repository<FlatcoinPriceOneWeek>, flatcoinPriceOneMonthRepository: Repository<FlatcoinPriceOneMonth>, flatcoinPriceOneYearRepository: Repository<FlatcoinPriceOneYear>, repository: Repository<FlatcoinPrice>);
|
|
9
10
|
findAllByPeriod(period: string): Promise<FlatcoinPriceParent[]>;
|
|
11
|
+
findLast(): Promise<FlatcoinPrice | null>;
|
|
12
|
+
findFirstByTimestamp(fromTimestamp: number): Promise<FlatcoinPrice | null>;
|
|
13
|
+
findFirst(): Promise<FlatcoinPrice | null>;
|
|
10
14
|
private getRepository;
|
|
11
15
|
}
|
|
@@ -19,18 +19,30 @@ const typeorm_2 = require("typeorm");
|
|
|
19
19
|
const entity_1 = require("../entity");
|
|
20
20
|
const constants_1 = require("../constants");
|
|
21
21
|
let PriceRepository = class PriceRepository {
|
|
22
|
-
constructor(flatcoinPriceOneDayRepository, flatcoinPriceOneWeekRepository, flatcoinPriceOneMonthRepository, flatcoinPriceOneYearRepository) {
|
|
22
|
+
constructor(flatcoinPriceOneDayRepository, flatcoinPriceOneWeekRepository, flatcoinPriceOneMonthRepository, flatcoinPriceOneYearRepository, repository) {
|
|
23
23
|
this.flatcoinPriceOneDayRepository = flatcoinPriceOneDayRepository;
|
|
24
24
|
this.flatcoinPriceOneWeekRepository = flatcoinPriceOneWeekRepository;
|
|
25
25
|
this.flatcoinPriceOneMonthRepository = flatcoinPriceOneMonthRepository;
|
|
26
26
|
this.flatcoinPriceOneYearRepository = flatcoinPriceOneYearRepository;
|
|
27
|
+
this.repository = repository;
|
|
27
28
|
}
|
|
28
29
|
async findAllByPeriod(period) {
|
|
29
|
-
return this.getRepository(period).
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
return this.getRepository(period).createQueryBuilder('price').orderBy('price.timestamp', 'ASC').getMany();
|
|
31
|
+
}
|
|
32
|
+
async findLast() {
|
|
33
|
+
return this.repository.createQueryBuilder('price').orderBy('price.timestamp', 'DESC').take(1).getOne();
|
|
34
|
+
}
|
|
35
|
+
async findFirstByTimestamp(fromTimestamp) {
|
|
36
|
+
return await this.repository
|
|
37
|
+
.createQueryBuilder('price')
|
|
38
|
+
.where('timestamp > :fromTimestamp')
|
|
39
|
+
.orderBy('price.timestamp', 'ASC')
|
|
40
|
+
.setParameter('fromTimestamp', fromTimestamp)
|
|
41
|
+
.take(1)
|
|
42
|
+
.getOne();
|
|
43
|
+
}
|
|
44
|
+
async findFirst() {
|
|
45
|
+
return await this.repository.createQueryBuilder('price').orderBy('price.timestamp', 'ASC').take(1).getOne();
|
|
34
46
|
}
|
|
35
47
|
getRepository(period) {
|
|
36
48
|
switch (period) {
|
|
@@ -54,7 +66,9 @@ exports.PriceRepository = PriceRepository = __decorate([
|
|
|
54
66
|
__param(1, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPriceOneWeek)),
|
|
55
67
|
__param(2, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPriceOneMonth)),
|
|
56
68
|
__param(3, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPriceOneYear)),
|
|
69
|
+
__param(4, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPrice)),
|
|
57
70
|
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
71
|
+
typeorm_2.Repository,
|
|
58
72
|
typeorm_2.Repository,
|
|
59
73
|
typeorm_2.Repository,
|
|
60
74
|
typeorm_2.Repository])
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./column.numeric.transformer"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./util"), exports);
|
|
19
|
+
__exportStar(require("./shared-types"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
export interface DepositEvent {
|
|
3
|
+
blockNumber: string;
|
|
4
|
+
depositor: string;
|
|
5
|
+
depositAmount: string;
|
|
6
|
+
mintedAmount: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Deposits {
|
|
9
|
+
deposits: DepositEvent[];
|
|
10
|
+
}
|
|
11
|
+
export interface WithdrawEvent {
|
|
12
|
+
blockNumber: string;
|
|
13
|
+
withdrawer: string;
|
|
14
|
+
withdrawAmount: string;
|
|
15
|
+
burnedAmount: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Withdraws {
|
|
18
|
+
withdraws: WithdrawEvent[];
|
|
19
|
+
}
|
|
20
|
+
export declare class DepositWithdrawAction {
|
|
21
|
+
isDeposit: boolean;
|
|
22
|
+
blockNumber: number;
|
|
23
|
+
unitAmount: BigNumber;
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhedge/backend-flatcoin-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Backend Flatcoin Core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"@nestjs/graphql": "^12.0.9",
|
|
21
21
|
"@nestjs/typeorm": "^9.0.0",
|
|
22
22
|
"typeorm": "^0.3.17",
|
|
23
|
-
"ethers": "5.7.2"
|
|
23
|
+
"ethers": "5.7.2",
|
|
24
|
+
"nest-winston": "1.9.3",
|
|
25
|
+
"winston": "3.10.0"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@swc/core": "^1.3.90",
|
|
File without changes
|
|
File without changes
|