@moneypot/hub 1.18.0 → 1.18.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/dist/src/risk-policy.js +10 -10
- package/package.json +1 -1
package/dist/src/risk-policy.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { formatCurrency } from "./format-currency.js";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
const
|
|
3
|
+
const _RiskLimitsSchema = z
|
|
4
4
|
.object({
|
|
5
5
|
maxPayout: z.number().positive(),
|
|
6
6
|
})
|
|
7
7
|
.strict();
|
|
8
8
|
export function validateRisk(options) {
|
|
9
|
-
const {
|
|
10
|
-
if (maxPotentialPayout >
|
|
11
|
-
const message = `
|
|
9
|
+
const { bankroll, maxPotentialPayout } = options;
|
|
10
|
+
if (maxPotentialPayout > options.riskLimits.maxPayout) {
|
|
11
|
+
const message = `Payout (${formatCurrency(maxPotentialPayout, {
|
|
12
12
|
displayUnitName: options.displayUnitName,
|
|
13
13
|
displayUnitScale: options.displayUnitScale,
|
|
14
|
-
})})
|
|
14
|
+
})}) exceeds limit (${formatCurrency(options.riskLimits.maxPayout, {
|
|
15
15
|
displayUnitName: options.displayUnitName,
|
|
16
16
|
displayUnitScale: options.displayUnitScale,
|
|
17
|
-
})}`;
|
|
17
|
+
})})`;
|
|
18
18
|
return {
|
|
19
19
|
ok: false,
|
|
20
20
|
error: { message, riskLimits: options.riskLimits },
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
if (maxPotentialPayout >
|
|
24
|
-
const message = `
|
|
23
|
+
if (maxPotentialPayout > bankroll) {
|
|
24
|
+
const message = `House cannot cover potential payout (${formatCurrency(maxPotentialPayout, {
|
|
25
25
|
displayUnitName: options.displayUnitName,
|
|
26
26
|
displayUnitScale: options.displayUnitScale,
|
|
27
|
-
})})
|
|
27
|
+
})}). Bankroll: ${formatCurrency(bankroll, {
|
|
28
28
|
displayUnitName: options.displayUnitName,
|
|
29
29
|
displayUnitScale: options.displayUnitScale,
|
|
30
|
-
})}
|
|
30
|
+
})}`;
|
|
31
31
|
return {
|
|
32
32
|
ok: false,
|
|
33
33
|
error: { message, riskLimits: options.riskLimits },
|