diff --git a/package.json b/package.json index 8e2d274..e6ad7c1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "stability-ui", "type": "module", - "version": "0.13.22-alpha", + "version": "0.13.23-alpha", "scripts": { "dev": "astro dev", "start": "astro dev", diff --git a/src/layouts/AppStore.tsx b/src/layouts/AppStore.tsx index 081aeea..20f22d3 100644 --- a/src/layouts/AppStore.tsx +++ b/src/layouts/AppStore.tsx @@ -74,19 +74,6 @@ import type { import type { Vaults, Vault } from "@stabilitydao/stability/out/api.types"; -const getVsHoldAPY = (lifetime: number, period: number) => { - if (lifetime >= 0) { - return ((lifetime / period) * 365).toFixed(2); - } - - const periodsPerYear = 365 / period; - - const periodFactor = 1 + lifetime / 100; - const compoundedAPR = Math.pow(periodFactor, periodsPerYear) - 1; - - return (compoundedAPR * 100).toFixed(2); -}; - const AppStore = (props: React.PropsWithChildren): JSX.Element => { const { address, isConnected } = useAccount(); @@ -406,28 +393,19 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => { } ///// VS HODL - const vaultCreated = vault.created as number; - const currentTime = Math.floor(Date.now() / 1000); - - const differenceInSecondsFromCreation = currentTime - vaultCreated; - - const secondsInADay = 60 * 60 * 24; - - const daysFromCreation = Math.round( - differenceInSecondsFromCreation / secondsInADay - ); + const daysFromCreation = getTimeDifference(vaultCreated)?.days; const vsHoldAPR = - vault.vsHold?.lifetime && getTimeDifference(vaultCreated)?.days >= 3 + vault.vsHold?.lifetime && daysFromCreation >= 3 ? Number(vault.vsHold?.lifetime).toFixed(2) : 0; - const lifetimeVsHoldAPR = getVsHoldAPY( - Number(vsHoldAPR), - daysFromCreation - ); + const lifetimeVsHoldAPR = + vault.vsHold?.aprLifetime && daysFromCreation >= 3 + ? Number(vault.vsHold?.aprLifetime).toFixed(2) + : 0; let lifetimeTokensHold: THoldData[] = []; if (vault.vsHold?.lifetimeAssets && prices) { @@ -447,29 +425,22 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => { const priceDifference = ((price - priceOnCreation) / priceOnCreation) * 100; - const percentDiff = - Number(vault.vsHold?.lifetimeAssets[index]) || 0; - - const yearPercentDiff = getVsHoldAPY( - Number(percentDiff), - daysFromCreation - ); - return { symbol: getTokenData(asset)?.symbol || "", initPrice: priceOnCreation.toFixed(2), price: price.toFixed(2), priceDifference: priceDifference.toFixed(2), - latestAPR: percentDiff.toFixed(2), - APR: yearPercentDiff, + latestAPR: + Number(vault.vsHold?.lifetimeAssets[index]).toFixed(2) || "0", + APR: + Number(vault.vsHold?.aprAssetsLifetime[index]).toFixed(2) || + "0", }; } ); } - const isVsActive = - getTimeDifference(vaultCreated).days > 2 && - !!Number(vault.sharePrice); + const isVsActive = daysFromCreation > 2 && !!Number(vault.sharePrice); /////***** YEARN PROTOCOLS *****///// let yearnProtocols: TYearnProtocol[] = []; diff --git a/tests/e2e/vault/basic.test.ts b/tests/e2e/vault/basic.test.ts index bfae266..32425b0 100644 --- a/tests/e2e/vault/basic.test.ts +++ b/tests/e2e/vault/basic.test.ts @@ -646,15 +646,15 @@ test("Should display basic info correctly", async ({ page }) => { // } /* Pool TVL should be dispalyed correctly */ - if (vaultData?.pool?.tvl) { - const infoBarPoolTVL = await page - .getByTestId("infoBarPoolTVL") - .innerText(); + // if (vaultData?.pool?.tvl) { + // const infoBarPoolTVL = await page + // .getByTestId("infoBarPoolTVL") + // .innerText(); - const poolTVL = formatNumber(Number(vaultData?.pool?.tvl), "abbreviate"); + // const poolTVL = formatNumber(Number(vaultData?.pool?.tvl), "abbreviate"); - expect(infoBarPoolTVL).toBe(poolTVL); - } + // expect(infoBarPoolTVL).toBe(poolTVL); + // } /* Share price should be displayed correctly */ // const vaultSP = await page.getByTestId("infoBarSP").innerText(); diff --git a/tests/e2e/vaults.test.ts b/tests/e2e/vaults.test.ts index 6fb69b3..958a7c2 100644 --- a/tests/e2e/vaults.test.ts +++ b/tests/e2e/vaults.test.ts @@ -305,52 +305,52 @@ test.describe("Vaults page tests", () => { await expect(vaultsAfterInvalidSearch).toBe(0); }); - test("should be filter by network", async ({ page }) => { - await page.waitForTimeout(5000); + // test("should be filter by network", async ({ page }) => { + // await page.waitForTimeout(5000); - const networks = await page.getByTestId("network"); - const networksCount = await networks.count(); + // const networks = await page.getByTestId("network"); + // const networksCount = await networks.count(); - const currentNetworks = []; + // const currentNetworks = []; - for (let i = 0; i < networksCount; i++) { - const networkName = await networks.nth(i).getAttribute("title"); + // for (let i = 0; i < networksCount; i++) { + // const networkName = await networks.nth(i).getAttribute("title"); - currentNetworks.push(networkName); - } + // currentNetworks.push(networkName); + // } - // to be all networks - await expect(currentNetworks).toEqual(NETWORKS); + // // to be all networks + // await expect(currentNetworks).toEqual(NETWORKS); - for (let i = 0; i < NETWORKS.length; i++) { - await networks.nth(i).click(); - if (i) await networks.nth(i - 1).click(); + // for (let i = 0; i < NETWORKS.length; i++) { + // await networks.nth(i).click(); + // if (i) await networks.nth(i - 1).click(); - await page.waitForTimeout(3000); + // await page.waitForTimeout(3000); - const vaults = await page.getByTestId("vault"); - const vaultsCount = await vaults.count(); + // const vaults = await page.getByTestId("vault"); + // const vaultsCount = await vaults.count(); - let networkVaultsCount = 0; + // let networkVaultsCount = 0; - for (let j = 0; j < vaultsCount; j++) { - const vault = vaults.nth(j); + // for (let j = 0; j < vaultsCount; j++) { + // const vault = vaults.nth(j); - const name = await vault - .locator("td") - .nth(0) - .getByRole("img") - .nth(0) - .getAttribute("alt"); + // const name = await vault + // .locator("td") + // .nth(0) + // .getByRole("img") + // .nth(0) + // .getAttribute("alt"); - if (name === NETWORKS[i]) { - networkVaultsCount++; - } - } + // if (name === NETWORKS[i]) { + // networkVaultsCount++; + // } + // } - await expect(networkVaultsCount).toEqual(vaultsCount); - } - }); + // await expect(networkVaultsCount).toEqual(vaultsCount); + // } + // }); test("should be filter by stablecoins", async ({ page }) => { const stablecoinsFilter = await page.getByTestId("filter").first(); @@ -380,20 +380,20 @@ test.describe("Vaults page tests", () => { await expect(stablecoinsVaultsCount).toEqual(vaultsCount); }); - test("should be all strategy filters", async ({ page }) => { - const strategiesCount = await page.getByTestId("strategy").count(); + // test("should be all strategy filters", async ({ page }) => { + // const strategiesCount = await page.getByTestId("strategy").count(); - const dropdownStrategies = []; + // const dropdownStrategies = []; - for (let i = 0; i < strategiesCount; i++) { - const strategy = await page.getByTestId("strategy").nth(i).textContent(); + // for (let i = 0; i < strategiesCount; i++) { + // const strategy = await page.getByTestId("strategy").nth(i).textContent(); - dropdownStrategies.push(strategy); - } + // dropdownStrategies.push(strategy); + // } - expect(dropdownStrategies.sort()).toEqual(STRATEGIES); - expect(strategiesCount).toBe(STRATEGIES.length); - }); + // expect(dropdownStrategies.sort()).toEqual(STRATEGIES); + // expect(strategiesCount).toBe(STRATEGIES.length); + // }); test("should be filter by strategy", async ({ page }) => { const strategiesCount = await page.getByTestId("strategy").count();