Skip to content

Commit 97994d1

Browse files
Merge pull request #5 from kaneki003/main
Updates based on feedback
2 parents cebfd7f + a5b93aa commit 97994d1

25 files changed

+2197
-1175
lines changed

app/create/page.tsx

Lines changed: 191 additions & 89 deletions
Large diffs are not rendered by default.

app/dashboard/page.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,38 +65,40 @@ export default function DashboardPage() {
6565
};
6666

6767
const fetchRecentDeposits = async () => {
68-
if (!address) return;
68+
if (!address) return [];
6969
try {
7070
const currentBlock = await publicClient?.getBlock();
71-
if (!currentBlock) return;
71+
if (!currentBlock) return [];
7272
const deposits = await contractClient.getDepositEventLogs(
7373
Number(currentBlock.number) - 999,
7474
Number(currentBlock.number),
7575
undefined,
7676
address
7777
);
78-
setEvents(deposits);
78+
return deposits;
7979
} catch (error) {
8080
console.error("Error fetching recent deposits:", error);
8181
toast.error("Failed to fetch recent deposits.");
82+
return [];
8283
}
8384
};
8485

8586
const fetchRecentWithdrawals = async () => {
86-
if (!address) return;
87+
if (!address) return [];
8788
try {
8889
const currentBlock = await publicClient?.getBlock();
89-
if (!currentBlock) return;
90+
if (!currentBlock) return [];
9091
const withdrawals = await contractClient.getWithdrawEventLogs(
9192
Number(currentBlock.number) - 999,
9293
Number(currentBlock.number),
9394
undefined,
9495
address
9596
);
96-
setEvents((prevEvents) => [...prevEvents, ...withdrawals]);
97+
return withdrawals;
9798
} catch (error) {
9899
console.error("Error fetching recent withdrawals:", error);
99100
toast.error("Failed to fetch recent withdrawals.");
101+
return [];
100102
}
101103
};
102104

