@moneypot/hub 1.9.0-dev.12 → 1.9.0-dev.13
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.
|
@@ -7,11 +7,10 @@ export type RiskPolicyArgs = {
|
|
|
7
7
|
maxPotentialPayout: number;
|
|
8
8
|
outcomes: DbOutcome[];
|
|
9
9
|
};
|
|
10
|
-
type
|
|
11
|
-
export type RiskLimits = AtLeastOneKey<{
|
|
10
|
+
export type RiskLimits = {
|
|
12
11
|
maxWager?: number;
|
|
13
|
-
maxPayout
|
|
14
|
-
}
|
|
12
|
+
maxPayout: number;
|
|
13
|
+
};
|
|
15
14
|
export type RiskPolicy = (args: RiskPolicyArgs) => RiskLimits;
|
|
16
15
|
export declare function validateRisk(options: RiskPolicyArgs & {
|
|
17
16
|
riskPolicy: RiskPolicy;
|
|
@@ -19,4 +18,3 @@ export declare function validateRisk(options: RiskPolicyArgs & {
|
|
|
19
18
|
displayUnitName: string;
|
|
20
19
|
displayUnitScale: number;
|
|
21
20
|
}): Result<void, string>;
|
|
22
|
-
export {};
|
package/dist/src/risk-policy.js
CHANGED
|
@@ -4,12 +4,9 @@ import { z } from "zod";
|
|
|
4
4
|
const RiskLimitsSchema = z
|
|
5
5
|
.object({
|
|
6
6
|
maxWager: z.number().positive().optional(),
|
|
7
|
-
maxPayout: z.number().positive()
|
|
7
|
+
maxPayout: z.number().positive(),
|
|
8
8
|
})
|
|
9
|
-
.strict()
|
|
10
|
-
.refine((v) => v.maxWager !== undefined || v.maxPayout !== undefined, {
|
|
11
|
-
message: "Provide at least one of maxWager or maxPayout.",
|
|
12
|
-
});
|
|
9
|
+
.strict();
|
|
13
10
|
export function validateRisk(options) {
|
|
14
11
|
const { wager, bankroll, maxPotentialPayout, riskPolicy } = options;
|
|
15
12
|
if (maxPotentialPayout > bankroll) {
|
|
@@ -48,7 +45,7 @@ export function validateRisk(options) {
|
|
|
48
45
|
})})`,
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
|
-
if (
|
|
48
|
+
if (maxPotentialPayout > limits.maxPayout) {
|
|
52
49
|
return {
|
|
53
50
|
ok: false,
|
|
54
51
|
error: `Payout (${formatCurrency(maxPotentialPayout, {
|