Skip to content

Commit

Permalink
Update RewardsTooltip to show multiplier based rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyDelott committed Dec 17, 2024
1 parent efc65e6 commit b34ac2c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
16 changes: 11 additions & 5 deletions apps/hyperdrive-trading/src/ui/rewards/RewardsTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fixed } from "@delvtech/fixed-point-wasm";
import { fixed, parseFixed } from "@delvtech/fixed-point-wasm";
import {
appConfig,
getHyperdriveConfig,
Expand Down Expand Up @@ -38,10 +38,13 @@ export function RewardsTooltip({
hyperdriveAddress: hyperdrive.address,
});

const multiplierLabel =
const multiplier =
longPriceStatus === "success" && longPrice
? `${calculateMarketYieldMultiplier(longPrice).format({ decimals: 1 })}x`
: undefined;
? calculateMarketYieldMultiplier(longPrice)
: null;
const multiplierLabel = multiplier
? `${multiplier.format({ decimals: 1 })}x`
: undefined;

if (!appConfigRewards?.length && multiplierLabel && (!netRate || !baseRate)) {
return (
Expand Down Expand Up @@ -200,7 +203,10 @@ export function RewardsTooltip({

<div className="grid justify-items-end">
<p className="flex items-center gap-1">
+{reward.pointMultiplier.toString()}x
{multiplier
?.mul(parseFixed(reward.pointMultiplier))
.format({ decimals: 0 })}
x
</p>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/hyperdrive-appconfig/src/rewards/etherfi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { EETH_ICON_URL } from "src/tokens/tokenIconsUrls";
export const fetchEtherfiRewards: RewardsResolver = async () => {
return [
{
type: "info",
type: "pointMultiplier",
iconUrl: EETH_ICON_URL,
message:
"eEther.fi loyalty points earned in this pool will be boosted 2x.",
pointMultiplier: 2n,
pointTokenLabel: "Ether.fi Loyalty Points",
},
];
};
5 changes: 3 additions & 2 deletions packages/hyperdrive-appconfig/src/rewards/gyroscope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { GYD_ICON_URL } from "src/tokens/tokenIconsUrls";
export const fetchGyroscopeRewards: RewardsResolver = async () => {
return [
{
type: "info",
message: "This pool is eligible for 2x SPIN Rewards",
type: "pointMultiplier",
iconUrl: GYD_ICON_URL,
pointMultiplier: 2n,
pointTokenLabel: "SPIN Rewards",
},
];
};

0 comments on commit b34ac2c

Please sign in to comment.