Skip to content

Commit

Permalink
fix: try get underlying price
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Jan 22, 2024
1 parent 6ceb0cd commit cc11e13
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion subgraphs/venus/src/utilities/getTokenPriceCents.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Address, BigInt, log } from '@graphprotocol/graph-ts';

import { valueOrNotAvailableIntIfReverted } from '.';
import { PriceOracle } from '../../generated/templates/VToken/PriceOracle';
import { getOrCreateComptroller } from '../operations/getOrCreate';
import { exponentToBigInt } from './exponentToBigInt';
Expand All @@ -22,7 +23,9 @@ export function getTokenPriceCents(eventAddress: Address, underlyingDecimals: i3
const mantissaDecimalFactor = 36 - underlyingDecimals;
const bdFactor = exponentToBigInt(mantissaDecimalFactor);
const oracle2 = PriceOracle.bind(oracleAddress);
const oracleUnderlyingPrice = oracle2.getUnderlyingPrice(eventAddress);
const oracleUnderlyingPrice = valueOrNotAvailableIntIfReverted(
oracle2.try_getUnderlyingPrice(eventAddress),
);
if (oracleUnderlyingPrice.equals(BigInt.zero())) {
return oracleUnderlyingPrice;
}
Expand Down

0 comments on commit cc11e13

Please sign in to comment.