Skip to content
Skip to Content
Developers

The worker

One background process that reads the escrow, buys bills, asks providers again, settles on chain, pays rewards and sends notices, each job safe to run twice.

On start it runs the database migrations, starts pg-boss, registers the jobs, starts the escrow indexer and the Telegram bot (when configured), and writes a heartbeat every 30 seconds that /api/health reads.

Jobs

JobWhat it doesRuns
delivery.vendBuys the bill from the provider. Never retried by the queueOn OrderPaid; 4 at a time
delivery.requeryAsks the provider againOn the ladder, on a webhook; 4 at a time
chain.operatorrelease, refund, claimFromPot, reclaimPotOne at a time (one signer)
orders.expireMarks unpaid prices expiredEvery minute
orders.sweepRe-sends anything stuck (a purchase, a settlement, a requery)Every minute and at start
rates.refreshThe naira rate from Paycrest, a QIE price sampleEvery minute
float.refreshProvider balances; opens or closes the float breakerEvery minute
escrow.solvencyCompares the escrow's balance with what it owesEvery minute
feed.publishA new naira round when neededEvery 5 minutes
rewards.payoutCashback, invite and shop rewards, gas drips, in QIEEvery minute and after each release
drops.tendClears failed claims, sends ended pots homeEvery minute
telegram.notify, telegram.reminders, telegram.opsNotices, reminders, operator alertsOn events; reminders every minute
oauth.purgeOld sign-in requests, dead tokens, unused app registrationsDaily

Jobs that touch one order use a singleton key per order, so the same work can't run twice at once.

The indexer

It reads the escrow's logs every 4 seconds in windows of up to 9,000 blocks, from one RPC node per pass (rotating through the five), and writes the events and its cursor (block number and hash) in one database transaction. If a stored block's hash changes, it rewinds 100 blocks. One advisory lock keeps it to one runner. Events are processed once, in chain order. The app's "I paid" call and the operator lane's own receipts feed the same handler.

Signing lanes

KeySignsCan it move money?
Quote key (web)EIP-712 prices onlyNo
Operator (worker)release, refund, claimFromPot, reclaimPotOnly along the contract's three paths
Feed key (worker)Rate feed roundsNo
Rewards (worker)QIE transfers for rewards and gas drips, under daily capsFrom its own small wallet
AdminRoles, limits, unpauseNever on the server

Each lane takes a database lock for its address, simulates the call, estimates gas (limit × 1.2), picks the nonce, signs, stores the signed transaction, then broadcasts and waits for the receipt. After a crash, stored transactions are re-sent first, oldest nonce first. A (purpose, ref) pair can only ever have one transaction, and before a release or refund the lane reads the order on chain to make sure it is still Held.

On this page