Skip to content

Commit

Permalink
Fix/incorrect text after collateral (#2198)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Grothe <[email protected]>
  • Loading branch information
foodaka and grothem authored Oct 2, 2024
1 parent d213b01 commit bb0a310
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { calculateHealthFactorFromBalancesBigUnits, valueToBigNumber } from '@aave/math-utils';
import { Trans } from '@lingui/macro';
import { Typography } from '@mui/material';
import { useEffect, useState } from 'react';
import { Warning } from 'src/components/primitives/Warning';
import { ExtendedFormattedUser } from 'src/hooks/app-data-provider/useAppDataProvider';
import { useAssetCaps } from 'src/hooks/useAssetCaps';
Expand Down Expand Up @@ -35,6 +36,10 @@ export const CollateralChangeModalContent = ({
const { gasLimit, mainTxState: collateralChangeTxState, txError } = useModalContext();
const { debtCeiling } = useAssetCaps();

const [collateralEnabled, setCollateralEnabled] = useState(
userReserve.usageAsCollateralEnabledOnUser
);

// Health factor calculations
const usageAsCollateralModeAfterSwitch = !userReserve.usageAsCollateralEnabledOnUser;
const currenttotalCollateralMarketReferenceCurrency = valueToBigNumber(
Expand Down Expand Up @@ -105,10 +110,15 @@ export const CollateralChangeModalContent = ({
}
};

// Effect to handle changes in collateral mode after switch as polling is fetching reserve state different after successful tx
useEffect(() => {
if (collateralChangeTxState.success) {
setCollateralEnabled(usageAsCollateralModeAfterSwitch);
}
}, [collateralChangeTxState.success, collateralEnabled]);

if (collateralChangeTxState.success)
return (
<TxSuccessView collateral={usageAsCollateralModeAfterSwitch} symbol={poolReserve.symbol} />
);
return <TxSuccessView collateral={collateralEnabled} symbol={poolReserve.symbol} />;

return (
<>
Expand Down

2 comments on commit bb0a310

@github-actions
Copy link

Choose a reason for hiding this comment

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

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

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

This commit was deployed on ipfs

Please sign in to comment.