Trade Mining

Trade Mining Overview

How DepthSight nodes mint $DEPTH by submitting anonymous trade telemetry — node identity, scoring, mining epochs and reward distribution.

⏱️ 12 min read📊 Level: Intermediate

Trade Mining is the federated incentive layer of the DepthSight ecosystem. Every node in the federation — the central master hub or any self-hosted mining server — mines tokens by reporting anonymous telemetry about the real trades it executes. Verified trades earn $DEPTH from a fixed daily emission budget, distributed across the nodes that contribute activity.

Telemetry is anonymous: no API keys, orders or secrets are shared. A node only sends trade facts (symbol, direction, entry, exit, duration, exit reason, strategy blocks, volume). Rewards follow the node identity, not the exchange account.


1. Concepts

TermMeaning
Central HubThe central deployment (IS_CENTRAL_HUB=true). Hosts the hub API, verifies trades, finalizes epochs and mints rewards.
HubNodeA node identity (node_uuid + node_secret) registered on the hub. Every miner and every mining server is a HubNode.
Mining serverA HubNode flagged is_mining_server=True. Hosts external miners and earns a commission on trades mined through it (source_node_uuid).
Miner nodeThe HubNode a specific trade is attributed to (node_uuid on the report).
Wallet-bound nodeA node owned by an EVM wallet. Its node_uuid = UUIDv5(NAMESPACE_DNS, "evm:<address>") is deterministic, so the same identity reproduces on any server and history follows the wallet.
HubServerConfigPer-server override of the user/server reward share (default 75%).
$DEPTHThe reward token minted by mining epochs.

Key modules: api/hub_router.py (hub endpoints), api/routes/config.py (local mining endpoints), bot_module/controller.py (telemetry dispatch), tasks.py (epoch processing), telemetry_sync.py (offline resync), api/models.py (mining schema).

Rendering diagram...

2. Node Identity & Wallet Binding

Before any telemetry can be attributed, a node must exist on the hub and prove who it is.

Node credentials

  • node_uuid — unique 36-char identity.
  • node_secret — the telemetry write credential. The hub stores only sha256(node_secret) and verifies every payload with an HMAC-SHA256 signature keyed by the raw secret. The raw secret is never persisted and travels only over TLS.

Local nodes read their identity from the HUB_NODE_UUID / HUB_NODE_SECRET env vars or from a node_identity.json / identity.json file. Wallet-bound users prefer the wallet identity stored in AppConfig.exchange_settings.weex (mining_node_uuid / mining_node_secret).

Wallet binding & ownership

  • POST /api/v1/config/node/wallet/nonce — returns a self-verifying, expiring SIWE-style ownership message (embeds the address, purpose, and absolute expiry — no shared nonce state, safe across uvicorn workers).
  • POST /api/v1/config/node/wallet/verify — verifies the signature and binds the wallet:
    • stores node_uuid = UUIDv5("evm:<address>"), a fresh mining_node_secret, wallet_address and wallet_configured=true in exchange_settings.weex;
    • migrates any legacy mining_node_uuid / virtual-<user_id> history (telemetry, ledger, total_mined, referral links) onto the new EVM node via _transfer_node_data — nothing is lost;
    • purges legacy mnemonics.

The EVM wallet is the ownership credential: wallet-bound nodes cannot be created, claimed, re-keyed, given a referrer, or revoked without a valid wallet signature. The node secret is only a write-only telemetry credential.

Hub registration

Nodes register via POST /api/v1/hub/nodes/register:

  • stores sha256(node_secret), IP, geolocation, version, optional weex_uid / public_domain;
  • assigns a unique referral code (DSN-REF-...) if absent and binds the referrer when referrer_code is provided;
  • may flag the node as a mining server and record its user_reward_share_percent in hub_server_configs;
  • adopts legacy random-UUID nodes onto their deterministic wallet UUID (FK-safe re-key of telemetry/rewards/server-config children);
  • guard rails: virtual-* UUIDs are reserved; a legacy node's secret hash is never overwritten with a different value; wallet signatures are mandatory for wallet-bound nodes — preventing pre-registration hijack.

