From 70ed11c7ddd795613fe1bac3a24c5e0179b93387 Mon Sep 17 00:00:00 2001 From: maxgort Date: Sun, 12 Jul 2026 19:58:06 +0300 Subject: [PATCH] feat: enforce a $500 minimum deposit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contract: add MIN_DEPOSIT (500e6) + BelowMinimum error, checked against the combined credit (stable leg + valued stock leg) in _deposit, so it covers single- and dual-sided deposits. Tests updated (sub-$500 fixtures raised, fuzz bounds lifted) plus three new cases; 33/33 pass. ABI regenerated. Frontend: pre-submit validation in AppBoard and DepositPanel — button disables with a "Min. deposit $500" label and an inline error below the minimum, so users get feedback before signing. Shared MIN_DEPOSIT_USD / MIN_DEPOSIT_UNITS constants. Also refreshes the local anvil addresses in the dev deployment block (dev-only; prod uses the seed). Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/web/src/components/DepositPanel.tsx | 25 ++++++++++++- apps/web/src/lib/abi/HoodquidityVaults.ts | 18 +++++++++ apps/web/src/lib/contracts.ts | 29 +++++++++------ apps/web/src/screens/AppBoard.tsx | 30 +++++++++++---- packages/contracts/src/HoodquidityVaults.sol | 5 +++ .../contracts/test/HoodquidityVaults.t.sol | 37 +++++++++++++++++-- 6 files changed, 119 insertions(+), 25 deletions(-) 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() {