Skip to content

Commit

Permalink
fix network string matching
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-chauhan committed Jun 25, 2024
1 parent 7fe7833 commit 9a1a77b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
10 changes: 2 additions & 8 deletions subgraphs/karak/src/mappings/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions subgraphs/karak/src/mappings/helpers.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 9a1a77b

Please sign in to comment.