Skip to content

Commit 1e1cb3f

Browse files
feat(BA-2964): Premium auction UI/UX for expired names in auction (#2691)
* Reuse launch auction logic to function for premium price auctions * Rename hook to match new method * Replace auction table with prod premium auction data * increase granularity of ui plot * Rename and refactor hook * Fix deps
1 parent 053ae02 commit 1e1cb3f

File tree

8 files changed

+488
-1072
lines changed

8 files changed

+488
-1072
lines changed

apps/web/src/components/Basenames/PremiumExplainerModal/index.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import Modal from 'apps/web/src/components/Modal';
22
import data from 'apps/web/src/data/usernamePriceDecayTable.json';
3-
import { useBasenamesLaunchTime } from 'apps/web/src/hooks/useBasenamesLaunchTime';
3+
import { useBasenamesNameExpiresWithGracePeriod } from 'apps/web/src/hooks/useBasenamesNameExpiresWithGracePeriod';
44
import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip } from 'recharts';
55
import { formatEther } from 'viem';
66

77
type CustomTooltipProps = {
88
active?: boolean;
99
baseSingleYearEthCost?: bigint;
10-
launchTimeSeconds?: bigint;
10+
auctionStartTimeSeconds?: bigint;
1111
payload: [
1212
{
1313
dataKey: 'premium';
1414
name: 'premium';
15-
payload: { hours: number; premium: number };
15+
payload: { days: number; premium: number };
1616
value: number;
1717
},
1818
];
@@ -22,13 +22,13 @@ function CustomTooltip({
2222
active,
2323
payload,
2424
baseSingleYearEthCost,
25-
launchTimeSeconds,
25+
auctionStartTimeSeconds,
2626
}: CustomTooltipProps) {
27-
if (active && payload?.length && launchTimeSeconds && baseSingleYearEthCost) {
27+
if (active && payload?.length && auctionStartTimeSeconds && baseSingleYearEthCost) {
2828
const premium = payload[0].value;
29-
const hours = payload[0].payload.hours;
30-
const seconds = hours * 60 * 60;
31-
const tooltipSeconds = seconds + Number(launchTimeSeconds);
29+
const days = payload[0].payload.days;
30+
const seconds = days * 24 * 60 * 60; // Convert days to seconds
31+
const tooltipSeconds = seconds + Number(auctionStartTimeSeconds);
3232
const timeOfPremium = new Date(tooltipSeconds * 1000).toLocaleString(undefined, {
3333
year: 'numeric',
3434
month: '2-digit',
@@ -65,15 +65,17 @@ type PremiumExplainerModalProps = {
6565
toggleModal: () => void;
6666
premiumEthAmount: bigint | undefined;
6767
baseSingleYearEthCost: bigint;
68+
name: string;
6869
};
6970
const chartMarginValues = { top: 2, right: 2, left: 2, bottom: 2 };
7071
export function PremiumExplainerModal({
7172
isOpen,
7273
toggleModal,
7374
premiumEthAmount,
7475
baseSingleYearEthCost,
76+
name,
7577
}: PremiumExplainerModalProps) {
76-
const { data: launchTimeSeconds } = useBasenamesLaunchTime();
78+
const { data: auctionStartTimeSeconds } = useBasenamesNameExpiresWithGracePeriod(name);
7779

7880
if (!premiumEthAmount || !baseSingleYearEthCost) return null;
7981
const formattedOneYearCost = Number(formatEther(baseSingleYearEthCost)).toLocaleString(
@@ -94,8 +96,8 @@ export function PremiumExplainerModal({
9496
<div className="flex max-w-[491px] flex-1 flex-col gap-3">
9597
<h1 className="w-full text-2xl font-bold">This name has a temporary premium</h1>
9698
<p className="mb-3 text-illoblack">
97-
To ensure fair distribution of Basenames, all names have a temporary premium starting at
98-
100 ETH that then decays exponentially to 0 over 36 hours.
99+
To ensure fair distribution of recently expired Basenames, all names have a price premium
100+
which starts at 100 ETH that then decays exponentially to 0 over 21 days.
99101
</p>
100102
<div className="grid grid-cols-2 grid-rows-4">
101103
<div className="col-span-2 mb-2 text-sm font-medium uppercase text-gray-60">
@@ -147,7 +149,7 @@ export function PremiumExplainerModal({
147149
// @ts-expect-error type wants an unnecessary prop
148150
<CustomTooltip
149151
baseSingleYearEthCost={baseSingleYearEthCost}
150-
launchTimeSeconds={launchTimeSeconds}
152+
auctionStartTimeSeconds={auctionStartTimeSeconds}
151153
/>
152154
}
153155
/>

apps/web/src/components/Basenames/RegistrationForm/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default function RegistrationForm() {
138138
const usdPrice = hasResolvedUSDPrice ? formatUsdPrice(price, ethUsdPrice) : '--.--';
139139
const nameIsFree = !hasRegisteredWithDiscount && price === 0n;
140140

141-
const { seconds, timestamp: premiumEndTimestamp } = usePremiumEndDurationRemaining();
141+
const { seconds, timestamp: premiumEndTimestamp } = usePremiumEndDurationRemaining(selectedName);
142142

143143
const isPremiumActive = Boolean(premiumPrice && premiumPrice !== 0n && seconds !== 0n);
144144
const mainRegistrationElementClasses = classNames(
@@ -331,6 +331,7 @@ export default function RegistrationForm() {
331331
baseSingleYearEthCost={singleYearBasePrice}
332332
isOpen={premiumExplainerModalOpen}
333333
toggleModal={togglePremiumExplainerModal}
334+
name={selectedName}
334335
/>
335336
)}
336337
</>

0 commit comments

Comments
 (0)