Skip to content

Commit

Permalink
Merge branch 'main' into feat/v3NestedRemoves
Browse files Browse the repository at this point in the history
  • Loading branch information
agualis committed Nov 26, 2024
2 parents 2d7a9bd + fa3ca3c commit b452954
Show file tree
Hide file tree
Showing 68 changed files with 1,700 additions and 554 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use client'

import { Box } from '@chakra-ui/react'
import { PoolActionsLayout } from '@repo/lib/modules/pool/actions/PoolActionsLayout'
import { getPoolActionableTokens } from '@repo/lib/modules/pool/pool.helpers'
import { usePoolRedirect } from '@repo/lib/modules/pool/pool.hooks'
import { chainToSlugMap } from '@repo/lib/modules/pool/pool.utils'
import { usePool } from '@repo/lib/modules/pool/PoolProvider'
import { SwapForm } from '@repo/lib/modules/swap/SwapForm'
import SwapLayout from '@repo/lib/modules/swap/SwapLayout'
import { PathParams, SwapProviderProps } from '@repo/lib/modules/swap/SwapProvider'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
import { BalAlert } from '@repo/lib/shared/components/alerts/BalAlert'
import { Hash } from 'viem'

type Props = {
params: { txHash?: string[] }
}
// Page for swapping from a pool page
export default function PoolSwapPage({ params: { txHash } }: Props) {
const { getToken } = useTokens()
const { pool, isLoading } = usePool()
const { redirectToPoolPage } = usePoolRedirect(pool)

const poolActionableTokens = getPoolActionableTokens(pool, getToken)

if (poolActionableTokens.length < 2) {
return (
<PoolActionsLayout>
<Box w="50%">
<BalAlert
content="You cannot swap the tokens in this pool because we are missing token metadata"
status="info"
/>
</Box>
</PoolActionsLayout>
)
}

const maybeTxHash = (txHash?.[0] as Hash) || undefined

const pathParams: PathParams = {
chain: chainToSlugMap[pool.chain],
tokenIn: poolActionableTokens[0].address,
tokenOut: poolActionableTokens[1].address,
urlTxHash: maybeTxHash,
}
const props: SwapProviderProps = {
pathParams,
pool,
poolActionableTokens: poolActionableTokens || [],
}

return (
<PoolActionsLayout>
{isLoading ? null : (
<SwapLayout props={props}>
<SwapForm redirectToPoolPage={redirectToPoolPage} />
</SwapLayout>
)}
</PoolActionsLayout>
)
}
16 changes: 12 additions & 4 deletions apps/beets-frontend-v3/app/(app)/pools/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { PoolList } from '@repo/lib/modules/pool/PoolList/PoolList'
import { DefaultPageContainer } from '@repo/lib/shared/components/containers/DefaultPageContainer'
import FadeInOnView from '@repo/lib/shared/components/containers/FadeInOnView'

import { Box, Skeleton } from '@chakra-ui/react'
import { Suspense } from 'react'

// import { getApolloServerClient } from '@repo/lib/shared/services/api/apollo-server.client'
// import { getProjectConfig } from '@repo/lib/config/getProjectConfig'
// import { GetFeaturedPoolsDocument } from '@repo/lib/shared/services/api/generated/graphql'
// import { FeaturedPools } from '@repo/lib/modules/featured-pools/FeaturedPools'
import { CowPromoBanner } from '@repo/lib/shared/components/promos/CowPromoBanner'
import { PoolListDisplayType } from '@repo/lib/modules/pool/pool.types'
import { GqlPoolType } from '@repo/lib/shared/services/api/generated/graphql'

