Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/modules/reserve-overview/ReserveConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { ReserveFactorOverview } from 'src/modules/reserve-overview/ReserveFacto

import LightningBoltGradient from '/public/lightningBoltGradient.svg';

import { CustomMarket, marketsData } from '../../utils/marketsAndNetworksConfig';
import { ApyGraphContainer } from './graphs/ApyGraphContainer';
import { InterestRateModelGraphContainer } from './graphs/InterestRateModelGraphContainer';
import { PanelItem, PanelRow, PanelTitle } from './ReservePanels';
Expand All @@ -37,10 +36,7 @@ type ReserveConfigurationProps = {

export const ReserveConfiguration: React.FC<ReserveConfigurationProps> = ({ reserve }) => {
const { currentNetworkConfig, currentMarketData, currentMarket } = useProtocolDataContext();
const { v3 } = marketsData[currentMarket as CustomMarket];
// V3 and V2 Polygon will be enabled once support is added to API
const renderCharts =
!v3 && !!currentNetworkConfig.ratesHistoryApiUrl && currentMarket !== 'proto_polygon';
const renderCharts = !!currentNetworkConfig.ratesHistoryApiUrl;
const { supplyCap, borrowCap, debtCeiling } = useAssetCaps();
const showSupplyCapStatus = reserve.supplyCap && reserve.supplyCap !== '0';
const showBorrowCapStatus = reserve.borrowCap && reserve.borrowCap !== '0';
Expand Down Expand Up @@ -196,7 +192,7 @@ export const ReserveConfiguration: React.FC<ReserveConfigurationProps> = ({ rese
<ApyGraphContainer
graphKey="supply"
reserve={reserve}
lendingPoolAddressProvider={currentMarketData.addresses.LENDING_POOL_ADDRESS_PROVIDER}
currentMarketData={currentMarketData}
/>
)}
<div>
Expand Down Expand Up @@ -475,9 +471,7 @@ export const ReserveConfiguration: React.FC<ReserveConfigurationProps> = ({ rese
<ApyGraphContainer
graphKey="borrow"
reserve={reserve}
lendingPoolAddressProvider={
currentMarketData.addresses.LENDING_POOL_ADDRESS_PROVIDER
}
currentMarketData={currentMarketData}
/>
)}
<Box
Expand Down
14 changes: 11 additions & 3 deletions src/modules/reserve-overview/graphs/ApyGraphContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ParentSize } from '@visx/responsive';
import { useState } from 'react';
import type { ComputedReserveData } from 'src/hooks/app-data-provider/useAppDataProvider';
import { ReserveRateTimeRange, useReserveRatesHistory } from 'src/hooks/useReservesHistory';
import { MarketDataType } from 'src/utils/marketsAndNetworksConfig';

import { ApyGraph } from './ApyGraph';
import { GraphLegend } from './GraphLegend';
Expand All @@ -18,7 +19,7 @@ type ApyGraphContainerKey = 'supply' | 'borrow';
type ApyGraphContainerProps = {
graphKey: ApyGraphContainerKey;
reserve: ComputedReserveData;
lendingPoolAddressProvider: string;
currentMarketData: MarketDataType;
};

/**
Expand All @@ -31,13 +32,20 @@ type ApyGraphContainerProps = {
export const ApyGraphContainer = ({
graphKey,
reserve,
lendingPoolAddressProvider,
currentMarketData,
}: ApyGraphContainerProps): JSX.Element => {
const [selectedTimeRange, setSelectedTimeRange] = useState<ReserveRateTimeRange>('1m');

const CHART_HEIGHT = 155;
const CHART_HEIGHT_LOADING_FIX = 3.5;
const reserveAddress = reserve ? `${reserve.underlyingAsset}${lendingPoolAddressProvider}` : '';
let reserveAddress = '';
if (reserve) {
if (currentMarketData.v3) {
reserveAddress = `${reserve.underlyingAsset}${currentMarketData.addresses.LENDING_POOL_ADDRESS_PROVIDER}${currentMarketData.chainId}`;
} else {
reserveAddress = `${reserve.underlyingAsset}${currentMarketData.addresses.LENDING_POOL_ADDRESS_PROVIDER}`;
}
}
const { data, loading, error, refetch } = useReserveRatesHistory(
reserveAddress,
selectedTimeRange
Expand Down
4 changes: 4 additions & 0 deletions src/ui-config/networksConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export const networkConfigs: Record<string, BaseNetworkConfig> = {
name: 'Arbitrum Bridge',
url: 'https://bridge.arbitrum.io',
},
ratesHistoryApiUrl: 'https://aave-api-v2.aave.com/data/rates-history',
},
[ChainId.harmony]: {
name: 'Harmony',
Expand All @@ -218,6 +219,7 @@ export const networkConfigs: Record<string, BaseNetworkConfig> = {
name: 'Harmony Bridge',
url: 'https://bridge.harmony.one',
},
ratesHistoryApiUrl: 'https://aave-api-v2.aave.com/data/rates-history',
},
[ChainId.optimism]: {
name: 'Optimism',
Expand All @@ -239,6 +241,7 @@ export const networkConfigs: Record<string, BaseNetworkConfig> = {
name: 'Optimism Bridge',
url: 'https://app.optimism.io/bridge',
},
ratesHistoryApiUrl: 'https://aave-api-v2.aave.com/data/rates-history',
},
[ChainId.optimism_goerli]: {
name: 'Optimism Görli',
Expand Down Expand Up @@ -279,6 +282,7 @@ export const networkConfigs: Record<string, BaseNetworkConfig> = {
name: 'Fantom Bridge',
url: 'https://app.multichain.org/#/router',
},
ratesHistoryApiUrl: 'https://aave-api-v2.aave.com/data/rates-history',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these could be the environment variable process.env.NEXT_PUBLIC_SCREENING_URL which I'll be renaming to NEXT_PUBLIC_API_BASEURL with the voters list: d017cf9

You could update them now, or I'll clean them up in my voters list branch after merge, either way works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it makes sense to update the screening url as well and you've already made that change let's just wait to update in your PR

},
[ChainId.fantom_testnet]: {
name: 'Fantom Testnet',
Expand Down