shufflecom-calculations 4.1.2 → 4.1.4-1
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.
- package/lib/games/floor-is-lava-rules.d.ts +19 -5
- package/lib/games/floor-is-lava-rules.js +18 -5
- package/lib/games/floor-is-lava-rules.js.map +1 -1
- package/lib/games/floor-is-lava.d.ts +8 -7
- package/lib/games/floor-is-lava.js +25 -19
- package/lib/games/floor-is-lava.js.map +1 -1
- package/lib/lottery/lottery.d.ts +1 -1
- package/lib/lottery/lottery.js +1 -1
- package/lib/sports/sports.types.d.ts +5 -7
- package/lib/sports/sports.types.js +4 -5
- package/lib/sports/sports.types.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/chain.d.ts +2 -1
- package/lib/utils/chain.js +1 -0
- package/lib/utils/chain.js.map +1 -1
- package/lib/utils/getExternalTxLinkOfChain.js +4 -0
- package/lib/utils/getExternalTxLinkOfChain.js.map +1 -1
- package/package.json +2 -2
- package/src/games/floor-is-lava-rules.spec.ts +30 -4
- package/src/games/floor-is-lava-rules.ts +35 -9
- package/src/games/floor-is-lava.spec.ts +73 -40
- package/src/games/floor-is-lava.ts +34 -19
- package/src/lottery/lottery.ts +1 -1
- package/src/sports/sports.types.ts +6 -9
- package/src/utils/chain.ts +1 -0
- package/src/utils/getExternalTxLinkOfChain.ts +4 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import {
|
|
3
3
|
DIFFICULTY_DROP_MAP,
|
|
4
|
+
FloorIsLavaActionPhase,
|
|
5
|
+
FloorIsLavaBustPickAction,
|
|
4
6
|
FloorIsLavaCashoutAction,
|
|
5
7
|
FloorIsLavaDifficulty,
|
|
6
8
|
FloorIsLavaGameAction,
|
|
7
|
-
FloorIsLavaPickAction,
|
|
8
9
|
FloorIsLavaRules,
|
|
9
10
|
FloorIsLavaStartAction,
|
|
11
|
+
FloorIsLavaSuccessfulPickAction,
|
|
10
12
|
} from './floor-is-lava-rules';
|
|
11
13
|
import { RandomNumberGenerator } from './random-number-generator.interface';
|
|
12
14
|
|
|
@@ -15,7 +17,13 @@ export * from './floor-is-lava-rules';
|
|
|
15
17
|
export type FloorIsLavaNextError = 'tile-already-dropped' | 'no-tiles-remaining' | 'invalid-tile';
|
|
16
18
|
|
|
17
19
|
export type FloorIsLavaNextResult =
|
|
18
|
-
| {
|
|
20
|
+
| {
|
|
21
|
+
ok: true;
|
|
22
|
+
multiplier: BigNumber;
|
|
23
|
+
gameAction: FloorIsLavaSuccessfulPickAction | FloorIsLavaBustPickAction;
|
|
24
|
+
isLoss: boolean;
|
|
25
|
+
isLastTile: boolean;
|
|
26
|
+
}
|
|
19
27
|
| { ok: false; error: FloorIsLavaNextError };
|
|
20
28
|
|
|
21
29
|
export type FloorIsLavaCashoutError = 'no-tiles-selected';
|
|
@@ -24,22 +32,22 @@ export type FloorIsLavaCashoutResult =
|
|
|
24
32
|
| { ok: true; multiplier: BigNumber; gameAction: FloorIsLavaCashoutAction }
|
|
25
33
|
| { ok: false; error: FloorIsLavaCashoutError };
|
|
26
34
|
|
|
27
|
-
export enum
|
|
35
|
+
export enum FloorIsLavaAutoBetRoundOutcome {
|
|
28
36
|
SURVIVED = 'SURVIVED',
|
|
29
37
|
LOST = 'LOST',
|
|
30
38
|
CASHED_OUT = 'CASHED_OUT',
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
export interface
|
|
41
|
+
export interface FloorIsLavaAutoBetRoundResult {
|
|
34
42
|
selectedTile: number;
|
|
35
43
|
droppedTiles: number[];
|
|
36
|
-
outcome:
|
|
44
|
+
outcome: FloorIsLavaAutoBetRoundOutcome;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
export type FloorIsLavaAutoBetError = 'invalid-selected-tiles-count' | 'invalid-tile';
|
|
40
48
|
|
|
41
49
|
export type FloorIsLavaAutoBetResult =
|
|
42
|
-
| { ok: true; multiplier: BigNumber; results:
|
|
50
|
+
| { ok: true; multiplier: BigNumber; results: FloorIsLavaAutoBetRoundResult[]; survivedRounds: number; lastSurvivingTile: number }
|
|
43
51
|
| { ok: false; error: FloorIsLavaAutoBetError };
|
|
44
52
|
|
|
45
53
|
export class FloorIsLava {
|
|
@@ -49,7 +57,7 @@ export class FloorIsLava {
|
|
|
49
57
|
) {}
|
|
50
58
|
|
|
51
59
|
public static createAction(difficulty: FloorIsLavaDifficulty): FloorIsLavaStartAction {
|
|
52
|
-
return { phase:
|
|
60
|
+
return { phase: FloorIsLavaActionPhase.START, difficulty };
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
public static fromActions(gameActions: FloorIsLavaGameAction[]): FloorIsLava {
|
|
@@ -83,21 +91,25 @@ export class FloorIsLava {
|
|
|
83
91
|
const isLastTile = FloorIsLavaRules.tilesRemaining(roundsSurvivedAfter, this.dropsPerRound) <= 1;
|
|
84
92
|
const multiplier = isLoss ? BigNumber(0) : FloorIsLavaRules.multiplier(roundsSurvivedAfter, this.dropsPerRound, edge);
|
|
85
93
|
|
|
94
|
+
const gameAction: FloorIsLavaSuccessfulPickAction | FloorIsLavaBustPickAction = isLoss
|
|
95
|
+
? {
|
|
96
|
+
phase: FloorIsLavaActionPhase.BUST_PICK,
|
|
97
|
+
selectedTile,
|
|
98
|
+
droppedTiles: thisRoundDrops,
|
|
99
|
+
lastSurvivingTile: FloorIsLavaRules.lastSurvivingTile(generator),
|
|
100
|
+
}
|
|
101
|
+
: { phase: FloorIsLavaActionPhase.SUCCESSFUL_PICK, selectedTile, droppedTiles: thisRoundDrops, multiplier };
|
|
102
|
+
|
|
86
103
|
return {
|
|
87
104
|
ok: true,
|
|
88
105
|
multiplier,
|
|
89
|
-
gameAction
|
|
90
|
-
phase: 'PICK',
|
|
91
|
-
selectedTile,
|
|
92
|
-
droppedTiles: thisRoundDrops,
|
|
93
|
-
multiplier,
|
|
94
|
-
},
|
|
106
|
+
gameAction,
|
|
95
107
|
isLoss,
|
|
96
108
|
isLastTile,
|
|
97
109
|
};
|
|
98
110
|
}
|
|
99
111
|
|
|
100
|
-
public cashout(edge: number): FloorIsLavaCashoutResult {
|
|
112
|
+
public cashout(generator: RandomNumberGenerator, edge: number): FloorIsLavaCashoutResult {
|
|
101
113
|
if (!this.canCashout()) {
|
|
102
114
|
return { ok: false, error: 'no-tiles-selected' };
|
|
103
115
|
}
|
|
@@ -107,7 +119,7 @@ export class FloorIsLava {
|
|
|
107
119
|
return {
|
|
108
120
|
ok: true,
|
|
109
121
|
multiplier,
|
|
110
|
-
gameAction: { phase:
|
|
122
|
+
gameAction: { phase: FloorIsLavaActionPhase.CASHOUT, multiplier, lastSurvivingTile: FloorIsLavaRules.lastSurvivingTile(generator) },
|
|
111
123
|
};
|
|
112
124
|
}
|
|
113
125
|
|
|
@@ -130,8 +142,9 @@ export class FloorIsLava {
|
|
|
130
142
|
|
|
131
143
|
const rounds = FloorIsLavaRules.getRoundResults(generator, dropsPerRound, selectedTiles.length);
|
|
132
144
|
|
|
133
|
-
const results:
|
|
145
|
+
const results: FloorIsLavaAutoBetRoundResult[] = [];
|
|
134
146
|
let survivedRounds = 0;
|
|
147
|
+
const lastSurvivingTile = FloorIsLavaRules.lastSurvivingTile(generator);
|
|
135
148
|
|
|
136
149
|
for (let round = 0; round < selectedTiles.length; round++) {
|
|
137
150
|
const selectedTile = selectedTiles[round];
|
|
@@ -141,20 +154,21 @@ export class FloorIsLava {
|
|
|
141
154
|
const priorDrops = results.flatMap(result => result.droppedTiles);
|
|
142
155
|
const isUnselectableDropTile = priorDrops.includes(selectedTile);
|
|
143
156
|
if (isUnselectableDropTile) {
|
|
144
|
-
results.push({ selectedTile, droppedTiles, outcome:
|
|
157
|
+
results.push({ selectedTile, droppedTiles, outcome: FloorIsLavaAutoBetRoundOutcome.CASHED_OUT });
|
|
145
158
|
return {
|
|
146
159
|
ok: true,
|
|
147
160
|
multiplier: FloorIsLavaRules.multiplier(survivedRounds, dropsPerRound, edge),
|
|
148
161
|
results,
|
|
149
162
|
survivedRounds,
|
|
163
|
+
lastSurvivingTile,
|
|
150
164
|
};
|
|
151
165
|
}
|
|
152
166
|
|
|
153
167
|
const isLoss = droppedTiles.includes(selectedTile);
|
|
154
|
-
results.push({ selectedTile, droppedTiles, outcome: isLoss ?
|
|
168
|
+
results.push({ selectedTile, droppedTiles, outcome: isLoss ? FloorIsLavaAutoBetRoundOutcome.LOST : FloorIsLavaAutoBetRoundOutcome.SURVIVED });
|
|
155
169
|
|
|
156
170
|
if (isLoss) {
|
|
157
|
-
return { ok: true, multiplier: BigNumber(0), results, survivedRounds };
|
|
171
|
+
return { ok: true, multiplier: BigNumber(0), results, survivedRounds, lastSurvivingTile };
|
|
158
172
|
}
|
|
159
173
|
survivedRounds++;
|
|
160
174
|
}
|
|
@@ -164,6 +178,7 @@ export class FloorIsLava {
|
|
|
164
178
|
multiplier: FloorIsLavaRules.multiplier(survivedRounds, dropsPerRound, edge),
|
|
165
179
|
results,
|
|
166
180
|
survivedRounds,
|
|
181
|
+
lastSurvivingTile,
|
|
167
182
|
};
|
|
168
183
|
}
|
|
169
184
|
}
|
package/src/lottery/lottery.ts
CHANGED
|
@@ -17,7 +17,7 @@ export const LOTTERY_VERSION_RECORD: Record<LotteryVersion, LotteryConfig> = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export class Lottery {
|
|
20
|
-
static readonly version = LotteryVersion.
|
|
20
|
+
static readonly version = LotteryVersion.V1;
|
|
21
21
|
|
|
22
22
|
static getConfig(version: LotteryVersion): LotteryConfig {
|
|
23
23
|
return LOTTERY_VERSION_RECORD[version];
|
|
@@ -638,21 +638,12 @@ export class MarketLayout {
|
|
|
638
638
|
marketDisplayType: SportsMarketDisplayType;
|
|
639
639
|
}
|
|
640
640
|
|
|
641
|
-
export enum MarketInfoVariantKey {
|
|
642
|
-
MAP = 'MAP',
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
export type MapVariant = string;
|
|
646
|
-
|
|
647
641
|
export class BaseDisplayGroup {
|
|
648
642
|
groupKey: string;
|
|
649
643
|
groupName: string;
|
|
650
644
|
groupSortName: string;
|
|
651
645
|
selectionGroups: SelectionGroup[] | null;
|
|
652
646
|
layout: MarketLayout;
|
|
653
|
-
variantData: Nullable<{
|
|
654
|
-
[MarketInfoVariantKey.MAP]?: MapVariant; // used for map market of oddin
|
|
655
|
-
}>;
|
|
656
647
|
is2UpAvailable: boolean;
|
|
657
648
|
}
|
|
658
649
|
|
|
@@ -720,10 +711,16 @@ export class SportsNewMarketOddsUpdate extends SportsMarketOddsBase {
|
|
|
720
711
|
expiryTime: Nullable<Date>;
|
|
721
712
|
}
|
|
722
713
|
|
|
714
|
+
export class SgmSubGroup {
|
|
715
|
+
group: SportsMarketGroup;
|
|
716
|
+
weight: number;
|
|
717
|
+
}
|
|
718
|
+
|
|
723
719
|
export class SportsMarketInfo {
|
|
724
720
|
odds: SportsNewMarketOddsUpdate[];
|
|
725
721
|
display: DisplayGroup[];
|
|
726
722
|
updatedAt: Nullable<Date>;
|
|
723
|
+
sgmSubGroups: Nullable<SgmSubGroup[]>;
|
|
727
724
|
}
|
|
728
725
|
|
|
729
726
|
export class SportsMarketSubInfo extends SportsMarketInfo {
|
package/src/utils/chain.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const TX_LINK_PREFIXES_TESTNET: Record<Chain, string> = {
|
|
|
14
14
|
[Chain.AVAXC]: 'https://testnet.snowtrace.io/tx/{txId}',
|
|
15
15
|
[Chain.ARBITRUM]: 'https://sepolia.arbiscan.io/tx/{txId}',
|
|
16
16
|
[Chain.BASE]: 'https://sepolia.basescan.org/tx/{txId}',
|
|
17
|
+
[Chain.RHC]: 'https://explorer.testnet.chain.robinhood.com/tx/{txId}',
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export const TX_LINK_PREFIXES_MAINNET: Record<Chain, string> = {
|
|
@@ -30,6 +31,7 @@ export const TX_LINK_PREFIXES_MAINNET: Record<Chain, string> = {
|
|
|
30
31
|
[Chain.AVAXC]: 'https://snowtrace.io/tx/{txId}',
|
|
31
32
|
[Chain.ARBITRUM]: 'https://arbiscan.io/tx/{txId}',
|
|
32
33
|
[Chain.BASE]: 'https://basescan.org/tx/{txId}',
|
|
34
|
+
[Chain.RHC]: 'https://robinhoodchain.blockscout.com/{txId}',
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
export const ADDRESS_LINK_PREFIXES_TESTNET: Record<Chain, string> = {
|
|
@@ -46,6 +48,7 @@ export const ADDRESS_LINK_PREFIXES_TESTNET: Record<Chain, string> = {
|
|
|
46
48
|
[Chain.AVAXC]: 'https://testnet.snowtrace.io/address/{address}',
|
|
47
49
|
[Chain.ARBITRUM]: 'https://sepolia.arbiscan.io/address/{address}',
|
|
48
50
|
[Chain.BASE]: 'https://sepolia.basescan.org/address/{address}',
|
|
51
|
+
[Chain.RHC]: 'https://explorer.testnet.chain.robinhood.com/address/{address}',
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
export const ADDRESS_LINK_PREFIXES_MAINNET: Record<Chain, string> = {
|
|
@@ -62,6 +65,7 @@ export const ADDRESS_LINK_PREFIXES_MAINNET: Record<Chain, string> = {
|
|
|
62
65
|
[Chain.AVAXC]: 'https://snowtrace.io/address/{address}',
|
|
63
66
|
[Chain.ARBITRUM]: 'https://arbiscan.io/address/{address}',
|
|
64
67
|
[Chain.BASE]: 'https://basescan.org/address/{address}',
|
|
68
|
+
[Chain.RHC]: 'https://robinhoodchain.blockscout.com/address/{address}',
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
export const getExternalTxLinkOfChain = (txId: string, chain: Chain, isTest: boolean = false) => {
|