@the-situation/collateral 0.5.0-alpha.0 → 0.8.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.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Off-chain collateral computation for categorical (multinoulli) distributions.
3
+ *
4
+ * Unlike normal distributions which require Newton-Raphson minimization,
5
+ * categorical distributions use exhaustive O(N) enumeration since outcomes
6
+ * are discrete.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Computes L2 norm for a categorical distribution: sqrt(sum(pi^2))
12
+ *
13
+ * @param probs - The probability vector
14
+ * @returns The L2 norm of the probability vector
15
+ */
16
+ export declare function computeCategoricalL2Norm(probs: readonly number[]): number;
17
+ /**
18
+ * Computes lambda = k / L2Norm for a categorical distribution.
19
+ *
20
+ * @param probs - The probability vector
21
+ * @param k - The scaling parameter
22
+ * @returns The lambda value, or 0 if L2 norm is non-positive
23
+ */
24
+ export declare function computeCategoricalLambda(probs: readonly number[], k: number): number;
25
+ /**
26
+ * Result of categorical collateral computation.
27
+ */
28
+ export interface CategoricalCollateralResult {
29
+ readonly lambdaF: number;
30
+ readonly lambdaG: number;
31
+ readonly minOutcomeIndex: number;
32
+ readonly minDifference: number;
33
+ readonly collateral: number;
34
+ }
35
+ /**
36
+ * Finds the outcome index that minimizes (lambda_g * gi - lambda_f * fi).
37
+ *
38
+ * This is the discrete analogue of the normal distribution's x* (infimum point).
39
+ *
40
+ * @param fProbs - Probability vector of the "from" distribution
41
+ * @param gProbs - Probability vector of the "to" distribution
42
+ * @param lambdaF - Lambda for the "from" distribution
43
+ * @param lambdaG - Lambda for the "to" distribution
44
+ * @returns The index and value of the minimum difference
45
+ */
46
+ export declare function findMinimumOutcome(fProbs: readonly number[], gProbs: readonly number[], lambdaF: number, lambdaG: number): {
47
+ minIndex: number;
48
+ minValue: number;
49
+ };
50
+ /**
51
+ * Computes collateral for trading from distribution f to g in a multinoulli market.
52
+ *
53
+ * Uses exhaustive O(N) scan over all outcomes.
54
+ *
55
+ * @param fProbs - Probability vector of the "from" distribution
56
+ * @param gProbs - Probability vector of the "to" distribution
57
+ * @param k - The scaling parameter
58
+ * @returns The collateral result including lambdas, minimum outcome, and collateral amount
59
+ */
60
+ export declare function computeCategoricalCollateral(fProbs: readonly number[], gProbs: readonly number[], k: number): CategoricalCollateralResult;
61
+ /**
62
+ * Verifies that a claimed minimum outcome index is correct.
63
+ *
64
+ * Used to validate hints before submitting to contract.
65
+ *
66
+ * @param fProbs - Probability vector of the "from" distribution
67
+ * @param gProbs - Probability vector of the "to" distribution
68
+ * @param lambdaF - Lambda for the "from" distribution
69
+ * @param lambdaG - Lambda for the "to" distribution
70
+ * @param claimedMinIndex - The claimed minimum outcome index to verify
71
+ * @param tolerance - Numerical tolerance for comparison (default 1e-12)
72
+ * @returns True if the claimed index is the true minimum
73
+ */
74
+ export declare function verifyCategoricalMinimum(fProbs: readonly number[], gProbs: readonly number[], lambdaF: number, lambdaG: number, claimedMinIndex: number, tolerance?: number): boolean;
75
+ //# sourceMappingURL=compute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../src/categorical/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAMzE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAIpF;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAiBxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,CAAC,EAAE,MAAM,GACR,2BAA2B,CAgB7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,SAAS,GAAE,MAAc,GACxB,OAAO,CAWT"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Off-chain collateral computation for categorical (multinoulli) distributions.
3
+ *
4
+ * Unlike normal distributions which require Newton-Raphson minimization,
5
+ * categorical distributions use exhaustive O(N) enumeration since outcomes
6
+ * are discrete.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Computes L2 norm for a categorical distribution: sqrt(sum(pi^2))
12
+ *
13
+ * @param probs - The probability vector
14
+ * @returns The L2 norm of the probability vector
15
+ */
16
+ export function computeCategoricalL2Norm(probs) {
17
+ let sumSq = 0;
18
+ for (const p of probs) {
19
+ sumSq += p * p;
20
+ }
21
+ return Math.sqrt(sumSq);
22
+ }
23
+ /**
24
+ * Computes lambda = k / L2Norm for a categorical distribution.
25
+ *
26
+ * @param probs - The probability vector
27
+ * @param k - The scaling parameter
28
+ * @returns The lambda value, or 0 if L2 norm is non-positive
29
+ */
30
+ export function computeCategoricalLambda(probs, k) {
31
+ const l2Norm = computeCategoricalL2Norm(probs);
32
+ if (l2Norm <= 0)
33
+ return 0;
34
+ return k / l2Norm;
35
+ }
36
+ /**
37
+ * Finds the outcome index that minimizes (lambda_g * gi - lambda_f * fi).
38
+ *
39
+ * This is the discrete analogue of the normal distribution's x* (infimum point).
40
+ *
41
+ * @param fProbs - Probability vector of the "from" distribution
42
+ * @param gProbs - Probability vector of the "to" distribution
43
+ * @param lambdaF - Lambda for the "from" distribution
44
+ * @param lambdaG - Lambda for the "to" distribution
45
+ * @returns The index and value of the minimum difference
46
+ */
47
+ export function findMinimumOutcome(fProbs, gProbs, lambdaF, lambdaG) {
48
+ if (fProbs.length !== gProbs.length) {
49
+ throw new Error('Distributions must have same number of outcomes');
50
+ }
51
+ let minIdx = 0;
52
+ let minVal = lambdaG * gProbs[0] - lambdaF * fProbs[0];
53
+ for (let i = 1; i < fProbs.length; i++) {
54
+ const diff = lambdaG * gProbs[i] - lambdaF * fProbs[i];
55
+ if (diff < minVal) {
56
+ minVal = diff;
57
+ minIdx = i;
58
+ }
59
+ }
60
+ return { minIndex: minIdx, minValue: minVal };
61
+ }
62
+ /**
63
+ * Computes collateral for trading from distribution f to g in a multinoulli market.
64
+ *
65
+ * Uses exhaustive O(N) scan over all outcomes.
66
+ *
67
+ * @param fProbs - Probability vector of the "from" distribution
68
+ * @param gProbs - Probability vector of the "to" distribution
69
+ * @param k - The scaling parameter
70
+ * @returns The collateral result including lambdas, minimum outcome, and collateral amount
71
+ */
72
+ export function computeCategoricalCollateral(fProbs, gProbs, k) {
73
+ const lambdaF = computeCategoricalLambda(fProbs, k);
74
+ const lambdaG = computeCategoricalLambda(gProbs, k);
75
+ const { minIndex, minValue } = findMinimumOutcome(fProbs, gProbs, lambdaF, lambdaG);
76
+ // Collateral = max(0, -minDifference)
77
+ const collateral = Math.max(0, -minValue);
78
+ return {
79
+ lambdaF,
80
+ lambdaG,
81
+ minOutcomeIndex: minIndex,
82
+ minDifference: minValue,
83
+ collateral,
84
+ };
85
+ }
86
+ /**
87
+ * Verifies that a claimed minimum outcome index is correct.
88
+ *
89
+ * Used to validate hints before submitting to contract.
90
+ *
91
+ * @param fProbs - Probability vector of the "from" distribution
92
+ * @param gProbs - Probability vector of the "to" distribution
93
+ * @param lambdaF - Lambda for the "from" distribution
94
+ * @param lambdaG - Lambda for the "to" distribution
95
+ * @param claimedMinIndex - The claimed minimum outcome index to verify
96
+ * @param tolerance - Numerical tolerance for comparison (default 1e-12)
97
+ * @returns True if the claimed index is the true minimum
98
+ */
99
+ export function verifyCategoricalMinimum(fProbs, gProbs, lambdaF, lambdaG, claimedMinIndex, tolerance = 1e-12) {
100
+ if (claimedMinIndex < 0 || claimedMinIndex >= fProbs.length)
101
+ return false;
102
+ const claimedValue = lambdaG * gProbs[claimedMinIndex] - lambdaF * fProbs[claimedMinIndex];
103
+ for (let i = 0; i < fProbs.length; i++) {
104
+ const diff = lambdaG * gProbs[i] - lambdaF * fProbs[i];
105
+ if (diff < claimedValue - tolerance)
106
+ return false;
107
+ }
108
+ return true;
109
+ }
110
+ //# sourceMappingURL=compute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.js","sourceRoot":"","sources":["../../src/categorical/compute.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Effect-wrapped categorical collateral computation utilities.
3
+ *
4
+ * Lifts validation and computation failures into Effect's typed error channel.
5
+ *
6
+ * @module
7
+ */
8
+ import { Effect } from 'effect';
9
+ import { InvalidInputError, SolverFailedError } from '@the-situation/core';
10
+ import { type CategoricalCollateralResult } from './compute';
11
+ /**
12
+ * Effect-wrapped categorical collateral computation.
13
+ *
14
+ * Validates inputs and lifts failures into typed error channels:
15
+ * - `InvalidInputError` for mismatched sizes, empty vectors, or invalid k
16
+ * - `SolverFailedError` for unexpected computation failures
17
+ *
18
+ * @param fProbs - Probability vector of the "from" distribution
19
+ * @param gProbs - Probability vector of the "to" distribution
20
+ * @param k - The scaling parameter (must be positive)
21
+ * @returns Effect yielding a CategoricalCollateralResult or failing with a typed error
22
+ */
23
+ export declare function computeCategoricalCollateralEffect(fProbs: readonly number[], gProbs: readonly number[], k: number): Effect.Effect<CategoricalCollateralResult, InvalidInputError | SolverFailedError>;
24
+ //# sourceMappingURL=effect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/categorical/effect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAgC,KAAK,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAE3F;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,CAAC,EAAE,MAAM,GACR,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,CA0BnF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Effect-wrapped categorical collateral computation utilities.
3
+ *
4
+ * Lifts validation and computation failures into Effect's typed error channel.
5
+ *
6
+ * @module
7
+ */
8
+ import { Effect } from 'effect';
9
+ import { InvalidInputError, SolverFailedError } from '@the-situation/core';
10
+ import { computeCategoricalCollateral } from './compute';
11
+ /**
12
+ * Effect-wrapped categorical collateral computation.
13
+ *
14
+ * Validates inputs and lifts failures into typed error channels:
15
+ * - `InvalidInputError` for mismatched sizes, empty vectors, or invalid k
16
+ * - `SolverFailedError` for unexpected computation failures
17
+ *
18
+ * @param fProbs - Probability vector of the "from" distribution
19
+ * @param gProbs - Probability vector of the "to" distribution
20
+ * @param k - The scaling parameter (must be positive)
21
+ * @returns Effect yielding a CategoricalCollateralResult or failing with a typed error
22
+ */
23
+ export function computeCategoricalCollateralEffect(fProbs, gProbs, k) {
24
+ return Effect.gen(function* () {
25
+ if (fProbs.length !== gProbs.length) {
26
+ return yield* new InvalidInputError({
27
+ message: `Distribution size mismatch: f has ${fProbs.length} outcomes, g has ${gProbs.length}`,
28
+ });
29
+ }
30
+ if (fProbs.length === 0) {
31
+ return yield* new InvalidInputError({
32
+ message: 'Empty probability vectors',
33
+ });
34
+ }
35
+ if (k <= 0) {
36
+ return yield* new InvalidInputError({
37
+ message: `Invalid k parameter: ${k}`,
38
+ });
39
+ }
40
+ try {
41
+ return computeCategoricalCollateral(fProbs, gProbs, k);
42
+ }
43
+ catch (e) {
44
+ return yield* new SolverFailedError({
45
+ message: `Categorical collateral computation failed: ${e instanceof Error ? e.message : String(e)}`,
46
+ });
47
+ }
48
+ });
49
+ }
50
+ //# sourceMappingURL=effect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect.js","sourceRoot":"","sources":["../../src/categorical/effect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAoC,MAAM,WAAW,CAAC;AAE3F;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kCAAkC,CAChD,MAAyB,EACzB,MAAyB,EACzB,CAAS;IAET,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC,CAAC,IAAI,iBAAiB,CAAC;gBAClC,OAAO,EAAE,qCAAqC,MAAM,CAAC,MAAM,oBAAoB,MAAM,CAAC,MAAM,EAAE;aAC/F,CAAC,CAAC;QACL,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,CAAC,IAAI,iBAAiB,CAAC;gBAClC,OAAO,EAAE,2BAA2B;aACrC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACX,OAAO,KAAK,CAAC,CAAC,IAAI,iBAAiB,CAAC;gBAClC,OAAO,EAAE,wBAAwB,CAAC,EAAE;aACrC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC;YACH,OAAO,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,KAAK,CAAC,CAAC,IAAI,iBAAiB,CAAC;gBAClC,OAAO,EAAE,8CAA8C,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;aACpG,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Categorical (multinoulli) collateral computation.
3
+ *
4
+ * @module
5
+ */
6
+ export { computeCategoricalCollateral, computeCategoricalL2Norm, computeCategoricalLambda, findMinimumOutcome, verifyCategoricalMinimum, type CategoricalCollateralResult, } from './compute';
7
+ export { computeCategoricalCollateralEffect } from './effect';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/categorical/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,2BAA2B,GACjC,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Categorical (multinoulli) collateral computation.
3
+ *
4
+ * @module
5
+ */
6
+ export { computeCategoricalCollateral, computeCategoricalL2Norm, computeCategoricalLambda, findMinimumOutcome, verifyCategoricalMinimum, } from './compute';
7
+ export { computeCategoricalCollateralEffect } from './effect';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/categorical/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,GAEzB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,9 +5,11 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- export { collateralFromMinimum, computeCollateral, computeL2Norm, computeLambda, computeScaledCollateral, DEFAULT_MAX_ITERATIONS, DEFAULT_TOLERANCE, defaultPolicy, findMinimum, getVerifiedMinimum, isOnCorrectSide, isVerified, pdfDifference, pdfDifferenceDerivative, pdfDifferenceSecondDerivative, relaxedPolicy, SQRT_PI, suggestInitialGuess, } from './compute';
8
+ export { collateralFromMinimum, computeCollateral, computeL2Norm, computeL2NormNumber, computeLambda, computeLambdaNumber, computeScaledCollateral, DEFAULT_MAX_ITERATIONS, DEFAULT_TOLERANCE, defaultPolicy, findMinimum, getVerifiedMinimum, isOnCorrectSide, isVerified, pdfDifference, pdfDifferenceDerivative, pdfDifferenceSecondDerivative, relaxedPolicy, SQRT_PI, suggestInitialGuess, } from './compute';
9
9
  export type { CandidateMinimum, FindMinimumResult, MinimizationMethod, MinimizationPolicy, NotVerifiedReason, ScaledCollateralResult, VerifiedMinimum, } from './compute';
