From 9a1a77b6873f0eb4aef7b85cb01d26f4ddf43bbf Mon Sep 17 00:00:00 2001 From: Dhruv Chauhan Date: Tue, 25 Jun 2024 17:33:14 +0530 Subject: [PATCH] fix network string matching --- subgraphs/karak/src/mappings/handlers.ts | 10 ++-------- subgraphs/karak/src/mappings/helpers.ts | 8 +++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/subgraphs/karak/src/mappings/handlers.ts b/subgraphs/karak/src/mappings/handlers.ts index 73633e8fbe..f780e35479 100644 --- a/subgraphs/karak/src/mappings/handlers.ts +++ b/subgraphs/karak/src/mappings/handlers.ts @@ -34,10 +34,7 @@ const conf = new ProtocolConfig( class Pricer implements TokenPricer { getTokenPrice(token: Token): BigDecimal { - const pricedToken = getUpdatedPricedToken( - dataSource.network(), - Address.fromBytes(token.id) - ); + const pricedToken = getUpdatedPricedToken(Address.fromBytes(token.id)); const pricedTokenAddr = pricedToken.addr; const pricedTokenMultiplier = pricedToken.multiplier; const pricedTokenChanged = pricedToken.changed; @@ -63,10 +60,7 @@ class Pricer implements TokenPricer { getAmountValueUSD(token: Token, amount: BigInt): BigDecimal { const _amount = bigIntToBigDecimal(amount, token.decimals); - const pricedToken = getUpdatedPricedToken( - dataSource.network(), - Address.fromBytes(token.id) - ); + const pricedToken = getUpdatedPricedToken(Address.fromBytes(token.id)); const pricedTokenAddr = pricedToken.addr; const pricedTokenMultiplier = pricedToken.multiplier; const pricedTokenChanged = pricedToken.changed; diff --git a/subgraphs/karak/src/mappings/helpers.ts b/subgraphs/karak/src/mappings/helpers.ts index a16539353e..769b19f27f 100644 --- a/subgraphs/karak/src/mappings/helpers.ts +++ b/subgraphs/karak/src/mappings/helpers.ts @@ -1,4 +1,4 @@ -import { Address, BigDecimal } from "@graphprotocol/graph-ts"; +import { Address, BigDecimal, dataSource } from "@graphprotocol/graph-ts"; import { bigIntToBigDecimal } from "../prices/common/utils"; import { WETH_ADDRESS as WETH_ADDRESS_MAINNET } from "../prices/config/mainnet"; @@ -33,14 +33,12 @@ export class PricedTokenParams { } } -export function getUpdatedPricedToken( - network: String, - tokenAddr: Address -): PricedTokenParams { +export function getUpdatedPricedToken(tokenAddr: Address): PricedTokenParams { let pricedToken = tokenAddr; let multiplier = BIGDECIMAL_ONE; let changed = false; + const network = dataSource.network().toUpperCase().replace("-", "_"); if (network == Network.MAINNET) { // Case: inputToken is mwBETH or mswETH if (