diff --git a/components/asset/FloatingPool/index.tsx b/components/asset/FloatingPool/index.tsx index f6f98642e..492e98138 100644 --- a/components/asset/FloatingPool/index.tsx +++ b/components/asset/FloatingPool/index.tsx @@ -4,12 +4,15 @@ import FloatingPoolInfo from './FloatingPoolInfo'; import { Box, Grid } from '@mui/material'; import HistoricalRateChart from 'components/charts/HistoricalRateChart'; import UtilizationRateChart from 'components/charts/UtilizationRateChart'; +import { useWeb3 } from 'hooks/useWeb3'; +import { mainnet } from 'wagmi'; type AssetFloatingPoolProps = { symbol: string; }; const AssetFloatingPool: FC = ({ symbol }) => { + const { chain } = useWeb3(); return ( = ({ symbol }) => { > - (palette.mode === 'light' ? '0px 4px 12px rgba(175, 177, 182, 0.2)' : '')} - borderRadius="0px 0px 6px 6px" - bgcolor="components.bg" - p="16px" - > - - + {chain.id !== mainnet.id && ( + (palette.mode === 'light' ? '0px 4px 12px rgba(175, 177, 182, 0.2)' : '')} + borderRadius="0px 0px 6px 6px" + bgcolor="components.bg" + p="16px" + > + + + )} ); }; diff --git a/components/asset/Header.tsx b/components/asset/Header.tsx index f35ef3363..f093a486f 100644 --- a/components/asset/Header.tsx +++ b/components/asset/Header.tsx @@ -22,6 +22,7 @@ import { useWeb3 } from 'hooks/useWeb3'; import Alert from '@mui/material/Alert'; import { useFloatingBalances } from 'hooks/useFloatingBalances'; import { useFixedBalances } from 'hooks/useFixedBalances'; +import { mainnet } from 'wagmi'; type Props = { symbol: string; @@ -154,8 +155,14 @@ const AssetHeaderInfo: FC = ({ symbol }) => { const borrowableUtilization = useMemo(() => { if (!marketAccount) return; - return Number(WAD - marketAccount.reserveFactor) / 1e18; - }, [marketAccount]); + + if (displayNetworkId === mainnet.id) return 0.9; + + if ('reserveFactor' in marketAccount) { + return Number(WAD - marketAccount.reserveFactor) / 1e18; + } + return; + }, [displayNetworkId, marketAccount]); return ( <> diff --git a/components/asset/MaturityPool/index.tsx b/components/asset/MaturityPool/index.tsx index 72e221c29..e9aac54e1 100644 --- a/components/asset/MaturityPool/index.tsx +++ b/components/asset/MaturityPool/index.tsx @@ -10,6 +10,8 @@ import MaturityPoolsMobile from './MaturityPoolsMobile'; import useAccountData from 'hooks/useAccountData'; import { formatUnits } from 'viem'; import SpreadModelChart from 'components/charts/SpreadModelChart'; +import { mainnet } from 'wagmi'; +import { useWeb3 } from 'hooks/useWeb3'; type Rate = { maturity: bigint; @@ -24,6 +26,7 @@ const AssetMaturityPools: FC = ({ symbol }) => { const { marketAccount } = useAccountData(symbol); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + const { chain } = useWeb3(); const { totalDeposited, totalBorrowed, bestDeposit, bestBorrow } = useMemo<{ totalDeposited?: number; @@ -94,15 +97,17 @@ const AssetMaturityPools: FC = ({ symbol }) => { )} - (palette.mode === 'light' ? '0px 4px 12px rgba(175, 177, 182, 0.2)' : '')} - borderRadius="0px 0px 6px 6px" - bgcolor="components.bg" - p="16px" - height={480} - > - - + {chain.id !== mainnet.id && ( + (palette.mode === 'light' ? '0px 4px 12px rgba(175, 177, 182, 0.2)' : '')} + borderRadius="0px 0px 6px 6px" + bgcolor="components.bg" + p="16px" + height={480} + > + + + )} ); }; diff --git a/config/networkData.json b/config/networkData.json index 9a6b3a60b..12c3ad4d0 100644 --- a/config/networkData.json +++ b/config/networkData.json @@ -2,7 +2,7 @@ "1": { "etherscan": "https://etherscan.io", "subgraph": { - "exactly": "https://gateway.thegraph.com/api/3bd03f49a36caaa5ed4efc5a27c5425d/subgraphs/id/As6Xz6GCvbW8B9Xb7Rx2LqQeJcL3FcUyD8Tk95L8rG5d", + "exactly": "https://api.thegraph.com/subgraphs/name/itofarina/exa-op-sandbox", "sablier": "https://api.thegraph.com/subgraphs/name/sablier-labs/sablier-v2" } }, diff --git a/hooks/useAccountData.ts b/hooks/useAccountData.ts index 1be990ca0..6ed6da64a 100644 --- a/hooks/useAccountData.ts +++ b/hooks/useAccountData.ts @@ -3,12 +3,18 @@ import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype'; import AccountDataContext from 'contexts/AccountDataContext'; import usePreviewerExactly from 'hooks/usePreviewerExactly'; -import { previewerABI } from 'types/abi'; +import { previewerABI, legacyPreviewerABI } from 'types/abi'; -export type MarketAccount = AbiParametersToPrimitiveTypes< +type NewMarketAccount = AbiParametersToPrimitiveTypes< ExtractAbiFunction['outputs'] >[number][number]; +export type LegacyMarketAccount = AbiParametersToPrimitiveTypes< + ExtractAbiFunction['outputs'] +>[number][number]; + +export type MarketAccount = NewMarketAccount | LegacyMarketAccount; + type AccountDataHook = { marketAccount?: MarketAccount; accountData?: readonly MarketAccount[]; diff --git a/hooks/useIRM.ts b/hooks/useIRM.ts index d948a44ca..6408ebd89 100644 --- a/hooks/useIRM.ts +++ b/hooks/useIRM.ts @@ -2,5 +2,6 @@ import useAccountData from './useAccountData'; export default function useIRM(symbol: string) { const { marketAccount } = useAccountData(symbol); - return marketAccount?.interestRateModel?.parameters; + if (!marketAccount) return; + if ('parameters' in marketAccount.interestRateModel) return marketAccount?.interestRateModel?.parameters; } diff --git a/hooks/usePreviewer.ts b/hooks/usePreviewer.ts index 2e263a2e6..51f2955d6 100644 --- a/hooks/usePreviewer.ts +++ b/hooks/usePreviewer.ts @@ -4,13 +4,13 @@ import { isAddress } from 'viem'; import { mainnet, optimismSepolia, optimism } from 'wagmi/chains'; import { useWeb3 } from './useWeb3'; -import { previewerABI } from 'types/abi'; +import { previewerABI, legacyPreviewerABI } from 'types/abi'; import mainnetPreviewer from '@exactly/protocol/deployments/ethereum/Previewer.json' assert { type: 'json' }; import optimismPreviewer from '@exactly/protocol/deployments/optimism/Previewer.json' assert { type: 'json' }; import sepoliaPreviewer from '@exactly/protocol/deployments/op-sepolia/Previewer.json' assert { type: 'json' }; -import { Previewer } from 'types/contracts'; +import { Previewer, LegacyPreviewer } from 'types/contracts'; -export default (): Previewer | undefined => { +export default (): Previewer | LegacyPreviewer | undefined => { const { chain } = useWeb3(); return useMemo(() => { @@ -22,10 +22,18 @@ export default (): Previewer | undefined => { if (!address || !isAddress(address)) return; - return getContract({ - chainId: chain.id, - address, - abi: previewerABI, - }); + if (chain.id === mainnet.id) { + return getContract({ + chainId: chain.id, + address, + abi: legacyPreviewerABI, + }); + } else { + return getContract({ + chainId: chain.id, + address, + abi: previewerABI, + }); + } }, [chain.id]); }; diff --git a/hooks/usePreviewerExactly.ts b/hooks/usePreviewerExactly.ts index 960890995..e15bfd7a5 100644 --- a/hooks/usePreviewerExactly.ts +++ b/hooks/usePreviewerExactly.ts @@ -2,7 +2,7 @@ import { isAddress, zeroAddress } from 'viem'; import { mainnet, optimismSepolia, optimism } from 'wagmi/chains'; import { useWeb3 } from './useWeb3'; -import { usePreviewerExactly } from 'types/abi'; +import { usePreviewerExactly, useLegacyPreviewerExactly } from 'types/abi'; import mainnetPreviewer from '@exactly/protocol/deployments/ethereum/Previewer.json' assert { type: 'json' }; import optimismPreviewer from '@exactly/protocol/deployments/optimism/Previewer.json' assert { type: 'json' }; import sepoliaPreviewer from '@exactly/protocol/deployments/op-sepolia/Previewer.json' assert { type: 'json' }; @@ -18,10 +18,19 @@ export default (override?: number) => { if (!address || !isAddress(address)) throw new Error(`No deployment for ${chain.id}`); - return usePreviewerExactly({ - chainId: override ?? chain.id, - address, - args: [walletAddress ?? zeroAddress], - staleTime: 5_000, - }); + if (chain.id === mainnet.id) { + return useLegacyPreviewerExactly({ + chainId: override ?? chain.id, + address, + args: [walletAddress ?? zeroAddress], + staleTime: 5_000, + }); + } else { + return usePreviewerExactly({ + chainId: override ?? chain.id, + address, + args: [walletAddress ?? zeroAddress], + staleTime: 5_000, + }); + } }; diff --git a/types/contracts.ts b/types/contracts.ts index 2d1c06479..d5da6234f 100644 --- a/types/contracts.ts +++ b/types/contracts.ts @@ -10,6 +10,7 @@ import { marketABI, marketEthRouterABI, previewerABI, + legacyPreviewerABI, rewardsControllerABI, permit2ABI, sablierV2LockupLinearABI, @@ -23,6 +24,7 @@ export type ReadContractType = ReturnType; export type Auditor = ContractType; export type Previewer = ReadContractType; +export type LegacyPreviewer = ReadContractType; export type Market = ContractType; export type MarketETHRouter = ContractType; export type InterestRateModel = ContractType; diff --git a/wagmi.config.ts b/wagmi.config.ts index ea89d4107..9215778fe 100644 --- a/wagmi.config.ts +++ b/wagmi.config.ts @@ -12,6 +12,7 @@ import EXAPool from '@exactly/protocol/deployments/optimism/EXAPool.json' assert import Swapper from '@exactly/protocol/deployments/optimism/Swapper.json' assert { type: 'json' }; import EXAGauge from '@exactly/protocol/deployments/optimism/EXAGauge.json' assert { type: 'json' }; import Previewer from '@exactly/protocol/deployments/op-sepolia/Previewer.json' assert { type: 'json' }; +import LegacyPreviewer from '@exactly/protocol/deployments/ethereum/Previewer.json' assert { type: 'json' }; import DebtManager from '@exactly/protocol/deployments/op-sepolia/DebtManager.json' assert { type: 'json' }; import DebtPreviewer from '@exactly/protocol/deployments/op-sepolia/DebtPreviewer.json' assert { type: 'json' }; import MarketETHRouter from '@exactly/protocol/deployments/op-sepolia/MarketETHRouter.json' assert { type: 'json' }; @@ -41,6 +42,7 @@ export default defineConfig({ { name: 'Swapper', abi: Swapper.abi as Abi }, { name: 'EXAGauge', abi: EXAGauge.abi as Abi }, { name: 'Previewer', abi: Previewer.abi as Abi }, + { name: 'LegacyPreviewer', abi: LegacyPreviewer.abi as Abi }, { name: 'DebtManager', abi: DebtManager.abi as Abi }, { name: 'DebtPreviewer', abi: DebtPreviewer.abi as Abi }, { name: 'MarketETHRouter', abi: MarketETHRouter.abi as Abi },