Skip to content

Commit 6a819ff

Browse files
committed
fix(apr-bar): correct staked ratio calculation and remove code duplication
1 parent 681c933 commit 6a819ff

File tree

10 files changed

+17
-427
lines changed

10 files changed

+17
-427
lines changed

apps/torus-wallet/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use client";
2+
3+
import { useTorus } from "@torus-ts/torus-provider";
4+
import { APRBarClient } from "@torus-ts/ui/components/apr";
5+
6+
export function APRBarWrapper() {
7+
const { api } = useTorus();
8+
return <APRBarClient api={api} />;
9+
}

apps/torus-wallet/src/app/_components/apr-bar/apr-bar-base.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

apps/torus-wallet/src/app/_components/apr-bar/apr-bar-shared.tsx

Lines changed: 0 additions & 57 deletions
This file was deleted.

apps/torus-wallet/src/app/_components/apr-bar/apr-bar.tsx

Lines changed: 0 additions & 94 deletions
This file was deleted.

apps/torus-wallet/src/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { WalletProvider } from "~/context/wallet-provider";
1212
import { env, EnvScript } from "~/env";
1313
import { firaMono } from "~/utils/fonts";
1414
import PlausibleProvider from "next-plausible";
15-
import { APRBar } from "./_components/apr-bar/apr-bar";
15+
import { APRBarWrapper } from "./_components/apr-bar-wrapper";
1616
import { SidebarLinks } from "./_components/sidebar-links";
1717
import { TransactionsSheet } from "./_components/transactions-sheet";
1818
import { WalletBalance } from "./_components/wallet-balance";
@@ -73,7 +73,7 @@ export default function RootLayout({
7373
torusCacheUrl={env("NEXT_PUBLIC_TORUS_CACHE_URL")}
7474
>
7575
<WalletHeader />
76-
<APRBar />
76+
<APRBarWrapper />
7777
<Container>
7878
<main className="mx-auto flex min-w-full flex-col items-center gap-3 text-white">
7979
<div className="flex w-full max-w-screen-xl flex-col justify-around gap-4 lg:mt-[10vh] lg:flex-row">

apps/torus-wallet/src/app/staking/_components/staking-calculator/staking-calculator.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import { formatToken } from "@torus-network/torus-utils/torus/token";
44
import { useCachedStakeOut } from "@torus-ts/query-provider/hooks";
55
import { useTorus } from "@torus-ts/torus-provider";
6+
import { useAPR } from "@torus-ts/ui/components/apr";
67
import { Card } from "@torus-ts/ui/components/card";
78
import { env } from "~/env";
8-
import { useAPR } from "~/hooks/useAPR";
99
import { DateTime } from "luxon";
1010
import { useEffect, useMemo, useState } from "react";
1111
import { StakingCalculatorAmountInput } from "./staking-calculator-amount-input";
@@ -30,8 +30,8 @@ export const FORECAST_MONTHS = 24;
3030
export const FORECAST_PERIODS = [3, 6, 12, 24];
3131

3232
function StakingCalculator() {
33-
const { selectedAccount } = useTorus();
34-
const { apr } = useAPR();
33+
const { api, selectedAccount } = useTorus();
34+
const { apr } = useAPR(api);
3535
const stakeOut = useCachedStakeOut(env("NEXT_PUBLIC_TORUS_CACHE_URL"));
3636
const projectedApr = apr ?? 24;
3737
const [customAmount, setCustomAmount] = useState("");

0 commit comments

Comments
 (0)