diff --git a/apps/storybook/package.json b/apps/storybook/package.json index d5a082b294..b8161d4ae1 100644 --- a/apps/storybook/package.json +++ b/apps/storybook/package.json @@ -19,7 +19,7 @@ "class-variance-authority": "0.7.0", "react": "19.0.0", "react-dom": "19.0.0", - "sushi": "4.1.23" + "sushi": "5.0.4" }, "devDependencies": { "@storybook/addon-a11y": "8.4.7", diff --git a/apps/web/package.json b/apps/web/package.json index aa3d957c0c..6900326da2 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -88,7 +88,7 @@ "react-window": "1.8.7", "sharp": "^0.33.5", "strapi-sdk-js": "2.3.3", - "sushi": "4.1.23", + "sushi": "5.0.4", "swr": "2.1.5", "tiny-invariant": "1.3.1", "tronweb": "5.3.2", diff --git a/apps/web/src/app/(landing)/components/Search.tsx b/apps/web/src/app/(landing)/components/Search.tsx index b0a35b61ed..65f7f28ab6 100644 --- a/apps/web/src/app/(landing)/components/Search.tsx +++ b/apps/web/src/app/(landing)/components/Search.tsx @@ -9,7 +9,7 @@ import { Currency } from '@sushiswap/ui' import { SkeletonCircle, SkeletonText } from '@sushiswap/ui' import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import { FC, useEffect, useMemo, useRef, useState } from 'react' -import chains, { ChainId, chainShortName } from 'sushi/chain' +import { EvmChainId, evmChainShortName, evmChains } from 'sushi/chain' import { Native, Token, Type } from 'sushi/currency' import { type TokenList } from 'sushi/token-list' import { isAddress } from 'viem' @@ -20,28 +20,28 @@ import { SUPPORTED_CHAIN_IDS } from '../../../config' const EXAMPLE_CURRENCIES = [ new Token({ - chainId: ChainId.ETHEREUM, + chainId: EvmChainId.ETHEREUM, address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'ETH', name: 'Ether', }), new Token({ - chainId: ChainId.ETHEREUM, + chainId: EvmChainId.ETHEREUM, address: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', decimals: 18, symbol: 'WBTC', name: 'Wrapped BTC', }), new Token({ - chainId: ChainId.ETHEREUM, + chainId: EvmChainId.ETHEREUM, address: '0xdac17f958d2ee523a2206206994597c13d831ec7', decimals: 18, symbol: 'USDT', name: 'Tether USD', }), new Token({ - chainId: ChainId.BSC, + chainId: EvmChainId.BSC, address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', decimals: 18, symbol: 'BNB', @@ -52,7 +52,7 @@ const EXAMPLE_CURRENCIES = [ export const Search: FC = () => { const ref = useRef(null) const [query, setQuery] = useState('') - const [chainId, setChainId] = useState(ChainId.ETHEREUM) + const [chainId, setChainId] = useState(EvmChainId.ETHEREUM) const debouncedQuery = useDebounce(query, 500) const [selectNetwork, setSelectNetwork] = useState(false) const [open, setOpen] = useState(false) @@ -147,7 +147,7 @@ export const Search: FC = () => { onKeyDown={() => setSelectNetwork((prev) => !prev)} className="font-semibold text-sm flex items-center gap-1 py-2 pl-3 pr-2 rounded-lg cursor-pointer bg-neutral-700 hover:bg-neutral-600 text-neutral-300 hover:text-neutral-200" > - {chainShortName[chainId].toUpperCase()}{' '} + {evmChainShortName[chainId].toUpperCase()}{' '}

@@ -188,7 +188,7 @@ export const Search: FC = () => { address: web3Token.address, name: web3Token.name, symbol: web3Token.symbol, - chainId: ChainId.ETHEREUM, + chainId: EvmChainId.ETHEREUM, decimals: web3Token.decimals, }) } @@ -206,7 +206,7 @@ export const Search: FC = () => { address, name, symbol, - chainId, + chainId: chainId as EvmChainId, decimals, }) } @@ -261,7 +261,7 @@ const Row: FC<{ currency: Type; onClick?(): void; isNetwork?: boolean }> = ({

- {isNetwork ? chains[currency.chainId].name : currency.name} + {isNetwork ? evmChains[currency.chainId].name : currency.name}

{currency.symbol} diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/hero.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/hero.tsx index 7cc7a2defa..19120ab0b3 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/hero.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/hero.tsx @@ -11,14 +11,14 @@ import { SelectIcon, } from '@sushiswap/ui' import { FC } from 'react' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChainId } from 'sushi/chain' import { SushiSwapV3ChainId, isSushiSwapV2ChainId, isSushiSwapV3ChainId, } from 'sushi/config' -export const Hero: FC<{ chainId: ChainId }> = ({ chainId }) => { +export const Hero: FC<{ chainId: EvmChainId }> = ({ chainId }) => { return (

Manage Liquidity Positions @@ -41,7 +41,7 @@ export const Hero: FC<{ chainId: ChainId }> = ({ chainId }) => { ? `/${ChainKey[chainId]}/pool/v3/add` : isSushiSwapV2ChainId(chainId as SushiSwapV3ChainId) ? `/${ChainKey[chainId]}/pool/v2/add` - : `/${ChainKey[ChainId.ETHEREUM]}/pool/v3/add` + : `/${ChainKey[EvmChainId.ETHEREUM]}/pool/v3/add` } > I want to create a position @@ -56,9 +56,7 @@ export const Hero: FC<{ chainId: ChainId }> = ({ chainId }) => { = ({ chainId }) => {
V3 Position - {isSushiSwapV3ChainId(chainId as SushiSwapV3ChainId) + {isSushiSwapV3ChainId(chainId) ? 'New 🔥' : 'Unavailable'} @@ -78,7 +76,7 @@ export const Hero: FC<{ chainId: ChainId }> = ({ chainId }) => {

- {isSushiSwapV2ChainId(chainId as ChainId) ? ( + {isSushiSwapV2ChainId(chainId) ? ( }) { const params = await props.params - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId if (!isSushiSwapV2ChainId(chainId)) { return notFound() diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/pool/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/pool/page.tsx index 26a5ac133e..a57ea54795 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/pool/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/(positions)/pool/page.tsx @@ -8,14 +8,14 @@ import { PositionsTab } from 'src/ui/pool/PositionsTab' import { TableFiltersNetwork } from 'src/ui/pool/TableFiltersNetwork' import { TableFiltersResetButton } from 'src/ui/pool/TableFiltersResetButton' import { TableFiltersSearchToken } from 'src/ui/pool/TableFiltersSearchToken' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapChainId } from 'sushi/config' export default function MyPositionsPage(props: { params: Promise<{ chainId: string }> }) { const params = use(props.params) - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId if (!isSushiSwapChainId(chainId)) { return notFound() diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/layout.tsx index b10266f8cc..45a52e7a59 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/layout.tsx @@ -1,7 +1,7 @@ import { Metadata } from 'next' import { notFound } from 'next/navigation' import { XSWAP_SUPPORTED_CHAIN_IDS, isXSwapSupportedChainId } from 'src/config' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { SidebarContainer } from '~evm/_common/ui/sidebar' import { Providers } from './providers' @@ -19,7 +19,7 @@ export default async function CrossChainSwapLayout(props: { const { children } = props - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId if (!isXSwapSupportedChainId(chainId)) { return notFound() diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/providers.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/providers.tsx index 3b3c8f1999..4320d225d0 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/providers.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/(trade)/cross-chain-swap/providers.tsx @@ -2,12 +2,12 @@ import { getCrossChainSwapEdgeConfig } from './get-cross-chain-swap-edge-config' import { EdgeProvider } from 'src/providers/edge-config-provider' import { DerivedstateCrossChainSwapProvider } from 'src/ui/swap/cross-chain/derivedstate-cross-chain-swap-provider' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' export async function Providers({ children, chainId, -}: { children: React.ReactNode; chainId: ChainId }) { +}: { children: React.ReactNode; chainId: EvmChainId }) { const config = await getCrossChainSwapEdgeConfig() return ( diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/layout.tsx index 636b20fc13..ec2dadcb43 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/layout.tsx @@ -2,7 +2,7 @@ import { Container, typographyVariants } from '@sushiswap/ui' import { Metadata } from 'next' import { notFound } from 'next/navigation' import { BackButton } from 'src/ui/pool/BackButton' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isMerklChainId } from 'sushi/config' export const metadata: Metadata = { @@ -19,7 +19,7 @@ export default async function Layout(props: { const { children } = props - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId if (!isMerklChainId(chainId)) { return notFound() } diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/page.tsx index 063ea062a2..0e01944eaf 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/incentivize/page.tsx @@ -50,7 +50,7 @@ import { import { SelectFeeConcentratedWidget } from 'src/ui/pool/SelectFeeConcentratedWidget' import { SelectNetworkWidget } from 'src/ui/pool/SelectNetworkWidget' import { SelectTokensWidget } from 'src/ui/pool/SelectTokensWidget' -import { Chain, ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChain, EvmChainId } from 'sushi/chain' import { MERKL_SUPPORTED_CHAIN_IDS, SushiSwapV3ChainId, @@ -66,10 +66,10 @@ const APPROVE_TAG = 'approve-incentivize' export default function Page(props: { params: Promise<{ chainId: string }> }) { const params = use(props.params) - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId return ( @@ -583,7 +583,10 @@ const Incentivize = withCheckerRoot(() => { flex title="Network" > - {Chain.from(pool.chainId)?.name} + { + EvmChain.from(pool.chainId) + ?.name + } ) : null} {feeAmount && ( diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/layout.tsx index a238b6ff5b..35eaef386c 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/layout.tsx @@ -5,7 +5,7 @@ import { headers } from 'next/headers' import { notFound } from 'next/navigation' import React from 'react' import { PoolHeader } from 'src/ui/pool/PoolHeader' -import { ChainId, ChainKey } from 'sushi' +import { ChainKey, EvmChainId } from 'sushi' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -22,7 +22,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/page.tsx index 4c90eaee26..992c51cb86 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(landing)/page.tsx @@ -3,7 +3,7 @@ import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' import { PoolPageV2 } from 'src/ui/pool/PoolPageV2' -import type { ChainId } from 'sushi' +import type { EvmChainId } from 'sushi' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -13,7 +13,7 @@ export default async function PoolPage(props: { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/add/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/add/page.tsx index 0d996cf38a..45e1e96cf8 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/add/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/add/page.tsx @@ -4,7 +4,7 @@ import { notFound } from 'next/navigation' import { PoolPositionProvider } from 'src/ui/pool' import { ManageV2LiquidityCard } from 'src/ui/pool/ManageV2LiquidityCard' import { PoolPosition } from 'src/ui/pool/PoolPosition' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -13,7 +13,7 @@ export default async function ManageV2PoolPage(props: { }) { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/layout.tsx index 004b52ef25..b91a9d947b 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/layout.tsx @@ -5,7 +5,7 @@ import { headers } from 'next/headers' import { notFound } from 'next/navigation' import React from 'react' import { PoolHeader } from 'src/ui/pool/PoolHeader' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChainId } from 'sushi/chain' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -18,7 +18,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/remove/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/remove/page.tsx index ed0e2d2425..fe3a5068bf 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/remove/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/(manage)/remove/page.tsx @@ -4,7 +4,7 @@ import { notFound } from 'next/navigation' import { PoolPositionProvider } from 'src/ui/pool' import { ManageV2LiquidityCard } from 'src/ui/pool/ManageV2LiquidityCard' import { PoolPosition } from 'src/ui/pool/PoolPosition' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -13,7 +13,7 @@ export default async function ManageV2PoolPage(props: { }) { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/layout.tsx index d19a91797e..91436c9855 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/layout.tsx @@ -2,7 +2,7 @@ import { getV2Pool } from '@sushiswap/graph-client/data-api' import { Metadata } from 'next' import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' -import { ChainId } from 'sushi' +import { EvmChainId } from 'sushi' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -19,7 +19,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/layout.tsx index 9eed934e30..e4cc134e17 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/layout.tsx @@ -5,7 +5,7 @@ import { headers } from 'next/headers' import { notFound } from 'next/navigation' import React from 'react' import { PoolHeader } from 'src/ui/pool/PoolHeader' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChainId } from 'sushi/chain' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -18,7 +18,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/page.tsx index 2530784254..fa220e2552 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/[address]/migrate/page.tsx @@ -4,7 +4,7 @@ import { notFound } from 'next/navigation' import { PoolPositionProvider } from 'src/ui/pool' import { ConcentratedLiquidityProvider } from 'src/ui/pool/ConcentratedLiquidityProvider' import { MigrateTab } from 'src/ui/pool/MigrateTab' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV2ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -13,7 +13,7 @@ export default async function MigrateV2PoolPage(props: { }) { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV2ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/add/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/add/page.tsx index 2f4ff11477..ecf878fba2 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/add/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/add/page.tsx @@ -42,7 +42,7 @@ import { SelectNetworkWidget } from 'src/ui/pool/SelectNetworkWidget' import { SelectTokensWidget } from 'src/ui/pool/SelectTokensWidget' import { ToggleZapCard } from 'src/ui/pool/ToggleZapCard' import { ZapInfoCard } from 'src/ui/pool/ZapInfoCard' -import { ChainId, ChainKey, TESTNET_CHAIN_IDS } from 'sushi/chain' +import { EVM_TESTNET_CHAIN_IDS, EvmChainId, EvmChainKey } from 'sushi/chain' import { SUSHISWAP_V2_ROUTER_ADDRESS, SUSHISWAP_V2_SUPPORTED_CHAIN_IDS, @@ -66,7 +66,7 @@ import { useRefetchBalances } from '~evm/_common/ui/balance-provider/use-refetch export default function Page(props: { params: Promise<{ chainId: string }> }) { const params = use(props.params) - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId if (!isSushiSwapV2ChainId(chainId)) { return notFound() } @@ -92,8 +92,8 @@ export default function Page(props: { params: Promise<{ chainId: string }> }) { () => SUSHISWAP_V2_SUPPORTED_CHAIN_IDS.filter( (chainId) => - !TESTNET_CHAIN_IDS.includes( - chainId as (typeof TESTNET_CHAIN_IDS)[number], + !EVM_TESTNET_CHAIN_IDS.includes( + chainId as (typeof EVM_TESTNET_CHAIN_IDS)[number], ) && !DISABLED_CHAIN_IDS.includes( chainId as (typeof DISABLED_CHAIN_IDS)[number], @@ -179,7 +179,7 @@ export default function Page(props: { params: Promise<{ chainId: string }> }) { selectedNetwork={chainId} onSelect={(chainId) => { if (!isSushiSwapV2ChainId(chainId)) return - router.push(`/${ChainKey[chainId]}/pool/v2/add`) + router.push(`/${EvmChainKey[chainId]}/pool/v2/add`) }} /> }) { } interface ZapWidgetProps { - chainId: ChainId + chainId: EvmChainId pool: SushiSwapV2Pool | null poolState: SushiSwapV2PoolState title: ReactNode @@ -489,7 +489,7 @@ const _ZapWidget: FC = ({ } interface AddLiquidityWidgetProps { - chainId: ChainId + chainId: EvmChainId pool: SushiSwapV2Pool | null poolState: SushiSwapV2PoolState title: ReactNode diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/layout.tsx index c8ca996210..4d488ac26b 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v2/layout.tsx @@ -1,5 +1,5 @@ import { notFound } from 'next/navigation' -import { ChainId } from 'sushi/chain' +import type { EvmChainId } from 'sushi/chain' import { isSushiSwapV2ChainId } from 'sushi/config' export default async function Layout(props: { @@ -10,7 +10,7 @@ export default async function Layout(props: { const { children } = props - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId if (!isSushiSwapV2ChainId(chainId)) { return notFound() } diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/layout.tsx index 3655f7d1ea..75b1f29e29 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/layout.tsx @@ -4,7 +4,7 @@ import { unstable_cache } from 'next/cache' import { headers } from 'next/headers' import { notFound } from 'next/navigation' import { PoolHeader } from 'src/ui/pool/PoolHeader' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -21,7 +21,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/page.tsx index 8c330bfcf1..1c3fc7c27e 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(landing)/page.tsx @@ -3,7 +3,7 @@ import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' import { PoolPageV3 } from 'src/ui/pool/PoolPageV3' -import type { ChainId } from 'sushi' +import type { EvmChainId } from 'sushi' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -12,7 +12,7 @@ export default async function PoolPage(props: { }) { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/create/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/create/page.tsx index 1acfb0048d..7bda8e164a 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/create/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/create/page.tsx @@ -2,7 +2,7 @@ import { notFound } from 'next/navigation' import React from 'react' import { ConcentratedLiquidityProvider } from 'src/ui/pool/ConcentratedLiquidityProvider' import { NewPosition } from 'src/ui/pool/NewPosition' -import { type ChainId } from 'sushi' +import type { EvmChainId } from 'sushi' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -11,7 +11,7 @@ export default async function PositionsCreatePage(props: { }) { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/layout.tsx index 524cf67b02..4591df29eb 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/layout.tsx @@ -5,7 +5,7 @@ import { headers } from 'next/headers' import { notFound } from 'next/navigation' import React from 'react' import { PoolHeader } from 'src/ui/pool/PoolHeader' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -18,7 +18,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/positions/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/positions/page.tsx index 2d0141dd1f..0ea99c51f9 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/positions/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/(manage)/positions/page.tsx @@ -2,7 +2,7 @@ import { V3Pool, getV3Pool } from '@sushiswap/graph-client/data-api' import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' import { PoolsFiltersProvider } from 'src/ui/pool' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' import { ManageV3PoolPositionsTable } from './table' @@ -12,7 +12,7 @@ export default async function ManageV3PoolPage(props: { }) { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/layout.tsx index 61e3f64a8a..a3685b5b2b 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/layout.tsx @@ -1,7 +1,7 @@ import { getV3Pool } from '@sushiswap/graph-client/data-api' import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -18,7 +18,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/(overview)/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/(overview)/page.tsx index bfdccb773a..c024269c51 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/(overview)/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/(overview)/page.tsx @@ -6,7 +6,7 @@ import { import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' import { SteerCarousel } from 'src/ui/pool/Steer/SteerCarousel' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -15,7 +15,7 @@ export default async function VaultOverviewPage(props: { }) { const params = await props.params const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/layout.tsx index fc77252259..98fa495490 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/layout.tsx @@ -6,7 +6,7 @@ import { import { Container } from '@sushiswap/ui' import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -18,7 +18,7 @@ export default async function Layout(props: { const { children } = props - const chainId = Number(params.chainId) as ChainId + const chainId = Number(params.chainId) as EvmChainId const vaultAddress = params.vault if ( diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/page.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/page.tsx index 94628bfd08..f0c1eeb890 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/page.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/[vault]/page.tsx @@ -10,10 +10,11 @@ import formatDistanceStrict from 'date-fns/formatDistanceStrict' import formatDistanceToNow from 'date-fns/formatDistanceToNow' import { unstable_cache } from 'next/cache' import { notFound } from 'next/navigation' +import { publicClientConfig } from 'src/lib/wagmi/config/viem' import { SteerStrategyGeneric } from 'src/ui/pool/Steer/SteerStrategies' import { SteerBaseStrategy } from 'src/ui/pool/Steer/SteerStrategies/SteerBaseStrategy' -import type { ChainId } from 'sushi' -import { isSushiSwapV3ChainId, publicClientConfig } from 'sushi/config' +import type { EvmChainId } from 'sushi' +import { isSushiSwapV3ChainId } from 'sushi/config' import { Token } from 'sushi/currency' import { formatNumber } from 'sushi/format' import { tickToPrice } from 'sushi/pool/sushiswap-v3' @@ -88,7 +89,7 @@ export default async function SteerVaultPage(props: { params: Promise<{ chainId: string; vault: string; address: string }> }) { const params = await props.params - const chainId = Number(params.chainId) as ChainId + const chainId = Number(params.chainId) as EvmChainId const vaultAddress = params.vault const poolAddress = params.address diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/layout.tsx index 47916abd94..0aeea08a16 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/[address]/smart/layout.tsx @@ -4,7 +4,7 @@ import { unstable_cache } from 'next/cache' import { headers } from 'next/headers' import { notFound } from 'next/navigation' import { PoolHeader } from 'src/ui/pool/PoolHeader' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { isAddress } from 'viem' @@ -17,7 +17,7 @@ export default async function Layout(props: { const { children } = props const { chainId: _chainId, address } = params - const chainId = +_chainId as ChainId + const chainId = +_chainId as EvmChainId if ( !isSushiSwapV3ChainId(chainId) || diff --git a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/layout.tsx b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/layout.tsx index e1ad550b5f..9e38b53ef6 100644 --- a/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/layout.tsx +++ b/apps/web/src/app/(networks)/(evm)/[chainId]/pool/v3/layout.tsx @@ -1,5 +1,5 @@ import { notFound } from 'next/navigation' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' export default async function Layout(props: { @@ -10,7 +10,7 @@ export default async function Layout(props: { const { children } = props - const chainId = +params.chainId as ChainId + const chainId = +params.chainId as EvmChainId if (!isSushiSwapV3ChainId(chainId)) { return notFound() } diff --git a/apps/web/src/app/(networks)/(evm)/_common/header-elements.tsx b/apps/web/src/app/(networks)/(evm)/_common/header-elements.tsx index 8bf1518b1a..5f8b3c8eb6 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/header-elements.tsx +++ b/apps/web/src/app/(networks)/(evm)/_common/header-elements.tsx @@ -12,7 +12,7 @@ import { EXPLORE_NAVIGATION_LINKS, // MORE_NAVIGATION_LINKS, } from 'src/app/_common/header-elements' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainId, ChainKey, EvmChainId } from 'sushi/chain' import { isAggregatorOnlyChainId } from 'sushi/config' interface HeaderElements { @@ -66,7 +66,7 @@ export const headerElements = ({ }, ] as const) : []), - ...(!chainId || !isAggregatorOnlyChainId(chainId) + ...(!chainId || !isAggregatorOnlyChainId(chainId as EvmChainId) ? ([ { title: 'Pool', diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/balance-provider.tsx b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/balance-provider.tsx index dce4b0fa52..9ce8e4ef7a 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/balance-provider.tsx +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/balance-provider.tsx @@ -12,7 +12,7 @@ import { import ms from 'ms' import { NativeAddress } from 'src/lib/constants' import { publicWagmiConfig } from 'src/lib/wagmi/config/public' -import { type ChainId, LowercaseMap } from 'sushi' +import { type EvmChainId, LowercaseMap } from 'sushi' import { erc20Abi_balanceOf, multicall3Abi_getEthBalance } from 'sushi/abi' import { Address } from 'viem' import { multicall } from 'viem/actions' @@ -27,7 +27,7 @@ import { } from './types' import { getTokenIds, isBalanceStale } from './utils' -function getOrCreateChain(state: ProviderState, chainId: ChainId) { +function getOrCreateChain(state: ProviderState, chainId: EvmChainId) { let chain = state.chains.get(chainId) if (!chain) { @@ -143,7 +143,7 @@ export function BalanceProvider({ children }: BalanceProviderContextProps) { }, []) const refetchChain = useCallback( - async (chainId: ChainId) => { + async (chainId: EvmChainId) => { const chain = getOrCreateChain(state, chainId) if (chain.isFetching || !state.account) return chain.isFetching = true @@ -242,7 +242,7 @@ export function BalanceProvider({ children }: BalanceProviderContextProps) { }, [updateAll]) const updateIfStaleOrMissing = useCallback( - (chainId: ChainId) => { + (chainId: EvmChainId) => { const chain = state.chains.get(chainId) if (!chain) return diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/types.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/types.ts index d535b3dea4..097ed9384e 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/types.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/types.ts @@ -1,4 +1,4 @@ -import type { ChainId, ID, LowercaseMap } from 'sushi' +import type { EvmChainId, ID, LowercaseMap } from 'sushi' import { Address } from 'viem' export interface Balance { @@ -9,7 +9,7 @@ export interface Balance { type ListenerCount = number export interface ProviderChainState { - chainId: ChainId + chainId: EvmChainId isFetching: boolean @@ -19,16 +19,16 @@ export interface ProviderChainState { export interface ProviderState { account: Address | undefined - chains: Map + chains: Map } -export type TokenId = ID | { address: Address; chainId: ChainId } +export type TokenId = ID | { address: Address; chainId: EvmChainId } export interface ProviderMutations { incrementToken: (tokenId: TokenId | TokenId[]) => void decrementToken: (tokenId: TokenId | TokenId[]) => void - refetchChain: (chainId: ChainId) => void + refetchChain: (chainId: EvmChainId) => void } export interface Provider { diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balance.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balance.ts index a34341ae29..fab9b06bd8 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balance.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balance.ts @@ -1,18 +1,18 @@ import { useMemo } from 'react' -import type { ChainId } from 'sushi' +import type { EvmChainId } from 'sushi' import { nativeAddress } from 'sushi/config' import { Amount, Type } from 'sushi/currency' import type { Address } from 'viem' import { useBalances } from './use-balances' -type Args = [Type | undefined] | [ChainId | undefined, Address | undefined] +type Args = [Type | undefined] | [EvmChainId | undefined, Address | undefined] type Return = Omit, 'data'> & { data: bigint | undefined } export function useBalance(currency: Type | undefined): Return export function useBalance( - chainId: ChainId | undefined, + chainId: EvmChainId | undefined, tokenAddress: Address | undefined, ): Return diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balances.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balances.ts index e9abe8233b..f600d4ad3d 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balances.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/balance-provider/use-balances.ts @@ -1,5 +1,5 @@ import { useEffect, useMemo } from 'react' -import { ChainId, ID, LowercaseMap } from 'sushi' +import { EvmChainId, ID, LowercaseMap } from 'sushi' import { nativeAddress } from 'sushi/config' import { Amount, Type } from 'sushi/currency' import { Address } from 'viem' @@ -7,7 +7,7 @@ import { useBalanceProvider } from './balance-provider' import { isBalanceStaleWhileRevalidate } from './utils' export function useBalances( - chainId: ChainId | undefined, + chainId: EvmChainId | undefined, tokenAddresses: Address[] | undefined, ) { const { state, mutate } = useBalanceProvider() @@ -91,7 +91,7 @@ export function useBalances( } export function useAmountBalances( - chainId: ChainId | undefined, + chainId: EvmChainId | undefined, _currencies: (Type | undefined)[] | undefined, ) { const currencies = useMemo(() => { diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/types.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/types.ts index defc641d5b..0508e42486 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/types.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/types.ts @@ -1,8 +1,8 @@ -import type { ChainId } from 'sushi' +import type { EvmChainId } from 'sushi' import { PriceWorkerReceiveMessageChainState } from '../price-worker/types' export interface ProviderChainState { - chainId: ChainId + chainId: EvmChainId priceMap?: Map @@ -14,13 +14,13 @@ export interface ProviderChainState { } export interface ProviderState { - chains: Map + chains: Map ready: boolean } export interface ProviderMutations { - incrementChainId: (chainId: ChainId) => void - decrementChainId: (chainId: ChainId) => void + incrementChainId: (chainId: EvmChainId) => void + decrementChainId: (chainId: EvmChainId) => void } export interface Provider { diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-price.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-price.ts index 19c47060d5..f42b0f8fbf 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-price.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-price.ts @@ -1,7 +1,7 @@ 'use client' import { useMemo } from 'react' -import type { ChainId } from 'sushi/chain' +import type { EvmChainId } from 'sushi/chain' import type { Address } from 'viem' import { usePrices } from './use-prices' @@ -10,7 +10,7 @@ export function usePrice({ address, enabled: _enabled = true, }: { - chainId: ChainId | undefined + chainId: EvmChainId | undefined address: Address | undefined enabled?: boolean }) { diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-prices.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-prices.ts index e06d0a50b1..944a331176 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-prices.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-provider/use-prices.ts @@ -3,7 +3,7 @@ import { useEffect, useMemo } from 'react' import { type Address, - type ChainId, + type EvmChainId, Fraction, withoutScientificNotation, } from 'sushi' @@ -19,7 +19,7 @@ export type PriceMap = { export function usePrices({ chainId, enabled = true, -}: { chainId: ChainId | undefined; enabled?: boolean }) { +}: { chainId: EvmChainId | undefined; enabled?: boolean }) { // Important to use state, not state.chains directly, as the reference to state.chains won't be changing and the component won't re-render // It's not best practice, but it's controlled here in the hook and not exposed const { state, mutate } = usePriceProvider() diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/price-worker.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/price-worker.ts index 412d1041ab..2e0a08677b 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/price-worker.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/price-worker.ts @@ -1,5 +1,5 @@ -import { ChainId } from 'sushi' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from 'src/lib/constants' +import { EvmChainId } from 'sushi' import { UPDATE_INTERVAL } from '../config' import { PriceWorkerPostMessage, @@ -11,8 +11,8 @@ import { { const state = { - chains: new Map(), - intervals: new Map(), + chains: new Map(), + intervals: new Map(), enabled: true, canUseSharedArrayBuffer: false, } @@ -77,7 +77,7 @@ import { } } - function incrementChainId(chainId: ChainId) { + function incrementChainId(chainId: EvmChainId) { const chainState = state.chains.get(chainId) if (chainState) { chainState.listenerCount++ @@ -108,7 +108,7 @@ import { return true } - function decrementChainId(chainId: ChainId) { + function decrementChainId(chainId: EvmChainId) { const chainState = state.chains.get(chainId) if (chainState && chainState.listenerCount > 0) { chainState.listenerCount-- @@ -144,7 +144,7 @@ import { } } - async function updateChainId(chainId: ChainId) { + async function updateChainId(chainId: EvmChainId) { const chainState = state.chains.get(chainId) if (!chainState) { return diff --git a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/types.ts b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/types.ts index 5612494e13..3ac55b149d 100644 --- a/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/types.ts +++ b/apps/web/src/app/(networks)/(evm)/_common/ui/price-provider/price-worker/types.ts @@ -1,4 +1,4 @@ -import type { ChainId } from 'sushi' +import type { EvmChainId } from 'sushi' export enum PriceWorkerPostMessageType { Initialize = 'Initialize', @@ -14,17 +14,17 @@ type Initialize = { } type IncrementChainId = { - chainId: ChainId + chainId: EvmChainId type: PriceWorkerPostMessageType.IncrementChainId } type DecrementChainId = { - chainId: ChainId + chainId: EvmChainId type: PriceWorkerPostMessageType.DecrementChainId } type RefetchChainId = { - chainId: ChainId + chainId: EvmChainId type: PriceWorkerPostMessageType.RefetchChainId } @@ -47,7 +47,7 @@ export enum PriceWorkerReceiveMessageType { export type PriceWorkerReceiveMessageChainState = { type: PriceWorkerReceiveMessageType.ChainState payload: Partial> & { - chainId: ChainId + chainId: EvmChainId } } @@ -58,7 +58,7 @@ export type PriceWorker = (typeof Worker)['prototype'] & { } export interface WorkerChainState { - chainId: ChainId + chainId: EvmChainId listenerCount: number priceMap: Map diff --git a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getFees.ts b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getFees.ts index 0c751cb189..61017fc9f3 100644 --- a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getFees.ts +++ b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getFees.ts @@ -1,8 +1,5 @@ -import { - SUSHISWAP_V3_POSTIION_MANAGER, - SushiSwapV3ChainId, - publicClientConfig, -} from 'sushi/config' +import { publicClientConfig } from 'src/lib/wagmi/config/viem' +import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId } from 'sushi/config' import { Address, createClient } from 'viem' import { simulateContract } from 'viem/actions' diff --git a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getOwner.ts b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getOwner.ts index 510103b072..bc85fd0ffe 100644 --- a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getOwner.ts +++ b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getOwner.ts @@ -1,8 +1,5 @@ -import { - SUSHISWAP_V3_POSTIION_MANAGER, - SushiSwapV3ChainId, - publicClientConfig, -} from 'sushi/config' +import { publicClientConfig } from 'src/lib/wagmi/config/viem' +import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId } from 'sushi/config' import { createClient } from 'viem' import { readContract } from 'viem/actions' diff --git a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPool.ts b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPool.ts index 5d76d43993..18ba3b30a6 100644 --- a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPool.ts +++ b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPool.ts @@ -1,9 +1,9 @@ +import { publicClientConfig } from 'src/lib/wagmi/config/viem' import { SushiSwapV3Pool, computeSushiSwapV3PoolAddress } from 'sushi' import { SUSHISWAP_V3_FACTORY_ADDRESS, SushiSwapV3ChainId, SushiSwapV3FeeAmount, - publicClientConfig, } from 'sushi/config' import { Token } from 'sushi/currency' import { Address, createClient } from 'viem' diff --git a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPosition.ts b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPosition.ts index 94cab29d77..583fe129de 100644 --- a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPosition.ts +++ b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/getPosition.ts @@ -2,11 +2,11 @@ import { SUSHISWAP_V3_FACTORY_ADDRESS, SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId, - publicClientConfig, } from 'sushi/config' import { createClient } from 'viem' import { readContract } from 'viem/actions' +import { publicClientConfig } from 'src/lib/wagmi/config/viem' import { computeSushiSwapV3PoolAddress } from 'sushi' import { getFees } from './getFees' import { getOwner } from './getOwner' diff --git a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/route.ts b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/route.ts index c24ed944bd..d6975a5045 100644 --- a/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/route.ts +++ b/apps/web/src/app/(networks)/(evm)/api/stable/v1/position-info/route.ts @@ -4,7 +4,7 @@ import { ipAddress } from '@vercel/functions' import { NextRequest, NextResponse } from 'next/server' import { rateLimit } from 'src/lib/rate-limit' import { Position, formatPercent } from 'sushi' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { SushiSwapV3ChainId, SushiSwapV3FeeAmount, @@ -20,7 +20,7 @@ import { getPosition } from './getPosition' async function getPrices({ chainId, }: { - chainId: ChainId + chainId: EvmChainId }): Promise> { return fetch(`https://api.sushi.com/price/v1/${chainId}`, { next: { revalidate: 0 }, @@ -35,7 +35,7 @@ async function getPrices({ const schema = z.object({ chainId: z.coerce .number() - .refine((chainId) => isSushiSwapV3ChainId(chainId as ChainId), { + .refine((chainId) => isSushiSwapV3ChainId(chainId as EvmChainId), { message: 'Invalid chainId', }) .transform((chainId) => { diff --git a/apps/web/src/app/_common/header-elements.ts b/apps/web/src/app/_common/header-elements.ts index a8fc74c042..b84a0bcf8f 100644 --- a/apps/web/src/app/_common/header-elements.ts +++ b/apps/web/src/app/_common/header-elements.ts @@ -4,7 +4,7 @@ import { type NavigationElementDropdown, NavigationElementType, } from '@sushiswap/ui' -import { ChainId, ChainKey, isChainId } from 'sushi' +import { ChainId, ChainKey, EvmChainId, isChainId } from 'sushi' import { isAggregatorOnlyChainId } from 'sushi/config' export const EXPLORE_NAVIGATION_LINKS = ( @@ -24,7 +24,7 @@ export const EXPLORE_NAVIGATION_LINKS = ( }, ] as const) : []), - ...(!chainId || !isAggregatorOnlyChainId(chainId) + ...(!chainId || !isAggregatorOnlyChainId(chainId as EvmChainId) ? ([ { title: 'Pool', diff --git a/apps/web/src/app/_common/mava-script.tsx b/apps/web/src/app/_common/mava-script.tsx index ea8a45baae..4628294b1f 100644 --- a/apps/web/src/app/_common/mava-script.tsx +++ b/apps/web/src/app/_common/mava-script.tsx @@ -11,7 +11,7 @@ export function MavaScript() { widget-version="v2" id="MavaWebChat" enable-sdk="false" - data-token="13a77dff2927f04aff517c51da8b35e921d69ecd86b5879ce2a7e747c71a646b" + data-token="0126227a207d845923cd0e316108e824126a288d0beb5c378d2ed512f1e9a878" /> ) } diff --git a/apps/web/src/app/tokenlist-request/approved/page.tsx b/apps/web/src/app/tokenlist-request/approved/page.tsx index bb6c3f424b..439867e88a 100644 --- a/apps/web/src/app/tokenlist-request/approved/page.tsx +++ b/apps/web/src/app/tokenlist-request/approved/page.tsx @@ -17,7 +17,7 @@ import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import { ColumnDef, SortingState, TableState } from '@tanstack/react-table' import React, { useMemo, useState } from 'react' import { useApprovedCommunityTokens } from 'src/lib/hooks' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { shortenAddress } from 'sushi/format' import { NavigationItems } from '../navigation-items' @@ -26,7 +26,7 @@ const COLUMNS: ColumnDef[] = [ id: 'chain', header: 'Network', accessorFn: (row) => row.chainId, - cell: (props) => Chain.from(props.row.original.chainId)?.name, + cell: (props) => EvmChain.from(props.row.original.chainId)?.name, meta: { skeleton: }, }, { @@ -89,7 +89,7 @@ const COLUMNS: ColumnDef[] = [ {props.row.original.address} diff --git a/apps/web/src/app/tokenlist-request/page.tsx b/apps/web/src/app/tokenlist-request/page.tsx index 13311b93ae..058a849846 100644 --- a/apps/web/src/app/tokenlist-request/page.tsx +++ b/apps/web/src/app/tokenlist-request/page.tsx @@ -30,10 +30,10 @@ import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import { useMutation } from '@tanstack/react-query' import { useEffect, useMemo } from 'react' import { SubmitHandler, useForm } from 'react-hook-form' +import { SUSHI_DATA_API_HOST } from 'src/lib/constants' import { useTokenAnalysis } from 'src/lib/hooks/api/useTokenAnalysis' import { NetworkSelector } from 'src/lib/wagmi/components/network-selector' -import { Chain, ChainId } from 'sushi/chain' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { ChainId, EvmChain } from 'sushi/chain' import { formatNumber, formatUSD } from 'sushi/format' import { SUPPORTED_CHAIN_IDS } from '../../config' import { NavigationItems } from './navigation-items' @@ -350,7 +350,7 @@ export default function TokenListing() { width={16} height={16} /> - {Chain.from(value)?.name} + {EvmChain.from(value)?.name} diff --git a/apps/web/src/app/tokenlist-request/pending/page.tsx b/apps/web/src/app/tokenlist-request/pending/page.tsx index d587557824..d70dddba74 100644 --- a/apps/web/src/app/tokenlist-request/pending/page.tsx +++ b/apps/web/src/app/tokenlist-request/pending/page.tsx @@ -25,7 +25,7 @@ import React, { useMemo, useState } from 'react' import { usePendingTokens } from 'src/lib/hooks/api/usePendingTokenListings' import { TokenSecurityView } from 'src/lib/wagmi/components/token-security-view' import { formatNumber, formatUSD, shortenAddress } from 'sushi' -import { Chain } from 'sushi/chain' +import { EvmChain, EvmChainId } from 'sushi/chain' import { Token } from 'sushi/currency' import { getAddress } from 'viem' import { NavigationItems } from '../navigation-items' @@ -66,7 +66,7 @@ const COLUMNS: ColumnDef[] = [ @@ -202,7 +202,12 @@ const COLUMNS: ColumnDef[] = [ trust_list: props.row.original.security.trustList, }, }} - token={new Token(props.row.original.token)} + token={ + new Token({ + ...props.row.original.token, + chainId: props.row.original.token.chainId as EvmChainId, + }) + } /> , diff --git a/apps/web/src/config.ts b/apps/web/src/config.ts index a88cf8ab62..76f57aeffc 100644 --- a/apps/web/src/config.ts +++ b/apps/web/src/config.ts @@ -1,5 +1,5 @@ import { PoolChainIds } from '@sushiswap/graph-client/data-api' -import { Chain, ChainId, TESTNET_CHAIN_IDS } from 'sushi/chain' +import { ChainId, EVM_TESTNET_CHAIN_IDS, EvmChain } from 'sushi/chain' import { AGGREGATOR_ONLY_CHAIN_IDS, EXTRACTOR_SUPPORTED_CHAIN_IDS, @@ -21,7 +21,7 @@ export const isNonStandardChainId = ( nonStandardChainId as NonStandardChainId, ) -interface NonStandardChain extends Omit { +interface NonStandardChain extends Omit { chainId: string } @@ -62,7 +62,7 @@ export const DISABLED_CHAIN_IDS = [ ChainId.PALM, ChainId.HECO, ChainId.OKEX, - // NonStandardChainId.TRON, + ChainId.HEMI, ] as const export const NEW_CHAIN_IDS = [ChainId.SONIC] as const @@ -135,10 +135,11 @@ export const AMM_SUPPORTED_CHAIN_IDS = SUSHISWAP_SUPPORTED_CHAIN_IDS.filter( c, ): c is Exclude< (typeof SUSHISWAP_SUPPORTED_CHAIN_IDS)[number], - (typeof TESTNET_CHAIN_IDS)[number] | (typeof DISABLED_CHAIN_IDS)[number] + (typeof EVM_TESTNET_CHAIN_IDS)[number] | (typeof DISABLED_CHAIN_IDS)[number] > => - !TESTNET_CHAIN_IDS.includes(c as (typeof TESTNET_CHAIN_IDS)[number]) && - !DISABLED_CHAIN_IDS.includes(c as (typeof DISABLED_CHAIN_IDS)[number]), + !EVM_TESTNET_CHAIN_IDS.includes( + c as (typeof EVM_TESTNET_CHAIN_IDS)[number], + ) && !DISABLED_CHAIN_IDS.includes(c as (typeof DISABLED_CHAIN_IDS)[number]), ) export const SUPPORTED_CHAIN_IDS = Array.from( @@ -153,10 +154,11 @@ export const SUPPORTED_CHAIN_IDS = Array.from( c, ): c is Exclude< (typeof CHAIN_IDS)[number], - (typeof TESTNET_CHAIN_IDS)[number] | (typeof DISABLED_CHAIN_IDS)[number] + (typeof EVM_TESTNET_CHAIN_IDS)[number] | (typeof DISABLED_CHAIN_IDS)[number] > => - !TESTNET_CHAIN_IDS.includes(c as (typeof TESTNET_CHAIN_IDS)[number]) && - !DISABLED_CHAIN_IDS.includes(c as (typeof DISABLED_CHAIN_IDS)[number]), + !EVM_TESTNET_CHAIN_IDS.includes( + c as (typeof EVM_TESTNET_CHAIN_IDS)[number], + ) && !DISABLED_CHAIN_IDS.includes(c as (typeof DISABLED_CHAIN_IDS)[number]), ) export type SupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number] diff --git a/apps/web/src/lib/constants.ts b/apps/web/src/lib/constants.ts index ec592555d0..7b922f081e 100644 --- a/apps/web/src/lib/constants.ts +++ b/apps/web/src/lib/constants.ts @@ -1,4 +1,10 @@ import { SushiSwapProtocol } from 'sushi' +import { SUSHI_DATA_API_HOST as PROD_SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' + +export const SUSHI_DATA_API_HOST = + process.env['SUSHI_DATA_API_HOST'] || + process.env['NEXT_PUBLIC_SUSHI_DATA_API_HOST'] || + PROD_SUSHI_DATA_API_HOST export const PROTOCOL_MAP: Record = { SUSHISWAP_V3: 'SushiSwap V3', diff --git a/apps/web/src/lib/functions.ts b/apps/web/src/lib/functions.ts index 72d4b7b6fe..c2c5797bc5 100644 --- a/apps/web/src/lib/functions.ts +++ b/apps/web/src/lib/functions.ts @@ -1,5 +1,5 @@ import type { Incentive } from 'sushi' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { SushiSwapV3FeeAmount, TICK_SPACINGS } from 'sushi/config' import { DAI, @@ -31,7 +31,7 @@ export const isSushiSwapV2Pool = ( } export const incentiveRewardToToken = ( - chainId: ChainId, + chainId: EvmChainId, incentive: Incentive, ): Token => { return new Token({ diff --git a/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardTokens.ts b/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardTokens.ts index 381281f006..2765747f72 100644 --- a/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardTokens.ts +++ b/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardTokens.ts @@ -1,11 +1,11 @@ import { useQuery } from '@tanstack/react-query' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Token, tryParseAmount } from 'sushi/currency' import { angleRewardTokensValidator } from './validator' interface UseAngleRewardTokensParams { - chainId: ChainId + chainId: EvmChainId } export const useAngleRewardTokens = ({ diff --git a/apps/web/src/lib/hooks/react-query/rewards/useAngleRewards.ts b/apps/web/src/lib/hooks/react-query/rewards/useAngleRewards.ts index f934a98593..653b5feca0 100644 --- a/apps/web/src/lib/hooks/react-query/rewards/useAngleRewards.ts +++ b/apps/web/src/lib/hooks/react-query/rewards/useAngleRewards.ts @@ -1,5 +1,5 @@ import { useQuery } from '@tanstack/react-query' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Amount, Token, tryParseAmount } from 'sushi/currency' import { ZERO } from 'sushi/math' import { parseUnits } from 'viem' @@ -25,7 +25,7 @@ export type AngleRewardsPool = Omit< 'rewardsPerToken' | 'token0' | 'token1' | 'distributionData' > & { id: string - chainId: ChainId + chainId: EvmChainId distributionData: Array< Omit< z.infer['distributionData'][0], @@ -40,7 +40,7 @@ export type AngleRewardsPool = Omit< type TransformedPools = Record interface AngleRewardsQueryParams { - chainIds: ChainId[] + chainIds: EvmChainId[] account?: string | undefined enabled?: boolean } @@ -65,7 +65,7 @@ export const angleRewardsQueryFn = async ({ } interface AngleRewardsSelect { - chainId: ChainId + chainId: EvmChainId data: z.infer[number] | undefined prices: ReturnType['data'] } @@ -221,7 +221,7 @@ export const angleRewardsSelect = ({ } interface UseAngleRewardsParams { - chainId: ChainId + chainId: EvmChainId account?: string | undefined enabled?: boolean } diff --git a/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardsMultipleChains.ts b/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardsMultipleChains.ts index 18f0f28a87..01173ac7a9 100644 --- a/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardsMultipleChains.ts +++ b/apps/web/src/lib/hooks/react-query/rewards/useAngleRewardsMultipleChains.ts @@ -1,13 +1,13 @@ import { useQuery } from '@tanstack/react-query' import { isPromiseRejected } from 'sushi' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Address } from 'viem' import { useAllPrices } from '../prices' import { angleRewardsQueryFn, angleRewardsSelect } from './useAngleRewards' interface UseAngleRewardsParams { - chainIds: ChainId[] + chainIds: EvmChainId[] account: Address | undefined } diff --git a/apps/web/src/lib/hooks/react-query/trade/types.ts b/apps/web/src/lib/hooks/react-query/trade/types.ts index a33f0cdd89..30e20f710a 100644 --- a/apps/web/src/lib/hooks/react-query/trade/types.ts +++ b/apps/web/src/lib/hooks/react-query/trade/types.ts @@ -2,7 +2,7 @@ import { routeProcessor2Abi_processRoute, routeProcessor2Abi_transferValueAndprocessRoute, } from 'sushi/abi' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Amount, Price, type Type } from 'sushi/currency' import { Percent } from 'sushi/math' import { RouterLiquiditySource } from 'sushi/router' @@ -12,7 +12,7 @@ import { legValidator, tradeValidator01 } from './validator01' import { tradeValidator02 } from './validator02' export interface UseTradeParams { - chainId: ChainId + chainId: EvmChainId fromToken: Type | undefined toToken: Type | undefined amount: Amount | undefined diff --git a/apps/web/src/lib/hooks/react-query/trade/useTrade.ts b/apps/web/src/lib/hooks/react-query/trade/useTrade.ts index 3101b3527e..45c303bbc0 100644 --- a/apps/web/src/lib/hooks/react-query/trade/useTrade.ts +++ b/apps/web/src/lib/hooks/react-query/trade/useTrade.ts @@ -5,9 +5,9 @@ import { } from '@sushiswap/telemetry' import { useQuery } from '@tanstack/react-query' import { useCallback, useMemo } from 'react' +import { API_BASE_URL } from 'src/lib/swap/api-base-url' import { slippageAmount } from 'sushi/calculate' import { - API_BASE_URL, TOKEN_CHOMPER_ADDRESS, isRouteProcessor5ChainId, isTokenChomperChainId, diff --git a/apps/web/src/lib/hooks/useTokenAmountDollarValues.ts b/apps/web/src/lib/hooks/useTokenAmountDollarValues.ts index a002f9dfe8..66a37d5568 100644 --- a/apps/web/src/lib/hooks/useTokenAmountDollarValues.ts +++ b/apps/web/src/lib/hooks/useTokenAmountDollarValues.ts @@ -1,13 +1,13 @@ 'use client' import { useMemo } from 'react' -import type { ChainId } from 'sushi/chain' +import type { EvmChainId } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' import { ZERO } from 'sushi/math' import { usePrices } from '~evm/_common/ui/price-provider/price-provider/use-prices' interface Params { - chainId: ChainId + chainId: EvmChainId amounts: (Amount | undefined)[] | null | undefined } diff --git a/apps/web/src/lib/hooks/useTokensFromPool.ts b/apps/web/src/lib/hooks/useTokensFromPool.ts index 61843cd4c1..355593e885 100644 --- a/apps/web/src/lib/hooks/useTokensFromPool.ts +++ b/apps/web/src/lib/hooks/useTokensFromPool.ts @@ -1,13 +1,14 @@ 'use client' import { useMemo } from 'react' +import { EvmChainId } from 'sushi' import { Native, Token } from 'sushi/currency' export const getTokensFromPool = (pool: { id: string token0: { address: string; name: string; decimals: number; symbol: string } token1: { address: string; name: string; decimals: number; symbol: string } - chainId: number + chainId: EvmChainId }) => { const _token0 = new Token({ address: pool.token0.address, @@ -52,7 +53,7 @@ export const useTokensFromPool = (pool: { id: string token0: { address: string; name: string; decimals: number; symbol: string } token1: { address: string; name: string; decimals: number; symbol: string } - chainId: number + chainId: EvmChainId }) => { return useMemo(() => { return getTokensFromPool(pool) diff --git a/apps/web/src/lib/hooks/useZap.ts b/apps/web/src/lib/hooks/useZap.ts index 9bfa86f949..5142d748f5 100644 --- a/apps/web/src/lib/hooks/useZap.ts +++ b/apps/web/src/lib/hooks/useZap.ts @@ -1,6 +1,6 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query' import { isZapSupportedChainId } from 'src/config' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Percent } from 'sushi/math' import { Address, Hex } from 'viem' import { z } from 'zod' @@ -47,7 +47,7 @@ const zapResponseSchema = z.object({ export type ZapResponse = z.infer type UseZapParams = { - chainId: ChainId + chainId: EvmChainId fromAddress?: Address receiver?: Address amountIn: string | string[] diff --git a/apps/web/src/lib/network.ts b/apps/web/src/lib/network.ts index 3918e236cd..79475f54b7 100644 --- a/apps/web/src/lib/network.ts +++ b/apps/web/src/lib/network.ts @@ -1,9 +1,9 @@ -import { Chain, ChainId, ChainKey } from 'sushi/chain' +import { ChainId, ChainKey, EvmChain } from 'sushi/chain' import { NonStandardChain, NonStandardChainId } from '../config' export const getNetworkName = (network: ChainId | NonStandardChainId) => { return typeof network === 'number' - ? Chain.from(network)?.name + ? EvmChain.from(network)?.name : NonStandardChain[network].name } diff --git a/apps/web/src/lib/schema.ts b/apps/web/src/lib/schema.ts index 8594167e4a..1acc786016 100644 --- a/apps/web/src/lib/schema.ts +++ b/apps/web/src/lib/schema.ts @@ -1,4 +1,4 @@ -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { FURO_SUPPORTED_CHAIN_IDS, isFuroChainId } from 'sushi/config' import { BENTOBOX_SUPPORTED_CHAIN_IDS, isBentoBoxChainId } from 'sushi/config' import { z } from 'zod' @@ -12,7 +12,7 @@ export const bentoBoxTokensSchema = z.object({ .string() .optional() .default(BENTOBOX_SUPPORTED_CHAIN_IDS.join(',')) - .transform((val) => val.split(',').map((v) => parseInt(v) as ChainId)) + .transform((val) => val.split(',').map((v) => parseInt(v) as EvmChainId)) .transform((chainIds) => chainIds.filter(isBentoBoxChainId)), }) @@ -29,6 +29,6 @@ export const furoTokensSchema = z.object({ .string() .optional() .default(FURO_SUPPORTED_CHAIN_IDS.join(',')) - .transform((val) => val.split(',').map((v) => parseInt(v) as ChainId)) + .transform((val) => val.split(',').map((v) => parseInt(v) as EvmChainId)) .transform((chainIds) => chainIds.filter(isFuroChainId)), }) diff --git a/apps/web/src/lib/swap/api-base-url.ts b/apps/web/src/lib/swap/api-base-url.ts new file mode 100644 index 0000000000..19a0e0491d --- /dev/null +++ b/apps/web/src/lib/swap/api-base-url.ts @@ -0,0 +1,6 @@ +import { API_BASE_URL as PROD_API_BASE_URL } from 'sushi/config' + +export const API_BASE_URL = + process.env['API_BASE_URL'] || + process.env['NEXT_PUBLIC_API_BASE_URL'] || + PROD_API_BASE_URL diff --git a/apps/web/src/lib/wagmi/components/header-network-selector.tsx b/apps/web/src/lib/wagmi/components/header-network-selector.tsx index 1831f8fdb8..dbc9bbebab 100644 --- a/apps/web/src/lib/wagmi/components/header-network-selector.tsx +++ b/apps/web/src/lib/wagmi/components/header-network-selector.tsx @@ -4,7 +4,7 @@ import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import React, { FC, Suspense, useCallback } from 'react' import { NonStandardChainId } from 'src/config' import { getNetworkName } from 'src/lib/network' -import { ChainId } from 'sushi/chain' +import { EvmChainId, isEvmChainId } from 'sushi/chain' import { ProviderRpcError, UserRejectedRequestError } from 'viem' import { useChainId, useSwitchChain } from 'wagmi' import { @@ -13,9 +13,9 @@ import { } from './network-selector' export const HeaderNetworkSelector: FC<{ - networks: readonly (ChainId | NonStandardChainId)[] - selectedNetwork?: ChainId | NonStandardChainId - onChange?(network: ChainId | NonStandardChainId): void + networks: readonly (EvmChainId | NonStandardChainId)[] + selectedNetwork?: EvmChainId | NonStandardChainId + onChange?(network: EvmChainId | NonStandardChainId): void hideNetworkName?: boolean className?: string }> = ({ @@ -32,7 +32,12 @@ export const HeaderNetworkSelector: FC<{ async (el, close) => { console.debug('onSwitchNetwork', el) try { - if (typeof el === 'number' && switchChainAsync && chainId !== el) { + if ( + typeof el === 'number' && + isEvmChainId(el) && + switchChainAsync && + chainId !== el + ) { await switchChainAsync({ chainId: el }) } diff --git a/apps/web/src/lib/wagmi/components/network-check.tsx b/apps/web/src/lib/wagmi/components/network-check.tsx index e34e4d8f4d..d1b2720252 100644 --- a/apps/web/src/lib/wagmi/components/network-check.tsx +++ b/apps/web/src/lib/wagmi/components/network-check.tsx @@ -4,10 +4,10 @@ import { useIsMounted } from '@sushiswap/hooks' import { Button } from '@sushiswap/ui' import { FC, useEffect, useState } from 'react' import ReactDOM from 'react-dom' -import { Chain, ChainId, chainName } from 'sushi/chain' +import { EvmChain, EvmChainId, evmChainName } from 'sushi/chain' import { useAccount, useSwitchChain } from 'wagmi' -export const NetworkCheck: FC<{ chainId: ChainId }> = ({ chainId }) => { +export const NetworkCheck: FC<{ chainId: EvmChainId }> = ({ chainId }) => { const [open, setOpen] = useState(false) const isMounted = useIsMounted() const { chain } = useAccount() @@ -34,8 +34,8 @@ export const NetworkCheck: FC<{ chainId: ChainId }> = ({ chainId }) => { return ReactDOM.createPortal(

- App network ({chainName?.[chainId]}) {"doesn't"} match network selected - in wallet ({chain?.id ? chainName[chain.id] : ''}). + App network ({evmChainName?.[chainId]}) {"doesn't"} match network + selected in wallet ({chain?.id ? evmChainName[chain.id] : ''}).

, diff --git a/apps/web/src/lib/wagmi/components/network-selector.tsx b/apps/web/src/lib/wagmi/components/network-selector.tsx index a3db09859a..1ee18c6f58 100644 --- a/apps/web/src/lib/wagmi/components/network-selector.tsx +++ b/apps/web/src/lib/wagmi/components/network-selector.tsx @@ -19,14 +19,14 @@ import { isNonStandardChainId, } from 'src/config' import { getNetworkName, replaceNetworkSlug } from 'src/lib/network' -import { ChainId, isChainId, isNetworkNameKey } from 'sushi/chain' +import { EvmChainId, isChainId, isEvmNetworkNameKey } from 'sushi/chain' export type NetworkSelectorOnSelectCallback< - T extends number | string = ChainId | NonStandardChainId, + T extends number | string = EvmChainId | NonStandardChainId, > = (chainId: T, close: () => void) => void export interface NetworkSelectorProps< - T extends number | string = ChainId | NonStandardChainId, + T extends number | string = EvmChainId | NonStandardChainId, > { networks: readonly T[] selected: T @@ -48,12 +48,15 @@ const NetworkSelector = ({ const network = (isChainId(+_network) ? +_network : _network) as T const pathSegments = pathname.split('/') if ( - isNetworkNameKey(pathSegments[1]) || + isEvmNetworkNameKey(pathSegments[1]) || isChainId(+pathSegments[1]) || isNonStandardChainId(pathSegments[1]) ) { push( - replaceNetworkSlug(network as ChainId | NonStandardChainId, pathname), + replaceNetworkSlug( + network as EvmChainId | NonStandardChainId, + pathname, + ), { scroll: false }, ) } else if (isNonStandardChainId(network.toString())) { @@ -78,7 +81,7 @@ const NetworkSelector = ({ {networks.map((network) => { const name = getNetworkName( - network as ChainId | NonStandardChainId, + network as EvmChainId | NonStandardChainId, ) return ( diff --git a/apps/web/src/lib/wagmi/components/token-selector/currency-info.tsx b/apps/web/src/lib/wagmi/components/token-selector/currency-info.tsx index 31800f80d4..cee6c8ca59 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/currency-info.tsx +++ b/apps/web/src/lib/wagmi/components/token-selector/currency-info.tsx @@ -37,7 +37,7 @@ import { useCoinGeckoTokenInfo, useTokenSecurity, } from 'src/lib/hooks/react-query' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { Type } from 'sushi/currency' import { formatNumber, formatUSD, shortenAddress } from 'sushi/format' @@ -92,7 +92,7 @@ export const CurrencyInfo: FC = ({ currency, onBack }) => {
{currency.symbol} - {Chain.from(currency.chainId)?.name} + {EvmChain.from(currency.chainId)?.name}
@@ -226,7 +226,7 @@ export const CurrencyInfo: FC = ({ currency, onBack }) => { diff --git a/apps/web/src/lib/wagmi/components/token-selector/hooks/use-chip-tokens.ts b/apps/web/src/lib/wagmi/components/token-selector/hooks/use-chip-tokens.ts index ca36c15ed4..ff9d295e3b 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/hooks/use-chip-tokens.ts +++ b/apps/web/src/lib/wagmi/components/token-selector/hooks/use-chip-tokens.ts @@ -1,10 +1,10 @@ // import { usePinnedTokens } from '@sushiswap/hooks' import { useMemo } from 'react' -import type { ChainId } from 'sushi/chain' -import { DEFAULT_BASES } from 'sushi/config' +import type { EvmChainId } from 'sushi/chain' +import { EVM_DEFAULT_BASES } from 'sushi/config' interface UseChipTokens { - chainId: ChainId + chainId: EvmChainId includeNative?: boolean showPinnedTokens?: boolean } @@ -16,7 +16,7 @@ export function useChipTokens({ includeNative = true, // showPinnedTokens = true, }: UseChipTokens) { - const defaultBases = DEFAULT_BASES[chainId] + const defaultBases = EVM_DEFAULT_BASES[chainId] // const {} = usePinnedTokens() diff --git a/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-import-row.tsx b/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-import-row.tsx index d77fcb659f..ea9dd144f3 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-import-row.tsx +++ b/apps/web/src/lib/wagmi/components/token-selector/token-lists/common/token-selector-import-row.tsx @@ -19,7 +19,7 @@ import { Currency } from '@sushiswap/ui' import { List } from '@sushiswap/ui' import { FC, useCallback, useState } from 'react' import { useTokenSecurity } from 'src/lib/hooks/react-query' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { Token } from 'sushi/currency' import { shortenAddress } from 'sushi/format' @@ -125,7 +125,7 @@ export const TokenSelectorImportRow: FC = ({ > = memo( - chainId: ChainId + chainId: EvmChainId account?: Address selected: Type | undefined onSelect(currency: Type): void diff --git a/apps/web/src/lib/wagmi/components/token-selector/token-selector-states.tsx b/apps/web/src/lib/wagmi/components/token-selector/token-selector-states.tsx index 95513c2301..362919956a 100644 --- a/apps/web/src/lib/wagmi/components/token-selector/token-selector-states.tsx +++ b/apps/web/src/lib/wagmi/components/token-selector/token-selector-states.tsx @@ -1,13 +1,13 @@ 'use client' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Type } from 'sushi/currency' import { isTokenListChainId, isTrendingTokensChainId, } from '@sushiswap/graph-client/data-api' -import { DEFAULT_BASES } from 'sushi/config' +import { EVM_DEFAULT_BASES } from 'sushi/config' import type { Address } from 'viem' import { useMyTokens } from './hooks/use-my-tokens' import { useSearchTokens } from './hooks/use-search-tokens' @@ -20,7 +20,7 @@ import { TokenSelectorTrendingTokens } from './token-lists/token-selector-trendi interface TokenSelectorStates { selected: Type | undefined - chainId: ChainId + chainId: EvmChainId account?: Address onSelect(currency: Type): void onShowInfo(currency: Type | false): void @@ -172,7 +172,7 @@ export function TokenSelectorStates({ includeNative?: boolean hidePinnedTokens?: boolean hideSearch?: boolean - networks?: readonly ChainId[] - selectedNetwork?: ChainId + networks?: readonly EvmChainId[] + selectedNetwork?: EvmChainId onNetworkSelect?: (network: number) => void } diff --git a/apps/web/src/lib/wagmi/components/user-portfolio/PortfolioDefaultView.tsx b/apps/web/src/lib/wagmi/components/user-portfolio/PortfolioDefaultView.tsx index 49b189baaa..35f912c74c 100644 --- a/apps/web/src/lib/wagmi/components/user-portfolio/PortfolioDefaultView.tsx +++ b/apps/web/src/lib/wagmi/components/user-portfolio/PortfolioDefaultView.tsx @@ -17,7 +17,7 @@ import Image from 'next/image' import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react' import { SUPPORTED_NETWORKS } from 'src/config' import { HeaderNetworkSelector } from 'src/lib/wagmi/components/header-network-selector' -import { ChainId, chains, shortenAddress } from 'sushi' +import { ChainId, evmChains, shortenAddress } from 'sushi' import { useAccount, useDisconnect } from 'wagmi' import { GetEnsNameReturnType } from 'wagmi/actions' import { PortfolioView } from '.' @@ -119,7 +119,7 @@ export const PortfolioDefaultView: FC = ({ )} leftContent: ReactElement rightContent: ReactElement | null diff --git a/apps/web/src/lib/wagmi/components/user-portfolio/portfolio-claimables/PortfolioFarmClaimables.tsx b/apps/web/src/lib/wagmi/components/user-portfolio/portfolio-claimables/PortfolioFarmClaimables.tsx index 8dec76a781..c50d59b5e2 100644 --- a/apps/web/src/lib/wagmi/components/user-portfolio/portfolio-claimables/PortfolioFarmClaimables.tsx +++ b/apps/web/src/lib/wagmi/components/user-portfolio/portfolio-claimables/PortfolioFarmClaimables.tsx @@ -7,7 +7,7 @@ import { } from '@sushiswap/ui' import { FC } from 'react' import React from 'react' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChainId } from 'sushi/chain' import { formatUSD } from 'sushi/format' import { PortfolioInfoRow } from '../PortfolioInfoRow' @@ -26,13 +26,13 @@ export const PortfolioFarmClaimables: FC = ({ {claimables.map(({ position, token }) => ( = ({ {claimables.map(({ position, token }) => ( = ({ {positions.map((position) => ( = ({ {positions.map((position) => ( = ({ {positions.map((position) => ( = ({ return ( = ({ }) => { return ( diff --git a/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioOtherTransaction.tsx b/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioOtherTransaction.tsx index aafaccada1..d6cbedc931 100644 --- a/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioOtherTransaction.tsx +++ b/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioOtherTransaction.tsx @@ -4,7 +4,7 @@ import { ClipboardController, FormattedNumber, IconButton } from '@sushiswap/ui' import { SushiLiteIcon } from '@sushiswap/ui/icons/SushiLiteIcon' import { format, fromUnixTime } from 'date-fns' import React, { FC } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { EvmChain, EvmChainId } from 'sushi/chain' import { shortenHash } from 'sushi/format' import { PortfolioInfoRow } from '../PortfolioInfoRow' @@ -13,8 +13,8 @@ export const PortfolioOtherTransaction: FC<{ tx: PortfolioTransaction }> = ({ }) => { return ( = ({ }) => { return ( diff --git a/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioSendTransaction.tsx b/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioSendTransaction.tsx index 8a16bc9df1..65cd4eb066 100644 --- a/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioSendTransaction.tsx +++ b/apps/web/src/lib/wagmi/components/user-portfolio/portolio-history/PortfolioSendTransaction.tsx @@ -4,7 +4,7 @@ import { ClipboardController, FormattedNumber, IconButton } from '@sushiswap/ui' import { format, fromUnixTime } from 'date-fns' import { FC } from 'react' import React from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { EvmChain, EvmChainId } from 'sushi/chain' import { shortenHash } from 'sushi/format' import { PortfolioInfoRow } from '../PortfolioInfoRow' @@ -13,8 +13,8 @@ export const PortfolioSendTransaction: FC<{ tx: PortfolioTransaction }> = ({ }) => { return ( diff --git a/apps/web/src/lib/wagmi/components/wagmi-header-components.tsx b/apps/web/src/lib/wagmi/components/wagmi-header-components.tsx index 40580a6af5..04439ab4df 100644 --- a/apps/web/src/lib/wagmi/components/wagmi-header-components.tsx +++ b/apps/web/src/lib/wagmi/components/wagmi-header-components.tsx @@ -8,14 +8,14 @@ import { } from '@sushiswap/telemetry' import { Suspense, useEffect } from 'react' import { NonStandardChainId } from 'src/config' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { useAccount } from 'wagmi' import { HeaderNetworkSelector } from './header-network-selector' import { UserPortfolio } from './user-portfolio' interface WagmiHeaderComponentsProps { - networks: readonly (ChainId | NonStandardChainId)[] - onChange?(chainId: ChainId): void + networks: readonly (EvmChainId | NonStandardChainId)[] + onChange?(chainId: EvmChainId): void } export const WagmiHeaderComponents: React.FC = ({ diff --git a/apps/web/src/lib/wagmi/components/web3-input/Currency/CurrencyInput.tsx b/apps/web/src/lib/wagmi/components/web3-input/Currency/CurrencyInput.tsx index 0d62bcf8de..6a82418709 100644 --- a/apps/web/src/lib/wagmi/components/web3-input/Currency/CurrencyInput.tsx +++ b/apps/web/src/lib/wagmi/components/web3-input/Currency/CurrencyInput.tsx @@ -21,7 +21,7 @@ import { useState, useTransition, } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { EvmChain, EvmChainId } from 'sushi/chain' import { Token, Type, tryParseAmount } from 'sushi/currency' import { Percent } from 'sushi/math' import { useAccount } from 'wagmi' @@ -38,7 +38,7 @@ interface CurrencyInputProps { onChange?(value: string): void currency: Type | undefined onSelect?(currency: Type): void - chainId: ChainId + chainId: EvmChainId className?: string loading?: boolean priceImpact?: Percent | undefined @@ -55,8 +55,8 @@ interface CurrencyInputProps { hidePricing?: boolean hideIcon?: boolean label?: string - networks?: readonly ChainId[] - selectedNetwork?: ChainId + networks?: readonly EvmChainId[] + selectedNetwork?: EvmChainId onNetworkChange?: (network: number) => void } @@ -204,7 +204,7 @@ const CurrencyInput: FC = ({
{currency.symbol} - {Chain.from(currency.chainId)?.name} + {EvmChain.from(currency.chainId)?.name}
diff --git a/apps/web/src/lib/wagmi/config/production.ts b/apps/web/src/lib/wagmi/config/production.ts index 0c3e790bd7..919a15d0e8 100644 --- a/apps/web/src/lib/wagmi/config/production.ts +++ b/apps/web/src/lib/wagmi/config/production.ts @@ -11,21 +11,21 @@ import { walletConnectWallet, } from '@rainbow-me/rainbowkit/wallets' import { gtagEvent } from '@sushiswap/ui' -import { ChainId } from 'sushi/chain' -import { publicTransports } from 'sushi/config' +import { EvmChainId } from 'sushi/chain' import { http, cookieStorage, createConfig, createStorage } from 'wagmi' import { Writeable } from 'zod' import { publicWagmiConfig } from './public' +import { publicTransports } from './viem' export const DEFAULT_POLLING_INTERVAL = 4_000 // Allow for custom polling intervals for each chain with a default const pollingInterval = new Proxy( { - [ChainId.ETHEREUM]: 8000, // BT is 12s - [ChainId.POLYGON_ZKEVM]: 8000, // BT is 13s - [ChainId.FILECOIN]: 20000, // BT is 30s - } as Partial>, + [EvmChainId.ETHEREUM]: 8000, // BT is 12s + [EvmChainId.POLYGON_ZKEVM]: 8000, // BT is 13s + [EvmChainId.FILECOIN]: 20000, // BT is 30s + } as Partial>, { get: (target, name) => { return Object.hasOwn(target, name) @@ -68,7 +68,7 @@ export const createProductionConfig = () => { } } - acc[Number(chainId) as ChainId] = http(transportUrl, { + acc[Number(chainId) as EvmChainId] = http(transportUrl, { fetchOptions, onFetchRequest(_req) { if (typeof window !== 'undefined' && transportUrl.includes('drpc')) { diff --git a/apps/web/src/lib/wagmi/config/public.ts b/apps/web/src/lib/wagmi/config/public.ts index 69255a37f7..fde1de71be 100644 --- a/apps/web/src/lib/wagmi/config/public.ts +++ b/apps/web/src/lib/wagmi/config/public.ts @@ -1,5 +1,5 @@ import { createConfig } from '@wagmi/core' -import { publicChains, publicTransports } from 'sushi/config' +import { publicChains, publicTransports } from './viem' export const publicWagmiConfig = { chains: publicChains, diff --git a/apps/web/src/lib/wagmi/config/test/constants.ts b/apps/web/src/lib/wagmi/config/test/constants.ts index 164d2af27c..9f57025d7e 100644 --- a/apps/web/src/lib/wagmi/config/test/constants.ts +++ b/apps/web/src/lib/wagmi/config/test/constants.ts @@ -1,5 +1,5 @@ -import { publicChains } from 'sushi/config' import { foundry } from 'viem/chains' +import { publicChains } from '../viem' export const testChains = publicChains.map((chain) => ({ ...chain, diff --git a/apps/web/src/lib/wagmi/config/viem.ts b/apps/web/src/lib/wagmi/config/viem.ts new file mode 100644 index 0000000000..e47e294621 --- /dev/null +++ b/apps/web/src/lib/wagmi/config/viem.ts @@ -0,0 +1,1062 @@ +import { EvmChainId } from 'sushi/chain' +import { + http, + type Address, + type Chain, + type PublicClientConfig, + type Transport, +} from 'viem' +import { + arbitrum, + // arbitrumGoerli, + arbitrumNova, + arbitrumSepolia, + // aurora, + // auroraGoerli, + avalanche, + avalancheFuji, + // avalancheFuji, + base, + boba, + // bronos, + // bronosTestnet, + bsc, + bscTestnet, + // bscTestnet, + // canto, + celo, + // ronin, + cronos, + // zkSyncTestnet, + curtis as _curtis, + // celoAlfajores, + // crossbell, + // evmos, + // evmosTestnet, + fantom, + fantomTestnet, + // fantomTestnet, + // filecoinTestnet, + foundry, + fuse as _fuse, // missing multicall + gnosis, + goerli, + haqqMainnet as _haqq, + // gnosisChiado, + hardhat, + harmonyOne, + // iotex, + // iotexTestnet, + linea, + localhost, + mainnet, + manta, + mantle, + metis, + // metisGoerli, + mode, + moonbeam, + moonriver, + okc, + optimism, + // optimismGoerli, + polygon, + polygonMumbai, + polygonZkEvm, + rootstock, + scroll, + sepolia, + taiko, + // polygonMumbai, + // sepolia, + // taraxa, + // taraxaTestnet, + telos, + zkLinkNova as _zkLinkNova, // missing multicall + zkSync, +} from 'viem/chains' + +export { + arbitrum, + // arbitrumGoerli, + arbitrumNova, + // aurora, + // auroraGoerli, + avalanche, + // avalancheFuji, + base, + boba, + // bronos, + // bronosTestnet, + bsc, + // bscTestnet, + // canto, + celo, + // celoAlfajores, + // crossbell, + // evmos, + // evmosTestnet, + fantom, + // fantomTestnet, + // filecoinTestnet, + foundry, + gnosis, + goerli, + // gnosisChiado, + hardhat, + // iotex, + // iotexTestnet, + linea, + localhost, + mainnet, + manta, + mantle, + metis, + // metisGoerli, + mode, + moonbeam, + moonriver, + okc, + optimism, + // optimismGoerli, + polygon, + polygonZkEvm, + rootstock, + taiko, + // polygonMumbai, + // sepolia, + // taraxa, + // taraxaTestnet, + zkSync, + // zkSyncTestnet, +} + +// Chains missing multicall +export const fuse = { + ..._fuse, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11' as Address, + blockCreated: 16146628, + }, + }, +} as const + +const haqq = { + ..._haqq, + contracts: { + multicall3: { + address: '0xfe2D04A5018AC1B366F599A13BF4e0C760b2aE6b', + blockCreated: 6589598, + }, + }, +} as const + +const zkLinkNova = { + ..._zkLinkNova, + contracts: { + multicall3: { + address: '0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5' as Address, + blockCreated: 146055, + }, + }, +} + +// Chains missing from viem entirely +export const kava = { + id: EvmChainId.KAVA, + name: 'Kava', + network: 'kava', + nativeCurrency: { name: 'Kava', symbol: 'KAVA', decimals: 18 }, + rpcUrls: { + default: { + http: ['https://evm.kava.io', 'https://evm2.kava.io'], + }, + public: { + http: ['https://evm.kava.io', 'https://evm2.kava.io'], + }, + }, + blockExplorers: { + etherscan: { + name: 'Kavascan', + url: 'https://explorer.kava.io/', + }, + default: { + name: 'Kavascan', + url: 'https://explorer.kava.io/', + }, + }, + contracts: { + multicall3: { + address: '0x1578f6d2D3168acF41b506AA666A521994F6BAB6' as Address, + blockCreated: 1176602, + }, + }, +} as const + +export const heco = { + id: EvmChainId.HECO, + name: 'Huobi ECO Chain', + network: 'huobieco', + nativeCurrency: { name: 'Huobi Token', symbol: 'HT', decimals: 18 }, + rpcUrls: { + default: { + http: ['https://http-mainnet.hecochain.com'], + }, + public: { + http: ['https://http-mainnet.hecochain.com'], + }, + }, + blockExplorers: { + etherscan: { + name: 'HecoInfo', + url: 'https://www.hecoinfo.com/', + }, + default: { + name: 'Heco Explorer', + url: 'https://www.hecoinfo.com/', + }, + }, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11' as Address, + blockCreated: 14413501, + }, + }, +} as const + +export const palm = { + id: EvmChainId.PALM, + name: 'Palm', + network: 'palm', + nativeCurrency: { name: 'Palm', symbol: 'PALM', decimals: 18 }, + rpcUrls: { + default: { + http: [ + 'https://palm-mainnet.infura.io/v3/3a961d6501e54add9a41aa53f15de99b', + ], + }, + public: { + http: [ + 'https://palm-mainnet.infura.io/v3/3a961d6501e54add9a41aa53f15de99b', + ], + }, + }, + blockExplorers: { + etherscan: { + name: 'Palm Explorer', + url: 'https://explorer.palm.io/', + }, + default: { + name: 'Palm Explorer', + url: 'https://explorer.palm.io/', + }, + }, + contracts: { + multicall3: { + address: '0x80C7DD17B01855a6D2347444a0FCC36136a314de' as Address, + blockCreated: 8005532, + }, + }, +} as const + +export const bobaAvax = { + id: EvmChainId.BOBA_AVAX, + name: 'Boba Avax', + network: 'boba-avax', + nativeCurrency: { name: 'Boba', symbol: 'BOBA', decimals: 18 }, + rpcUrls: { + default: { + http: ['https://avax.boba.network'], + }, + public: { + http: ['https://avax.boba.network'], + }, + }, + blockExplorers: { + etherscan: { + name: 'Boba Avalanche Mainnet Explorer', + url: 'https://blockexplorer.avax.boba.network/', + }, + default: { + name: 'Boba Avalanche Mainnet Explorer', + url: 'https://blockexplorer.avax.boba.network/', + }, + }, + contracts: { + multicall3: { + address: '0x2c46217Fae90D302d1Fb5467ADA504bC2A84f448' as Address, + blockCreated: 3652, + }, + }, +} as const + +export const bobaBnb = { + id: EvmChainId.BOBA_BNB, + name: 'Boba BNB', + network: 'boba-bnb', + nativeCurrency: { name: 'Boba', symbol: 'BOBA', decimals: 18 }, + rpcUrls: { + default: { + http: ['https://bnb.boba.network'], + }, + public: { + http: ['https://bnb.boba.network'], + }, + }, + blockExplorers: { + etherscan: { + name: 'Boba BNB Mainnet Explorer', + url: 'https://blockexplorer.bnb.boba.network/', + }, + default: { + name: 'Boba BNB Mainnet Explorer', + url: 'https://blockexplorer.bnb.boba.network/', + }, + }, + contracts: { + multicall3: { + address: '0x67dA5f2FfaDDfF067AB9d5F025F8810634d84287' as Address, + blockCreated: 18871, + }, + }, +} as const + +export const bttc = { + id: EvmChainId.BTTC, + name: 'BitTorrent Chain', + network: 'btt', + nativeCurrency: { name: 'BitTorrent', symbol: 'BTT', decimals: 18 }, + rpcUrls: { + default: { + http: ['https://rpc.bittorrentchain.io'], + }, + public: { + http: ['https://rpc.bittorrentchain.io'], + }, + }, + blockExplorers: { + etherscan: { + name: 'BitTorrent Chain Explorer', + url: 'https://bttcscan.com/', + }, + default: { + name: 'BitTorrent Chain Explorer', + url: 'https://bttcscan.com/', + }, + }, + contracts: { + multicall3: { + address: '0x67dA5f2FfaDDfF067AB9d5F025F8810634d84287' as Address, + blockCreated: 13014184, + }, + }, +} as const + +const thundercore = { + id: EvmChainId.THUNDERCORE, + name: 'ThunderCore', + network: 'thundercore', + nativeCurrency: { name: 'Thunder Token', symbol: 'TT', decimals: 18 }, + rpcUrls: { + default: { + http: [ + 'https://mainnet-rpc.thundercore.com', + // 'https://mainnet-rpc.thundercore.io', + // 'https://mainnet-rpc.thundertoken.net', + ], + }, + public: { + http: [ + 'https://mainnet-rpc.thundercore.com', + 'https://mainnet-rpc.thundercore.io', + 'https://mainnet-rpc.thundertoken.net', + ], + }, + }, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 100671921, + }, + }, +} as const + +export const core = { + id: EvmChainId.CORE, + name: 'Core', + network: 'core', + nativeCurrency: { name: 'Core', symbol: 'CORE', decimals: 18 }, + rpcUrls: { + default: { + http: ['https://rpc.coredao.org', 'https://rpc-core.icecreamswap.com'], + }, + public: { + http: ['https://rpc.coredao.org', 'https://rpc-core.icecreamswap.com'], + }, + }, + contracts: { + multicall3: { + address: '0xC4b2e1718E850535A0f3e79F7fC522d966821688', + blockCreated: 5087121, + }, + }, +} as const + +export const filecoin = { + id: EvmChainId.FILECOIN, + name: 'Filecoin Mainnet', + network: 'filecoin-mainnet', + nativeCurrency: { + decimals: 18, + name: 'filecoin', + symbol: 'FIL', + }, + rpcUrls: { + default: { http: ['https://rpc.ankr.com/filecoin'] }, + public: { http: ['https://rpc.ankr.com/filecoin'] }, + }, + blockExplorers: { + default: { name: 'Filfox', url: 'https://filfox.info/en' }, + filscan: { name: 'Filscan', url: 'https://filscan.io' }, + filscout: { name: 'Filscout', url: 'https://filscout.io/en' }, + glif: { name: 'Glif', url: 'https://explorer.glif.io' }, + }, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 3328594, + }, + }, +} as const + +export const zetachain = { + id: EvmChainId.ZETACHAIN, + name: 'ZetaChain', + network: 'zetachain', + nativeCurrency: { + decimals: 18, + name: 'Zeta', + symbol: 'ZETA', + }, + rpcUrls: { + default: { + http: [ + 'https://zetachain-evm.blockpi.network/v1/rpc/public', + 'https://zetachain-mainnet-archive.allthatnode.com:8545', + 'https://zetachain.rpc.thirdweb.com', + 'https://jsonrpc.zetachain.nodestake.org', + ], + }, + public: { + http: [ + 'https://zetachain-evm.blockpi.network/v1/rpc/public', + 'https://zetachain-mainnet-archive.allthatnode.com:8545', + 'https://zetachain.rpc.thirdweb.com', + 'https://jsonrpc.zetachain.nodestake.org', + ], + }, + }, + blockExplorers: { + default: { name: 'ZetaScan', url: 'https://explorer.zetachain.com/' }, + blockscout: { + name: 'Blockscout', + url: 'https://zetachain.blockscout.com/', + }, + }, + contracts: { + multicall3: { + address: '0x039e87AB90205F9d87c5b40d4B28e2Be45dA4a20', + blockCreated: 1565755, + }, + }, +} as const + +export const blast = { + id: EvmChainId.BLAST, + name: 'Blast', + network: 'blast', + nativeCurrency: { + decimals: 18, + name: 'Ether', + symbol: 'ETH', + }, + rpcUrls: { + default: { + http: [ + 'https://rpc.blast.io', + 'https://rpc.ankr.com/blast', + 'https://blast.din.dev/rpc', + 'https://blastl2-mainnet.public.blastapi.io', + 'https://blast.blockpi.network/v1/rpc/public', + ], + }, + public: { + http: [ + 'https://rpc.blast.io', + 'https://rpc.ankr.com/blast', + 'https://blast.din.dev/rpc', + 'https://blastl2-mainnet.public.blastapi.io', + 'https://blast.blockpi.network/v1/rpc/public', + ], + }, + }, + blockExplorers: { + default: { name: 'BlastScan', url: 'https://blastscan.io/' }, + }, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 88189, + }, + }, +} as const + +export const skaleEuropa = { + id: EvmChainId.SKALE_EUROPA, + name: 'SKALE Europa', + network: 'skale-europa', + nativeCurrency: { + decimals: 18, + name: 'SKALE Fuel', + symbol: 'sFUEL', + }, + rpcUrls: { + default: { + http: ['https://mainnet.skalenodes.com/v1/elated-tan-skat'], + }, + public: { + http: ['https://mainnet.skalenodes.com/v1/elated-tan-skat'], + }, + }, + blockExplorers: { + default: { + name: 'Blockscout', + url: 'https://elated-tan-skat.explorer.mainnet.skalenodes.com/', + }, + }, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 3113495, + }, + }, +} as const + +export const curtis = { + ..._curtis, + contracts: { + multicall3: { + address: '0xc454132B017b55b427f45078E335549A7124f5f7', + blockCreated: 6661339, + }, + }, +} + +export const apeChain = { + id: 33139, + name: 'Ape Chain', + nativeCurrency: { + name: 'ApeCoin', + symbol: 'APE', + decimals: 18, + }, + rpcUrls: { + default: { + http: ['https://rpc.apechain.com/http'], + webSocket: ['wss://rpc.apechain.com/ws'], + }, + }, + blockExplorers: { + default: { + name: 'Apescan', + url: 'https://apescan.io', + apiUrl: 'https://api.apescan.io', + }, + }, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 20889, + }, + }, + sourceId: 42_161, +} as const + +export const sonic = { + id: 146, + name: 'Sonic', + nativeCurrency: { + decimals: 18, + name: 'Sonic', + symbol: 'S', + }, + rpcUrls: { + default: { http: ['https://rpc.soniclabs.com'] }, + }, + blockExplorers: { + default: { + name: 'Sonic Explorer', + url: 'https://sonicscan.org', + apiUrl: 'https://api.sonicscan.org/api', + }, + }, + testnet: false, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 60, + }, + }, +} as const + +export const hemi = { + id: 43111, + name: 'Hemi Network', + nativeCurrency: { + decimals: 18, + name: 'Ether', + symbol: 'ETH', + }, + rpcUrls: { + default: { http: ['https://9277255a.rpc.hemi.network/rpc'] }, + }, + blockExplorers: { + default: { + name: 'Hemi Explorer', + url: 'https://explorer.hemi.xyz', + apiUrl: 'https://explorer.hemi.xyz/api', + }, + }, + testnet: false, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 0, + }, + }, +} as const + +const drpcId = process.env['DRPC_ID'] || process.env['NEXT_PUBLIC_DRPC_ID'] + +export const publicTransports = { + [EvmChainId.ARBITRUM_NOVA]: http( + `https://lb.drpc.org/ogrpc?network=arbitrum-nova&dkey=${drpcId}`, + ), + [EvmChainId.ARBITRUM]: http( + `https://lb.drpc.org/ogrpc?network=arbitrum&dkey=${drpcId}`, + ), + [EvmChainId.AVALANCHE]: http( + `https://lb.drpc.org/ogrpc?network=avalanche&dkey=${drpcId}`, + ), + [EvmChainId.BOBA]: http( + `https://lb.drpc.org/ogrpc?network=boba-eth&dkey=${drpcId}`, + ), + [EvmChainId.BOBA_AVAX]: http('https://avax.boba.network'), + [EvmChainId.BOBA_BNB]: http( + `https://lb.drpc.org/ogrpc?network=boba-bnb&dkey=${drpcId}`, + ), + [EvmChainId.BSC]: http( + `https://lb.drpc.org/ogrpc?network=bsc&dkey=${drpcId}`, + ), + [EvmChainId.BTTC]: http('https://rpc.bittorrentchain.io'), + [EvmChainId.CELO]: http( + `https://lb.drpc.org/ogrpc?network=celo&dkey=${drpcId}`, + ), + [EvmChainId.ETHEREUM]: http( + `https://lb.drpc.org/ogrpc?network=ethereum&dkey=${drpcId}`, + ), + [EvmChainId.FANTOM]: http( + `https://lb.drpc.org/ogrpc?network=fantom&dkey=${drpcId}`, + ), + [EvmChainId.FUSE]: http( + `https://lb.drpc.org/ogrpc?network=fuse&dkey=${drpcId}`, + ), + [EvmChainId.GNOSIS]: http( + `https://lb.drpc.org/ogrpc?network=gnosis&dkey=${drpcId}`, + ), + [EvmChainId.HARMONY]: http( + `https://lb.drpc.org/ogrpc?network=harmony-0&dkey=${drpcId}`, + ), + [EvmChainId.KAVA]: http( + `https://lb.drpc.org/ogrpc?network=kava&dkey=${drpcId}`, + ), + [EvmChainId.METIS]: http( + `https://lb.drpc.org/ogrpc?network=metis&dkey=${drpcId}`, + ), + [EvmChainId.MOONBEAM]: http( + `https://lb.drpc.org/ogrpc?network=moonbeam&dkey=${drpcId}`, + ), + [EvmChainId.MOONRIVER]: http( + `https://lb.drpc.org/ogrpc?network=moonriver&dkey=${drpcId}`, + ), + [EvmChainId.OPTIMISM]: http( + `https://lb.drpc.org/ogrpc?network=optimism&dkey=${drpcId}`, + ), + [EvmChainId.POLYGON]: http( + `https://lb.drpc.org/ogrpc?network=polygon&dkey=${drpcId}`, + ), + [EvmChainId.POLYGON_ZKEVM]: http( + `https://lb.drpc.org/ogrpc?network=polygon-zkevm&dkey=${drpcId}`, + ), + [EvmChainId.THUNDERCORE]: http( + `https://lb.drpc.org/ogrpc?network=thundercore&dkey=${drpcId}`, + ), + [EvmChainId.HAQQ]: http( + `https://lb.drpc.org/ogrpc?network=haqq&dkey=${drpcId}`, + ), + [EvmChainId.CORE]: http( + `https://lb.drpc.org/ogrpc?network=core&dkey=${drpcId}`, + ), + [EvmChainId.TELOS]: http( + `https://lb.drpc.org/ogrpc?network=telos&dkey=${drpcId}`, + ), + [EvmChainId.PALM]: http(palm.rpcUrls.default.http[0]), + [EvmChainId.OKEX]: http(okc.rpcUrls.default.http[0]), + [EvmChainId.HECO]: http( + `https://lb.drpc.org/ogrpc?network=heco&dkey=${drpcId}`, + ), + [EvmChainId.ZKSYNC_ERA]: http( + `https://lb.drpc.org/ogrpc?network=zksync&dkey=${drpcId}`, + ), + [EvmChainId.LINEA]: http( + `https://lb.drpc.org/ogrpc?network=linea&dkey=${drpcId}`, + ), + [EvmChainId.BASE]: http( + `https://lb.drpc.org/ogrpc?network=base&dkey=${drpcId}`, + ), + [EvmChainId.SCROLL]: http( + `https://lb.drpc.org/ogrpc?network=scroll&dkey=${drpcId}`, + ), + [EvmChainId.FILECOIN]: http( + `https://lb.drpc.org/ogrpc?network=filecoin&dkey=${drpcId}`, + // 'https://fil-mainnet-1.rpc.laconic.com/rpc/v1' + ), + [EvmChainId.ZETACHAIN]: http( + `https://lb.drpc.org/ogrpc?network=zeta-chain&dkey=${drpcId}`, + ), + [EvmChainId.CRONOS]: http( + `https://lb.drpc.org/ogrpc?network=cronos&dkey=${drpcId}`, + ), + [EvmChainId.BLAST]: http( + `https://lb.drpc.org/ogrpc?network=blast&dkey=${drpcId}`, + ), + [EvmChainId.SKALE_EUROPA]: http( + 'https://elated-tan-skat-indexer.skalenodes.com:10072', + ), + [EvmChainId.ROOTSTOCK]: http( + `https://lb.drpc.org/ogrpc?network=rootstock&dkey=${drpcId}`, + ), + [EvmChainId.MANTLE]: http( + `https://lb.drpc.org/ogrpc?network=mantle&dkey=${drpcId}`, + ), + [EvmChainId.MANTA]: http( + `https://lb.drpc.org/ogrpc?network=manta-pacific&dkey=${drpcId}`, + ), + [EvmChainId.MODE]: http( + `https://lb.drpc.org/ogrpc?network=mode&dkey=${drpcId}`, + ), + [EvmChainId.TAIKO]: http( + `https://lb.drpc.org/ogrpc?network=taiko&dkey=${drpcId}`, + ), + [EvmChainId.ZKLINK]: http('https://rpc.zklink.io'), + [EvmChainId.APE]: http( + `https://lb.drpc.org/ogrpc?network=apechain&dkey=${drpcId}`, + ), + [EvmChainId.SONIC]: http( + `https://lb.drpc.org/ogrpc?network=sonic&dkey=${drpcId}`, + ), + [EvmChainId.HEMI]: http('https://9277255a.rpc.hemi.network/rpc'), + /* Testnets */ // TODO: add testnet transports + [EvmChainId.ARBITRUM_TESTNET]: http('https://sepolia-rollup.arbitrum.io/rpc'), + [EvmChainId.AVALANCHE_TESTNET]: http( + 'https://api.avax-test.network/ext/bc/C/rpc', + ), + [EvmChainId.BSC_TESTNET]: http('https://bsc-testnet.public.blastapi.io'), + [EvmChainId.FANTOM_TESTNET]: http('https://rpc.testnet.fantom.network'), + [EvmChainId.POLYGON_TESTNET]: http('https://rpc.ankr.com/polygon_mumbai'), + [EvmChainId.SEPOLIA]: http('https://sepolia.drpc.org'), + [EvmChainId.GÖRLI]: http('https://eth-goerli.api.onfinality.io/public'), + [EvmChainId.CURTIS]: http('https://curtis.rpc.caldera.xyz/http'), +} as const satisfies Record + +export const publicChains = [ + mainnet, + arbitrumNova, + arbitrum, + avalanche, + boba, + bobaAvax, + bobaBnb, + bsc, + bttc, + blast, + celo as unknown as Omit & { id: 42220 }, + cronos, + fantom, + fuse, + gnosis, + harmonyOne, + kava, + metis, + optimism, + moonbeam, + moonriver, + polygon, + polygonZkEvm, + rootstock, + thundercore, + haqq, + core, + telos, + palm, + okc, + heco, + zkSync as unknown as Omit & { id: 324 }, + linea, + base, + scroll, + skaleEuropa, + filecoin, + zetachain, + mantle, + manta, + mode, + taiko, + zkLinkNova, + apeChain as unknown as Omit & { id: 33139 }, + sonic, + hemi, + /* Testnets */ + arbitrumSepolia, + avalancheFuji, + bscTestnet, + fantomTestnet, + goerli, + polygonMumbai, + sepolia, + curtis as unknown as Omit & { id: 33111 }, +] as const satisfies Readonly + +export const publicClientConfig = { + [EvmChainId.ARBITRUM_NOVA]: { + chain: arbitrumNova, + transport: publicTransports[EvmChainId.ARBITRUM_NOVA], + }, + [EvmChainId.ARBITRUM]: { + chain: arbitrum, + transport: publicTransports[EvmChainId.ARBITRUM], + }, + [EvmChainId.AVALANCHE]: { + chain: avalanche, + transport: publicTransports[EvmChainId.AVALANCHE], + }, + [EvmChainId.BOBA]: { + chain: boba, + transport: publicTransports[EvmChainId.BOBA], + }, + [EvmChainId.BOBA_AVAX]: { + chain: bobaAvax, + transport: publicTransports[EvmChainId.BOBA_AVAX], + }, + [EvmChainId.BOBA_BNB]: { + chain: bobaBnb, + transport: publicTransports[EvmChainId.BOBA_BNB], + }, + [EvmChainId.BSC]: { + chain: bsc, + transport: publicTransports[EvmChainId.BSC], + }, + [EvmChainId.BTTC]: { + chain: bttc, + transport: publicTransports[EvmChainId.BTTC], + }, + [EvmChainId.CELO]: { + chain: celo as unknown as typeof mainnet & { id: 42220 }, + transport: publicTransports[EvmChainId.CELO], + }, + [EvmChainId.ETHEREUM]: { + chain: mainnet, + transport: publicTransports[EvmChainId.ETHEREUM], + }, + [EvmChainId.FANTOM]: { + chain: fantom, + transport: publicTransports[EvmChainId.FANTOM], + }, + [EvmChainId.FUSE]: { + chain: fuse, + transport: publicTransports[EvmChainId.FUSE], + }, + [EvmChainId.GNOSIS]: { + chain: gnosis, + transport: publicTransports[EvmChainId.GNOSIS], + }, + [EvmChainId.HARMONY]: { + chain: harmonyOne, + transport: publicTransports[EvmChainId.HARMONY], + }, + [EvmChainId.KAVA]: { + chain: kava, + transport: publicTransports[EvmChainId.KAVA], + }, + [EvmChainId.METIS]: { + chain: metis, + transport: publicTransports[EvmChainId.METIS], + }, + [EvmChainId.MOONBEAM]: { + chain: moonbeam, + transport: publicTransports[EvmChainId.MOONBEAM], + }, + [EvmChainId.MOONRIVER]: { + chain: moonriver, + transport: publicTransports[EvmChainId.MOONRIVER], + }, + [EvmChainId.OPTIMISM]: { + chain: optimism, + transport: publicTransports[EvmChainId.OPTIMISM], + }, + [EvmChainId.POLYGON]: { + chain: polygon, + transport: publicTransports[EvmChainId.POLYGON], + }, + [EvmChainId.POLYGON_ZKEVM]: { + chain: polygonZkEvm, + transport: publicTransports[EvmChainId.POLYGON_ZKEVM], + }, + [EvmChainId.THUNDERCORE]: { + chain: thundercore, + transport: publicTransports[EvmChainId.THUNDERCORE], + }, + [EvmChainId.HAQQ]: { + chain: haqq, + transport: publicTransports[EvmChainId.HAQQ], + }, + [EvmChainId.CORE]: { + chain: core, + transport: publicTransports[EvmChainId.CORE], + }, + [EvmChainId.TELOS]: { + chain: telos, + transport: publicTransports[EvmChainId.TELOS], + }, + [EvmChainId.PALM]: { + chain: palm, + transport: publicTransports[EvmChainId.PALM], + }, + [EvmChainId.OKEX]: { + chain: okc, + transport: publicTransports[EvmChainId.OKEX], + }, + [EvmChainId.HECO]: { + chain: heco, + transport: publicTransports[EvmChainId.HECO], + }, + [EvmChainId.ZKSYNC_ERA]: { + chain: zkSync as unknown as typeof mainnet & { id: 324 }, + transport: publicTransports[EvmChainId.ZKSYNC_ERA], + }, + [EvmChainId.LINEA]: { + chain: linea, + transport: publicTransports[EvmChainId.LINEA], + }, + [EvmChainId.BASE]: { + chain: base, + transport: publicTransports[EvmChainId.BASE], + }, + [EvmChainId.SCROLL]: { + chain: scroll, + transport: publicTransports[EvmChainId.SCROLL], + }, + [EvmChainId.FILECOIN]: { + chain: filecoin, + transport: publicTransports[EvmChainId.FILECOIN], + }, + [EvmChainId.ZETACHAIN]: { + chain: zetachain, + transport: publicTransports[EvmChainId.ZETACHAIN], + }, + [EvmChainId.CRONOS]: { + chain: cronos, + transport: publicTransports[EvmChainId.CRONOS], + }, + [EvmChainId.BLAST]: { + chain: blast, + transport: publicTransports[EvmChainId.BLAST], + }, + [EvmChainId.SKALE_EUROPA]: { + chain: skaleEuropa, + transport: publicTransports[EvmChainId.SKALE_EUROPA], + }, + [EvmChainId.ROOTSTOCK]: { + chain: rootstock, + transport: publicTransports[EvmChainId.ROOTSTOCK], + }, + [EvmChainId.MANTLE]: { + chain: mantle, + transport: publicTransports[EvmChainId.MANTLE], + }, + [EvmChainId.MANTA]: { + chain: manta, + transport: publicTransports[EvmChainId.MANTA], + }, + [EvmChainId.MODE]: { + chain: mode, + transport: publicTransports[EvmChainId.MODE], + }, + [EvmChainId.TAIKO]: { + chain: taiko, + transport: publicTransports[EvmChainId.TAIKO], + }, + [EvmChainId.ZKLINK]: { + chain: zkLinkNova, + transport: publicTransports[EvmChainId.ZKLINK], + }, + [EvmChainId.APE]: { + chain: apeChain as unknown as typeof mainnet & { id: 33139 }, + transport: publicTransports[EvmChainId.APE], + }, + [EvmChainId.SONIC]: { + chain: sonic, + transport: publicTransports[EvmChainId.SONIC], + }, + [EvmChainId.HEMI]: { + chain: hemi, + transport: publicTransports[EvmChainId.HEMI], + }, + /* Testnets */ + [EvmChainId.ARBITRUM_TESTNET]: { + chain: arbitrumSepolia, + transport: publicTransports[EvmChainId.ARBITRUM_TESTNET], + }, + [EvmChainId.AVALANCHE_TESTNET]: { + chain: avalancheFuji, + transport: publicTransports[EvmChainId.AVALANCHE_TESTNET], + }, + [EvmChainId.BSC_TESTNET]: { + chain: bscTestnet, + transport: publicTransports[EvmChainId.BSC_TESTNET], + }, + [EvmChainId.FANTOM_TESTNET]: { + chain: fantomTestnet, + transport: publicTransports[EvmChainId.FANTOM_TESTNET], + }, + [EvmChainId.GÖRLI]: { + chain: goerli, + transport: publicTransports[EvmChainId.GÖRLI], + }, + [EvmChainId.POLYGON_TESTNET]: { + chain: polygonMumbai, + transport: publicTransports[EvmChainId.POLYGON_TESTNET], + }, + [EvmChainId.SEPOLIA]: { + chain: sepolia, + transport: publicTransports[EvmChainId.SEPOLIA], + }, + [EvmChainId.CURTIS]: { + chain: curtis as unknown as typeof mainnet & { id: 33111 }, + transport: publicTransports[EvmChainId.CURTIS], + }, +} as const satisfies Record< + EvmChainId, + PublicClientConfig & { chain: (typeof publicChains)[number] } +> diff --git a/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance.ts b/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance.ts index ffa0311b6a..ca717dff05 100644 --- a/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance.ts +++ b/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance.ts @@ -2,14 +2,14 @@ import { useQueryClient } from '@tanstack/react-query' import { useEffect } from 'react' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Amount, Token } from 'sushi/currency' import { Address, erc20Abi } from 'viem' import { useBlockNumber, useReadContract } from 'wagmi' interface UseTokenAllowance { token?: Token - chainId: ChainId | undefined + chainId: EvmChainId | undefined owner: Address | undefined spender: Address | undefined enabled?: boolean diff --git a/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenPermit.ts b/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenPermit.ts index cf95658d4f..0cb4b3c557 100644 --- a/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenPermit.ts +++ b/apps/web/src/lib/wagmi/hooks/approvals/hooks/useTokenPermit.ts @@ -4,7 +4,7 @@ import { TTLStorageKey } from '@sushiswap/hooks' import { createErrorToast } from '@sushiswap/notifications' import { useCallback, useMemo, useState } from 'react' import { eip2612Abi_nonces } from 'sushi/abi' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' import { Address, UserRejectedRequestError, hexToSignature } from 'viem' import { useAccount, useReadContract, useSignTypedData } from 'wagmi' @@ -84,7 +84,7 @@ export const useTokenPermit = ({ const { signTypedDataAsync } = useSignTypedData() const { data: transactionDeadline } = useTransactionDeadline({ - chainId: chainId as ChainId, + chainId: chainId as EvmChainId, storageKey: ttlStorageKey, enabled, }) diff --git a/apps/web/src/lib/wagmi/hooks/balances/useBalanceWeb3.ts b/apps/web/src/lib/wagmi/hooks/balances/useBalanceWeb3.ts index a8f0637c70..a823a04265 100644 --- a/apps/web/src/lib/wagmi/hooks/balances/useBalanceWeb3.ts +++ b/apps/web/src/lib/wagmi/hooks/balances/useBalanceWeb3.ts @@ -1,5 +1,5 @@ import { useQuery } from '@tanstack/react-query' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Type } from 'sushi/currency' import { Address, zeroAddress } from 'viem' @@ -8,7 +8,7 @@ import { useWatchByInterval } from '../watch/useWatchByInterval' import { queryFnUseBalances } from './useBalancesWeb3' interface UseBalanceParams { - chainId: ChainId | undefined + chainId: EvmChainId | undefined currency: Type | undefined account: Address | undefined enabled?: boolean diff --git a/apps/web/src/lib/wagmi/hooks/balances/useBalancesWeb3.ts b/apps/web/src/lib/wagmi/hooks/balances/useBalancesWeb3.ts index 75a953e01e..8cf8b5747c 100644 --- a/apps/web/src/lib/wagmi/hooks/balances/useBalancesWeb3.ts +++ b/apps/web/src/lib/wagmi/hooks/balances/useBalancesWeb3.ts @@ -1,6 +1,6 @@ import { useQuery } from '@tanstack/react-query' import { useEffect } from 'react' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Amount, Native, Token, Type } from 'sushi/currency' import { Address, erc20Abi, isAddress, zeroAddress } from 'viem' @@ -10,7 +10,7 @@ import { GetBalanceReturnType } from 'wagmi/actions' import { useWatchByInterval } from '../watch/useWatchByInterval' interface QueryBalanceParams { - chainId: ChainId | undefined + chainId: EvmChainId | undefined currencies: (Type | undefined)[] account: Address | undefined nativeBalance?: GetBalanceReturnType @@ -81,7 +81,7 @@ export const queryFnUseBalances = async ({ } interface UseBalanceParams { - chainId: ChainId | undefined + chainId: EvmChainId | undefined currencies: (Type | undefined)[] account: Address | undefined enabled?: boolean diff --git a/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts b/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts index c8d3512c0e..58be9543e6 100644 --- a/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts +++ b/apps/web/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts @@ -3,7 +3,7 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query' import { useMemo } from 'react' import { ChefType, RewarderType } from 'sushi' -import { chainShortName } from 'sushi/chain' +import { evmChainShortName, isEvmChainId } from 'sushi/chain' import { Token } from 'sushi/currency' import { PoolType } from '../pools/types' @@ -77,27 +77,29 @@ export const useFarmRewards = ({ ? Object.entries(farmsMap).reduce>>( (acc, [_chainId, j]) => { const chainId = Number(_chainId) + if (!isEvmChainId(chainId)) return acc acc[chainId] = { ...j, farms: Object.entries(farmsMap[chainId].farms).reduce< Record> >((acc, [farm, v]) => { - acc[`${chainShortName[chainId]}:${farm.toLowerCase()}`] = { - ...v, - incentives: farmsMap[chainId].farms[farm].incentives - .filter((el) => el.rewardToken.address !== '') - .map((el) => { - return { - ...el, - rewardToken: new Token({ - chainId, - address: el.rewardToken.address, - symbol: el.rewardToken.symbol, - decimals: 18, - }), - } - }), - } + acc[`${evmChainShortName[chainId]}:${farm.toLowerCase()}`] = + { + ...v, + incentives: farmsMap[chainId].farms[farm].incentives + .filter((el) => el.rewardToken.address !== '') + .map((el) => { + return { + ...el, + rewardToken: new Token({ + chainId, + address: el.rewardToken.address, + symbol: el.rewardToken.symbol, + decimals: 18, + }), + } + }), + } return acc }, {}), } diff --git a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-deposit.ts b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-deposit.ts index a4c6174336..8794c418c4 100644 --- a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-deposit.ts +++ b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-deposit.ts @@ -13,12 +13,12 @@ import { } from 'wagmi' import { SendTransactionReturnType } from 'wagmi/actions' -import { ChainId, ChefType } from 'sushi' +import { ChefType, EvmChainId } from 'sushi' import { masterChefV1Abi_deposit, masterChefV2Abi_deposit } from 'sushi/abi' import { useMasterChefContract } from './use-master-chef-contract' interface UseMasterChefDepositParams { - chainId: ChainId | undefined + chainId: EvmChainId | undefined chef: ChefType pid: number amount?: Amount diff --git a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw.ts b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw.ts index 84474d686f..48f46756c4 100644 --- a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw.ts +++ b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw.ts @@ -2,7 +2,7 @@ import { createErrorToast, createToast } from '@sushiswap/notifications' import { useCallback, useMemo } from 'react' -import { ChainId, ChefType } from 'sushi' +import { ChefType, EvmChainId } from 'sushi' import { masterChefV1Abi_withdraw, masterChefV2Abi_withdraw, @@ -21,7 +21,7 @@ import { SendTransactionReturnType } from 'wagmi/actions' import { getMasterChefContractConfig } from './use-master-chef-contract' interface UseMasterChefWithdrawParams { - chainId: ChainId + chainId: EvmChainId chef: ChefType pid: number amount?: Amount diff --git a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef.ts b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef.ts index 411c3d85a0..b555cb6665 100644 --- a/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef.ts +++ b/apps/web/src/lib/wagmi/hooks/master-chef/use-master-chef.ts @@ -12,7 +12,7 @@ import { masterChefV2Abi_harvestFromMasterChef, miniChefV2Abi_harvest, } from 'sushi/abi' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { MASTERCHEF_ADDRESS, MASTERCHEF_V2_ADDRESS, @@ -42,7 +42,7 @@ interface UseMasterChefReturn } interface UseMasterChefParams { - chainId: ChainId + chainId: EvmChainId chef: ChefType pid: number token: Token | undefined @@ -67,10 +67,10 @@ export const useMasterChef: UseMasterChef = ({ const contracts = useMemo(() => { if (!chainId || !enabled || !address) return [] - if (chainId === ChainId.ETHEREUM) { + if (chainId === EvmChainId.ETHEREUM) { return [ { - chainId: ChainId.ETHEREUM as ChainId, + chainId: EvmChainId.ETHEREUM as EvmChainId, address: SUSHI_ADDRESS[chainId] as Address, abi: erc20Abi_balanceOf, functionName: 'balanceOf', @@ -81,7 +81,7 @@ export const useMasterChef: UseMasterChef = ({ ], } as const, { - chainId: ChainId.ETHEREUM as ChainId, + chainId: EvmChainId.ETHEREUM as EvmChainId, address: (chef === ChefType.MasterChefV1 ? MASTERCHEF_ADDRESS[chainId] : MASTERCHEF_V2_ADDRESS[chainId]) as Address, @@ -134,7 +134,7 @@ export const useMasterChef: UseMasterChef = ({ args: [pid, address as Address], } as const, { - chainId: ChainId.ETHEREUM as ChainId, + chainId: EvmChainId.ETHEREUM as EvmChainId, address: MASTERCHEF_V2_ADDRESS[chainId] as Address, abi: [ { diff --git a/apps/web/src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions.ts b/apps/web/src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions.ts index b4d04e46db..3931400efe 100644 --- a/apps/web/src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions.ts +++ b/apps/web/src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions.ts @@ -2,7 +2,6 @@ import { createErrorToast, createToast } from '@sushiswap/notifications' import { useCallback, useMemo, useState } from 'react' -import { ChainId } from 'sushi/chain' import { SendTransactionReturnType, UserRejectedRequestError } from 'viem' import { useAccount, @@ -20,6 +19,26 @@ export enum AngleConditionsState { ACCEPTED = 'ACCEPTED', } +const userSignatureWhitelistAbi = [ + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'userSignatureWhitelist', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, +] as const + +const acceptConditionsAbi = [ + { + inputs: [], + name: 'acceptConditions', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + export const useAcceptAngleConditions = ( { enabled = true }: { enabled?: boolean } = { enabled: true }, ) => { @@ -32,17 +51,10 @@ export const useAcceptAngleConditions = ( refetch, } = useReadContract({ address: '0x8BB4C975Ff3c250e0ceEA271728547f3802B36Fd', - abi: [ - { - inputs: [{ internalType: 'address', name: '', type: 'address' }], - name: 'userSignatureWhitelist', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - ] as const, + abi: userSignatureWhitelistAbi, functionName: 'userSignatureWhitelist', - chainId: chainId as ChainId, + // Typescript hack, prevents the "Instantiation too deep" error + chainId: chainId as 42161, args: [address!], query: { enabled: Boolean(enabled && address && chainId), @@ -51,16 +63,10 @@ export const useAcceptAngleConditions = ( const { data: simulation } = useSimulateContract({ address: '0x8BB4C975Ff3c250e0ceEA271728547f3802B36Fd', - abi: [ - { - inputs: [], - name: 'acceptConditions', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - ] as const, + abi: acceptConditionsAbi, functionName: 'acceptConditions', + // Typescript hack, prevents the "Instantiation too deep" error + chainId: chainId as 42161, query: { enabled: Boolean( enabled && @@ -124,9 +130,8 @@ export const useAcceptAngleConditions = ( if (!simulation?.request) return return () => execute.writeContract(simulation.request as any) - // eslint-disable-next-line react-hooks/exhaustive-deps }, - [execute.writeContract, simulation?.request] as const, + [execute.writeContract, simulation] as const, ) return useMemo< diff --git a/apps/web/src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards.ts b/apps/web/src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards.ts index 6c3169c1cf..06a8278539 100644 --- a/apps/web/src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards.ts +++ b/apps/web/src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards.ts @@ -1,6 +1,6 @@ import { createErrorToast, createToast } from '@sushiswap/notifications' import { useCallback, useMemo } from 'react' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Address, UserRejectedRequestError } from 'viem' import { useAccount, @@ -13,7 +13,7 @@ import { useRefetchBalances } from '~evm/_common/ui/balance-provider/use-refetch interface UseHarvestAngleRewards { account: Address | undefined - chainId: ChainId + chainId: EvmChainId enabled?: boolean args: | { diff --git a/apps/web/src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts b/apps/web/src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts index 1fe2b1769e..5fad06e0bd 100644 --- a/apps/web/src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts +++ b/apps/web/src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts @@ -1,6 +1,6 @@ import { createErrorToast, createToast } from '@sushiswap/notifications' import { useCallback } from 'react' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Address, UserRejectedRequestError } from 'viem' import { UseSimulateContractParameters, @@ -70,7 +70,7 @@ const distributionCreatorAbi_createDistribution = [ interface UseHarvestAngleRewards { account: Address | undefined - chainId: ChainId + chainId: EvmChainId enabled?: boolean args: | UseSimulateContractParameters< diff --git a/apps/web/src/lib/wagmi/hooks/tokens/useTokenWithCache.ts b/apps/web/src/lib/wagmi/hooks/tokens/useTokenWithCache.ts index 3fb4615f49..0b608075b9 100644 --- a/apps/web/src/lib/wagmi/hooks/tokens/useTokenWithCache.ts +++ b/apps/web/src/lib/wagmi/hooks/tokens/useTokenWithCache.ts @@ -7,14 +7,14 @@ import { keepPreviousData, useQuery } from '@tanstack/react-query' import { getToken as getTokenWeb3 } from '@wagmi/core/actions' import { useCallback } from 'react' import type { ID } from 'sushi' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Token } from 'sushi/currency' import { Address, getAddress, isAddress } from 'viem' import { useConfig } from 'wagmi' import { PublicWagmiConfig } from '../../config/public' interface UseTokenParams { - chainId: ChainId | undefined + chainId: EvmChainId | undefined address: Address | undefined enabled?: boolean keepPreviousData?: boolean @@ -32,7 +32,7 @@ type Data = { } export const getTokenWithQueryCacheHydrate = ( - chainId: ChainId | undefined, + chainId: EvmChainId | undefined, data: Data, ): UseTokenReturn | undefined => { if (data && chainId) { @@ -53,7 +53,7 @@ export const getTokenWithQueryCacheHydrate = ( } interface GetTokenWithQueryCacheFn { - chainId: ChainId | undefined + chainId: EvmChainId | undefined address: Address | undefined | null customTokens: Record hasToken: (cur: string | Token) => boolean diff --git a/apps/web/src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline.ts b/apps/web/src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline.ts index 67f73c4dd2..a9b6000665 100644 --- a/apps/web/src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline.ts +++ b/apps/web/src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline.ts @@ -1,17 +1,17 @@ import { TTLStorageKey, useTTL } from '@sushiswap/hooks' import { useQuery } from '@tanstack/react-query' -import { ChainId, chainsL2 } from 'sushi/chain' +import { EvmChainId, evmChainsL2 } from 'sushi/chain' import { useCurrentBlockTimestamp } from '../../block/useCurrentBlockTimestamp' const L2_TTL = 5n const TTL = 30n -export const getDefaultTTL = (chainId: ChainId) => { - return Object.keys(chainsL2).includes(chainId.toString()) ? L2_TTL : TTL +export const getDefaultTTL = (chainId: EvmChainId) => { + return evmChainsL2[chainId] ? L2_TTL : TTL } interface UseTransactionDeadline { - chainId: ChainId + chainId: EvmChainId enabled?: boolean storageKey: TTLStorageKey } diff --git a/apps/web/src/lib/wagmi/hooks/watch/useWatchByBlock.ts b/apps/web/src/lib/wagmi/hooks/watch/useWatchByBlock.ts index 48d0dc1d65..f021c54ea3 100644 --- a/apps/web/src/lib/wagmi/hooks/watch/useWatchByBlock.ts +++ b/apps/web/src/lib/wagmi/hooks/watch/useWatchByBlock.ts @@ -1,6 +1,6 @@ import { QueryKey, useQueryClient } from '@tanstack/react-query' import { useEffect, useMemo } from 'react' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { useBlockNumber } from 'wagmi' type UseWatchByBlockKey = { @@ -14,7 +14,7 @@ type UseWatchByBlockKeys = { } type UseWatchByBlock = { - chainId: ChainId | undefined + chainId: EvmChainId | undefined // Refresh every modulo blocks modulo?: number } & (UseWatchByBlockKey | UseWatchByBlockKeys) diff --git a/apps/web/src/lib/wagmi/systems/Checker/Amounts.tsx b/apps/web/src/lib/wagmi/systems/Checker/Amounts.tsx index 885e366688..ee3774d157 100644 --- a/apps/web/src/lib/wagmi/systems/Checker/Amounts.tsx +++ b/apps/web/src/lib/wagmi/systems/Checker/Amounts.tsx @@ -2,13 +2,13 @@ import { Button, ButtonProps } from '@sushiswap/ui' import { FC, useMemo } from 'react' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' import { ZERO } from 'sushi/math' import { useAmountBalances } from '~evm/_common/ui/balance-provider/use-balances' type AmountsProps = ButtonProps & { - chainId: ChainId | undefined + chainId: EvmChainId | undefined } & ( | { amounts: (Amount | undefined)[]; amount?: undefined } | { amounts?: undefined; amount: Amount | undefined } diff --git a/apps/web/src/lib/wagmi/systems/Checker/Network.tsx b/apps/web/src/lib/wagmi/systems/Checker/Network.tsx index 102e6aec87..e23848a735 100644 --- a/apps/web/src/lib/wagmi/systems/Checker/Network.tsx +++ b/apps/web/src/lib/wagmi/systems/Checker/Network.tsx @@ -4,11 +4,11 @@ import { InformationCircleIcon } from '@heroicons/react/24/solid' import { HoverCard, HoverCardContent, HoverCardTrigger } from '@sushiswap/ui' import { Button, ButtonProps } from '@sushiswap/ui' import { FC, ReactElement, ReactNode } from 'react' -import { ChainId, chainName } from 'sushi/chain' +import { EvmChainId, evmChainName } from 'sushi/chain' import { useAccount, useSwitchChain } from 'wagmi' interface NetworkProps extends ButtonProps { - chainId: ChainId | undefined + chainId: EvmChainId | undefined hoverCardContent?: ReactNode | undefined } @@ -36,7 +36,7 @@ const Network: FC = ({ testId={`switch-network-${chainId}`} {...rest} > - Switch to {chainName[chainId]} + Switch to {evmChainName[chainId]} ) : ( @@ -47,7 +47,7 @@ const Network: FC = ({ testId={`switch-network-${chainId}`} {...rest} > - Switch to {chainName[chainId]} + Switch to {evmChainName[chainId]} diff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.ts index ad5ace2335..590dadea33 100644 --- a/apps/web/src/middleware.ts +++ b/apps/web/src/middleware.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from 'next/server' -import { ChainKey, getChainInfo } from 'sushi/chain' +import { ChainKey, getEvmChainInfo } from 'sushi/chain' import { isSushiSwapChainId } from 'sushi/config' export const config = { @@ -57,7 +57,7 @@ export async function middleware(req: NextRequest) { /([\w-]+)(?=\/swap|\/limit|\/dca|\/cross-chain-swap|\/explore|\/pool|\/positions|\/rewards|\/migrate)/, ) if (networkNameMatch?.length) { - const { chainId, networkName } = getChainInfo(networkNameMatch[0]) + const { chainId, networkName } = getEvmChainInfo(networkNameMatch[0]) if (!chainId) return NextResponse.next() const url = req.nextUrl.clone() diff --git a/apps/web/src/ui/explore/global-stats-loading.tsx b/apps/web/src/ui/explore/global-stats-loading.tsx index efb3a2aa33..c8277bde44 100644 --- a/apps/web/src/ui/explore/global-stats-loading.tsx +++ b/apps/web/src/ui/explore/global-stats-loading.tsx @@ -1,6 +1,6 @@ import { SkeletonChart, SkeletonText } from '@sushiswap/ui' import { FC } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' export const GlobalStatsLoading: FC<{ chainId: ChainId }> = ({ chainId }) => { return ( @@ -8,7 +8,7 @@ export const GlobalStatsLoading: FC<{ chainId: ChainId }> = ({ chainId }) => {
- {Chain.from(chainId)?.name} TVL + {EvmChain.from(chainId)?.name} TVL @@ -18,7 +18,7 @@ export const GlobalStatsLoading: FC<{ chainId: ChainId }> = ({ chainId }) => {
- {Chain.from(chainId)?.name} Volume + {EvmChain.from(chainId)?.name} Volume diff --git a/apps/web/src/ui/explore/tvl-chart.tsx b/apps/web/src/ui/explore/tvl-chart.tsx index 7a7fb2a9e4..430ae6eaf7 100644 --- a/apps/web/src/ui/explore/tvl-chart.tsx +++ b/apps/web/src/ui/explore/tvl-chart.tsx @@ -8,7 +8,7 @@ import { EChartsOption } from 'echarts-for-react/lib/types' import echarts from 'echarts/lib/echarts' import { useTheme } from 'next-themes' import { FC, useCallback, useMemo } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' import { formatUSD } from 'sushi/format' interface TVLChart { @@ -186,7 +186,7 @@ export const TVLChart: FC = ({ data, chainId }) => {
- {Chain.from(chainId)?.name} TVL + {EvmChain.from(chainId)?.name} TVL
diff --git a/apps/web/src/ui/explore/volume-chart.tsx b/apps/web/src/ui/explore/volume-chart.tsx index 3d051bb6b0..c97fc61415 100644 --- a/apps/web/src/ui/explore/volume-chart.tsx +++ b/apps/web/src/ui/explore/volume-chart.tsx @@ -7,7 +7,7 @@ import { EChartsOption } from 'echarts-for-react/lib/types' import echarts from 'echarts/lib/echarts' import { useTheme } from 'next-themes' import { FC, useCallback, useMemo } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' import { formatUSD } from 'sushi/format' interface VolumeChart { @@ -149,7 +149,7 @@ export const VolumeChart: FC = ({ data, chainId }) => {
- {Chain.from(chainId)?.name} Volume + {EvmChain.from(chainId)?.name} Volume
diff --git a/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx b/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx index 0613704b81..3c8ad1640c 100644 --- a/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx +++ b/apps/web/src/ui/pool/AddSectionReviewModalConcentrated.tsx @@ -33,7 +33,7 @@ import { getDefaultTTL, useTransactionDeadline, } from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' -import { Chain, ChainId } from 'sushi/chain' +import { EvmChain, EvmChainId } from 'sushi/chain' import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3FeeAmount, @@ -58,7 +58,7 @@ interface AddSectionReviewModalConcentratedProps ReturnType, 'noLiquidity' | 'position' | 'price' | 'pricesAtTicks' | 'ticksAtLimit' > { - chainId: ChainId + chainId: EvmChainId feeAmount: SushiSwapV3FeeAmount | undefined token0: Type | undefined token1: Type | undefined @@ -341,7 +341,7 @@ export const AddSectionReviewModalConcentrated: FC< - {Chain.from(chainId)?.name} + {EvmChain.from(chainId)?.name} {feeAmount && ( {`${ diff --git a/apps/web/src/ui/pool/AddSectionWidget.tsx b/apps/web/src/ui/pool/AddSectionWidget.tsx index 2dee1829f5..68fdb44a62 100644 --- a/apps/web/src/ui/pool/AddSectionWidget.tsx +++ b/apps/web/src/ui/pool/AddSectionWidget.tsx @@ -14,13 +14,13 @@ import React, { FC, ReactNode } from 'react' import { isZapSupportedChainId } from 'src/config' import { Web3Input } from 'src/lib/wagmi/components/web3-input' import { getDefaultTTL } from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Type } from 'sushi/currency' import { ToggleZapCard } from './ToggleZapCard' interface AddSectionWidgetProps { isFarm: boolean - chainId: ChainId + chainId: EvmChainId input0: string input1: string token0: Type | undefined diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityCollectAllWidget.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityCollectAllWidget.tsx new file mode 100644 index 0000000000..825abe454d --- /dev/null +++ b/apps/web/src/ui/pool/ConcentratedLiquidityCollectAllWidget.tsx @@ -0,0 +1,346 @@ +'use client' + +import { createErrorToast, createToast } from '@sushiswap/notifications' +import { + DialogConfirm, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogProvider, + DialogReview, + DialogTitle, + DialogTrigger, + Dots, + Switch, +} from '@sushiswap/ui' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import React, { FC, useCallback, useMemo, useState } from 'react' +import { ConcentratedLiquidityPositionWithV3Pool } from 'src/lib/wagmi/hooks/positions/types' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { EvmChain, EvmChainId } from 'sushi/chain' +import { + SUSHISWAP_V3_POSTIION_MANAGER, + isSushiSwapV3ChainId, +} from 'sushi/config' +import { Amount, Native, Type, unwrapToken } from 'sushi/currency' +import { NonfungiblePositionManager } from 'sushi/pool/sushiswap-v3' +import { Hex, SendTransactionReturnType, UserRejectedRequestError } from 'viem' +import { + useCall, + useSendTransaction, + useWaitForTransactionReceipt, +} from 'wagmi' +import { useAccount } from 'wagmi' +import { usePublicClient } from 'wagmi' +import { useRefetchBalances } from '~evm/_common/ui/balance-provider/use-refetch-balances' +import { useTokenAmountDollarValues } from '../../lib/hooks' + +interface ConcentratedLiquidityCollectAllWidget { + positions: ConcentratedLiquidityPositionWithV3Pool[] + chainId: EvmChainId + account: `0x${string}` | undefined +} + +export const ConcentratedLiquidityCollectAllWidget: FC< + ConcentratedLiquidityCollectAllWidget +> = ({ positions, chainId, account }) => { + const { chain } = useAccount() + const client = usePublicClient() + const { refetchChain: refetchBalances } = useRefetchBalances() + const [receiveWrapped, setReceiveWrapped] = useState(false) + + const nativeToken = useMemo(() => Native.onChain(chainId), [chainId]) + + const hasNativeToken = useMemo(() => { + return positions.some(({ pool: { token0, token1 } }) => { + if (!token0 || !token1 || !nativeToken) return false + return ( + token0.isNative || + token1.isNative || + token0.address === nativeToken.wrapped?.address || + token1.address === nativeToken.wrapped?.address + ) + }) + }, [positions, nativeToken]) + + const positionsToCollect = useMemo(() => { + return positions.flatMap((position) => { + const { token0, token1 } = position.pool + if (!token0 || !token1 || !position?.fees || !account) return [] + + const expectedToken0 = receiveWrapped + ? token0.wrapped + : unwrapToken(token0) + const expectedToken1 = receiveWrapped + ? token1.wrapped + : unwrapToken(token1) + + const feeValue0 = Amount.fromRawAmount(expectedToken0, position.fees[0]) + const feeValue1 = Amount.fromRawAmount(expectedToken1, position.fees[1]) + + if (feeValue0.equalTo(0n) && feeValue1.equalTo(0n)) return [] + + return [ + { + tokenId: position.tokenId.toString(), + expectedCurrencyOwed0: feeValue0, + expectedCurrencyOwed1: feeValue1, + recipient: account, + }, + ] + }) + }, [positions, receiveWrapped, account]) + + const aggregatedAmounts = useMemo(() => { + const aggregatedAmounts = new Map>() + + positionsToCollect.forEach((position) => { + const { expectedCurrencyOwed0, expectedCurrencyOwed1 } = position + + if (expectedCurrencyOwed0.greaterThan(0n)) { + const existing = aggregatedAmounts.get( + expectedCurrencyOwed0.currency.id, + ) + aggregatedAmounts.set( + expectedCurrencyOwed0.currency.id, + existing + ? existing.add(expectedCurrencyOwed0) + : expectedCurrencyOwed0, + ) + } + + if (expectedCurrencyOwed1.greaterThan(0n)) { + const existing = aggregatedAmounts.get( + expectedCurrencyOwed1.currency.id, + ) + aggregatedAmounts.set( + expectedCurrencyOwed1.currency.id, + existing + ? existing.add(expectedCurrencyOwed1) + : expectedCurrencyOwed1, + ) + } + }) + + return Array.from(aggregatedAmounts.values()) + }, [positionsToCollect]) + + const feeValues = useTokenAmountDollarValues({ + chainId, + amounts: aggregatedAmounts, + }) + + const totalFeeValue = useMemo(() => { + return feeValues.reduce((sum, value) => sum + value, 0) + }, [feeValues]) + + const prepare = useMemo(() => { + if (!isSushiSwapV3ChainId(chainId)) return + + if (positionsToCollect.length === 0) return + + const { calldata, value } = + NonfungiblePositionManager.collectCallParameters(positionsToCollect) + + return { + to: SUSHISWAP_V3_POSTIION_MANAGER[chainId], + data: calldata as Hex, + value: BigInt(value), + chainId, + } + }, [positionsToCollect, chainId]) + + const onSuccess = useCallback( + (hash: SendTransactionReturnType) => { + const receipt = client.waitForTransactionReceipt({ hash }) + receipt.then(() => { + refetchBalances(chainId) + }) + + const ts = new Date().getTime() + void createToast({ + account, + type: 'claimRewards', + chainId, + txHash: hash, + promise: receipt, + summary: { + pending: 'Collecting fees from all your pool positions', + completed: 'Successfully collected fees from all your pool positions', + failed: 'Something went wrong when trying to collect fees', + }, + timestamp: ts, + groupTimestamp: ts, + }) + }, + [account, chainId, client, refetchBalances], + ) + + const onError = useCallback((e: Error) => { + if (!(e.cause instanceof UserRejectedRequestError)) { + createErrorToast(e?.message, true) + } + }, []) + + const { isError: isSimulationError } = useCall({ + ...prepare, + chainId, + query: { + enabled: Boolean(prepare && chainId === chain?.id), + }, + }) + + const { + sendTransactionAsync, + isPending: isWritePending, + data: hash, + } = useSendTransaction({ + mutation: { + onSuccess, + onError, + }, + }) + + const { status } = useWaitForTransactionReceipt({ + chainId, + hash, + }) + + const send = useMemo(() => { + if (!prepare || isSimulationError) return undefined + + return async (confirm: () => void) => { + try { + await sendTransactionAsync(prepare) + confirm() + } catch {} + } + }, [isSimulationError, prepare, sendTransactionAsync]) + + return ( + + + {({ confirm }) => ( + <> + {aggregatedAmounts.length > 0 ? ( +
+ + + + + + + +
+ ) : null} + + + + Claim V3 Fees + + On {EvmChain.from(chainId)?.name} + + +
+
+ + Total Value + + + ${totalFeeValue.toFixed(2)} + +
+
+ + You'll receive collected fees: + +
+ {aggregatedAmounts.map((amount, i) => ( +
+
+ + + {amount.currency.symbol} + +
+
+ + {amount.toSignificant(6)} + + + ${feeValues[i].toFixed(1)} + +
+
+ ))} +
+
+ {hasNativeToken && ( +
+ + Receive {nativeToken?.wrapped.symbol} instead of{' '} + {nativeToken?.symbol} + + +
+ )} +
+ + + +
+ + )} +
+ +
+ ) +} diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityCollectButton.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityCollectButton.tsx index 9674c15112..dc342d6cc7 100644 --- a/apps/web/src/ui/pool/ConcentratedLiquidityCollectButton.tsx +++ b/apps/web/src/ui/pool/ConcentratedLiquidityCollectButton.tsx @@ -8,7 +8,7 @@ import { } from '@sushiswap/telemetry' import { FC, ReactElement, useCallback, useMemo } from 'react' import { ConcentratedLiquidityPosition } from 'src/lib/wagmi/hooks/positions/types' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { SUSHISWAP_V3_POSTIION_MANAGER, isSushiSwapV3ChainId, @@ -31,7 +31,7 @@ interface ConcentratedLiquidityCollectButton { token0: Type | undefined token1: Type | undefined account: `0x${string}` | undefined - chainId: ChainId + chainId: EvmChainId children( params: Omit< ReturnType, diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityCollectWidget.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityCollectWidget.tsx index 3b207f9c4e..089e021b47 100644 --- a/apps/web/src/ui/pool/ConcentratedLiquidityCollectWidget.tsx +++ b/apps/web/src/ui/pool/ConcentratedLiquidityCollectWidget.tsx @@ -12,7 +12,7 @@ import { Button } from '@sushiswap/ui' import { FC, useMemo, useState } from 'react' import { ConcentratedLiquidityPosition } from 'src/lib/wagmi/hooks/positions/types' import { Checker } from 'src/lib/wagmi/systems/Checker' -import { Address, ChainId, Position } from 'sushi' +import { Address, EvmChainId, Position } from 'sushi' import { Amount, Native, Type, unwrapToken } from 'sushi/currency' import { formatUSD } from 'sushi/format' import { ConcentratedLiquidityCollectButton } from './ConcentratedLiquidityCollectButton' @@ -22,7 +22,7 @@ interface ConcentratedLiquidityCollectWidget { positionDetails: ConcentratedLiquidityPosition | undefined token0: Type | undefined token1: Type | undefined - chainId: ChainId + chainId: EvmChainId isLoading: boolean address: Address | undefined amounts: undefined[] | Amount[] diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx index 5991ebbeb6..4bf8b395f8 100644 --- a/apps/web/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx +++ b/apps/web/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx @@ -3,13 +3,13 @@ import { FC, ReactElement, useMemo } from 'react' import { useAngleRewards } from 'src/lib/hooks/react-query' import { useHarvestAngleRewards } from 'src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Address } from 'viem' interface ConcentratedLiquidityHarvestButton { account: Address | undefined enabled?: boolean - chainId: ChainId + chainId: EvmChainId children(params: ReturnType): ReactElement } diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx index dc1bd826eb..21dddbc43b 100644 --- a/apps/web/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx +++ b/apps/web/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx @@ -47,7 +47,7 @@ import { useTransactionDeadline, } from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' import { Checker } from 'src/lib/wagmi/systems/Checker' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId, @@ -513,7 +513,7 @@ export const ConcentratedLiquidityRemoveWidget: FC< - {Chain.from(chainId)?.name} + {EvmChain.from(chainId)?.name} {slippageTolerance?.toSignificant(2)}% diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx index ddd8371b72..1ca8dd2c79 100644 --- a/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx +++ b/apps/web/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx @@ -3,7 +3,7 @@ import { usePathname, useRouter, useSearchParams } from 'next/navigation' import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react' import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { SUSHISWAP_V3_SUPPORTED_CHAIN_IDS, SushiSwapV3ChainId, @@ -52,11 +52,11 @@ export const ConcentratedLiquidityUrlStateContext = createContext( interface ConcentratedLiquidityURLStateProvider { children: ReactNode | ((state: State) => ReactNode) chainId: SushiSwapV3ChainId - supportedNetworks?: ChainId[] + supportedNetworks?: EvmChainId[] } const getTokenFromUrl = ( - chainId: ChainId, + chainId: EvmChainId, currencyId: string | undefined | null, token: Token | undefined, isLoading: boolean, @@ -70,7 +70,7 @@ const getTokenFromUrl = ( } else if (!currencyId || !isWNativeSupported(chainId)) { return undefined } else { - return Native.onChain(chainId ? chainId : ChainId.ETHEREUM) + return Native.onChain(chainId ? chainId : EvmChainId.ETHEREUM) } } @@ -95,7 +95,7 @@ export const ConcentratedLiquidityURLStateProvider: FC< const _chainId = supportedNetworks?.includes(chainId) ? chainId - : ChainId.ETHEREUM + : EvmChainId.ETHEREUM const { data: tokenFrom, isInitialLoading: isTokenFromLoading } = useTokenWithCache({ diff --git a/apps/web/src/ui/pool/ConcentratedLiquidityWidget.tsx b/apps/web/src/ui/pool/ConcentratedLiquidityWidget.tsx index d6467a3acc..669c323024 100644 --- a/apps/web/src/ui/pool/ConcentratedLiquidityWidget.tsx +++ b/apps/web/src/ui/pool/ConcentratedLiquidityWidget.tsx @@ -5,7 +5,6 @@ import { LockClosedIcon, PlusIcon } from '@heroicons/react-v1/solid' import { DialogTrigger, FormSection, Message, classNames } from '@sushiswap/ui' import { Button } from '@sushiswap/ui' import { FC, Fragment, useCallback, useMemo } from 'react' -import { ChainId } from 'sushi/chain' import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId, @@ -272,7 +271,7 @@ export const ConcentratedLiquidityWidget: FC = ({ enabled={!depositBDisabled} > = hideNewSmartPositionButton = true, hideNewPositionButton = false, hideClosedPositions = true, + hideCollectAllButton = false, actions, }) => { const { address } = useAccount() @@ -125,11 +128,17 @@ export const ConcentratedPositionsTable: FC = ({_positions.length}) - {actions} + {!hideCollectAllButton ? ( + + ) : null} {!hideNewSmartPositionButton ? ( ) : null} + {actions}
@@ -161,7 +171,7 @@ export const ConcentratedPositionsTable: FC = testId="concentrated-positions" loading={isInitialLoading} linkFormatter={(row) => - `/${ChainKey[row.chainId]}/pool/v3/${row.address}/${row.tokenId}` + `/${EvmChainKey[row.chainId]}/pool/v3/${row.address}/${row.tokenId}` } rowRenderer={rowRenderer} columns={COLUMNS} diff --git a/apps/web/src/ui/pool/MigrateTab.tsx b/apps/web/src/ui/pool/MigrateTab.tsx index b130f25863..38d7bcc04b 100644 --- a/apps/web/src/ui/pool/MigrateTab.tsx +++ b/apps/web/src/ui/pool/MigrateTab.tsx @@ -53,7 +53,7 @@ import { useApproved, withCheckerRoot, } from 'src/lib/wagmi/systems/Checker/Provider' -import { Chain, ChainId } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { SushiSwapV2ChainId, SushiSwapV3ChainId, @@ -345,7 +345,7 @@ export const MigrateTab: FC<{ pool: V2Pool }> = withCheckerRoot(({ pool }) => { const { approved: approvedMigrate } = useApproved(APPROVE_TAG_MIGRATE) const { data: deadline } = useTransactionDeadline({ storageKey: TTLStorageKey.AddLiquidity, - chainId: pool.chainId as ChainId, + chainId: pool.chainId, }) const { @@ -553,7 +553,7 @@ export const MigrateTab: FC<{ pool: V2Pool }> = withCheckerRoot(({ pool }) => { = withCheckerRoot(({ pool }) => { storageKey: TTLStorageKey.AddLiquidity, defaultValue: getDefaultTTL( - pool.chainId as ChainId, + pool.chainId, ).toString(), }, }} @@ -641,7 +641,7 @@ export const MigrateTab: FC<{ pool: V2Pool }> = withCheckerRoot(({ pool }) => { - {Chain.from(pool.chainId)?.name} + {EvmChain.from(pool.chainId)?.name} {feeAmount && ( {`${ diff --git a/apps/web/src/ui/pool/PoolHeader.tsx b/apps/web/src/ui/pool/PoolHeader.tsx index 0accb7fda3..5e4cc32773 100644 --- a/apps/web/src/ui/pool/PoolHeader.tsx +++ b/apps/web/src/ui/pool/PoolHeader.tsx @@ -11,7 +11,7 @@ import { typographyVariants, } from '@sushiswap/ui' import React, { FC, useMemo } from 'react' -import { Chain, ChainKey } from 'sushi/chain' +import { EvmChain, EvmChainKey } from 'sushi/chain' import { Token, unwrapToken } from 'sushi/currency' import { formatPercent, shortenAddress } from 'sushi/format' import { APRHoverCard } from './APRHoverCard' @@ -87,7 +87,7 @@ export const PoolHeader: FC = ({ })} > {token0.symbol}/{token1.symbol} @@ -114,9 +114,11 @@ export const PoolHeader: FC = ({ = ({
Network - {Chain.from(pool.chainId)?.name} + {EvmChain.from(pool.chainId)?.name}
@@ -165,7 +167,7 @@ export const PoolHeader: FC = ({ @@ -186,7 +188,7 @@ export const PoolHeader: FC = ({ diff --git a/apps/web/src/ui/pool/PoolQuickHoverTooltip.tsx b/apps/web/src/ui/pool/PoolQuickHoverTooltip.tsx index 06a5aba86a..01ccb877cf 100644 --- a/apps/web/src/ui/pool/PoolQuickHoverTooltip.tsx +++ b/apps/web/src/ui/pool/PoolQuickHoverTooltip.tsx @@ -8,7 +8,6 @@ import { List } from '@sushiswap/ui' import React, { FC } from 'react' import { incentiveRewardToToken } from 'src/lib/functions' import { SushiSwapProtocol } from 'sushi' -import { ChainId } from 'sushi/chain' import { formatNumber, formatPercent } from 'sushi/format' interface PoolQuickHoverTooltipProps { @@ -68,10 +67,7 @@ export const PoolQuickHoverTooltip: FC = ({ key={incentive.id} icon={Currency.Icon} iconProps={{ - currency: incentiveRewardToToken( - row.chainId as ChainId, - incentive, - ), + currency: incentiveRewardToToken(row.chainId, incentive), }} title={`${formatNumber(incentive.rewardPerDay)} ${ incentive.rewardToken.symbol diff --git a/apps/web/src/ui/pool/PoolRewardDistributionsCard.tsx b/apps/web/src/ui/pool/PoolRewardDistributionsCard.tsx index 7b0f8b4fd3..71d0a3844d 100644 --- a/apps/web/src/ui/pool/PoolRewardDistributionsCard.tsx +++ b/apps/web/src/ui/pool/PoolRewardDistributionsCard.tsx @@ -15,7 +15,7 @@ import { } from '@sushiswap/ui' import { FC } from 'react' import { useAngleRewards } from 'src/lib/hooks/react-query' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainKey } from 'sushi/chain' import { Native } from 'sushi/currency' import { getAddress } from 'viem' @@ -31,7 +31,7 @@ export const PoolRewardDistributionsCard: FC< PoolRewardDistributionsCardParams > = ({ pool }) => { const { data: rewardsData, isLoading: rewardsLoading } = useAngleRewards({ - chainId: pool.chainId as ChainId, + chainId: pool.chainId, }) if (!pool) return null diff --git a/apps/web/src/ui/pool/PoolRewards.tsx b/apps/web/src/ui/pool/PoolRewards.tsx index b3e384aa4e..c6036a5ae5 100644 --- a/apps/web/src/ui/pool/PoolRewards.tsx +++ b/apps/web/src/ui/pool/PoolRewards.tsx @@ -13,7 +13,6 @@ import { } from '@sushiswap/ui' import { FC } from 'react' import { incentiveRewardToToken } from 'src/lib/functions' -import { ChainId } from 'sushi/chain' import { tryParseAmount } from 'sushi/currency' export const PoolRewards: FC<{ pool: V2Pool }> = ({ pool }) => { @@ -35,7 +34,7 @@ export const PoolRewards: FC<{ pool: V2Pool }> = ({ pool }) => { {incentives.map((incentive, index) => { const amount = tryParseAmount( incentive.rewardPerDay.toString(), - incentiveRewardToToken(pool.chainId as ChainId, incentive), + incentiveRewardToToken(pool.chainId, incentive), ) return })} diff --git a/apps/web/src/ui/pool/PoolTransactionsV2.tsx b/apps/web/src/ui/pool/PoolTransactionsV2.tsx index 052c55c0ae..022dc44cda 100644 --- a/apps/web/src/ui/pool/PoolTransactionsV2.tsx +++ b/apps/web/src/ui/pool/PoolTransactionsV2.tsx @@ -11,7 +11,7 @@ import { import { useQuery } from '@tanstack/react-query' import { PaginationState } from '@tanstack/react-table' import { FC, useMemo, useState } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { EvmChain, EvmChainId } from 'sushi/chain' import { SushiSwapV2ChainId, isSushiSwapV2ChainId } from 'sushi/config' import { @@ -95,7 +95,7 @@ function useTransactionsV2( return useQuery({ queryKey: ['poolTransactionsV2', poolAddress, pool?.chainId, opts], queryFn: async () => { - const chainId = pool?.chainId as ChainId + const chainId = pool?.chainId as EvmChainId if (!pool || !isSushiSwapV2ChainId(chainId)) return [] @@ -168,7 +168,7 @@ function useTransactionsV2( .sort((a, b) => b.logIndex - a.logIndex) }) }, - enabled: !!pool && isSushiSwapV2ChainId(pool?.chainId as ChainId), + enabled: !!pool && isSushiSwapV2ChainId(pool?.chainId as EvmChainId), refetchInterval: opts?.refetchInterval, }) } @@ -257,7 +257,7 @@ const PoolTransactionsV2: FC = ({ - Chain.from(row.chainId)?.getTxUrl(row.txHash) ?? '' + EvmChain.from(row.chainId)?.getTxUrl(row.txHash) ?? '' } loading={isLoading} columns={COLUMNS} diff --git a/apps/web/src/ui/pool/PoolTransactionsV3.tsx b/apps/web/src/ui/pool/PoolTransactionsV3.tsx index 99bb23e7c0..1f072f4141 100644 --- a/apps/web/src/ui/pool/PoolTransactionsV3.tsx +++ b/apps/web/src/ui/pool/PoolTransactionsV3.tsx @@ -11,7 +11,7 @@ import { import { useQuery } from '@tanstack/react-query' import { PaginationState } from '@tanstack/react-table' import { FC, useMemo, useState } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { EvmChain, EvmChainId } from 'sushi/chain' import { SushiSwapV3ChainId, isSushiSwapV3ChainId } from 'sushi/config' import { @@ -115,7 +115,7 @@ function useTransactionsV3( return useQuery({ queryKey: ['poolTransactionsV3', poolAddress, opts], queryFn: async () => { - const chainId = pool?.chainId as ChainId + const chainId = pool?.chainId as EvmChainId if (!pool || !isSushiSwapV3ChainId(chainId)) return [] @@ -194,7 +194,7 @@ function useTransactionsV3( .sort((a, b) => b.logIndex - a.logIndex) }) }, - enabled: !!pool && isSushiSwapV3ChainId(pool?.chainId as ChainId), + enabled: !!pool && isSushiSwapV3ChainId(pool?.chainId as EvmChainId), refetchInterval: opts?.refetchInterval, }) } @@ -285,7 +285,7 @@ const PoolTransactionsV3: FC = ({ - Chain.from(row.pool.chainId)?.getTxUrl(row.transaction.id) ?? '' + EvmChain.from(row.pool.chainId)?.getTxUrl(row.transaction.id) ?? '' } loading={isLoading} columns={COLUMNS} diff --git a/apps/web/src/ui/pool/PositionCard.tsx b/apps/web/src/ui/pool/PositionCard.tsx index 906c166148..664e756c48 100644 --- a/apps/web/src/ui/pool/PositionCard.tsx +++ b/apps/web/src/ui/pool/PositionCard.tsx @@ -11,7 +11,7 @@ import { } from '@sushiswap/ui' import React, { FC } from 'react' import { useTokensFromPool } from 'src/lib/hooks' -import { Chain, ChainKey } from 'sushi/chain' +import { EvmChain, EvmChainKey } from 'sushi/chain' import { formatPercent, formatUSD } from 'sushi/format' interface PositionCard { @@ -50,7 +50,7 @@ export const PositionCard: FC = ({ position }) => { return (
- {Chain.from(position.pool.chainId)?.name} + {EvmChain.from(position.pool.chainId)?.name}

{token0.symbol}/{token1.symbol}{' '} @@ -89,7 +89,7 @@ export const PositionCard: FC = ({ position }) => {
diff --git a/apps/web/src/ui/pool/SelectTokensWidget.tsx b/apps/web/src/ui/pool/SelectTokensWidget.tsx index 1ac92625b8..d82a09321f 100644 --- a/apps/web/src/ui/pool/SelectTokensWidget.tsx +++ b/apps/web/src/ui/pool/SelectTokensWidget.tsx @@ -4,11 +4,11 @@ import { Currency } from '@sushiswap/ui' import { SelectIcon } from '@sushiswap/ui' import React, { FC } from 'react' import { TokenSelector } from 'src/lib/wagmi/components/token-selector/token-selector' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Type } from 'sushi/currency' interface SelectTokensWidget { - chainId: ChainId + chainId: EvmChainId token0: Type | undefined token1: Type | undefined setToken0(token: Type): void diff --git a/apps/web/src/ui/pool/SmartPositionsTable.tsx b/apps/web/src/ui/pool/SmartPositionsTable.tsx index 6e2cd678fc..14899c41c6 100644 --- a/apps/web/src/ui/pool/SmartPositionsTable.tsx +++ b/apps/web/src/ui/pool/SmartPositionsTable.tsx @@ -15,7 +15,7 @@ import { SteerAccountPositionExtended, useSteerAccountPositionsExtended, } from 'src/lib/wagmi/hooks/steer/useSteerAccountPositionsExtended' -import { ChainId, ChainKey, SushiSwapProtocol, formatPercent } from 'sushi' +import { ChainKey, SushiSwapProtocol, formatPercent } from 'sushi' import { Address } from 'viem' import { useAccount } from 'wagmi' import { APRHoverCard } from './APRHoverCard' @@ -52,7 +52,7 @@ const COLUMNS = [ pool={{ id: props.row.original.id as `${string}:0x${string}`, address: props.row.original.vault.poolAddress as Address, - chainId: props.row.original.vault.chainId as ChainId, + chainId: props.row.original.vault.chainId, protocol: SushiSwapProtocol.SUSHISWAP_V3, feeApr1d: props.row.original.vault.feeApr1d, incentiveApr: props.row.original.vault.incentiveApr, diff --git a/apps/web/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx b/apps/web/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx index e4ebf16324..65bce2af2d 100644 --- a/apps/web/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx +++ b/apps/web/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx @@ -4,7 +4,6 @@ import { PlusIcon } from '@heroicons/react/24/solid' import { STEER_PERIPHERY_ADDRESS, SteerChainId } from '@sushiswap/steer-sdk' import { Button, DialogTrigger, classNames } from '@sushiswap/ui' import React, { FC, useMemo } from 'react' -import { ChainId } from 'sushi/chain' import { VaultV1 } from '@sushiswap/graph-client/data-api' import { useIsMounted } from '@sushiswap/hooks' @@ -61,7 +60,7 @@ export const SteerPositionAdd: FC = ({ vault }) => { id="add-liquidity-token0" type="INPUT" className="p-3 bg-white dark:bg-secondary rounded-xl border border-accent" - chainId={vault.chainId as ChainId} + chainId={vault.chainId} value={formattedAmounts[Field.CURRENCY_A]} onChange={onFieldAInput} currency={currencies?.CURRENCY_A} @@ -82,7 +81,7 @@ export const SteerPositionAdd: FC = ({ vault }) => { id="add-liquidity-token1" type="INPUT" className="p-3 bg-white dark:bg-secondary rounded-xl border border-accent" - chainId={vault.chainId as ChainId} + chainId={vault.chainId} value={formattedAmounts[Field.CURRENCY_B]} onChange={onFieldBInput} currency={currencies?.CURRENCY_B} @@ -99,12 +98,12 @@ export const SteerPositionAdd: FC = ({ vault }) => { = - {Chain.from(vault.chainId)!.name} + {EvmChain.from(vault.chainId)!.name} diff --git a/apps/web/src/ui/pool/UnknownTokenAlert.tsx b/apps/web/src/ui/pool/UnknownTokenAlert.tsx index 99fc0fb044..e048a5c510 100644 --- a/apps/web/src/ui/pool/UnknownTokenAlert.tsx +++ b/apps/web/src/ui/pool/UnknownTokenAlert.tsx @@ -5,7 +5,6 @@ import { useCustomTokens } from '@sushiswap/hooks' import { Message } from '@sushiswap/ui' import { FC, useMemo } from 'react' import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' -import { ChainId } from 'sushi/chain' import { shortenAddress } from 'sushi/format' interface UnknownTokenAlert { @@ -21,12 +20,12 @@ export const UnknownTokenAlert: FC = ({ pool }) => { const { hasToken } = useCustomTokens() const { data: tokenFrom } = useTokenWithCache({ - chainId: pool.chainId as ChainId, + chainId: pool.chainId, address: token0.address, }) const { data: tokenTo } = useTokenWithCache({ - chainId: pool.chainId as ChainId, + chainId: pool.chainId, address: token1.address, }) diff --git a/apps/web/src/ui/pool/V3FeesTable.tsx b/apps/web/src/ui/pool/V3FeesTable.tsx index 72a6ca6ea0..3671fed081 100644 --- a/apps/web/src/ui/pool/V3FeesTable.tsx +++ b/apps/web/src/ui/pool/V3FeesTable.tsx @@ -18,7 +18,7 @@ import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import { ColumnDef, SortingState, TableState } from '@tanstack/react-table' import { FC, MouseEventHandler, useCallback, useMemo, useState } from 'react' import { ProtocolBadge } from 'src/ui/pool/PoolNameCell' -import { Address, Chain, ChainId } from 'sushi' +import { Address, EvmChain, EvmChainId } from 'sushi' import { uniswapV3PoolAbi_setFeeProtocol } from 'sushi/abi' import { Token } from 'sushi/currency' import { formatNumber, formatUSD } from 'sushi/format' @@ -143,7 +143,7 @@ const VOLUME_COLUMN: ColumnDef = { }, } -const EnableProtocolFeeButton: FC<{ pool: Address; chainId: ChainId }> = ({ +const EnableProtocolFeeButton: FC<{ pool: Address; chainId: EvmChainId }> = ({ pool, chainId, }) => { @@ -213,7 +213,7 @@ const COLUMNS = [ PROTOCOL_FEE_COLUMN, ] -export const V3FeesTable: FC<{ pools: V3BasePool[]; chainId: ChainId }> = ({ +export const V3FeesTable: FC<{ pools: V3BasePool[]; chainId: EvmChainId }> = ({ pools, chainId, }) => { @@ -248,7 +248,9 @@ export const V3FeesTable: FC<{ pools: V3BasePool[]; chainId: ChainId }> = ({ loading={!pools} columns={COLUMNS} data={data} - linkFormatter={(row) => Chain.from(chainId)!.getAccountUrl(row.address)} + linkFormatter={(row) => + EvmChain.from(chainId)!.getAccountUrl(row.address) + } /> ) } diff --git a/apps/web/src/ui/pool/V3PositionView.tsx b/apps/web/src/ui/pool/V3PositionView.tsx index 73a6767f57..3ce1e9355b 100644 --- a/apps/web/src/ui/pool/V3PositionView.tsx +++ b/apps/web/src/ui/pool/V3PositionView.tsx @@ -40,7 +40,7 @@ import { useConcentratedLiquidityPositionsFromTokenId } from 'src/lib/wagmi/hook import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' import { getDefaultTTL } from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' import { Checker } from 'src/lib/wagmi/systems/Checker' -import { Chain, ChainKey } from 'sushi/chain' +import { EvmChain, EvmChainKey } from 'sushi/chain' import { SushiSwapV3ChainId, isMerklChainId } from 'sushi/config' import { Amount, unwrapToken } from 'sushi/currency' import { formatPercent, formatUSD } from 'sushi/format' @@ -314,7 +314,7 @@ const Component: FC<{ chainId: string; address: string; position: string }> = ({ Unclaimed rewards This will claim your rewards for every V3 - liquidity position on {Chain.from(chainId)?.name} + liquidity position on {EvmChain.from(chainId)?.name} @@ -641,7 +641,7 @@ const Component: FC<{ chainId: string; address: string; position: string }> = ({ {_token0 && _token1 ? ( = ({ tokenRatios, }) => { const { data: prices } = usePrices({ - chainId: pool?.chainId as ChainId | undefined, + chainId: pool?.chainId as EvmChainId | undefined, }) const outputToken = useMemo( diff --git a/apps/web/src/ui/stake/BarHeader.tsx b/apps/web/src/ui/stake/BarHeader.tsx index f9115bc46c..ed9a6a521c 100644 --- a/apps/web/src/ui/stake/BarHeader.tsx +++ b/apps/web/src/ui/stake/BarHeader.tsx @@ -9,7 +9,7 @@ import { TooltipTrigger, } from '@sushiswap/ui' import React from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' import { XSUSHI } from 'sushi/currency' import { formatPercent, shortenAddress } from 'sushi/format' import { useSushiBar } from './SushiBarProvider' @@ -62,7 +62,7 @@ export const BarHeader = () => {
XSUSHI diff --git a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-confirmation-dialog.tsx b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-confirmation-dialog.tsx index fe36a0ce9d..ca8d16006d 100644 --- a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-confirmation-dialog.tsx +++ b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-confirmation-dialog.tsx @@ -3,7 +3,7 @@ import { Button, Dots, Loader, classNames } from '@sushiswap/ui' import { CheckMarkIcon } from '@sushiswap/ui/icons/CheckMarkIcon' import { FailedMarkIcon } from '@sushiswap/ui/icons/FailedMarkIcon' import { FC, ReactNode } from 'react' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { shortenAddress } from 'sushi/format' import { UseSelectedCrossChainTradeRouteReturn, @@ -52,12 +52,12 @@ export const ConfirmationDialogContent: FC = ({ transaction {' '} - to be confirmed on {Chain.from(chainId0)?.name} + to be confirmed on {EvmChain.from(chainId0)?.name} ) } @@ -116,7 +116,7 @@ export const ConfirmationDialogContent: FC = ({ {shortenAddress(recipient)} @@ -137,7 +137,7 @@ export const ConfirmationDialogContent: FC = ({ {trade?.amountIn?.toSignificant(6)} {token0?.symbol} @@ -147,7 +147,9 @@ export const ConfirmationDialogContent: FC = ({ {trade?.amountOut?.toSignificant(6)} {token1?.symbol} @@ -162,7 +164,9 @@ export const ConfirmationDialogContent: FC = ({ {trade?.amountOut?.toSignificant(6)} {token1?.symbol} diff --git a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-route-view.tsx b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-route-view.tsx index 9c9850515c..2056946374 100644 --- a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-route-view.tsx +++ b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-route-view.tsx @@ -9,7 +9,7 @@ import type { CrossChainStep, CrossChainToolDetails, } from 'src/lib/swap/cross-chain/types' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { Amount, Native, Token, Type } from 'sushi/currency' import { formatNumber } from 'sushi/format' import { zeroAddress } from 'viem' @@ -124,7 +124,7 @@ const SendAction: FC<{ amount: Amount }> = ({ label, amount }) => { const chain = useMemo( - () => Chain.fromChainId(amount.currency.chainId)?.name?.toUpperCase(), + () => EvmChain.fromChainId(amount.currency.chainId)?.name?.toUpperCase(), [amount], ) @@ -160,7 +160,7 @@ const SwapAction: FC<{ ? Native.onChain(action.toToken.chainId) : new Token(action.toToken) - const chain = Chain.fromChainId( + const chain = EvmChain.fromChainId( label === 'From' ? fromToken.chainId : toToken.chainId, )?.name?.toUpperCase() diff --git a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-token-not-found-dialog.tsx b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-token-not-found-dialog.tsx index be3689d8ce..475df9d5fd 100644 --- a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-token-not-found-dialog.tsx +++ b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-token-not-found-dialog.tsx @@ -16,7 +16,7 @@ import { List } from '@sushiswap/ui' import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import React, { useCallback, useMemo } from 'react' import { useTokenSecurity } from 'src/lib/hooks/react-query' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { defaultCurrency, defaultQuoteCurrency, @@ -145,7 +145,7 @@ export const CrossChainSwapTokenNotFoundDialog = () => { Could not retrieve token info for{' '} { > {shortenAddress(token0.wrapped.address)} {' '} - are you sure this token is on {Chain.from(chainId0)?.name}? + are you sure this token is on {EvmChain.from(chainId0)?.name}?

@@ -191,7 +191,7 @@ export const CrossChainSwapTokenNotFoundDialog = () => { > @@ -211,7 +211,7 @@ export const CrossChainSwapTokenNotFoundDialog = () => { Could not retrieve token info for{' '} { > {shortenAddress(token1.wrapped.address)} {' '} - are you sure this token is on {Chain.from(chainId1)?.name}? + are you sure this token is on {EvmChain.from(chainId1)?.name}?

@@ -257,7 +257,7 @@ export const CrossChainSwapTokenNotFoundDialog = () => { > diff --git a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-dialog.tsx b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-dialog.tsx index 6a059ab578..ba01eee800 100644 --- a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-dialog.tsx +++ b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-dialog.tsx @@ -54,7 +54,7 @@ import { } from 'src/lib/swap/cross-chain' import { warningSeverity } from 'src/lib/swap/warningSeverity' import { useApproved } from 'src/lib/wagmi/systems/Checker/Provider' -import { Chain, ChainKey } from 'sushi/chain' +import { ChainKey, EvmChain } from 'sushi/chain' import { Amount, Native } from 'sushi/currency' import { formatNumber, formatUSD, shortenAddress } from 'sushi/format' import { ZERO } from 'sushi/math' @@ -239,16 +239,18 @@ const _CrossChainSwapTradeReviewDialog: FC<{ pending: `Sending ${routeRef?.current?.amountIn?.toSignificant( 6, )} ${routeRef?.current?.amountIn?.currency.symbol} to ${ - Chain.fromChainId(routeRef?.current?.toChainId)?.name + EvmChain.fromChainId(routeRef?.current?.toChainId)?.name }`, completed: `Sent ${routeRef?.current?.amountIn?.toSignificant( 6, )} ${routeRef?.current?.amountIn?.currency.symbol} to ${ - Chain.fromChainId(routeRef?.current?.toChainId)?.name + EvmChain.fromChainId(routeRef?.current?.toChainId)?.name }`, failed: `Something went wrong when trying to send ${ routeRef?.current?.amountIn?.currency.symbol - } to ${Chain.fromChainId(routeRef?.current?.toChainId)?.name}`, + } to ${ + EvmChain.fromChainId(routeRef?.current?.toChainId)?.name + }`, } : { pending: `Swapping ${routeRef.current?.amountIn?.toSignificant( @@ -422,8 +424,8 @@ const _CrossChainSwapTradeReviewDialog: FC<{ chainId: chainId0, href: lifiData.lifiExplorerLink, summary: `Bridging ${routeRef?.current?.fromToken?.symbol} from ${ - Chain.from(chainId0)?.name - } to ${Chain.from(chainId1)?.name}`, + EvmChain.from(chainId0)?.name + } to ${EvmChain.from(chainId1)?.name}`, timestamp: new Date().getTime(), groupTimestamp: groupTs.current, }) @@ -487,17 +489,17 @@ const _CrossChainSwapTradeReviewDialog: FC<{ pending: `Receiving ${routeRef?.current?.amountOut?.toSignificant( 6, )} ${routeRef?.current?.amountOut?.currency.symbol} on ${ - Chain.fromChainId(routeRef?.current?.toChainId!)?.name + EvmChain.fromChainId(routeRef?.current?.toChainId!)?.name }`, completed: `Received ${routeRef?.current?.amountOut?.toSignificant( 6, )} ${routeRef?.current?.amountOut?.currency.symbol} on ${ - Chain.fromChainId(routeRef?.current?.toChainId!)?.name + EvmChain.fromChainId(routeRef?.current?.toChainId!)?.name }`, failed: `Something went wrong when trying to receive ${routeRef?.current?.amountOut?.toSignificant( 6, )} ${routeRef?.current?.amountOut?.currency.symbol} on ${ - Chain.fromChainId(routeRef?.current?.toChainId!)?.name + EvmChain.fromChainId(routeRef?.current?.toChainId!)?.name }`, }, timestamp: new Date().getTime(), @@ -592,7 +594,7 @@ const _CrossChainSwapTradeReviewDialog: FC<{
Insufficient {Native.onChain(chainId0).symbol} balance on{' '} - {Chain.fromChainId(chainId0)?.name} to cover the network + {EvmChain.fromChainId(chainId0)?.name} to cover the network fee. Please lower your input amount or{' '} diff --git a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-route.tsx b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-route.tsx index 6534021b7a..a877382570 100644 --- a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-route.tsx +++ b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-review-route.tsx @@ -2,7 +2,7 @@ import { classNames } from '@sushiswap/ui' import React from 'react' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { useDerivedStateCrossChainSwap, useSelectedCrossChainTradeRoute, @@ -38,7 +38,7 @@ export const CrossChainSwapTradeReviewRoute = () => {
{step.action.fromChainId === chainId0 ? 'From' : 'To'}:{' '} - {Chain.fromChainId( + {EvmChain.fromChainId( step.action.fromChainId, )?.name?.toUpperCase()} diff --git a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-stats.tsx b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-stats.tsx index 577a97458a..661bf22b84 100644 --- a/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-stats.tsx +++ b/apps/web/src/ui/swap/cross-chain/cross-chain-swap-trade-stats.tsx @@ -2,7 +2,7 @@ import { Collapsible, Explainer, SkeletonBox, classNames } from '@sushiswap/ui' import React, { FC, useMemo } from 'react' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { formatUSD, shortenAddress } from 'sushi/format' import { ZERO } from 'sushi/math' import { isAddress } from 'viem' @@ -133,7 +133,7 @@ export const CrossChainSwapTradeStats: FC = () => { | undefined recipient: Address | undefined @@ -74,7 +74,7 @@ const DerivedStateCrossChainSwapContext = createContext({} as State) interface DerivedStateCrossChainSwapProviderProps { children: React.ReactNode - defaultChainId: ChainId + defaultChainId: EvmChainId } /* Parses the URL and provides the chainId, token0, and token1 globally. @@ -96,7 +96,9 @@ const DerivedstateCrossChainSwapProvider: FC< ) const [routeOrder, setRouteOrder] = useState('CHEAPEST') - const chainId0 = isXSwapSupportedChainId(chainId) ? chainId : ChainId.ETHEREUM + const chainId0 = isXSwapSupportedChainId(chainId) + ? chainId + : EvmChainId.ETHEREUM // Get the searchParams and complete with defaults. // This handles the case where some params might not be provided by the user @@ -106,9 +108,9 @@ const DerivedstateCrossChainSwapProvider: FC< if (!params.has('chainId1')) params.set( 'chainId1', - chainId0 === ChainId.ARBITRUM - ? ChainId.ETHEREUM.toString() - : ChainId.ARBITRUM.toString(), + chainId0 === EvmChainId.ARBITRUM + ? EvmChainId.ETHEREUM.toString() + : EvmChainId.ARBITRUM.toString(), ) if (!params.has('token0')) params.set('token0', getDefaultCurrency(chainId0)) @@ -143,14 +145,14 @@ const DerivedstateCrossChainSwapProvider: FC< const token1 = params.get('token1') const pathSegments = pathname.split('/') - pathSegments[1] = ChainKey[Number(chainId1) as ChainId] + pathSegments[1] = ChainKey[Number(chainId1) as EvmChainId] // Can safely cast as defaultedParams are always defined history.pushState( null, '', `${replaceNetworkSlug( - Number(chainId1) as ChainId, + Number(chainId1) as EvmChainId, pathname, )}?${createQueryString([ { name: 'swapAmount', value: null }, @@ -173,7 +175,7 @@ const DerivedstateCrossChainSwapProvider: FC< null, '', `${replaceNetworkSlug( - chainId as ChainId, + chainId as EvmChainId, pathname, )}?${createQueryString([ { name: 'swapAmount', value: null }, @@ -264,7 +266,7 @@ const DerivedstateCrossChainSwapProvider: FC< ) // Derive chainId from defaultedParams - const chainId1 = Number(defaultedParams.get('chainId1')) as ChainId + const chainId1 = Number(defaultedParams.get('chainId1')) as EvmChainId // Derive token0 const { data: token0, isInitialLoading: token0Loading } = useTokenWithCache({ diff --git a/apps/web/src/ui/swap/simple/derivedstate-simple-swap-provider.tsx b/apps/web/src/ui/swap/simple/derivedstate-simple-swap-provider.tsx index ada332029b..fe17c6b1c2 100644 --- a/apps/web/src/ui/swap/simple/derivedstate-simple-swap-provider.tsx +++ b/apps/web/src/ui/swap/simple/derivedstate-simple-swap-provider.tsx @@ -18,7 +18,7 @@ import { import { useTrade as useApiTrade } from 'src/lib/hooks/react-query' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { defaultCurrency, defaultQuoteCurrency, @@ -56,7 +56,7 @@ interface State { state: { token0: Type | undefined token1: Type | undefined - chainId: ChainId + chainId: EvmChainId swapAmountString: string swapAmount: Amount | undefined recipient: string | undefined @@ -94,7 +94,7 @@ const DerivedstateSimpleSwapProvider: FC = const chainId = _chainId && isSupportedChainId(+_chainId) ? (+_chainId as SupportedChainId) - : ChainId.ETHEREUM + : EvmChainId.ETHEREUM // Get the searchParams and complete with defaults. // This handles the case where some params might not be provided by the user diff --git a/apps/web/src/ui/swap/simple/simple-swap-bridge-banner.tsx b/apps/web/src/ui/swap/simple/simple-swap-bridge-banner.tsx index 325eecd24d..2d95082767 100644 --- a/apps/web/src/ui/swap/simple/simple-swap-bridge-banner.tsx +++ b/apps/web/src/ui/swap/simple/simple-swap-bridge-banner.tsx @@ -5,7 +5,7 @@ import { ArrowUpRightIcon } from '@heroicons/react/24/solid' import { useLocalStorage } from '@sushiswap/hooks' import { NetworkIcon } from '@sushiswap/ui/icons/NetworkIcon' import { FC } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' import { useDerivedStateSimpleSwap } from './derivedstate-simple-swap-provider' const BridgeInfo = { @@ -53,13 +53,13 @@ export const SimpleSwapBridgeBanner: FC = () => {
- Bridge to {Chain.fromChainId(chainId)?.name} + Bridge to {EvmChain.fromChainId(chainId)?.name}
- Deposit your tokens to {Chain.fromChainId(chainId)?.name}. + Deposit your tokens to {EvmChain.fromChainId(chainId)?.name}.
diff --git a/apps/web/src/ui/swap/simple/simple-swap-token-not-found-dialog.tsx b/apps/web/src/ui/swap/simple/simple-swap-token-not-found-dialog.tsx index 508382e7af..1f5333f60e 100644 --- a/apps/web/src/ui/swap/simple/simple-swap-token-not-found-dialog.tsx +++ b/apps/web/src/ui/swap/simple/simple-swap-token-not-found-dialog.tsx @@ -14,7 +14,7 @@ import { } from '@sushiswap/ui' import React, { useCallback, useMemo } from 'react' import { useTokenSecurity } from 'src/lib/hooks/react-query' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import { defaultCurrency, defaultQuoteCurrency, @@ -112,7 +112,7 @@ export const SimpleSwapTokenNotFoundDialog = () => { Could not retrieve token info for{' '} { > {shortenAddress(token0.wrapped.address)} {' '} - are you sure this token is on {Chain.from(chainId)?.name}? + are you sure this token is on {EvmChain.from(chainId)?.name}?

@@ -158,7 +158,7 @@ export const SimpleSwapTokenNotFoundDialog = () => { > @@ -178,7 +178,7 @@ export const SimpleSwapTokenNotFoundDialog = () => { Could not retrieve token info for{' '} { > {shortenAddress(token1.wrapped.address)} {' '} - are you sure this token is on {Chain.from(chainId)?.name}? + are you sure this token is on {EvmChain.from(chainId)?.name}?

@@ -224,7 +224,7 @@ export const SimpleSwapTokenNotFoundDialog = () => { > diff --git a/apps/web/src/ui/swap/simple/simple-swap-trade-review-dialog.tsx b/apps/web/src/ui/swap/simple/simple-swap-trade-review-dialog.tsx index 88183338fc..0daec8d666 100644 --- a/apps/web/src/ui/swap/simple/simple-swap-trade-review-dialog.tsx +++ b/apps/web/src/ui/swap/simple/simple-swap-trade-review-dialog.tsx @@ -38,7 +38,7 @@ import { UseTradeReturn } from 'src/lib/hooks/react-query' import { useSimulateTrade } from 'src/lib/hooks/useSimulateTrade' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' import { useApproved } from 'src/lib/wagmi/systems/Checker/Provider' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' import { Native } from 'sushi/currency' import { shortenAddress } from 'sushi/format' import { ZERO } from 'sushi/math' @@ -327,7 +327,7 @@ export const SimpleSwapTradeReviewDialog: FC<{ - {Chain.from(chainId)?.name} + {EvmChain.from(chainId)?.name} {isSwap && ( { { const { chainId: _chainId } = useParams() - const chainId = +_chainId! as ChainId + const chainId = +_chainId! as EvmChainId return (
diff --git a/apps/web/src/ui/swap/twap/twap.tsx b/apps/web/src/ui/swap/twap/twap.tsx index f1b99faf0f..a84b29a0c8 100644 --- a/apps/web/src/ui/swap/twap/twap.tsx +++ b/apps/web/src/ui/swap/twap/twap.tsx @@ -27,7 +27,7 @@ import { NetworkSelector } from 'src/lib/wagmi/components/network-selector' import { useSearchTokens } from 'src/lib/wagmi/components/token-selector/hooks/use-search-tokens' import { TokenSelector } from 'src/lib/wagmi/components/token-selector/token-selector' import { Checker } from 'src/lib/wagmi/systems/Checker' -import { ChainId } from 'sushi/chain' +import { EvmChainId } from 'sushi/chain' import { Currency, Native } from 'sushi/currency' import { Address, zeroAddress } from 'viem' import { useAccount, useChainId, useSwitchChain } from 'wagmi' @@ -153,8 +153,8 @@ const TwapNetworkSelector = ({ children }: { children: ReactNode }) => { const { switchChain } = useSwitchChain() const chainId = useChainId() const onSelect = useCallback( - (chainId: number) => { - switchChain({ chainId: chainId as ChainId }) + (chainId: EvmChainId) => { + switchChain({ chainId: chainId }) }, [switchChain], ) @@ -162,7 +162,7 @@ const TwapNetworkSelector = ({ children }: { children: ReactNode }) => { return ( {children} diff --git a/apps/web/test/helpers/pool.ts b/apps/web/test/helpers/pool.ts index 23ca20d937..d4bb342058 100644 --- a/apps/web/test/helpers/pool.ts +++ b/apps/web/test/helpers/pool.ts @@ -2,6 +2,7 @@ import { Page, expect } from '@playwright/test' import { NextFixture } from 'next/experimental/testmode/playwright' import { isZapSupportedChainId } from 'src/config' import { NativeAddress } from 'src/lib/constants' +import { EvmChainId } from 'sushi' import { SUSHISWAP_V2_FACTORY_ADDRESS, SUSHISWAP_V3_FACTORY_ADDRESS, @@ -50,9 +51,9 @@ interface AddV2LiquidityArgs { const BASE_URL = 'http://localhost:3000' export class PoolPage extends BaseActions { - readonly chainId: number + readonly chainId: EvmChainId readonly nativeToken: Native - constructor(page: Page, chainId: number) { + constructor(page: Page, chainId: EvmChainId) { super(page) this.chainId = chainId this.nativeToken = Native.onChain(chainId) diff --git a/apps/web/test/helpers/swap.ts b/apps/web/test/helpers/swap.ts index d31f739c9e..cd5d3c815a 100644 --- a/apps/web/test/helpers/swap.ts +++ b/apps/web/test/helpers/swap.ts @@ -1,15 +1,16 @@ import { Page, expect } from '@playwright/test' import { NativeAddress } from 'src/lib/constants' -import { API_BASE_URL } from 'sushi/config' +import { API_BASE_URL } from 'src/lib/swap/api-base-url' +import { EvmChainId } from 'sushi/chain' import { Amount, Native, Type } from 'sushi/currency' import { BaseActions } from './base' // Adjust the import path as necessary type InputType = 'INPUT' | 'OUTPUT' export class SwapPage extends BaseActions { - readonly chainId: number + readonly chainId: EvmChainId readonly nativeToken: Native - constructor(page: Page, chainId: number) { + constructor(page: Page, chainId: EvmChainId) { super(page) this.chainId = chainId this.nativeToken = Native.onChain(chainId) diff --git a/apps/web/test/swap/cross-chain.test.ts b/apps/web/test/swap/cross-chain.test.ts index 9e8747b604..52f8ce064b 100644 --- a/apps/web/test/swap/cross-chain.test.ts +++ b/apps/web/test/swap/cross-chain.test.ts @@ -1,5 +1,5 @@ import { Page, expect, test } from '@playwright/test' -import { ChainId, chainName } from 'sushi/chain' +import { EvmChainId, evmChainName } from 'sushi/chain' import { Native, Type } from 'sushi/currency' import { zeroAddress } from 'viem' @@ -151,7 +151,7 @@ async function approve(page: Page, currency: Type) { } } -async function handleNetwork(page: Page, chainId: ChainId, type: InputType) { +async function handleNetwork(page: Page, chainId: EvmChainId, type: InputType) { const selectorInfix = `${type === 'INPUT' ? 'from' : 'to'}` // Open network list @@ -165,7 +165,7 @@ async function handleNetwork(page: Page, chainId: ChainId, type: InputType) { const networkSearch = page.locator('[testdata-id=network-selector-input]') await expect(networkSearch).toBeVisible() await expect(networkSearch).toBeEnabled() - await networkSearch.fill(chainName[chainId]) + await networkSearch.fill(evmChainName[chainId]) const networkToSelect = page.locator( `[testdata-id=network-selector-${chainId}]`, @@ -173,7 +173,7 @@ async function handleNetwork(page: Page, chainId: ChainId, type: InputType) { await expect(networkToSelect).toBeVisible() await networkToSelect.click() - await expect(networkSelector).toContainText(chainName[chainId]) + await expect(networkSelector).toContainText(evmChainName[chainId]) } async function handleToken(page: Page, currency: Type, type: InputType) { @@ -215,7 +215,7 @@ async function inputAmount(page: Page, amount: string) { await input0.fill(amount) } -async function switchNetwork(page: Page, chainId: number) { +async function switchNetwork(page: Page, chainId: EvmChainId) { const networkSelector = page.locator('[testdata-id=network-selector-button]') await expect(networkSelector).toBeVisible() await expect(networkSelector).toBeEnabled() diff --git a/apps/web/test/swap/scripts/generate-swaps.ts b/apps/web/test/swap/scripts/generate-swaps.ts index d041f6df45..c2ccd77b1d 100644 --- a/apps/web/test/swap/scripts/generate-swaps.ts +++ b/apps/web/test/swap/scripts/generate-swaps.ts @@ -3,13 +3,9 @@ import { type UseTradeParams, tradeValidator02, } from 'src/lib/hooks/react-query' +import { API_BASE_URL } from 'src/lib/swap/api-base-url' +import { publicClientConfig } from 'src/lib/wagmi/config/viem' import { ChainId } from 'sushi/chain' -import { - API_BASE_URL, - // TOKEN_CHOMPER_ADDRESS, - // isTokenChomperChainId, - publicClientConfig, -} from 'sushi/config' import { Amount, Native, USDC, USDT, WBTC } from 'sushi/currency' import { createPublicClient, stringify } from 'viem' import { getBlockNumber } from 'viem/actions' diff --git a/packages/graph-client/package.json b/packages/graph-client/package.json index 6b41005bd6..2a5bbab779 100644 --- a/packages/graph-client/package.json +++ b/packages/graph-client/package.json @@ -69,7 +69,7 @@ "graphql": "16.6.0", "graphql-request": "7.1.0", "json-bigint": "1.0.0", - "sushi": "4.1.23", + "sushi": "5.0.4", "viem": "2.21.55" }, "devDependencies": { diff --git a/packages/graph-client/src/lib/get-subgraph-url.ts b/packages/graph-client/src/lib/get-subgraph-url.ts new file mode 100644 index 0000000000..a0d23a5380 --- /dev/null +++ b/packages/graph-client/src/lib/get-subgraph-url.ts @@ -0,0 +1,30 @@ +import type { ChainId } from 'sushi/chain' +import { SUSHI_DOMAIN_RESTRICTED_API_KEY } from 'sushi/config/subgraph' + +type GetSubgraphUrlArgs = { + chainId: CHAIN + getter: ( + chainId: CHAIN, + config: { decentralizedKey: string }, + ) => string | undefined +} + +const DECENTRALIZED_NETWORK_KEY = + process.env['SUSHI_GRAPH_KEY'] || + process.env['NEXT_PUBLIC_SUSHI_GRAPH_KEY'] || + SUSHI_DOMAIN_RESTRICTED_API_KEY + +export function getSubgraphUrl({ + chainId, + getter, +}: GetSubgraphUrlArgs) { + const baseUrl = getter(chainId, { + decentralizedKey: DECENTRALIZED_NETWORK_KEY, + }) + + if (!baseUrl) { + throw new Error(`No subgraph URL found for chainId ${chainId}`) + } + + return `https://${baseUrl}` +} diff --git a/packages/graph-client/src/lib/request-paged.ts b/packages/graph-client/src/lib/request-paged.ts index 92ba780061..ed37879e8a 100644 --- a/packages/graph-client/src/lib/request-paged.ts +++ b/packages/graph-client/src/lib/request-paged.ts @@ -1,11 +1,11 @@ import type { ResultOf, TadaDocumentNode, VariablesOf } from 'gql.tada' import { type RequestOptions, request as _request } from 'src/lib/request' -import type { ChainId } from 'sushi/chain' +import type { EvmChainId } from 'sushi/chain' import { MAX_FIRST } from 'sushi/config/subgraph' import { FetchError } from './fetch-error' interface RequestPaged>> { - chainId: ChainId + chainId: EvmChainId url: string query: T variables: VariablesOf diff --git a/packages/graph-client/src/subgraphs/bentobox/queries/rebases.ts b/packages/graph-client/src/subgraphs/bentobox/queries/rebases.ts index cb978db6e1..3b3f9ee386 100644 --- a/packages/graph-client/src/subgraphs/bentobox/queries/rebases.ts +++ b/packages/graph-client/src/subgraphs/bentobox/queries/rebases.ts @@ -1,6 +1,6 @@ import type { VariablesOf } from 'gql.tada' import type { BentoBoxChainId } from 'sushi/config' -import { BENTOBOX_SUBGRAPH_URL } from 'sushi/config/subgraph' +import { getBentoBoxSubgraphUrl } from 'sushi/config/subgraph' import { addChainId } from 'src/lib/modifiers/add-chain-id' import { convertIdToMultichainId } from 'src/lib/modifiers/convert-id-to-multichain-id' @@ -10,6 +10,7 @@ import { requestPaged } from 'src/lib/request-paged' import type { ChainIdVariable } from 'src/lib/types/chainId' import type { Hex } from 'src/lib/types/hex' import { graphql } from '../graphql' +import { getSubgraphUrl } from 'src/lib/get-subgraph-url' export const BentoBoxRebasesQuery = graphql(` query Rebases($first: Int = 1000, $skip: Int = 0, $block: Block_height, $orderBy: Rebase_orderBy, $orderDirection: OrderDirection, $where: Rebase_filter) { @@ -33,7 +34,10 @@ export async function getRebases( { chainId, ...variables }: GetRebases, options?: RequestOptions, ) { - const url = `https://${BENTOBOX_SUBGRAPH_URL[chainId]}` + const url = getSubgraphUrl({ + chainId, + getter: getBentoBoxSubgraphUrl, + }) const result = await requestPaged({ chainId, diff --git a/packages/graph-client/src/subgraphs/data-api/data-api-host.ts b/packages/graph-client/src/subgraphs/data-api/data-api-host.ts new file mode 100644 index 0000000000..9ce2fe5bbd --- /dev/null +++ b/packages/graph-client/src/subgraphs/data-api/data-api-host.ts @@ -0,0 +1,6 @@ +import { SUSHI_DATA_API_HOST as PROD_SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' + +export const SUSHI_DATA_API_HOST = + process.env['SUSHI_DATA_API_HOST'] || + process.env['NEXT_PUBLIC_SUSHI_DATA_API_HOST'] || + PROD_SUSHI_DATA_API_HOST diff --git a/packages/graph-client/src/subgraphs/data-api/queries/analytics/day-buckets.ts b/packages/graph-client/src/subgraphs/data-api/queries/analytics/day-buckets.ts index da6c994039..6690fce463 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/analytics/day-buckets.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/analytics/day-buckets.ts @@ -2,8 +2,8 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' import { graphql } from '../../graphql' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' export const AnalyticsDayBucketsQuery = graphql( ` diff --git a/packages/graph-client/src/subgraphs/data-api/queries/features/chain-ids-by-feature.ts b/packages/graph-client/src/subgraphs/data-api/queries/features/chain-ids-by-feature.ts index b047af60fa..d5f184fc32 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/features/chain-ids-by-feature.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/features/chain-ids-by-feature.ts @@ -2,7 +2,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' import { graphql } from '../../graphql' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' export const ChainIdsByFeatureQuery = graphql( diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/pool-addresses.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/pool-addresses.ts index b9ba9c6196..1e3920c203 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/pool/pool-addresses.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/pool-addresses.ts @@ -1,6 +1,6 @@ import type { VariablesOf } from 'gql.tada' import { type RequestOptions, request } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/pools.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/pools.ts index 2e837ee28e..049a48128f 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/pool/pools.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/pools.ts @@ -1,9 +1,10 @@ import type { VariablesOf } from 'gql.tada' import { type RequestOptions, request } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' import { Token } from 'sushi/currency' +import { isEvmChainId } from 'sushi' export const PoolsQuery = graphql( ` @@ -80,10 +81,20 @@ export async function getPools(variables: GetPools, options?: RequestOptions) { data: result.pools.data.map((pool) => ({ ...pool, chainId: variables.chainId, - incentives: pool.incentives.map((incentive) => ({ - ...incentive, - rewardToken: new Token(incentive.rewardToken), - })), + incentives: pool.incentives.map((incentive) => { + // Shouldn't happen, just to make typescript happy + if (!isEvmChainId(incentive.rewardToken.chainId)) { + throw new Error('Invalid chainId') + } + + return { + ...incentive, + rewardToken: new Token({ + ...incentive.rewardToken, + chainId: incentive.rewardToken.chainId, + }), + } + }), })), } } diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/top-evm-pools.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/top-evm-pools.ts index 495a4e7758..6958dd5a9a 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/pool/top-evm-pools.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/top-evm-pools.ts @@ -1,9 +1,9 @@ import type { VariablesOf } from 'gql.tada' import { type RequestOptions, request } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' -import { ChainId, isChainId } from 'sushi' +import { EvmChainId, isEvmChainId } from 'sushi' export const TopPoolsQuery = graphql( ` @@ -49,12 +49,12 @@ export async function getTopPools( ) { const url = `${SUSHI_DATA_API_HOST}/graphql` try { - if (!isChainId(parseInt(variables.chainId))) { + if (!isEvmChainId(parseInt(variables.chainId))) { throw new Error( `Invalid chainId: ${variables.chainId}, this only supports evm networks and must be a number.`, ) } - const chainId = parseInt(variables.chainId) as ChainId + const chainId = parseInt(variables.chainId) as EvmChainId const result = await request( { url, diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/top-non-evm-pools.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/top-non-evm-pools.ts index 7548ae1039..ab753b4d85 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/pool/top-non-evm-pools.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/top-non-evm-pools.ts @@ -1,6 +1,6 @@ import type { VariablesOf } from 'gql.tada' import { type RequestOptions, request } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/v2-pool.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/v2-pool.ts index 996f8aadb7..e0d686c762 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/pool/v2-pool.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/v2-pool.ts @@ -2,8 +2,8 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' import { - ChainId, ChefType, + EvmChainId, RewarderType, SushiSwapProtocol, type PoolBase, @@ -13,7 +13,7 @@ import { type PoolWithIncentives, } from 'sushi' import { isSushiSwapV2ChainId } from 'sushi/config' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import type { Address } from 'viem' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' @@ -93,7 +93,7 @@ export async function getV2Pool( options?: RequestOptions, ) { const url = `${SUSHI_DATA_API_HOST}/graphql` - const chainId = Number(variables.chainId) as ChainId + const chainId = Number(variables.chainId) as EvmChainId if (!isSushiSwapV2ChainId(chainId)) { throw new Error('Invalid chainId') diff --git a/packages/graph-client/src/subgraphs/data-api/queries/pool/v3-pool.ts b/packages/graph-client/src/subgraphs/data-api/queries/pool/v3-pool.ts index 4b7ccc092e..3d198bfb30 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/pool/v3-pool.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/pool/v3-pool.ts @@ -3,7 +3,7 @@ import type { VariablesOf } from 'gql.tada' import type { PoolHasSteerVaults } from '@sushiswap/steer-sdk' import { request, type RequestOptions } from 'src/lib/request' import { - ChainId, + EvmChainId, ChefType, RewarderType, SushiSwapProtocol, @@ -14,7 +14,7 @@ import { type PoolWithIncentives, } from 'sushi' import { isSushiSwapV3ChainId } from 'sushi/config' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import type { Address } from 'viem' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' @@ -102,7 +102,7 @@ export async function getV3Pool( options?: RequestOptions, ) { const url = `${SUSHI_DATA_API_HOST}/graphql` - const chainId = Number(variables.chainId) as ChainId + const chainId = Number(variables.chainId) as EvmChainId if (!isSushiSwapV3ChainId(chainId)) { throw new Error('Invalid chainId') diff --git a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-claimables.ts b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-claimables.ts index 0cdf14a38b..a31d1f18d5 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-claimables.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-claimables.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const PortfolioClaimablesQuery = graphql( diff --git a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-history.ts b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-history.ts index 108599635b..4561290750 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-history.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-history.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const PortfolioHistoryQuery = graphql( diff --git a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-positions.ts b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-positions.ts index 84bdad29ad..af73bd85e9 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-positions.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-positions.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const PortfolioPositionsQuery = graphql( diff --git a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-wallet.ts b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-wallet.ts index efe3f21dab..6a5dfbf204 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-wallet.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/portfolio/portfolio-wallet.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const PortfolioWalletQuery = graphql( diff --git a/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/smart-pools.ts b/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/smart-pools.ts index 50b74f5f82..082fa9dd17 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/smart-pools.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/smart-pools.ts @@ -1,8 +1,8 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import type { ChainId } from 'sushi' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import type { EvmChainId } from 'sushi' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import type { Address } from 'viem' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' @@ -76,13 +76,13 @@ export async function getSmartPools( if (result) { return result.smartPools.map((pool) => ({ ...pool, - chainId: pool.chainId as ChainId, + chainId: pool.chainId as EvmChainId, id: pool.id as `${string}:0x${string}`, strategy: pool.strategy, token0: { id: pool.token0.id as `${string}:0x${string}`, address: pool.token0.address as Address, - chainId: pool.token0.chainId as ChainId, + chainId: pool.token0.chainId as EvmChainId, decimals: pool.token0.decimals, name: pool.token0.name, symbol: pool.token0.symbol, @@ -90,7 +90,7 @@ export async function getSmartPools( token1: { id: pool.token1.id as `${string}:0x${string}`, address: pool.token1.address as Address, - chainId: pool.token1.chainId as ChainId, + chainId: pool.token1.chainId as EvmChainId, decimals: pool.token1.decimals, name: pool.token1.name, symbol: pool.token1.symbol, diff --git a/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vault.ts b/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vault.ts index f914c9a60d..6bfd3d31c3 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vault.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vault.ts @@ -1,7 +1,7 @@ import type { SteerChainId } from '@sushiswap/steer-sdk' import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import type { Address } from 'viem' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vaults.ts b/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vaults.ts index 1a57c15b2c..c2902420da 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vaults.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/smart-pool/vaults.ts @@ -1,7 +1,7 @@ import type { SteerChainId } from '@sushiswap/steer-sdk' import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import type { Address } from 'viem' import { graphql } from '../../graphql' import type { VaultV1 } from './vault' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/history.ts b/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/history.ts index 34130315e7..4c86f53a76 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/history.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/history.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/stats.ts b/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/stats.ts index 13451362b8..5e044952ea 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/stats.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/sushi-bar/stats.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/approved-community-tokens.ts b/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/approved-community-tokens.ts index 785d3db2cc..caebedc656 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/approved-community-tokens.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/approved-community-tokens.ts @@ -1,4 +1,4 @@ -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' import { request } from 'src/lib/request' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/pending-tokens.ts b/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/pending-tokens.ts index 672e9f451e..78f1f66fcf 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/pending-tokens.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/pending-tokens.ts @@ -1,4 +1,4 @@ -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' import { request } from 'src/lib/request' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/token-analysis.ts b/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/token-analysis.ts index a249d1126f..cd171957ee 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/token-analysis.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/token-list-submission/token-analysis.ts @@ -1,8 +1,8 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { type ChainId } from 'sushi' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import type { ChainId } from 'sushi' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' import type { ChainIdVariable } from 'src/lib/types/chainId' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list-balances.ts b/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list-balances.ts index 9ef56b1e50..e27331f7eb 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list-balances.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list-balances.ts @@ -2,7 +2,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' import { getIdFromChainIdAddress, type ChainId } from 'sushi' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' import type { ChainIdVariable } from 'src/lib/types/chainId' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list.ts b/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list.ts index 0083ffa3b2..5414d67d23 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/token-list/token-list.ts @@ -2,7 +2,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' import { getIdFromChainIdAddress, type ChainId } from 'sushi' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' import type { ChainIdVariable } from 'src/lib/types/chainId' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/trending-tokens/trending-tokens.ts b/packages/graph-client/src/subgraphs/data-api/queries/trending-tokens/trending-tokens.ts index 85075ba5de..c272401fae 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/trending-tokens/trending-tokens.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/trending-tokens/trending-tokens.ts @@ -2,7 +2,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' import { getIdFromChainIdAddress, type ChainId } from 'sushi' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' import type { ChainIdVariable } from 'src/lib/types/chainId' diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v2/buckets.ts b/packages/graph-client/src/subgraphs/data-api/queries/v2/buckets.ts index c908733882..77c180bd87 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v2/buckets.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v2/buckets.ts @@ -1,9 +1,9 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { ChainId } from 'sushi' +import type { EvmChainId } from 'sushi' import { isSushiSwapV2ChainId } from 'sushi/config' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const V2PoolBucketsQuery = graphql( @@ -38,7 +38,7 @@ export async function getV2PoolBuckets( options?: RequestOptions, ) { const url = `${SUSHI_DATA_API_HOST}/graphql` - const chainId = Number(variables.chainId) as ChainId + const chainId = Number(variables.chainId) as EvmChainId if (!isSushiSwapV2ChainId(chainId)) { throw new Error('Invalid chainId') diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v2/burns.ts b/packages/graph-client/src/subgraphs/data-api/queries/v2/burns.ts index 05a3acb4ec..cf78cdb5df 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v2/burns.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v2/burns.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const SushiV2BurnsQuery = graphql(` diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v2/mints.ts b/packages/graph-client/src/subgraphs/data-api/queries/v2/mints.ts index 2f86b2c6e0..8ac80fd33a 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v2/mints.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v2/mints.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const SushiV2MintsQuery = graphql(` diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v2/positions.ts b/packages/graph-client/src/subgraphs/data-api/queries/v2/positions.ts index 9c34105ee1..bea24d76ed 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v2/positions.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v2/positions.ts @@ -1,9 +1,9 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { ChainId, ChefType, RewarderType, SushiSwapProtocol } from 'sushi' +import { EvmChainId, ChefType, RewarderType, SushiSwapProtocol } from 'sushi' import { isSushiSwapV2ChainId } from 'sushi/config' import { getAddress, type Address } from 'viem' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const V2PositionsQuery = graphql( @@ -75,7 +75,7 @@ export async function getV2Positions( options?: RequestOptions, ) { const url = `${SUSHI_DATA_API_HOST}/graphql` - const chainId = Number(variables.chainId) as ChainId + const chainId = Number(variables.chainId) as EvmChainId if (!isSushiSwapV2ChainId(chainId)) { throw new Error('Invalid chainId') diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v2/swaps.ts b/packages/graph-client/src/subgraphs/data-api/queries/v2/swaps.ts index 045b712e6c..fcfeb13c8a 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v2/swaps.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v2/swaps.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const SushiV2SwapsQuery = graphql(` diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v3/buckets.ts b/packages/graph-client/src/subgraphs/data-api/queries/v3/buckets.ts index 3ca4986a22..97ffbe2428 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v3/buckets.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v3/buckets.ts @@ -1,9 +1,9 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { ChainId } from 'sushi' +import { EvmChainId } from 'sushi' import { isSushiSwapV3ChainId } from 'sushi/config' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const V3PoolBucketsQuery = graphql( @@ -38,7 +38,7 @@ export async function getV3PoolBuckets( options?: RequestOptions, ) { const url = `${SUSHI_DATA_API_HOST}/graphql` - const chainId = Number(variables.chainId) as ChainId + const chainId = Number(variables.chainId) as EvmChainId if (!isSushiSwapV3ChainId(chainId)) { throw new Error('Invalid chainId') diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v3/burns.ts b/packages/graph-client/src/subgraphs/data-api/queries/v3/burns.ts index 084213e571..1b2aa9eaea 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v3/burns.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v3/burns.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const SushiV3BurnsQuery = graphql(` diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v3/collects.ts b/packages/graph-client/src/subgraphs/data-api/queries/v3/collects.ts index d921957e7b..3c26d972c7 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v3/collects.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v3/collects.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const SushiV3CollectsQuery = graphql(` diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v3/mints.ts b/packages/graph-client/src/subgraphs/data-api/queries/v3/mints.ts index 2675975bca..1ad62b266f 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v3/mints.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v3/mints.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const SushiV3MintsQuery = graphql(` diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v3/pools-by-tokens.ts b/packages/graph-client/src/subgraphs/data-api/queries/v3/pools-by-tokens.ts index 014e9dcca8..9d3d3f04b1 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v3/pools-by-tokens.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v3/pools-by-tokens.ts @@ -1,10 +1,10 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { ChainId, SushiSwapProtocol, type PoolBase, type PoolV3 } from 'sushi' +import { SushiSwapProtocol, type PoolBase, type PoolV3 } from 'sushi' import { isSushiSwapV3ChainId } from 'sushi/config' import type { Address } from 'viem' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const V3PoolsByTokensQuery = graphql( @@ -62,7 +62,7 @@ export async function getV3BasePoolsByToken( options?: RequestOptions, ): Promise[]> { const url = `${SUSHI_DATA_API_HOST}/graphql` - const chainId = variables.chainId as ChainId + const chainId = variables.chainId if (!isSushiSwapV3ChainId(chainId)) { throw new Error('Invalid chainId') diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v3/pools.ts b/packages/graph-client/src/subgraphs/data-api/queries/v3/pools.ts index e992a1b3e7..36c093a850 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v3/pools.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v3/pools.ts @@ -1,10 +1,15 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { ChainId, SushiSwapProtocol, type PoolBase, type PoolV3 } from 'sushi' +import { + EvmChainId, + SushiSwapProtocol, + type PoolBase, + type PoolV3, +} from 'sushi' import { isSushiSwapV3ChainId } from 'sushi/config' import type { Address } from 'viem' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' import { SUSHI_REQUEST_HEADERS } from '../../request-headers' @@ -63,7 +68,7 @@ export async function getV3BasePools( options?: RequestOptions, ): Promise[]> { const url = `${SUSHI_DATA_API_HOST}/graphql` - const chainId = variables.chainId as ChainId + const chainId = variables.chainId as EvmChainId if (!isSushiSwapV3ChainId(chainId)) { throw new Error('Invalid chainId') diff --git a/packages/graph-client/src/subgraphs/data-api/queries/v3/swaps.ts b/packages/graph-client/src/subgraphs/data-api/queries/v3/swaps.ts index e127572e86..cbdeb5db48 100644 --- a/packages/graph-client/src/subgraphs/data-api/queries/v3/swaps.ts +++ b/packages/graph-client/src/subgraphs/data-api/queries/v3/swaps.ts @@ -1,7 +1,7 @@ import type { VariablesOf } from 'gql.tada' import { request, type RequestOptions } from 'src/lib/request' -import { SUSHI_DATA_API_HOST } from 'sushi/config/subgraph' +import { SUSHI_DATA_API_HOST } from '../../data-api-host' import { graphql } from '../../graphql' export const SushiV3SwapsQuery = graphql(` diff --git a/packages/graph-client/src/subgraphs/data-api/types/PoolChainId.ts b/packages/graph-client/src/subgraphs/data-api/types/PoolChainId.ts index 49be12dc97..3542c292ce 100644 --- a/packages/graph-client/src/subgraphs/data-api/types/PoolChainId.ts +++ b/packages/graph-client/src/subgraphs/data-api/types/PoolChainId.ts @@ -1,6 +1,6 @@ // This file is auto-generated by scripts/update-data-api-types.ts import type { ChainId } from 'sushi/chain' -export const PoolChainIds = [42161,42170,43114,8453,288,56288,56,42220,1,250,122,100,11235,1666600000,1284,1285,137,534352,2222,1088,199,314,7000,1116,108,10,59144,1101,81457,2046399126,30,146,11155111] as const +export const PoolChainIds = [42161,42170,43114,8453,288,56288,56,42220,1,250,122,100,11235,1666600000,1284,1285,137,534352,2222,1088,199,314,7000,1116,108,10,59144,1101,81457,2046399126,30,146,43111,11155111] as const export type PoolChainId = typeof PoolChainIds[number] export function isPoolChainId(value: ChainId): value is PoolChainId {return PoolChainIds.includes(value as PoolChainId)} \ No newline at end of file diff --git a/packages/graph-client/src/subgraphs/data-api/types/TokenListChainId.ts b/packages/graph-client/src/subgraphs/data-api/types/TokenListChainId.ts index 06abe48dca..5bb5bfc081 100644 --- a/packages/graph-client/src/subgraphs/data-api/types/TokenListChainId.ts +++ b/packages/graph-client/src/subgraphs/data-api/types/TokenListChainId.ts @@ -1,6 +1,6 @@ // This file is auto-generated by scripts/update-data-api-types.ts import type { ChainId } from 'sushi/chain' -export const TokenListChainIds = [42161,42170,43114,8453,288,56288,56,42220,1,250,122,100,11235,1666600000,1284,1285,137,534352,2222,1088,199,314,7000,1116,108,10,59144,1101,81457,2046399126,30,146,11155111,25,5000,324,169,34443,167000,810180,33139] as const +export const TokenListChainIds = [42161,42170,43114,8453,288,56288,56,42220,1,250,122,100,11235,1666600000,1284,1285,137,534352,2222,1088,199,314,7000,1116,108,10,59144,1101,81457,2046399126,30,146,43111,11155111,25,5000,324,169,34443,167000,810180,33139] as const export type TokenListChainId = typeof TokenListChainIds[number] export function isTokenListChainId(value: ChainId): value is TokenListChainId {return TokenListChainIds.includes(value as TokenListChainId)} \ No newline at end of file diff --git a/packages/graph-client/src/subgraphs/furo/queries/tokens.ts b/packages/graph-client/src/subgraphs/furo/queries/tokens.ts index ffaeecd437..05e12e22ca 100644 --- a/packages/graph-client/src/subgraphs/furo/queries/tokens.ts +++ b/packages/graph-client/src/subgraphs/furo/queries/tokens.ts @@ -1,6 +1,6 @@ import type { VariablesOf } from 'gql.tada' import type { FuroChainId } from 'sushi/config' -import { FURO_SUBGRAPH_URL } from 'sushi/config/subgraph' +import { getFuroSubgraphUrl } from 'sushi/config/subgraph' import { addChainId } from 'src/lib/modifiers/add-chain-id' import { convertIdToMultichainId } from 'src/lib/modifiers/convert-id-to-multichain-id' @@ -10,6 +10,7 @@ import { requestPaged } from 'src/lib/request-paged' import type { ChainIdVariable } from 'src/lib/types/chainId' import type { Hex } from 'src/lib/types/hex' import { graphql } from '../graphql' +import { getSubgraphUrl } from 'src/lib/get-subgraph-url' export const FuroTokensQuery = graphql(` query Tokens($first: Int = 1000, $skip: Int = 0, $block: Block_height, $orderBy: Token_orderBy, $orderDirection: OrderDirection, $where: Token_filter) { @@ -34,7 +35,10 @@ export async function getFuroTokens( { chainId, ...variables }: GetFuroTokens, options?: RequestOptions, ) { - const url = `https://${FURO_SUBGRAPH_URL[chainId]}` + const url = getSubgraphUrl({ + chainId, + getter: getFuroSubgraphUrl, + }) const result = await requestPaged({ chainId, diff --git a/packages/hooks/package.json b/packages/hooks/package.json index b8e4aef5fb..365cd9720a 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -47,7 +47,7 @@ "@types/react-dom": "19.0.2", "react": "19.0.0", "react-dom": "19.0.0", - "sushi": "4.1.23", + "sushi": "5.0.4", "tailwindcss": "3.3.2", "typescript": "5.7.2" }, diff --git a/packages/hooks/src/useCustomTokens.ts b/packages/hooks/src/useCustomTokens.ts index a3e835de8e..a01f0114f9 100644 --- a/packages/hooks/src/useCustomTokens.ts +++ b/packages/hooks/src/useCustomTokens.ts @@ -4,10 +4,11 @@ import { useCallback, useMemo } from 'react' import { Token } from 'sushi/currency' import { getAddress, isAddress } from 'viem/utils' +import { EvmChainId } from 'sushi' import { useLocalStorage } from './useLocalStorage' type Data = { - chainId: number + chainId: EvmChainId id: string address: string decimals: number diff --git a/packages/notifications/package.json b/packages/notifications/package.json index 4e44e4af29..75cf0b8013 100644 --- a/packages/notifications/package.json +++ b/packages/notifications/package.json @@ -54,7 +54,7 @@ "@tsconfig/strictest": "2.0.2", "@types/react": "19.0.1", "@types/react-dom": "19.0.2", - "sushi": "4.1.23", + "sushi": "5.0.4", "typescript": "5.7.2" }, "peerDependencies": { diff --git a/packages/notifications/src/components/toast/toast-completed.tsx b/packages/notifications/src/components/toast/toast-completed.tsx index a342421e4f..e14b7e8b58 100644 --- a/packages/notifications/src/components/toast/toast-completed.tsx +++ b/packages/notifications/src/components/toast/toast-completed.tsx @@ -1,5 +1,5 @@ import type { FC } from 'react' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import type { ResolvedNotification } from '../../types' import { ToastContent } from './toast-content' @@ -19,7 +19,7 @@ export const ToastCompleted: FC = ({ const txUrl = href ? href : txHash - ? Chain.from(chainId)?.getTxUrl(txHash) + ? EvmChain.from(chainId)?.getTxUrl(txHash) : '' return ( <> diff --git a/packages/notifications/src/components/toast/toast-failed.tsx b/packages/notifications/src/components/toast/toast-failed.tsx index 55f0d4bdf4..ddaf817981 100644 --- a/packages/notifications/src/components/toast/toast-failed.tsx +++ b/packages/notifications/src/components/toast/toast-failed.tsx @@ -1,5 +1,5 @@ import type { FC } from 'react' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import type { ResolvedNotification } from '../../types' import { ToastContent } from './toast-content' @@ -19,7 +19,7 @@ export const ToastFailed: FC = ({ const txUrl = href ? href : txHash - ? Chain.from(chainId)?.getTxUrl(txHash) + ? EvmChain.from(chainId)?.getTxUrl(txHash) : '' return ( <> diff --git a/packages/notifications/src/components/toast/toast-info.tsx b/packages/notifications/src/components/toast/toast-info.tsx index b75efb8bd9..333533e349 100644 --- a/packages/notifications/src/components/toast/toast-info.tsx +++ b/packages/notifications/src/components/toast/toast-info.tsx @@ -1,6 +1,6 @@ import { HalfCircleIcon } from '@sushiswap/ui/icons/HalfCircleIcon' import type { FC } from 'react' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import type { ResolvedNotification } from '../../types' import { ToastContent } from './toast-content' @@ -18,7 +18,7 @@ export const ToastInfo: FC = ({ const txUrl = href ? href : txHash - ? Chain.from(chainId)?.getTxUrl(txHash) + ? EvmChain.from(chainId)?.getTxUrl(txHash) : '' return ( <> diff --git a/packages/notifications/src/components/toast/toast-pending.tsx b/packages/notifications/src/components/toast/toast-pending.tsx index 513d33b2b5..5a1dfd2c3d 100644 --- a/packages/notifications/src/components/toast/toast-pending.tsx +++ b/packages/notifications/src/components/toast/toast-pending.tsx @@ -1,6 +1,6 @@ import { Dots } from '@sushiswap/ui' import type { FC } from 'react' -import { Chain } from 'sushi/chain' +import { EvmChain } from 'sushi/chain' import type { ResolvedNotification } from '../../types' import { ToastContent } from './toast-content' @@ -20,7 +20,7 @@ export const ToastPending: FC = ({ const txUrl = href ? href : txHash - ? Chain.from(chainId)?.getTxUrl(txHash) + ? EvmChain.from(chainId)?.getTxUrl(txHash) : '' return ( <> diff --git a/packages/steer-sdk/package.json b/packages/steer-sdk/package.json index dc4afed42e..cd0b9c6ff3 100644 --- a/packages/steer-sdk/package.json +++ b/packages/steer-sdk/package.json @@ -54,7 +54,7 @@ }, "dependencies": { "@steerprotocol/contracts": "2.1.0-beta.14", - "sushi": "4.1.23", + "sushi": "5.0.4", "viem": "2.21.55" }, "devDependencies": { diff --git a/packages/steer-sdk/src/constants.ts b/packages/steer-sdk/src/constants.ts index cfb376ecd2..51819b9cba 100644 --- a/packages/steer-sdk/src/constants.ts +++ b/packages/steer-sdk/src/constants.ts @@ -1,5 +1,7 @@ import { ChainId } from 'sushi/chain' -import { DECENTRALIZED_HOST_BY_SUBGRAPH_ID } from 'sushi/config/subgraph' +import { SUSHI_DOMAIN_RESTRICTED_API_KEY } from 'sushi/config/subgraph' + +const DECENTRALIZED_HOST_BY_SUBGRAPH_ID = `gateway-arbitrum.network.thegraph.com/api/${SUSHI_DOMAIN_RESTRICTED_API_KEY}/subgraphs/id` export const STEER_SUPPORTED_CHAIN_IDS = [ ChainId.POLYGON, diff --git a/packages/ui/package.json b/packages/ui/package.json index 647a82177b..50a2104835 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -121,7 +121,7 @@ "postcss": "8.4.23", "react": "19.0.0", "react-dom": "19.0.0", - "sushi": "4.1.23", + "sushi": "5.0.4", "tailwindcss": "3.3.2", "typescript": "5.7.2", "wagmi": "2.12.10" diff --git a/packages/ui/src/components/currency/Icon.tsx b/packages/ui/src/components/currency/Icon.tsx index cc60ec7a5b..625919cf05 100644 --- a/packages/ui/src/components/currency/Icon.tsx +++ b/packages/ui/src/components/currency/Icon.tsx @@ -1,6 +1,6 @@ import { ImageProps } from 'next/image' import { FC } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' import { Currency } from 'sushi/currency' import { Avatar, AvatarImage } from '../avatar' @@ -150,7 +150,7 @@ export const Icon: FC = ({ return ( {avatar} diff --git a/packages/ui/src/components/dialog.tsx b/packages/ui/src/components/dialog.tsx index f86bfef1bb..1c7164c3f0 100644 --- a/packages/ui/src/components/dialog.tsx +++ b/packages/ui/src/components/dialog.tsx @@ -15,7 +15,7 @@ import { useMemo, useState, } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { ChainId, EvmChain } from 'sushi/chain' import { CheckMarkIcon } from '../icons/CheckMarkIcon' import { FailedMarkIcon } from '../icons/FailedMarkIcon' @@ -268,7 +268,7 @@ const DialogConfirm: FC = ({ Waiting for your{' '} @@ -279,7 +279,7 @@ const DialogConfirm: FC = ({ ) : status === 'success' ? ( @@ -288,7 +288,7 @@ const DialogConfirm: FC = ({ ) : ( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2585d2b94a..765077a85d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,8 +111,8 @@ importers: specifier: 19.0.0 version: 19.0.0(react@19.0.0) sushi: - specifier: 4.1.23 - version: 4.1.23(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) + specifier: 5.0.4 + version: 5.0.4(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) devDependencies: '@storybook/addon-a11y': specifier: 8.4.7 @@ -400,8 +400,8 @@ importers: specifier: 2.3.3 version: 2.3.3 sushi: - specifier: 4.1.23 - version: 4.1.23(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) + specifier: 5.0.4 + version: 5.0.4(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) swr: specifier: 2.1.5 version: 2.1.5(react@19.0.0) @@ -588,8 +588,8 @@ importers: specifier: 1.0.0 version: 1.0.0 sushi: - specifier: 4.1.23 - version: 4.1.23(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) + specifier: 5.0.4 + version: 5.0.4(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) viem: specifier: 2.21.55 version: 2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8) @@ -650,8 +650,8 @@ importers: specifier: 19.0.0 version: 19.0.0(react@19.0.0) sushi: - specifier: 4.1.23 - version: 4.1.23(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) + specifier: 5.0.4 + version: 5.0.4(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8) tailwindcss: specifier: 3.3.2 version: 3.3.2(ts-node@10.9.2(@types/node@20.14.14)(typescript@5.7.2)) @@ -696,8 +696,8 @@ importers: specifier: 19.0.2 version: 19.0.2(@types/react@19.0.1) sushi: - specifier: 4.1.23 - version: 4.1.23(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) + specifier: 5.0.4 + version: 5.0.4(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) typescript: specifier: 5.7.2 version: 5.7.2 @@ -708,8 +708,8 @@ importers: specifier: 2.1.0-beta.14 version: 2.1.0-beta.14(bufferutil@4.0.8)(encoding@0.1.13)(squirrelly@8.0.8)(ts-node@10.9.2(@types/node@20.14.14)(typescript@5.7.2))(typescript@5.7.2)(utf-8-validate@5.0.10) sushi: - specifier: 4.1.23 - version: 4.1.23(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) + specifier: 5.0.4 + version: 5.0.4(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) viem: specifier: 2.21.55 version: 2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)(zod@3.23.8) @@ -952,8 +952,8 @@ importers: specifier: 19.0.0 version: 19.0.0(react@19.0.0) sushi: - specifier: 4.1.23 - version: 4.1.23(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) + specifier: 5.0.4 + version: 5.0.4(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8) tailwindcss: specifier: 3.3.2 version: 3.3.2(ts-node@10.9.2(@types/node@20.14.14)(typescript@5.7.2)) @@ -13343,8 +13343,8 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - sushi@4.1.23: - resolution: {integrity: sha512-i0A05i/Tg7RVwokoPTsx7Cbwa5/NOzK0ipiMTSlSofg5t0jJl4C00Eah8PmMPNYrv+gkMLtC0lubE9mIbgd1Hw==} + sushi@5.0.4: + resolution: {integrity: sha512-W2vWAXO7AXgePIocfVnmYrywXFwSqhTnHl7VPvU9SZ7xSxvI64VqNMwH2wFLNXZBn1P1THqvdc0jAA8mYerpSw==} peerDependencies: typescript: 5.7.2 viem: '*' @@ -17842,7 +17842,7 @@ snapshots: '@motionone/easing': 10.15.1 '@motionone/types': 10.15.1 '@motionone/utils': 10.15.1 - tslib: 2.7.0 + tslib: 2.8.1 '@motionone/dom@10.16.2': dependencies: @@ -17851,23 +17851,23 @@ snapshots: '@motionone/types': 10.15.1 '@motionone/utils': 10.15.1 hey-listen: 1.0.8 - tslib: 2.7.0 + tslib: 2.8.1 '@motionone/easing@10.15.1': dependencies: '@motionone/utils': 10.15.1 - tslib: 2.7.0 + tslib: 2.8.1 '@motionone/generators@10.15.1': dependencies: '@motionone/types': 10.15.1 '@motionone/utils': 10.15.1 - tslib: 2.7.0 + tslib: 2.8.1 '@motionone/svelte@10.16.2': dependencies: '@motionone/dom': 10.16.2 - tslib: 2.7.0 + tslib: 2.8.1 '@motionone/types@10.15.1': {} @@ -17875,12 +17875,12 @@ snapshots: dependencies: '@motionone/types': 10.15.1 hey-listen: 1.0.8 - tslib: 2.7.0 + tslib: 2.8.1 '@motionone/vue@10.16.2': dependencies: '@motionone/dom': 10.16.2 - tslib: 2.7.0 + tslib: 2.8.1 '@msafe/aptos-wallet-adapter@1.1.3(patch_hash=ztcfam72g3tcfvfy23kjubyhqa)(@aptos-labs/ts-sdk@1.27.0)(@mizuwallet-sdk/core@1.3.0(@aptos-labs/ts-sdk@1.27.0)(graphql-request@7.1.0(@dprint/formatter@0.3.0)(graphql@16.6.0)))(@mizuwallet-sdk/protocol@0.0.1)(@wallet-standard/core@1.0.3)(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: @@ -18553,7 +18553,7 @@ snapshots: is-glob: 4.0.3 open: 9.1.0 picocolors: 1.1.0 - tslib: 2.7.0 + tslib: 2.8.1 '@playwright/test@1.45.0': dependencies: @@ -27899,7 +27899,7 @@ snapshots: lower-case@2.0.2: dependencies: - tslib: 2.7.0 + tslib: 2.8.1 lowercase-keys@2.0.0: {} @@ -29042,7 +29042,7 @@ snapshots: no-case@3.0.4: dependencies: lower-case: 2.0.2 - tslib: 2.7.0 + tslib: 2.8.1 nocache@3.0.4: {} @@ -29433,7 +29433,7 @@ snapshots: pascal-case@3.1.2: dependencies: no-case: 3.0.4 - tslib: 2.7.0 + tslib: 2.8.1 patch-package@6.5.1: dependencies: @@ -30198,7 +30198,7 @@ snapshots: dependencies: get-nonce: 1.0.1 react: 19.0.0 - tslib: 2.7.0 + tslib: 2.8.1 optionalDependencies: '@types/react': 19.0.1 @@ -30643,7 +30643,7 @@ snapshots: rxjs@7.8.1: dependencies: - tslib: 2.7.0 + tslib: 2.8.1 sade@1.8.1: dependencies: @@ -31344,7 +31344,7 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - sushi@4.1.23(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8): + sushi@5.0.4(typescript@5.7.2)(viem@2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8))(zod@3.23.8): dependencies: '@uniswap/token-lists': 1.0.0-beta.33 big.js: 6.1.1 @@ -31358,7 +31358,7 @@ snapshots: viem: 2.21.55(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@6.0.3)(zod@3.23.8) zod: 3.23.8 - sushi@4.1.23(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8): + sushi@5.0.4(typescript@5.7.2)(viem@2.21.55(typescript@5.7.2)(zod@3.23.8))(zod@3.23.8): dependencies: '@uniswap/token-lists': 1.0.0-beta.33 big.js: 6.1.1