studio41

case study · · 6 min read

Desk: building a non-custodial web3 trading terminal for Polymarket

A cross-platform desktop terminal for Polymarket’s on-chain prediction markets: fast, data-dense, keyboard-driven — and it never touches a user’s funds. Here is how it’s built, and why.

ElectronTypeScriptNode.jsweb3PolygonCloudflare Workersreal-time data

Desk (desktrading.app) is a cross-platform (macOS and Windows) desktop trading terminal for Polymarket’s on-chain prediction markets. It gives serious traders a fast, data-dense, keyboard-driven interface to trade, hedge and manage positions across sports, crypto and event markets — from their own self-custodied wallet, with orders signed on-device and settled on-chain.

It is a non-custodial web3 application: Desk never holds user funds, and the user’s key never leaves their machine. That one constraint shaped almost every engineering decision below.

The stack — and why

Desk is built on Electron (Chromium plus a Node runtime) in TypeScript, structured across Electron’s isolated main, preload and renderer processes and bundled with esbuild. Each layer of that choice is deliberate.

  • Desktop, not a web app. Non-custodial trading means the wallet key has to live locally and sign locally. A desktop application is the natural, secure home for a self-custody signer — and it gives traders a persistent, always-on, multi-window workspace a browser tab can’t.
  • Electron and Chromium. One TypeScript codebase ships to both macOS and Windows, and Chromium’s mature, GPU-accelerated rendering engine is what lets Desk drive genuinely heavy real-time visualisations — live depth heatmaps, streaming ladders, tick-by-tick charts — without the UI buckling under load.
  • The Node runtime. Direct, first-class access to cryptographic signing, WebSocket market-data feeds, worker threads for offloading heavy work, and the filesystem for local key and state handling.
  • esbuild. Near-instant bundling of the main, preload, renderer and worker targets keeps the build-and-iterate loop tight.

Order execution and performance

The design goal: end-to-end order latency should be bounded by the exchange round-trip, not by the client.

  • Orders are signed on-device and fired as fill-or-kill.
  • The real-time market-data feed is parsed on a worker thread, so the firehose never competes with the order and fill path.
  • UI updates are frame-coalesced — batched to the display refresh — so a torrent of price ticks renders smoothly instead of thrashing the interface.
  • A confirmed-fill model keeps position tracking exact even when fills return thick and fast.

The practical result: Desk stays responsive on order entry and fill confirmation even through Polymarket’s high-churn five-minute crypto markets, where the book updates many times a second.

The trading surfaces

Desk isn’t one view. It’s a set of purpose-built surfaces, each tuned to how a different kind of trader actually works.

The Ladder — for sports and event traders

A keyboard-driven price ladder in the vein of professional exchange trading tools, with an adaptive display, a built-in exits engine and a tools panel: one-click position reduction, tick-offset and stop entries, and stake or contract modes. It’s engineered for fast, precise clicks and clean position and hedge readouts, so an in-play sports trader can work a market at speed.

Desk’s price ladder: lay and back liquidity either side of the traded price
The Ladder — lay and back liquidity either side of the price, built for fast, keyboard-driven in-play trading.

Financial charting — for crypto and financial traders

A live charting surface that renders multiple synchronised price series — multi-venue spot plus reference feeds — as smooth streaming lines alongside candles. It’s the kind of chart a crypto trader expects, built on the real-time feed rather than a static image.

Timed crypto markets

Polymarket’s rapid five-minute “up/down” crypto rounds get dedicated handling, including precise resolution of each round’s strike — the “price to beat” — pinned to the exact on-chain reference: a Chainlink TWAP at the round’s opening second. It’s cache-served, so even a cold open shows the correct level instantly.

Depth and order-flow heatmap

A Bookmap-style depth heatmap — a third crypto view alongside price and odds — that visualises resting liquidity as a colour-graded heat surface, with live best bid/offer tracking, 3D trade bubbles for executed flow, and a full-height consolidated order-book (COB) ladder with a session volume profile (SVP).

Notably, the underlying multi-venue order book is self-assembled from free public Binance and Coinbase WebSocket feeds rather than bought from a paid data vendor — a genuine piece of market-data engineering.

Desk’s market heatmap: markets sized by volume and coloured by their move
The market heatmap — every market at a glance, sized by 24-hour volume and coloured by its move.

Copy-trading engine

A live copy-trading system that detects a followed wallet’s on-chain activity in real time and mirrors it through a full pipeline — filter → size → slippage gate → fill-or-kill — with configurable rails and safety limits, surfaced from a “smart money” activity rail built on public data.

Desk’s smart-money panel: the largest wallets in a market, their side and their profit
Follow the smart money — the biggest wallets in a market, their side and their profit, live from public on-chain data.

Sports market tooling

Structured labelling and grouping of sports markets, derived from the venue’s structured fields rather than fragile title parsing, so events, lines and in-play markets present cleanly.

The real-time data layer

Underpinning all of it is a live trade-and-quote feed over WebSockets (Polymarket’s real-time activity and trades stream). The heavy parsing is pushed to a worker thread so market-data volume never delays fills, and a stall watchdog transparently reconnects a dropped feed. This one layer feeds the tape, volume, live pills and every charting surface at once.

Infrastructure and delivery

The supporting infrastructure is intentionally lean and serverless.

  • Cloudflare Workers and KV for latency-sensitive edge caches, such as crypto strike levels and a market-detail cache — fast cold loads worldwide, with zero always-on servers.
  • A stateless credentials broker that holds only the app’s own builder credentials: no user accounts, no user data, no custody.
  • Cloudflare R2 serving signed, auto-updating releases via electron-updater, so installs update themselves over the air.
  • A hardened cross-platform build pipeline: esbuild bundle → Apple notarisation for a universal macOS build → Azure Trusted Signing for a signed Windows x64 installer.

Security and the custody model

Desk is trading-only and key-import-only by design. There is no withdraw, sweep, transfer or key-export surface: the app can place orders, but it can never move funds off the wallet.

Trades settle on-chain on Polygon against Polymarket’s CLOB, using EIP-1271 deposit-wallet signing and pUSD collateral. Architecturally it’s the standard modern-DeFi hybrid — off-chain order matching, on-chain custody and settlement — giving exchange-grade speed while the trader stays fully self-custodied.

Engineering highlights

  • A cross-platform Electron and TypeScript desktop app with a data-dense, GPU-accelerated real-time UI.
  • A worker-thread market-data pipeline plus frame-coalesced rendering, responsive under high-churn markets.
  • A self-built multi-venue order book and depth/volume-profile heatmap from free public feeds.
  • On-device cryptographic signing, with non-custodial, on-chain settlement.
  • A live copy-trading engine with a full detect → filter → size → gate → execute pipeline.
  • Serverless edge infrastructure (Cloudflare Workers, KV and R2) plus signed, auto-updating cross-platform builds (Apple notarisation, Azure Trusted Signing).

What it says about how we work

Desk is the kind of project that looks like a user interface and is really a systems problem: latency budgets, threading, cryptography, market microstructure, release engineering. We picked every layer for a reason and can explain each one — which is exactly what we do for every client, whether the brief is a trading terminal, a booking platform or a single, very fast website.

If you have a problem with that kind of depth, we’d like to hear about it.

← All posts