This morning we stopped a one-cent pool on cexswap from pricing WOW. The same rule was missing on the nonlogs last-trade path, where the test was volume greater than zero, which one print satisfies. Today it cost us the desk. We sold 209 WOW by hand at 0.0361, near four times fair, into a bid standing above our whole ask ladder. That print became WOW-USDT's last trade. Its book is 42% wide, so the midpoint was refused and the print stood in for it, and the route carried $12 of daily volume of which $7.56 was that one trade. WOW marked 15.6 sat against a consensus near 10.7, and wowdesk's divergence rail then held every WOW market it makes, correctly: the feed was quoting our own trade back at us. A last trade must now clear $25 of 24h volume, the same floor cexswap got and the same one the desk uses for a consensus venue. A live book keeps needing no floor, because it is somebody else's standing offer and has already passed both-sides, ask-above-bid and the spread limit. Verified against the live payloads, since this repo has no test framework: WOW-BTC prices from its book at $0.00918 with $105 of volume and is unchanged. WOW-USDT drops, having $12. The blended mark moves 15.63 sat to 12.00, and divergence against the desk's consensus moves 33.0% to 2.1%, inside its 8% limit, so WOW can quote again.
hash-wallet-prices
Cloudflare Worker that aggregates USD prices for Hash Wallet and serves them at one cached endpoint.
Why this exists: see the architectural notes in the wallet repo. Short version — having every user's phone hit Kraken/NonKYC directly leaks wallet-holder activity to the exchanges and spreads our rate-limit budget across thousands of IPs. One Worker with a cron-refreshed KV cache fixes both.
Sources
- Kraken (
api.kraken.com/0/public/Ticker) — BTC, XMR, LTC, DOGE, ETH, BCH, XNO (all → USD). - Nonlogs.io (
api.nonlogs.io/api/markets) — WOW. Algorithm averagesWOW-BTC × Kraken BTC/USDandWOW-USDTwhen both exist. Lifted from~/src/smirk-backend/src/infra/prices.rs. - cexswap.cc (
cexswap.cc/api/public/markets/summary) — WOW backup. Endpoint returnslast_usdprecomputed per pair, so we average across all WOW spot pairs. - Pinned — USDT, USDC, DAI all return 1.00.
WOW USD price is the average of whichever Nonlogs and cexswap routes returned a value — survives one source going down without a code change.
Endpoints
| Path | Shape |
|---|---|
GET /v2/rates?base=BTC"e=USD |
{ "results": { "BTC_USD": 67342.5 } } — drop-in compatible with the wallet's existing fetch code |
GET /v1/prices |
{ "rates": { ... }, "sources": { ... }, "fetched_at": "..." } — preferred, returns everything in one call |
GET /v1/sparkline?coin=BTC&hours=24 |
{ coin, hours, points: [[ts_ms, price], ...] } — hourly buckets, max 168 points (7 days) |
POST /v1/trocador-webhook |
Trocador POSTs the full trade body on every status change; we store it under trade:<id> for 14 days |
GET /v1/trade/:trade_id |
Returns the cached trade body (whatever Trocador last sent for that id), or 404 |
GET /healthz |
{ ok: true, coins: N, fetched_at: ... } |
Non-USD quotes convert through ECB daily reference rates (fetched each cron run); an unknown quote currency returns 0 and the wallet falls back to "price unavailable."
Deploy
npm install
npx wrangler login
npx wrangler kv:namespace create PRICES
# Paste the returned id into wrangler.toml's kv_namespaces.id field.
npx wrangler deploy
After first deploy the worker is live at https://hash-wallet-prices.<your-cloudflare-subdomain>.workers.dev. To put it behind prices.suchsoftware.com, point that hostname's DNS at Cloudflare and uncomment the [[routes]] block in wrangler.toml.
Local dev
npm install
npx wrangler dev # starts a local server with hot reload
curl localhost:8787/healthz
curl 'localhost:8787/v2/rates?base=BTC"e=USD'
Adding a coin
- If Kraken lists it: add
TICKER: "PAIRUSD"toKRAKEN_PAIRSinsrc/index.ts. - If only smaller exchanges list it: add a new fetcher function alongside
fetchNonkyc()and merge its results inrefreshPrices(). Keep ittry/catchwrapped so a single source failure doesn't poison the whole refresh.
License
MIT.
The oracle
GET /v1/oracle returns the current rates alongside the method that produced
them, the guard values, and the limits we know about. It is served by the code
that implements it, so it cannot drift from the truth the way a separate
document would.
What it prices, and from what
| Source | Covers | Price basis |
|---|---|---|
| Kraken | majors | spot ticker |
| Nonlogs | niche tickers, BTC and USDT routes | live book midpoint, falling back to last trade |
| CexSwap | niche tickers, all quote routes | last trade in USD, weighted by 7-day USD volume, expiring after 12 hours |
Niche tickers are volume-weighted across the venues that produce a usable number.
Why the book midpoint, and not the last trade
A last print says where somebody traded once. On a market doing a few hundred dollars a day that can be many hours old, and it can sit at the day's extreme. The midpoint of the current best bid and ask says where you could trade now, which is what a price feed is being asked.
The case that prompted the change, on 2026-09-06: Nonlogs WOW-BTC last traded at 10 sat while its book stood 10 bid, 13 ask. The feed said $0.007989; the market said $0.009187. Meanwhile CexSwap's WOW-XMR print, carrying $635 of seven-day volume against Nonlogs' $169, was the 24-hour low and 11.5 hours old. The feed as a whole read $0.008546 against a cross-venue consensus of $0.009280, low by 8.6%, and a desk quoting against it refused to bid where the market actually traded.
Guards
- Spread. A midpoint is only meaningful across a real two-sided book, so both sides must exist, the ask must be above the bid, and the spread must be at or under 60%. Otherwise the last trade is used. 60% is deliberately loose: on these venues a 30% spread is ordinary, while dead pairs show books wider than 1000% that must never set a price.
- Staleness. A CexSwap print older than 12 hours is dropped. Its summary carries no book, so staleness is the only guard available there, and seven days of volume can be a single old fill.
- Dead pairs. Any pair with no volume is ignored entirely. Without this, a stale print on an untraded pair drags the average; WOW-ETH sat at $0.000087 and WOW-USDT at $0.070 on the same day the coin was worth about $0.009.
What it does not do
- A midpoint is not depth-weighted. It says where the touch is, not what size can trade there.
- CexSwap pool prices are not read directly. Only its last trade is available without an authenticated quote, so between trades that source lags the pool it describes.
- No source is excluded for being one we quote on ourselves. This is a public price index and it prices the market as it finds it; a consumer that needs to exclude its own influence has to do that itself.