diff --git a/website/src/lib/components/self/TradeModal.svelte b/website/src/lib/components/self/TradeModal.svelte
index 68aa438..417d6e7 100644
--- a/website/src/lib/components/self/TradeModal.svelte
+++ b/website/src/lib/components/self/TradeModal.svelte
@@ -5,7 +5,7 @@
import { Label } from '$lib/components/ui/label';
import { Badge } from '$lib/components/ui/badge';
import { TrendingUp, TrendingDown, Loader2 } from 'lucide-svelte';
- import { USER_DATA } from '$lib/stores/user-data';
+ import { PORTFOLIO_DATA } from '$lib/stores/portfolio-data';
import { toast } from 'svelte-sonner';
let {
@@ -33,10 +33,9 @@
? Math.min(userHolding, Math.floor(Number(coin.poolCoinAmount) * 0.995))
: userHolding
);
-
let estimatedResult = $derived(calculateEstimate(numericAmount, type, currentPrice));
let hasValidAmount = $derived(numericAmount > 0);
- let userBalance = $derived($USER_DATA ? Number($USER_DATA.baseCurrencyBalance) : 0);
+ let userBalance = $derived($PORTFOLIO_DATA ? $PORTFOLIO_DATA.baseCurrencyBalance : 0);
let hasEnoughFunds = $derived(
type === 'BUY' ? numericAmount <= userBalance : numericAmount <= userHolding
);
@@ -114,7 +113,7 @@
function setMaxAmount() {
if (type === 'SELL') {
amount = maxSellableAmount.toString();
- } else if ($USER_DATA) {
+ } else if ($PORTFOLIO_DATA) {
// For BUY, max is user's balance
amount = userBalance.toString();
}
@@ -164,7 +163,7 @@
Max sellable: {maxSellableAmount.toFixed(0)} {coin.symbol} (pool limit)
{/if}
Balance: ${userBalance.toFixed(6)}
diff --git a/website/src/lib/stores/websocket.ts b/website/src/lib/stores/websocket.ts index 4d220dc..8d2a0ba 100644 --- a/website/src/lib/stores/websocket.ts +++ b/website/src/lib/stores/websocket.ts @@ -16,6 +16,16 @@ export interface LiveTrade { userImage?: string; } +export interface PriceUpdate { + coinSymbol: string; + currentPrice: number; + marketCap: number; + change24h: number; + volume24h: number; + poolCoinAmount?: number; + poolBaseCurrencyAmount?: number; +} + // Constants const WEBSOCKET_URL = PUBLIC_WEBSOCKET_URL; const RECONNECT_DELAY = 5000; @@ -32,10 +42,14 @@ export const liveTradesStore = writable- ${formatPrice(coin.currentPrice)} -
++ ${formatPrice(coin.currentPrice)} +
+{formatMarketCap(coin.marketCap)}
++ {formatMarketCap(coin.marketCap)} +
{formatMarketCap(coin.volume24h)}
++ {formatMarketCap(coin.volume24h)} +