Engine
Holder draws
Every 15 minutes the engine builds the table of holder weights for the round that just closed and proposes it. The PrizePoolV2 contract checks the randomness and derives the three winners itself.
| Id | draws |
| Venue | Elysium |
| Tick | every 20 s |
| Capital | none (allocation 0) |
| Today | Paper. Draws run over the stand-in pool's real holders with real randomness. Nothing is sent: PrizePoolV2 is not deployed |
Half of every fee claim goes to the prize pool. Once a round, three holders are paid that pot: 50 %, 30 % and 20 %.
The engine does not choose the winners. It supplies one thing: the table of weights, which says how much each holder held, and for how long, during the round. That table is a fixed function of the token's public transfer history. The contract checks the random value and works the winners out from the table itself, and the watcher rebuilds the table for every round and cancels a round whose table is wrong.
The code: the arithmetic is lib/protocol/draw.ts, rebuilding a round from the chain is engine/src/draws/round.ts (one copy, used by the engine, the watcher and npm run draw), and the job is engine/src/strategies/draws.ts.
A round
A round is fully described by its id: the unix time it ends, a multiple of the round length.
| Part of a round | How it is fixed |
|---|---|
| Length | The PrizePool's roundSeconds. 900 s (15 minutes) when no PrizePool is set to read it from |
| Window | The time after roundId − roundSeconds, up to and including roundId |
| Supply | What had been minted less what had been burned by the round's end, read from the token's own transfers (totalSupply() only if the mint emitted no transfer) |
| Random value | The first drand quicknet round published after the round ends |
| Pot | Live: the PrizePool's available(). Paper: the pretend pot |
Nothing is the engine's choice or depends on when it runs, so anyone rebuilding a round gets the same table, bit for bit.
Rounds are counted on the chain's clock. A round is closed once a block later than its end time exists, because no more transfers can land inside it.
Weights
Every balance is rebuilt from the token's Transfer logs, from the block the coin was launched in. The amounts are exact integers; nothing is rounded.
| Rule | Value |
|---|---|
| Weight | The wallet's time-weighted balance over the round (token-seconds) |
| Cap | 3.00 % of supply, held for the whole round |
| Sits out | A wallet holding more than 3.10 % of supply at any moment in the round is out for that round |
| Minimum | A draw needs at least 3 eligible wallets |
Addresses that can never win
- the zero address and
0x…dEaD - the token contract itself
- the Treasury
- the pool: the v4 PoolManager and the pool's CreatorEscrow
- Motion's own contracts: the PrizePool, the fee splitter and the swap adapter (
PRIZE_POOL_ADDRESS,FEE_SPLITTER_ADDRESS,SWAP_ADAPTER_ADDRESS) - Ascend's wallets: the launchpad, the escrow factory, the universal router and the launchpad's two treasuries (
inventoryTreasuryandcohortTreasury, which hold the coins its standing bids buy) - every address in
DRAW_EXCLUDE
The full list used for a round is written in that round's record.
Randomness
drand quicknet is a public randomness beacon that publishes one round every 3 seconds. The round used is the first one published after the draw round ends, so nobody can know the value while the round is open and anyone can fetch it afterwards.
The engine asks drand for it on each tick. If it is still unavailable 10 minutes after the round closed, the round is skipped.
The table and the pick
- The eligible wallets are sorted by address and laid end to end: wallet
kowns the stretch[start, end)of the weight line, as long as its weight. - Each stretch is a leaf,
keccak256(keccak256(abi.encode(wallet, start, end))), of a Merkle tree. Pairs are hashed smaller-first, as OpenZeppelin'sMerkleProofchecks them. - Pick
i(0, 1, 2) lands atkeccak256(randomness, i) mod (the weight still in play). The holder whose stretch contains it wins and leaves the line, so the three winners are different. - The pot is split 50 % / 30 % / 20 %. Third place gets the remainder, so nothing is lost to rounding.
The engine computes the picks only to know which three leaves and proofs to send. If it sent any others the contract would revert.
What the engine does, every 20 s
- Stands by if it cannot work. See Statuses.
- Live only: settles. For each of the PrizePool's
pendingRoundswhose veto window has ended it callsfinalize(roundId), marks the recordpaidand writes adrawevent. A round it proposed that is no longer pending is markedpaid(someone else finalized it) orvetoed(a guardian cancelled it, with a warning in the ledger). - Finds the round that just closed. On its first run it only notes the round that is open now, so the first draw covers a whole round the engine watched. Only the most recently closed round is drawn. Rounds that closed while the engine was stopped are not drawn afterwards, and their pot carries over.
- Reads the pot. A pot under
DRAW_MIN_POT_HYPEstays for the next round. Live, a round the contract already holds (roundId ≤ lastRoundId) is left alone. - Fetches the random value, or waits for it.
- Rebuilds the round from the token's transfers and computes the table. With fewer than three eligible wallets the round is skipped.
- Writes the record and its hash.
- Paper: stores the record with status
paper, takes the pot off the pretend pot and writes adrawevent (Paper draw, round HH:MM UTC: X HYPE to …). Nothing is sent. - Live: sends
PrizePoolV2.proposewith the round id, the pot, the table's Merkle root and total weight, the three winners' leaves and proofs, the record's hash and drand's signature. The contract verifies the signature and derives the winners. The record is stored with statusproposed.
A skipped round is not retried. Its pot waits for the next one.
Veto window and payment
A proposed round is not paid at once. For the PrizePool's vetoDelay (3 600 s in the deploy script), a guardian can cancel it with veto(roundId). The watcher does this for any round whose table does not match the chain. A cancelled round's pot stays in the pool.
After the window anyone can call finalize(roundId). The engine does it on its next tick.
The window is longer than a round, so several rounds can be pending at once. The engine proposes each new round while earlier ones wait, and pays each as its window ends. A pending round's pot is set aside, and the next round draws on what is left.
Paper mode
The draws are on paper whenever Ascend is on paper, which includes a live run with LIVE_VENUES=hypercore. See Paper & live modes.
- No transaction is sent, and no key is used.
- The holders, their weights and the random value are real. Before MOTION launches they are the stand-in pool's holders.
- The pot is pretend: it is the prize half of the fees the harvest has booked on paper since the last draw. It is kept across restarts.
- Every record is stored with
paper = trueand statuspaper.
Settings
| Variable | Default | What it does |
|---|---|---|
DRAWS_ENABLED | true | false switches the job off (status idle) |
DRAW_MIN_POT_HYPE | 0.05 | A smaller pot stays for the next round |
DRAW_EXCLUDE | empty | Extra addresses that can never win, comma-separated: another pool that holds the token, a team wallet. The watcher must have exactly the same list |
DRAW_KEY | OPERATOR_KEY | Live only. The wallet that proposes rounds. It needs the PrizePool's OPERATOR_ROLE and a little HYPE for gas |
PRIZE_POOL_ADDRESS | unset | The deployed PrizePoolV2. Live draws are blocked without it. Set the same value on Vercel and on the watcher |
Statuses
| Status | Note | Fix |
|---|---|---|
idle | Switched off (DRAWS_ENABLED=false) | Set DRAWS_ENABLED=true |
blocked | Waiting for MOTION to launch on Ascend (set MOTION_TOKEN) | Live with no token set. On paper the stand-in pool is used |
blocked | Set PRIZE_POOL_ADDRESS to the deployed PrizePoolV2 | Live only |
blocked | This token has no HYPE-paired pool on Ascend, so its holders cannot be read | Use a HYPE-paired Ascend coin |
blocked | The draw wallet 0x… does not have the PrizePool's operator role… | Live only. The admin grants the role with grantRole |
Each stored round has one of these statuses:
| Round status | Meaning |
|---|---|
paper | Drawn on paper. Nothing was sent |
proposed | Sent on chain, inside its veto window |
paid | Finalized. The winners were paid |
vetoed | Cancelled by a guardian. The pot stayed in the pool |
Records
Every drawn round has a full record: the round's id and window, the supply, the rules and the excluded addresses, drand's round number, value and signature, the pot, the disqualified wallets, every eligible wallet with its average balance and weight, the table's root and total weight, and the winners. The keccak256 of its exact text is the resultsHash stored on chain with the round.
Records are stored in the draws table of the database and served by the API:
| Endpoint | Returns |
|---|---|
GET /api/v1/draws | The last 50 rounds, newest first, without their full records |
GET /api/v1/draws/:roundId | One round with its full record in results |
Each round carries roundId, time, status, paper, token, potHype, winners, eligible, resultsHash, proposeTx and finalizeTx.
Re-running or checking a draw
All three commands run in engine/. The first two read the chain only.
npm run draw -- 0xTOKEN <roundId> <potHype>Rebuilds one closed round and prints the winners, the table's root and total weight, and the record's hash: the values getRound(roundId) holds on chain. Set PRIZE_POOL_ADDRESS, FEE_SPLITTER_ADDRESS, SWAP_ADAPTER_ADDRESS and DRAW_EXCLUDE as the engine has them, or the table will differ. PRINT_RECORD=1 also prints the full record.
npm run check:token -- 0xTOKENSays whether a token works with the backend at all (it must be an Ascend coin paired with HYPE).
npm run draw:vectorsRewrites contracts/test/fixtures/draw-vectors.json: tables of weights, real drand rounds, and the winners, root and proofs this code computes for them. The contract's tests check that the contract arrives at the same winners from the root and the randomness alone. It needs drand to be reachable.
engine/test/e2e-draws.test.ts runs the real strategy and the real watcher against a real PrizePoolV2 on a local fork of Elysium. It is skipped in npm test because it needs a fork node.
What a stolen draw key can do
It can propose a round with a wrong table. It cannot forge the randomness or choose winners from a true table, and the PrizePool has no withdraw function. The watcher cancels the round and the pot stays.
Warning
Real draws without a running watcher rest on the draw key alone.