Skip to content

Commit bcfc75a

Browse files
committed
feat(frontend): show transaction fee preview before confirmation
Adds a fee breakdown panel above transaction submission so users can review estimated protocol and network fees before confirming deposit or withdrawal. Made-with: Cursor
1 parent 944a2de commit bcfc75a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

frontend/src/components/VaultDashboard.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ const VaultDashboard: React.FC<VaultDashboardProps> = ({
4646

4747
const availableBalance = walletAddress ? usdcBalance : 0;
4848
const strategy = summary.strategy;
49+
const enteredAmount = Number(amount);
50+
const isValidAmount = Number.isFinite(enteredAmount) && enteredAmount > 0;
51+
const managementFeeBps = 35;
52+
const estimatedFee = isValidAmount ? (enteredAmount * managementFeeBps) / 10_000 : 0;
53+
const estimatedNetAmount = isValidAmount ? Math.max(enteredAmount - estimatedFee, 0) : 0;
4954

5055
const handleTransaction = async (actionType: "deposit" | "withdraw") => {
5156
const value = Number(amount);
@@ -229,6 +234,26 @@ const VaultDashboard: React.FC<VaultDashboardProps> = ({
229234
</div>
230235
</div>
231236

237+
<div className="glass-panel" style={{ padding: "14px 16px", background: "rgba(0, 0, 0, 0.15)", marginBottom: "16px" }}>
238+
<div className="flex justify-between items-center" style={{ marginBottom: "6px" }}>
239+
<span style={{ color: "var(--text-secondary)", fontSize: "0.86rem" }}>Estimated protocol fee</span>
240+
<span style={{ fontSize: "0.9rem", fontWeight: 600 }}>
241+
{isValidAmount ? `${estimatedFee.toFixed(4)} USDC` : "0.0000 USDC"}
242+
</span>
243+
</div>
244+
<div className="flex justify-between items-center">
245+
<span style={{ color: "var(--text-secondary)", fontSize: "0.82rem" }}>
246+
{tab === "deposit" ? "Estimated net deposit" : "Estimated net withdrawal"}
247+
</span>
248+
<span style={{ fontSize: "0.9rem", fontWeight: 600 }}>
249+
{isValidAmount ? `${estimatedNetAmount.toFixed(4)} USDC` : "0.0000 USDC"}
250+
</span>
251+
</div>
252+
<div style={{ marginTop: "6px", color: "var(--text-secondary)", fontSize: "0.75rem" }}>
253+
Network fee: {summary.networkFeeEstimate}
254+
</div>
255+
</div>
256+
232257
<button className="btn btn-primary" style={{ width: "100%", padding: "16px" }} onClick={() => handleTransaction(tab)} disabled={isProcessing !== null || !amount || Number(amount) <= 0}>
233258
{isProcessing === tab ? "Processing Transaction..." : tab === "deposit" ? "Approve & Deposit" : "Withdraw Funds"}
234259
</button>

0 commit comments

Comments
 (0)