Skip to content

Commit

Permalink
fix: include spec version
Browse files Browse the repository at this point in the history
  • Loading branch information
hieronx committed Jun 3, 2024
1 parent eb33ead commit 0a13b69
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mappings/services/trancheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a13b69

Please sign in to comment.