Skip to content
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

refactor: PoolCore, remove pool.displayTokens, new display token functions #373

Open
wants to merge 32 commits into
base: feat/vote-list
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b9319c9
Create dependabot.yml
garethfuller Dec 20, 2024
fbacd6b
Update dependabot.yml
garethfuller Dec 20, 2024
b31c08d
fix: Token inputs (#365)
garethfuller Dec 20, 2024
54fe27a
refactor: PoolCore, remove pool.displayTokens, new display token func…
agualis Dec 20, 2024
d189dc4
Update dependabot.yml
garethfuller Dec 20, 2024
e313738
chore: bump graphql (#372)
garethfuller Dec 20, 2024
b23cdb4
chore: update dependencies recommended by dependabot (#375)
agualis Dec 20, 2024
86cea82
chore: rename prop
agualis Dec 20, 2024
19e8ce2
chore: add addPossibleNestedTokens
agualis Dec 20, 2024
ca91d8e
fix: use getCompositionDisplayTokensWithPossibleNestedTokensWithBalan…
agualis Dec 20, 2024
ad5605a
Merge branch 'main' into refactor/displayTokensInVoteListPR
agualis Dec 20, 2024
4196de4
chore: add pool examples to debug page
agualis Dec 20, 2024
cc60d6a
refactor: user reference tokens
agualis Dec 20, 2024
46c333a
refactor: with balance user reference helper
agualis Dec 20, 2024
a643067
test weitghts and uris
agualis Dec 20, 2024
e4b42ad
fix: swap symbol (#387)
agualis Dec 24, 2024
824d326
refactor: replace blockExplorer hook by plain TS functions (#378)
agualis Dec 24, 2024
e98febd
chore: Hide pool swap for cow pools (#392)
garethfuller Dec 30, 2024
a6dfdd0
chore(deps): bump @tanstack/react-query-devtools from 5.56.2 to 5.62.…
dependabot[bot] Jan 2, 2025
11ce2b7
chore(deps-dev): bump @testing-library/jest-dom from 6.5.0 to 6.6.3 (…
dependabot[bot] Jan 2, 2025
1e0704c
chore(deps): bump react-swipeable from 7.0.1 to 7.0.2 (#384)
dependabot[bot] Jan 2, 2025
82863e3
Merge branch 'main' into refactor/displayTokensInVoteListPR
agualis Jan 2, 2025
c99d6c4
chore: remove comments
agualis Jan 3, 2025
35daa25
refactor: move ApiToken type to token.types.ts
agualis Jan 3, 2025
0dfea2d
refactor: PoolToken type
agualis Jan 3, 2025
0ae79fe
chore: update Twitter URL to x.com format (#400)
agualis Jan 6, 2025
190bdab
chore: simplify pool types
agualis Jan 6, 2025
e4f6677
chore: sort pool tokens by index
agualis Jan 7, 2025
3cde3a8
merge from beets (#376)
groninge01 Jan 7, 2025
1372ff4
chore: Merge main
agualis Jan 7, 2025
d1337ed
refactor: from allowNestedActions to disallowNestedActions (#346)
agualis Jan 7, 2025
cf34d15
Merge branch 'main' into refactor/displayTokensInVoteListPR
agualis Jan 7, 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
@@ -1,11 +1,6 @@
/* eslint-disable max-len */
import { FetchPoolProps } from '@repo/lib/modules/pool/pool.types'
import {
ChainSlug,
getChainSlug,
getPoolDisplayTokens,
getPoolTypeLabel,
} from '@repo/lib/modules/pool/pool.utils'
import { FetchPoolProps, PoolCore } from '@repo/lib/modules/pool/pool.types'
import { ChainSlug, getChainSlug, getPoolTypeLabel } from '@repo/lib/modules/pool/pool.utils'
import { PropsWithChildren, Suspense } from 'react'
import { PoolDetailSkeleton } from '@repo/lib/modules/pool/PoolDetail/PoolDetailSkeleton'
import { getApolloServerClient } from '@repo/lib/shared/services/api/apollo-server.client'
Expand All @@ -15,6 +10,7 @@ import { PoolProvider } from '@repo/lib/modules/pool/PoolProvider'
import { arrayToSentence } from '@repo/lib/shared/utils/strings'
import { ensureError } from '@repo/lib/shared/utils/errors'
import { notFound } from 'next/navigation'
import { getHeaderDisplayTokens } from '@repo/lib/modules/pool/pool.tokens.display'

type Props = PropsWithChildren<{
params: Omit<FetchPoolProps, 'chain'> & { chain: ChainSlug }
Expand Down Expand Up @@ -48,7 +44,7 @@ export async function generateMetadata({
const pool = data?.pool
if (!pool) return {}

const displayTokens = getPoolDisplayTokens(pool)
const displayTokens = getHeaderDisplayTokens(pool as PoolCore)
const poolTokenString = arrayToSentence(displayTokens.map(token => token.symbol))

return {
Expand Down
6 changes: 4 additions & 2 deletions apps/beets-frontend-v3/app/(app)/portfolio/[chain]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PoolName } from '@repo/lib/modules/pool/PoolName'
import { Pool } from '@repo/lib/modules/pool/PoolProvider'
import { ClaimModal } from '@repo/lib/modules/pool/actions/claim/ClaimModal'
import { ClaimProvider } from '@repo/lib/modules/pool/actions/claim/ClaimProvider'
import { ChainSlug, getChainSlug, getPoolDisplayTokens } from '@repo/lib/modules/pool/pool.utils'
import { ChainSlug, getChainSlug } from '@repo/lib/modules/pool/pool.utils'
// eslint-disable-next-line max-len
import { ClaimNetworkPoolsLayout } from '@repo/lib/modules/portfolio/PortfolioClaim/ClaimNetworkPools/ClaimNetworkPoolsLayout'
import { usePortfolio } from '@repo/lib/modules/portfolio/PortfolioProvider'
Expand All @@ -15,6 +15,8 @@ import { Button, Card, HStack, Heading, Skeleton, Stack, Text, VStack } from '@c
import { capitalize } from 'lodash'
import { useParams } from 'next/navigation'
import { useState } from 'react'
import { getHeaderDisplayTokens } from '@repo/lib/modules/pool/pool.tokens.display'
import { PoolCore } from '@repo/lib/modules/pool/pool.types'

export default function NetworkClaim() {
const { toCurrency } = useCurrency()
Expand Down Expand Up @@ -76,7 +78,7 @@ export default function NetworkClaim() {
<TokenIconStack
chain={pool.chain}
size={36}
tokens={getPoolDisplayTokens(pool)}
tokens={getHeaderDisplayTokens(pool as PoolCore)}
/>
{hasMultipleClaims && (
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/* eslint-disable max-len */
import { FetchPoolProps } from '@repo/lib/modules/pool/pool.types'
import {
ChainSlug,
getChainSlug,
getPoolDisplayTokens,
getPoolTypeLabel,
} from '@repo/lib/modules/pool/pool.utils'
import { FetchPoolProps, PoolCore } from '@repo/lib/modules/pool/pool.types'
import { ChainSlug, getChainSlug, getPoolTypeLabel } from '@repo/lib/modules/pool/pool.utils'
import { PropsWithChildren, Suspense } from 'react'
import { PoolDetailSkeleton } from '@repo/lib/modules/pool/PoolDetail/PoolDetailSkeleton'
import { getApolloServerClient } from '@repo/lib/shared/services/api/apollo-server.client'
Expand All @@ -15,6 +10,7 @@ import { PoolProvider } from '@repo/lib/modules/pool/PoolProvider'
import { arrayToSentence } from '@repo/lib/shared/utils/strings'
import { ensureError } from '@repo/lib/shared/utils/errors'
import { notFound } from 'next/navigation'
import { getHeaderDisplayTokens } from '@repo/lib/modules/pool/pool.tokens.display'

type Props = PropsWithChildren<{
params: Omit<FetchPoolProps, 'chain'> & { chain: ChainSlug }
Expand Down Expand Up @@ -48,7 +44,7 @@ export async function generateMetadata({
const pool = data?.pool
if (!pool) return {}

const displayTokens = getPoolDisplayTokens(pool)
const displayTokens = getHeaderDisplayTokens(pool as PoolCore)
const poolTokenString = arrayToSentence(displayTokens.map(token => token.symbol))

return {
Expand Down
6 changes: 4 additions & 2 deletions apps/frontend-v3/app/(app)/portfolio/[chain]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PoolName } from '@repo/lib/modules/pool/PoolName'
import { Pool } from '@repo/lib/modules/pool/PoolProvider'
import { ClaimModal } from '@repo/lib/modules/pool/actions/claim/ClaimModal'
import { ClaimProvider } from '@repo/lib/modules/pool/actions/claim/ClaimProvider'
import { ChainSlug, getChainSlug, getPoolDisplayTokens } from '@repo/lib/modules/pool/pool.utils'
import { ChainSlug, getChainSlug } from '@repo/lib/modules/pool/pool.utils'
// eslint-disable-next-line max-len
import { ClaimNetworkPoolsLayout } from '@repo/lib/modules/portfolio/PortfolioClaim/ClaimNetworkPools/ClaimNetworkPoolsLayout'
import { usePortfolio } from '@repo/lib/modules/portfolio/PortfolioProvider'
Expand All @@ -15,6 +15,8 @@ import { Button, Card, HStack, Heading, Skeleton, Stack, Text, VStack } from '@c
import { capitalize } from 'lodash'
import { useParams } from 'next/navigation'
import { useState } from 'react'
import { getHeaderDisplayTokens } from '@repo/lib/modules/pool/pool.tokens.display'
import { PoolCore } from '@repo/lib/modules/pool/pool.types'

export default function NetworkClaim() {
const { toCurrency } = useCurrency()
Expand Down Expand Up @@ -75,7 +77,7 @@ export default function NetworkClaim() {
<TokenIconStack
chain={pool.chain}
size={36}
tokens={getPoolDisplayTokens(pool)}
tokens={getHeaderDisplayTokens(pool as PoolCore)}
/>
{hasMultipleClaims && (
<Button
Expand Down
32 changes: 18 additions & 14 deletions packages/lib/modules/pool/PoolDetail/PoolComposition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,30 @@ import {
Text,
VStack,
} from '@chakra-ui/react'
import { Pool, usePool } from '../PoolProvider'
import { Address } from 'viem'
import { GqlChain, GqlPoolTokenDetail } from '@repo/lib/shared/services/api/generated/graphql'
import { useCurrency } from '@repo/lib/shared/hooks/useCurrency'
import { bn, fNum } from '@repo/lib/shared/utils/numbers'
import TokenRow from '@repo/lib/modules/tokens/TokenRow/TokenRow'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
import { NoisyCard } from '@repo/lib/shared/components/containers/NoisyCard'
import { PoolZenGarden } from '@repo/lib/shared/components/zen/ZenGarden'
import { PoolWeightChart } from './PoolWeightCharts/PoolWeightChart'
import { useBreakpoints } from '@repo/lib/shared/hooks/useBreakpoints'
import TokenRow from '@repo/lib/modules/tokens/TokenRow/TokenRow'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
import { getPoolDisplayTokens, getPoolDisplayTokensWithPossibleNestedPools } from '../pool.utils'
import { PoolTypeTag } from './PoolTypeTag'
import { isBoosted } from '../pool.helpers'
import { useCurrency } from '@repo/lib/shared/hooks/useCurrency'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { bn, fNum } from '@repo/lib/shared/utils/numbers'
import { useLayoutEffect, useRef, useState } from 'react'
import { Address } from 'viem'
import { usePoolsMetadata } from '../metadata/PoolsMetadataProvider'
import { isBoosted } from '../pool.helpers'
import { ApiTokenWithBalance, PoolCore } from '../pool.types'
import { Pool, usePool } from '../PoolProvider'
import { PoolTypeTag } from './PoolTypeTag'
import { PoolWeightChart } from './PoolWeightCharts/PoolWeightChart'
import {
getCompositionDisplayTokens,
getHeaderTokensWithPossibleNestedTokensWithBalance,
} from '../pool.tokens.display'

type CardContentProps = {
totalLiquidity: string
displayTokens: GqlPoolTokenDetail[]
displayTokens: ApiTokenWithBalance[]
chain: GqlChain
pool: Pool
}
Expand Down Expand Up @@ -122,7 +126,7 @@ export function PoolComposition() {
const [height, setHeight] = useState(0)
const { getErc4626Metadata } = usePoolsMetadata()

const displayTokens = getPoolDisplayTokens(pool)
const displayTokens = getCompositionDisplayTokens(pool as PoolCore)
const totalLiquidity = calcTotalUsdValue(displayTokens, chain)
const erc4626Metadata = getErc4626Metadata(pool)

Expand Down Expand Up @@ -181,7 +185,7 @@ export function PoolComposition() {
) : (
<PoolWeightChart
chain={chain}
displayTokens={getPoolDisplayTokensWithPossibleNestedPools(pool)}
displayTokens={getHeaderTokensWithPossibleNestedTokensWithBalance(pool as PoolCore)}
hasLegend
totalLiquidity={totalLiquidity}
/>
Expand Down
27 changes: 7 additions & 20 deletions packages/lib/modules/pool/PoolDetail/PoolHeader/PoolMetaBadges.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use client'

import { Badge, Flex } from '@chakra-ui/react'
import { usePool } from '../../PoolProvider'
import Image from 'next/image'
import { PoolListTokenPills } from '../../PoolList/PoolListTokenPills'
import { getPoolDisplayTokens, shouldHideSwapFee } from '../../pool.utils'
import { getChainShortName } from '@repo/lib/config/app.config'
import { PoolTypeTag } from '../PoolTypeTag'
import Image from 'next/image'
import { PoolVersionTag } from '../../PoolList/PoolListTable/PoolVersionTag'
import { PoolListTokenPills } from '../../PoolList/PoolListTokenPills'
import { usePool } from '../../PoolProvider'
import { PoolCore } from '../../pool.types'
import { shouldHideSwapFee } from '../../pool.utils'
import { PoolHookTag } from '../PoolHookTag'
import { PoolTypeTag } from '../PoolTypeTag'
import { PoolSwapFees } from './PoolSwapFees'
import { GqlPoolTokenDetail } from '@repo/lib/shared/services/api/generated/graphql'

export default function PoolMetaBadges() {
const { pool, chain } = usePool()
Expand All @@ -34,20 +34,7 @@ export default function PoolMetaBadges() {
width={20}
/>
</Badge>
<PoolListTokenPills
pool={{
displayTokens: getPoolDisplayTokens(pool),
type: pool.type,
chain: pool.chain,
poolTokens: pool.poolTokens as GqlPoolTokenDetail[], // fix: poolTokens are incompatible
address: pool.address,
hasErc4626: pool.hasErc4626,
hasAnyAllowedBuffer: pool.hasAnyAllowedBuffer,
protocolVersion: pool.protocolVersion,
}}
px="sm"
py="2"
/>
<PoolListTokenPills pool={pool as PoolCore} px="sm" py="2" />
<PoolVersionTag isSmall pool={pool} />
<PoolTypeTag pool={pool} />
<PoolHookTag pool={pool} />
Expand Down
5 changes: 3 additions & 2 deletions packages/lib/modules/pool/PoolDetail/PoolMyLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { useCurrency } from '@repo/lib/shared/hooks/useCurrency'
import { keyBy } from 'lodash'
import {
getAuraPoolLink,
getPoolDisplayTokens,
getProportionalExitAmountsFromScaledBptIn,
getXavePoolLink,
} from '../pool.utils'
Expand Down Expand Up @@ -54,6 +53,8 @@ import {
PartnerRedirectModal,
RedirectPartner,
} from '@repo/lib/shared/components/modals/PartnerRedirectModal'
import { PoolCore } from '../pool.types'
import { getHeaderTokensWithPossibleNestedTokensWithBalance } from '../pool.tokens.display'

function getTabs(isVeBalPool: boolean) {
return [
Expand Down Expand Up @@ -257,7 +258,7 @@ export default function PoolMyLiquidity() {
}
}

const displayTokens = getPoolDisplayTokens(pool)
const displayTokens = getHeaderTokensWithPossibleNestedTokensWithBalance(pool as PoolCore)

return (
<Card h="fit-content" ref={myLiquiditySectionRef}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
'use client'

import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { GqlPoolTokenDetail } from '@repo/lib/shared/services/api/generated/graphql'
import { Box, VStack, useTheme } from '@chakra-ui/react'
import { NoisyCard } from '@repo/lib/shared/components/containers/NoisyCard'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { useThemeColorMode } from '@repo/lib/shared/services/chakra/useThemeColorMode'
import { Box, VStack, useTheme } from '@chakra-ui/react'
import ReactECharts from 'echarts-for-react'
import EChartsReactCore from 'echarts-for-react/lib/core'
import * as echarts from 'echarts/core'
import { motion } from 'framer-motion'
import { useRef, useMemo } from 'react'
import PoolWeightChartLegend from './PoolWeightChartLegend'
import Image from 'next/image'
import ReactECharts from 'echarts-for-react'
import * as echarts from 'echarts/core'
import { useMemo, useRef } from 'react'
import { ApiToken } from '../../pool.types'
import PoolWeightChartLegend from './PoolWeightChartLegend'

interface PoolWeightChartProps {
displayTokens: GqlPoolTokenDetail[]
displayTokens: ApiToken[]
chain: GqlChain
hasLegend?: boolean
isSmall?: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { GqlChain, GqlPoolTokenDetail } from '@repo/lib/shared/services/api/generated/graphql'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { NoisyCard } from '@repo/lib/shared/components/containers/NoisyCard'
import { useThemeColorMode } from '@repo/lib/shared/services/chakra/useThemeColorMode'
import { Box, VStack, useTheme } from '@chakra-ui/react'
Expand All @@ -13,9 +13,10 @@ import ReactECharts from 'echarts-for-react'
import * as echarts from 'echarts/core'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
import { fNum } from '@repo/lib/shared/utils/numbers'
import { ApiTokenWithBalance } from '../../pool.types'

export interface PoolWeightChartProps {
displayTokens: GqlPoolTokenDetail[]
displayTokens: ApiTokenWithBalance[]
chain: GqlChain
totalLiquidity: string
hasLegend?: boolean
Expand All @@ -30,7 +31,7 @@ export interface ChartSizeValues {
haloTop: string
haloLeft: string
haloWidth: string
haloHeigth: string
haloHeight: string
}

export interface PoolWeightChartColorDef {
Expand Down Expand Up @@ -85,7 +86,7 @@ const smallSize: ChartSizeValues = {
haloTop: '40%',
haloLeft: '55px',
haloWidth: '40px',
haloHeigth: '40px',
haloHeight: '40px',
}

const normalSize: ChartSizeValues = {
Expand All @@ -95,7 +96,7 @@ const normalSize: ChartSizeValues = {
haloTop: '49%',
haloLeft: '95px',
haloWidth: '60px',
haloHeigth: '60px',
haloHeight: '60px',
}

function OuterSymbolCircle({ opacity, isSmall }: { opacity: string; isSmall: boolean }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Box, HStack, Text } from '@chakra-ui/react'
import { ApiToken } from '../../pool.types'
import { PoolWeightChartColorDef } from './PoolWeightChart'
import { GqlPoolTokenDetail } from '@repo/lib/shared/services/api/generated/graphql'

export default function PoolWeightChartLegend({
displayTokens,
colors = [],
}: {
displayTokens: GqlPoolTokenDetail[]
displayTokens: ApiToken[]
colors?: PoolWeightChartColorDef[]
}) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const smallSize: ChartSizeValues = {
haloTop: '40%',
haloLeft: '55px',
haloWidth: '40px',
haloHeigth: '40px',
haloHeight: '40px',
}

const normalSize: ChartSizeValues = {
Expand All @@ -28,7 +28,7 @@ const normalSize: ChartSizeValues = {
haloTop: '49%',
haloLeft: '95px',
haloWidth: '60px',
haloHeigth: '60px',
haloHeight: '60px',
}

export default function StakedBalanceDistributionChart({
Expand Down
Loading
Loading