> For the complete documentation index, see [llms.txt](https://suigar.gitbook.io/suigar-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://suigar.gitbook.io/suigar-docs/end-to-end-ai-map/slots-stake-engine-alignment.md).

# Slots stake engine alignment

This note captures the Stake Engine slot/RGS requirements that Suigar's mocked slots flow now targets. Move settlement is intentionally out of scope for this pass, but the play path is shaped for Move to select the outcome directly.

## Stake Engine Requirements Aggregated

* RGS flow is `authenticate -> play -> animate -> end-round`. `authenticate` establishes session config and bet limits. `play` debits the bet and returns the resolved round. `end-round` finalizes payout after presentation.
* Round data returned from `play` is a replayable "book": required fields are `id`, `events`, and `payoutMultiplier`.
* Frontend executes ordered events. It must not decide wins or invent payout. It should only animate the resolved round facts.
* Static math publication requires `index.json`, lookup CSV rows of `simulation number, round probability, payout multiplier`, and compressed `.jsonl.zst` round logic.
* Slot setup is mode-based. Each mode has explicit cost, RTP, max win, distribution criteria, and simulation outputs.
* Replay is mandatory. Replay mode must load without a player session, fetch by `game/version/mode/event`, disable betting, and replay the same events and result.
* Fair verification maps seed/nonce entropy into an event table: HMAC-SHA256 entropy -> uint128 -> modulo total weight -> event range -> payout.

## Suigar Local Book Contract

Current gameplay does not call a slots backend. The frontend owns chunked static outcome books for the active game/version/mode and hydrates the selected outcome into the same replayable `SlotRound.events` shape the Stake docs expect.

Current mock selector:

* `selectMockBlockchainSlotOutcome()` chooses an `outcomeId` from the active mode's local weights.
* `buildLocalSlotSpinResult()` hydrates that `outcomeId` into the full animation book.
* `buildLocalSlotReplayResult()` replays a local outcome by `event`.

Current frontend route:

* `/slots`
* `/slots?replay=true&game=candy-rush&version=2&mode=base&event=2&amount=1&currency=SUI`
* Legacy `/slots?replay=true&game=sugar-cascade...` links resolve through the Candy Rush game alias.

Current local book:

* `frontend/src/features/games/slots/slot-outcome-book.ts`
* `frontend/src/features/games/slots/data/candy-rush/index.json`
* `frontend/src/features/games/slots/data/candy-rush/outcomes-*.json`
* Book metadata includes `gameId`, `version`, `modes`, `rtpBps`, `volatility`, `maxWinMultiplier`, symbol roles, scatter awards, Sugar Meter rules, chunk names, weighted outcomes, refill strips, feature spins, and bonus events.
* Candy Rush v2 is a high-volatility 7x7 cluster-pays slot with wilds, scatters, free spins, multiplier bombs, ante mode, bonus-buy mode, Sugar Meter persistence, and a hard 10,000x cap.
* Production math should keep using split static assets per `game/version/mode`; Move only needs to replace the mock selector with the on-chain selected outcome.

Current round shape:

```ts
type SlotRound = {
	id: number;
	eventId: string;
	gameId: string;
	version: number;
	mode: string;
	status: 'complete';
	costMultiplier: number;
	payoutMultiplier: number; // multiplier * 100, Stake-style
	events: SlotRoundEvent[];
	fair: {
		nonce: number;
		outcomeId: number;
		roll: number;
		weightSum: number;
		tableHash: string;
		entropyCommitment: string;
	};
	mock: true;
};
```

Move integration target:

* Move returns or emits the selected `outcomeId`, `nonce`, `roll`, `weightSum`, `gameId`, `version`, `mode`, `costMultiplier`, and `payoutMultiplier`.
* The frontend replaces only `selectMockBlockchainSlotOutcome()` with the Move result.
* Keep rich animation books off-chain and static in the frontend bundle unless gas analysis says otherwise.
* Keep the frontend consuming `SlotRound.events`; do not bind animation code to Move internals.
* The backend/indexer may observe history, but it is not required to play a spin.

## Source Docs

* <https://stake-engine.com/docs/rgs>
* <https://stake-engine.com/docs/rgs/wallet>
* <https://stake-engine.com/docs/math/math-file-format>
* <https://stake-engine.com/docs/math/high-level-structure/game-format>
* <https://stake-engine.com/docs/front-end/flowchart>
* <https://stake-engine.com/docs/approval-guidelines/game-replay-requirements>
* <https://stake-engine.com/docs/approval-guidelines/rgs-communication>
* <https://stake-engine.com/docs/approval-guidelines/math-verification>
* <https://stake-engine.com/fair/api>
