diff --git a/subgraphs/isolated-pools/schema.graphql b/subgraphs/isolated-pools/schema.graphql index 30c586ec..2f2894ca 100644 --- a/subgraphs/isolated-pools/schema.graphql +++ b/subgraphs/isolated-pools/schema.graphql @@ -94,7 +94,7 @@ type Market @entity { # Fields that are not in Venus api "Block the market is updated to" - accrualBlockNumber: Int! + accrualBlockNumber: BigInt! "Timestamp the market was most recently updated" blockTimestamp: Int! "The history of the markets borrow index return (Think S&P 500)" diff --git a/subgraphs/isolated-pools/src/operations/create.ts b/subgraphs/isolated-pools/src/operations/create.ts index 22dea9d2..5706790b 100644 --- a/subgraphs/isolated-pools/src/operations/create.ts +++ b/subgraphs/isolated-pools/src/operations/create.ts @@ -119,7 +119,7 @@ export function createMarket( market.reservesMantissa = vTokenContract.totalReserves(); market.supplyRateMantissa = vTokenContract.supplyRatePerBlock(); - market.accrualBlockNumber = vTokenContract.accrualBlockNumber().toI32(); + market.accrualBlockNumber = vTokenContract.accrualBlockNumber(); market.blockTimestamp = blockTimestamp.toI32(); diff --git a/subgraphs/isolated-pools/src/operations/update.ts b/subgraphs/isolated-pools/src/operations/update.ts index fc15bfed..a42716b6 100644 --- a/subgraphs/isolated-pools/src/operations/update.ts +++ b/subgraphs/isolated-pools/src/operations/update.ts @@ -127,7 +127,7 @@ export const updateMarket = ( const market = getMarket(vTokenAddress)!; // Only updateMarket if it has not been updated this block - if (market.accrualBlockNumber === blockNumber) { + if (market.accrualBlockNumber.equals(BigInt.fromI32(blockNumber))) { return market as Market; } const marketContract = VToken.bind(vTokenAddress); @@ -141,7 +141,7 @@ export const updateMarket = ( market.accrualBlockNumber = valueOrNotAvailableIntIfReverted( marketContract.try_accrualBlockNumber(), - ).toI32(); + ); market.blockTimestamp = blockTimestamp; const exchangeRateMantissa = valueOrNotAvailableIntIfReverted( diff --git a/subgraphs/isolated-pools/tests/integration/queries/accountVTokenByAccountAndMarket.graphql b/subgraphs/isolated-pools/tests/integration/queries/accountVTokenByAccountAndMarket.graphql index 9ee77dcf..00842052 100644 --- a/subgraphs/isolated-pools/tests/integration/queries/accountVTokenByAccountAndMarket.graphql +++ b/subgraphs/isolated-pools/tests/integration/queries/accountVTokenByAccountAndMarket.graphql @@ -30,5 +30,6 @@ query AccountVTokenByAccountAndMarket($id: ID!) { totalUnderlyingRedeemedMantissa borrowIndex totalUnderlyingRepaidMantissa + accrualBlockNumber } } diff --git a/subgraphs/venus/schema.graphql b/subgraphs/venus/schema.graphql index f87a9c25..c0e7c31a 100644 --- a/subgraphs/venus/schema.graphql +++ b/subgraphs/venus/schema.graphql @@ -62,7 +62,7 @@ type Market @entity { # Fields that are not in Venus api "Block the market is updated to" - accrualBlockNumber: Int! + accrualBlockNumber: BigInt! "Timestamp the market was most recently updated" blockTimestamp: Int! "The history of the markets borrow index return (Think S&P 500)" diff --git a/subgraphs/venus/src/mappings/vToken.ts b/subgraphs/venus/src/mappings/vToken.ts index 82f77863..cf5d0841 100644 --- a/subgraphs/venus/src/mappings/vToken.ts +++ b/subgraphs/venus/src/mappings/vToken.ts @@ -375,7 +375,7 @@ export function handleAccrueInterest(event: AccrueInterest): void { const market = getOrCreateMarket(marketAddress, event); const vTokenContract = VToken.bind(marketAddress); - market.accrualBlockNumber = vTokenContract.accrualBlockNumber().toI32(); + market.accrualBlockNumber = vTokenContract.accrualBlockNumber(); market.blockTimestamp = event.block.timestamp.toI32(); market.borrowIndex = event.params.borrowIndex; market.totalBorrowsMantissa = event.params.totalBorrows; diff --git a/subgraphs/venus/src/operations/getOrCreate.ts b/subgraphs/venus/src/operations/getOrCreate.ts index 650582b4..7585bdf8 100644 --- a/subgraphs/venus/src/operations/getOrCreate.ts +++ b/subgraphs/venus/src/operations/getOrCreate.ts @@ -62,7 +62,7 @@ export function getOrCreateMarket(marketAddress: Address, event: ethereum.Event) : getUnderlyingPrice(marketAddress, market.underlyingDecimals); market.lastUnderlyingPriceBlockNumber = event.block.number; - market.accrualBlockNumber = vTokenContract.accrualBlockNumber().toI32(); + market.accrualBlockNumber = vTokenContract.accrualBlockNumber(); market.totalXvsDistributedMantissa = zeroBigInt32; market.collateralFactorMantissa = zeroBigInt32; market.supplierCount = zeroBigInt32;