10
10
  export { computeCollateralAtPoint, isValid, quickVerify, verifyMinimum, } from './verify';
11
11
  export type { CollateralVerificationResult } from './verify';
12
12
  export { findMinimumEffect } from './effect';
13
+ export { computeCategoricalCollateral, computeCategoricalL2Norm, computeCategoricalLambda, findMinimumOutcome, verifyCategoricalMinimum, type CategoricalCollateralResult, } from './categorical/compute';
14
+ export { computeCategoricalCollateralEffect } from './categorical/effect';
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,aAAa,EACb,OAAO,EACP,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,wBAAwB,EACxB,OAAO,EACP,WAAW,EACX,aAAa,GACd,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,aAAa,EACb,OAAO,EACP,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,wBAAwB,EACxB,OAAO,EACP,WAAW,EACX,aAAa,GACd,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,2BAA2B,GACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kCAAkC,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -6,9 +6,12 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
  // Computation
9
- export { collateralFromMinimum, computeCollateral, computeL2Norm, computeLambda, computeScaledCollateral, DEFAULT_MAX_ITERATIONS, DEFAULT_TOLERANCE, defaultPolicy, findMinimum, getVerifiedMinimum, isOnCorrectSide, isVerified, pdfDifference, pdfDifferenceDerivative, pdfDifferenceSecondDerivative, relaxedPolicy, SQRT_PI, suggestInitialGuess, } from './compute';
9
+ export { collateralFromMinimum, computeCollateral, computeL2Norm, computeL2NormNumber, computeLambda, computeLambdaNumber, computeScaledCollateral, DEFAULT_MAX_ITERATIONS, DEFAULT_TOLERANCE, defaultPolicy, findMinimum, getVerifiedMinimum, isOnCorrectSide, isVerified, pdfDifference, pdfDifferenceDerivative, pdfDifferenceSecondDerivative, relaxedPolicy, SQRT_PI, suggestInitialGuess, } from './compute';
10
10
  // Verification
11
11
  export { computeCollateralAtPoint, isValid, quickVerify, verifyMinimum, } from './verify';
12
12
  // Effect-wrapped convenience exports
13
13
  export { findMinimumEffect } from './effect';
14
+ // Categorical (multinoulli) collateral
15
+ export { computeCategoricalCollateral, computeCategoricalL2Norm, computeCategoricalLambda, findMinimumOutcome, verifyCategoricalMinimum, } from './categorical/compute';
16
+ export { computeCategoricalCollateralEffect } from './categorical/effect';
14
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc;AACd,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,aAAa,EACb,OAAO,EACP,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAanB,eAAe;AACf,OAAO,EACL,wBAAwB,EACxB,OAAO,EACP,WAAW,EACX,aAAa,GACd,MAAM,UAAU,CAAC;AAIlB,qCAAqC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc;AACd,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,aAAa,EACb,OAAO,EACP,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAanB,eAAe;AACf,OAAO,EACL,wBAAwB,EACxB,OAAO,EACP,WAAW,EACX,aAAa,GACd,MAAM,UAAU,CAAC;AAIlB,qCAAqC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,uCAAuC;AACvC,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,GAEzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kCAAkC,EAAE,MAAM,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-situation/collateral",
3
- "version": "0.5.0-alpha.0",
3
+ "version": "0.8.0",
4
4
  "description": "Off-chain collateral computation for The Situation prediction markets",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,7 +11,9 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  }
13
13
  },
14
- "files": ["dist"],
14
+ "files": [
15
+ "dist"
16
+ ],
15
17
  "scripts": {
16
18
  "build": "tsc -b",
17
19
  "typecheck": "tsc -b",
@@ -19,7 +21,7 @@
19
21
  "clean": "rm -rf dist tsconfig.tsbuildinfo"
20
22
  },
21
23
  "dependencies": {
22
- "@the-situation/core": "0.5.0-alpha.0",
24
+ "@the-situation/core": "workspace:*",
23
25
  "effect": "^3.12.0"
24
26
  },
25
27
  "devDependencies": {