jonnify·codemojex /codemojex/commerce/cash-out-and-the-treasury

Codemojex · C6.3 · a dive of The Revenue Ledger and the KeyShop

Cash-out and the treasury.

Everything so far moves money inward. Cash-out is the one outward rail — diamonds leaving for TON, USDT, or RUB. It is forward — cm.8: cm.7 designed for the seam and built none of it, quarantining the regulatory and fraud weight into its own rung. The lesson is that the outward rail needs no new ledger verb and no new account — it is a house debit through the same signed house_post. What cm.8 adds is not machinery but policy.

Grounding — the shipped seams: wallet.ex (house_post/5 signed, balance/1 / locked_diamonds) · key_shop.ex (the create_order rate snapshot) · rails.ex · the webhook (WHK) forward shape. The rates poller, the hold, KYC/AML, and treasury reconciliation are stated forward-tense.

Four shipped seams, one forward rung — select a seam
seam shipped today cm.8 adds · forward the signed ledger house_post · signed delta the withdrawal debit the pinned rate create_order rate snapshot a rates table + poller the locked hold locked_diamonds column the 21-day hold policy the push confirm WHK forward shape the push-rail table
the signed ledger → house_post/5 already books a signed delta — the house swings negative on the deposit_seed debit today. A withdrawal is a negative revenue_ledger.delta through the same primitive: no new verb, no new account. Shipped.
§1

The seams are already shipped

wallet.ex · balance/1

The outward rail is a small addition rather than a new system because four seams already exist. The signed house_post admits a negative delta (proven by the seed debit); create_order pins a rate snapshot at creation and never re-reads the live rate; the players.locked_diamonds column is live, and balance/1 already reports available_diamonds as diamonds − locked_diamonds; and the WHK schema is the designed-forward idempotency shape for a push rail. A hold window is a locked_diamonds move — the column exists; only the policy is new.

echo/…/codemojex/wallet.ex · balance/1 — the shipped hold seam source
def balance(player) do
  case Repo.get(Player, player) do
    nil ->
      nil

    p ->
      p
      |> Map.from_struct()
      |> Map.drop([:__meta__])
      |> Map.merge(%{available_keys: p.keys,
                    available_diamonds: p.diamonds - p.locked_diamonds}) # the hold seam
  end
end

The signed primitive is C6.1: house_post/5 books a signed delta, so the withdrawal debit needs no new verb. This dive is the outward direction the design points at but has not built.

§2

The withdrawal pipeline

forward · cm.8

The withdrawal runs five stages. Select one to see the shipped seam it rests on and the forward policy it adds — only the middle stages are new; the endpoints are the same signed ledger and the same rail set the KeyShop uses.

The five stages — select one
pin the rate seam + poller lock (hold) forward policy KYC / AML forward policy house debit shipped seam push + confirm WHK shape
pin the rate → the floating TON/USDT/RUB quote is pinned per withdrawal at request time — the inverse of create_order’s pinned rate snapshot, which records rate_minor/rate_pair/rate_source/rate_quoted_at and never re-reads the live rate. The snapshot discipline is shipped; the rates table and its poller are forward.
Forward (cm.8). No stage above is built. The rates table, the poller, the hold window, and the KYC/AML gate are the next rung’s work; only the endpoints — the signed house_post debit and the Rails set — exist today.
§3

What cm.8 adds

the forward policy

The regulatory and fraud weight is quarantined into cm.8 on purpose: the inward rails ship safely without it, and the outward rail cannot ship without it. Three additions, all forward, each expressed over a shipped seam.

  • A rates table with a poller. The floating quote, pinned per withdrawal at request time — the create_order snapshot discipline, inverted for the outward direction. forward
  • KYC/AML and the 21-day hold. The compliance gate the outward direction requires, expressed over the shipped locked_diamonds seam — a hold locks diamonds, so available_diamonds falls while the balance does not. forward
  • Treasury reconciliation. The platform’s on-chain balances reconciled against the signed revenue_ledger debits — the ledger is the book of record, the chain the counterparty. forward

The design’s rule holds: transparent margin levers, never undisclosed house players. The outward rail is the last piece of the money story — the house’s book (C6.1) and the pay-in (C6.2) are shipped; the withdrawal is where the platform’s obligations to a regulator begin, so it waits for its own rung.

§4

References

sources · related

Sources

Related