@ottochain/sdk 1.0.2 → 1.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.
Files changed (157) hide show
  1. package/dist/cjs/apps/contracts/state-machines/contract.json +1 -29
  2. package/dist/cjs/apps/contracts/state-machines/escrow.json +2 -32
  3. package/dist/cjs/generated/index.js +11 -1
  4. package/dist/cjs/metakit/drop-nulls.js +50 -0
  5. package/dist/cjs/metakit/normalize.js +147 -0
  6. package/dist/cjs/ottochain/metagraph-client.js +147 -0
  7. package/dist/cjs/validation.js +1 -1
  8. package/dist/esm/apps/contracts/state-machines/contract.json +1 -29
  9. package/dist/esm/apps/contracts/state-machines/escrow.json +2 -32
  10. package/dist/esm/generated/index.js +11 -1
  11. package/dist/esm/metakit/drop-nulls.js +46 -0
  12. package/dist/esm/metakit/normalize.js +140 -0
  13. package/dist/esm/ottochain/metagraph-client.js +147 -0
  14. package/dist/esm/validation.js +1 -1
  15. package/dist/types/generated/index.d.ts +11 -1
  16. package/dist/types/metakit/drop-nulls.d.ts +29 -0
  17. package/dist/types/metakit/normalize.d.ts +67 -0
  18. package/dist/types/ottochain/index.d.ts +1 -1
  19. package/dist/types/ottochain/metagraph-client.d.ts +90 -0
  20. package/package.json +12 -12
  21. package/dist/apps/contracts/index.d.ts +0 -21
  22. package/dist/apps/contracts/index.js +0 -39
  23. package/dist/apps/contracts/types.d.ts +0 -24
  24. package/dist/apps/contracts/types.js +0 -48
  25. package/dist/apps/identity/index.d.ts +0 -22
  26. package/dist/apps/identity/index.js +0 -40
  27. package/dist/apps/identity/types.d.ts +0 -30
  28. package/dist/apps/identity/types.js +0 -53
  29. package/dist/apps/index.d.ts +0 -29
  30. package/dist/apps/index.js +0 -60
  31. package/dist/apps/markets/index.d.ts +0 -26
  32. package/dist/apps/markets/index.js +0 -46
  33. package/dist/apps/markets/types.d.ts +0 -185
  34. package/dist/apps/markets/types.js +0 -252
  35. package/dist/apps/oracles/index.d.ts +0 -26
  36. package/dist/apps/oracles/index.js +0 -46
  37. package/dist/apps/oracles/types.d.ts +0 -211
  38. package/dist/apps/oracles/types.js +0 -306
  39. package/dist/cjs/apps/contracts/types.js +0 -48
  40. package/dist/cjs/apps/corporate/types.js +0 -44
  41. package/dist/cjs/apps/governance/types.js +0 -42
  42. package/dist/cjs/apps/identity/types.js +0 -53
  43. package/dist/cjs/apps/markets/types.js +0 -219
  44. package/dist/cjs/apps/oracles/types.js +0 -282
  45. package/dist/cjs/generated/ottochain/apps/contracts/v1/contract_pb.js +0 -100
  46. package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate_pb.js +0 -392
  47. package/dist/cjs/generated/ottochain/apps/governance/v1/governance_pb.js +0 -235
  48. package/dist/cjs/generated/ottochain/apps/identity/v1/agent_pb.js +0 -116
  49. package/dist/cjs/generated/ottochain/apps/identity/v1/attestation_pb.js +0 -79
  50. package/dist/cjs/generated/ottochain/apps/markets/v1/market_pb.js +0 -151
  51. package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle_pb.js +0 -109
  52. package/dist/cjs/generated/ottochain/v1/common_pb.js +0 -37
  53. package/dist/cjs/generated/ottochain/v1/fiber_pb.js +0 -86
  54. package/dist/cjs/generated/ottochain/v1/messages_pb.js +0 -44
  55. package/dist/cjs/generated/ottochain/v1/records_pb.js +0 -44
  56. package/dist/errors.d.ts +0 -221
  57. package/dist/errors.js +0 -293
  58. package/dist/esm/apps/contracts/types.js +0 -44
  59. package/dist/esm/apps/corporate/types.js +0 -38
  60. package/dist/esm/apps/governance/types.js +0 -35
  61. package/dist/esm/apps/identity/types.js +0 -50
  62. package/dist/esm/apps/markets/types.js +0 -206
  63. package/dist/esm/apps/oracles/types.js +0 -267
  64. package/dist/esm/generated/ottochain/apps/contracts/v1/contract_pb.js +0 -97
  65. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate_pb.js +0 -389
  66. package/dist/esm/generated/ottochain/apps/governance/v1/governance_pb.js +0 -232
  67. package/dist/esm/generated/ottochain/apps/identity/v1/agent_pb.js +0 -113
  68. package/dist/esm/generated/ottochain/apps/identity/v1/attestation_pb.js +0 -76
  69. package/dist/esm/generated/ottochain/apps/markets/v1/market_pb.js +0 -148
  70. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle_pb.js +0 -106
  71. package/dist/esm/generated/ottochain/v1/common_pb.js +0 -34
  72. package/dist/esm/generated/ottochain/v1/fiber_pb.js +0 -83
  73. package/dist/esm/generated/ottochain/v1/messages_pb.js +0 -41
  74. package/dist/esm/generated/ottochain/v1/records_pb.js +0 -41
  75. package/dist/generated/index.d.ts +0 -15
  76. package/dist/generated/index.js +0 -34
  77. package/dist/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +0 -274
  78. package/dist/generated/ottochain/apps/contracts/v1/contract_pb.js +0 -100
  79. package/dist/generated/ottochain/apps/identity/v1/agent_pb.d.ts +0 -211
  80. package/dist/generated/ottochain/apps/identity/v1/agent_pb.js +0 -116
  81. package/dist/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +0 -238
  82. package/dist/generated/ottochain/apps/identity/v1/attestation_pb.js +0 -79
  83. package/dist/generated/ottochain/apps/markets/v1/market_pb.d.ts +0 -436
  84. package/dist/generated/ottochain/apps/markets/v1/market_pb.js +0 -151
  85. package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +0 -393
  86. package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.js +0 -109
  87. package/dist/generated/ottochain/v1/common_pb.d.ts +0 -86
  88. package/dist/generated/ottochain/v1/common_pb.js +0 -37
  89. package/dist/generated/ottochain/v1/fiber_pb.d.ts +0 -292
  90. package/dist/generated/ottochain/v1/fiber_pb.js +0 -86
  91. package/dist/generated/ottochain/v1/messages_pb.d.ts +0 -190
  92. package/dist/generated/ottochain/v1/messages_pb.js +0 -44
  93. package/dist/generated/ottochain/v1/records_pb.d.ts +0 -221
  94. package/dist/generated/ottochain/v1/records_pb.js +0 -44
  95. package/dist/index.d.ts +0 -21
  96. package/dist/index.js +0 -77
  97. package/dist/metakit/binary.d.ts +0 -38
  98. package/dist/metakit/binary.js +0 -58
  99. package/dist/metakit/canonicalize.d.ts +0 -26
  100. package/dist/metakit/canonicalize.js +0 -40
  101. package/dist/metakit/codec.d.ts +0 -16
  102. package/dist/metakit/codec.js +0 -45
  103. package/dist/metakit/currency-transaction.d.ts +0 -157
  104. package/dist/metakit/currency-transaction.js +0 -319
  105. package/dist/metakit/currency-types.d.ts +0 -55
  106. package/dist/metakit/currency-types.js +0 -13
  107. package/dist/metakit/hash.d.ts +0 -50
  108. package/dist/metakit/hash.js +0 -84
  109. package/dist/metakit/index.d.ts +0 -23
  110. package/dist/metakit/index.js +0 -74
  111. package/dist/metakit/network/client.d.ts +0 -23
  112. package/dist/metakit/network/client.js +0 -78
  113. package/dist/metakit/network/currency-l1-client.d.ts +0 -71
  114. package/dist/metakit/network/currency-l1-client.js +0 -101
  115. package/dist/metakit/network/data-l1-client.d.ts +0 -57
  116. package/dist/metakit/network/data-l1-client.js +0 -76
  117. package/dist/metakit/network/index.d.ts +0 -10
  118. package/dist/metakit/network/index.js +0 -16
  119. package/dist/metakit/network/types.d.ts +0 -74
  120. package/dist/metakit/network/types.js +0 -20
  121. package/dist/metakit/sign.d.ts +0 -65
  122. package/dist/metakit/sign.js +0 -120
  123. package/dist/metakit/signed-object.d.ts +0 -66
  124. package/dist/metakit/signed-object.js +0 -100
  125. package/dist/metakit/types.d.ts +0 -67
  126. package/dist/metakit/types.js +0 -14
  127. package/dist/metakit/verify.d.ts +0 -55
  128. package/dist/metakit/verify.js +0 -217
  129. package/dist/metakit/wallet.d.ts +0 -70
  130. package/dist/metakit/wallet.js +0 -127
  131. package/dist/ottochain/index.d.ts +0 -13
  132. package/dist/ottochain/index.js +0 -45
  133. package/dist/ottochain/metagraph-client.d.ts +0 -111
  134. package/dist/ottochain/metagraph-client.js +0 -157
  135. package/dist/ottochain/snapshot.d.ts +0 -86
  136. package/dist/ottochain/snapshot.js +0 -110
  137. package/dist/ottochain/types.d.ts +0 -278
  138. package/dist/ottochain/types.js +0 -11
  139. package/dist/types/apps/contracts/types.d.ts +0 -24
  140. package/dist/types/apps/corporate/types.d.ts +0 -9861
  141. package/dist/types/apps/governance/types.d.ts +0 -344
  142. package/dist/types/apps/identity/types.d.ts +0 -30
  143. package/dist/types/apps/markets/types.d.ts +0 -155
  144. package/dist/types/apps/oracles/types.d.ts +0 -193
  145. package/dist/types/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +0 -274
  146. package/dist/types/generated/ottochain/apps/corporate/v1/corporate_pb.d.ts +0 -1172
  147. package/dist/types/generated/ottochain/apps/governance/v1/governance_pb.d.ts +0 -772
  148. package/dist/types/generated/ottochain/apps/identity/v1/agent_pb.d.ts +0 -211
  149. package/dist/types/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +0 -238
  150. package/dist/types/generated/ottochain/apps/markets/v1/market_pb.d.ts +0 -436
  151. package/dist/types/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +0 -393
  152. package/dist/types/generated/ottochain/v1/common_pb.d.ts +0 -86
  153. package/dist/types/generated/ottochain/v1/fiber_pb.d.ts +0 -292
  154. package/dist/types/generated/ottochain/v1/messages_pb.d.ts +0 -190
  155. package/dist/types/generated/ottochain/v1/records_pb.d.ts +0 -221
  156. package/dist/validation.d.ts +0 -449
  157. package/dist/validation.js +0 -312
