-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/v3NestedRemoves
- Loading branch information
Showing
68 changed files
with
1,700 additions
and
554 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
apps/beets-frontend-v3/app/(app)/pools/[chain]/[variant]/[id]/swap/[[...txHash]]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 6 additions & 29 deletions
35
apps/beets-frontend-v3/app/(app)/swap/[[...slug]]/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.