Skip to content
QORECHAIN
Register

Quantum Pass

Pool Doctor

Every native AMM pool diagnosed, certified on chain with ML-DSA-87, and treated in one quantum-signed transaction.

Share on X

About

Pool Doctor is a clinic for QoreChain's markets. It examines every pool in the chain's built-in exchange (the native AMM), works out what each token is really worth, and shows which pools are lying. On diana today it finds one critical patient: pool 1 (fETH/QOR) prices fETH about 1.3 million times above what the rest of the market says, because a dust amount of fETH sits against millions of QOR. What you can do with it: - Open the ward: all pools, live, each with a heartbeat trace that is its diagnosis (Stable, Watch, Fever, Critical, Flatline, or No second opinion). - Open a pool's chart: pool price, consensus price, deviation, depth, and its on-chain certificate. - Treat a sick pool: the Doctor prescribes a QOR → fUSD → fETH → QOR loop through healthy pools, every leg under the chain's 5% impact rule and re-checked with the chain's own quote engine. QoreX signs all legs as ONE hybrid ML-DSA-87 transaction. The last leg must return more QOR than went in or the chain cancels everything, so the healer cannot lose; the arbitrage profit is their fee. That is how markets correct themselves. - Verify certificates: every round the Doctor signs all diagnoses with one ML-DSA-87 signature, and the PoolDoctorLedger contract verifies it on chain with the pqcKeyStatus and pqcVerify precompiles. Any contract can ask isHealthy(pool, maxAge) before it trades. "Verify here" re-checks a round entirely in your browser. Live: https://pool-doctor-three.vercel.app Code: https://github.com/Oluwatimothy/pool-doctor (MIT)

How it's made

Scaffolded with create-qorechain-dapp 0.14.0: web/ from the fullstack-web template (Vite + React + TypeScript) and contracts/ from the foundry template. Diagnosis engine (web/src/lib/engine.ts, shared by the app and the doctor's rounds): each pool is an observation log P(a) − log P(b) = log(rate). The engine fits one log-price per token, anchored at QOR, by weighted least ABSOLUTE deviations, weighted by each pool's depth in QOR. L1 is robust: a broken pool cannot drag the consensus, it just stands out. The optimum of an L1 fit on a graph sits on a spanning tree, and the pool graph is small, so the engine enumerates every spanning tree and keeps the best: exact, deterministic, no solver. Dust pools are Flatline; pools that are a bridge in the graph of deep pools get "No second opinion" instead of a guess. Treatment: constant-product math with the 0.30% fee, impact capped at 4.5% (chain rule: 5%), route as a QOR→…→QOR cycle through healthy pools, each leg's minOut chained into the next leg's input, the final minOut ≥ the QOR input. Every leg is re-checked with GET /qorechain/amm/v1/quote/exact_in. Sent with QoreX signAndBroadcast as 3 × MsgSwapExactIn in one hybrid-signed transaction (verified: 0C74A3C18A16060633EB6604C20A0C91280E209FA5441ADAFBE45844B3E05974). Certificates: PoolDoctorLedger (0xFeD2f625B8a24f70BD9C96BfAaefAF98aAbacb70) rebuilds the exact signed text on chain ("qorechain-msg-v1|qorechain-diana|" + round text, QoreSign message-signing-v1), reads the doctor's key with pqcKeyStatus (requires registered, ML-DSA-87, possessionProven), verifies with pqcVerify, and rejects replays and other chain ids. No owner, no upgrade. rounds.ts signs one round with pqcSign, checks its bytes against the contract's signedBytes(), dry-runs certify against the live precompiles, opens an EVM window by a hybrid-signed message scoped to the ledger only (1 tx, ~100 blocks), then relays. Kits and features: @qorechain/sdk (hybrid signing, pqcSign/pqcVerify, AMM message types, EVM window and key registration messages), @qorechain/evm, QoreX, pqcKeyStatus and pqcVerify precompiles, native AMM, fUSD/fETH test tokens, Foundry, viem. Tests: 25 Foundry tests (golden signed text shared with TypeScript, tampering, replay, chain id, key registry failures, inactive precompiles, fuzzing) and 19 vitest engine tests (robust fit, thresholds, no-loss prescriptions, impact cap). CI on GitHub. What was hard: the REST API sends no CORS headers (Vercel rewrite /lcd → REST); keeping signed bytes identical across TypeScript and Solidity; QoreX refuses messages it cannot display, so we confirmed it decodes MsgSwapExactIn before building; sizing multi-leg treatments under the 5% impact rule. AI use is documented in AI_USAGE.md.

Timeline

Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 52d85e1 AI_USAGE.md: full workflow, division of labour, verification, and where the agent was wrong · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 364cf4e Tests: golden round 3, rebuilt byte for byte from the pools at height 10,999,486 · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 72143c0 Round 3 certified on testnet: pool 5 (fBTC/fUSD) newly critical, pool 1 easing; README record updated · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • e34d183 Add npm run verify: read-only re-verification of every certified round on testnet, run in CI · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 153c674 Tests: ledger reads, round paging, in-browser ML-DSA-87 re-verification, treatment encoding · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 05a0071 Tests: REST reads, chain second opinion, tx polling, QoreX errors, ledger events and later rounds · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 65080c6 Tests: routing, status boundaries, dose and slippage, token resolution · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 99e1241 Tests: number formatting and explorer-link resolution · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 2 commits to main

  • 0a332e8 README: demo video, project page and Built on QoreChain badge · Oluwatimothy
  • 2efa325 Pool Doctor: diagnose, certify and treat QoreChain's native AMM pools · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 7d17956 Explorer links: resolve EVM transaction hashes to their native hash · Oluwatimothy
Pool DoctorQuantum Pass

Pushed 1 commit to main

  • 570eb50 Rounds: record round 2, run the workflow on demand until the doctor secret is set · Oluwatimothy
Pool DoctorQuantum Pass

Earned a Ship Weeks badge.

Pool DoctorQuantum Pass

Earned a Ship Weeks badge.

Pool DoctorQuantum Pass

Earned a Ship Weeks badge.

Comments and questions

  • No comments yet.