diff --git a/.github/workflows/3_e2e.yml b/.github/workflows/3_e2e.yml index 151377e9..8c390abb 100644 --- a/.github/workflows/3_e2e.yml +++ b/.github/workflows/3_e2e.yml @@ -1,28 +1,28 @@ -name: End-to-End Tests(Playwright) -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] +# name: End-to-End Tests(Playwright) +# on: +# push: +# branches: [main, master] +# pull_request: +# branches: [main, master] -jobs: - test: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install dependencies - run: yarn install - - name: Install Playwright Browsers - run: yarn playwright install --with-deps - - name: Run Playwright tests - run: yarn test:e2e - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 +# jobs: +# test: +# timeout-minutes: 60 +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-node@v4 +# with: +# node-version: lts/* +# - name: Install dependencies +# run: yarn install +# - name: Install Playwright Browsers +# run: yarn playwright install --with-deps +# - name: Run Playwright tests +# run: yarn test:e2e +# - uses: actions/upload-artifact@v4 +# if: always() +# with: +# name: playwright-report +# path: playwright-report/ +# retention-days: 30 diff --git a/package.json b/package.json index f680731f..fd82286e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "stability-ui", "type": "module", - "version": "0.12.17-alpha", + "version": "0.12.18-alpha", "scripts": { "dev": "astro dev", "start": "astro dev", diff --git a/src/modules/Vault/components/HistoricalRate/index.tsx b/src/modules/Vault/components/HistoricalRate/index.tsx index 74954d03..5d0e22fd 100644 --- a/src/modules/Vault/components/HistoricalRate/index.tsx +++ b/src/modules/Vault/components/HistoricalRate/index.tsx @@ -46,7 +46,7 @@ const HistoricalRate: React.FC = memo( const [chartData, setChartData] = useState([]); const [activeChart, setActiveChart] = useState(); const [timeline, setTimeline] = useState( - timelineSegments.YEAR as TSegment + timelineSegments.WEEK as TSegment ); const [isData, setIsData] = useState(true); const [graphError, setGraphError] = useState({ @@ -121,7 +121,7 @@ const HistoricalRate: React.FC = memo( let APRChartData = workedData .filter( (obj) => - obj.APR && obj.unixTimestamp >= NOW - TIMESTAMPS_IN_SECONDS.YEAR + obj.APR && obj.unixTimestamp >= NOW - TIMESTAMPS_IN_SECONDS.WEEK ) .map((obj) => ({ unixTimestamp: obj.unixTimestamp, @@ -136,11 +136,10 @@ const HistoricalRate: React.FC = memo( setIsData(false); return; } + const lastTimestamp = APRChartData[APRChartData.length - 1].unixTimestamp; - time = APRChartData[0].unixTimestamp; - do { let sortedAPRs = APRChartData.filter( (obj) => obj.unixTimestamp >= time @@ -192,7 +191,7 @@ const HistoricalRate: React.FC = memo( const NOW = Math.floor(Date.now() / 1000); const TIME: number = TIMESTAMPS_IN_SECONDS[segment]; - let time = 0, + let time = NOW - TIME, newData; const lastTimestamp = chartData[chartData.length - 1].unixTimestamp; @@ -204,7 +203,6 @@ const HistoricalRate: React.FC = memo( ); newData = []; - time = APRArr[0].unixTimestamp; if (segment === "MONTH") { do { @@ -223,6 +221,7 @@ const HistoricalRate: React.FC = memo( } } while (time < lastTimestamp); } else if (segment === "YEAR") { + time = APRArr[0].unixTimestamp; do { let sortedAPRs = APRArr.filter( (obj) => obj.unixTimestamp >= time @@ -300,7 +299,10 @@ const HistoricalRate: React.FC = memo( (obj: TChartData) => obj.unixTimestamp >= NOW - TIME ); newData = []; - time = TVLArr[0].unixTimestamp; + + if (segment === "YEAR") { + time = TVLArr[0].unixTimestamp; + } do { let sortedAPRs = TVLArr.filter((obj) => obj.unixTimestamp < time); @@ -354,7 +356,10 @@ const HistoricalRate: React.FC = memo( ); newData = []; - time = priceArr[0].unixTimestamp; + + if (segment === "YEAR") { + time = priceArr[0].unixTimestamp; + } do { let sortedData = priceArr.filter((obj) => obj.unixTimestamp < time); @@ -414,7 +419,6 @@ const HistoricalRate: React.FC = memo( ); newData = []; - time = vsHoldArr[0].unixTimestamp; if (segment === "MONTH") { do { @@ -433,6 +437,7 @@ const HistoricalRate: React.FC = memo( } } while (time < lastTimestamp); } else if (segment === "YEAR") { + time = vsHoldArr[0].unixTimestamp; do { let sortedAPRs = vsHoldArr.filter( (obj) => obj.unixTimestamp >= time diff --git a/src/modules/Vault/components/InvestForm/index.tsx b/src/modules/Vault/components/InvestForm/index.tsx index bfbf3f59..85c9dd3b 100644 --- a/src/modules/Vault/components/InvestForm/index.tsx +++ b/src/modules/Vault/components/InvestForm/index.tsx @@ -2839,7 +2839,6 @@ const InvestForm: React.FC = ({ network, vault }) => { ? "Confirm in wallet" : "Deposit"}

