Skip to content

fix: gho debt amount #2346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 18, 2025
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"test:coverage": "jest --coverage"
},
"dependencies": {
"@aave/contract-helpers": "1.31.1",
"@aave/math-utils": "1.31.1",
"@aave/contract-helpers": "1.32.1",
"@aave/math-utils": "1.32.1",
"@bgd-labs/aave-address-book": "4.10.0",
"@emotion/cache": "11.10.3",
"@emotion/react": "11.10.4",
Expand Down
35 changes: 35 additions & 0 deletions src/hooks/app-data-provider/useAppDataProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
ComputedUserReserve,
FormattedGhoReserveData,
FormattedGhoUserData,
formatUserSummaryWithDiscount,
USD_DECIMALS,
UserReserveData,
} from '@aave/math-utils';
import { AaveV3Ethereum } from '@bgd-labs/aave-address-book';
import { formatUnits } from 'ethers/lib/utils';
import React, { PropsWithChildren, useContext } from 'react';
import { EmodeCategory } from 'src/helpers/types';
Expand Down Expand Up @@ -140,9 +142,42 @@ export const AppDataProvider: React.FC<PropsWithChildren> = ({ children }) => {
formatUnits(baseCurrencyData.marketReferenceCurrencyPriceInUsd, USD_DECIMALS)
),
});

const userGhoReserve = user.userReservesData.find(
(r) => r.reserve.underlyingAsset === AaveV3Ethereum.ASSETS.GHO.UNDERLYING.toLowerCase()
);

if (!userGhoReserve) {
throw new Error('GHO reserve not found in user reserves data');
}

const mergeUserReserves = (reserve: ComputedUserReserve<FormattedReservesAndIncentives>) => {
if (reserve.underlyingAsset !== AaveV3Ethereum.ASSETS.GHO.UNDERLYING.toLowerCase()) {
return reserve;
}

if (reserve.variableBorrows === '0') {
return reserve;
}

// This amount takes into account the discount applied on the accrued interest.
const userGhoDebtBalance = formattedGhoUserData.userGhoBorrowBalance.toString();

// Merge with the user reserves so the correct debt balance can be shown throughout the app.
return {
...reserve,
variableBorrows: userGhoDebtBalance,
variableBorrowsUSD: userGhoDebtBalance,
totalBorrowsUSD: userGhoDebtBalance,
totalBorrows: userGhoDebtBalance,
totalBorrowsMarketReferenceCurrency: userGhoDebtBalance,
};
};

user = {
...user,
...userSummaryWithDiscount,
userReservesData: user.userReservesData.map(mergeUserReserves),
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/pool/useUserYield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const useUserYields = (
) => {
return formatUserYield(formattedPoolReserves, undefined, undefined, user, marketData.market);
};
if (GHO_MINTING_MARKETS.includes(marketData.marketTitle))
if (GHO_MINTING_MARKETS.includes(marketData.market))
return combineQueries(
[
elem,
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# yarn lockfile v1


"@aave/contract-helpers@1.31.1":
version "1.31.1"
resolved "https://registry.yarnpkg.com/@aave/contract-helpers/-/contract-helpers-1.31.1.tgz#e0464847f18b7daa063cd5f1a1926c4b7ffce767"
integrity sha512-68/RIxOSZXpAJ0CbzN25tPDGF0QUoVbJQ6c7UDtA1hT2aL5g06URqHKhdIg1+Jvnz4VU8Qu0YYC26F5K+lVUcQ==
"@aave/contract-helpers@1.32.1":
version "1.32.1"
resolved "https://registry.yarnpkg.com/@aave/contract-helpers/-/contract-helpers-1.32.1.tgz#ad3e216118f282f450b7ab160bd270930ccf5fa4"
integrity sha512-iYkopRnzbfnW7Pxa/qNmqVJVSCWKqF14FNK9SKpmLAkndH8P0UZqSkIdcnvW/ekNx6cyGIc506gKc00j5OnegQ==
dependencies:
isomorphic-unfetch "^3.1.0"

"@aave/math-utils@1.31.1":
version "1.31.1"
resolved "https://registry.yarnpkg.com/@aave/math-utils/-/math-utils-1.31.1.tgz#f465a316c1b59b75b112b772236118541e14b716"
integrity sha512-thdudjGLygOhvDlhhndhSZjVcwglWfYROv1z6qfx9c4LsyiVITAxfz1FLUXbjEOI3kirHitl060Ng4rNuYjT1Q==
"@aave/math-utils@1.32.1":
version "1.32.1"
resolved "https://registry.yarnpkg.com/@aave/math-utils/-/math-utils-1.32.1.tgz#9cd4bb9343f2fabb078b6ca61b5845c7044fe643"
integrity sha512-uLjwGNEOilWWguW7CX6Dwsk9uP4aT9HmOCzXpHqDrPbR2oGSLV8BlvHWx/8wzY9Cdt5Jr4ofP0vm/Xs4lrgDNg==

"@adobe/css-tools@^4.0.1":
version "4.4.1"
Expand Down
Loading