diff --git a/pages/api/aave.ts b/pages/api/aave.ts index 9115bf3..32019f1 100644 --- a/pages/api/aave.ts +++ b/pages/api/aave.ts @@ -1,5 +1,5 @@ import { NextApiRequest, NextApiResponse } from "next"; -import { ethers } from "ethers"; +import { Contract, ethers } from "ethers"; import { UiPoolDataProvider } from "@aave/contract-helpers"; import { formatReserves } from "@aave/math-utils"; import dayjs from "dayjs"; @@ -23,6 +23,7 @@ type configInterface = { protocol: string; lendingPoolAddressProvider: string; uiDataProvider: string; + pool: string; }; export default async function handler( @@ -35,6 +36,7 @@ export default async function handler( protocol: req.query.protocol as string, lendingPoolAddressProvider: req.query.lendingPoolAddressProvider as string, uiDataProvider: req.query.uiDataProvider as string, + pool: req.query.pool as string, }; const currentTimestamp = dayjs().unix(); @@ -55,6 +57,15 @@ export default async function handler( chainId, }); + let paused = false; + if (config.protocol === "v2") { + const abi = [ + "function paused() public view returns (bool)"] + const poolContract = new Contract(config.pool, abi, provider); + paused = await poolContract.paused(); + } + + const reserves = await poolDataProviderContract.getReservesHumanized({ lendingPoolAddressProvider, }); @@ -116,7 +127,7 @@ export default async function handler( : { symbol: n.symbol, frozen: n.isFrozen ? "True" : "False", - paused: n.isPaused ? "True" : "False", + paused: paused ? "True" : "False", canCollateral: n.usageAsCollateralEnabled ? "True" : "False", LTV: parseInt(n.baseLTVasCollateral) / 100 + "%", liqThereshold: parseInt(n.reserveLiquidationThreshold) / 100 + "%", diff --git a/services/aave.tsx b/services/aave.tsx index 06face4..f4c97e7 100644 --- a/services/aave.tsx +++ b/services/aave.tsx @@ -6,13 +6,14 @@ const fetchReservesAny = async ( publicJsonRPCUrl: string; LENDING_POOL_ADDRESS_PROVIDER: string; UI_POOL_DATA_PROVIDER: string; + POOL: string; marketName: string; }, protocol: string ) => { try { const response = await fetch( - `/api/aave?chainId=${config.chainId}&marketName=${config.marketName}&protocol=${protocol}&lendingPoolAddressProvider=${config.LENDING_POOL_ADDRESS_PROVIDER}&uiDataProvider=${config.UI_POOL_DATA_PROVIDER}` + `/api/aave?chainId=${config.chainId}&marketName=${config.marketName}&protocol=${protocol}&lendingPoolAddressProvider=${config.LENDING_POOL_ADDRESS_PROVIDER}&uiDataProvider=${config.UI_POOL_DATA_PROVIDER}&pool=${config.POOL}` ); const reservesArray = await response.json(); return reservesArray.data; diff --git a/utils/marketconfig.tsx b/utils/marketconfig.tsx index 5cbb467..f0f5657 100644 --- a/utils/marketconfig.tsx +++ b/utils/marketconfig.tsx @@ -22,6 +22,7 @@ export const marketConfig = { publicJsonRPCUrl: "https://eth-mainnet.alchemyapi.io/v2/demo", LENDING_POOL_ADDRESS_PROVIDER: AaveV2Ethereum.POOL_ADDRESSES_PROVIDER, UI_POOL_DATA_PROVIDER: AaveV2Ethereum.UI_POOL_DATA_PROVIDER, + POOL: AaveV2Ethereum.POOL, marketName: "proto_mainnet", }, avalanche: { @@ -29,6 +30,7 @@ export const marketConfig = { publicJsonRPCUrl: "https://api.avax.network/ext/bc/C/rpc", LENDING_POOL_ADDRESS_PROVIDER: AaveV2Avalanche.POOL_ADDRESSES_PROVIDER, UI_POOL_DATA_PROVIDER: AaveV2Avalanche.UI_POOL_DATA_PROVIDER, + POOL: AaveV2Avalanche.POOL, marketName: "proto_avalanche", }, polygon: { @@ -36,6 +38,7 @@ export const marketConfig = { publicJsonRPCUrl: "https://polygon-rpc.com", LENDING_POOL_ADDRESS_PROVIDER: AaveV2Polygon.POOL_ADDRESSES_PROVIDER, UI_POOL_DATA_PROVIDER: AaveV2Polygon.UI_POOL_DATA_PROVIDER, + POOL: AaveV2Polygon.POOL, marketName: "proto_polygon", }, ethamm: { @@ -43,6 +46,7 @@ export const marketConfig = { publicJsonRPCUrl: "https://eth-mainnet.alchemyapi.io/v2/demo", LENDING_POOL_ADDRESS_PROVIDER: AaveV2EthereumAMM.POOL_ADDRESSES_PROVIDER, UI_POOL_DATA_PROVIDER: AaveV2EthereumAMM.UI_POOL_DATA_PROVIDER, + POOL: AaveV2EthereumAMM.POOL, marketName: "amm_mainnet", }, arbitrum: {