diff --git a/.vscode/settings.json b/.vscode/settings.json index 890b18e1a4..5343c441be 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,6 +32,8 @@ "editor.defaultFormatter": "biomejs.biome", "editor.formatOnSave": true }, + "typescript.tsdk": "apps/evm/node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true, "[typescript]": { "editor.defaultFormatter": "biomejs.biome", "editor.formatOnSave": true diff --git a/apis/extractor/package.json b/apis/extractor/package.json index 9f1926b354..418b911107 100644 --- a/apis/extractor/package.json +++ b/apis/extractor/package.json @@ -30,14 +30,14 @@ "dependencies": { "@sentry/node": "7.110.0", "@sushiswap/extractor": "workspace:*", - "@wagmi/core": "2.6.17", + "@wagmi/core": "2.10.2", "compression": "^1.7.4", "cors": "2.8.5", "dotenv": "16.3.1", "express": "4.18.2", "sushi": "workspace:*", - "viem": "2.8.14", - "wagmi": "2.5.20", + "viem": "2.10.11", + "wagmi": "2.9.2", "zod": "3.21.4" }, "devDependencies": { diff --git a/apis/extractor/src/config.ts b/apis/extractor/src/config.ts index 165e5af38b..898577d1ee 100644 --- a/apis/extractor/src/config.ts +++ b/apis/extractor/src/config.ts @@ -645,7 +645,7 @@ export const EXTRACTOR_CONFIG: Record< }, [ChainId.TELOS]: { client: createPublicClient(extractorClientConfig(ChainId.TELOS)), - factoriesV2: [sushiswapV2Factory(ChainId.TELOS)], + factoriesV2: [], factoriesV3: [], factoriesAlgebra: [ { diff --git a/apis/router/package.json b/apis/router/package.json index 35b04d4dd1..cbeabb9f16 100644 --- a/apis/router/package.json +++ b/apis/router/package.json @@ -31,14 +31,14 @@ "dependencies": { "@sentry/node": "7.110.0", "@sushiswap/extractor": "workspace:*", - "@wagmi/core": "2.6.17", + "@wagmi/core": "2.10.2", "compression": "^1.7.4", "cors": "2.8.5", "dotenv": "16.3.1", "express": "4.18.2", "sushi": "workspace:*", - "viem": "2.8.14", - "wagmi": "2.5.20", + "viem": "2.10.11", + "wagmi": "2.9.2", "zod": "3.21.4" }, "devDependencies": { diff --git a/apis/tokens/package.json b/apis/tokens/package.json index 2c16debcac..d7b5ac7a2d 100644 --- a/apis/tokens/package.json +++ b/apis/tokens/package.json @@ -30,11 +30,11 @@ "@sushiswap/wagmi-config": "workspace:*", "@upstash/redis": "1.22.1", "@vercel/node": "3.0.9", - "@wagmi/core": "2.6.17", + "@wagmi/core": "2.10.2", "drizzle-orm": "^0.29.5", "postgres": "^3.4.3", "sushi": "workspace:*", - "viem": "2.8.14", + "viem": "2.10.11", "zod": "3.21.4" }, "devDependencies": { diff --git a/apps/academy/common/components/AdditionalArticles.tsx b/apps/academy/common/components/AdditionalArticles.tsx index 2ecadd5854..21ba223783 100644 --- a/apps/academy/common/components/AdditionalArticles.tsx +++ b/apps/academy/common/components/AdditionalArticles.tsx @@ -1,6 +1,6 @@ import { PlusCircleIcon } from '@heroicons/react/24/solid' import { LinkInternal, classNames } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import { FC, ReactNode } from 'react' import { DEFAULT_SIDE_PADDING } from '../helpers' diff --git a/apps/academy/common/components/ArticlesPageHeader.tsx b/apps/academy/common/components/ArticlesPageHeader.tsx index 194753288b..1fbf95c35f 100644 --- a/apps/academy/common/components/ArticlesPageHeader.tsx +++ b/apps/academy/common/components/ArticlesPageHeader.tsx @@ -1,12 +1,12 @@ import { useBreakpoint } from '@sushiswap/hooks' -import { classNames } from '@sushiswap/ui' -import { Container } from '@sushiswap/ui/components/container' import { + Container, Select, SelectContent, SelectItem, SelectTrigger, -} from '@sushiswap/ui/components/select' + classNames, +} from '@sushiswap/ui' import { LooperBg } from 'common/assets/LooperBg' import { FC, useEffect, useLayoutEffect, useState } from 'react' diff --git a/apps/academy/common/components/Breadcrumb.tsx b/apps/academy/common/components/Breadcrumb.tsx index 1baa798275..e9d85b08e7 100644 --- a/apps/academy/common/components/Breadcrumb.tsx +++ b/apps/academy/common/components/Breadcrumb.tsx @@ -1,7 +1,5 @@ import { ArrowLeftIcon, ShareIcon } from '@heroicons/react/24/solid' -import { LinkInternal } from '@sushiswap/ui' -import { Container } from '@sushiswap/ui/components/container' -import { IconButton } from '@sushiswap/ui/components/iconbutton' +import { Container, IconButton, LinkInternal } from '@sushiswap/ui' import { getShareText } from 'common/helpers' import { GhostArticle } from 'lib/ghost' import { FC } from 'react' diff --git a/apps/academy/common/components/Difficulties.tsx b/apps/academy/common/components/Difficulties.tsx index 3f7410a6ea..b30b82b561 100644 --- a/apps/academy/common/components/Difficulties.tsx +++ b/apps/academy/common/components/Difficulties.tsx @@ -1,7 +1,7 @@ import { DIFFICULTY_ELEMENTS } from 'common/helpers' import { FC } from 'react' -import { CircleIcon } from '@sushiswap/ui/components/icons' +import { CircleIcon } from '@sushiswap/ui' import { DifficultyEntity } from '../../.mesh' interface Difficulties { diff --git a/apps/academy/common/components/DifficultyCard.tsx b/apps/academy/common/components/DifficultyCard.tsx index a6f965d9a7..1a99d2d8b2 100644 --- a/apps/academy/common/components/DifficultyCard.tsx +++ b/apps/academy/common/components/DifficultyCard.tsx @@ -4,8 +4,7 @@ import { DIFFICULTY_ELEMENTS, DOCS_URL } from 'common/helpers' import { AcademyIcon } from 'common/icons' import { FC, Fragment, useState } from 'react' -import { Chip } from '@sushiswap/ui/components/chip' -import { CircleIcon } from '@sushiswap/ui/components/icons' +import { Chip, CircleIcon } from '@sushiswap/ui' import { DifficultyEntity } from '.mesh' interface DifficultyCard { diff --git a/apps/academy/common/components/DifficultyLabel.tsx b/apps/academy/common/components/DifficultyLabel.tsx index 0deb42281a..c89bb73f91 100644 --- a/apps/academy/common/components/DifficultyLabel.tsx +++ b/apps/academy/common/components/DifficultyLabel.tsx @@ -1,5 +1,4 @@ -import { classNames } from '@sushiswap/ui' -import { CircleIcon } from '@sushiswap/ui/components/icons' +import { CircleIcon, classNames } from '@sushiswap/ui' import { DIFFICULTY_ELEMENTS } from 'common/helpers' import { FC } from 'react' import { Article } from 'types' diff --git a/apps/academy/common/components/FilterButton.tsx b/apps/academy/common/components/FilterButton.tsx index 7e44fb0de2..2825f1ae40 100644 --- a/apps/academy/common/components/FilterButton.tsx +++ b/apps/academy/common/components/FilterButton.tsx @@ -1,6 +1,6 @@ import { FC } from 'react' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import { Maybe } from '../../.mesh' interface FilterButton { diff --git a/apps/academy/common/productsData.tsx b/apps/academy/common/productsData.tsx index 0fbc0976b5..59023d98d4 100644 --- a/apps/academy/common/productsData.tsx +++ b/apps/academy/common/productsData.tsx @@ -6,7 +6,7 @@ import { FantomCircle, OptimismCircle, PolygonCircle, -} from '@sushiswap/ui/components/icons' +} from '@sushiswap/ui' import { AcademyIcon, diff --git a/apps/aptos/package.json b/apps/aptos/package.json index 339d2f8dec..acafacf900 100644 --- a/apps/aptos/package.json +++ b/apps/aptos/package.json @@ -43,7 +43,7 @@ "lodash.uniqby": "^4.7.0", "next": "14.2.3", "next-axiom": "0.17.0", - "next-themes": "^0.2.1", + "next-themes": "0.2.1", "petra-plugin-wallet-adapter": "^0.4.5", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/apps/evm/analyze/nodejs.html b/apps/evm/analyze/nodejs.html new file mode 100644 index 0000000000..986ae9083e --- /dev/null +++ b/apps/evm/analyze/nodejs.html @@ -0,0 +1,39 @@ + + + + + + evm [7 Jun 2024 at 16:44] + + + + + + + + +
+ + + \ No newline at end of file diff --git a/apps/evm/next.config.mjs b/apps/evm/next.config.mjs index b3febd9f5a..d1454f9f7f 100644 --- a/apps/evm/next.config.mjs +++ b/apps/evm/next.config.mjs @@ -2,12 +2,17 @@ import defaultNextConfig from '@sushiswap/nextjs-config' import { withAxiom } from 'next-axiom' +// import withBundleAnalyzer from '@next/bundle-analyzer' +// const bundleAnalyzer = withBundleAnalyzer({ enabled: false }) +// issue with the above.. +const bundleAnalyzer = (a) => a // withBundleAnalyzer({ enabled: true }) + const ACADEMY_URL = process.env.ACADEMY_URL || 'https://academy.sushi.com' const BLOG_URL = process.env.BLOG_URL || 'https://blog.sushi.com' const FURO_URL = process.env.FURO_URL || 'https://furo.sushi.com' /** @type {import('next').NextConfig} */ -const nextConfig = { +const nextConfig = bundleAnalyzer({ ...defaultNextConfig, logging: { fetches: { @@ -17,7 +22,6 @@ const nextConfig = { experimental: { testProxy: true, }, - transpilePackages: ['@sushiswap/wagmi'], async redirects() { return [ { @@ -100,7 +104,7 @@ const nextConfig = { // widenClientFileUpload: true, // automaticVercelMonitors: true, // }, -} +}) /** @type {import('@sentry/nextjs').SentryWebpackPluginOptions} */ // const sentryWebpackPluginOptions = { diff --git a/apps/evm/package.json b/apps/evm/package.json index 33281a18d7..8bf5021174 100644 --- a/apps/evm/package.json +++ b/apps/evm/package.json @@ -20,6 +20,7 @@ "@heroicons/react-v1": "npm:@heroicons/react@v1", "@hookform/resolvers": "3.3.1", "@layerzerolabs/scan-client": "0.0.6", + "@next/bundle-analyzer": "^14.2.3", "@octokit/auth-app": "4.0.7", "@radix-ui/react-slot": "1.0.2", "@sentry/nextjs": "7.110.0", @@ -29,14 +30,12 @@ "@sushiswap/database": "workspace:*", "@sushiswap/dexie": "workspace:*", "@sushiswap/graph-client": "workspace:*", - "@sushiswap/graph-config": "workspace:*", "@sushiswap/hooks": "workspace:*", "@sushiswap/nextjs-config": "workspace:*", "@sushiswap/react-query": "workspace:*", "@sushiswap/steer-sdk": "workspace:*", "@sushiswap/tailwindcss-config": "workspace:*", "@sushiswap/ui": "workspace:*", - "@sushiswap/wagmi": "workspace:*", "@sushiswap/wagmi-config": "workspace:*", "@tanstack/react-query": "4.28.0", "@tanstack/react-query-devtools": "4.28.0", @@ -46,12 +45,12 @@ "@upstash/redis": "1.22.1", "@vercel/analytics": "1.1.1", "@vercel/edge-config": "0.4.1", - "@wagmi/connectors": "^4.1.14", - "@wagmi/core": "2.6.17", + "@wagmi/connectors": "^5.0.2", + "@wagmi/core": "2.10.2", "cors": "2.8.5", "d3": "7.8.4", "date-fns": "2.30.0", - "echarts": "5.4.3", + "echarts": "4.9.0", "echarts-for-react": "3.0.2", "fast-json-stable-stringify": "2.1.0", "framer-motion": "7.10.3", @@ -74,8 +73,8 @@ "sushi": "workspace:*", "swr": "2.1.5", "tiny-invariant": "1.3.1", - "viem": "2.8.14", - "wagmi": "2.5.20", + "viem": "2.10.11", + "wagmi": "2.9.2", "zod": "3.21.4" }, "devDependencies": { @@ -87,6 +86,7 @@ "@tsconfig/next": "2.0.1", "@types/cors": "2.8.13", "@types/d3": "7.4.0", + "@types/echarts": "^4.9.22", "@types/lodash.once": "4.1.9", "@types/lodash.zip": "4.2.9", "@types/node": "20", diff --git a/apps/evm/src/app/(landing)/api/stats/route.ts b/apps/evm/src/app/(landing)/api/stats/route.ts index ccfd198d01..c09da8dfc7 100644 --- a/apps/evm/src/app/(landing)/api/stats/route.ts +++ b/apps/evm/src/app/(landing)/api/stats/route.ts @@ -1,8 +1,5 @@ -import { getBuiltGraphSDK } from '@sushiswap/graph-client' -import { BENTOBOX_ENABLED_NETWORKS } from '@sushiswap/graph-config' import { NextResponse } from 'next/server' import { DISABLED_ANALYTICS_CHAIN_IDS } from 'src/config' -import { getAllPrices } from 'src/lib/get-all-prices' import { ChainId } from 'sushi/chain' import { SUSHISWAP_V2_SUPPORTED_CHAIN_IDS, @@ -10,7 +7,9 @@ import { } from 'sushi/config' import { SUSHI_ADDRESS } from 'sushi/currency' import { formatNumber, formatUSD } from 'sushi/format' -import { getAddress } from 'viem' +import { fetchMultichain } from '../../../../../../../packages/graph-client/dist/multichain' +import { getSushiV2Factory } from '../../../../../../../packages/graph-client/dist/subgraphs/sushi-v2' +import { getSushiV3Factory } from '../../../../../../../packages/graph-client/dist/subgraphs/sushi-v3' const getSushiPriceUSD = async () => { const url = `https://api.sushi.com/price/v1/1/${ @@ -28,81 +27,43 @@ interface ExchangeData { } const getV2Data = async () => { - const sdk = getBuiltGraphSDK() - const { factories } = await sdk.Factories({ + const { data: factories } = await fetchMultichain({ chainIds: SUSHISWAP_V2_SUPPORTED_CHAIN_IDS.filter( (c) => !DISABLED_ANALYTICS_CHAIN_IDS.includes( c as (typeof DISABLED_ANALYTICS_CHAIN_IDS)[number], ), ), + fetch: getSushiV2Factory, }) return { - v2: factories - .filter(({ id }) => id !== 'ALL') - .reduce( - (acc, cur) => { - return { - tvlUSD: acc.tvlUSD + Number(cur.liquidityUSD), - volumeUSD: acc.volumeUSD + Number(cur.volumeUSD), - pairCount: acc.pairCount + Number(cur.pairCount), - } - }, - { - tvlUSD: 0, - volumeUSD: 0, - pairCount: 0, - }, - ), - trident: factories - .filter(({ id }) => id === 'ALL') - .reduce( - (acc, cur) => { - return { - tvlUSD: acc.tvlUSD + Number(cur.liquidityUSD), - volumeUSD: acc.volumeUSD + Number(cur.volumeUSD), - pairCount: acc.pairCount + Number(cur.pairCount), - } - }, - { - tvlUSD: 0, - volumeUSD: 0, - pairCount: 0, - }, - ), + v2: factories.reduce( + (acc, cur) => { + return { + tvlUSD: acc.tvlUSD + Number(cur.totalLiquidityUSD), + volumeUSD: acc.volumeUSD + Number(cur.totalVolumeUSD), + pairCount: acc.pairCount + Number(cur.poolCount), + } + }, + { + tvlUSD: 0, + volumeUSD: 0, + pairCount: 0, + }, + ), } } -const getBentoTvl = async () => { - const sdk = getBuiltGraphSDK() - const { rebases } = await sdk.RebasesByChainIds({ - first: 1000, - chainIds: BENTOBOX_ENABLED_NETWORKS, - }) - const prices = await getAllPrices() - return rebases.reduce((acc, cur) => { - const price = - prices?.[cur.chainId as keyof typeof prices]?.[cur.id] || - prices?.[cur.chainId as keyof typeof prices]?.[getAddress(cur.id)] - if (!price) return acc - - return ( - acc + - (Number(cur.elastic) / 10 ** Number(cur.token.decimals)) * Number(price) - ) - }, 0) -} - const getV3Data = async () => { - const sdk = getBuiltGraphSDK() - const { factories } = await sdk.V3Factories({ + const { data: factories } = await fetchMultichain({ chainIds: SUSHISWAP_V3_SUPPORTED_CHAIN_IDS.filter( (c) => !DISABLED_ANALYTICS_CHAIN_IDS.includes( c as (typeof DISABLED_ANALYTICS_CHAIN_IDS)[number], ), ), + fetch: getSushiV3Factory, }) return factories.reduce( @@ -124,23 +85,15 @@ const getV3Data = async () => { export const revalidate = 3600 export async function GET() { - const [sushiPrice, bentoTVL, v2Data, v3Data] = await Promise.all([ + const [sushiPrice, v2Data, v3Data] = await Promise.all([ getSushiPriceUSD(), - getBentoTvl(), getV2Data(), getV3Data(), ]) - let totalTVL = - Number(bentoTVL) + Number(v2Data.v2.tvlUSD) + Number(v3Data.tvlUSD) - let totalVolume = - Number(v2Data.v2.volumeUSD) + - Number(v2Data.trident.volumeUSD) + - Number(v3Data.volumeUSD) - const totalPoolCount = - Number(v2Data.v2.pairCount) + - Number(v2Data.trident.pairCount) + - Number(v3Data.pairCount) + let totalTVL = Number(v2Data.v2.tvlUSD) + Number(v3Data.tvlUSD) + let totalVolume = Number(v2Data.v2.volumeUSD) + Number(v3Data.volumeUSD) + const totalPoolCount = Number(v2Data.v2.pairCount) + Number(v3Data.pairCount) totalTVL = totalTVL > 10_000_000_000 ? 0 : totalTVL totalVolume = totalVolume > 5_000_000_000_000 ? 0 : totalVolume diff --git a/apps/evm/src/app/(landing)/components/BuildFuture.tsx b/apps/evm/src/app/(landing)/components/BuildFuture.tsx index cb94e3c62f..b9c5938267 100644 --- a/apps/evm/src/app/(landing)/components/BuildFuture.tsx +++ b/apps/evm/src/app/(landing)/components/BuildFuture.tsx @@ -1,5 +1,5 @@ import { Button } from '@sushiswap/ui' -import { Container } from '@sushiswap/ui/components/container' +import { Container } from '@sushiswap/ui' import { motion } from 'framer-motion' import React, { FC } from 'react' diff --git a/apps/evm/src/app/(landing)/components/BuildWealth.tsx b/apps/evm/src/app/(landing)/components/BuildWealth.tsx index 2602af5520..ef6ba30059 100644 --- a/apps/evm/src/app/(landing)/components/BuildWealth.tsx +++ b/apps/evm/src/app/(landing)/components/BuildWealth.tsx @@ -1,4 +1,4 @@ -import { Container } from '@sushiswap/ui/components/container' +import { Container } from '@sushiswap/ui' import Image from 'next/legacy/image' import React, { FC } from 'react' diff --git a/apps/evm/src/app/(landing)/components/Ecosystem.tsx b/apps/evm/src/app/(landing)/components/Ecosystem.tsx index 4a86e99fae..6743af0415 100644 --- a/apps/evm/src/app/(landing)/components/Ecosystem.tsx +++ b/apps/evm/src/app/(landing)/components/Ecosystem.tsx @@ -1,5 +1,5 @@ -import { Button } from '@sushiswap/ui/components/button' -import { Container } from '@sushiswap/ui/components/container' +import { Button } from '@sushiswap/ui' +import { Container } from '@sushiswap/ui' import { motion } from 'framer-motion' import React, { FC } from 'react' diff --git a/apps/evm/src/app/(landing)/components/ExpandableCard.tsx b/apps/evm/src/app/(landing)/components/ExpandableCard.tsx index 91b0e09ccc..e2abdadc1e 100644 --- a/apps/evm/src/app/(landing)/components/ExpandableCard.tsx +++ b/apps/evm/src/app/(landing)/components/ExpandableCard.tsx @@ -1,5 +1,5 @@ import { LinkExternal } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import { AnimatePresence, AnimateSharedLayout, motion } from 'framer-motion' import { nanoid } from 'nanoid' import React, { FC, ReactNode, useCallback, useState } from 'react' diff --git a/apps/evm/src/app/(landing)/components/Hero.tsx b/apps/evm/src/app/(landing)/components/Hero.tsx index 9d18df630a..8c33f63da7 100644 --- a/apps/evm/src/app/(landing)/components/Hero.tsx +++ b/apps/evm/src/app/(landing)/components/Hero.tsx @@ -1,11 +1,11 @@ import { ArrowDownIcon } from '@heroicons/react/24/outline' import { useInterval } from '@sushiswap/hooks' import { LinkInternal, typographyVariants } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Container } from '@sushiswap/ui/components/container' -import { CurrencyInput } from '@sushiswap/wagmi/components/web3-input/Currency' +import { Button } from '@sushiswap/ui' +import { Container } from '@sushiswap/ui' import { motion } from 'framer-motion' import React, { FC, useEffect, useState } from 'react' +import { CurrencyInput } from 'src/lib/wagmi/components/web3-input/Currency' import { ChainId } from 'sushi/chain' import { Native, SUSHI } from 'sushi/currency' diff --git a/apps/evm/src/app/(landing)/components/NeedHelp.tsx b/apps/evm/src/app/(landing)/components/NeedHelp.tsx index 2442cd39b5..112f928fea 100644 --- a/apps/evm/src/app/(landing)/components/NeedHelp.tsx +++ b/apps/evm/src/app/(landing)/components/NeedHelp.tsx @@ -1,12 +1,12 @@ import { LinkExternal, LinkInternal } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Container } from '@sushiswap/ui/components/container' +import { Button } from '@sushiswap/ui' +import { Container } from '@sushiswap/ui' import { DiscordIcon, GithubIcon, TwitterIcon, YoutubeIcon, -} from '@sushiswap/ui/components/icons' +} from '@sushiswap/ui' import React, { FC } from 'react' const SUPPORT_CHANNELS = [ diff --git a/apps/evm/src/app/(landing)/components/Partners.tsx b/apps/evm/src/app/(landing)/components/Partners.tsx index 0667709539..4fc72792dc 100644 --- a/apps/evm/src/app/(landing)/components/Partners.tsx +++ b/apps/evm/src/app/(landing)/components/Partners.tsx @@ -1,4 +1,4 @@ -import { Container } from '@sushiswap/ui/components/container' +import { Container } from '@sushiswap/ui' import { FC } from 'react' import { diff --git a/apps/evm/src/app/(landing)/components/Search.tsx b/apps/evm/src/app/(landing)/components/Search.tsx index 762b17591a..6b1624ebd9 100644 --- a/apps/evm/src/app/(landing)/components/Search.tsx +++ b/apps/evm/src/app/(landing)/components/Search.tsx @@ -5,10 +5,9 @@ import { } from '@heroicons/react-v1/solid' import { useDebounce, useOnClickOutside } from '@sushiswap/hooks' import { LinkInternal, classNames } from '@sushiswap/ui' -import { Currency } from '@sushiswap/ui/components/currency' -import { NetworkIcon } from '@sushiswap/ui/components/icons' -import { SkeletonCircle, SkeletonText } from '@sushiswap/ui/components/skeleton' -import { useToken } from '@sushiswap/wagmi' +import { Currency } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' +import { SkeletonCircle, SkeletonText } from '@sushiswap/ui' import { FC, useEffect, useMemo, useRef, useState } from 'react' import chains, { ChainId, chainShortName } from 'sushi/chain' import { Native, Token, Type } from 'sushi/currency' @@ -16,6 +15,7 @@ import { type TokenList } from 'sushi/token-list' import { isAddress } from 'viem' import { useQuery } from '@tanstack/react-query' +import { useToken } from 'wagmi' import { SUPPORTED_CHAIN_IDS } from '../../../config' const EXAMPLE_CURRENCIES = [ diff --git a/apps/evm/src/app/(landing)/components/Stats.tsx b/apps/evm/src/app/(landing)/components/Stats.tsx index 3910606859..d053907019 100644 --- a/apps/evm/src/app/(landing)/components/Stats.tsx +++ b/apps/evm/src/app/(landing)/components/Stats.tsx @@ -1,6 +1,6 @@ import { useIsMounted } from '@sushiswap/hooks' -import { Container } from '@sushiswap/ui/components/container' -import { SkeletonText } from '@sushiswap/ui/components/skeleton' +import { Container } from '@sushiswap/ui' +import { SkeletonText } from '@sushiswap/ui' import { useQuery } from '@tanstack/react-query' import React, { FC } from 'react' diff --git a/apps/evm/src/app/(landing)/components/Story/Section1/Custody.tsx b/apps/evm/src/app/(landing)/components/Story/Section1/Custody.tsx index 3f15d5621d..d083f8dc97 100644 --- a/apps/evm/src/app/(landing)/components/Story/Section1/Custody.tsx +++ b/apps/evm/src/app/(landing)/components/Story/Section1/Custody.tsx @@ -1,5 +1,5 @@ -import { Button } from '@sushiswap/ui/components/button' -import { Container } from '@sushiswap/ui/components/container' +import { Button } from '@sushiswap/ui' +import { Container } from '@sushiswap/ui' import { motion } from 'framer-motion' import { FC } from 'react' diff --git a/apps/evm/src/app/(landing)/components/Story/Section2/Move.tsx b/apps/evm/src/app/(landing)/components/Story/Section2/Move.tsx index 51f4430c39..cfcce951ef 100644 --- a/apps/evm/src/app/(landing)/components/Story/Section2/Move.tsx +++ b/apps/evm/src/app/(landing)/components/Story/Section2/Move.tsx @@ -1,6 +1,6 @@ import { LinkInternal } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Container } from '@sushiswap/ui/components/container' +import { Button } from '@sushiswap/ui' +import { Container } from '@sushiswap/ui' import { FC } from 'react' import { MoveImage } from './MoveImage' diff --git a/apps/evm/src/app/(landing)/components/Story/Section3/Guard.tsx b/apps/evm/src/app/(landing)/components/Story/Section3/Guard.tsx index f489e38413..26759729cc 100644 --- a/apps/evm/src/app/(landing)/components/Story/Section3/Guard.tsx +++ b/apps/evm/src/app/(landing)/components/Story/Section3/Guard.tsx @@ -1,5 +1,5 @@ -import { Button } from '@sushiswap/ui/components/button' -import { Container } from '@sushiswap/ui/components/container' +import { Button } from '@sushiswap/ui' +import { Container } from '@sushiswap/ui' import { motion } from 'framer-motion' import { FC } from 'react' diff --git a/apps/evm/src/app/(landing)/layout.tsx b/apps/evm/src/app/(landing)/layout.tsx index 4e504f40c0..be0daf6f12 100644 --- a/apps/evm/src/app/(landing)/layout.tsx +++ b/apps/evm/src/app/(landing)/layout.tsx @@ -1,5 +1,5 @@ import { classNames } from '@sushiswap/ui' -import { HotJar } from '@sushiswap/ui/components/scripts' +import { HotJar } from '@sushiswap/ui' import React from 'react' import { Header } from './header' diff --git a/apps/evm/src/app/analytics/api/bentobox/route.ts b/apps/evm/src/app/analytics/api/bentobox/route.ts index 1f9348c2e4..3159171c2d 100644 --- a/apps/evm/src/app/analytics/api/bentobox/route.ts +++ b/apps/evm/src/app/analytics/api/bentobox/route.ts @@ -14,5 +14,9 @@ export async function GET(request: Request) { return new Response(result.error.message, { status: 422 }) } const tokens = await getBentoBoxTokens(result.data) - return NextResponse.json(tokens) + return NextResponse.json(tokens, { + headers: { + 'Cache-Control': 'public, max-age=60, stale-while-revalidate=600', + }, + }) } diff --git a/apps/evm/src/app/analytics/api/bundles/route.ts b/apps/evm/src/app/analytics/api/bundles/route.ts deleted file mode 100644 index 77d99e89d2..0000000000 --- a/apps/evm/src/app/analytics/api/bundles/route.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { NextResponse } from 'next/server' - -import { getBundles } from '../../../../lib/graph' - -export const revalidate = 3600 - -export async function GET() { - const bundles = await getBundles() - return NextResponse.json(bundles) -} diff --git a/apps/evm/src/app/analytics/api/charts/route.ts b/apps/evm/src/app/analytics/api/charts/route.ts index 41ae475807..f44c352a70 100644 --- a/apps/evm/src/app/analytics/api/charts/route.ts +++ b/apps/evm/src/app/analytics/api/charts/route.ts @@ -8,5 +8,9 @@ export async function GET(request: Request) { const { searchParams } = new URL(request.url) const networks = searchParams.get('networks') as string const data = await getCharts({ networks }) - return NextResponse.json(data) + return NextResponse.json(data, { + headers: { + 'Cache-Control': 'public, max-age=60, stale-while-revalidate=600', + }, + }) } diff --git a/apps/evm/src/app/analytics/api/furoTokens/route.ts b/apps/evm/src/app/analytics/api/furoTokens/route.ts index fe16b36ade..c33aa02ca2 100644 --- a/apps/evm/src/app/analytics/api/furoTokens/route.ts +++ b/apps/evm/src/app/analytics/api/furoTokens/route.ts @@ -14,5 +14,9 @@ export async function GET(request: Request) { return new Response(result.error.message, { status: 422 }) } const tokens = await getFuroTokens(result.data) - return NextResponse.json(tokens) + return NextResponse.json(tokens, { + headers: { + 'Cache-Control': 'public, max-age=60, stale-while-revalidate=600', + }, + }) } diff --git a/apps/evm/src/app/analytics/api/pools/count/route.ts b/apps/evm/src/app/analytics/api/pools/count/route.ts index 6267db265d..261db7e93f 100644 --- a/apps/evm/src/app/analytics/api/pools/count/route.ts +++ b/apps/evm/src/app/analytics/api/pools/count/route.ts @@ -22,5 +22,9 @@ export async function GET(request: Request) { return new Response(result.error.message, { status: 422 }) } const count = await getPoolCount(result.data) - return NextResponse.json(count) + return NextResponse.json(count, { + headers: { + 'Cache-Control': 'public, max-age=60, stale-while-revalidate=600', + }, + }) } diff --git a/apps/evm/src/app/analytics/api/pools/route.ts b/apps/evm/src/app/analytics/api/pools/route.ts index c98b5ca5ca..67e71cd4ab 100644 --- a/apps/evm/src/app/analytics/api/pools/route.ts +++ b/apps/evm/src/app/analytics/api/pools/route.ts @@ -28,5 +28,9 @@ export async function GET(request: Request) { return new Response(result.error.message, { status: 422 }) } const pools = await getPools(result.data) - return NextResponse.json(pools) + return NextResponse.json(pools, { + headers: { + 'Cache-Control': 'public, max-age=60, stale-while-revalidate=600', + }, + }) } diff --git a/apps/evm/src/app/analytics/api/token/[id]/route.ts b/apps/evm/src/app/analytics/api/token/[id]/route.ts deleted file mode 100644 index 25172aff02..0000000000 --- a/apps/evm/src/app/analytics/api/token/[id]/route.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NextResponse } from 'next/server' - -import { getToken } from '../../../../../lib/graph' - -export const revalidate = 3600 - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const id = searchParams.get('id') as string - const [token] = await Promise.all([getToken(id)]) - return NextResponse.json({ token }) -} diff --git a/apps/evm/src/app/analytics/api/tokens/count/route.ts b/apps/evm/src/app/analytics/api/tokens/count/route.ts deleted file mode 100644 index 5e5649c611..0000000000 --- a/apps/evm/src/app/analytics/api/tokens/count/route.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NextResponse } from 'next/server' - -import { getTokenCount } from '../../../../../lib/graph' - -export const revalidate = 3600 - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const networks = searchParams.get('networks') as string - const bundles = await getTokenCount({ networks }) - return NextResponse.json(bundles) -} diff --git a/apps/evm/src/app/analytics/api/tokens/route.ts b/apps/evm/src/app/analytics/api/tokens/route.ts deleted file mode 100644 index 923f6ca99b..0000000000 --- a/apps/evm/src/app/analytics/api/tokens/route.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NextResponse } from 'next/server' - -import { GetTokensQuery, getTokens } from '../../../../lib/graph' - -export const revalidate = 3600 - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const networks = searchParams.get('networks') - const where = searchParams.get('where') - const pagination = searchParams.get('pagination') - const pairs = await getTokens({ - networks, - where, - pagination, - } as GetTokensQuery) - return NextResponse.json(pairs) -} diff --git a/apps/evm/src/app/analytics/layout.tsx b/apps/evm/src/app/analytics/layout.tsx index 173305398e..b81621cc42 100644 --- a/apps/evm/src/app/analytics/layout.tsx +++ b/apps/evm/src/app/analytics/layout.tsx @@ -1,5 +1,5 @@ import { Container, LinkInternal, typographyVariants } from '@sushiswap/ui' -import { HotJar } from '@sushiswap/ui/components/scripts' +import { HotJar } from '@sushiswap/ui' import { Header } from './header' import { Providers } from './providers' diff --git a/apps/evm/src/app/analytics/token/[id]/page.tsx b/apps/evm/src/app/analytics/token/[id]/page.tsx deleted file mode 100644 index 29c9e988dd..0000000000 --- a/apps/evm/src/app/analytics/token/[id]/page.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Token } from '@sushiswap/graph-client' -import { FC } from 'react' -import notFound from 'src/app/pool/not-found' - -import { unsanitize } from 'sushi' -import { getToken } from '../../../../lib/graph' -import { TokenHeader } from '../../../../ui/analytics/token-page-header' -import { TokenInformation } from '../../../../ui/analytics/token-page-information' -import { TokenPairs } from '../../../../ui/analytics/token-page-pairs' -import { TokenStats } from '../../../../ui/analytics/token-page-stats' - -const TokenPage: FC<{ params: { id: string } }> = async ({ params }) => { - const token = (await getToken(unsanitize(params.id))) as Token - if (!token) { - return notFound() - } - - return ( - <> - - - - - - ) -} - -export default TokenPage diff --git a/apps/evm/src/app/analytics/vault/table.tsx b/apps/evm/src/app/analytics/vault/table.tsx index 1feb3d07c7..231a1556e1 100644 --- a/apps/evm/src/app/analytics/vault/table.tsx +++ b/apps/evm/src/app/analytics/vault/table.tsx @@ -27,6 +27,7 @@ import { } from './use-bentobox-tokens' import { usePoolFilters } from 'src/ui/pool' +import { BentoBoxChainId, isBentoBoxChainId } from 'sushi/config' const COLUMNS: ColumnDef[] = [ { @@ -100,7 +101,7 @@ export const BentoBoxTokenTable: FC = () => { const args = useMemo( () => ({ - chainIds, + chainIds: chainIds.filter(isBentoBoxChainId) as BentoBoxChainId[], tokenSymbols, }), [chainIds, tokenSymbols], diff --git a/apps/evm/src/app/analytics/vault/use-bentobox-tokens.ts b/apps/evm/src/app/analytics/vault/use-bentobox-tokens.ts index dbe0eeaf49..992f4b9081 100644 --- a/apps/evm/src/app/analytics/vault/use-bentobox-tokens.ts +++ b/apps/evm/src/app/analytics/vault/use-bentobox-tokens.ts @@ -1,12 +1,12 @@ 'use client' import { GetApiInputFromOutput, parseArgs } from '@sushiswap/client' -import { Rebase } from '@sushiswap/graph-client' import { useAllPrices } from '@sushiswap/react-query' import { useMemo } from 'react' import { Amount, Token } from 'sushi/currency' -import useSWR from 'swr' +import type { BentoBoxRebases } from '../../../../../../packages/graph-client/dist/subgraphs/bentobox' +import { useQuery } from '@tanstack/react-query' import { bentoBoxTokensSchema } from '../../../lib/schema' export type GetBentoBoxTokenArgs = GetApiInputFromOutput< @@ -22,10 +22,11 @@ export const getBentoBoxTokensUrl = (args: GetBentoBoxTokenArgs) => `/analytics/api/bentobox${parseArgs(args)}` function useBentoBoxTokens(args: GetBentoBoxTokenArgs) { - const { data: rebases, isValidating } = useSWR( - getBentoBoxTokensUrl(args), - (url) => fetch(url).then((data) => data.json()), - ) + const { data: rebases, isInitialLoading } = useQuery({ + queryKey: [getBentoBoxTokensUrl(args)], + queryFn: () => + fetch(getBentoBoxTokensUrl(args)).then((data) => data.json()), + }) const { data: prices, isLoading } = useAllPrices() @@ -37,7 +38,7 @@ function useBentoBoxTokens(args: GetBentoBoxTokenArgs) { const token = new Token({ chainId: rebase.chainId, decimals: rebase.token.decimals, - address: rebase.id, + address: rebase.id.split(':')[1], symbol: rebase.token.symbol, name: rebase.token.name, }) @@ -63,7 +64,7 @@ function useBentoBoxTokens(args: GetBentoBoxTokenArgs) { }), [rebases, prices], ), - isLoading: isLoading || isValidating, + isLoading: isLoading || isInitialLoading, } } diff --git a/apps/evm/src/app/api/campaign/taskon/core/route.ts b/apps/evm/src/app/api/campaign/taskon/core/route.ts index 3a236a0515..2285a53c55 100644 --- a/apps/evm/src/app/api/campaign/taskon/core/route.ts +++ b/apps/evm/src/app/api/campaign/taskon/core/route.ts @@ -1,9 +1,8 @@ -import { getBuiltGraphSDK } from '@sushiswap/graph-client' -import { SUSHISWAP_V3_SUBGRAPH_URL } from '@sushiswap/graph-config' import { NextRequest, NextResponse } from 'next/server' -import { ChainId } from 'sushi' +import { ChainId } from 'sushi/chain' import { getAddress } from 'viem' import { z } from 'zod' +import { getSushiV3Mints } from '../../../../../../../../packages/graph-client/dist/subgraphs/sushi-v3' const schema = z.object({ address: z.coerce.string().transform((address) => getAddress(address)), @@ -16,12 +15,13 @@ export async function GET(request: NextRequest) { try { const { address } = schema.parse(params) - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_V3_SUBGRAPH_URL[ChainId.CORE], - }) - const { mints } = await sdk.V3Mints({ - where: { origin: address, pool: poolAddress }, + const mints = await getSushiV3Mints({ + chainId: ChainId.CORE, + where: { + origin: address, + pool: poolAddress, + }, }) if (mints.length > 0) { diff --git a/apps/evm/src/app/bonds/api/v1/bonds/[marketId]/route.ts b/apps/evm/src/app/bonds/api/v1/bonds/[marketId]/route.ts index 5820218185..4ecb4a1b6b 100644 --- a/apps/evm/src/app/bonds/api/v1/bonds/[marketId]/route.ts +++ b/apps/evm/src/app/bonds/api/v1/bonds/[marketId]/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { BondApiSchema, getBondFromSubgraph } from '@sushiswap/client/api' import { NextResponse } from 'next/server.js' import { CORS } from '../../../cors' @@ -23,7 +25,9 @@ export async function GET( return NextResponse.json({ error: 'Bond not found' }, { status: 404 }) } - return NextResponse.json(bond, { headers: CORS }) + return NextResponse.json(bond, { + headers: CORS, + }) } catch (e) { return NextResponse.json(e, { headers: CORS }) } diff --git a/apps/evm/src/app/bonds/api/v1/bonds/route.ts b/apps/evm/src/app/bonds/api/v1/bonds/route.ts index 27bc6f0609..c7d399101e 100644 --- a/apps/evm/src/app/bonds/api/v1/bonds/route.ts +++ b/apps/evm/src/app/bonds/api/v1/bonds/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { BondsApiSchema, getBondsFromSubgraph } from '@sushiswap/client/api' import { NextResponse } from 'next/server.js' import { CORS } from '../../cors' @@ -14,7 +16,11 @@ export async function GET(request: Request) { try { const bonds = await getBondsFromSubgraph(result.data) - return NextResponse.json(bonds, { headers: CORS }) + + return NextResponse.json(bonds, { + status: 200, + headers: CORS, + }) } catch (e) { return NextResponse.json(e, { headers: CORS }) } diff --git a/apps/evm/src/app/bonds/api/v1/positions/route.ts b/apps/evm/src/app/bonds/api/v1/positions/route.ts index f16155624d..96f46bfcbb 100644 --- a/apps/evm/src/app/bonds/api/v1/positions/route.ts +++ b/apps/evm/src/app/bonds/api/v1/positions/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { BondsPositionsApiSchema, getBondPositionsFromSubgraph, @@ -19,7 +21,10 @@ export async function GET(request: Request) { try { const positions = await getBondPositionsFromSubgraph(result.data) - return NextResponse.json(positions, { headers: CORS }) + + return NextResponse.json(positions, { + headers: CORS, + }) } catch (e) { return NextResponse.json(e, { headers: CORS }) } diff --git a/apps/evm/src/app/bonds/header.tsx b/apps/evm/src/app/bonds/header.tsx index 6a4255561a..d9062fdaeb 100644 --- a/apps/evm/src/app/bonds/header.tsx +++ b/apps/evm/src/app/bonds/header.tsx @@ -1,9 +1,9 @@ 'use client' import { Navigation } from '@sushiswap/ui' -import { WagmiHeaderComponents } from '@sushiswap/wagmi/components' import React, { FC } from 'react' import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { WagmiHeaderComponents } from 'src/lib/wagmi/components/wagmi-header-components' export const Header: FC = () => { return ( diff --git a/apps/evm/src/app/bonds/hero.tsx b/apps/evm/src/app/bonds/hero.tsx index 6a2e59b331..be94275820 100644 --- a/apps/evm/src/app/bonds/hero.tsx +++ b/apps/evm/src/app/bonds/hero.tsx @@ -2,8 +2,8 @@ import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline' import { LinkExternal, LinkInternal, typographyVariants } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { DiscordIcon } from '@sushiswap/ui/components/icons' +import { Button } from '@sushiswap/ui' +import { DiscordIcon } from '@sushiswap/ui' import { FC } from 'react' export const Hero: FC = () => { diff --git a/apps/evm/src/app/bonds/layout.tsx b/apps/evm/src/app/bonds/layout.tsx index fbb572a742..a62982ac1e 100644 --- a/apps/evm/src/app/bonds/layout.tsx +++ b/apps/evm/src/app/bonds/layout.tsx @@ -1,4 +1,4 @@ -import { HotJar } from '@sushiswap/ui/components/scripts' +import { HotJar } from '@sushiswap/ui' import { Header } from './header' import { Providers } from './providers' diff --git a/apps/evm/src/app/claims/components/ClaimItem.tsx b/apps/evm/src/app/claims/components/ClaimItem.tsx index bfaab7fb1a..0476b76af6 100644 --- a/apps/evm/src/app/claims/components/ClaimItem.tsx +++ b/apps/evm/src/app/claims/components/ClaimItem.tsx @@ -2,26 +2,24 @@ import { CheckIcon } from '@heroicons/react-v1/solid' import { classNames } from '@sushiswap/ui' -import { Badge } from '@sushiswap/ui/components/badge' -import { Button } from '@sushiswap/ui/components/button' -import { Currency } from '@sushiswap/ui/components/currency' -import { NetworkIcon } from '@sushiswap/ui/components/icons' -import { SkeletonCircle, SkeletonText } from '@sushiswap/ui/components/skeleton' -import { - useRP2ExploitClaim, - useRP2ExploitIsClaimed, - useTokenAllowance, - useTokenRevokeApproval, - useTokenWithCache, -} from '@sushiswap/wagmi' -import { RP2ClaimChainId } from '@sushiswap/wagmi' -import { RP2MerkleTreeClaimSchema } from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' +import { Badge } from '@sushiswap/ui' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' +import { SkeletonCircle, SkeletonText } from '@sushiswap/ui' import React, { FC, useMemo } from 'react' +import { useTokenAllowance } from 'src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance' +import { useTokenRevokeApproval } from 'src/lib/wagmi/hooks/approvals/hooks/useTokenRevokeApproval' +import { RP2MerkleTreeClaimSchema } from 'src/lib/wagmi/hooks/exploits/constants' +import { useRP2ExploitClaim } from 'src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaim' +import { useRP2ExploitIsClaimed } from 'src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitIsClaimed' +import { type RP2ClaimChainId } from 'src/lib/wagmi/hooks/exploits/types' +import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { ROUTE_PROCESSOR_2_ADDRESS } from 'sushi/config' import { Amount } from 'sushi/currency' import { ZERO } from 'sushi/math' -import { Address } from 'viem' +import type { Address } from 'viem' import { z } from 'zod' interface ClaimItem { @@ -37,6 +35,7 @@ export const ClaimItem: FC = ({ chainId, account, claim }) => { }) const { data: isClaimed, isLoading: checkIsClaimedLoading } = useRP2ExploitIsClaimed({ index: claim.index, chainId }) + const { write, isPending: isClaimPending } = useRP2ExploitClaim({ claim, chainId, @@ -58,7 +57,9 @@ export const ClaimItem: FC = ({ chainId, account, claim }) => { const amount = useMemo( () => - token ? Amount.fromRawAmount(token, claim.amount.toString()) : undefined, + token + ? Amount.fromRawAmount(token, claim.amount.hex.toString()) + : undefined, [claim.amount, token], ) diff --git a/apps/evm/src/app/claims/components/Header.tsx b/apps/evm/src/app/claims/components/Header.tsx index 6a4255561a..d9062fdaeb 100644 --- a/apps/evm/src/app/claims/components/Header.tsx +++ b/apps/evm/src/app/claims/components/Header.tsx @@ -1,9 +1,9 @@ 'use client' import { Navigation } from '@sushiswap/ui' -import { WagmiHeaderComponents } from '@sushiswap/wagmi/components' import React, { FC } from 'react' import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { WagmiHeaderComponents } from 'src/lib/wagmi/components/wagmi-header-components' export const Header: FC = () => { return ( diff --git a/apps/evm/src/app/claims/components/RevokeItem.tsx b/apps/evm/src/app/claims/components/RevokeItem.tsx index 41729c7671..47662aa53e 100644 --- a/apps/evm/src/app/claims/components/RevokeItem.tsx +++ b/apps/evm/src/app/claims/components/RevokeItem.tsx @@ -1,12 +1,13 @@ import { CheckIcon } from '@heroicons/react-v1/solid' -import { Badge } from '@sushiswap/ui/components/badge' -import { Button } from '@sushiswap/ui/components/button' -import { Currency } from '@sushiswap/ui/components/currency' -import { NetworkIcon } from '@sushiswap/ui/components/icons' -import { List } from '@sushiswap/ui/components/list/List' -import { useTokenAllowance, useTokenRevokeApproval } from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' +import { Badge } from '@sushiswap/ui' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' import React, { FC } from 'react' +import { useTokenAllowance } from 'src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance' +import { useTokenRevokeApproval } from 'src/lib/wagmi/hooks/approvals/hooks/useTokenRevokeApproval' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { ROUTE_PROCESSOR_2_ADDRESS, RouteProcessor2ChainId } from 'sushi/config' import { Token } from 'sushi/currency' import { ZERO } from 'sushi/math' diff --git a/apps/evm/src/app/claims/rp2/check-approvals/route.ts b/apps/evm/src/app/claims/rp2/check-approvals/route.ts new file mode 100644 index 0000000000..1f75132750 --- /dev/null +++ b/apps/evm/src/app/claims/rp2/check-approvals/route.ts @@ -0,0 +1,76 @@ +import { RouteProcessor2ChainId } from 'sushi/config' +import type { Token } from 'sushi/types' +import { type Address } from 'viem' +import { createConfig } from 'wagmi' +import { getToken } from 'wagmi/actions' +import { z } from 'zod' + +import { publicWagmiConfig } from '@sushiswap/wagmi-config' +import { getIdFromChainIdAddress } from 'sushi/format' +import rp2Approvals from '../../../../lib/wagmi/hooks/exploits/data/rp2-approvals.json' + +const querySchema = z.object({ + account: z.coerce.string().transform((account) => account as Address), +}) + +const rp2ApprovalsItemSchema = z.object({ + address: z.string().transform((el) => el as Address), + transactionHash: z.string(), + spender: z.string().transform((el) => el as Address), + owner: z.string().transform((el) => el as Address), + value: z.number(), +}) + +const rp2ApprovalsSchema = z.record( + z.coerce.number().transform((el) => el as RouteProcessor2ChainId), + z.array(rp2ApprovalsItemSchema), +) + +async function checkApprovals(account: Address) { + const approvals = rp2ApprovalsSchema.parse(rp2Approvals) + const items = Object.entries(approvals) + const tokens: Token[] = [] + + for (let i = 0; i < items.length; i++) { + const [key, value] = items[i] + const chainId = +key as RouteProcessor2ChainId + + for (let j = 0; j < value.length; j++) { + const item = value[j] + if (item.owner.toLowerCase() === account.toLowerCase()) { + const resp = await getToken(createConfig(publicWagmiConfig), { + address: item.address, + chainId, + }) + const { decimals, address: tokenAddress, symbol, name } = resp + const token = { + id: getIdFromChainIdAddress(chainId, tokenAddress), + chainId, + address: tokenAddress, + symbol: symbol || '', + name: name || '', + decimals, + } + + if (!tokens.map((el) => el.id).includes(token.id)) { + tokens.push(token) + } + } + } + } + + return tokens +} + +export type Approvals = Awaited> + +export const revalidate = 60 + +export async function GET(req: Request) { + const { searchParams } = new URL(req.url) + const { account } = querySchema.parse(Object.fromEntries(searchParams)) + + const body = await checkApprovals(account) + + return Response.json(body) +} diff --git a/apps/evm/src/app/claims/rp2/find-claims/route.ts b/apps/evm/src/app/claims/rp2/find-claims/route.ts new file mode 100644 index 0000000000..52848c77f3 --- /dev/null +++ b/apps/evm/src/app/claims/rp2/find-claims/route.ts @@ -0,0 +1,42 @@ +import { + RP2ClaimChainIds, + RP2MerkleTreeClaimSchema, + RP2MerkleTreeSchema, +} from 'src/lib/wagmi/hooks/exploits/constants' +import { RP2MerkleTree } from 'src/lib/wagmi/hooks/exploits/rp2-merkle-trees' +import { RP2ClaimChainId } from 'src/lib/wagmi/hooks/exploits/types' +import type { Address } from 'viem' +import { z } from 'zod' + +const querySchema = z.object({ + account: z.coerce.string().transform((account) => account as Address), +}) + +function findClaims(account: Address) { + return RP2ClaimChainIds.reduce< + [RP2ClaimChainId, z.TypeOf][] + >((acc, cur) => { + const claims = RP2MerkleTreeSchema.parse(RP2MerkleTree[cur]).claims.filter( + (el) => el.user.toLowerCase() === account?.toLowerCase(), + ) + + claims.forEach((claim) => { + acc.push([cur, claim]) + }) + + return acc + }, []) +} + +export type Claims = ReturnType + +export const revalidate = Infinity + +export async function GET(req: Request) { + const { searchParams } = new URL(req.url) + const { account } = querySchema.parse(Object.fromEntries(searchParams)) + + const body = findClaims(account) + + return Response.json(body) +} diff --git a/apps/evm/src/app/claims/rp2/page.tsx b/apps/evm/src/app/claims/rp2/page.tsx index decf5a53f4..16f8f677a1 100644 --- a/apps/evm/src/app/claims/rp2/page.tsx +++ b/apps/evm/src/app/claims/rp2/page.tsx @@ -3,25 +3,25 @@ import { Disclosure } from '@headlessui/react' import { ChevronRightIcon } from '@heroicons/react-v1/solid' import { LinkExternal, LinkInternal } from '@sushiswap/ui' -import { Container } from '@sushiswap/ui/components/container' -import { List } from '@sushiswap/ui/components/list/List' -import { - useAccount, - useRP2ExploitCheck, - useRP2ExploitClaimFinder, -} from '@sushiswap/wagmi' -import { ConnectButton } from '@sushiswap/wagmi/components' +import { Container } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' import React, { Fragment } from 'react' +import { ConnectButton } from 'src/lib/wagmi/components/connect-button' +import { useRP2ExploitCheck } from 'src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitCheck' +import { useRP2ExploitClaimFinder } from 'src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaimFinder' +import { useAccount } from 'wagmi' import { ClaimItem } from '../components/ClaimItem' import { Header } from '../components/Header' import { RevokeItem } from '../components/RevokeItem' const RP2ClaimPage = () => { const { address } = useAccount() - const claims = useRP2ExploitClaimFinder({ - account: address, - }) + + const { data: claims, isInitialLoading: isClaimsLoading } = + useRP2ExploitClaimFinder({ + account: address, + }) const { data: tokens, isInitialLoading: isLoading } = useRP2ExploitCheck({ account: address, @@ -92,8 +92,12 @@ const RP2ClaimPage = () => { - ) : claims.length > 0 ? ( - claims.map(([chainId, claim]) => ( + ) : isClaimsLoading ? ( + + {' '} + + ) : (claims?.length || 0) > 0 ? ( + claims?.map(([chainId, claim]) => ( { diff --git a/apps/evm/src/app/internal/bentobox/components/BentoBoxKpis.tsx b/apps/evm/src/app/internal/bentobox/components/BentoBoxKpis.tsx deleted file mode 100644 index 5b8d7417ce..0000000000 --- a/apps/evm/src/app/internal/bentobox/components/BentoBoxKpis.tsx +++ /dev/null @@ -1,44 +0,0 @@ -'use client' - -import { formatNumber } from 'sushi/format' -import useSWR from 'swr' - -import { getBentoBoxKpis } from '../lib' - -// const stats = [ -// { name: 'Total Subscribers', value: '71,897' }, -// { name: 'Avg. Open Rate', value: '58.16%' }, -// { name: 'Avg. Click Rate', value: '24.57%' }, -// ] - -interface KpiProps { - kpi: { name: string; value: number } -} - -function Kpi({ kpi }: KpiProps) { - return ( -
-
- {kpi.name} -
-
- {formatNumber(kpi.value)} -
-
- ) -} - -export function BentoBoxKpis() { - const { data: kpis } = useSWR('bentobox-kpis', () => getBentoBoxKpis()) - - return ( -
- {kpis?.map((kpi) => ( - - ))} -
- ) -} diff --git a/apps/evm/src/app/internal/bentobox/lib/index.ts b/apps/evm/src/app/internal/bentobox/lib/index.ts deleted file mode 100644 index 0ec6049459..0000000000 --- a/apps/evm/src/app/internal/bentobox/lib/index.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { ChainId } from 'sushi/chain' - -const reduceObjectArray = (arr: Record[]) => { - const keys = Object.keys(arr[0]) - - return Object.fromEntries( - keys.map((key) => [ - key, - arr.reduce((acc, cur) => Number(cur[key]) + acc, 0), - ]), - ) -} - -const keyTitleMap: Record = { - depositCount: 'Deposit Count', - withdrawCount: 'Withdraw Count', - transferCount: 'Transfer Count', - protocolCount: 'Protocol Count', - userCount: 'User Count', - tokenCount: 'Token Count', - masterContractCount: 'Master Contract Count', - cloneCount: 'Clone Count', - flashloanCount: 'Flashloan Count', - transactionCount: 'Transaction Count', - strategyCount: 'Strategy Count', - activeStrategyCount: 'Active Strategy Count', - pendingStrategyCount: 'Pending Strategy Count', -} - -export async function getBentoBoxKpis() { - const { getBuiltGraphSDK } = await import('@sushiswap/graph-client') - const sdk = getBuiltGraphSDK() - - const { crossChainBentoBoxKpis } = await sdk.CrossChainBentoBoxKpis({ - chainIds: [ - ChainId.ETHEREUM, - ChainId.POLYGON, - ChainId.AVALANCHE, - ChainId.BSC, - ChainId.FANTOM, - ChainId.GNOSIS, - ChainId.ARBITRUM, - ChainId.CELO, - ChainId.MOONRIVER, - ChainId.MOONBEAM, - ChainId.OPTIMISM, - ChainId.HARMONY, - // ChainId.KAVA, - ], - }) - - const reducedKpis = reduceObjectArray(crossChainBentoBoxKpis) - - const kpis = Object.entries(keyTitleMap).map(([key, title]) => ({ - name: title, - value: reducedKpis[key], - })) - - return kpis -} diff --git a/apps/evm/src/app/internal/bentobox/page.tsx b/apps/evm/src/app/internal/bentobox/page.tsx deleted file mode 100644 index 54a432bd32..0000000000 --- a/apps/evm/src/app/internal/bentobox/page.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { BentoBoxKpis } from './components/BentoBoxKpis' - -export default function BentoBoxPage() { - return ( -
-

BentoBox KPIs

-
-

- Cross Chain BentoBox Kpis -

- -
-
- ) -} diff --git a/apps/evm/src/app/internal/bentobox/strategies/lib/index.ts b/apps/evm/src/app/internal/bentobox/strategies/lib/index.ts deleted file mode 100644 index 5690637b51..0000000000 --- a/apps/evm/src/app/internal/bentobox/strategies/lib/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ChainId } from 'sushi/chain' - -export async function getStrategies() { - const { getBuiltGraphSDK } = await import('@sushiswap/graph-client') - const sdk = getBuiltGraphSDK() - - const { crossChainStrategyKpis: data } = await sdk.CrossChainStrategyKpis({ - chainIds: [ - ChainId.ETHEREUM, - ChainId.POLYGON, - ChainId.AVALANCHE, - ChainId.BSC, - ChainId.FANTOM, - ChainId.GNOSIS, - ChainId.ARBITRUM, - ChainId.CELO, - ChainId.MOONRIVER, - ChainId.MOONBEAM, - ChainId.OPTIMISM, - ChainId.HARMONY, - // ChainId.KAVA, - ], - }) - - return data -} diff --git a/apps/evm/src/app/internal/bentobox/strategies/page.tsx b/apps/evm/src/app/internal/bentobox/strategies/page.tsx deleted file mode 100644 index f6e2653cbf..0000000000 --- a/apps/evm/src/app/internal/bentobox/strategies/page.tsx +++ /dev/null @@ -1,62 +0,0 @@ -'use client' - -import { ChevronDownIcon } from '@heroicons/react/24/outline' -import { NetworkSelector } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { NetworkIcon } from '@sushiswap/ui/components/icons' -import React, { useMemo, useState } from 'react' -import { Chain, ChainId } from 'sushi/chain' -import useSWR from 'swr' - -import { getStrategies } from './lib' - -export default function BentoBoxStrategiesPage() { - const { data } = useSWR('bentobox-strategies', () => getStrategies()) - const strategyChainIds = useMemo( - () => - data?.reduce((acc, cur) => { - acc.push(cur.chainId as ChainId) - return acc - }, [] as ChainId[]), - [data], - ) - - const [selectedChainId, setSelectedChainId] = useState( - ChainId.ETHEREUM, - ) - const filteredStrategies = useMemo( - () => data?.filter((el) => el.chainId === selectedChainId), - [data, selectedChainId], - ) - - return ( -
-

- BentoBox Strategies -

- {strategyChainIds && ( - - - - )} -
- {filteredStrategies?.map((strategy) => ( -
-            {JSON.stringify(strategy, null, 2)}
-          
- ))} -
-
- ) -} diff --git a/apps/evm/src/app/internal/tokens/components/TokenAdder.tsx b/apps/evm/src/app/internal/tokens/components/TokenAdder.tsx index a173dac1a1..f5a2c2c56a 100644 --- a/apps/evm/src/app/internal/tokens/components/TokenAdder.tsx +++ b/apps/evm/src/app/internal/tokens/components/TokenAdder.tsx @@ -1,12 +1,7 @@ import { CheckIcon, XMarkIcon } from '@heroicons/react/24/outline' -import { Currency } from '@sushiswap/ui/components/currency' -import { Loader } from '@sushiswap/ui/components/loader' -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, -} from '@sushiswap/ui/components/select' +import { Currency } from '@sushiswap/ui' +import { Loader } from '@sushiswap/ui' +import { Select, SelectContent, SelectItem, SelectTrigger } from '@sushiswap/ui' import stringify from 'fast-json-stable-stringify' import Image from 'next/legacy/image' import React, { FC, useCallback, useMemo, useState } from 'react' diff --git a/apps/evm/src/app/internal/tokens/components/TokenTable.tsx b/apps/evm/src/app/internal/tokens/components/TokenTable.tsx index 4efc07a246..1642484701 100644 --- a/apps/evm/src/app/internal/tokens/components/TokenTable.tsx +++ b/apps/evm/src/app/internal/tokens/components/TokenTable.tsx @@ -1,9 +1,8 @@ 'use client' import { XIcon } from '@heroicons/react-v1/outline' -import { CHAIN_NAME } from '@sushiswap/graph-config' import { DataTable } from '@sushiswap/ui' -import { CheckIcon, NetworkIcon } from '@sushiswap/ui/components/icons' +import { CheckIcon, NetworkIcon } from '@sushiswap/ui' import { createColumnHelper } from '@tanstack/react-table' import { FC } from 'react' import { ChainId, chainName } from 'sushi/chain' @@ -31,7 +30,7 @@ function useColumns() { width={20} height={20} /> -
{CHAIN_NAME[chainId] ?? chainName[chainId]}
+
{chainName[chainId]}
) }, @@ -53,9 +52,9 @@ function useColumns() { }, enableHiding: true, }), - columnHelper.accessor('liquidityUSD', { + columnHelper.accessor('totalLiquidity', { header: 'Liquidity', - cell: (info) => formatUSD(info.getValue()), + cell: (info) => info.getValue(), enableHiding: true, }), columnHelper.accessor('volumeUSD', { diff --git a/apps/evm/src/app/internal/tokens/config.ts b/apps/evm/src/app/internal/tokens/config.ts index f41c7e5066..2571963a2c 100644 --- a/apps/evm/src/app/internal/tokens/config.ts +++ b/apps/evm/src/app/internal/tokens/config.ts @@ -1,9 +1,3 @@ -import { - SUSHISWAP_ENABLED_NETWORKS, - TRIDENT_ENABLED_NETWORKS, -} from '@sushiswap/graph-config' +import { SUSHISWAP_V2_SUPPORTED_CHAIN_IDS } from 'sushi/config' -export const TOKENS_SUPPORTED_CHAIN_IDS = [ - ...TRIDENT_ENABLED_NETWORKS, - ...SUSHISWAP_ENABLED_NETWORKS, -] +export const TOKENS_SUPPORTED_CHAIN_IDS = [...SUSHISWAP_V2_SUPPORTED_CHAIN_IDS] diff --git a/apps/evm/src/app/internal/tokens/lib/index.ts b/apps/evm/src/app/internal/tokens/lib/index.ts index 11e4abf0c2..d2dced1a1a 100644 --- a/apps/evm/src/app/internal/tokens/lib/index.ts +++ b/apps/evm/src/app/internal/tokens/lib/index.ts @@ -1,6 +1,8 @@ -import { getBuiltGraphSDK } from '@sushiswap/graph-client' import { ChainId } from 'sushi/chain' +import { SushiSwapV2ChainId } from 'sushi/config' import { SUSHI_DEFAULT_TOKEN_LIST } from 'sushi/token-list' +import { fetchMultichain } from '../../../../../../../packages/graph-client/dist/multichain' +import { getSushiV2Tokens } from '../../../../../../../packages/graph-client/dist/subgraphs/sushi-v2' export type Token = Awaited>[0] @@ -8,29 +10,28 @@ export type Token = Awaited>[0] export async function getTokens({ chainIds, filter, -}: { chainIds: ChainId[]; filter?: string }) { - const sdk = getBuiltGraphSDK() - +}: { chainIds: SushiSwapV2ChainId[]; filter?: string }) { const defaultTokenList = await getDefaultTokenList() - const tokens = await sdk - .TokensByChainIds({ - chainIds, - orderBy: 'liquidityUSD', + const { data } = await fetchMultichain({ + chainIds, + fetch: getSushiV2Tokens, + variables: { + orderBy: 'tradeVolumeUSD', where: { symbol_contains_nocase: filter }, - }) - .then(({ tokens }) => - tokens.map((token) => ({ - ...token, - listEntry: - defaultTokenList.find( - (entry) => - entry.address.toLowerCase() === - token.id.toLowerCase().split(':')[1] && - entry.chainId === token.chainId, - ) || null, - })), - ) + }, + }) + + const tokens = data.map((token) => ({ + ...token, + listEntry: + defaultTokenList.find( + (entry) => + entry.address.toLowerCase() === + token.id.toLowerCase().split(':')[1] && + entry.chainId === token.chainId, + ) || null, + })) const tokensCombined = new Map() tokens.forEach((token) => { @@ -39,10 +40,12 @@ export async function getTokens({ if (tokenCombined) { tokensCombined.set(token.id, { ...token, - volumeUSD: Number(token.volumeUSD) + Number(tokenCombined.volumeUSD), - liquidityUSD: - Number(token.liquidityUSD) + Number(tokenCombined.liquidityUSD), - feesUSD: Number(token.feesUSD) + Number(tokenCombined.feesUSD), + volumeUSD: String( + Number(token.volumeUSD) + Number(tokenCombined.volumeUSD), + ), + totalLiquidity: String( + Number(token.totalLiquidity) + Number(tokenCombined.totalLiquidity), + ), }) } else { tokensCombined.set(token.id, token) diff --git a/apps/evm/src/app/internal/tokens/page.tsx b/apps/evm/src/app/internal/tokens/page.tsx index d3f087e5d1..1039736a2f 100644 --- a/apps/evm/src/app/internal/tokens/page.tsx +++ b/apps/evm/src/app/internal/tokens/page.tsx @@ -5,8 +5,8 @@ import { ChevronDownIcon } from '@heroicons/react/24/outline' import { useDebounce } from '@sushiswap/hooks' import { classNames } from '@sushiswap/ui' import { NetworkSelector } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { NetworkIcon } from '@sushiswap/ui/components/icons' +import { Button } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' import stringify from 'fast-json-stable-stringify' import React, { FC, useState } from 'react' import { Chain, ChainId } from 'sushi/chain' @@ -18,7 +18,9 @@ import { Token, getTokens } from './lib' const TokensPage: FC = () => { const [filter, setFilter] = useState('') - const [chainId, setChainId] = useState(ChainId.ETHEREUM) + const [chainId, setChainId] = useState< + (typeof TOKENS_SUPPORTED_CHAIN_IDS)[number] + >(ChainId.ETHEREUM) const debouncedFilter = useDebounce(filter, 400) const { data: tokens } = useSWR( diff --git a/apps/evm/src/app/layout.tsx b/apps/evm/src/app/layout.tsx index a852c95200..2b3fe7e6a6 100644 --- a/apps/evm/src/app/layout.tsx +++ b/apps/evm/src/app/layout.tsx @@ -1,12 +1,14 @@ import '@sushiswap/ui/index.css' -import { SanctionedAddressDialog } from '@sushiswap/wagmi/components/sanctioned-address-dialog' +import 'sushi/bigint-serializer' + import type { Metadata } from 'next' import { Inter, Roboto_Mono } from 'next/font/google' import React from 'react' import { headers } from 'next/headers' -import { getWagmiInitialState } from 'src/lib/wagmi' +import { SanctionedAddressDialog } from 'src/lib/wagmi/components/sanctioned-address-dialog' +import { getWagmiInitialState } from 'src/lib/wagmi/config' import { Providers } from './providers' import { Trackers } from './trackers' diff --git a/apps/evm/src/app/partner/collab-hub-image.tsx b/apps/evm/src/app/partner/collab-hub-image.tsx index c7b3b4a9d4..800f808e10 100644 --- a/apps/evm/src/app/partner/collab-hub-image.tsx +++ b/apps/evm/src/app/partner/collab-hub-image.tsx @@ -1,6 +1,6 @@ 'use client' -import { cloudinaryImageLoader } from '@sushiswap/ui/cloudinary' +import { cloudinaryImageLoader } from '@sushiswap/ui' import Image from 'next/image' export const CollabHubImage = () => { diff --git a/apps/evm/src/app/partner/farmer-image.tsx b/apps/evm/src/app/partner/farmer-image.tsx index 877748faaf..03a977fa88 100644 --- a/apps/evm/src/app/partner/farmer-image.tsx +++ b/apps/evm/src/app/partner/farmer-image.tsx @@ -1,6 +1,6 @@ 'use client' -import { cloudinaryImageLoader } from '@sushiswap/ui/cloudinary' +import { cloudinaryImageLoader } from '@sushiswap/ui' import Image from 'next/image' export const FarmerImage = () => { diff --git a/apps/evm/src/app/partner/page.tsx b/apps/evm/src/app/partner/page.tsx index ccb194d7cd..027f777a2a 100644 --- a/apps/evm/src/app/partner/page.tsx +++ b/apps/evm/src/app/partner/page.tsx @@ -1,8 +1,8 @@ -import { Button } from '@sushiswap/ui/components/button' -import { Container } from '@sushiswap/ui/components/container' -import { LinkExternal, LinkInternal } from '@sushiswap/ui/components/link' -import { Separator } from '@sushiswap/ui/components/separator' -import { typographyVariants } from '@sushiswap/ui/components/typography' +import { Button } from '@sushiswap/ui' +import { Container } from '@sushiswap/ui' +import { LinkExternal, LinkInternal } from '@sushiswap/ui' +import { Separator } from '@sushiswap/ui' +import { typographyVariants } from '@sushiswap/ui' import { Metadata } from 'next' import React from 'react' import { CollabHubImage } from './collab-hub-image' diff --git a/apps/evm/src/app/pool/[id]/(landing)/add/page.tsx b/apps/evm/src/app/pool/[id]/(landing)/add/page.tsx index 8425ac2e31..388fe82c55 100644 --- a/apps/evm/src/app/pool/[id]/(landing)/add/page.tsx +++ b/apps/evm/src/app/pool/[id]/(landing)/add/page.tsx @@ -3,5 +3,5 @@ import PoolPage from '../page' export default async function PoolPageAdd({ params, }: { params: { id: string } }) { - return + return } diff --git a/apps/evm/src/app/pool/[id]/(landing)/page.tsx b/apps/evm/src/app/pool/[id]/(landing)/page.tsx index b8c834a84b..5cb48140af 100644 --- a/apps/evm/src/app/pool/[id]/(landing)/page.tsx +++ b/apps/evm/src/app/pool/[id]/(landing)/page.tsx @@ -8,14 +8,12 @@ import { unsanitize } from 'sushi' export default async function PoolPage({ params, - tab, }: { - params: { id: string } - tab: 'add' | 'remove' | 'unstake' | 'stake' + params: { id: string; tab: 'add' | 'remove' | 'unstake' | 'stake' } }) { const poolId = unsanitize(params.id) const pool = await unstable_cache( - async () => getPool(poolId), + async () => await getPool(poolId), ['pool', poolId], { revalidate: 60 * 15, @@ -31,5 +29,5 @@ export default async function PoolPage({ return } - return + return } diff --git a/apps/evm/src/app/pool/[id]/(landing)/remove/page.tsx b/apps/evm/src/app/pool/[id]/(landing)/remove/page.tsx index f564892814..e53610eaba 100644 --- a/apps/evm/src/app/pool/[id]/(landing)/remove/page.tsx +++ b/apps/evm/src/app/pool/[id]/(landing)/remove/page.tsx @@ -3,5 +3,5 @@ import PoolPage from '../page' export default async function PoolPageRemove({ params, }: { params: { id: string } }) { - return + return } diff --git a/apps/evm/src/app/pool/[id]/(landing)/stake/page.tsx b/apps/evm/src/app/pool/[id]/(landing)/stake/page.tsx index 4322934b1c..1322612519 100644 --- a/apps/evm/src/app/pool/[id]/(landing)/stake/page.tsx +++ b/apps/evm/src/app/pool/[id]/(landing)/stake/page.tsx @@ -3,5 +3,5 @@ import PoolPage from '../page' export default async function PoolPageStake({ params, }: { params: { id: string } }) { - return + return } diff --git a/apps/evm/src/app/pool/[id]/(landing)/unstake/page.tsx b/apps/evm/src/app/pool/[id]/(landing)/unstake/page.tsx index 10af6880e9..45259e807f 100644 --- a/apps/evm/src/app/pool/[id]/(landing)/unstake/page.tsx +++ b/apps/evm/src/app/pool/[id]/(landing)/unstake/page.tsx @@ -3,5 +3,5 @@ import PoolPage from '../page' export default async function PoolPageUnstake({ params, }: { params: { id: string } }) { - return + return } diff --git a/apps/evm/src/app/pool/[id]/smart/(overview)/page.tsx b/apps/evm/src/app/pool/[id]/smart/(overview)/page.tsx index f5a50bebf5..83b45b4190 100644 --- a/apps/evm/src/app/pool/[id]/smart/(overview)/page.tsx +++ b/apps/evm/src/app/pool/[id]/smart/(overview)/page.tsx @@ -1,22 +1,29 @@ -import { getPool } from '@sushiswap/client' +import { getPool, getSteerVaults } from '@sushiswap/client' import { unstable_cache } from 'next/cache' import notFound from 'src/app/pool/not-found' import { SteerCarousel } from 'src/ui/pool/Steer/SteerCarousel' +import type { ID } from 'sushi' import { unsanitize } from 'sushi/format' export default async function VaultOverviewPage({ params, }: { params: { id: string } }) { - const poolId = unsanitize(params.id) - const pool = await unstable_cache( - async () => getPool(poolId), + const poolId = unsanitize(params.id) as ID + const poolP = unstable_cache(async () => getPool(poolId), ['pool', poolId], { + revalidate: 60 * 15, + })() + + const vaultsP = unstable_cache( + async () => getSteerVaults({ poolId }), ['pool', poolId], { revalidate: 60 * 15, }, )() - if (!pool) { + const [pool, vaults] = await Promise.all([poolP, vaultsP]) + + if (!pool || !vaults) { notFound() } diff --git a/apps/evm/src/app/pool/[id]/smart/[vaultId]/page.tsx b/apps/evm/src/app/pool/[id]/smart/[vaultId]/page.tsx index 1045560c6e..39541b2116 100644 --- a/apps/evm/src/app/pool/[id]/smart/[vaultId]/page.tsx +++ b/apps/evm/src/app/pool/[id]/smart/[vaultId]/page.tsx @@ -6,14 +6,13 @@ import { getVaultPositions, } from '@sushiswap/steer-sdk' import { Container } from '@sushiswap/ui' -import { deserialize, serialize } from '@wagmi/core' import formatDistanceStrict from 'date-fns/formatDistanceStrict' import formatDistanceToNow from 'date-fns/formatDistanceToNow' import { unstable_cache } from 'next/cache' import { publicClientConfig } from 'sushi/config' import { Token } from 'sushi/currency' import { formatNumber, unsanitize } from 'sushi/format' -import { tickToPrice } from 'sushi/pool' +import { tickToPrice } from 'sushi/pool/sushiswap-v3' import { PublicClient, createPublicClient } from 'viem' import { SteerStrategyComponents, @@ -23,14 +22,8 @@ import { function getPriceExtremes( vault: SteerVault, ): SteerStrategyGeneric['priceExtremes'] { - const token0 = new Token({ - chainId: vault.pool.chainId, - ...vault.pool.token0, - }) - const token1 = new Token({ - chainId: vault.pool.chainId, - ...vault.pool.token1, - }) + const token0 = new Token(vault.token0) + const token1 = new Token(vault.token1) let lowerPrice = tickToPrice(token0, token1, vault.lowerTick).toSignificant(7) let upperPrice = tickToPrice(token0, token1, vault.upperTick).toSignificant(7) @@ -92,15 +85,13 @@ export default async function SteerVaultPage({ ['steer-vault', vaultId], { revalidate: 60 * 15 }, )() - const generics = deserialize( - await unstable_cache( - async () => serialize(await getGenerics(vault)), - ['steer-vault-generics', vaultId], - { - revalidate: 60 * 5, - }, - )(), - ) as Awaited> + const generics = await unstable_cache( + async () => await getGenerics(vault), + ['steer-vault-generics', vaultId], + { + revalidate: 60 * 5, + }, + )() const Component = SteerStrategyComponents[vault.strategy] diff --git a/apps/evm/src/app/pool/add/page.tsx b/apps/evm/src/app/pool/add/page.tsx index bdd23ee3c9..8c75f7e07a 100644 --- a/apps/evm/src/app/pool/add/page.tsx +++ b/apps/evm/src/app/pool/add/page.tsx @@ -1,12 +1,12 @@ 'use client' -import { useAccount, useConcentratedPositionInfo } from '@sushiswap/wagmi' -import { getV3FactoryContractConfig } from '@sushiswap/wagmi/hooks/contracts/useV3FactoryContract' import React, { FC, useMemo, useState } from 'react' +import { useConcentratedPositionInfo } from 'src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionInfo' import { computeSushiSwapV3PoolAddress } from 'sushi' -import { isWNativeSupported } from 'sushi/config' +import { SUSHISWAP_V3_FACTORY_ADDRESS, isWNativeSupported } from 'sushi/config' import { tryParseAmount } from 'sushi/currency' import { SWRConfig } from 'swr' +import { useAccount } from 'wagmi' import { SUPPORTED_CHAIN_IDS } from '../../../config' import { useTokenAmountDollarValues } from '../../../lib/hooks' import { ConcentratedLiquidityProvider } from '../../../ui/pool/ConcentratedLiquidityProvider' @@ -60,7 +60,7 @@ const _Add: FC = () => { () => token0 && token1 && feeAmount && chainId ? computeSushiSwapV3PoolAddress({ - factoryAddress: getV3FactoryContractConfig(chainId).address, + factoryAddress: SUSHISWAP_V3_FACTORY_ADDRESS[chainId], tokenA: token0.wrapped, tokenB: token1.wrapped, fee: feeAmount, diff --git a/apps/evm/src/app/pool/add/v2/[chainId]/page.tsx b/apps/evm/src/app/pool/add/v2/[chainId]/page.tsx index 2edf34d21a..20032a4cb3 100644 --- a/apps/evm/src/app/pool/add/v2/[chainId]/page.tsx +++ b/apps/evm/src/app/pool/add/v2/[chainId]/page.tsx @@ -2,12 +2,8 @@ import { PlusIcon } from '@heroicons/react-v1/solid' import { FormSection } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Loader } from '@sushiswap/ui/components/loader' -import { PoolFinder, SushiSwapV2PoolState } from '@sushiswap/wagmi' -import { Web3Input } from '@sushiswap/wagmi/components/web3-input' -import { Checker } from '@sushiswap/wagmi/systems' -import { CheckerProvider } from '@sushiswap/wagmi/systems/Checker/Provider' +import { Button } from '@sushiswap/ui' +import { Loader } from '@sushiswap/ui' import { useRouter } from 'next/navigation' import React, { Dispatch, @@ -34,9 +30,14 @@ import { } from 'sushi/config' import { Amount, Type, tryParseAmount } from 'sushi/currency' import { ZERO } from 'sushi/math' -import { SushiSwapV2Pool } from 'sushi/pool' +import { SushiSwapV2Pool } from 'sushi/pool/sushiswap-v2' import { SWRConfig } from 'swr' +import { Web3Input } from 'src/lib/wagmi/components/web3-input' +import { SushiSwapV2PoolState } from 'src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { CheckerProvider } from 'src/lib/wagmi/systems/Checker/Provider' +import { PoolFinder } from 'src/lib/wagmi/systems/PoolFinder/PoolFinder' import { AddSectionPoolShareCardV2 } from 'src/ui/pool/AddSectionPoolShareCardV2' import { AddSectionReviewModalLegacy } from '../../../../../ui/pool/AddSectionReviewModalLegacy' import { SelectNetworkWidget } from '../../../../../ui/pool/SelectNetworkWidget' diff --git a/apps/evm/src/app/pool/api/graphPool/[id]/route.ts b/apps/evm/src/app/pool/api/graphPool/[id]/route.ts index 22eebef43a..ff245fdc6a 100644 --- a/apps/evm/src/app/pool/api/graphPool/[id]/route.ts +++ b/apps/evm/src/app/pool/api/graphPool/[id]/route.ts @@ -1,5 +1,7 @@ +import 'sushi/bigint-serializer' + import { NextResponse } from 'next/server' -import { getGraphPool } from 'src/lib/graph' +import { getV2GraphPool } from 'src/lib/graph' import { z } from 'zod' export const revalidate = 15 @@ -18,6 +20,6 @@ export async function GET( return new Response(result.error.message, { status: 400 }) } - const pool = await getGraphPool(result.data.id) + const pool = await getV2GraphPool(result.data.id) return NextResponse.json(pool) } diff --git a/apps/evm/src/app/pool/api/graphPools/route.ts b/apps/evm/src/app/pool/api/graphPools/route.ts deleted file mode 100644 index b6dc1ebbaa..0000000000 --- a/apps/evm/src/app/pool/api/graphPools/route.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { NextResponse } from 'next/server' -import { getGraphPools } from 'src/lib/graph' -import { z } from 'zod' - -export const revalidate = 60 - -const schema = z.object({ - ids: z.string().transform((ids) => ids.split(',')), -}) - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const ids = searchParams.get('ids') - const result = schema.safeParse({ ids }) - if (!result.success) { - return new Response(result.error.message, { status: 422 }) - } - const pool = await getGraphPools(result.data.ids) - return NextResponse.json(pool) -} diff --git a/apps/evm/src/app/pool/api/pools/[chainId]/[address]/route.ts b/apps/evm/src/app/pool/api/pools/[chainId]/[address]/route.ts index e1ef81a61b..101c9b31c2 100644 --- a/apps/evm/src/app/pool/api/pools/[chainId]/[address]/route.ts +++ b/apps/evm/src/app/pool/api/pools/[chainId]/[address]/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { PoolApiSchema, getPoolFromDB } from '@sushiswap/client/api' import { NextResponse } from 'next/server.js' import { CORS } from '../../../cors' @@ -26,5 +28,7 @@ export async function GET( return NextResponse.json({ error: 'Failed to fetch pool' }, { status: 500 }) } - return NextResponse.json(pool, { headers: CORS }) + return NextResponse.json(pool, { + headers: CORS, + }) } diff --git a/apps/evm/src/app/pool/api/pools/count/route.ts b/apps/evm/src/app/pool/api/pools/count/route.ts index ad540a1846..072245b225 100644 --- a/apps/evm/src/app/pool/api/pools/count/route.ts +++ b/apps/evm/src/app/pool/api/pools/count/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { PoolCountApiSchema, getPoolCountFromDB } from '@sushiswap/client/api' import { NextResponse } from 'next/server.js' import { CORS } from '../../cors' @@ -13,5 +15,7 @@ export async function GET(request: Request) { } const count = await getPoolCountFromDB(result.data) - return NextResponse.json(count, { headers: CORS }) + return NextResponse.json(count, { + headers: CORS, + }) } diff --git a/apps/evm/src/app/pool/api/pools/route.ts b/apps/evm/src/app/pool/api/pools/route.ts index 1bed334db3..6443a12a5e 100644 --- a/apps/evm/src/app/pool/api/pools/route.ts +++ b/apps/evm/src/app/pool/api/pools/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { PoolsApiSchema, getPoolsFromDB } from '@sushiswap/client/api' import { NextResponse } from 'next/server.js' import { CORS } from '../cors' @@ -13,5 +15,8 @@ export async function GET(request: Request) { } const pools = await getPoolsFromDB(result.data) - return NextResponse.json(pools, { headers: CORS }) + + return NextResponse.json(pools, { + headers: CORS, + }) } diff --git a/apps/evm/src/app/pool/api/steer-vault/[chainId]/[address]/route.ts b/apps/evm/src/app/pool/api/steer-vault/[chainId]/[address]/route.ts index fdee2173a8..7e09de2f2d 100644 --- a/apps/evm/src/app/pool/api/steer-vault/[chainId]/[address]/route.ts +++ b/apps/evm/src/app/pool/api/steer-vault/[chainId]/[address]/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { SteerVaultApiSchema, getSteerVaultFromDB } from '@sushiswap/client/api' import { NextResponse } from 'next/server.js' import { CORS } from '../../../cors' @@ -18,5 +20,7 @@ export async function GET( } const vault = await getSteerVaultFromDB(result.data) - return NextResponse.json(vault, { headers: CORS }) + return NextResponse.json(vault, { + headers: CORS, + }) } diff --git a/apps/evm/src/app/pool/api/steer-vault/count/route.ts b/apps/evm/src/app/pool/api/steer-vault/count/route.ts index 2814a88cc6..158150b100 100644 --- a/apps/evm/src/app/pool/api/steer-vault/count/route.ts +++ b/apps/evm/src/app/pool/api/steer-vault/count/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { SteerVaultCountApiSchema, getSteerVaultCountFromDB, @@ -18,5 +20,7 @@ export async function GET(request: Request) { } const count = await getSteerVaultCountFromDB(result.data) - return NextResponse.json(count, { headers: CORS }) + return NextResponse.json(count, { + headers: CORS, + }) } diff --git a/apps/evm/src/app/pool/api/steer-vault/route.ts b/apps/evm/src/app/pool/api/steer-vault/route.ts index 691063590e..cce9b56134 100644 --- a/apps/evm/src/app/pool/api/steer-vault/route.ts +++ b/apps/evm/src/app/pool/api/steer-vault/route.ts @@ -1,3 +1,5 @@ +import 'sushi/bigint-serializer' + import { SteerVaultsApiSchema, getSteerVaultsFromDB, @@ -18,5 +20,7 @@ export async function GET(request: Request) { } const vaults = await getSteerVaultsFromDB(result.data) - return NextResponse.json(vaults, { headers: CORS }) + return NextResponse.json(vaults, { + headers: CORS, + }) } diff --git a/apps/evm/src/app/pool/api/user-with-pools/route.ts b/apps/evm/src/app/pool/api/user-with-pools/route.ts new file mode 100644 index 0000000000..97f88516cc --- /dev/null +++ b/apps/evm/src/app/pool/api/user-with-pools/route.ts @@ -0,0 +1,117 @@ +import 'sushi/bigint-serializer' + +import { getPools } from '@sushiswap/client' +import type { PoolHasSteerVaults } from '@sushiswap/steer-sdk' +import { NextResponse } from 'next/server' +import { getUser, getV2GraphPools } from 'src/lib/graph' +import { ChainId } from 'sushi/chain' + +import { isSushiSwapV2ChainId } from 'sushi/config' +import type { + PoolBase, + PoolIfIncentivized, + PoolWithAprs, + SushiPositionStaked, + SushiPositionWithPool, +} from 'sushi/types' +import { Address } from 'viem' +import { z } from 'zod' +import { CORS } from '../cors' + +export const revalidate = 15 + +const schema = z.object({ + id: z + .string() + .refine((id) => id.startsWith('0x')) + .transform((id) => id.toLowerCase() as Address), + chainIds: z.nullable(z.string()).transform((chainIds) => + chainIds + ?.split(',') + .map((chainId) => Number(chainId) as ChainId) + .filter(isSushiSwapV2ChainId), + ), +}) + +export type UserWithPool = SushiPositionWithPool< + PoolHasSteerVaults, true>, + SushiPositionStaked +> + +export async function GET(request: Request) { + const { searchParams } = new URL(request.url) + const id = searchParams.get('id') + const chainIds = searchParams.get('chainIds') + + if (!id) return new Response('No user(id) provided', { status: 422 }) + const result = schema.safeParse({ id, chainIds }) + if (!result.success) { + return new Response(result.error.message, { status: 400 }) + } + const args = result.data + const data = await getUser(args) + const poolIds = data.map((position) => position.pool.id) + + if (poolIds.length === 0) { + return NextResponse.json([], { + status: 200, + headers: { + 'Cache-Control': 'public, max-age=15, stale-while-revalidate=600', + ...CORS, + }, + }) + } + + const [graphPoolsPromise, dbPoolsPromise] = await Promise.allSettled([ + getV2GraphPools(poolIds), + getPools({ + ids: poolIds, + }), + ]) + + const graphPools = + graphPoolsPromise.status === 'fulfilled' ? graphPoolsPromise.value : [] + const dbPools = + dbPoolsPromise.status === 'fulfilled' ? dbPoolsPromise.value : [] + + const userPositions = data + .map((position) => { + const dbPool = dbPools?.find((pool) => pool.id === position.pool.id) + const graphPool = graphPools?.find( + (graphPool) => graphPool.id === position.pool.id, + ) + + const pool: PoolWithAprs> | undefined = + dbPool || graphPool + ? { + ...graphPool!, + isIncentivized: dbPool?.isIncentivized ?? false, + wasIncentivized: dbPool?.wasIncentivized ?? false, + incentiveApr: dbPool?.incentiveApr ?? 0, + feeApr1h: dbPool?.feeApr1h ?? 0, + feeApr1d: dbPool?.feeApr1d ?? 0, + feeApr1w: dbPool?.feeApr1w ?? 0, + feeApr1m: dbPool?.feeApr1m ?? 0, + totalApr1h: dbPool?.totalApr1h ?? 0, + totalApr1d: dbPool?.totalApr1d ?? 0, + totalApr1w: dbPool?.totalApr1w ?? 0, + totalApr1m: dbPool?.totalApr1m ?? 0, + } + : undefined + + if (!pool) return undefined + + return { + ...position, + pool, + } + }) + .filter((pool): pool is NonNullable => pool !== undefined) + + return NextResponse.json(userPositions, { + headers: { + 'Cache-Control': 'public, max-age=15, stale-while-revalidate=600', + ...CORS, + }, + }) +} diff --git a/apps/evm/src/app/pool/api/user/route.ts b/apps/evm/src/app/pool/api/user/route.ts index 15ee8c5145..296dc97508 100644 --- a/apps/evm/src/app/pool/api/user/route.ts +++ b/apps/evm/src/app/pool/api/user/route.ts @@ -1,17 +1,26 @@ +import 'sushi/bigint-serializer' + import { NextResponse } from 'next/server' import { getUser } from 'src/lib/graph' import { ChainId } from 'sushi/chain' +import { isSushiSwapV2ChainId } from 'sushi/config' +import { Address } from 'viem' import { z } from 'zod' +import { CORS } from '../cors' export const revalidate = 15 const schema = z.object({ - id: z.string(), - chainIds: z - .nullable(z.string()) - .transform((chainIds) => - chainIds?.split(',').map((chainId) => Number(chainId) as ChainId), - ), + id: z + .string() + .refine((id) => id.startsWith('0x')) + .transform((id) => id.toLowerCase() as Address), + chainIds: z.nullable(z.string()).transform((chainIds) => + chainIds + ?.split(',') + .map((chainId) => Number(chainId) as ChainId) + .filter(isSushiSwapV2ChainId), + ), }) // export const dynamic = 'auto' @@ -32,5 +41,11 @@ export async function GET(request: Request) { } const args = result.data const data = await getUser(args) - return NextResponse.json(data) + + return NextResponse.json(data, { + headers: { + 'Cache-Control': 'public, max-age=15, stale-while-revalidate=600', + ...CORS, + }, + }) } diff --git a/apps/evm/src/app/pool/header.tsx b/apps/evm/src/app/pool/header.tsx index 6a4255561a..d9062fdaeb 100644 --- a/apps/evm/src/app/pool/header.tsx +++ b/apps/evm/src/app/pool/header.tsx @@ -1,9 +1,9 @@ 'use client' import { Navigation } from '@sushiswap/ui' -import { WagmiHeaderComponents } from '@sushiswap/wagmi/components' import React, { FC } from 'react' import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { WagmiHeaderComponents } from 'src/lib/wagmi/components/wagmi-header-components' export const Header: FC = () => { return ( diff --git a/apps/evm/src/app/pool/hero.tsx b/apps/evm/src/app/pool/hero.tsx index 66d16d1fbe..1e30b88a0b 100644 --- a/apps/evm/src/app/pool/hero.tsx +++ b/apps/evm/src/app/pool/hero.tsx @@ -2,18 +2,17 @@ import { GiftIcon } from '@heroicons/react-v1/outline' import { LinkExternal, LinkInternal, typographyVariants } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Chip } from '@sushiswap/ui/components/chip' +import { Button } from '@sushiswap/ui' +import { Chip } from '@sushiswap/ui' import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, -} from '@sushiswap/ui/components/dropdown-menu' -import { DiscordIcon } from '@sushiswap/ui/components/icons' -import { SelectIcon } from '@sushiswap/ui/components/select' -import { useChainId } from '@sushiswap/wagmi' +} from '@sushiswap/ui' +import { DiscordIcon } from '@sushiswap/ui' +import { SelectIcon } from '@sushiswap/ui' import { FC } from 'react' import { ChainId } from 'sushi/chain' import { @@ -21,6 +20,7 @@ import { isSushiSwapV2ChainId, isSushiSwapV3ChainId, } from 'sushi/config' +import { useChainId } from 'wagmi' export const Hero: FC = () => { const chainId = useChainId() diff --git a/apps/evm/src/app/pool/incentivize/page.tsx b/apps/evm/src/app/pool/incentivize/page.tsx index 0fdbf8b8ff..533ffe581f 100644 --- a/apps/evm/src/app/pool/incentivize/page.tsx +++ b/apps/evm/src/app/pool/incentivize/page.tsx @@ -27,31 +27,30 @@ import { classNames, typographyVariants, } from '@sushiswap/ui' +import { format } from 'date-fns' +import { useMemo, useState } from 'react' +import { Web3Input } from 'src/lib/wagmi/components/web3-input' +import { useConcentratedLiquidityPool } from 'src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool' import { AngleConditionsState, useAcceptAngleConditions, - useAccount, - useConcentratedLiquidityPool, - useWaitForTransactionReceipt, -} from '@sushiswap/wagmi' -import { useIncentivizePoolWithRewards } from '@sushiswap/wagmi' -import { Web3Input } from '@sushiswap/wagmi/components/web3-input' -import { Checker } from '@sushiswap/wagmi/systems' +} from 'src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions' +import { useIncentivizePoolWithRewards } from 'src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { useApproved, withCheckerRoot, -} from '@sushiswap/wagmi/systems/Checker/Provider' -import { format } from 'date-fns' -import { useMemo, useState } from 'react' +} from 'src/lib/wagmi/systems/Checker/Provider' import { Chain } from 'sushi/chain' import { - ANGLE_ENABLED_NETWORKS, + ANGLE_SUPPORTED_CHAIN_IDS, SushiSwapV3ChainId, isWNativeSupported, } from 'sushi/config' import { Token, Type, tryParseAmount } from 'sushi/currency' -import { SushiSwapV3Pool } from 'sushi/pool' +import { SushiSwapV3Pool } from 'sushi/pool/sushiswap-v3' import { Address, zeroAddress } from 'viem' +import { useAccount, useWaitForTransactionReceipt } from 'wagmi' import { ConcentratedLiquidityProvider } from '../../../ui/pool/ConcentratedLiquidityProvider' import { ConcentratedLiquidityURLStateProvider, @@ -66,7 +65,7 @@ const APPROVE_TAG = 'approve-incentivize' export default function Page() { return ( @@ -203,7 +202,7 @@ const Incentivize = withCheckerRoot(() => { title="On which network would you like to add rewards?" selectedNetwork={chainId} onSelect={setNetwork} - networks={ANGLE_ENABLED_NETWORKS} + networks={ANGLE_SUPPORTED_CHAIN_IDS} /> { In order to incentivize a pool, you must review and agree to{' '} . diff --git a/apps/evm/src/app/pool/layout.tsx b/apps/evm/src/app/pool/layout.tsx index 088c8cabf7..bd46e1474f 100644 --- a/apps/evm/src/app/pool/layout.tsx +++ b/apps/evm/src/app/pool/layout.tsx @@ -1,4 +1,4 @@ -import { HotJar } from '@sushiswap/ui/components/scripts' +import { HotJar } from '@sushiswap/ui' import { Header } from './header' import { Providers } from './providers' diff --git a/apps/evm/src/app/providers.tsx b/apps/evm/src/app/providers.tsx index 4b2febceb7..43be3be656 100644 --- a/apps/evm/src/app/providers.tsx +++ b/apps/evm/src/app/providers.tsx @@ -1,8 +1,10 @@ 'use client' -import { State } from '@sushiswap/wagmi' -import { WagmiStoreVersionCheck } from '@sushiswap/wagmi/components' +import 'sushi/bigint-serializer' +import { State } from 'wagmi' + +import { WagmiStoreVersionCheck } from 'src/lib/wagmi/components/wagmi-store-version-check' import { QueryClientProvider } from '../providers/query-client-provider' import { WagmiConfig } from '../providers/wagmi-provider' diff --git a/apps/evm/src/app/stake/header.tsx b/apps/evm/src/app/stake/header.tsx index 9fb8a588c7..d9062fdaeb 100644 --- a/apps/evm/src/app/stake/header.tsx +++ b/apps/evm/src/app/stake/header.tsx @@ -1,9 +1,9 @@ 'use client' -import { Navigation } from '@sushiswap/ui/components/navigation' -import { WagmiHeaderComponents } from '@sushiswap/wagmi/components' +import { Navigation } from '@sushiswap/ui' import React, { FC } from 'react' import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { WagmiHeaderComponents } from 'src/lib/wagmi/components/wagmi-header-components' export const Header: FC = () => { return ( diff --git a/apps/evm/src/app/stake/layout.tsx b/apps/evm/src/app/stake/layout.tsx index 12bf42709a..e49a382204 100644 --- a/apps/evm/src/app/stake/layout.tsx +++ b/apps/evm/src/app/stake/layout.tsx @@ -1,5 +1,5 @@ import { Container } from '@sushiswap/ui' -import { HotJar } from '@sushiswap/ui/components/scripts' +import { HotJar } from '@sushiswap/ui' import { BarHeader } from 'src/ui/stake' import { Header } from './header' import { Providers } from './providers' diff --git a/apps/evm/src/app/swap/header.tsx b/apps/evm/src/app/swap/header.tsx index 9fb8a588c7..d9062fdaeb 100644 --- a/apps/evm/src/app/swap/header.tsx +++ b/apps/evm/src/app/swap/header.tsx @@ -1,9 +1,9 @@ 'use client' -import { Navigation } from '@sushiswap/ui/components/navigation' -import { WagmiHeaderComponents } from '@sushiswap/wagmi/components' +import { Navigation } from '@sushiswap/ui' import React, { FC } from 'react' import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { WagmiHeaderComponents } from 'src/lib/wagmi/components/wagmi-header-components' export const Header: FC = () => { return ( diff --git a/apps/evm/src/app/swap/layout.tsx b/apps/evm/src/app/swap/layout.tsx index b112a92567..ecdc662922 100644 --- a/apps/evm/src/app/swap/layout.tsx +++ b/apps/evm/src/app/swap/layout.tsx @@ -1,4 +1,4 @@ -import { HotJar } from '@sushiswap/ui/components/scripts' +import { HotJar } from '@sushiswap/ui' import { Header } from './header' import { Providers } from './providers' diff --git a/apps/evm/src/app/swap/providers.tsx b/apps/evm/src/app/swap/providers.tsx index d7ed959931..32256585e8 100644 --- a/apps/evm/src/app/swap/providers.tsx +++ b/apps/evm/src/app/swap/providers.tsx @@ -1,7 +1,7 @@ 'use client' import { ThemeProvider } from '@sushiswap/ui' -import { CheckerProvider } from '@sushiswap/wagmi/systems/Checker/Provider' +import { CheckerProvider } from 'src/lib/wagmi/systems/Checker/Provider' export function Providers({ children }: { children: React.ReactNode }) { return ( diff --git a/apps/evm/src/app/tokenlist-request/api/submit/route.ts b/apps/evm/src/app/tokenlist-request/api/submit/route.ts index 35c667d4c6..8e3a1852e7 100644 --- a/apps/evm/src/app/tokenlist-request/api/submit/route.ts +++ b/apps/evm/src/app/tokenlist-request/api/submit/route.ts @@ -1,10 +1,9 @@ import { createAppAuth } from '@octokit/auth-app' -import { CHAIN_NAME } from '@sushiswap/graph-config' import { Ratelimit } from '@upstash/ratelimit' import stringify from 'fast-json-stable-stringify' import { NextRequest, NextResponse } from 'next/server' import { Octokit } from 'octokit' -import { ChainId, ChainKey } from 'sushi/chain' +import { ChainId, ChainKey, chainName } from 'sushi/chain' import { formatUSD } from 'sushi/format' import { rateLimit } from 'src/lib/rate-limit' @@ -214,7 +213,7 @@ export async function POST(request: NextRequest) { branch: branch, path: listPath, content: Buffer.from(JSON.stringify(newList, null, 2)).toString('base64'), - message: `Add ${displayName} on ${CHAIN_NAME[chainId].toLowerCase()}`, + message: `Add ${displayName} on ${chainName[chainId].toLowerCase()}`, sha: currentListData?.sha, }) @@ -227,7 +226,7 @@ export async function POST(request: NextRequest) { title: `Token: ${displayName}`, head: branch, base: 'master', - body: `Chain: ${CHAIN_NAME[chainId] ?? chainId} + body: `Chain: ${chainName[chainId] ?? chainId} Name: ${tokenName} Symbol: ${tokenSymbol} Decimals: ${tokenDecimals} @@ -250,7 +249,7 @@ export async function POST(request: NextRequest) { description: 'New pull request', color: 5814783, author: { - name: `${tokenName} - ${CHAIN_NAME[chainId]}`, + name: `${tokenName} - ${chainName[chainId]}`, url: listPr, icon_url: `https://raw.githubusercontent.com/${owner}/list/${branch}/${imagePath}`, }, @@ -278,7 +277,7 @@ export async function POST(request: NextRequest) { async function getCoinGecko(chainId: ChainId, address: string) { return await fetch( - `https://api.coingecko.com/api/v3/coins/${CHAIN_NAME[ + `https://api.coingecko.com/api/v3/coins/${chainName[ chainId ].toLowerCase()}/contract/${address}`, ) diff --git a/apps/evm/src/app/tokenlist-request/page.tsx b/apps/evm/src/app/tokenlist-request/page.tsx index ad64783cb9..5b0f7bb1a5 100644 --- a/apps/evm/src/app/tokenlist-request/page.tsx +++ b/apps/evm/src/app/tokenlist-request/page.tsx @@ -20,13 +20,13 @@ import { TextField, typographyVariants, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { useTokenWithCache } from '@sushiswap/wagmi' +import { Button } from '@sushiswap/ui' import React, { useCallback, useEffect } from 'react' import { DropzoneOptions, useDropzone } from 'react-dropzone' import { useForm } from 'react-hook-form' import { Chain, ChainId } from 'sushi/chain' +import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' import { SUPPORTED_CHAIN_IDS } from '../../config' import { ApplyForTokenListListType, diff --git a/apps/evm/src/app/trackers.tsx b/apps/evm/src/app/trackers.tsx index 4b3a87e785..a1300bf30b 100644 --- a/apps/evm/src/app/trackers.tsx +++ b/apps/evm/src/app/trackers.tsx @@ -1,6 +1,6 @@ 'use client' -import { GoogleAnalytics } from '@sushiswap/ui/components/scripts' +import { GoogleAnalytics } from '@sushiswap/ui' import { Analytics as VercelAnalytics } from '@vercel/analytics/react' export function Trackers() { diff --git a/apps/evm/src/config.ts b/apps/evm/src/config.ts index f8ed3ddd2b..777c7c431b 100644 --- a/apps/evm/src/config.ts +++ b/apps/evm/src/config.ts @@ -7,13 +7,14 @@ import { } from 'sushi/config' import { Currency } from 'sushi/currency' -export const SWAP_API_ENABLED_NETWORKS = EXTRACTOR_SUPPORTED_CHAIN_IDS +export const SWAP_API_SUPPORTED_CHAIN_IDS = EXTRACTOR_SUPPORTED_CHAIN_IDS -export type SwapApiEnabledChainId = (typeof SWAP_API_ENABLED_NETWORKS)[number] +export type SwapApiEnabledChainId = + (typeof SWAP_API_SUPPORTED_CHAIN_IDS)[number] export const isSwapApiEnabledChainId = ( chainId: number, ): chainId is SwapApiEnabledChainId => - SWAP_API_ENABLED_NETWORKS.includes(chainId as SwapApiEnabledChainId) + SWAP_API_SUPPORTED_CHAIN_IDS.includes(chainId as SwapApiEnabledChainId) export const DISABLED_CHAIN_IDS = [ ChainId.BOBA_AVAX, diff --git a/apps/evm/src/lib/analytics/use-furo-tokens.ts b/apps/evm/src/lib/analytics/use-furo-tokens.ts index 7c1e58fb18..e9ea04a106 100644 --- a/apps/evm/src/lib/analytics/use-furo-tokens.ts +++ b/apps/evm/src/lib/analytics/use-furo-tokens.ts @@ -1,12 +1,12 @@ 'use client' import { GetApiInputFromOutput, parseArgs } from '@sushiswap/client' -import { Furo_token } from '@sushiswap/graph-client' import { useAllPrices } from '@sushiswap/react-query' import { useMemo } from 'react' import { Amount, Token } from 'sushi/currency' import useSWR from 'swr' +import { FuroTokens } from '../../../../../packages/graph-client/dist/subgraphs/furo' import { furoTokensSchema } from '../schema' export type GetFuroTokenArgs = GetApiInputFromOutput< @@ -22,7 +22,7 @@ export const getFuroTokensUrl = (args: GetFuroTokenArgs) => `/analytics/api/furoTokens${parseArgs(args)}` export function useFuroTokens(args: GetFuroTokenArgs) { - const { data: furoTokens, isValidating } = useSWR( + const { data: furoTokens, isValidating } = useSWR( getFuroTokensUrl(args), (url) => fetch(url).then((data) => data.json()), ) @@ -37,7 +37,7 @@ export function useFuroTokens(args: GetFuroTokenArgs) { const token = new Token({ chainId: furoToken.chainId, decimals: furoToken.decimals, - address: furoToken.id, + address: furoToken.id.split(':')[1], symbol: furoToken.symbol, name: furoToken.name, }) diff --git a/apps/evm/src/lib/constants.ts b/apps/evm/src/lib/constants.ts index 67cbc059c0..48d39c7360 100644 --- a/apps/evm/src/lib/constants.ts +++ b/apps/evm/src/lib/constants.ts @@ -1,4 +1,5 @@ -import { GetPoolsArgs, Protocol } from '@sushiswap/client' +import type { GetPoolsArgs } from '@sushiswap/client' +import { Protocol } from '@sushiswap/database' import { SUPPORTED_CHAIN_IDS } from '../config' diff --git a/apps/evm/src/lib/functions.ts b/apps/evm/src/lib/functions.ts index 1d6230bb83..a70de43241 100644 --- a/apps/evm/src/lib/functions.ts +++ b/apps/evm/src/lib/functions.ts @@ -1,4 +1,4 @@ -import { Pool, Protocol } from '@sushiswap/client' +import type { Incentive } from 'sushi' import { ChainId } from 'sushi/chain' import { SushiSwapV3FeeAmount, TICK_SPACINGS } from 'sushi/config' import { @@ -11,47 +11,28 @@ import { WBTC, tryParseAmount, } from 'sushi/currency' +import { SushiSwapV2Pool } from 'sushi/pool/sushiswap-v2' import { Position, - SushiSwapV2Pool, TickMath, - TridentConstantPool, - TridentStablePool, encodeSqrtRatioX96, nearestUsableTick, priceToClosestTick, tickToPrice, -} from 'sushi/pool' +} from 'sushi/pool/sushiswap-v3' import { Bound } from './constants' import { useTicks } from './hooks' import { TickProcessed } from './pool/v3/use-concentrated-active-liquidity' -export const isTridentConstantPool = ( - pool: SushiSwapV2Pool | TridentConstantPool | TridentStablePool | null, -): pool is TridentConstantPool => { - return pool instanceof TridentConstantPool -} - -export const isTridentStablePool = ( - pool: SushiSwapV2Pool | TridentStablePool | null, -): pool is TridentStablePool => { - return pool instanceof TridentStablePool -} - export const isSushiSwapV2Pool = ( - pool: SushiSwapV2Pool | TridentConstantPool | TridentStablePool | null, + pool: SushiSwapV2Pool | null, ): pool is SushiSwapV2Pool => { return pool instanceof SushiSwapV2Pool } -export const isTridentPoolProtocol = (protocol: Protocol) => - ( - [Protocol.BENTOBOX_CLASSIC, Protocol.BENTOBOX_STABLE] as Protocol[] - ).includes(protocol) - export const incentiveRewardToToken = ( chainId: ChainId, - incentive: Pool['incentives'][0], + incentive: Incentive, ): Token => { return new Token({ chainId, diff --git a/apps/evm/src/lib/graph.ts b/apps/evm/src/lib/graph.ts index 8b93b0014d..5932c5fab3 100644 --- a/apps/evm/src/lib/graph.ts +++ b/apps/evm/src/lib/graph.ts @@ -1,223 +1,186 @@ -import { - Bundle, - Pagination, - QuerytokensByChainIdsArgs, - getBuiltGraphSDK, -} from '@sushiswap/graph-client' - import { SUPPORTED_CHAIN_IDS } from 'src/config' - -import { ChainId, chainShortName } from 'sushi/chain' - +import { + SUSHISWAP_V2_SUPPORTED_CHAIN_IDS, + SushiSwapV2ChainId, + isSushiSwapV2ChainId, + isSushiSwapV3ChainId, +} from 'sushi/config' +import { getChainIdAddressFromId } from 'sushi/format' +import { Address } from 'viem' +import { getSushiDayDatas } from '../../../../packages/graph-client/dist/composite/sushi-day-datas' +import { getSushiV2StakedUnstakedPositions } from '../../../../packages/graph-client/dist/composite/sushi-v2-staked-unstaked-positions' +import { fetchMultichain } from '../../../../packages/graph-client/dist/multichain' +import { getRebases as _getRebases } from '../../../../packages/graph-client/dist/subgraphs/bentobox' +import { getFuroTokens as _getFuroTokens } from '../../../../packages/graph-client/dist/subgraphs/furo' +import { + SushiV2Pools, + getSushiV2Pool, + getSushiV2Pools, +} from '../../../../packages/graph-client/dist/subgraphs/sushi-v2' +import { getSushiV3PoolsByTokenPair } from '../../../../packages/graph-client/dist/subgraphs/sushi-v3' import { bentoBoxTokensSchema, furoTokensSchema } from './schema' -const sdk = getBuiltGraphSDK() - -export async function getUser(args: { id?: string; chainIds?: ChainId[] }) { +export async function getUser(args: { + id?: Address + chainIds?: SushiSwapV2ChainId[] +}) { if (!args.id) return [] - const { crossChainUserPositions: user } = await sdk.CrossChainUserPositions({ - chainIds: args.chainIds || SUPPORTED_CHAIN_IDS, - id: args.id.toLowerCase(), + + const { data } = await getSushiV2StakedUnstakedPositions({ + chainIds: args.chainIds || [...SUSHISWAP_V2_SUPPORTED_CHAIN_IDS], + id: args.id.toLowerCase() as Address, }) - return user + + return data } -export const getGraphPool = async (id: string) => { - if (!id.includes(':')) throw Error('Invalid pair id') - // Migrating to new format, graph-client uses the deprecated one - const split = id.split(':') - const { pair } = await sdk.PairById({ - id: `${chainShortName[split[0]]}:${split[1]}`, - }) - return pair +export const getV2GraphPool = async (id: string) => { + const split = getChainIdAddressFromId(id) + + if (!isSushiSwapV2ChainId(split.chainId)) throw Error('Invalid chain id') + + const pool = await getSushiV2Pool( + { + chainId: split.chainId, + id: split.address, + }, + { + retries: 3, + }, + ) + + return pool } -export const getGraphPools = async (ids: string[]) => { +export const getV2GraphPools = async (ids: string[]) => { if (!ids.every((id) => id.includes(':'))) throw Error('Invalid pair ids') // Migrating to new format, graph-client uses the deprecated one - const addresses = ids.map((id) => id.split(':')[1]) + const addresses = ids.map((id) => id.split(':')[1]) as Address[] // PairsByIds would be better, not implemented though... // Need to hack around - const { pairs } = await sdk.PairsByChainIds({ - chainIds: Array.from(new Set(ids.map((id) => Number(id.split(':')[0])))), - where: { - id_in: addresses, + + const chainIds = Array.from( + new Set(ids.map((id) => Number(id.split(':')[0]))), + ) as SushiSwapV2ChainId[] + + const { data: pools } = await fetchMultichain({ + chainIds, + fetch: getSushiV2Pools, + variables: { + where: { + id_in: addresses, + }, }, }) return ( - pairs - .map((pair) => ({ ...pair, id: `${pair.chainId}:${pair.address}` })) + pools + .map((pool) => ({ ...pool, id: `${pool.chainId}:${pool.address}` })) // To prevent possible (although unlikely) collisions - .filter((pair) => ids.includes(pair.id)) + .filter((pool) => ids.includes(pool.id)) as SushiV2Pools ) } -export const getPoolsByTokenPair = async ( +export const getV3PoolsByTokenPair = async ( tokenId0: string, tokenId1: string, ) => { - const [chainId0, tokenAddress0] = tokenId0.split(':') - if (!chainId0 || !tokenAddress0) throw Error('Invalid token0 id') - - const [chainId1, tokenAddress1] = tokenId1.split(':') - if (!chainId1 || !tokenAddress1) throw Error('Invalid token1 id') + const { chainId: chainId0, address: address0 } = + getChainIdAddressFromId(tokenId0) + const { chainId: chainId1, address: address1 } = + getChainIdAddressFromId(tokenId1) if (chainId0 !== chainId1) throw Error('Tokens must be on the same chain') - const { pools } = await sdk.PoolsByTokenPair({ - tokenId0, - tokenId1, - }) - - return pools -} + if (!isSushiSwapV3ChainId(chainId0)) { + throw Error('Invalid chain id') + } -export const getBundles = async () => { - const { bundles } = await sdk.Bundles({ - chainIds: SUPPORTED_CHAIN_IDS, + const pools = await getSushiV3PoolsByTokenPair({ + chainId: chainId0, + token0: address0, + token1: address1, }) - return bundles.reduce< - Record> - >((acc, cur) => { - acc[cur.chainId] = cur - return acc - }, {}) -} - -export type GetTokensQuery = Omit< - QuerytokensByChainIdsArgs, - 'where' | 'pagination' -> & { - networks: string - where?: string - pagination: string -} - -export const getTokens = async (query?: GetTokensQuery) => { - try { - const pagination: Pagination = query?.pagination - ? JSON.parse(query?.pagination) - : { - pageIndex: 0, - pageSize: 20, - } - const first = - pagination?.pageIndex && pagination?.pageSize - ? pagination.pageIndex * pagination.pageSize - : 20 - const skip = 0 - const where = { ...(query?.where && { ...JSON.parse(query.where) }) } - const orderBy = query?.orderBy || 'liquidityUSD' - const orderDirection = query?.orderDirection || 'desc' - const chainIds = query?.networks - ? JSON.parse(query.networks) - : SUPPORTED_CHAIN_IDS - const { tokens } = await sdk.TokensByChainIds({ - first, - skip, - pagination, - where, - orderBy, - orderDirection, - chainIds, - }) - return tokens - } catch (error: any) { - console.error(error) - throw new Error(error) - } + return pools } -export const getBentoBoxTokens = async ( - query: (typeof bentoBoxTokensSchema)['_output'], +export const getFuroTokens = async ( + query: (typeof furoTokensSchema)['_output'], ) => { try { - const { rebases } = await sdk.RebasesByChainIds({ - where: { - token_: { - or: query.tokenSymbols?.map((symbol) => ({ - symbol_contains_nocase: symbol, - })), - }, - }, + const variables = + query?.tokenSymbols && query.tokenSymbols?.length > 0 + ? { + where: { + or: query.tokenSymbols.map((symbol) => ({ + symbol_contains_nocase: symbol, + })), + liquidityShares_gt: '0', + }, + } + : { + where: { + liquidityShares_gt: '0', + }, + } + const { data: tokens } = await fetchMultichain({ chainIds: query.chainIds, + fetch: _getFuroTokens, + variables, }) - return rebases + return tokens } catch (error) { throw new Error(error as string) } } -export const getFuroTokens = async ( - query: (typeof furoTokensSchema)['_output'], +export const getBentoBoxTokens = async ( + query: (typeof bentoBoxTokensSchema)['_output'], ) => { try { - const { tokens } = await sdk.furoTokensByChainIds({ - where: { - or: query.tokenSymbols?.map((symbol) => ({ - symbol_contains_nocase: symbol, - })), - }, - // orderBy, - // orderDirection, + const variables = + query?.tokenSymbols && query.tokenSymbols?.length > 0 + ? { + where: { + or: query.tokenSymbols.map((symbol) => ({ + symbol_contains_nocase: symbol, + })), + base_gt: '0', + }, + } + : { + where: { + base_gt: '0', + }, + } + const { data: rebases } = await fetchMultichain({ chainIds: query.chainIds, + fetch: _getRebases, + variables, }) - return tokens + return rebases } catch (error) { throw new Error(error as string) } } -export const getToken = async (id: string) => { - const { crossChainToken: token } = await sdk.CrossChainToken({ - id: id.includes(':') ? id.split(':')[1] : id, - chainId: id.split(':')[0], - now: Math.round(new Date().getTime() / 1000), - }) - - return token -} - -export type GetTokenCountQuery = Partial<{ - networks: string -}> - -export const getTokenCount = async (query?: GetTokenCountQuery) => { - const { factories } = await sdk.Factories({ - chainIds: SUPPORTED_CHAIN_IDS, - }) - - const chainIds = query?.networks - ? JSON.parse(query.networks) - : SUPPORTED_CHAIN_IDS - - return factories.reduce((sum, cur) => { - if (chainIds.includes(cur.chainId)) { - sum = sum + Number(cur.tokenCount) - } - - return sum - }, 0) -} - export const getCharts = async (query?: { networks: string }) => { const chainIds = query?.networks ? JSON.parse(query.networks) : SUPPORTED_CHAIN_IDS - const { factoryDaySnapshots } = await sdk.FactoryDaySnapshots({ - chainIds: chainIds, - first: 1000, + + const { data: daySnapshots } = await getSushiDayDatas({ + chainIds, }) const dateSnapshotMap = new Map() - for (const snapshot of factoryDaySnapshots) { + for (const snapshot of daySnapshots) { const value = dateSnapshotMap.get(snapshot.date) dateSnapshotMap.set( snapshot.date, diff --git a/apps/evm/src/lib/hooks/api/index.ts b/apps/evm/src/lib/hooks/api/index.ts index e515a8d356..2729093d2d 100644 --- a/apps/evm/src/lib/hooks/api/index.ts +++ b/apps/evm/src/lib/hooks/api/index.ts @@ -1,3 +1,3 @@ export * from './useGraphPool' export * from './usePoolGraphData' -export * from './useUserPositions' +export * from './useSushiV2UserPositions' diff --git a/apps/evm/src/lib/hooks/api/useGraphPool.ts b/apps/evm/src/lib/hooks/api/useGraphPool.ts index d153b2cdc7..cd1907cac1 100644 --- a/apps/evm/src/lib/hooks/api/useGraphPool.ts +++ b/apps/evm/src/lib/hooks/api/useGraphPool.ts @@ -1,55 +1,69 @@ 'use client' -import { Pool } from '@sushiswap/client' -import { Pair } from '@sushiswap/graph-client' +import 'sushi/bigint-serializer' + import { useMemo } from 'react' import { Amount } from 'sushi/currency' -import useSWR from 'swr' +import { SushiV2Pool } from '../../../../../../packages/graph-client/dist/subgraphs/sushi-v2' -import { useTokensFromPool } from '../useTokensFromPool' +import { useQuery } from '@tanstack/react-query' +import type { PoolId } from 'sushi' +import { getTokensFromPool } from '../useTokensFromPool' export function getGraphPoolUrl(poolId: string) { return `/pools/api/graphPool/${poolId}` } -export const useGraphPool = (pool: Pool) => { +export const useGraphPool = (pool: PoolId) => { const { data: graphPool, isLoading, - isValidating, error, - } = useSWR(getGraphPoolUrl(pool.id), async (url) => - fetch(url).then((data) => data.json()), - ) + } = useQuery({ + queryKey: [getGraphPoolUrl(pool.id)], + queryFn: async () => { + const res = await fetch(getGraphPoolUrl(pool.id)) + + return JSON.parse(await res.text()) + }, + }) + + const { token0, token1, liquidityToken } = useMemo(() => { + if (!graphPool) + return { + token0: undefined, + token1: undefined, + liquidityToken: undefined, + } - const { token0, token1, liquidityToken } = useTokensFromPool(pool) + return getTokensFromPool(graphPool) + }, [graphPool]) return useMemo(() => { return { isLoading, - isValidating, error, data: { token0, token1, liquidityToken, - liquidityNative: graphPool ? Number(graphPool?.liquidityNative) : null, + // liquidityNative: graphPool ? Number(graphPool?.reserveETH) : null, liquidityUSD: graphPool ? Number(graphPool?.liquidityUSD) : null, - liquidity1dChange: graphPool - ? Number(graphPool?.liquidity1dChange ?? 0) - : null, - fees1d: graphPool ? Number(graphPool?.fees1d ?? 0) : null, - fees1dChange: graphPool ? Number(graphPool?.fees1dChange ?? 0) : null, - volume1d: graphPool ? Number(graphPool?.volume1d ?? 0) : null, - volume1dChange: graphPool - ? Number(graphPool?.volume1dChange ?? 0) - : null, - txCount1d: graphPool ? Number(graphPool?.txCount1d ?? 0) : null, - txCount1dChange: graphPool - ? Number(graphPool?.txCount1dChange ?? 0) - : null, - hourSnapshots: graphPool?.hourSnapshots ?? null, - daySnapshots: graphPool?.daySnapshots ?? null, + // liquidity1dChange: graphPool + // ? Number(graphPool?.liquidity1dChange ?? 0) + // : null, + // fees1d: graphPool ? Number(graphPool?.fees1d ?? 0) : null, + // fees1dChange: graphPool ? Number(graphPool?.fees1dChange ?? 0) : null, + // volume1d: graphPool ? Number(graphPool?.volume1d ?? 0) : null, + // volume1dChange: graphPool + // ? Number(graphPool?.volume1dChange ?? 0) + // : null, + // txCount1d: graphPool ? Number(graphPool?.txCount1d ?? 0) : null, + // txCount1dChange: graphPool + // ? Number(graphPool?.txCount1dChange ?? 0) + // : null, + // hourSnapshots: graphPool?.hourSnapshots ?? null, + // daySnapshots: graphPool?.daySnapshots ?? null, reserve0: token0 && graphPool ? Amount.fromRawAmount(token0, graphPool.reserve0) @@ -64,13 +78,5 @@ export const useGraphPool = (pool: Pool) => { : null, }, } - }, [ - error, - graphPool, - isLoading, - isValidating, - liquidityToken, - token0, - token1, - ]) + }, [error, graphPool, isLoading, liquidityToken, token0, token1]) } diff --git a/apps/evm/src/lib/hooks/api/useGraphPools.ts b/apps/evm/src/lib/hooks/api/useGraphPools.ts deleted file mode 100644 index 380e41cef7..0000000000 --- a/apps/evm/src/lib/hooks/api/useGraphPools.ts +++ /dev/null @@ -1,150 +0,0 @@ -'use client' - -import { Pool, Pools, Protocol, parseArgs } from '@sushiswap/client' -import { useMemo } from 'react' -import useSWR from 'swr' - -import { usePools } from '@sushiswap/client/hooks' -import { getGraphPools } from '../../graph' - -function transformGraphPool( - graphPool: Awaited>[0], -): Pool { - let protocol: Protocol = Protocol.SUSHISWAP_V2 - // if (graphPool.source === 'LEGACY') protocol = Protocol.SUSHISWAP_V2 - if (graphPool.source === 'TRIDENT') { - if (graphPool.type === 'CONSTANT_PRODUCT_POOL') - protocol = Protocol.BENTOBOX_CLASSIC - if (graphPool.type === 'STABLE_POOL') protocol = Protocol.BENTOBOX_STABLE - } - - return { - id: graphPool.id, - address: graphPool.address, - name: graphPool.name, - chainId: graphPool.chainId, - protocol: protocol, - swapFee: Number(graphPool.swapFee) / 10000, - twapEnabled: false, - totalSupply: String(graphPool.liquidity), - liquidityUSD: String(graphPool.liquidityUSD), - volumeUSD: String(graphPool.volumeUSD), - feeApr1h: 0, - feeApr1d: 0, - feeApr1w: 0, - feeApr1m: 0, - totalApr1h: 0, - totalApr1d: 0, - totalApr1w: 0, - totalApr1m: 0, - incentiveApr: 0, - isIncentivized: false, - wasIncentivized: false, - fees1h: '0', - fees1d: '0', - fees1w: '0', - fees1m: '0', - feesChange1h: 0, - feesChange1d: 0, - feesChange1w: 0, - feesChange1m: 0, - volume1h: '0', - volume1d: '0', - volume1w: '0', - volume1m: '0', - volumeChange1h: 0, - volumeChange1d: 0, - volumeChange1w: 0, - volumeChange1m: 0, - liquidityUSDChange1h: 0, - liquidityUSDChange1d: 0, - liquidityUSDChange1w: 0, - liquidityUSDChange1m: 0, - isBlacklisted: false, - token0: { - id: `${graphPool.chainId}:${graphPool.token0.id}`, - address: graphPool.token0.id, - name: graphPool.token0.name, - symbol: graphPool.token0.symbol, - decimals: graphPool.token0.decimals, - }, - token1: { - id: `${graphPool.chainId}:${graphPool.token1.id}`, - address: graphPool.token1.id, - name: graphPool.token1.name, - symbol: graphPool.token1.symbol, - decimals: graphPool.token1.decimals, - }, - incentives: [], - hasEnabledSteerVault: false, - hadEnabledSteerVault: false, - steerVaults: [], - } satisfies Pool -} - -export function getGraphPoolsUrl(poolIds: string[]) { - return `/pools/api/graphPools${parseArgs({ ids: poolIds })}` -} - -// Returns the Pools type, to make everyone's life easier -// Updates possibly stale values with subgraph values -export const useGraphPools = (poolIds: string[]): Pools => { - const { - data: graphPools, - isLoading: isGraphPoolsLoading, - error: graphPoolsError, - } = useSWR>>( - poolIds.length > 0 ? getGraphPoolsUrl(poolIds) : null, - async () => getGraphPools(poolIds), - ) - - const { - data: pools, - isLoading: isPoolsLoading, - error: poolsError, - } = usePools({ args: { ids: poolIds } }) - - return useMemo(() => { - if ( - (isGraphPoolsLoading && !graphPoolsError) || - (isPoolsLoading && !poolsError) - ) { - return [] - } - - if (pools || graphPools) { - return poolIds - .map((poolId) => { - const pool = pools?.find((pool) => pool.id === poolId) - const graphPool = graphPools?.find( - (graphPool) => graphPool.id === poolId, - ) - - if (!pool && !graphPool) return undefined - - if (!graphPool) return pool - if (!pool) return transformGraphPool(graphPool) - - return { - ...pool, - totalSupply: String(graphPool.liquidity), - liquidityUSD: String(graphPool.liquidityUSD), - volumeUSD: String(graphPool.volumeUSD), - feeApr: Number(graphPool.apr), - totalApr: Number(graphPool.apr) + pool.incentiveApr, - } - }) - .filter((pool) => pool !== undefined) as Pools - } - - return [] - }, [ - graphPools, - isGraphPoolsLoading, - isPoolsLoading, - poolIds, - pools, - graphPoolsError, - poolsError, - ]) -} diff --git a/apps/evm/src/lib/hooks/api/usePoolGraphData.ts b/apps/evm/src/lib/hooks/api/usePoolGraphData.ts index da65679b68..c967c0b0c8 100644 --- a/apps/evm/src/lib/hooks/api/usePoolGraphData.ts +++ b/apps/evm/src/lib/hooks/api/usePoolGraphData.ts @@ -1,18 +1,16 @@ 'use client' -import { getBuiltGraphSDK } from '@sushiswap/graph-client' import { useQuery } from '@tanstack/react-query' -import { ChainId, chainShortName } from 'sushi/chain' +import { SushiSwapV2ChainId } from 'sushi/config' import { Amount, Token } from 'sushi/currency' +import { getSushiHistoricPool } from '../../../../../../packages/graph-client/dist/composite/sushi-historic-pool' interface UsePoolGraphDataParams { poolAddress: string - chainId: ChainId + chainId: SushiSwapV2ChainId enabled?: boolean } -const sdk = getBuiltGraphSDK() - export const usePoolGraphData = ({ poolAddress, chainId, @@ -21,14 +19,15 @@ export const usePoolGraphData = ({ return useQuery({ queryKey: ['usePoolGraphData', { poolAddress, chainId }], queryFn: async () => { - const { pair } = await sdk.PairById({ - id: `${chainShortName[chainId]}:${poolAddress}`, + const pair = await getSushiHistoricPool({ + chainId, + id: poolAddress, }) if (pair) { const token0 = new Token({ chainId: pair.chainId, - address: pair.token0.id, + address: pair.token0.address, decimals: pair.token0.decimals, symbol: pair.token0.symbol, name: pair.token0.name, @@ -36,7 +35,7 @@ export const usePoolGraphData = ({ const token1 = new Token({ chainId: pair.chainId, - address: pair.token1.id, + address: pair.token1.address, decimals: pair.token1.decimals, symbol: pair.token1.symbol, name: pair.token1.name, @@ -48,17 +47,16 @@ export const usePoolGraphData = ({ swapFee: Number(pair.swapFee), reserve0: Amount.fromRawAmount(token0, pair.reserve0), reserve1: Amount.fromRawAmount(token1, pair.reserve1), - liquidityNative: Number(pair.liquidityNative), liquidityUSD: Number(pair.liquidityUSD), - liquidity1dChange: Number(pair.liquidity1dChange ?? 0), - fees1d: Number(pair.fees1d ?? 0), - fees1dChange: Number(pair.fees1dChange ?? 0), - volume1d: Number(pair.volume1d ?? 0), - volume1dChange: Number(pair.volume1dChange ?? 0), - txCount1d: Number(pair.txCount1d ?? 0), - txCount1dChange: Number(pair.txCount1dChange ?? 0), - hourSnapshots: pair.hourSnapshots, - daySnapshots: pair.daySnapshots, + liquidity1dChange: Number(pair.liquidityUSD1dChange), + fees1d: Number(pair.feesUSD1d), + fees1dChange: Number(pair.feesUSD1dChange), + volume1d: Number(pair.volumeUSD1d), + volume1dChange: Number(pair.volumeUSD1dChange), + txCount1d: Number(pair.txCount1d), + txCount1dChange: Number(pair.txCount1dChange), + hourSnapshots: pair.poolHourData, + daySnapshots: pair.poolDayData, } } @@ -66,7 +64,7 @@ export const usePoolGraphData = ({ }, keepPreviousData: true, staleTime: 0, - cacheTime: 86400000, // 24hs + cacheTime: 3600, // 1hr enabled: Boolean(poolAddress && chainId && enabled), }) } diff --git a/apps/evm/src/lib/hooks/api/useSushiV2UserPositions.ts b/apps/evm/src/lib/hooks/api/useSushiV2UserPositions.ts new file mode 100644 index 0000000000..a7b810cfb4 --- /dev/null +++ b/apps/evm/src/lib/hooks/api/useSushiV2UserPositions.ts @@ -0,0 +1,32 @@ +'use client' + +import { parseArgs } from '@sushiswap/client' +import { useQuery } from '@tanstack/react-query' +import { UserWithPool } from 'src/app/pool/api/user-with-pools/route' +import { ChainId } from 'sushi/chain' +import type { GetSushiV2StakedUnstakedPositions } from '../../../../../../packages/graph-client/dist/composite/sushi-v2-staked-unstaked-positions' + +export interface GetUserArgs { + id?: string + chainIds?: ChainId[] +} + +export function getUserPositionsWithPoolsUrl( + args: GetSushiV2StakedUnstakedPositions, +) { + return `/pool/api/user-with-pools/${parseArgs(args)}` +} + +export function useSushiV2UserPositions( + args: GetSushiV2StakedUnstakedPositions, + shouldFetch = true, +) { + return useQuery({ + queryKey: [getUserPositionsWithPoolsUrl(args)], + queryFn: () => + fetch(getUserPositionsWithPoolsUrl(args)) + .then((data) => data.text()) + .then(JSON.parse), + enabled: Boolean(shouldFetch && args.id), + }) +} diff --git a/apps/evm/src/lib/hooks/api/useUserPositions.ts b/apps/evm/src/lib/hooks/api/useUserPositions.ts deleted file mode 100644 index 6d8938dcd6..0000000000 --- a/apps/evm/src/lib/hooks/api/useUserPositions.ts +++ /dev/null @@ -1,61 +0,0 @@ -'use client' - -import { Pools, parseArgs } from '@sushiswap/client' -import { UserPosition } from '@sushiswap/graph-client' -import { useMemo } from 'react' -import { ChainId } from 'sushi/chain' -import useSWR from 'swr' - -import { PositionWithPool } from '../../../types' -import { useGraphPools } from './useGraphPools' - -export interface GetUserArgs { - id?: string - chainIds?: ChainId[] -} - -export function getUserPositionsUrl(args: GetUserArgs) { - return `/pool/api/user/${parseArgs(args)}` -} - -const transformPositions = (positions?: UserPosition[], pools?: Pools) => - positions && pools - ? positions - .map((position) => { - const pool = pools.find((pool) => pool.id === position.pool) - - return { ...position, pool } - }) - .filter((position): position is PositionWithPool => !!position.pool) - : undefined - -export function useUserPositions(args: GetUserArgs, shouldFetch = true) { - const { data: positions } = useSWR( - shouldFetch && args.id ? getUserPositionsUrl(args) : null, - async (url) => fetch(url).then((data) => data.json()), - ) - - const _positions = useMemo( - () => positions?.map((position) => position.pool) || [], - [positions], - ) - const pools = useGraphPools(_positions) - - const isValidating = - shouldFetch && - (!positions || !pools || (positions.length > 0 && pools.length === 0)) - - return useMemo( - () => ({ - data: !isValidating - ? transformPositions(positions, pools)?.filter((position) => - Array.isArray(args.chainIds) - ? args.chainIds?.includes(position.chainId as ChainId) - : true, - ) - : undefined, - isValidating, - }), - [args.chainIds, isValidating, pools, positions], - ) -} diff --git a/apps/evm/src/lib/hooks/usePoolsByTokenPair.ts b/apps/evm/src/lib/hooks/usePoolsByTokenPair.ts index 0716cb953f..6bfcc9cf7d 100644 --- a/apps/evm/src/lib/hooks/usePoolsByTokenPair.ts +++ b/apps/evm/src/lib/hooks/usePoolsByTokenPair.ts @@ -1,7 +1,7 @@ 'use client' import { useQuery } from '@tanstack/react-query' -import { getPoolsByTokenPair } from 'src/lib/graph' +import { getV3PoolsByTokenPair } from 'src/lib/graph' function usePoolsByTokenPair(tokenId0?: string, tokenId1?: string) { return useQuery({ @@ -9,7 +9,10 @@ function usePoolsByTokenPair(tokenId0?: string, tokenId1?: string) { queryFn: () => { if (!tokenId0 || !tokenId1) return [] - return getPoolsByTokenPair(tokenId0.toLowerCase(), tokenId1.toLowerCase()) + return getV3PoolsByTokenPair( + tokenId0.toLowerCase(), + tokenId1.toLowerCase(), + ) }, enabled: !!tokenId0 && !!tokenId1, }) diff --git a/apps/evm/src/lib/hooks/useSimulateTrade.ts b/apps/evm/src/lib/hooks/useSimulateTrade.ts index db1b815d3e..9dc9f5906f 100644 --- a/apps/evm/src/lib/hooks/useSimulateTrade.ts +++ b/apps/evm/src/lib/hooks/useSimulateTrade.ts @@ -1,8 +1,5 @@ import { UseTradeReturn } from '@sushiswap/react-query' -import { - SimulateContractErrorType, - useSimulateContract, -} from '@sushiswap/wagmi' +import { SimulateContractErrorType } from '@wagmi/core' import { useMemo } from 'react' import { useDerivedStateSimpleSwap } from 'src/ui/swap/simple/derivedstate-simple-swap-provider' import { routeProcessor4Abi } from 'sushi/abi' @@ -11,6 +8,7 @@ import { isRouteProcessor4ChainId, } from 'sushi/config' import { BaseError } from 'viem' +import { useSimulateContract } from 'wagmi' import { getTokenTax } from '../swap/getTokenTax' const isMinOutError = (error: SimulateContractErrorType | null) => diff --git a/apps/evm/src/lib/hooks/useTokenFromToken.ts b/apps/evm/src/lib/hooks/useTokenFromToken.ts deleted file mode 100644 index 9cfec5cff2..0000000000 --- a/apps/evm/src/lib/hooks/useTokenFromToken.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Token as GraphToken } from '@sushiswap/graph-client' -import { useMemo } from 'react' -import { Native, Token } from 'sushi/currency' - -export const useTokenFromToken = (token: GraphToken) => { - return useMemo(() => { - const id = token.id.includes(':') ? token.id.split(':')[1] : token.id - if (id === Native.onChain(token.chainId).wrapped.address) { - return Native.onChain(token.chainId) - } - - return new Token({ - address: id, - chainId: token.chainId, - name: token.name, - symbol: token.symbol, - decimals: Number(token.decimals), - }) - }, [token.chainId, token.decimals, token.id, token.name, token.symbol]) -} diff --git a/apps/evm/src/lib/hooks/useTokensFromPool.ts b/apps/evm/src/lib/hooks/useTokensFromPool.ts index f976ab2e47..711b16e986 100644 --- a/apps/evm/src/lib/hooks/useTokensFromPool.ts +++ b/apps/evm/src/lib/hooks/useTokensFromPool.ts @@ -1,49 +1,51 @@ 'use client' -import { Pool } from '@sushiswap/client' import { useMemo } from 'react' +import type { PoolBase } from 'sushi' import { Native, Token } from 'sushi/currency' -export const useTokensFromPool = (pool: Pool) => { - return useMemo(() => { - const _token0 = new Token({ - address: pool.token0.address, - name: pool.token0.name, - decimals: Number(pool.token0.decimals), - symbol: pool.token0.symbol, - chainId: pool.chainId, - }) +export const getTokensFromPool = (pool: PoolBase) => { + const _token0 = new Token({ + address: pool.token0.address, + name: pool.token0.name, + decimals: Number(pool.token0.decimals), + symbol: pool.token0.symbol, + chainId: pool.chainId, + }) + + const _token1 = new Token({ + address: pool.token1.address, + name: pool.token1.name, + decimals: Number(pool.token1.decimals), + symbol: pool.token1.symbol, + chainId: pool.chainId, + }) - const _token1 = new Token({ - address: pool.token1.address, - name: pool.token1.name, - decimals: Number(pool.token1.decimals), - symbol: pool.token1.symbol, + const [token0, token1, liquidityToken] = [ + _token0.wrapped.address === Native.onChain(_token0.chainId).wrapped.address + ? Native.onChain(_token0.chainId) + : _token0, + _token1.wrapped.address === Native.onChain(_token1.chainId).wrapped.address + ? Native.onChain(_token1.chainId) + : _token1, + new Token({ + address: pool.id.includes(':') ? pool.id.split(':')[1] : pool.id, + name: 'SLP Token', + decimals: 18, + symbol: 'SLP', chainId: pool.chainId, - }) + }), + ] - const [token0, token1, liquidityToken] = [ - _token0.wrapped.address === - Native.onChain(_token0.chainId).wrapped.address - ? Native.onChain(_token0.chainId) - : _token0, - _token1.wrapped.address === - Native.onChain(_token1.chainId).wrapped.address - ? Native.onChain(_token1.chainId) - : _token1, - new Token({ - address: pool.id.includes(':') ? pool.id.split(':')[1] : pool.id, - name: 'SLP Token', - decimals: 18, - symbol: 'SLP', - chainId: pool.chainId, - }), - ] + return { + token0, + token1, + liquidityToken, + } +} - return { - token0, - token1, - liquidityToken, - } +export const useTokensFromPool = (pool: PoolBase) => { + return useMemo(() => { + return getTokensFromPool(pool) }, [pool]) } diff --git a/apps/evm/src/lib/pool/v3/use-concentrated-active-liquidity.ts b/apps/evm/src/lib/pool/v3/use-concentrated-active-liquidity.ts index 8104ae78e7..44c9ed30c7 100644 --- a/apps/evm/src/lib/pool/v3/use-concentrated-active-liquidity.ts +++ b/apps/evm/src/lib/pool/v3/use-concentrated-active-liquidity.ts @@ -1,6 +1,5 @@ 'use client' -import { useConcentratedLiquidityPool } from '@sushiswap/wagmi' import { useMemo } from 'react' import { SushiSwapV3ChainId, @@ -8,8 +7,9 @@ import { TICK_SPACINGS, } from 'sushi/config' import { Type } from 'sushi/currency' -import { tickToPrice } from 'sushi/pool' +import { tickToPrice } from 'sushi/pool/sushiswap-v3' +import { useConcentratedLiquidityPool } from 'src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool' import computeSurroundingTicks from '../../functions' import { useTicks } from './use-ticks' diff --git a/apps/evm/src/lib/pool/v3/use-is-tick-at-limit.ts b/apps/evm/src/lib/pool/v3/use-is-tick-at-limit.ts index 0e436745d3..bf34f7225b 100644 --- a/apps/evm/src/lib/pool/v3/use-is-tick-at-limit.ts +++ b/apps/evm/src/lib/pool/v3/use-is-tick-at-limit.ts @@ -2,7 +2,7 @@ import { useMemo } from 'react' import { SushiSwapV3FeeAmount, TICK_SPACINGS } from 'sushi/config' -import { TickMath, nearestUsableTick } from 'sushi/pool' +import { TickMath, nearestUsableTick } from 'sushi/pool/sushiswap-v3' import { Bound } from '../../constants' export function useIsTickAtLimit( diff --git a/apps/evm/src/lib/pool/v3/use-ticks.ts b/apps/evm/src/lib/pool/v3/use-ticks.ts index 13902a0b14..3b3388f918 100644 --- a/apps/evm/src/lib/pool/v3/use-ticks.ts +++ b/apps/evm/src/lib/pool/v3/use-ticks.ts @@ -1,20 +1,21 @@ 'use client' -import { useReadContracts } from '@sushiswap/wagmi' -import { - getV3FactoryContractConfig, - getV3TickLensContractConfig, - useConcentratedLiquidityPool, -} from '@sushiswap/wagmi' import { useMemo } from 'react' +import { useConcentratedLiquidityPool } from 'src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool' import { + SUSHISWAP_V3_FACTORY_ADDRESS, + SUSHISWAP_V3_TICK_LENS, SushiSwapV3ChainId, SushiSwapV3FeeAmount, TICK_SPACINGS, } from 'sushi/config' import { Type } from 'sushi/currency' -import { computeSushiSwapV3PoolAddress, nearestUsableTick } from 'sushi/pool' +import { + computeSushiSwapV3PoolAddress, + nearestUsableTick, +} from 'sushi/pool/sushiswap-v3' import { Address } from 'viem' +import { useReadContracts } from 'wagmi' import { Writeable } from 'zod' interface useTicksProps { @@ -30,6 +31,42 @@ const bitmapIndex = (tick: number, tickSpacing: number) => { return Math.floor(tick / tickSpacing / 256) } +const getPopulatedTicksInWordAbiShard = [ + { + inputs: [ + { internalType: 'address', name: 'pool', type: 'address' }, + { + internalType: 'int16', + name: 'tickBitmapIndex', + type: 'int16', + }, + ], + name: 'getPopulatedTicksInWord', + outputs: [ + { + components: [ + { internalType: 'int24', name: 'tick', type: 'int24' }, + { + internalType: 'int128', + name: 'liquidityNet', + type: 'int128', + }, + { + internalType: 'uint128', + name: 'liquidityGross', + type: 'uint128', + }, + ], + internalType: 'struct ITickLens.PopulatedTick[]', + name: 'populatedTicks', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const + export function useTicks({ token0, token1, @@ -57,7 +94,7 @@ export function useTicks({ () => token0 && token1 && feeAmount && chainId ? computeSushiSwapV3PoolAddress({ - factoryAddress: getV3FactoryContractConfig(chainId).address, + factoryAddress: SUSHISWAP_V3_FACTORY_ADDRESS[chainId], tokenA: token0.wrapped, tokenB: token1.wrapped, fee: feeAmount, @@ -96,7 +133,8 @@ export function useTicks({ ) { for (let i = minIndex; i <= maxIndex; i++) { reads.push({ - ...getV3TickLensContractConfig(chainId), + address: SUSHISWAP_V3_TICK_LENS[chainId], + abi: getPopulatedTicksInWordAbiShard, chainId, functionName: 'getPopulatedTicksInWord', args: [poolAddress as Address, i], diff --git a/apps/evm/src/lib/schema.ts b/apps/evm/src/lib/schema.ts index d10bf1d8cc..925727945f 100644 --- a/apps/evm/src/lib/schema.ts +++ b/apps/evm/src/lib/schema.ts @@ -1,7 +1,9 @@ import { - BENTOBOX_ENABLED_NETWORKS, - FURO_ENABLED_NETWORKS, -} from '@sushiswap/graph-config' + FURO_SUPPORTED_CHAIN_IDS, + isFuroChainId, +} from 'node_modules/sushi/dist/config/furo' +import { ChainId } from 'sushi/chain' +import { BENTOBOX_SUPPORTED_CHAIN_IDS, isBentoBoxChainId } from 'sushi/config' import { z } from 'zod' export const bentoBoxTokensSchema = z.object({ @@ -12,8 +14,9 @@ export const bentoBoxTokensSchema = z.object({ chainIds: z .string() .optional() - .default(BENTOBOX_ENABLED_NETWORKS.join(',')) - .transform((val) => val.split(',').map((v) => parseInt(v))), + .default(BENTOBOX_SUPPORTED_CHAIN_IDS.join(',')) + .transform((val) => val.split(',').map((v) => parseInt(v) as ChainId)) + .transform((chainIds) => chainIds.filter(isBentoBoxChainId)), }) export const furoTokensSchema = z.object({ @@ -28,6 +31,7 @@ export const furoTokensSchema = z.object({ chainIds: z .string() .optional() - .default(FURO_ENABLED_NETWORKS.join(',')) - .transform((val) => val.split(',').map((v) => parseInt(v))), + .default(FURO_SUPPORTED_CHAIN_IDS.join(',')) + .transform((val) => val.split(',').map((v) => parseInt(v) as ChainId)) + .transform((chainIds) => chainIds.filter(isFuroChainId)), }) diff --git a/apps/evm/src/lib/stake/use-bar-chart-data.ts b/apps/evm/src/lib/stake/use-bar-chart-data.ts index 58a3a543dc..1c7f8e901a 100644 --- a/apps/evm/src/lib/stake/use-bar-chart-data.ts +++ b/apps/evm/src/lib/stake/use-bar-chart-data.ts @@ -1,14 +1,12 @@ 'use client' -import { getBuiltGraphSDK } from '@sushiswap/graph-client' import { useQuery } from '@tanstack/react-query' - -const sdk = getBuiltGraphSDK() +import { getSushiBarHistory } from '../../../../../packages/graph-client/dist/subgraphs/sushi-bar' export const useBarChartData = (enabled = true) => { return useQuery({ queryKey: ['useBarChartData'], - queryFn: async () => await sdk.BarHistory(), + queryFn: async () => await getSushiBarHistory({}), keepPreviousData: true, staleTime: 0, cacheTime: 86400000, // 24hs diff --git a/apps/evm/src/lib/stake/use-bar-data.ts b/apps/evm/src/lib/stake/use-bar-data.ts index dbf2c7a67d..227e176871 100644 --- a/apps/evm/src/lib/stake/use-bar-data.ts +++ b/apps/evm/src/lib/stake/use-bar-data.ts @@ -1,14 +1,12 @@ 'use client' -import { getBuiltGraphSDK } from '@sushiswap/graph-client' import { useQuery } from '@tanstack/react-query' - -const sdk = getBuiltGraphSDK() +import { getSushiBar } from '../../../../../packages/graph-client/dist/subgraphs/sushi-bar' export const useBarData = (enabled = true) => { return useQuery({ queryKey: ['useBarData'], - queryFn: async () => await sdk.Bar(), + queryFn: async () => await getSushiBar({}), keepPreviousData: true, staleTime: 30000, cacheTime: 86400000, // 24hs diff --git a/apps/evm/src/lib/swap/getTokenTax.ts b/apps/evm/src/lib/swap/getTokenTax.ts index 3bfec20dd6..795c2db1e0 100644 --- a/apps/evm/src/lib/swap/getTokenTax.ts +++ b/apps/evm/src/lib/swap/getTokenTax.ts @@ -1,4 +1,4 @@ -import { SimulateContractErrorType } from '@sushiswap/wagmi' +import { SimulateContractErrorType } from '@wagmi/core' import { Fraction, Percent } from 'sushi' import { Amount, Type } from 'sushi/currency' import { decodeErrorResult } from 'viem' diff --git a/apps/evm/src/lib/swap/useCrossChainTrade/SushiXSwap2/adapters/SquidAdapter.ts b/apps/evm/src/lib/swap/useCrossChainTrade/SushiXSwap2/adapters/SquidAdapter.ts index 0f9c6e7d15..b8135d6b30 100644 --- a/apps/evm/src/lib/swap/useCrossChainTrade/SushiXSwap2/adapters/SquidAdapter.ts +++ b/apps/evm/src/lib/swap/useCrossChainTrade/SushiXSwap2/adapters/SquidAdapter.ts @@ -1,8 +1,8 @@ import { ChainType, DexName, - Hook, - RouteRequest, + type Hook, + type RouteRequest, SquidCallType, } from '@0xsquid/squid-types' import { UseTradeReturn } from '@sushiswap/react-query' diff --git a/apps/evm/src/lib/swap/useCrossChainTrade/useSquidCrossChainTrade.ts b/apps/evm/src/lib/swap/useCrossChainTrade/useSquidCrossChainTrade.ts index 3ca594c107..b901001a22 100644 --- a/apps/evm/src/lib/swap/useCrossChainTrade/useSquidCrossChainTrade.ts +++ b/apps/evm/src/lib/swap/useCrossChainTrade/useSquidCrossChainTrade.ts @@ -1,5 +1,4 @@ import { UseTradeReturn, useTrade as useApiTrade } from '@sushiswap/react-query' -import { useAccount, useGasPrice } from '@sushiswap/wagmi' import { useQuery } from '@tanstack/react-query' import { log } from 'next-axiom' import { useMemo } from 'react' @@ -15,6 +14,7 @@ import { Percent, ZERO_PERCENT } from 'sushi/math' import { RouterLiquiditySource } from 'sushi/router' import { RToken } from 'sushi/tines' import { Hex, encodeFunctionData, stringify } from 'viem' +import { useAccount, useGasPrice } from 'wagmi' import { TransactionType, decodeSquidRouterCallData, diff --git a/apps/evm/src/lib/swap/useCrossChainTrade/useSquidRoute.ts b/apps/evm/src/lib/swap/useCrossChainTrade/useSquidRoute.ts index be0115a32f..34a59fcaa3 100644 --- a/apps/evm/src/lib/swap/useCrossChainTrade/useSquidRoute.ts +++ b/apps/evm/src/lib/swap/useCrossChainTrade/useSquidRoute.ts @@ -1,4 +1,4 @@ -import { RouteRequest } from '@0xsquid/squid-types' +import type { RouteRequest } from '@0xsquid/squid-types' import { useQuery } from '@tanstack/react-query' import { useSquid } from './useSquid' diff --git a/apps/evm/src/lib/swap/useCrossChainTrade/useStargateBridgeFees.ts b/apps/evm/src/lib/swap/useCrossChainTrade/useStargateBridgeFees.ts index 06482159ad..8811f0531f 100644 --- a/apps/evm/src/lib/swap/useCrossChainTrade/useStargateBridgeFees.ts +++ b/apps/evm/src/lib/swap/useCrossChainTrade/useStargateBridgeFees.ts @@ -1,8 +1,3 @@ -import { - useBlockNumber, - useReadContract, - useReadContracts, -} from '@sushiswap/wagmi' import { useQueryClient } from '@tanstack/react-query' import { useEffect, useMemo } from 'react' import { stargateFeeLibraryV03Abi, stargatePoolAbi } from 'sushi/abi' @@ -17,6 +12,8 @@ import { } from 'sushi/config' import { Amount, Currency } from 'sushi/currency' import { Address, zeroAddress } from 'viem' +import { useBlockNumber, useReadContract } from 'wagmi' +import { useReadContracts } from 'wagmi' interface UseStargateBridgeFees { amount?: Amount diff --git a/apps/evm/src/lib/swap/useCrossChainTrade/useStargateCrossChainTrade.ts b/apps/evm/src/lib/swap/useCrossChainTrade/useStargateCrossChainTrade.ts index 8aeccf9512..78bc1fd556 100644 --- a/apps/evm/src/lib/swap/useCrossChainTrade/useStargateCrossChainTrade.ts +++ b/apps/evm/src/lib/swap/useCrossChainTrade/useStargateCrossChainTrade.ts @@ -1,5 +1,4 @@ import { useTrade as useApiTrade } from '@sushiswap/react-query' -import { useGasPrice, usePublicClient } from '@sushiswap/wagmi' import { useQuery } from '@tanstack/react-query' import { log } from 'next-axiom' import { useMemo } from 'react' @@ -19,6 +18,7 @@ import { parseUnits, stringify, } from 'viem' +import { useGasPrice, usePublicClient } from 'wagmi' import { STARGATE_DEFAULT_SLIPPAGE, TransactionType, diff --git a/packages/wagmi/src/actions/account/fetchBalances.ts b/apps/evm/src/lib/wagmi/actions/account/fetchBalances.ts similarity index 100% rename from packages/wagmi/src/actions/account/fetchBalances.ts rename to apps/evm/src/lib/wagmi/actions/account/fetchBalances.ts diff --git a/packages/wagmi/src/components/account/AddressToEnsResolver.tsx b/apps/evm/src/lib/wagmi/components/account/AddressToEnsResolver.tsx similarity index 100% rename from packages/wagmi/src/components/account/AddressToEnsResolver.tsx rename to apps/evm/src/lib/wagmi/components/account/AddressToEnsResolver.tsx diff --git a/packages/wagmi/src/components/account/EnsToAddressResolver.tsx b/apps/evm/src/lib/wagmi/components/account/EnsToAddressResolver.tsx similarity index 100% rename from packages/wagmi/src/components/account/EnsToAddressResolver.tsx rename to apps/evm/src/lib/wagmi/components/account/EnsToAddressResolver.tsx diff --git a/packages/wagmi/src/components/account/index.ts b/apps/evm/src/lib/wagmi/components/account/index.ts similarity index 100% rename from packages/wagmi/src/components/account/index.ts rename to apps/evm/src/lib/wagmi/components/account/index.ts diff --git a/packages/wagmi/src/components/connect-button.tsx b/apps/evm/src/lib/wagmi/components/connect-button.tsx similarity index 94% rename from packages/wagmi/src/components/connect-button.tsx rename to apps/evm/src/lib/wagmi/components/connect-button.tsx index 1ccbfd01e6..87cb381f15 100644 --- a/packages/wagmi/src/components/connect-button.tsx +++ b/apps/evm/src/lib/wagmi/components/connect-button.tsx @@ -1,12 +1,12 @@ import { ChevronDoubleDownIcon } from '@heroicons/react/24/outline' -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, -} from '@sushiswap/ui/components/dropdown-menu' +} from '@sushiswap/ui' import { CoinbaseWalletIcon, FrameIcon, @@ -17,11 +17,11 @@ import { TrustWalletIcon, WalletConnectIcon, XDEFIWalletIcon, -} from '@sushiswap/ui/components/icons' +} from '@sushiswap/ui' import React, { FC, useCallback, useMemo } from 'react' import Link from 'next/link' -import { useConnect } from '../hooks' +import { useConnect } from '../hooks/wallet/useConnect' const Icons: Record = { Injected: ChevronDoubleDownIcon, @@ -59,8 +59,6 @@ export const ConnectButton: FC = ({ const _connectors = useMemo(() => { const conns = [...connectors] - console.log('conns', conns) - const injected = conns.find((el) => el.id === 'injected') if (injected) { diff --git a/packages/wagmi/src/components/header-network-selector.tsx b/apps/evm/src/lib/wagmi/components/header-network-selector.tsx similarity index 85% rename from packages/wagmi/src/components/header-network-selector.tsx rename to apps/evm/src/lib/wagmi/components/header-network-selector.tsx index d4bc5d5881..08a51511b4 100644 --- a/packages/wagmi/src/components/header-network-selector.tsx +++ b/apps/evm/src/lib/wagmi/components/header-network-selector.tsx @@ -1,11 +1,8 @@ import { useIsMounted } from '@sushiswap/hooks' -import { Button } from '@sushiswap/ui/components/button' -import { NetworkIcon } from '@sushiswap/ui/components/icons' -import { - NetworkSelector, - NetworkSelectorOnSelectCallback, -} from '@sushiswap/ui/components/network-selector' -import { createErrorToast } from '@sushiswap/ui/components/toast' +import { Button } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' +import { NetworkSelector, NetworkSelectorOnSelectCallback } from '@sushiswap/ui' +import { createErrorToast } from '@sushiswap/ui' import React, { FC, Suspense, useCallback } from 'react' import { Chain, ChainId } from 'sushi/chain' import { ProviderRpcError, UserRejectedRequestError } from 'viem' diff --git a/packages/wagmi/src/components/network-check.tsx b/apps/evm/src/lib/wagmi/components/network-check.tsx similarity index 96% rename from packages/wagmi/src/components/network-check.tsx rename to apps/evm/src/lib/wagmi/components/network-check.tsx index 08fb237fdd..e34e4d8f4d 100644 --- a/packages/wagmi/src/components/network-check.tsx +++ b/apps/evm/src/lib/wagmi/components/network-check.tsx @@ -1,7 +1,7 @@ 'use client' import { useIsMounted } from '@sushiswap/hooks' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import { FC, useEffect, useState } from 'react' import ReactDOM from 'react-dom' import { Chain, ChainId, chainName } from 'sushi/chain' diff --git a/packages/wagmi/src/components/sanctioned-address-dialog.tsx b/apps/evm/src/lib/wagmi/components/sanctioned-address-dialog.tsx similarity index 87% rename from packages/wagmi/src/components/sanctioned-address-dialog.tsx rename to apps/evm/src/lib/wagmi/components/sanctioned-address-dialog.tsx index d72985f437..9b4a87f244 100644 --- a/packages/wagmi/src/components/sanctioned-address-dialog.tsx +++ b/apps/evm/src/lib/wagmi/components/sanctioned-address-dialog.tsx @@ -1,7 +1,7 @@ 'use client' import { useLocalStorage } from '@sushiswap/hooks' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import { Dialog, DialogContent, @@ -9,8 +9,8 @@ import { DialogFooter, DialogHeader, DialogTitle, -} from '@sushiswap/ui/components/dialog' -import { LinkExternal } from '@sushiswap/ui/components/link' +} from '@sushiswap/ui' +import { LinkExternal } from '@sushiswap/ui' export const SanctionedAddressDialog = () => { const [open, setOpen] = useLocalStorage('sanctionedAddress', false) diff --git a/packages/wagmi/src/components/token-security-view.tsx b/apps/evm/src/lib/wagmi/components/token-security-view.tsx similarity index 100% rename from packages/wagmi/src/components/token-security-view.tsx rename to apps/evm/src/lib/wagmi/components/token-security-view.tsx diff --git a/packages/wagmi/src/components/token-selector/TokenSelector.tsx b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelector.tsx similarity index 96% rename from packages/wagmi/src/components/token-selector/TokenSelector.tsx rename to apps/evm/src/lib/wagmi/components/token-selector/TokenSelector.tsx index 1bb31d73e9..d904e274cf 100644 --- a/packages/wagmi/src/components/token-selector/TokenSelector.tsx +++ b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelector.tsx @@ -26,10 +26,10 @@ import { classNames, gtagEvent, } from '@sushiswap/ui' -import { Button, buttonIconVariants } from '@sushiswap/ui/components/button' -import { Currency } from '@sushiswap/ui/components/currency' -import { List } from '@sushiswap/ui/components/list' -import { SkeletonCircle, SkeletonText } from '@sushiswap/ui/components/skeleton' +import { Button, buttonIconVariants } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' +import { SkeletonCircle, SkeletonText } from '@sushiswap/ui' import React, { FC, ReactNode, @@ -42,7 +42,7 @@ import { ChainId } from 'sushi/chain' import { Native, Token, Type } from 'sushi/currency' import { isAddress } from 'viem' import { useAccount } from 'wagmi' -import { useTokenWithCache } from '../../hooks' +import { useTokenWithCache } from '../../hooks/tokens/useTokenWithCache' import { TokenSelectorCurrencyList } from './TokenSelectorCurrencyList' import { TokenSelectorImportRow } from './TokenSelectorImportRow' import { useSortedTokenList } from './hooks/useSortedTokenList' diff --git a/packages/wagmi/src/components/token-selector/TokenSelectorCurrencyList.tsx b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorCurrencyList.tsx similarity index 97% rename from packages/wagmi/src/components/token-selector/TokenSelectorCurrencyList.tsx rename to apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorCurrencyList.tsx index 16e240fac1..6e47a3a162 100644 --- a/packages/wagmi/src/components/token-selector/TokenSelectorCurrencyList.tsx +++ b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorCurrencyList.tsx @@ -1,5 +1,5 @@ import { NativeAddress } from '@sushiswap/react-query' -import { Currency } from '@sushiswap/ui/components/currency' +import { Currency } from '@sushiswap/ui' import React, { FC, memo, useMemo } from 'react' import { ChainId } from 'sushi/chain' import { Amount, Native, Type } from 'sushi/currency' diff --git a/packages/wagmi/src/components/token-selector/TokenSelectorImportRow.tsx b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorImportRow.tsx similarity index 94% rename from packages/wagmi/src/components/token-selector/TokenSelectorImportRow.tsx rename to apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorImportRow.tsx index 3eee3b2f53..a3dfdaee6c 100644 --- a/packages/wagmi/src/components/token-selector/TokenSelectorImportRow.tsx +++ b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorImportRow.tsx @@ -9,9 +9,9 @@ import { DialogTrigger, Message, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Icon } from '@sushiswap/ui/components/currency/Icon' -import { List } from '@sushiswap/ui/components/list/List' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' import { FC, useCallback, useState } from 'react' import { Chain } from 'sushi/chain' import { Token } from 'sushi/currency' @@ -57,7 +57,12 @@ export const TokenSelectorImportRow: FC = ({
- +
diff --git a/packages/wagmi/src/components/token-selector/TokenSelectorRow.tsx b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorRow.tsx similarity index 97% rename from packages/wagmi/src/components/token-selector/TokenSelectorRow.tsx rename to apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorRow.tsx index 9ba5fa9be8..bb64b1c78f 100644 --- a/packages/wagmi/src/components/token-selector/TokenSelectorRow.tsx +++ b/apps/evm/src/lib/wagmi/components/token-selector/TokenSelectorRow.tsx @@ -12,8 +12,8 @@ import { TooltipTrigger, classNames, } from '@sushiswap/ui' -import { Badge } from '@sushiswap/ui/components/badge' -import { Icon } from '@sushiswap/ui/components/currency/Icon' +import { Badge } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' import React, { CSSProperties, FC, memo, useCallback } from 'react' import { Chain } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' @@ -96,7 +96,7 @@ export const TokenSelectorRow: FC = memo( } >
- = memo( ) : (
- { + const isTest = process.env.NEXT_PUBLIC_APP_ENV === 'test' + + const config = (() => { + if (isTest) { + return createTestConfig() as unknown as PublicWagmiConfig + } + return createProductionConfig() + })() + + return config +})() + +export const getWagmiInitialState = ( + cookieHeaders: string | null | undefined, +) => { + const initialState = cookieToInitialState(wagmiConfig, cookieHeaders) + return initialState +} diff --git a/apps/evm/src/lib/wagmi/production.ts b/apps/evm/src/lib/wagmi/config/production.ts similarity index 100% rename from apps/evm/src/lib/wagmi/production.ts rename to apps/evm/src/lib/wagmi/config/production.ts diff --git a/apps/evm/src/lib/wagmi/test/constants.ts b/apps/evm/src/lib/wagmi/config/test/constants.ts similarity index 100% rename from apps/evm/src/lib/wagmi/test/constants.ts rename to apps/evm/src/lib/wagmi/config/test/constants.ts diff --git a/apps/evm/src/lib/wagmi/test/index.ts b/apps/evm/src/lib/wagmi/config/test/index.ts similarity index 100% rename from apps/evm/src/lib/wagmi/test/index.ts rename to apps/evm/src/lib/wagmi/config/test/index.ts diff --git a/packages/wagmi/src/hooks/approvals/actions/getTokenAllowance.ts b/apps/evm/src/lib/wagmi/hooks/approvals/actions/getTokenAllowance.ts similarity index 100% rename from packages/wagmi/src/hooks/approvals/actions/getTokenAllowance.ts rename to apps/evm/src/lib/wagmi/hooks/approvals/actions/getTokenAllowance.ts diff --git a/packages/wagmi/src/hooks/approvals/hooks/useTokenAllowance.ts b/apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance.ts similarity index 100% rename from packages/wagmi/src/hooks/approvals/hooks/useTokenAllowance.ts rename to apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenAllowance.ts diff --git a/packages/wagmi/src/hooks/approvals/hooks/useTokenApproval.ts b/apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenApproval.ts similarity index 98% rename from packages/wagmi/src/hooks/approvals/hooks/useTokenApproval.ts rename to apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenApproval.ts index e0d9d573e4..c0da67c635 100644 --- a/packages/wagmi/src/hooks/approvals/hooks/useTokenApproval.ts +++ b/apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenApproval.ts @@ -1,6 +1,6 @@ 'use client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo, useState } from 'react' // import * as Sentry from '@sentry/nextjs' import { Amount, Type } from 'sushi/currency' diff --git a/packages/wagmi/src/hooks/approvals/hooks/useTokenPermit.ts b/apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenPermit.ts similarity index 97% rename from packages/wagmi/src/hooks/approvals/hooks/useTokenPermit.ts rename to apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenPermit.ts index bad8998653..5d492090e4 100644 --- a/packages/wagmi/src/hooks/approvals/hooks/useTokenPermit.ts +++ b/apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenPermit.ts @@ -13,7 +13,7 @@ import { useApprovedActions, useSignature, } from '../../../systems/Checker/Provider' -import { useTransactionDeadline } from '../../utils' +import { useTransactionDeadline } from '../../utils/hooks/useTransactionDeadline' import { ApprovalState } from './useTokenApproval' export enum PermitType { @@ -116,12 +116,12 @@ export const useTokenPermit = ({ ? { name: permitInfo.name, version: permitInfo.version, - chainId: BigInt(chainId), + chainId: chainId, verifyingContract: amount.currency.wrapped.address, } : ({ name: permitInfo.name, - chainId: BigInt(chainId), + chainId: chainId, verifyingContract: amount.currency.wrapped.address, } as any) const message = allowed diff --git a/packages/wagmi/src/hooks/approvals/hooks/useTokenRevokeApproval.ts b/apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenRevokeApproval.ts similarity index 96% rename from packages/wagmi/src/hooks/approvals/hooks/useTokenRevokeApproval.ts rename to apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenRevokeApproval.ts index 92d4313929..3a6f3e6978 100644 --- a/packages/wagmi/src/hooks/approvals/hooks/useTokenRevokeApproval.ts +++ b/apps/evm/src/lib/wagmi/hooks/approvals/hooks/useTokenRevokeApproval.ts @@ -1,6 +1,6 @@ 'use client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo, useState } from 'react' import { Token } from 'sushi/currency' import { Address, UserRejectedRequestError, erc20Abi } from 'viem' diff --git a/packages/wagmi/src/hooks/balances/useBalanceWeb3.ts b/apps/evm/src/lib/wagmi/hooks/balances/useBalanceWeb3.ts similarity index 95% rename from packages/wagmi/src/hooks/balances/useBalanceWeb3.ts rename to apps/evm/src/lib/wagmi/hooks/balances/useBalanceWeb3.ts index 3fbb61aab8..a8f0637c70 100644 --- a/packages/wagmi/src/hooks/balances/useBalanceWeb3.ts +++ b/apps/evm/src/lib/wagmi/hooks/balances/useBalanceWeb3.ts @@ -4,7 +4,7 @@ import { Type } from 'sushi/currency' import { Address, zeroAddress } from 'viem' import { serialize, useBalance, useConfig } from 'wagmi' -import { useWatchByInterval } from '../watch' +import { useWatchByInterval } from '../watch/useWatchByInterval' import { queryFnUseBalances } from './useBalancesWeb3' interface UseBalanceParams { diff --git a/packages/wagmi/src/hooks/balances/useBalanceWeb3Refetch.ts b/apps/evm/src/lib/wagmi/hooks/balances/useBalanceWeb3Refetch.ts similarity index 100% rename from packages/wagmi/src/hooks/balances/useBalanceWeb3Refetch.ts rename to apps/evm/src/lib/wagmi/hooks/balances/useBalanceWeb3Refetch.ts diff --git a/packages/wagmi/src/hooks/balances/useBalancesWeb3.ts b/apps/evm/src/lib/wagmi/hooks/balances/useBalancesWeb3.ts similarity index 97% rename from packages/wagmi/src/hooks/balances/useBalancesWeb3.ts rename to apps/evm/src/lib/wagmi/hooks/balances/useBalancesWeb3.ts index 81bd86e0d7..75a953e01e 100644 --- a/packages/wagmi/src/hooks/balances/useBalancesWeb3.ts +++ b/apps/evm/src/lib/wagmi/hooks/balances/useBalancesWeb3.ts @@ -7,7 +7,7 @@ import { Address, erc20Abi, isAddress, zeroAddress } from 'viem' import { getBalance, readContracts } from '@wagmi/core' import { Config, serialize, useBalance, useConfig } from 'wagmi' import { GetBalanceReturnType } from 'wagmi/actions' -import { useWatchByInterval } from '../watch' +import { useWatchByInterval } from '../watch/useWatchByInterval' interface QueryBalanceParams { chainId: ChainId | undefined diff --git a/packages/wagmi/src/hooks/bar/useBarDeposit.ts b/apps/evm/src/lib/wagmi/hooks/bar/useBarDeposit.ts similarity index 96% rename from packages/wagmi/src/hooks/bar/useBarDeposit.ts rename to apps/evm/src/lib/wagmi/hooks/bar/useBarDeposit.ts index fb15dccd79..b10c4a793a 100644 --- a/packages/wagmi/src/hooks/bar/useBarDeposit.ts +++ b/apps/evm/src/lib/wagmi/hooks/bar/useBarDeposit.ts @@ -1,6 +1,6 @@ 'use client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo } from 'react' import { xsushiAbi } from 'sushi/abi' import { Amount, Token, XSUSHI_ADDRESS } from 'sushi/currency' diff --git a/packages/wagmi/src/hooks/bar/useBarWithdaw.ts b/apps/evm/src/lib/wagmi/hooks/bar/useBarWithdaw.ts similarity index 96% rename from packages/wagmi/src/hooks/bar/useBarWithdaw.ts rename to apps/evm/src/lib/wagmi/hooks/bar/useBarWithdaw.ts index 8ce7eb3416..14fa7d8128 100644 --- a/packages/wagmi/src/hooks/bar/useBarWithdaw.ts +++ b/apps/evm/src/lib/wagmi/hooks/bar/useBarWithdaw.ts @@ -1,6 +1,6 @@ 'use client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo } from 'react' import { xsushiAbi } from 'sushi/abi' import { Amount, Token, XSUSHI_ADDRESS } from 'sushi/currency' diff --git a/packages/wagmi/src/hooks/bentobox/actions/getBentoboxTotal.ts b/apps/evm/src/lib/wagmi/hooks/bentobox/actions/getBentoboxTotal.ts similarity index 100% rename from packages/wagmi/src/hooks/bentobox/actions/getBentoboxTotal.ts rename to apps/evm/src/lib/wagmi/hooks/bentobox/actions/getBentoboxTotal.ts diff --git a/packages/wagmi/src/hooks/bentobox/actions/getBentoboxTotals.ts b/apps/evm/src/lib/wagmi/hooks/bentobox/actions/getBentoboxTotals.ts similarity index 100% rename from packages/wagmi/src/hooks/bentobox/actions/getBentoboxTotals.ts rename to apps/evm/src/lib/wagmi/hooks/bentobox/actions/getBentoboxTotals.ts diff --git a/packages/wagmi/src/hooks/bentobox/hooks/useBentoBoxApproval.ts b/apps/evm/src/lib/wagmi/hooks/bentobox/hooks/useBentoBoxApproval.ts similarity index 93% rename from packages/wagmi/src/hooks/bentobox/hooks/useBentoBoxApproval.ts rename to apps/evm/src/lib/wagmi/hooks/bentobox/hooks/useBentoBoxApproval.ts index 7892eff34f..5afbe95cb6 100644 --- a/packages/wagmi/src/hooks/bentobox/hooks/useBentoBoxApproval.ts +++ b/apps/evm/src/lib/wagmi/hooks/bentobox/hooks/useBentoBoxApproval.ts @@ -1,10 +1,6 @@ 'use client' -import { - createErrorToast, - createFailedToast, - createToast, -} from '@sushiswap/ui/components/toast' +import { createErrorToast, createFailedToast, createToast } from '@sushiswap/ui' import { useQuery } from '@tanstack/react-query' import { useCallback, useMemo, useState } from 'react' import { BENTOBOX_ADDRESS, BentoBoxChainId } from 'sushi/config' @@ -18,12 +14,12 @@ import { } from 'wagmi' import { SendTransactionReturnType } from 'wagmi/actions' -import { getBentoBoxContractConfig } from '../..' +import { bentoBoxV1Abi } from 'sushi/abi' import { useApprovedActions, useSignature, } from '../../../systems/Checker/Provider' -import { ApprovalState } from '../../approvals' +import { ApprovalState } from '../../approvals/hooks/useTokenApproval' interface UseBentoboxApprovalParams { enabled?: boolean @@ -68,14 +64,16 @@ export const useBentoBoxApproval = ({ queryFn: async () => { if (masterContract && address) { const isApproved = await client.readContract({ - ...getBentoBoxContractConfig(chainId), + abi: bentoBoxV1Abi, + address: BENTOBOX_ADDRESS[chainId], functionName: 'masterContractApproved', args: [masterContract, address], }) if (!isApproved) { const nonces = await client.readContract({ - ...getBentoBoxContractConfig(chainId), + abi: bentoBoxV1Abi, + address: BENTOBOX_ADDRESS[chainId], functionName: 'nonces', args: [address], }) @@ -93,7 +91,8 @@ export const useBentoBoxApproval = ({ }) const { data: simulation } = useSimulateContract({ - ...getBentoBoxContractConfig(chainId), + abi: bentoBoxV1Abi, + address: BENTOBOX_ADDRESS[chainId], chainId, functionName: 'setMasterContractApproval', args: diff --git a/packages/wagmi/src/hooks/bentobox/hooks/useBentoBoxTotals.ts b/apps/evm/src/lib/wagmi/hooks/bentobox/hooks/useBentoBoxTotals.ts similarity index 94% rename from packages/wagmi/src/hooks/bentobox/hooks/useBentoBoxTotals.ts rename to apps/evm/src/lib/wagmi/hooks/bentobox/hooks/useBentoBoxTotals.ts index 6c5a714500..b58fb2ef7d 100644 --- a/packages/wagmi/src/hooks/bentobox/hooks/useBentoBoxTotals.ts +++ b/apps/evm/src/lib/wagmi/hooks/bentobox/hooks/useBentoBoxTotals.ts @@ -7,7 +7,7 @@ import { Type } from 'sushi/currency' import { PublicWagmiConfig } from '@sushiswap/wagmi-config' import { useConfig } from 'wagmi' -import { getBentoboxTotals } from '../actions' +import { getBentoboxTotals } from '../actions/getBentoboxTotals' interface UseBentoboxTotalsParams { chainId: ChainId diff --git a/packages/wagmi/src/hooks/block/useCurrentBlockTimestamp.ts b/apps/evm/src/lib/wagmi/hooks/block/useCurrentBlockTimestamp.ts similarity index 80% rename from packages/wagmi/src/hooks/block/useCurrentBlockTimestamp.ts rename to apps/evm/src/lib/wagmi/hooks/block/useCurrentBlockTimestamp.ts index dfe990d820..7e8327bb9b 100644 --- a/packages/wagmi/src/hooks/block/useCurrentBlockTimestamp.ts +++ b/apps/evm/src/lib/wagmi/hooks/block/useCurrentBlockTimestamp.ts @@ -2,8 +2,9 @@ import { useQueryClient } from '@tanstack/react-query' import { useEffect } from 'react' +import { multicall3Abi } from 'sushi/abi' import { useBlockNumber, useReadContract } from 'wagmi' -import { Multicall3ChainId, getMulticall3ContractConfig } from '../contracts' +import { MULTICALL_3_ADDRESS, Multicall3ChainId } from '../contracts/multicall3' // TODO: Readd direct export, not sure why it's not working export const useCurrentBlockTimestamp = ( @@ -12,7 +13,8 @@ export const useCurrentBlockTimestamp = ( ) => { const queryClient = useQueryClient() const query = useReadContract({ - ...getMulticall3ContractConfig(chainId), + address: MULTICALL_3_ADDRESS[chainId], + abi: multicall3Abi, functionName: 'getCurrentBlockTimestamp', query: { enabled, diff --git a/packages/wagmi/src/hooks/bonds/useDiscount.ts b/apps/evm/src/lib/wagmi/hooks/bonds/use-bond-discount.ts similarity index 96% rename from packages/wagmi/src/hooks/bonds/useDiscount.ts rename to apps/evm/src/lib/wagmi/hooks/bonds/use-bond-discount.ts index 3db1576d2a..05c43167ff 100644 --- a/packages/wagmi/src/hooks/bonds/useDiscount.ts +++ b/apps/evm/src/lib/wagmi/hooks/bonds/use-bond-discount.ts @@ -6,7 +6,7 @@ import { import { usePrices } from '@sushiswap/react-query' import { useMemo } from 'react' import { Address, getAddress } from 'viem' -import { useBondMarketPrices } from './useMarketPrice' +import { useBondMarketPrices } from './use-bond-market-price' interface UseBondsDiscount { marketId: MarketId diff --git a/packages/wagmi/src/hooks/bonds/useMarketDetails.ts b/apps/evm/src/lib/wagmi/hooks/bonds/use-bond-market-details.ts similarity index 100% rename from packages/wagmi/src/hooks/bonds/useMarketDetails.ts rename to apps/evm/src/lib/wagmi/hooks/bonds/use-bond-market-details.ts diff --git a/packages/wagmi/src/hooks/bonds/useMarketPrice.ts b/apps/evm/src/lib/wagmi/hooks/bonds/use-bond-market-price.ts similarity index 100% rename from packages/wagmi/src/hooks/bonds/useMarketPrice.ts rename to apps/evm/src/lib/wagmi/hooks/bonds/use-bond-market-price.ts diff --git a/apps/evm/src/lib/wagmi/hooks/contracts/multicall3.ts b/apps/evm/src/lib/wagmi/hooks/contracts/multicall3.ts new file mode 100644 index 0000000000..a02c6c375e --- /dev/null +++ b/apps/evm/src/lib/wagmi/hooks/contracts/multicall3.ts @@ -0,0 +1,15 @@ +'use client' + +import { publicWagmiConfig } from '@sushiswap/wagmi-config' +import { Address } from 'viem' + +export type Multicall3ChainId = + (typeof publicWagmiConfig)['chains'][number]['id'] + +export const MULTICALL_3_ADDRESS = publicWagmiConfig.chains.reduce( + (acc, chain) => { + acc[chain.id] = chain.contracts.multicall3.address + return acc + }, + {} as Record, +) diff --git a/packages/wagmi/src/hooks/contracts/useSushiSwapRouter.ts b/apps/evm/src/lib/wagmi/hooks/contracts/useSushiSwapRouter.ts similarity index 100% rename from packages/wagmi/src/hooks/contracts/useSushiSwapRouter.ts rename to apps/evm/src/lib/wagmi/hooks/contracts/useSushiSwapRouter.ts diff --git a/packages/wagmi/src/hooks/currency/useCurrencyCombinations.ts b/apps/evm/src/lib/wagmi/hooks/currency/useCurrencyCombinations.ts similarity index 100% rename from packages/wagmi/src/hooks/currency/useCurrencyCombinations.ts rename to apps/evm/src/lib/wagmi/hooks/currency/useCurrencyCombinations.ts diff --git a/packages/wagmi/src/hooks/currency/useNativeCurrency.ts b/apps/evm/src/lib/wagmi/hooks/currency/useNativeCurrency.ts similarity index 100% rename from packages/wagmi/src/hooks/currency/useNativeCurrency.ts rename to apps/evm/src/lib/wagmi/hooks/currency/useNativeCurrency.ts diff --git a/packages/wagmi/src/hooks/exploits/abis/SushiFundsReturnerAbi.ts b/apps/evm/src/lib/wagmi/hooks/exploits/abis/SushiFundsReturnerAbi.ts similarity index 100% rename from packages/wagmi/src/hooks/exploits/abis/SushiFundsReturnerAbi.ts rename to apps/evm/src/lib/wagmi/hooks/exploits/abis/SushiFundsReturnerAbi.ts diff --git a/packages/wagmi/src/hooks/exploits/constants.ts b/apps/evm/src/lib/wagmi/hooks/exploits/constants.ts similarity index 58% rename from packages/wagmi/src/hooks/exploits/constants.ts rename to apps/evm/src/lib/wagmi/hooks/exploits/constants.ts index 2e2653cec1..7526d83425 100644 --- a/packages/wagmi/src/hooks/exploits/constants.ts +++ b/apps/evm/src/lib/wagmi/hooks/exploits/constants.ts @@ -2,15 +2,6 @@ import { ChainId } from 'sushi/chain' import { z } from 'zod' import { Address } from 'viem' -import Rp2MerkleTreeArbitrum from './data/arbitrum-tree.json' -import Rp2MerkleTreeAvalanche from './data/avalanche-tree.json' -import Rp2MerkleTreeBoba from './data/boba-tree.json' -import Rp2MerkleTreeBSC from './data/bsc-tree.json' -import Rp2MerkleTreeEthereum from './data/ethereum-tree.json' -import Rp2MerkleTreeFantom from './data/fantom-tree.json' -import Rp2MerkleTreeNova from './data/nova-tree.json' -import Rp2MerkleTreeOptimism from './data/optimism-tree.json' -import Rp2MerkleTreePolygon from './data/polygon-tree.json' import { RP2ClaimChainId } from './types' export const RP2ClaimAddress = { @@ -25,18 +16,6 @@ export const RP2ClaimAddress = { [ChainId.POLYGON]: '0xeaD6bD491457f3Aa7dbcb079FaAc93329837ABb0', } -export const RP2MerkleTree = { - [ChainId.ARBITRUM]: Rp2MerkleTreeArbitrum, - [ChainId.AVALANCHE]: Rp2MerkleTreeAvalanche, - [ChainId.BOBA]: Rp2MerkleTreeBoba, - [ChainId.BSC]: Rp2MerkleTreeBSC, - [ChainId.ETHEREUM]: Rp2MerkleTreeEthereum, - [ChainId.FANTOM]: Rp2MerkleTreeFantom, - [ChainId.ARBITRUM_NOVA]: Rp2MerkleTreeNova, - [ChainId.OPTIMISM]: Rp2MerkleTreeOptimism, - [ChainId.POLYGON]: Rp2MerkleTreePolygon, -} - export const RP2MerkleTreeClaimSchema = z.object({ user: z.string().transform((el) => el as Address), index: z.number(), diff --git a/packages/wagmi/src/hooks/exploits/data/arbitrum-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/arbitrum-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/arbitrum-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/arbitrum-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/avalanche-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/avalanche-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/avalanche-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/avalanche-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/boba-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/boba-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/boba-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/boba-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/bsc-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/bsc-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/bsc-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/bsc-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/ethereum-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/ethereum-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/ethereum-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/ethereum-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/fantom-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/fantom-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/fantom-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/fantom-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/nova-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/nova-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/nova-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/nova-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/optimism-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/optimism-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/optimism-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/optimism-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/polygon-tree.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/polygon-tree.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/polygon-tree.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/polygon-tree.json diff --git a/packages/wagmi/src/hooks/exploits/data/rp2-approvals.json b/apps/evm/src/lib/wagmi/hooks/exploits/data/rp2-approvals.json similarity index 100% rename from packages/wagmi/src/hooks/exploits/data/rp2-approvals.json rename to apps/evm/src/lib/wagmi/hooks/exploits/data/rp2-approvals.json diff --git a/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitCheck.ts b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitCheck.ts new file mode 100644 index 0000000000..66d0ff629f --- /dev/null +++ b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitCheck.ts @@ -0,0 +1,31 @@ +'use client' + +import { useQuery } from '@tanstack/react-query' +import type { Approvals } from 'src/app/claims/rp2/check-approvals/route' +import { Token } from 'sushi/currency' +import type { Address } from 'viem' + +interface UseRP2ExploitCheck { + account: Address | undefined +} + +export const useRP2ExploitCheck = ({ account }: UseRP2ExploitCheck) => { + return useQuery({ + queryKey: ['useRP2ExploitCheck', { account }], + enabled: Boolean(account), + queryFn: async () => { + if (!account) return [] + + const data: Approvals = await fetch( + `/claims/rp2/check-approvals?account=${account}`, + ).then((res) => res.json()) + + return data.map((token) => new Token(token)) + }, + refetchOnWindowFocus: false, + refetchOnReconnect: false, + refetchIntervalInBackground: false, + refetchOnMount: false, + refetchInterval: 10000 * 60 * 60, + }) +} diff --git a/packages/wagmi/src/hooks/exploits/hooks/useRP2ExploitClaim.ts b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaim.ts similarity index 97% rename from packages/wagmi/src/hooks/exploits/hooks/useRP2ExploitClaim.ts rename to apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaim.ts index e2676db2a1..8ef2450f9a 100644 --- a/packages/wagmi/src/hooks/exploits/hooks/useRP2ExploitClaim.ts +++ b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaim.ts @@ -1,6 +1,6 @@ 'use client' -import { createToast } from '@sushiswap/ui/components/toast' +import { createToast } from '@sushiswap/ui' import { useCallback, useMemo, useState } from 'react' import { Token } from 'sushi/currency' import { usePublicClient, useSimulateContract, useWriteContract } from 'wagmi' diff --git a/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaimFinder.ts b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaimFinder.ts new file mode 100644 index 0000000000..109780df65 --- /dev/null +++ b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitClaimFinder.ts @@ -0,0 +1,20 @@ +'use client' + +import { Address } from 'viem' + +import { useQuery } from '@tanstack/react-query' +import type { Claims } from 'src/app/claims/rp2/find-claims/route' + +interface UseRP2ExploitCheck { + account: Address | undefined +} + +export const useRP2ExploitClaimFinder = ({ account }: UseRP2ExploitCheck) => { + return useQuery({ + queryKey: ['rp2-claims', account], + queryFn: async () => + fetch(`/claims/rp2/find-claims?account=${account}`).then((res) => + res.json(), + ), + }) +} diff --git a/packages/wagmi/src/hooks/exploits/hooks/useRP2ExploitIsClaimed.ts b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitIsClaimed.ts similarity index 98% rename from packages/wagmi/src/hooks/exploits/hooks/useRP2ExploitIsClaimed.ts rename to apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitIsClaimed.ts index 92465a4ab9..9190bb77ad 100644 --- a/packages/wagmi/src/hooks/exploits/hooks/useRP2ExploitIsClaimed.ts +++ b/apps/evm/src/lib/wagmi/hooks/exploits/hooks/useRP2ExploitIsClaimed.ts @@ -18,6 +18,7 @@ export const useRP2ExploitIsClaimed = ({ const queryClient = useQueryClient() const query = useReadContract({ ...ClaimContractConfig(chainId), + chainId, functionName: 'isClaimed', args: [BigInt(index)], query: { diff --git a/apps/evm/src/lib/wagmi/hooks/exploits/rp2-merkle-trees.ts b/apps/evm/src/lib/wagmi/hooks/exploits/rp2-merkle-trees.ts new file mode 100644 index 0000000000..cfdedb3860 --- /dev/null +++ b/apps/evm/src/lib/wagmi/hooks/exploits/rp2-merkle-trees.ts @@ -0,0 +1,23 @@ +import { ChainId } from 'sushi/chain' + +import Rp2MerkleTreeArbitrum from './data/arbitrum-tree.json' +import Rp2MerkleTreeAvalanche from './data/avalanche-tree.json' +import Rp2MerkleTreeBoba from './data/boba-tree.json' +import Rp2MerkleTreeBSC from './data/bsc-tree.json' +import Rp2MerkleTreeEthereum from './data/ethereum-tree.json' +import Rp2MerkleTreeFantom from './data/fantom-tree.json' +import Rp2MerkleTreeNova from './data/nova-tree.json' +import Rp2MerkleTreeOptimism from './data/optimism-tree.json' +import Rp2MerkleTreePolygon from './data/polygon-tree.json' + +export const RP2MerkleTree = { + [ChainId.ARBITRUM]: Rp2MerkleTreeArbitrum, + [ChainId.AVALANCHE]: Rp2MerkleTreeAvalanche, + [ChainId.BOBA]: Rp2MerkleTreeBoba, + [ChainId.BSC]: Rp2MerkleTreeBSC, + [ChainId.ETHEREUM]: Rp2MerkleTreeEthereum, + [ChainId.FANTOM]: Rp2MerkleTreeFantom, + [ChainId.ARBITRUM_NOVA]: Rp2MerkleTreeNova, + [ChainId.OPTIMISM]: Rp2MerkleTreeOptimism, + [ChainId.POLYGON]: Rp2MerkleTreePolygon, +} diff --git a/packages/wagmi/src/hooks/exploits/types.ts b/apps/evm/src/lib/wagmi/hooks/exploits/types.ts similarity index 100% rename from packages/wagmi/src/hooks/exploits/types.ts rename to apps/evm/src/lib/wagmi/hooks/exploits/types.ts diff --git a/packages/wagmi/src/hooks/master-chef/use-farm-rewards.ts b/apps/evm/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts similarity index 96% rename from packages/wagmi/src/hooks/master-chef/use-farm-rewards.ts rename to apps/evm/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts index 3ee6c48c89..d1800ff7fa 100644 --- a/packages/wagmi/src/hooks/master-chef/use-farm-rewards.ts +++ b/apps/evm/src/lib/wagmi/hooks/master-chef/use-farm-rewards.ts @@ -5,8 +5,8 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query' import { useMemo } from 'react' import { chainShortName } from 'sushi/chain' import { Token } from 'sushi/currency' -import { RewarderType } from '.' -import { PoolType } from '../pools' +import { PoolType } from '../pools/types' +import { RewarderType } from './use-rewarder' export interface FarmMap { chainId: number diff --git a/packages/wagmi/src/hooks/master-chef/use-master-chef-contract.ts b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-contract.ts similarity index 91% rename from packages/wagmi/src/hooks/master-chef/use-master-chef-contract.ts rename to apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-contract.ts index df971400a9..0c3ac42e5f 100644 --- a/packages/wagmi/src/hooks/master-chef/use-master-chef-contract.ts +++ b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-contract.ts @@ -4,8 +4,7 @@ import { ChefType } from '@sushiswap/client' import { useMemo } from 'react' import { masterChefV1Abi, masterChefV2Abi, miniChefAbi } from 'sushi/abi' import { ChainId } from 'sushi/chain' -import { Address, getContract } from 'viem' -import { usePublicClient } from 'wagmi' +import { Address } from 'viem' // TODO move to package export const MASTERCHEF_ADDRESS = { @@ -87,18 +86,12 @@ export const getMasterChefContractConfig = ( } export function useMasterChefContract( - chainId: ChainId, + chainId: ChainId | undefined, chef: Omit, ) { - const client = usePublicClient({ chainId }) as any - return useMemo(() => { if (!chainId) return null - // @ts-ignore - return getContract({ - ...getMasterChefContractConfig(chainId, chef), - client, - }) - }, [chainId, client, chef]) + return getMasterChefContractConfig(chainId, chef) + }, [chainId, chef]) } diff --git a/packages/wagmi/src/hooks/master-chef/use-master-chef-deposit.ts b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-deposit.ts similarity index 95% rename from packages/wagmi/src/hooks/master-chef/use-master-chef-deposit.ts rename to apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-deposit.ts index 4cc5918cc0..57f65530e0 100644 --- a/packages/wagmi/src/hooks/master-chef/use-master-chef-deposit.ts +++ b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-deposit.ts @@ -1,7 +1,7 @@ 'use client' import { ChefType } from '@sushiswap/client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo } from 'react' import { masterChefV1Abi, masterChefV2Abi } from 'sushi/abi' import { Amount, Token } from 'sushi/currency' @@ -19,7 +19,7 @@ import { ChainId } from 'sushi' import { useMasterChefContract } from './use-master-chef-contract' interface UseMasterChefDepositParams { - chainId: ChainId + chainId: ChainId | undefined chef: ChefType pid: number amount?: Amount @@ -45,7 +45,7 @@ export const useMasterChefDeposit = ({ const onSuccess = useCallback( (data: SendTransactionReturnType) => { - if (!amount) return + if (!amount || !chainId) return try { const ts = new Date().getTime() diff --git a/packages/wagmi/src/hooks/master-chef/use-master-chef-withdraw.ts b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw.ts similarity index 97% rename from packages/wagmi/src/hooks/master-chef/use-master-chef-withdraw.ts rename to apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw.ts index 664857fee0..28094c38db 100644 --- a/packages/wagmi/src/hooks/master-chef/use-master-chef-withdraw.ts +++ b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw.ts @@ -1,7 +1,7 @@ 'use client' import { ChefType } from '@sushiswap/client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo } from 'react' import { ChainId } from 'sushi' import { masterChefV1Abi, masterChefV2Abi, miniChefV2Abi } from 'sushi/abi' diff --git a/packages/wagmi/src/hooks/master-chef/use-master-chef.ts b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef.ts similarity index 98% rename from packages/wagmi/src/hooks/master-chef/use-master-chef.ts rename to apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef.ts index 1f204bd6a0..ca2c4d8e94 100644 --- a/packages/wagmi/src/hooks/master-chef/use-master-chef.ts +++ b/apps/evm/src/lib/wagmi/hooks/master-chef/use-master-chef.ts @@ -1,7 +1,7 @@ 'use client' import { ChefType } from '@sushiswap/client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useQueryClient } from '@tanstack/react-query' import { useCallback, useEffect, useMemo } from 'react' import { erc20Abi, masterChefV2Abi, miniChefV2Abi } from 'sushi/abi' @@ -38,7 +38,7 @@ interface UseMasterChefParams { chainId: ChainId chef: ChefType pid: number - token: Token + token: Token | undefined enabled?: boolean watch?: boolean } @@ -218,10 +218,9 @@ export const useMasterChef: UseMasterChef = ({ const _balance = data?.[1] ? (data?.[1] as [bigint, bigint])[0] : undefined const _pendingSushi = data?.[2] ? data?.[2] : undefined - const balance = Amount.fromRawAmount( - token, - _balance ? _balance.toString() : 0, - ) + const balance = token + ? Amount.fromRawAmount(token, _balance ? _balance.toString() : 0) + : undefined const pendingSushi = SUSHI[chainId as keyof typeof SUSHI] ? Amount.fromRawAmount( SUSHI[chainId as keyof typeof SUSHI], diff --git a/packages/wagmi/src/hooks/master-chef/use-rewarder.ts b/apps/evm/src/lib/wagmi/hooks/master-chef/use-rewarder.ts similarity index 90% rename from packages/wagmi/src/hooks/master-chef/use-rewarder.ts rename to apps/evm/src/lib/wagmi/hooks/master-chef/use-rewarder.ts index 4afcf48727..75d53d93c8 100644 --- a/packages/wagmi/src/hooks/master-chef/use-rewarder.ts +++ b/apps/evm/src/lib/wagmi/hooks/master-chef/use-rewarder.ts @@ -6,7 +6,7 @@ import { useEffect, useMemo } from 'react' import { ChainId } from 'sushi/chain' import { Amount, Token } from 'sushi/currency' import { Address } from 'viem' -import { useBlockNumber, useReadContract, useReadContracts } from 'wagmi' +import { useBlockNumber, useReadContracts } from 'wagmi' import { getMasterChefContractConfig } from './use-master-chef-contract' interface UseRewarderPayload { @@ -19,20 +19,12 @@ interface UseRewarderPayload { chef: ChefType enabled?: boolean } - -interface UseRewarderData - extends Pick, 'isLoading' | 'isError'> { - data: (Amount | undefined)[] -} - -type UseRewarder = (payload: UseRewarderPayload) => UseRewarderData - export enum RewarderType { Primary = 'Primary', Secondary = 'Secondary', } -export const useRewarder: UseRewarder = ({ +export const useRewarder = ({ chainId, account, rewarderAddresses, @@ -41,7 +33,7 @@ export const useRewarder: UseRewarder = ({ farmId, chef, enabled, -}) => { +}: UseRewarderPayload) => { const config = getMasterChefContractConfig(chainId, chef) const contracts = useMemo(() => { @@ -143,7 +135,7 @@ export const useRewarder: UseRewarder = ({ const queryClient = useQueryClient() - const { isError, isLoading, data, queryKey } = useReadContracts({ + const { isError, isInitialLoading, data, queryKey } = useReadContracts({ contracts, allowFailure: true, query: { @@ -165,7 +157,7 @@ export const useRewarder: UseRewarder = ({ if (!data) return { data: rewardTokens.map(() => undefined), - isLoading, + isInitialLoading, isError, } @@ -191,8 +183,8 @@ export const useRewarder: UseRewarder = ({ return acc }, []), - isLoading, + isInitialLoading, isError, } - }, [data, isError, isLoading, rewardTokens]) + }, [data, isError, isInitialLoading, rewardTokens]) } diff --git a/packages/wagmi/src/hooks/migrate/abis/V3Migrator.ts b/apps/evm/src/lib/wagmi/hooks/migrate/abis/V3Migrator.ts similarity index 100% rename from packages/wagmi/src/hooks/migrate/abis/V3Migrator.ts rename to apps/evm/src/lib/wagmi/hooks/migrate/abis/V3Migrator.ts diff --git a/packages/wagmi/src/hooks/migrate/constants.ts b/apps/evm/src/lib/wagmi/hooks/migrate/constants.ts similarity index 100% rename from packages/wagmi/src/hooks/migrate/constants.ts rename to apps/evm/src/lib/wagmi/hooks/migrate/constants.ts diff --git a/packages/wagmi/src/hooks/migrate/hooks/useV3Migrate.tsx b/apps/evm/src/lib/wagmi/hooks/migrate/hooks/useV3Migrate.tsx similarity index 98% rename from packages/wagmi/src/hooks/migrate/hooks/useV3Migrate.tsx rename to apps/evm/src/lib/wagmi/hooks/migrate/hooks/useV3Migrate.tsx index 373ab554c0..6d00544869 100644 --- a/packages/wagmi/src/hooks/migrate/hooks/useV3Migrate.tsx +++ b/apps/evm/src/lib/wagmi/hooks/migrate/hooks/useV3Migrate.tsx @@ -1,4 +1,4 @@ -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { SendTransactionReturnType } from '@wagmi/core' import { useCallback, useMemo } from 'react' import { SushiSwapV3FeeAmount } from 'sushi/config' diff --git a/packages/wagmi/src/hooks/migrate/types.ts b/apps/evm/src/lib/wagmi/hooks/migrate/types.ts similarity index 100% rename from packages/wagmi/src/hooks/migrate/types.ts rename to apps/evm/src/lib/wagmi/hooks/migrate/types.ts diff --git a/apps/evm/src/lib/wagmi/hooks/pools/actions/getAllPools.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/getAllPools.ts new file mode 100644 index 0000000000..9d4df603b7 --- /dev/null +++ b/apps/evm/src/lib/wagmi/hooks/pools/actions/getAllPools.ts @@ -0,0 +1,83 @@ +import { isSushiSwapV2ChainId, isSushiSwapV3ChainId } from 'sushi/config' +import { Type } from 'sushi/currency' +import { TradeType } from 'sushi/dex' +import { SushiSwapV2Pool } from 'sushi/pool/sushiswap-v2' +import { getCurrencyCombinations } from 'sushi/router' +import { UniV3Pool } from 'sushi/tines' +import { UsePoolsParams, UsePoolsReturn } from '../types' +import { PairState, getSushiSwapV2Pools } from './getSushiSwapV2Pools' +import { V3PoolState, getV3Pools } from './getV3Pools' + +const queryFn = async ({ + chainId, + currencyA, + currencyB, + tradeType = TradeType.EXACT_INPUT, + withCombinations = true, + config, +}: UsePoolsParams) => { + const [currencyIn, currencyOut] = + tradeType === TradeType.EXACT_INPUT + ? [currencyA, currencyB] + : [currencyB, currencyA] + + let currencyCombinations: [Type | undefined, Type | undefined][] = [ + [currencyIn, currencyOut], + ] + if (withCombinations && currencyIn && currencyOut && chainId) { + currencyCombinations = getCurrencyCombinations( + chainId, + currencyIn, + currencyOut, + ) + } + + // let v3CurrencyCombinations: [Type | undefined, Type | undefined][] = [[currencyIn, currencyOut]] + // if (withCombinations && currencyIn && currencyOut && chainId) { + // v3CurrencyCombinations = getV3CurrencyCombinations(chainId, currencyIn, currencyOut) + // } + + const [pairs, v3Pools] = await Promise.all([ + isSushiSwapV2ChainId(chainId) + ? getSushiSwapV2Pools(chainId, currencyCombinations, config) + : Promise.resolve([]), + isSushiSwapV3ChainId(chainId) + ? getV3Pools(chainId, currencyCombinations, config) + : Promise.resolve([]), + ]) + // const filteredCurrencyCombinations = currencyCombinations.filter(([a, b]) => a === currencyA || b === currencyA || a === currencyB || b === currencyB) + // const v3Pools = await getV3Pools(chainId, v3CurrencyCombinations) + + return { + pairs, + v3Pools, + } +} + +export const getAllPools = async ( + variables: Omit & { asMap?: boolean }, +): Promise => { + if (!variables.currencyA || !variables.currencyB) { + return { + sushiSwapV2Pools: [], + sushiSwapV3Pools: [], + } + } + const data = await queryFn(variables) + return { + sushiSwapV2Pools: Object.values( + data.pairs + .filter((result): result is [PairState.EXISTS, SushiSwapV2Pool] => + Boolean(result[0] === PairState.EXISTS && result[1]), + ) + .map(([, pair]) => pair as SushiSwapV2Pool), + ), + sushiSwapV3Pools: Object.values( + data.v3Pools + .filter((result): result is [V3PoolState.EXISTS, UniV3Pool] => + Boolean(result[0] === V3PoolState.EXISTS && result[1]), + ) + .map(([, pair]) => pair as UniV3Pool), + ), + } +} diff --git a/packages/wagmi/src/hooks/pools/actions/getAllPoolsCodeMap.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/getAllPoolsCodeMap.ts similarity index 100% rename from packages/wagmi/src/hooks/pools/actions/getAllPoolsCodeMap.ts rename to apps/evm/src/lib/wagmi/hooks/pools/actions/getAllPoolsCodeMap.ts diff --git a/packages/wagmi/src/hooks/pools/actions/getConcentratedLiquidityPool.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedLiquidityPool.ts similarity index 93% rename from packages/wagmi/src/hooks/pools/actions/getConcentratedLiquidityPool.ts rename to apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedLiquidityPool.ts index 720a466370..dc24af6328 100644 --- a/packages/wagmi/src/hooks/pools/actions/getConcentratedLiquidityPool.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedLiquidityPool.ts @@ -1,11 +1,17 @@ -import { SushiSwapV3ChainId, SushiSwapV3FeeAmount } from 'sushi/config' +import { + SUSHISWAP_V3_FACTORY_ADDRESS, + SushiSwapV3ChainId, + SushiSwapV3FeeAmount, +} from 'sushi/config' import { Token, Type } from 'sushi/currency' -import { SushiSwapV3Pool, computeSushiSwapV3PoolAddress } from 'sushi/pool' +import { + SushiSwapV3Pool, + computeSushiSwapV3PoolAddress, +} from 'sushi/pool/sushiswap-v3' import { PublicWagmiConfig } from '@sushiswap/wagmi-config' import { readContracts } from '@wagmi/core/actions' import { Address } from 'viem' -import { getV3FactoryContractConfig } from '../../contracts/useV3FactoryContract' export const getConcentratedLiquidityPools = async ({ chainId, @@ -42,7 +48,7 @@ export const getConcentratedLiquidityPools = async ({ (value) => value && computeSushiSwapV3PoolAddress({ - factoryAddress: getV3FactoryContractConfig(chainId).address, + factoryAddress: SUSHISWAP_V3_FACTORY_ADDRESS[chainId], tokenA: value[0], tokenB: value[1], fee: value[2], diff --git a/packages/wagmi/src/hooks/pools/actions/getConcentratedLiquidityPoolReserves.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedLiquidityPoolReserves.ts similarity index 77% rename from packages/wagmi/src/hooks/pools/actions/getConcentratedLiquidityPoolReserves.ts rename to apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedLiquidityPoolReserves.ts index 834c6f7629..d5a0e4662a 100644 --- a/packages/wagmi/src/hooks/pools/actions/getConcentratedLiquidityPoolReserves.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedLiquidityPoolReserves.ts @@ -1,11 +1,12 @@ -import { SushiSwapV3ChainId } from 'sushi/config' +import { SUSHISWAP_V3_FACTORY_ADDRESS, SushiSwapV3ChainId } from 'sushi/config' import { Amount } from 'sushi/currency' -import { SushiSwapV3Pool, computeSushiSwapV3PoolAddress } from 'sushi/pool' +import { + SushiSwapV3Pool, + computeSushiSwapV3PoolAddress, +} from 'sushi/pool/sushiswap-v3' import { PublicWagmiConfig } from '@sushiswap/wagmi-config' import { getBalance } from '@wagmi/core' -import { getV3FactoryContractConfig } from '../../contracts' - export const getConcentratedLiquidityPoolReserves = async ({ pool, chainId, @@ -16,7 +17,7 @@ export const getConcentratedLiquidityPoolReserves = async ({ config: PublicWagmiConfig }) => { const address = computeSushiSwapV3PoolAddress({ - factoryAddress: getV3FactoryContractConfig(chainId).address, + factoryAddress: SUSHISWAP_V3_FACTORY_ADDRESS[chainId], tokenA: pool.token0, tokenB: pool.token1, fee: pool.fee, diff --git a/packages/wagmi/src/hooks/pools/actions/getConcentratedPositionOwner.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedPositionOwner.ts similarity index 80% rename from packages/wagmi/src/hooks/pools/actions/getConcentratedPositionOwner.ts rename to apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedPositionOwner.ts index da949b50c3..7809639b21 100644 --- a/packages/wagmi/src/hooks/pools/actions/getConcentratedPositionOwner.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/actions/getConcentratedPositionOwner.ts @@ -1,8 +1,7 @@ -import { SushiSwapV3ChainId } from 'sushi/config' +import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId } from 'sushi/config' import { PublicWagmiConfig } from '@sushiswap/wagmi-config' import { readContracts } from 'wagmi/actions' -import { getV3NonFungiblePositionManagerContractConfig } from '../../contracts/useV3NonFungiblePositionManager' export const getConcentratedPositionOwners = async ({ tokenIds, @@ -16,8 +15,7 @@ export const getConcentratedPositionOwners = async ({ ({ tokenId, chainId }) => ({ chainId, - address: - getV3NonFungiblePositionManagerContractConfig(chainId).address, + address: SUSHISWAP_V3_POSTIION_MANAGER[chainId], abi: [ { inputs: [ diff --git a/packages/wagmi/src/hooks/pools/actions/getSushiSwapV2Pools.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/getSushiSwapV2Pools.ts similarity index 96% rename from packages/wagmi/src/hooks/pools/actions/getSushiSwapV2Pools.ts rename to apps/evm/src/lib/wagmi/hooks/pools/actions/getSushiSwapV2Pools.ts index 5dd54ca9e1..373babd3a0 100644 --- a/packages/wagmi/src/hooks/pools/actions/getSushiSwapV2Pools.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/actions/getSushiSwapV2Pools.ts @@ -7,7 +7,10 @@ import { isSushiSwapV2ChainId, } from 'sushi/config' import { Amount, Currency, Token, Type } from 'sushi/currency' -import { SushiSwapV2Pool, computeSushiSwapV2PoolAddress } from 'sushi/pool' +import { + SushiSwapV2Pool, + computeSushiSwapV2PoolAddress, +} from 'sushi/pool/sushiswap-v2' export enum PairState { LOADING = 'Loading', diff --git a/packages/wagmi/src/hooks/pools/actions/getV3Pools.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/getV3Pools.ts similarity index 99% rename from packages/wagmi/src/hooks/pools/actions/getV3Pools.ts rename to apps/evm/src/lib/wagmi/hooks/pools/actions/getV3Pools.ts index 5eb6796569..442b2e8e3f 100644 --- a/packages/wagmi/src/hooks/pools/actions/getV3Pools.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/actions/getV3Pools.ts @@ -10,7 +10,7 @@ import { SushiSwapV3FeeAmount, } from 'sushi/config' import { Currency, Token, Type } from 'sushi/currency' -import { computeSushiSwapV3PoolAddress } from 'sushi/pool' +import { computeSushiSwapV3PoolAddress } from 'sushi/pool/sushiswap-v3' import { RToken, UniV3Pool } from 'sushi/tines' import { Address } from 'viem' diff --git a/packages/wagmi/src/hooks/pools/actions/utils.ts b/apps/evm/src/lib/wagmi/hooks/pools/actions/utils.ts similarity index 100% rename from packages/wagmi/src/hooks/pools/actions/utils.ts rename to apps/evm/src/lib/wagmi/hooks/pools/actions/utils.ts diff --git a/packages/wagmi/src/hooks/pools/hooks/useConcentratedLiquidityPool.ts b/apps/evm/src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool.ts similarity index 91% rename from packages/wagmi/src/hooks/pools/hooks/useConcentratedLiquidityPool.ts rename to apps/evm/src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool.ts index 6d37839177..2f1764b573 100644 --- a/packages/wagmi/src/hooks/pools/hooks/useConcentratedLiquidityPool.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool.ts @@ -3,7 +3,7 @@ import { SushiSwapV3ChainId, SushiSwapV3FeeAmount } from 'sushi/config' import { Type } from 'sushi/currency' import { useConfig } from 'wagmi' -import { getConcentratedLiquidityPool } from '../actions' +import { getConcentratedLiquidityPool } from '../actions/getConcentratedLiquidityPool' interface UseConcentratedLiquidityPool { token0: Type | undefined diff --git a/packages/wagmi/src/hooks/pools/hooks/useConcentratedLiquidityPoolReserves.ts b/apps/evm/src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPoolReserves.ts similarity index 91% rename from packages/wagmi/src/hooks/pools/hooks/useConcentratedLiquidityPoolReserves.ts rename to apps/evm/src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPoolReserves.ts index 9679801083..e1316d8fc0 100644 --- a/packages/wagmi/src/hooks/pools/hooks/useConcentratedLiquidityPoolReserves.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPoolReserves.ts @@ -1,8 +1,8 @@ import { useQuery } from '@tanstack/react-query' import { SushiSwapV3ChainId } from 'sushi/config' -import { SushiSwapV3Pool } from 'sushi/pool' +import { SushiSwapV3Pool } from 'sushi/pool/sushiswap-v3' import { useConfig } from 'wagmi' -import { getConcentratedLiquidityPoolReserves } from '../actions' +import { getConcentratedLiquidityPoolReserves } from '../actions/getConcentratedLiquidityPoolReserves' interface UseConcentratedLiquidityPoolReserves { pool: SushiSwapV3Pool | null | undefined diff --git a/packages/wagmi/src/hooks/pools/hooks/usePools.ts b/apps/evm/src/lib/wagmi/hooks/pools/hooks/usePools.ts similarity index 100% rename from packages/wagmi/src/hooks/pools/hooks/usePools.ts rename to apps/evm/src/lib/wagmi/hooks/pools/hooks/usePools.ts diff --git a/packages/wagmi/src/hooks/pools/hooks/usePoolsAsMap.ts b/apps/evm/src/lib/wagmi/hooks/pools/hooks/usePoolsAsMap.ts similarity index 66% rename from packages/wagmi/src/hooks/pools/hooks/usePoolsAsMap.ts rename to apps/evm/src/lib/wagmi/hooks/pools/hooks/usePoolsAsMap.ts index 11ca5b15cd..b441d0fdd8 100644 --- a/packages/wagmi/src/hooks/pools/hooks/usePoolsAsMap.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/hooks/usePoolsAsMap.ts @@ -2,24 +2,17 @@ import { useQuery } from '@tanstack/react-query' import { ChainId } from 'sushi/chain' import { SUSHISWAP_V2_FACTORY_ADDRESS, - TRIDENT_CONSTANT_POOL_FACTORY_ADDRESS, - TRIDENT_STABLE_POOL_FACTORY_ADDRESS, isSushiSwapV2ChainId, - isTridentChainId, } from 'sushi/config' import { Token } from 'sushi/currency' import { Fee } from 'sushi/dex' import { SushiSwapV2Pool, - TridentConstantPool, - TridentStablePool, computeSushiSwapV2PoolAddress, - computeTridentConstantPoolAddress, - computeTridentStablePoolAddress, -} from 'sushi/pool' +} from 'sushi/pool/sushiswap-v2' import { useConfig } from 'wagmi' -import { getAllPools } from '../actions' +import { getAllPools } from '../actions/getAllPools' import { PoolType, UsePoolsParams } from '../types' const getPoolAddress = ({ @@ -27,7 +20,6 @@ const getPoolAddress = ({ poolType, token0, token1, - fee, }: { chainId: ChainId poolType: PoolType @@ -38,22 +30,6 @@ const getPoolAddress = ({ const [tokenA, tokenB] = token0.wrapped.sortsBefore(token1.wrapped) ? [token0.wrapped, token1.wrapped] : [token1.wrapped, token0.wrapped] - if (poolType === PoolType.TridentStablePool && isTridentChainId(chainId)) - return computeTridentStablePoolAddress({ - factoryAddress: TRIDENT_STABLE_POOL_FACTORY_ADDRESS[chainId], - tokenA, - tokenB, - fee, - }) - - if (poolType === PoolType.TridentConstantPool && isTridentChainId(chainId)) - return computeTridentConstantPoolAddress({ - factoryAddress: TRIDENT_CONSTANT_POOL_FACTORY_ADDRESS[chainId], - tokenA, - tokenB, - fee, - twap: false, - }) if (poolType === PoolType.SushiSwapV2Pool && isSushiSwapV2ChainId(chainId)) { return computeSushiSwapV2PoolAddress({ @@ -88,17 +64,8 @@ export const usePoolsAsMap = ({ withBentoPools: false, config, }) - const pools = [ - ...(data.sushiSwapV2Pools || []), - ...(data.tridentStablePools || []), - ...(data.tridentConstantPools || []), - ] - return pools.reduce< - Record< - string, - SushiSwapV2Pool | TridentConstantPool | TridentStablePool - > - >((acc, cur) => { + const pools = [...(data.sushiSwapV2Pools || [])] + return pools.reduce>((acc, cur) => { acc[cur.liquidityToken.address] = cur return acc }, {}) diff --git a/packages/wagmi/src/hooks/pools/hooks/usePoolsCodeMap.ts b/apps/evm/src/lib/wagmi/hooks/pools/hooks/usePoolsCodeMap.ts similarity index 100% rename from packages/wagmi/src/hooks/pools/hooks/usePoolsCodeMap.ts rename to apps/evm/src/lib/wagmi/hooks/pools/hooks/usePoolsCodeMap.ts diff --git a/packages/wagmi/src/hooks/pools/hooks/useSushiSwapV2Pools.ts b/apps/evm/src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools.ts similarity index 98% rename from packages/wagmi/src/hooks/pools/hooks/useSushiSwapV2Pools.ts rename to apps/evm/src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools.ts index cb6f5f46f5..e896a0ec76 100644 --- a/packages/wagmi/src/hooks/pools/hooks/useSushiSwapV2Pools.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools.ts @@ -9,7 +9,10 @@ import { isSushiSwapV2ChainId, } from 'sushi/config' import { Amount, Currency, Token, Type } from 'sushi/currency' -import { SushiSwapV2Pool, computeSushiSwapV2PoolAddress } from 'sushi/pool' +import { + SushiSwapV2Pool, + computeSushiSwapV2PoolAddress, +} from 'sushi/pool/sushiswap-v2' import { Address } from 'viem' import { UseReadContractsParameters, diff --git a/packages/wagmi/src/hooks/pools/types/index.ts b/apps/evm/src/lib/wagmi/hooks/pools/types/index.ts similarity index 61% rename from packages/wagmi/src/hooks/pools/types/index.ts rename to apps/evm/src/lib/wagmi/hooks/pools/types/index.ts index 9920ceed20..56c255bef5 100644 --- a/packages/wagmi/src/hooks/pools/types/index.ts +++ b/apps/evm/src/lib/wagmi/hooks/pools/types/index.ts @@ -1,14 +1,12 @@ import { PublicWagmiConfig } from '@sushiswap/wagmi-config' -import { SushiSwapV2Pool, TridentConstantPool, TridentStablePool } from 'sushi' +import { SushiSwapV2Pool } from 'sushi' import { ChainId } from 'sushi/chain' import { Type } from 'sushi/currency' import { TradeType } from 'sushi/dex' -import { BridgeBento, UniV3Pool } from 'sushi/tines' +import { UniV3Pool } from 'sushi/tines' export enum PoolType { SushiSwapV2Pool = 'SushiSwapV2', - TridentConstantPool = 'TridentConstant', - TridentStablePool = 'TridentStable', } export interface UsePoolsParams { @@ -24,8 +22,5 @@ export interface UsePoolsParams { export type UsePoolsReturn = { sushiSwapV2Pools: SushiSwapV2Pool[] | undefined - tridentConstantPools: TridentConstantPool[] | undefined - tridentStablePools: TridentStablePool[] | undefined - bridgeBentoPools: BridgeBento[] | undefined sushiSwapV3Pools: UniV3Pool[] | undefined } diff --git a/packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositionFees.ts b/apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositionFees.ts similarity index 89% rename from packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositionFees.ts rename to apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositionFees.ts index e3ee0c6fd5..6e2c21520b 100644 --- a/packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositionFees.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositionFees.ts @@ -1,7 +1,6 @@ import { PublicWagmiConfig } from '@sushiswap/wagmi-config' import { simulateContract } from '@wagmi/core/actions' -import { SushiSwapV3ChainId } from 'sushi/config' -import { getV3NonFungiblePositionManagerContractConfig } from '../../contracts/useV3NonFungiblePositionManager' +import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId } from 'sushi/config' import { getConcentratedPositionOwners } from '../../pools/actions/getConcentratedPositionOwner' const MAX_UINT128 = 2n ** 128n - 1n @@ -73,8 +72,7 @@ export const getConcentratedLiquidityPositionFees = async ({ result = await simulateContract(config, { chainId: el.chainId, abi: abiShard, - address: getV3NonFungiblePositionManagerContractConfig(el.chainId) - .address, + address: SUSHISWAP_V3_POSTIION_MANAGER[el.chainId], functionName: 'collect', args: [ { diff --git a/packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositions.ts b/apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositions.ts similarity index 84% rename from packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositions.ts rename to apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositions.ts index dc335c7f48..d41133c082 100644 --- a/packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositions.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositions.ts @@ -1,12 +1,15 @@ import { ChainId } from 'sushi/chain' -import { SUSHISWAP_V3_INIT_CODE_HASH, SushiSwapV3ChainId } from 'sushi/config' -import { computeSushiSwapV3PoolAddress } from 'sushi/pool' +import { + SUSHISWAP_V3_FACTORY_ADDRESS, + SUSHISWAP_V3_INIT_CODE_HASH, + SUSHISWAP_V3_POSTIION_MANAGER, + SushiSwapV3ChainId, +} from 'sushi/config' +import { computeSushiSwapV3PoolAddress } from 'sushi/pool/sushiswap-v3' import { PublicWagmiConfig } from '@sushiswap/wagmi-config' import { readContracts } from '@wagmi/core/actions' import { erc20Abi } from 'viem' -import { getV3FactoryContractConfig } from '../../contracts/useV3FactoryContract' -import { getV3NonFungiblePositionManagerContractConfig } from '../../contracts/useV3NonFungiblePositionManager' import { ConcentratedLiquidityPosition } from '../types' import { getConcentratedLiquidityPositionFees } from './getConcentratedLiquidityPositionFees' import { getConcentratedLiquidityPositionsFromTokenIds } from './getConcentratedLiquidityPositionsFromTokenIds' @@ -53,7 +56,7 @@ export const getConcentratedLiquidityPositions = async ({ contracts: chainIds.map( (el) => ({ - address: getV3NonFungiblePositionManagerContractConfig(el).address, + address: SUSHISWAP_V3_POSTIION_MANAGER[el], abi: erc20Abi, chainId: el, functionName: 'balanceOf' as const, @@ -85,8 +88,7 @@ export const getConcentratedLiquidityPositions = async ({ ([_chainId, account, index]) => ({ chainId: _chainId, - address: - getV3NonFungiblePositionManagerContractConfig(_chainId).address, + address: SUSHISWAP_V3_POSTIION_MANAGER[_chainId], abi: abiShard, functionName: 'tokenOfOwnerByIndex' as const, args: [account, BigInt(index)], @@ -114,7 +116,7 @@ export const getConcentratedLiquidityPositions = async ({ return positions.filter(Boolean).map((el, i) => ({ ...el, address: computeSushiSwapV3PoolAddress({ - factoryAddress: getV3FactoryContractConfig(el.chainId).address, + factoryAddress: SUSHISWAP_V3_FACTORY_ADDRESS[el.chainId], tokenA: el.token0, tokenB: el.token1, fee: el.fee, diff --git a/packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositionsFromTokenIds.ts b/apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositionsFromTokenIds.ts similarity index 88% rename from packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositionsFromTokenIds.ts rename to apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositionsFromTokenIds.ts index 4d67dca324..4365db3e2a 100644 --- a/packages/wagmi/src/hooks/positions/actions/getConcentratedLiquidityPositionsFromTokenIds.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/actions/getConcentratedLiquidityPositionsFromTokenIds.ts @@ -1,10 +1,12 @@ -import { SushiSwapV3ChainId } from 'sushi/config' -import { computeSushiSwapV3PoolAddress } from 'sushi/pool' +import { + SUSHISWAP_V3_FACTORY_ADDRESS, + SUSHISWAP_V3_POSTIION_MANAGER, + SushiSwapV3ChainId, +} from 'sushi/config' +import { computeSushiSwapV3PoolAddress } from 'sushi/pool/sushiswap-v3' import { PublicWagmiConfig } from '@sushiswap/wagmi-config' import { readContracts } from '@wagmi/core/actions' -import { getV3FactoryContractConfig } from '../../contracts/useV3FactoryContract' -import { getV3NonFungiblePositionManagerContractConfig } from '../../contracts/useV3NonFungiblePositionManager' import { ConcentratedLiquidityPosition } from '../types' import { getConcentratedLiquidityPositionFees } from './getConcentratedLiquidityPositionFees' @@ -94,8 +96,7 @@ export const getConcentratedLiquidityPositionsFromTokenIds = async ({ }): Promise => { const results = await readContracts(config, { contracts: tokenIds.map((el) => ({ - address: getV3NonFungiblePositionManagerContractConfig(el.chainId) - .address, + address: SUSHISWAP_V3_POSTIION_MANAGER[el.chainId], abi: abiShard, chainId: el.chainId, functionName: 'positions', @@ -128,7 +129,7 @@ export const getConcentratedLiquidityPositionsFromTokenIds = async ({ return { id: tokenId.toString(), address: computeSushiSwapV3PoolAddress({ - factoryAddress: getV3FactoryContractConfig(chainId).address, + factoryAddress: SUSHISWAP_V3_FACTORY_ADDRESS[chainId], tokenA: token0, tokenB: token1, fee: fee, diff --git a/packages/wagmi/src/hooks/positions/hooks/useConcentratedLiquidityPositions.ts b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedLiquidityPositions.ts similarity index 94% rename from packages/wagmi/src/hooks/positions/hooks/useConcentratedLiquidityPositions.ts rename to apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedLiquidityPositions.ts index 07dc1d5b90..9eb993eda8 100644 --- a/packages/wagmi/src/hooks/positions/hooks/useConcentratedLiquidityPositions.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedLiquidityPositions.ts @@ -3,17 +3,17 @@ import { useAllPrices, usePrices } from '@sushiswap/react-query' import { useQuery } from '@tanstack/react-query' import { SushiSwapV3ChainId } from 'sushi/config' import { Amount, Token } from 'sushi/currency' -import { Position, SushiSwapV3Pool } from 'sushi/pool' +import { Position, SushiSwapV3Pool } from 'sushi/pool/sushiswap-v3' import { useMemo } from 'react' import { Address } from 'viem' import { useConfig } from 'wagmi' -import { getConcentratedLiquidityPool } from '../../pools' +import { getConcentratedLiquidityPool } from '../../pools/actions/getConcentratedLiquidityPool' import { getTokenWithCacheQueryFn, getTokenWithQueryCacheHydrate, -} from '../../tokens' -import { getConcentratedLiquidityPositions } from '../actions' +} from '../../tokens/useTokenWithCache' +import { getConcentratedLiquidityPositions } from '../actions/getConcentratedLiquidityPositions' import { ConcentratedLiquidityPosition } from '../types' interface UseConcentratedLiquidityPositionsData diff --git a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionInfo.ts b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionInfo.ts similarity index 91% rename from packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionInfo.ts rename to apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionInfo.ts index 05ac22ec52..a39ad64c28 100644 --- a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionInfo.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionInfo.ts @@ -1,11 +1,11 @@ import { useQuery } from '@tanstack/react-query' import { SushiSwapV3ChainId } from 'sushi/config' import { Type } from 'sushi/currency' -import { Position } from 'sushi/pool' +import { Position } from 'sushi/pool/sushiswap-v3' import { stringify } from 'viem' import { useConfig } from 'wagmi' -import { getConcentratedLiquidityPool } from '../../pools' +import { getConcentratedLiquidityPool } from '../../pools/actions/getConcentratedLiquidityPool' import { useConcentratedLiquidityPositionsFromTokenId } from './useConcentratedPositionsFromTokenId' interface UseConcentratedLiquidityPositionsFromTokenIdParams { diff --git a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionOwner.ts b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionOwner.ts similarity index 77% rename from packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionOwner.ts rename to apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionOwner.ts index 1931f67131..78a9f9cb74 100644 --- a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionOwner.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionOwner.ts @@ -1,8 +1,6 @@ -import { SushiSwapV3ChainId } from 'sushi/config' +import { SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId } from 'sushi/config' import { useReadContract } from 'wagmi' -import { getV3NonFungiblePositionManagerContractConfig } from '../../contracts/useV3NonFungiblePositionManager' - export const useConcentratedPositionOwner = ({ chainId, tokenId, @@ -12,7 +10,7 @@ export const useConcentratedPositionOwner = ({ }) => { const query = useReadContract({ chainId, - address: getV3NonFungiblePositionManagerContractConfig(chainId).address, + address: SUSHISWAP_V3_POSTIION_MANAGER[chainId], abi: [ { inputs: [ diff --git a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionsFromTokenId.ts b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenId.ts similarity index 95% rename from packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionsFromTokenId.ts rename to apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenId.ts index 3c39fd8df1..cf37f9236d 100644 --- a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionsFromTokenId.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenId.ts @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query' import { SushiSwapV3ChainId } from 'sushi/config' import { useConfig } from 'wagmi' -import { getConcentratedLiquidityPositionsFromTokenIds } from '../actions' +import { getConcentratedLiquidityPositionsFromTokenIds } from '../actions/getConcentratedLiquidityPositionsFromTokenIds' interface UseConcentratedLiquidityPositionsFromTokenIdParams { tokenId: number | string | undefined diff --git a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionsFromTokenIds.ts b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenIds.ts similarity index 94% rename from packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionsFromTokenIds.ts rename to apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenIds.ts index 871522b4da..dd275afeee 100644 --- a/packages/wagmi/src/hooks/positions/hooks/useConcentratedPositionsFromTokenIds.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenIds.ts @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query' import { SushiSwapV3ChainId } from 'sushi/config' import { useConfig } from 'wagmi' -import { getConcentratedLiquidityPositionsFromTokenIds } from '../actions' +import { getConcentratedLiquidityPositionsFromTokenIds } from '../actions/getConcentratedLiquidityPositionsFromTokenIds' interface UseConcentratedLiquidityPositionsFromTokenIdsParams { keys: { tokenId: bigint; chainId: SushiSwapV3ChainId }[] | undefined diff --git a/packages/wagmi/src/hooks/positions/types.ts b/apps/evm/src/lib/wagmi/hooks/positions/types.ts similarity index 86% rename from packages/wagmi/src/hooks/positions/types.ts rename to apps/evm/src/lib/wagmi/hooks/positions/types.ts index 0616ed1a56..c3b27cd025 100644 --- a/packages/wagmi/src/hooks/positions/types.ts +++ b/apps/evm/src/lib/wagmi/hooks/positions/types.ts @@ -1,6 +1,6 @@ import { SushiSwapV3ChainId } from 'sushi/config' -import { useConcentratedLiquidityPositions } from './hooks' +import { useConcentratedLiquidityPositions } from './hooks/useConcentratedLiquidityPositions' export interface ConcentratedLiquidityPosition { id: string diff --git a/packages/wagmi/src/hooks/rewards/abis/DistributionCreator.ts b/apps/evm/src/lib/wagmi/hooks/rewards/abis/DistributionCreator.ts similarity index 100% rename from packages/wagmi/src/hooks/rewards/abis/DistributionCreator.ts rename to apps/evm/src/lib/wagmi/hooks/rewards/abis/DistributionCreator.ts diff --git a/packages/wagmi/src/hooks/rewards/abis/ERC1967Proxy.ts b/apps/evm/src/lib/wagmi/hooks/rewards/abis/ERC1967Proxy.ts similarity index 100% rename from packages/wagmi/src/hooks/rewards/abis/ERC1967Proxy.ts rename to apps/evm/src/lib/wagmi/hooks/rewards/abis/ERC1967Proxy.ts diff --git a/packages/wagmi/src/hooks/rewards/abis/index.ts b/apps/evm/src/lib/wagmi/hooks/rewards/abis/index.ts similarity index 100% rename from packages/wagmi/src/hooks/rewards/abis/index.ts rename to apps/evm/src/lib/wagmi/hooks/rewards/abis/index.ts diff --git a/packages/wagmi/src/hooks/rewards/hooks/useAcceptAngleConditions.ts b/apps/evm/src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions.ts similarity index 97% rename from packages/wagmi/src/hooks/rewards/hooks/useAcceptAngleConditions.ts rename to apps/evm/src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions.ts index b00d5405f9..8e6fe48c8e 100644 --- a/packages/wagmi/src/hooks/rewards/hooks/useAcceptAngleConditions.ts +++ b/apps/evm/src/lib/wagmi/hooks/rewards/hooks/useAcceptAngleConditions.ts @@ -1,6 +1,6 @@ 'use client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo, useState } from 'react' import { ChainId } from 'sushi/chain' import { SendTransactionReturnType, UserRejectedRequestError } from 'viem' diff --git a/packages/wagmi/src/hooks/rewards/hooks/useHarvestAngleRewards.ts b/apps/evm/src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards.ts similarity index 96% rename from packages/wagmi/src/hooks/rewards/hooks/useHarvestAngleRewards.ts rename to apps/evm/src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards.ts index 27f3ebaba1..fdcb829f32 100644 --- a/packages/wagmi/src/hooks/rewards/hooks/useHarvestAngleRewards.ts +++ b/apps/evm/src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards.ts @@ -1,4 +1,4 @@ -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback, useMemo } from 'react' import { ChainId } from 'sushi/chain' import { Address, UserRejectedRequestError } from 'viem' diff --git a/packages/wagmi/src/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts b/apps/evm/src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts similarity index 96% rename from packages/wagmi/src/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts rename to apps/evm/src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts index 5ff4985f54..e16d590155 100644 --- a/packages/wagmi/src/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts +++ b/apps/evm/src/lib/wagmi/hooks/rewards/hooks/useIncentivizePoolWithRewards.ts @@ -1,4 +1,4 @@ -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' import { useCallback } from 'react' import { ChainId } from 'sushi/chain' import { Address, UserRejectedRequestError } from 'viem' diff --git a/packages/wagmi/src/hooks/useSteer/useSteerAccountPosition.ts b/apps/evm/src/lib/wagmi/hooks/steer/useSteerAccountPosition.ts similarity index 93% rename from packages/wagmi/src/hooks/useSteer/useSteerAccountPosition.ts rename to apps/evm/src/lib/wagmi/hooks/steer/useSteerAccountPosition.ts index 4c6de8df8e..76426c3754 100644 --- a/packages/wagmi/src/hooks/useSteer/useSteerAccountPosition.ts +++ b/apps/evm/src/lib/wagmi/hooks/steer/useSteerAccountPosition.ts @@ -12,14 +12,17 @@ import { import { Address } from 'viem' import { useMemo } from 'react' -import { useWatchByInterval } from '../watch' +import type { ID } from 'sushi/types' +import { useWatchByInterval } from '../watch/useWatchByInterval' interface UseSteerAccountPositions { account: Address | undefined - vaultIds: string[] | undefined + vaultIds: ID[] | undefined enabled?: boolean } +export type SteerAccountPosition = ReturnType[0] + export const useSteerAccountPositions = ({ vaultIds, account, @@ -94,20 +97,12 @@ export const useSteerAccountPositions = ({ const data = useMemo(() => { if (!accountBalances || !totalSupplies || !vaultReserves) return undefined - console.log({ - accountBalances, - totalSupplies, - vaultReserves, - }) - const positions = getAccountPositions({ accountBalances, totalSupplies, vaultReserves, }) - console.log(positions) - return positions }, [accountBalances, totalSupplies, vaultReserves]) @@ -122,7 +117,7 @@ export const useSteerAccountPositions = ({ interface UseSteerAccountPosition { account: Address | undefined - vaultId: string | undefined + vaultId: ID | undefined enabled?: boolean } diff --git a/packages/wagmi/src/hooks/useSteer/useSteerAccountPositionsExtended.ts b/apps/evm/src/lib/wagmi/hooks/steer/useSteerAccountPositionsExtended.ts similarity index 90% rename from packages/wagmi/src/hooks/useSteer/useSteerAccountPositionsExtended.ts rename to apps/evm/src/lib/wagmi/hooks/steer/useSteerAccountPositionsExtended.ts index 81a575a1b9..c20dc4bebf 100644 --- a/packages/wagmi/src/hooks/useSteer/useSteerAccountPositionsExtended.ts +++ b/apps/evm/src/lib/wagmi/hooks/steer/useSteerAccountPositionsExtended.ts @@ -13,6 +13,10 @@ interface UseSteerAccountPositionsExtended { chainIds?: number[] } +export type SteerAccountPositionExtended = NonNullable< + ReturnType['data'] +>[0] + export const useSteerAccountPositionsExtended = ({ account, enabled = true, @@ -43,8 +47,8 @@ export const useSteerAccountPositionsExtended = ({ if (!vault) return [] - const token0 = new Token({ chainId: vault.chainId, ...vault.token0 }) - const token1 = new Token({ chainId: vault.chainId, ...vault.token1 }) + const token0 = new Token(vault.token0) + const token1 = new Token(vault.token1) const token0Price = prices?.[String(vault.chainId)]?.[token0.address] || 0 const token1Price = prices?.[String(vault.chainId)]?.[token1.address] || 0 @@ -62,6 +66,8 @@ export const useSteerAccountPositionsExtended = ({ return { ...position, vault, + token0, + token1, token0Amount, token1Amount, token0AmountUSD, diff --git a/packages/wagmi/src/hooks/useSteer/useSteerVaultReserves.ts b/apps/evm/src/lib/wagmi/hooks/steer/useSteerVaultReserves.ts similarity index 97% rename from packages/wagmi/src/hooks/useSteer/useSteerVaultReserves.ts rename to apps/evm/src/lib/wagmi/hooks/steer/useSteerVaultReserves.ts index 2685f6ac1c..d7eacc0066 100644 --- a/packages/wagmi/src/hooks/useSteer/useSteerVaultReserves.ts +++ b/apps/evm/src/lib/wagmi/hooks/steer/useSteerVaultReserves.ts @@ -7,7 +7,7 @@ import { useReadContracts, useSimulateContract } from 'wagmi' import { useQueryClient } from '@tanstack/react-query' import { useEffect, useMemo } from 'react' import { getChainIdAddressFromId } from 'sushi' -import { useWatchByBlock } from '../watch' +import { useWatchByBlock } from '../watch/useWatchByBlock' interface UseSteerVaultsReserves { vaultIds: string[] | undefined diff --git a/packages/wagmi/src/hooks/tokens/useSortedTokensByQuery.ts b/apps/evm/src/lib/wagmi/hooks/tokens/useSortedTokensByQuery.ts similarity index 100% rename from packages/wagmi/src/hooks/tokens/useSortedTokensByQuery.ts rename to apps/evm/src/lib/wagmi/hooks/tokens/useSortedTokensByQuery.ts diff --git a/packages/wagmi/src/hooks/tokens/useTokenWithCache.ts b/apps/evm/src/lib/wagmi/hooks/tokens/useTokenWithCache.ts similarity index 100% rename from packages/wagmi/src/hooks/tokens/useTokenWithCache.ts rename to apps/evm/src/lib/wagmi/hooks/tokens/useTokenWithCache.ts diff --git a/packages/wagmi/src/hooks/tokens/useTokens.ts b/apps/evm/src/lib/wagmi/hooks/tokens/useTokens.ts similarity index 100% rename from packages/wagmi/src/hooks/tokens/useTokens.ts rename to apps/evm/src/lib/wagmi/hooks/tokens/useTokens.ts diff --git a/packages/wagmi/src/hooks/tokens/useTotalSupply.ts b/apps/evm/src/lib/wagmi/hooks/tokens/useTotalSupply.ts similarity index 100% rename from packages/wagmi/src/hooks/tokens/useTotalSupply.ts rename to apps/evm/src/lib/wagmi/hooks/tokens/useTotalSupply.ts diff --git a/packages/wagmi/src/hooks/trade/use-client-trade.ts b/apps/evm/src/lib/wagmi/hooks/trade/use-client-trade.ts similarity index 99% rename from packages/wagmi/src/hooks/trade/use-client-trade.ts rename to apps/evm/src/lib/wagmi/hooks/trade/use-client-trade.ts index 16712b95b1..fca842e051 100644 --- a/packages/wagmi/src/hooks/trade/use-client-trade.ts +++ b/apps/evm/src/lib/wagmi/hooks/trade/use-client-trade.ts @@ -17,7 +17,7 @@ import { Fraction, Percent } from 'sushi/math' import { Router } from 'sushi/router' import { Address, Hex, zeroAddress } from 'viem' import { useGasPrice } from 'wagmi' -import { usePoolsCodeMap } from '../pools' +import { usePoolsCodeMap } from '../pools/hooks/usePoolsCodeMap' export const useClientTrade = (variables: UseTradeParams) => { const { diff --git a/packages/wagmi/src/hooks/utils/hooks/useTransactionDeadline.ts b/apps/evm/src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline.ts similarity index 94% rename from packages/wagmi/src/hooks/utils/hooks/useTransactionDeadline.ts rename to apps/evm/src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline.ts index dce1c96283..67f73c4dd2 100644 --- a/packages/wagmi/src/hooks/utils/hooks/useTransactionDeadline.ts +++ b/apps/evm/src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline.ts @@ -1,7 +1,7 @@ import { TTLStorageKey, useTTL } from '@sushiswap/hooks' import { useQuery } from '@tanstack/react-query' import { ChainId, chainsL2 } from 'sushi/chain' -import { useCurrentBlockTimestamp } from '../../block' +import { useCurrentBlockTimestamp } from '../../block/useCurrentBlockTimestamp' const L2_TTL = 5n const TTL = 30n diff --git a/packages/wagmi/src/hooks/wallet/useConnect.ts b/apps/evm/src/lib/wagmi/hooks/wallet/useConnect.ts similarity index 100% rename from packages/wagmi/src/hooks/wallet/useConnect.ts rename to apps/evm/src/lib/wagmi/hooks/wallet/useConnect.ts diff --git a/packages/wagmi/src/hooks/wallet/useWalletState.ts b/apps/evm/src/lib/wagmi/hooks/wallet/useWalletState.ts similarity index 100% rename from packages/wagmi/src/hooks/wallet/useWalletState.ts rename to apps/evm/src/lib/wagmi/hooks/wallet/useWalletState.ts diff --git a/packages/wagmi/src/hooks/watch/useWatchByBlock.ts b/apps/evm/src/lib/wagmi/hooks/watch/useWatchByBlock.ts similarity index 100% rename from packages/wagmi/src/hooks/watch/useWatchByBlock.ts rename to apps/evm/src/lib/wagmi/hooks/watch/useWatchByBlock.ts diff --git a/packages/wagmi/src/hooks/watch/useWatchByInterval.ts b/apps/evm/src/lib/wagmi/hooks/watch/useWatchByInterval.ts similarity index 100% rename from packages/wagmi/src/hooks/watch/useWatchByInterval.ts rename to apps/evm/src/lib/wagmi/hooks/watch/useWatchByInterval.ts diff --git a/apps/evm/src/lib/wagmi/index.ts b/apps/evm/src/lib/wagmi/index.ts index 4b64f3c732..51272cd40a 100644 --- a/apps/evm/src/lib/wagmi/index.ts +++ b/apps/evm/src/lib/wagmi/index.ts @@ -1,27 +1,7 @@ import { PublicWagmiConfig } from '@sushiswap/wagmi-config' -import { cookieToInitialState } from '@wagmi/core' -import { createProductionConfig } from './production' -import { createTestConfig } from './test' -export { createProductionConfig } -export { createTestConfig } - -export const wagmiConfig = (() => { - const isTest = process.env.NEXT_PUBLIC_APP_ENV === 'test' - - const config = (() => { - if (isTest) { - return createTestConfig() as unknown as PublicWagmiConfig - } - return createProductionConfig() - })() - - return config -})() - -export const getWagmiInitialState = ( - cookieHeaders: string | null | undefined, -) => { - const initialState = cookieToInitialState(wagmiConfig, cookieHeaders) - return initialState +declare module 'wagmi' { + interface Register { + config: PublicWagmiConfig + } } diff --git a/packages/wagmi/src/systems/Checker/Amounts.tsx b/apps/evm/src/lib/wagmi/systems/Checker/Amounts.tsx similarity index 93% rename from packages/wagmi/src/systems/Checker/Amounts.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/Amounts.tsx index f47c681886..92f0fe2736 100644 --- a/packages/wagmi/src/systems/Checker/Amounts.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/Amounts.tsx @@ -1,14 +1,13 @@ 'use client' -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import { FC, useMemo } from 'react' import { ChainId } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' import { ZERO } from 'sushi/math' import { zeroAddress } from 'viem' import { useAccount } from 'wagmi' - -import { useBalancesWeb3 } from '../../hooks/balances' +import { useBalancesWeb3 } from '../../hooks/balances/useBalancesWeb3' interface AmountsProps extends ButtonProps { chainId: ChainId | undefined diff --git a/packages/wagmi/src/systems/Checker/ApproveBentobox.tsx b/apps/evm/src/lib/wagmi/systems/Checker/ApproveBentobox.tsx similarity index 90% rename from packages/wagmi/src/systems/Checker/ApproveBentobox.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/ApproveBentobox.tsx index 48e94bdf34..73271df268 100644 --- a/packages/wagmi/src/systems/Checker/ApproveBentobox.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/ApproveBentobox.tsx @@ -10,12 +10,12 @@ import { HoverCardTrigger, LinkExternal, } from '@sushiswap/ui' -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import { FC } from 'react' import { BentoBoxChainId } from 'sushi/config' import { Address } from 'viem' - -import { ApprovalState, useBentoBoxApproval } from '../../hooks' +import { ApprovalState } from '../../hooks/approvals/hooks/useTokenApproval' +import { useBentoBoxApproval } from '../../hooks/bentobox/hooks/useBentoBoxApproval' interface ApproveBentoboxProps extends ButtonProps { chainId: BentoBoxChainId diff --git a/packages/wagmi/src/systems/Checker/ApproveERC20.tsx b/apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20.tsx similarity index 90% rename from packages/wagmi/src/systems/Checker/ApproveERC20.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20.tsx index c1c0130b97..af07d2d285 100644 --- a/packages/wagmi/src/systems/Checker/ApproveERC20.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20.tsx @@ -12,18 +12,21 @@ import { LinkExternal, classNames, } from '@sushiswap/ui' -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import { Select, SelectContent, SelectItem, SelectPrimitive, -} from '@sushiswap/ui/components/select' +} from '@sushiswap/ui' import { FC, useState } from 'react' import { Amount, Type } from 'sushi/currency' import { Address } from 'viem' -import { ApprovalState, useTokenApproval } from '../../hooks' +import { + ApprovalState, + useTokenApproval, +} from '../../hooks/approvals/hooks/useTokenApproval' interface ApproveERC20Props extends ButtonProps { id: string @@ -119,8 +122,9 @@ const ApproveERC20: FC = ({
Approve one-time only - You'll give your approval to spend {amount?.toSignificant(6)}{' '} - {amount?.currency?.symbol} on your behalf + {`You'll give your approval to spend `} + {amount?.toSignificant(6)} {amount?.currency?.symbol} on your + behalf
@@ -128,7 +132,7 @@ const ApproveERC20: FC = ({
Approve unlimited amount - You won't need to approve again next time you want to spend{' '} + {`You won't need to approve again next time you want to spend`}{' '} {amount?.currency?.symbol}.
diff --git a/packages/wagmi/src/systems/Checker/ApproveERC20Multiple.tsx b/apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20Multiple.tsx similarity index 95% rename from packages/wagmi/src/systems/Checker/ApproveERC20Multiple.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20Multiple.tsx index 2be79c8d88..bf6cf2d6ef 100644 --- a/packages/wagmi/src/systems/Checker/ApproveERC20Multiple.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20Multiple.tsx @@ -1,6 +1,6 @@ 'use client' -import { ButtonProps } from '@sushiswap/ui/components/button' +import { ButtonProps } from '@sushiswap/ui' import { FC } from 'react' import { Amount, Type } from 'sushi/currency' diff --git a/packages/wagmi/src/systems/Checker/ApproveERC20WithPermit.tsx b/apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20WithPermit.tsx similarity index 92% rename from packages/wagmi/src/systems/Checker/ApproveERC20WithPermit.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20WithPermit.tsx index c4756b9ed7..72aac1538d 100644 --- a/packages/wagmi/src/systems/Checker/ApproveERC20WithPermit.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/ApproveERC20WithPermit.tsx @@ -12,13 +12,13 @@ import { LinkExternal, classNames, } from '@sushiswap/ui' -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import { Select, SelectContent, SelectItem, SelectPrimitive, -} from '@sushiswap/ui/components/select' +} from '@sushiswap/ui' import { FC, useEffect, useState } from 'react' import { Amount, Type } from 'sushi/currency' @@ -27,10 +27,12 @@ import { Address } from 'viem' import { useAccount, useBytecode } from 'wagmi' import { ApprovalState, - PermitInfo, useTokenApproval, +} from '../../hooks/approvals/hooks/useTokenApproval' +import { + PermitInfo, useTokenPermit, -} from '../../hooks' +} from '../../hooks/approvals/hooks/useTokenPermit' import { useApprovedActions } from './Provider' enum ApprovalType { @@ -197,11 +199,12 @@ const ApproveERC20WithPermit: FC = ({ value={ApprovalType.Approve} testdata-id={'approval-type-approve-button'} > -
+
Approve one-time only - You'll give your approval to spend {amount?.toSignificant(6)}{' '} - {amount?.currency?.symbol} on your behalf + {`You'll give your approval to spend `} + {amount?.toSignificant(6)} {amount?.currency?.symbol} on your + behalf
@@ -212,7 +215,7 @@ const ApproveERC20WithPermit: FC = ({
Approve unlimited amount - You won't need to approve again next time you want to spend{' '} + {`You won't need to approve again next time you want to spend`}{' '} {amount?.currency?.symbol}.
diff --git a/packages/wagmi/src/systems/Checker/Connect.tsx b/apps/evm/src/lib/wagmi/systems/Checker/Connect.tsx similarity index 88% rename from packages/wagmi/src/systems/Checker/Connect.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/Connect.tsx index dd47aecb9a..555d6ceafb 100644 --- a/packages/wagmi/src/systems/Checker/Connect.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/Connect.tsx @@ -1,13 +1,13 @@ 'use client' -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import { FC } from 'react' import { useAccount } from 'wagmi' import { Dots } from '@sushiswap/ui' import { useIsMounted } from '@sushiswap/hooks' -import { ConnectButton } from '../../components' +import { ConnectButton } from '../../components/connect-button' const Connect: FC = ({ children, diff --git a/packages/wagmi/src/systems/Checker/Custom.tsx b/apps/evm/src/lib/wagmi/systems/Checker/Custom.tsx similarity index 87% rename from packages/wagmi/src/systems/Checker/Custom.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/Custom.tsx index 669285b6df..1857b48cc2 100644 --- a/packages/wagmi/src/systems/Checker/Custom.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/Custom.tsx @@ -1,4 +1,4 @@ -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import React, { FC } from 'react' interface CustomProps extends ButtonProps { diff --git a/packages/wagmi/src/systems/Checker/Guard.tsx b/apps/evm/src/lib/wagmi/systems/Checker/Guard.tsx similarity index 86% rename from packages/wagmi/src/systems/Checker/Guard.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/Guard.tsx index 052d95e950..3bbeee3eea 100644 --- a/packages/wagmi/src/systems/Checker/Guard.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/Guard.tsx @@ -1,4 +1,4 @@ -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import React, { FC } from 'react' interface GuardProps extends ButtonProps { diff --git a/packages/wagmi/src/systems/Checker/Network.tsx b/apps/evm/src/lib/wagmi/systems/Checker/Network.tsx similarity index 95% rename from packages/wagmi/src/systems/Checker/Network.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/Network.tsx index bd1043a1bd..3b842283ec 100644 --- a/packages/wagmi/src/systems/Checker/Network.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/Network.tsx @@ -2,7 +2,7 @@ import { InformationCircleIcon } from '@heroicons/react/24/solid' import { HoverCard, HoverCardContent, HoverCardTrigger } from '@sushiswap/ui' -import { Button, ButtonProps } from '@sushiswap/ui/components/button' +import { Button, ButtonProps } from '@sushiswap/ui' import { FC, ReactElement, ReactNode } from 'react' import { ChainId, chainName } from 'sushi/chain' import { useAccount, useSwitchChain } from 'wagmi' diff --git a/packages/wagmi/src/systems/Checker/Provider.tsx b/apps/evm/src/lib/wagmi/systems/Checker/Provider.tsx similarity index 98% rename from packages/wagmi/src/systems/Checker/Provider.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/Provider.tsx index c21862e38c..cd6ed712ce 100644 --- a/packages/wagmi/src/systems/Checker/Provider.tsx +++ b/apps/evm/src/lib/wagmi/systems/Checker/Provider.tsx @@ -72,7 +72,6 @@ const CheckerProvider: FC = ({ children }) => { // Reset state when address/wallet changes useEffect(() => { - console.log('reset state', initialState) const unwatchAccountListener = watchAccount(config, { onChange: () => setState(initialState), }) diff --git a/packages/wagmi/src/systems/Checker/Success.tsx b/apps/evm/src/lib/wagmi/systems/Checker/Success.tsx similarity index 100% rename from packages/wagmi/src/systems/Checker/Success.tsx rename to apps/evm/src/lib/wagmi/systems/Checker/Success.tsx diff --git a/packages/wagmi/src/systems/Checker/index.ts b/apps/evm/src/lib/wagmi/systems/Checker/index.ts similarity index 95% rename from packages/wagmi/src/systems/Checker/index.ts rename to apps/evm/src/lib/wagmi/systems/Checker/index.ts index a59f96fd1b..96aa83eed7 100644 --- a/packages/wagmi/src/systems/Checker/index.ts +++ b/apps/evm/src/lib/wagmi/systems/Checker/index.ts @@ -1,4 +1,4 @@ -import { ButtonProps } from '@sushiswap/ui/components/button' +import { ButtonProps } from '@sushiswap/ui' import { ComponentType, FC } from 'react' import { Amounts, AmountsProps } from './Amounts' diff --git a/apps/evm/src/lib/wagmi/systems/PoolFinder/ComponentsWrapper.tsx b/apps/evm/src/lib/wagmi/systems/PoolFinder/ComponentsWrapper.tsx new file mode 100644 index 0000000000..d4095eff38 --- /dev/null +++ b/apps/evm/src/lib/wagmi/systems/PoolFinder/ComponentsWrapper.tsx @@ -0,0 +1,9 @@ +import React, { FC } from 'react' + +import { ComponentsWrapperProps, SushiSwapV2PoolFinderProps } from './types' + +export const ComponentsWrapper: FC< + ComponentsWrapperProps +> = ({ children }) => { + return <>{children} +} diff --git a/packages/wagmi/src/systems/PoolFinder/PoolFinder.tsx b/apps/evm/src/lib/wagmi/systems/PoolFinder/PoolFinder.tsx similarity index 77% rename from packages/wagmi/src/systems/PoolFinder/PoolFinder.tsx rename to apps/evm/src/lib/wagmi/systems/PoolFinder/PoolFinder.tsx index 57df47ab95..6352e636f9 100644 --- a/packages/wagmi/src/systems/PoolFinder/PoolFinder.tsx +++ b/apps/evm/src/lib/wagmi/systems/PoolFinder/PoolFinder.tsx @@ -9,23 +9,18 @@ import { useReducer, } from 'react' -import { SushiSwapV2PoolState } from '../../hooks' +import { SushiSwapV2PoolState } from '../../hooks/pools/hooks/useSushiSwapV2Pools' import { ComponentsWrapper } from './ComponentsWrapper' import { SushiSwapV2Pool } from './SushiSwapV2Pool' -import { TridentConstantPool } from './TridentConstantPool' -import { TridentStablePool } from './TridentStablePool' import { ComponentsWrapperProps, PoolExistenceStateAction, PoolStateUnion, SushiSwapV2PoolFinderProps, - TridentPoolFinderProps, } from './types' interface Props { - components: ReactElement< - ComponentsWrapperProps - > + components: ReactElement> children({ pool }: { pool: PoolStateUnion }): ReactNode } @@ -74,11 +69,7 @@ const Controller: FC = ({ components, children }) => { export const PoolFinder: typeof Controller & { Components: typeof ComponentsWrapper SushiSwapV2Pool: typeof SushiSwapV2Pool - TridentConstantPool: typeof TridentConstantPool - TridentStablePool: typeof TridentStablePool } = Object.assign(Controller, { Components: ComponentsWrapper, SushiSwapV2Pool, - TridentConstantPool, - TridentStablePool, }) diff --git a/packages/wagmi/src/systems/PoolFinder/SushiSwapV2Pool.tsx b/apps/evm/src/lib/wagmi/systems/PoolFinder/SushiSwapV2Pool.tsx similarity index 87% rename from packages/wagmi/src/systems/PoolFinder/SushiSwapV2Pool.tsx rename to apps/evm/src/lib/wagmi/systems/PoolFinder/SushiSwapV2Pool.tsx index beb5588ecb..0ec5912ff1 100644 --- a/packages/wagmi/src/systems/PoolFinder/SushiSwapV2Pool.tsx +++ b/apps/evm/src/lib/wagmi/systems/PoolFinder/SushiSwapV2Pool.tsx @@ -1,6 +1,6 @@ import { FC, useEffect } from 'react' -import { useSushiSwapV2Pool } from '../../hooks' +import { useSushiSwapV2Pool } from '../../hooks/pools/hooks/useSushiSwapV2Pools' import { PoolFinderType, SushiSwapV2PoolFinderProps } from './types' export const SushiSwapV2Pool: FC = ({ diff --git a/packages/wagmi/src/systems/PoolFinder/types.ts b/apps/evm/src/lib/wagmi/systems/PoolFinder/types.ts similarity index 61% rename from packages/wagmi/src/systems/PoolFinder/types.ts rename to apps/evm/src/lib/wagmi/systems/PoolFinder/types.ts index e1153cca14..e5c29f2d8a 100644 --- a/packages/wagmi/src/systems/PoolFinder/types.ts +++ b/apps/evm/src/lib/wagmi/systems/PoolFinder/types.ts @@ -1,18 +1,8 @@ import { ReactElement } from 'react' -import { SushiSwapV2ChainId, TridentChainId } from 'sushi/config' +import { SushiSwapV2ChainId } from 'sushi/config' import { Type } from 'sushi/currency' -import { Fee } from 'sushi/dex' -import { - SushiSwapV2Pool, - TridentConstantPool, - TridentStablePool, -} from 'sushi/pool' - -import { - SushiSwapV2PoolState, - TridentConstantPoolState, - TridentStablePoolState, -} from '../../hooks' +import { SushiSwapV2Pool } from 'sushi/pool/sushiswap-v2' +import { SushiSwapV2PoolState } from '../../hooks/pools/hooks/useSushiSwapV2Pools' export type ComponentsWrapperProps = { children: @@ -39,16 +29,7 @@ export interface SushiSwapV2PoolFinderProps extends PoolFinderProps { enabled: boolean } -export interface TridentPoolFinderProps extends PoolFinderProps { - chainId: TridentChainId - fee?: Fee - twap?: boolean -} - -export type PoolStateUnion = [ - SushiSwapV2PoolState | TridentConstantPoolState | TridentStablePoolState, - SushiSwapV2Pool | TridentConstantPool | TridentStablePool | null, -] +export type PoolStateUnion = [SushiSwapV2PoolState, SushiSwapV2Pool | null] export enum PoolFinderType { Classic = 'Classic', diff --git a/apps/evm/src/providers/wagmi-provider.tsx b/apps/evm/src/providers/wagmi-provider.tsx index 7f006b3f73..93a1643523 100644 --- a/apps/evm/src/providers/wagmi-provider.tsx +++ b/apps/evm/src/providers/wagmi-provider.tsx @@ -1,14 +1,9 @@ 'use client' -import { - State, - WagmiProvider, - // getChainId, - // switchChain, - // watchChainId, -} from '@sushiswap/wagmi' import { type FC, type ReactNode } from 'react' -import { wagmiConfig } from 'src/lib/wagmi' +import { wagmiConfig } from 'src/lib/wagmi/config' +import { State } from 'wagmi' +import { WagmiProvider } from 'wagmi' // import { type ChainId } from 'sushi' export const WagmiConfig: FC<{ diff --git a/apps/evm/src/types/window.d.ts b/apps/evm/src/types/global.d.ts similarity index 100% rename from apps/evm/src/types/window.d.ts rename to apps/evm/src/types/global.d.ts diff --git a/apps/evm/src/types/index.ts b/apps/evm/src/types/index.ts index e8b0db0f75..09c94761e8 100644 --- a/apps/evm/src/types/index.ts +++ b/apps/evm/src/types/index.ts @@ -8,10 +8,3 @@ export type SwapChainId = | TridentChainId | SushiSwapV2ChainId | SushiSwapV3ChainId - -import { Pool } from '@sushiswap/client' -import { UserPosition } from '@sushiswap/graph-client' - -export interface PositionWithPool extends Omit { - pool: Pool -} diff --git a/apps/evm/src/ui/analytics/furo-token-table.tsx b/apps/evm/src/ui/analytics/furo-token-table.tsx index 5db697243e..06f9089488 100644 --- a/apps/evm/src/ui/analytics/furo-token-table.tsx +++ b/apps/evm/src/ui/analytics/furo-token-table.tsx @@ -15,6 +15,7 @@ import { ColumnDef, PaginationState, SortingState } from '@tanstack/react-table' import React, { FC, useMemo, useState } from 'react' import { formatNumber, formatUSD } from 'sushi/format' +import { isFuroChainId } from 'sushi/config' import { FuroToken, GetFuroTokenArgs, @@ -94,7 +95,7 @@ export const FuroTokenTable: FC = () => { const args = useMemo( () => ({ - chainIds, + chainIds: chainIds.filter(isFuroChainId), tokenSymbols, }), [chainIds, tokenSymbols], diff --git a/apps/evm/src/ui/analytics/token-page-header.tsx b/apps/evm/src/ui/analytics/token-page-header.tsx index 21070c81a0..23f67ee4c6 100644 --- a/apps/evm/src/ui/analytics/token-page-header.tsx +++ b/apps/evm/src/ui/analytics/token-page-header.tsx @@ -1,59 +1,59 @@ -'use client' +// 'use client' -import { Bundle, Token as GraphToken } from '@sushiswap/graph-client' -import { Button } from '@sushiswap/ui/components/button' -import { Chip } from '@sushiswap/ui/components/chip' -import { Currency } from '@sushiswap/ui/components/currency' -import { useRouter } from 'next/router' -import { FC } from 'react' -import { formatUSD } from 'sushi/format' -import useSWR from 'swr' -import { getAddress } from 'viem' +// import { Bundle, Token as GraphToken } from '@sushiswap/graph-client' +// import { Button } from '@sushiswap/ui' +// import { Chip } from '@sushiswap/ui' +// import { Currency } from '@sushiswap/ui' +// import { useRouter } from 'next/router' +// import { FC } from 'react' +// import { formatUSD } from 'sushi/format' +// import useSWR from 'swr' +// import { getAddress } from 'viem' -import { useTokenFromToken } from '../../lib/hooks/useTokenFromToken' +// import { useTokenFromToken } from '../../lib/hooks/useTokenFromToken' -interface TokenHeader { - token: GraphToken -} -export const TokenHeader: FC = ({ token }) => { - const router = useRouter() - const _token = useTokenFromToken(token) - const { data: bundles } = useSWR('/analytics/api/bundles', (url) => - fetch(url).then((response) => response.json()), - ) +// interface TokenHeader { +// token: GraphToken +// } +// export const TokenHeader: FC = ({ token }) => { +// const router = useRouter() +// const _token = useTokenFromToken(token) +// const { data: bundles } = useSWR('/analytics/api/bundles', (url) => +// fetch(url).then((response) => response.json()), +// ) - const price = formatUSD( - token.price.derivedNative * bundles?.[token.chainId]?.nativePrice, - ) +// const price = formatUSD( +// token.derivedETH * bundles?.[token.chainId]?.ethPrice, +// ) - return ( -
-
-
-
- -
- - {_token.name} - - {_token.symbol} -
- - {price.includes('NaN') ? '$0.00' : price} - -
- -
- ) -} +// return ( +//
+//
+//
+//
+// +//
+// +// {_token.name} +// +// {_token.symbol} +//
+// +// {price.includes('NaN') ? '$0.00' : price} +// +//
+// +//
+// ) +// } diff --git a/apps/evm/src/ui/analytics/token-page-information.tsx b/apps/evm/src/ui/analytics/token-page-information.tsx index f048bcb777..b092859fd6 100644 --- a/apps/evm/src/ui/analytics/token-page-information.tsx +++ b/apps/evm/src/ui/analytics/token-page-information.tsx @@ -1,89 +1,89 @@ -'use client' +// 'use client' -import { ExternalLinkIcon } from '@heroicons/react-v1/solid' -import { Token as GraphToken } from '@sushiswap/graph-client' -import { ClipboardController, LinkExternal } from '@sushiswap/ui' -import { Currency } from '@sushiswap/ui/components/currency' -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from '@sushiswap/ui/components/table' -import { FC } from 'react' -import { Chain } from 'sushi/chain' -import { shortenAddress } from 'sushi/format' +// import { ExternalLinkIcon } from '@heroicons/react-v1/solid' +// import { Token as GraphToken } from '@sushiswap/graph-client' +// import { ClipboardController, LinkExternal } from '@sushiswap/ui' +// import { Currency } from '@sushiswap/ui' +// import { +// Table, +// TableBody, +// TableCell, +// TableHead, +// TableHeader, +// TableRow, +// } from '@sushiswap/ui' +// import { FC } from 'react' +// import { Chain } from 'sushi/chain' +// import { shortenAddress } from 'sushi/format' -import { useTokenFromToken } from '../../lib/hooks/useTokenFromToken' +// import { useTokenFromToken } from '../../lib/hooks/useTokenFromToken' -interface TokenInformation { - token: GraphToken -} +// interface TokenInformation { +// token: GraphToken +// } -export const TokenInformation: FC = ({ token }) => { - const _token = useTokenFromToken(token) - const chain = Chain.from(_token.chainId) as Chain +// export const TokenInformation: FC = ({ token }) => { +// const _token = useTokenFromToken(token) +// const chain = Chain.from(_token.chainId) as Chain - return ( -
-

Token Information

- - - -
Symbol
-
- -
Name
-
- -
Address
-
- -
Action
-
-
- - - -

- {_token.symbol} -

-
- -
- -

- {_token.name} -

-
-
- - - {({ setCopied }) => ( - setCopied(_token.wrapped.address)} - onKeyDown={() => setCopied(_token.wrapped.address)} - className="text-sm font-medium" - > - {shortenAddress(_token.wrapped.address)} - - )} - - - - -

View

- -
-
-
-
-
-
- ) -} +// return ( +//
+//

Token Information

+// +// +// +//
Symbol
+//
+// +//
Name
+//
+// +//
Address
+//
+// +//
Action
+//
+//
+// +// +// +//

+// {_token.symbol} +//

+//
+// +//
+// +//

+// {_token.name} +//

+//
+//
+// +// +// {({ setCopied }) => ( +// setCopied(_token.wrapped.address)} +// onKeyDown={() => setCopied(_token.wrapped.address)} +// className="text-sm font-medium" +// > +// {shortenAddress(_token.wrapped.address)} +// +// )} +// +// +// +// +//

View

+// +//
+//
+//
+//
+//
+//
+// ) +// } diff --git a/apps/evm/src/ui/analytics/token-page-pairs.tsx b/apps/evm/src/ui/analytics/token-page-pairs.tsx index cead27c647..1852a9db27 100644 --- a/apps/evm/src/ui/analytics/token-page-pairs.tsx +++ b/apps/evm/src/ui/analytics/token-page-pairs.tsx @@ -1,140 +1,140 @@ -'use client' +// 'use client' -import { usePools } from '@sushiswap/client/hooks' -import { Token as GraphToken } from '@sushiswap/graph-client' -import { LinkExternal, LinkInternal } from '@sushiswap/ui' -import { Currency } from '@sushiswap/ui/components/currency' -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from '@sushiswap/ui/components/table' -import React, { FC } from 'react' -import chains from 'sushi/chain' -import { Native, Token } from 'sushi/currency' -import { formatPercent, formatUSD } from 'sushi/format' -import { useSWRConfig } from 'swr' +// import { usePools } from '@sushiswap/client/hooks' +// import { Token as GraphToken } from '@sushiswap/graph-client' +// import { LinkExternal, LinkInternal } from '@sushiswap/ui' +// import { Currency } from '@sushiswap/ui' +// import { +// Table, +// TableBody, +// TableCell, +// TableHead, +// TableHeader, +// TableRow, +// } from '@sushiswap/ui' +// import React, { FC } from 'react' +// import chains from 'sushi/chain' +// import { Native, Token } from 'sushi/currency' +// import { formatPercent, formatUSD } from 'sushi/format' +// import { useSWRConfig } from 'swr' -interface TokenPairs { - token: GraphToken -} +// interface TokenPairs { +// token: GraphToken +// } -export const TokenPairs: FC = ({ token }) => { - const { data: pools } = usePools({ - args: { ids: token.pairs.map(({ pair }) => pair.id) }, - swrConfig: useSWRConfig(), - }) +// export const TokenPairs: FC = ({ token }) => { +// const { data: pools } = usePools({ +// args: { ids: [...token.pairBase.map(({ pair }) => pair.id), ...token.pairQuote.map(({ pair }) => pair.id)] }, +// swrConfig: useSWRConfig(), +// }) - return ( -
-

Trending Pairs

- - - -
Name
-
- -
TVL
-
- -
Volume (7d)
-
- -
APY
-
-
- - {pools && - token.pairs.map(({ pair }, i) => { - const _pool = pools.find((pool) => pool.id === pair.id) +// return ( +//
+//

Trending Pairs

+//
+// +// +//
Name
+//
+// +//
TVL
+//
+// +//
Volume (7d)
+//
+// +//
APY
+//
+//
+// +// {pools && +// token.pairs.map(({ pair }, i) => { +// const _pool = pools.find((pool) => pool.id === pair.id) - const [token0, token1] = [ - pair.token0.id === Native.onChain(token.chainId).wrapped.address - ? Native.onChain(token.chainId) - : new Token({ - address: pair.token0.id, - chainId: pair.chainId, - decimals: Number(pair.token0.decimals), - symbol: pair.token0.symbol, - }), - pair.token1.id === Native.onChain(token.chainId).wrapped.address - ? Native.onChain(token.chainId) - : new Token({ - address: pair.token1.id, - chainId: pair.chainId, - decimals: Number(pair.token1.decimals), - symbol: pair.token1.symbol, - }), - ] +// const [token0, token1] = [ +// pair.token0.id === Native.onChain(token.chainId).wrapped.address +// ? Native.onChain(token.chainId) +// : new Token({ +// address: pair.token0.id, +// chainId: pair.chainId, +// decimals: Number(pair.token0.decimals), +// symbol: pair.token0.symbol, +// }), +// pair.token1.id === Native.onChain(token.chainId).wrapped.address +// ? Native.onChain(token.chainId) +// : new Token({ +// address: pair.token1.id, +// chainId: pair.chainId, +// decimals: Number(pair.token1.decimals), +// symbol: pair.token1.symbol, +// }), +// ] - const liquidityUSD = formatUSD(pair.liquidityUSD) - const volume1w = formatUSD(pair.volume1w) +// const liquidityUSD = formatUSD(pair.liquidityUSD) +// const volume1w = formatUSD(pair.volume1w) - return ( - - - -
- - - - - -

- {token0.symbol}{' '} - /{' '} - {token1.symbol} -

-
-
-
-
- - -

- {liquidityUSD.includes('NaN') ? '$0.00' : liquidityUSD} -

-
-
- - -

- {volume1w.includes('NaN') ? '$0.00' : volume1w} -

-
-
- - -

- {formatPercent(pair.feeApr)}{' '} - {/*{pool && pool.incentives.length > 0 && pool.incentiveApr > 0 && (*/} - {/* */} - {/*)}*/} -

-
-
-
- ) - })} -
-
-
- ) -} +// return ( +// +// +// +//
+// +// +// +// +// +//

+// {token0.symbol}{' '} +// /{' '} +// {token1.symbol} +//

+//
+//
+//
+//
+// +// +//

+// {liquidityUSD.includes('NaN') ? '$0.00' : liquidityUSD} +//

+//
+//
+// +// +//

+// {volume1w.includes('NaN') ? '$0.00' : volume1w} +//

+//
+//
+// +// +//

+// {formatPercent(pair.feeApr)}{' '} +// {/*{pool && pool.incentives.length > 0 && pool.incentiveApr > 0 && (*/} +// {/* */} +// {/*)}*/} +//

+//
+//
+//
+// ) +// })} +// +// +//
+// ) +// } diff --git a/apps/evm/src/ui/analytics/token-page-stats.tsx b/apps/evm/src/ui/analytics/token-page-stats.tsx index bffbd20fe1..38228a739a 100644 --- a/apps/evm/src/ui/analytics/token-page-stats.tsx +++ b/apps/evm/src/ui/analytics/token-page-stats.tsx @@ -1,42 +1,42 @@ -import { Token as GraphToken } from '@sushiswap/graph-client' -import { FC } from 'react' -import { formatUSD } from 'sushi/format' +// import { Token as GraphToken } from '@sushiswap/graph-client' +// import { FC } from 'react' +// import { formatUSD } from 'sushi/format' -interface TokenStatsProps { - token: GraphToken -} +// interface TokenStatsProps { +// token: GraphToken +// } -export const TokenStats: FC = ({ token }) => { - const tvl = formatUSD(token.liquidityUSD) - const volume = formatUSD(token.volumeUSD) - const fees = formatUSD(token.feesUSD) +// export const TokenStats: FC = ({ token }) => { +// const tvl = formatUSD(token.liquidityUSD) +// const volume = formatUSD(token.volumeUSD) +// const fees = formatUSD(token.feesUSD) - return ( -
-
-

Liquidity

-

- {tvl.includes('NaN') ? '$0.00' : tvl} -

-
-
-

Volume

-

- {volume.includes('NaN') ? '$0.00' : volume} -

-
-
-

Fees

-

- {fees.includes('NaN') ? '$0.00' : fees} -

-
-
-

Market Cap

-

- {fees.includes('NaN') ? '$0.00' : fees} -

-
-
- ) -} +// return ( +//
+//
+//

Liquidity

+//

+// {tvl.includes('NaN') ? '$0.00' : tvl} +//

+//
+//
+//

Volume

+//

+// {volume.includes('NaN') ? '$0.00' : volume} +//

+//
+//
+//

Fees

+//

+// {fees.includes('NaN') ? '$0.00' : fees} +//

+//
+//
+//

Market Cap

+//

+// {fees.includes('NaN') ? '$0.00' : fees} +//

+//
+//
+// ) +// } diff --git a/apps/evm/src/ui/analytics/tvl-chart.tsx b/apps/evm/src/ui/analytics/tvl-chart.tsx index d56cefaf01..e06c05cb58 100644 --- a/apps/evm/src/ui/analytics/tvl-chart.tsx +++ b/apps/evm/src/ui/analytics/tvl-chart.tsx @@ -11,13 +11,20 @@ import { classNames, } from '@sushiswap/ui' import { format } from 'date-fns' -import ReactECharts from 'echarts-for-react' -import { EChartsOption } from 'echarts-for-react/lib/types' import { FC, useCallback, useMemo, useState } from 'react' import { formatUSD } from 'sushi/format' import tailwindConfig from 'tailwind.config.js' import resolveConfig from 'tailwindcss/resolveConfig' +import ReactEchartsCore from 'echarts-for-react' +import { EChartsOption } from 'echarts-for-react/lib/types' +import 'echarts/lib/chart/bar' +import 'echarts/lib/chart/line' +import 'echarts/lib/component/tooltip' +import 'echarts/lib/component/visualMap' +import echarts from 'echarts/lib/echarts' +import 'echarts/lib/visual/seriesColor' + const tailwind = resolveConfig(tailwindConfig) enum TvlChartPeriod { @@ -81,6 +88,11 @@ export const TVLChart: FC<{ x: number[]; y: number[] }> = ({ x, y }) => { fontSize: 12, fontWeight: 600, }, + axisPointer: { + lineStyle: { + type: 'dashed', + }, + }, formatter: (params: any) => { onMouseOver({ name: params[0].name, value: params[0].value }) @@ -246,7 +258,11 @@ export const TVLChart: FC<{ x: number[]; y: number[] }> = ({ x, y }) => { {xData ? ( - + ) : ( = ({ x, y }) => { fontSize: 12, fontWeight: 600, }, + axisPointer: { + lineStyle: { + type: 'dashed', + }, + }, formatter: (params: any) => { onMouseOver({ name: params[0].name, value: params[0].value }) @@ -143,6 +148,7 @@ export const VolumeChart: FC<{ x: number[]; y: number[] }> = ({ x, y }) => { type: 'bar', xAxisIndex: 0, yAxisIndex: 0, + barWidth: '70%', itemStyle: { color: 'blue', normal: { diff --git a/apps/evm/src/ui/bonds/bonds-buy-review-modal.tsx b/apps/evm/src/ui/bonds/bonds-buy-review-modal.tsx index 010cd5ff2f..31937086d5 100644 --- a/apps/evm/src/ui/bonds/bonds-buy-review-modal.tsx +++ b/apps/evm/src/ui/bonds/bonds-buy-review-modal.tsx @@ -19,19 +19,12 @@ import { createErrorToast, createToast, } from '@sushiswap/ui' -import { - UseSimulateContractParameters, - usePublicClient, - useSimulateContract, - useWriteContract, -} from '@sushiswap/wagmi' -import { useAccount, useWaitForTransactionReceipt } from '@sushiswap/wagmi' -import { useApproved } from '@sushiswap/wagmi/systems/Checker/Provider' import { SendTransactionReturnType } from '@wagmi/core' import format from 'date-fns/format' import formatDistance from 'date-fns/formatDistance' import { FC, ReactNode, useCallback, useMemo } from 'react' import { APPROVE_TAG_BONDS } from 'src/lib/constants' +import { useApproved } from 'src/lib/wagmi/systems/Checker/Provider' import { Percent, formatPercent, @@ -42,6 +35,14 @@ import { import { Chain } from 'sushi/chain' import { Amount, Token } from 'sushi/currency' import { UserRejectedRequestError } from 'viem' +import { + UseSimulateContractParameters, + useAccount, + useSimulateContract, + useWaitForTransactionReceipt, + useWriteContract, +} from 'wagmi' +import { usePublicClient } from 'wagmi' interface BondsBuyReviewModal { bond: Bond diff --git a/apps/evm/src/ui/bonds/bonds-market-details.tsx b/apps/evm/src/ui/bonds/bonds-market-details.tsx index 41333eb557..c6072ac09c 100644 --- a/apps/evm/src/ui/bonds/bonds-market-details.tsx +++ b/apps/evm/src/ui/bonds/bonds-market-details.tsx @@ -16,8 +16,8 @@ import { SkeletonText, Toggle, } from '@sushiswap/ui' -import { useBondMarketDetails } from '@sushiswap/wagmi' import { FC, useMemo, useState } from 'react' +import { useBondMarketDetails } from 'src/lib/wagmi/hooks/bonds/use-bond-market-details' import { Token } from 'sushi/currency' import { formatNumber, formatPercent, formatUSD } from 'sushi/format' diff --git a/apps/evm/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-discount.tsx b/apps/evm/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-discount.tsx index 021de2f387..64e5055e44 100644 --- a/apps/evm/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-discount.tsx +++ b/apps/evm/src/ui/bonds/bonds-market-page-header/bonds-market-page-header-discount.tsx @@ -2,7 +2,7 @@ import { Bond } from '@sushiswap/client' import { SkeletonText, classNames } from '@sushiswap/ui' -import { useBondMarketDetails } from '@sushiswap/wagmi' +import { useBondMarketDetails } from 'src/lib/wagmi/hooks/bonds/use-bond-market-details' import { formatPercent } from 'sushi/format' export const BondsMarketPageHeaderDiscount = ({ bond }: { bond: Bond }) => { diff --git a/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-columns.tsx b/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-columns.tsx index 2fa58bfe06..7adeebce48 100644 --- a/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-columns.tsx +++ b/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-columns.tsx @@ -14,18 +14,11 @@ import { createErrorToast, createToast, } from '@sushiswap/ui' -import { - Checker, - UseSimulateContractParameters, - useAccount, - usePublicClient, - useSimulateContract, - useWriteContract, -} from '@sushiswap/wagmi' import { ColumnDef } from '@tanstack/react-table' import format from 'date-fns/format' import formatDistance from 'date-fns/formatDistance' import { useCallback, useMemo, useState } from 'react' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { Amount, Token } from 'sushi/currency' import { formatUSD } from 'sushi/format' import { @@ -33,6 +26,13 @@ import { SendTransactionReturnType, UserRejectedRequestError, } from 'viem' +import { + type UseSimulateContractParameters, + useAccount, + usePublicClient, + useSimulateContract, + useWriteContract, +} from 'wagmi' export const PAYOUT_ASSET_COLUMN: ColumnDef = { id: 'payout-asset', diff --git a/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks.tsx b/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks.tsx index 4e49a39184..521a62865b 100644 --- a/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks.tsx +++ b/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table-filters/table-positions-filters-networks.tsx @@ -10,13 +10,9 @@ import { PopoverTrigger, Separator, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { - Command, - CommandGroup, - CommandItem, -} from '@sushiswap/ui/components/command' -import { CheckIcon, NetworkIcon } from '@sushiswap/ui/components/icons' +import { Button } from '@sushiswap/ui' +import { Command, CommandGroup, CommandItem } from '@sushiswap/ui' +import { CheckIcon, NetworkIcon } from '@sushiswap/ui' import React, { FC, useCallback, diff --git a/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table.tsx b/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table.tsx index 3335eeeb6d..25deef0247 100644 --- a/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table.tsx +++ b/apps/evm/src/ui/bonds/bonds-positions-table/bonds-positions-table.tsx @@ -9,10 +9,10 @@ import { } from '@sushiswap/client' import { useIsMounted } from '@sushiswap/hooks' import { Card, CardHeader, CardTitle, DataTable } from '@sushiswap/ui' -import { useAccount } from '@sushiswap/wagmi' import { useQuery } from '@tanstack/react-query' import { ColumnDef, PaginationState, SortingState } from '@tanstack/react-table' import React, { FC, useMemo, useState } from 'react' +import { useAccount } from 'wagmi' import { CLAIM_COLUMN, MATURITY_COLUMN, diff --git a/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-auction-type.tsx b/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-auction-type.tsx index bbbf040c9d..aa2284b8bf 100644 --- a/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-auction-type.tsx +++ b/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-auction-type.tsx @@ -16,13 +16,9 @@ import { PopoverTrigger, Separator, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { - Command, - CommandGroup, - CommandItem, -} from '@sushiswap/ui/components/command' -import { CheckIcon } from '@sushiswap/ui/components/icons' +import { Button } from '@sushiswap/ui' +import { Command, CommandGroup, CommandItem } from '@sushiswap/ui' +import { CheckIcon } from '@sushiswap/ui' import React, { FC, useCallback, useState, useTransition } from 'react' import { useBondFilters, useSetBondFilters } from './bonds-filters-provider' diff --git a/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-networks.tsx b/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-networks.tsx index 2926b42876..e0063b5a0f 100644 --- a/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-networks.tsx +++ b/apps/evm/src/ui/bonds/bonds-table/bonds-table-filters/table-filters-networks.tsx @@ -10,13 +10,9 @@ import { PopoverTrigger, Separator, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { - Command, - CommandGroup, - CommandItem, -} from '@sushiswap/ui/components/command' -import { CheckIcon, NetworkIcon } from '@sushiswap/ui/components/icons' +import { Button } from '@sushiswap/ui' +import { Command, CommandGroup, CommandItem } from '@sushiswap/ui' +import { CheckIcon, NetworkIcon } from '@sushiswap/ui' import React, { FC, useCallback, diff --git a/apps/evm/src/ui/bonds/bonds-widget.tsx b/apps/evm/src/ui/bonds/bonds-widget.tsx index 115fd10086..ff321ac226 100644 --- a/apps/evm/src/ui/bonds/bonds-widget.tsx +++ b/apps/evm/src/ui/bonds/bonds-widget.tsx @@ -19,19 +19,17 @@ import { SkeletonText, classNames, } from '@sushiswap/ui' -import { - Checker, - Web3Input, - useBondMarketDetails, - useChainId, -} from '@sushiswap/wagmi' -import { CheckerProvider } from '@sushiswap/wagmi/systems/Checker/Provider' import format from 'date-fns/format' import formatDistance from 'date-fns/formatDistance' import React, { useCallback, useEffect, useMemo, useState } from 'react' import { APPROVE_TAG_BONDS } from 'src/lib/constants' +import { Web3Input } from 'src/lib/wagmi/components/web3-input' +import { useBondMarketDetails } from 'src/lib/wagmi/hooks/bonds/use-bond-market-details' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { CheckerProvider } from 'src/lib/wagmi/systems/Checker/Provider' import { Amount, Token, tryParseAmount } from 'sushi/currency' import { formatPercent } from 'sushi/format' +import { useChainId } from 'wagmi' import { BondsBuyReviewModal } from './bonds-buy-review-modal' const GetTokens = ({ bond }: { bond: Bond }) => { diff --git a/apps/evm/src/ui/pool/APRHoverCard.tsx b/apps/evm/src/ui/pool/APRHoverCard.tsx index 2c1b1c8cf9..6531241210 100644 --- a/apps/evm/src/ui/pool/APRHoverCard.tsx +++ b/apps/evm/src/ui/pool/APRHoverCard.tsx @@ -1,9 +1,5 @@ -'use client' - -import { Pool } from '@sushiswap/client' import { CardDescription, - Currency, HoverCard, HoverCardContent, HoverCardTrigger, @@ -13,15 +9,19 @@ import { Separator, } from '@sushiswap/ui' import { FC, ReactNode } from 'react' -import { ChainId } from 'sushi/chain' -import { tryParseAmount } from 'sushi/currency' import { formatPercent } from 'sushi/format' -import { incentiveRewardToToken } from '../../lib/functions' +import type { + PoolIfIncentivized, + PoolWithFeeAprs, + PoolWithIncentiveApr, +} from 'sushi' + +type RequiredPool = PoolIfIncentivized> interface APRHoverCardProps { children: ReactNode - pool: Pool + pool: RequiredPool showEmissions?: boolean smartPoolAPR?: number } @@ -29,16 +29,12 @@ interface APRHoverCardProps { export const APRHoverCard: FC = ({ children, pool, - showEmissions = true, smartPoolAPR, }) => { - const totalAPR = - (typeof smartPoolAPR === 'number' - ? smartPoolAPR * 100 - : pool.feeApr1d * 100) + - pool.incentives - .filter((el) => +el.rewardPerDay > 0) - .reduce((acc, cur) => acc + cur.apr * 100, 0) + const feeApr1d = + typeof smartPoolAPR === 'number' ? smartPoolAPR : pool.feeApr1d + + const totalAPR = (feeApr1d + pool.incentiveApr) * 100 const card = ( <> @@ -78,33 +74,6 @@ export const APRHoverCard: FC = ({ {formatPercent(pool.incentiveApr)}
-
- {pool.isIncentivized && showEmissions - ? pool.incentives.map((el, i) => { - const amount = tryParseAmount( - el.rewardPerDay.toString(), - incentiveRewardToToken(el.chainId as ChainId, el), - ) - if (!amount) return null - - return ( - - +{' '} - - {amount?.toSignificant(6)} {amount?.currency.symbol} per - day - - ) - }) - : null} -
diff --git a/apps/evm/src/ui/pool/AddSectionLegacy.tsx b/apps/evm/src/ui/pool/AddSectionLegacy.tsx index a022ec4219..72033ad0d3 100644 --- a/apps/evm/src/ui/pool/AddSectionLegacy.tsx +++ b/apps/evm/src/ui/pool/AddSectionLegacy.tsx @@ -3,13 +3,6 @@ import { Pool } from '@sushiswap/client' import { useIsMounted } from '@sushiswap/hooks' import { Button } from '@sushiswap/ui' -import { - SushiSwapV2PoolState, - getSushiSwapRouterContractConfig, - useSushiSwapV2Pool, -} from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' -import { CheckerProvider } from '@sushiswap/wagmi/systems/Checker/Provider' import { FC, useCallback, useMemo, useState } from 'react' import { APPROVE_TAG_ADD_LEGACY } from 'src/lib/constants' import { type ChainId } from 'sushi/chain' @@ -17,6 +10,13 @@ import { SushiSwapV2ChainId } from 'sushi/config' import { tryParseAmount } from 'sushi/currency' import { useTokensFromPool } from '../../lib/hooks' +import { getSushiSwapRouterContractConfig } from 'src/lib/wagmi/hooks/contracts/useSushiSwapRouter' +import { + SushiSwapV2PoolState, + useSushiSwapV2Pool, +} from 'src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { CheckerProvider } from 'src/lib/wagmi/systems/Checker/Provider' import { AddSectionReviewModalLegacy } from './AddSectionReviewModalLegacy' import { AddSectionWidget } from './AddSectionWidget' diff --git a/apps/evm/src/ui/pool/AddSectionMyPosition.tsx b/apps/evm/src/ui/pool/AddSectionMyPosition.tsx index c39dcda2e6..b4c07155b3 100644 --- a/apps/evm/src/ui/pool/AddSectionMyPosition.tsx +++ b/apps/evm/src/ui/pool/AddSectionMyPosition.tsx @@ -1,6 +1,6 @@ import { Pool } from '@sushiswap/client' import { classNames } from '@sushiswap/ui' -import { Currency as UICurrency } from '@sushiswap/ui/components/currency' +import { Currency as UICurrency } from '@sushiswap/ui' import React, { FC } from 'react' import { incentiveRewardToToken } from 'src/lib/functions' import { ChainId } from 'sushi/chain' diff --git a/apps/evm/src/ui/pool/AddSectionMyPositionStaked.tsx b/apps/evm/src/ui/pool/AddSectionMyPositionStaked.tsx index 2f6d7349d0..c419973106 100644 --- a/apps/evm/src/ui/pool/AddSectionMyPositionStaked.tsx +++ b/apps/evm/src/ui/pool/AddSectionMyPositionStaked.tsx @@ -1,4 +1,4 @@ -import { Currency } from '@sushiswap/ui/components/currency' +import { Currency } from '@sushiswap/ui' import React, { FC } from 'react' import { formatUSD } from 'sushi/format' diff --git a/apps/evm/src/ui/pool/AddSectionMyPositionUnstaked.tsx b/apps/evm/src/ui/pool/AddSectionMyPositionUnstaked.tsx index 94cbe7ba25..ead2d417f4 100644 --- a/apps/evm/src/ui/pool/AddSectionMyPositionUnstaked.tsx +++ b/apps/evm/src/ui/pool/AddSectionMyPositionUnstaked.tsx @@ -1,4 +1,4 @@ -import { Currency } from '@sushiswap/ui/components/currency' +import { Currency } from '@sushiswap/ui' import React, { FC } from 'react' import { formatUSD } from 'sushi/format' diff --git a/apps/evm/src/ui/pool/AddSectionPoolShareCardV2.tsx b/apps/evm/src/ui/pool/AddSectionPoolShareCardV2.tsx index 1ee1d2bcd3..ce243870c8 100644 --- a/apps/evm/src/ui/pool/AddSectionPoolShareCardV2.tsx +++ b/apps/evm/src/ui/pool/AddSectionPoolShareCardV2.tsx @@ -6,8 +6,8 @@ import { StatLabel, StatValue, } from '@sushiswap/ui' -import { SushiSwapV2PoolState } from '@sushiswap/wagmi' import { FC, useMemo } from 'react' +import { SushiSwapV2PoolState } from 'src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools' import { SushiSwapV2Pool } from 'sushi' import { Amount, Type } from 'sushi/currency' import { formatPercent } from 'sushi/format' diff --git a/apps/evm/src/ui/pool/AddSectionReviewModal.tsx b/apps/evm/src/ui/pool/AddSectionReviewModal.tsx index 6727fcb1bb..3151218922 100644 --- a/apps/evm/src/ui/pool/AddSectionReviewModal.tsx +++ b/apps/evm/src/ui/pool/AddSectionReviewModal.tsx @@ -1,5 +1,5 @@ import { Button, List } from '@sushiswap/ui' -import { Currency } from '@sushiswap/ui/components/currency' +import { Currency } from '@sushiswap/ui' import { FC, useMemo } from 'react' import { useTokenAmountDollarValues } from 'src/lib/hooks' import { BentoBoxChainId } from 'sushi/config' diff --git a/apps/evm/src/ui/pool/AddSectionReviewModalConcentrated.tsx b/apps/evm/src/ui/pool/AddSectionReviewModalConcentrated.tsx index 96a815d99a..b0cb874098 100644 --- a/apps/evm/src/ui/pool/AddSectionReviewModalConcentrated.tsx +++ b/apps/evm/src/ui/pool/AddSectionReviewModalConcentrated.tsx @@ -17,27 +17,32 @@ import { SettingsModule, SettingsOverlay, } from '@sushiswap/ui' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' -import { - UseCallParameters, - getDefaultTTL, - getV3NonFungiblePositionManagerContractConfig, - useAccount, - useCall, - usePublicClient, - useSendTransaction, - useTransactionDeadline, - useWaitForTransactionReceipt, -} from '@sushiswap/wagmi' +import { createErrorToast, createToast } from '@sushiswap/ui' import React, { FC, ReactNode, useCallback, useMemo } from 'react' import { Bound } from 'src/lib/constants' import { useTokenAmountDollarValues } from 'src/lib/hooks' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' +import { + getDefaultTTL, + useTransactionDeadline, +} from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' import { Chain, ChainId } from 'sushi/chain' -import { SushiSwapV3FeeAmount, isSushiSwapV3ChainId } from 'sushi/config' +import { + SUSHISWAP_V3_POSTIION_MANAGER, + SushiSwapV3FeeAmount, + isSushiSwapV3ChainId, +} from 'sushi/config' import { Amount, Type, tryParseAmount } from 'sushi/currency' -import { NonfungiblePositionManager, Position } from 'sushi/pool' +import { NonfungiblePositionManager, Position } from 'sushi/pool/sushiswap-v3' import { Hex, SendTransactionReturnType, UserRejectedRequestError } from 'viem' +import { + UseCallParameters, + useAccount, + useCall, + usePublicClient, + useSendTransaction, + useWaitForTransactionReceipt, +} from 'wagmi' import { useConcentratedDerivedMintInfo } from './ConcentratedLiquidityProvider' interface AddSectionReviewModalConcentratedProps @@ -199,7 +204,7 @@ export const AddSectionReviewModalConcentrated: FC< }) return { - to: getV3NonFungiblePositionManagerContractConfig(chainId).address, + to: SUSHISWAP_V3_POSTIION_MANAGER[chainId], account: address, chainId, data: calldata as Hex, diff --git a/apps/evm/src/ui/pool/AddSectionReviewModalLegacy.tsx b/apps/evm/src/ui/pool/AddSectionReviewModalLegacy.tsx index 8542e4e9e4..44292e9793 100644 --- a/apps/evm/src/ui/pool/AddSectionReviewModalLegacy.tsx +++ b/apps/evm/src/ui/pool/AddSectionReviewModalLegacy.tsx @@ -14,32 +14,37 @@ import { SettingsModule, SettingsOverlay, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Dots } from '@sushiswap/ui/components/dots' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' -import { - SushiSwapV2PoolState, - UseSimulateContractParameters, - getDefaultTTL, - getSushiSwapRouterContractConfig, - useAccount, - usePublicClient, - useSimulateContract, - useTransactionDeadline, - useWaitForTransactionReceipt, - useWriteContract, -} from '@sushiswap/wagmi' -import { SendTransactionReturnType } from '@sushiswap/wagmi/actions' -import { useApproved } from '@sushiswap/wagmi/systems/Checker/Provider' +import { Button } from '@sushiswap/ui' +import { Dots } from '@sushiswap/ui' +import { createErrorToast, createToast } from '@sushiswap/ui' import { FC, ReactNode, useCallback, useMemo } from 'react' import { APPROVE_TAG_ADD_LEGACY } from 'src/lib/constants' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' +import { getSushiSwapRouterContractConfig } from 'src/lib/wagmi/hooks/contracts/useSushiSwapRouter' +import { SushiSwapV2PoolState } from 'src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools' +import { + getDefaultTTL, + useTransactionDeadline, +} from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' +import { useApproved } from 'src/lib/wagmi/systems/Checker/Provider' import { gasMargin, slippageAmount } from 'sushi/calculate' import { SushiSwapV2ChainId } from 'sushi/config' import { BentoBoxChainId } from 'sushi/config' import { Amount, Type } from 'sushi/currency' import { ZERO } from 'sushi/math' -import { Address, UserRejectedRequestError } from 'viem' +import { + Address, + SendTransactionReturnType, + UserRejectedRequestError, +} from 'viem' +import { + UseSimulateContractParameters, + usePublicClient, + useWriteContract, +} from 'wagmi' +import { useSimulateContract } from 'wagmi' +import { useAccount } from 'wagmi' +import { useWaitForTransactionReceipt } from 'wagmi' import { AddSectionReviewModal } from './AddSectionReviewModal' interface UseAddSushiSwapV2 { diff --git a/apps/evm/src/ui/pool/AddSectionReviewModalTrident.tsx b/apps/evm/src/ui/pool/AddSectionReviewModalTrident.tsx deleted file mode 100644 index 6d7178c3f3..0000000000 --- a/apps/evm/src/ui/pool/AddSectionReviewModalTrident.tsx +++ /dev/null @@ -1,401 +0,0 @@ -import { - DialogConfirm, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogProvider, - DialogReview, - DialogTitle, - DialogTrigger, -} from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Dots } from '@sushiswap/ui/components/dots' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' -import { - TridentConstantPoolState, - TridentStablePoolState, - UseCallParameters, - useAccount, - useBentoBoxTotals, - useCall, - usePublicClient, - useSendTransaction, - useTotalSupply, - useTridentRouterContract, - useWaitForTransactionReceipt, -} from '@sushiswap/wagmi' -import { - useApproved, - useApprovedActions, - useSignature, -} from '@sushiswap/wagmi/systems/Checker/Provider' -import { FC, ReactNode, useCallback, useMemo } from 'react' - -import { - LiquidityInput, - approveMasterContractAction, - batchAction, -} from 'src/lib/pool/trident' - -import { APPROVE_TAG_ADD_TRIDENT } from 'src/lib/constants' -import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' -import { TridentConstantPool, TridentStablePool } from 'sushi' -import { slippageAmount } from 'sushi/calculate' -import { ChainId } from 'sushi/chain' -import { BentoBoxChainId, TridentChainId } from 'sushi/config' -import { Amount, Token, Type } from 'sushi/currency' -import { Percent, ZERO } from 'sushi/math' -import { - Address, - SendTransactionReturnType, - UserRejectedRequestError, - encodeAbiParameters, - encodeFunctionData, - parseAbiParameters, - zeroAddress, -} from 'viem' - -import { SlippageToleranceStorageKey } from '@sushiswap/hooks' -import { AddSectionReviewModal } from './AddSectionReviewModal' - -interface AddSectionReviewModalTridentProps { - poolAddress: string - poolState: TridentConstantPoolState | TridentStablePoolState | undefined - pool: TridentConstantPool | TridentStablePool | null | undefined - chainId: TridentChainId - token0: Type | undefined - token1: Type | undefined - input0: Amount | undefined - input1: Amount | undefined - children: ReactNode - onSuccess: () => void -} - -const ZERO_PERCENT = new Percent('0') - -export const AddSectionReviewModalTrident: FC< - AddSectionReviewModalTridentProps -> = ({ - poolAddress, - poolState, - pool, - chainId, - token0, - token1, - input0, - input1, - children, - onSuccess: _onSuccess, -}) => { - const { address, chain } = useAccount() - const { signature } = useSignature(APPROVE_TAG_ADD_TRIDENT) - const { setSignature } = useApprovedActions(APPROVE_TAG_ADD_TRIDENT) - const { approved } = useApproved(APPROVE_TAG_ADD_TRIDENT) - const client = usePublicClient() - - const liquidityToken = useMemo(() => { - return new Token({ - address: poolAddress.includes(':') - ? poolAddress.split(':')[1] - : poolAddress, - name: 'SLP Token', - decimals: 18, - symbol: 'SLP', - chainId, - }) - }, [chainId, poolAddress]) - - const totalSupply = useTotalSupply(liquidityToken) - const tokens = useMemo(() => [token0, token1], [token0, token1]) - const { data: rebases } = useBentoBoxTotals({ chainId, currencies: tokens }) - const contract = useTridentRouterContract(chainId) - const [slippageTolerance] = useSlippageTolerance( - SlippageToleranceStorageKey.AddLiquidity, - ) - const [minAmount0, minAmount1] = useMemo(() => { - return [ - input0 - ? poolState === TridentConstantPoolState.NOT_EXISTS || - poolState === TridentStablePoolState.NOT_EXISTS - ? input0 - : Amount.fromRawAmount( - input0.currency, - slippageAmount(input0, slippageTolerance)[0], - ) - : undefined, - input1 - ? poolState === TridentConstantPoolState.NOT_EXISTS || - poolState === TridentStablePoolState.NOT_EXISTS - ? input1 - : Amount.fromRawAmount( - input1.currency, - slippageAmount(input1, slippageTolerance)[0], - ) - : undefined, - ] - }, [poolState, input0, input1, slippageTolerance]) - - const noLiquidity = useMemo(() => { - return ( - poolState === TridentConstantPoolState.NOT_EXISTS || - poolState === TridentStablePoolState.NOT_EXISTS || - Boolean(totalSupply && totalSupply.quotient === ZERO) || - Boolean( - pool && - pool.reserve0.quotient === ZERO && - pool.reserve1.quotient === ZERO, - ) - ) - }, [pool, poolState, totalSupply]) - - const liquidityMinted = useMemo(() => { - if ( - pool && - totalSupply && - token0 && - token1 && - input0 && - input1 && - rebases?.[token0.wrapped.address] && - rebases?.[token1.wrapped.address] - ) { - const amountA = input0.wrapped.toShare(rebases?.[token0.wrapped.address]) - const amountB = input1.wrapped.toShare(rebases?.[token1.wrapped.address]) - - // Both can't be zero - if (amountA.equalTo(ZERO) && amountB.equalTo(ZERO)) return undefined - - try { - const slp = pool.getLiquidityMinted(totalSupply, amountA, amountB) - const minSLP = slippageAmount( - slp, - noLiquidity ? ZERO_PERCENT : slippageTolerance, - )[0] - return Amount.fromRawAmount(slp.currency, minSLP.toString()) - } catch (error) { - console.error(error) - } - } - - return undefined - }, [ - noLiquidity, - input0, - input1, - pool, - rebases, - slippageTolerance, - token0, - token1, - totalSupply, - ]) - - const onSuccess = useCallback( - (hash: SendTransactionReturnType) => { - setSignature(undefined) - _onSuccess() - - if (!chain?.id || !token0 || !token1) return - - const ts = new Date().getTime() - createToast({ - account: address, - type: 'mint', - chainId: chain.id, - txHash: hash, - promise: client.waitForTransactionReceipt({ hash }), - summary: { - pending: `Adding liquidity to the ${token0.symbol}/${token1.symbol} pair`, - completed: `Successfully added liquidity to the ${token0.symbol}/${token1.symbol} pair`, - failed: 'Something went wrong when adding liquidity', - }, - timestamp: ts, - groupTimestamp: ts, - }) - }, - [client, address, chain, token0, token1, setSignature, _onSuccess], - ) - - const onError = useCallback((e: Error) => { - if (e instanceof UserRejectedRequestError) { - createErrorToast(e?.message, true) - } - }, []) - - const prepare = useMemo(() => { - try { - if ( - !chain?.id || - !pool || - !token0 || - !token1 || - !chainId || - !contract || - !input0 || - !input1 || - !address || - !minAmount0 || - !minAmount1 || - !liquidityMinted - ) - return - - let value = 0n - const liquidityInput: LiquidityInput[] = [] - const encoded = encodeAbiParameters(parseAbiParameters('address'), [ - address, - ]) - - if (input0) { - if (input0.currency.isNative) { - value = BigInt(input0.quotient.toString()) - } - - liquidityInput.push({ - token: input0.currency.isNative - ? zeroAddress - : (input0.currency.wrapped.address as Address), - native: true, - amount: BigInt(input0.quotient.toString()), - }) - } - - if (input1) { - if (input1.currency.isNative) { - value = BigInt(input1.quotient.toString()) - } - - liquidityInput.push({ - token: input1.currency.isNative - ? zeroAddress - : (input1.currency.wrapped.address as Address), - native: true, - amount: BigInt(input1.quotient.toString()), - }) - } - - if (liquidityInput.length === 0) return - return { - to: contract.address, - account: address, - chainId, - data: batchAction({ - actions: [ - approveMasterContractAction({ - signature: signature, - }), - encodeFunctionData({ - ...contract, - functionName: 'addLiquidity', - args: [ - liquidityInput, - pool.liquidityToken.address as Address, - BigInt(liquidityMinted.quotient.toString()), - encoded, - ], - }), - ], - }), - value, - } satisfies UseCallParameters - } catch (_e: unknown) { - // - } - }, [ - chain?.id, - pool, - token0, - token1, - chainId, - contract, - input0, - input1, - address, - minAmount0, - minAmount1, - liquidityMinted, - signature, - ]) - - const { isError: isSimulationError } = useCall({ - ...prepare, - query: { - enabled: Boolean( - approved && - minAmount0?.greaterThan(ZERO) && - minAmount1?.greaterThan(ZERO), - ), - }, - }) - - const { - sendTransactionAsync, - isLoading: isWritePending, - data: hash, - } = useSendTransaction({ - mutation: { - onSuccess, - onError, - }, - }) - - const send = useMemo(() => { - if (!prepare || isSimulationError) return undefined - - return async (confirm: () => void) => { - try { - await sendTransactionAsync(prepare) - - confirm() - } catch {} - } - }, [isSimulationError, prepare, sendTransactionAsync]) - - const { status } = useWaitForTransactionReceipt({ chainId, hash }) - - return ( - - - {({ confirm }) => ( - <> - {children} - - - Add liquidity - - Please review your entered details. - - - - - - - - - )} - - - - ) -} diff --git a/apps/evm/src/ui/pool/AddSectionStake.tsx b/apps/evm/src/ui/pool/AddSectionStake.tsx index a658a8edda..5e4252fdfa 100644 --- a/apps/evm/src/ui/pool/AddSectionStake.tsx +++ b/apps/evm/src/ui/pool/AddSectionStake.tsx @@ -3,17 +3,8 @@ import { ChefType, Pool } from '@sushiswap/client' import { usePool } from '@sushiswap/client/hooks' import { useIsMounted } from '@sushiswap/hooks' -import { Button } from '@sushiswap/ui/components/button' -import { Dots } from '@sushiswap/ui/components/dots' -import { - getMasterChefContractConfig, - useMasterChefDeposit, -} from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' -import { - useApproved, - withCheckerRoot, -} from '@sushiswap/wagmi/systems/Checker/Provider' +import { Button } from '@sushiswap/ui' +import { Dots } from '@sushiswap/ui' import { FC, useMemo, useState } from 'react' import { APPROVE_TAG_STAKE } from 'src/lib/constants' import { useGraphPool } from 'src/lib/hooks' @@ -22,6 +13,13 @@ import { tryParseAmount } from 'sushi/currency' import { ZERO } from 'sushi/math' import { useSWRConfig } from 'swr' +import { getMasterChefContractConfig } from 'src/lib/wagmi/hooks/master-chef/use-master-chef-contract' +import { useMasterChefDeposit } from 'src/lib/wagmi/hooks/master-chef/use-master-chef-deposit' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { + useApproved, + withCheckerRoot, +} from 'src/lib/wagmi/systems/Checker/Provider' import { AddSectionStakeWidget } from './AddSectionStakeWidget' interface AddSectionStakeProps { @@ -67,7 +65,7 @@ const _AddSectionStake: FC = withCheckerRoot( const { write, isLoading: isWritePending } = useMasterChefDeposit({ amount: amounts[0], - chainId: liquidityToken.chainId, + chainId: liquidityToken?.chainId, chef: chefType, pid: farmId, enabled: Boolean( diff --git a/apps/evm/src/ui/pool/AddSectionStakeWidget.tsx b/apps/evm/src/ui/pool/AddSectionStakeWidget.tsx index a83632f9a5..bf36ef04b0 100644 --- a/apps/evm/src/ui/pool/AddSectionStakeWidget.tsx +++ b/apps/evm/src/ui/pool/AddSectionStakeWidget.tsx @@ -7,9 +7,8 @@ import { textFieldVariants, typographyVariants, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Widget, WidgetHeader } from '@sushiswap/ui/components/widget' -import { useTotalSupply } from '@sushiswap/wagmi' +import { Button } from '@sushiswap/ui' +import { Widget, WidgetHeader } from '@sushiswap/ui' import { FC, ReactNode, useMemo } from 'react' import { useTokenAmountDollarValues, @@ -18,6 +17,7 @@ import { import { Amount, Token, Type, tryParseAmount } from 'sushi/currency' import { formatUSD } from 'sushi/format' +import { useTotalSupply } from 'src/lib/wagmi/hooks/tokens/useTotalSupply' import { usePoolPosition } from './PoolPositionProvider' interface AddSectionStakeWidgetProps { @@ -27,7 +27,7 @@ interface AddSectionStakeWidgetProps { setValue(value: string): void reserve0: Amount | null reserve1: Amount | null - liquidityToken: Token + liquidityToken: Token | undefined children: ReactNode isFarm?: boolean isIncentivized?: boolean diff --git a/apps/evm/src/ui/pool/AddSectionWidget.tsx b/apps/evm/src/ui/pool/AddSectionWidget.tsx index 0dd2df0538..ea376ec367 100644 --- a/apps/evm/src/ui/pool/AddSectionWidget.tsx +++ b/apps/evm/src/ui/pool/AddSectionWidget.tsx @@ -7,15 +7,12 @@ import { WidgetFooter, WidgetTitle, } from '@sushiswap/ui' -import { IconButton } from '@sushiswap/ui/components/iconbutton' -import { - SettingsModule, - SettingsOverlay, -} from '@sushiswap/ui/components/settings' -import { Widget, WidgetHeader } from '@sushiswap/ui/components/widget' -import { getDefaultTTL } from '@sushiswap/wagmi' -import { Web3Input } from '@sushiswap/wagmi/components/web3-input' +import { IconButton } from '@sushiswap/ui' +import { SettingsModule, SettingsOverlay } from '@sushiswap/ui' +import { Widget, WidgetHeader } from '@sushiswap/ui' import React, { FC, ReactNode } from 'react' +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 { Type } from 'sushi/currency' diff --git a/apps/evm/src/ui/pool/ConcentratedLiquidityCollectButton.tsx b/apps/evm/src/ui/pool/ConcentratedLiquidityCollectButton.tsx index 6caadd42c3..c221dd240f 100644 --- a/apps/evm/src/ui/pool/ConcentratedLiquidityCollectButton.tsx +++ b/apps/evm/src/ui/pool/ConcentratedLiquidityCollectButton.tsx @@ -1,21 +1,23 @@ 'use client' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { createErrorToast, createToast } from '@sushiswap/ui' +import { FC, ReactElement, useCallback, useMemo } from 'react' +import { ConcentratedLiquidityPosition } from 'src/lib/wagmi/hooks/positions/types' +import { ChainId } from 'sushi/chain' +import { + SUSHISWAP_V3_POSTIION_MANAGER, + isSushiSwapV3ChainId, +} from 'sushi/config' +import { Amount, Type, unwrapToken } from 'sushi/currency' +import { NonfungiblePositionManager, Position } from 'sushi/pool/sushiswap-v3' +import { Hex, SendTransactionReturnType, UserRejectedRequestError } from 'viem' import { - ConcentratedLiquidityPosition, UseCallParameters, - getV3NonFungiblePositionManagerContractConfig, useAccount, useCall, usePublicClient, useSendTransaction, -} from '@sushiswap/wagmi' -import { FC, ReactElement, useCallback, useMemo } from 'react' -import { ChainId } from 'sushi/chain' -import { isSushiSwapV3ChainId } from 'sushi/config' -import { Amount, Type, unwrapToken } from 'sushi/currency' -import { NonfungiblePositionManager, Position } from 'sushi/pool' -import { Hex, SendTransactionReturnType, UserRejectedRequestError } from 'viem' +} from 'wagmi' interface ConcentratedLiquidityCollectButton { positionDetails: ConcentratedLiquidityPosition | undefined @@ -73,7 +75,7 @@ export const ConcentratedLiquidityCollectButton: FC< }) return { - to: getV3NonFungiblePositionManagerContractConfig(chainId).address, + to: SUSHISWAP_V3_POSTIION_MANAGER[chainId], chainId, data: calldata as Hex, value: BigInt(value), diff --git a/apps/evm/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx b/apps/evm/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx index 88994c1f9a..0035746ab1 100644 --- a/apps/evm/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx +++ b/apps/evm/src/ui/pool/ConcentratedLiquidityHarvestButton.tsx @@ -1,8 +1,8 @@ 'use client' import { useAngleRewards } from '@sushiswap/react-query' -import { useHarvestAngleRewards } from '@sushiswap/wagmi' import { FC, ReactElement, useMemo } from 'react' +import { useHarvestAngleRewards } from 'src/lib/wagmi/hooks/rewards/hooks/useHarvestAngleRewards' import { ChainId } from 'sushi/chain' import { Address } from 'viem' diff --git a/apps/evm/src/ui/pool/ConcentratedLiquidityPositionAPRCell.tsx b/apps/evm/src/ui/pool/ConcentratedLiquidityPositionAPRCell.tsx index 3e8c7cd1f2..c75fb5c3b8 100644 --- a/apps/evm/src/ui/pool/ConcentratedLiquidityPositionAPRCell.tsx +++ b/apps/evm/src/ui/pool/ConcentratedLiquidityPositionAPRCell.tsx @@ -6,9 +6,9 @@ import { HoverCardContent, HoverCardTrigger, } from '@sushiswap/ui' -import { ConcentratedLiquidityPositionWithV3Pool } from '@sushiswap/wagmi' import { Row } from '@tanstack/react-table' import { FC } from 'react' +import { ConcentratedLiquidityPositionWithV3Pool } from 'src/lib/wagmi/hooks/positions/types' export const ConcentratedLiquidityPositionAPRCell: FC< Row diff --git a/apps/evm/src/ui/pool/ConcentratedLiquidityProvider.tsx b/apps/evm/src/ui/pool/ConcentratedLiquidityProvider.tsx index 446300b7b5..31afe25dbf 100644 --- a/apps/evm/src/ui/pool/ConcentratedLiquidityProvider.tsx +++ b/apps/evm/src/ui/pool/ConcentratedLiquidityProvider.tsx @@ -1,6 +1,5 @@ 'use client' -import { useConcentratedLiquidityPool } from '@sushiswap/wagmi' import { FC, ReactNode, @@ -12,6 +11,7 @@ import { } from 'react' import { Bound, Field } from 'src/lib/constants' import { getTickToPrice, tryParseTick } from 'src/lib/functions' +import { useConcentratedLiquidityPool } from 'src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool' import { SushiSwapV3ChainId, SushiSwapV3FeeAmount, @@ -37,7 +37,7 @@ import { priceToClosestTick, priceToNumber, tickToPrice, -} from 'sushi/pool' +} from 'sushi/pool/sushiswap-v3' type FullRange = true diff --git a/apps/evm/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx b/apps/evm/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx index 94bde8a49a..f7fa22dc34 100644 --- a/apps/evm/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx +++ b/apps/evm/src/ui/pool/ConcentratedLiquidityRemoveWidget.tsx @@ -30,28 +30,33 @@ import { SettingsOverlay, classNames, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' +import { Button } from '@sushiswap/ui' +import { createErrorToast, createToast } from '@sushiswap/ui' +import React, { FC, useCallback, useMemo, useState } from 'react' +import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' +import { ConcentratedLiquidityPosition } from 'src/lib/wagmi/hooks/positions/types' import { - ConcentratedLiquidityPosition, getDefaultTTL, - getV3NonFungiblePositionManagerContractConfig, - useAccount, - useCall, - usePublicClient, - useSendTransaction, useTransactionDeadline, - useWaitForTransactionReceipt, -} from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' -import React, { FC, useCallback, useMemo, useState } from 'react' -import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' +} from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { Chain } from 'sushi/chain' -import { SushiSwapV3ChainId, isSushiSwapV3ChainId } from 'sushi/config' +import { + SUSHISWAP_V3_POSTIION_MANAGER, + SushiSwapV3ChainId, + isSushiSwapV3ChainId, +} from 'sushi/config' import { Amount, Type, unwrapToken } from 'sushi/currency' import { Percent, ZERO } from 'sushi/math' -import { NonfungiblePositionManager, Position } from 'sushi/pool' +import { NonfungiblePositionManager, Position } 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 { useTokenAmountDollarValues } from '../../lib/hooks' interface ConcentratedLiquidityRemoveWidget { @@ -203,7 +208,7 @@ export const ConcentratedLiquidityRemoveWidget: FC< }) return { - to: getV3NonFungiblePositionManagerContractConfig(chainId).address, + to: SUSHISWAP_V3_POSTIION_MANAGER[chainId], data: calldata as Hex, value: BigInt(_value), } diff --git a/apps/evm/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx b/apps/evm/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx index 1e3701156b..aad1aaf6e5 100644 --- a/apps/evm/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx +++ b/apps/evm/src/ui/pool/ConcentratedLiquidityURLStateProvider.tsx @@ -1,10 +1,9 @@ 'use client' -import { useChainId } from '@sushiswap/wagmi' -import { useTokenWithCache } from '@sushiswap/wagmi' import { usePathname, useRouter, useSearchParams } from 'next/navigation' import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react' import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { useTokenWithCache } from 'src/lib/wagmi/hooks/tokens/useTokenWithCache' import { ChainId } from 'sushi/chain' import { SushiSwapV3ChainId, @@ -16,6 +15,7 @@ import { } from 'sushi/config' import { Native, Token, Type } from 'sushi/currency' import { isAddress } from 'viem' +import { useChainId } from 'wagmi' import { z } from 'zod' export const queryParamsSchema = z.object({ diff --git a/apps/evm/src/ui/pool/ConcentratedLiquidityWidget.tsx b/apps/evm/src/ui/pool/ConcentratedLiquidityWidget.tsx index 81b29d8cbe..d6467a3acc 100644 --- a/apps/evm/src/ui/pool/ConcentratedLiquidityWidget.tsx +++ b/apps/evm/src/ui/pool/ConcentratedLiquidityWidget.tsx @@ -3,23 +3,21 @@ import { Transition } from '@headlessui/react' import { LockClosedIcon, PlusIcon } from '@heroicons/react-v1/solid' import { DialogTrigger, FormSection, Message, classNames } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { - getV3NonFungiblePositionManagerContractConfig, - useConcentratedPositionOwner, -} from '@sushiswap/wagmi' -import { Web3Input } from '@sushiswap/wagmi/components/web3-input' -import { Checker } from '@sushiswap/wagmi/systems' +import { Button } from '@sushiswap/ui' import { FC, Fragment, useCallback, useMemo } from 'react' import { ChainId } from 'sushi/chain' import { + SUSHISWAP_V3_POSTIION_MANAGER, SushiSwapV3ChainId, SushiSwapV3FeeAmount, isWNativeSupported, } from 'sushi/config' import { Type } from 'sushi/currency' -import { Position } from 'sushi/pool' +import { Position } from 'sushi/pool/sushiswap-v3' +import { Web3Input } from 'src/lib/wagmi/components/web3-input' +import { useConcentratedPositionOwner } from 'src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionOwner' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { Bound, Field } from '../../lib/constants' import { AddSectionReviewModalConcentrated } from './AddSectionReviewModalConcentrated' import { @@ -263,19 +261,14 @@ export const ConcentratedLiquidityWidget: FC = ({ fullWidth id="approve-erc20-0" amount={parsedAmounts[Field.CURRENCY_A]} - contract={ - getV3NonFungiblePositionManagerContractConfig(chainId).address - } + contract={SUSHISWAP_V3_POSTIION_MANAGER[chainId]} enabled={!depositADisabled} > = const chainIds = useMemo(() => { if (chainId) return [chainId] as SushiSwapV3ChainId[] - return SUSHISWAP_V3_ENABLED_NETWORKS + return [...SUSHISWAP_V3_SUPPORTED_CHAIN_IDS] }, [chainId]) const [paginationState, setPaginationState] = useState({ @@ -74,7 +76,11 @@ export const ConcentratedPositionsTable: FC = const _positions = useMemo(() => { const _tokenSymbols = tokenSymbols?.filter((el) => el !== '') || [] return (positions || []) - ?.filter((el) => filterChainIds.includes(el.chainId)) + ?.filter((el) => + filterChainIds.includes( + el.chainId as (typeof filterChainIds)[number], + ), + ) .filter((el) => _tokenSymbols.length > 0 ? _tokenSymbols.some((symbol) => { diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/Manual.tsx b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/Manual.tsx deleted file mode 100644 index da54f3c07a..0000000000 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/Manual.tsx +++ /dev/null @@ -1,81 +0,0 @@ -'use client' - -import { Slot } from '@radix-ui/react-slot' -import { DataTable } from '@sushiswap/ui' -import { ColumnDef, PaginationState, Row } from '@tanstack/react-table' -import React, { FC, ReactNode, useCallback, useState } from 'react' -import { ChainId } from 'sushi/chain' - -import { ConcentratedLiquidityPositionWithV3Pool } from '@sushiswap/wagmi' -import { Address } from 'viem' -import { - NAME_COLUMN_V3, - POSITION_SIZE_CELL, - POSITION_UNCLAIMED_CELL, - PRICE_RANGE_COLUMN, -} from '../../../columns' -import { useManualPositions } from './useManualPositions' - -const COLUMNS = [ - NAME_COLUMN_V3, - PRICE_RANGE_COLUMN, - POSITION_SIZE_CELL, - POSITION_UNCLAIMED_CELL, -] satisfies ColumnDef[] - -const tableState = { sorting: [{ id: 'positionSize', desc: true }] } - -interface Manual { - chainId?: ChainId - poolAddress?: Address - onRowClick?(row: ConcentratedLiquidityPositionWithV3Pool): void -} - -export const Manual: FC = ({ chainId, poolAddress, onRowClick }) => { - const [paginationState, setPaginationState] = useState({ - pageIndex: 0, - pageSize: 10, - }) - - const rowRenderer = useCallback( - (row: Row, rowNode: ReactNode) => { - if (onRowClick) - return ( - onRowClick?.(row.original)} - > - {rowNode} - - ) - return rowNode - }, - [onRowClick], - ) - - const { data, isInitialLoading } = useManualPositions({ - chainId, - poolAddress, - }) - - return ( - - `/pool/${row.chainId}:${ - row.address - }/positions/${row.tokenId.toString()}` - } - rowRenderer={rowRenderer} - columns={COLUMNS} - data={data} - pagination={true} - onPaginationChange={setPaginationState} - state={{ - ...tableState, - pagination: paginationState, - }} - /> - ) -} diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/index.ts b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/index.ts deleted file mode 100644 index a7b1889fcf..0000000000 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Manual' diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/useManualPositions.ts b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/useManualPositions.ts deleted file mode 100644 index 4a5c138b1d..0000000000 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Manual/useManualPositions.ts +++ /dev/null @@ -1,67 +0,0 @@ -'use client' - -import { useAccount, useConcentratedLiquidityPositions } from '@sushiswap/wagmi' -import { useMemo } from 'react' -import { ChainId } from 'sushi/chain' -import { - SUSHISWAP_V3_SUPPORTED_CHAIN_IDS, - isSushiSwapV3ChainId, -} from 'sushi/config' -import { Writeable } from 'zod' - -import { Address } from 'viem' -import { usePoolFilters } from '../../../PoolsFiltersProvider' - -interface UseManualPositions { - chainId?: ChainId - poolAddress?: Address -} - -export const useManualPositions = ({ - poolAddress, - chainId, -}: UseManualPositions) => { - const { address } = useAccount() - const { chainIds, tokenSymbols } = usePoolFilters() - - const chainIdsToQuery = useMemo(() => { - if (chainId && isSushiSwapV3ChainId(chainId)) { - return [chainId] - } - - return SUSHISWAP_V3_SUPPORTED_CHAIN_IDS - }, [chainId]) - - const { data: manualPositions, isInitialLoading } = - useConcentratedLiquidityPositions({ - account: address, - chainIds: chainIdsToQuery as Writeable, - }) - - return { - data: useMemo(() => { - const _tokenSymbols = tokenSymbols?.filter((el) => el !== '') || [] - return (manualPositions || []) - ?.filter((el) => chainIds.includes(el.chainId)) - .filter((el) => - _tokenSymbols.length > 0 - ? _tokenSymbols.some((symbol) => { - return [ - el.pool?.token0.symbol, - el.pool?.token1.symbol, - ].includes(symbol.toUpperCase()) - }) - : true, - ) - .filter((el) => { - return ( - el.liquidity !== 0n && - (poolAddress - ? el.address.toLowerCase() === poolAddress.toLowerCase() - : true) - ) - }) - }, [tokenSymbols, manualPositions, chainIds, poolAddress]), - isInitialLoading, - } -} diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/Smart.tsx b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/Smart.tsx deleted file mode 100644 index 846c326634..0000000000 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/Smart.tsx +++ /dev/null @@ -1,85 +0,0 @@ -'use client' - -import { Slot } from '@radix-ui/react-slot' -import { DataTable } from '@sushiswap/ui' -import { ColumnDef, PaginationState } from '@tanstack/react-table' -import { Row } from '@tanstack/react-table' -import React, { FC, ReactNode, useCallback, useState } from 'react' -import { ChainId } from 'sushi/chain' - -import { Card, CardHeader, CardTitle } from '@sushiswap/ui' -import { Address } from 'viem' -import { - STEER_NAME_COLUMN, - STEER_POSITION_SIZE_COLUMN, - STEER_STRATEGY_COLUMN, -} from './columns' -import { SteerPosition, useSteerPositions } from './useSteerPositions' - -const COLUMNS = [ - STEER_NAME_COLUMN, - STEER_STRATEGY_COLUMN, - STEER_POSITION_SIZE_COLUMN, -] satisfies ColumnDef[] - -const tableState = { sorting: [{ id: 'positionSize', desc: true }] } - -interface Smart { - chainId?: ChainId - poolAddress?: Address - onRowClick?(row: SteerPosition): void -} - -export const Smart: FC = ({ chainId, poolAddress, onRowClick }) => { - const [paginationState, setPaginationState] = useState({ - pageIndex: 0, - pageSize: 10, - }) - - const rowRenderer = useCallback( - (row: Row, rowNode: ReactNode) => { - if (onRowClick) - return ( - onRowClick?.(row.original)} - > - {rowNode} - - ) - return rowNode - }, - [onRowClick], - ) - - const { data, isLoading } = useSteerPositions({ chainId, poolAddress }) - - return ( - - - - My Positions{' '} - - ({data?.length}) - - - - - `/pool/${row.vault.pool.id}/smart/${row.vault.id}` - } - rowRenderer={rowRenderer} - columns={COLUMNS} - data={data} - pagination={true} - onPaginationChange={setPaginationState} - state={{ - ...tableState, - pagination: paginationState, - }} - /> - - ) -} diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/columns/index.tsx b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/columns/index.tsx index 6c7cd07a1a..14a429ab11 100644 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/columns/index.tsx +++ b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/columns/index.tsx @@ -13,33 +13,21 @@ import { import { ColumnDef } from '@tanstack/react-table' import { formatNumber } from 'sushi/format' -import { Token, unwrapToken } from 'sushi/currency' +import { SteerAccountPositionExtended } from 'src/lib/wagmi/hooks/steer/useSteerAccountPositionsExtended' +import { unwrapToken } from 'sushi/currency' import { ProtocolBadge } from '../../../../PoolNameCell' -import { SteerPosition } from '../useSteerPositions' import { SteerStrategyCell } from './SteerStrategyCell' -export const STEER_NAME_COLUMN: ColumnDef = { +export const STEER_NAME_COLUMN: ColumnDef< + SteerAccountPositionExtended, + unknown +> = { id: 'name', header: 'Name', cell: ({ row: { original } }) => { const vault = original.vault const pool = vault.pool - const token0 = new Token({ - chainId: original.chainId, - address: pool.token0.address, - decimals: pool.token0.decimals, - symbol: pool.token0.symbol, - }) - const token1 = new Token({ - chainId: original.chainId, - address: pool.token1.address, - decimals: pool.token1.decimals, - symbol: pool.token1.symbol, - }) - - const incentives = pool.incentives.filter((i) => i.rewardPerDay > 0) - return (
@@ -51,18 +39,18 @@ export const STEER_NAME_COLUMN: ColumnDef = { } > - - + +
- {unwrapToken(token0).symbol}{' '} + {unwrapToken(original.token0).symbol}{' '} / {' '} - {unwrapToken(token1).symbol}{' '} + {unwrapToken(original.token1).symbol}{' '}
= {
- 🧑🌾{' '} - {incentives.length > 1 - ? `x ${incentives.length}` - : ''}{' '} + 🧑🌾{' '}
@@ -148,7 +133,10 @@ export const STEER_NAME_COLUMN: ColumnDef = { size: 300, } -export const STEER_STRATEGY_COLUMN: ColumnDef = { +export const STEER_STRATEGY_COLUMN: ColumnDef< + SteerAccountPositionExtended, + unknown +> = { id: 'strategy', header: 'Strategy', cell: (props) => , @@ -162,7 +150,10 @@ export const STEER_STRATEGY_COLUMN: ColumnDef = { size: 300, } -export const STEER_POSITION_SIZE_COLUMN: ColumnDef = { +export const STEER_POSITION_SIZE_COLUMN: ColumnDef< + SteerAccountPositionExtended, + unknown +> = { id: 'positionSize', header: 'Position Size', accessorFn: (row) => row.totalAmountUSD ?? 0, diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/index.ts b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/index.ts deleted file mode 100644 index 4f41f158dd..0000000000 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Smart' diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/useSteerPositions.ts b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/useSteerPositions.ts deleted file mode 100644 index 1968a860c2..0000000000 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/Smart/useSteerPositions.ts +++ /dev/null @@ -1,101 +0,0 @@ -'use client' - -import { usePool, useSteerVaults } from '@sushiswap/client/hooks' -import { useAllPrices } from '@sushiswap/react-query' -import { useAccount, useSteerAccountPositions } from '@sushiswap/wagmi' -import { useMemo } from 'react' -import { ChainId } from 'sushi/chain' -import { Amount, Token } from 'sushi/currency' -import { Address } from 'viem' - -interface UseSteerPositions { - chainId?: ChainId - poolAddress?: Address -} - -export const useSteerPositions = ({ - poolAddress, - chainId, -}: UseSteerPositions) => { - const { address: account } = useAccount() - - const { data: vaultsPerChain, isLoading: isPerChainLoading } = useSteerVaults( - { - args: { chainIds: chainId ? [chainId] : undefined }, - shouldFetch: account && (!poolAddress || !chainId), - }, - ) - const { data: vaultsPerPool, isLoading: isPerPoolLoading } = usePool({ - args: chainId && poolAddress ? { chainId, address: poolAddress } : '', - shouldFetch: !!account && !!poolAddress && !!chainId, - }) - - const { data: prices, isLoading: isPricesLoading } = useAllPrices() - - const isVaultsLoading = isPerChainLoading || isPerPoolLoading - const vaults = useMemo(() => { - if (vaultsPerChain) { - return vaultsPerChain - } - - if (vaultsPerPool) { - return vaultsPerPool.steerVaults.map((steerVault) => ({ - ...steerVault, - pool: vaultsPerPool, - })) - } - }, [vaultsPerChain, vaultsPerPool]) - - const vaultIds = useMemo(() => vaults?.map((el) => el.id), [vaults]) - const { data: positions, isLoading: isPositionsLoading } = - useSteerAccountPositions({ - vaultIds, - account, - }) - - return { - data: useMemo(() => { - if (!vaults || !positions || !account) return [] - - return positions.flatMap((el, i) => { - if (!el || el.steerTokenBalance === 0n) return [] - - const vault = vaults[i] - - const token0 = new Token({ chainId: vault.chainId, ...vault.token0 }) - const token1 = new Token({ chainId: vault.chainId, ...vault.token1 }) - - const token0Price = - prices?.[String(vault.chainId)]?.[token0.address] || 0 - const token1Price = - prices?.[String(vault.chainId)]?.[token1.address] || 0 - - const token0Amount = Amount.fromRawAmount(token0, el?.token0Balance) - const token1Amount = Amount.fromRawAmount(token1, el?.token1Balance) - - const token0AmountUSD = Number( - token0Amount?.multiply(token0Price).toSignificant(8), - ) - const token1AmountUSD = Number( - token1Amount?.multiply(token1Price).toSignificant(8), - ) - - return { - ...el, - vault, - token0Amount, - token1Amount, - token0AmountUSD, - token1AmountUSD, - totalAmountUSD: token0AmountUSD + token1AmountUSD, - } - }) - }, [account, positions, prices, vaults]), - isLoading: - !!account && (isVaultsLoading || isPricesLoading || isPositionsLoading), - } -} - -export type SteerPosition = NonNullable< - ReturnType['data'] ->[number] diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/index.ts b/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/index.ts deleted file mode 100644 index 754f36527f..0000000000 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/Tables/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Manual' -export * from './Smart' diff --git a/apps/evm/src/ui/pool/ConcentratedPositionsTable/index.ts b/apps/evm/src/ui/pool/ConcentratedPositionsTable/index.ts index 3c61e534a2..64a7ee3edb 100644 --- a/apps/evm/src/ui/pool/ConcentratedPositionsTable/index.ts +++ b/apps/evm/src/ui/pool/ConcentratedPositionsTable/index.ts @@ -1,2 +1 @@ export * from './ConcentratedPositionsTable' -export * from './Tables' diff --git a/apps/evm/src/ui/pool/CreatePositionManual.tsx b/apps/evm/src/ui/pool/CreatePositionManual.tsx index f95d4eb364..1554cbcb48 100644 --- a/apps/evm/src/ui/pool/CreatePositionManual.tsx +++ b/apps/evm/src/ui/pool/CreatePositionManual.tsx @@ -9,11 +9,11 @@ import { CardTitle, Separator, } from '@sushiswap/ui' -import { useAccount } from '@sushiswap/wagmi' import React, { FC, useMemo, useState } from 'react' import { ConcentratedLiquidityWidget } from 'src/ui/pool/ConcentratedLiquidityWidget' import { SushiSwapV3ChainId } from 'sushi/config' import { unwrapToken } from 'sushi/currency' +import { useAccount } from 'wagmi' import { SelectPricesWidget } from './SelectPricesWidget' interface ManualProps { diff --git a/apps/evm/src/ui/pool/CreateSectionReviewModalTrident.tsx b/apps/evm/src/ui/pool/CreateSectionReviewModalTrident.tsx deleted file mode 100644 index 8f815caa06..0000000000 --- a/apps/evm/src/ui/pool/CreateSectionReviewModalTrident.tsx +++ /dev/null @@ -1,403 +0,0 @@ -import { - Button, - DialogConfirm, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogProvider, - DialogReview, - DialogTitle, - DialogTrigger, - Dots, -} from '@sushiswap/ui' -import { createErrorToast, createToast } from '@sushiswap/ui/components/toast' -import { - PoolFinderType, - UseCallParameters, - useAccount, - useBentoBoxTotals, - useCall, - usePublicClient, - useSendTransaction, - useTridentConstantPoolFactoryContract, - useTridentRouterContract, - useTridentStablePoolFactoryContract, - useWaitForTransactionReceipt, -} from '@sushiswap/wagmi' -import { - useApproved, - useApprovedActions, - useSignature, -} from '@sushiswap/wagmi/systems/Checker/Provider' -import { FC, ReactNode, useCallback, useMemo } from 'react' - -import { - LiquidityInput, - approveMasterContractAction, - batchAction, - deployNewPoolAction, -} from 'src/lib/pool/trident' - -import { APPROVE_TAG_CREATE_TRIDENT } from 'src/lib/constants' -import { - TridentConstantPool, - TridentStablePool, - computeTridentConstantPoolAddress, - computeTridentStablePoolAddress, -} from 'sushi' -import { ChainId } from 'sushi/chain' -import { BentoBoxChainId, TridentChainId } from 'sushi/config' -import { Amount, Type } from 'sushi/currency' -import { Fee } from 'sushi/dex' -import { - Address, - SendTransactionReturnType, - UserRejectedRequestError, - encodeAbiParameters, - encodeFunctionData, - parseAbiParameters, - zeroAddress, -} from 'viem' - -import { AddSectionReviewModal } from './AddSectionReviewModal' - -interface CreateSectionReviewModalTridentProps { - chainId: TridentChainId - token0: Type | undefined - token1: Type | undefined - input0: Amount | undefined - input1: Amount | undefined - fee: Fee - poolType: PoolFinderType - children: ReactNode -} - -export const CreateSectionReviewModalTrident: FC< - CreateSectionReviewModalTridentProps -> = ({ token0, token1, input0, input1, fee, poolType, chainId, children }) => { - const client = usePublicClient() - const { address, chain } = useAccount() - const { signature } = useSignature(APPROVE_TAG_CREATE_TRIDENT) - const { setSignature } = useApprovedActions(APPROVE_TAG_CREATE_TRIDENT) - const { approved } = useApproved(APPROVE_TAG_CREATE_TRIDENT) - const contract = useTridentRouterContract(chainId) - const constantProductPoolFactory = - useTridentConstantPoolFactoryContract(chainId) - const stablePoolFactory = useTridentStablePoolFactoryContract(chainId) - - const { data: totals } = useBentoBoxTotals({ - chainId, - currencies: useMemo(() => [token0, token1], [token0, token1]), - }) - - const pool = useMemo(() => { - if (!token0 || !token1 || !fee) return - if (poolType === PoolFinderType.Classic) { - return new TridentConstantPool( - Amount.fromRawAmount(token0.wrapped, 0), - Amount.fromRawAmount(token1.wrapped, 0), - fee, - false, - ) - } else if ( - poolType === PoolFinderType.Stable && - totals && - token0.wrapped.address in totals && - token1.wrapped.address in totals - ) { - return new TridentStablePool( - Amount.fromRawAmount(token0.wrapped, 0), - Amount.fromRawAmount(token1.wrapped, 0), - fee, - totals[token0.wrapped.address], - totals[token1.wrapped.address], - ) - } - }, [fee, token0, token1, poolType, totals]) - - const totalSupply = useMemo( - () => (pool ? Amount.fromRawAmount(pool?.liquidityToken, 0) : undefined), - [pool], - ) - - const factory = useMemo(() => { - switch (poolType) { - case PoolFinderType.Classic: - return constantProductPoolFactory - case PoolFinderType.Stable: - return stablePoolFactory - } - }, [constantProductPoolFactory, poolType, stablePoolFactory]) - - const poolAddress = useMemo(() => { - // !poolType === 0, don't guared against it - if (!factory || !token0 || !token1 || !fee) return - switch (poolType) { - case PoolFinderType.Classic: - return computeTridentConstantPoolAddress({ - factoryAddress: factory.address, - tokenA: token0.wrapped, - tokenB: token1.wrapped, - fee: fee, - twap: false, - }) as Address - case PoolFinderType.Stable: - return computeTridentStablePoolAddress({ - factoryAddress: factory.address, - tokenA: token0.wrapped, - tokenB: token1.wrapped, - fee: fee, - }) as Address - } - }, [factory, fee, token0, token1, poolType]) - - const isValid = useMemo(() => { - return Boolean( - chain?.id && - factory && - token0 && - token1 && - poolAddress && - input0 && - input1 && - totalSupply && - pool && - contract && - totals?.[token0.wrapped.address] && - totals?.[token1.wrapped.address], - ) - }, [ - chain?.id, - contract, - factory, - input0, - input1, - pool, - poolAddress, - token0, - token1, - totalSupply, - totals, - ]) - - const onSuccess = useCallback( - (hash: SendTransactionReturnType) => { - setSignature(undefined) - - if (!chain?.id || !token0 || !token1) return - - const ts = new Date().getTime() - createToast({ - account: address, - type: 'mint', - chainId: chain.id, - txHash: hash, - promise: client.waitForTransactionReceipt({ hash }), - summary: { - pending: `Adding liquidity to the ${token0.symbol}/${token1.symbol} pair`, - completed: `Successfully added liquidity to the ${token0.symbol}/${token1.symbol} pair`, - failed: 'Something went wrong when adding liquidity', - }, - timestamp: ts, - groupTimestamp: ts, - }) - }, - [client, chain, token0, token1, address, setSignature], - ) - - const onError = useCallback((e: Error) => { - if (e instanceof UserRejectedRequestError) { - createErrorToast(e?.message, true) - } - }, []) - - const prepare = useMemo(() => { - try { - if ( - !chain?.id || - !factory || - !token0 || - !token1 || - !poolAddress || - !input0 || - !input1 || - !totalSupply || - !pool || - !contract || - !totals?.[token0.wrapped.address] || - !totals?.[token1.wrapped.address] || - !address - ) { - return undefined - } - - let value - const liquidityInput: LiquidityInput[] = [] - const encoded = encodeAbiParameters(parseAbiParameters('address'), [ - address, - ]) - - if (input0) { - if (input0.currency.isNative) { - value = input0.quotient - } - - liquidityInput.push({ - token: input0.currency.isNative - ? zeroAddress - : (input0.currency.wrapped.address as Address), - native: true, - amount: BigInt(input0.quotient.toString()), - }) - } - - if (input1) { - if (input1.currency.isNative) { - value = input1.quotient - } - - liquidityInput.push({ - token: input1.currency.isNative - ? zeroAddress - : (input1.currency.wrapped.address as Address), - native: true, - amount: BigInt(input1.quotient.toString()), - }) - } - - return { - account: address, - to: contract.address, - value: value ?? 0n, - data: batchAction({ - actions: [ - approveMasterContractAction({ - signature: signature, - }), - deployNewPoolAction({ - assets: [input0.currency, input1.currency], - factory: factory.address, - feeTier: fee, - twap: false, - }), - encodeFunctionData({ - ...contract, - functionName: 'addLiquidity', - args: [ - liquidityInput, - poolAddress, - BigInt( - pool - .getLiquidityMinted( - totalSupply, - input0.wrapped.toShare(totals?.[token0.wrapped.address]), - input1.wrapped.toShare(totals?.[token1.wrapped.address]), - ) - .quotient.toString(), - ), - encoded, - ], - }), - ], - }), - } satisfies UseCallParameters - } catch (e: unknown) { - console.error(e) - } - }, [ - address, - chain?.id, - contract, - factory, - fee, - input0, - input1, - pool, - poolAddress, - signature, - token0, - token1, - totalSupply, - totals, - ]) - - const { isError: isSimulationError } = useCall({ - ...prepare, - query: { - enabled: Boolean(approved && totals), - }, - }) - - const { - sendTransactionAsync, - isLoading: isWritePending, - data: hash, - } = useSendTransaction({ - mutation: { - onSuccess, - onError, - }, - }) - - const send = useMemo(() => { - if (!prepare || isSimulationError) return - - return async (confirm: () => void) => { - try { - await sendTransactionAsync(prepare) - - confirm() - } catch {} - } - }, [isSimulationError, prepare, sendTransactionAsync]) - - const { status } = useWaitForTransactionReceipt({ chainId, hash }) - - return ( - - - {({ confirm }) => ( - <> - {children} - - - Create pool - - Please review your entered details. - - - - - - - - - )} - - - - ) -} diff --git a/apps/evm/src/ui/pool/FarmRewardsAvailableTooltip.tsx b/apps/evm/src/ui/pool/FarmRewardsAvailableTooltip.tsx index 024cb41617..8d23a65510 100644 --- a/apps/evm/src/ui/pool/FarmRewardsAvailableTooltip.tsx +++ b/apps/evm/src/ui/pool/FarmRewardsAvailableTooltip.tsx @@ -3,7 +3,7 @@ import { TooltipContent, TooltipProvider, TooltipTrigger, -} from '@sushiswap/ui/components/tooltip' +} from '@sushiswap/ui' import { FC } from 'react' export const FarmRewardsAvailableTooltip: FC = () => { diff --git a/apps/evm/src/ui/pool/LiquidityChartRangeInput/Zoom.tsx b/apps/evm/src/ui/pool/LiquidityChartRangeInput/Zoom.tsx index 72cf60e143..c51d9a3d68 100644 --- a/apps/evm/src/ui/pool/LiquidityChartRangeInput/Zoom.tsx +++ b/apps/evm/src/ui/pool/LiquidityChartRangeInput/Zoom.tsx @@ -2,7 +2,7 @@ import { MagnifyingGlassMinusIcon, MagnifyingGlassPlusIcon, } from '@heroicons/react/20/solid' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import { ScaleLinear, ZoomBehavior, diff --git a/apps/evm/src/ui/pool/LiquidityChartRangeInput/index.tsx b/apps/evm/src/ui/pool/LiquidityChartRangeInput/index.tsx index 100fe65bab..e6ee64a76f 100644 --- a/apps/evm/src/ui/pool/LiquidityChartRangeInput/index.tsx +++ b/apps/evm/src/ui/pool/LiquidityChartRangeInput/index.tsx @@ -1,11 +1,11 @@ import { ChartBarIcon, InboxIcon, StopIcon } from '@heroicons/react-v1/solid' -import { SkeletonBox } from '@sushiswap/ui/components/skeleton' +import { SkeletonBox } from '@sushiswap/ui' import { format } from 'd3' import React, { FC, ReactNode, useCallback, useMemo } from 'react' import { Bound } from 'src/lib/constants' import { SushiSwapV3ChainId, SushiSwapV3FeeAmount } from 'sushi/config' import { Price, Token, Type } from 'sushi/currency' -import { getPriceRangeWithTokenRatio } from 'sushi/pool' +import { getPriceRangeWithTokenRatio } from 'sushi/pool/sushiswap-v3' import colors from 'tailwindcss/colors' import { Chart } from './Chart' diff --git a/apps/evm/src/ui/pool/LiquidityDepthWidget.tsx b/apps/evm/src/ui/pool/LiquidityDepthWidget.tsx index b408160619..aa821936ba 100644 --- a/apps/evm/src/ui/pool/LiquidityDepthWidget.tsx +++ b/apps/evm/src/ui/pool/LiquidityDepthWidget.tsx @@ -1,7 +1,7 @@ 'use client' import { useConcentratedLiquidityPoolStats } from '@sushiswap/react-query' -import { SkeletonBox } from '@sushiswap/ui/components/skeleton' +import { SkeletonBox } from '@sushiswap/ui' import React, { FC, useMemo } from 'react' import { Bound } from 'src/lib/constants' import { SushiSwapV3ChainId } from 'sushi/config' diff --git a/apps/evm/src/ui/pool/ManageTridentLiquidityCard.tsx b/apps/evm/src/ui/pool/ManageTridentLiquidityCard.tsx deleted file mode 100644 index 3a8b47ea1c..0000000000 --- a/apps/evm/src/ui/pool/ManageTridentLiquidityCard.tsx +++ /dev/null @@ -1,150 +0,0 @@ -'use client' - -import { Pool } from '@sushiswap/client' -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, - Message, - Separator, - Tabs, - TabsContent, - TabsList, - TabsTrigger, -} from '@sushiswap/ui' -import Link from 'next/link' -import { FC } from 'react' - -import { AddSectionStake } from './AddSectionStake' -import { PoolPositionProvider } from './PoolPositionProvider' -import { PoolPositionRewardsProvider } from './PoolPositionRewardsProvider' -import { PoolPositionStakedProvider } from './PoolPositionStakedProvider' -import { RemoveSectionTrident } from './RemoveSectionTrident' -import { RemoveSectionUnstake } from './RemoveSectionUnstake' - -interface ManageTridentLiquidityCard { - pool: Pool - tab?: 'stake' | 'unstake' | 'add' | 'remove' -} - -export const ManageTridentLiquidityCard: FC = ({ - pool, - tab = 'remove', -}) => { - const isFarm = pool.wasIncentivized || pool.isIncentivized - - return ( - - - Manage - Manage your position - - {}} - className="w-full" - defaultValue={tab} - > - - - - - Remove - - - {isFarm ? ( - - - Stake - - - ) : ( - - Stake - - )} - {isFarm ? ( - - - Unstake - - - ) : ( - - Unstake - - )} - - -
- -
- - - - - - - - - - - {isFarm ? ( - - ) : ( - - No farms available for this pool - - )} - - - - - {isFarm ? ( - - ) : ( - - No farms available for this pool - - )} - - - - - -
-
- ) -} diff --git a/apps/evm/src/ui/pool/MigrateTab.tsx b/apps/evm/src/ui/pool/MigrateTab.tsx index 061b9e029a..188ebe5b55 100644 --- a/apps/evm/src/ui/pool/MigrateTab.tsx +++ b/apps/evm/src/ui/pool/MigrateTab.tsx @@ -33,25 +33,7 @@ import { SettingsModule, SettingsOverlay, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { - V3MigrateChainId, - V3MigrateContractConfig, - getDefaultTTL, - getMasterChefContractConfig, - useAccount, - useMasterChefWithdraw, - useSushiSwapV2Pool, - useTotalSupply, - useTransactionDeadline, - useV3Migrate, - useWaitForTransactionReceipt, -} from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' -import { - useApproved, - withCheckerRoot, -} from '@sushiswap/wagmi/systems/Checker/Provider' +import { Button } from '@sushiswap/ui' import React, { FC, useMemo, useState } from 'react' import { APPROVE_TAG_MIGRATE, @@ -61,6 +43,24 @@ import { } from 'src/lib/constants' import { useGraphPool, useTokenAmountDollarValues } from 'src/lib/hooks' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' +import { getMasterChefContractConfig } from 'src/lib/wagmi/hooks/master-chef/use-master-chef-contract' +import { useMasterChefWithdraw } from 'src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw' +import { + V3MigrateContractConfig, + useV3Migrate, +} from 'src/lib/wagmi/hooks/migrate/hooks/useV3Migrate' +import { V3MigrateChainId } from 'src/lib/wagmi/hooks/migrate/types' +import { useSushiSwapV2Pool } from 'src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools' +import { useTotalSupply } from 'src/lib/wagmi/hooks/tokens/useTotalSupply' +import { + getDefaultTTL, + useTransactionDeadline, +} from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { + useApproved, + withCheckerRoot, +} from 'src/lib/wagmi/systems/Checker/Provider' import { Chain, ChainId } from 'sushi/chain' import { SushiSwapV2ChainId, @@ -75,8 +75,9 @@ import { SushiSwapV3Pool, TickMath, priceToClosestTick, -} from 'sushi/pool' +} from 'sushi/pool/sushiswap-v3' import { Address } from 'viem' +import { useAccount, useWaitForTransactionReceipt } from 'wagmi' import { useConcentratedDerivedMintInfo } from './ConcentratedLiquidityProvider' import { usePoolPosition } from './PoolPositionProvider' import { usePoolPositionStaked } from './PoolPositionStakedProvider' @@ -529,12 +530,12 @@ export const MigrateTab: FC<{ pool: Pool }> = withCheckerRoot(({ pool }) => { size="sm" onClick={() => setInvertPrice((prev) => !prev)} > - 1 {invertPrice ? _token1.symbol : _token0.symbol} ={' '} + 1 {invertPrice ? _token1!.symbol : _token0!.symbol} ={' '} {invertPrice ? `${v2SpotPrice?.invert()?.toSignificant(6)} ${ - _token0.symbol + _token0!.symbol }` - : `${v2SpotPrice?.toSignificant(6)} ${_token1.symbol}`} + : `${v2SpotPrice?.toSignificant(6)} ${_token1!.symbol}`}
) : ( @@ -552,12 +553,12 @@ export const MigrateTab: FC<{ pool: Pool }> = withCheckerRoot(({ pool }) => { size="sm" onClick={() => setInvertPrice((prev) => !prev)} > - 1 {invertPrice ? _token1.symbol : _token0.symbol} ={' '} + 1 {invertPrice ? _token1!.symbol : _token0!.symbol} ={' '} {invertPrice ? `${v3SpotPrice?.invert()?.toSignificant(6)} ${ - _token0.symbol + _token0!.symbol }` - : `${v3SpotPrice?.toSignificant(6)} ${_token1.symbol}`} + : `${v3SpotPrice?.toSignificant(6)} ${_token1!.symbol}`}
) : ( diff --git a/apps/evm/src/ui/pool/MigrateTabContent.tsx b/apps/evm/src/ui/pool/MigrateTabContent.tsx index 4c8fa2246f..e072f41764 100644 --- a/apps/evm/src/ui/pool/MigrateTabContent.tsx +++ b/apps/evm/src/ui/pool/MigrateTabContent.tsx @@ -7,12 +7,12 @@ import { Carousel, Container, } from '@sushiswap/ui' -import { ConnectButton, useAccount } from '@sushiswap/wagmi' import React from 'react' -import { ChainId } from 'sushi/chain' import { isSushiSwapV3ChainId } from 'sushi/config' import { useIsMounted } from '@sushiswap/hooks' +import { ConnectButton } from 'src/lib/wagmi/components/connect-button' +import { useAccount } from 'wagmi' import { PositionCard, PositionCardSkeleton } from './PositionCard' import { PositionCardList } from './PositionCardList' @@ -44,7 +44,7 @@ function MigrateTabContentPositions() { - isSushiSwapV3ChainId(position?.chainId as ChainId), + isSushiSwapV3ChainId(position?.pool.chainId), )} render={(position) => } className="px-2" diff --git a/apps/evm/src/ui/pool/PoolButtons.tsx b/apps/evm/src/ui/pool/PoolButtons.tsx index fb915718dd..38e3cc3bb0 100644 --- a/apps/evm/src/ui/pool/PoolButtons.tsx +++ b/apps/evm/src/ui/pool/PoolButtons.tsx @@ -1,6 +1,6 @@ import { Pool } from '@sushiswap/client' import { LinkInternal } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import Link from 'next/link' import { FC } from 'react' import { ZERO } from 'sushi/math' diff --git a/apps/evm/src/ui/pool/PoolChartGraph.tsx b/apps/evm/src/ui/pool/PoolChartGraph.tsx index 21bb953cec..ccb5738576 100644 --- a/apps/evm/src/ui/pool/PoolChartGraph.tsx +++ b/apps/evm/src/ui/pool/PoolChartGraph.tsx @@ -6,30 +6,34 @@ import { SkeletonText, classNames, } from '@sushiswap/ui' -import { CardDescription, CardTitle } from '@sushiswap/ui/components/card' -import { SkeletonBox } from '@sushiswap/ui/components/skeleton' +import { CardDescription, CardTitle } from '@sushiswap/ui' +import { SkeletonBox } from '@sushiswap/ui' import { format } from 'date-fns' -import ReactECharts from 'echarts-for-react' -import { EChartsOption } from 'echarts-for-react/lib/types' import { FC, useCallback, useMemo } from 'react' import { usePoolGraphData } from 'src/lib/hooks' -import { ChainId } from 'sushi/chain' -import { formatPercent, formatUSD } from 'sushi/format' + +import { formatUSD } from 'sushi/format' import tailwindConfig from 'tailwind.config.js' import resolveConfig from 'tailwindcss/resolveConfig' +import { SushiSwapV2ChainId } from 'sushi/config' import { PoolChartPeriod, chartPeriods } from './PoolChartPeriods' import { PoolChartType } from './PoolChartTypes' +import ReactEchartsCore from 'echarts-for-react/lib/core' +import { EChartsOption } from 'echarts-for-react/lib/types' +import 'echarts/lib/chart/bar' +import 'echarts/lib/chart/line' +import 'echarts/lib/component/tooltip' +import 'echarts/lib/component/visualMap' +import echarts from 'echarts/lib/echarts' +import 'echarts/lib/visual/seriesColor' + interface PoolChartProps { - chart: - | PoolChartType.Volume - | PoolChartType.Fees - | PoolChartType.TVL - | PoolChartType.APR + chart: PoolChartType.Volume | PoolChartType.Fees | PoolChartType.TVL period: PoolChartPeriod address: string - chainId: ChainId + chainId: SushiSwapV2ChainId } const tailwind = resolveConfig(tailwindConfig) @@ -40,12 +44,16 @@ export const PoolChartGraph: FC = ({ address, chainId, }) => { - const { data: graphPair, isLoading } = usePoolGraphData({ + const { + data: graphPair, + isInitialLoading: isLoading, + isError, + } = usePoolGraphData({ poolAddress: address, chainId, }) - const swapFee = graphPair ? graphPair?.swapFee / 10000 : 0 + const swapFee = graphPair ? graphPair?.swapFee : 0 const [xData, yData]: [number[], number[]] = useMemo(() => { const data = @@ -56,16 +64,14 @@ export const PoolChartGraph: FC = ({ const currentDate = Math.round(Date.now()) const [x, y] = data.reduce<[number[], number[]]>( (acc, cur) => { - if (cur.date * 1000 >= currentDate - chartPeriods[period]) { - acc[0].push(cur.date) + if (cur?.date * 1000 >= currentDate - chartPeriods[period]) { + acc[0].push(cur?.date) if (chart === PoolChartType.Fees) { - acc[1].push(Number(cur.volumeUSD * Number(swapFee))) + acc[1].push(Number(cur?.volumeUSD * Number(swapFee))) } else if (chart === PoolChartType.Volume) { - acc[1].push(Number(cur.volumeUSD)) + acc[1].push(Number(cur?.volumeUSD)) } else if (chart === PoolChartType.TVL) { - acc[1].push(Number(cur.liquidityUSD)) - } else if (chart === PoolChartType.APR) { - acc[1].push(Number(cur.apr)) + acc[1].push(Number(cur?.liquidityUSD)) } } return acc @@ -89,11 +95,7 @@ export const PoolChartGraph: FC = ({ const nameNodes = document.getElementsByClassName('hoveredItemName') if (valueNodes[0]) { - if (chart === PoolChartType.APR) { - valueNodes[0].innerHTML = formatPercent(value) - } else { - valueNodes[0].innerHTML = formatUSD(value) - } + valueNodes[0].innerHTML = formatUSD(value) } if (valueNodes[1]) { @@ -129,16 +131,19 @@ export const PoolChartGraph: FC = ({ fontSize: 12, fontWeight: 600, }, + axisPointer: { + lineStyle: { + type: 'dashed', + }, + }, formatter: (params: any) => { onMouseOver({ name: params[0].name, value: params[0].value }) const date = new Date(Number(params[0].name * 1000)) return `
- ${ - chart === PoolChartType.APR - ? formatPercent(params[0].value) - : formatUSD(params[0].value) - } + ${formatUSD( + params[0].value, + )} ${ date instanceof Date && !Number.isNaN(date?.getTime()) ? format( @@ -191,13 +196,11 @@ export const PoolChartGraph: FC = ({ series: [ { name: 'Volume', - type: - chart === PoolChartType.TVL || chart === PoolChartType.APR - ? 'line' - : 'bar', + type: chart === PoolChartType.TVL ? 'line' : 'bar', smooth: true, xAxisIndex: 0, yAxisIndex: 0, + barWidth: '70%', itemStyle: { color: 'blue', normal: { @@ -217,35 +220,35 @@ export const PoolChartGraph: FC = ({ [xData, chart, yData, onMouseOver, period], ) + const defaultValue = yData[yData.length - 1] || 0 + return ( <> - - {chart === PoolChartType.APR - ? formatPercent(yData[yData.length - 1]) - : formatUSD(yData[yData.length - 1])} - {' '} + {formatUSD(defaultValue)}{' '} {chart === PoolChartType.Volume && ( {' '} - {formatUSD(Number(yData[yData.length - 1]) * Number(swapFee))} + {formatUSD(defaultValue * Number(swapFee))} {' '} earned )} - {xData.length ? ( + {isLoading ? ( + + ) : isError || !xData.length ? ( +
+ ) : (
{format( new Date(xData[xData.length - 1] * 1000), 'dd MMM yyyy HH:mm', )}
- ) : ( - )} @@ -256,8 +259,14 @@ export const PoolChartGraph: FC = ({ 'h-[400px] w-full dark:via-slate-800 dark:to-slate-900', )} /> + ) : isError ? ( +
) : ( - + )} diff --git a/apps/evm/src/ui/pool/PoolChartPeriods.tsx b/apps/evm/src/ui/pool/PoolChartPeriods.tsx index 29bda4f1c5..e7b5e9c19c 100644 --- a/apps/evm/src/ui/pool/PoolChartPeriods.tsx +++ b/apps/evm/src/ui/pool/PoolChartPeriods.tsx @@ -1,4 +1,4 @@ -import { Toggle } from '@sushiswap/ui/components/toggle' +import { Toggle } from '@sushiswap/ui' import React, { FC } from 'react' export enum PoolChartPeriod { diff --git a/apps/evm/src/ui/pool/PoolChartTypes.tsx b/apps/evm/src/ui/pool/PoolChartTypes.tsx index 93d484a62f..ef227c0e22 100644 --- a/apps/evm/src/ui/pool/PoolChartTypes.tsx +++ b/apps/evm/src/ui/pool/PoolChartTypes.tsx @@ -1,11 +1,10 @@ -import { Toggle } from '@sushiswap/ui/components/toggle' +import { Toggle } from '@sushiswap/ui' import React from 'react' export enum PoolChartType { Volume = 'Volume', TVL = 'TVL', Fees = 'Fees', - APR = 'APR', Depth = 'Depth', } diff --git a/apps/evm/src/ui/pool/PoolChartV2.tsx b/apps/evm/src/ui/pool/PoolChartV2.tsx index 780a985b31..8f97bdc68e 100644 --- a/apps/evm/src/ui/pool/PoolChartV2.tsx +++ b/apps/evm/src/ui/pool/PoolChartV2.tsx @@ -2,8 +2,8 @@ import { Card } from '@sushiswap/ui' import React, { FC, useState } from 'react' -import { ChainId } from 'sushi/chain' +import { SushiSwapV2ChainId } from 'sushi/config' import { PoolChartGraph } from './PoolChartGraph' import { PoolChartPeriod, PoolChartPeriods } from './PoolChartPeriods' import { PoolChartType, PoolChartTypes } from './PoolChartTypes' @@ -12,7 +12,6 @@ const charts = [ PoolChartType.Volume, PoolChartType.TVL, PoolChartType.Fees, - PoolChartType.APR, ] as const const periods = [ PoolChartPeriod.Day, @@ -24,7 +23,7 @@ const periods = [ interface PoolChartV2Props { address: string - chainId: ChainId + chainId: SushiSwapV2ChainId } const PoolChartV2: FC = ({ address, chainId }) => { diff --git a/apps/evm/src/ui/pool/PoolComposition.tsx b/apps/evm/src/ui/pool/PoolComposition.tsx index 092e0a00ee..26e340cb73 100644 --- a/apps/evm/src/ui/pool/PoolComposition.tsx +++ b/apps/evm/src/ui/pool/PoolComposition.tsx @@ -11,10 +11,10 @@ import { CardHeader, CardLabel, CardTitle, -} from '@sushiswap/ui/components/card' +} from '@sushiswap/ui' import React, { FC, useMemo } from 'react' import { usePoolGraphData, useTokenAmountDollarValues } from 'src/lib/hooks' -import { ChainId } from 'sushi/chain' +import { SushiSwapV2ChainId } from 'sushi/config' import { formatUSD } from 'sushi/format' interface PoolCompositionProps { @@ -24,7 +24,7 @@ interface PoolCompositionProps { export const PoolComposition: FC = ({ pool }) => { const { data, isLoading: isPoolLoading } = usePoolGraphData({ poolAddress: pool.address, - chainId: pool.chainId as ChainId, + chainId: pool.chainId as SushiSwapV2ChainId, }) const amounts = [data?.reserve0, data?.reserve1] diff --git a/apps/evm/src/ui/pool/PoolDepthChart.tsx b/apps/evm/src/ui/pool/PoolDepthChart.tsx index 1113868e60..0e1d599291 100644 --- a/apps/evm/src/ui/pool/PoolDepthChart.tsx +++ b/apps/evm/src/ui/pool/PoolDepthChart.tsx @@ -6,7 +6,6 @@ import { CardTitle, Toggle, } from '@sushiswap/ui' -import ReactECharts, { EChartsOption } from 'echarts-for-react' import { useTheme } from 'next-themes' import React, { FC, useCallback, useMemo, useState } from 'react' import { formatUSD } from 'sushi/format' @@ -14,6 +13,16 @@ import colors from 'tailwindcss/colors' import { ChartEntry } from './LiquidityChartRangeInput/types' +import ReactEChartsCore from 'echarts-for-react/lib/core' +import { EChartsOption } from 'echarts-for-react/lib/types' +import 'echarts/lib/chart/bar' +import 'echarts/lib/chart/line' +import 'echarts/lib/component/markLine' +import 'echarts/lib/component/tooltip' +import 'echarts/lib/component/visualMap' +import echarts from 'echarts/lib/echarts' +import 'echarts/lib/visual/seriesColor' + interface PoolDepthChartProps { poolStats: NonNullable< ReturnType['data'] @@ -23,10 +32,11 @@ interface PoolDepthChartProps { } const getTvlUSD = ( - liquidity: number | string, - totalSupply: number | string, + liquidity: number | bigint | string, + totalLiquidity: number | bigint | string, liquidityUSD: number | string, -) => formatUSD((Number(liquidity) / Number(totalSupply)) * Number(liquidityUSD)) +) => + formatUSD((Number(liquidity) / Number(totalLiquidity)) * Number(liquidityUSD)) export const PoolDepthChart: FC = ({ poolStats, @@ -71,7 +81,7 @@ export const PoolDepthChart: FC = ({ if (valueNodes[0]) { valueNodes[0].innerHTML = `${getTvlUSD( value[1], - Number(poolStats.totalSupply), + Number(poolStats.liquidity), Number(poolStats.liquidityUSD), )}` } @@ -82,12 +92,7 @@ export const PoolDepthChart: FC = ({ } per ${token0.symbol}` } }, - [ - poolStats.liquidityUSD, - poolStats.totalSupply, - token0.symbol, - token1.symbol, - ], + [poolStats.liquidityUSD, poolStats.liquidity, token0.symbol, token1.symbol], ) const DEFAULT_OPTION = useMemo( @@ -110,7 +115,7 @@ export const PoolDepthChart: FC = ({ const tvlUSD = getTvlUSD( params[0].data[1], - poolStats.totalSupply, + poolStats.liquidity, poolStats.liquidityUSD, ) @@ -203,7 +208,7 @@ export const PoolDepthChart: FC = ({ current, resolvedTheme, onMouseOver, - poolStats.totalSupply, + poolStats.liquidity, poolStats.liquidityUSD, token0.symbol, token1.symbol, @@ -229,7 +234,7 @@ export const PoolDepthChart: FC = ({ {getTvlUSD( currentLiquidity, - Number(poolStats.totalSupply), + Number(poolStats.liquidity), Number(poolStats.liquidityUSD), )} @@ -260,7 +265,11 @@ export const PoolDepthChart: FC = ({ - + ) diff --git a/apps/evm/src/ui/pool/PoolHeader.tsx b/apps/evm/src/ui/pool/PoolHeader.tsx index f364779296..a1767a32ac 100644 --- a/apps/evm/src/ui/pool/PoolHeader.tsx +++ b/apps/evm/src/ui/pool/PoolHeader.tsx @@ -15,12 +15,12 @@ import { TooltipContent, TooltipProvider, TooltipTrigger, -} from '@sushiswap/ui/components/tooltip' +} from '@sushiswap/ui' import React, { FC, useMemo } from 'react' import { Chain } from 'sushi/chain' import { Token, unwrapToken } from 'sushi/currency' import { formatPercent, shortenAddress } from 'sushi/format' -import { SushiSwapV3Pool } from 'sushi/pool' +import { SushiSwapV3Pool } from 'sushi/pool/sushiswap-v3' import { APRHoverCard } from './APRHoverCard' @@ -46,6 +46,7 @@ export const PoolHeader: FC = ({ }) => { const [token0, token1] = useMemo(() => { if (!pool) return [undefined, undefined] + if (pool instanceof SushiSwapV3Pool) { return [unwrapToken(pool.token0), unwrapToken(pool.token1)] } diff --git a/apps/evm/src/ui/pool/PoolMyRewards.tsx b/apps/evm/src/ui/pool/PoolMyRewards.tsx index 72f622277d..cbd57cda76 100644 --- a/apps/evm/src/ui/pool/PoolMyRewards.tsx +++ b/apps/evm/src/ui/pool/PoolMyRewards.tsx @@ -1,7 +1,7 @@ 'use client' import { Pool } from '@sushiswap/client' -import { Button } from '@sushiswap/ui/components/button' +import { Button } from '@sushiswap/ui' import { Card, CardContent, @@ -12,11 +12,11 @@ import { CardHeader, CardLabel, CardTitle, -} from '@sushiswap/ui/components/card' -import { Checker } from '@sushiswap/wagmi/systems/Checker' +} from '@sushiswap/ui' import { FC } from 'react' import { formatUSD } from 'sushi/format' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { type ChainId } from 'sushi/chain' import { usePoolPositionRewards } from './PoolPositionRewardsProvider' diff --git a/apps/evm/src/ui/pool/PoolNameCell.tsx b/apps/evm/src/ui/pool/PoolNameCell.tsx index edd59e1f15..2c1ec33cb0 100644 --- a/apps/evm/src/ui/pool/PoolNameCell.tsx +++ b/apps/evm/src/ui/pool/PoolNameCell.tsx @@ -1,132 +1,57 @@ 'use client' -import { Pool, Protocol } from '@sushiswap/client' import { classNames } from '@sushiswap/ui' -import { Badge } from '@sushiswap/ui/components/badge' -import { Currency } from '@sushiswap/ui/components/currency' -import { NetworkIcon } from '@sushiswap/ui/components/icons' +import { Badge } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, -} from '@sushiswap/ui/components/tooltip' -import { Row } from '@tanstack/react-table' +} from '@sushiswap/ui' import { FC } from 'react' import { useTokensFromPool } from 'src/lib/hooks' -import { ChainId } from 'sushi/chain' import { formatNumber } from 'sushi/format' -import { PositionWithPool } from '../../types' +import { PoolHasSteerVaults } from '@sushiswap/steer-sdk' +import { + type PoolBase, + type PoolIfIncentivized, + SushiSwapProtocol, +} from 'sushi' -export const ProtocolBadge: Record = { - [Protocol.BENTOBOX_STABLE]: ( -
- Trident Stable -
- ), - [Protocol.BENTOBOX_CLASSIC]: ( -
- Trident Classic -
- ), - [Protocol.SUSHISWAP_V2]: ( +export const ProtocolBadge: Record = { + // [Protocol.BENTOBOX_STABLE]: ( + //
+ // Trident Stable + //
+ // ), + // [Protocol.BENTOBOX_CLASSIC]: ( + //
+ // Trident Classic + //
+ // ), + [SushiSwapProtocol.SUSHISWAP_V2]: (
V2
), - [Protocol.SUSHISWAP_V3]: ( + [SushiSwapProtocol.SUSHISWAP_V3]: (
V3
), } -export const PoolNameCell: FC> = ({ original }) => { - const { token0, token1 } = useTokensFromPool(original.pool) - - const incentives = original.pool.incentives.filter((i) => i.rewardPerDay > 0) - - return ( -
-
- {token0 && token1 && ( - - } - > - - - - - - )} -
-
- - {token0?.symbol}{' '} - - / - {' '} - {token1?.symbol}{' '} -
- -
- {ProtocolBadge[original.pool.protocol]} -
- {formatNumber(original.pool.swapFee * 100)}% -
- {original.pool.isIncentivized && ( - - - -
- 🧑‍🌾 {incentives.length > 1 - ? `x ${incentives.length}` - : ''}{' '} -
-
- -

Farm rewards available

-
-
-
- )} - {original.pool.hasEnabledSteerVault && ( - - - -
- 💡 -
-
- -

Smart Pool available

-
-
-
- )} -
-
-
- ) -} - -export const PoolNameCellPool: FC<{ pool: Pool }> = ({ pool }) => { +export const PoolNameCell: FC<{ + pool: PoolHasSteerVaults, true> +}> = ({ pool }) => { const { token0, token1 } = useTokensFromPool(pool) - const incentives = pool.incentives.filter((i) => i.rewardPerDay > 0) + const isIncentivized = 'isIncentivized' in pool && pool.isIncentivized + const hasEnabledVault = + 'hasEnabledSteerVault' in pool && pool.hasEnabledSteerVault return (
@@ -136,11 +61,7 @@ export const PoolNameCellPool: FC<{ pool: Pool }> = ({ pool }) => { className="border-2 border-slate-900 rounded-full z-[11]" position="bottom-right" badgeContent={ - + } > @@ -186,14 +107,12 @@ export const PoolNameCellPool: FC<{ pool: Pool }> = ({ pool }) => { - {pool.isIncentivized && ( + {isIncentivized && (
- 🧑‍🌾 {incentives.length > 1 - ? `x ${incentives.length}` - : ''}{' '} + 🧑‍🌾{' '}
@@ -202,7 +121,7 @@ export const PoolNameCellPool: FC<{ pool: Pool }> = ({ pool }) => {
)} - {pool.hasEnabledSteerVault && ( + {hasEnabledVault && ( diff --git a/apps/evm/src/ui/pool/PoolNameCellV3.tsx b/apps/evm/src/ui/pool/PoolNameCellV3.tsx index c0f260fbc4..ec4a899cfa 100644 --- a/apps/evm/src/ui/pool/PoolNameCellV3.tsx +++ b/apps/evm/src/ui/pool/PoolNameCellV3.tsx @@ -1,10 +1,10 @@ import { classNames } from '@sushiswap/ui' -import { Badge } from '@sushiswap/ui/components/badge' -import { Currency } from '@sushiswap/ui/components/currency' -import { NetworkIcon } from '@sushiswap/ui/components/icons' -import { ConcentratedLiquidityPositionWithV3Pool } from '@sushiswap/wagmi' +import { Badge } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' import { Row } from '@tanstack/react-table' import { FC, useMemo } from 'react' +import { ConcentratedLiquidityPositionWithV3Pool } from 'src/lib/wagmi/hooks/positions/types' import { ChainId } from 'sushi/chain' import { Type, unwrapToken } from 'sushi/currency' import { formatNumber } from 'sushi/format' diff --git a/apps/evm/src/ui/pool/PoolPageV2.tsx b/apps/evm/src/ui/pool/PoolPageV2.tsx index b8815cba2c..bc8409694e 100644 --- a/apps/evm/src/ui/pool/PoolPageV2.tsx +++ b/apps/evm/src/ui/pool/PoolPageV2.tsx @@ -1,11 +1,10 @@ import { Container, Separator } from '@sushiswap/ui' import { ManageV2LiquidityCard } from 'src/ui/pool/ManageV2LiquidityCard' import { PoolTransactionsV2 } from 'src/ui/pool/PoolTransactionsV2' -import { ChainId } from 'sushi/chain' -import { Protocol, getPool } from '@sushiswap/client' +import { getPool } from '@sushiswap/client' import { FC } from 'react' -import { ManageTridentLiquidityCard } from './ManageTridentLiquidityCard' +import { SushiSwapV2ChainId } from 'sushi/config' import { PoolChartV2 } from './PoolChartV2' import { PoolComposition } from './PoolComposition' import { PoolMyRewards } from './PoolMyRewards' @@ -29,11 +28,7 @@ export const PoolPageV2: FC = ({ pool, tab }) => {
- {pool.protocol === Protocol.SUSHISWAP_V2 ? ( - - ) : ( - - )} +
@@ -53,7 +48,7 @@ export const PoolPageV2: FC = ({ pool, tab }) => {
diff --git a/apps/evm/src/ui/pool/PoolPageV3.tsx b/apps/evm/src/ui/pool/PoolPageV3.tsx index b085529761..7380375f2a 100644 --- a/apps/evm/src/ui/pool/PoolPageV3.tsx +++ b/apps/evm/src/ui/pool/PoolPageV3.tsx @@ -11,14 +11,12 @@ import { CardDescription, CardHeader, CardTitle, -} from '@sushiswap/ui/components/card' -import { Toggle } from '@sushiswap/ui/components/toggle' -import { - useConcentratedLiquidityPool, - useConcentratedLiquidityPoolReserves, -} from '@sushiswap/wagmi' +} from '@sushiswap/ui' +import { Toggle } from '@sushiswap/ui' import React, { FC, useState } from 'react' import { useTokenAmountDollarValues } from 'src/lib/hooks' +import { useConcentratedLiquidityPool } from 'src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPool' +import { useConcentratedLiquidityPoolReserves } from 'src/lib/wagmi/hooks/pools/hooks/useConcentratedLiquidityPoolReserves' import { SushiSwapV3ChainId } from 'sushi/config' import { formatUSD } from 'sushi/format' import { Address } from 'viem' @@ -155,16 +153,16 @@ const Pool: FC<{ pool: Awaited> }> = ({ pool }) => {
{formatUSD( granularity === Granularity.Week - ? poolStats.volume1w - : poolStats.volume1d ?? 0, + ? poolStats.volumeUSD1w + : poolStats.volumeUSD1d ?? 0, )}{' '} 0 ? 'text-green' : 'text-red', @@ -173,8 +171,8 @@ const Pool: FC<{ pool: Awaited> }> = ({ pool }) => { ( {poolStats[ granularity === Granularity.Week - ? 'volumeChange1w' - : 'volumeChange1d' + ? 'volumeUSD1wChange' + : 'volumeUSD1dChange' ].toFixed(2)} %) @@ -189,16 +187,16 @@ const Pool: FC<{ pool: Awaited> }> = ({ pool }) => {
{formatUSD( granularity === Granularity.Week - ? poolStats.fees1w - : poolStats.fees1d ?? 0, + ? poolStats.feesUSD1w + : poolStats.feesUSD1d ?? 0, )}{' '} 0 ? 'text-green' : 'text-red', @@ -207,8 +205,8 @@ const Pool: FC<{ pool: Awaited> }> = ({ pool }) => { ( {poolStats[ granularity === Granularity.Week - ? 'feesChange1w' - : 'feesChange1d' + ? 'feesUSD1wChange' + : 'feesUSD1dChange' ].toFixed(2)} %) diff --git a/apps/evm/src/ui/pool/PoolPosition.tsx b/apps/evm/src/ui/pool/PoolPosition.tsx index e48d2192c5..49a1fcae22 100644 --- a/apps/evm/src/ui/pool/PoolPosition.tsx +++ b/apps/evm/src/ui/pool/PoolPosition.tsx @@ -7,12 +7,13 @@ import { CardDescription, CardHeader, CardTitle, -} from '@sushiswap/ui/components/card' +} from '@sushiswap/ui' import { FC } from 'react' import { formatUSD } from 'sushi/format' import { SkeletonText } from '@sushiswap/ui' -import { ConnectButton, useAccount } from '@sushiswap/wagmi' +import { ConnectButton } from 'src/lib/wagmi/components/connect-button' +import { useAccount } from 'wagmi' import { PoolPositionDesktop } from './PoolPositionDesktop' import { usePoolPosition } from './PoolPositionProvider' import { PoolPositionStakedDesktop } from './PoolPositionStakedDesktop' diff --git a/apps/evm/src/ui/pool/PoolPositionDesktop.tsx b/apps/evm/src/ui/pool/PoolPositionDesktop.tsx index 7d8c0cb2d0..858bbf361a 100644 --- a/apps/evm/src/ui/pool/PoolPositionDesktop.tsx +++ b/apps/evm/src/ui/pool/PoolPositionDesktop.tsx @@ -1,9 +1,5 @@ import { Pool } from '@sushiswap/client' -import { - CardCurrencyAmountItem, - CardGroup, - CardLabel, -} from '@sushiswap/ui/components/card' +import { CardCurrencyAmountItem, CardGroup, CardLabel } from '@sushiswap/ui' import { FC } from 'react' import { formatUSD } from 'sushi/format' diff --git a/apps/evm/src/ui/pool/PoolPositionProvider.tsx b/apps/evm/src/ui/pool/PoolPositionProvider.tsx index a9284abd22..808719a82e 100644 --- a/apps/evm/src/ui/pool/PoolPositionProvider.tsx +++ b/apps/evm/src/ui/pool/PoolPositionProvider.tsx @@ -1,16 +1,16 @@ 'use client' -import { Pool } from '@sushiswap/client' -import { useAccount } from '@sushiswap/wagmi' -import { useBalanceWeb3 } from '@sushiswap/wagmi' import { FC, ReactNode, createContext, useContext, useMemo } from 'react' import { useGraphPool, useTokenAmountDollarValues, useUnderlyingTokenBalanceFromPool, } from 'src/lib/hooks' +import { useBalanceWeb3 } from 'src/lib/wagmi/hooks/balances/useBalanceWeb3' import { ChainId } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' +import type { PoolId } from 'sushi/types' +import { useAccount } from 'wagmi' interface PoolPositionContext { balance: Amount | null | undefined @@ -25,7 +25,7 @@ interface PoolPositionContext { const Context = createContext(undefined) export const PoolPositionProvider: FC<{ - pool: Pool + pool: PoolId children: ReactNode watch?: boolean }> = ({ pool, children }) => { diff --git a/apps/evm/src/ui/pool/PoolPositionRewardsProvider.tsx b/apps/evm/src/ui/pool/PoolPositionRewardsProvider.tsx index 5bbe10e559..0557938dc3 100644 --- a/apps/evm/src/ui/pool/PoolPositionRewardsProvider.tsx +++ b/apps/evm/src/ui/pool/PoolPositionRewardsProvider.tsx @@ -1,17 +1,18 @@ 'use client' -import { ChefType, Pool } from '@sushiswap/client' -import { - RewarderType, - useAccount, - useMasterChef, - useRewarder, -} from '@sushiswap/wagmi' +import { ChefType } from '@sushiswap/client' import { FC, ReactNode, createContext, useContext, useMemo } from 'react' import { incentiveRewardToToken } from 'src/lib/functions' import { useTokenAmountDollarValues, useTokensFromPool } from 'src/lib/hooks' +import { useMasterChef } from 'src/lib/wagmi/hooks/master-chef/use-master-chef' +import { + RewarderType, + useRewarder, +} from 'src/lib/wagmi/hooks/master-chef/use-rewarder' import { ChainId } from 'sushi/chain' import { Amount, Token } from 'sushi/currency' +import type { Incentive, PoolBase, PoolWithIncentives } from 'sushi/types' +import { useAccount } from 'wagmi' interface PoolPositionRewardsContext { pendingRewards: (Amount | undefined)[] @@ -25,15 +26,15 @@ interface PoolPositionRewardsContext { const Context = createContext(undefined) interface PoolPositionRewardsProviderProps { - pool: Pool + pool: PoolBase farmId: number chefType: ChefType children: ReactNode - incentives: Pool['incentives'] + incentives: Incentive[] } interface PoolPositionStakedProviderProps { - pool: Pool + pool: PoolWithIncentives children: ReactNode } @@ -92,7 +93,7 @@ export const _PoolPositionRewardsProvider: FC< const { data: pendingRewards, - isLoading, + isInitialLoading: isLoading, isError, } = useRewarder({ chainId: pool.chainId as ChainId, diff --git a/apps/evm/src/ui/pool/PoolPositionStakedDesktop.tsx b/apps/evm/src/ui/pool/PoolPositionStakedDesktop.tsx index 7d9d37477c..16bc5367ac 100644 --- a/apps/evm/src/ui/pool/PoolPositionStakedDesktop.tsx +++ b/apps/evm/src/ui/pool/PoolPositionStakedDesktop.tsx @@ -1,9 +1,5 @@ import { Pool } from '@sushiswap/client' -import { - CardCurrencyAmountItem, - CardGroup, - CardLabel, -} from '@sushiswap/ui/components/card' +import { CardCurrencyAmountItem, CardGroup, CardLabel } from '@sushiswap/ui' import { FC } from 'react' import { formatUSD } from 'sushi/format' diff --git a/apps/evm/src/ui/pool/PoolPositionStakedProvider.tsx b/apps/evm/src/ui/pool/PoolPositionStakedProvider.tsx index 4bbd2f9cd4..8b5c4db0d0 100644 --- a/apps/evm/src/ui/pool/PoolPositionStakedProvider.tsx +++ b/apps/evm/src/ui/pool/PoolPositionStakedProvider.tsx @@ -1,13 +1,14 @@ 'use client' -import { ChefType, Pool } from '@sushiswap/client' -import { useMasterChef } from '@sushiswap/wagmi' +import { ChefType } from '@sushiswap/client' import { FC, ReactNode, createContext, useContext, useMemo } from 'react' import { useGraphPool, useTokenAmountDollarValues, useUnderlyingTokenBalanceFromPool, } from 'src/lib/hooks' +import { useMasterChef } from 'src/lib/wagmi/hooks/master-chef/use-master-chef' +import type { PoolId, PoolWithIncentives } from 'sushi' import { ChainId } from 'sushi/chain' import { Amount, Currency, Token } from 'sushi/currency' @@ -26,7 +27,7 @@ interface PoolPositionStakedContext { const Context = createContext(undefined) interface PoolPositionStakedProviderProps { - pool: Pool + pool: PoolWithIncentives children: ReactNode watch?: boolean } @@ -65,7 +66,7 @@ export const PoolPositionStakedProvider: FC = } interface _PoolPositionStakedProviderProps { - pool: Pool + pool: PoolId children: ReactNode farmId: number chefType: ChefType @@ -82,6 +83,7 @@ const _PoolPositionStakedProvider: FC<_PoolPositionStakedProviderProps> = ({ const { data: { reserve0, reserve1, totalSupply, liquidityToken }, } = useGraphPool(pool) + const { balance, isLoading, isError, isWritePending, isWriteError } = useMasterChef({ chainId: pool.chainId as ChainId, diff --git a/apps/evm/src/ui/pool/PoolQuickHoverTooltip.tsx b/apps/evm/src/ui/pool/PoolQuickHoverTooltip.tsx index 3a7d08aab2..5304660922 100644 --- a/apps/evm/src/ui/pool/PoolQuickHoverTooltip.tsx +++ b/apps/evm/src/ui/pool/PoolQuickHoverTooltip.tsx @@ -1,9 +1,9 @@ import { PlusIcon, UserCircleIcon } from '@heroicons/react-v1/solid' import { Pool, Protocol } from '@sushiswap/client' import { LinkInternal } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Currency } from '@sushiswap/ui/components/currency' -import { List } from '@sushiswap/ui/components/list/List' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' import React, { FC } from 'react' import { incentiveRewardToToken } from 'src/lib/functions' import { ChainId } from 'sushi/chain' diff --git a/apps/evm/src/ui/pool/PoolRewards.tsx b/apps/evm/src/ui/pool/PoolRewards.tsx index 7947410aac..2492305fb0 100644 --- a/apps/evm/src/ui/pool/PoolRewards.tsx +++ b/apps/evm/src/ui/pool/PoolRewards.tsx @@ -9,7 +9,7 @@ import { CardLabel, CardTitle, } from '@sushiswap/ui' -import { Card, CardDescription } from '@sushiswap/ui/components/card' +import { Card, CardDescription } from '@sushiswap/ui' import React, { FC } from 'react' import { incentiveRewardToToken } from 'src/lib/functions' import { ChainId } from 'sushi/chain' diff --git a/apps/evm/src/ui/pool/PoolRewardsCell.tsx b/apps/evm/src/ui/pool/PoolRewardsCell.tsx index a064459bdb..e7ac91eaca 100644 --- a/apps/evm/src/ui/pool/PoolRewardsCell.tsx +++ b/apps/evm/src/ui/pool/PoolRewardsCell.tsx @@ -1,4 +1,4 @@ -import { Currency } from '@sushiswap/ui/components/currency' +import { Currency } from '@sushiswap/ui' import { Row } from '@tanstack/react-table' import { FC } from 'react' import { ChainId } from 'sushi/chain' diff --git a/apps/evm/src/ui/pool/PoolStats.tsx b/apps/evm/src/ui/pool/PoolStats.tsx index 2f4bfaeaca..a937817a39 100644 --- a/apps/evm/src/ui/pool/PoolStats.tsx +++ b/apps/evm/src/ui/pool/PoolStats.tsx @@ -9,10 +9,10 @@ import { CardTitle, classNames, } from '@sushiswap/ui' -import { SkeletonText } from '@sushiswap/ui/components/skeleton' +import { SkeletonText } from '@sushiswap/ui' import { FC } from 'react' import { usePoolGraphData } from 'src/lib/hooks' -import { ChainId } from 'sushi/chain' +import { SushiSwapV2ChainId } from 'sushi/config' import { formatNumber, formatPercent, formatUSD } from 'sushi/format' interface PoolStats { @@ -22,7 +22,7 @@ interface PoolStats { export const PoolStats: FC = ({ pool }) => { const { data, isLoading } = usePoolGraphData({ poolAddress: pool.address, - chainId: pool.chainId as ChainId, + chainId: pool.chainId as SushiSwapV2ChainId, }) return ( diff --git a/apps/evm/src/ui/pool/PoolTransactionsV2.tsx b/apps/evm/src/ui/pool/PoolTransactionsV2.tsx index 20157e7610..4792113416 100644 --- a/apps/evm/src/ui/pool/PoolTransactionsV2.tsx +++ b/apps/evm/src/ui/pool/PoolTransactionsV2.tsx @@ -1,8 +1,6 @@ 'use client' import { Pool } from '@sushiswap/client' -import { getBuiltGraphSDK } from '@sushiswap/graph-client' -import { SUSHISWAP_SUBGRAPH_URL } from '@sushiswap/graph-config' import { Card, CardContent, @@ -10,13 +8,19 @@ import { CardTitle, DataTable, } from '@sushiswap/ui' -import { Toggle } from '@sushiswap/ui/components/toggle' +import { Toggle } from '@sushiswap/ui' import { useQuery } from '@tanstack/react-query' import { PaginationState } from '@tanstack/react-table' import React, { FC, useMemo, useState } from 'react' import { Chain, ChainId } from 'sushi/chain' import { SushiSwapV2ChainId, isSushiSwapV2ChainId } from 'sushi/config' +import { + getSushiV2Burns, + getSushiV2Mints, + getSushiV2Swaps, + getSushiV2Transactions, +} from '../../../../../packages/graph-client/dist/subgraphs/sushi-v2' import { TX_AMOUNT_IN_V2_COLUMN, TX_AMOUNT_OUT_V2_COLUMN, @@ -43,11 +47,8 @@ const fetchAll = async ( chainId: SushiSwapV2ChainId, opts: UseTransactionsV2Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_SUBGRAPH_URL[chainId], - }) - - const { transactions } = await sdk.V2Transactions({ + const transactions = await getSushiV2Transactions({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { @@ -72,6 +73,8 @@ const fetchAll = async ( }, ], }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return transactions @@ -82,14 +85,13 @@ const fetchMints = async ( chainId: SushiSwapV2ChainId, opts: UseTransactionsV2Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_SUBGRAPH_URL[chainId], - }) - - const { mints } = await sdk.V2Mints({ + const mints = await getSushiV2Mints({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { pair: poolId.toLowerCase() }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return mints.map((mint) => ({ @@ -105,19 +107,19 @@ const fetchBurns = async ( chainId: SushiSwapV2ChainId, opts: UseTransactionsV2Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_SUBGRAPH_URL[chainId], - }) - - const { burns } = await sdk.V2Burns({ + const burns = await getSushiV2Burns({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { pair: poolId.toLowerCase(), - amount0_not: null, - amount1_not: null, - sender_not: null, + // TODO: disbled for now, according to the types this can never be null so not sure if we need it anymore + // amount0_not: null, + // amount1_not: null, + // sender_not: null, }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return burns.map((burn) => ({ @@ -133,14 +135,13 @@ const fetchSwaps = async ( chainId: SushiSwapV2ChainId, opts: UseTransactionsV2Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_SUBGRAPH_URL[chainId], - }) - - const { swaps } = await sdk.V2Swaps({ + const swaps = await getSushiV2Swaps({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { pair: poolId.toLowerCase() }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return swaps.map((swap) => ({ @@ -213,8 +214,12 @@ function useTransactionsV2( ...swap, sender: String(swap.sender), to: String(swap.to), - amountIn: Number(swap.amountIn), - amountOut: Number(swap.amountOut), + amountIn: Number( + swap.amount0In !== '0' ? swap.amount0In : swap.amount1In, + ), + amountOut: Number( + swap.amount0Out !== '0' ? swap.amount0Out : swap.amount1Out, + ), type: TransactionType.Swap as const, })) diff --git a/apps/evm/src/ui/pool/PoolTransactionsV3.tsx b/apps/evm/src/ui/pool/PoolTransactionsV3.tsx index 3d36c607ff..30514730de 100644 --- a/apps/evm/src/ui/pool/PoolTransactionsV3.tsx +++ b/apps/evm/src/ui/pool/PoolTransactionsV3.tsx @@ -1,8 +1,6 @@ 'use client' import { Pool } from '@sushiswap/client' -import { getBuiltGraphSDK } from '@sushiswap/graph-client' -import { SUSHISWAP_V3_SUBGRAPH_URL } from '@sushiswap/graph-config' import { Card, CardContent, @@ -10,13 +8,20 @@ import { CardTitle, DataTable, } from '@sushiswap/ui' -import { Toggle } from '@sushiswap/ui/components/toggle' +import { Toggle } from '@sushiswap/ui' import { useQuery } from '@tanstack/react-query' import { PaginationState } from '@tanstack/react-table' import React, { FC, useMemo, useState } from 'react' import { Chain, ChainId } from 'sushi/chain' import { SushiSwapV3ChainId, isSushiSwapV3ChainId } from 'sushi/config' +import { + getSushiV3Burns, + getSushiV3Collects, + getSushiV3Mints, + getSushiV3Swaps, + getSushiV3Transactions, +} from '../../../../../packages/graph-client/dist/subgraphs/sushi-v3' import { TX_AMOUNT_IN_V3_COLUMN, TX_AMOUNT_OUT_V3_COLUMN, @@ -44,11 +49,8 @@ const fetchAll = async ( chainId: SushiSwapV3ChainId, opts: UseTransactionsV3Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_V3_SUBGRAPH_URL[chainId], - }) - - const { transactions } = await sdk.V3Transactions({ + const transactions = await getSushiV3Transactions({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { @@ -75,6 +77,8 @@ const fetchAll = async ( }, ], }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return transactions @@ -85,14 +89,13 @@ const fetchMints = async ( chainId: SushiSwapV3ChainId, opts: UseTransactionsV3Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_V3_SUBGRAPH_URL[chainId], - }) - - const { mints } = await sdk.V3Mints({ + const mints = await getSushiV3Mints({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { pool: poolId.toLowerCase() }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return mints.map((mint) => ({ @@ -109,14 +112,13 @@ const fetchBurns = async ( chainId: SushiSwapV3ChainId, opts: UseTransactionsV3Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_V3_SUBGRAPH_URL[chainId], - }) - - const { burns } = await sdk.V3Burns({ + const burns = await getSushiV3Burns({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { pool: poolId.toLowerCase() }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return burns.map((burn) => ({ @@ -133,14 +135,13 @@ const fetchSwaps = async ( chainId: SushiSwapV3ChainId, opts: UseTransactionsV3Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_V3_SUBGRAPH_URL[chainId], - }) - - const { swaps } = await sdk.V3Swaps({ + const swaps = await getSushiV3Swaps({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { pool: poolId.toLowerCase() }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return swaps.map((swap) => ({ @@ -157,14 +158,13 @@ const fetchCollects = async ( chainId: SushiSwapV3ChainId, opts: UseTransactionsV3Opts, ) => { - const sdk = getBuiltGraphSDK({ - url: SUSHISWAP_V3_SUBGRAPH_URL[chainId], - }) - - const { collects } = await sdk.V3Collects({ + const collects = await getSushiV3Collects({ + chainId, first: opts.first, skip: opts?.skip ?? 0, where: { pool: poolId.toLowerCase() }, + orderBy: 'timestamp', + orderDirection: 'desc', }) return collects.map((collect) => ({ diff --git a/apps/evm/src/ui/pool/PoolsFiltersProvider.tsx b/apps/evm/src/ui/pool/PoolsFiltersProvider.tsx index ce8f59bb01..3dde44c6f3 100644 --- a/apps/evm/src/ui/pool/PoolsFiltersProvider.tsx +++ b/apps/evm/src/ui/pool/PoolsFiltersProvider.tsx @@ -11,7 +11,7 @@ import { useContext, useMemo, } from 'react' -import { SUPPORTED_CHAIN_IDS } from 'src/config' +import { SUPPORTED_CHAIN_IDS, isSupportedChainId } from 'src/config' import { z } from 'zod' import { useTypedSearchParams } from '../../lib/hooks' @@ -39,7 +39,8 @@ export const poolFiltersSchema = z.object({ chainIds !== null && chainIds !== ',' ? chainIds.split(',').map((chainId) => Number(chainId)) : SUPPORTED_CHAIN_IDS, - ), + ) + .transform((chainIds) => chainIds.filter(isSupportedChainId)), protocols: z .string() .transform((protocols) => diff --git a/apps/evm/src/ui/pool/PoolsTable.tsx b/apps/evm/src/ui/pool/PoolsTable.tsx index 7a5b2a8e6d..1182b1b2f7 100644 --- a/apps/evm/src/ui/pool/PoolsTable.tsx +++ b/apps/evm/src/ui/pool/PoolsTable.tsx @@ -11,7 +11,7 @@ import { PlusIcon, } from '@heroicons/react/24/outline' import { Slot } from '@radix-ui/react-slot' -import { GetPoolsArgs, Pool, Protocol } from '@sushiswap/client' +import { GetPoolsArgs } from '@sushiswap/client' import { Button, Card, @@ -42,26 +42,37 @@ import { Native } from 'sushi/currency' import { useSWRConfig } from 'swr' import { usePoolCount, usePoolsInfinite } from '@sushiswap/client/hooks' +import { PoolHasSteerVaults } from '@sushiswap/steer-sdk' import { isAngleEnabledChainId } from 'sushi/config' +import { + PoolBase, + PoolHistory, + PoolIfIncentivized, + unnestPool, +} from 'sushi/types' import { usePoolFilters } from './PoolsFiltersProvider' import { - APR_COLUMN_POOL, + APR_COLUMN, FEES_COLUMN, NAME_COLUMN_POOL, TVL_COLUMN, VOLUME_1D_COLUMN, VOLUME_1M_COLUMN, - VOLUME_7D_COLUMN, + VOLUME_1W_COLUMN, } from './columns' +type RequiredPool = PoolHasSteerVaults< + PoolIfIncentivized> +> + const COLUMNS = [ NAME_COLUMN_POOL, TVL_COLUMN, VOLUME_1D_COLUMN, - VOLUME_7D_COLUMN, + VOLUME_1W_COLUMN, VOLUME_1M_COLUMN, FEES_COLUMN, - APR_COLUMN_POOL, + APR_COLUMN, { id: 'actions', cell: ({ row }) => @@ -197,16 +208,6 @@ const COLUMNS = [ {row.original.token0.symbol} / {row.original.token1.symbol} - {row.original.protocol === Protocol.BENTOBOX_STABLE && ( - - Trident Stable - - )} - {row.original.protocol === Protocol.BENTOBOX_CLASSIC && ( - - Trident Classic - - )} {row.original.protocol === 'SUSHISWAP_V2' && ( SushiSwap V2 @@ -287,11 +288,11 @@ const COLUMNS = [ disableLink: true, skeleton: , }, - }, -] satisfies ColumnDef[] + } satisfies ColumnDef, +] as ColumnDef[] interface PositionsTableProps { - onRowClick?(row: Pool): void + onRowClick?(row: RequiredPool): void } export const PoolsTable: FC = ({ onRowClick }) => { @@ -325,6 +326,7 @@ export const PoolsTable: FC = ({ onRowClick }) => { shouldFetch: true, swrConfig: useSWRConfig(), }) + const data = useMemo(() => pools?.flat() || [], [pools]) const state: Partial = useMemo(() => { @@ -338,7 +340,7 @@ export const PoolsTable: FC = ({ onRowClick }) => { }, [data?.length, sorting]) const rowRenderer = useCallback( - (row: Row, rowNode: ReactNode) => { + (row: Row, rowNode: ReactNode) => { if (onRowClick) return ( = ({ onRowClick }) => { state={state} onSortingChange={setSorting} loading={!pools && isValidating} - linkFormatter={(row) => `/pool/${row.chainId}%3A${row.address}`} + linkFormatter={(row) => + `/pool/${unnestPool(row).chainId}%3A${unnestPool(row).address}` + } rowRenderer={rowRenderer} columns={COLUMNS} data={data} diff --git a/apps/evm/src/ui/pool/PositionCard.tsx b/apps/evm/src/ui/pool/PositionCard.tsx index 1a67344d11..1390afbd77 100644 --- a/apps/evm/src/ui/pool/PositionCard.tsx +++ b/apps/evm/src/ui/pool/PositionCard.tsx @@ -1,21 +1,21 @@ import { LinkInternal } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Currency } from '@sushiswap/ui/components/currency' -import { SkeletonCircle, SkeletonText } from '@sushiswap/ui/components/skeleton' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { SkeletonCircle, SkeletonText } from '@sushiswap/ui' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, -} from '@sushiswap/ui/components/tooltip' +} from '@sushiswap/ui' import React, { FC } from 'react' +import { UserWithPool } from 'src/app/pool/api/user-with-pools/route' import { useTokensFromPool } from 'src/lib/hooks' -import { PositionWithPool } from 'src/types' import { Chain } from 'sushi/chain' import { formatNumber, formatUSD } from 'sushi/format' interface PositionCard { - position: PositionWithPool + position: UserWithPool } export const PositionCardSkeleton = () => { @@ -44,12 +44,13 @@ export const PositionCardSkeleton = () => { export const PositionCard: FC = ({ position }) => { const { token0, token1 } = useTokensFromPool(position.pool) const valueUSD = - (Number(position.balance) / Number(position.pool.totalSupply)) * + (Number(position.unstakedBalance) / Number(position.pool.liquidity)) * Number(position.pool.liquidityUSD) + return (
- {Chain.from(position.chainId)?.name} + {Chain.from(position.pool.chainId)?.name}

{token0.symbol}/{token1.symbol}{' '} @@ -76,9 +77,6 @@ export const PositionCard: FC = ({ position }) => {
🧑‍🌾{' '} - {position.pool.incentives.length > 1 - ? `x ${position.pool.incentives.length}` - : ''}{' '}
diff --git a/apps/evm/src/ui/pool/PositionCardList.tsx b/apps/evm/src/ui/pool/PositionCardList.tsx index dcc6dac66c..95fbd60e44 100644 --- a/apps/evm/src/ui/pool/PositionCardList.tsx +++ b/apps/evm/src/ui/pool/PositionCardList.tsx @@ -1,38 +1,38 @@ -import { Protocol } from '@sushiswap/client' -import { useAccount } from '@sushiswap/wagmi' import React, { FC, ReactNode } from 'react' +import type { UserWithPool } from 'src/app/pool/api/user-with-pools/route' import { SUPPORTED_CHAIN_IDS } from 'src/config' -import { useUserPositions } from 'src/lib/hooks' -import { PositionWithPool } from 'src/types' +import { useSushiV2UserPositions } from 'src/lib/hooks' +import { useAccount } from 'wagmi' interface PositionCardList { children({ positions, isLoading, - }: { positions: PositionWithPool[]; isLoading: boolean }): ReactNode + }: { + positions: UserWithPool[] + isLoading: boolean + }): ReactNode } -const value = (position: PositionWithPool) => - (Number(position.balance + position.stakedBalance) / - Number(position.pool.totalSupply)) * +const value = (position: UserWithPool) => + (Number(position.unstakedBalance + position.stakedBalance) / + Number(position.pool.liquidity)) * Number(position.pool.liquidityUSD) export const PositionCardList: FC = ({ children }) => { const { address } = useAccount() - const { data: userPositions, isValidating } = useUserPositions({ - id: address, + const { data: userPositions, isLoading } = useSushiV2UserPositions({ + id: address!, chainIds: SUPPORTED_CHAIN_IDS, }) return ( <> {children({ - positions: isValidating + positions: isLoading ? new Array(6).fill(null) - : (userPositions || []) - .filter((el) => el.pool.protocol === Protocol.SUSHISWAP_V2) - .sort((a, b) => value(b) - value(a)), - isLoading: isValidating, + : (userPositions || []).sort((a, b) => value(b) - value(a)), + isLoading, })} ) diff --git a/apps/evm/src/ui/pool/PositionQuickHoverTooltip.tsx b/apps/evm/src/ui/pool/PositionQuickHoverTooltip.tsx index c9d04472ff..dc258dd58d 100644 --- a/apps/evm/src/ui/pool/PositionQuickHoverTooltip.tsx +++ b/apps/evm/src/ui/pool/PositionQuickHoverTooltip.tsx @@ -1,15 +1,21 @@ import { ArrowDownIcon, MinusIcon, PlusIcon } from '@heroicons/react-v1/solid' -import { Button } from '@sushiswap/ui/components/button' -import { Currency } from '@sushiswap/ui/components/currency' -import { LinkInternal } from '@sushiswap/ui/components/link' -import { List } from '@sushiswap/ui/components/list' -import { useAccount, useSwitchChain } from '@sushiswap/wagmi' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { LinkInternal } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' import React, { FC, useCallback } from 'react' -import { PositionWithPool } from 'src/types' import { formatPercent, formatUSD } from 'sushi/format' import { ZERO } from 'sushi/math' +import type { + PoolBase, + PoolWithAprs, + PoolWithIncentives, + SushiPositionStaked, + SushiPositionWithPool, +} from 'sushi' import { ChainId } from 'sushi/chain' +import { useAccount, useSwitchChain } from 'wagmi' import { PoolPositionProvider, usePoolPosition } from './PoolPositionProvider' import { PoolPositionRewardsProvider, @@ -21,7 +27,9 @@ import { } from './PoolPositionStakedProvider' interface PositionQuickHoverTooltipProps { - row: PositionWithPool + row: SushiPositionStaked< + SushiPositionWithPool>> + > } export const PositionQuickHoverTooltip: FC = ({ diff --git a/apps/evm/src/ui/pool/PositionView.tsx b/apps/evm/src/ui/pool/PositionView.tsx index 3f6a7f4704..bd948ff055 100644 --- a/apps/evm/src/ui/pool/PositionView.tsx +++ b/apps/evm/src/ui/pool/PositionView.tsx @@ -30,24 +30,22 @@ import { WidgetAction, classNames, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { FormattedNumber } from '@sushiswap/ui/components/formatted-number' -import { SkeletonText } from '@sushiswap/ui/components/skeleton' -import { - getDefaultTTL, - useAccount, - useConcentratedLiquidityPositionsFromTokenId, - useConcentratedPositionInfo, - useConcentratedPositionOwner, - useTokenWithCache, -} from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' +import { Button } from '@sushiswap/ui' +import { FormattedNumber } from '@sushiswap/ui' +import { SkeletonText } from '@sushiswap/ui' import { FC, useMemo, useState } from 'react' +import { useConcentratedPositionInfo } from 'src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionInfo' +import { useConcentratedPositionOwner } from 'src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionOwner' +import { useConcentratedLiquidityPositionsFromTokenId } from 'src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenId' +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 } from 'sushi/chain' import { SushiSwapV3ChainId, isAngleEnabledChainId } from 'sushi/config' import { Amount, unwrapToken } from 'sushi/currency' import { formatUSD } from 'sushi/format' import { getAddress } from 'viem' +import { useAccount } from 'wagmi' import { Bound } from '../../lib/constants' import { formatTickPrice, @@ -90,7 +88,7 @@ const Component: FC<{ id: string }> = ({ id }) => { address: positionDetails?.token1, }) - const { data: position, isLoading: isPositionLoading } = + const { data: position, isInitialLoading: isPositionLoading } = useConcentratedPositionInfo({ chainId, token0, diff --git a/apps/evm/src/ui/pool/PositionsTab.tsx b/apps/evm/src/ui/pool/PositionsTab.tsx index 4a79cf963a..3c466694f6 100644 --- a/apps/evm/src/ui/pool/PositionsTab.tsx +++ b/apps/evm/src/ui/pool/PositionsTab.tsx @@ -1,4 +1,3 @@ -import { Protocol } from '@sushiswap/client' import { Select, SelectContent, @@ -41,26 +40,6 @@ const ITEMS: { id: string; value: string; children: React.ReactNode }[] = [

), }, - { - id: 'trident-stable', - value: 'stable', - children: ( -
- 🍱 - Trident Stable -
- ), - }, - { - id: 'trident-classic', - value: 'classic', - children: ( -
- 🍱 - Trident Classic -
- ), - }, { id: 'sushiswap-smart', value: 'smart', @@ -110,22 +89,7 @@ export const PositionsTab = () => { - `/pool/${row.pool.id}`} - /> - - - `/pool/${row.pool.id}`} - /> - - - `/pool/${row.pool.id}`} - /> + `/pool/${row.pool.id}`} /> diff --git a/apps/evm/src/ui/pool/PositionsTable.tsx b/apps/evm/src/ui/pool/PositionsTable.tsx index e31fd26be2..142280b069 100644 --- a/apps/evm/src/ui/pool/PositionsTable.tsx +++ b/apps/evm/src/ui/pool/PositionsTable.tsx @@ -1,36 +1,30 @@ -import { Protocol } from '@sushiswap/client' import { Card, CardHeader, CardTitle, DataTable } from '@sushiswap/ui' -import { Slot } from '@sushiswap/ui/components/slot' -import { useAccount } from '@sushiswap/wagmi' -import { ColumnDef, PaginationState, Row } from '@tanstack/react-table' +import { Slot } from '@sushiswap/ui' +import { DisplayColumnDef, PaginationState, Row } from '@tanstack/react-table' import React, { FC, ReactNode, useCallback, useMemo, useState } from 'react' import { SUPPORTED_CHAIN_IDS } from 'src/config' -import { useUserPositions } from 'src/lib/hooks' -import { PositionWithPool } from 'src/types' +import { useSushiV2UserPositions } from 'src/lib/hooks' +import type { UserWithPool } from 'src/app/pool/api/user-with-pools/route' +import { useAccount } from 'wagmi' import { usePoolFilters } from './PoolsFiltersProvider' -import { - APR_COLUMN, - NAME_COLUMN_POSITION_WITH_POOL, - VALUE_COLUMN, -} from './columns' +import { APR_COLUMN, NAME_COLUMN_POOL, VALUE_COLUMN } from './columns' +// ! Column types have to be checked manually const COLUMNS = [ - NAME_COLUMN_POSITION_WITH_POOL, + NAME_COLUMN_POOL, VALUE_COLUMN, APR_COLUMN, -] satisfies ColumnDef[] +] as DisplayColumnDef[] interface PositionsTableProps { - protocol: Protocol - onRowClick?(row: PositionWithPool): void - rowLink?(row: PositionWithPool): string + onRowClick?(row: UserWithPool): void + rowLink?(row: UserWithPool): string } const tableState = { sorting: [{ id: 'value', desc: true }] } export const PositionsTable: FC = ({ - protocol, onRowClick, rowLink, }) => { @@ -41,9 +35,9 @@ export const PositionsTable: FC = ({ pageSize: 10, }) - const { data: positions, isValidating } = useUserPositions( + const { data: positions, isLoading } = useSushiV2UserPositions( { - id: address, + id: address!, chainIds: SUPPORTED_CHAIN_IDS, }, !!address, @@ -62,14 +56,15 @@ export const PositionsTable: FC = ({ }) : true, ) + const chainFiltered = searchFiltered.filter((el) => - chainIds.includes(el.chainId), + chainIds.includes(el.pool.chainId as (typeof chainIds)[number]), ) - return chainFiltered.filter((el) => el.pool?.protocol === protocol) - }, [positions, tokenSymbols, chainIds, protocol]) + return chainFiltered + }, [positions, tokenSymbols, chainIds]) const rowRenderer = useCallback( - (row: Row, rowNode: ReactNode) => { + (row: Row, rowNode: ReactNode) => { if (onRowClick) return ( = ({ > = ({ original }) => { diff --git a/apps/evm/src/ui/pool/RemoveSectionLegacy.tsx b/apps/evm/src/ui/pool/RemoveSectionLegacy.tsx index 062a48784f..3ed707e9b1 100644 --- a/apps/evm/src/ui/pool/RemoveSectionLegacy.tsx +++ b/apps/evm/src/ui/pool/RemoveSectionLegacy.tsx @@ -7,30 +7,7 @@ import { useDebounce, useIsMounted, } from '@sushiswap/hooks' -import { Dots } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { createToast } from '@sushiswap/ui/components/toast' -import { - PermitInfo, - PermitType, - SushiSwapV2PoolState, - UseCallParameters, - getSushiSwapRouterContractConfig, - useAccount, - useCall, - usePublicClient, - useSendTransaction, - useSushiSwapRouterContract, - useSushiSwapV2Pool, - useTotalSupply, - useTransactionDeadline, -} from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' -import { - useApproved, - useSignature, - withCheckerRoot, -} from '@sushiswap/wagmi/systems/Checker/Provider' +import { Button, Dots, createToast } from '@sushiswap/ui' import { FC, useCallback, useEffect, useMemo, useState } from 'react' import { APPROVE_TAG_REMOVE_LEGACY } from 'src/lib/constants' import { @@ -45,14 +22,41 @@ import { Amount, Native } from 'sushi/currency' import { Percent } from 'sushi/math' import { SendTransactionReturnType, encodeFunctionData } from 'viem' +// import { +// PermitInfo, +// PermitType, +// } from 'src/lib/wagmi/hooks/approvals/hooks/useTokenPermit' +import { + getSushiSwapRouterContractConfig, + useSushiSwapRouterContract, +} from 'src/lib/wagmi/hooks/contracts/useSushiSwapRouter' +import { + SushiSwapV2PoolState, + useSushiSwapV2Pool, +} from 'src/lib/wagmi/hooks/pools/hooks/useSushiSwapV2Pools' +import { useTotalSupply } from 'src/lib/wagmi/hooks/tokens/useTotalSupply' +import { useTransactionDeadline } from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { + useApproved, + useSignature, + withCheckerRoot, +} from 'src/lib/wagmi/systems/Checker/Provider' +import { + UseCallParameters, + useAccount, + useCall, + usePublicClient, + useSendTransaction, +} from 'wagmi' import { usePoolPosition } from './PoolPositionProvider' import { RemoveSectionWidget } from './RemoveSectionWidget' -const REMOVE_V2_LIQUIDITY_PERMIT_INFO: PermitInfo = { - version: '1', - name: 'SushiSwap LP Token', - type: PermitType.AMOUNT, -} +// const REMOVE_V2_LIQUIDITY_PERMIT_INFO: PermitInfo = { +// version: '1', +// name: 'SushiSwap LP Token', +// type: PermitType.AMOUNT, +// } interface RemoveSectionLegacyProps { pool: Pool @@ -429,7 +433,7 @@ export const RemoveSectionLegacy: FC = guardWhen={+percentage <= 0} guardText="Enter amount" > - = _pool.chainId as SushiSwapV2ChainId, ).address } - permitInfo={REMOVE_V2_LIQUIDITY_PERMIT_INFO} - tag={APPROVE_TAG_REMOVE_LEGACY} - ttlStorageKey={TTLStorageKey.RemoveLiquidity} + // permitInfo={REMOVE_V2_LIQUIDITY_PERMIT_INFO} + // tag={APPROVE_TAG_REMOVE_LEGACY} + // ttlStorageKey={TTLStorageKey.RemoveLiquidity} > - + diff --git a/apps/evm/src/ui/pool/RemoveSectionTrident.tsx b/apps/evm/src/ui/pool/RemoveSectionTrident.tsx deleted file mode 100644 index ad2e0cc2e5..0000000000 --- a/apps/evm/src/ui/pool/RemoveSectionTrident.tsx +++ /dev/null @@ -1,411 +0,0 @@ -'use client' - -import { Pool, Protocol } from '@sushiswap/client' -import { SlippageToleranceStorageKey, useIsMounted } from '@sushiswap/hooks' -import { Button } from '@sushiswap/ui/components/button' -import { Dots } from '@sushiswap/ui/components/dots' -import { createToast } from '@sushiswap/ui/components/toast' -import { - TridentConstantPoolState, - TridentStablePoolState, - UseCallParameters, - getTridentRouterContractConfig, - useAccount, - useBentoBoxTotals, - useCall, - usePublicClient, - useSendTransaction, - useTotalSupply, - useTridentConstantPool, - useTridentRouterContract, - useTridentStablePool, -} from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' -import { - useApproved, - useApprovedActions, - useSignature, - withCheckerRoot, -} from '@sushiswap/wagmi/systems/Checker/Provider' -import { FC, useCallback, useMemo, useState } from 'react' -import { APPROVE_TAG_REMOVE_TRIDENT } from 'src/lib/constants' -import { - useTokensFromPool, - useUnderlyingTokenBalanceFromPool, -} from 'src/lib/hooks' -import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' -import { - LiquidityOutput, - approveMasterContractAction, - batchAction, - burnLiquidityAction, - sweepAction, - unwrapWETHAction, -} from 'src/lib/pool/trident/actions' -import { slippageAmount } from 'sushi/calculate' -import { ChainId } from 'sushi/chain' -import { BentoBoxChainId, TridentChainId } from 'sushi/config' -import { Amount, Native } from 'sushi/currency' -import { Percent } from 'sushi/math' - -import { SendTransactionReturnType } from 'viem' -import { usePoolPosition } from './PoolPositionProvider' -import { RemoveSectionWidget } from './RemoveSectionWidget' - -interface RemoveSectionTridentProps { - pool: Pool -} - -export const RemoveSectionTrident: FC = - withCheckerRoot(({ pool: _pool }) => { - const chainId = _pool.chainId as BentoBoxChainId - const client = usePublicClient() - const { address, chain } = useAccount() - const { token0, token1, liquidityToken } = useTokensFromPool(_pool) - const isMounted = useIsMounted() - const { approved } = useApproved(APPROVE_TAG_REMOVE_TRIDENT) - const { signature } = useSignature(APPROVE_TAG_REMOVE_TRIDENT) - const { setSignature } = useApprovedActions(APPROVE_TAG_REMOVE_TRIDENT) - const contract = useTridentRouterContract(_pool.chainId as TridentChainId) - const [slippageTolerance] = useSlippageTolerance( - SlippageToleranceStorageKey.RemoveLiquidity, - ) - - const [percentage, setPercentage] = useState('0') - const percentToRemove = useMemo( - () => new Percent(percentage, 100), - [percentage], - ) - const tokens = useMemo(() => [token0, token1], [token0, token1]) - const { data: rebases } = useBentoBoxTotals({ - chainId: _pool.chainId as BentoBoxChainId, - currencies: tokens, - }) - const { balance } = usePoolPosition() - - const slpAmountToRemove = useMemo(() => { - return balance?.multiply(percentToRemove) - }, [balance, percentToRemove]) - - // TODO: Standardize fee format - const [tridentConstantPoolState, tridentConstantPool] = - useTridentConstantPool( - _pool.chainId as TridentChainId, - token0, - token1, - _pool.swapFee * 10000, - _pool.twapEnabled, - ) - - const [tridentStablePoolState, tridentStablePool] = useTridentStablePool( - _pool.chainId as TridentChainId, - token0, - token1, - _pool.swapFee * 10000, - _pool.twapEnabled, - ) - - const [poolState, pool] = useMemo(() => { - if (_pool.protocol === Protocol.BENTOBOX_STABLE) - return [tridentStablePoolState, tridentStablePool] - if (_pool.protocol === Protocol.BENTOBOX_CLASSIC) - return [tridentConstantPoolState, tridentConstantPool] - - return [undefined, undefined] - }, [ - _pool.protocol, - tridentConstantPool, - tridentConstantPoolState, - tridentStablePool, - tridentStablePoolState, - ]) - - const totalSupply = useTotalSupply(liquidityToken) - - const underlying = useUnderlyingTokenBalanceFromPool({ - reserve0: pool?.reserve0, - reserve1: pool?.reserve1, - totalSupply, - balance: balance, - }) - - const [underlying0, underlying1] = underlying - - const currencyAToRemove = useMemo( - () => - token0 - ? percentToRemove?.greaterThan('0') && underlying0 - ? Amount.fromRawAmount( - token0, - percentToRemove.multiply(underlying0.quotient).quotient || '0', - ) - : Amount.fromRawAmount(token0, '0') - : undefined, - [token0, percentToRemove, underlying0], - ) - - const currencyBToRemove = useMemo( - () => - token1 - ? percentToRemove?.greaterThan('0') && underlying1 - ? Amount.fromRawAmount( - token1, - percentToRemove.multiply(underlying1.quotient).quotient || '0', - ) - : Amount.fromRawAmount(token1, '0') - : undefined, - [token1, percentToRemove, underlying1], - ) - - const [minAmount0, minAmount1] = useMemo(() => { - return [ - currencyAToRemove - ? Amount.fromRawAmount( - currencyAToRemove.currency, - slippageAmount(currencyAToRemove, slippageTolerance)[0], - ) - : undefined, - currencyBToRemove - ? Amount.fromRawAmount( - currencyBToRemove.currency, - slippageAmount(currencyBToRemove, slippageTolerance)[0], - ) - : undefined, - ] - }, [slippageTolerance, currencyAToRemove, currencyBToRemove]) - - const onSuccess = useCallback( - (hash: SendTransactionReturnType) => { - setPercentage('0') - setSignature(undefined) - - if (!chain?.id) return - - const ts = new Date().getTime() - void createToast({ - account: address, - type: 'burn', - chainId: chain.id, - txHash: hash, - promise: client.waitForTransactionReceipt({ hash }), - summary: { - pending: `Removing liquidity from the ${token0.symbol}/${token1.symbol} pair`, - completed: `Successfully removed liquidity from the ${token0.symbol}/${token1.symbol} pair`, - failed: 'Something went wrong when removing liquidity', - }, - timestamp: ts, - groupTimestamp: ts, - }) - }, - [client, address, chain, token0.symbol, token1.symbol, setSignature], - ) - - const prepare = useMemo(() => { - try { - if ( - !chain?.id || - !pool || - !token0 || - !token1 || - !_pool.chainId || - !contract || - !minAmount0 || - !minAmount1 || - !address || - !minAmount0 || - !minAmount1 || - !rebases?.[token0.wrapped.address] || - !rebases?.[token1.wrapped.address] || - !slpAmountToRemove - ) - return undefined - - const liquidityOutput: LiquidityOutput[] = [ - { - token: minAmount0.wrapped.currency.address, - amount: minAmount0.toShare(rebases?.[token0.wrapped.address]) - .quotient, - }, - { - token: minAmount1.wrapped.currency.address, - amount: minAmount1.toShare(rebases?.[token1.wrapped.address]) - .quotient, - }, - ] - - let indexOfWETH = -1 - indexOfWETH = - minAmount0.wrapped.currency.address === - Native.onChain(_pool.chainId).wrapped.address - ? 0 - : indexOfWETH - indexOfWETH = - minAmount1.wrapped.currency.address === - Native.onChain(_pool.chainId).wrapped.address - ? 1 - : indexOfWETH - - const actions = [ - approveMasterContractAction({ signature }), - burnLiquidityAction({ - address: pool.liquidityToken.address, - amount: slpAmountToRemove.quotient, - recipient: indexOfWETH >= 0 ? contract.address : address, - liquidityOutput, - receiveToWallet: true, - }), - ] - - if (indexOfWETH >= 0) { - actions.push( - unwrapWETHAction({ - recipient: address, - }), - sweepAction({ - token: liquidityOutput[indexOfWETH === 0 ? 1 : 0].token, - recipient: address, - fromBento: false, - }), - ) - } - - return { - account: address, - to: contract.address, - chainId: _pool.chainId as ChainId, - data: batchAction({ - actions, - }), - } satisfies UseCallParameters - } catch (_e: unknown) { - return undefined - } - }, [ - chain?.id, - pool, - token0, - token1, - _pool.chainId, - contract, - minAmount0, - minAmount1, - address, - rebases, - slpAmountToRemove, - signature, - ]) - - const { isError: isSimulationError } = useCall({ - ...prepare, - query: { - enabled: Boolean(approved && Number(percentage) > 0), - }, - }) - - const { sendTransactionAsync, isLoading: isWritePending } = - useSendTransaction({ - mutation: { - onSuccess, - }, - }) - - const send = useMemo(() => { - if (!prepare || isSimulationError) return undefined - - return async () => { - try { - await sendTransactionAsync(prepare) - } catch {} - } - }, [sendTransactionAsync, isSimulationError, prepare]) - - return ( -
- 0} - chainId={_pool.chainId as ChainId} - percentage={percentage} - token0={token0} - token1={token1} - token0Minimum={minAmount0} - token1Minimum={minAmount1} - setPercentage={setPercentage} - > - - - - - - - - - - - - - - - - -
- ) - }) diff --git a/apps/evm/src/ui/pool/RemoveSectionUnstake.tsx b/apps/evm/src/ui/pool/RemoveSectionUnstake.tsx index 246044582f..063a561707 100644 --- a/apps/evm/src/ui/pool/RemoveSectionUnstake.tsx +++ b/apps/evm/src/ui/pool/RemoveSectionUnstake.tsx @@ -15,16 +15,16 @@ import { WidgetHeader, WidgetTitle, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Dots } from '@sushiswap/ui/components/dots' -import { useMasterChefWithdraw } from '@sushiswap/wagmi' -import { Checker } from '@sushiswap/wagmi/systems' -import { withCheckerRoot } from '@sushiswap/wagmi/systems/Checker/Provider' +import { Button } from '@sushiswap/ui' +import { Dots } from '@sushiswap/ui' import { FC, useMemo, useState } from 'react' import { ChainId } from 'sushi/chain' import { ZERO } from 'sushi/math' import { useSWRConfig } from 'swr' +import { useMasterChefWithdraw } from 'src/lib/wagmi/hooks/master-chef/use-master-chef-withdraw' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { withCheckerRoot } from 'src/lib/wagmi/systems/Checker/Provider' import { usePoolPositionStaked } from './PoolPositionStakedProvider' interface AddSectionStakeProps { diff --git a/apps/evm/src/ui/pool/RemoveSectionWidget.tsx b/apps/evm/src/ui/pool/RemoveSectionWidget.tsx index 0017c3aa84..c3476375dc 100644 --- a/apps/evm/src/ui/pool/RemoveSectionWidget.tsx +++ b/apps/evm/src/ui/pool/RemoveSectionWidget.tsx @@ -11,24 +11,17 @@ import { WidgetDescription, WidgetFooter, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { IconButton } from '@sushiswap/ui/components/iconbutton' -import { - SettingsModule, - SettingsOverlay, -} from '@sushiswap/ui/components/settings' -import { - Widget, - WidgetHeader, - WidgetTitle, -} from '@sushiswap/ui/components/widget' +import { Button } from '@sushiswap/ui' +import { IconButton } from '@sushiswap/ui' +import { SettingsModule, SettingsOverlay } from '@sushiswap/ui' +import { Widget, WidgetHeader, WidgetTitle } from '@sushiswap/ui' import React, { FC, ReactNode } from 'react' import { ChainId } from 'sushi/chain' import { Amount, Type } from 'sushi/currency' import { ZERO } from 'sushi/math' import { SlippageToleranceStorageKey, TTLStorageKey } from '@sushiswap/hooks' -import { getDefaultTTL } from '@sushiswap/wagmi' +import { getDefaultTTL } from 'src/lib/wagmi/hooks/utils/hooks/useTransactionDeadline' import { usePoolPosition } from './PoolPositionProvider' interface RemoveSectionWidgetProps { diff --git a/apps/evm/src/ui/pool/RewardSlide.tsx b/apps/evm/src/ui/pool/RewardSlide.tsx index f91c882fa0..7c6026bbb1 100644 --- a/apps/evm/src/ui/pool/RewardSlide.tsx +++ b/apps/evm/src/ui/pool/RewardSlide.tsx @@ -16,11 +16,11 @@ import { SkeletonBox, SkeletonText, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Currency } from '@sushiswap/ui/components/currency' -import { List } from '@sushiswap/ui/components/list/List' -import { Checker } from '@sushiswap/wagmi/systems/Checker' +import { Button } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' import React, { FC, ReactNode, useMemo } from 'react' +import { Checker } from 'src/lib/wagmi/systems/Checker' import { Chain } from 'sushi/chain' import { formatNumber } from 'sushi/format' import { Address } from 'viem' diff --git a/apps/evm/src/ui/pool/RewardsSection.tsx b/apps/evm/src/ui/pool/RewardsSection.tsx index 84700cc689..bda147dd27 100644 --- a/apps/evm/src/ui/pool/RewardsSection.tsx +++ b/apps/evm/src/ui/pool/RewardsSection.tsx @@ -11,12 +11,12 @@ import { Container, DataTable, } from '@sushiswap/ui' -import { Carousel } from '@sushiswap/ui/components/carousel' -import { useAccount } from '@sushiswap/wagmi' +import { Carousel } from '@sushiswap/ui' import { ColumnDef, PaginationState } from '@tanstack/react-table' import React, { FC, useCallback, useMemo, useState } from 'react' -import { ANGLE_ENABLED_NETWORKS } from 'sushi/config' +import { ANGLE_SUPPORTED_CHAIN_IDS } from 'sushi/config' +import { useAccount } from 'wagmi' import { usePoolFilters } from './PoolsFiltersProvider' import { RewardSlide, RewardSlideSkeleton } from './RewardSlide' import { @@ -37,7 +37,7 @@ export const RewardsSection: FC = () => { const { address } = useAccount() const { chainIds, tokenSymbols } = usePoolFilters() const { data, isInitialLoading } = useAngleRewardsMultipleChains({ - chainIds: ANGLE_ENABLED_NETWORKS, + chainIds: ANGLE_SUPPORTED_CHAIN_IDS, account: address, }) @@ -59,7 +59,9 @@ export const RewardsSection: FC = () => { const positions = useMemo(() => { const _tokenSymbols = tokenSymbols?.filter((el) => el !== '') || [] return (data ?? []) - .filter((el) => chainIds.includes(el.chainId)) + .filter((el) => + chainIds.includes(el.chainId as (typeof chainIds)[number]), + ) .flatMap((el) => { return Object.values(el.pools ?? {}) .filter( @@ -87,7 +89,7 @@ export const RewardsSection: FC = () => { <> [0] | number> containerWidth={1280} - slides={chainsSorted || ANGLE_ENABLED_NETWORKS} + slides={chainsSorted || ANGLE_SUPPORTED_CHAIN_IDS} render={(row) => typeof row === 'number' ? ( diff --git a/apps/evm/src/ui/pool/RewardsV3NameCell.tsx b/apps/evm/src/ui/pool/RewardsV3NameCell.tsx index 5d6a9de3fe..036c4252b3 100644 --- a/apps/evm/src/ui/pool/RewardsV3NameCell.tsx +++ b/apps/evm/src/ui/pool/RewardsV3NameCell.tsx @@ -9,9 +9,9 @@ import { HoverCardPrimitive, HoverCardTrigger, } from '@sushiswap/ui' -import { Badge } from '@sushiswap/ui/components/badge' -import { Currency } from '@sushiswap/ui/components/currency' -import { NetworkIcon } from '@sushiswap/ui/components/icons' +import { Badge } from '@sushiswap/ui' +import { Currency } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' import { Row } from '@tanstack/react-table' import React, { FC } from 'react' import { unwrapToken } from 'sushi/currency' diff --git a/apps/evm/src/ui/pool/SelectFeeConcentratedWidget.tsx b/apps/evm/src/ui/pool/SelectFeeConcentratedWidget.tsx index 597d71ea51..ca8a9bf31e 100644 --- a/apps/evm/src/ui/pool/SelectFeeConcentratedWidget.tsx +++ b/apps/evm/src/ui/pool/SelectFeeConcentratedWidget.tsx @@ -15,7 +15,7 @@ import { LinkInternal, Toggle, } from '@sushiswap/ui' -import { Dots } from '@sushiswap/ui/components/dots' +import { Dots } from '@sushiswap/ui' import React, { FC, memo, useMemo } from 'react' import { usePoolsByTokenPair } from 'src/lib/hooks/usePoolsByTokenPair' import { SushiSwapV3FeeAmount } from 'sushi/config' @@ -71,19 +71,19 @@ export const SelectFeeConcentratedWidget: FC = if (!pools) return tvlDistribution const totalTvl = pools?.reduce( - (acc, pool) => acc + Number(pool.totalValueLockedUSD), + (acc, pool) => acc + Number(pool.liquidityUSD), 0, ) pools?.forEach((pool) => { if ( - !FEE_OPTIONS.find((option) => option.value === Number(pool.feeTier)) + !FEE_OPTIONS.find((option) => option.value === Number(pool.swapFee)) ) return - const tvlShare = pool.totalValueLockedUSD / totalTvl + const tvlShare = pool.liquidityUSD / totalTvl if (Number.isNaN(tvlShare)) return - tvlDistribution.set(Number(pool.feeTier), tvlShare) + tvlDistribution.set(Number(pool.swapFee), tvlShare) }) return tvlDistribution diff --git a/apps/evm/src/ui/pool/SelectNetworkWidget.tsx b/apps/evm/src/ui/pool/SelectNetworkWidget.tsx index cd90d6f4b7..69eb6be5a5 100644 --- a/apps/evm/src/ui/pool/SelectNetworkWidget.tsx +++ b/apps/evm/src/ui/pool/SelectNetworkWidget.tsx @@ -1,7 +1,7 @@ import { FormSection, NetworkSelector } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { NetworkIcon } from '@sushiswap/ui/components/icons' -import { SelectIcon } from '@sushiswap/ui/components/select' +import { Button } from '@sushiswap/ui' +import { NetworkIcon } from '@sushiswap/ui' +import { SelectIcon } from '@sushiswap/ui' import React, { FC, memo } from 'react' import { ChainId, chainName } from 'sushi/chain' diff --git a/apps/evm/src/ui/pool/SelectPoolTypeWidget.tsx b/apps/evm/src/ui/pool/SelectPoolTypeWidget.tsx index 18543321a8..7c2015dd6e 100644 --- a/apps/evm/src/ui/pool/SelectPoolTypeWidget.tsx +++ b/apps/evm/src/ui/pool/SelectPoolTypeWidget.tsx @@ -3,9 +3,9 @@ import { RadioGroup } from '@headlessui/react' import { StarIcon } from '@heroicons/react-v1/solid' import { FormSection, classNames } from '@sushiswap/ui' -import { CheckIcon } from '@sushiswap/ui/components/icons' -import { PoolFinderType } from '@sushiswap/wagmi' +import { CheckIcon } from '@sushiswap/ui' import React, { FC, memo } from 'react' +import { PoolFinderType } from 'src/lib/wagmi/systems/PoolFinder/types' const POOL_OPTIONS = [ { diff --git a/apps/evm/src/ui/pool/SelectPricesWidget.tsx b/apps/evm/src/ui/pool/SelectPricesWidget.tsx index 12e0468dc1..e2a2fb9530 100644 --- a/apps/evm/src/ui/pool/SelectPricesWidget.tsx +++ b/apps/evm/src/ui/pool/SelectPricesWidget.tsx @@ -27,10 +27,8 @@ import { TooltipTrigger, classNames, } from '@sushiswap/ui' -import { SkeletonText } from '@sushiswap/ui/components/skeleton' -import { Toggle } from '@sushiswap/ui/components/toggle' -import { useAccount } from '@sushiswap/wagmi' -import { useConcentratedLiquidityPositionsFromTokenId } from '@sushiswap/wagmi' +import { SkeletonText } from '@sushiswap/ui' +import { Toggle } from '@sushiswap/ui' import React, { FC, ReactNode, @@ -41,16 +39,26 @@ import React, { } from 'react' import { Bound, Field } from 'src/lib/constants' import { useTokenAmountDollarValues } from 'src/lib/hooks' -import { SushiSwapV3ChainId, SushiSwapV3FeeAmount } from 'sushi/config' +import { + SushiSwapV3ChainId, + SushiSwapV3FeeAmount, + TICK_SPACINGS, +} from 'sushi/config' import { Type, tryParseAmount } from 'sushi/currency' -import { getCapitalEfficiency, getTokenRatio } from 'sushi/pool' +import { + getCapitalEfficiency, + getTokenRatio, + tickToPrice, +} from 'sushi/pool/sushiswap-v3' import { RadioGroup } from '@headlessui/react' import { LockClosedIcon, LockOpenIcon } from '@heroicons/react/24/solid' import { ExclamationTriangleIcon } from '@heroicons/react/24/solid' import { useConcentratedLiquidityPoolStats } from '@sushiswap/react-query' +import { useConcentratedLiquidityPositionsFromTokenId } from 'src/lib/wagmi/hooks/positions/hooks/useConcentratedPositionsFromTokenId' import { formatPercent } from 'sushi/format' import { Fraction } from 'sushi/math' +import { useAccount } from 'wagmi' import { useConcentratedDerivedMintInfo, useConcentratedMintActionHandlers, @@ -64,6 +72,8 @@ enum PriceRange { BPS_20000 = 1, BPS_12000 = 2, BPS_10100 = 3, + LEFT_SIDE = 4, + RIGHT_SIDE = 5, } enum YieldRatePeriod { @@ -212,6 +222,46 @@ export const SelectPricesWidget: FC = ({ ], ) + const setSingleSided = useCallback( + (side: 'left' | 'right') => { + if (!token0 || !token1 || !price || !feeAmount || !pool) return + + getSetFullRange() + + switch (side) { + case 'left': { + const newRightPrice = tickToPrice( + token0.wrapped, + token1.wrapped, + pool.tickCurrent + (invertPrice ? 1 : 0) * TICK_SPACINGS[feeAmount], + ) + onRightRangeInput(newRightPrice.toFixed(6)) + break + } + case 'right': { + const newLeftPrice = tickToPrice( + token0.wrapped, + token1.wrapped, + pool.tickCurrent + (invertPrice ? 0 : 1) * TICK_SPACINGS[feeAmount], + ) + onLeftRangeInput(newLeftPrice.toFixed(6)) + break + } + } + }, + [ + token0, + token1, + price, + feeAmount, + pool, + getSetFullRange, + invertPrice, + onRightRangeInput, + onLeftRangeInput, + ], + ) + const formattedAmounts: { [_formattedAmountsField in Field]: string } = useMemo( @@ -279,8 +329,23 @@ export const SelectPricesWidget: FC = ({ value: PriceRange.BPS_10100, onClick: () => setPriceRange(new Fraction(10100, 10000)), }, + { + label: 'Single Sided (Left)', + value: PriceRange.LEFT_SIDE, + onClick: () => setSingleSided('left'), + }, + { + label: 'Single Sided (Right)', + value: PriceRange.RIGHT_SIDE, + onClick: () => setSingleSided('right'), + }, + ], + [ + getSetFullRange, + setPriceRange, + setWeightLockedCurrencyBase, + setSingleSided, ], - [getSetFullRange, setPriceRange, setWeightLockedCurrencyBase], ) const isSorted = @@ -497,7 +562,7 @@ export const SelectPricesWidget: FC = ({ )}
- + {PRICE_RANGE_OPTIONS.map(({ value, label, onClick }) => ( i.rewardPerDay > 0, - ) - return (
@@ -141,9 +137,6 @@ const COLUMNS = [
🧑🌾{' '} - {incentives.length > 1 - ? `x ${incentives.length}` - : ''}{' '}
@@ -244,11 +237,11 @@ const COLUMNS = [ { id: 'fees1d', header: 'Fees (24h)', - accessorFn: (row) => row.pool.fees1d, + accessorFn: (row) => row.pool.feesUSD1d, cell: (props) => - formatUSD(props.row.original.pool.fees1d).includes('NaN') + formatUSD(props.row.original.pool.feesUSD1d).includes('NaN') ? '$0.00' - : formatUSD(props.row.original.pool.fees1d), + : formatUSD(props.row.original.pool.feesUSD1d), meta: { skeleton: , }, @@ -256,17 +249,10 @@ const COLUMNS = [ { id: 'totalApr1d', header: 'APR (24h)', - accessorFn: (row) => - row.apr1d * 100 + - row.pool.incentives - .filter((el) => +el.rewardPerDay > 0) - .reduce((acc, cur) => acc + cur.apr * 100, 0), + accessorFn: (row) => (row.apr1d + row.pool.incentiveApr) * 100, cell: (props) => { const totalAPR = - props.row.original.apr1d * 100 + - props.row.original.pool.incentives - .filter((el) => +el.rewardPerDay > 0) - .reduce((acc, cur) => acc + cur.apr * 100, 0) + (props.row.original.apr1d + props.row.original.pool.incentiveApr) * 100 return (
@@ -433,16 +419,6 @@ const COLUMNS = [ {row.original.token0.symbol} / {row.original.token1.symbol} - {row.original.pool.protocol === Protocol.BENTOBOX_STABLE && ( - - Trident Stable - - )} - {row.original.pool.protocol === Protocol.BENTOBOX_CLASSIC && ( - - Trident Classic - - )} {row.original.pool.protocol === 'SUSHISWAP_V2' && ( SushiSwap V2 @@ -527,7 +503,7 @@ const COLUMNS = [ skeleton: , }, }, -] satisfies ColumnDef[] +] satisfies ColumnDef[] export const SmartPoolsTable = () => { const { tokenSymbols, chainIds, protocols, farmsOnly } = usePoolFilters() @@ -556,11 +532,11 @@ export const SmartPoolsTable = () => { } }, [sorting, pagination]) - const _vaults: SteerVaults = useMemo( + const _vaults = useMemo( () => vaults ? vaults - .filter((el) => (farmsOnly ? el.pool.incentives.length > 0 : true)) + .filter((el) => (farmsOnly ? el.pool.isIncentivized : true)) .filter((el) => protocols.length > 0 ? protocols.includes(el.pool.protocol) diff --git a/apps/evm/src/ui/pool/SmartPositionsTable.tsx b/apps/evm/src/ui/pool/SmartPositionsTable.tsx index e8e9a4340f..ccd3fd3f8a 100644 --- a/apps/evm/src/ui/pool/SmartPositionsTable.tsx +++ b/apps/evm/src/ui/pool/SmartPositionsTable.tsx @@ -12,15 +12,18 @@ import { TooltipProvider, TooltipTrigger, } from '@sushiswap/ui' -import { useAccount, useSteerAccountPositionsExtended } from '@sushiswap/wagmi' +import { + SteerAccountPositionExtended, + useSteerAccountPositionsExtended, +} from 'src/lib/wagmi/hooks/steer/useSteerAccountPositionsExtended' import { formatPercent } from 'sushi' +import { useAccount } from 'wagmi' import { APRHoverCard } from './APRHoverCard' import { STEER_NAME_COLUMN, STEER_POSITION_SIZE_COLUMN, STEER_STRATEGY_COLUMN, } from './ConcentratedPositionsTable/Tables/Smart/columns' -import { SteerPosition } from './ConcentratedPositionsTable/Tables/Smart/useSteerPositions' import { usePoolFilters } from './PoolsFiltersProvider' const COLUMNS = [ @@ -30,17 +33,12 @@ const COLUMNS = [ { id: 'totalApr1d', header: 'APR (24h)', - accessorFn: (row) => - row.vault.apr1d * 100 + - row.vault.pool.incentives - .filter((el) => +el.rewardPerDay > 0) - .reduce((acc, cur) => acc + cur.apr * 100, 0), + accessorFn: (row) => (row.vault.apr1d + row.vault.pool.incentiveApr) * 100, cell: (props) => { const totalAPR = - props.row.original.vault.apr1d * 100 + - props.row.original.vault.pool.incentives - .filter((el) => +el.rewardPerDay > 0) - .reduce((acc, cur) => acc + cur.apr * 100, 0) + (props.row.original.vault.apr1d + + props.row.original.vault.pool.incentiveApr) * + 100 return (
@@ -71,7 +69,7 @@ const COLUMNS = [ skeleton: , }, }, -] satisfies ColumnDef[] +] satisfies ColumnDef[] const tableState = { sorting: [{ id: 'positionSize', desc: true }] } @@ -106,7 +104,7 @@ export const SmartPositionsTable = () => { `/pool/${row.vault.pool.id}/smart/${row.vault.id}` } columns={COLUMNS} - data={_positions as SteerPosition[]} + data={_positions} pagination={true} onPaginationChange={setPaginationState} state={{ diff --git a/apps/evm/src/ui/pool/Steer/SteerAPRChart/SteerAPRChart.tsx b/apps/evm/src/ui/pool/Steer/SteerAPRChart/SteerAPRChart.tsx index 059e6cca3e..0dc338948c 100644 --- a/apps/evm/src/ui/pool/Steer/SteerAPRChart/SteerAPRChart.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerAPRChart/SteerAPRChart.tsx @@ -1,14 +1,13 @@ 'use client' -import { Pool } from '@sushiswap/client' -import { getSteerVaultAprTimeseries } from '@sushiswap/steer-sdk' +import { SteerVaultId, getSteerVaultAprTimeseries } from '@sushiswap/steer-sdk' import { useQuery } from '@tanstack/react-query' import React, { FC } from 'react' import { _SteerAPRChart } from './_SteerAPRChart' interface SteerAPRChartProps { - vault: Pool['steerVaults'][0] + vault: SteerVaultId } export const SteerAPRChart: FC = ({ vault }) => { diff --git a/apps/evm/src/ui/pool/Steer/SteerAPRChart/_SteerAPRChart.tsx b/apps/evm/src/ui/pool/Steer/SteerAPRChart/_SteerAPRChart.tsx index aa362fa3ed..8f6dd6b244 100644 --- a/apps/evm/src/ui/pool/Steer/SteerAPRChart/_SteerAPRChart.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerAPRChart/_SteerAPRChart.tsx @@ -3,13 +3,20 @@ import { getSteerVaultAprTimeseries } from '@sushiswap/steer-sdk' import { SkeletonBox } from '@sushiswap/ui' import format from 'date-fns/format' -import ReactECharts, { EChartsOption } from 'echarts-for-react' import React, { useMemo } from 'react' import ReactVirtualizedAutoSizer from 'react-virtualized-auto-sizer' import { formatPercent } from 'sushi/format' import tailwindConfig from 'tailwind.config.js' import resolveConfig from 'tailwindcss/resolveConfig' +import ReactEChartsCore from 'echarts-for-react/lib/core' +import { EChartsOption } from 'echarts-for-react/lib/types' +import 'echarts/lib/chart/line' +import 'echarts/lib/component/tooltip' +import 'echarts/lib/component/visualMap' +import echarts from 'echarts/lib/echarts' +import 'echarts/lib/visual/seriesColor' + const tailwind = resolveConfig(tailwindConfig) interface _SteerAPRChartProps { @@ -49,6 +56,11 @@ export function _SteerAPRChart({ timeseries, loading }: _SteerAPRChartProps) { }, borderWidth: 0, }, + visualMap: { + show: false, + // @ts-ignore + color: [tailwind.theme.colors.blue['500']], + }, grid: { top: 2, bottom: 2, @@ -144,7 +156,11 @@ export function _SteerAPRChart({ timeseries, loading }: _SteerAPRChartProps) { {({ height, width }) => ( <> {timeseries?.length ? ( - + ) : (
= ({ @@ -65,7 +65,7 @@ export const SteerAPRHoverCard: FC = ({ {pool.incentives.map((el) => { const amount = tryParseAmount( el.rewardPerDay.toString(), - incentiveRewardToToken(el.chainId as ChainId, el), + incentiveRewardToToken(el.chainId, el), ) if (!amount) return null diff --git a/apps/evm/src/ui/pool/Steer/SteerCarousel.tsx b/apps/evm/src/ui/pool/Steer/SteerCarousel.tsx index c439b85cc3..1be088d5d8 100644 --- a/apps/evm/src/ui/pool/Steer/SteerCarousel.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerCarousel.tsx @@ -1,39 +1,45 @@ 'use client' -import { Pool } from '@sushiswap/client' import { Carousel, SkeletonBox } from '@sushiswap/ui' import { FC, useCallback, useMemo } from 'react' +import { SteerVault } from '@sushiswap/steer-sdk' +import type { PoolWithFeeAprs, PoolWithIncentives } from 'sushi/types' import { SteerPoolCard } from './SteerPoolCard' +type RequiredPool = PoolWithIncentives + interface SteerCarousel { - pool?: Pool + pool?: RequiredPool + vaults?: SteerVault[] isLoading?: boolean } export const SteerCarousel: FC = ({ pool, + vaults, isLoading = false, }) => { - if (isLoading || !pool) { + if (isLoading || !pool || !vaults) { return <_SteerCarouselLoading /> } - return <_SteerCarousel pool={pool} /> + return <_SteerCarousel pool={pool} vaults={vaults} /> } interface _SteerCarousel { - pool: Pool + pool: RequiredPool + vaults: SteerVault[] } -const _SteerCarousel: FC<_SteerCarousel> = ({ pool }) => { +const _SteerCarousel: FC<_SteerCarousel> = ({ pool, vaults }) => { const enabledVaults = useMemo( - () => pool.steerVaults.filter((vault) => vault.isEnabled), - [pool], + () => vaults.filter((vault) => vault.isEnabled), + [vaults], ) const render = useCallback( - (vault: Pool['steerVaults'][0]) => { + (vault: SteerVault) => { return (
diff --git a/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityDistributionWidget.tsx b/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityDistributionWidget.tsx index e5a0f0e67d..0553558f5b 100644 --- a/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityDistributionWidget.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityDistributionWidget.tsx @@ -1,12 +1,12 @@ -import { Pool } from '@sushiswap/client' import { CardTitle } from '@sushiswap/ui' import React, { FC } from 'react' +import { SteerVault } from '@sushiswap/steer-sdk' import { SteerLiquidityInRangeChip } from './SteerLiquidityInRangeChip' import { SteerTokenDistributionBar } from './SteerTokenDistributionBar' interface SteerLiquidityDistributionWidgetProps { - vault: Pool['steerVaults'][0] + vault: SteerVault } export const SteerLiquidityDistributionWidget: FC< diff --git a/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityInRangeChip.tsx b/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityInRangeChip.tsx index 602f24e2f4..f63158f9d1 100644 --- a/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityInRangeChip.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerLiquidityInRangeChip.tsx @@ -1,6 +1,6 @@ 'use client' -import { Pool } from '@sushiswap/client' +import { SteerVault } from '@sushiswap/steer-sdk' import { Chip, SkeletonBox, classNames } from '@sushiswap/ui' import React, { FC, useMemo } from 'react' import { SushiSwapV3ChainId } from 'sushi/config' @@ -8,7 +8,7 @@ import { Token } from 'sushi/currency' import { useConcentratedActiveLiquidity } from '../../../../lib/pool/v3/use-concentrated-active-liquidity' interface SteerLiquidityInRangeChipProps { - vault: Pool['steerVaults'][0] + vault: SteerVault } export const SteerLiquidityInRangeChip: FC = ({ diff --git a/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerTokenDistributionBar.tsx b/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerTokenDistributionBar.tsx index 792c0ea8af..1c4e752dd7 100644 --- a/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerTokenDistributionBar.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerLiquidityDistributionWidget/SteerTokenDistributionBar.tsx @@ -1,13 +1,12 @@ 'use client' -import { Pool } from '@sushiswap/client' import { usePrices } from '@sushiswap/react-query' -import { getTokenRatios } from '@sushiswap/steer-sdk' +import { SteerVault, getTokenRatios } from '@sushiswap/steer-sdk' import { useQuery } from '@tanstack/react-query' import React from 'react' interface SteerTokenDistributionBarProps { - vault: Pool['steerVaults'][0] + vault: SteerVault } export function SteerTokenDistributionBar({ diff --git a/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx b/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx index 7d807f6386..d0b7fa4062 100644 --- a/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAdd.tsx @@ -1,16 +1,20 @@ 'use client' import { PlusIcon } from '@heroicons/react-v1/solid' -import { SteerVault } from '@sushiswap/client' -import { STEER_PERIPHERY_ADDRESS, SteerChainId } from '@sushiswap/steer-sdk' +import { + STEER_PERIPHERY_ADDRESS, + SteerChainId, + SteerVault, +} from '@sushiswap/steer-sdk' import { Button, DialogTrigger, classNames } from '@sushiswap/ui' -import { CheckerProvider } from '@sushiswap/wagmi/systems/Checker/Provider' import React, { FC, useMemo } from 'react' import { ChainId } from 'sushi/chain' import { useIsMounted } from '@sushiswap/hooks' -import { Checker, Web3Input } from '@sushiswap/wagmi' import { APPROVE_TAG_STEER, Field } from 'src/lib/constants' +import { Web3Input } from 'src/lib/wagmi/components/web3-input' +import { Checker } from 'src/lib/wagmi/systems/Checker' +import { CheckerProvider } from 'src/lib/wagmi/systems/Checker/Provider' import { useSteerPositionAddActions, useSteerPositionAddDerivedInfo, diff --git a/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddProvider.tsx b/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddProvider.tsx index fe5947e2ff..de59723067 100644 --- a/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddProvider.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddProvider.tsx @@ -1,8 +1,7 @@ 'use client' -import type { SteerVault } from '@sushiswap/client' import { useSteerVault } from '@sushiswap/client/hooks' -import { useSteerVaultReserves } from '@sushiswap/wagmi' +import type { SteerVault } from '@sushiswap/steer-sdk' import { FC, ReactNode, @@ -12,6 +11,7 @@ import { useReducer, } from 'react' import { Field } from 'src/lib/constants' +import { useSteerVaultReserves } from 'src/lib/wagmi/hooks/steer/useSteerVaultReserves' import { Amount, Currency, Token, tryParseAmount } from 'sushi/currency' interface State { @@ -132,10 +132,7 @@ export function useSteerPositionAddDerivedInfo({ const [currencyA, currencyB] = useMemo(() => { if (!vault) return [] - return [ - new Token({ chainId: vault.pool.chainId, ...vault.pool.token0 }), - new Token({ chainId: vault.pool.chainId, ...vault.pool.token1 }), - ] + return [new Token(vault.token0), new Token(vault.token1)] }, [vault]) // currencies diff --git a/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddReviewModal.tsx b/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddReviewModal.tsx index 7ae5ceee42..c5933a5994 100644 --- a/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddReviewModal.tsx +++ b/apps/evm/src/ui/pool/Steer/SteerLiquidityManagement/Add/SteerPositionAddReviewModal.tsx @@ -1,7 +1,10 @@ 'use client' -import { SteerVault } from '@sushiswap/client' -import { STEER_PERIPHERY_ADDRESS, isSteerChainId } from '@sushiswap/steer-sdk' +import { + STEER_PERIPHERY_ADDRESS, + SteerVault, + isSteerChainId, +} from '@sushiswap/steer-sdk' import { steerPeripheryAbi } from '@sushiswap/steer-sdk/abi' import { Currency, @@ -16,21 +19,11 @@ import { createErrorToast, createToast, } from '@sushiswap/ui' -import { Button } from '@sushiswap/ui/components/button' -import { Dots } from '@sushiswap/ui/components/dots' -import { List } from '@sushiswap/ui/components/list/List' -import { - UseSimulateContractParameters, - useAccount, - usePublicClient, - useSimulateContract, - useSteerAccountPosition, - useWaitForTransactionReceipt, - useWriteContract, -} from '@sushiswap/wagmi' -import { useApproved } from '@sushiswap/wagmi/systems/Checker/Provider' +import { Button } from '@sushiswap/ui' +import { Dots } from '@sushiswap/ui' +import { List } from '@sushiswap/ui' import React, { FC, ReactNode, useCallback, useMemo } from 'react' -import { Chain, ChainId } from 'sushi/chain' +import { Chain } from 'sushi/chain' import { Amount } from 'sushi/currency' import { formatUSD } from 'sushi/format' import { @@ -42,7 +35,14 @@ import { import { SlippageToleranceStorageKey } from '@sushiswap/hooks' import { APPROVE_TAG_STEER } from 'src/lib/constants' import { useSlippageTolerance } from 'src/lib/hooks/useSlippageTolerance' +import { useSteerAccountPosition } from 'src/lib/wagmi/hooks/steer/useSteerAccountPosition' +import { useApproved } from 'src/lib/wagmi/systems/Checker/Provider' import { slippageAmount } from 'sushi' +import { UseSimulateContractParameters, usePublicClient } from 'wagmi' +import { useAccount } from 'wagmi' +import { useSimulateContract } from 'wagmi' +import { useWaitForTransactionReceipt } from 'wagmi' +import { useWriteContract } from 'wagmi' import { useTokenAmountDollarValues } from '../../../../../lib/hooks' import { SteerStrategyConfig } from '../../constants' import { useSteerPositionAddDerivedInfo } from './SteerPositionAddProvider' @@ -56,7 +56,6 @@ interface SteerPositionAddReviewModalProps { export const SteerPositionAddReviewModal: FC = ({ vault, onSuccess: _onSuccess, successLink, children }) => { - const { chainId } = vault as { chainId: ChainId } const { currencies, parsedAmounts } = useSteerPositionAddDerivedInfo({ vault, }) @@ -87,7 +86,7 @@ export const SteerPositionAddReviewModal: FC = return [token0Amount, token1Amount] }, [accountPosition, currencies]) const accountPositionValues = useTokenAmountDollarValues({ - chainId: chainId, + chainId: vault.chainId, amounts: accountPositionAmountsArray, }) const accountPositionValue = useMemo( @@ -103,7 +102,7 @@ export const SteerPositionAddReviewModal: FC = [parsedAmounts], ) const newPositionValues = useTokenAmountDollarValues({ - chainId: chainId, + chainId: vault.chainId, amounts: parsedAmountsArray, }) const newPositionValue = useMemo( @@ -123,7 +122,7 @@ export const SteerPositionAddReviewModal: FC = void createToast({ account: address, type: 'mint', - chainId: chainId, + chainId: vault.chainId, txHash: hash, promise: client.waitForTransactionReceipt({ hash }), summary: { @@ -135,7 +134,7 @@ export const SteerPositionAddReviewModal: FC = groupTimestamp: ts, }) }, - [client, currencies, address, chainId, _onSuccess], + [client, currencies, address, vault.chainId, _onSuccess], ) const onError = useCallback((e: Error) => { @@ -145,13 +144,18 @@ export const SteerPositionAddReviewModal: FC = }, []) const prepare = useMemo(() => { - if (!address || !currencies || !parsedAmounts || !isSteerChainId(chainId)) + if ( + !address || + !currencies || + !parsedAmounts || + !isSteerChainId(vault.chainId) + ) return undefined return { - address: STEER_PERIPHERY_ADDRESS[chainId], + address: STEER_PERIPHERY_ADDRESS[vault.chainId], abi: steerPeripheryAbi, - chainId, + chainId: vault.chainId, functionName: 'deposit', args: [ vault.address as Address, @@ -164,7 +168,7 @@ export const SteerPositionAddReviewModal: FC = } satisfies UseSimulateContractParameters }, [ address, - chainId, + vault.chainId, currencies, parsedAmounts, slippagePercent, @@ -174,7 +178,7 @@ export const SteerPositionAddReviewModal: FC = const { data: simulation, isError } = useSimulateContract({ ...prepare, query: { - enabled: Boolean(approved && chainId === chain?.id), + enabled: Boolean(approved && vault.chainId === chain?.id), }, }) @@ -214,7 +218,7 @@ export const SteerPositionAddReviewModal: FC = }, [writeContractAsync, simulation /*, adjustedGas*/]) const { status } = useWaitForTransactionReceipt({ - chainId: chainId, + chainId: vault.chainId, hash, }) @@ -235,7 +239,7 @@ export const SteerPositionAddReviewModal: FC = - {Chain.from(chainId)!.name} + {Chain.from(vault.chainId)!.name} @@ -312,7 +316,7 @@ export const SteerPositionAddReviewModal: FC = )} = ({ vault, }) => { - const { chainId } = vault as { chainId: ChainId } - const client = usePublicClient() const { address: account, chain } = useAccount() const [value, setValue] = useState('0') @@ -63,11 +55,11 @@ export const SteerPositionRemove: FC = ({ }) const [token0, token1] = useMemo(() => { - const token0 = new Token({ chainId: chainId, ...vault.pool.token0 }) - const token1 = new Token({ chainId: chainId, ...vault.pool.token1 }) + const token0 = new Token(vault.token0) + const token1 = new Token(vault.token1) return [token0, token1] - }, [chainId, vault]) + }, [vault]) const tokenAmountsTotal = useMemo(() => { const token0Amount = Amount.fromRawAmount( @@ -107,7 +99,7 @@ export const SteerPositionRemove: FC = ({ void createToast({ account, type: 'burn', - chainId: chainId, + chainId: vault.chainId, txHash: hash, promise: client.waitForTransactionReceipt({ hash }), summary: { @@ -119,7 +111,7 @@ export const SteerPositionRemove: FC = ({ groupTimestamp: ts, }) }, - [client, account, chainId, token0.symbol, token1.symbol], + [client, account, vault.chainId, token0.symbol, token1.symbol], ) const onError = useCallback((e: Error) => { @@ -134,13 +126,13 @@ export const SteerPositionRemove: FC = ({ !position || position?.steerTokenBalance === 0n || !tokenAmountsDiscounted || - !isSteerChainId(chainId) + !isSteerChainId(vault.chainId) ) return undefined return { - address: vault.address as Address, - chainId, + address: vault.address, + chainId: vault.chainId, abi: steerMultiPositionManager, functionName: 'withdraw', args: [ @@ -152,7 +144,7 @@ export const SteerPositionRemove: FC = ({ } satisfies UseSimulateContractParameters }, [ account, - chainId, + vault.chainId, position, slippagePercent, tokenAmountsDiscounted, @@ -162,7 +154,7 @@ export const SteerPositionRemove: FC = ({ const { data: simulation } = useSimulateContract({ ...prepare, query: { - enabled: prepare && chainId === chain?.id, + enabled: prepare && vault.chainId === chain?.id, }, }) @@ -279,7 +271,7 @@ export const SteerPositionRemove: FC = ({ fullWidth variant="outline" size="xl" - chainId={chainId} + chainId={vault.chainId} >