> For the complete documentation index, see [llms.txt](https://docs.fast.poker/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fast.poker/for-operators-dealer-service/phase-actions.md).

# Phase-driven actions

Every table is in exactly one phase at a time. The Dealer Service reads the phase, looks up the action, submits the transaction, and waits for the next phase. This page is the canonical map.

## Cash and SNG, shared phases

| Phase detected                     | Dealer action                              | Chain |
| ---------------------------------- | ------------------------------------------ | ----- |
| `Waiting` (2+ active players)      | `start_game` then `tee_deal`               | TEE   |
| `Starting`                         | `tee_deal`                                 | TEE   |
| `Preflop`                          | none (players act)                         | --    |
| `FlopRevealPending`                | `tee_reveal` (3 community cards)           | TEE   |
| `Flop`                             | none (players act)                         | --    |
| `TurnRevealPending`                | `tee_reveal` (1 community card)            | TEE   |
| `Turn`                             | none (players act)                         | --    |
| `RiverRevealPending`               | `tee_reveal` (1 community card)            | TEE   |
| `River`                            | none (players act)                         | --    |
| `Showdown`                         | `settle_hand`                              | TEE   |
| Any phase, current player idle 20s | `handle_timeout` (auto-check or auto-fold) | TEE   |

For a duel-mode SNG, `Waiting` must first check whether a scheduled duel is due. If `duel_active` is true, do not call `start_game`.

## Cash-specific phases

| Phase detected                            | Dealer action                                                                                                                        | Chain            |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------- |
| `Waiting`, seats in `Leaving` state       | `commit_state` -> `process_cashout_v2` -> `clear_leaving_seat`                                                                       | TEE -> L1 -> TEE |
| `Waiting`, seats `SittingOut` > 5 minutes | `crank_remove_player` or `crank_kick_inactive`                                                                                       | TEE              |
| Periodic (every 60s)                      | `commit_state` -> `settle_table_rewards` -> `update_acc_reward_per_weight` -> `claim_operator_rewards` (or `_token_rewards` for SPL) | L1               |

The cash leave pipeline is detailed in [Cash pipeline](/for-operators-dealer-service/cash-pipeline.md).

## SNG-specific phases

| Phase detected                                    | Dealer action                                                                                                                                                                                                         | Chain     |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| `Waiting`, 6/9-max at a new eligible blind level  | `maybe_start_sng_duel`                                                                                                                                                                                                | TEE       |
| Active duel, missing player choice after deadline | `sng_duel_timeout`                                                                                                                                                                                                    | TEE       |
| Active duel, ready to resolve                     | `resolve_sng_duel`                                                                                                                                                                                                    | TEE       |
| `Complete`, record mode                           | Commit/undelegate record + table/sidecar -> settle jackpots -> `distribute_prizes_from_record` -> finalize rewards -> close jackpot entries -> `assert_table_clean` -> `reset_sng_table` -> `close_settlement_record` | TEE -> L1 |

The full SNG completion sequence is detailed in [SNG pipeline](/for-operators-dealer-service/sng-pipeline.md).

## Timeout details

* Threshold: 20 seconds of wall-clock inactivity by the current player.
* Auto-checks if the player's current bet covers `min_bet`, otherwise auto-folds.
* After 3 consecutive auto-folds at a cash table, the seat is moved to `SittingOut` and `sit_out_timestamp` is set.
* The on-chain program enforces a minimum 15s delay (`TIMEOUT_SECONDS`) before `handle_timeout` is accepted, so the dealer's 20s threshold has built-in margin.

## Misdeal handling

If `tee_deal` or `tee_reveal` returns a deal-integrity error, the dealer submits `misdeal` and the table returns to `Waiting`. Players' chips are unchanged; only the in-flight hand is voided.

## What happens during `Preflop`, `Flop`, `Turn`, `River`

Nothing on the dealer's part. These are the betting rounds; players submit `player_action` transactions themselves (gasless, signed on the ER). The dealer just polls and waits for the round to complete, at which point the phase advances to the next `*RevealPending`.

The exception is timeouts: if the current player is idle, the dealer kicks in with `handle_timeout`.
