House bankroll and how it works

The hub database has a hub.bankroll table that stores the house bankroll for each currency.

Hub’s makeOutcomeBet mutation automatically updates the house bankroll for you.

What is the house bankroll?

The house bankroll is the total amount of money (per currency) that you, the house, are letting players bet against.

When do you update the house bankroll?

You update the house bankroll any time the amount of money at risk changes.

  1. When a player wins a bet: ✅ You decrease the house bankroll by their net payout since they won money from the pool of money that you have at risk, and now the house has less money to risk. (⚠️ This is the most important one to get right!)
  2. When a player loses a bet: ✅ You increase the house bankroll by their wager since they gave up their wager to the pool of money that the house is willing to risk.

When not to update the house bankroll:

  1. When a player deposits money: ❌ Do not update the bankroll. Just because a player deposits $1,000,000 doesn’t mean you have +$1,000,000 at risk!
  2. When a player withdraws money: ❌ Do not update the bankroll. Just because a player withdraws $1,000,000 doesn’t mean you have less money at risk!
  3. When you reserve the wager from a player’s balance that will be settled later: ❌ Do not update the bankroll. The bankroll is only updated when the wager is settled (the player wins or loses the bet).

How important is it that the house bankroll is updated correctly?

The house bankroll is just as critical as the player balance.

It’s an easy mistake to not take the house bankroll seriously since you set it by hand; It can feel arbitrary.

But correctly updating the bankroll (especially decreasing it when players win) is essential for limiting your risk.

Remember that the bankroll is used to determine whether your server accepts a bet. So if your bankroll is too high or if you forget to decrease it when players win, then you will end up crediting balances to players that you don’t have!

Then they will request a withdrawal (aka create a “take request”) to their MoneyPot balance, and you will be on the hook to fund your controller so that you can afford the transfer.

What’s the difference between the house bankroll and the controller’s balance on MoneyPot?

The controller’s balance on MoneyPot is only used to fund take requests (when players want to withdraw their funds in your experience to their MoneyPot balance). In other words, it’s the amount of funds your controller has access to on MoneyPot to service transfers to players.

The house bankroll is how much total money you want to risk; it determines the maximum bet and payout that the server will accept. MoneyPot does not know your house bankroll.

For example, you might have $1000 of BTC to risk in your experience. The $1000 don’t exist anywhere in the MoneyPot system; it’s simply a number you set in the hub.bankroll table.

But it’s a “promise” to your players that you’re good for $1000 since maybe your risk logic means that with a bankroll of $1000, players can make bets that win up to $10.

Meanwhile, your MoneyPot controller might only be funded with $2 of BTC. Now, those funds do live in the MoneyPot system; you deposit BTC from your cryptocurrency wallet into your MoneyPot account.

If a player deposits $10 of BTC into your experience, wins some bets against your bankroll, and then creates a take request to withdraw all $20 of their funds, then your controller will need to have $20 of BTC in its MoneyPot balance. If not, then the transfer will stay in the PENDING state until you fund your MoneyPot controller with the necessary funds.

Things to keep in mind

  1. Always insert into the audit log when you update the house bankroll.

Read more: Audit log

  1. Think about whether you need to include the wager in the bankroll update.

    For atomic bets, you tend to add the player’s wager to the bankroll on player loss and subtract only the player’s profit (no wager) on player win.

    We like to represent this as a playerProfit multplier that might be -1 when the player loses their wager and a number like 0.2 when the player wins a 1.2x multiplier.

    // Example
    const wager = 100;
    const playerProfit = 0.2; // Player wins 1.2x their wager
    const playerBalanceChange = wager * playerProfit; // 100 * 0.2 = 20
    const houseBankrollChange = -playerBalanceChange; // -20 (notice that it's zero-sum)
    dbUpdatePlayerBalance(playerId, playerBalanceChange);
    dbUpdateHouseBankroll(bankrollId, houseBankrollChange);
    

    For non-atomic bets, you may need to think more deeply about this. For example, when a player starts a mines game, you will deduct the wager from the player balance, but the bankroll will not change until the player wins or loses the game.

  2. Lock the player balance and the house bankroll rows any time you update them.