Skip to content

Commit

Permalink
transfer dialog: alert user if transfer amount is <1 USDC
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc committed Sep 7, 2024
1 parent 0e73e2f commit 38808f8
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions components/dialogs/transfer/transfer-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,18 @@ function TransferForm({
const { setSide } = useSide()

async function onSubmit(values: z.infer<typeof formSchema>) {
const isAmountSufficient = checkAmount(
queryClient,
values.amount,
baseToken,
)
if (!isAmountSufficient) {
form.setError("amount", {
message: `Amount must be greater than or equal to ${MIN_DEPOSIT_AMOUNT} USDC`,
})
return
}

if (direction === ExternalTransferDirection.Deposit) {
await checkChain()
const isBalanceSufficient = checkBalance({
Expand All @@ -350,17 +362,6 @@ function TransferForm({
})
return
}
const isAmountSufficient = checkAmount(
queryClient,
values.amount,
baseToken,
)
if (!isAmountSufficient) {
form.setError("amount", {
message: `Amount must be greater than or equal to ${MIN_DEPOSIT_AMOUNT} USDC`,
})
return
}
if (needsApproval) {
handleApprove({
onSuccess: () => {
Expand Down

0 comments on commit 38808f8

Please sign in to comment.