POST /api/v1/hub/nodes/ping is the heartbeat: it refreshes last_ping, latency, version, public domain, auto-updates geolocation and upserts the server's reward share. The live network is exposed by GET /api/v1/hub/nodes (all nodes with a ping in the last 5 minutes).

Wallet-bound nodes may revoke their telemetry credential via POST /api/v1/hub/nodes/revoke-telemetry (wallet signature required; secret_hash is cleared and the node can no longer report until re-keyed).


3. Telemetry Dispatch

When a position closes and the user has both shareTelemetry enabled (auto-asserted when mining is active) and a hub mining config allows the exchange, the bot controller (_dispatch_telemetry_to_hub) performs:

  1. Saves a local LOCAL_ONLY copy (visible in the "Trades" UI tab).
  2. Computes HMAC-SHA256 over the exact serialized body (sort_keys=True).
  3. POSTs the report to the hub at /api/v1/hub/telemetry/report with X-Node-UUID, X-Node-Secret, X-Node-Signature headers.
  4. Marks the local copy SENT when the hub acknowledges (a 409 duplicate is also treated as success).

The full payload schema, headers and signing rules are documented on the Telemetry Report API page.

If the node goes offline, telemetry_sync.py / the sync_pending_telemetry_task re-uploads any LOCAL_ONLY records later.


4. Scoring & Eligibility

On ingestion the hub computes an anti-abuse score and an estimated rebate.

Eligibility — a report is eligible only when:

  • mining is enabled in MiningConfig and the exchange is in eligibleExchanges;
  • tradeMode is LIVE (never backtest/paper);
  • hold time is at least minTradeDurationSec (default 30 s) — anti-wash;
  • entry and exit prices are set and positive.

Score (_score_trade) — 0.0–1.0; longer holds score higher (duration capped at 1 h), so fast scalps earn less than trend holds.

Estimated rebate (_estimate_rebate) — tradeVolumeUsdt × 0.0005 (fee rate) × rebateRate[exchange_market]. Volume is the notional open+close (|qty × entry| + |qty × exit|).

The report row stores score, is_mining_eligible, estimated_rebate_usdt, and the initial verification status (PENDING / SKIPPED).


5. Verification Statuses

StatusMeaning
PENDINGAwaiting broker verification (exchange in the verifiable set).
VERIFIEDBroker-verified; eligible to be credited by a mining epoch.
SKIPPEDReported from an exchange with no verifier — treated as verified immediately.
LOCAL_ONLYSaved locally, not yet uploaded to the hub.
SENTLocal copy acknowledged by the hub.

Verification of PENDING reports happens in the daily epoch processor on the hub (closed-source broker verification in a private module). The open source manages the status columns (verification_status, verified_volume_usdt, verification_error, verified_at).


6. Mining Epochs

Rewards are minted once per UTC day by the Celery task process_mining_epoch_task (tasks.py, shared logic also exposed via POST /api/v1/hub/mining/process-epoch and recalculate_past.py). The daily algorithm is documented in the closed-source epoch processor; from the open-source side the persisted state is:

  1. Epoch day — yesterday (UTC), unless forced. Days that are not fully over are never finalized (late-arriving reports for a past day are credited to the next epoch via epoch_date IS NULL).
  2. Verification pass over the epoch window (closed-source verifier).
  3. Eligible reports — VERIFIED, eligible, created_at <= end-of-day, epoch_date IS NULL. Already-attributed reports are never re-added, so re-processing is idempotent.
    • If PENDING reports remain, the epoch is not finalized and re-queued.
  4. Emission with halving: daily_emission = daily_emission_base / 2**halvings.
  5. Points — base points = summed estimated_rebate_usdt; referral points = base × referral_mining_boost (credited to the referrer node). Tokens-per-point = daily_emission / total_points.
  6. Reward per node — base reward + referral bonus, plus a one-time welcome bonus milestone when cumulative volume crosses MIN_WELCOME_REBATE_USDT.
    • Welcome bonuses come from a dedicated 100M $DEPTH pool with progressive stages (1000 / 500 / 250 / 125 $DEPTH) and a per-UID claim cap.
  7. Per-report server commission — the reporting server keeps (1 − share) of each report's gross base reward (shared_from its hub_server_configs; otherwise global 75% default); the miner keeps share. NULL/banned source routes the commission to the hub operator root (is_operator, else the first admin who bound a wallet node).
  8. Persist — upsert MiningLedger per node+epoch; increment HubNode.total_mined; track MiningConfig.total_commission_collected.

