Skip to content

Commit

Permalink
chore: change to dedicated endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
filo87 committed Aug 22, 2024
1 parent 42c6259 commit 7ecfb2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chains-cfg/centrifuge.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/mappings/handlers/blockHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function _handleBlock(block: SubstrateBlock): Promise<void> {
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)
Expand All @@ -53,6 +53,7 @@ async function _handleBlock(block: SubstrateBlock): Promise<void> {
// 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()
Expand All @@ -78,7 +79,7 @@ async function _handleBlock(block: SubstrateBlock): Promise<void> {
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,
Expand Down Expand Up @@ -145,8 +146,10 @@ async function _handleBlock(block: SubstrateBlock): Promise<void> {
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(
Expand All @@ -170,6 +173,7 @@ async function _handleBlock(block: SubstrateBlock): Promise<void> {
true,
'poolFeeId'
)
logger.info('## Snapshotting completed!')

//Update tracking of period and continue
await (await timekeeper).update(period.start)
Expand Down

0 comments on commit 7ecfb2d

Please sign in to comment.