diff --git a/src/routes/[network]/(account)/ram/+page.svelte b/src/routes/[network]/(account)/ram/+page.svelte index e38cd2659..1c77e26b6 100644 --- a/src/routes/[network]/(account)/ram/+page.svelte +++ b/src/routes/[network]/(account)/ram/+page.svelte @@ -12,84 +12,65 @@ const { data } = $props(); const context = getContext('state'); + + const ramState = $derived(data.network.ramstate); + + let marketCapEOS: Asset | undefined = $state(); + let ramSupply: Asset | undefined = $state(); + + $effect(() => { + if (ramState) { + const quoteBalanceEOS = ramState.quote.balance.value; + const connectorWeight = ramState.quote.weight.value; + marketCapEOS = Asset.from( + quoteBalanceEOS / connectorWeight, + data.network.chain.systemToken?.symbol || '0, UNKNOWN' + ); + ramSupply = Asset.from((ramState?.base.balance.value || 0) / (1000 * 1000 * 1000), '2,GB'); + } + }); + + let marketCapUSDValue = $derived( + marketCapEOS?.value || 0 * (data.network.ramprice?.usd?.value || 0) + ); -{#if context.account} - - - {#if context.account.ram} -
-
- Total RAM: - -
-
-

Value:

- {#if context.account.network.ramprice} -
-
- Network Token: - {calculateValue( - Asset.fromUnits(context.account.ram.max, '3,RAM'), - context.account.network.ramprice.eos - )} -
- {#if context.account.network.ramprice.usd} -
- USD: - {calculateValue( - Asset.fromUnits(context.account.ram.max, '3,RAM'), - context.account.network.ramprice.usd - )} -
- {/if} -
- {:else} -

RAM price information unavailable

- {/if} -
+
+
+
+
+

RAM

+

Available

+

{ramState?.base.balance.toString() || '0 RAM'}

- {:else} -

Loading your RAM information...

- {/if} - - -{:else} - - To view your RAM usage, please log in or create an account. -{/if} - -{#if data.network && data.network.ramstate} - - -

Current RAM Price

-
-
- Network Token: - {String(data.network.ramstate.price_per_kb(1))}/KB +
+

Total RAM Value USD

+

$ {data.network.ramprice?.usd?.toString() || '0'}

+

Total RAM Value EOS

+

{data.network.ramprice?.eos?.toString() || '0 EOS'}

- {#if data.network.ramprice && data.network.ramprice.usd} -
- USD: - ${data.network.ramprice.usd.value}/KB -
- {/if}
- -{:else} -

Loading current RAM price...

-{/if} +
+ + +
+
-{#if data.network.supports('timeseries')} - {#if data.historicalPrices && data.historicalPrices.length > 0} - + - {:else} -

No historical RAM prices available.

- {/if} -{/if} +
+ +
+ +

RAM Market Cap

+

{String(marketCapEOS) || '0 EOS'}

+

+ $ {String(marketCapUSDValue) || '0.00'} USD +

+
+ +

RAM Supply

+

{String(ramSupply)}

+
+
+