11 min readHow to design a bet settlement engine: official results, grading rules, payout maths, idempotent ledger design, resettlement and the final-whistle spike.
Building a Custom Sportsbook?
Real-time odds feeds, automated risk management, and settlement engines built for high throughput. Sportsbook platform engineering.
The first time I was pulled into a settlement incident, it wasn't a crash. Everything was up. A tennis result had been corrected about two hours after the match, the platform had settled on the original result, and the fix someone applied in a hurry credited the right customers without taking anything back from the wrong ones. Finance found it on the Monday—a five-figure payout leak on an event that had already finished, completely invisible to automated monitoring.
That's the thing about settlement. It rarely fails loudly. It fails by quietly moving money it shouldn't, and you learn about it from a reconciliation report days later.
In short: a bet settlement engine takes the official result, grades every open bet against it (win, lose, void, push, and the awkward fractions in between), calculates what each bet returns, and credits that through a double-entry ledger so that each change to a customer's money happens once. When a result is corrected later, it posts the difference as new entries and leaves the old ones alone.
This is part three of our sportsbook architecture series, following odds feed integration and the risk management module. The ledger approach below is the same one behind the wallet in our slot aggregator case study.
1. What a bet settlement engine actually does
On paper it's four steps: take in the official result, grade the open bets on that market, work out the payouts, credit the money. Notifications, reporting and regulatory feeds all hang off the same events.
The step people underestimate is grading. For a match-result single it really is a lookup. Then quarter-line Asian handicaps show up, and dead heats, and a tennis player retiring with a sore shoulder, and before long grading is the most rule-heavy code in the building. We now split the betting settlement architecture into three services (results, grading, payouts) that talk through events. The first platform I worked on did all three in one end-of-match job, and every change to one of them meant retesting all of them.
2. Results: wait for official
Most results arrive on the data provider's results stream. Some are corrected hours later. For lower-tier events with no feed coverage, someone in operations types them in, and that should always need a second person to approve before it counts.
The question you have to settle early is when to pay. Customers love instant payouts, so it's tempting to settle on the first score update after full time. That update is also the one most likely to change. We settle on the provider's confirmed or official status, and we respect any sport's own settling point. In UK and Irish horse racing that's the weigh-in: bets are settled on the result at that moment, even if an appeal changes the official placings later.
A few rules keep the results layer honest. Results are versioned, so a correction becomes version 2 and version 1 stays as it was. Every result records its source, whether a feed message ID or the two operators who entered and approved it. And the grading engine only ever reads the stored result record, never the raw feed message that created it.
3. The bet grading engine, and why its rules belong in data
The bet grading engine turns a market plus a result into an outcome for each selection. There are more outcomes than most people expect:
| Outcome | Example | What the customer gets |
|---|---|---|
| Win | Home to win; home wins 2–1 | Stake × price |
| Lose | Home to win; match drawn | Nothing |
| Void | Match postponed and not replayed within the rules | Stake back |
| Push | Over 3.0 goals; exactly three scored | Stake back |
| Half win | Over 2.75 goals; exactly three scored (the 2.5 half wins, the 3.0 half pushes) | Half stake × price, plus half stake back |
| Half lose | Home −0.25; match drawn (the 0 half pushes, the −0.5 half loses) | Half stake back |
| Dead heat | Two players tie for top goalscorer | Stake divided by the number tied, paid at full price |
Keep the rules as data, keyed by market type. The reason is that they're really your terms and conditions, and they differ between operators. When a tennis player retires mid-match, some books void match-winner bets, some settle once a set has been completed, and some pay whoever goes through. An abandoned football match usually means markets that were already decided stand (a first-goalscorer bet after the first goal, for instance) and undecided ones are void, unless the match is finished within a set window. Esports walkovers, basketball overtime and whether extra time counts all vary too. So does what each regulator will accept, which is why rule sets drafted for one licence usually need changes for markets such as Germany or Spain.
Two more things. Date the rules, so every bet is graded under the rules that applied when it was placed, not the version legal changed last week. And when a rule doesn't clearly cover what's in front of it, send the bet to a person. An engine that guesses will eventually guess wrong in a way that ends up with an adjudicator.
4. Inside the sportsbook payout engine: singles, multiples, each-way
Singles are simple: stake × price, adjusted for the outcome types above. The sportsbook payout engine earns its keep on multiples and each-way.
A void leg in an accumulator counts as odds of 1.0. So a €10 treble at 2.0, 1.5 and 3.0 with the middle leg voided returns €10 × 2.0 × 3.0 = €60 if the other two win. Each-way is two bets of equal stake, one to win and one to place, with the place part paid at the fraction of the odds your terms set (a quarter or a fifth is common). Dead-heat rules then apply to each part on its own. If the customer took a partial cash-out earlier, only the stake still running is settled; the rest was paid at cash-out.
A multiple is also graded more than once. Each leg's result can change the bet's status, and a correction on any leg means grading it again, which matters for the next section.
On the money itself: hold everything in integer minor units (cents), never floating point. Apply one rounding rule at one point, and put it in your terms; plenty of operators round the final return down to the cent. Convert currency once and store the rate alongside the amount. Crypto books follow the same rule with the token's smallest unit (satoshis, wei) and a stored exchange rate for reporting; it's one of the first things we set up on crypto sportsbook builds. I once watched a one-cent rounding mismatch between settlement and the finance export take most of a month to untangle, mostly because nobody could say which system was right.
5. Idempotent ledger design: paying once, however often you're asked
If you only take one thing from this post, take this: grading a bet can happen many times, and the money has to end up right regardless.
A lot of advice stops at "use a natural key like bet ID + market ID + result version, with a unique constraint." I'd push back on that. A multiple spans several markets, so market ID doesn't identify its settlement. Worse, a unique key does nothing to stop an old grading arriving late and being applied on top of a newer one.
What we do instead: the grading engine gives each grading of a bet a sequence number that only goes up. The payout worker locks the bet, applies the event only if its number is higher than the one already applied, and credits just the difference between the new return and what the bet has already been paid. An older event that arrives late is simply ignored, since a newer grading has already brought the bet to the right amount. All of it happens in one transaction:
BEGIN;
-- Lock the bet and see how far it has already been settled.
SELECT settlement_seq, credited_cents
FROM bets
WHERE bet_id = :bet_id
FOR UPDATE;
-- In the worker:
-- if :event_seq <= settlement_seq -> replay, or overtaken by a newer grading.
-- ROLLBACK, log it, pay nothing.
-- delta = :new_return_cents - credited_cents
-- if delta = 0 -> update the bet row only, skip the ledger inserts.
UPDATE bets
SET settlement_seq = :event_seq,
status = :outcome,
credited_cents = :new_return_cents
WHERE bet_id = :bet_id;
INSERT INTO ledger_entries (bet_id, settlement_seq, account_id, amount_cents)
VALUES (:bet_id, :event_seq, :customer_wallet, :delta_cents),
(:bet_id, :event_seq, :settlement_liability, -:delta_cents);
-- UNIQUE (bet_id, settlement_seq, account_id) is the backstop
-- in case anything ever gets past the check above.
UPDATE wallets
SET balance_cents = balance_cents + :delta_cents
WHERE account_id = :customer_wallet;
COMMIT;
Posting the difference means a first settlement and a correction use the same code path. First time round, the difference is the whole return. On a correction, it's whatever needs putting right, positive or negative.
The wallet is a double-entry ledger. Every credit to a customer has a matching opposite entry on a settlement liability account, so the entries always add up to zero. You'll still store a balance, because nobody wants to sum millions of rows to show a balance on the home screen. Update it in the same transaction as the entries, as above, and have a nightly job compare it with the ledger total. If they ever disagree, that should page someone.
With that in place, the everyday mess of production stops being dangerous. Workers crash halfway through, Kafka redelivers, somebody replays a topic to debug something else. None of it pays a bet twice.
6. Resettlement without rewriting history
Results get corrected after payout more often than you'd think. In our experience it's most common in lower-tier tennis and esports, where coverage is thinner. The engine re-grades the affected bets against the new result, and each one gets a new sequence number and a correcting entry that points back to the original. The customer's balance is right, finance can follow every step, and no past entry is edited. Two years later, when a regulator or a customer's solicitor asks what happened, that history is what you'll be glad to have.
Decide one thing with compliance before launch: what happens when a customer who was paid by mistake has already withdrawn the money. The ledger will quite happily take their balance negative. Whether you allow that, recover it from future winnings, write off small amounts, or contact the customer depends on your terms and your regulator. The engineering job is to record the correction properly whichever route the business picks.
7. Palpable errors and trading voids
Settlement also carries out the trading desk's decisions. That includes voids for palpable errors (a price that was obviously wrong when the bet was struck), voids over integrity concerns such as suspected match-fixing, and anything a regulator orders. Rules on palpable errors differ by jurisdiction; some regulators expect the bet to be settled at the correct price rather than voided, so check yours before you build the button.
We send these through the same event path as normal results, tagged with a different source and the name of the trader who approved them. Then "who voided this, when, and on whose authority" is a query, not an afternoon of searching chat history.
8. Surviving the final-whistle spike
Settlement load comes in bursts. On a big book, the final whistles of a Saturday football programme can mean hundreds of thousands of bets to settle within minutes, followed by an hour of near silence. So we grade as partitioned stream processing keyed by event, which stops one huge match holding up everything else. Payouts go through a queue, and the ledger write path stays as short as we can make it. Notifications sit behind their own queue, so a slow email provider has no way to slow payouts down.
Casino products put a different kind of load on the same ledger. A crash game settles every round seconds after the crash, all day long, which looks more like a steady stream than a Saturday spike. Our crash game development work and the crash game API integration guide cover that pattern, and the Lahore operator crash game case study shows it in production.
The number worth watching is settlement lag, from confirmed result to money in the wallet. Customers do notice a winning bet that takes ten minutes to land on a Saturday afternoon.
Before you build one
If I had to boil this down for a team about to start: settle on official results, keep grading rules as dated data, do the payout maths in cents, and make every change to a balance idempotent and append-only. Get those right and most of the horror stories in this area simply don't happen to you.
The last post in the series covers the other checkpoint money passes through, KYC and AML architecture for sportsbooks.
Launching on a white-label platform instead? Settlement usually comes with it, and the idempotency questions above are worth putting to the vendor; our white-label iGaming platform case study is a useful reference. For the bigger picture on costs and licence timelines, see our guide to building an online casino platform in 2026.
And if you'd rather have someone else build and run it, sportsbook settlement engine development is part of our sportsbook platform engineering work. Send us your current settlement flow and we'll tell you where we think it could pay twice.
Frequently asked questions
What is a bet settlement engine?
It's the part of a sportsbook that takes the official result, decides whether each open bet won, lost, pushed or was voided, works out the payout, and moves the money into the customer's wallet with a full audit trail. It also handles corrections when a result changes after bets have already been paid.
How do you stop a sportsbook paying a bet twice?
Give every grading of a bet an increasing sequence number, and let the payout step apply an event only if its number is higher than the one already applied. Credit only the difference between the new return and what was already paid, inside one database transaction, with a unique constraint on the ledger as a backstop. Retries and replays then change nothing.
What happens when a result is corrected after bets are settled?
The affected bets are graded again against the corrected result. Each bet's difference is posted as new ledger entries that reference the original settlement, so balances are corrected and the original entries stay untouched for audit.
How does an accumulator with a void leg pay out?
The void leg counts as odds of 1.0 and the bet settles on the remaining legs. A €10 treble at 2.0, 1.5 and 3.0 with the middle leg voided returns €10 × 2.0 × 3.0 = €60 if the other two legs win.
What is a push, and what is a half-win in Asian handicap?
A push means the stake comes back because the result landed exactly on the line, such as exactly three goals on over/under 3.0. Quarter lines like −0.25 or 2.75 split the stake across the two nearest lines, so half of it can win or lose while the other half is pushed.
When should a sportsbook settle bets?
Once the result is confirmed as official, rather than at the first score update after full time. Most data providers flag confirmed results, and some sports have their own settling point; in UK and Irish horse racing, bets are settled on the result at the weigh-in.
Related Services from Betadrix
At Betadrix, we specialize in delivering enterprise-grade solutions. Explore our related services to see how we can assist with your technology goals: Crypto Casino Software Development Company | Betadrix, Casino & Sportsbook Software Development Company in Canada, B2B Casino, Sportsbook & Blockchain iGaming Platform Development in Brazil, Casino, Sportsbook & Gaming Software Development Company in Spain, Best Blockchain Development Company | Betadrix, Casino Sportsbook Development Services | Betadrix, Casino & Sportsbook Development Services in Finland, Casino & Sportsbook Software Development Company in Germany, Casino & Sportsbook Development Services in Austria | Betadrix, Casino Game Development Services | Betadrix, Custom Crash Game Development | Aviator-Style Platforms | Betadrix.
Starting From Scratch?
Licensing, betting ledger, wallet integration and compliance — the full 2026 build roadmap. How to build an online casino platform.
Sportsbook settlement microservices and sportsbook development
Results service
Ingests official provider results and stores them as versioned records.
Grading service
Applies dated, per-market grading rules to each open bet: win, lose, void, push, half win, half lose, dead heat.
Payout service
Computes the difference between the new return and what was already paid, then posts it to the double-entry ledger.
Sportsbook development
Custom sportsbook and settlement engine development by Betadrix.
Settlement that never pays twice
Send us your current settlement flow and we'll tell you where we think it could pay twice.
Related Services
?Frequently Asked Questions
What is a bet settlement engine?
How do you stop a sportsbook paying a bet twice?
What happens when a result is corrected after bets are settled?
How does an accumulator with a void leg pay out?
What is a push, and what is a half-win in Asian handicap?
When should a sportsbook settle bets?

