From fdcd613e0c44ca07d917815d1b772ada424fb2e5 Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Mon, 24 Mar 2025 10:00:48 -0700 Subject: [PATCH 1/2] Make CTAs link to respective pool details sections --- .../src/ui/markets/PoolRow/FixedAprCta.tsx | 60 ++++++++++++----- .../src/ui/markets/PoolRow/LpApyCta.tsx | 66 +++++++++++++------ .../src/ui/markets/PoolRow/VariableApyCta.tsx | 64 +++++++++++++----- 3 files changed, 135 insertions(+), 55 deletions(-) diff --git a/apps/hyperdrive-trading/src/ui/markets/PoolRow/FixedAprCta.tsx b/apps/hyperdrive-trading/src/ui/markets/PoolRow/FixedAprCta.tsx index 2598f7a63..3c1041f99 100644 --- a/apps/hyperdrive-trading/src/ui/markets/PoolRow/FixedAprCta.tsx +++ b/apps/hyperdrive-trading/src/ui/markets/PoolRow/FixedAprCta.tsx @@ -1,15 +1,19 @@ +import { fixed } from "@delvtech/fixed-point-wasm"; import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig"; +import { Link } from "@tanstack/react-router"; import { ReactElement } from "react"; import { formatRate } from "src/base/formatRate"; import { useFixedRate } from "src/ui/hyperdrive/longs/hooks/useFixedRate"; import { PercentLabel } from "src/ui/markets/PoolRow/PercentLabel"; import { PoolStat } from "src/ui/markets/PoolRow/PoolStat"; +import { useAccount } from "wagmi"; interface FixedAprCtaProps { hyperdrive: HyperdriveConfig; } export function FixedAprCta({ hyperdrive }: FixedAprCtaProps): ReactElement { + const { address: account } = useAccount(); const { fixedApr, fixedRateStatus } = useFixedRate({ chainId: hyperdrive.chainId, hyperdriveAddress: hyperdrive.address, @@ -18,22 +22,44 @@ export function FixedAprCta({ hyperdrive }: FixedAprCtaProps): ReactElement { const label = "Fixed APR"; return ( - - ) : ( - "-" - ) - } - isLoading={fixedRateStatus === "loading"} - /> + { + e.stopPropagation(); + window.plausible("positionCtaClick", { + props: { + chainId: hyperdrive.chainId, + poolAddress: hyperdrive.address, + positionType: "long", + statName: label, + statValue: fixedApr ? fixed(fixedApr.apr, 18).toString() : "", + connectedWallet: account, + }, + }); + }} + > + + ) : ( + "-" + ) + } + isLoading={fixedRateStatus === "loading"} + /> + ); } diff --git a/apps/hyperdrive-trading/src/ui/markets/PoolRow/LpApyCta.tsx b/apps/hyperdrive-trading/src/ui/markets/PoolRow/LpApyCta.tsx index cb809ec73..5a4204169 100644 --- a/apps/hyperdrive-trading/src/ui/markets/PoolRow/LpApyCta.tsx +++ b/apps/hyperdrive-trading/src/ui/markets/PoolRow/LpApyCta.tsx @@ -1,15 +1,19 @@ +import { fixed } from "@delvtech/fixed-point-wasm"; import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig"; +import { Link } from "@tanstack/react-router"; import { ReactElement } from "react"; import { useLpApy } from "src/ui/hyperdrive/lp/hooks/useLpApy"; import { LpApyStat } from "src/ui/markets/PoolRow/LpApyStat"; import { PoolStat } from "src/ui/markets/PoolRow/PoolStat"; import { RewardsTooltipContent } from "src/ui/rewards/RewardsTooltip/RewardsTooltipContent"; +import { useAccount } from "wagmi"; interface LpApyCtaProps { hyperdrive: HyperdriveConfig; } export function LpApyCta({ hyperdrive }: LpApyCtaProps): ReactElement { + const { address: account } = useAccount(); const { lpApy, lpApyStatus } = useLpApy({ hyperdriveAddress: hyperdrive.address, chainId: hyperdrive.chainId, @@ -18,25 +22,47 @@ export function LpApyCta({ hyperdrive }: LpApyCtaProps): ReactElement { const label = lpApy ? `LP APY (${lpApy.ratePeriodDays}d)` : "LP APY"; return ( - - } - isLoading={lpApyStatus === "loading"} - isNew={lpApy?.isNew} - value={ - - } - /> + { + e.stopPropagation(); + window.plausible("positionCtaClick", { + props: { + chainId: hyperdrive.chainId, + poolAddress: hyperdrive.address, + positionType: "lp", + statName: label, + statValue: lpApy?.netLpApy ? fixed(lpApy.netLpApy).toString() : "", + connectedWallet: account, + }, + }); + }} + > + + } + isLoading={lpApyStatus === "loading"} + isNew={lpApy?.isNew} + value={ + + } + /> + ); } diff --git a/apps/hyperdrive-trading/src/ui/markets/PoolRow/VariableApyCta.tsx b/apps/hyperdrive-trading/src/ui/markets/PoolRow/VariableApyCta.tsx index 2cf8e302b..7cd53ef4b 100644 --- a/apps/hyperdrive-trading/src/ui/markets/PoolRow/VariableApyCta.tsx +++ b/apps/hyperdrive-trading/src/ui/markets/PoolRow/VariableApyCta.tsx @@ -1,10 +1,13 @@ +import { fixed } from "@delvtech/fixed-point-wasm"; import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig"; +import { Link } from "@tanstack/react-router"; import { ReactElement } from "react"; import { PoolStat } from "src/ui/markets/PoolRow/PoolStat"; import { VariableApyStat } from "src/ui/markets/PoolRow/VariableApyStat"; import { useOpenShortRewards } from "src/ui/rewards/hooks/useOpenShortRewards"; import { RewardsTooltipContent } from "src/ui/rewards/RewardsTooltip/RewardsTooltipContent"; import { useYieldSourceRate } from "src/ui/vaults/useYieldSourceRate"; +import { useAccount } from "wagmi"; interface YieldMultiplierCtaProps { hyperdrive: HyperdriveConfig; @@ -13,6 +16,7 @@ interface YieldMultiplierCtaProps { export function VariableApyCta({ hyperdrive, }: YieldMultiplierCtaProps): ReactElement { + const { address: account } = useAccount(); const { vaultRate: yieldSourceRate } = useYieldSourceRate({ chainId: hyperdrive.chainId, hyperdriveAddress: hyperdrive.address, @@ -24,25 +28,49 @@ export function VariableApyCta({ : "Variable APY"; return ( - { + e.stopPropagation(); + window.plausible("positionCtaClick", { + props: { + chainId: hyperdrive.chainId, + poolAddress: hyperdrive.address, + positionType: "short", + statName: label, + statValue: yieldSourceRate?.netVaultRate + ? fixed(yieldSourceRate.netVaultRate).toString() + : "", + connectedWallet: account, + }, + }); + }} + > + + ) : null + } + value={ + - ) : null - } - value={ - - } - /> + } + /> + ); } From 5b1234e61b12eb0d4713851c4b97e6021d548e96 Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Mon, 24 Mar 2025 10:05:12 -0700 Subject: [PATCH 2/2] update captial exposure -> yield exposure --- .../ui/hyperdrive/shorts/OpenShortForm/OpenShortForm.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortForm/OpenShortForm.tsx b/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortForm/OpenShortForm.tsx index 14c5f176b..7ee7367e8 100644 --- a/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortForm/OpenShortForm.tsx +++ b/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortForm/OpenShortForm.tsx @@ -244,9 +244,9 @@ export function OpenShortForm({ amountOfBondsToShortAsBigInt && traderDeposit ? fixed(amountOfBondsToShortAsBigInt, activeToken.decimals) .div(traderDeposit, activeToken.decimals) - .format({ decimals: 2, rounding: "trunc" }) + .format({ decimals: 1, rounding: "trunc" }) : calculateMarketYieldMultiplier(longPrice ?? 0n).format({ - decimals: 2, + decimals: 1, rounding: "trunc", }); @@ -430,7 +430,7 @@ export function OpenShortForm({ ≈ {`${exposureMultiplier}x`} {" "} - capital exposure + yield exposure } valueLoading={longPriceStatus === "loading"}