@rolly-dev/wasm-signer 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,45 @@
13
13
  export function amount_split(amount: bigint): Uint32Array;
14
14
 
15
15
  /**
16
- * Aviato RTP percent (99). Canonical source for backend/frontend.
16
+ * Backward-compatible alias for `crash_rtp_percent`.
17
17
  */
18
18
  export function aviato_rtp_percent(): number;
19
19
 
20
+ /**
21
+ * Reconstruct the 30 dealt Blackjack rank codes from the fairness seeds.
22
+ *
23
+ * This is the SINGLE client/backend-side mirror of the native shoe unfold in
24
+ * `tx_validator::blackjack::unfold_shoe` and the in-circuit shuffle: it computes
25
+ * `mix = Poseidon2(server_seed ‖ user_secret_random)` and the per-step swap
26
+ * randomness `low32(Poseidon2(mix ‖ k))`, then defers the deterministic
27
+ * 30-swap partial Fisher–Yates over the fixed 416-card layout to the pure
28
+ * `rolly_game_core::blackjack::deal_shoe`. Mixing the player-chosen
29
+ * `user_secret_random` into the seed makes the shuffle a mutual commit–reveal,
30
+ * so neither the operator nor the player can pre-grind a shoe.
31
+ *
32
+ * `server_seed` must be 8 elements (the full fairness preimage); `user_secret_random`
33
+ * must be 4 elements (`string_to_user_seed(user_seed_source)`).
34
+ *
35
+ * **Output**: `Uint8Array` of length 30 — rank codes `0..=12` (Ace=0, 2..9=1..8,
36
+ * 10/J/Q/K=9..12). Suits are cosmetic and restored off-engine.
37
+ *
38
+ * ```js
39
+ * const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
40
+ * ```
41
+ */
42
+ export function blackjack_deal_shoe(server_seed: BigUint64Array, user_secret_random: BigUint64Array): Uint8Array;
43
+
44
+ /**
45
+ * Pack a Blackjack action sequence into the two base-8 halves the rollup records
46
+ * as `prediction_lo` / `prediction_hi` (`actions[0..10]` → lo, `actions[10..20]`
47
+ * → hi). Single-sources `rolly_game_core::blackjack::pack_actions` so the
48
+ * backend feeds the WitnessEngine exactly what the circuit re-derives.
49
+ *
50
+ * `actions` are the `ACTION_*` codes (1..=6). **Output**: `Uint32Array` of
51
+ * length 2 = `[prediction_lo, prediction_hi]`.
52
+ */
53
+ export function blackjack_pack_actions(actions: Uint8Array): Uint32Array;
54
+
20
55
  /**
21
56
  * CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
22
57
  */
@@ -34,12 +69,17 @@ export function coinflip_rtp_percent(): number;
34
69
  export function compute_address_hash(address_hex: string): BigUint64Array;
35
70
 
36
71
  /**
37
- * Extract aviato point (×100) from raw server seed fields.
72
+ * Backward-compatible alias for `compute_crash_point`.
73
+ */
74
+ export function compute_aviato_point(random: BigUint64Array): number;
75
+
76
+ /**
77
+ * Extract crash point (×100) from raw server seed fields.
38
78
  *
39
79
  * `random` must be exactly 4 elements (first 4 fields of server_seed).
40
- * Returns the clamped aviato multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
80
+ * Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
41
81
  */
42
- export function compute_aviato_point(random: BigUint64Array): number;
82
+ export function compute_crash_point(random: BigUint64Array): number;
43
83
 
