shufflecom-calculations 6.0.0 → 6.1.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.
- package/lib/airdrop/airdrop-calculator.d.ts +0 -1
- package/lib/airdrop/airdrop-calculator.js +0 -3
- package/lib/airdrop/airdrop-calculator.js.map +1 -1
- package/lib/fiat-document/index.d.ts +0 -13
- package/lib/fiat-document/index.js +1 -82
- package/lib/fiat-document/index.js.map +1 -1
- package/lib/regex/index.d.ts +0 -3
- package/lib/regex/index.js +1 -4
- package/lib/regex/index.js.map +1 -1
- package/lib/sports/calculate-sports-payout-odds.d.ts +1 -12
- package/lib/sports/calculate-sports-payout-odds.js +1 -63
- package/lib/sports/calculate-sports-payout-odds.js.map +1 -1
- package/lib/sports/sports.types.d.ts +3 -2
- package/lib/sports/sports.types.js +1 -0
- package/lib/sports/sports.types.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/src/airdrop/airdrop-calculator.ts +0 -4
- package/src/fiat-document/index.ts +0 -97
- package/src/regex/index.ts +0 -7
- package/src/regex/regex.spec.ts +0 -20
- package/src/sports/calculate-sports-payout-odd.spec.ts +101 -110
- package/src/sports/calculate-sports-payout-odds.ts +1 -98
- package/src/sports/sports.types.ts +2 -3
- package/src/fiat-document/fiat-document.spec.ts +0 -137
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shufflecom-calculations",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -12,10 +12,9 @@
|
|
|
12
12
|
"bignumber.js": "^11.x",
|
|
13
13
|
"bs58": "^6.0.0",
|
|
14
14
|
"dayjs": "^1.x",
|
|
15
|
-
"lodash": "^4.x"
|
|
16
|
-
"stdnum": "^1.12.6"
|
|
15
|
+
"lodash": "^4.x"
|
|
17
16
|
},
|
|
18
17
|
"author": "",
|
|
19
18
|
"license": "ISC",
|
|
20
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "cf8a037f371d7155f6aa0d69c936ba0e8e54d2d8"
|
|
21
20
|
}
|
|
@@ -96,10 +96,6 @@ export class AirdropCalculator {
|
|
|
96
96
|
return dayjs(distributionDate).subtract(1, 'week').add(1, 'minute').toDate();
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
static hasNextEventStarted(distributionDate: Date): boolean {
|
|
100
|
-
return dayjs.utc().isAfter(dayjs.utc(distributionDate).add(1, 'minute'));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
99
|
/**
|
|
104
100
|
* @decription calculates the points without limit on decimal places
|
|
105
101
|
* @note: default round down to 2 decimal places
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import * as arCuit from 'stdnum/lib/cjs/ar/cuit';
|
|
2
|
-
import * as brCpf from 'stdnum/lib/cjs/br/cpf';
|
|
3
|
-
import * as mxCurp from 'stdnum/lib/cjs/mx/curp';
|
|
4
|
-
import { CPF_REGEX, CUIL_CUIT_REGEX, CURP_REGEX } from '../regex';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Government-issued documents collected for fiat payments.
|
|
8
3
|
*/
|
|
@@ -11,95 +6,3 @@ export enum FiatDocumentType {
|
|
|
11
6
|
CURP = 'CURP',
|
|
12
7
|
CUIL_CUIT = 'CUIL_CUIT',
|
|
13
8
|
}
|
|
14
|
-
|
|
15
|
-
export type FiatDocumentColumn = 'cpf' | 'curp' | 'cuilCuit';
|
|
16
|
-
|
|
17
|
-
export type FiatDocumentSpec = {
|
|
18
|
-
/** Column on user_fiat_information holding this document. */
|
|
19
|
-
column: FiatDocumentColumn;
|
|
20
|
-
pattern: RegExp;
|
|
21
|
-
/** Strips separators and upper-cases. */
|
|
22
|
-
compact: (value: string) => string;
|
|
23
|
-
/** Opposite of compact */
|
|
24
|
-
format: (value: string) => string;
|
|
25
|
-
/**
|
|
26
|
-
* Issuer check-digit validation of the compacted value, applied on top of `pattern`.
|
|
27
|
-
*/
|
|
28
|
-
checksum?: (value: string) => boolean;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Repeated digits pass the CPF checksum but must be explicitly rejected
|
|
33
|
-
* https://lookuptax.com/docs/how-to-verify/cpf-verification-brazil
|
|
34
|
-
*/
|
|
35
|
-
const CPF_REPEATED_DIGITS = /^(\d)\1+$/;
|
|
36
|
-
|
|
37
|
-
function hasValidCpfCheckDigit(value: string): boolean {
|
|
38
|
-
return !CPF_REPEATED_DIGITS.test(value) && brCpf.validate(value).isValid;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* AFIP's CUIT check digit, computed here rather than via stdnum due to some algorithm updates.
|
|
43
|
-
* https://lookuptax.com/docs/tax-identification-number/argentina-tax-id-guide
|
|
44
|
-
*/
|
|
45
|
-
const CUIT_WEIGHTS = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
|
|
46
|
-
|
|
47
|
-
function hasValidCuitCheckDigit(value: string): boolean {
|
|
48
|
-
if (value.slice(2, 10) === '00000000') return false;
|
|
49
|
-
|
|
50
|
-
const sum = CUIT_WEIGHTS.reduce((acc, weight, index) => acc + Number(value[index]) * weight, 0);
|
|
51
|
-
const remainder = 11 - (sum % 11);
|
|
52
|
-
const expected = remainder === 11 ? 0 : remainder === 10 ? 9 : remainder;
|
|
53
|
-
return expected === Number(value[10]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* One row per government-issued document we collect. Adding a fiat currency that needs a new
|
|
58
|
-
* document means adding a FiatDocumentType, a column, and a row here — nothing else branches
|
|
59
|
-
* per country.
|
|
60
|
-
*/
|
|
61
|
-
export const FIAT_DOCUMENT_SPECS: Record<FiatDocumentType, FiatDocumentSpec> = {
|
|
62
|
-
[FiatDocumentType.CPF]: {
|
|
63
|
-
column: 'cpf',
|
|
64
|
-
pattern: CPF_REGEX,
|
|
65
|
-
compact: brCpf.compact,
|
|
66
|
-
format: brCpf.format,
|
|
67
|
-
checksum: hasValidCpfCheckDigit,
|
|
68
|
-
},
|
|
69
|
-
[FiatDocumentType.CURP]: {
|
|
70
|
-
column: 'curp',
|
|
71
|
-
pattern: CURP_REGEX,
|
|
72
|
-
compact: mxCurp.compact,
|
|
73
|
-
format: mxCurp.format,
|
|
74
|
-
checksum: value => mxCurp.validate(value).isValid,
|
|
75
|
-
},
|
|
76
|
-
[FiatDocumentType.CUIL_CUIT]: {
|
|
77
|
-
column: 'cuilCuit',
|
|
78
|
-
pattern: CUIL_CUIT_REGEX,
|
|
79
|
-
compact: arCuit.compact,
|
|
80
|
-
format: arCuit.format,
|
|
81
|
-
checksum: hasValidCuitCheckDigit,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const DOCUMENT_TYPE_TO_COLUMN: Record<FiatDocumentType, FiatDocumentColumn> = Object.fromEntries(
|
|
86
|
-
Object.entries(FIAT_DOCUMENT_SPECS).map(([type, spec]) => [type, spec.column]),
|
|
87
|
-
) as Record<FiatDocumentType, FiatDocumentColumn>;
|
|
88
|
-
|
|
89
|
-
const SPEC_BY_COLUMN = new Map<FiatDocumentColumn, FiatDocumentSpec>(Object.values(FIAT_DOCUMENT_SPECS).map(spec => [spec.column, spec]));
|
|
90
|
-
|
|
91
|
-
export function isFiatDocumentValid(documentType: FiatDocumentType, value: string): boolean {
|
|
92
|
-
const { pattern, compact, checksum } = FIAT_DOCUMENT_SPECS[documentType];
|
|
93
|
-
const canonical = compact(value);
|
|
94
|
-
return pattern.test(canonical) && (!checksum || checksum(canonical));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function compactFiatDocument(column: string, value: string): string {
|
|
98
|
-
const spec = SPEC_BY_COLUMN.get(column as FiatDocumentColumn);
|
|
99
|
-
return spec ? spec.compact(value) : value;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function formatFiatDocument(column: string, value: string): string {
|
|
103
|
-
const spec = SPEC_BY_COLUMN.get(column as FiatDocumentColumn);
|
|
104
|
-
return spec ? spec.format(value) : value;
|
|
105
|
-
}
|
package/src/regex/index.ts
CHANGED
|
@@ -25,10 +25,3 @@ export const NO_INVISIBLE_CHAR_REGEX = /^[^\u2800\uFFA0\u115F\u1160\u3164]*$/;
|
|
|
25
25
|
export const US_PHONE_NUMBER_REGEX = /^\+1\d{10}$/;
|
|
26
26
|
// E.164 international phone number: leading +, first digit 1-9, total 7-15 digits
|
|
27
27
|
export const E164_PHONE_NUMBER_REGEX = /^\+[1-9]\d{6,14}$/;
|
|
28
|
-
// Brazilian CPF (digits only, no formatting)
|
|
29
|
-
export const CPF_REGEX = /^\d{11}$/;
|
|
30
|
-
// Mexican CURP (18 alphanumeric chars)
|
|
31
|
-
export const CURP_REGEX = /^[A-Z0-9]{18}$/i;
|
|
32
|
-
// Argentine CUIL/CUIT: 11 digits, no formatting, leading with a valid person/entity
|
|
33
|
-
// prefix (20-27 individuals, 30/33/34 legal entities)
|
|
34
|
-
export const CUIL_CUIT_REGEX = /^(20|23|24|25|26|27|30|33|34)\d{9}$/;
|
package/src/regex/regex.spec.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ADDRESS_URL_REGEX,
|
|
3
|
-
CUIL_CUIT_REGEX,
|
|
4
3
|
HEX_COLOR_CODE_REGEX,
|
|
5
4
|
NO_INVISIBLE_CHAR_REGEX,
|
|
6
5
|
PROMOTION_CODE_REGEX,
|
|
@@ -12,25 +11,6 @@ import {
|
|
|
12
11
|
} from '.';
|
|
13
12
|
|
|
14
13
|
describe('regex', () => {
|
|
15
|
-
describe('CUIL_CUIT_REGEX', () => {
|
|
16
|
-
it('accepts 11 digits with a valid individual or entity prefix', () => {
|
|
17
|
-
expect(CUIL_CUIT_REGEX.test('20123456789')).toBe(true);
|
|
18
|
-
expect(CUIL_CUIT_REGEX.test('27123456789')).toBe(true);
|
|
19
|
-
expect(CUIL_CUIT_REGEX.test('30123456789')).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('rejects an invalid leading prefix', () => {
|
|
23
|
-
expect(CUIL_CUIT_REGEX.test('19123456789')).toBe(false);
|
|
24
|
-
expect(CUIL_CUIT_REGEX.test('28123456789')).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('rejects wrong length or non-digits', () => {
|
|
28
|
-
expect(CUIL_CUIT_REGEX.test('2012345678')).toBe(false); // 10 digits
|
|
29
|
-
expect(CUIL_CUIT_REGEX.test('201234567890')).toBe(false); // 12 digits
|
|
30
|
-
expect(CUIL_CUIT_REGEX.test('20-12345678-9')).toBe(false); // formatted
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
14
|
describe('PWD_REGEX', () => {
|
|
35
15
|
it('should not allow passwords with less than 8 characters', () => {
|
|
36
16
|
expect(PWD_REGEX.test('abcdef1')).toBe(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import {
|
|
2
|
+
import { calculateSportsPayoutOddsFromLegs, getSystemBetSubBetLegs } from './calculate-sports-payout-odds';
|
|
3
3
|
import {
|
|
4
4
|
OutcomeResult,
|
|
5
5
|
SportsBetLegInterface,
|
|
@@ -20,6 +20,7 @@ const createSelection = (
|
|
|
20
20
|
oddsDenominator: number,
|
|
21
21
|
): SportsBetSelectionInterface => ({
|
|
22
22
|
marketSelectionId,
|
|
23
|
+
sportsBetLegId: 'leg-1',
|
|
23
24
|
status,
|
|
24
25
|
oddsNumerator: new BigNumber(oddsNumerator),
|
|
25
26
|
oddsDenominator: new BigNumber(oddsDenominator),
|
|
@@ -45,16 +46,30 @@ const createMarketSelection = (
|
|
|
45
46
|
provider: SportsMarketProvider.GENIUS,
|
|
46
47
|
});
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
// A regular bet is one REGULAR leg per selection, carrying that selection's own odds
|
|
50
|
+
const toRegularLegs = (selections: SportsBetSelectionInterface[]): SportsBetLegInterface[] =>
|
|
51
|
+
selections.map(selection => ({
|
|
52
|
+
type: SportsBetLegType.REGULAR,
|
|
53
|
+
oddsDecimal: selection.oddsNumerator.dividedBy(selection.oddsDenominator).plus(1),
|
|
54
|
+
selections: [selection],
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
// A custom bet leg carries its own combined odds and holds every selection in the combination
|
|
58
|
+
const toCustomLeg = (oddsDecimal: BigNumber, selections: SportsBetSelectionInterface[]): SportsBetLegInterface => ({
|
|
59
|
+
type: SportsBetLegType.CUSTOM,
|
|
60
|
+
oddsDecimal,
|
|
61
|
+
selections,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('calculateSportsPayoutOddsFromLegs', () => {
|
|
49
65
|
describe('regular bet', () => {
|
|
50
66
|
describe('all selections won', () => {
|
|
51
67
|
it('should calculate correct payout odds for single selection', () => {
|
|
52
68
|
const selections = [createSelection('sel1', SportsBetSelectionStatus.WON, 150, 100)];
|
|
53
69
|
const marketSelections = [createMarketSelection('sel1', 150, 100)];
|
|
54
70
|
|
|
55
|
-
const result =
|
|
56
|
-
|
|
57
|
-
subBetSelections: null,
|
|
71
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
72
|
+
subBetLegs: null,
|
|
58
73
|
isEstimation: false,
|
|
59
74
|
});
|
|
60
75
|
|
|
@@ -74,9 +89,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
74
89
|
createMarketSelection('sel3', 100, 100),
|
|
75
90
|
];
|
|
76
91
|
|
|
77
|
-
const result =
|
|
78
|
-
|
|
79
|
-
subBetSelections: null,
|
|
92
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
93
|
+
subBetLegs: null,
|
|
80
94
|
isEstimation: false,
|
|
81
95
|
});
|
|
82
96
|
|
|
@@ -93,9 +107,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
93
107
|
];
|
|
94
108
|
const marketSelections = [createMarketSelection('sel1', 150, 100), createMarketSelection('sel2', 200, 100)];
|
|
95
109
|
|
|
96
|
-
const result =
|
|
97
|
-
|
|
98
|
-
subBetSelections: null,
|
|
110
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
111
|
+
subBetLegs: null,
|
|
99
112
|
isEstimation: false,
|
|
100
113
|
});
|
|
101
114
|
|
|
@@ -109,9 +122,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
109
122
|
];
|
|
110
123
|
const marketSelections = [createMarketSelection('sel1', 150, 100), createMarketSelection('sel2', 200, 100)];
|
|
111
124
|
|
|
112
|
-
const result =
|
|
113
|
-
|
|
114
|
-
subBetSelections: null,
|
|
125
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
126
|
+
subBetLegs: null,
|
|
115
127
|
isEstimation: false,
|
|
116
128
|
});
|
|
117
129
|
|
|
@@ -132,9 +144,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
132
144
|
createMarketSelection('sel3', 100, 100),
|
|
133
145
|
];
|
|
134
146
|
|
|
135
|
-
const result =
|
|
136
|
-
|
|
137
|
-
subBetSelections: null,
|
|
147
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
148
|
+
subBetLegs: null,
|
|
138
149
|
isEstimation: false,
|
|
139
150
|
});
|
|
140
151
|
|
|
@@ -149,9 +160,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
149
160
|
];
|
|
150
161
|
const marketSelections = [createMarketSelection('sel1', 150, 100), createMarketSelection('sel2', 200, 100)];
|
|
151
162
|
|
|
152
|
-
const result =
|
|
153
|
-
|
|
154
|
-
subBetSelections: null,
|
|
163
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
164
|
+
subBetLegs: null,
|
|
155
165
|
isEstimation: false,
|
|
156
166
|
});
|
|
157
167
|
|
|
@@ -168,9 +178,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
168
178
|
];
|
|
169
179
|
const marketSelections = [createMarketSelection('sel1', 150, 100), createMarketSelection('sel2', 200, 100)];
|
|
170
180
|
|
|
171
|
-
const result =
|
|
172
|
-
|
|
173
|
-
subBetSelections: null,
|
|
181
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
182
|
+
subBetLegs: null,
|
|
174
183
|
isEstimation: false,
|
|
175
184
|
});
|
|
176
185
|
|
|
@@ -193,9 +202,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
193
202
|
}),
|
|
194
203
|
];
|
|
195
204
|
|
|
196
|
-
const result =
|
|
197
|
-
|
|
198
|
-
subBetSelections: null,
|
|
205
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
206
|
+
subBetLegs: null,
|
|
199
207
|
isEstimation: false,
|
|
200
208
|
});
|
|
201
209
|
|
|
@@ -218,9 +226,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
218
226
|
}),
|
|
219
227
|
];
|
|
220
228
|
|
|
221
|
-
const result =
|
|
222
|
-
|
|
223
|
-
subBetSelections: null,
|
|
229
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
230
|
+
subBetLegs: null,
|
|
224
231
|
isEstimation: false,
|
|
225
232
|
});
|
|
226
233
|
|
|
@@ -243,9 +250,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
243
250
|
}),
|
|
244
251
|
];
|
|
245
252
|
|
|
246
|
-
const result =
|
|
247
|
-
|
|
248
|
-
subBetSelections: null,
|
|
253
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
254
|
+
subBetLegs: null,
|
|
249
255
|
isEstimation: false,
|
|
250
256
|
});
|
|
251
257
|
|
|
@@ -267,9 +273,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
267
273
|
}),
|
|
268
274
|
];
|
|
269
275
|
|
|
270
|
-
const result =
|
|
271
|
-
|
|
272
|
-
subBetSelections: null,
|
|
276
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
277
|
+
subBetLegs: null,
|
|
273
278
|
isEstimation: false,
|
|
274
279
|
});
|
|
275
280
|
|
|
@@ -293,9 +298,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
293
298
|
}),
|
|
294
299
|
];
|
|
295
300
|
|
|
296
|
-
const result =
|
|
297
|
-
|
|
298
|
-
subBetSelections: null,
|
|
301
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
302
|
+
subBetLegs: null,
|
|
299
303
|
isEstimation: false,
|
|
300
304
|
});
|
|
301
305
|
|
|
@@ -312,9 +316,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
312
316
|
];
|
|
313
317
|
const marketSelections = [createMarketSelection('sel1', 100, 100), createMarketSelection('sel2', 200, 100)];
|
|
314
318
|
|
|
315
|
-
const result =
|
|
316
|
-
|
|
317
|
-
subBetSelections: null,
|
|
319
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
320
|
+
subBetLegs: null,
|
|
318
321
|
isEstimation: false,
|
|
319
322
|
});
|
|
320
323
|
|
|
@@ -336,9 +339,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
336
339
|
winProbability: 0.7,
|
|
337
340
|
};
|
|
338
341
|
|
|
339
|
-
const result =
|
|
340
|
-
|
|
341
|
-
subBetSelections: null,
|
|
342
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
343
|
+
subBetLegs: null,
|
|
342
344
|
isEstimation: false,
|
|
343
345
|
});
|
|
344
346
|
|
|
@@ -358,9 +360,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
358
360
|
halfWinProbability: 0.5,
|
|
359
361
|
};
|
|
360
362
|
|
|
361
|
-
const result =
|
|
362
|
-
|
|
363
|
-
subBetSelections: null,
|
|
363
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
364
|
+
subBetLegs: null,
|
|
364
365
|
isEstimation: false,
|
|
365
366
|
});
|
|
366
367
|
|
|
@@ -379,9 +380,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
379
380
|
halfLoseProbability: 0.4,
|
|
380
381
|
};
|
|
381
382
|
|
|
382
|
-
const result =
|
|
383
|
-
|
|
384
|
-
subBetSelections: null,
|
|
383
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
384
|
+
subBetLegs: null,
|
|
385
385
|
isEstimation: false,
|
|
386
386
|
});
|
|
387
387
|
|
|
@@ -400,9 +400,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
400
400
|
refundProbability: 0.3,
|
|
401
401
|
};
|
|
402
402
|
|
|
403
|
-
const result =
|
|
404
|
-
|
|
405
|
-
subBetSelections: null,
|
|
403
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
404
|
+
subBetLegs: null,
|
|
406
405
|
isEstimation: false,
|
|
407
406
|
});
|
|
408
407
|
|
|
@@ -418,9 +417,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
418
417
|
];
|
|
419
418
|
const marketSelections = [createMarketSelection('sel1', 100, 100), createMarketSelection('sel2', 200, 100, 0.6)];
|
|
420
419
|
|
|
421
|
-
const result =
|
|
422
|
-
|
|
423
|
-
subBetSelections: null,
|
|
420
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
421
|
+
subBetLegs: null,
|
|
424
422
|
isEstimation: false,
|
|
425
423
|
});
|
|
426
424
|
|
|
@@ -439,9 +437,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
439
437
|
createMarketSelection('sel2', 200, 100), // current odds different from bet odds
|
|
440
438
|
];
|
|
441
439
|
|
|
442
|
-
const result =
|
|
443
|
-
|
|
444
|
-
subBetSelections: null,
|
|
440
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
441
|
+
subBetLegs: null,
|
|
445
442
|
isEstimation: false,
|
|
446
443
|
});
|
|
447
444
|
|
|
@@ -462,9 +459,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
462
459
|
winProbability: 0.8,
|
|
463
460
|
};
|
|
464
461
|
|
|
465
|
-
const result =
|
|
466
|
-
|
|
467
|
-
subBetSelections: null,
|
|
462
|
+
const result = calculateSportsPayoutOddsFromLegs(toRegularLegs(selections), marketSelections, {
|
|
463
|
+
subBetLegs: null,
|
|
468
464
|
isEstimation: false,
|
|
469
465
|
});
|
|
470
466
|
|
|
@@ -485,9 +481,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
485
481
|
|
|
486
482
|
const customOdds = new BigNumber(5.5);
|
|
487
483
|
|
|
488
|
-
const result =
|
|
489
|
-
|
|
490
|
-
subBetSelections: null,
|
|
484
|
+
const result = calculateSportsPayoutOddsFromLegs([toCustomLeg(customOdds, selections)], marketSelections, {
|
|
485
|
+
subBetLegs: null,
|
|
491
486
|
isEstimation: false,
|
|
492
487
|
});
|
|
493
488
|
|
|
@@ -503,9 +498,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
503
498
|
|
|
504
499
|
const customOdds = new BigNumber(5.5);
|
|
505
500
|
|
|
506
|
-
const result =
|
|
507
|
-
|
|
508
|
-
subBetSelections: null,
|
|
501
|
+
const result = calculateSportsPayoutOddsFromLegs([toCustomLeg(customOdds, selections)], marketSelections, {
|
|
502
|
+
subBetLegs: null,
|
|
509
503
|
isEstimation: false,
|
|
510
504
|
});
|
|
511
505
|
|
|
@@ -521,9 +515,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
521
515
|
|
|
522
516
|
const customOdds = new BigNumber(5.5);
|
|
523
517
|
|
|
524
|
-
const result =
|
|
525
|
-
|
|
526
|
-
subBetSelections: null,
|
|
518
|
+
const result = calculateSportsPayoutOddsFromLegs([toCustomLeg(customOdds, selections)], marketSelections, {
|
|
519
|
+
subBetLegs: null,
|
|
527
520
|
isEstimation: false,
|
|
528
521
|
});
|
|
529
522
|
|
|
@@ -539,9 +532,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
539
532
|
|
|
540
533
|
const customOdds = new BigNumber(5.5);
|
|
541
534
|
|
|
542
|
-
const result =
|
|
543
|
-
|
|
544
|
-
subBetSelections: null,
|
|
535
|
+
const result = calculateSportsPayoutOddsFromLegs([toCustomLeg(customOdds, selections)], marketSelections, {
|
|
536
|
+
subBetLegs: null,
|
|
545
537
|
isEstimation: false,
|
|
546
538
|
});
|
|
547
539
|
|
|
@@ -557,9 +549,8 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
557
549
|
|
|
558
550
|
const customOdds = new BigNumber(5.5);
|
|
559
551
|
|
|
560
|
-
const result =
|
|
561
|
-
|
|
562
|
-
subBetSelections: null,
|
|
552
|
+
const result = calculateSportsPayoutOddsFromLegs([toCustomLeg(customOdds, selections)], marketSelections, {
|
|
553
|
+
subBetLegs: null,
|
|
563
554
|
isEstimation: false,
|
|
564
555
|
});
|
|
565
556
|
|
|
@@ -649,18 +640,18 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
649
640
|
createSelection('sel2', SportsBetSelectionStatus.WON, 22, 100),
|
|
650
641
|
createSelection('sel3', SportsBetSelectionStatus.LOST, 25, 100),
|
|
651
642
|
];
|
|
652
|
-
const
|
|
653
|
-
const
|
|
654
|
-
|
|
643
|
+
const legs = toRegularLegs(selections);
|
|
644
|
+
const subBetLegs = getSystemBetSubBetLegs(legs, SportsSystemBetType.DOUBLES);
|
|
645
|
+
const result = calculateSportsPayoutOddsFromLegs(
|
|
646
|
+
legs,
|
|
655
647
|
[
|
|
656
648
|
createMarketSelection('sel1', 7, 100, 0.934589),
|
|
657
649
|
createMarketSelection('sel2', 22, 100, 0.778984),
|
|
658
650
|
createMarketSelection('sel3', 25, 100, 0.254629),
|
|
659
651
|
],
|
|
660
652
|
{
|
|
661
|
-
|
|
653
|
+
subBetLegs,
|
|
662
654
|
isEstimation: false,
|
|
663
|
-
sportsCustomBetTotalOddsDecimal: null,
|
|
664
655
|
},
|
|
665
656
|
);
|
|
666
657
|
|
|
@@ -680,11 +671,11 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
680
671
|
createMarketSelection('sel3', 200, 100),
|
|
681
672
|
];
|
|
682
673
|
|
|
683
|
-
const
|
|
674
|
+
const selectionsLegs = toRegularLegs(selections);
|
|
675
|
+
const subBetLegs = getSystemBetSubBetLegs(selectionsLegs, SportsSystemBetType.DOUBLES);
|
|
684
676
|
|
|
685
|
-
const result =
|
|
686
|
-
|
|
687
|
-
subBetSelections,
|
|
677
|
+
const result = calculateSportsPayoutOddsFromLegs(selectionsLegs, marketSelections, {
|
|
678
|
+
subBetLegs,
|
|
688
679
|
isEstimation: false,
|
|
689
680
|
});
|
|
690
681
|
|
|
@@ -708,11 +699,11 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
708
699
|
createMarketSelection('sel3', 200, 100),
|
|
709
700
|
];
|
|
710
701
|
|
|
711
|
-
const
|
|
702
|
+
const selectionsLegs = toRegularLegs(selections);
|
|
703
|
+
const subBetLegs = getSystemBetSubBetLegs(selectionsLegs, SportsSystemBetType.DOUBLES);
|
|
712
704
|
|
|
713
|
-
const result =
|
|
714
|
-
|
|
715
|
-
subBetSelections,
|
|
705
|
+
const result = calculateSportsPayoutOddsFromLegs(selectionsLegs, marketSelections, {
|
|
706
|
+
subBetLegs,
|
|
716
707
|
isEstimation: false,
|
|
717
708
|
});
|
|
718
709
|
|
|
@@ -736,11 +727,11 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
736
727
|
createMarketSelection('sel3', 100, 100),
|
|
737
728
|
];
|
|
738
729
|
|
|
739
|
-
const
|
|
730
|
+
const selectionsLegs = toRegularLegs(selections);
|
|
731
|
+
const subBetLegs = getSystemBetSubBetLegs(selectionsLegs, SportsSystemBetType.TRIXIE);
|
|
740
732
|
|
|
741
|
-
const result =
|
|
742
|
-
|
|
743
|
-
subBetSelections,
|
|
733
|
+
const result = calculateSportsPayoutOddsFromLegs(selectionsLegs, marketSelections, {
|
|
734
|
+
subBetLegs,
|
|
744
735
|
isEstimation: false,
|
|
745
736
|
});
|
|
746
737
|
|
|
@@ -763,11 +754,11 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
763
754
|
createMarketSelection('sel3', 150, 100),
|
|
764
755
|
];
|
|
765
756
|
|
|
766
|
-
const
|
|
757
|
+
const selectionsLegs = toRegularLegs(selections);
|
|
758
|
+
const subBetLegs = getSystemBetSubBetLegs(selectionsLegs, SportsSystemBetType.PATENT);
|
|
767
759
|
|
|
768
|
-
const result =
|
|
769
|
-
|
|
770
|
-
subBetSelections,
|
|
760
|
+
const result = calculateSportsPayoutOddsFromLegs(selectionsLegs, marketSelections, {
|
|
761
|
+
subBetLegs,
|
|
771
762
|
isEstimation: false,
|
|
772
763
|
});
|
|
773
764
|
|
|
@@ -795,11 +786,11 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
795
786
|
createMarketSelection('sel3', 150, 100),
|
|
796
787
|
];
|
|
797
788
|
|
|
798
|
-
const
|
|
789
|
+
const selectionsLegs = toRegularLegs(selections);
|
|
790
|
+
const subBetLegs = getSystemBetSubBetLegs(selectionsLegs, SportsSystemBetType.DOUBLES);
|
|
799
791
|
|
|
800
|
-
const result =
|
|
801
|
-
|
|
802
|
-
subBetSelections,
|
|
792
|
+
const result = calculateSportsPayoutOddsFromLegs(selectionsLegs, marketSelections, {
|
|
793
|
+
subBetLegs,
|
|
803
794
|
isEstimation: false,
|
|
804
795
|
});
|
|
805
796
|
|
|
@@ -825,11 +816,11 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
825
816
|
createMarketSelection('sel4', 100, 100),
|
|
826
817
|
];
|
|
827
818
|
|
|
828
|
-
const
|
|
819
|
+
const selectionsLegs = toRegularLegs(selections);
|
|
820
|
+
const subBetLegs = getSystemBetSubBetLegs(selectionsLegs, SportsSystemBetType.YANKEE);
|
|
829
821
|
|
|
830
|
-
const result =
|
|
831
|
-
|
|
832
|
-
subBetSelections,
|
|
822
|
+
const result = calculateSportsPayoutOddsFromLegs(selectionsLegs, marketSelections, {
|
|
823
|
+
subBetLegs,
|
|
833
824
|
isEstimation: false,
|
|
834
825
|
});
|
|
835
826
|
|
|
@@ -853,11 +844,11 @@ describe('calculateSportsPayoutOdds', () => {
|
|
|
853
844
|
createMarketSelection('sel3', 200, 100),
|
|
854
845
|
];
|
|
855
846
|
|
|
856
|
-
const
|
|
847
|
+
const selectionsLegs = toRegularLegs(selections);
|
|
848
|
+
const subBetLegs = getSystemBetSubBetLegs(selectionsLegs, SportsSystemBetType.DOUBLES);
|
|
857
849
|
|
|
858
|
-
const result =
|
|
859
|
-
|
|
860
|
-
subBetSelections,
|
|
850
|
+
const result = calculateSportsPayoutOddsFromLegs(selectionsLegs, marketSelections, {
|
|
851
|
+
subBetLegs,
|
|
861
852
|
isEstimation: false,
|
|
862
853
|
});
|
|
863
854
|
|