@@ -119,13 +121,19 @@ export default function DashboardPage() {
119121
try {
120122
setIsLoading(true);
121123

122-
// Fetch all data
123124
const count = await fetchPoolCount();
124125
if (count === undefined) throw new Error("Pool count is undefined");
125126

126127
await fetchUserPools(count);
127-
await fetchRecentDeposits();
128-
await fetchRecentWithdrawals();
128+
129+
// Fetch deposits and withdrawals in parallel and combine them
130+
const [deposits, withdrawals] = await Promise.all([
131+
fetchRecentDeposits(),
132+
fetchRecentWithdrawals()
133+
]);
134+
135+
// Combine and set all events at once to avoid duplicates
136+
setEvents([...deposits, ...withdrawals]);
129137

130138
} catch (error) {
131139
console.error("Error fetching dashboard data:", error);

components/CircularText.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@
2323
font-size: 24px;
2424
transition: all 0.5s cubic-bezier(0, 0, 0, 1);
2525
}
26+
27+
/* Large circular text for hero section */
28+
.hero-circular-text {
29+
width: 900px;
30+
height: 900px;
31+
}
32+
33+
.hero-circular-text span {
34+
font-size: 64px !important;
35+
font-weight: 900;
36+
letter-spacing: 0.05em;
37+
}

components/dashboard/dashboard-overview.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { Card } from "@/components/ui/card";
4+
import { useAccount } from "wagmi";
45

56
interface Stat {
67
portfolioValue: string;
@@ -17,10 +18,12 @@ export function DashboardOverview({
1718
// profit,
1819
loading,
1920
}: Stat) {
21+
const { chainId, chain } = useAccount();
22+
const nativeCurrencySymbol = chain?.nativeCurrency?.symbol || "ETH";
2023
const stats = [
2124
{
2225
label: "Portfolio Value",
23-
value: loading ? "..." : `${Number(portfolioValue).toFixed(8)} ETH`,
26+
value: loading ? "..." : `${Number(portfolioValue).toFixed(8)} ${nativeCurrencySymbol}`,
2427
},
2528
// {
2629
// label: "Total Liquidity",

components/dashboard/recent-activity.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Deposit, Withdraw } from "@/types/trades";
44
import { useEffect, useState } from "react";
55
import { formatEther } from "viem";
6+
import { useAccount } from "wagmi";
67

78
interface RecentActivityProps {
89
events: (Deposit | Withdraw)[];
@@ -16,6 +17,8 @@ interface Activity {
1617
}
1718

1819
export function RecentActivity({ events }: RecentActivityProps) {
20+
const { chainId, chain } = useAccount();
21+
const nativeCurrencySymbol = chain?.nativeCurrency?.symbol || "ETH";
1922
const [transactions, setTransactions] = useState<Activity[]>([]);
2023
const [isLoading, setIsLoading] = useState<boolean>(true);
2124

@@ -28,7 +31,7 @@ export function RecentActivity({ events }: RecentActivityProps) {
2831
return {
2932
type: "Deposit",
3033
token: event.token.symbol,
31-
amount: `${formatEther(BigInt(event.ethAmount))} ETH + ${formatEther(
34+
amount: `${formatEther(BigInt(event.ethAmount))} ${nativeCurrencySymbol} + ${formatEther(
3235
BigInt(event.tokenAmount)
3336
)} ${event.token.symbol}`,
3437
timestamp: event.timestamp,
@@ -37,7 +40,7 @@ export function RecentActivity({ events }: RecentActivityProps) {
3740
return {
3841
type: "Withdraw",
3942
token: event.token.symbol,
40-
amount: `${formatEther(BigInt(event.ethAmount))} ETH + ${formatEther(
43+
amount: `${formatEther(BigInt(event.ethAmount))} ${nativeCurrencySymbol} + ${formatEther(
4144
BigInt(event.tokenAmount)
4245
)} ${event.token.symbol}`,
4346
timestamp: event.timestamp,
@@ -54,7 +57,7 @@ export function RecentActivity({ events }: RecentActivityProps) {
5457
Recent Activity
5558
</h2>
5659
<div className="space-y-4">
57-
{isLoading ? (
60+
{isLoading ? (
5861
Array.from({ length: 5 }).map((_, i) => (
5962
<div
6063
key={i}

components/landing/hero-section.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,21 @@ export function HeroSection() {
4545
weight: "700",
4646
},
4747
{
48-
text: "Automated Market Making with Proper Price Discovery",
48+
text: "Automated Market Making",
4949
size: 28,
5050
x: window.innerWidth / 2,
5151
y: centerY + 120, // Adjusted position
5252
font: "Plus Jakarta Sans, sans-serif",
5353
weight: "500",
5454
},
55+
{
56+
text: "with Proper Price Discovery",
57+
size: 28,
58+
x: window.innerWidth / 2,
59+
y: centerY + 160, // Adjusted position
60+
font: "Plus Jakarta Sans, sans-serif",
61+
weight: "500",
62+
},
5563
]);
5664
};
5765

@@ -82,13 +90,13 @@ export function HeroSection() {
8290
{/* Visible Content */}
8391
<div className="relative container mx-auto px-4 text-center z-30">
8492
<div className="max-w-4xl mx-auto">
85-
{/* Animated Circular Text - Positioned above */}
86-
<div className="absolute top-[-50px] left-1/2 transform -translate-x-1/2">
93+
{/* Animated Circular Text - Positioned to encompass all content */}
94+
<div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
8795
<CircularText
88-
text="MAELSTROM*EXCHANGE*"
96+
text="MAELSTROM*MAELSTROM*"
8997
onHover="speedUp"
90-
spinDuration={20}
91-
className="custom-class"
98+
spinDuration={60}
99+
className="hero-circular-text"
92100
/>
93101
</div>
94102

components/swap/buy-form.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import { SwapPreviewModal } from "@/components/swap/swap-preview-modal";
66
import { toast } from "sonner";
77
import { ArrowDownUp, HelpCircle, Settings } from "lucide-react";
88
import { TokenSelector } from "./token-selector";
9-
import { Token } from "@/types/token";
9+
import { Token, getNativeCurrencyToken } from "@/types/token";
1010
import { BuyRequest, BuyResult } from "@/types/trades";
1111
import { useAccount, usePublicClient, useWriteContract } from "wagmi";
1212
import { ContractClient } from "@/lib/contract-client";
13-
import { ETH } from "@/types/token";
1413
import { RowPool } from "@/types/pool";
1514
import { formatEther } from "viem";
1615
import {
@@ -51,6 +50,7 @@ export function BuyForm({
5150
);
5251
const { chain } = useAccount();
5352
const baseUrl = chain?.blockExplorers?.default.url;
53+
const nativeCurrencySymbol = chain?.nativeCurrency?.symbol || "ETH";
5454
const [ethAmount, setEthAmount] = useState("");
5555
const [tokenAmount, setTokenAmount] = useState("");
5656
const [showPreview, setShowPreview] = useState(false);
@@ -206,7 +206,7 @@ export function BuyForm({
206206
<div className="w-6 h-6 rounded-full bg-accent/20 flex items-center justify-center">
207207
<span className="text-sm font-bold text-accent">E</span>
208208
</div>
209-
<span className="text-base">ETH</span>
209+
<span className="text-base">{nativeCurrencySymbol}</span>
210210
</div>
211211
</Button>
212212
)}
@@ -273,7 +273,7 @@ export function BuyForm({
273273
<div className="w-6 h-6 rounded-full bg-accent/20 flex items-center justify-center">
274274
<span className="text-sm font-bold text-accent">E</span>
275275
</div>
276-
<span className="text-base">ETH</span>
276+
<span className="text-base">{nativeCurrencySymbol}</span>
277277
</div>
278278
</Button>
279279
)}
@@ -286,7 +286,7 @@ export function BuyForm({
286286
<span className="text-white/50 font-medium">Rate</span>
287287
<span className="text-white/80 font-medium">
288288
1 {token.symbol.toUpperCase()} ={" "}
289-
{Number(ethAmount) / Number(tokenAmount)} {"ETH"}
289+
{Number(ethAmount) / Number(tokenAmount)} {nativeCurrencySymbol}
290290
</span>
291291
</div>
292292
{/* Slippage Tolerance - Only show in Advanced Mode */}
@@ -373,7 +373,7 @@ export function BuyForm({
373373
isOpen={showPreview}
374374
onClose={() => setShowPreview(false)}
375375
onConfirm={handleConfirmBuy}
376-
tokenIn={ETH}
376+
tokenIn={getNativeCurrencyToken(chain)}
377377
tokenOut={token}
378378
amountIn={ethAmount}
379379
amountOut={tokenAmount}

components/swap/sell-form.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { toast } from "sonner";
88
import { ArrowDownUp, HelpCircle, Settings } from "lucide-react";
99
import { useAccount, usePublicClient, useWriteContract } from "wagmi";
1010
import { ContractClient } from "@/lib/contract-client";
11-
import { ETH, Token } from "@/types/token";
11+
import { Token, getNativeCurrencyToken } from "@/types/token";
1212
import { SellRequest, SellResult } from "@/types/trades";
1313
import { RowPool } from "@/types/pool";
1414
import { formatEther } from "viem";
@@ -50,6 +50,7 @@ export function SellForm({
5050
);
5151
const { chain } = useAccount();
5252
const baseUrl = chain?.blockExplorers?.default.url;
53+
const nativeCurrencySymbol = chain?.nativeCurrency?.symbol || "ETH";
5354
const [ethAmount, setEthAmount] = useState("");
5455
const [token, setToken] = useState<Token | undefined>(undefined);
5556
const [tokenAmount, setTokenAmount] = useState("");
@@ -74,7 +75,7 @@ export function SellForm({
7475
if (Number(ethValue) * 1e18 > Number(ethInReserve) * 0.1) {
7576
const maxEthAllowed = String((Number(ethInReserve) * 0.1) / 1e18);
7677
setValidationError(
77-
`Amount exceeds 10% of reserve. Maximum: ${maxEthAllowed} ETH`
78+
`Amount exceeds 10% of reserve. Maximum: ${maxEthAllowed} ${nativeCurrencySymbol}`
7879
);
7980
return "";
8081
}
@@ -84,7 +85,7 @@ export function SellForm({
8485
if (Number(value) * 1e18 > Number(ethInReserve) * 0.1) {
8586
const maxEthAllowed = String((Number(ethInReserve) * 0.1) / 1e18);
8687
setValidationError(
87-
`Amount exceeds 10% of reserve. Maximum: ${maxEthAllowed} ETH`
88+
`Amount exceeds 10% of reserve. Maximum: ${maxEthAllowed} ${nativeCurrencySymbol}`
8889
);
8990
return "";
9091
}
@@ -189,7 +190,7 @@ export function SellForm({
189190
<div className="w-6 h-6 rounded-full bg-accent/20 flex items-center justify-center">
190191
<span className="text-sm font-bold text-accent">E</span>
191192
</div>
192-
<span className="text-base">ETH</span>
193+
<span className="text-base">{nativeCurrencySymbol}</span>
193194
</div>
194195
</Button>
195196
</>
@@ -288,7 +289,7 @@ export function SellForm({
288289
<div className="w-6 h-6 rounded-full bg-accent/20 flex items-center justify-center">
289290
<span className="text-sm font-bold text-accent">E</span>
290291
</div>
291-
<span className="text-base">ETH</span>
292+
<span className="text-base">{nativeCurrencySymbol}</span>
292293
</div>
293294
</Button>
294295
</>
@@ -302,7 +303,7 @@ export function SellForm({
302303
<span className="text-white/50 font-medium">Rate</span>
303304
<span className="text-white/80 font-medium">
304305
1 {token.symbol.toUpperCase()} ={" "}
305-
{Number(ethAmount) / Number(tokenAmount)} {"ETH"}
306+
{Number(ethAmount) / Number(tokenAmount)} {nativeCurrencySymbol}
306307
</span>
307308
</div>
308309
{/* Slippage Tolerance - Only show in Advanced Mode */}
@@ -390,7 +391,7 @@ export function SellForm({
390391
onClose={() => setShowPreview(false)}
391392
onConfirm={handleConfirmSell}
392393
tokenIn={token!}
393-
tokenOut={ETH}
394+
tokenOut={getNativeCurrencyToken(chain)}
394395
amountIn={tokenAmount}
395396
amountOut={ethAmount}
396397
loading={isSwapping}

components/tokens/TokenRow.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ import type { RowPool } from "@/types/pool";
55
import { ChevronRight } from "lucide-react";
66
import Link from "next/link";
77
import { formatEther } from "viem";
8+
import { useAccount } from "wagmi";
89

910
interface TokenRowProps {
1011
poolToken: RowPool;
1112
}
1213

1314
export function TokenRow({ poolToken }: TokenRowProps) {
1415
const { token, buyPrice, sellPrice, totalLiquidity } = poolToken;
16+
const { chain } = useAccount();
17+
const nativeCurrencySymbol = chain?.nativeCurrency?.symbol || "ETH";
1518

1619
return (
1720
<Link
@@ -50,23 +53,23 @@ export function TokenRow({ poolToken }: TokenRowProps) {
5053
<div className="flex flex-col items-end min-w-[100px]">
5154
<div className="text-xs text-muted-foreground/60 mb-1">Buy Price</div>
5255
<div className="text-sm font-medium text-emerald-400">
53-
{formatEther(BigInt(buyPrice))} ETH
56+
{formatEther(BigInt(buyPrice))} {nativeCurrencySymbol}
5457
</div>
5558
</div>
5659

5760
{/* Sell Price */}
5861
<div className="flex flex-col items-end min-w-[100px]">
5962
<div className="text-xs text-muted-foreground/60 mb-1">Sell Price</div>
6063
<div className="text-sm font-medium text-red-400">
61-
{formatEther(BigInt(sellPrice))} ETH
64+
{formatEther(BigInt(sellPrice))} {nativeCurrencySymbol}
6265
</div>
6366
</div>
6467

6568
{/* Total Liquidity */}
6669
<div className="hidden lg:flex flex-col items-end min-w-[120px]">
6770
<div className="text-xs text-muted-foreground/60 mb-1">Total Liquidity</div>
6871
<div className="text-sm font-medium text-white/90">
69-
{formatEther(BigInt(totalLiquidity))} ETH
72+
{formatEther(BigInt(totalLiquidity))} {nativeCurrencySymbol}
7073
</div>
7174
</div>
7275

0 commit comments

Comments
 (0)