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 committed Nov 27, 2023
1 parent 8e94a0b commit 1bca30e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 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 @@ -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

0 comments on commit 1bca30e

Please sign in to comment.