44
84
  /**
45
85
  * Extract the 10 drawn numbers from Poseidon2 random output using
@@ -59,15 +99,7 @@ export function compute_drawn_keno(random: BigUint64Array): Uint8Array;
59
99
  export function compute_multi_dice(win_numbers: number): bigint;
60
100
 
61
101
  /**
62
- * Full aviato payout computation — pure integer arithmetic, zero floats.
63
- *
64
- * `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
65
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
66
- * `cashout_x100`: multiplier at which the user cashed out (×100).
67
- * - 0 = user did NOT cash out (loss).
68
- * - 100..=1_000_000 = user stopped at this multiplier.
69
- *
70
- * Returns `BigUint64Array[4]`: `[win_amount, aviato_x100, is_win (0|1), multiplier×10000]`.
102
+ * Backward-compatible alias for `compute_payout_crash`.
71
103
  */
72
104
  export function compute_payout_aviato(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
73
105
 
@@ -82,6 +114,19 @@ export function compute_payout_aviato(random: BigUint64Array, bet_atomic: bigint
82
114
  */
83
115
  export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
84
116
 
117
+ /**
118
+ * Full crash payout computation — pure integer arithmetic, zero floats.
119
+ *
120
+ * `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
121
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
122
+ * `cashout_x100`: multiplier at which the user cashed out (×100).
123
+ * - 0 = user did NOT cash out (loss).
124
+ * - 100..=1_000_000 = user stopped at this multiplier.
125
+ *
126
+ * Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
127
+ */
128
+ export function compute_payout_crash(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
129
+
85
130
  /**
86
131
  * Full dice payout computation — pure integer arithmetic, zero floats.
87
132
  *
@@ -211,6 +256,11 @@ export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64
211
256
  */
212
257
  export function compute_user_seed_binding(game_id: number, bet: bigint, pred_hash: BigUint64Array, secret: BigUint64Array): BigUint64Array;
213
258
 
259
+ /**
260
+ * Crash RTP percent (99). Canonical source for backend/frontend.
261
+ */
262
+ export function crash_rtp_percent(): number;
263
+
214
264
  /**
215
265
  * Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
216
266
  *
@@ -27,7 +27,7 @@ function amount_split(amount) {
27
27
  exports.amount_split = amount_split;
28
28
 
29
29
  /**
30
- * Aviato RTP percent (99). Canonical source for backend/frontend.
30
+ * Backward-compatible alias for `crash_rtp_percent`.
31
31
  * @returns {number}
32
32
  */
33
33
  function aviato_rtp_percent() {
@@ -36,6 +36,78 @@ function aviato_rtp_percent() {
36
36
  }
37
37
  exports.aviato_rtp_percent = aviato_rtp_percent;
38
38
 
39
+ /**
40
+ * Reconstruct the 30 dealt Blackjack rank codes from the fairness seeds.
41
+ *
42
+ * This is the SINGLE client/backend-side mirror of the native shoe unfold in
43
+ * `tx_validator::blackjack::unfold_shoe` and the in-circuit shuffle: it computes
44
+ * `mix = Poseidon2(server_seed ‖ user_secret_random)` and the per-step swap
45
+ * randomness `low32(Poseidon2(mix ‖ k))`, then defers the deterministic
46
+ * 30-swap partial Fisher–Yates over the fixed 416-card layout to the pure
47
+ * `rolly_game_core::blackjack::deal_shoe`. Mixing the player-chosen
48
+ * `user_secret_random` into the seed makes the shuffle a mutual commit–reveal,
49
+ * so neither the operator nor the player can pre-grind a shoe.
50
+ *
51
+ * `server_seed` must be 8 elements (the full fairness preimage); `user_secret_random`
52
+ * must be 4 elements (`string_to_user_seed(user_seed_source)`).
53
+ *
54
+ * **Output**: `Uint8Array` of length 30 — rank codes `0..=12` (Ace=0, 2..9=1..8,
55
+ * 10/J/Q/K=9..12). Suits are cosmetic and restored off-engine.
56
+ *
57
+ * ```js
58
+ * const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
59
+ * ```
60
+ * @param {BigUint64Array} server_seed
61
+ * @param {BigUint64Array} user_secret_random
62
+ * @returns {Uint8Array}
63
+ */
64
+ function blackjack_deal_shoe(server_seed, user_secret_random) {
65
+ try {
66
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
67
+ const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
68
+ const len0 = WASM_VECTOR_LEN;
69
+ const ptr1 = passArray64ToWasm0(user_secret_random, wasm.__wbindgen_export);
70
+ const len1 = WASM_VECTOR_LEN;
71
+ wasm.blackjack_deal_shoe(retptr, ptr0, len0, ptr1, len1);
72
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
73
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
74
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
75
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
76
+ return v3;
77
+ } finally {
78
+ wasm.__wbindgen_add_to_stack_pointer(16);
79
+ }
80
+ }
81
+ exports.blackjack_deal_shoe = blackjack_deal_shoe;
82
+
83
+ /**
84
+ * Pack a Blackjack action sequence into the two base-8 halves the rollup records
85
+ * as `prediction_lo` / `prediction_hi` (`actions[0..10]` → lo, `actions[10..20]`
86
+ * → hi). Single-sources `rolly_game_core::blackjack::pack_actions` so the
87
+ * backend feeds the WitnessEngine exactly what the circuit re-derives.
88
+ *
89
+ * `actions` are the `ACTION_*` codes (1..=6). **Output**: `Uint32Array` of
90
+ * length 2 = `[prediction_lo, prediction_hi]`.
91
+ * @param {Uint8Array} actions
92
+ * @returns {Uint32Array}
93
+ */
94
+ function blackjack_pack_actions(actions) {
95
+ try {
96
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
97
+ const ptr0 = passArray8ToWasm0(actions, wasm.__wbindgen_export);
98
+ const len0 = WASM_VECTOR_LEN;
99
+ wasm.blackjack_pack_actions(retptr, ptr0, len0);
100
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
101
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
102
+ var v2 = getArrayU32FromWasm0(r0, r1).slice();
103
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
104
+ return v2;
105
+ } finally {
106
+ wasm.__wbindgen_add_to_stack_pointer(16);
107
+ }
108
+ }
109
+ exports.blackjack_pack_actions = blackjack_pack_actions;
110
+
39
111
  /**
40
112
  * CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
41
113
  * @returns {number}
@@ -80,10 +152,7 @@ function compute_address_hash(address_hex) {
80
152
  exports.compute_address_hash = compute_address_hash;
81
153
 
82
154
  /**
83
- * Extract aviato point (×100) from raw server seed fields.
84
- *
85
- * `random` must be exactly 4 elements (first 4 fields of server_seed).
86
- * Returns the clamped aviato multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
155
+ * Backward-compatible alias for `compute_crash_point`.
87
156
  * @param {BigUint64Array} random
88
157
  * @returns {number}
89
158
  */
@@ -95,6 +164,22 @@ function compute_aviato_point(random) {
95
164
  }
96
165
  exports.compute_aviato_point = compute_aviato_point;
97
166
 
167
+ /**
168
+ * Extract crash point (×100) from raw server seed fields.
169
+ *
170
+ * `random` must be exactly 4 elements (first 4 fields of server_seed).
171
+ * Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
172
+ * @param {BigUint64Array} random
173
+ * @returns {number}
174
+ */
175
+ function compute_crash_point(random) {
176
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
177
+ const len0 = WASM_VECTOR_LEN;
178
+ const ret = wasm.compute_crash_point(ptr0, len0);
179
+ return ret >>> 0;
180
+ }
181
+ exports.compute_crash_point = compute_crash_point;
182
+
98
183
  /**
99
184
  * Extract the 10 drawn numbers from Poseidon2 random output using
100
185
  * the combinatorial number system: `combo_index = random[0] % C(40,10)`.
@@ -136,15 +221,7 @@ function compute_multi_dice(win_numbers) {
136
221
  exports.compute_multi_dice = compute_multi_dice;
137
222
 
138
223
  /**
139
- * Full aviato payout computation — pure integer arithmetic, zero floats.
140
- *
141
- * `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
142
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
143
- * `cashout_x100`: multiplier at which the user cashed out (×100).
144
- * - 0 = user did NOT cash out (loss).
145
- * - 100..=1_000_000 = user stopped at this multiplier.
146
- *
147
- * Returns `BigUint64Array[4]`: `[win_amount, aviato_x100, is_win (0|1), multiplier×10000]`.
224
+ * Backward-compatible alias for `compute_payout_crash`.
148
225
  * @param {BigUint64Array} random
149
226
  * @param {bigint} bet_atomic
150
227
  * @param {number} cashout_x100
@@ -197,6 +274,38 @@ function compute_payout_coinflip(random, bet_atomic, prediction) {
197
274
  }
198
275
  exports.compute_payout_coinflip = compute_payout_coinflip;
199
276
 
277
+ /**
278
+ * Full crash payout computation — pure integer arithmetic, zero floats.
279
+ *
280
+ * `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
281
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
282
+ * `cashout_x100`: multiplier at which the user cashed out (×100).
283
+ * - 0 = user did NOT cash out (loss).
284
+ * - 100..=1_000_000 = user stopped at this multiplier.
285
+ *
286
+ * Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
287
+ * @param {BigUint64Array} random
288
+ * @param {bigint} bet_atomic
289
+ * @param {number} cashout_x100
290
+ * @returns {BigUint64Array}
291
+ */
292
+ function compute_payout_crash(random, bet_atomic, cashout_x100) {
293
+ try {
294
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
295
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
296
+ const len0 = WASM_VECTOR_LEN;
297
+ wasm.compute_payout_crash(retptr, ptr0, len0, bet_atomic, cashout_x100);
298
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
299
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
300
+ var v2 = getArrayU64FromWasm0(r0, r1).slice();
301
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
302
+ return v2;
303
+ } finally {
304
+ wasm.__wbindgen_add_to_stack_pointer(16);
305
+ }
306
+ }
307
+ exports.compute_payout_crash = compute_payout_crash;
308
+
200
309
  /**
201
310
  * Full dice payout computation — pure integer arithmetic, zero floats.
202
311
  *
@@ -519,6 +628,16 @@ function compute_user_seed_binding(game_id, bet, pred_hash, secret) {
519
628
  }
520
629
  exports.compute_user_seed_binding = compute_user_seed_binding;
521
630
 
631
+ /**
632
+ * Crash RTP percent (99). Canonical source for backend/frontend.
633
+ * @returns {number}
634
+ */
635
+ function crash_rtp_percent() {
636
+ const ret = wasm.aviato_rtp_percent();
637
+ return ret >>> 0;
638
+ }
639
+ exports.crash_rtp_percent = crash_rtp_percent;
640
+
522
641
  /**
523
642
  * Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
524
643
  *
Binary file
@@ -3,13 +3,17 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const amount_split: (a: number, b: bigint) => void;
5
5
  export const aviato_rtp_percent: () => number;
6
+ export const blackjack_deal_shoe: (a: number, b: number, c: number, d: number, e: number) => void;
7
+ export const blackjack_pack_actions: (a: number, b: number, c: number) => void;
6
8
  export const coinflip_multiplier_x10000: () => number;
7
9
  export const compute_address_hash: (a: number, b: number, c: number) => void;
8
10
  export const compute_aviato_point: (a: number, b: number) => number;
11
+ export const compute_crash_point: (a: number, b: number) => number;
9
12
  export const compute_drawn_keno: (a: number, b: number, c: number) => void;
10
13
  export const compute_multi_dice: (a: number) => bigint;
11
14
  export const compute_payout_aviato: (a: number, b: number, c: number, d: bigint, e: number) => void;
12
15
  export const compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
16
+ export const compute_payout_crash: (a: number, b: number, c: number, d: bigint, e: number) => void;
13
17
  export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
14
18
  export const compute_payout_keno: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
15
19
  export const compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number) => void;
@@ -53,6 +57,7 @@ export const string_to_user_seed: (a: number, b: number, c: number) => void;
53
57
  export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
54
58
  export const validate_slot: (a: number, b: number) => void;
55
59
  export const coinflip_rtp_percent: () => number;
60
+ export const crash_rtp_percent: () => number;
56
61
  export const dice_rtp_percent: () => number;
57
62
  export const keno_max_picks: () => number;
58
63
  export const goldilocks_modulus: () => bigint;
@@ -0,0 +1,148 @@
1
+ # @rolly-dev/wasm-signer
2
+
3
+ Client-side Poseidon2 hashing and bet authentication for the Rolly ZK-Rollup casino.
4
+
5
+ Built with Rust → WebAssembly (via `wasm-pack`), using the same Poseidon2 hasher
6
+ and Goldilocks field as the plonky2 proving circuit.
7
+
8
+ ## Build
9
+
10
+ ```bash
11
+ # requires: cargo, wasm-pack
12
+ npm run build
13
+ # → dist/node/ (Node.js, CJS, sync init)
14
+ # → dist/web/ (Browser, ESM, async init)
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Node.js (CommonJS)
20
+
21
+ ```javascript
22
+ const {
23
+ poseidon2_hash,
24
+ derive_session_key,
25
+ session_public_key,
26
+ } = require('@rolly-dev/wasm-signer');
27
+
28
+ const hash = poseidon2_hash(BigUint64Array.from([1n, 2n, 3n]));
29
+ // → BigUint64Array(4)
30
+ ```
31
+
32
+ ### Node.js (ESM)
33
+
34
+ ```javascript
35
+ import {
36
+ poseidon2_hash,
37
+ derive_session_key,
38
+ session_public_key,
39
+ } from '@rolly-dev/wasm-signer';
40
+
41
+ const sessionKey = derive_session_key(metamaskSignatureBytes);
42
+ const pkHash = session_public_key(sessionKey, BigInt(expiryTimestamp));
43
+ ```
44
+
45
+ ### React
46
+
47
+ ```jsx
48
+ import { useRollyWasm } from '@rolly-dev/wasm-signer/react';
49
+
50
+ function SessionInfo({ sessionKey, expiry }) {
51
+ const { ready, session_public_key } = useRollyWasm();
52
+
53
+ if (!ready) return <span>Loading...</span>;
54
+
55
+ const pkHash = session_public_key(sessionKey, BigInt(expiry));
56
+ // register pkHash on-chain via key_register tx...
57
+
58
+ return <div>Session active until {new Date(Number(expiry) * 1000).toLocaleString()}</div>;
59
+ }
60
+ ```
61
+
62
+ ### Browser (vanilla ESM)
63
+
64
+ ```html
65
+ <script type="module">
66
+ import { init, poseidon2_hash } from '@rolly-dev/wasm-signer';
67
+
68
+ await init(); // loads .wasm, must be called once
69
+ const h = poseidon2_hash(BigUint64Array.from([1n, 2n]));
70
+ </script>
71
+ ```
72
+
73
+ ### Manual init (advanced)
74
+
75
+ ```javascript
76
+ import init, { poseidon2_hash } from '@rolly-dev/wasm-signer/init';
77
+
78
+ // custom wasm URL or ArrayBuffer
79
+ await init('/assets/rolly_wasm_signer_bg.wasm');
80
+ poseidon2_hash(BigUint64Array.from([1n]));
81
+ ```
82
+
83
+ ## API
84
+
85
+ | Function | Input | Output | Description |
86
+ |----------------------------|--------------------------------|-------------------|------------------------------------------------|
87
+ | `poseidon2_hash` | `BigUint64Array` | `BigUint64Array(4)` | Hash N field elements |
88
+ | `poseidon2_two_to_one` | `BigUint64Array(4)` × 2 | `BigUint64Array(4)` | Merkle hash: H(left‖right) |
89
+ | `derive_session_key` | `Uint8Array(32)` | `BigUint64Array(4)` | MetaMask sig → session key |
90
+ | `session_public_key` | `(BigUint64Array(4), bigint)` | `BigUint64Array(4)` | pk_hash = Poseidon2(session_key, expiry) |
91
+ | `compute_server_seed_hash` | `BigUint64Array(8)` | `BigUint64Array(4)` | Full hash of server seed |
92
+ | `seed_hash_truncated` | `BigUint64Array(8)` | `BigUint64Array(3)` | First 3 elements (circuit leaf format, 192-bit commitment) |
93
+ | `goldilocks_modulus` | — | `bigint` | Returns p = 2^64 - 2^32 + 1 |
94
+ | `goldilocks_reduce` | `bigint` | `bigint` | Reduce mod p |
95
+
96
+ ## Bundler notes
97
+
98
+ **Vite** — add to `optimizeDeps.exclude`:
99
+ ```js
100
+ optimizeDeps: { exclude: ['@rolly-dev/wasm-signer'] }
101
+ ```
102
+
103
+ **Webpack 5** — enable WASM experiments:
104
+ ```js
105
+ module.exports = { experiments: { asyncWebAssembly: true } };
106
+ ```
107
+
108
+ **Next.js** — conditional exports auto-resolve: Node.js entry on server, browser entry on client.
109
+
110
+ ## Dice — range constraints
111
+
112
+ Roll number: `[0, 999]` (TOTAL_RANGE = 1000).
113
+ win_numbers (wn): `[1, 950]` (MIN_RANGE..=MAX_RANGE).
114
+
115
+ ### prediction_range constraints per mode
116
+
117
+ | Mode | wn formula | prediction\[0\] | prediction\[1\] | wn range |
118
+ |-------|-------------------------------------------------|-----------------|-----------------|------------|
119
+ | Under | `prediction[0]` | `[1, 950]` | unused (0) | `[1, 950]` |
120
+ | Over | `999 − prediction[0]` | `[49, 998]` | unused (0) | `[1, 950]` |
121
+ | In | `prediction[1] − prediction[0] + 1` | `[0, 999]` | `[0, 999]` | `[1, 950]` |
122
+ | Out | `1000 − (prediction[1] − prediction[0] + 1)` | `[0, 999]` | `[0, 999]` | `[1, 950]` |
123
+
124
+ **Under** — `prediction[0]` ∈ `[1, 950]` (= wn directly). Win: `roll < prediction[0]`.
125
+
126
+ **Over** — `prediction[0]` ∈ `[49, 998]` (lower: `999 − 950 = 49`, upper: `999 − 1 = 998`). Win: `roll > prediction[0]`.
127
+
128
+ **In** — `prediction[0] <= prediction[1]`, span ∈ `[1, 950]`. Win: `prediction[0] <= roll <= prediction[1]`.
129
+
130
+ **Out** — `prediction[0] <= prediction[1]`, inner span ∈ `[50, 999]` (wn = `1000 − inner` ∈ `[1, 950]`). Win: `roll < prediction[0] || roll > prediction[1]`.
131
+
132
+ ### Multiplier
133
+
134
+ `multiplier = floor(9_900_000 / wn)` (scaled ×10000).
135
+
136
+ | wn | multiplier | display |
137
+ |-----|-----------|-----------|
138
+ | 1 | 9_900_000 | 990.0000x |
139
+ | 500 | 19_800 | 1.9800x |
140
+ | 950 | 10_421 | 1.0421x |
141
+
142
+ ### RTP
143
+
144
+ Theoretical: **98.998%** (floor-division costs ~0.002%). House edge: **~1.002%**. Max win cap: 10,000 USDT (business rule, not formula).
145
+
146
+ ## License
147
+
148
+ MIT
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}