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.

Iddraws
VenueElysium
Tickevery 20 s
Capitalnone (allocation 0)
TodayPaper. 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 roundHow it is fixed
LengthThe PrizePool's roundSeconds. 900 s (15 minutes) when no PrizePool is set to read it from
WindowThe time after roundId − roundSeconds, up to and including roundId
SupplyWhat 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 valueThe first drand quicknet round published after the round ends
PotLive: 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.

RuleValue
WeightThe wallet's time-weighted balance over the round (token-seconds)
Cap3.00 % of supply, held for the whole round
Sits outA wallet holding more than 3.10 % of supply at any moment in the round is out for that round
MinimumA 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 (inventoryTreasury and cohortTreasury, 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

  1. The eligible wallets are sorted by address and laid end to end: wallet k owns the stretch [start, end) of the weight line, as long as its weight.
  2. Each stretch is a leaf, keccak256(keccak256(abi.encode(wallet, start, end))), of a Merkle tree. Pairs are hashed smaller-first, as OpenZeppelin's MerkleProof checks them.
  3. Pick i (0, 1, 2) lands at keccak256(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.
  4. 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

  1. Stands by if it cannot work. See Statuses.
  2. Live only: settles. For each of the PrizePool's pendingRounds whose veto window has ended it calls finalize(roundId), marks the record paid and writes a draw event. A round it proposed that is no longer pending is marked paid (someone else finalized it) or vetoed (a guardian cancelled it, with a warning in the ledger).
  3. 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.
  4. Reads the pot. A pot under DRAW_MIN_POT_HYPE stays for the next round. Live, a round the contract already holds (roundId ≤ lastRoundId) is left alone.
  5. Fetches the random value, or waits for it.
  6. Rebuilds the round from the token's transfers and computes the table. With fewer than three eligible wallets the round is skipped.
  7. Writes the record and its hash.
  8. Paper: stores the record with status paper, takes the pot off the pretend pot and writes a draw event (Paper draw, round HH:MM UTC: X HYPE to …). Nothing is sent.
  9. Live: sends PrizePoolV2.propose with 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 status proposed.

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 = true and status paper.

Settings

VariableDefaultWhat it does
DRAWS_ENABLEDtruefalse switches the job off (status idle)
DRAW_MIN_POT_HYPE0.05A smaller pot stays for the next round
DRAW_EXCLUDEemptyExtra 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_KEYOPERATOR_KEYLive only. The wallet that proposes rounds. It needs the PrizePool's OPERATOR_ROLE and a little HYPE for gas
PRIZE_POOL_ADDRESSunsetThe deployed PrizePoolV2. Live draws are blocked without it. Set the same value on Vercel and on the watcher

Statuses

StatusNoteFix
idleSwitched off (DRAWS_ENABLED=false)Set DRAWS_ENABLED=true
blockedWaiting for MOTION to launch on Ascend (set MOTION_TOKEN)Live with no token set. On paper the stand-in pool is used
blockedSet PRIZE_POOL_ADDRESS to the deployed PrizePoolV2Live only
blockedThis token has no HYPE-paired pool on Ascend, so its holders cannot be readUse a HYPE-paired Ascend coin
blockedThe 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 statusMeaning
paperDrawn on paper. Nothing was sent
proposedSent on chain, inside its veto window
paidFinalized. The winners were paid
vetoedCancelled 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:

EndpointReturns
GET /api/v1/drawsThe last 50 rounds, newest first, without their full records
GET /api/v1/draws/:roundIdOne 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.

bash
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.

bash
npm run check:token -- 0xTOKEN

Says whether a token works with the backend at all (it must be an Ascend coin paired with HYPE).

bash
npm run draw:vectors

Rewrites 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.