@dhedge/backend-flatcoin-core 0.3.1 → 0.3.3

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.
@@ -3,5 +3,5 @@ export declare class ApyHistory {
3
3
  blockchainCode: string;
4
4
  daily: number;
5
5
  timestamp: number;
6
- constructor(daily: number, timestamp: number);
6
+ constructor(daily: number, timestamp: number, blockchainCode: string);
7
7
  }
@@ -14,9 +14,10 @@ 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, timestamp) {
17
+ constructor(daily, timestamp, blockchainCode) {
18
18
  this.daily = daily;
19
19
  this.timestamp = timestamp;
20
+ this.blockchainCode = blockchainCode;
20
21
  }
21
22
  };
22
23
  exports.ApyHistory = ApyHistory;
@@ -42,5 +43,5 @@ __decorate([
42
43
  exports.ApyHistory = ApyHistory = __decorate([
43
44
  (0, graphql_1.ObjectType)(),
44
45
  (0, typeorm_1.Entity)({ name: 'apy_history' }),
45
- __metadata("design:paramtypes", [Number, Number])
46
+ __metadata("design:paramtypes", [Number, Number, String])
46
47
  ], ApyHistory);
@@ -4,5 +4,5 @@ export declare class BorrowingRateApyHistory {
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, blockchainCode: string);
8
8
  }
@@ -14,10 +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, blockchainCode) {
18
18
  this.daily = daily;
19
19
  this.eightHour = eightHour;
20
20
  this.timestamp = timestamp;
21
+ this.blockchainCode = blockchainCode;
21
22
  }
22
23
  };
23
24
  exports.BorrowingRateApyHistory = BorrowingRateApyHistory;
@@ -55,5 +56,5 @@ __decorate([
55
56
  exports.BorrowingRateApyHistory = BorrowingRateApyHistory = __decorate([
56
57
  (0, graphql_1.ObjectType)(),
57
58
  (0, typeorm_1.Entity)({ name: 'borrowing_rate_apy_history' }),
58
- __metadata("design:paramtypes", [Number, Number, Number])
59
+ __metadata("design:paramtypes", [Number, Number, Number, String])
59
60
  ], BorrowingRateApyHistory);
@@ -10,6 +10,7 @@ export declare class PriceRepository {
10
10
  findAllByPeriod(period: string, blockchainCode: string): Promise<FlatcoinPriceParent[]>;
11
11
  findLast(blockchainCode: string): Promise<FlatcoinPrice | null>;
12
12
  findFirstByTimestamp(fromTimestamp: number, blockchainCode: string): Promise<FlatcoinPrice | null>;
13
+ findFirstByBlock(fromBlock: number, blockchainCode: string): Promise<FlatcoinPrice | null>;
13
14
  findFirst(blockchainCode: string): Promise<FlatcoinPrice | null>;
14
15
  private getRepository;
15
16
  }
@@ -36,10 +36,10 @@ let PriceRepository = class PriceRepository {
36
36
  }
37
37
  async findLast(blockchainCode) {
38
38
  return this.repository
39
- .createQueryBuilder('price')
39
+ .createQueryBuilder()
40
40
  .where('blockchain_code = :blockchainCode')
41
41
  .setParameter('blockchainCode', blockchainCode)
42
- .orderBy('price.timestamp', 'DESC')
42
+ .orderBy('timestamp', 'DESC')
43
43
  .take(1)
44
44
  .getOne();
45
45
  }
@@ -54,6 +54,17 @@ let PriceRepository = class PriceRepository {
54
54
  .take(1)
55
55
  .getOne();
56
56
  }
57
+ async findFirstByBlock(fromBlock, blockchainCode) {
58
+ return await this.repository
59
+ .createQueryBuilder()
60
+ .where('block_number > :fromBlock')
61
+ .andWhere('blockchain_code = :blockchainCode')
62
+ .setParameter('blockchainCode', blockchainCode)
63
+ .setParameter('fromBlock', fromBlock)
64
+ .orderBy('timestamp', 'ASC')
65
+ .take(1)
66
+ .getOne();
67
+ }
57
68
  async findFirst(blockchainCode) {
58
69
  return await this.repository
59
70
  .createQueryBuilder('price')
@@ -45,7 +45,7 @@ let NotificationService = class NotificationService {
45
45
  await axios_1.default.post(slackUri, { text: message });
46
46
  }
47
47
  catch (error) {
48
- this.logger.error(`Error sending notification '${message}' to slack channel ${process.env.SLACK_CHANNEL}`, error);
48
+ this.logger.error(`Error sending notification '${message}' to slack channel ${slackUri}`, error);
49
49
  }
50
50
  }
51
51
  async sendSlackEmergencyNotification(message, slackUri = this.slackEmergencyUri) {
@@ -53,7 +53,7 @@ let NotificationService = class NotificationService {
53
53
  await axios_1.default.post(slackUri, { text: message });
54
54
  }
55
55
  catch (error) {
56
- this.logger.error(`Error sending notification '${message}' to slack channel ${process.env.SLACK_EMERGENCY_CHANNEL}`, error);
56
+ this.logger.error(`Error sending notification '${message}' to slack channel ${slackUri}`, error);
57
57
  }
58
58
  }
59
59
  async sendSlackMonitoringNotification(message, slackUri = this.slackMonitoringUri) {
@@ -62,7 +62,7 @@ let NotificationService = class NotificationService {
62
62
  await axios_1.default.post(slackUri, { text: message });
63
63
  }
64
64
  catch (error) {
65
- this.logger.error(`Error sending notification '${message}' to slack channel ${process.env.SLACK_MONITORING_CHANNEL}`, error);
65
+ this.logger.error(`Error sending notification '${message}' to slack channel ${slackUri}`, error);
66
66
  }
67
67
  }
68
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/backend-flatcoin-core",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Backend Flatcoin Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",