Skip to content

Commit

Permalink
Merge branch 'main' into fix/proportionalSlippage
Browse files Browse the repository at this point in the history
  • Loading branch information
garethfuller committed Jan 15, 2025
2 parents 05f7c9b + f003816 commit 9df37ef
Show file tree
Hide file tree
Showing 97 changed files with 890 additions and 653 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,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 { getUserReferenceTokens } from '@repo/lib/modules/pool/pool-tokens.utils'

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

const poolTokenString = arrayToSentence(pool.displayTokens.map(token => token.symbol))
const displayTokens = getUserReferenceTokens(pool)
const poolTokenString = arrayToSentence(displayTokens.map(token => token.symbol))

return {
title: `Liquidity Pool (${variant}): ${pool.name}`,
Expand Down
7 changes: 6 additions & 1 deletion apps/beets-frontend-v3/app/(app)/portfolio/[chain]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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 { getUserReferenceTokens } from '@repo/lib/modules/pool/pool-tokens.utils'

export default function NetworkClaim() {
const { toCurrency } = useCurrency()
Expand Down Expand Up @@ -73,7 +74,11 @@ export default function NetworkClaim() {
</Text>
</HStack>
<HStack w="full">
<TokenIconStack chain={pool.chain} size={36} tokens={pool.displayTokens} />
<TokenIconStack
chain={pool.chain}
size={36}
tokens={getUserReferenceTokens(pool)}
/>
{hasMultipleClaims && (
<Button
minW="60px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export function LstTokenRow({
chain,
tokenAmount,
tokenAddress,
isLoading,
isLoading = false,
}: {
label: string
chain: GqlChain
tokenAmount: string
tokenAddress: string
isLoading: boolean
isLoading?: boolean
}) {
return (
<VStack align="start" spacing="md">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ import { useBreakpoints } from '@repo/lib/shared/hooks/useBreakpoints'
import { MobileStepTracker } from '@repo/lib/modules/transactions/transaction-steps/step-tracker/MobileStepTracker'
import { useLst } from '../LstProvider'
import { LstTokenRow } from './LstTokenRow'
import { useGetConvertToAssets } from '../hooks/useGetConvertToAssets'
import { formatUnits, parseUnits } from 'viem'
import { BalAlert } from '@repo/lib/shared/components/alerts/BalAlert'
import { BalAlertContent } from '@repo/lib/shared/components/alerts/BalAlertContent'

export function LstUnstakeSummary() {
const { isMobile } = useBreakpoints()

const { chain, stakeTransactionSteps, lstUnstakeTxHash, nativeAsset, stakedAsset, amountShares } =
useLst()

const { assetsAmount, isLoading } = useGetConvertToAssets(parseUnits(amountShares, 18), chain)
const { chain, stakeTransactionSteps, lstUnstakeTxHash, stakedAsset, amountShares } = useLst()

const shouldShowReceipt = !!lstUnstakeTxHash

Expand All @@ -25,21 +19,11 @@ export function LstUnstakeSummary() {
<Card variant="modalSubSection">
<LstTokenRow
chain={chain}
isLoading={isLoading}
label={shouldShowReceipt ? 'You unstaked' : 'You unstake'}
tokenAddress={stakedAsset?.address || ''}
tokenAmount={amountShares}
/>
</Card>
<Card variant="modalSubSection">
<LstTokenRow
chain={chain}
isLoading={isLoading}
label="You will receive (estimated)"
tokenAddress={nativeAsset?.address || ''}
tokenAmount={formatUnits(assetsAmount, 18)}
/>
</Card>
<BalAlert
content={
<BalAlertContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ export function LstWithdrawSummary({
<LstTokenRow
chain={chain}
isLoading={isLoading}
label={shouldShowReceipt ? 'You withdrew' : 'You withdraw'}
label={shouldShowReceipt ? 'You received' : 'You will receive (estimated)'}
tokenAddress={nativeAsset?.address || ''}
tokenAmount={formatUnits(amountWithdraw, nativeAsset?.decimals || 18).toString()}
tokenAmount={
shouldShowReceipt
? receivedToken.humanAmount
: formatUnits(amountWithdraw, nativeAsset?.decimals || 18).toString()
}
/>
{/* TODO: add received amount */}
</Card>
</AnimateHeightChange>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useLst } from '../LstProvider'
import { TokenIcon } from '@repo/lib/modules/tokens/TokenIcon'
import { UserWithdraw } from '../hooks/useGetUserWithdraws'
import { formatUnits } from 'viem'
import { ApiToken } from '@repo/lib/modules/pool/pool.types'
import { ApiToken } from '@repo/lib/modules/tokens/token.types'
import { fNum } from '@repo/lib/shared/utils/numbers'

interface Props extends GridProps {
Expand Down
22 changes: 22 additions & 0 deletions apps/beets-frontend-v3/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

export function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/api/rpc')) {
// Add logging for /api/rpc paths
console.log('Referer:', request.headers.get('referer'))
}

const blockedPaths = ['/api/rpc/FANTOM/routes', '/api/rpc/OPTIMISM/routes']

if (blockedPaths.some(path => request.nextUrl.pathname.startsWith(path))) {
return new NextResponse('This path is blocked.', { status: 403 })
}

return NextResponse.next()
}

// Apply the middleware to /api/rpc/* routes
export const config = {
matcher: ['/api/rpc/:path*'],
}
6 changes: 0 additions & 6 deletions apps/beets-frontend-v3/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ const nextConfig = {
destination: 'https://discord.gg/kbPnYJjvwZ',
permanent: false,
},
// some cached apps are still trying to access this route
{
source: '/api/rpc/FANTOM/routes',
destination: 'https://ftm.beets.fi/api/rpc/FANTOM/routes',
permanent: false,
},
]
},
}
Expand Down
1 change: 1 addition & 0 deletions apps/beets-frontend-v3/public/images/icons/pool-points.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/beets-frontend-v3/public/images/misc/staking-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 35 additions & 7 deletions apps/frontend-v3/app/(app)/debug/pools/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
'use client'
import { HStack, Heading, VStack } from '@chakra-ui/react'
import { HStack, Heading, VStack, Text } from '@chakra-ui/react'
import NextLink from 'next/link'
import { Link } from '@chakra-ui/react'
import FadeInOnView from '@repo/lib/shared/components/containers/FadeInOnView'
import { boostedPoolExamples } from '@repo/lib/modules/pool/__mocks__/pool-examples/boosted'
import { flatPoolExamples } from '@repo/lib/modules/pool/__mocks__/pool-examples/flat'
import { nestedPoolExamples } from '@repo/lib/modules/pool/__mocks__/pool-examples/nested'
import { getPoolExampleUri } from '@repo/lib/modules/pool/__mocks__/pool-examples/pool-example-helpers'
import { PoolExample } from '@repo/lib/modules/pool/__mocks__/pool-examples/pool-examples.types'

export default function DebugPools() {
return (
<FadeInOnView>
<HStack align="start" mx="auto" spacing="24px" width="80%">
<VStack align="start" margin="lg" padding="lg">
<Heading size="md">Debug V3 pools</Heading>
<HStack align="start" margin="xs" mx="auto" spacing="24px" width="90%">
<VStack align="start" margin="xs" padding="0" width="40%">
<Heading size="md">Flat pool examples</Heading>
<PoolExampleLinks poolExamples={flatPoolExamples} />

<Heading size="md">Boosted examples</Heading>
<PoolExampleLinks poolExamples={boostedPoolExamples} />

<Heading size="md">Nested pool examples</Heading>
<PoolExampleLinks poolExamples={nestedPoolExamples} />
</VStack>
<VStack align="start" margin="xs" padding="0">
<Heading size="md">V3 reference pools</Heading>
<Link as={NextLink} href="/pools/sepolia/v3/0xe69b70a86a4e1fd33da95693a1ae12be1c26c8ea">
Sepolia WEIGHTED (Balancer 50 BAL 50 DAI-aave)
</Link>
Expand All @@ -30,8 +45,8 @@ export default function DebugPools() {
</Link>
</VStack>

<VStack align="start" margin="lg" padding="lg">
<Heading size="md">Debug V2 pools</Heading>
<VStack align="start" margin="xs" padding="0">
<Heading size="md">V2 reference pools</Heading>
<Link
as={NextLink}
href="/pools/ethereum/v2/0x68e3266c9c8bbd44ad9dca5afbfe629022aee9fe000200000000000000000512"
Expand Down Expand Up @@ -118,7 +133,7 @@ export default function DebugPools() {
</Link>
</VStack>

<VStack align="start" margin="lg" padding="lg">
<VStack align="start" margin="xs" padding="0">
<Heading size="md">Debug CoW AMM (V1) pools</Heading>
<Link as={NextLink} href="/pools/gnosis/cow/0x079d2094e16210c42457438195042898a3cff72d">
Gnosis CoW AMM
Expand All @@ -128,3 +143,16 @@ export default function DebugPools() {
</FadeInOnView>
)
}

function PoolExampleLinks({ poolExamples }: { poolExamples: PoolExample[] }) {
return poolExamples.map(pool => (
<Link as={NextLink} href={getPoolExampleUri(pool)} key={pool.poolId} margin="sm">
<Text align="start" w="full">
<Text color="font.highlight" fontSize="md" fontStyle="italic">
{pool.name}
</Text>
<Text fontSize="sm">{pool.description}</Text>
</Text>
</Link>
))
}
2 changes: 1 addition & 1 deletion apps/frontend-v3/app/(app)/debug/token-input/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ConnectWallet } from '@repo/lib/modules/web3/ConnectWallet'
import { daiAddress } from '@repo/lib/debug-helpers'
import { TokenInputsValidationProvider } from '@repo/lib/modules/tokens/TokenInputsValidationProvider'
import { PriceImpactProvider } from '@repo/lib/modules/price-impact/PriceImpactProvider'
import { ApiToken } from '@repo/lib/modules/pool/pool.types'
import { ApiToken } from '@repo/lib/modules/tokens/token.types'

export default function TokenInputPage() {
const [currentValue, setCurrentValue] = useState('')
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend-v3/app/(app)/debug/token-select/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { Button, Text, useDisclosure } from '@chakra-ui/react'
import { ApiToken } from '@repo/lib/modules/pool/pool.types'
import { ApiToken } from '@repo/lib/modules/tokens/token.types'
import { TokenBalancesProvider } from '@repo/lib/modules/tokens/TokenBalancesProvider'
import { TokenSelectModal } from '@repo/lib/modules/tokens/TokenSelectModal/TokenSelectModal'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,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 { getUserReferenceTokens } from '@repo/lib/modules/pool/pool-tokens.utils'

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

const poolTokenString = arrayToSentence(pool.displayTokens.map(token => token.symbol))
const displayTokens = getUserReferenceTokens(pool)
const poolTokenString = arrayToSentence(displayTokens.map(token => token.symbol))

return {
title: `Liquidity Pool (${variant}): ${pool.name}`,
Expand Down
7 changes: 6 additions & 1 deletion apps/frontend-v3/app/(app)/portfolio/[chain]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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 { getUserReferenceTokens } from '@repo/lib/modules/pool/pool-tokens.utils'

export default function NetworkClaim() {
const { toCurrency } = useCurrency()
Expand Down Expand Up @@ -72,7 +73,11 @@ export default function NetworkClaim() {
</Text>
</HStack>
<HStack w="full">
<TokenIconStack chain={pool.chain} size={36} tokens={pool.displayTokens} />
<TokenIconStack
chain={pool.chain}
size={36}
tokens={getUserReferenceTokens(pool)}
/>
{hasMultipleClaims && (
<Button
minW="60px"
Expand Down
1 change: 1 addition & 0 deletions apps/frontend-v3/public/images/icons/pool-points.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions apps/frontend-v3/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function handleNonFatalError(event: Sentry.ErrorEvent): Sentry.ErrorEvent | null
const firstValue = getFirstExceptionValue(event)
if (firstValue && shouldIgnoreException(firstValue)) return null
event.level = 'error'
return event

return addTags(event)
}

function handleFatalError(
Expand All @@ -108,7 +109,7 @@ function handleFatalError(
event.exception.values[0] = firstValue
}

return event
return addTags(event)
}

function uppercaseSegment(path: string): string {
Expand All @@ -131,3 +132,18 @@ function getFirstExceptionValue(event: Sentry.ErrorEvent) {
return event.exception.values[0]
}
}

function addTags(event: Sentry.ErrorEvent) {
const errorMessage = getFirstExceptionValue(event)?.value || ''

/*
This is a known rainbow-kit/wagmi related issue that is randomly happening to many users.
We couldn't understand/reproduce it yet so we are tagging it as a known issue to track it better.
More context: https://github.com/rainbow-me/rainbowkit/issues/2238
*/
if (errorMessage.includes('provider.disconnect is not a function')) {
event.tags = { ...event.tags, error_category: 'known_issue', error_type: 'provider_disconnect' }
}

return event
}
6 changes: 5 additions & 1 deletion packages/lib/config/networks/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ const networkConfig: NetworkConfig = {
'0xad0e5e0778cac28f1ff459602b31351871b5754a0002000000000000000003cD',
],
},
disallowNestedActions: ['0x3dd0843a028c86e0b760b1a76929d1c5ef93a2dd000200000000000000000249'],
disallowNestedActions: [
'0x3dd0843a028c86e0b760b1a76929d1c5ef93a2dd000200000000000000000249', // 80BAL20WETH + AuraBal
'0xc5c91aea7551095c3e1ff0f94f682c45b347ad730002000000000000000006c0', // 80BAL20WETH + WETH
'0x2d011adf89f0576c9b722c28269fcb5d50c2d17900020000000000000000024d', // 80BAL20WETH + SdBal
],
}),
} as const satisfies NetworkConfig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { NumberFormatter } from '@repo/lib/shared/utils/numbers'
import { usePoolEvents } from '../pool/usePoolEvents'
import { supportedNetworks } from '../web3/ChainConfig'
import { getChainShortName } from '@repo/lib/config/app.config'
import { ApiToken } from '../pool/pool.types'
import { ApiToken } from '../tokens/token.types'
import {
getBlockExplorerAddressUrl,
getBlockExplorerTxUrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GqlPoolType } from '@repo/lib/shared/services/api/generated/graphql'
import { ApiToken, BaseVariant, PoolVariant } from '../../pool.types'
import { BaseVariant, PoolVariant } from '../../pool.types'
import { ApiToken } from '@repo/lib/modules/tokens/token.types'

export type PoolActivityTokens = {
token?: ApiToken
Expand Down
Loading

0 comments on commit 9df37ef

Please sign in to comment.