diff --git a/bun.lockb b/bun.lockb
index 53fc12b..503c6a1 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/package.json b/package.json
index 273bf68..eba7bc6 100644
--- a/package.json
+++ b/package.json
@@ -10,14 +10,14 @@
"lint": "biome check *"
},
"devDependencies": {
- "@biomejs/biome": "^1.8.3",
- "@sveltejs/kit": "^2.5.20",
- "@sveltejs/vite-plugin-svelte": "^3.1.1",
- "sass": "^1.77.8",
- "svelte": "^5.0.0-next.210",
+ "@biomejs/biome": "^1.9.0",
+ "@sveltejs/kit": "^2.5.27",
+ "@sveltejs/vite-plugin-svelte": "^4.0.0-next.7",
+ "sass": "^1.78.0",
+ "svelte": "^5.0.0-next.246",
"svelte-adapter-bun": "^0.5.2",
"svelte-preprocess": "^6.0.2",
- "vite": "^5.3.5"
+ "vite": "^5.4.5"
},
"type": "module",
"dependencies": {
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index f44dfb0..38ef484 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -15,76 +15,82 @@ import {
TimeScale,
} from "svelte-lightweight-charts";
-let {data} = $props();
+let { data } = $props();
const grouped = Object.groupBy(data.trades, ({ currency }) => currency);
let interval = $state("86400000");
let key = $state("USD");
-let trades = $derived((() => {
- let trades = grouped[key]
- .map((e) => {
- return {
- time: new Date(e.date),
- value: getPrice(e.price, e.currency),
- };
- })
- .toSorted((a, b) => (a.time - b.time));
-
- trades = Object.groupBy(
- trades,
- ({ time }) => new Date(time - (time % interval)) / 1000,
- );
-
- for (const intervalDate in trades) {
- trades[intervalDate] = trades[intervalDate].reduce((a, c) => {
- return {
- open: a.open ?? c.value,
- close: c.value,
- high: (c.value > a.high ? c.value : a.high) ?? c.value,
- low: (c.value < a.low ? c.value : a.low) ?? c.value,
- };
- }, {});
- trades[intervalDate].time = Number.parseInt(intervalDate, 10);
- }
- return Object.values(trades);
-})());
-let [volume, swaps] = $derived((() => {
- let volume = Object.groupBy(
- data.trades
+let trades = $derived(
+ (() => {
+ let trades = grouped[key]
.map((e) => {
return {
- volume: e.xmrAmount,
- time: e.date,
+ time: new Date(e.date),
+ value: getPrice(e.price, e.currency),
};
})
- .toSorted((a, b) => (a.time - b.time)),
- ({ time }) => new Date(time - (time % interval)) / 1000,
- );
- let swaps = {};
- for (const intervalDate in volume) {
- swaps[intervalDate] = volume[intervalDate].reduce(
- (a) => {
- return {
- value: a.value + 1,
- };
- },
- { value: 0 },
+ .toSorted((a, b) => a.time - b.time);
+
+ trades = Object.groupBy(
+ trades,
+ ({ time }) => new Date(time - (time % interval)) / 1000,
);
- volume[intervalDate] = volume[intervalDate].reduce(
- (a, c) => {
+ for (const intervalDate in trades) {
+ trades[intervalDate] = trades[intervalDate].reduce((a, c) => {
return {
- value: a.value + c.volume / 10 ** 12,
+ open: a.open ?? c.value,
+ close: c.value,
+ high: (c.value > a.high ? c.value : a.high) ?? c.value,
+ low: (c.value < a.low ? c.value : a.low) ?? c.value,
};
- },
- { value: 0 },
+ }, {});
+ trades[intervalDate].time = Number.parseInt(intervalDate, 10);
+ }
+ return Object.values(trades);
+ })(),
+);
+let [volume, swaps] = $derived(
+ (() => {
+ let volume = Object.groupBy(
+ data.trades
+ .map((e) => {
+ return {
+ volume: e.xmrAmount,
+ time: e.date,
+ };
+ })
+ .toSorted((a, b) => a.time - b.time),
+ ({ time }) => new Date(time - (time % interval)) / 1000,
);
+ let swaps = {};
+ for (const intervalDate in volume) {
+ swaps[intervalDate] = volume[intervalDate].reduce(
+ (a) => {
+ return {
+ value: a.value + 1,
+ };
+ },
+ { value: 0 },
+ );
- volume[intervalDate].time = Number.parseInt(intervalDate, 10);
- swaps[intervalDate].time = Number.parseInt(intervalDate, 10);
- }
- return [Object.values(volume), Object.values(swaps)];
-})());
-let precision = $derived(getSignificantDigits(trades.flatMap((e) => [e.open, e.close])));
+ volume[intervalDate] = volume[intervalDate].reduce(
+ (a, c) => {
+ return {
+ value: a.value + c.volume / 10 ** 12,
+ };
+ },
+ { value: 0 },
+ );
+
+ volume[intervalDate].time = Number.parseInt(intervalDate, 10);
+ swaps[intervalDate].time = Number.parseInt(intervalDate, 10);
+ }
+ return [Object.values(volume), Object.values(swaps)];
+ })(),
+);
+let precision = $derived(
+ getSignificantDigits(trades.flatMap((e) => [e.open, e.close])),
+);
const chartLayout = {
background: {
@@ -188,6 +194,6 @@ let w = $state();
{/each}
-
+
\ No newline at end of file
diff --git a/src/routes/market/[market]/+page.svelte b/src/routes/market/[market]/+page.svelte
index 003f00c..e67aeb1 100644
--- a/src/routes/market/[market]/+page.svelte
+++ b/src/routes/market/[market]/+page.svelte
@@ -10,38 +10,42 @@ import {
import { CandlestickSeries, Chart, TimeScale } from "svelte-lightweight-charts";
const market = $page.params.market;
-let {data} = $props();
+let { data } = $props();
const interval = 86400000;
-let trades = $derived((() => {
- let trades = data.trades
- .map((e) => {
- return {
- time: new Date(e.date),
- value: getPrice(e.price, e.currency, false, false),
- };
- })
- .toSorted((a, b) => (a.time - b.time));
+let trades = $derived(
+ (() => {
+ let trades = data.trades
+ .map((e) => {
+ return {
+ time: new Date(e.date),
+ value: getPrice(e.price, e.currency, false, false),
+ };
+ })
+ .toSorted((a, b) => a.time - b.time);
- trades = Object.groupBy(
- trades,
- ({ time }) => new Date(time - (time % interval)) / 1000,
- );
+ trades = Object.groupBy(
+ trades,
+ ({ time }) => new Date(time - (time % interval)) / 1000,
+ );
- for (const intervalDate in trades) {
- trades[intervalDate] = trades[intervalDate].reduce((a, c) => {
- return {
- open: a.open ?? c.value,
- close: c.value,
- high: (c.value > a.high ? c.value : a.high) ?? c.value,
- low: (c.value < a.low ? c.value : a.low) ?? c.value,
- };
- }, {});
- trades[intervalDate].time = Number.parseInt(intervalDate, 10);
- }
- return Object.values(trades);
-})());
+ for (const intervalDate in trades) {
+ trades[intervalDate] = trades[intervalDate].reduce((a, c) => {
+ return {
+ open: a.open ?? c.value,
+ close: c.value,
+ high: (c.value > a.high ? c.value : a.high) ?? c.value,
+ low: (c.value < a.low ? c.value : a.low) ?? c.value,
+ };
+ }, {});
+ trades[intervalDate].time = Number.parseInt(intervalDate, 10);
+ }
+ return Object.values(trades);
+ })(),
+);
-let precision = $derived(getSignificantDigits(trades.flatMap((e) => [e.open, e.close])));
+let precision = $derived(
+ getSignificantDigits(trades.flatMap((e) => [e.open, e.close])),
+);
let w = $state();
const chartLayout = {
@@ -117,7 +121,7 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
-
Last Trades
+
Latest Trades
diff --git a/src/routes/markets/+page.server.js b/src/routes/markets/+page.server.js
new file mode 100644
index 0000000..a86a2b6
--- /dev/null
+++ b/src/routes/markets/+page.server.js
@@ -0,0 +1,6 @@
+import { trades } from "$lib/server/context";
+import { get } from "svelte/store";
+
+export function load() {
+ return { trades: get(trades) };
+}
diff --git a/src/routes/markets/+page.svelte b/src/routes/markets/+page.svelte
index b9c4d8d..15f077a 100644
--- a/src/routes/markets/+page.svelte
+++ b/src/routes/markets/+page.svelte
@@ -1 +1,139 @@
-Under construction
\ No newline at end of file
+
+
+
+
+ Markets - Haveno Markets
+
+
+
+
+
+
+ Hourly
+ Daily
+ Weekly
+ Volume
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Markets
+
+
+
+ Currency
+ Price
+ Volume (XMR)
+ 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)}
+ {formatPrice(market.reduce((a,b) => a + b.xmrAmount, 0), "XMR", false, false)}
+ {market.length}
+
+ {/each}
+
+
+
+
+
+
+
Latest Trades
+
+
+
+ Date
+ Price
+ Amount (XMR)
+ Amount
+
+ {#each data.trades.slice(0, 64) as trade}
+
+ {new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")}
+ {formatPrice(trade.price, trade.currency, true, false)}
+ {formatPrice(trade.xmrAmount, "XMR", false, false)}
+ {formatPrice(trade.amount, trade.currency, false, false)} {trade.currency}
+
+ {/each}
+
+
+
+
\ No newline at end of file
diff --git a/src/routes/trades/+page.svelte b/src/routes/trades/+page.svelte
deleted file mode 100644
index b9c4d8d..0000000
--- a/src/routes/trades/+page.svelte
+++ /dev/null
@@ -1 +0,0 @@
-Under construction
\ No newline at end of file