-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
336 additions
and
190 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
subgraphs/isolated-pools/tests/integration/checkEntities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { TransactionResponse } from '@ethersproject/abstract-provider'; | ||
import { expect } from 'chai'; | ||
import { ethers } from 'hardhat'; | ||
|
||
import subgraphClient from '../../subgraph-client'; | ||
|
||
export const checkMarket = async (marketAddress: string) => { | ||
const vToken = await ethers.getContractAt('VToken', marketAddress); | ||
const { accountVTokens: accountVTokensSupply } = | ||
await subgraphClient.getAccountVTokensWithSupplyByMarketId(marketAddress.toLowerCase()); | ||
const { accountVTokens: accountVTokensBorrow } = | ||
await subgraphClient.getAccountVTokensWithBorrowByMarketId(marketAddress.toLowerCase()); | ||
const { market } = await subgraphClient.getMarketById(marketAddress.toLowerCase()); | ||
expect(market?.supplierCount).to.equal(accountVTokensSupply.length.toString()); | ||
expect(market?.borrowerCount).to.equal(accountVTokensBorrow.length.toString()); | ||
|
||
expect(market?.totalBorrowsMantissa).to.equal(await vToken.totalBorrows()); | ||
expect(market?.totalSupplyVTokenMantissa).to.equal(await vToken.totalSupply()); | ||
|
||
expect(market?.borrowIndexMantissa).to.equal(await vToken.borrowIndex()); | ||
expect(market?.borrowRateMantissa).to.equal(await vToken.borrowRatePerBlock()); | ||
expect(market?.supplyRateMantissa).to.equal(await vToken.supplyRatePerBlock()); | ||
|
||
expect(market?.cashMantissa).to.equal(await vToken.getCash()); | ||
expect(market?.reservesMantissa).to.equal(await vToken.totalReserves()); | ||
|
||
return market; | ||
}; | ||
|
||
export const checkAccountVToken = async ( | ||
accountAddress: string, | ||
marketAddress: string, | ||
transaction: TransactionResponse, | ||
) => { | ||
const vToken = await ethers.getContractAt('VToken', marketAddress); | ||
|
||
const { accountVToken } = await subgraphClient.getAccountVTokenByAccountAndMarket({ | ||
accountId: accountAddress.toLowerCase(), | ||
marketId: marketAddress.toLowerCase(), | ||
}); | ||
expect(accountVToken!.accrualBlockNumber).to.equal(transaction.blockNumber); | ||
expect(accountVToken!.vTokenBalanceMantissa).to.equal(await vToken.balanceOf(accountAddress)); | ||
expect(accountVToken!.storedBorrowBalanceMantissa).to.equal( | ||
await vToken.borrowBalanceStored(accountAddress), | ||
); | ||
expect(accountVToken!.borrowIndex).to.equal(await vToken.borrowIndex()); | ||
expect(accountVToken!.enteredMarket).to.equal(await vToken.checkMembership(accountAddress)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.