export default async function PoolsPage() {
// Featured pools set up
Expand Down Expand Up @@ -43,11 +43,19 @@ export default async function PoolsPage() {
</FadeInOnView> */}
</DefaultPageContainer>
</Box>

<DefaultPageContainer noVerticalPadding pb={['xl', '2xl']} pt={['lg', '54px']}>
<FadeInOnView animateOnce={false}>
<Suspense fallback={<Skeleton h="500px" w="full" />}>
<PoolList />
<PoolList
displayType={PoolListDisplayType.Name}
hidePoolTags={['VE8020']}
hidePoolTypes={[
GqlPoolType.LiquidityBootstrapping,
GqlPoolType.CowAmm,
GqlPoolType.Fx,
]}
hideProtocolVersion={['cow']}
/>
</Suspense>
</FadeInOnView>
</DefaultPageContainer>
Expand Down
35 changes: 6 additions & 29 deletions apps/beets-frontend-v3/app/(app)/swap/[[...slug]]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,24 @@
'use client'

import { ChainSlug, slugToChainMap } from '@repo/lib/modules/pool/pool.utils'
import { SwapProviderProps, SwapProvider } from '@repo/lib/modules/swap/SwapProvider'
import { TokenBalancesProvider } from '@repo/lib/modules/tokens/TokenBalancesProvider'
import { TokenInputsValidationProvider } from '@repo/lib/modules/tokens/TokenInputsValidationProvider'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
import { TransactionStateProvider } from '@repo/lib/modules/transactions/transaction-steps/TransactionStateProvider'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { PropsWithChildren } from 'react'
import { PriceImpactProvider } from '@repo/lib/modules/price-impact/PriceImpactProvider'
import { DefaultPageContainer } from '@repo/lib/shared/components/containers/DefaultPageContainer'
import { getSwapPathParams } from '@repo/lib/modules/swap/getSwapPathParams'
import { RelayerSignatureProvider } from '@repo/lib/modules/relayer/RelayerSignatureProvider'
import SwapLayout from '@repo/lib/modules/swap/SwapLayout'
import { DefaultPageContainer } from '@repo/lib/shared/components/containers/DefaultPageContainer'
import { SwapProviderProps } from '@repo/lib/modules/swap/SwapProvider'

type Props = PropsWithChildren<{
params: { slug?: string[] }
}>

export default function SwapLayout({ params: { slug }, children }: Props) {
export default function Layout({ params: { slug }, children }: Props) {
const pathParams = getSwapPathParams(slug)

const { getTokensByChain } = useTokens()
const initChain = pathParams.chain
? slugToChainMap[pathParams.chain as ChainSlug]
: GqlChain.Mainnet
const initTokens = getTokensByChain(initChain)
const props: SwapProviderProps = {
const swapProps: SwapProviderProps = {
pathParams,
}

return (
<DefaultPageContainer minH="100vh">
<TransactionStateProvider>
<RelayerSignatureProvider>
<TokenInputsValidationProvider>
<TokenBalancesProvider initTokens={initTokens}>
<PriceImpactProvider>
<SwapProvider params={props}>{children}</SwapProvider>
</PriceImpactProvider>
</TokenBalancesProvider>
</TokenInputsValidationProvider>
</RelayerSignatureProvider>
</TransactionStateProvider>
<SwapLayout props={swapProps}> {children} </SwapLayout>
</DefaultPageContainer>
)
}
8 changes: 2 additions & 6 deletions apps/beets-frontend-v3/app/(app)/swap/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/* eslint-disable max-len */

import { getProjectConfig } from '@repo/lib/config/getProjectConfig'
import { SwapForm } from '@repo/lib/modules/swap/SwapForm'
import { Metadata } from 'next'

const { projectName } = getProjectConfig()

export const metadata: Metadata = {
title: `Swap tokens on ${projectName}`,
description: `Swap tokens on networks like Ethereum, Optimism, Arbitrum and Base via the Balancer decentralized exchange`,
title: 'Swap tokens on Beets',
description: `Swap tokens on networks like Fantom and Optimism via the Beets decentralized exchange`,
}

export default function SwapPage() {
Expand Down
1 change: 1 addition & 0 deletions apps/beets-frontend-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build": "pnpm --filter @repo/lib graphql:gen && next build",
"dev": "concurrently \"pnpm --filter @repo/lib graphql:gen --watch\" \"next dev -p 3001\"",
"dev:no-gen": "next dev -p 3001",
"gen:wagmi": "pnpm wagmi generate",
"lint": "next lint",
"lint:fix": "next lint --fix",
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend-v3/app/(app)/pools/cow/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function PoolsPage() {
<DefaultPageContainer noVerticalPadding pb={['xl', '2xl']} pt={['lg', '54px']}>
<FadeInOnView animateOnce={false}>
<Suspense fallback={<Skeleton h="500px" w="full" />}>
<PoolList fixedPoolTypes={[GqlPoolType.CowAmm]} />
<PoolList fixedPoolTypes={[GqlPoolType.CowAmm]} hidePoolTags={['VE8020']} />
</Suspense>
</FadeInOnView>
</DefaultPageContainer>
Expand Down
6 changes: 2 additions & 4 deletions apps/frontend-v3/app/(app)/pools/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { PoolList } from '@repo/lib/modules/pool/PoolList/PoolList'
import { DefaultPageContainer } from '@repo/lib/shared/components/containers/DefaultPageContainer'
import FadeInOnView from '@repo/lib/shared/components/containers/FadeInOnView'

import { Box, Skeleton } from '@chakra-ui/react'
import { Suspense } from 'react'

// import { getApolloServerClient } from '@repo/lib/shared/services/api/apollo-server.client'
// import { getProjectConfig } from '@repo/lib/config/getProjectConfig'
// import { GetFeaturedPoolsDocument } from '@repo/lib/shared/services/api/generated/graphql'
// import { FeaturedPools } from '@repo/lib/modules/featured-pools/FeaturedPools'
import { CowPromoBanner } from '@repo/lib/shared/components/promos/CowPromoBanner'
import { GqlPoolType } from '@repo/lib/shared/services/api/generated/graphql'

export default async function PoolsPage() {
// Featured pools set up
Expand Down Expand Up @@ -43,11 +42,10 @@ export default async function PoolsPage() {
</FadeInOnView> */}
</DefaultPageContainer>
</Box>

<DefaultPageContainer noVerticalPadding pb={['xl', '2xl']} pt={['lg', '54px']}>
<FadeInOnView animateOnce={false}>
<Suspense fallback={<Skeleton h="500px" w="full" />}>
<PoolList />
<PoolList hidePoolTypes={[GqlPoolType.CowAmm]} />
</Suspense>
</FadeInOnView>
</DefaultPageContainer>
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend-v3/app/(app)/swap/[[...slug]]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { PropsWithChildren } from 'react'
import { getSwapPathParams } from '@repo/lib/modules/swap/getSwapPathParams'
import SwapLayout from '../../../../../../packages/lib/modules/swap/SwapLayout'
import SwapLayout from '@repo/lib/modules/swap/SwapLayout'
import { DefaultPageContainer } from '@repo/lib/shared/components/containers/DefaultPageContainer'
import { SwapProviderProps } from '@repo/lib/modules/swap/SwapProvider'

Expand Down
64 changes: 48 additions & 16 deletions apps/frontend-v3/app/(marketing)/risks/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export default function Privacy() {
<li>
<Link href="risks#impermanent-loss-risk">Impermanent loss risk</Link>
</li>
<li>
<Link href="risks#hooks-risk">Hooks risk</Link>
</li>
<li>
<Link href="risks#ui-risk">User Interface risk</Link>
</li>
Expand Down Expand Up @@ -708,6 +711,37 @@ export default function Privacy() {
</ul>
</div>
</FadeInOnView>
<FadeInOnView>
<div className="subsection">
<h4 className="anchor" id="hooks-risk">
Hooks
</h4>
<p>
Hooks introduces complex logic into Balancer pools and changes in its parameters can
significantly impact the risk profile of a pool. This complexity increases the
potential for unforeseen errors or vulnerabilities in the hook's code, that may i.e.
amplify impermanent loss, introduce new sources of volatility or impose restrictions
on pool interactions like joins and exits.
</p>
<ul>
<li>
Hook specific risk: Balancer hooks introduce unique functionalities to Balancer
pools, and while they offer exciting possibilities, they also present specific
risks that users should be aware of.
</li>
<li>
Hook Interactions: Hooks can interact with each other and with the pool contracts
in unexpected ways. These interactions may lead to unintended and yet unknown
consequences or exploits.
</li>
<li>
Hook Updates: Hooks may be updated or modified over time. These updates could
introduce new risks or alter the functionality of the pool in ways that may
negatively impact your assets.
</li>
</ul>
</div>
</FadeInOnView>
<FadeInOnView>
<div className="subsection">
<h4 className="anchor" id="ui-risk">
Expand Down Expand Up @@ -1016,39 +1050,37 @@ export default function Privacy() {
liquidity, and increased yield for Liquidity Providers.
</li>
<li>
For traders, Boosted Pools are a cheaper entry/exit into lending protocols
like Aave.
For traders, Boosted Pools are a cheaper entry/exit into decentralized lending
protocols like Aave.
</li>
<li>
Boosted Pools increase the opportunity for LPs to gain exposure to a wide
variety of yield increases from multiple yield protocols.
</li>
</ul>
<h5>Third party lending platform risk exposure (DeFi composability risk)</h5>
<h5>Third party platform risk exposure (DeFi composability risk)</h5>
<p>
Since boosted pools deposit excess liquidity into lending protocols, like Aave,
to generate yield, LPs must fully understand the risks of the underlying lending
Since boosted pools deposit excess liquidity into third-party protocols, like
Aave, to generate yield, LPs must fully understand the risks of the underlying
protocol since a portion of their funds will be exposed to the risks of that
protocol. Some of the risks of the underlying lending protocol may include smart
protocol. Some of the risks of the underlying protocol may include smart
contract bugs, economic attack vulnerabilities and counterparty risk from the
protocol&rsquo;s borrowers. Lending platforms may also use{' '}
protocol&rsquo;s borrowers. Underlaying protocols may also use{' '}
<Link href="risks#oracles">
<span>Oracles</span>
</Link>{' '}
which face additional risks (described above).
</p>

<p>
Also note, some Boosted pools, like those by Tetu and Idle may use strategies
that utilize multiple yield protocols in order to maximize yield. Since these
strategies may change exposure to the underlying yield protocols at any time,
LPs must accept the risk that the protocol utilizing these strategies carefully
vets all third party protocols to reduce composability risks.
Also note, some boosted pools may use strategies that utilize multiple yield
protocols in order to maximize yield. Since these strategies may change exposure
to the underlying yield protocols at any time, LPs must accept the risk that the
protocol utilizing these strategies carefully vets all third party protocols to
reduce composability risks.
</p>

<p>
If the underlying lending protocol were to get hacked, LPs in a boosted pool
that deposits liquidity in that protocol could lose funds.
If the underlying protocol were to get hacked, LPs in a boosted pool that
deposits liquidity in that protocol could lose funds.
</p>
<h5>Depegging risk</h5>
<p>
Expand Down
1 change: 1 addition & 0 deletions apps/frontend-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build": "pnpm --filter @repo/lib graphql:gen && next build",
"dev": "concurrently \"pnpm --filter @repo/lib graphql:gen --watch\" \"next dev\"",
"dev:no-gen": "next dev",
"gen:wagmi": "pnpm wagmi generate",
"lint": "next lint",
"lint:fix": "next lint --fix",
Expand Down
4 changes: 3 additions & 1 deletion packages/lib/config/config.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface Config {
}
}

interface Banners {
export interface Banners {
headerSrc: string
footerSrc: string
}
Expand All @@ -107,4 +107,6 @@ export interface ProjectConfig {
supportedNetworks: GqlChain[]
corePoolId: string // this prop is used to adjust the color of the SparklesIcon
variantConfig?: VariantConfig
defaultNetwork: GqlChain
ensNetwork: GqlChain
}
2 changes: 1 addition & 1 deletion packages/lib/config/networks/fantom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const networkConfig: NetworkConfig = {
tokens: {
addresses: {
bal: emptyAddress,
wNativeAsset: emptyAddress,
wNativeAsset: '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83',
},
nativeAsset: {
name: 'Fantom',
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/config/projects/balancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ export const ProjectConfigBalancer: ProjectConfig = {
},
},
corePoolId: '0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014', // veBAL BAL8020 (Balancer 80 BAL 20 WETH) pool on Ethereum
defaultNetwork: GqlChain.Mainnet,
ensNetwork: GqlChain.Mainnet,
}
2 changes: 2 additions & 0 deletions packages/lib/config/projects/beets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export const ProjectConfigBeets: ProjectConfig = {
projectName: 'BeethovenX',
supportedNetworks: beetsSupportedNetworks,
corePoolId: '0x9e4341acef4147196e99d648c5e43b3fc9d026780002000000000000000005ec', // maBEETS BEETS8020 (Fresh BEETS) pool on Fantom
defaultNetwork: GqlChain.Fantom,
ensNetwork: GqlChain.Fantom,
}
Loading

0 comments on commit b452954

Please sign in to comment.