Referral and welcome bonuses are not subject to server commission.

The $DEPTH reward formula

dailyEmission  = dailyEmissionBase / 2^(daysSinceLaunch / halvingIntervalDays)
tokenPerPoint  = dailyEmission / Σ(basePoints + referralPoints)

baseReward(node)  = Σ(estRebate(node)) × tokenPerPoint
referralReward(node)= Σ(estRebate(referrals)) × boost × tokenPerPoint

gross(perReport)= baseReward(node) × (reportRebate / nodeTotalRebate)
netBase         = Σ gross × serverShareOf(source_server)
totalReward     = netBase + referralReward + welcomeBonus

Referral model

A node's referrer is resolved in priority order: explicit referrer_node_uuid → the owner user's referred_by relationship resolved to that user's mining node. Referrers earn boost × base points on every eligible trade of their referred nodes, plus a matching welcome grant at mint time.


7. Configuration

Public mining settings: GET /api/v1/hub/mining/config (public), POST /api/v1/hub/mining/config (admin). Node-level: GET/PUT /config/mining/node-config (admin, on the hub side).

Setting (MiningConfig)DefaultMeaning
is_mining_enabledfalseGlobal switch
eligibleExchanges["weex","weex_futures","weex_spot"]Eligible exchanges + market keys
dailyEmissionBase547945.21Initial daily $DEPTH emission
halvingIntervalDays365Days between halvings
launchDateNULLStart date for the halving countdown
minTradeDurationSec30Minimum hold time for eligibility
minTradePnlAbs0.0Not an active gate
referralMiningBoost0.10Referral multiplier on base points
rebateRatessee belowRebate fraction per exchange_market

Rebate rate defaults: weex_futures 0.60, weex_spot 0.45, weex 0.60, bybit_futures 0.40, binance_futures 0.25.

NodeMiningConfig: is_global_mining_enabled (True) and user_reward_share_percent (75% — positive values only, legacy 0 is treated as 75% so rewards are never silently zeroed). Per-server: hub_server_configs.user_reward_share_percent.


8. Environment Variables

VariablePurpose
IS_CENTRAL_HUBtrue on the hub (no outbound reporting, owns the mining DB).
FEDERATION_HUB_URLHub base URL for telemetry posts, mining status and the epoch proxy.
HUB_NODE_UUID / HUB_NODE_SECRETLocal node identity (non-wallet nodes).
HUB_ADMIN_API_KEYAdmin key for hub config, epoch trigger and operator designation.
WELCOME_BONUS_MAX_POOLWelcome bonus total supply (default 100000000.0).
MIN_WELCOME_REBATE_USDTVolume threshold to earn the welcome bonus (default 5.0).
MAX_NODES_PER_UIDMax welcome grants per Weex UID (default 1).

9. Operations Tooling

ToolPurpose
recalculate_past.pyRe-runs the epoch processor for a historical day.
reset_mining.pyDev/ops: wipes MiningLedger/MiningEpoch, zeroes total_mined and commission, resets reports to PENDING/re-open for re-processing.
telemetry_sync.py + sync_pending_telemetry_taskRe-uploads LOCAL_ONLY reports to the hub after connectivity is restored.

10. Security Model

  • X-Node-Secret is only sent over TLS; the hub stores only its SHA-256 hash and the raw secret is needed to compute the HMAC, so a leaked DB never exposes a usable signing key.
  • Payload tampering → HMAC mismatch → 403; duplicate broker_trade_id on another node → 409.
  • Attribution is restricted to the caller's own node or a node of the same owner (referral / Weex UID / wallet), so trades can't be misattributed.
  • source_node_uuid must point to a node flagged is_mining_server.
  • No double-counting: reports carry epoch_date, ledger upserts are additive and epochs are finalized exactly once.
  • Privacy: report carries no API keys, order IDs, risk config or private data.

The closed-source verifier is the only private component; telemetry intake, scoring, attribution, epoch math and the ledger all ship open-source.