+
+
+
Circulating Supply
{displayLamports(supply.circulating)} /{" "}
@@ -118,8 +118,11 @@ function StakingComponent() {
{circulatingPercentage}% is circulating
-
-
+
+
+
+
+
Active Stake
{activeStake && (
@@ -133,66 +136,65 @@ function StakingComponent() {
)}
-
- {solanaInfo && (
-
-
- Price{" "}
-
- Rank #{solanaInfo.market_cap_rank}
-
-
-
- ${solanaInfo.price.toFixed(2)}{" "}
- {solanaInfo.price_change_percentage_24h > 0 && (
-
- ↑ {solanaInfo.price_change_percentage_24h.toFixed(2)}%
-
- )}
- {solanaInfo.price_change_percentage_24h < 0 && (
-
- ↓ {solanaInfo.price_change_percentage_24h.toFixed(2)}%
-
- )}
- {solanaInfo.price_change_percentage_24h === 0 && (
- 0%
- )}
-
-
- 24h Vol: ${abbreviatedNumber(solanaInfo.volume_24)}{" "}
- MCap: ${abbreviatedNumber(solanaInfo.market_cap)}
-
-
- )}
- {coinInfo.status === CoingeckoStatus.FetchFailed && (
-
-
Price
-
- $--.--
-
- Error fetching the latest price information
-
- )}
- {solanaInfo && (
-
- Updated at{" "}
- {displayTimestampWithoutDate(solanaInfo.last_updated.getTime())}
-
- )}
+
+
+
+
+ {solanaInfo && (
+ <>
+
+ Price{" "}
+
+ Rank #{solanaInfo.market_cap_rank}
+
+
+
+ ${solanaInfo.price.toFixed(2)}{" "}
+ {solanaInfo.price_change_percentage_24h > 0 && (
+
+ ↑ {solanaInfo.price_change_percentage_24h.toFixed(2)}
+ %
+
+ )}
+ {solanaInfo.price_change_percentage_24h < 0 && (
+
+ ↓ {solanaInfo.price_change_percentage_24h.toFixed(2)}
+ %
+
+ )}
+ {solanaInfo.price_change_percentage_24h === 0 && (
+ 0%
+ )}
+
+
+ 24h Vol: ${abbreviatedNumber(solanaInfo.volume_24)}{" "}
+ MCap: ${abbreviatedNumber(solanaInfo.market_cap)}
+
+ >
+ )}
+ {coinInfo.status === CoingeckoStatus.FetchFailed && (
+ <>
+
Price
+
+ $--.--
+
+
Error fetching the latest price information
+ >
+ )}
+ {solanaInfo && (
+
+ Updated at{" "}
+ {displayTimestampWithoutDate(solanaInfo.last_updated.getTime())}
+
+ )}
+
+
);
}
-const abbreviatedNumber = (value: number, fixed = 1) => {
- if (value < 1e3) return value;
- if (value >= 1e3 && value < 1e6) return +(value / 1e3).toFixed(fixed) + "K";
- if (value >= 1e6 && value < 1e9) return +(value / 1e6).toFixed(fixed) + "M";
- if (value >= 1e9 && value < 1e12) return +(value / 1e9).toFixed(fixed) + "B";
- if (value >= 1e12) return +(value / 1e12).toFixed(fixed) + "T";
-};
-
function displayLamports(value: number) {
return abbreviatedNumber(lamportsToSol(value));
}
diff --git a/explorer/src/scss/_solana.scss b/explorer/src/scss/_solana.scss
index 53e020564a..7426b1828c 100644
--- a/explorer/src/scss/_solana.scss
+++ b/explorer/src/scss/_solana.scss
@@ -379,8 +379,11 @@ pre.json-wrap {
}
p.updated-time {
+ position: absolute;
font-size: 0.66rem;
- text-align: right;
+ margin: .375rem;
+ right: 0;
+ bottom: 0;
}
.change-positive {
diff --git a/explorer/src/utils/coingecko.tsx b/explorer/src/utils/coingecko.tsx
index cf86fbc5f9..df7d9626c4 100644
--- a/explorer/src/utils/coingecko.tsx
+++ b/explorer/src/utils/coingecko.tsx
@@ -9,6 +9,7 @@ const CoinGeckoClient = new CoinGecko();
export enum CoingeckoStatus {
Success,
FetchFailed,
+ Loading,
}
export interface CoinInfo {
@@ -49,7 +50,12 @@ export function useCoinGecko(coinId?: string): CoinGeckoResult | undefined {
React.useEffect(() => {
let interval: NodeJS.Timeout | undefined;
if (coinId) {
- const getCoinInfo = () => {
+ const getCoinInfo = (refresh = false) => {
+ if (!refresh) {
+ setCoinInfo({
+ status: CoingeckoStatus.Loading,
+ });
+ }
CoinGeckoClient.coins
.fetch(coinId)
.then((info: CoinInfoResult) => {
@@ -75,7 +81,7 @@ export function useCoinGecko(coinId?: string): CoinGeckoResult | undefined {
getCoinInfo();
interval = setInterval(() => {
- getCoinInfo();
+ getCoinInfo(true);
}, PRICE_REFRESH);
}
return () => {
diff --git a/explorer/src/utils/index.tsx b/explorer/src/utils/index.tsx
index 9f81b093ad..95fa3943c0 100644
--- a/explorer/src/utils/index.tsx
+++ b/explorer/src/utils/index.tsx
@@ -125,3 +125,11 @@ export function camelToTitleCase(str: string): string {
const result = str.replace(/([A-Z])/g, " $1");
return result.charAt(0).toUpperCase() + result.slice(1);
}
+
+export function abbreviatedNumber(value: number, fixed = 1) {
+ if (value < 1e3) return value;
+ if (value >= 1e3 && value < 1e6) return +(value / 1e3).toFixed(fixed) + "K";
+ if (value >= 1e6 && value < 1e9) return +(value / 1e6).toFixed(fixed) + "M";
+ if (value >= 1e9 && value < 1e12) return +(value / 1e9).toFixed(fixed) + "B";
+ if (value >= 1e12) return +(value / 1e12).toFixed(fixed) + "T";
+}