Skip to content

Commit

Permalink
net apr tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
0xshiba1 committed May 10, 2024
1 parent 703c661 commit 03e9490
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
Binary file modified bun.lockb
Binary file not shown.
5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"next-themes": "^0.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-latex-next": "^3.0.0",
"react-merge-refs": "^2.1.1",
"react-responsive": "^10.0.0",
"recharts": "^2.12.0",
Expand All @@ -74,7 +75,7 @@
"postcss": "^8.4.33",
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3",
"tw-colors": "^3.3.1"
"tw-colors": "^3.3.1",
"typescript": "^5.3.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
DEPOSITS_TOOLTIP,
EQUITY_TOOLTIP,
LIQUIDATION_THRESHOLD_TOOLTIP,
NET_APR_TOOLTIP,
WEIGHTED_BORROWS_TOOLTIP,
} from "@/lib/tooltips";

Expand Down Expand Up @@ -104,7 +105,17 @@ function AccountPositionCardContent() {
</div>

<div className="flex flex-row items-center justify-between gap-2">
<LabelWithTooltip>Net APR</LabelWithTooltip>
<LabelWithTooltip
tooltip={NET_APR_TOOLTIP}
tooltipContentProps={{
style: {
maxWidth:
"min(var(--radix-tooltip-content-available-width), 360px)",
},
}}
>
Net APR
</LabelWithTooltip>
<TBody className="w-max text-right">
{formatPercent(netAprPercent)}
</TBody>
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/lib/tooltips.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Latex from "react-latex-next";

import TextLink from "@/components/shared/TextLink";
import "katex/dist/katex.min.css";

export const OPEN_LTV_BW_TOOLTIP =
"Open LTV is a ratio that determines how much borrow power is contributed by a deposited asset. Borrow weight (BW) is a multiplier on the value borrowed, used for borrow limit calculations.";
Expand All @@ -21,6 +24,24 @@ export const EQUITY_TOOLTIP = (
</>
);

export const NET_APR_TOOLTIP = (
<>
If your account is worth $X, assuming no prices or rates change, in 1 year
it will be worth $X * (1 + Net APR).
<br />
<br />
<span className="font-mono text-muted-foreground">
Formula:
<br />
<Latex>
{
"$$\\frac{\\sum_{Deposits} d_{USD,i} \\times d_{APR,i} - \\sum_{Borrows} b_{USD,i} \\times b_{APR,i}}{d_{USD} - b_{USD}}$$"
}
</Latex>
</span>
</>
);

export const WEIGHTED_BORROWS_TOOLTIP = (
<>
Your weighted borrows is the value of all assets borrowed, adjusted by their
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,9 @@ body {
border-radius: 38% 52% 75% 36% / 50% 40% 50% 60%;
}
}

/* LaTeX */
.katex-display {
width: max-content;
margin: 6px 0 !important;
}

0 comments on commit 03e9490

Please sign in to comment.