Skip to content

Commit

Permalink
nit: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-chauhan committed Oct 24, 2024
1 parent dfb43e3 commit 913fb9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
6 changes: 3 additions & 3 deletions subgraphs/hord-fi/src/mappings/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions subgraphs/hord-fi/src/sdk/protocols/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
26 changes: 5 additions & 21 deletions subgraphs/hord-fi/src/sdk/protocols/generic/pool.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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();
Expand All @@ -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(
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 913fb9b

Please sign in to comment.