Skip to content

Commit

Permalink
Remove dfract related code. Global improvement + deps bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Segfaultd committed Feb 14, 2024
1 parent 8fa0191 commit 01895d8
Show file tree
Hide file tree
Showing 28 changed files with 1,063 additions and 1,652 deletions.
94 changes: 47 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,81 +32,81 @@
"test:e2e": "jest --config ./test/jest-e2e.json --runInBand --detectOpenHandles --forceExit"
},
"dependencies": {
"@bull-board/api": "^5.9.1",
"@bull-board/express": "^5.9.1",
"@lum-network/sdk-javascript": "^1.0.0-beta.2",
"@nestjs/axios": "^3.0.1",
"@nestjs/bull": "^10.0.1",
"@nestjs/cache-manager": "^2.1.1",
"@nestjs/common": "^10.2.10",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.2.10",
"@nestjs/microservices": "^10.2.10",
"@nestjs/platform-express": "^10.2.10",
"@nestjs/platform-socket.io": "^10.2.10",
"@nestjs/schedule": "^4.0.0",
"@nestjs/swagger": "^7.1.16",
"@nestjs/terminus": "^10.1.1",
"@nestjs/typeorm": "^10.0.1",
"@nestjs/websockets": "^10.2.10",
"@ntegral/nestjs-sentry": "^4.0.0",
"@sentry/node": "^7.81.1",
"@sentry/tracing": "^7.81.1",
"@bull-board/api": "^5.14.0",
"@bull-board/express": "^5.14.0",
"@lum-network/sdk-javascript": "^1.0.0",
"@nestjs/axios": "^3.0.2",
"@nestjs/bull": "^10.1.0",
"@nestjs/cache-manager": "^2.2.1",
"@nestjs/common": "^10.3.3",
"@nestjs/config": "^3.2.0",
"@nestjs/core": "^10.3.3",
"@nestjs/microservices": "^10.3.3",
"@nestjs/platform-express": "^10.3.3",
"@nestjs/platform-socket.io": "^10.3.3",
"@nestjs/schedule": "^4.0.1",
"@nestjs/swagger": "^7.3.0",
"@nestjs/terminus": "^10.2.2",
"@nestjs/typeorm": "^10.0.2",
"@nestjs/websockets": "^10.3.3",
"@ntegral/nestjs-sentry": "^4.0.1",
"@sentry/node": "^7.101.0",
"@sentry/tracing": "^7.101.0",
"@willsoto/nestjs-prometheus": "^6.0.0",
"bcrypt": "^5.1.1",
"bull": "^4.11.5",
"cache-manager": "^5.3.1",
"bull": "^4.12.2",
"cache-manager": "^5.4.0",
"cache-manager-redis-store": "^3.0.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"class-validator": "^0.14.1",
"dayjs": "^1.11.10",
"dotenv": "^16.3.1",
"dotenv": "^16.4.4",
"express-basic-auth": "^1.2.1",
"hosted-git-info": "^7.0.1",
"joi": "^17.11.0",
"joi": "^17.12.1",
"lodash": "^4.17.21",
"long": "^5.2.3",
"nestjs-console": "^9.0.0",
"node-notifier": "^10.0.1",
"parse-redis-url-simple": "^1.0.2",
"pg": "^8.11.3",
"prom-client": "^15.0.0",
"reflect-metadata": "^0.1.13",
"prom-client": "^15.1.0",
"reflect-metadata": "^0.2.1",
"rimraf": "^5.0.5",
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.0",
"typeorm": "0.3.17",
"typeorm": "0.3.20",
"xmlhttprequest-ssl": "^2.1.1"
},
"devDependencies": {
"@jest/test-sequencer": "^29.7.0",
"@nestjs/cli": "^10.2.1",
"@nestjs/schematics": "^10.0.3",
"@nestjs/testing": "^10.2.10",
"@swc/cli": "^0.1.63",
"@swc/core": "^1.3.99",
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^10.1.1",
"@nestjs/testing": "^10.3.3",
"@swc/cli": "^0.3.9",
"@swc/core": "^1.4.1",
"@types/bull": "^4.10.0",
"@types/cache-manager": "^4.0.6",
"@types/express": "^4.17.21",
"@types/jest": "29.5.10",
"@types/jest": "29.5.12",
"@types/joi": "^17.2.3",
"@types/node": "^20.9.4",
"@types/pg": "^8.10.9",
"@types/node": "^20.11.17",
"@types/pg": "^8.11.0",
"@types/socket.io": "^3.0.2",
"@types/supertest": "^2.0.16",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"eslint": "8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"prettier": "^3.1.0",
"supertest": "^6.3.3",
"ts-jest": "29.1.1",
"prettier": "^3.2.5",
"supertest": "^6.3.4",
"ts-jest": "29.1.2",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.2"
"typescript": "^5.3.3"
},
"jest": {
"moduleFileExtensions": [
Expand Down
83 changes: 0 additions & 83 deletions src/async/consumers/asset.consumer.ts

This file was deleted.

7 changes: 4 additions & 3 deletions src/async/consumers/block.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MsgMultiSend } from '@lum-network/sdk-javascript/build/codegen/cosmos/b

import { BlockEntity, TransactionEntity } from '@app/database';
import { BlockService, ChainService, TransactionService, ValidatorService } from '@app/services';
import { LumChain } from "@app/services/chains";
import { AssetSymbol, getAddressesRelatedToTransaction, isBeam, NotificationChannels, NotificationEvents, QueueJobs, QueuePriority, Queues } from '@app/utils';

@Processor(Queues.BLOCKS)
Expand Down Expand Up @@ -41,7 +42,7 @@ export class BlockConsumer {
this._logger.debug(`Ingesting block ${job.data.blockHeight} (attempt ${job.attemptsMade})`);

// Get block data
const block = await this._chainService.getChain(AssetSymbol.LUM).client.cosmos.base.tendermint.v1beta1.getBlockByHeight({ height: BigInt(job.data.blockHeight) });
const block = await this._chainService.getChain<LumChain>(AssetSymbol.LUM).client.cosmos.base.tendermint.v1beta1.getBlockByHeight({ height: BigInt(job.data.blockHeight) });

// Get the operator address
const proposerAddress = toBech32(LumBech32Prefixes.CONS_ADDR, block.block.header.proposerAddress);
Expand Down Expand Up @@ -109,7 +110,7 @@ export class BlockConsumer {
}
} else if (attr.key === 'amount') {
const amount = parseFloat(attr.value);
const denom = attr.value.substring(amount.toString().length);
const denom = attr.value.substring(Number(amount).toString().length);

if (!res.amount) {
res.amount = { amount, denom };
Expand Down Expand Up @@ -141,7 +142,7 @@ export class BlockConsumer {
if (amountAttr) {
const amountValue = amountAttr.value;
const amount = parseFloat(amountValue);
const denom = amountValue.substring(amount.toString().length);
const denom = amountValue.substring(Number(amount).toString().length);

amountObj = { amount, denom };
}
Expand Down
1 change: 0 additions & 1 deletion src/async/consumers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './asset.consumer';
export * from './beam.consumer';
export * from './block.consumer';
export * from './millions-deposit.consumer';
Expand Down
48 changes: 0 additions & 48 deletions src/async/schedulers/asset.scheduler.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/async/schedulers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './asset.scheduler';
export * from './block.scheduler';
export * from './governance.scheduler';
export * from './market.scheduler';
Expand Down
36 changes: 2 additions & 34 deletions src/async/schedulers/metric.scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { IdentifiedChannel, State } from '@lum-network/sdk-javascript/build/code
import { PageRequest } from '@lum-network/sdk-javascript/build/codegen/helpers';

import { AssetSymbol, depositStateToString, MetricNames, sleep, withdrawalStateToString } from '@app/utils';
import { ChainService, DfractService } from '@app/services';
import { ChainService } from '@app/services';
import { LumChain } from '@app/services/chains';

@Injectable()
Expand All @@ -27,14 +27,6 @@ export class MetricScheduler {
@InjectMetric(MetricNames.MARKET_CAP) private readonly _marketCap: Gauge<string>,
@InjectMetric(MetricNames.LUM_PRICE_EUR) private readonly _lumPriceEUR: Gauge<string>,
@InjectMetric(MetricNames.LUM_PRICE_USD) private readonly _lumPriceUSD: Gauge<string>,
// Dfr metrics constructors
@InjectMetric(MetricNames.DFRACT_CURRENT_SUPPLY) private readonly _dfractCurrentSupply: Gauge<string>,
@InjectMetric(MetricNames.DFRACT_MA_BALANCE) private readonly _dfractMaBalance: Gauge<string>,
@InjectMetric(MetricNames.DFRACT_APY) private readonly _dfractApy: Gauge<string>,
@InjectMetric(MetricNames.DFRACT_NEW_DFR_TO_MINT) private readonly _dfractNewDfrToMint: Gauge<string>,
@InjectMetric(MetricNames.DFRACT_BACKING_PRICE) private readonly _dfractBackingPrice: Gauge<string>,
@InjectMetric(MetricNames.DFRACT_MINT_RATIO) private readonly _dfractMintRatio: Gauge<string>,
@InjectMetric(MetricNames.DFRACT_MARKET_CAP) private readonly _dfractMarketCap: Gauge<string>,
// Millions metrics constructors
@InjectMetric(MetricNames.MILLIONS_POOL_VALUE_LOCKED) private readonly _millionsPoolValueLocked: Gauge<string>,
@InjectMetric(MetricNames.MILLIONS_POOL_DEPOSITORS) private readonly _millionsPoolDepositors: Gauge<string>,
Expand All @@ -50,7 +42,6 @@ export class MetricScheduler {
// General metrics constructors
@InjectMetric(MetricNames.TWITTER_FOLLOWERS) private readonly _twitterFollowers: Gauge<string>,
private readonly _configService: ConfigService,
private readonly _dfrService: DfractService,
private readonly _chainService: ChainService,
) {}

Expand All @@ -65,13 +56,6 @@ export class MetricScheduler {
metrics.set(MetricNames.MARKET_CAP, this._marketCap);
metrics.set(MetricNames.LUM_PRICE_EUR, this._lumPriceEUR);
metrics.set(MetricNames.LUM_PRICE_USD, this._lumPriceUSD);
metrics.set(MetricNames.DFRACT_APY, this._dfractApy);
metrics.set(MetricNames.DFRACT_BACKING_PRICE, this._dfractBackingPrice);
metrics.set(MetricNames.DFRACT_CURRENT_SUPPLY, this._dfractCurrentSupply);
metrics.set(MetricNames.DFRACT_MARKET_CAP, this._dfractMarketCap);
metrics.set(MetricNames.DFRACT_MA_BALANCE, this._dfractMaBalance);
metrics.set(MetricNames.DFRACT_MINT_RATIO, this._dfractMintRatio);
metrics.set(MetricNames.DFRACT_NEW_DFR_TO_MINT, this._dfractNewDfrToMint);
metrics.set(MetricNames.TWITTER_FOLLOWERS, this._twitterFollowers);
metrics.set(MetricNames.MILLIONS_POOL_VALUE_LOCKED, this._millionsPoolValueLocked);
metrics.set(MetricNames.MILLIONS_POOL_DEPOSITORS, this._millionsPoolDepositors);
Expand Down Expand Up @@ -107,19 +91,12 @@ export class MetricScheduler {
this._logger.log(`Syncing global metrics...`);

// Acquire data
const [lumCommunityPool, lumSupply, lumPrice, lumPriceEUR, lumCommunityData, dfrApy, dfrBackingPrice, dfrSupply, dfrMcap, dfrBalance, newDfrToMint, dfrMintRatio] = await Promise.all([
const [lumCommunityPool, lumSupply, lumPrice, lumPriceEUR, lumCommunityData] = await Promise.all([
this._chainService.getChain<LumChain>(AssetSymbol.LUM).client.cosmos.distribution.v1beta1.communityPool(),
this._chainService.getChain<LumChain>(AssetSymbol.LUM).getTokenSupply(),
this._chainService.getChain<LumChain>(AssetSymbol.LUM).getPrice(),
this._chainService.getChain<LumChain>(AssetSymbol.LUM).getPriceEUR(),
this._chainService.getChain<LumChain>(AssetSymbol.LUM).getCommunityData(),
this._dfrService.getApy(),
this._dfrService.getDfrBackingPrice(),
this._dfrService.getTokenSupply(),
this._dfrService.getMcap(),
this._dfrService.getAccountBalance(),
this._dfrService.getNewDfrToMint(),
this._dfrService.getDfrMintRatio(),
]);

// Compute community pool supply
Expand All @@ -133,15 +110,6 @@ export class MetricScheduler {
lumPrice && this.updateMetric({ name: MetricNames.LUM_PRICE_EUR, value: lumPriceEUR, labels: null }),
lumPrice && this.updateMetric({ name: MetricNames.LUM_PRICE_USD, value: lumPrice, labels: null }),

// DFR metrics
dfrApy && this.updateMetric({ name: MetricNames.DFRACT_APY, value: dfrApy, labels: null }),
dfrBackingPrice && this.updateMetric({ name: MetricNames.DFRACT_BACKING_PRICE, value: dfrBackingPrice, labels: null }),
dfrSupply && this.updateMetric({ name: MetricNames.DFRACT_CURRENT_SUPPLY, value: dfrSupply, labels: null }),
dfrMcap && this.updateMetric({ name: MetricNames.DFRACT_MARKET_CAP, value: dfrMcap, labels: null }),
dfrBalance && this.updateMetric({ name: MetricNames.DFRACT_MA_BALANCE, value: dfrBalance, labels: null }),
newDfrToMint && this.updateMetric({ name: MetricNames.DFRACT_NEW_DFR_TO_MINT, value: newDfrToMint, labels: null }),
dfrMintRatio && this.updateMetric({ name: MetricNames.DFRACT_MINT_RATIO, value: dfrMintRatio, labels: null }),

// General metrics
lumPrice && this.updateMetric({ name: MetricNames.TWITTER_FOLLOWERS, value: lumCommunityData.twitter_followers, labels: null }),
]);
Expand Down
Loading

0 comments on commit 01895d8

Please sign in to comment.