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.
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.The pool on the game
wallet.ex · inc_pool!/2Every 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.
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.
The fee waterfall
economy.ex · entry_fee_split/5Economy.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).
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.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.
Break-even by design; the rake is forward
economy/economy.md §8The 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).
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.
References
sources · relatedSources
- All-pay auctionthe buy-in-plus-fee contest the pool funds
- Contests — Networks, ch. 9the contest structure of a prize pool the whole field pays into
Related
- C4.3 — Settlement strategieshow the pool is paid out
- C6 — The Revenue Ledger and the KeyShopthe revenue ledger and cash-out (forward cm.8)
- BCS — the architecture lawthe ledger law behind the books