Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
114328f
refactor: sdk integrated in market page
AGMASO Sep 26, 2025
940cdf4
chore: clean code
AGMASO Sep 26, 2025
fcb1a39
fix: simplified icon fetch logic & clean code
AGMASO Sep 29, 2025
92eeffd
fix: build error
AGMASO Sep 29, 2025
a80c04b
fix: build error
AGMASO Sep 29, 2025
4a5e1fe
fix: build error
AGMASO Sep 29, 2025
eff6ed6
chore: clean code
AGMASO Sep 30, 2025
8653eb9
chore: clean code
AGMASO Sep 30, 2025
75769d3
refactor: integrate sdk into reserve-overview. missing few flags from…
AGMASO Oct 3, 2025
be28f80
fix: show disabled only for > 0 amounts
AGMASO Oct 3, 2025
c4d503f
Merge branch 'refactor/sdk-in-markets' into refactor/reserve-overview…
AGMASO Oct 3, 2025
9f5d624
fix: solved issue on tokenIcons in reserve-overview page
AGMASO Oct 6, 2025
47ec420
fix: clean code
AGMASO Oct 6, 2025
18dadae
fix: clean code
AGMASO Oct 6, 2025
27eb9b8
fix: clean code
AGMASO Oct 6, 2025
8f7da60
chore: clean code
AGMASO Oct 7, 2025
2e502e9
feat: added interest Rate Strategy Address to link, after updated sdk
AGMASO Oct 8, 2025
d3d3e45
fix: use typescript guards
AGMASO Oct 10, 2025
3610842
fix: simplified code
AGMASO Oct 10, 2025
4e83b97
refactor: move incentives calculation to parent component
AGMASO Oct 10, 2025
de6b877
chore: clean code
AGMASO Oct 13, 2025
cdc1ae9
Merge branch 'refactor/sdk-in-markets' into refactor/reserve-overview…
AGMASO Oct 13, 2025
98b4714
refactor: wip supply assets list finished with sdk
AGMASO Oct 14, 2025
9292a2f
refactor: wip supplies positions listo, aun pequenos fallos
AGMASO Oct 15, 2025
9d13c1b
refactor: wip your borrows terminado perfecto
AGMASO Oct 16, 2025
59326b7
refactor: only dashboard top panel left
AGMASO Oct 17, 2025
abff5a8
refactor: only dashboard top panel left
AGMASO Oct 17, 2025
94b2eb9
refactor: refactored dashboard with sdk
AGMASO Oct 20, 2025
f8fa340
feat: added Pts-ethena tokens to mapping
AGMASO Oct 21, 2025
5b6f0ee
chore: trigger rebuild
AGMASO Oct 21, 2025
ca6db43
Merge remote-tracking branch 'origin/refactor/sdk-in-markets' into re…
AGMASO Oct 21, 2025
7b35f28
Merge remote-tracking branch 'origin/refactor/sdk-in-markets' into re…
AGMASO Oct 21, 2025
3a9fc62
chore: clean code
AGMASO Oct 21, 2025
d8b34d3
chore: clean code
AGMASO Oct 21, 2025
4aacd78
feat: adding some more refactor
AGMASO Oct 29, 2025
12e64df
chore: clean debugging
AGMASO Nov 3, 2025
21ca830
chore: bump aave-sdk versions
AGMASO Nov 5, 2025
d31da54
fix: isolationdebtceiling values displaying correct now
AGMASO Nov 5, 2025
c41a961
Merge remote-tracking branch 'origin/refactor/reserve-overview-page-s…
AGMASO Nov 5, 2025
03bd783
fix: refactor to apply apys now returned from backend
AGMASO Nov 5, 2025
31005c4
fix: total balance value
AGMASO Nov 5, 2025
dfbe506
chore: clean debugging
AGMASO Nov 5, 2025
4759ef5
feat: added support for all actions still using legacy flow
AGMASO Dec 5, 2025
0168761
Merge branch 'main' into refactor/dashboard-page
AGMASO Dec 8, 2025
33ea96b
fix: i18n rebuild
AGMASO Dec 8, 2025
5b5e2f6
fix: corrected some issues hooking data form sdk
AGMASO Dec 8, 2025
fbc7f13
Merge branch 'main' into refactor/dashboard-page
AGMASO Dec 8, 2025
f7bf16b
fix: i18n rebuild
AGMASO Dec 8, 2025
857b056
fix: collateral toggle display
AGMASO Dec 8, 2025
adfb0c9
fix: address review comments
AGMASO Dec 11, 2025
7f59af5
chore: clean code
AGMASO Dec 11, 2025
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
5 changes: 3 additions & 2 deletions src/components/lists/ListMobileItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Divider, Skeleton, Typography } from '@mui/material';
import { ReactNode } from 'react';
import { IsolatedEnabledBadge } from 'src/components/isolationMode/IsolatedBadge';
import { useAssetCaps } from 'src/hooks/useAssetCaps';
import { useAssetCapsSDK } from 'src/hooks/useAssetCapsSDK';
import { CustomMarket } from 'src/ui-config/marketsConfig';

