Skip to content

betting-market: describe the Draft state and the betting close time - #165

Merged
mikemaccana merged 2 commits into
mainfrom
claude/kind-pasteur-2sw8p5
Sep 23, 2026
Merged

mikemaccana merged 2 commits into
mainfrom
claude/kind-pasteur-2sw8p5

Conversation

@mikemaccana

@mikemaccana mikemaccana commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Merge after quicknode/solana-program-examples#154. This PR names open_betting(), betting_closes_at, EventNotDraft, NotEnoughOutcomes, CloseTimeInPast, BettingClosed and BettingStillOpen, which exist only on that PR's branch until it merges.

Summary

The companion program now starts every event as a Draft. open_betting() fixes the outcome list before any bet can land, bets stop at a betting_closes_at fixed at creation, and settlement is allowed only at or after that time. Before this, the outcome list was locked implicitly by an empty-pool check. That let anyone freeze a half-built market with a one-minor-unit bet, and bets were accepted until settlement ran, even after the result was public.

Changes

  • Betting Market chapter: the setup now reads initialize_event() (with a close time), add_outcome() twice, then open_betting(). New text explains why an explicit Draft status beats locking the list at the first bet. The chapter covers BettingClosed and BettingStillOpen and the four states, adds an invariant and a "betting on a known result" failure mode, and lists the new tests.
  • Offchain Truth, Operating Financial Software, and the fundamentals intro: the "fix the terms when money commits" and "make the state explicit" passages now describe the new design.
  • Figures:
    • The state machine gains the Draft state and the open_betting() transition.
    • The five step figures add open_betting() to the program box, and the right column shifts down 10 units to make room.
    • The setup figure and the account map show the event's betting_closes_at.
    • The program box listed a create_event() handler that doesn't exist; it now says initialize_event().
    • The check-figure-geometry.mjs exception for the place-bets arrowhead moves with that arrowhead (470,601 to 470,611).

Verification

npm run lint, node scripts/check-figure-geometry.mjs (99 figures) and npm run build-pdf all pass on the merged head.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK

Mike MacCana added 2 commits September 22, 2026 23:35
The companion program now starts every event as a Draft, fixes the outcome
list with open_betting() before any bet can land, and stops bets at a
betting_closes_at fixed at creation, with settlement allowed only after it.
The chapter, the offchain-truth and operating chapters, and the
fundamentals intro now describe that design and why a status beats locking
the list at the first bet.

The figures gain open_betting() in the program box, the event's close time,
and a Draft state in the state machine. They also stop naming
create_event() and default_fee_bps, which never existed: the handler is
initialize_event() and the config field is fee_bps.

Claude-Session: https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
Main moved the betting chapter's account descriptions to the steps that
create them and restored default_fee_bps, which the companion repository
now ships as the config's field name. The Draft state, open_betting() and
betting_closes_at are carried into that structure, and the figures' config
boxes say default_fee_bps again.

Claude-Session: https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
@mikemaccana mikemaccana changed the title Rename create_event to initialize_event and add open_betting instruction betting-market: describe the Draft state and the betting close time Sep 23, 2026
@mikemaccana
mikemaccana merged commit b034878 into main Sep 23, 2026
1 check passed
@mikemaccana
mikemaccana deleted the claude/kind-pasteur-2sw8p5 branch October 13, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant