From 913fb9b0a7a464d9e46574e6752cc2cf5ebfd878 Mon Sep 17 00:00:00 2001 From: Dhruv Chauhan Date: Thu, 24 Oct 2024 17:29:30 +0530 Subject: [PATCH] nit: fix lint --- subgraphs/hord-fi/src/mappings/handlers.ts | 6 ++--- subgraphs/hord-fi/src/sdk/protocols/config.ts | 4 +-- .../hord-fi/src/sdk/protocols/generic/pool.ts | 26 ++++--------------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/subgraphs/hord-fi/src/mappings/handlers.ts b/subgraphs/hord-fi/src/mappings/handlers.ts index 05881523bc..4db87191b3 100644 --- a/subgraphs/hord-fi/src/mappings/handlers.ts +++ b/subgraphs/hord-fi/src/mappings/handlers.ts @@ -28,7 +28,7 @@ const conf = new ProtocolConfig( ); class Pricer implements TokenPricer { - getTokenPrice(token: Token, block: BigInt): BigDecimal { + getTokenPrice(token: Token): BigDecimal { if (Address.fromBytes(token.id) == Address.fromString(ETH_ADDRESS)) { const chainlinkDataFeedContract = ChainlinkDataFeed.bind( Address.fromString("0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419") // ETH / USD feed @@ -40,8 +40,8 @@ class Pricer implements TokenPricer { return BIGDECIMAL_ZERO; } - getAmountValueUSD(token: Token, amount: BigInt, block: BigInt): BigDecimal { - const usdPrice = this.getTokenPrice(token, block); + getAmountValueUSD(token: Token, amount: BigInt): BigDecimal { + const usdPrice = this.getTokenPrice(token); const _amount = bigIntToBigDecimal(amount, token.decimals); return usdPrice.times(_amount); diff --git a/subgraphs/hord-fi/src/sdk/protocols/config.ts b/subgraphs/hord-fi/src/sdk/protocols/config.ts index 943f83919d..f75004e165 100644 --- a/subgraphs/hord-fi/src/sdk/protocols/config.ts +++ b/subgraphs/hord-fi/src/sdk/protocols/config.ts @@ -40,6 +40,6 @@ export class ProtocolConfig implements ProtocolConfigurer { } export interface TokenPricer { - getTokenPrice(token: Token, block: BigInt): BigDecimal; - getAmountValueUSD(token: Token, amount: BigInt, block: BigInt): BigDecimal; + getTokenPrice(token: Token): BigDecimal; + getAmountValueUSD(token: Token, amount: BigInt): BigDecimal; } diff --git a/subgraphs/hord-fi/src/sdk/protocols/generic/pool.ts b/subgraphs/hord-fi/src/sdk/protocols/generic/pool.ts index 0fb895a21a..007e801ea5 100644 --- a/subgraphs/hord-fi/src/sdk/protocols/generic/pool.ts +++ b/subgraphs/hord-fi/src/sdk/protocols/generic/pool.ts @@ -1,11 +1,7 @@ import { TokenManager } from "./tokens"; import { ProtocolManager } from "./protocol"; import { PoolSnapshot } from "./poolSnapshot"; -import { - BIGDECIMAL_ZERO, - BIGINT_ZERO, - ZERO_ADDRESS, -} from "../../util/constants"; +import { BIGDECIMAL_ZERO, BIGINT_ZERO } from "../../util/constants"; import { Pool as PoolSchema, Token } from "../../../../generated/schema"; import { Bytes, BigDecimal, BigInt, Address } from "@graphprotocol/graph-ts"; @@ -163,9 +159,7 @@ export class Pool { (token.lastPriceBlockNumber && token.lastPriceBlockNumber! < this.protocol.event.block.number) ) { - const pricePerToken = this.protocol - .getTokenPricer() - .getTokenPrice(token, this.protocol.event.block.number); + const pricePerToken = this.protocol.getTokenPricer().getTokenPrice(token); token.lastPriceUSD = pricePerToken; token.lastPriceBlockNumber = this.protocol.event.block.number; token.save(); @@ -182,9 +176,7 @@ export class Pool { getInputTokenAmountPrice(token: Token, amount: BigInt): BigDecimal { this.setTokenPrice(token); - return this.protocol - .getTokenPricer() - .getAmountValueUSD(token, amount, this.protocol.event.block.number); + return this.protocol.getTokenPricer().getAmountValueUSD(token, amount); } addInputTokenBalances( @@ -297,16 +289,8 @@ export class Pool { ): void { const pricer = this.protocol.pricer; - const pAmountUSD = pricer.getAmountValueUSD( - inputToken, - protocolSide, - this.protocol.event.block.number - ); - const sAmountUSD = pricer.getAmountValueUSD( - inputToken, - supplySide, - this.protocol.event.block.number - ); + const pAmountUSD = pricer.getAmountValueUSD(inputToken, protocolSide); + const sAmountUSD = pricer.getAmountValueUSD(inputToken, supplySide); this.pool.cumulativeProtocolSideRevenue = this.pool.cumulativeProtocolSideRevenue.plus(protocolSide);