jonnify·codemojex /codemojex/the-economy/the-bank-the-pool-and-the-rake

Codemojex · C5.3 · a dive of The Economy and the Bank

The bank, the pool, and the rake.

Today the pool is not a separate bank — it lives on the game’s own prize_pool column, in diamonds. An ordinary room is platform-seeded; a Golden Room is funded by the field’s own buy-ins. The BNK escrow as a first-class entity and a published platform rake are forward (cm.9+).

Grounding — echo/…/codemojex/economy.ex (entry_fee_split/5) · wallet.ex (charge_guess_golden, inc_pool!/2, buy_in/2) · design §Privacy and fairness · economy/economy.md §8 · the golden-economy + golden-tournament stories.

Where the pool’s diamonds come from — select a source
prize_pool on the games row inc_pool! — atomic SQL + the seed virtual_deposit | seed_pool the buy-ins entry_fee_split waterfall the guesses golden guess: fee × 10
the seed → an ordinary room opens with seed_pool; a Golden Room forms in :gathering seeded with the platform’s virtual_deposit. The seed is the platform’s stake in the pool before any member has paid in.
§1

The pool on the game

wallet.ex · inc_pool!/2

Every credit to the pool is an atomic SQL + on the game’s prize_pool column — never an app-side read-modify-write, so two concurrent credits cannot lose an update. A Golden Room’s paid guess is two-sided: the keys fee is debited and the pool is funded by fee × 10 diamonds, in the same transaction.

echo/…/codemojex/wallet.ex · the two-sided guess + inc_pool!/2 source
defp charge_guess_golden(player, fee, ref) do
  Repo.transaction(fn ->
    case lock(player) do
      nil -> Repo.rollback(:no_player)
      p ->
        if p.keys < fee do
          Repo.rollback(:insufficient)
        else
          update!(p, %{keys: p.keys - fee})              # the keys debit
          txn!(player, :keys, -fee, "guess", ref)
          inc_pool!(ref, fee * Economy.diamonds_per_key()) # the pool +, fee×10
          p.keys - fee
        end
    end
  end)
end

defp inc_pool!(game, diamonds) do
  {1, _} = Repo.update_all(from(g in Game, where: g.id == ^game), inc: [prize_pool: diamonds])
end

The golden-economy story pins it: a golden guess with a fee of 1 key raises the pool by fee × 10 = 10 diamonds and the member’s keys fall by the fee — every guess is all-pay, and every guess funds the prize.

§2

The fee waterfall

economy.ex · entry_fee_split/5

Economy.entry_fee_split/5 is pure, and it partitions each buy-in by the paid member’s ordinal into three bands. Select a band to see how much of the fee funds the pool versus stays platform revenue — the numbers are the golden-economy story’s (virtual_deposit 1000, threshold 2, first_movers 1, revenue 50%, fee 8 keys).

The three bands of the waterfall — select one
ordinal band pool credit where the fee goes ord ≤ 2 deposit-recovery pool += 0 whole fee = platform revenue ord 3 first-mover pool += 40 floor(8×50/100)×10 = 40 diamonds ord 4+ pure revenue pool += 0 100% platform revenue
member 1–2 → the deposit-recovery band. A member at or below the start_threshold adds nothing to the pool — the whole fee is platform revenue that recovers the seeded virtual_deposit. The pool stays at 1000 while each member’s keys fall by 8.
echo/…/codemojex/economy.ex · entry_fee_split/5 source
def entry_fee_split(ordinal, start_threshold, first_movers, revenue_pct, entry_fee_keys)
    when ordinal > start_threshold and ordinal <= start_threshold + first_movers do
  pool_keys = div(entry_fee_keys * (100 - revenue_pct), 100)
  pool_keys * @diamonds_per_key
end

def entry_fee_split(_ordinal, _start_threshold, _first_movers, _revenue_pct, _entry_fee_keys), do: 0

The keys portion is floored before the ×10 keys-to-diamonds conversion, so the pool conserves to whole diamonds. The house cut and the pool share derive from the one floor, so they partition the fee exactly with no residue.

§3

Break-even by design; the rake is forward

economy/economy.md §8

The design’s launch model is a candid one. A flat $1 buy-in and a hard floor of ten members give a guaranteed $1 × 10 = $10 pool that the ten buy-ins fund exactly — so the platform never loses money on a started game, and the pool grows past ten only above ten players. A never-fills Golden Room voids with no refund: the field voids and the platform keeps the collected fees (the golden-tournament story: voided, room reset, no refund TXN exists).

Forward (cm.9+). Where durable margin ultimately lives is the published platform rake — Arm C in the economy decision surface — together with the BNK escrow as a first-class entity. Both are forward. The ruled default is transparent margin levers, never undisclosed house players: at launch the per-guess fee is the platform’s revenue and the prize pool is stated up front.

The house’s own signed books — the RVL revenue ledger that records every platform movement, and cash-out (the forward cm.8) — are C6. This dive is the pool: where its diamonds come from, and how the fee is split.

§4

References

sources · related

Sources

Related