Skip to content

Commit

Permalink
feat(dHEDGE V1 Withdraw): add low ETH balance warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dimlbc committed Sep 16, 2024
1 parent d2630b3 commit 04da803
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { usePushNotification } from '@frontend/shared-providers';
import { ViewEtherscanLink } from '@frontend/shared-ui';
import { Button, CircularProgress } from '@mui/material';
import { Box, Button, CircularProgress, Typography } from '@mui/material';
import { constants } from 'ethers';
import {
useContractWrite,
Expand Down Expand Up @@ -32,7 +32,8 @@ export const SubmitButton = ({ disabled }: SubmitButtonProps) => {
const needsApproval = useNeedsApproval();

const config = useRedeemCallConfig();
const { data: submitConfig } = usePrepareContractWrite(config);
const { data: submitConfig, error: estimateError } =
usePrepareContractWrite(config);

const {
data: submitData,
Expand Down Expand Up @@ -139,8 +140,22 @@ export const SubmitButton = ({ disabled }: SubmitButtonProps) => {
}

return (
<Button {...buttonProps} onClick={submit} disabled={disabled}>
Redeem
</Button>
<>
<Button {...buttonProps} onClick={submit} disabled={disabled}>
Redeem
</Button>
{estimateError?.message.includes('transfer amount exceeds balance') && (
<Box>
<Typography
variant="hint"
mt={1}
color="warning.dark"
sx={{ position: 'absolute' }}
>
Not enough ETH balance
</Typography>
</Box>
)}
</>
);
};

0 comments on commit 04da803

Please sign in to comment.