diff --git a/frontend/components/MainPage/sections/AddFundsSection.tsx b/frontend/components/MainPage/sections/AddFundsSection.tsx
index 97bf85641..ad3e17053 100644
--- a/frontend/components/MainPage/sections/AddFundsSection.tsx
+++ b/frontend/components/MainPage/sections/AddFundsSection.tsx
@@ -18,7 +18,6 @@ import styled from 'styled-components';
import { UNICODE_SYMBOLS } from '@/constants/symbols';
import { COW_SWAP_GNOSIS_XDAI_OLAS_URL } from '@/constants/urls';
import { useWallet } from '@/hooks/useWallet';
-import { Address } from '@/types/Address';
import { copyToClipboard } from '@/utils/copyToClipboard';
import { truncateAddress } from '@/utils/truncate';
@@ -35,23 +34,6 @@ const CustomizedCardSection = styled(CardSection)<{ border?: boolean }>`
export const AddFundsSection = () => {
const [isAddFundsVisible, setIsAddFundsVisible] = useState(false);
- const { masterSafeAddress } = useWallet();
-
- const fundingAddress: Address | undefined = masterSafeAddress;
-
- const truncatedFundingAddress: string | undefined = useMemo(
- () => fundingAddress && truncateAddress(fundingAddress),
- [fundingAddress],
- );
-
- const handleCopyAddress = useCallback(
- () =>
- fundingAddress &&
- copyToClipboard(fundingAddress).then(() =>
- message.success('Copied successfully!'),
- ),
- [fundingAddress],
- );
return (
<>
@@ -75,17 +57,36 @@ export const AddFundsSection = () => {
- {isAddFundsVisible && (
- <>
-
-
-
- >
- )}
+ {isAddFundsVisible && }
+ >
+ );
+};
+
+export const OpenAddFundsSection = () => {
+ const { masterSafeAddress } = useWallet();
+
+ const truncatedFundingAddress: string | undefined = useMemo(
+ () => masterSafeAddress && truncateAddress(masterSafeAddress),
+ [masterSafeAddress],
+ );
+
+ const handleCopyAddress = useCallback(
+ () =>
+ masterSafeAddress &&
+ copyToClipboard(masterSafeAddress).then(() =>
+ message.success('Copied successfully!'),
+ ),
+ [masterSafeAddress],
+ );
+ return (
+ <>
+
+
+
>
);
};
diff --git a/frontend/components/ManageStakingPage/StakingContractSection/alerts.tsx b/frontend/components/ManageStakingPage/StakingContractSection/alerts.tsx
index f2c1cf6cd..7df340884 100644
--- a/frontend/components/ManageStakingPage/StakingContractSection/alerts.tsx
+++ b/frontend/components/ManageStakingPage/StakingContractSection/alerts.tsx
@@ -6,28 +6,35 @@ import { UNICODE_SYMBOLS } from '@/constants/symbols';
const { Text } = Typography;
export const AlertInsufficientMigrationFunds = ({
- totalOlasBalance,
+ masterSafeOlasBalance,
+ stakedOlasBalance,
+ totalOlasRequiredForStaking,
}: {
- totalOlasBalance: number;
-}) => (
-
-
- Insufficient amount of funds to switch
-
+ masterSafeOlasBalance: number;
+ stakedOlasBalance: number;
+ totalOlasRequiredForStaking: number;
+}) => {
+ const requiredOlasDeposit =
+ totalOlasRequiredForStaking - (stakedOlasBalance + masterSafeOlasBalance);
- Add funds to your account to meet the program requirements.
-
- Your current OLAS balance:{' '}
- {totalOlasBalance} OLAS
-
-
- }
- />
-);
+ return (
+
+
+ An additional {requiredOlasDeposit} OLAS is required to switch
+
+
+ Add {requiredOlasDeposit} OLAS to your account to
+ meet the contract requirements and switch.
+
+
+ }
+ />
+ );
+};
export const AlertNoSlots = () => (
{
const { goto } = usePageState();
- const { setServiceStatus, serviceStatus, setIsServicePollingPaused } =
- useServices();
+ const {
+ setServiceStatus,
+ serviceStatus,
+ setIsServicePollingPaused,
+ updateServiceStatus,
+ } = useServices();
const { serviceTemplate } = useServiceTemplates();
const { setMigrationModalOpen } = useModals();
const { activeStakingProgram, defaultStakingProgram, updateStakingProgram } =
useStakingProgram();
- const { stakingContractInfoRecord } = useStakingContractInfo();
const { token } = useToken();
- const { totalOlasBalance, isBalanceLoaded } = useBalance();
- const { isServiceStakedForMinimumDuration } = useStakingContractInfo();
+ const { safeBalance, totalOlasStakedBalance, isBalanceLoaded } = useBalance();
+ const { isServiceStakedForMinimumDuration, stakingContractInfoRecord } =
+ useStakingContractInfo();
+ const [isFundingSectionOpen, setIsFundingSectionOpen] = useState(false);
const stakingContractInfoForStakingProgram =
stakingContractInfoRecord?.[stakingProgram];
@@ -87,10 +93,15 @@ export const StakingContractSection = ({
);
const hasEnoughOlasToMigrate = useMemo(() => {
- if (totalOlasBalance === undefined) return false;
- if (!minimumOlasRequiredToMigrate) return false;
- return totalOlasBalance >= minimumOlasRequiredToMigrate;
- }, [minimumOlasRequiredToMigrate, totalOlasBalance]);
+ if (safeBalance?.OLAS === undefined || totalOlasStakedBalance === undefined)
+ return false;
+
+ const balanceForMigration = safeBalance.OLAS + totalOlasStakedBalance;
+
+ if (minimumOlasRequiredToMigrate === undefined) return false;
+
+ return balanceForMigration >= minimumOlasRequiredToMigrate;
+ }, [minimumOlasRequiredToMigrate, safeBalance?.OLAS, totalOlasStakedBalance]);
const hasEnoughSlots =
stakingContractInfoForStakingProgram?.maxNumServices &&
@@ -167,6 +178,7 @@ export const StakingContractSection = ({
isBalanceLoaded,
isSelected,
isServiceStakedForMinimumDuration,
+ minimumOlasRequiredToMigrate,
serviceStatus,
]);
@@ -179,9 +191,17 @@ export const StakingContractSection = ({
return ;
}
- if (!hasEnoughOlasToMigrate) {
+ if (
+ !hasEnoughOlasToMigrate &&
+ safeBalance?.OLAS !== undefined &&
+ totalOlasStakedBalance !== undefined
+ ) {
return (
-
+
);
}
@@ -191,10 +211,12 @@ export const StakingContractSection = ({
}, [
isSelected,
isBalanceLoaded,
- totalOlasBalance,
hasEnoughSlots,
hasEnoughOlasToMigrate,
isAppVersionCompatible,
+ safeBalance?.OLAS,
+ totalOlasStakedBalance,
+ minimumOlasRequiredToMigrate,
]);
const contractTagStatus = useMemo(() => {
@@ -213,40 +235,41 @@ export const StakingContractSection = ({
}, [activeStakingProgram, defaultStakingProgram, stakingProgram]);
return (
-
- {/* Title */}
-
- {`${activeStakingProgramMeta.name} contract`}
- {/* TODO: pass `status` attribute */}
-
- {!isSelected && (
- // here instead of isSelected we should check that the contract is not the old staking contract
- // but the one from staking factory (if we want to open govern)
-
- Contract details {UNICODE_SYMBOLS.EXTERNAL_LINK}
-
- )}
-
-
- {/* TODO: fix */}
-
- {/* Contract details
+ <>
+
+ {/* Title */}
+
+ {`${activeStakingProgramMeta.name} contract`}
+
+ {!isSelected && (
+ // here instead of isSelected we should check that the contract is not the old staking contract
+ // but the one from staking factory (if we want to open govern)
+
+ Contract details {UNICODE_SYMBOLS.EXTERNAL_LINK}
+
+ )}
+
+
+ {/* TODO: redisplay once bugs resolved */}
+
+ {/* Contract details
{stakingContractInfo?.availableRewards && (
)} */}
- {cantMigrateAlert}
- {/* Switch to program button */}
- {!isSelected && (
-
+ {cantMigrateAlert}
+ {/* Switch to program button */}
+ {
+
+
+
+ }
+ {stakingProgram === StakingProgram.Beta && (
-
+ )}
+
+ {stakingProgram === StakingProgram.Beta && isFundingSectionOpen && (
+
)}
-
+ >
);
};