Skip to content

Commit 82cf217

Browse files
authored
Merge pull request #268 from yinkscss/fix/245-frontend-add-fee-display-before-transaction-confirmation
[#245] Frontend: Add fee display before transaction confirmation
2 parents caf3a9d + 30a35de commit 82cf217

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

frontend/src/components/VaultDashboard.tsx

Lines changed: 27 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,28 @@ 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+
257+
<button className="btn btn-primary" style={{ width: "100%", padding: "16px" }} onClick={() => handleTransaction(tab)} disabled={isProcessing !== null || !amount || Number(amount) <= 0}>
258+
{isProcessing === tab ? "Processing Transaction..." : tab === "deposit" ? "Approve & Deposit" : "Withdraw Funds"}
232259
<button className="btn btn-primary" style={{ width: "100%", padding: "16px", display: "flex", alignItems: "center", justifyContent: "center", gap: "8px" }} onClick={() => handleTransaction(tab)} disabled={isProcessing !== null || !amount || Number(amount) <= 0}>
233260
{isProcessing === tab ? (
234261
<>

0 commit comments

Comments
 (0)