Skip to content

Commit

Permalink
Merge pull request #1474 from sushiswap/feature/egn-694
Browse files Browse the repository at this point in the history
repo optimizations
  • Loading branch information
OlaStenberg authored Jun 12, 2024
2 parents b39d620 + 5909726 commit c2303fe
Show file tree
Hide file tree
Showing 1,006 changed files with 46,609 additions and 18,407 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions apis/extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion apis/extractor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ export const EXTRACTOR_CONFIG: Record<
},
[ChainId.TELOS]: {
client: createPublicClient(extractorClientConfig(ChainId.TELOS)),
factoriesV2: [sushiswapV2Factory(ChainId.TELOS)],
factoriesV2: [],
factoriesV3: [],
factoriesAlgebra: [
{
Expand Down
6 changes: 3 additions & 3 deletions apis/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions apis/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion apps/academy/common/components/AdditionalArticles.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions apps/academy/common/components/ArticlesPageHeader.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 1 addition & 3 deletions apps/academy/common/components/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion apps/academy/common/components/Difficulties.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions apps/academy/common/components/DifficultyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions apps/academy/common/components/DifficultyLabel.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion apps/academy/common/components/FilterButton.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion apps/academy/common/productsData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
FantomCircle,
OptimismCircle,
PolygonCircle,
} from '@sushiswap/ui/components/icons'
} from '@sushiswap/ui'

import {
AcademyIcon,
Expand Down
2 changes: 1 addition & 1 deletion apps/aptos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
39 changes: 39 additions & 0 deletions apps/evm/analyze/nodejs.html

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions apps/evm/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -17,7 +22,6 @@ const nextConfig = {
experimental: {
testProxy: true,
},
transpilePackages: ['@sushiswap/wagmi'],
async redirects() {
return [
{
Expand Down Expand Up @@ -100,7 +104,7 @@ const nextConfig = {
// widenClientFileUpload: true,
// automaticVercelMonitors: true,
// },
}
})

/** @type {import('@sentry/nextjs').SentryWebpackPluginOptions} */
// const sentryWebpackPluginOptions = {
Expand Down
14 changes: 7 additions & 7 deletions apps/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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": {
Expand All @@ -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",
Expand Down
97 changes: 25 additions & 72 deletions apps/evm/src/app/(landing)/api/stats/route.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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,
SUSHISWAP_V3_SUPPORTED_CHAIN_IDS,
} 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/${
Expand All @@ -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<ExchangeData>(
(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<ExchangeData>(
(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<ExchangeData>(
(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<ExchangeData>(
Expand All @@ -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
Expand Down
Loading

0 comments on commit c2303fe

Please sign in to comment.