Skip to content

[EGN-742] Token page #1835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2b7c9bd
add explore tokens query
danielr18 Feb 2, 2025
7385a9c
Tokens query hook
danielr18 Feb 2, 2025
0817a1c
Tokens table
danielr18 Feb 2, 2025
c3ec6f7
Add token page queries
danielr18 Feb 2, 2025
5c1a907
Merge remote-tracking branch 'origin/master' into feature/egn-742
danielr18 Mar 3, 2025
0e04533
chore: format
danielr18 Mar 3, 2025
0d973de
chore: lint
sushi-actions Mar 3, 2025
efb22dc
feat: add token page
danielr18 Mar 3, 2025
f4d4e5c
chore: format
danielr18 Mar 3, 2025
e3818a4
chore: remove log
danielr18 Mar 5, 2025
7a5a51c
chore: cleanup
0xMasayoshi Mar 27, 2025
26b62b7
Merge remote-tracking branch 'origin/master' into feature/egn-742-tok…
0xMasayoshi Mar 28, 2025
dd590c2
chore: cleanup twap
0xMasayoshi Mar 28, 2025
e29cdc5
feat: add search to /explore/tokens
0xMasayoshi Mar 28, 2025
32791b4
fix: token sidebar
0xMasayoshi Mar 28, 2025
be3b094
fix: serialize token
0xMasayoshi Mar 28, 2025
38a58f6
fix: disable unsupported swap widget buttons
0xMasayoshi Mar 28, 2025
43add10
fix: swap widget button url
0xMasayoshi Apr 1, 2025
549fb61
fix: token price chart
0xMasayoshi Apr 1, 2025
4d09959
feat: token chart styles & duration toggle
0xMasayoshi Apr 21, 2025
f7ceb8b
fix: token types
0xMasayoshi Apr 21, 2025
3e0bef7
feat: animate swap widget mount/unmount
0xMasayoshi Apr 21, 2025
89d3c8e
Merge remote-tracking branch 'origin/master' into feature/egn-742-tok…
0xMasayoshi Apr 22, 2025
ce30d6a
fix: chainId types
0xMasayoshi Apr 22, 2025
75dd37e
chore: cleanup filter providers
0xMasayoshi Apr 22, 2025
7f3e586
fix: wrap
0xMasayoshi Apr 22, 2025
6f73473
chore: remove seperator
0xMasayoshi Apr 22, 2025
61facdd
chore: All Pools -> Pools
0xMasayoshi Apr 22, 2025
64d1de6
fix: filter providers
0xMasayoshi Apr 22, 2025
cc06913
Merge remote-tracking branch 'origin/master' into feature/egn-742-tok…
0xMasayoshi May 5, 2025
bb58c01
fix: chart resize issue
0xMasayoshi May 5, 2025
175d917
fix: set isLoading to false when no chain or tokenAddresses
0xMasayoshi May 5, 2025
a7e87ec
fix: area chart skeleton
0xMasayoshi May 5, 2025
08d969a
fix: token chart padding & alignment
0xMasayoshi May 5, 2025
4c01f25
chore: cleanup
0xMasayoshi May 5, 2025
114a329
chore: token page metadata
0xMasayoshi May 5, 2025
196b226
chore: pool page metadata
0xMasayoshi May 5, 2025
b425ff5
chore: add v2/v3 prefix to pool cache key
0xMasayoshi May 5, 2025
f36d9d5
fix: trim search tokens
0xMasayoshi May 5, 2025
584cefa
fix: set farmsOnly default value to false
0xMasayoshi May 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,32 @@ import { type ChainId, ChainKey } from 'sushi/chain'
export function NavigationItems({ chainId }: { chainId: ChainId }) {
return (
<>
<LinkInternal
shallow={true}
scroll={false}
href={`/${ChainKey[chainId]}/explore/tokens`}
>
<PathnameButton
id="tokens"
pathname={`/${ChainKey[chainId]}/explore/tokens`}
asChild
size="sm"
>
Tokens
</PathnameButton>
</LinkInternal>
<LinkInternal
shallow={true}
scroll={false}
href={`/${ChainKey[chainId]}/explore/pools`}
>
<PathnameButton
id="all-pools"
id="pools"
pathname={`/${ChainKey[chainId]}/explore/pools`}
asChild
size="sm"
>
All Pools
Pools
</PathnameButton>
</LinkInternal>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Container } from '@sushiswap/ui'
import type { Metadata } from 'next'
import { notFound } from 'next/navigation'
import type React from 'react'
import { GlobalStatsCharts } from 'src/ui/explore/global-stats-charts'
import { TokensFiltersProvider } from 'src/ui/token/TokensFiltersProvider'
import type { EvmChainId } from 'sushi/chain'
import { SUSHISWAP_SUPPORTED_CHAIN_IDS, isSushiSwapChainId } from 'sushi/config'
import { SidebarContainer } from '~evm/_common/ui/sidebar'
import { NavigationItems } from '../navigation-items'

export const metadata: Metadata = {
title: 'Tokens',
description: 'Explore SushiSwap tokens.',
}

export default async function ExploreLayout(props: {
children: React.ReactNode
params: Promise<{ chainId: string }>
}) {
const params = await props.params

const { children } = props

const chainId = +params.chainId as EvmChainId

if (!isSushiSwapChainId(chainId)) {
return notFound()
}

return (
<SidebarContainer
selectedNetwork={chainId}
supportedNetworks={SUSHISWAP_SUPPORTED_CHAIN_IDS}
unsupportedNetworkHref={'/ethereum/explore/tokens'}
shiftContent
>
<main className="flex flex-col h-full flex-1">
<Container maxWidth="7xl" className="px-4 py-4">
<GlobalStatsCharts chainId={chainId} />
</Container>
<Container maxWidth="7xl" className="px-4 flex gap-2 pb-4">
<NavigationItems chainId={chainId} />
</Container>
<section className="flex flex-col flex-1">
<div className="bg-gray-50 dark:bg-white/[0.02] border-t border-accent pt-4 pb-10 min-h-screen">
<TokensFiltersProvider>{children}</TokensFiltersProvider>
</div>
</section>
</main>
</SidebarContainer>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Container } from '@sushiswap/ui'
import { notFound } from 'next/navigation'
import React from 'react'
import { TableFiltersSearchToken } from 'src/ui/token/TableFiltersSearchToken'
import { TokensTable } from 'src/ui/token/TokensTable'
import { type SushiSwapChainId, isSushiSwapChainId } from 'sushi/config'

export default async function TokensPage(props: {
params: Promise<{ chainId: string }>
}) {
const params = await props.params
const chainId = +params.chainId as SushiSwapChainId

if (!isSushiSwapChainId(chainId)) {
return notFound()
}

return (
<Container maxWidth="7xl" className="px-4">
<div className="flex flex-wrap gap-3 mb-4">
<TableFiltersSearchToken />
</div>
<TokensTable chainId={chainId} />
</Container>
)
}
4 changes: 0 additions & 4 deletions apps/web/src/app/(networks)/(evm)/[chainId]/pool/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import type { ChainId } from 'sushi/chain'
import { SidebarContainer, SidebarProvider } from '~evm/_common/ui/sidebar'
import { Header } from '../header'

export const metadata = {
title: 'Pool 💦',
}

export default async function PoolLayout(props: {
children: React.ReactNode
params: Promise<{ chainId: string }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import { ChainKey, type EvmChainId } from 'sushi'
import { isSushiSwapV2ChainId } from 'sushi/config'
import { isAddress } from 'viem'

export const metadata = {
title: 'Pool 💦',
}

export default async function Layout(props: {
children: React.ReactNode
params: Promise<{ chainId: string; address: string }>
Expand All @@ -33,7 +29,7 @@ export default async function Layout(props: {

const pool = (await unstable_cache(
async () => getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function PoolPage(props: {

const pool = (await unstable_cache(
async () => await getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function ManageV2PoolPage(props: {

const pool = (await unstable_cache(
async () => getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async function Layout(props: {

const pool = (await unstable_cache(
async () => getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function ManageV2PoolPage(props: {

const pool = (await unstable_cache(
async () => getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,36 @@ import type { EvmChainId } from 'sushi'
import { isSushiSwapV2ChainId } from 'sushi/config'
import { isAddress } from 'viem'

export const metadata: Metadata = {
title: 'Pool 💦',
export async function generateMetadata(props: {
params: Promise<{ chainId: string; address: string }>
}): Promise<Metadata> {
console.log('generateMetadata')
const params = await props.params
const { chainId: _chainId, address } = params
const chainId = +_chainId as EvmChainId

if (
!isSushiSwapV2ChainId(chainId) ||
!isAddress(address, { strict: false })
) {
return {}
}

const pool = await unstable_cache(
async () => getV2Pool({ chainId, address }),
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
)()

if (!pool) {
return {}
}

return {
title: `BUY & SELL ${pool.token0.symbol}/${pool.token1.symbol}`,
}
}

export default async function Layout(props: {
Expand All @@ -30,7 +58,7 @@ export default async function Layout(props: {

const pool = await unstable_cache(
async () => getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async function Layout(props: {

const pool = (await unstable_cache(
async () => getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function MigrateV2PoolPage(props: {

const pool = (await unstable_cache(
async () => getV2Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v2', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { Container, typographyVariants } from '@sushiswap/ui'

import { BackButton } from 'src/ui/pool/BackButton'

export const metadata = {
title: 'Pool 💦',
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import { ChainKey, type EvmChainId } from 'sushi/chain'
import { isSushiSwapV3ChainId } from 'sushi/config'
import { isAddress } from 'viem'

export const metadata = {
title: 'Pool 💦',
}

export default async function Layout(props: {
children: React.ReactNode
params: Promise<{ chainId: string; address: string }>
Expand All @@ -32,7 +28,7 @@ export default async function Layout(props: {

const pool = (await unstable_cache(
async () => getV3Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v3', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function PoolPage(props: {

const pool = (await unstable_cache(
async () => await getV3Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v3', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async function Layout(props: {

const pool = (await unstable_cache(
async () => getV3Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v3', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function ManageV3PoolPage(props: {

const pool = (await unstable_cache(
async () => await getV3Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v3', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
import { getV3Pool } from '@sushiswap/graph-client/data-api'
import { unstable_cache } from 'next/cache'
import { notFound } from 'next/navigation'
import type { Metadata } from 'next/types'
import type { EvmChainId } from 'sushi/chain'
import { isSushiSwapV3ChainId } from 'sushi/config'
import { isAddress } from 'viem'

export const metadata = {
title: 'Pool 💦',
export async function generateMetadata(props: {
params: Promise<{ chainId: string; address: string }>
}): Promise<Metadata> {
const params = await props.params
const { chainId: _chainId, address } = params
const chainId = +_chainId as EvmChainId

if (
!isSushiSwapV3ChainId(chainId) ||
!isAddress(address, { strict: false })
) {
return {}
}

const pool = await unstable_cache(
async () => getV3Pool({ chainId, address }),
['v3', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
)()

if (!pool) {
return {}
}

return {
title: `BUY & SELL ${pool.token0.symbol}/${pool.token1.symbol}`,
}
}

export default async function Layout(props: {
Expand All @@ -29,7 +57,7 @@ export default async function Layout(props: {

const pool = await unstable_cache(
async () => getV3Pool({ chainId, address }),
['pool', `${chainId}:${address}`],
['v3', 'pool', `${chainId}:${address}`],
{
revalidate: 60 * 15,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { Container, typographyVariants } from '@sushiswap/ui'

import { BackButton } from 'src/ui/pool/BackButton'

export const metadata = {
title: 'Pool 💦',
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<>
Expand Down
Loading
Loading