Skip to content

Commit cf8870d

Browse files
committed
Add isNewDesign feature flag
1 parent 8bf1119 commit cf8870d

File tree

13 files changed

+189
-34
lines changed

13 files changed

+189
-34
lines changed

apps/hyperdrive-trading/src/ui/app/Navbar/DevtoolsMenu.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export function DevtoolsMenu(): ReactElement {
2020
<FeatureFlagMenuItem flagName="show-paused-pools">
2121
Show paused pools
2222
</FeatureFlagMenuItem>
23+
<FeatureFlagMenuItem flagName="new-design">
24+
New design
25+
</FeatureFlagMenuItem>
2326
<MenuItem
2427
onClick={() => {
2528
window.localStorage.clear();

apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongForm/OpenLongForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function OpenLongForm({
4949
onOpenLong,
5050
}: OpenLongFormProps): ReactElement {
5151
const { address: account } = useAccount();
52+
const { isFlagEnabled: isNewDesign } = useFeatureFlag("new-design");
5253
const connectedChainId = useChainId();
5354
const { marketState } = useMarketState({
5455
hyperdriveAddress: hyperdrive.address,
@@ -450,7 +451,7 @@ export function OpenLongForm({
450451
onOpenLong?.(e);
451452
}}
452453
>
453-
Buy Fixed
454+
{isNewDesign ? "Buy Fixed" : "Open Long"}
454455
</button>
455456
);
456457
})()}

apps/hyperdrive-trading/src/ui/markets/PoolRow/FixedAprCta.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
33
import { Link } from "@tanstack/react-router";
44
import { ReactElement } from "react";
55
import { formatRate } from "src/base/formatRate";
6+
import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags";
67
import { useFixedRate } from "src/ui/hyperdrive/longs/hooks/useFixedRate";
78
import { PercentLabel } from "src/ui/markets/PoolRow/PercentLabel";
89
import { PoolStat } from "src/ui/markets/PoolRow/PoolStat";
@@ -14,6 +15,7 @@ interface FixedAprCtaProps {
1415

1516
export function FixedAprCta({ hyperdrive }: FixedAprCtaProps): ReactElement {
1617
const { address: account } = useAccount();
18+
const { isFlagEnabled: isNewDesign } = useFeatureFlag("new-design");
1719
const { fixedApr, fixedRateStatus } = useFixedRate({
1820
chainId: hyperdrive.chainId,
1921
hyperdriveAddress: hyperdrive.address,
@@ -59,6 +61,36 @@ export function FixedAprCta({ hyperdrive }: FixedAprCtaProps): ReactElement {
5961
)
6062
}
6163
isLoading={fixedRateStatus === "loading"}
64+
action={
65+
isNewDesign ? null : (
66+
<Link
67+
to="/market/$chainId/$address"
68+
params={{
69+
address: hyperdrive.address,
70+
chainId: hyperdrive.chainId.toString(),
71+
}}
72+
search={{ position: "long" }}
73+
className="daisy-btn h-10 min-h-10 w-full rounded-full bg-gray-500 sm:daisy-btn-sm hover:bg-gray-400 sm:h-8 sm:bg-gray-600 sm:hover:bg-gray-500 md:w-28"
74+
onClick={(e) => {
75+
e.stopPropagation();
76+
window.plausible("positionCtaClick", {
77+
props: {
78+
chainId: hyperdrive.chainId,
79+
poolAddress: hyperdrive.address,
80+
positionType: "long",
81+
statName: label,
82+
statValue: fixedApr
83+
? fixed(fixedApr.apr, 18).toString()
84+
: "",
85+
connectedWallet: account,
86+
},
87+
});
88+
}}
89+
>
90+
Open Long
91+
</Link>
92+
)
93+
}
6294
/>
6395
</Link>
6496
);

apps/hyperdrive-trading/src/ui/markets/PoolRow/LpApyCta.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { fixed } from "@delvtech/fixed-point-wasm";
22
import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
33
import { Link } from "@tanstack/react-router";
44
import { ReactElement } from "react";
5+
import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags";
56
import { useLpApy } from "src/ui/hyperdrive/lp/hooks/useLpApy";
67
import { LpApyStat } from "src/ui/markets/PoolRow/LpApyStat";
78
import { PoolStat } from "src/ui/markets/PoolRow/PoolStat";
@@ -14,6 +15,7 @@ interface LpApyCtaProps {
1415

1516
export function LpApyCta({ hyperdrive }: LpApyCtaProps): ReactElement {
1617
const { address: account } = useAccount();
18+
const { isFlagEnabled: isNewDesign } = useFeatureFlag("new-design");
1719
const { lpApy, lpApyStatus } = useLpApy({
1820
hyperdriveAddress: hyperdrive.address,
1921
chainId: hyperdrive.chainId,
@@ -62,6 +64,36 @@ export function LpApyCta({ hyperdrive }: LpApyCtaProps): ReactElement {
6264
hyperdriveAddress={hyperdrive.address}
6365
/>
6466
}
67+
action={
68+
isNewDesign ? null : (
69+
<Link
70+
to="/market/$chainId/$address"
71+
params={{
72+
address: hyperdrive.address,
73+
chainId: hyperdrive.chainId.toString(),
74+
}}
75+
search={{ position: "lp" }}
76+
className="daisy-btn h-10 min-h-10 w-full rounded-full bg-gray-500 sm:daisy-btn-sm hover:bg-gray-400 sm:h-8 sm:bg-gray-600 sm:hover:bg-gray-500 md:w-32"
77+
onClick={(e) => {
78+
e.stopPropagation();
79+
window.plausible("positionCtaClick", {
80+
props: {
81+
chainId: hyperdrive.chainId,
82+
poolAddress: hyperdrive.address,
83+
positionType: "lp",
84+
statName: label,
85+
statValue: lpApy?.netLpApy
86+
? fixed(lpApy.netLpApy).toString()
87+
: "",
88+
connectedWallet: account,
89+
},
90+
});
91+
}}
92+
>
93+
Add Liquidity
94+
</Link>
95+
)
96+
}
6597
/>
6698
</Link>
6799
);

apps/hyperdrive-trading/src/ui/markets/PoolRow/PoolRow.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { isTestnetChain } from "src/chains/isTestnetChain";
1212
import { getDepositAssets } from "src/hyperdrive/getDepositAssets";
1313
import { useAppConfigForConnectedChain } from "src/ui/appconfig/useAppConfigForConnectedChain";
1414
import { Well } from "src/ui/base/components/Well/Well";
15+
import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags";
1516
import { formatCompact } from "src/ui/base/formatting/formatCompact";
1617
import { usePresentValue } from "src/ui/hyperdrive/hooks/usePresentValue";
1718
import { AssetStack } from "src/ui/markets/AssetStack";
@@ -37,6 +38,7 @@ const pinnedBorderClassNames: Record<number, string> = {
3738
export function PoolRow({ hyperdrive }: PoolRowProps): ReactElement {
3839
const navigate = useNavigate();
3940
const appConfig = useAppConfigForConnectedChain();
41+
const { isFlagEnabled: isNewDesign } = useFeatureFlag("new-design");
4042
const { chains } = appConfig;
4143
const chainInfo = chains[hyperdrive.chainId];
4244

@@ -175,13 +177,29 @@ export function PoolRow({ hyperdrive }: PoolRowProps): ReactElement {
175177

176178
{/* Right side */}
177179
<div className="flex flex-col items-center justify-between gap-6 sm:flex-row sm:gap-12 lg:items-start lg:justify-start">
178-
<div className="size-full border-r border-gray-500/20 lg:w-[112px]">
180+
<div
181+
className={
182+
isNewDesign
183+
? "size-full border-r border-gray-500/20 lg:w-[112px]"
184+
: "w-full lg:w-[112px]"
185+
}
186+
>
179187
<FixedAprCta hyperdrive={hyperdrive} />
180188
</div>
181-
<div className="size-full border-r border-gray-500/20 lg:w-[181px]">
189+
<div
190+
className={
191+
isNewDesign
192+
? "size-full border-r border-gray-500/20 lg:w-[181px]"
193+
: "w-full lg:w-[181px]"
194+
}
195+
>
182196
<VariableApyCta hyperdrive={hyperdrive} />
183197
</div>
184-
<div className="size-full lg:w-[122px]">
198+
<div
199+
className={
200+
isNewDesign ? "size-full lg:w-[122px]" : "w-full lg:w-[122px]"
201+
}
202+
>
185203
<LpApyCta hyperdrive={hyperdrive} />
186204
</div>
187205
</div>

apps/hyperdrive-trading/src/ui/markets/PoolRow/PoolStat.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export interface PoolStatProps {
1212
overlay?: ReactNode;
1313
value: ReactNode;
1414
isLoading?: boolean;
15+
16+
/**
17+
* @deprecated
18+
*/
19+
action?: ReactNode;
1520
isNew?: boolean;
1621
variant?: "default" | "gradient";
1722
}
@@ -22,6 +27,7 @@ export function PoolStat({
2227
overlay,
2328
isNew = false,
2429
variant = "default",
30+
action,
2531
isLoading = false,
2632
}: PoolStatProps): ReactElement {
2733
let displayValue;
@@ -43,6 +49,7 @@ export function PoolStat({
4349
>
4450
{displayValue}
4551
</div>
52+
{action}
4653
</div>
4754
);
4855

apps/hyperdrive-trading/src/ui/markets/PoolRow/VariableApyCta.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { fixed } from "@delvtech/fixed-point-wasm";
22
import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
33
import { Link } from "@tanstack/react-router";
44
import { ReactElement } from "react";
5+
import { calculateMarketYieldMultiplier } from "src/hyperdrive/calculateMarketYieldMultiplier";
6+
import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags";
7+
import { useCurrentLongPrice } from "src/ui/hyperdrive/longs/hooks/useCurrentLongPrice";
58
import { PoolStat } from "src/ui/markets/PoolRow/PoolStat";
69
import { VariableApyStat } from "src/ui/markets/PoolRow/VariableApyStat";
710
import { useOpenShortRewards } from "src/ui/rewards/hooks/useOpenShortRewards";
@@ -17,12 +20,23 @@ export function VariableApyCta({
1720
hyperdrive,
1821
}: YieldMultiplierCtaProps): ReactElement {
1922
const { address: account } = useAccount();
23+
const { isFlagEnabled: isNewDesign } = useFeatureFlag("new-design");
2024
const { vaultRate: yieldSourceRate } = useYieldSourceRate({
2125
chainId: hyperdrive.chainId,
2226
hyperdriveAddress: hyperdrive.address,
2327
});
28+
2429
const { rewards } = useOpenShortRewards({ hyperdriveConfig: hyperdrive });
2530

31+
const { longPrice, longPriceStatus } = useCurrentLongPrice({
32+
chainId: hyperdrive.chainId,
33+
hyperdriveAddress: hyperdrive.address,
34+
});
35+
const multiplier =
36+
longPriceStatus === "success" && longPrice
37+
? calculateMarketYieldMultiplier(longPrice)
38+
: undefined;
39+
2640
const label = yieldSourceRate
2741
? `Variable APY (${yieldSourceRate.ratePeriodDays}d)`
2842
: "Variable APY";
@@ -70,6 +84,37 @@ export function VariableApyCta({
7084
chainId={hyperdrive.chainId}
7185
/>
7286
}
87+
action={
88+
<div className="flex flex-col gap-2">
89+
{isNewDesign ? null : (
90+
<Link
91+
to="/market/$chainId/$address"
92+
params={{
93+
address: hyperdrive.address,
94+
chainId: hyperdrive.chainId.toString(),
95+
}}
96+
search={{ position: "short" }}
97+
className="daisy-btn h-10 min-h-10 w-full rounded-full bg-gray-500 sm:daisy-btn-sm hover:bg-gray-400 sm:h-8 sm:bg-gray-600 sm:hover:bg-gray-500 md:w-28"
98+
onClick={(e) => {
99+
e.stopPropagation();
100+
window.plausible("positionCtaClick", {
101+
props: {
102+
chainId: hyperdrive.chainId,
103+
poolAddress: hyperdrive.address,
104+
positionType: "short",
105+
statName: label,
106+
statValue: multiplier ? multiplier.toString() : "",
107+
connectedWallet: account,
108+
},
109+
});
110+
}}
111+
>
112+
Open Short
113+
</Link>
114+
)}
115+
<span className="gradient-text text-left font-inter text-sm font-medium">{`${multiplier?.format({ decimals: 0 })}x yield exposure`}</span>
116+
</div>
117+
}
73118
/>
74119
</Link>
75120
);

apps/hyperdrive-trading/src/ui/markets/PoolRow/VariableApyStat.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { getHyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
33
import { ReactNode } from "react";
44
import Skeleton from "react-loading-skeleton";
55
import { formatRate } from "src/base/formatRate";
6-
import { calculateMarketYieldMultiplier } from "src/hyperdrive/calculateMarketYieldMultiplier";
76
import { useAppConfigForConnectedChain } from "src/ui/appconfig/useAppConfigForConnectedChain";
8-
import { useCurrentLongPrice } from "src/ui/hyperdrive/longs/hooks/useCurrentLongPrice";
97
import { useShortRate } from "src/ui/hyperdrive/shorts/hooks/useShortRate";
108
import { PercentLabel } from "src/ui/markets/PoolRow/PercentLabel";
119
import { useOpenShortRewards } from "src/ui/rewards/hooks/useOpenShortRewards";
@@ -30,10 +28,6 @@ export function VariableApyStat({
3028
chainId,
3129
hyperdriveAddress,
3230
});
33-
const { longPrice, longPriceStatus } = useCurrentLongPrice({
34-
chainId: hyperdrive.chainId,
35-
hyperdriveAddress: hyperdrive.address,
36-
});
3731

3832
const { shortApr, shortRateStatus } = useShortRate({
3933
chainId: hyperdrive.chainId,
@@ -44,11 +38,6 @@ export function VariableApyStat({
4438
variableApy: yieldSourceRate?.netVaultRate,
4539
});
4640

47-
const multiplierLabel =
48-
longPriceStatus === "success" && longPrice
49-
? `${calculateMarketYieldMultiplier(longPrice).format({ decimals: 0 })}x`
50-
: undefined;
51-
5241
if (yieldSourceRateStatus !== "success" || shortRateStatus !== "success") {
5342
return <Skeleton width={100} />;
5443
}
@@ -64,7 +53,6 @@ export function VariableApyStat({
6453
/>
6554
{rewards?.length ? <span className="mx-1"></span> : null}
6655
</div>
67-
<span className="gradient-text text-left font-inter text-md font-medium">{`Up to ${multiplierLabel} exposure`}</span>
6856
</div>
6957
);
7058
}

apps/hyperdrive-trading/src/ui/markets/PositionPicker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
22
import { Link, useSearch } from "@tanstack/react-router";
33
import classNames from "classnames";
44
import { ReactElement } from "react";
5+
import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags";
56
import { formatTermLength2 } from "src/ui/markets/formatTermLength";
67
import { MARKET_DETAILS_ROUTE } from "src/ui/markets/routes";
78
import { useAccount } from "wagmi";
@@ -12,6 +13,7 @@ export function PositionPicker({
1213
hyperdrive: HyperdriveConfig;
1314
}): ReactElement {
1415
const { address: account } = useAccount();
16+
const { isFlagEnabled: isNewDesign } = useFeatureFlag("new-design");
1517
const { position: activePosition = "long" } = useSearch({
1618
from: MARKET_DETAILS_ROUTE,
1719
});
@@ -67,7 +69,7 @@ export function PositionPicker({
6769
});
6870
}}
6971
>
70-
Fixed
72+
{isNewDesign ? "Fixed" : "Long"}
7173
</Link>
7274
<Link
7375
className={classNames(

apps/hyperdrive-trading/src/ui/onboarding/faqData2.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
export const faqData2 = [
22
{
3-
question: "How do fixed rates work?",
3+
// This should be revised when the new-design feature flag is lifted
4+
// See https://github.com/delvtech/hyperdrive-frontend/commit/682098738b412ef46b665c76194e481d22632a9d
5+
question: "How can I get fixed rates?",
46
answer: (
57
<>
8+
<p>Open a Long and hold it to maturity.</p>
69
<p>
7-
When you open a fixed rate position in Hyperdrive, you&apos;re buying
8-
tokens at a discount. These tokens are redeemable at maturity for
9-
their full value, giving you a fixed return.
10+
When you open a Long in Hyperdrive, you&apos;re buying tokens at a
11+
discount. These tokens are redeemable at maturity for their full
12+
value, giving you a fixed return.
1013
</p>
1114
<p>
12-
Opening a fixed rate position has an immediate impact on the market.
13-
If more people buy the fixed rate, the fixed rate goes down. If they
14-
close their position, the fixed rate goes up.
15+
Opening Longs has an immediate impact on the market. If more people
16+
open Longs, the fixed rate goes down. If they close Longs, the fixed
17+
rate goes up.
1518
</p>
1619
<p>
17-
Users can also take speculative fixed rate positions where they bet on
18-
the short-term movement of rates. Read our docs to learn more about{" "}
20+
Users can also take speculative Long positions where they bet on the
21+
short-term movement of rates. Read our docs to learn more about{" "}
1922
<a
2023
className="daisy-link hover:text-white"
2124
rel="noreferrer"

0 commit comments

Comments
 (0)