Skip to content

Commit

Permalink
fix: disable actions when reserve is paused [skip cypress] (#1832)
Browse files Browse the repository at this point in the history
  • Loading branch information
grothem authored Nov 4, 2023
1 parent b5fc163 commit 3052440
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const SuppliedPositionsListItem = ({
underlyingAsset,
}: DashboardReserve) => {
const { user } = useAppDataContext();
const { isIsolated, aIncentivesData, isFrozen, isActive } = reserve;
const { isIsolated, aIncentivesData, isFrozen, isActive, isPaused } = reserve;
const { currentMarketData, currentMarket } = useProtocolDataContext();
const { openSupply, openWithdraw, openCollateralChange, openSwap } = useModalContext();
const { debtCeiling } = useAssetCaps();
Expand All @@ -38,9 +38,9 @@ export const SuppliedPositionsListItem = ({
user.isolatedReserve?.underlyingAsset === reserve.underlyingAsset ||
(reserve.isIsolated && user.totalCollateralMarketReferenceCurrency === '0'));

const disableSwap = !isActive || reserve.symbol == 'stETH';
const disableWithdraw = !isActive;
const disableSupply = !isActive || isFrozen;
const disableSwap = !isActive || isPaused || reserve.symbol == 'stETH';
const disableWithdraw = !isActive || isPaused;
const disableSupply = !isActive || isFrozen || isPaused;

return (
<ListItemWrapper
Expand Down Expand Up @@ -71,6 +71,7 @@ export const SuppliedPositionsListItem = ({

<ListColumn>
<ListItemUsedAsCollateral
disabled={reserve.isPaused}
isIsolated={isIsolated}
usageAsCollateralEnabledOnUser={usageAsCollateralEnabledOnUser}
canBeEnabledAsCollateral={canBeEnabledAsCollateral}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ export const SuppliedPositionsListMobileItem = ({
const { openSupply, openSwap, openWithdraw, openCollateralChange } = useModalContext();
const { debtCeiling } = useAssetCaps();
const isSwapButton = isFeatureEnabled.liquiditySwap(currentMarketData);
const { symbol, iconSymbol, name, supplyAPY, isIsolated, aIncentivesData, isFrozen, isActive } =
reserve;
const {
symbol,
iconSymbol,
name,
supplyAPY,
isIsolated,
aIncentivesData,
isFrozen,
isActive,
isPaused,
} = reserve;

const canBeEnabledAsCollateral =
!debtCeiling.isMaxed &&
Expand All @@ -35,9 +44,9 @@ export const SuppliedPositionsListMobileItem = ({
user.isolatedReserve?.underlyingAsset === reserve.underlyingAsset ||
(reserve.isIsolated && user.totalCollateralMarketReferenceCurrency === '0'));

const disableSwap = !isActive || reserve.symbol == 'stETH';
const disableWithdraw = !isActive;
const disableSupply = !isActive || isFrozen;
const disableSwap = !isActive || isPaused || reserve.symbol == 'stETH';
const disableWithdraw = !isActive || isPaused;
const disableSupply = !isActive || isFrozen || isPaused;

return (
<ListMobileItemWrapper
Expand Down Expand Up @@ -78,6 +87,7 @@ export const SuppliedPositionsListMobileItem = ({
mb={2}
>
<ListItemUsedAsCollateral
disabled={reserve.isPaused}
isIsolated={isIsolated}
usageAsCollateralEnabledOnUser={usageAsCollateralEnabledOnUser}
canBeEnabledAsCollateral={canBeEnabledAsCollateral}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const SupplyAssetsListItem = ({
isIsolated,
usageAsCollateralEnabledOnUser,
detailsAddress,
isPaused,
}: DashboardReserve) => {
const currentMarketData = useRootStore((store) => store.currentMarketData);
const currentMarket = useRootStore((store) => store.currentMarket);
Expand All @@ -55,7 +56,8 @@ export const SupplyAssetsListItem = ({
const handleClose = () => {
setAnchorEl(null);
};
const disableSupply = !isActive || isFreezed || Number(walletBalance) <= 0 || isMaxCapReached;
const disableSupply =
!isActive || isPaused || isFreezed || Number(walletBalance) <= 0 || isMaxCapReached;

const onDetailsClick = () => {
trackEvent(DASHBOARD.DETAILS_NAVIGATION, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const SupplyAssetsListMobileItem = ({
isFreezed,
underlyingAsset,
detailsAddress,
isPaused,
}: DashboardReserve) => {
const { currentMarket } = useProtocolDataContext();
const { openSupply } = useModalContext();
Expand All @@ -38,7 +39,8 @@ export const SupplyAssetsListMobileItem = ({
const { supplyCap: supplyCapUsage } = useAssetCaps();
const isMaxCapReached = supplyCapUsage.isMaxed;

const disableSupply = !isActive || isFreezed || Number(walletBalance) <= 0 || isMaxCapReached;
const disableSupply =
!isActive || isPaused || isFreezed || Number(walletBalance) <= 0 || isMaxCapReached;

return (
<ListMobileItemWrapper
Expand Down

2 comments on commit 3052440

@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.