From c4fd76d9be6f0f12f3425274ee5b26ac6a7e16f4 Mon Sep 17 00:00:00 2001 From: 0xMasayoshi <0xMasayoshi@protonmail.com> Date: Wed, 14 Aug 2024 00:42:44 +0700 Subject: [PATCH 1/5] feat: prepare cronos for rp5 integration --- apps/web/src/config.ts | 5 +- apps/web/src/ui/pool/PositionCardList.tsx | 4 +- apps/web/src/ui/pool/PositionsTable.tsx | 4 +- packages/sushi/src/config/wallet.ts | 2 + .../src/icons/network/circle/CronosCircle.tsx | 7 +++ .../ui/src/icons/network/circle/index.tsx | 3 + .../src/icons/network/naked/CronosNaked.tsx | 61 +++++++++++++++++++ packages/ui/src/icons/network/naked/index.tsx | 3 + 8 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 packages/ui/src/icons/network/circle/CronosCircle.tsx create mode 100644 packages/ui/src/icons/network/naked/CronosNaked.tsx diff --git a/apps/web/src/config.ts b/apps/web/src/config.ts index 66c7ae901a..54d3fa05b6 100644 --- a/apps/web/src/config.ts +++ b/apps/web/src/config.ts @@ -48,10 +48,7 @@ const SUSHI_CHAIN_IDS = Array.from( export const SWAP_ONLY_CHAIN_IDS = [ChainId.CRONOS] as const -export const CHAIN_IDS = [ - ...SUSHI_CHAIN_IDS, - // ChainId.CRONOS -] as const +export const CHAIN_IDS = [...SUSHI_CHAIN_IDS, ChainId.CRONOS] as const export const SUPPORTED_CHAIN_IDS = Array.from( new Set([ diff --git a/apps/web/src/ui/pool/PositionCardList.tsx b/apps/web/src/ui/pool/PositionCardList.tsx index 90d6adc24c..6e22ce649e 100644 --- a/apps/web/src/ui/pool/PositionCardList.tsx +++ b/apps/web/src/ui/pool/PositionCardList.tsx @@ -1,7 +1,7 @@ import React, { FC, ReactNode } from 'react' import type { UserWithPool } from 'src/app/(evm)/pool/api/user-with-pools/route' -import { SUPPORTED_CHAIN_IDS } from 'src/config' import { useSushiV2UserPositions } from 'src/lib/hooks' +import { SUSHISWAP_V2_SUPPORTED_CHAIN_IDS } from 'sushi/config' import { useAccount } from 'wagmi' interface PositionCardList { @@ -23,7 +23,7 @@ export const PositionCardList: FC = ({ children }) => { const { address } = useAccount() const { data: userPositions, isLoading } = useSushiV2UserPositions({ id: address!, - chainIds: SUPPORTED_CHAIN_IDS, + chainIds: SUSHISWAP_V2_SUPPORTED_CHAIN_IDS, }) return ( diff --git a/apps/web/src/ui/pool/PositionsTable.tsx b/apps/web/src/ui/pool/PositionsTable.tsx index a4f4391173..22867e8ce3 100644 --- a/apps/web/src/ui/pool/PositionsTable.tsx +++ b/apps/web/src/ui/pool/PositionsTable.tsx @@ -2,8 +2,8 @@ import { Card, CardHeader, CardTitle, DataTable } from '@sushiswap/ui' import { Slot } from '@sushiswap/ui' import { DisplayColumnDef, PaginationState, Row } from '@tanstack/react-table' import React, { FC, ReactNode, useCallback, useMemo, useState } from 'react' -import { SUPPORTED_CHAIN_IDS } from 'src/config' import { useSushiV2UserPositions } from 'src/lib/hooks' +import { SUSHISWAP_V2_SUPPORTED_CHAIN_IDS } from 'sushi/config' import type { UserWithPool } from 'src/app/(evm)/pool/api/user-with-pools/route' import { useAccount } from 'wagmi' @@ -38,7 +38,7 @@ export const PositionsTable: FC = ({ const { data: positions, isLoading } = useSushiV2UserPositions( { id: address!, - chainIds: SUPPORTED_CHAIN_IDS, + chainIds: SUSHISWAP_V2_SUPPORTED_CHAIN_IDS, }, !!address, ) diff --git a/packages/sushi/src/config/wallet.ts b/packages/sushi/src/config/wallet.ts index 16ae93542e..98c847dbba 100644 --- a/packages/sushi/src/config/wallet.ts +++ b/packages/sushi/src/config/wallet.ts @@ -11,6 +11,7 @@ export const MULTISIG_CHAIN_IDS = [ ChainId.BTTC, ChainId.CELO, ChainId.CORE, + ChainId.CRONOS, ChainId.ETHEREUM, ChainId.FANTOM, ChainId.FUSE, @@ -44,6 +45,7 @@ export const MULTISIG_ADDRESS: Record = { [ChainId.BSC]: '0xc6fD91aD4919Fd91e2c84077ba648092cB499638', [ChainId.BTTC]: '0x488398D8EfeF84Bd3271f13ae8Eb44Cd2C1eE687', [ChainId.CELO]: '0x751b01Fa14fD9640a1DF9014e2D0f3a03A198b81', + [ChainId.CRONOS]: '0xb8f2faca5b2EBcd6Be7B5D9E164962dE9CCc3B76', [ChainId.CORE]: '0x9ffC84bc9Cf7c85E4E6e2B0aB67BB6c643cA72A2', [ChainId.ETHEREUM]: '0x19B3Eb3Af5D93b77a5619b047De0EED7115A19e7', [ChainId.FANTOM]: '0xF9E7d4c6d36ca311566f46c81E572102A2DC9F52', diff --git a/packages/ui/src/icons/network/circle/CronosCircle.tsx b/packages/ui/src/icons/network/circle/CronosCircle.tsx new file mode 100644 index 0000000000..4997fe1cbf --- /dev/null +++ b/packages/ui/src/icons/network/circle/CronosCircle.tsx @@ -0,0 +1,7 @@ +import * as React from 'react' + +import { CronosNaked } from '../naked/CronosNaked' + +import { IconComponent } from '../../../types' + +export const CronosCircle: IconComponent = CronosNaked diff --git a/packages/ui/src/icons/network/circle/index.tsx b/packages/ui/src/icons/network/circle/index.tsx index 32aaa7f58c..d8f544791d 100644 --- a/packages/ui/src/icons/network/circle/index.tsx +++ b/packages/ui/src/icons/network/circle/index.tsx @@ -13,6 +13,7 @@ import { BobaCircle } from './BobaCircle' import { BttcCircle } from './BttcCircle' import { CeloCircle } from './CeloCircle' import { CoreCircle } from './CoreCircle' +import { CronosCircle } from './CronosCircle' import { EthereumCircle } from './EthereumCircle' import { FantomCircle } from './FantomCircle' import { FilecoinCircle } from './FilecoinCircle' @@ -51,6 +52,7 @@ export * from './BobaCircle' export * from './BttcCircle' export * from './CeloCircle' export * from './CoreCircle' +export * from './CronosCircle' export * from './EthereumCircle' export * from './FantomCircle' export * from './FilecoinCircle' @@ -114,4 +116,5 @@ export const NETWORK_CIRCLE_ICON: Partial> = { [ChainId.BLAST]: BlastCircle, [ChainId.SKALE_EUROPA]: SkaleCircle, [ChainId.ROOTSTOCK]: RootstockCircle, + [ChainId.CRONOS]: CronosCircle, } diff --git a/packages/ui/src/icons/network/naked/CronosNaked.tsx b/packages/ui/src/icons/network/naked/CronosNaked.tsx new file mode 100644 index 0000000000..aac16f0930 --- /dev/null +++ b/packages/ui/src/icons/network/naked/CronosNaked.tsx @@ -0,0 +1,61 @@ +import React from 'react' + +import { NakedNetworkIconComponent } from '../../../types' + +export const CronosNaked: NakedNetworkIconComponent = (props) => { + return ( + + + + + + + + + + + + + + + + + + ) +} diff --git a/packages/ui/src/icons/network/naked/index.tsx b/packages/ui/src/icons/network/naked/index.tsx index 3bdb7c8b47..03081ed09d 100644 --- a/packages/ui/src/icons/network/naked/index.tsx +++ b/packages/ui/src/icons/network/naked/index.tsx @@ -13,6 +13,7 @@ import { BobaNaked } from './BobaNaked' import { BttcNaked } from './BttcNaked' import { CeloNaked } from './CeloNaked' import { CoreNaked } from './CoreNaked' +import { CronosNaked } from './CronosNaked' import { EthereumNaked } from './EthereumNaked' import { FantomNaked } from './FantomNaked' import { FilecoinNaked } from './FilecoinNaked' @@ -50,6 +51,7 @@ export * from './BobaNaked' export * from './BttcNaked' export * from './CeloNaked' export * from './CoreNaked' +export * from './CronosNaked' export * from './EthereumNaked' export * from './FantomNaked' export * from './FilecoinNaked' @@ -112,4 +114,5 @@ export const NETWORK_NAKED_ICON: Partial> = { [ChainId.BLAST]: BlastNaked, [ChainId.SKALE_EUROPA]: SkaleNaked, [ChainId.ROOTSTOCK]: RootstockNaked, + [ChainId.CRONOS]: CronosNaked, } From ca064120c8276cb59d5c672d262204e2dc5a879a Mon Sep 17 00:00:00 2001 From: 0xMasayoshi <0xMasayoshi@protonmail.com> Date: Wed, 14 Aug 2024 01:55:39 +0700 Subject: [PATCH 2/5] chore: AMM_SUPPORTED_CHAIN_IDS --- apps/web/src/app/(evm)/pool/add/page.tsx | 11 +++++++---- apps/web/src/config.ts | 11 +++++++++++ apps/web/src/lib/constants.ts | 4 ++-- apps/web/src/lib/graph.ts | 4 ++-- .../ui/pool/ConcentratedLiquidityURLStateProvider.tsx | 4 ++-- apps/web/src/ui/pool/PoolsFiltersProvider.tsx | 8 ++++---- apps/web/src/ui/pool/TableFiltersNetwork.tsx | 8 ++++---- apps/web/src/ui/pool/TableFiltersResetButton.tsx | 4 ++-- 8 files changed, 34 insertions(+), 20 deletions(-) diff --git a/apps/web/src/app/(evm)/pool/add/page.tsx b/apps/web/src/app/(evm)/pool/add/page.tsx index 018dc7a660..a3dc500e05 100644 --- a/apps/web/src/app/(evm)/pool/add/page.tsx +++ b/apps/web/src/app/(evm)/pool/add/page.tsx @@ -1,7 +1,6 @@ 'use client' import React, { FC, useMemo, useState } from 'react' -import { SUPPORTED_CHAIN_IDS } from 'src/config' import { useTokenAmountDollarValues } from 'src/lib/hooks' import { useConcentratedPositionInfo } from 'src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionInfo' import { ConcentratedLiquidityProvider } from 'src/ui/pool/ConcentratedLiquidityProvider' @@ -14,8 +13,12 @@ import { SelectFeeConcentratedWidget } from 'src/ui/pool/SelectFeeConcentratedWi import { SelectNetworkWidget } from 'src/ui/pool/SelectNetworkWidget' import { SelectPricesWidget } from 'src/ui/pool/SelectPricesWidget' import { SelectTokensWidget } from 'src/ui/pool/SelectTokensWidget' -import { computeSushiSwapV3PoolAddress } from 'sushi' -import { SUSHISWAP_V3_FACTORY_ADDRESS, isWNativeSupported } from 'sushi/config' +import { ChainId, computeSushiSwapV3PoolAddress } from 'sushi' +import { + SUSHISWAP_V3_FACTORY_ADDRESS, + SUSHISWAP_V3_SUPPORTED_CHAIN_IDS, + isWNativeSupported, +} from 'sushi/config' import { tryParseAmount } from 'sushi/currency' import { SWRConfig } from 'swr' import { useAccount } from 'wagmi' @@ -167,7 +170,7 @@ const _Add: FC = () => { => + !TESTNET_CHAIN_IDS.includes(c as (typeof TESTNET_CHAIN_IDS)[number]) && + !DISABLED_CHAIN_IDS.includes(c as (typeof DISABLED_CHAIN_IDS)[number]), +) + export const SUPPORTED_CHAIN_IDS = Array.from( new Set([ ...PREFERRED_CHAINID_ORDER.filter((el) => diff --git a/apps/web/src/lib/constants.ts b/apps/web/src/lib/constants.ts index 48d39c7360..744dbca7f8 100644 --- a/apps/web/src/lib/constants.ts +++ b/apps/web/src/lib/constants.ts @@ -1,7 +1,7 @@ import type { GetPoolsArgs } from '@sushiswap/client' import { Protocol } from '@sushiswap/database' -import { SUPPORTED_CHAIN_IDS } from '../config' +import { AMM_SUPPORTED_CHAIN_IDS } from '../config' export const L2_DEADLINE_FROM_NOW = BigInt(60) * BigInt(5) @@ -46,7 +46,7 @@ export const AVAILABLE_PROTOCOL_MAP: Partial = { // ! Has to be kept up to date with default filters // Else prefetching won't work export const defaultPoolsArgs: GetPoolsArgs = { - chainIds: SUPPORTED_CHAIN_IDS, + chainIds: AMM_SUPPORTED_CHAIN_IDS, orderBy: 'liquidityUSD', orderDir: 'desc', protocols: Object.values(Protocol), diff --git a/apps/web/src/lib/graph.ts b/apps/web/src/lib/graph.ts index 336b97e2b2..49aa029129 100644 --- a/apps/web/src/lib/graph.ts +++ b/apps/web/src/lib/graph.ts @@ -9,7 +9,7 @@ import { getSushiV2Pools, } from '@sushiswap/graph-client/sushi-v2' import { getSushiV3PoolsByTokenPair } from '@sushiswap/graph-client/sushi-v3' -import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { AMM_SUPPORTED_CHAIN_IDS } from 'src/config' import { SUSHISWAP_V2_SUPPORTED_CHAIN_IDS, SushiSwapV2ChainId, @@ -172,7 +172,7 @@ export const getBentoBoxTokens = async ( export const getCharts = async (query?: { networks: string }) => { const chainIds = query?.networks ? JSON.parse(query.networks) - : SUPPORTED_CHAIN_IDS + : AMM_SUPPORTED_CHAIN_IDS const { data: daySnapshots } = await getSushiDayDatas({ chainIds, diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx index b80dd32b74..e59a813f22 100644 --- a/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx +++ b/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx @@ -2,10 +2,10 @@ import { usePathname, useRouter, useSearchParams } from 'next/navigation' import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react' -import { SUPPORTED_CHAIN_IDS } from 'src/config' import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' import { ChainId } from 'sushi/chain' import { + SUSHISWAP_V3_SUPPORTED_CHAIN_IDS, SushiSwapV3ChainId, SushiSwapV3FeeAmount, currencyFromShortCurrencyName, @@ -98,7 +98,7 @@ const getChainIdFromUrl = ( export const ConcentratedLiquidityURLStateProvider: FC< ConcentratedLiquidityURLStateProvider -> = ({ children, supportedNetworks = SUPPORTED_CHAIN_IDS }) => { +> = ({ children, supportedNetworks = SUSHISWAP_V3_SUPPORTED_CHAIN_IDS }) => { const { push } = useRouter() const pathname = usePathname() const searchParams = useSearchParams()! diff --git a/apps/web/src/ui/pool/PoolsFiltersProvider.tsx b/apps/web/src/ui/pool/PoolsFiltersProvider.tsx index 3dde44c6f3..624fc28c32 100644 --- a/apps/web/src/ui/pool/PoolsFiltersProvider.tsx +++ b/apps/web/src/ui/pool/PoolsFiltersProvider.tsx @@ -11,7 +11,7 @@ import { useContext, useMemo, } from 'react' -import { SUPPORTED_CHAIN_IDS, isSupportedChainId } from 'src/config' +import { AMM_SUPPORTED_CHAIN_IDS, isSupportedChainId } from 'src/config' import { z } from 'zod' import { useTypedSearchParams } from '../../lib/hooks' @@ -34,11 +34,11 @@ export const poolFiltersSchema = z.object({ }), chainIds: z.coerce .string() - .default(SUPPORTED_CHAIN_IDS.join(',')) + .default(AMM_SUPPORTED_CHAIN_IDS.join(',')) .transform((chainIds) => chainIds !== null && chainIds !== ',' ? chainIds.split(',').map((chainId) => Number(chainId)) - : SUPPORTED_CHAIN_IDS, + : AMM_SUPPORTED_CHAIN_IDS, ) .transform((chainIds) => chainIds.filter(isSupportedChainId)), protocols: z @@ -68,7 +68,7 @@ export const PoolsFiltersProvider: FC = ({ value={useMemo( () => ({ tokenSymbols: tokenSymbols ? tokenSymbols : [], - chainIds: chainIds ? chainIds : SUPPORTED_CHAIN_IDS, + chainIds: chainIds ? chainIds : AMM_SUPPORTED_CHAIN_IDS, protocols: protocols ? protocols : POOL_TYPES, farmsOnly: farmsOnly ? farmsOnly : false, smartPoolsOnly: smartPoolsOnly ? smartPoolsOnly : false, diff --git a/apps/web/src/ui/pool/TableFiltersNetwork.tsx b/apps/web/src/ui/pool/TableFiltersNetwork.tsx index 07b4a120e5..b7a15f386d 100644 --- a/apps/web/src/ui/pool/TableFiltersNetwork.tsx +++ b/apps/web/src/ui/pool/TableFiltersNetwork.tsx @@ -19,13 +19,13 @@ import { import { CheckIcon } from '@sushiswap/ui/icons/CheckIcon' import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import React, { FC, useCallback, useState, useTransition } from 'react' -import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { AMM_SUPPORTED_CHAIN_IDS } from 'src/config' import { Chain } from 'sushi/chain' import { usePoolFilters, useSetPoolFilters } from './PoolsFiltersProvider' const isAllThenNone = (chainIds: number[]) => - SUPPORTED_CHAIN_IDS.length === chainIds.length ? [] : chainIds + AMM_SUPPORTED_CHAIN_IDS.length === chainIds.length ? [] : chainIds export const TableFiltersNetwork: FC = () => { const [pending, startTransition] = useTransition() @@ -82,7 +82,7 @@ export const TableFiltersNetwork: FC = () => { {values.length > 2 ? ( {values.length} selected ) : ( - SUPPORTED_CHAIN_IDS.filter((option) => + AMM_SUPPORTED_CHAIN_IDS.filter((option) => values.includes(option), ).map((option) => ( @@ -106,7 +106,7 @@ export const TableFiltersNetwork: FC = () => { /> No network found. - {SUPPORTED_CHAIN_IDS.map((chainId) => ( + {AMM_SUPPORTED_CHAIN_IDS.map((chainId) => ( { const setFilters = useSetPoolFilters() const networks = useMemo( - () => (SUPPORTED_CHAIN_IDS.length === chainIds.length ? [] : chainIds), + () => (AMM_SUPPORTED_CHAIN_IDS.length === chainIds.length ? [] : chainIds), [chainIds], ) const types = useMemo( From 48b612a34f4896ed1e0c477c740aea4aeabb8a46 Mon Sep 17 00:00:00 2001 From: 0xMasayoshi <0xMasayoshi@protonmail.com> Date: Wed, 14 Aug 2024 01:59:25 +0700 Subject: [PATCH 3/5] fix: cronos svg filename --- packages/ui/src/components/currency/Icon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/components/currency/Icon.tsx b/packages/ui/src/components/currency/Icon.tsx index 11bb2cb554..0f833957e6 100644 --- a/packages/ui/src/components/currency/Icon.tsx +++ b/packages/ui/src/components/currency/Icon.tsx @@ -30,7 +30,7 @@ const CoreLogo = 'core.svg' const IslmLogo = 'islm.svg' const FilecoinLogo = 'filecoin.svg' const ZetaLogo = 'zeta.svg' -const CroLogo = 'cro.svg' +const CroLogo = 'cronos.svg' const BitcoinLogo = 'bitcoin.svg' const LOGO: Record = { From d414252ef2d0797cd303b31d47afe58518ccd620 Mon Sep 17 00:00:00 2001 From: 0xMasayoshi <0xMasayoshi@protonmail.com> Date: Wed, 14 Aug 2024 02:05:37 +0700 Subject: [PATCH 4/5] chore: add cronos to NEW_CHAINS --- packages/ui/src/components/network-selector.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/ui/src/components/network-selector.tsx b/packages/ui/src/components/network-selector.tsx index 3b4d3dab86..82485c8fcc 100644 --- a/packages/ui/src/components/network-selector.tsx +++ b/packages/ui/src/components/network-selector.tsx @@ -52,6 +52,7 @@ export interface NetworkSelectorProps { } const NEW_CHAINS: number[] = [ + ChainId.CRONOS, ChainId.SKALE_EUROPA, ChainId.ROOTSTOCK, ] satisfies ChainId[] From a8af10a69bb13ef5538e9f0ff8619ccdc01a911d Mon Sep 17 00:00:00 2001 From: 0xMasayoshi <0xMasayoshi@protonmail.com> Date: Wed, 14 Aug 2024 16:53:58 +0700 Subject: [PATCH 5/5] fix: create position --- apps/web/src/app/(evm)/pool/hero.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/app/(evm)/pool/hero.tsx b/apps/web/src/app/(evm)/pool/hero.tsx index a1e0ecfda6..e0b5408950 100644 --- a/apps/web/src/app/(evm)/pool/hero.tsx +++ b/apps/web/src/app/(evm)/pool/hero.tsx @@ -57,7 +57,7 @@ export const Hero: FC = () => { ? `/pool/add?chainId=${chainId}` : isSushiSwapV2ChainId(chainId as SushiSwapV3ChainId) ? `/pool/add/v2/${chainId}` - : '' + : '/pool/add' } > I want to create a position