import { Link, ROUTES } from '../primitives/Link';
Expand Down Expand Up @@ -38,7 +38,7 @@ export const ListMobileItem = ({
isIsolated,
onIconError,
}: ListMobileItemProps) => {
const { supplyCap, borrowCap, debtCeiling } = useAssetCaps();
const { supplyCap, borrowCap, debtCeiling } = useAssetCapsSDK();
return (
<Box>
<Divider />
Expand Down Expand Up @@ -75,6 +75,7 @@ export const ListMobileItem = ({
)}
</Box>
</Box>

{showSupplyCapTooltips && supplyCap.displayMaxedTooltip({ supplyCap })}
{showBorrowCapTooltips && borrowCap.displayMaxedTooltip({ borrowCap })}
{showDebtCeilingTooltips && debtCeiling.displayMaxedTooltip({ debtCeiling })}
Expand Down
48 changes: 45 additions & 3 deletions src/hooks/app-data-provider/useAppDataProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import type { EmodeMarketCategory, Market, MarketUserState, Reserve } from '@aave/graphql';
import type {
EmodeMarketCategory,
Market,
MarketUserReserveBorrowPosition,
MarketUserReserveSupplyPosition,
MarketUserState,
PercentValue,
Reserve,
TokenAmount,
} from '@aave/graphql';
import { UserReserveData } from '@aave/math-utils';
import { client } from 'pages/_app.page';
import React, { PropsWithChildren, useContext } from 'react';
Expand All @@ -19,6 +28,8 @@ import { usePoolReservesHumanized } from '../pool/usePoolReserves';
import { useUserPoolReservesHumanized } from '../pool/useUserPoolReserves';
import { FormattedUserReserves } from '../pool/useUserSummaryAndIncentives';
import { useMarketsData } from './useMarketsData';
import { useUserBorrows } from './useUserBorrows';
import { useUserSupplies } from './useUserSupplies';

/**
* removes the marketPrefix from a symbol
Expand All @@ -43,7 +54,17 @@ export type ComputedUserReserveData = FormattedUserReserves;
* @deprecated Use ExtendedFormattedUser type from useExtendedUserSummaryAndIncentives hook
*/
export type ExtendedFormattedUser = _ExtendedFormattedUser;
export type ReserveWithId = Reserve & { id: string };
export type ReserveWithId = Reserve & {
id: string;
supplyAPY?: number;
borrowAPY?: number;
underlyingBalance?: string;
usageAsCollateralEnabledOnUser?: boolean;
isCollateralPosition?: boolean;
canBeEnabledAsCollateral?: boolean;
apyPosition?: PercentValue;
balancePosition?: TokenAmount;
};
export interface AppDataContextType {
loading: boolean;
/** SDK market snapshot */
Expand All @@ -53,6 +74,8 @@ export interface AppDataContextType {
borrowReserves: ReserveWithId[];
eModeCategories: EmodeMarketCategory[];
userState?: MarketUserState;
userSupplies?: MarketUserReserveSupplyPosition[];
userBorrows?: MarketUserReserveBorrowPosition[];
/** Legacy fields (deprecated) kept temporarily for incremental migration */
reserves: ComputedReserveData[];
eModes: Record<number, EmodeCategory>;
Expand All @@ -79,6 +102,18 @@ export const AppDataProvider: React.FC<PropsWithChildren> = ({ children }) => {
account: currentAccount,
});

const { data: userSuppliesData, isPending: userSuppliesLoading } = useUserSupplies({
client,
marketData: currentMarketData,
account: currentAccount,
});

const { data: userBorrowsData, isPending: userBorrowsLoading } = useUserBorrows({
client,
marketData: currentMarketData,
account: currentAccount,
});

const marketAddress = currentMarketData.addresses.LENDING_POOL.toLowerCase();

const sdkMarket = data?.find((item) => item.address.toLowerCase() === marketAddress);
Expand Down Expand Up @@ -120,7 +155,12 @@ export const AppDataProvider: React.FC<PropsWithChildren> = ({ children }) => {
const isReservesLoading = reservesDataLoading || formattedPoolReservesLoading;
const isUserDataLoading = userReservesDataLoading || userSummaryLoading;

const loading = isPending || isReservesLoading || (!!currentAccount && isUserDataLoading);
const loading =
isPending ||
userSuppliesLoading ||
userBorrowsLoading ||
isReservesLoading ||
(!!currentAccount && isUserDataLoading);

return (
<AppDataContext.Provider
Expand All @@ -132,6 +172,8 @@ export const AppDataProvider: React.FC<PropsWithChildren> = ({ children }) => {
borrowReserves,
eModeCategories,
userState: marketUserState,
userSupplies: userSuppliesData,
userBorrows: userBorrowsData,
// Legacy fields (to be removed once consumers migrate)
reserves: formattedPoolReserves || [],
eModes,
Expand Down
39 changes: 39 additions & 0 deletions src/hooks/app-data-provider/useUserBorrows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { AaveClient, chainId, evmAddress, OrderDirection } from '@aave/client';
import { userBorrows } from '@aave/client/actions';
import { useQuery } from '@tanstack/react-query';
import { MarketDataType } from 'src/ui-config/marketsConfig';
import { queryKeysFactory } from 'src/ui-config/queries';

type UseUserBorrowsDataParams = {
client: AaveClient;
marketData: MarketDataType;
account?: string | null;
};

export const useUserBorrows = ({ client, marketData, account }: UseUserBorrowsDataParams) => {
const userAddress = account ? evmAddress(account) : undefined;

return useQuery({
queryKey: [
...queryKeysFactory.market(marketData),
...queryKeysFactory.user(userAddress ?? 'anonymous'),
'userBorrows',
],
enabled: !!client && !!userAddress,
queryFn: async () => {
const response = await userBorrows(client, {
markets: [
{
chainId: chainId(marketData.chainId),
address: evmAddress(marketData.addresses.LENDING_POOL),
},
],
user: userAddress!,
orderBy: { debt: OrderDirection.Asc },
Copy link
Contributor

Choose a reason for hiding this comment

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

should we order Desc so bigger first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it doesn’t sort based on the balance. It sorts according to the internal order in the backend. That’s why I think one ordering or the other makes no difference.

});

if (response.isErr()) throw response.error;
return response.value;
},
});
};
39 changes: 39 additions & 0 deletions src/hooks/app-data-provider/useUserSupplies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { AaveClient, chainId, evmAddress, OrderDirection } from '@aave/client';
import { userSupplies } from '@aave/client/actions';
import { useQuery } from '@tanstack/react-query';
import { MarketDataType } from 'src/ui-config/marketsConfig';
import { queryKeysFactory } from 'src/ui-config/queries';

type UseUserSuppliesDataParams = {
client: AaveClient;
marketData: MarketDataType;
account?: string | null;
};

export const useUserSupplies = ({ client, marketData, account }: UseUserSuppliesDataParams) => {
const userAddress = account ? evmAddress(account) : undefined;

return useQuery({
queryKey: [
...queryKeysFactory.market(marketData),
...queryKeysFactory.user(userAddress ?? 'anonymous'),
'userSupplies',
],
enabled: !!client && !!userAddress,
queryFn: async () => {
const response = await userSupplies(client, {
markets: [
{
chainId: chainId(marketData.chainId),
address: evmAddress(marketData.addresses.LENDING_POOL),
},
],
user: userAddress!,
orderBy: { balance: OrderDirection.Asc },
Copy link
Contributor

Choose a reason for hiding this comment

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

should we order Desc so bigger first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same answer

});

if (response.isErr()) throw response.error;
return response.value;
},
});
};
55 changes: 19 additions & 36 deletions src/hooks/useWrappedTokens.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { normalize } from '@aave/math-utils';
import { AaveV3Ethereum } from '@bgd-labs/aave-address-book';
import { useRootStore } from 'src/store/root';
import { CustomMarket } from 'src/ui-config/marketsConfig';
import { amountToUsd } from 'src/utils/utils';

import { useAppDataContext } from './app-data-provider/useAppDataProvider';

Expand Down Expand Up @@ -37,57 +35,42 @@ const wrappedTokenConfig: {
};

export const useWrappedTokens = () => {
const { marketReferencePriceInUsd, marketReferenceCurrencyDecimals, reserves } =
useAppDataContext();
const { supplyReserves } = useAppDataContext();
const currentMarket = useRootStore((store) => store.currentMarket);

if (!reserves || reserves.length === 0) {
if (!supplyReserves || supplyReserves.length === 0) {
return [];
}

const wrappedTokens = wrappedTokenConfig[currentMarket] ?? [];
let wrappedTokenReserves: WrappedTokenConfig[] = [];

wrappedTokenReserves = wrappedTokens.map<WrappedTokenConfig>((config) => {
const tokenInReserve = reserves.find((reserve) => reserve.underlyingAsset === config.tokenIn);
const tokenOutReserve = reserves.find((reserve) => reserve.underlyingAsset === config.tokenOut);
const tokenInReserve = supplyReserves.find(
(reserve) => reserve.underlyingToken.address.toLowerCase() === config.tokenIn
);

const tokenOutReserve = supplyReserves.find(
(reserve) => reserve.underlyingToken.address.toLowerCase() === config.tokenOut
);

if (!tokenInReserve || !tokenOutReserve) {
throw new Error('wrapped token reserves not found');
}

const tokenInFormattedPriceInMarketReferenceCurrency = normalize(
tokenInReserve.priceInMarketReferenceCurrency,
marketReferenceCurrencyDecimals
);

const tokenOutFormattedPriceInMarketReferenceCurrency = normalize(
tokenOutReserve.priceInMarketReferenceCurrency,
marketReferenceCurrencyDecimals
);

return {
tokenIn: {
symbol: tokenInReserve.symbol,
underlyingAsset: tokenInReserve.underlyingAsset,
decimals: tokenInReserve.decimals,
priceInUSD: amountToUsd(
1,
tokenInFormattedPriceInMarketReferenceCurrency,
marketReferencePriceInUsd
).toString(),
formattedPriceInMarketReferenceCurrency: tokenInFormattedPriceInMarketReferenceCurrency,
symbol: tokenInReserve.underlyingToken.symbol,
underlyingAsset: tokenInReserve.underlyingToken.address,
decimals: tokenInReserve.underlyingToken.decimals,
priceInUSD: tokenInReserve.usdExchangeRate,
Copy link
Contributor

Choose a reason for hiding this comment

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

is usdExchangeRate giving the amount in usd as we had before or just the rate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

usd amount per token

formattedPriceInMarketReferenceCurrency: tokenInReserve.size.usdPerToken,
},
tokenOut: {
symbol: tokenOutReserve.symbol,
underlyingAsset: tokenOutReserve.underlyingAsset,
decimals: tokenOutReserve.decimals,
priceInUSD: amountToUsd(
1,
tokenOutFormattedPriceInMarketReferenceCurrency,
marketReferencePriceInUsd
).toString(),
formattedPriceInMarketReferenceCurrency: tokenOutFormattedPriceInMarketReferenceCurrency,
symbol: tokenOutReserve.underlyingToken.symbol,
underlyingAsset: tokenOutReserve.underlyingToken.address,
decimals: tokenOutReserve.underlyingToken.decimals,
priceInUSD: tokenOutReserve.usdExchangeRate,
formattedPriceInMarketReferenceCurrency: tokenOutReserve.size.usdPerToken,
},
tokenWrapperAddress: config.tokenWrapperContractAddress,
};
Expand Down
2 changes: 1 addition & 1 deletion src/locales/el/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ msgstr "Total"
msgid "{stepName}"
msgstr "{stepName}"

#: src/modules/dashboard/DashboardEModeButton.tsx
msgid "DISABLED"
msgstr "DISABLED"

#: src/components/transactions/FlowCommons/TxModalDetails.tsx
#: src/modules/dashboard/DashboardTopPanel.tsx
#: src/modules/dashboard/LiquidationRiskParametresModal/LiquidationRiskParametresModal.tsx
Expand Down Expand Up @@ -1450,7 +1454,6 @@ msgstr "No voting power"

#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx
#: src/modules/reserve-overview/SupplyInfo.tsx
msgid "Can be collateral"
msgstr "Can be collateral"
Expand Down Expand Up @@ -2008,7 +2011,6 @@ msgstr "Send cancel"
#: src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsListItem.tsx
#: src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsListMobileItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx
#: src/modules/markets/MarketAssetsListItem.tsx
msgid "Details"
msgstr "Details"
Expand Down Expand Up @@ -2429,7 +2431,6 @@ msgstr "supply"
#: src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListMobileItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx
#: src/modules/history/actions/ActionDetails.tsx
#: src/modules/history/HistoryFilterMenu.tsx
#: src/modules/reserve-overview/ReserveActions.tsx
Expand Down Expand Up @@ -3426,7 +3427,6 @@ msgstr "Staked"
#: src/components/transactions/Supply/SupplyModalContent.tsx
#: src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListMobileItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx
#: src/modules/markets/MarketAssetsList.tsx
#: src/modules/markets/MarketAssetsListMobileItem.tsx
msgid "Supply APY"
Expand Down Expand Up @@ -4071,7 +4071,6 @@ msgstr "Remaining debt"
#: src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListMobileItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListItem.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx
msgid "Supply balance"
msgstr "Supply balance"

Expand Down
2 changes: 1 addition & 1 deletion src/locales/es/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/fr/messages.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/modules/dashboard/DashboardEModeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ import LightningBoltGradient from '/public/lightningBoltGradient.svg';
import { Link } from '../../components/primitives/Link';
import { Row } from '../../components/primitives/Row';
import { TypographyGradient } from '../../components/primitives/TypographyGradient';
import { getEmodeMessage } from '../../components/transactions/Emode/EmodeNaming';

interface DashboardEModeButtonProps {
userEmodeCategoryId: number;
}

export const DashboardEModeButton = ({ userEmodeCategoryId }: DashboardEModeButtonProps) => {
const { openEmode } = useModalContext();
const { eModes: _eModes } = useAppDataContext();
const { eModeCategories: _eModes } = useAppDataContext();
const trackEvent = useRootStore((store) => store.trackEvent);

const iconButtonSize = 12;
Expand All @@ -39,9 +38,12 @@ export const DashboardEModeButton = ({ userEmodeCategoryId }: DashboardEModeButt

const isEModeDisabled = userEmodeCategoryId === 0;

const EModeLabelMessage = () => (
<Trans>{getEmodeMessage(_eModes[userEmodeCategoryId].label)}</Trans>
);
const EModeLabelMessage = () => {
if (isEModeDisabled) {
return <Trans>DISABLED</Trans>;
}
return <Trans>{_eModes[userEmodeCategoryId]?.label}</Trans>;
};

return (
<Box
Expand Down
Loading
Loading