From 7ecfb2dcd218bf0fe3514fb6fccfa9ba3692986e Mon Sep 17 00:00:00 2001 From: Filippo Fontana Date: Thu, 22 Aug 2024 16:27:20 +0200 Subject: [PATCH] chore: change to dedicated endpoint --- chains-cfg/centrifuge.yaml | 2 +- src/mappings/handlers/blockHandlers.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/chains-cfg/centrifuge.yaml b/chains-cfg/centrifuge.yaml index f705b96d..2c798913 100644 --- a/chains-cfg/centrifuge.yaml +++ b/chains-cfg/centrifuge.yaml @@ -1,7 +1,7 @@ name: pools network: dictionary: https://api.subquery.network/sq/centrifuge/centrifuge-dictionary - endpoint: wss://fullnode.parachain.centrifuge.io + endpoint: wss://query.fullnode.centrifuge.io/ chainId: '0xb3db41421702df9a7fcac62b53ffeac85f7853cc4e689e0b93aeb3db18c09d82' chaintypes: file: ./dist/chaintypes.js diff --git a/src/mappings/handlers/blockHandlers.ts b/src/mappings/handlers/blockHandlers.ts index ca213e8d..70db37bc 100644 --- a/src/mappings/handlers/blockHandlers.ts +++ b/src/mappings/handlers/blockHandlers.ts @@ -35,7 +35,7 @@ async function _handleBlock(block: SubstrateBlock): Promise { if (newPeriod) { const specVersion = api.runtimeVersion.specVersion.toNumber() logger.info( - `It's a new period on block ${blockNumber}: ${block.timestamp.toISOString()} (specVersion: ${specVersion})` + `# It's a new period on block ${blockNumber}: ${block.timestamp.toISOString()} (specVersion: ${specVersion})` ) const period = SnapshotPeriodService.init(blockPeriodStart) @@ -53,6 +53,7 @@ async function _handleBlock(block: SubstrateBlock): Promise { // Update Pool States const pools = await PoolService.getCfgActivePools() for (const pool of pools) { + logger.info(` ## Updating pool ${pool.id} states...`) const currentEpoch = await EpochService.getById(pool.id, pool.currentEpoch) await pool.updateState() await pool.resetDebtOverdue() @@ -78,7 +79,7 @@ async function _handleBlock(block: SubstrateBlock): Promise { await tranche.save() // Compute TrancheBalances Unrealized Profit - const trancheBalances = await TrancheBalanceService.getByTrancheId(tranche.id) as TrancheBalanceService[] + const trancheBalances = (await TrancheBalanceService.getByTrancheId(tranche.id)) as TrancheBalanceService[] for (const trancheBalance of trancheBalances) { const unrealizedProfit = await InvestorPositionService.computeUnrealizedProfitAtPrice( trancheBalance.accountId, @@ -145,8 +146,10 @@ async function _handleBlock(block: SubstrateBlock): Promise { const sumPoolFeesPendingAmount = await PoolFeeService.computeSumPendingFees(pool.id) await pool.updateSumPoolFeesPendingAmount(sumPoolFeesPendingAmount) await pool.save() + logger.info(`## Pool ${pool.id} states update completed!`) } + logger.info('## Performing snapshots...') //Perform Snapshots and reset accumulators await substrateStateSnapshotter('periodId', period.id, Pool, PoolSnapshot, block, 'isActive', true, 'poolId') await substrateStateSnapshotter( @@ -170,6 +173,7 @@ async function _handleBlock(block: SubstrateBlock): Promise { true, 'poolFeeId' ) + logger.info('## Snapshotting completed!') //Update tracking of period and continue await (await timekeeper).update(period.start)