Skip to content

Commit 3176659

Browse files
Merge pull request #3 from kaneki003/main
Resolved Next Server Build + Some bug fixes
2 parents c8ef51f + c7ca3e8 commit 3176659

File tree

106 files changed

+13148
-15101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+13148
-15101
lines changed

LICENSE

Lines changed: 0 additions & 674 deletions
This file was deleted.

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
# Maelstrom-WebUI
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22

3-
import { Header } from "@/components/header";
43
import { Button } from "@/components/ui/button";
54
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
65
import { Input } from "@/components/ui/input";
@@ -11,8 +10,8 @@ import { CONTRACT_ADDRESS } from "@/types/contract";
1110
import { InitPool } from "@/types/pool";
1211
import { useState } from "react";
1312
import { toast } from "sonner";
14-
import { parseEther, isAddress } from "viem";
15-
import { Loader2, Plus, DollarSign, Coins } from "lucide-react";
13+
import { parseEther, isAddress, Address } from "viem";
14+
import { Loader2, Plus } from "lucide-react";
1615

1716
export default function CreatePoolPage() {
1817
const { writeContractAsync } = useWriteContract();
@@ -22,7 +21,7 @@ export default function CreatePoolPage() {
2221
writeContractAsync,
2322
publicClient
2423
);
25-
const { address, isConnected } = useAccount();
24+
const { isConnected } = useAccount();
2625

2726
const [formData, setFormData] = useState<InitPool>({
2827
token: "",
@@ -51,7 +50,7 @@ export default function CreatePoolPage() {
5150

5251
setIsValidatingToken(true);
5352
try {
54-
const token = await contractClient.getToken(tokenAddress as any);
53+
const token = await contractClient.getToken(tokenAddress as Address);
5554
setTokenInfo({
5655
symbol: token.symbol,
5756
name: token.name,
@@ -161,9 +160,6 @@ export default function CreatePoolPage() {
161160

162161
return (
163162
<div className="min-h-screen relative bg-gradient-pattern overflow-hidden">
164-
{/* Enhanced background effects */}
165-
<Header />
166-
167163
<main className="container relative mx-auto px-4 py-8">
168164
<div className="max-w-2xl mx-auto space-y-8">
169165
{/* Page Header with glass effect */}
@@ -226,7 +222,6 @@ export default function CreatePoolPage() {
226222
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
227223
<div className="space-y-2">
228224
<Label htmlFor="ethAmount" className="text-white flex items-center gap-2">
229-
<DollarSign className="h-4 w-4" />
230225
ETH Amount
231226
</Label>
232227
<Input
@@ -241,7 +236,6 @@ export default function CreatePoolPage() {
241236

242237
<div className="space-y-2">
243238
<Label htmlFor="tokenAmount" className="text-white flex items-center gap-2">
244-
<Coins className="h-4 w-4" />
245239
Token Amount
246240
</Label>
247241
<Input
Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
"use client";
22

3-
import { Header } from "@/components/header";
43
import { DashboardOverview } from "@/components/dashboard/dashboard-overview";
54
import { PoolsTable } from "@/components/dashboard/pools-table";
65
import { RecentActivity } from "@/components/dashboard/recent-activity";
6+
import { DashboardSkeleton } from "@/components/dashboard/dashboard-skeleton";
77
import { useAccount, usePublicClient, useWriteContract } from "wagmi";
88
import { ContractClient } from "@/lib/contract-client";
99
import { CONTRACT_ADDRESS } from "@/types/contract";
1010
import { useEffect, useState } from "react";
1111
import { RowPool } from "@/types/pool";
1212
import { toast } from "sonner";
13-
import { set } from "lodash";
14-
import { formatEther, parseEther } from "viem";
13+
import { formatEther } from "viem";
1514
import { Deposit, Withdraw } from "@/types/trades";
1615

1716
export default function DashboardPage() {
@@ -46,16 +45,18 @@ export default function DashboardPage() {
4645

4746
const fetchUserPools = async (poolCount: number) => {
4847
if (!address) return;
49-
if(poolCount == pools.length) return;
48+
if (poolCount === 0) return;
5049
try {
50+
const allPools: RowPool[] = [];
5151
for (let i = 0; i < Math.ceil(poolCount / POOL_FETCH_LIMIT); i++) {
5252
const userPools = await contractClient.getUserPools(
5353
address,
5454
i * POOL_FETCH_LIMIT,
55-
Math.min(POOL_FETCH_LIMIT,poolCount - 1)
55+
Math.min(i * POOL_FETCH_LIMIT + POOL_FETCH_LIMIT, poolCount - 1)
5656
);
57-
setPools((prevPools) => [...prevPools, ...userPools]);
57+
allPools.push(...userPools);
5858
}
59+
setPools(allPools);
5960
} catch (error) {
6061
console.error("Error fetching user pools:", error);
6162
toast.error("Failed to fetch user pools.");
@@ -98,44 +99,42 @@ export default function DashboardPage() {
9899
}
99100
};
100101

101-
const fetchUserLiquidity = async () => {
102-
if (!address) return;
103-
try {
104-
const liquidity = await contractClient.getUserLiquidity(address);
105-
setTotalLiquidity(formatEther(BigInt(liquidity)));
106-
} catch (error) {
107-
console.error("Error fetching user liquidity:", error);
108-
toast.error("Failed to fetch user liquidity.");
109-
}
110-
};
111102

112-
const calculatePortfolioValue = () => {
103+
104+
const calculatePortfolioValue = (poolsData: RowPool[]) => {
113105
let total = 0;
114-
for (const pool of pools) {
106+
for (const pool of poolsData) {
115107
const proportion =
116-
BigInt(pool.lpToken!.balance) / BigInt(pool.lpToken!.totalSupply);
108+
Number(pool.lpToken!.balance) / Number(pool.lpToken!.totalSupply);
117109
total += Number(proportion) * Number(pool.totalLiquidity);
118110
}
119-
console.log(pools)
120-
setPortfolioValue((formatEther(BigInt(total))));
111+
return formatEther(BigInt(total));
121112
};
122113

123-
const calculateProfit = () => {
124-
const gain =
125-
((Number(portfolioValue) - Number(totalLiquidity)) /
126-
Number(totalLiquidity)) *
127-
100;
128-
setTotalProfit(gain.toFixed(2));
114+
const calculateProfit = (portfolio: string, liquidity: string) => {
115+
const portfolioNum = Number(portfolio);
116+
const liquidityNum = Number(liquidity);
117+
if (liquidityNum === 0) return "0.00";
118+
const gain = ((portfolioNum - liquidityNum) / liquidityNum) * 100;
119+
return gain.toFixed(2);
129120
};
130121

131122
useEffect(() => {
123+
if (!address) return;
124+
132125
const fetchData = async () => {
133126
try {
134127
setIsLoading(true);
128+
129+
// Fetch all data
135130
const count = await fetchPoolCount();
136-
if(count == undefined) throw new Error("Pool count is undefined");
131+
if (count === undefined) throw new Error("Pool count is undefined");
132+
137133
await fetchUserPools(count);
138-
await fetchUserLiquidity();
134+
const liquidity = await contractClient.getUserLiquidity(address);
135+
const liquidityFormatted = formatEther(BigInt(liquidity));
136+
setTotalLiquidity(liquidityFormatted);
137+
139138
await fetchRecentDeposits();
140139
await fetchRecentWithdrawals();
141140

@@ -146,20 +145,26 @@ export default function DashboardPage() {
146145
setIsLoading(false);
147146
}
148147
};
149-
const calculateValues = () => {
150-
calculatePortfolioValue();
151-
calculateProfit();
152-
setIsLoading(false);
153-
}
148+
154149
fetchData();
155-
calculateValues();
156-
},[pools]);
150+
}, [address]);
151+
152+
// Separate effect to calculate values when pools or liquidity changes
153+
useEffect(() => {
154+
if (pools.length > 0 && totalLiquidity !== "0") {
155+
const portfolio = calculatePortfolioValue(pools);
156+
setPortfolioValue(portfolio);
157+
const profit = calculateProfit(portfolio, totalLiquidity);
158+
setTotalProfit(profit);
159+
}
160+
}, [pools, totalLiquidity]);
161+
162+
if (isLoading) {
163+
return <DashboardSkeleton />;
164+
}
157165

158166
return (
159167
<div className="min-h-screen relative bg-gradient-pattern overflow-hidden">
160-
{/* Enhanced background effects */}
161-
<Header />
162-
163168
<main className="container relative mx-auto px-4 py-8">
164169
<div className="space-y-8">
165170
{/* Page Header with glass effect */}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@
252252
animation: slide-up 0.3s ease-out;
253253
}
254254

255+
.animate-shimmer {
256+
animation: shimmer 2s ease-in-out infinite;
257+
}
258+
255259
/* Startup-style liquid animations */
256260
.animate-liquid-primary {
257261
animation: liquid-flow-primary 35s ease-in-out infinite;
@@ -768,6 +772,15 @@
768772
}
769773
}
770774

775+
@keyframes shimmer {
776+
0% {
777+
transform: translateX(-100%);
778+
}
779+
100% {
780+
transform: translateX(100%);
781+
}
782+
}
783+
771784
/* Accessibility and reduced motion support */
772785
@media (prefers-reduced-motion: reduce) {
773786
.animate-ripple,
@@ -778,6 +791,7 @@
778791
.animate-pulse-slow,
779792
.animate-fade-in,
780793
.animate-slide-up,
794+
.animate-shimmer,
781795
.animate-liquid-primary,
782796
.animate-liquid-secondary {
783797
animation: none;
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type React from "react";
22
import type { Metadata } from "next";
33
import { ThemeProvider } from "@/components/theme-provider";
4-
import { NotificationProvider } from "@/components/ui/notification-system";
5-
import { TourProvider } from "@/components/ui/guided-tour";
64
import { Suspense } from "react";
75
import { Providers } from "@/providers/chain-provider";
86
import "./globals.css";
7+
import { Header } from "@/components/header";
8+
import { Footer } from "@/components/footer";
99

1010
export const metadata: Metadata = {
1111
title: "Maelstrom",
@@ -14,19 +14,24 @@ export const metadata: Metadata = {
1414
generator: "maelstrom-ui",
1515
keywords: ["DeFi", "trading", "liquidity", "blockchain", "swap", "tokens"],
1616
authors: [{ name: "Maelstrom Team" }],
17+
icons: {
18+
icon: [{ url: "/logo_maelstrom.svg", type: "image/svg+xml" }],
19+
shortcut: "/logo_maelstrom.svg",
20+
apple: "/logo_maelstrom.svg",
21+
},
1722
openGraph: {
1823
title: "Maelstrom",
1924
description:
2025
"Experience fluid, innovative DeFi trading with advanced liquidity mechanics.",
2126
type: "website",
22-
images: ["/public/logo_maelstrom.svg"],
27+
images: ["/logo_maelstrom.svg"],
2328
},
2429
twitter: {
2530
card: "summary_large_image",
2631
title: "Maelstrom",
2732
description:
2833
"Experience fluid, innovative DeFi trading with advanced liquidity mechanics.",
29-
images: ["/public/logo_maelstrom.svg"],
34+
images: ["/logo_maelstrom.svg"],
3035
},
3136
};
3237

@@ -46,9 +51,11 @@ export default function RootLayout({
4651
disableTransitionOnChange
4752
>
4853
<Providers>
49-
<NotificationProvider>
50-
<TourProvider>{children}</TourProvider>
51-
</NotificationProvider>
54+
<div>
55+
<Header />
56+
<main>{children}</main>
57+
<Footer />
58+
</div>
5259
</Providers>
5360
</ThemeProvider>
5461
</Suspense>
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
import { Header } from "@/components/header"
21
import { HeroSection } from "@/components/landing/hero-section"
32
import { ValuePropsSection } from "@/components/landing/value-props-section"
43
import { StatsSection } from "@/components/landing/stats-section"
5-
import { Footer } from "@/components/footer"
6-
import { RealTimeTicker } from "@/components/ui/real-time-ticker"
74

85
export default function LandingPage() {
96
return (
107
<div className="min-h-screen">
11-
<Header />
12-
<RealTimeTicker />
138
<main className="bg-gradient-pattern overflow-hidden">
149
<HeroSection />
1510
<ValuePropsSection />
1611
<StatsSection />
1712
</main>
18-
<Footer />
1913
</div>
2014
)
2115
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { Header } from "@/components/header"
21
import { SwapInterface } from "@/components/swap/swap-interface"
32

43
export default function SwapPage() {
54
return (
65
<div className="min-h-screen bg-gradient-pattern overflow-hidden">
7-
<Header />
86
<main className="container mx-auto px-4 py-8 relative">
97
<div className="max-w-6xl mx-auto">
108
{/* Page Header */}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
"use client";
22

3-
import { Header } from "@/components/header";
43
import { TokenList } from "@/components/tokens/TokenList";
54
import { Card, CardContent } from "@/components/ui/card";
5+
import { useSearchParams } from "next/navigation";
6+
import TokenPage from "./pool-detail";
67

78
export default function TokensPage() {
9+
const searchParams = useSearchParams();
10+
const tokenAddress = searchParams.get("tokenAddress");
11+
if (tokenAddress) {
12+
return <TokenPage tokenAddress={tokenAddress} />;
13+
}
814
return (
915
<div className="min-h-screen overflow-hidden bg-gradient-pattern relative">
10-
<Header />
1116
<main className="container mx-auto px-4 py-8 relative">
1217
<div className="max-w-screen-xl mx-auto space-y-8">
1318
{/* Page Header */}

0 commit comments

Comments
 (0)