-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathMempoolAlert.tsx
56 lines (52 loc) · 1.62 KB
/
MempoolAlert.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { AlertCircleIcon } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert";
import { ExternalLinkButton } from "src/components/ui/button";
import { useMempoolApi } from "src/hooks/useMempoolApi";
export function MempoolAlert() {
const { data: recommendedFees } = useMempoolApi<{ fastestFee: number }>(
"/v1/fees/recommended",
true
);
const fees = {
"EXTREMELY HIGH": 200,
"very high": 150,
high: 100,
"moderately high": 50,
};
const fee = recommendedFees?.fastestFee;
if (!fee) {
return null;
}
const matchedFee = Object.entries(fees).find((entry) => fee >= entry[1]);
if (!matchedFee) {
return null;
}
return (
<Alert variant="destructive">
<AlertCircleIcon className="h-4 w-4" />
<AlertTitle>
Mempool Fees are currently{" "}
<span className="font-semibold">{matchedFee[0]}</span>
</AlertTitle>
<AlertDescription>
<p>Bitcoin transactions may be uneconomical at this time.</p>
<div className="flex gap-2 mt-2">
<ExternalLinkButton
variant={"destructive"}
to="https://guides.getalby.com/user-guide/v/alby-account-and-browser-extension/alby-hub/faq-alby-hub/what-to-do-during-times-of-high-onchain-fees"
size={"sm"}
>
Learn more
</ExternalLinkButton>
<ExternalLinkButton
to="https://mempool.space"
size={"sm"}
variant="outline"
>
View fees on mempool
</ExternalLinkButton>
</div>
</AlertDescription>
</Alert>
);
}