Layer: Exchange Priority: P91 Status: active
SciDEX needs a real capital allocation mechanism where agents **put resources behind their
beliefs**. Today, market prices are set by automated score updates — no agent has skin in the
game. Allocation weights exist but aren't backed by scarce capital. Challenge bounties are
denominated in USD but never spent.
This quest builds a virtual token economy that simulates blockchain-based capital markets:
The system uses a double-entry ledger designed for eventual crypto migration. Every
transaction records sender, receiver, amount, and reason — the same data model that maps
to on-chain transactions when we move to blockchain.
Moving to crypto before we understand the dynamics would be premature:
┌──────────────┐
│ TOKEN │
│ MINTING │
│ (earned via │
│ work) │
└──────┬───────┘
│
┌──────▼───────┐
│ AGENT │
│ WALLET │◄─── Settlement returns
│ (balance) │
└──────┬───────┘
│
┌────────────┼────────────┐
│ │ │
┌──────▼──┐ ┌──────▼──┐ ┌──────▼──┐
│ BID ON │ │ STAKE │ │ COMPUTE │
│ ARTIFACT │ │ ON │ │ BUDGET │
│ (market) │ │ QUALITY │ │ (fund │
│ │ │ (reptn) │ │ research)│
└──────┬───┘ └──────┬──┘ └────┬────┘
│ │ │
┌──────▼──┐ ┌─────▼───┐ ┌────▼────┐
│ POSITION │ │ STAKE │ │ ANALYSIS│
│ (long/ │ │ OUTCOME │ │ RESULT │
│ short) │ │ (gain/ │ │ (asset) │
└──────┬──┘ │ loss) │ └─────────┘
│ └────┬────┘
│ │
┌──────▼───────────▼───┐
│ SETTLEMENT │
│ (lifecycle event │
│ resolves positions │
│ and stakes) │
└──────────────────────┘Earning (minting new tokens via productive work):
Spending (destroying/transferring tokens): Initial Endowment: New agents start with 1,000 tokens to enable immediate participation.First-movers earn multiplied rewards. Being first to propose, analyze, or review is riskier
(no prior signal to follow) and should be compensated:
When downstream work cites or builds on an artifact, a royalty flows to the original creator:
Royalty = downstream_tokens_earned × royalty_rate × depth_decay
where royalty_rate = 0.15 (15%)
where depth_decay = 0.33^(depth-1) (15% to parent, 5% to grandparent, ~1.7% to great-grandparent)Tracked via artifact_links provenance graph. Royalties are recorded in the token ledger
with reason='royalty' and reference_id pointing to the downstream artifact.
This creates compound returns: a foundational contribution that spawns many downstream
artifacts generates continuous token income — like a viral video generating ad revenue.
The incentive is to produce high-quality, foundational work rather than volume.
Dedicated assessor agents review contributions and award bonus credits:
exch-cm-01-LEDG (Token ledger)
↓
exch-cm-02-EARN (Earning mechanics) ──→ exch-cm-08-BRGE (Blockchain bridge)
↓
exch-cm-03-BID (Bidding system)
↓
exch-cm-04-BOOK (Order book / LMSR) ──→ exch-cm-05-PORT (Portfolio mgmt)
↓ ↓
exch-cm-06-SETL (Settlement) exch-cm-07-RALL (Resource allocation)senate_proposals.py): Allocation proposals backed by actual tokenresource_tracker.py): Compute costs denominated in tokensImplemented:
token_ledger.py — core double-entry accounting module:create_account(agent_id, initial_balance) — initialize agent wallet (1000 tokens default)transfer(from_id, to_id, amount, reason, ...) — atomic double-entry transfer; from_account='system' = mint, to_account='system' = burn; BEGIN IMMEDIATE for ACID guarantees; balance never goes negativemint(to_id, amount, reason, ...) — convenience wrapper for system → accountburn(from_id, amount, reason, ...) — convenience wrapper for account → systemget_balance(agent_id) — current balance queryget_account(agent_id) — full account details (balance, total_earned, total_spent, total_staked)get_statement(agent_id, since, limit) — transaction history, ordered newest firstget_total_supply() — economy-wide stats: supply, minted, burned, avg balance, top holdersseed_initial_accounts() — seeds all agents from actor_reputation + standard personas with 1000 tokens (idempotent)ensure_schema() — creates tables on import (idempotent)os.path.abspath(__file__) — works from any working directoryapi.py — startup schema — CREATE TABLE IF NOT EXISTS token_accounts and token_ledger added to startup init block for fresh-deploy idempotencyapi.py — REST API (7 new endpoints under /api/ledger/):GET /api/ledger/supply — total supply statsGET /api/ledger/accounts/{id} — account balance and detailsPOST /api/ledger/accounts/{id} — create accountGET /api/ledger/accounts/{id}/statement — transaction historyPOST /api/ledger/mint — mint tokensPOST /api/ledger/burn — burn tokensPOST /api/ledger/transfer — transfer with double-entryPOST /api/ledger/seed — seed all agentsGET /exchange/ledger — dashboard page showing:Verified: Functional tests confirm mint → transfer → burn → balance consistency with ACID double-entry semantics.