From 0a13b69f02061ddafea26191a132dd86d6131000 Mon Sep 17 00:00:00 2001 From: Jeroen Offerijns Date: Mon, 3 Jun 2024 10:54:47 +0200 Subject: [PATCH] fix: include spec version --- src/mappings/services/trancheService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mappings/services/trancheService.ts b/src/mappings/services/trancheService.ts index 589fec00..b483bfe9 100644 --- a/src/mappings/services/trancheService.ts +++ b/src/mappings/services/trancheService.ts @@ -74,12 +74,14 @@ export class TrancheService extends Tranche { } public async updatePrice(price: bigint, block?: number) { + const specVersion = api.runtimeVersion.specVersion.toNumber() + if (MAINNET_CHAINID === chainId && !!block && block < 4058350) { // https://centrifuge.subscan.io/extrinsic/4058350-0?event=4058350-0 // fix decimal error in old blocks, the fix was enacted at block #4058350 this.tokenPrice = nToBigInt(bnToBn(price).div(bnToBn(1000000000))) logger.info(`Updating price for tranche ${this.id} to: ${this.tokenPrice} (WITH CORRECTION FACTOR)`) - } else if (MAINNET_CHAINID === chainId && !!block && block < 5664672) { + } else if (MAINNET_CHAINID === chainId && !!block && specVersion >= 1025 && specVersion < 1029) { // fix token price not accounting for fees logger.info(`Starting price update ${this.id} to: ${this.tokenPrice} (WITHOUT ACCRUED FEES FIX)`) const apiCall = api.call as ExtendedCall