Shivam Swami
Founder & CEOShivam Swami is the Founder & CEO of Betadrix, leading technical architecture and engineering. He specializes in distributed systems, real-time betting architectures, and high-concurrency iGaming platforms.
Recognized & Verified Excellence
Trusted by Technical Leaders Worldwide
Verified ratings across global enterprise review platforms for custom software, AI development, and cloud engineering.
More Articles in iGaming & Casino Gaming
Related services built to solve your specific challenges
Watch.
Learn.
Grow.
Discover how our engineered solutions transform industries and propel client operations forward.

Owning the Game, Not Renting It: Custom Crash Game Development for a Lahore-Based iGaming Operator
READ CASE STUDYTechnologies & Frameworks Powering This Service
Hire Specialized Developers For Your Service Project

Flutter Developers
Pre-vetted senior Flutter Developers ready to deploy into your existing architecture in 3-7 days.

Python Developers
Pre-vetted senior Python Developers ready to deploy into your existing architecture in 3-7 days.

React Developers
Pre-vetted senior React Developers ready to deploy into your existing architecture in 3-7 days.

Nodejs Developers
Pre-vetted senior Nodejs Developers ready to deploy into your existing architecture in 3-7 days.
What Our Clients Say
“Mobile app development and cloud migration were handled smoothly. Strong technical skills, clear communication, and dependable post-launch support stood out throughout the engagement.”

Sarah Mitchell
Director of Operations, HealthFirst Clinics
Have a Project in Mind?
Let's Build It Together.
Connect directly with our senior software architects and technical leads. We evaluate your requirements and deliver an actionable technical proposal within 24 hours.
Strict NDA Protection
Your intellectual property and technical specs remain 100% confidential.
24-Hour Response Guarantee
Guaranteed evaluation and scoping reply from an engineering manager.
Zero Obligation Estimate
Get accurate cost breakdowns and tech stack recommendations free of charge.
Request Free Technical Consultation
Let's build something serious.
Diagnose your system architecture, budget ranges, and roadmap parameters with an expert.
Scoping Diagnostic
Analyze your workflows in 60 seconds. A senior AI architect reviews every parameter personally.
Not sure where AI actually moves the needle for you?
Answer a few brief questions. We will deliver a highly concrete scoping plan within 24 hours including:
- Recommendations on automation use-cases and MVP components
- Calculations on expected ROI and engineering timelines
- A structural roadmap to make your legacy stack AI-native