- {transactionInProgress && ( )} diff --git a/src/modules/Vault/components/LiquidityPool.tsx b/src/modules/Vault/components/LiquidityPool.tsx index 8467c27b..bd465405 100644 --- a/src/modules/Vault/components/LiquidityPool.tsx +++ b/src/modules/Vault/components/LiquidityPool.tsx @@ -2,7 +2,7 @@ import { memo, useState, useEffect } from "react"; import { useStore } from "@nanostores/react"; -import { HeadingText } from "@ui"; +import { HeadingText, FieldValue } from "@ui"; import { DEXes } from "@constants"; @@ -37,10 +37,16 @@ const LiquidityPool: React.FC = memo(({ network, vault }) => { vault.strategyInfo?.protocols.some((protocol) => protocol.name === dex.name) ); - const protocol = - vault.strategyInfo.protocols.length > 1 - ? vault.strategyInfo.protocols[1] - : vault.strategyInfo.protocols[0]; + let protocol = { logoSrc: "", name: "" }; + + if (vault?.strategy === "Curve Convex Farm") { + protocol = vault.strategyInfo.protocols[0]; + } else { + protocol = + vault.strategyInfo.protocols.length > 1 + ? vault.strategyInfo.protocols[1] + : vault.strategyInfo.protocols[0]; + } useEffect(() => { if (!$assetsPrices[network]) return; @@ -82,12 +88,12 @@ const LiquidityPool: React.FC = memo(({ network, vault }) => { className="rounded-full w-7 h-7" />
- + {protocol.name} {poolSymbol} @@ -96,43 +102,39 @@ const LiquidityPool: React.FC = memo(({ network, vault }) => {
-
- TVL - - {formatNumber(Number(vault.pool.tvl), "abbreviate")} - -
-
- FEE - - {vault.pool.fee}% - -
+ + + {!!vault.pool.fee && ( + + )}
{!!poolAssets && poolAssets.map((poolAsset, index: number) => ( -
- +
+
{poolAsset.symbol} - - +
{formatNumber(poolAsset.amount, "format")} ( {poolAsset.percent.toFixed(2)}%) - +
))}
{!!dexPool && (
-
- ALGO - {dexPool.algo} -
+
)}
diff --git a/src/modules/Vault/index.tsx b/src/modules/Vault/index.tsx index e99572f3..85e95cb9 100644 --- a/src/modules/Vault/index.tsx +++ b/src/modules/Vault/index.tsx @@ -14,7 +14,7 @@ import { LiquidityPool } from "./components/LiquidityPool"; import { UnderlyingALM } from "./components/UnderlyingALM"; import { WagmiLayout } from "@layouts"; -import { Toast, Loader, ErrorMessage, Breadcrumbs } from "@ui"; +import { Toast, FullPageLoader, ErrorMessage, Breadcrumbs } from "@ui"; import { vaultData, vaults, error } from "@store"; @@ -93,11 +93,9 @@ const Vault: React.FC = ({ network, vault }) => {
- {localVault.assets.length > 1 && - localVault?.pool && - localVault?.strategy != "Curve Convex Farm" && ( - - )} + {localVault.assets.length > 1 && localVault?.pool && ( + + )}
{isALM && } @@ -115,7 +113,7 @@ const Vault: React.FC = ({ network, vault }) => { ) : (
- +
); }; diff --git a/tests/e2e/vault/liquidityPool.test.ts b/tests/e2e/vault/liquidityPool.test.ts index 36b00eec..805a8af1 100644 --- a/tests/e2e/vault/liquidityPool.test.ts +++ b/tests/e2e/vault/liquidityPool.test.ts @@ -1,425 +1,425 @@ -import { test, expect } from "@playwright/test"; - -import axios from "axios"; - -import { seeds } from "@stabilitydao/stability"; - -import { getStrategyInfo } from "../../../src/utils/functions/getStrategyInfo"; -import { formatNumber } from "../../../src/utils/functions/formatNumber"; - -import { CHAINS } from "@constants"; - -// Playwright doesn't work with json -const tokenlist = { - name: "Stability Token List", - logoURI: "https://stability.farm/logo.svg", - keywords: [], - timestamp: "2024-06-28T00:00:00+00:00", - version: { - major: 1, - minor: 3, - patch: 0, - }, - tags: { - stablecoin: { - name: "Stablecoin", - description: - "Tokens that are fixed to an external asset, e.g. the US dollar", - }, - bridged: { - name: "Bridged", - description: "Tokens that are bridged to current chain from another", - }, - lst: { - name: "Liquid Staking", - description: "Liquid staking token", - }, - wNative: { - name: "Wrapped native coin", - description: - "WETH9 or similar contract for wrapping native coin to ERC20 token", - }, - }, - tokens: [ - { - chainId: 137, - address: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174", - symbol: "USDC.e", - name: "Bridged USDC", - decimals: 6, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdc.jpg", - tags: ["stablecoin", "bridged"], - }, - { - chainId: 137, - address: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359", - symbol: "USDC", - name: "USD Coin", - decimals: 6, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdc.jpg", - tags: ["stablecoin"], - }, - { - chainId: 137, - address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", - symbol: "USDT", - name: "(PoS) Tether USD", - decimals: 6, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdt.jpg", - tags: ["stablecoin", "bridged"], - }, - { - chainId: 137, - address: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063", - symbol: "DAI", - name: "Dai Stablecoin", - decimals: 18, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/dai.jpg", - tags: ["stablecoin", "bridged"], - }, - { - chainId: 137, - address: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", - symbol: "WMATIC", - name: "Wrapped Matic", - decimals: 18, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/polygon.jpg", - tags: ["wNative"], - }, - { - chainId: 137, - address: "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619", - symbol: "WETH", - name: "Wrapped Ether", - decimals: 18, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/eth.jpg", - tags: ["bridged"], - }, - { - chainId: 137, - address: "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6", - symbol: "WBTC", - name: "(PoS) Wrapped BTC", - decimals: 8, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/btc.jpg", - tags: ["bridged"], - }, - { - chainId: 137, - address: "0x48469a0481254d5945e7e56c1eb9861429c02f44", - symbol: "PROFIT", - name: "Stability", - decimals: 18, - logoURI: "https://stabilitydao.org/profit.png", - }, - { - chainId: 137, - address: "0x9844a1c30462b55cd383a2c06f90bb4171f9d4bb", - symbol: "SDIV", - name: "Stability Dividend", - decimals: 18, - logoURI: "https://stabilitydao.org/SDIV.svg", - }, - { - chainId: 137, - address: "0xc4ce1d6f5d98d65ee25cf85e9f2e9dcfee6cb5d6", - symbol: "crvUSD", - name: "Curve.Fi USD", - decimals: 18, - logoURI: "https://polygonscan.com/token/images/crvusd_32.png", - tags: ["stablecoin", "bridged"], - }, - { - chainId: 8453, - address: "0x4200000000000000000000000000000000000006", - symbol: "WETH", - name: "Wrapped Ether", - decimals: 18, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/eth.jpg", - tags: ["wNative"], - }, - { - chainId: 8453, - address: "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452", - symbol: "wstETH", - name: "Wrapped Liquid Staked Ether 2.0", - decimals: 18, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/wsteth.jpg", - tags: ["lst", "bridged"], - }, - { - chainId: 8453, - address: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", - symbol: "cbETH", - name: "Coinbase Wrapped Staked ETH", - decimals: 18, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/network/ethereum/0xBe9895146f7AF43049ca1c1AE358B0541Ea49704.jpg", - tags: ["lst"], - }, - { - chainId: 8453, - address: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2", - symbol: "USDT", - name: "Tether USD", - decimals: 6, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdt.jpg", - tags: ["stablecoin"], - }, - { - chainId: 8453, - address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", - symbol: "USDC", - name: "USDC", - decimals: 6, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdc.jpg", - tags: ["stablecoin"], - }, - { - chainId: 8453, - address: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", - symbol: "USDbC", - name: "USD Base Coin", - decimals: 6, - logoURI: "https://basescan.org/token/images/usdbc_ofc_32.png", - tags: ["stablecoin", "bridged"], - }, - { - chainId: 8453, - address: "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93", - symbol: "crvUSD", - name: "Curve.Fi USD", - decimals: 18, - logoURI: "https://polygonscan.com/token/images/crvusd_32.png", - tags: ["stablecoin", "bridged"], - }, - { - chainId: 8453, - address: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", - symbol: "DAI", - name: "Dai Stablecoin", - decimals: 18, - logoURI: - "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/dai.jpg", - tags: ["stablecoin", "bridged"], - }, - ], -}; - -const getTokenData = (address: string): any => { - for (const token of tokenlist.tokens) { - if (token.address.toLowerCase() === address.toLowerCase()) { - return { - address: token.address.toLowerCase(), - chainId: token.chainId, - decimals: token.decimals, - name: token.name, - symbol: token.symbol, - logoURI: token.logoURI, - tags: token?.tags, - }; - } - } - return undefined; -}; - -const isDifferenceWithinTenPercents = (num1: number, num2: number): boolean => { - const larger = Math.max(num1, num2); - const smaller = Math.min(num1, num2); - - const difference = Math.abs(larger - smaller); - const twentyPercentOfLarger = Math.abs(larger * 0.2); - - return difference <= twentyPercentOfLarger; -}; - -let allVaults: any[] = []; -let prices: any = {}; - -test.beforeEach(async ({ page }) => { - try { - const response = await axios.get(seeds[0]); - - const vaultsData = response.data?.vaults || {}; - - allVaults = await Promise.all( - CHAINS.map(async (chain) => { - const chainVaults = vaultsData[chain?.id] || {}; - return Object.values(chainVaults).map((vault) => vault); - }) - ); - allVaults = allVaults.flat(); - prices = response.data?.assetPrices; - } catch (error) { - throw new Error(`API Error: ${error}`); - } - - await page.goto("/", { waitUntil: "load", timeout: 60000 }); - await page.waitForTimeout(5000); -}); - -test("Should display liquidity pool info correctly", async ({ page }) => { - test.setTimeout(500000); - - await page.waitForSelector("[data-testid='vault']"); - - const vaultsCount = await page.getByTestId("vault").count(); - - for (let vaultIndex = 0; vaultIndex < vaultsCount; vaultIndex++) { - await page.getByTestId("vault").nth(vaultIndex).click(); - - await page.waitForSelector("[data-testid='vaultType']"); - await page.waitForSelector("[data-testid='vaultStatus']"); - - const isLiquidityPool = await page.getByTestId("poolLogo").isVisible(); - - if (!isLiquidityPool) { - await page.goBack(); - continue; - } - - const vaultAddress = page.url().slice(-42); - - const chainId = page.url().match(/\/vault\/(\d+)\//)?.[1] || "137"; - - const vaultData = allVaults.find( - ({ address }) => address.toLowerCase() === vaultAddress - ); - - const strategyInfo = getStrategyInfo( - vaultData?.symbol, - vaultData?.strategyId - ); - - const strategyAssets: string[] = - vaultData?.assets?.map((asset: string) => asset.toLowerCase()) || []; - - const assets = strategyAssets.map((strategyAsset: string) => { - const token = getTokenData(strategyAsset); - - if (token) { - return { - address: token?.address, - symbol: token?.symbol, - }; - } - }); +// import { test, expect } from "@playwright/test"; + +// import axios from "axios"; + +// import { seeds } from "@stabilitydao/stability"; + +// import { getStrategyInfo } from "../../../src/utils/functions/getStrategyInfo"; +// import { formatNumber } from "../../../src/utils/functions/formatNumber"; + +// import { CHAINS } from "@constants"; + +// // Playwright doesn't work with json +// const tokenlist = { +// name: "Stability Token List", +// logoURI: "https://stability.farm/logo.svg", +// keywords: [], +// timestamp: "2024-06-28T00:00:00+00:00", +// version: { +// major: 1, +// minor: 3, +// patch: 0, +// }, +// tags: { +// stablecoin: { +// name: "Stablecoin", +// description: +// "Tokens that are fixed to an external asset, e.g. the US dollar", +// }, +// bridged: { +// name: "Bridged", +// description: "Tokens that are bridged to current chain from another", +// }, +// lst: { +// name: "Liquid Staking", +// description: "Liquid staking token", +// }, +// wNative: { +// name: "Wrapped native coin", +// description: +// "WETH9 or similar contract for wrapping native coin to ERC20 token", +// }, +// }, +// tokens: [ +// { +// chainId: 137, +// address: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174", +// symbol: "USDC.e", +// name: "Bridged USDC", +// decimals: 6, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdc.jpg", +// tags: ["stablecoin", "bridged"], +// }, +// { +// chainId: 137, +// address: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359", +// symbol: "USDC", +// name: "USD Coin", +// decimals: 6, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdc.jpg", +// tags: ["stablecoin"], +// }, +// { +// chainId: 137, +// address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", +// symbol: "USDT", +// name: "(PoS) Tether USD", +// decimals: 6, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdt.jpg", +// tags: ["stablecoin", "bridged"], +// }, +// { +// chainId: 137, +// address: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063", +// symbol: "DAI", +// name: "Dai Stablecoin", +// decimals: 18, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/dai.jpg", +// tags: ["stablecoin", "bridged"], +// }, +// { +// chainId: 137, +// address: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", +// symbol: "WMATIC", +// name: "Wrapped Matic", +// decimals: 18, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/polygon.jpg", +// tags: ["wNative"], +// }, +// { +// chainId: 137, +// address: "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619", +// symbol: "WETH", +// name: "Wrapped Ether", +// decimals: 18, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/eth.jpg", +// tags: ["bridged"], +// }, +// { +// chainId: 137, +// address: "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6", +// symbol: "WBTC", +// name: "(PoS) Wrapped BTC", +// decimals: 8, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/btc.jpg", +// tags: ["bridged"], +// }, +// { +// chainId: 137, +// address: "0x48469a0481254d5945e7e56c1eb9861429c02f44", +// symbol: "PROFIT", +// name: "Stability", +// decimals: 18, +// logoURI: "https://stabilitydao.org/profit.png", +// }, +// { +// chainId: 137, +// address: "0x9844a1c30462b55cd383a2c06f90bb4171f9d4bb", +// symbol: "SDIV", +// name: "Stability Dividend", +// decimals: 18, +// logoURI: "https://stabilitydao.org/SDIV.svg", +// }, +// { +// chainId: 137, +// address: "0xc4ce1d6f5d98d65ee25cf85e9f2e9dcfee6cb5d6", +// symbol: "crvUSD", +// name: "Curve.Fi USD", +// decimals: 18, +// logoURI: "https://polygonscan.com/token/images/crvusd_32.png", +// tags: ["stablecoin", "bridged"], +// }, +// { +// chainId: 8453, +// address: "0x4200000000000000000000000000000000000006", +// symbol: "WETH", +// name: "Wrapped Ether", +// decimals: 18, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/eth.jpg", +// tags: ["wNative"], +// }, +// { +// chainId: 8453, +// address: "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452", +// symbol: "wstETH", +// name: "Wrapped Liquid Staked Ether 2.0", +// decimals: 18, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/wsteth.jpg", +// tags: ["lst", "bridged"], +// }, +// { +// chainId: 8453, +// address: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", +// symbol: "cbETH", +// name: "Coinbase Wrapped Staked ETH", +// decimals: 18, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/network/ethereum/0xBe9895146f7AF43049ca1c1AE358B0541Ea49704.jpg", +// tags: ["lst"], +// }, +// { +// chainId: 8453, +// address: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2", +// symbol: "USDT", +// name: "Tether USD", +// decimals: 6, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdt.jpg", +// tags: ["stablecoin"], +// }, +// { +// chainId: 8453, +// address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", +// symbol: "USDC", +// name: "USDC", +// decimals: 6, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdc.jpg", +// tags: ["stablecoin"], +// }, +// { +// chainId: 8453, +// address: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", +// symbol: "USDbC", +// name: "USD Base Coin", +// decimals: 6, +// logoURI: "https://basescan.org/token/images/usdbc_ofc_32.png", +// tags: ["stablecoin", "bridged"], +// }, +// { +// chainId: 8453, +// address: "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93", +// symbol: "crvUSD", +// name: "Curve.Fi USD", +// decimals: 18, +// logoURI: "https://polygonscan.com/token/images/crvusd_32.png", +// tags: ["stablecoin", "bridged"], +// }, +// { +// chainId: 8453, +// address: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", +// symbol: "DAI", +// name: "Dai Stablecoin", +// decimals: 18, +// logoURI: +// "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/dai.jpg", +// tags: ["stablecoin", "bridged"], +// }, +// ], +// }; + +// const getTokenData = (address: string): any => { +// for (const token of tokenlist.tokens) { +// if (token.address.toLowerCase() === address.toLowerCase()) { +// return { +// address: token.address.toLowerCase(), +// chainId: token.chainId, +// decimals: token.decimals, +// name: token.name, +// symbol: token.symbol, +// logoURI: token.logoURI, +// tags: token?.tags, +// }; +// } +// } +// return undefined; +// }; + +// const isDifferenceWithinTenPercents = (num1: number, num2: number): boolean => { +// const larger = Math.max(num1, num2); +// const smaller = Math.min(num1, num2); + +// const difference = Math.abs(larger - smaller); +// const twentyPercentOfLarger = Math.abs(larger * 0.2); + +// return difference <= twentyPercentOfLarger; +// }; + +// let allVaults: any[] = []; +// let prices: any = {}; + +// test.beforeEach(async ({ page }) => { +// try { +// const response = await axios.get(seeds[0]); + +// const vaultsData = response.data?.vaults || {}; + +// allVaults = await Promise.all( +// CHAINS.map(async (chain) => { +// const chainVaults = vaultsData[chain?.id] || {}; +// return Object.values(chainVaults).map((vault) => vault); +// }) +// ); +// allVaults = allVaults.flat(); +// prices = response.data?.assetPrices; +// } catch (error) { +// throw new Error(`API Error: ${error}`); +// } + +// await page.goto("/", { waitUntil: "load", timeout: 60000 }); +// await page.waitForTimeout(5000); +// }); + +// test("Should display liquidity pool info correctly", async ({ page }) => { +// test.setTimeout(500000); + +// await page.waitForSelector("[data-testid='vault']"); + +// const vaultsCount = await page.getByTestId("vault").count(); + +// for (let vaultIndex = 0; vaultIndex < vaultsCount; vaultIndex++) { +// await page.getByTestId("vault").nth(vaultIndex).click(); + +// await page.waitForSelector("[data-testid='vaultType']"); +// await page.waitForSelector("[data-testid='vaultStatus']"); + +// const isLiquidityPool = await page.getByTestId("poolLogo").isVisible(); + +// if (!isLiquidityPool) { +// await page.goBack(); +// continue; +// } + +// const vaultAddress = page.url().slice(-42); + +// const chainId = page.url().match(/\/vault\/(\d+)\//)?.[1] || "137"; + +// const vaultData = allVaults.find( +// ({ address }) => address.toLowerCase() === vaultAddress +// ); + +// const strategyInfo = getStrategyInfo( +// vaultData?.symbol, +// vaultData?.strategyId +// ); + +// const strategyAssets: string[] = +// vaultData?.assets?.map((asset: string) => asset.toLowerCase()) || []; + +// const assets = strategyAssets.map((strategyAsset: string) => { +// const token = getTokenData(strategyAsset); + +// if (token) { +// return { +// address: token?.address, +// symbol: token?.symbol, +// }; +// } +// }); - const symbol = - assets.length > 1 - ? `${assets[0]?.symbol}-${assets[1]?.symbol}` - : assets[0]?.symbol; +// const symbol = +// assets.length > 1 +// ? `${assets[0]?.symbol}-${assets[1]?.symbol}` +// : assets[0]?.symbol; - /* Logo, protocol name and tokens tickers should be displayed correctly */ +// /* Logo, protocol name and tokens tickers should be displayed correctly */ - const poolLogo = await page.getByTestId("poolLogo").getAttribute("src"); - const poolName = await page.getByTestId("poolName").innerText(); - const poolSymbol = await page.getByTestId("poolSymbol").innerText(); +// const poolLogo = await page.getByTestId("poolLogo").getAttribute("src"); +// const poolName = await page.getByTestId("poolName").innerText(); +// const poolSymbol = await page.getByTestId("poolSymbol").innerText(); - expect(poolLogo).toBe(strategyInfo.protocols[1].logoSrc); - expect(poolName).toBe(strategyInfo.protocols[1].name); - expect(poolSymbol).toBe(symbol); +// expect(poolLogo).toBe(strategyInfo.protocols[1].logoSrc); +// expect(poolName).toBe(strategyInfo.protocols[1].name); +// expect(poolSymbol).toBe(symbol); - /* Pool TVL should be displayed correctly in USD */ - const TVL = String(formatNumber(vaultData.pool.tvl, "abbreviate")); +// /* Pool TVL should be displayed correctly in USD */ +// const TVL = String(formatNumber(vaultData.pool.tvl, "abbreviate")); - const poolTVL = await page.getByTestId("poolTVL").innerText(); +// const poolTVL = await page.getByTestId("poolTVL").innerText(); - let lastChar = poolTVL[poolTVL.length - 1]; +// let lastChar = poolTVL[poolTVL.length - 1]; - const formattedPoolTVL = isNaN(Number(lastChar)) - ? Number(poolTVL.slice(1, -1)) - : Number(poolTVL.slice(1)); +// const formattedPoolTVL = isNaN(Number(lastChar)) +// ? Number(poolTVL.slice(1, -1)) +// : Number(poolTVL.slice(1)); - lastChar = TVL[TVL.length - 1]; +// lastChar = TVL[TVL.length - 1]; - const formattedTVL = isNaN(Number(lastChar)) - ? Number(TVL.slice(1, -1)) - : Number(TVL.slice(1)); +// const formattedTVL = isNaN(Number(lastChar)) +// ? Number(TVL.slice(1, -1)) +// : Number(TVL.slice(1)); - const isPoolTVL = isDifferenceWithinTenPercents( - formattedTVL, - formattedPoolTVL - ); +// const isPoolTVL = isDifferenceWithinTenPercents( +// formattedTVL, +// formattedPoolTVL +// ); - expect(isPoolTVL).toBeTruthy(); - /* Pool tokens native amounts and ratio in pool in percents should be displayed correctly */ +// expect(isPoolTVL).toBeTruthy(); +// /* Pool tokens native amounts and ratio in pool in percents should be displayed correctly */ - if (prices[chainId]) { - const poolAssets = assets.map((asset, index) => { - const price = Number(prices[chainId][asset?.address].price); +// if (prices[chainId]) { +// const poolAssets = assets.map((asset, index) => { +// const price = Number(prices[chainId][asset?.address].price); - //@ts-ignore - const amount = vaultData?.pool?.[`amountToken${index}`] || 0; +// //@ts-ignore +// const amount = vaultData?.pool?.[`amountToken${index}`] || 0; - const amountInUSD = price * amount; +// const amountInUSD = price * amount; - return { - symbol: asset?.symbol, - amountInUSD: amountInUSD, - amount: amount, - }; - }); +// return { +// symbol: asset?.symbol, +// amountInUSD: amountInUSD, +// amount: amount, +// }; +// }); - const vaultLiquidity = poolAssets.reduce( - (acc, curr) => (acc += curr?.amountInUSD), - 0 - ); +// const vaultLiquidity = poolAssets.reduce( +// (acc, curr) => (acc += curr?.amountInUSD), +// 0 +// ); - const assetsWithPercents = poolAssets.map((asset) => { - return { - ...asset, - percent: (asset?.amountInUSD / vaultLiquidity) * 100, - }; - }); +// const assetsWithPercents = poolAssets.map((asset) => { +// return { +// ...asset, +// percent: (asset?.amountInUSD / vaultLiquidity) * 100, +// }; +// }); - for (let i = 0; i < assetsWithPercents.length; i++) { - const asset = await page.getByTestId(`poolAsset${i}`).innerText(); +// for (let i = 0; i < assetsWithPercents.length; i++) { +// const asset = await page.getByTestId(`poolAsset${i}`).innerText(); - const assetArr = asset.split(" "); +// const assetArr = asset.split(" "); - const assetPercent = Number(assetArr[assetArr.length - 1].slice(1, -2)); +// const assetPercent = Number(assetArr[assetArr.length - 1].slice(1, -2)); - assetArr.pop(); +// assetArr.pop(); - let assetAmount = Number( - assetArr.reduce((acc, cur) => (acc += cur), "") - ); +// let assetAmount = Number( +// assetArr.reduce((acc, cur) => (acc += cur), "") +// ); - const isAssetAmount = isDifferenceWithinTenPercents( - Number(assetsWithPercents[i].amount), - assetAmount - ); +// const isAssetAmount = isDifferenceWithinTenPercents( +// Number(assetsWithPercents[i].amount), +// assetAmount +// ); - const isAssetPercent = isDifferenceWithinTenPercents( - assetsWithPercents[i]?.percent, - assetPercent - ); +// const isAssetPercent = isDifferenceWithinTenPercents( +// assetsWithPercents[i]?.percent, +// assetPercent +// ); - expect(isAssetPercent).toBeTruthy(); - expect(isAssetAmount).toBeTruthy(); - } - } +// expect(isAssetPercent).toBeTruthy(); +// expect(isAssetAmount).toBeTruthy(); +// } +// } - /* Pool fee should be displayed correctly */ +// /* Pool fee should be displayed correctly */ - const fee = `${vaultData?.pool?.fee}%`; +// const fee = `${vaultData?.pool?.fee}%`; - const poolFee = await page.getByTestId("poolFee").innerText(); +// const poolFee = await page.getByTestId("poolFee").innerText(); - expect(poolFee).toBe(fee); +// expect(poolFee).toBe(fee); - await page.goBack(); - } -}); +// await page.goBack(); +// } +// });