@@ -1,48 +0,0 @@
1
- "use strict";
2
- /**
3
- * Contract Utilities
4
- *
5
- * Constants and utilities for the Contract application.
6
- * Core types are generated from protobuf - see the generated exports.
7
- *
8
- * @packageDocumentation
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.isTerminalState = exports.CONTRACT_TRANSITIONS = exports.DEFAULT_CONTRACT_CONFIG = void 0;
12
- const contract_pb_js_1 = require("../../generated/ottochain/apps/contracts/v1/contract_pb.js");
13
- // ---------------------------------------------------------------------------
14
- // Configuration Defaults
15
- // ---------------------------------------------------------------------------
16
- /**
17
- * Default contract configuration
18
- */
19
- exports.DEFAULT_CONTRACT_CONFIG = {
20
- requireBothSignatures: false,
21
- disputeWindowEpochs: 10,
22
- };
23
- // ---------------------------------------------------------------------------
24
- // State Machine Transitions
25
- // ---------------------------------------------------------------------------
26
- /**
27
- * Valid transitions for each contract state
28
- */
29
- exports.CONTRACT_TRANSITIONS = {
30
- [contract_pb_js_1.ContractState.UNSPECIFIED]: [],
31
- [contract_pb_js_1.ContractState.PROPOSED]: ['accept', 'reject', 'cancel'],
32
- [contract_pb_js_1.ContractState.ACTIVE]: ['complete', 'dispute'],
33
- [contract_pb_js_1.ContractState.DISPUTED]: ['resolve_for_completer', 'resolve_for_disputant'],
34
- [contract_pb_js_1.ContractState.COMPLETED]: [], // Terminal state
35
- [contract_pb_js_1.ContractState.REJECTED]: [], // Terminal state
36
- [contract_pb_js_1.ContractState.CANCELLED]: [], // Terminal state
37
- };
38
- /**
39
- * Check if a contract state is terminal (no further transitions allowed)
40
- */
41
- function isTerminalState(state) {
42
- return [
43
- contract_pb_js_1.ContractState.COMPLETED,
44
- contract_pb_js_1.ContractState.REJECTED,
45
- contract_pb_js_1.ContractState.CANCELLED,
46
- ].includes(state);
47
- }
48
- exports.isTerminalState = isTerminalState;
@@ -1,22 +0,0 @@
1
- /**
2
- * Agent Identity Application
3
- *
4
- * Types and utilities for the Agent Identity system on OttoChain.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { AgentState, AttestationType, AgentIdentitySchema } from '@ottochain/sdk/apps/identity';
9
- * import { create } from '@bufbuild/protobuf';
10
- *
11
- * const agent = create(AgentIdentitySchema, {
12
- * publicKey: '...',
13
- * reputation: 10,
14
- * state: AgentState.REGISTERED,
15
- * });
16
- * ```
17
- *
18
- * @packageDocumentation
19
- */
20
- export * from '../../generated/ottochain/apps/identity/v1/agent_pb.js';
21
- export * from '../../generated/ottochain/apps/identity/v1/attestation_pb.js';
22
- export * from './types.js';
@@ -1,40 +0,0 @@
1
- "use strict";
2
- /**
3
- * Agent Identity Application
4
- *
5
- * Types and utilities for the Agent Identity system on OttoChain.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { AgentState, AttestationType, AgentIdentitySchema } from '@ottochain/sdk/apps/identity';
10
- * import { create } from '@bufbuild/protobuf';
11
- *
12
- * const agent = create(AgentIdentitySchema, {
13
- * publicKey: '...',
14
- * reputation: 10,
15
- * state: AgentState.REGISTERED,
16
- * });
17
- * ```
18
- *
19
- * @packageDocumentation
20
- */
21
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- var desc = Object.getOwnPropertyDescriptor(m, k);
24
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
- desc = { enumerable: true, get: function() { return m[k]; } };
26
- }
27
- Object.defineProperty(o, k2, desc);
28
- }) : (function(o, m, k, k2) {
29
- if (k2 === undefined) k2 = k;
30
- o[k2] = m[k];
31
- }));
32
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
33
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- // Re-export generated protobuf types
37
- __exportStar(require("../../generated/ottochain/apps/identity/v1/agent_pb.js"), exports);
38
- __exportStar(require("../../generated/ottochain/apps/identity/v1/attestation_pb.js"), exports);
39
- // Re-export convenience types and constants
40
- __exportStar(require("./types.js"), exports);
@@ -1,30 +0,0 @@
1
- /**
2
- * Agent Identity Utilities
3
- *
4
- * Constants and utilities for the Agent Identity application.
5
- * Core types are generated from protobuf - see the generated exports.
6
- *
7
- * @packageDocumentation
8
- */
9
- import { AgentState } from '../../generated/ottochain/apps/identity/v1/agent_pb.js';
10
- import { AttestationType } from '../../generated/ottochain/apps/identity/v1/attestation_pb.js';
11
- /**
12
- * Default reputation configuration for agent identity
13
- */
14
- export declare const DEFAULT_REPUTATION_CONFIG: {
15
- readonly baseReputation: 10;
16
- readonly completionDelta: 5;
17
- readonly vouchDelta: 2;
18
- readonly violationDelta: -10;
19
- readonly behavioralDelta: 3;
20
- readonly minReputation: 0;
21
- readonly challengeThreshold: 5;
22
- };
23
- /**
24
- * Valid transitions for each agent state
25
- */
26
- export declare const AGENT_TRANSITIONS: Record<AgentState, readonly string[]>;
27
- /**
28
- * Reputation delta by attestation type
29
- */
30
- export declare const ATTESTATION_DELTAS: Record<AttestationType, number>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- /**
3
- * Agent Identity Utilities
4
- *
5
- * Constants and utilities for the Agent Identity application.
6
- * Core types are generated from protobuf - see the generated exports.
7
- *
8
- * @packageDocumentation
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ATTESTATION_DELTAS = exports.AGENT_TRANSITIONS = exports.DEFAULT_REPUTATION_CONFIG = void 0;
12
- const agent_pb_js_1 = require("../../generated/ottochain/apps/identity/v1/agent_pb.js");
13
- const attestation_pb_js_1 = require("../../generated/ottochain/apps/identity/v1/attestation_pb.js");
14
- // ---------------------------------------------------------------------------
15
- // Configuration Defaults
16
- // ---------------------------------------------------------------------------
17
- /**
18
- * Default reputation configuration for agent identity
19
- */
20
- exports.DEFAULT_REPUTATION_CONFIG = {
21
- baseReputation: 10,
22
- completionDelta: 5,
23
- vouchDelta: 2,
24
- violationDelta: -10,
25
- behavioralDelta: 3,
26
- minReputation: 0,
27
- challengeThreshold: 5,
28
- };
29
- // ---------------------------------------------------------------------------
30
- // State Machine Transitions
31
- // ---------------------------------------------------------------------------
32
- /**
33
- * Valid transitions for each agent state
34
- */
35
- exports.AGENT_TRANSITIONS = {
36
- [agent_pb_js_1.AgentState.UNSPECIFIED]: [],
37
- [agent_pb_js_1.AgentState.REGISTERED]: ['activate', 'withdraw'],
38
- [agent_pb_js_1.AgentState.ACTIVE]: ['challenge', 'withdraw'],
39
- [agent_pb_js_1.AgentState.CHALLENGED]: ['uphold_challenge', 'dismiss_challenge'],
40
- [agent_pb_js_1.AgentState.SUSPENDED]: ['begin_probation'],
41
- [agent_pb_js_1.AgentState.PROBATION]: ['complete_probation'],
42
- [agent_pb_js_1.AgentState.WITHDRAWN]: [], // Terminal state
43
- };
44
- /**
45
- * Reputation delta by attestation type
46
- */
47
- exports.ATTESTATION_DELTAS = {
48
- [attestation_pb_js_1.AttestationType.UNSPECIFIED]: 0,
49
- [attestation_pb_js_1.AttestationType.COMPLETION]: 5,
50
- [attestation_pb_js_1.AttestationType.VOUCH]: 2,
51
- [attestation_pb_js_1.AttestationType.VIOLATION]: -10,
52
- [attestation_pb_js_1.AttestationType.BEHAVIORAL]: 3,
53
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * OttoChain Applications
3
- *
4
- * Application-specific types and utilities for OttoChain SDK.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { identity, contracts, markets, oracles } from '@ottochain/sdk/apps';
9
- *
10
- * // Use identity types
11
- * const { AgentState, AGENT_TRANSITIONS } = identity;
12
- *
13
- * // Use market calculations
14
- * const payout = markets.calculatePayout(shares);
15
- *
16
- * // Check oracle reputation
17
- * const newRep = oracles.calculateReputation(current, delta);
18
- * ```
19
- *
20
- * @packageDocumentation
21
- */
22
- export * as identity from './identity/index.js';
23
- export * as contracts from './contracts/index.js';
24
- export * as markets from './markets/index.js';
25
- export * as oracles from './oracles/index.js';
26
- export * from './identity/index.js';
27
- export * from './contracts/index.js';
28
- export * from './markets/index.js';
29
- export * from './oracles/index.js';
@@ -1,60 +0,0 @@
1
- "use strict";
2
- /**
3
- * OttoChain Applications
4
- *
5
- * Application-specific types and utilities for OttoChain SDK.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { identity, contracts, markets, oracles } from '@ottochain/sdk/apps';
10
- *
11
- * // Use identity types
12
- * const { AgentState, AGENT_TRANSITIONS } = identity;
13
- *
14
- * // Use market calculations
15
- * const payout = markets.calculatePayout(shares);
16
- *
17
- * // Check oracle reputation
18
- * const newRep = oracles.calculateReputation(current, delta);
19
- * ```
20
- *
21
- * @packageDocumentation
22
- */
23
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- var desc = Object.getOwnPropertyDescriptor(m, k);
26
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
- desc = { enumerable: true, get: function() { return m[k]; } };
28
- }
29
- Object.defineProperty(o, k2, desc);
30
- }) : (function(o, m, k, k2) {
31
- if (k2 === undefined) k2 = k;
32
- o[k2] = m[k];
33
- }));
34
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
- Object.defineProperty(o, "default", { enumerable: true, value: v });
36
- }) : function(o, v) {
37
- o["default"] = v;
38
- });
39
- var __importStar = (this && this.__importStar) || function (mod) {
40
- if (mod && mod.__esModule) return mod;
41
- var result = {};
42
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
- __setModuleDefault(result, mod);
44
- return result;
45
- };
46
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
47
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.oracles = exports.markets = exports.contracts = exports.identity = void 0;
51
- // Re-export as namespaces for organized access
52
- exports.identity = __importStar(require("./identity/index.js"));
53
- exports.contracts = __importStar(require("./contracts/index.js"));
54
- exports.markets = __importStar(require("./markets/index.js"));
55
- exports.oracles = __importStar(require("./oracles/index.js"));
56
- // Also allow direct imports
57
- __exportStar(require("./identity/index.js"), exports);
58
- __exportStar(require("./contracts/index.js"), exports);
59
- __exportStar(require("./markets/index.js"), exports);
60
- __exportStar(require("./oracles/index.js"), exports);
@@ -1,26 +0,0 @@
1
- /**
2
- * Markets Application
3
- *
4
- * Types and utilities for the Markets system on OttoChain.
5
- * Supports prediction markets, auctions, crowdfunding, and group buys.
6
- *
7
- * @example
8
- * ```typescript
9
- * import {
10
- * MarketState,
11
- * MarketType,
12
- * calculatePayout,
13
- * DEFAULT_MARKET_CONFIG
14
- * } from '@ottochain/sdk/apps/markets';
15
- *
16
- * // Calculate payout for a winning prediction
17
- * const payout = calculatePayout({
18
- * winningPool: 1000n,
19
- * losingPool: 500n,
20
- * userCommitment: 100n,
21
- * });
22
- * ```
23
- *
24
- * @packageDocumentation
25
- */
26
- export * from './types.js';
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /**
3
- * Markets Application
4
- *
5
- * Types and utilities for the Markets system on OttoChain.
6
- * Supports prediction markets, auctions, crowdfunding, and group buys.
7
- *
8
- * @example
9
- * ```typescript
10
- * import {
11
- * MarketState,
12
- * MarketType,
13
- * calculatePayout,
14
- * DEFAULT_MARKET_CONFIG
15
- * } from '@ottochain/sdk/apps/markets';
16
- *
17
- * // Calculate payout for a winning prediction
18
- * const payout = calculatePayout({
19
- * winningPool: 1000n,
20
- * losingPool: 500n,
21
- * userCommitment: 100n,
22
- * });
23
- * ```
24
- *
25
- * @packageDocumentation
26
- */
27
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
- if (k2 === undefined) k2 = k;
29
- var desc = Object.getOwnPropertyDescriptor(m, k);
30
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
31
- desc = { enumerable: true, get: function() { return m[k]; } };
32
- }
33
- Object.defineProperty(o, k2, desc);
34
- }) : (function(o, m, k, k2) {
35
- if (k2 === undefined) k2 = k;
36
- o[k2] = m[k];
37
- }));
38
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
39
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- // Note: Once proto files are generated, uncomment these exports:
43
- // export * from '../../generated/ottochain/apps/markets/v1/market_pb.js';
44
- // export * from '../../generated/ottochain/apps/markets/v1/commitment_pb.js';
45
- // Export convenience types, constants, and helpers
46
- __exportStar(require("./types.js"), exports);
@@ -1,185 +0,0 @@
1
- /**
2
- * Markets Application Types
3
- *
4
- * Constants, types, and utilities for the Markets application on OttoChain.
5
- *
6
- * Note: When proto files are generated, enums will move to generated types.
7
- *
8
- * @packageDocumentation
9
- */
10
- /**
11
- * Market lifecycle states
12
- */
13
- export declare enum MarketState {
14
- UNSPECIFIED = 0,
15
- /** Market is open for commitments */
16
- OPEN = 1,
17
- /** Commitment period has ended, awaiting resolution */
18
- CLOSED = 2,
19
- /** Oracle has resolved the outcome */
20
- RESOLVED = 3,
21
- /** Payouts distributed to winners */
22
- SETTLED = 4,
23
- /** Market cancelled, refunds issued */
24
- CANCELLED = 5,
25
- /** Market is disputed */
26
- DISPUTED = 6
27
- }
28
- /**
29
- * Types of markets supported
30
- */
31
- export declare enum MarketType {
32
- UNSPECIFIED = 0,
33
- /** Binary or multi-outcome prediction market */
34
- PREDICTION = 1,
35
- /** Ascending/descending price auction */
36
- AUCTION = 2,
37
- /** All-or-nothing crowdfunding */
38
- CROWDFUND = 3,
39
- /** Group buying with volume discounts */
40
- GROUP_BUY = 4
41
- }
42
- /**
43
- * Commitment direction (for prediction markets)
44
- */
45
- export declare enum CommitmentSide {
46
- UNSPECIFIED = 0,
47
- YES = 1,
48
- NO = 2
49
- }
50
- /**
51
- * Market configuration type
52
- */
53
- export interface MarketConfig {
54
- /** Platform fee as percentage (0.01 = 1%) */
55
- platformFeePercent: number;
56
- /** Market creator fee as percentage */
57
- creatorFeePercent: number;
58
- /** Oracle fee as percentage */
59
- oracleFeePercent: number;
60
- /** Minimum quorum for market validity (in tokens) */
61
- minQuorum: bigint;
62
- /** Default resolution window in epochs */
63
- resolutionWindowEpochs: number;
64
- /** Dispute window after resolution in epochs */
65
- disputeWindowEpochs: number;
66
- /** Minimum commitment amount */
67
- minCommitment: bigint;
68
- /** Maximum slippage for AMM-style markets */
69
- maxSlippagePercent: number;
70
- }
71
- /**
72
- * Default market configuration
73
- */
74
- export declare const DEFAULT_MARKET_CONFIG: MarketConfig;
75
- /**
76
- * Type-specific market configurations
77
- */
78
- export declare const MARKET_TYPE_CONFIGS: Record<MarketType, Partial<MarketConfig>>;
79
- /**
80
- * Valid transitions for each market state
81
- */
82
- export declare const MARKET_TRANSITIONS: Record<MarketState, readonly string[]>;
83
- /**
84
- * Check if a market state is terminal
85
- */
86
- export declare function isTerminalMarketState(state: MarketState): boolean;
87
- /**
88
- * Calculate effective commitment after fees
89
- *
90
- * @param amount - Raw commitment amount
91
- * @param config - Market configuration (uses defaults if not provided)
92
- * @returns Net commitment amount after platform fees
93
- */
94
- export declare function calculateNetCommitment(amount: bigint, config?: Partial<MarketConfig>): bigint;
95
- /**
96
- * Calculate total fees for a commitment
97
- *
98
- * @param amount - Commitment amount
99
- * @param marketType - Type of market for type-specific fees
100
- * @returns Fee breakdown object
101
- */
102
- export declare function calculateFees(amount: bigint, marketType?: MarketType): {
103
- platform: bigint;
104
- creator: bigint;
105
- oracle: bigint;
106
- total: bigint;
107
- };
108
- /**
109
- * Outcome shares for payout calculation
110
- */
111
- export interface OutcomeShares {
112
- /** Total committed to winning outcome */
113
- winningPool: bigint;
114
- /** Total committed to losing outcome(s) */
115
- losingPool: bigint;
116
- /** Individual's commitment to winning outcome */
117
- userCommitment: bigint;
118
- }
119
- /**
120
- * Calculate payout for a winning commitment in a prediction market
121
- *
122
- * Winner receives: their original + proportional share of losing pool (minus fees)
123
- *
124
- * @param shares - Pool and commitment details
125
- * @param marketType - Type of market for fee calculation
126
- * @returns Payout amount
127
- */
128
- export declare function calculatePayout(shares: OutcomeShares, marketType?: MarketType): bigint;
129
- /**
130
- * Calculate refund for cancelled market
131
- *
132
- * @param commitment - Original commitment amount
133
- * @param refundFeePercent - Optional fee retained on refund (default 0)
134
- * @returns Refund amount
135
- */
136
- export declare function calculateRefund(commitment: bigint, refundFeePercent?: number): bigint;
137
- /**
138
- * Validate a commitment meets market requirements
139
- */
140
- export interface CommitmentValidation {
141
- valid: boolean;
142
- reason?: string;
143
- }
144
- /**
145
- * Validate a commitment against market rules
146
- */
147
- export declare function validateCommitment(amount: bigint, marketState: MarketState, config?: Partial<MarketConfig>): CommitmentValidation;
148
- /**
149
- * Calculate crowdfund progress
150
- */
151
- export interface CrowdfundProgress {
152
- /** Current total committed */
153
- current: bigint;
154
- /** Target goal */
155
- goal: bigint;
156
- /** Percentage complete (0-100) */
157
- percentComplete: number;
158
- /** Whether goal has been reached */
159
- goalReached: boolean;
160
- }
161
- /**
162
- * Calculate crowdfund campaign progress
163
- */
164
- export declare function calculateCrowdfundProgress(current: bigint, goal: bigint): CrowdfundProgress;
165
- /**
166
- * Tier definition for group buys
167
- */
168
- export interface GroupBuyTier {
169
- /** Minimum participants for this tier */
170
- minParticipants: number;
171
- /** Discount percentage for this tier */
172
- discountPercent: number;
173
- }
174
- /**
175
- * Calculate applicable discount based on participant count
176
- */
177
- export declare function calculateGroupBuyDiscount(participantCount: number, tiers: GroupBuyTier[]): number;
178
- /**
179
- * Check if a value is a valid MarketState
180
- */
181
- export declare function isMarketState(value: unknown): value is MarketState;
182
- /**
183
- * Check if a value is a valid MarketType
184
- */
185
- export declare function isMarketType(value: unknown): value is MarketType;