Skip to content

Commit

Permalink
refactor: accrualBlockNumber as bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Oct 24, 2024
1 parent 59fec43 commit d01434f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion subgraphs/isolated-pools/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/isolated-pools/src/operations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions subgraphs/isolated-pools/src/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -141,7 +141,7 @@ export const updateMarket = (

market.accrualBlockNumber = valueOrNotAvailableIntIfReverted(
marketContract.try_accrualBlockNumber(),
).toI32();
);
market.blockTimestamp = blockTimestamp;

const exchangeRateMantissa = valueOrNotAvailableIntIfReverted(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ query AccountVTokenByAccountAndMarket($id: ID!) {
totalUnderlyingRedeemedMantissa
borrowIndex
totalUnderlyingRepaidMantissa
accrualBlockNumber
}
}
2 changes: 1 addition & 1 deletion subgraphs/venus/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/venus/src/mappings/vToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/venus/src/operations/getOrCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d01434f

Please sign in to comment.