diff --git a/apps/web/src/components/DepositPanel.tsx b/apps/web/src/components/DepositPanel.tsx index 7854c8f..86b8fde 100644 --- a/apps/web/src/components/DepositPanel.tsx +++ b/apps/web/src/components/DepositPanel.tsx @@ -9,7 +9,13 @@ import { import { useAppKit } from "@reown/appkit/react"; import { hoodquidityVaultsAbi } from "@/lib/abi/HoodquidityVaults"; import { mockERC20Abi } from "@/lib/abi/MockERC20"; -import { ACTIVE_CHAIN_ID, getActiveDeployment, USD_DECIMALS } from "@/lib/contracts"; +import { + ACTIVE_CHAIN_ID, + getActiveDeployment, + USD_DECIMALS, + MIN_DEPOSIT_USD, + MIN_DEPOSIT_UNITS, +} from "@/lib/contracts"; import { slippageImpact } from "@/lib/math"; import { fmtPct, fmtUsd } from "@/lib/format"; import { Button } from "@/components/ui/button"; @@ -125,6 +131,10 @@ export function DepositPanel({ const busy = isPending || isConfirming; const dual = mode === "dual"; + // combined credit (stable leg + valued stock leg) in stable base units + const creditUnits = dual ? amount + (stockAmount > 0n ? stockQuote : 0n) : amount; + const belowMin = creditUnits > 0n && creditUnits < MIN_DEPOSIT_UNITS; + const needsUsdFaucet = amount > 0n && balance < amount; const needsUsdApprove = !needsUsdFaucet && amount > 0n && allowance < amount; const needsStockFaucet = dual && stockAmount > 0n && stockBalance < stockAmount; @@ -140,6 +150,7 @@ export function DepositPanel({ const act = () => { if (!isConnected) return openConnectModal?.(); + if (belowMin) return; // guarded; the button is disabled below the minimum if (needsUsdFaucet) { writeContract({ address: deployment.usd, @@ -195,6 +206,8 @@ export function DepositPanel({ ? dual ? `Enter ${symbol} amount` : "Enter amount" + : belowMin + ? `Min. deposit $${MIN_DEPOSIT_USD}` : needsUsdFaucet ? "Get hUSD" : needsStockFaucet @@ -300,10 +313,18 @@ export function DepositPanel({ )} + {isConnected && belowMin && ( +

+ Minimum deposit is ${MIN_DEPOSIT_USD} +

+ )} + + {isConnected && belowMin && ( +

+ Minimum deposit is ${MIN_DEPOSIT_USD} +

+ )}
@@ -450,7 +466,7 @@ export default function AppBoard() {