Skip to content

Commit

Permalink
net apr formula (#50)
Browse files Browse the repository at this point in the history
* wip formula

* net apr formula
  • Loading branch information
0xshiba1 authored May 13, 2024
1 parent 280755c commit 6892345
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 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 Down
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,10 +105,7 @@ function AccountPositionCardContent() {
</div>

<div className="flex flex-row items-center justify-between gap-2">
<LabelWithTooltip
>
Net APR
</LabelWithTooltip>
<LabelWithTooltip tooltip={NET_APR_TOOLTIP}>Net APR</LabelWithTooltip>
<TBody className="w-max text-right">
{formatPercent(netAprPercent)}
</TBody>
Expand Down
26 changes: 26 additions & 0 deletions frontend/src/lib/tooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Latex from "react-latex-next";

import TextLink from "@/components/shared/TextLink";
import "katex/dist/katex.min.css";
import { Separator } from "@/components/ui/separator";

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 @@ -24,6 +25,31 @@ export const EQUITY_TOOLTIP = (
</>
);

export const NET_APR_TOOLTIP = (
<>
If your account is worth $X today, assuming no prices or rates change, in 1
year it will be worth $X × (1 + Net APR).
<br />
<br />
<Separator />
<span className="text-muted-foreground">
<Latex>
{
"$$D = \\sum_{i=0}^{N(\\textnormal{Deposits})} USD(d_i) \\times APR(d_i)$$"
}
</Latex>
<Latex>
{
"$$B = \\sum_{i=0}^{N(\\textnormal{Borrows})} USD(b_i) \\times APR(b_i)$$"
}
</Latex>
<Latex>
{"$$\\textnormal{Net APR} = \\frac{D-B}{USD(d) - USD(b)}$$"}
</Latex>
</span>
</>
);

export const WEIGHTED_BORROWS_TOOLTIP = (
<>
Your weighted borrows is the value of all assets borrowed, adjusted by their
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,5 @@ body {
/* LaTeX */
.katex-display {
width: max-content;
margin: 6px 0 !important;
margin: 12px 0 !important;
}

0 comments on commit 6892345

Please sign in to comment.