diff --git a/.changeset/olive-rings-beg.md b/.changeset/olive-rings-beg.md new file mode 100644 index 0000000000..f6df25541a --- /dev/null +++ b/.changeset/olive-rings-beg.md @@ -0,0 +1,5 @@ +--- +"@venusprotocol/evm": minor +--- + +fetch BSC Core pool participant counts from subgraph diff --git a/apps/evm/codegen.config.ts b/apps/evm/codegen.config.ts index 7cb569dfd0..ffeacc90c2 100644 --- a/apps/evm/codegen.config.ts +++ b/apps/evm/codegen.config.ts @@ -3,19 +3,38 @@ import { ChainId } from '@venusprotocol/chains/types'; import { envVariables } from './src/config/envVariables'; -import { getGovernanceSubgraphUrls, getIsolatedPoolsSubgraphUrls } from './src/config/subgraphUrls'; +import { + getBscCorePoolSubgraphUrls, + getGovernanceSubgraphUrls, + getIsolatedPoolsSubgraphUrls, +} from './src/config/subgraphUrls'; const keys = { nodeRealApiKey: envVariables.VITE_NODE_REAL_API_KEY, theGraphApiKey: envVariables.VITE_THE_GRAPH_API_KEY, }; +const bscCorePoolsSubgraphUrls = getBscCorePoolSubgraphUrls(keys); const isolatedPoolsSubgraphUrls = getIsolatedPoolsSubgraphUrls(keys); const governanceSubgraphUrls = getGovernanceSubgraphUrls(keys); const plugins = ['typescript', 'typed-document-node', 'typescript-operations']; export const projects = { + bscCorePool: { + schema: bscCorePoolsSubgraphUrls[ChainId.BSC_MAINNET], + documents: ['./src/clients/subgraph/queries/bscCorePool/**/*.graphql'], + errorsOnly: true, + extensions: { + codegen: { + generates: { + './src/clients/subgraph/gql/generated/bscCorePool.ts': { + plugins, + }, + }, + }, + }, + }, isolatedPools: { schema: isolatedPoolsSubgraphUrls[ChainId.BSC_MAINNET], documents: ['./src/clients/subgraph/queries/isolatedPools/**/*.graphql'], diff --git a/apps/evm/package.json b/apps/evm/package.json index 4a6f4a4e88..f4f696ccb5 100644 --- a/apps/evm/package.json +++ b/apps/evm/package.json @@ -17,10 +17,11 @@ "tsc": "tsc --noEmit", "extract-translations": "yarn i18next", "generate-project-subgraph:project": "dotenvx run -f .env -- yarn graphql-codegen --config codegen.config.ts --project $PROJECT", + "generate-subgraph-types:bsc-core-pool": "PROJECT=bscCorePool yarn generate-project-subgraph:project", "generate-subgraph-types:isolated-pools": "PROJECT=isolatedPools yarn generate-project-subgraph:project", "generate-subgraph-types:governance-bsc": "PROJECT=governanceBsc yarn generate-project-subgraph:project", "generate-subgraph-types:governance-non-bsc": "PROJECT=governanceNonBsc yarn generate-project-subgraph:project", - "generate-subgraph-types": "yarn generate-subgraph-types:isolated-pools && yarn generate-subgraph-types:governance-bsc && yarn generate-subgraph-types:governance-non-bsc", + "generate-subgraph-types": "yarn generate-subgraph-types:isolated-pools && yarn generate-subgraph-types:bsc-core-pool && yarn generate-subgraph-types:governance-bsc && yarn generate-subgraph-types:governance-non-bsc", "generate-contracts": "rimraf src/libs/contracts/generated/getters && rimraf src/libs/contracts/generated/infos && src/libs/contracts/scripts/generateContractRecords/index.ts", "generate-pancake-swap-tokens": "src/libs/tokens/scripts/generatePancakeSwapTokenRecords/index.ts", "generate-version-files": "genversion --es6 --semi src/constants/version.ts && src/scripts/generatePublicVersionFile.ts && yarn biome format --vcs-use-ignore-file=false --write public/version.json", diff --git a/apps/evm/src/__mocks__/subgraph/bscCorePoolParticipantsCount.json b/apps/evm/src/__mocks__/subgraph/bscCorePoolParticipantsCount.json new file mode 100644 index 0000000000..8aaea8f218 --- /dev/null +++ b/apps/evm/src/__mocks__/subgraph/bscCorePoolParticipantsCount.json @@ -0,0 +1,114 @@ +{ + "markets": [ + { + "id": "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4", + "borrowerCount": 438, + "supplierCount": 933 + }, + { + "id": "0x162D005F0Fff510E54958Cfc5CF32A3180A84aab", + "borrowerCount": 35, + "supplierCount": 25 + }, + { + "id": "0x171B468b52d7027F12cEF90cd065d6776a25E24e", + "borrowerCount": 1, + "supplierCount": 2 + }, + { + "id": "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", + "borrowerCount": 263, + "supplierCount": 923 + }, + { + "id": "0x35566ED3AF9E537Be487C98b1811cDf95ad0C32b", + "borrowerCount": 0, + "supplierCount": 0 + }, + { + "id": "0x3619bdDc61189F33365CC572DF3a68FB3b316516", + "borrowerCount": 8, + "supplierCount": 6 + }, + { + "id": "0x369Fea97f6fB7510755DCA389088d9E2e2819278", + "borrowerCount": 4, + "supplierCount": 4 + }, + { + "id": "0x37C28DE42bA3d22217995D146FC684B2326Ede64", + "borrowerCount": 10, + "supplierCount": 6 + }, + { + "id": "0x3A00d9B02781f47d033BAd62edc55fBF8D083Fb0", + "borrowerCount": 1, + "supplierCount": 1 + }, + { + "id": "0x488aB2826a154da01CC4CC16A8C83d4720D3cA2C", + "borrowerCount": 35, + "supplierCount": 53 + }, + { + "id": "0x6AF3Fdb3282c5bb6926269Db10837fa8Aec67C04", + "borrowerCount": 1, + "supplierCount": 3 + }, + { + "id": "0x6d6F697e34145Bb95c54E77482d97cc261Dc237E", + "borrowerCount": 68, + "supplierCount": 274 + }, + { + "id": "0x714db6c38A17883964B68a07d56cE331501d9eb6", + "borrowerCount": 8, + "supplierCount": 9 + }, + { + "id": "0x74469281310195A04840Daf6EdF576F559a3dE80", + "borrowerCount": 277, + "supplierCount": 661 + }, + { + "id": "0xAfc13BC065ABeE838540823431055D2ea52eBA52", + "borrowerCount": 27, + "supplierCount": 18 + }, + { + "id": "0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe", + "borrowerCount": 49, + "supplierCount": 30 + }, + { + "id": "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A", + "borrowerCount": 249, + "supplierCount": 670 + }, + { + "id": "0xD5C4C2e2facBEB59D0216D0595d63FcDc6F9A1a7", + "borrowerCount": 229, + "supplierCount": 534 + }, + { + "id": "0xeDaC03D29ff74b5fDc0CC936F6288312e1459BC6", + "borrowerCount": 8, + "supplierCount": 13 + }, + { + "id": "0xEFAACF73CE2D38ED40991f29E72B12C74bd4cf23", + "borrowerCount": 0, + "supplierCount": 0 + }, + { + "id": "0xF06e662a00796c122AaAE935EC4F0Be3F74f5636", + "borrowerCount": 1, + "supplierCount": 2 + }, + { + "id": "0xF912d3001CAf6DC4ADD366A62Cc9115B4303c9A9", + "borrowerCount": 12, + "supplierCount": 4 + } + ] +} diff --git a/apps/evm/src/clients/api/queries/useGetPools/__testUtils__/fakeData.ts b/apps/evm/src/clients/api/queries/useGetPools/__testUtils__/fakeData.ts index f56a871780..b24b2ce119 100644 --- a/apps/evm/src/clients/api/queries/useGetPools/__testUtils__/fakeData.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/__testUtils__/fakeData.ts @@ -158,13 +158,16 @@ export const fakePublicClient = { } as unknown as PublicClient; export const fakeIsolatedPoolParticipantsCount = { - pools: apiPoolsResponse.result.map(pool => ({ - __typename: 'Pool', - id: pool.address, - markets: pool.markets.map(market => ({ - id: market.address, - supplierCount: 10, - borrowerCount: 20, + // filter the BSC Core pool, it's not an isolated pool + pools: apiPoolsResponse.result + .filter(pool => pool.address !== '0x94d1820b2D1c7c7452A163983Dc888CEC546b77D') + .map(pool => ({ + __typename: 'Pool', + id: pool.address, + markets: pool.markets.map(market => ({ + id: market.address, + supplierCount: 10, + borrowerCount: 20, + })), })), - })), }; diff --git a/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.spec.ts.snap b/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.spec.ts.snap index 6becf2b6b6..508887e67c 100644 --- a/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.spec.ts.snap +++ b/apps/evm/src/clients/api/queries/useGetPools/__tests__/__snapshots__/index.spec.ts.snap @@ -1078,7 +1078,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "type": "venus", }, ], - "borrowerCount": 20, + "borrowerCount": 0, "cashTokens": "1.00000000080503544824460983238917793784e+21", "collateralFactor": 0, "disabledTokenActions": [ @@ -1090,7 +1090,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "liquidityCents": "1.000006200805040439464388948970138750743214608e+23", "reserveFactor": 1, "reserveTokens": "0", - "supplierCount": 10, + "supplierCount": 0, "supplyApyPercentage": "0", "supplyBalanceCents": "1.000006201051670556767362816225462034303610544746e+23", "supplyBalanceTokens": "1.00000000105166403645033682413715238395883e+21", @@ -1159,7 +1159,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "type": "venus", }, ], - "borrowerCount": 20, + "borrowerCount": 0, "cashTokens": "0", "collateralFactor": 0.8, "disabledTokenActions": [], @@ -1168,7 +1168,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "liquidityCents": "0", "reserveFactor": 0.1, "reserveTokens": "21.269535066688975633", - "supplierCount": 10, + "supplierCount": 0, "supplyApyPercentage": "11.401000590716290067", "supplyBalanceCents": "3716729453.6129492577232450137", "supplyBalanceTokens": "15115.4767135290690422233", @@ -1238,7 +1238,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "type": "venus", }, ], - "borrowerCount": 20, + "borrowerCount": 0, "cashTokens": "5.556233762724731858", "collateralFactor": 0.8, "disabledTokenActions": [], @@ -1247,7 +1247,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "liquidityCents": "291731.6894670817923653489952", "reserveFactor": 0.25, "reserveTokens": "187487.447405339178551222", - "supplierCount": 10, + "supplierCount": 0, "supplyApyPercentage": "156.911092632839993416", "supplyBalanceCents": "44362974574.359412320127072323564288", "supplyBalanceTokens": "844923.83256419589412162352", @@ -1317,7 +1317,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "type": "venus", }, ], - "borrowerCount": 20, + "borrowerCount": 0, "cashTokens": "2259657.074761148481496107", "collateralFactor": 0.6, "disabledTokenActions": [], @@ -1326,7 +1326,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "liquidityCents": "1444669788.91666196711723462774301", "reserveFactor": 0.25, "reserveTokens": "0", - "supplierCount": 10, + "supplierCount": 0, "supplyApyPercentage": "1.830999347346963073", "supplyBalanceCents": "1711197065.9464062401284554003137589", "supplyBalanceTokens": "2676541.43946341921611527123", @@ -1395,7 +1395,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "type": "venus", }, ], - "borrowerCount": 20, + "borrowerCount": 0, "cashTokens": "1.0000736633870942814396398228131475074669e+34", "collateralFactor": 0.8, "disabledTokenActions": [], @@ -1404,7 +1404,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "liquidityCents": "1.000036490649026183145198711400933542774047455327e+36", "reserveFactor": 0.1, "reserveTokens": "0", - "supplierCount": 10, + "supplierCount": 0, "supplyApyPercentage": "0", "supplyBalanceCents": "1.00003649064902618314530970887489046343322854178897705712904885e+36", "supplyBalanceTokens": "1.000073663387094281439750824413033895903139261475326095e+34", @@ -1473,7 +1473,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "type": "venus", }, ], - "borrowerCount": 20, + "borrowerCount": 0, "cashTokens": "1.010176805025969148511141552e+21", "collateralFactor": 0.81, "disabledTokenActions": [], @@ -1482,7 +1482,7 @@ exports[`useGetPools > returns pools with time based reward rates in the correct "liquidityCents": "1.01015151019877129824366283301553792e+23", "reserveFactor": 0.1, "reserveTokens": "0", - "supplierCount": 10, + "supplierCount": 0, "supplyApyPercentage": "2.7256320003e-8", "supplyBalanceCents": "1.0101515258227468345608256850251328456045167117888e+23", "supplyBalanceTokens": "1.01017682065033591897223674983334867265528e+21", diff --git a/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.prime.spec.ts b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.prime.spec.ts index 96285d2f12..926ea3dbb0 100644 --- a/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.prime.spec.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.prime.spec.ts @@ -3,9 +3,13 @@ import type { Mock } from 'vitest'; import apiPoolsResponse from '__mocks__/api/pools.json'; import fakeAccountAddress from '__mocks__/models/address'; +import fakeBscCorePoolParticipantsCount from '__mocks__/subgraph/bscCorePoolParticipantsCount.json'; import BigNumber from 'bignumber.js'; import { type GetTokenBalancesInput, getTokenBalances, getUserVaiBorrowBalance } from 'clients/api'; -import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; +import { + getBscCorePoolParticipantsCount, + getIsolatedPoolParticipantsCount, +} from 'clients/subgraph'; import { type UseIsFeatureEnabled, useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; import { useGetLegacyPoolComptrollerContractAddress, @@ -58,6 +62,10 @@ describe('useGetPools', () => { data: apiPoolsResponse, })); + (getBscCorePoolParticipantsCount as Mock).mockImplementation( + () => fakeBscCorePoolParticipantsCount, + ); + (getIsolatedPoolParticipantsCount as Mock).mockImplementation( () => fakeIsolatedPoolParticipantsCount, ); diff --git a/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.spec.ts b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.spec.ts index b09b942e54..6a734d122c 100644 --- a/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.spec.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/__tests__/index.spec.ts @@ -4,9 +4,10 @@ import type { Mock } from 'vitest'; import apiPoolsResponse from '__mocks__/api/pools.json'; import fakeAccountAddress from '__mocks__/models/address'; +import fakeBscCorePoolParticipantsCount from '__mocks__/subgraph/bscCorePoolParticipantsCount.json'; import BigNumber from 'bignumber.js'; import { type GetTokenBalancesInput, getTokenBalances, getUserVaiBorrowBalance } from 'clients/api'; -import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; +import { getBscCorePoolParticipantsCount, getIsolatedPoolParticipantsCount } from 'clients/subgraph'; import { useGetLegacyPoolComptrollerContractAddress, useGetPoolLensContractAddress, @@ -50,6 +51,10 @@ describe('useGetPools', () => { data: apiPoolsResponse, })); + (getBscCorePoolParticipantsCount as Mock).mockImplementation( + () => fakeBscCorePoolParticipantsCount, + ); + (getIsolatedPoolParticipantsCount as Mock).mockImplementation( () => fakeIsolatedPoolParticipantsCount, ); diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts index 5d1a3d5ec2..2f69bd1498 100644 --- a/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts @@ -25,7 +25,7 @@ export const formatOutput = ({ chainId, tokens, currentBlockNumber, - isolatedPoolParticipantsCountMap, + participantsCountMap, userPrimeApyMap, userVTokenBalances = [], userTokenBalances = [], @@ -36,7 +36,7 @@ export const formatOutput = ({ tokens: Token[]; currentBlockNumber: bigint; apiPools: ApiPool[]; - isolatedPoolParticipantsCountMap?: Map; + participantsCountMap?: Map; userPrimeApyMap?: Map; userCollateralVTokenAddresses?: string[]; userVTokenBalances?: VTokenBalance[]; @@ -207,13 +207,11 @@ export const formatOutput = ({ ); } - const supplierCount = isIsolated - ? isolatedPoolParticipantsCountMap?.get(vToken.address.toLowerCase())?.supplierCount ?? 0 - : market.supplierCount; + const supplierCount = + participantsCountMap?.get(vToken.address.toLowerCase())?.supplierCount ?? 0; - const borrowerCount = isIsolated - ? isolatedPoolParticipantsCountMap?.get(vToken.address.toLowerCase())?.borrowerCount ?? 0 - : market.borrowerCount; + const borrowerCount = + participantsCountMap?.get(vToken.address.toLowerCase())?.borrowerCount ?? 0; const asset: Asset = { vToken, diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts index 030f022699..0215774480 100644 --- a/apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts @@ -55,8 +55,6 @@ export interface ApiMarket { lastCalculatedXvsAccruedBlockNumber: string | null; supplyCapsMantissa: string; borrowCapsMantissa: string; - borrowerCount: number; - supplierCount: number; estimatedPrimeBorrowApyBoost: string | null; estimatedPrimeSupplyApyBoost: string | null; pausedActionsBitmap: number; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getIsolatedPoolParticipantCounts/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getIsolatedPoolParticipantCounts/index.ts deleted file mode 100644 index 859b899fa3..0000000000 --- a/apps/evm/src/clients/api/queries/useGetPools/getPools/getIsolatedPoolParticipantCounts/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { getIsolatedPoolParticipantsCount } from 'clients/subgraph'; -import type { ChainId } from 'types'; -import type { MarketParticipantsCounts } from '../../types'; - -export const getIsolatedPoolParticipantCounts = async ({ chainId }: { chainId: ChainId }) => { - const isolatedPoolParticipantsCount = await getIsolatedPoolParticipantsCount({ chainId }); - - const isolatedPoolParticipantsCountMap = new Map(); - (isolatedPoolParticipantsCount?.pools || []).forEach(pool => - pool.markets.forEach(market => { - isolatedPoolParticipantsCountMap.set(market.id.toLowerCase(), { - borrowerCount: +market.borrowerCount, - supplierCount: +market.supplierCount, - }); - }), - ); - - return { isolatedPoolParticipantsCountMap }; -}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/getParticipantCounts/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/getParticipantCounts/index.ts new file mode 100644 index 0000000000..426905f4bc --- /dev/null +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/getParticipantCounts/index.ts @@ -0,0 +1,41 @@ +import { + getBscCorePoolParticipantsCount, + getIsolatedPoolParticipantsCount, +} from 'clients/subgraph'; +import { logError } from 'libs/errors'; +import { ChainId } from 'types'; +import { extractSettledPromiseValue } from 'utilities'; +import type { MarketParticipantsCounts } from '../../types'; + +export const getParticipantCounts = async ({ chainId }: { chainId: ChainId }) => { + const participantsCountMap = new Map(); + const [isolatedPoolParticipantsCountsResult, bscCorePoolParticipantsCountsResult] = + await Promise.allSettled([ + getIsolatedPoolParticipantsCount({ chainId }), + chainId === ChainId.BSC_MAINNET || chainId === ChainId.BSC_TESTNET + ? getBscCorePoolParticipantsCount({ chainId }) + : undefined, + ]); + + if (isolatedPoolParticipantsCountsResult.status === 'rejected') { + logError(isolatedPoolParticipantsCountsResult.reason); + } + + if (bscCorePoolParticipantsCountsResult.status === 'rejected') { + logError(bscCorePoolParticipantsCountsResult.reason); + } + + const isolatedPoolParticipantsCounts = ( + extractSettledPromiseValue(isolatedPoolParticipantsCountsResult)?.pools || [] + ).flatMap(p => p.markets); + const bscCorePoolParticipantsCounts = + extractSettledPromiseValue(bscCorePoolParticipantsCountsResult)?.markets || []; + + [...isolatedPoolParticipantsCounts, ...bscCorePoolParticipantsCounts].forEach(market => { + participantsCountMap.set(market.id.toLowerCase(), { + borrowerCount: +market.borrowerCount, + supplierCount: +market.supplierCount, + }); + }); + return { participantsCountMap }; +}; diff --git a/apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts b/apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts index d6b7e8f358..ec7b757fc1 100644 --- a/apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts +++ b/apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts @@ -1,37 +1,16 @@ import BigNumber from 'bignumber.js'; import { getUserVaiBorrowBalance } from 'clients/api'; -import type { GetIsolatedPoolParticipantsCountInput } from 'clients/subgraph'; import { primeAbi } from 'libs/contracts'; -import { logError } from 'libs/errors'; import type { Asset, TokenBalance } from 'types'; import type { GetPoolsInput, GetPoolsOutput, PrimeApy, VTokenBalance } from '../types'; import { appendPrimeSimulationDistributions } from './appendPrimeSimulationDistributions'; import { formatOutput } from './formatOutput'; import { getApiPools } from './getApiPools'; -import { getIsolatedPoolParticipantCounts } from './getIsolatedPoolParticipantCounts'; +import { getParticipantCounts } from './getParticipantCounts'; import { getUserCollateralAddresses } from './getUserCollateralAddresses'; import { getUserPrimeApys } from './getUserPrimeApys'; import { getUserTokenBalances } from './getUserTokenBalances'; -const safeGetIsolatedPoolParticipantCount = async ( - input: GetIsolatedPoolParticipantsCountInput, -) => { - try { - const result = await getIsolatedPoolParticipantCounts(input); - return result; - } catch (error) { - // Safari throws a "TypeError: Load failed" error if the fetch is canceled - // e.g., if the user navigates away from the page before the request is finished - // we can safely filter them out from being logged - if (error instanceof Error && error.name === 'TypeError' && error.message === 'Load failed') { - return undefined; - } - // Log error without throwing to prevent the entire query from failing, since this relies on a - // third-party service that could be down and doesn't constitute a critical failure - logError(error); - } -}; - export const getPools = async ({ publicClient, chainId, @@ -45,14 +24,14 @@ export const getPools = async ({ }: GetPoolsInput) => { const [ { pools: apiPools }, - isolatedPoolParticipantCounts, + participantCounts, currentBlockNumber, unsafePrimeVTokenAddresses, primeMinimumXvsToStakeMantissa, userPrimeToken, ] = await Promise.all([ getApiPools({ chainId }), - safeGetIsolatedPoolParticipantCount({ chainId }), + getParticipantCounts({ chainId }), // Fetch current block number publicClient.getBlockNumber(), // Prime related calls @@ -136,8 +115,7 @@ export const getPools = async ({ tokens, currentBlockNumber, apiPools, - isolatedPoolParticipantsCountMap: - isolatedPoolParticipantCounts?.isolatedPoolParticipantsCountMap, + participantsCountMap: participantCounts?.participantsCountMap, userPrimeApyMap, userCollateralVTokenAddresses, userVTokenBalances, diff --git a/apps/evm/src/clients/subgraph/__mocks__/index.ts b/apps/evm/src/clients/subgraph/__mocks__/index.ts index 005ff98beb..2b3b208b86 100644 --- a/apps/evm/src/clients/subgraph/__mocks__/index.ts +++ b/apps/evm/src/clients/subgraph/__mocks__/index.ts @@ -1,6 +1,7 @@ import bscProposalsResponse from '__mocks__/subgraph/bscProposals.json'; import nonBscProposalsResponse from '__mocks__/subgraph/nonBscProposals.json'; +export * from '../queries/bscCorePool/getBscCorePoolParticipantsCount'; export * from '../queries/isolatedPools/getIsolatedPoolParticipantsCount'; export * from '../queries/governanceBsc/getBscProposals'; export * from '../utilities/formatToProposal'; @@ -13,4 +14,6 @@ export const getBscProposal = vi.fn(async () => ({ export const getNonBscProposals = vi.fn(async () => nonBscProposalsResponse); +export const getBscCorePoolParticipantsCount = vi.fn(); + export const getIsolatedPoolParticipantsCount = vi.fn(); diff --git a/apps/evm/src/clients/subgraph/gql/generated/bscCorePool.ts b/apps/evm/src/clients/subgraph/gql/generated/bscCorePool.ts new file mode 100644 index 0000000000..522e3109e0 --- /dev/null +++ b/apps/evm/src/clients/subgraph/gql/generated/bscCorePool.ts @@ -0,0 +1,1322 @@ +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +export type Maybe = T | null; +export type InputMaybe = Maybe; +export type Exact = { [K in keyof T]: T[K] }; +export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; +export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; +export type MakeEmpty = { [_ in K]?: never }; +export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +/** All built-in and custom scalars, mapped to their actual values */ +export type Scalars = { + ID: { input: string; output: string; } + String: { input: string; output: string; } + Boolean: { input: boolean; output: boolean; } + Int: { input: number; output: number; } + Float: { input: number; output: number; } + BigDecimal: { input: any; output: any; } + BigInt: { input: any; output: any; } + Bytes: { input: any; output: any; } + Int8: { input: any; output: any; } + Timestamp: { input: any; output: any; } +}; + +/** + * Account is an BNB address, with a list of all vToken markets the account has + * participated in, along with liquidation information. + * + */ +export type Account = { + __typename?: 'Account'; + /** Account address */ + address: Scalars['Bytes']['output']; + /** Count user has been liquidated */ + countLiquidated: Scalars['Int']['output']; + /** Count user has liquidated others */ + countLiquidator: Scalars['Int']['output']; + /** True if user has ever borrowed */ + hasBorrowed: Scalars['Boolean']['output']; + /** Account address */ + id: Scalars['Bytes']['output']; + /** Array of VTokens user is in */ + tokens: Array; +}; + + +/** + * Account is an BNB address, with a list of all vToken markets the account has + * participated in, along with liquidation information. + * + */ +export type AccountTokensArgs = { + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + where?: InputMaybe; +}; + +export type Account_Filter = { + /** Filter for the block changed event. */ + _change_block?: InputMaybe; + address?: InputMaybe; + address_contains?: InputMaybe; + address_gt?: InputMaybe; + address_gte?: InputMaybe; + address_in?: InputMaybe>; + address_lt?: InputMaybe; + address_lte?: InputMaybe; + address_not?: InputMaybe; + address_not_contains?: InputMaybe; + address_not_in?: InputMaybe>; + and?: InputMaybe>>; + countLiquidated?: InputMaybe; + countLiquidated_gt?: InputMaybe; + countLiquidated_gte?: InputMaybe; + countLiquidated_in?: InputMaybe>; + countLiquidated_lt?: InputMaybe; + countLiquidated_lte?: InputMaybe; + countLiquidated_not?: InputMaybe; + countLiquidated_not_in?: InputMaybe>; + countLiquidator?: InputMaybe; + countLiquidator_gt?: InputMaybe; + countLiquidator_gte?: InputMaybe; + countLiquidator_in?: InputMaybe>; + countLiquidator_lt?: InputMaybe; + countLiquidator_lte?: InputMaybe; + countLiquidator_not?: InputMaybe; + countLiquidator_not_in?: InputMaybe>; + hasBorrowed?: InputMaybe; + hasBorrowed_in?: InputMaybe>; + hasBorrowed_not?: InputMaybe; + hasBorrowed_not_in?: InputMaybe>; + id?: InputMaybe; + id_contains?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_in?: InputMaybe>; + or?: InputMaybe>>; + tokens_?: InputMaybe; +}; + +export enum Account_OrderBy { + Address = 'address', + CountLiquidated = 'countLiquidated', + CountLiquidator = 'countLiquidator', + HasBorrowed = 'hasBorrowed', + Id = 'id', + Tokens = 'tokens' +} + +export enum Aggregation_Interval { + Day = 'day', + Hour = 'hour' +} + +export type BlockChangedFilter = { + number_gte: Scalars['Int']['input']; +}; + +export type Block_Height = { + hash?: InputMaybe; + number?: InputMaybe; + number_gte?: InputMaybe; +}; + +/** + * The Comptroller type has protocol level variables stored + * + */ +export type Comptroller = { + __typename?: 'Comptroller'; + /** Comptroller Address */ + address: Scalars['Bytes']['output']; + /** Factor used to determine repayAmount for liquidating */ + closeFactorMantissa: Scalars['BigInt']['output']; + /** ID is set to comptroller address */ + id: Scalars['Bytes']['output']; + /** The percent bonus liquidators get for liquidating */ + liquidationIncentive: Scalars['BigInt']['output']; + /** Address of price oracle the comptroller uses */ + priceOracle: Scalars['Bytes']['output']; +}; + +export type Comptroller_Filter = { + /** Filter for the block changed event. */ + _change_block?: InputMaybe; + address?: InputMaybe; + address_contains?: InputMaybe; + address_gt?: InputMaybe; + address_gte?: InputMaybe; + address_in?: InputMaybe>; + address_lt?: InputMaybe; + address_lte?: InputMaybe; + address_not?: InputMaybe; + address_not_contains?: InputMaybe; + address_not_in?: InputMaybe>; + and?: InputMaybe>>; + closeFactorMantissa?: InputMaybe; + closeFactorMantissa_gt?: InputMaybe; + closeFactorMantissa_gte?: InputMaybe; + closeFactorMantissa_in?: InputMaybe>; + closeFactorMantissa_lt?: InputMaybe; + closeFactorMantissa_lte?: InputMaybe; + closeFactorMantissa_not?: InputMaybe; + closeFactorMantissa_not_in?: InputMaybe>; + id?: InputMaybe; + id_contains?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_in?: InputMaybe>; + liquidationIncentive?: InputMaybe; + liquidationIncentive_gt?: InputMaybe; + liquidationIncentive_gte?: InputMaybe; + liquidationIncentive_in?: InputMaybe>; + liquidationIncentive_lt?: InputMaybe; + liquidationIncentive_lte?: InputMaybe; + liquidationIncentive_not?: InputMaybe; + liquidationIncentive_not_in?: InputMaybe>; + or?: InputMaybe>>; + priceOracle?: InputMaybe; + priceOracle_contains?: InputMaybe; + priceOracle_gt?: InputMaybe; + priceOracle_gte?: InputMaybe; + priceOracle_in?: InputMaybe>; + priceOracle_lt?: InputMaybe; + priceOracle_lte?: InputMaybe; + priceOracle_not?: InputMaybe; + priceOracle_not_contains?: InputMaybe; + priceOracle_not_in?: InputMaybe>; +}; + +export enum Comptroller_OrderBy { + Address = 'address', + CloseFactorMantissa = 'closeFactorMantissa', + Id = 'id', + LiquidationIncentive = 'liquidationIncentive', + PriceOracle = 'priceOracle' +} + +export enum EventType { + Borrow = 'BORROW', + Liquidate = 'LIQUIDATE', + Mint = 'MINT', + MintBehalf = 'MINT_BEHALF', + Redeem = 'REDEEM', + Repay = 'REPAY', + Transfer = 'TRANSFER' +} + +/** + * Market stores all high level variables for a vToken market + * + */ +export type Market = { + __typename?: 'Market'; + /** Accounts who participate in this market */ + accounts: Array; + /** Block the market is updated to */ + accrualBlockNumber: Scalars['BigInt']['output']; + /** Vtoken Address */ + address: Scalars['Bytes']['output']; + /** The history of the markets borrow index return (Think S&P 500) */ + borrowIndex: Scalars['BigInt']['output']; + /** Borrow rate per block */ + borrowRateMantissa: Scalars['BigInt']['output']; + /** Number of accounts currently borrowing from this market */ + borrowerCount: Scalars['BigInt']['output']; + /** The vToken contract balance of BEP20 or BNB */ + cashMantissa: Scalars['BigInt']['output']; + /** Collateral factor determining how much one can borrow */ + collateralFactorMantissa: Scalars['BigInt']['output']; + /** Exchange rate of tokens / vTokens */ + exchangeRateMantissa: Scalars['BigInt']['output']; + /** VToken address */ + id: Scalars['Bytes']['output']; + /** Address of the interest rate model */ + interestRateModelAddress: Scalars['Bytes']['output']; + /** Flag indicating if the market is listed */ + isListed: Scalars['Boolean']['output']; + /** Block price was last updated */ + lastUnderlyingPriceBlockNumber: Scalars['BigInt']['output']; + /** Last recorded Underlying token price in USD cents */ + lastUnderlyingPriceCents: Scalars['BigInt']['output']; + /** Name of the vToken */ + name: Scalars['String']['output']; + /** The factor determining interest that goes to reserves */ + reserveFactorMantissa: Scalars['BigInt']['output']; + /** Reserves stored in the contract */ + reservesMantissa: Scalars['BigInt']['output']; + /** Number of accounts currently supplying to this market */ + supplierCount: Scalars['BigInt']['output']; + /** Supply rate per block */ + supplyRateMantissa: Scalars['BigInt']['output']; + /** VToken symbol */ + symbol: Scalars['String']['output']; + /** Borrows in the market */ + totalBorrowsMantissa: Scalars['BigInt']['output']; + /** Total vToken supplied */ + totalSupplyVTokenMantissa: Scalars['BigInt']['output']; + /** Total XVS Distributed for this market */ + totalXvsDistributedMantissa: Scalars['BigInt']['output']; + /** Underlying Token */ + underlyingToken: Token; + /** vToken decimal length */ + vTokenDecimals: Scalars['Int']['output']; + /** The rate at which XVS is distributed to the corresponding borrow market (per block) */ + xvsBorrowSpeed: Scalars['BigInt']['output']; + /** XVS Reward Distribution Block */ + xvsBorrowStateBlock: Scalars['BigInt']['output']; + /** XVS Reward Distribution Index */ + xvsBorrowStateIndex: Scalars['BigInt']['output']; + /** The rate at which XVS is distributed to the corresponding supply market (per block) */ + xvsSupplySpeed: Scalars['BigInt']['output']; + /** XVS Supply Distribution Block */ + xvsSupplyStateBlock: Scalars['BigInt']['output']; + /** XVS Supply Distribution Index */ + xvsSupplyStateIndex: Scalars['BigInt']['output']; +}; + + +/** + * Market stores all high level variables for a vToken market + * + */ +export type MarketAccountsArgs = { + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + where?: InputMaybe; +}; + +/** + * MarketPosition is a single account within a single vToken market + * + */ +export type MarketPosition = { + __typename?: 'MarketPosition'; + /** Relation to user */ + account: Account; + /** Block the position is updated to */ + accrualBlockNumber: Scalars['BigInt']['output']; + /** Borrow Index this position last accrued interest */ + borrowIndex: Scalars['BigInt']['output']; + /** True if user is entered, false if they are exited */ + enteredMarket: Scalars['Boolean']['output']; + /** Concatenation of VToken address and user address */ + id: Scalars['Bytes']['output']; + /** Relation to market */ + market: Market; + /** Stored borrow balance stored in contract (exclusive of interest since accrualBlockNumber) */ + storedBorrowBalanceMantissa: Scalars['BigInt']['output']; + /** Total amount of underlying redeemed */ + totalUnderlyingRedeemedMantissa: Scalars['BigInt']['output']; + /** Total amount underlying repaid */ + totalUnderlyingRepaidMantissa: Scalars['BigInt']['output']; + /** VToken balance of the user */ + vTokenBalanceMantissa: Scalars['BigInt']['output']; +}; + +export type MarketPosition_Filter = { + /** Filter for the block changed event. */ + _change_block?: InputMaybe; + account?: InputMaybe; + account_?: InputMaybe; + account_contains?: InputMaybe; + account_contains_nocase?: InputMaybe; + account_ends_with?: InputMaybe; + account_ends_with_nocase?: InputMaybe; + account_gt?: InputMaybe; + account_gte?: InputMaybe; + account_in?: InputMaybe>; + account_lt?: InputMaybe; + account_lte?: InputMaybe; + account_not?: InputMaybe; + account_not_contains?: InputMaybe; + account_not_contains_nocase?: InputMaybe; + account_not_ends_with?: InputMaybe; + account_not_ends_with_nocase?: InputMaybe; + account_not_in?: InputMaybe>; + account_not_starts_with?: InputMaybe; + account_not_starts_with_nocase?: InputMaybe; + account_starts_with?: InputMaybe; + account_starts_with_nocase?: InputMaybe; + accrualBlockNumber?: InputMaybe; + accrualBlockNumber_gt?: InputMaybe; + accrualBlockNumber_gte?: InputMaybe; + accrualBlockNumber_in?: InputMaybe>; + accrualBlockNumber_lt?: InputMaybe; + accrualBlockNumber_lte?: InputMaybe; + accrualBlockNumber_not?: InputMaybe; + accrualBlockNumber_not_in?: InputMaybe>; + and?: InputMaybe>>; + borrowIndex?: InputMaybe; + borrowIndex_gt?: InputMaybe; + borrowIndex_gte?: InputMaybe; + borrowIndex_in?: InputMaybe>; + borrowIndex_lt?: InputMaybe; + borrowIndex_lte?: InputMaybe; + borrowIndex_not?: InputMaybe; + borrowIndex_not_in?: InputMaybe>; + enteredMarket?: InputMaybe; + enteredMarket_in?: InputMaybe>; + enteredMarket_not?: InputMaybe; + enteredMarket_not_in?: InputMaybe>; + id?: InputMaybe; + id_contains?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_in?: InputMaybe>; + market?: InputMaybe; + market_?: InputMaybe; + market_contains?: InputMaybe; + market_contains_nocase?: InputMaybe; + market_ends_with?: InputMaybe; + market_ends_with_nocase?: InputMaybe; + market_gt?: InputMaybe; + market_gte?: InputMaybe; + market_in?: InputMaybe>; + market_lt?: InputMaybe; + market_lte?: InputMaybe; + market_not?: InputMaybe; + market_not_contains?: InputMaybe; + market_not_contains_nocase?: InputMaybe; + market_not_ends_with?: InputMaybe; + market_not_ends_with_nocase?: InputMaybe; + market_not_in?: InputMaybe>; + market_not_starts_with?: InputMaybe; + market_not_starts_with_nocase?: InputMaybe; + market_starts_with?: InputMaybe; + market_starts_with_nocase?: InputMaybe; + or?: InputMaybe>>; + storedBorrowBalanceMantissa?: InputMaybe; + storedBorrowBalanceMantissa_gt?: InputMaybe; + storedBorrowBalanceMantissa_gte?: InputMaybe; + storedBorrowBalanceMantissa_in?: InputMaybe>; + storedBorrowBalanceMantissa_lt?: InputMaybe; + storedBorrowBalanceMantissa_lte?: InputMaybe; + storedBorrowBalanceMantissa_not?: InputMaybe; + storedBorrowBalanceMantissa_not_in?: InputMaybe>; + totalUnderlyingRedeemedMantissa?: InputMaybe; + totalUnderlyingRedeemedMantissa_gt?: InputMaybe; + totalUnderlyingRedeemedMantissa_gte?: InputMaybe; + totalUnderlyingRedeemedMantissa_in?: InputMaybe>; + totalUnderlyingRedeemedMantissa_lt?: InputMaybe; + totalUnderlyingRedeemedMantissa_lte?: InputMaybe; + totalUnderlyingRedeemedMantissa_not?: InputMaybe; + totalUnderlyingRedeemedMantissa_not_in?: InputMaybe>; + totalUnderlyingRepaidMantissa?: InputMaybe; + totalUnderlyingRepaidMantissa_gt?: InputMaybe; + totalUnderlyingRepaidMantissa_gte?: InputMaybe; + totalUnderlyingRepaidMantissa_in?: InputMaybe>; + totalUnderlyingRepaidMantissa_lt?: InputMaybe; + totalUnderlyingRepaidMantissa_lte?: InputMaybe; + totalUnderlyingRepaidMantissa_not?: InputMaybe; + totalUnderlyingRepaidMantissa_not_in?: InputMaybe>; + vTokenBalanceMantissa?: InputMaybe; + vTokenBalanceMantissa_gt?: InputMaybe; + vTokenBalanceMantissa_gte?: InputMaybe; + vTokenBalanceMantissa_in?: InputMaybe>; + vTokenBalanceMantissa_lt?: InputMaybe; + vTokenBalanceMantissa_lte?: InputMaybe; + vTokenBalanceMantissa_not?: InputMaybe; + vTokenBalanceMantissa_not_in?: InputMaybe>; +}; + +export enum MarketPosition_OrderBy { + Account = 'account', + AccountAddress = 'account__address', + AccountCountLiquidated = 'account__countLiquidated', + AccountCountLiquidator = 'account__countLiquidator', + AccountHasBorrowed = 'account__hasBorrowed', + AccountId = 'account__id', + AccrualBlockNumber = 'accrualBlockNumber', + BorrowIndex = 'borrowIndex', + EnteredMarket = 'enteredMarket', + Id = 'id', + Market = 'market', + MarketAccrualBlockNumber = 'market__accrualBlockNumber', + MarketAddress = 'market__address', + MarketBorrowIndex = 'market__borrowIndex', + MarketBorrowRateMantissa = 'market__borrowRateMantissa', + MarketBorrowerCount = 'market__borrowerCount', + MarketCashMantissa = 'market__cashMantissa', + MarketCollateralFactorMantissa = 'market__collateralFactorMantissa', + MarketExchangeRateMantissa = 'market__exchangeRateMantissa', + MarketId = 'market__id', + MarketInterestRateModelAddress = 'market__interestRateModelAddress', + MarketIsListed = 'market__isListed', + MarketLastUnderlyingPriceBlockNumber = 'market__lastUnderlyingPriceBlockNumber', + MarketLastUnderlyingPriceCents = 'market__lastUnderlyingPriceCents', + MarketName = 'market__name', + MarketReserveFactorMantissa = 'market__reserveFactorMantissa', + MarketReservesMantissa = 'market__reservesMantissa', + MarketSupplierCount = 'market__supplierCount', + MarketSupplyRateMantissa = 'market__supplyRateMantissa', + MarketSymbol = 'market__symbol', + MarketTotalBorrowsMantissa = 'market__totalBorrowsMantissa', + MarketTotalSupplyVTokenMantissa = 'market__totalSupplyVTokenMantissa', + MarketTotalXvsDistributedMantissa = 'market__totalXvsDistributedMantissa', + MarketVTokenDecimals = 'market__vTokenDecimals', + MarketXvsBorrowSpeed = 'market__xvsBorrowSpeed', + MarketXvsBorrowStateBlock = 'market__xvsBorrowStateBlock', + MarketXvsBorrowStateIndex = 'market__xvsBorrowStateIndex', + MarketXvsSupplySpeed = 'market__xvsSupplySpeed', + MarketXvsSupplyStateBlock = 'market__xvsSupplyStateBlock', + MarketXvsSupplyStateIndex = 'market__xvsSupplyStateIndex', + StoredBorrowBalanceMantissa = 'storedBorrowBalanceMantissa', + TotalUnderlyingRedeemedMantissa = 'totalUnderlyingRedeemedMantissa', + TotalUnderlyingRepaidMantissa = 'totalUnderlyingRepaidMantissa', + VTokenBalanceMantissa = 'vTokenBalanceMantissa' +} + +export type Market_Filter = { + /** Filter for the block changed event. */ + _change_block?: InputMaybe; + accounts_?: InputMaybe; + accrualBlockNumber?: InputMaybe; + accrualBlockNumber_gt?: InputMaybe; + accrualBlockNumber_gte?: InputMaybe; + accrualBlockNumber_in?: InputMaybe>; + accrualBlockNumber_lt?: InputMaybe; + accrualBlockNumber_lte?: InputMaybe; + accrualBlockNumber_not?: InputMaybe; + accrualBlockNumber_not_in?: InputMaybe>; + address?: InputMaybe; + address_contains?: InputMaybe; + address_gt?: InputMaybe; + address_gte?: InputMaybe; + address_in?: InputMaybe>; + address_lt?: InputMaybe; + address_lte?: InputMaybe; + address_not?: InputMaybe; + address_not_contains?: InputMaybe; + address_not_in?: InputMaybe>; + and?: InputMaybe>>; + borrowIndex?: InputMaybe; + borrowIndex_gt?: InputMaybe; + borrowIndex_gte?: InputMaybe; + borrowIndex_in?: InputMaybe>; + borrowIndex_lt?: InputMaybe; + borrowIndex_lte?: InputMaybe; + borrowIndex_not?: InputMaybe; + borrowIndex_not_in?: InputMaybe>; + borrowRateMantissa?: InputMaybe; + borrowRateMantissa_gt?: InputMaybe; + borrowRateMantissa_gte?: InputMaybe; + borrowRateMantissa_in?: InputMaybe>; + borrowRateMantissa_lt?: InputMaybe; + borrowRateMantissa_lte?: InputMaybe; + borrowRateMantissa_not?: InputMaybe; + borrowRateMantissa_not_in?: InputMaybe>; + borrowerCount?: InputMaybe; + borrowerCount_gt?: InputMaybe; + borrowerCount_gte?: InputMaybe; + borrowerCount_in?: InputMaybe>; + borrowerCount_lt?: InputMaybe; + borrowerCount_lte?: InputMaybe; + borrowerCount_not?: InputMaybe; + borrowerCount_not_in?: InputMaybe>; + cashMantissa?: InputMaybe; + cashMantissa_gt?: InputMaybe; + cashMantissa_gte?: InputMaybe; + cashMantissa_in?: InputMaybe>; + cashMantissa_lt?: InputMaybe; + cashMantissa_lte?: InputMaybe; + cashMantissa_not?: InputMaybe; + cashMantissa_not_in?: InputMaybe>; + collateralFactorMantissa?: InputMaybe; + collateralFactorMantissa_gt?: InputMaybe; + collateralFactorMantissa_gte?: InputMaybe; + collateralFactorMantissa_in?: InputMaybe>; + collateralFactorMantissa_lt?: InputMaybe; + collateralFactorMantissa_lte?: InputMaybe; + collateralFactorMantissa_not?: InputMaybe; + collateralFactorMantissa_not_in?: InputMaybe>; + exchangeRateMantissa?: InputMaybe; + exchangeRateMantissa_gt?: InputMaybe; + exchangeRateMantissa_gte?: InputMaybe; + exchangeRateMantissa_in?: InputMaybe>; + exchangeRateMantissa_lt?: InputMaybe; + exchangeRateMantissa_lte?: InputMaybe; + exchangeRateMantissa_not?: InputMaybe; + exchangeRateMantissa_not_in?: InputMaybe>; + id?: InputMaybe; + id_contains?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_in?: InputMaybe>; + interestRateModelAddress?: InputMaybe; + interestRateModelAddress_contains?: InputMaybe; + interestRateModelAddress_gt?: InputMaybe; + interestRateModelAddress_gte?: InputMaybe; + interestRateModelAddress_in?: InputMaybe>; + interestRateModelAddress_lt?: InputMaybe; + interestRateModelAddress_lte?: InputMaybe; + interestRateModelAddress_not?: InputMaybe; + interestRateModelAddress_not_contains?: InputMaybe; + interestRateModelAddress_not_in?: InputMaybe>; + isListed?: InputMaybe; + isListed_in?: InputMaybe>; + isListed_not?: InputMaybe; + isListed_not_in?: InputMaybe>; + lastUnderlyingPriceBlockNumber?: InputMaybe; + lastUnderlyingPriceBlockNumber_gt?: InputMaybe; + lastUnderlyingPriceBlockNumber_gte?: InputMaybe; + lastUnderlyingPriceBlockNumber_in?: InputMaybe>; + lastUnderlyingPriceBlockNumber_lt?: InputMaybe; + lastUnderlyingPriceBlockNumber_lte?: InputMaybe; + lastUnderlyingPriceBlockNumber_not?: InputMaybe; + lastUnderlyingPriceBlockNumber_not_in?: InputMaybe>; + lastUnderlyingPriceCents?: InputMaybe; + lastUnderlyingPriceCents_gt?: InputMaybe; + lastUnderlyingPriceCents_gte?: InputMaybe; + lastUnderlyingPriceCents_in?: InputMaybe>; + lastUnderlyingPriceCents_lt?: InputMaybe; + lastUnderlyingPriceCents_lte?: InputMaybe; + lastUnderlyingPriceCents_not?: InputMaybe; + lastUnderlyingPriceCents_not_in?: InputMaybe>; + name?: InputMaybe; + name_contains?: InputMaybe; + name_contains_nocase?: InputMaybe; + name_ends_with?: InputMaybe; + name_ends_with_nocase?: InputMaybe; + name_gt?: InputMaybe; + name_gte?: InputMaybe; + name_in?: InputMaybe>; + name_lt?: InputMaybe; + name_lte?: InputMaybe; + name_not?: InputMaybe; + name_not_contains?: InputMaybe; + name_not_contains_nocase?: InputMaybe; + name_not_ends_with?: InputMaybe; + name_not_ends_with_nocase?: InputMaybe; + name_not_in?: InputMaybe>; + name_not_starts_with?: InputMaybe; + name_not_starts_with_nocase?: InputMaybe; + name_starts_with?: InputMaybe; + name_starts_with_nocase?: InputMaybe; + or?: InputMaybe>>; + reserveFactorMantissa?: InputMaybe; + reserveFactorMantissa_gt?: InputMaybe; + reserveFactorMantissa_gte?: InputMaybe; + reserveFactorMantissa_in?: InputMaybe>; + reserveFactorMantissa_lt?: InputMaybe; + reserveFactorMantissa_lte?: InputMaybe; + reserveFactorMantissa_not?: InputMaybe; + reserveFactorMantissa_not_in?: InputMaybe>; + reservesMantissa?: InputMaybe; + reservesMantissa_gt?: InputMaybe; + reservesMantissa_gte?: InputMaybe; + reservesMantissa_in?: InputMaybe>; + reservesMantissa_lt?: InputMaybe; + reservesMantissa_lte?: InputMaybe; + reservesMantissa_not?: InputMaybe; + reservesMantissa_not_in?: InputMaybe>; + supplierCount?: InputMaybe; + supplierCount_gt?: InputMaybe; + supplierCount_gte?: InputMaybe; + supplierCount_in?: InputMaybe>; + supplierCount_lt?: InputMaybe; + supplierCount_lte?: InputMaybe; + supplierCount_not?: InputMaybe; + supplierCount_not_in?: InputMaybe>; + supplyRateMantissa?: InputMaybe; + supplyRateMantissa_gt?: InputMaybe; + supplyRateMantissa_gte?: InputMaybe; + supplyRateMantissa_in?: InputMaybe>; + supplyRateMantissa_lt?: InputMaybe; + supplyRateMantissa_lte?: InputMaybe; + supplyRateMantissa_not?: InputMaybe; + supplyRateMantissa_not_in?: InputMaybe>; + symbol?: InputMaybe; + symbol_contains?: InputMaybe; + symbol_contains_nocase?: InputMaybe; + symbol_ends_with?: InputMaybe; + symbol_ends_with_nocase?: InputMaybe; + symbol_gt?: InputMaybe; + symbol_gte?: InputMaybe; + symbol_in?: InputMaybe>; + symbol_lt?: InputMaybe; + symbol_lte?: InputMaybe; + symbol_not?: InputMaybe; + symbol_not_contains?: InputMaybe; + symbol_not_contains_nocase?: InputMaybe; + symbol_not_ends_with?: InputMaybe; + symbol_not_ends_with_nocase?: InputMaybe; + symbol_not_in?: InputMaybe>; + symbol_not_starts_with?: InputMaybe; + symbol_not_starts_with_nocase?: InputMaybe; + symbol_starts_with?: InputMaybe; + symbol_starts_with_nocase?: InputMaybe; + totalBorrowsMantissa?: InputMaybe; + totalBorrowsMantissa_gt?: InputMaybe; + totalBorrowsMantissa_gte?: InputMaybe; + totalBorrowsMantissa_in?: InputMaybe>; + totalBorrowsMantissa_lt?: InputMaybe; + totalBorrowsMantissa_lte?: InputMaybe; + totalBorrowsMantissa_not?: InputMaybe; + totalBorrowsMantissa_not_in?: InputMaybe>; + totalSupplyVTokenMantissa?: InputMaybe; + totalSupplyVTokenMantissa_gt?: InputMaybe; + totalSupplyVTokenMantissa_gte?: InputMaybe; + totalSupplyVTokenMantissa_in?: InputMaybe>; + totalSupplyVTokenMantissa_lt?: InputMaybe; + totalSupplyVTokenMantissa_lte?: InputMaybe; + totalSupplyVTokenMantissa_not?: InputMaybe; + totalSupplyVTokenMantissa_not_in?: InputMaybe>; + totalXvsDistributedMantissa?: InputMaybe; + totalXvsDistributedMantissa_gt?: InputMaybe; + totalXvsDistributedMantissa_gte?: InputMaybe; + totalXvsDistributedMantissa_in?: InputMaybe>; + totalXvsDistributedMantissa_lt?: InputMaybe; + totalXvsDistributedMantissa_lte?: InputMaybe; + totalXvsDistributedMantissa_not?: InputMaybe; + totalXvsDistributedMantissa_not_in?: InputMaybe>; + underlyingToken?: InputMaybe; + underlyingToken_?: InputMaybe; + underlyingToken_contains?: InputMaybe; + underlyingToken_contains_nocase?: InputMaybe; + underlyingToken_ends_with?: InputMaybe; + underlyingToken_ends_with_nocase?: InputMaybe; + underlyingToken_gt?: InputMaybe; + underlyingToken_gte?: InputMaybe; + underlyingToken_in?: InputMaybe>; + underlyingToken_lt?: InputMaybe; + underlyingToken_lte?: InputMaybe; + underlyingToken_not?: InputMaybe; + underlyingToken_not_contains?: InputMaybe; + underlyingToken_not_contains_nocase?: InputMaybe; + underlyingToken_not_ends_with?: InputMaybe; + underlyingToken_not_ends_with_nocase?: InputMaybe; + underlyingToken_not_in?: InputMaybe>; + underlyingToken_not_starts_with?: InputMaybe; + underlyingToken_not_starts_with_nocase?: InputMaybe; + underlyingToken_starts_with?: InputMaybe; + underlyingToken_starts_with_nocase?: InputMaybe; + vTokenDecimals?: InputMaybe; + vTokenDecimals_gt?: InputMaybe; + vTokenDecimals_gte?: InputMaybe; + vTokenDecimals_in?: InputMaybe>; + vTokenDecimals_lt?: InputMaybe; + vTokenDecimals_lte?: InputMaybe; + vTokenDecimals_not?: InputMaybe; + vTokenDecimals_not_in?: InputMaybe>; + xvsBorrowSpeed?: InputMaybe; + xvsBorrowSpeed_gt?: InputMaybe; + xvsBorrowSpeed_gte?: InputMaybe; + xvsBorrowSpeed_in?: InputMaybe>; + xvsBorrowSpeed_lt?: InputMaybe; + xvsBorrowSpeed_lte?: InputMaybe; + xvsBorrowSpeed_not?: InputMaybe; + xvsBorrowSpeed_not_in?: InputMaybe>; + xvsBorrowStateBlock?: InputMaybe; + xvsBorrowStateBlock_gt?: InputMaybe; + xvsBorrowStateBlock_gte?: InputMaybe; + xvsBorrowStateBlock_in?: InputMaybe>; + xvsBorrowStateBlock_lt?: InputMaybe; + xvsBorrowStateBlock_lte?: InputMaybe; + xvsBorrowStateBlock_not?: InputMaybe; + xvsBorrowStateBlock_not_in?: InputMaybe>; + xvsBorrowStateIndex?: InputMaybe; + xvsBorrowStateIndex_gt?: InputMaybe; + xvsBorrowStateIndex_gte?: InputMaybe; + xvsBorrowStateIndex_in?: InputMaybe>; + xvsBorrowStateIndex_lt?: InputMaybe; + xvsBorrowStateIndex_lte?: InputMaybe; + xvsBorrowStateIndex_not?: InputMaybe; + xvsBorrowStateIndex_not_in?: InputMaybe>; + xvsSupplySpeed?: InputMaybe; + xvsSupplySpeed_gt?: InputMaybe; + xvsSupplySpeed_gte?: InputMaybe; + xvsSupplySpeed_in?: InputMaybe>; + xvsSupplySpeed_lt?: InputMaybe; + xvsSupplySpeed_lte?: InputMaybe; + xvsSupplySpeed_not?: InputMaybe; + xvsSupplySpeed_not_in?: InputMaybe>; + xvsSupplyStateBlock?: InputMaybe; + xvsSupplyStateBlock_gt?: InputMaybe; + xvsSupplyStateBlock_gte?: InputMaybe; + xvsSupplyStateBlock_in?: InputMaybe>; + xvsSupplyStateBlock_lt?: InputMaybe; + xvsSupplyStateBlock_lte?: InputMaybe; + xvsSupplyStateBlock_not?: InputMaybe; + xvsSupplyStateBlock_not_in?: InputMaybe>; + xvsSupplyStateIndex?: InputMaybe; + xvsSupplyStateIndex_gt?: InputMaybe; + xvsSupplyStateIndex_gte?: InputMaybe; + xvsSupplyStateIndex_in?: InputMaybe>; + xvsSupplyStateIndex_lt?: InputMaybe; + xvsSupplyStateIndex_lte?: InputMaybe; + xvsSupplyStateIndex_not?: InputMaybe; + xvsSupplyStateIndex_not_in?: InputMaybe>; +}; + +export enum Market_OrderBy { + Accounts = 'accounts', + AccrualBlockNumber = 'accrualBlockNumber', + Address = 'address', + BorrowIndex = 'borrowIndex', + BorrowRateMantissa = 'borrowRateMantissa', + BorrowerCount = 'borrowerCount', + CashMantissa = 'cashMantissa', + CollateralFactorMantissa = 'collateralFactorMantissa', + ExchangeRateMantissa = 'exchangeRateMantissa', + Id = 'id', + InterestRateModelAddress = 'interestRateModelAddress', + IsListed = 'isListed', + LastUnderlyingPriceBlockNumber = 'lastUnderlyingPriceBlockNumber', + LastUnderlyingPriceCents = 'lastUnderlyingPriceCents', + Name = 'name', + ReserveFactorMantissa = 'reserveFactorMantissa', + ReservesMantissa = 'reservesMantissa', + SupplierCount = 'supplierCount', + SupplyRateMantissa = 'supplyRateMantissa', + Symbol = 'symbol', + TotalBorrowsMantissa = 'totalBorrowsMantissa', + TotalSupplyVTokenMantissa = 'totalSupplyVTokenMantissa', + TotalXvsDistributedMantissa = 'totalXvsDistributedMantissa', + UnderlyingToken = 'underlyingToken', + UnderlyingTokenAddress = 'underlyingToken__address', + UnderlyingTokenDecimals = 'underlyingToken__decimals', + UnderlyingTokenId = 'underlyingToken__id', + UnderlyingTokenName = 'underlyingToken__name', + UnderlyingTokenSymbol = 'underlyingToken__symbol', + VTokenDecimals = 'vTokenDecimals', + XvsBorrowSpeed = 'xvsBorrowSpeed', + XvsBorrowStateBlock = 'xvsBorrowStateBlock', + XvsBorrowStateIndex = 'xvsBorrowStateIndex', + XvsSupplySpeed = 'xvsSupplySpeed', + XvsSupplyStateBlock = 'xvsSupplyStateBlock', + XvsSupplyStateIndex = 'xvsSupplyStateIndex' +} + +/** Defines the order direction, either ascending or descending */ +export enum OrderDirection { + Asc = 'asc', + Desc = 'desc' +} + +export type Query = { + __typename?: 'Query'; + /** Access to subgraph metadata */ + _meta?: Maybe<_Meta_>; + account?: Maybe; + accounts: Array; + comptroller?: Maybe; + comptrollers: Array; + market?: Maybe; + marketPosition?: Maybe; + marketPositions: Array; + markets: Array; + token?: Maybe; + tokens: Array; + transaction?: Maybe; + transactions: Array; +}; + + +export type Query_MetaArgs = { + block?: InputMaybe; +}; + + +export type QueryAccountArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type QueryAccountsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type QueryComptrollerArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type QueryComptrollersArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type QueryMarketArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type QueryMarketPositionArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type QueryMarketPositionsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type QueryMarketsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type QueryTokenArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type QueryTokensArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type QueryTransactionArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type QueryTransactionsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + +export type Subscription = { + __typename?: 'Subscription'; + /** Access to subgraph metadata */ + _meta?: Maybe<_Meta_>; + account?: Maybe; + accounts: Array; + comptroller?: Maybe; + comptrollers: Array; + market?: Maybe; + marketPosition?: Maybe; + marketPositions: Array; + markets: Array; + token?: Maybe; + tokens: Array; + transaction?: Maybe; + transactions: Array; +}; + + +export type Subscription_MetaArgs = { + block?: InputMaybe; +}; + + +export type SubscriptionAccountArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type SubscriptionAccountsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type SubscriptionComptrollerArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type SubscriptionComptrollersArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type SubscriptionMarketArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type SubscriptionMarketPositionArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type SubscriptionMarketPositionsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type SubscriptionMarketsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type SubscriptionTokenArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type SubscriptionTokensArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + + +export type SubscriptionTransactionArgs = { + block?: InputMaybe; + id: Scalars['ID']['input']; + subgraphError?: _SubgraphErrorPolicy_; +}; + + +export type SubscriptionTransactionsArgs = { + block?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + skip?: InputMaybe; + subgraphError?: _SubgraphErrorPolicy_; + where?: InputMaybe; +}; + +/** + * ERC20 Token + * + */ +export type Token = { + __typename?: 'Token'; + /** Address of the asset */ + address: Scalars['Bytes']['output']; + /** Decimals of the asset */ + decimals: Scalars['Int']['output']; + /** Address of the asset */ + id: Scalars['Bytes']['output']; + /** Name of the asset */ + name: Scalars['String']['output']; + /** Symbol of the asset */ + symbol?: Maybe; +}; + +export type Token_Filter = { + /** Filter for the block changed event. */ + _change_block?: InputMaybe; + address?: InputMaybe; + address_contains?: InputMaybe; + address_gt?: InputMaybe; + address_gte?: InputMaybe; + address_in?: InputMaybe>; + address_lt?: InputMaybe; + address_lte?: InputMaybe; + address_not?: InputMaybe; + address_not_contains?: InputMaybe; + address_not_in?: InputMaybe>; + and?: InputMaybe>>; + decimals?: InputMaybe; + decimals_gt?: InputMaybe; + decimals_gte?: InputMaybe; + decimals_in?: InputMaybe>; + decimals_lt?: InputMaybe; + decimals_lte?: InputMaybe; + decimals_not?: InputMaybe; + decimals_not_in?: InputMaybe>; + id?: InputMaybe; + id_contains?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_in?: InputMaybe>; + name?: InputMaybe; + name_contains?: InputMaybe; + name_contains_nocase?: InputMaybe; + name_ends_with?: InputMaybe; + name_ends_with_nocase?: InputMaybe; + name_gt?: InputMaybe; + name_gte?: InputMaybe; + name_in?: InputMaybe>; + name_lt?: InputMaybe; + name_lte?: InputMaybe; + name_not?: InputMaybe; + name_not_contains?: InputMaybe; + name_not_contains_nocase?: InputMaybe; + name_not_ends_with?: InputMaybe; + name_not_ends_with_nocase?: InputMaybe; + name_not_in?: InputMaybe>; + name_not_starts_with?: InputMaybe; + name_not_starts_with_nocase?: InputMaybe; + name_starts_with?: InputMaybe; + name_starts_with_nocase?: InputMaybe; + or?: InputMaybe>>; + symbol?: InputMaybe; + symbol_contains?: InputMaybe; + symbol_contains_nocase?: InputMaybe; + symbol_ends_with?: InputMaybe; + symbol_ends_with_nocase?: InputMaybe; + symbol_gt?: InputMaybe; + symbol_gte?: InputMaybe; + symbol_in?: InputMaybe>; + symbol_lt?: InputMaybe; + symbol_lte?: InputMaybe; + symbol_not?: InputMaybe; + symbol_not_contains?: InputMaybe; + symbol_not_contains_nocase?: InputMaybe; + symbol_not_ends_with?: InputMaybe; + symbol_not_ends_with_nocase?: InputMaybe; + symbol_not_in?: InputMaybe>; + symbol_not_starts_with?: InputMaybe; + symbol_not_starts_with_nocase?: InputMaybe; + symbol_starts_with?: InputMaybe; + symbol_starts_with_nocase?: InputMaybe; +}; + +export enum Token_OrderBy { + Address = 'address', + Decimals = 'decimals', + Id = 'id', + Name = 'name', + Symbol = 'symbol' +} + +/** + * An interface for a transfer of any vToken. TransferEvent, MintEvent, + * RedeemEvent, and LiquidationEvent all use this interface + * + */ +export type Transaction = { + __typename?: 'Transaction'; + /** count of vTokens transferred */ + amountMantissa: Scalars['BigInt']['output']; + /** Block number */ + blockNumber: Scalars['Int']['output']; + /** Block time */ + blockTime: Scalars['Int']['output']; + /** The account that sent the tokens, usually vToken */ + from: Scalars['Bytes']['output']; + /** Transaction hash concatenated with log index */ + id: Scalars['Bytes']['output']; + /** Account that received tokens */ + to: Scalars['Bytes']['output']; + /** enum of event type */ + type: EventType; +}; + +export type Transaction_Filter = { + /** Filter for the block changed event. */ + _change_block?: InputMaybe; + amountMantissa?: InputMaybe; + amountMantissa_gt?: InputMaybe; + amountMantissa_gte?: InputMaybe; + amountMantissa_in?: InputMaybe>; + amountMantissa_lt?: InputMaybe; + amountMantissa_lte?: InputMaybe; + amountMantissa_not?: InputMaybe; + amountMantissa_not_in?: InputMaybe>; + and?: InputMaybe>>; + blockNumber?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + blockTime?: InputMaybe; + blockTime_gt?: InputMaybe; + blockTime_gte?: InputMaybe; + blockTime_in?: InputMaybe>; + blockTime_lt?: InputMaybe; + blockTime_lte?: InputMaybe; + blockTime_not?: InputMaybe; + blockTime_not_in?: InputMaybe>; + from?: InputMaybe; + from_contains?: InputMaybe; + from_gt?: InputMaybe; + from_gte?: InputMaybe; + from_in?: InputMaybe>; + from_lt?: InputMaybe; + from_lte?: InputMaybe; + from_not?: InputMaybe; + from_not_contains?: InputMaybe; + from_not_in?: InputMaybe>; + id?: InputMaybe; + id_contains?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_in?: InputMaybe>; + or?: InputMaybe>>; + to?: InputMaybe; + to_contains?: InputMaybe; + to_gt?: InputMaybe; + to_gte?: InputMaybe; + to_in?: InputMaybe>; + to_lt?: InputMaybe; + to_lte?: InputMaybe; + to_not?: InputMaybe; + to_not_contains?: InputMaybe; + to_not_in?: InputMaybe>; + type?: InputMaybe; + type_in?: InputMaybe>; + type_not?: InputMaybe; + type_not_in?: InputMaybe>; +}; + +export enum Transaction_OrderBy { + AmountMantissa = 'amountMantissa', + BlockNumber = 'blockNumber', + BlockTime = 'blockTime', + From = 'from', + Id = 'id', + To = 'to', + Type = 'type' +} + +export type _Block_ = { + __typename?: '_Block_'; + /** The hash of the block */ + hash?: Maybe; + /** The block number */ + number: Scalars['Int']['output']; + /** The hash of the parent block */ + parentHash?: Maybe; + /** Integer representation of the timestamp stored in blocks for the chain */ + timestamp?: Maybe; +}; + +/** The type for the top-level _meta field */ +export type _Meta_ = { + __typename?: '_Meta_'; + /** + * Information about a specific subgraph block. The hash of the block + * will be null if the _meta field has a block constraint that asks for + * a block number. It will be filled if the _meta field has no block constraint + * and therefore asks for the latest block + * + */ + block: _Block_; + /** The deployment ID */ + deployment: Scalars['String']['output']; + /** If `true`, the subgraph encountered indexing errors at some past block */ + hasIndexingErrors: Scalars['Boolean']['output']; +}; + +export enum _SubgraphErrorPolicy_ { + /** Data will be returned even if the subgraph has indexing errors */ + Allow = 'allow', + /** If the subgraph has indexing errors, data will be omitted. The default. */ + Deny = 'deny' +} + + +export const BscCorePoolParticipantsCountDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"BscCorePoolParticipantsCount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"markets"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"supplierCount"}},{"kind":"Field","name":{"kind":"Name","value":"borrowerCount"}}]}}]}}]} as unknown as DocumentNode; +export type BscCorePoolParticipantsCountQueryVariables = Exact<{ [key: string]: never; }>; + + +export type BscCorePoolParticipantsCountQuery = { __typename?: 'Query', markets: Array<{ __typename?: 'Market', id: any, supplierCount: any, borrowerCount: any }> }; diff --git a/apps/evm/src/clients/subgraph/index.ts b/apps/evm/src/clients/subgraph/index.ts index 8a99d195c1..948b8c24b9 100644 --- a/apps/evm/src/clients/subgraph/index.ts +++ b/apps/evm/src/clients/subgraph/index.ts @@ -1,3 +1,4 @@ +export * from './queries/bscCorePool/getBscCorePoolParticipantsCount'; export * from './queries/isolatedPools/getIsolatedPoolParticipantsCount'; export * from './queries/governanceBsc/getBscProposals'; export * from './queries/governanceBsc/getBscProposal'; diff --git a/apps/evm/src/clients/subgraph/queries/bscCorePool/getBscCorePoolParticipantsCount/bscCorePoolParticipantsCount.graphql b/apps/evm/src/clients/subgraph/queries/bscCorePool/getBscCorePoolParticipantsCount/bscCorePoolParticipantsCount.graphql new file mode 100644 index 0000000000..892d11822e --- /dev/null +++ b/apps/evm/src/clients/subgraph/queries/bscCorePool/getBscCorePoolParticipantsCount/bscCorePoolParticipantsCount.graphql @@ -0,0 +1,7 @@ +query BscCorePoolParticipantsCount { + markets { + id + supplierCount + borrowerCount + } +} diff --git a/apps/evm/src/clients/subgraph/queries/bscCorePool/getBscCorePoolParticipantsCount/index.ts b/apps/evm/src/clients/subgraph/queries/bscCorePool/getBscCorePoolParticipantsCount/index.ts new file mode 100644 index 0000000000..4a1ea77a52 --- /dev/null +++ b/apps/evm/src/clients/subgraph/queries/bscCorePool/getBscCorePoolParticipantsCount/index.ts @@ -0,0 +1,16 @@ +import { request } from 'graphql-request'; + +import { BscCorePoolParticipantsCountDocument } from 'clients/subgraph/gql/generated/bscCorePool'; +import config from 'config'; +import type { ChainId } from 'types'; + +export interface GetBscCorePoolParticipantsCountInput { + chainId: ChainId.BSC_MAINNET | ChainId.BSC_TESTNET; +} + +export const getBscCorePoolParticipantsCount = ({ + chainId, +}: GetBscCorePoolParticipantsCountInput) => + config.bscCorePoolSubgraphUrls[chainId] + ? request(config.bscCorePoolSubgraphUrls[chainId], BscCorePoolParticipantsCountDocument) + : undefined; diff --git a/apps/evm/src/config/index.ts b/apps/evm/src/config/index.ts index 11496e3c84..276ff33d40 100644 --- a/apps/evm/src/config/index.ts +++ b/apps/evm/src/config/index.ts @@ -3,7 +3,11 @@ import type { ChainId, Environment, Network } from 'types'; import { apiUrls } from './apiUrls'; import { envVariables } from './envVariables'; import { rpcUrls } from './rpcUrls'; -import { getGovernanceSubgraphUrls, getIsolatedPoolsSubgraphUrls } from './subgraphUrls'; +import { + getBscCorePoolSubgraphUrls, + getGovernanceSubgraphUrls, + getIsolatedPoolsSubgraphUrls, +} from './subgraphUrls'; export interface Config { environment: Environment; @@ -12,6 +16,10 @@ export interface Config { rpcUrls: { [chainId in ChainId]: string; }; + bscCorePoolSubgraphUrls: { + [ChainId.BSC_MAINNET]: string | undefined; + [ChainId.BSC_TESTNET]: string | undefined; + }; isolatedPoolsSubgraphUrls: { [chainId in ChainId]: string | undefined; }; @@ -37,6 +45,7 @@ const keys = { }; const governanceSubgraphUrls = getGovernanceSubgraphUrls(keys); +const bscCorePoolSubgraphUrls = getBscCorePoolSubgraphUrls(keys); const isolatedPoolsSubgraphUrls = getIsolatedPoolsSubgraphUrls(keys); const config: Config = { @@ -44,6 +53,7 @@ const config: Config = { network, apiUrl, rpcUrls, + bscCorePoolSubgraphUrls, isolatedPoolsSubgraphUrls, governanceSubgraphUrls, sentryDsn: envVariables.VITE_SENTRY_DSN || '', diff --git a/apps/evm/src/config/subgraphUrls.ts b/apps/evm/src/config/subgraphUrls.ts index d1e4ad116d..7b6d041cbe 100644 --- a/apps/evm/src/config/subgraphUrls.ts +++ b/apps/evm/src/config/subgraphUrls.ts @@ -1,5 +1,22 @@ import { ChainId } from '@venusprotocol/chains/types'; +export const getBscCorePoolSubgraphUrls = ({ + theGraphApiKey, +}: { + theGraphApiKey: string; +}) => { + const subgraphUrls: { + [ChainId.BSC_MAINNET]: string | undefined; + [ChainId.BSC_TESTNET]: string | undefined; + } = { + [ChainId.BSC_MAINNET]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/deployments/id/QmUun2d96q7zTJS9q8pubMsCNVv2peomdfK6CkEeJyR7YA`, + [ChainId.BSC_TESTNET]: + 'https://api.studio.thegraph.com/query/64786/venus-subgraph-chapel/version/latest', + }; + + return subgraphUrls; +}; + export const getIsolatedPoolsSubgraphUrls = ({ nodeRealApiKey, theGraphApiKey, diff --git a/apps/evm/src/libs/errors/logError.ts b/apps/evm/src/libs/errors/logError.ts index bb5d99e448..132ec12fa7 100644 --- a/apps/evm/src/libs/errors/logError.ts +++ b/apps/evm/src/libs/errors/logError.ts @@ -9,6 +9,13 @@ export const logError = (error: string | unknown) => { return; } + // Safari throws a "TypeError: Load failed" error if the fetch is canceled + // e.g., if the user navigates away from the page before the request is finished + // we can safely filter them out from being logged + if (error instanceof Error && error.name === 'TypeError' && error.message === 'Load failed') { + return; + } + if (typeof error === 'string') { Sentry.captureMessage(error); } else {