Skip to content

Commit

Permalink
Merge pull request #504 from liquity/update-yield-information
Browse files Browse the repository at this point in the history
devui: Update yield information on Stability Pool and Farm
  • Loading branch information
edmulraney authored Apr 7, 2021
2 parents 25c7ab7 + e3b0b4b commit c760806
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions packages/dev-frontend/src/components/Farm/views/Yield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const selector = ({
export const Yield: React.FC = () => {
const {
liquity: {
connection: { addresses }
connection: { addresses, liquidityMiningLQTYRewardRate }
}
} = useLiquity();

Expand All @@ -28,6 +28,8 @@ export const Yield: React.FC = () => {
const hasZeroValue = remainingLiquidityMiningLQTYReward.isZero || totalStakedUniTokens.isZero;
const lqtyTokenAddress = addresses["lqtyToken"];
const uniTokenAddress = addresses["uniToken"];
const secondsRemaining = remainingLiquidityMiningLQTYReward.div(liquidityMiningLQTYRewardRate);
const daysRemaining = secondsRemaining.div(60 * 60 * 24);

useEffect(() => {
(async () => {
Expand All @@ -51,7 +53,9 @@ export const Yield: React.FC = () => {

return (
<Badge>
<Text>Yield {yieldPercentage.toString(2)}%</Text>
<Text>
{daysRemaining?.prettify(0)} day yield {yieldPercentage.toString(2)}%
</Text>
<InfoIcon
tooltip={
<Card variant="tooltip" sx={{ minWidth: ["auto", "352px"] }}>
Expand Down
14 changes: 7 additions & 7 deletions packages/dev-frontend/src/components/Stability/Yield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@ export const Yield: React.FC = () => {
const yearlyHalvingSchedule = 0.5; // 50% see LQTY distribution schedule for more info
const remainingLqtyOneYear = remainingStabilityPoolLQTYReward.mul(yearlyHalvingSchedule);
const remainingLqtyInUSD = remainingLqtyOneYear.mul(lqtyPrice);
const apyPercentage = remainingLqtyInUSD.div(lusdInStabilityPool).mul(100);
const aprPercentage = remainingLqtyInUSD.div(lusdInStabilityPool).mul(100);

if (apyPercentage.isZero) return null;
if (aprPercentage.isZero) return null;

return (
<Badge>
<Text>LQTY APY {apyPercentage.toString(2)}%</Text>
<Text>LQTY APR {aprPercentage.toString(2)}%</Text>
<InfoIcon
tooltip={
<Card variant="tooltip" sx={{ width: ["220px", "506px"] }}>
<Card variant="tooltip" sx={{ width: ["220px", "518px"] }}>
<Paragraph>
An <Text sx={{ fontWeight: "bold" }}>estimate</Text> of the LQTY return on the LUSD
deposited to the Stability Pool over the next year, not including your ETH gains from
liquidations.
</Paragraph>
<Paragraph sx={{ fontSize: "12px", fontFamily: "monospace", mt: 2 }}>
($LQTY_REWARDS * YEARLY_DISTRIBUTION% / DEPOSITED_LUSD) * 100 ={" "}
<Text sx={{ fontWeight: "bold" }}> APY</Text>
(($LQTY_REWARDS * YEARLY_DISTRIBUTION%) / DEPOSITED_LUSD) * 100 ={" "}
<Text sx={{ fontWeight: "bold" }}> APR</Text>
</Paragraph>
<Paragraph sx={{ fontSize: "12px", fontFamily: "monospace" }}>
($
{remainingLqtyInUSD.shorten()} * 50% / ${lusdInStabilityPool.shorten()}) * 100 =
<Text sx={{ fontWeight: "bold" }}> {apyPercentage.toString(2)}%</Text>
<Text sx={{ fontWeight: "bold" }}> {aprPercentage.toString(2)}%</Text>
</Paragraph>
</Card>
}
Expand Down

0 comments on commit c760806

Please sign in to comment.