mirror of
https://gitea.gf4.pw/gf4/haveno-markets.git
synced 2024-12-22 08:09:21 +00:00
add prettier
biome doesn't support formatting html and css in svelte yet, so we use prettier as a workaround for now
This commit is contained in:
parent
64bcead0b2
commit
a921561083
9 changed files with 390 additions and 220 deletions
15
.prettierrc
Normal file
15
.prettierrc
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"useTabs": true,
|
||||
"singleQuote": false,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 80,
|
||||
"plugins": ["prettier-plugin-svelte"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.svelte",
|
||||
"options": {
|
||||
"parser": "svelte"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
10
README.md
10
README.md
|
@ -1,5 +1,7 @@
|
|||
# haveno-markets
|
||||
# Haveno Markets
|
||||
|
||||
## Requirements
|
||||
* Haveno
|
||||
* ./haveno-statsnode --dumpStatistics=true
|
||||
* bun
|
||||
|
||||
- Haveno
|
||||
- ./haveno-statsnode --dumpStatistics=true
|
||||
- bun
|
||||
|
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -6,13 +6,15 @@
|
|||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"fix": "biome check --write *",
|
||||
"fix": "prettier --write . && biome check --write *",
|
||||
"lint": "biome check *"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.9.3",
|
||||
"@sveltejs/kit": "^2.6.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.7",
|
||||
"prettier": "^3.3.2",
|
||||
"prettier-plugin-svelte": "^3.2.5",
|
||||
"sass": "^1.79.4",
|
||||
"svelte": "^5.0.0-next.262",
|
||||
"svelte-adapter-bun": "^0.5.2",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Haveno Markets</title>
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
<link rel="icon" href="data:;base64,=" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
|
|
|
@ -33,25 +33,39 @@ Object.groupBy ||= (values, keyFinder) => {
|
|||
<span>
|
||||
Links:
|
||||
<a href="https://haveno.markets">Clearnet</a> |
|
||||
<a href="http://lsj5o4i7iiogz6q4rstiv75nk7kots2f2nhuga75y7s23leskz2uh6id.onion">Tor</a> |
|
||||
<a
|
||||
href="http://lsj5o4i7iiogz6q4rstiv75nk7kots2f2nhuga75y7s23leskz2uh6id.onion"
|
||||
>Tor</a
|
||||
>
|
||||
|
|
||||
<a href="http://haveno-markets.i2p">I2P</a>
|
||||
<a href="http://okoeicsihmjkqcqaiqow3arcrzm5ascwhpxq34incxg6a5z4tjza.b32.i2p">(b32)</a>
|
||||
<a
|
||||
href="http://okoeicsihmjkqcqaiqow3arcrzm5ascwhpxq34incxg6a5z4tjza.b32.i2p"
|
||||
>(b32)</a
|
||||
>
|
||||
</span>
|
||||
<span style="display:flex;gap:.2em;">
|
||||
Data from:
|
||||
<a href="https://haveno-reto.com" style="display:inline-flex;gap:.2em;align-items:center;">
|
||||
<a
|
||||
href="https://haveno-reto.com"
|
||||
style="display:inline-flex;gap:.2em;align-items:center;"
|
||||
>
|
||||
<img src="/haveno-reto_logo.svg" alt="" style="height:1em;width:1em;" />
|
||||
haveno-reto
|
||||
</a>
|
||||
</span>
|
||||
<span>
|
||||
Donations:
|
||||
<a style="word-break:break-all;" href="monero:84LnuW3YpCQirNMN6y6Px1E3DfwnqwXVRARi9eHjzeSVFJqEQmJCxkP5WpkysbcktqUNhXxQLowhJGSknNjJWZNQ7FKp5bu">
|
||||
<a
|
||||
style="word-break:break-all;"
|
||||
href="monero:84LnuW3YpCQirNMN6y6Px1E3DfwnqwXVRARi9eHjzeSVFJqEQmJCxkP5WpkysbcktqUNhXxQLowhJGSknNjJWZNQ7FKp5bu"
|
||||
>
|
||||
84LnuW3YpCQirNMN6y6Px1E3DfwnqwXVRARi9eHjzeSVFJqEQmJCxkP5WpkysbcktqUNhXxQLowhJGSknNjJWZNQ7FKp5bu
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss" global>
|
||||
.app {
|
||||
display: flex;
|
||||
|
@ -94,21 +108,23 @@ Object.groupBy ||= (values, keyFinder) => {
|
|||
}
|
||||
.card {
|
||||
margin: 1em;
|
||||
padding:.5em;
|
||||
background-color:#552A64;
|
||||
padding: 0.5em;
|
||||
background-color: #552a64;
|
||||
border-radius: 5px;
|
||||
:global(h4) {
|
||||
text-align: center;
|
||||
color:#F1482D;
|
||||
color: #f1482d;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
th, td {
|
||||
th,
|
||||
td {
|
||||
text-align: right;
|
||||
padding:.3em;
|
||||
padding: 0.3em;
|
||||
}
|
||||
th:first-child, td:first-child {
|
||||
th:first-child,
|
||||
td:first-child {
|
||||
text-align: left;
|
||||
}
|
||||
tbody tr:nth-child(2n) {
|
||||
|
@ -120,7 +136,8 @@ Object.groupBy ||= (values, keyFinder) => {
|
|||
}
|
||||
}
|
||||
|
||||
a, .price {
|
||||
a,
|
||||
.price {
|
||||
text-decoration: none;
|
||||
color: #f60;
|
||||
}
|
||||
|
@ -129,10 +146,10 @@ Object.groupBy ||= (values, keyFinder) => {
|
|||
}
|
||||
.price {
|
||||
font-size: 2em;
|
||||
margin-bottom:.4em;
|
||||
margin-bottom: 0.4em;
|
||||
}
|
||||
h4 {
|
||||
margin:.4em;
|
||||
margin: 0.4em;
|
||||
}
|
||||
.trade-currency {
|
||||
font-size: 1em;
|
||||
|
@ -148,11 +165,11 @@ Object.groupBy ||= (values, keyFinder) => {
|
|||
width: 97% !important;
|
||||
}
|
||||
.card {
|
||||
margin:.5em 0;
|
||||
padding:.5em 0;
|
||||
margin: 0.5em 0;
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
.header {
|
||||
padding:.2em 0;
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
}
|
||||
.header > * {
|
||||
|
@ -160,7 +177,7 @@ Object.groupBy ||= (values, keyFinder) => {
|
|||
width: 33.3%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap:.2em;
|
||||
gap: 0.2em;
|
||||
}
|
||||
@media only screen and (max-width: 600px) {
|
||||
.header > * {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<svelte:options runes={true} />
|
||||
|
||||
<script>
|
||||
import {
|
||||
formatPrice,
|
||||
|
@ -116,7 +117,9 @@ let w = $state();
|
|||
<div class="row">
|
||||
<div class="col card">
|
||||
<h4>XMR/USD</h4>
|
||||
<span class="price">{formatPrice(grouped["USD"][0].price, "USD", true)}</span>
|
||||
<span class="price"
|
||||
>{formatPrice(grouped["USD"][0].price, "USD", true)}</span
|
||||
>
|
||||
</div>
|
||||
<div class="col card">
|
||||
<h4>Liquidity</h4>
|
||||
|
@ -126,14 +129,26 @@ let w = $state();
|
|||
|
||||
<div class="row">
|
||||
<div class="col card" style="flex:1;" bind:clientWidth={w}>
|
||||
<h4>Price XMR/<select bind:value={key}>
|
||||
<h4>
|
||||
Price XMR/<select bind:value={key}>
|
||||
{#each Object.keys(grouped) as key}
|
||||
<option>{key}</option>
|
||||
{/each}
|
||||
</select></h4>
|
||||
</select>
|
||||
</h4>
|
||||
|
||||
<Chart width={w-20} height={300} container={{class:"row"}} layout={chartLayout} grid={gridLayout}>
|
||||
<CandlestickSeries data={trades} reactive={true} priceFormat={{minMove:10**-precision, precision:precision}}></CandlestickSeries>
|
||||
<Chart
|
||||
width={w - 20}
|
||||
height={300}
|
||||
container={{ class: "row" }}
|
||||
layout={chartLayout}
|
||||
grid={gridLayout}
|
||||
>
|
||||
<CandlestickSeries
|
||||
data={trades}
|
||||
reactive={true}
|
||||
priceFormat={{ minMove: 10 ** -precision, precision: precision }}
|
||||
></CandlestickSeries>
|
||||
<TimeScale rightBarStaysOnScroll={true} rightOffset={0} />
|
||||
</Chart>
|
||||
</div>
|
||||
|
@ -143,13 +158,29 @@ let w = $state();
|
|||
<option value="3600000">Hourly</option>
|
||||
<option value="86400000">Daily</option>
|
||||
<option value="604800000">Weekly</option>
|
||||
</select> Volume</h4>
|
||||
<Chart width={w-20} height={300} container={{class:"row"}} layout={chartLayout} grid={gridLayout}>
|
||||
<LineSeries data={volume} reactive={true} priceFormat={{precision:2, minMove:.01}}>
|
||||
<PriceScale scaleMargins={{bottom:.4, top:.1}}/>
|
||||
</select> Volume
|
||||
</h4>
|
||||
<Chart
|
||||
width={w - 20}
|
||||
height={300}
|
||||
container={{ class: "row" }}
|
||||
layout={chartLayout}
|
||||
grid={gridLayout}
|
||||
>
|
||||
<LineSeries
|
||||
data={volume}
|
||||
reactive={true}
|
||||
priceFormat={{ precision: 2, minMove: 0.01 }}
|
||||
>
|
||||
<PriceScale scaleMargins={{ bottom: 0.4, top: 0.1 }} />
|
||||
</LineSeries>
|
||||
<HistogramSeries data={swaps} reactive={true} priceScaleId="" priceFormat={{precision:0, minMove:1}}>
|
||||
<PriceScale scaleMargins={{top:.7, bottom:0}}/>
|
||||
<HistogramSeries
|
||||
data={swaps}
|
||||
reactive={true}
|
||||
priceScaleId=""
|
||||
priceFormat={{ precision: 0, minMove: 1 }}
|
||||
>
|
||||
<PriceScale scaleMargins={{ top: 0.7, bottom: 0 }} />
|
||||
</HistogramSeries>
|
||||
<TimeScale rightBarStaysOnScroll={true} rightOffset={0} />
|
||||
</Chart>
|
||||
|
@ -165,10 +196,23 @@ let w = $state();
|
|||
<th>Price</th>
|
||||
<th>Trades</th>
|
||||
</tr>
|
||||
{#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}
|
||||
{#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}
|
||||
<tr>
|
||||
<td><a href="market/{market[0].currency}">{getAsset(market[0].currency).name} ({market[0].currency})</a></td>
|
||||
<td>{formatPrice(market[0].price, market[0].currency, true, false)}</td>
|
||||
<td
|
||||
><a href="market/{market[0].currency}"
|
||||
>{getAsset(market[0].currency).name} ({market[0].currency})</a
|
||||
></td
|
||||
>
|
||||
<td
|
||||
>{formatPrice(
|
||||
market[0].price,
|
||||
market[0].currency,
|
||||
true,
|
||||
false,
|
||||
)}</td
|
||||
>
|
||||
<td>{market.length}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
|
@ -187,9 +231,17 @@ let w = $state();
|
|||
</tr>
|
||||
{#each data.trades.slice(0, 16) as trade}
|
||||
<tr>
|
||||
<td>{new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")}</td>
|
||||
<td
|
||||
>{new Date(trade.date)
|
||||
.toISOString()
|
||||
.replace("T", " ")
|
||||
.replace(/\.\d*Z/, "")}</td
|
||||
>
|
||||
<td>{formatPrice(trade.xmrAmount, "XMR", false, false)}</td>
|
||||
<td>{formatPrice(trade.amount, trade.currency, false, false)} <span class="trade-currency">{trade.currency}</span></td>
|
||||
<td
|
||||
>{formatPrice(trade.amount, trade.currency, false, false)}
|
||||
<span class="trade-currency">{trade.currency}</span></td
|
||||
>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<svelte:options runes={true} />
|
||||
|
||||
<script>
|
||||
import { page } from "$app/stores";
|
||||
import {
|
||||
|
@ -66,16 +67,29 @@ const gridLayout = {
|
|||
const marketPair = isMoneroQuote(market) ? `${market}/XMR` : `XMR/${market}`;
|
||||
const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{marketPair} - Haveno Markets</title>
|
||||
</svelte:head>
|
||||
<div class="row">
|
||||
<div class="col card" bind:clientWidth={w}>
|
||||
<h4>{marketPair}</h4>
|
||||
<span class="price">{formatPrice(data.trades?.[0]?.price, market, true, false) || "-"}</span>
|
||||
<span class="price"
|
||||
>{formatPrice(data.trades?.[0]?.price, market, true, false) || "-"}</span
|
||||
>
|
||||
{#if data.trades?.length}
|
||||
<Chart width={w-20} height={500} container={{class:"row"}} layout={chartLayout} grid={gridLayout}>
|
||||
<CandlestickSeries data={trades} reactive={true} priceFormat={{minMove:10**-precision, precision:precision}}></CandlestickSeries>
|
||||
<Chart
|
||||
width={w - 20}
|
||||
height={500}
|
||||
container={{ class: "row" }}
|
||||
layout={chartLayout}
|
||||
grid={gridLayout}
|
||||
>
|
||||
<CandlestickSeries
|
||||
data={trades}
|
||||
reactive={true}
|
||||
priceFormat={{ minMove: 10 ** -precision, precision: precision }}
|
||||
></CandlestickSeries>
|
||||
<TimeScale rightBarStaysOnScroll={true} rightOffset={0} />
|
||||
</Chart>
|
||||
{/if}
|
||||
|
@ -95,7 +109,14 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
|
|||
<tr title={offer.paymentMethod}>
|
||||
<td>{formatPrice(offer.price, market, false, false)}</td>
|
||||
<td>{formatPrice(offer.amount, "XMR", false, false)}</td>
|
||||
<td>{formatPrice(offer.primaryMarketAmount, market, false, false)}</td>
|
||||
<td
|
||||
>{formatPrice(
|
||||
offer.primaryMarketAmount,
|
||||
market,
|
||||
false,
|
||||
false,
|
||||
)}</td
|
||||
>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
|
@ -114,7 +135,14 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
|
|||
<tr title={offer.paymentMethod}>
|
||||
<td>{formatPrice(offer.price, market, false, false)}</td>
|
||||
<td>{formatPrice(offer.amount, "XMR", false, false)}</td>
|
||||
<td>{formatPrice(offer.primaryMarketAmount, market, false, false)}</td>
|
||||
<td
|
||||
>{formatPrice(
|
||||
offer.primaryMarketAmount,
|
||||
market,
|
||||
false,
|
||||
false,
|
||||
)}</td
|
||||
>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
|
@ -134,7 +162,12 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];
|
|||
</tr>
|
||||
{#each data.trades as trade}
|
||||
<tr>
|
||||
<td>{new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")}</td>
|
||||
<td
|
||||
>{new Date(trade.date)
|
||||
.toISOString()
|
||||
.replace("T", " ")
|
||||
.replace(/\.\d*Z/, "")}</td
|
||||
>
|
||||
<td>{formatPrice(trade.price, trade.currency, false, false)}</td>
|
||||
<td>{formatPrice(trade.xmrAmount, "XMR", false, false)}</td>
|
||||
<td>{formatPrice(trade.amount, trade.currency, false, false)}</td>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<svelte:options runes={true} />
|
||||
|
||||
<script>
|
||||
import { crypto, fiat, formatPrice, getAsset } from "$lib/formatPrice";
|
||||
import {
|
||||
|
@ -93,12 +94,27 @@ let w = $state();
|
|||
<option value="604800000">Weekly</option>
|
||||
</select> Volume
|
||||
</h4>
|
||||
<Chart width={w-20} height={500} container={{class:"row"}} layout={chartLayout} grid={gridLayout}>
|
||||
<LineSeries data={volume} reactive={true} priceFormat={{precision:2, minMove:.01}}>
|
||||
<PriceScale scaleMargins={{bottom:.4, top:.1}}/>
|
||||
<Chart
|
||||
width={w - 20}
|
||||
height={500}
|
||||
container={{ class: "row" }}
|
||||
layout={chartLayout}
|
||||
grid={gridLayout}
|
||||
>
|
||||
<LineSeries
|
||||
data={volume}
|
||||
reactive={true}
|
||||
priceFormat={{ precision: 2, minMove: 0.01 }}
|
||||
>
|
||||
<PriceScale scaleMargins={{ bottom: 0.4, top: 0.1 }} />
|
||||
</LineSeries>
|
||||
<HistogramSeries data={swaps} reactive={true} priceScaleId="" priceFormat={{precision:0, minMove:1}}>
|
||||
<PriceScale scaleMargins={{top:.7, bottom:0}}/>
|
||||
<HistogramSeries
|
||||
data={swaps}
|
||||
reactive={true}
|
||||
priceScaleId=""
|
||||
priceFormat={{ precision: 0, minMove: 1 }}
|
||||
>
|
||||
<PriceScale scaleMargins={{ top: 0.7, bottom: 0 }} />
|
||||
</HistogramSeries>
|
||||
<TimeScale rightBarStaysOnScroll={true} rightOffset={0} />
|
||||
</Chart>
|
||||
|
@ -118,10 +134,28 @@ let w = $state();
|
|||
</tr>
|
||||
{#each Object.values(markets).toSorted((a, b) => (b.trades?.length || 0) - (a.trades?.length || 0) || (b.offers?.length || 0) - (a.offers?.length || 0) || (b.code < a.code ? 1 : -1)) as market}
|
||||
<tr>
|
||||
<td><a href="market/{market.code}">{getAsset(market.code).name} ({market.code})</a></td>
|
||||
<td>{formatPrice(market.trades?.[0]?.price, market.code, true, false) || "-"}</td>
|
||||
<td
|
||||
><a href="market/{market.code}"
|
||||
>{getAsset(market.code).name} ({market.code})</a
|
||||
></td
|
||||
>
|
||||
<td
|
||||
>{formatPrice(
|
||||
market.trades?.[0]?.price,
|
||||
market.code,
|
||||
true,
|
||||
false,
|
||||
) || "-"}</td
|
||||
>
|
||||
<td>{market.offers?.length || "-"}</td>
|
||||
<td>{formatPrice(market.trades?.reduce((a,b) => a + b.xmrAmount, 0), "XMR", false, false) || "-"}</td>
|
||||
<td
|
||||
>{formatPrice(
|
||||
market.trades?.reduce((a, b) => a + b.xmrAmount, 0),
|
||||
"XMR",
|
||||
false,
|
||||
false,
|
||||
) || "-"}</td
|
||||
>
|
||||
<td>{market.trades?.length || "-"}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
|
@ -131,7 +165,14 @@ let w = $state();
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td>{Object.values(data.offers).flat().length}</td>
|
||||
<td>{formatPrice(data.trades.reduce((a,b) => a + b.xmrAmount, 0), "XMR", false, false)}</td>
|
||||
<td
|
||||
>{formatPrice(
|
||||
data.trades.reduce((a, b) => a + b.xmrAmount, 0),
|
||||
"XMR",
|
||||
false,
|
||||
false,
|
||||
)}</td
|
||||
>
|
||||
<td>{data.trades.length}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
@ -151,10 +192,18 @@ let w = $state();
|
|||
</tr>
|
||||
{#each data.trades.slice(0, 64) as trade}
|
||||
<tr>
|
||||
<td>{new Date(trade.date).toISOString().replace("T", " ").replace(/\.\d*Z/, "")}</td>
|
||||
<td
|
||||
>{new Date(trade.date)
|
||||
.toISOString()
|
||||
.replace("T", " ")
|
||||
.replace(/\.\d*Z/, "")}</td
|
||||
>
|
||||
<td>{formatPrice(trade.price, trade.currency, true, false)}</td>
|
||||
<td>{formatPrice(trade.xmrAmount, "XMR", false, false)}</td>
|
||||
<td>{formatPrice(trade.amount, trade.currency, false, false)} <span class="trade-currency">{trade.currency}</span></td>
|
||||
<td
|
||||
>{formatPrice(trade.amount, trade.currency, false, false)}
|
||||
<span class="trade-currency">{trade.currency}</span></td
|
||||
>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in a new issue