diff --git a/bun.lockb b/bun.lockb
index d83674a..53fc12b 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/package.json b/package.json
index 30be46e..273bf68 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"@sveltejs/kit": "^2.5.20",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"sass": "^1.77.8",
- "svelte": "^4.2.18",
+ "svelte": "^5.0.0-next.210",
"svelte-adapter-bun": "^0.5.2",
"svelte-preprocess": "^6.0.2",
"vite": "^5.3.5"
diff --git a/src/lib/server/context.js b/src/lib/server/context.js
index 947d18e..f2b690c 100644
--- a/src/lib/server/context.js
+++ b/src/lib/server/context.js
@@ -1,10 +1,15 @@
import { watch } from "fs";
-import { writable } from "svelte/store";
+import { derived, writable } from "svelte/store";
const offers = writable([]);
const trades = writable([]);
const crypto = writable([]);
const fiat = writable([]);
+const liquidity = derived(offers, ($offers) =>
+ Object.values($offers)
+ .flat()
+ .reduce((a, b) => a + Number.parseInt(b.amount), 0),
+);
const formatTrades = (e) => {
return e.map((e) => {
@@ -20,11 +25,26 @@ const formatTrades = (e) => {
});
};
const formatOffers = (e) => {
- return Object.groupBy(e, ({ currencyCode }) => currencyCode);
+ return Object.groupBy(
+ e.map((e) => {
+ return {
+ direction: e.direction,
+ currencyCode: e.currencyCode,
+ amount: e.amount,
+ price: e.price,
+ paymentMethod: e.paymentMethod,
+ primaryMarketAmount: e.primaryMarketAmount,
+ };
+ }),
+ ({ currencyCode }) => currencyCode,
+ );
};
const formatCrypto = (e) => {
- e[e.findIndex((e) => e.code === "XMR")].precision = 12;
- e[e.findIndex((e) => e.code === "XMR")].sign = "ɱ";
+ e.push({
+ precision: 12,
+ code: "XMR",
+ sign: "ɱ",
+ });
return e;
};
const formatFiat = (e) => {
@@ -47,16 +67,16 @@ Bun.file(`${import.meta.env.VITE_DB_PATH}trade_statistics.json`)
.then((j) => {
trades.set(formatTrades(j));
});
-Bun.file(`${import.meta.env.VITE_DB_PATH}crypto_currency_list.json`)
- .json()
- .then((j) => {
- crypto.set(formatCrypto(j));
- });
-Bun.file(`${import.meta.env.VITE_DB_PATH}/traditional_currency_list.json`)
+Bun.file(`${import.meta.env.VITE_DB_PATH}active_traditional_currency_list.json`)
.json()
.then((j) => {
fiat.set(formatFiat(j));
});
+Bun.file(`${import.meta.env.VITE_DB_PATH}active_crypto_currency_list.json`)
+ .json()
+ .then((j) => {
+ crypto.set(formatCrypto(j));
+ });
const watcher = watch(import.meta.env.VITE_DB_PATH, async (_, filename) => {
const file = Bun.file(import.meta.env.VITE_DB_PATH + filename);
@@ -84,4 +104,4 @@ process.on("SIGINT", () => {
process.exit(0);
});
-export { offers, trades, crypto, fiat };
+export { offers, trades, crypto, fiat, liquidity };
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index abe104d..9a6d9ae 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -15,153 +15,153 @@ Object.groupBy ||= (values, keyFinder) => {
\ No newline at end of file
diff --git a/src/routes/+page.server.js b/src/routes/+page.server.js
index 84f7fa0..6512e33 100644
--- a/src/routes/+page.server.js
+++ b/src/routes/+page.server.js
@@ -1,6 +1,6 @@
-import { offers, trades } from "$lib/server/context";
+import { liquidity, trades } from "$lib/server/context";
import { get } from "svelte/store";
export function load() {
- return { trades: get(trades), offers: get(offers) };
+ return { trades: get(trades), liquidity: get(liquidity) };
}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 0be8b67..e6a4da3 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -111,9 +111,6 @@ const gridLayout = {
},
};
let w;
-const liquidity = Object.values(data.offers)
- .flat()
- .reduce((a, b) => a + Number.parseInt(b.amount), 0);
@@ -125,77 +122,81 @@ const liquidity = Object.values(data.offers)
XMR/USD
{formatPrice(grouped["USD"][0].price, "USD", true)}
-
-
Liquidity
- {formatPrice(liquidity, "XMR", true, false)}
-
+
+
Liquidity
+ {formatPrice(data.liquidity, "XMR", true, false)}
+
-
-
Price XMR/
+
+
Price XMR/
-
-
-
-
-
-
-
- Volume
-
-
-
-
-
-
-
+
+
-
-
+
+
+
+
+ Volume
+
+
+
+
+
+
+
+
+
+
-
Markets
-
-
- Currency |
- Price |
- Trades |
-
- {#each Object.values(Object.groupBy(data.trades, ({currency}) => currency)).toSorted((a,b) => b.length - a.length || (b[0].currency < a[0].currency ? 1 : -1)).slice(0, 16) as market}
-
- {getAsset(market[0].currency).name} ({market[0].currency}) |
- {formatPrice(market[0].price, market[0].currency, true, false)} |
- {market.length} |
-
- {/each}
-
-
+
Markets
+
+
+
+ Currency |
+ Price |
+ Trades |
+
+ {#each Object.values(Object.groupBy(data.trades, ({currency}) => currency)).toSorted((a,b) => b.length - a.length || (b[0].currency < a[0].currency ? 1 : -1)).slice(0, 16) as market}
+
+ {getAsset(market[0].currency).name} ({market[0].currency}) |
+ {formatPrice(market[0].price, market[0].currency, true, false)} |
+ {market.length} |
+
+ {/each}
+
+
+
-
Trades
+
Trades
-
- Date |
- Amount (XMR) |
- Amount |
-
- {#each data.trades.slice(0, 16) as trade}
-
- {new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")} |
- {formatPrice(trade.xmrAmount, "XMR", false, false)} |
- {formatPrice(trade.amount, trade.currency, false, false)} {trade.currency} |
-
- {/each}
+
+
+ Date |
+ Amount (XMR) |
+ Amount |
+
+ {#each data.trades.slice(0, 16) as trade}
+
+ {new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")} |
+ {formatPrice(trade.xmrAmount, "XMR", false, false)} |
+ {formatPrice(trade.amount, trade.currency, false, false)} {trade.currency} |
+
+ {/each}
+
diff --git a/src/routes/market/[market]/+page.svelte b/src/routes/market/[market]/+page.svelte
index 92b4e77..7e486fc 100644
--- a/src/routes/market/[market]/+page.svelte
+++ b/src/routes/market/[market]/+page.svelte
@@ -71,69 +71,75 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
{marketPair} - Haveno Markets
-
-
{marketPair}
- {formatPrice(data.trades?.[0]?.price, market, true, false)}
-
-
-
-
-
+
+
{marketPair}
+ {formatPrice(data.trades?.[0]?.price, market, true, false)}
+
+
+
+
+
Buy Offers
-
- Price |
- Amount (XMR) |
- Amount ({market}) |
-
- {#each data.offers[BUY_SELL[0]]?.toSorted((a,b) => a.price < b.price ? 1 : -1)||[] as offer}
-
- {formatPrice(offer.price, market, false, false)} |
- {formatPrice(offer.amount, "XMR", false, false)} |
- {formatPrice(offer.primaryMarketAmount, market, false, false)} |
-
- {/each}
+
+
+ Price |
+ Amount (XMR) |
+ Amount ({market}) |
+
+ {#each data.offers[BUY_SELL[0]]?.toSorted((a,b) => a.price < b.price ? 1 : -1)||[] as offer}
+
+ {formatPrice(offer.price, market, false, false)} |
+ {formatPrice(offer.amount, "XMR", false, false)} |
+ {formatPrice(offer.primaryMarketAmount, market, false, false)} |
+
+ {/each}
+
Sell Offers
-
- Price |
- Amount (XMR) |
- Amount ({market}) |
-
- {#each data.offers[BUY_SELL[1]]?.toSorted((a,b) => a.price > b.price ? 1 : -1)||[] as offer}
-
- {formatPrice(offer.price, market, false, false)} |
- {formatPrice(offer.amount, "XMR", false, false)} |
- {formatPrice(offer.primaryMarketAmount, market, false, false)} |
-
- {/each}
+
+
+ Price |
+ Amount (XMR) |
+ Amount ({market}) |
+
+ {#each data.offers[BUY_SELL[1]]?.toSorted((a,b) => a.price > b.price ? 1 : -1)||[] as offer}
+
+ {formatPrice(offer.price, market, false, false)} |
+ {formatPrice(offer.amount, "XMR", false, false)} |
+ {formatPrice(offer.primaryMarketAmount, market, false, false)} |
+
+ {/each}
+
-
-
Last Trades
-
-
- Date |
- Price |
- Amount (XMR) |
- Amount ({market}) |
-
- {#each data.trades as trade}
-
- {new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")} |
- {formatPrice(trade.price, trade.currency, false, false)} |
- {formatPrice(trade.xmrAmount, "XMR", false, false)} |
- {formatPrice(trade.amount, trade.currency, false, false)} |
-
- {/each}
-
-
+
+
Last Trades
+
+
+
+ Date |
+ Price |
+ Amount (XMR) |
+ Amount ({market}) |
+
+ {#each data.trades as trade}
+
+ {new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")} |
+ {formatPrice(trade.price, trade.currency, false, false)} |
+ {formatPrice(trade.xmrAmount, "XMR", false, false)} |
+ {formatPrice(trade.amount, trade.currency, false, false)} |
+
+ {/each}
+
+
+
\ No newline at end of file
diff --git a/svelte.config.js b/svelte.config.js
index f6c3133..7e91979 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -1,12 +1,12 @@
import adapter from "svelte-adapter-bun";
-import preprocess from "svelte-preprocess";
+import { sveltePreprocess } from "svelte-preprocess";
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
},
- preprocess: [preprocess()],
+ preprocess: sveltePreprocess(),
};
export default config;