@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,344 +0,0 @@
1
- /**
2
- * Governance & DAO Types
3
- *
4
- * TypeScript types matching the JSON Logic state machine definitions
5
- * in ottochain/docs/trust-graph/state-machines/dao/
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * DAO status values (matches JSON schema status field)
11
- */
12
- export type DAOStatus = 'ACTIVE' | 'DISSOLVED';
13
- /**
14
- * Proposal status for voting DAOs
15
- */
16
- export type ProposalStatus = 'ACTIVE' | 'PENDING' | 'VOTING' | 'QUEUED' | 'EXECUTED' | 'REJECTED' | 'CANCELLED';
17
- /**
18
- * Vote choice
19
- */
20
- export type VoteChoice = 'for' | 'against' | 'abstain';
21
- /**
22
- * Base metadata for all DAOs
23
- */
24
- export interface DAOMetadata {
25
- description?: string;
26
- website?: string;
27
- logo?: string;
28
- [key: string]: unknown;
29
- }
30
- /**
31
- * Single owner DAO state.
32
- * One address controls all actions. Simplest governance model.
33
- */
34
- export interface SingleOwnerDAOState {
35
- schema: 'SingleOwnerDAO';
36
- name: string;
37
- owner: string;
38
- pendingOwner: string | null;
39
- transferInitiatedAt: number | null;
40
- actions: SingleOwnerAction[];
41
- ownershipHistory: OwnershipTransfer[];
42
- metadata: DAOMetadata;
43
- status: DAOStatus;
44
- }
45
- export interface SingleOwnerAction {
46
- id: string;
47
- type: string;
48
- payload: unknown;
49
- executedAt: number;
50
- }
51
- export interface OwnershipTransfer {
52
- from: string;
53
- to: string;
54
- at: number;
55
- }
56
- /**
57
- * Events for SingleOwnerDAO
58
- */
59
- export type SingleOwnerEvent = {
60
- eventName: 'execute';
61
- agent: string;
62
- actionId: string;
63
- actionType: string;
64
- payload: unknown;
65
- } | {
66
- eventName: 'transfer_ownership';
67
- agent: string;
68
- newOwner: string;
69
- } | {
70
- eventName: 'accept_ownership';
71
- agent: string;
72
- } | {
73
- eventName: 'cancel_transfer';
74
- agent: string;
75
- } | {
76
- eventName: 'dissolve';
77
- agent: string;
78
- };
79
- /**
80
- * Multisig DAO state.
81
- * N-of-M signatures required for actions.
82
- */
83
- export interface MultisigDAOState {
84
- schema: 'MultisigDAO';
85
- name: string;
86
- signers: string[];
87
- threshold: number;
88
- proposalTTLMs: number;
89
- proposal: MultisigProposal | null;
90
- signatures: Record<string, number>;
91
- actions: MultisigAction[];
92
- cancelledProposals: MultisigProposal[];
93
- metadata: DAOMetadata;
94
- status: DAOStatus;
95
- }
96
- export interface MultisigProposal {
97
- id: string;
98
- actionType: string;
99
- payload: unknown;
100
- proposer: string;
101
- proposedAt: number;
102
- expiresAt: number;
103
- }
104
- export interface MultisigAction extends MultisigProposal {
105
- signatures: Record<string, number>;
106
- executedAt: number;
107
- }
108
- /**
109
- * Events for MultisigDAO
110
- */
111
- export type MultisigEvent = {
112
- eventName: 'propose';
113
- agent: string;
114
- proposalId: string;
115
- actionType: string;
116
- payload: unknown;
117
- } | {
118
- eventName: 'sign';
119
- agent: string;
120
- } | {
121
- eventName: 'execute';
122
- agent: string;
123
- } | {
124
- eventName: 'cancel';
125
- agent: string;
126
- } | {
127
- eventName: 'propose_add_signer';
128
- agent: string;
129
- proposalId: string;
130
- newSigner: string;
131
- } | {
132
- eventName: 'propose_remove_signer';
133
- agent: string;
134
- proposalId: string;
135
- removeSigner: string;
136
- } | {
137
- eventName: 'propose_change_threshold';
138
- agent: string;
139
- proposalId: string;
140
- newThreshold: number;
141
- } | {
142
- eventName: 'apply_signer_change';
143
- agent: string;
144
- } | {
145
- eventName: 'dissolve';
146
- agent: string;
147
- signatureCount: number;
148
- };
149
- /**
150
- * Token DAO state.
151
- * Token-weighted voting. Voting power proportional to holdings.
152
- */
153
- export interface TokenDAOState {
154
- schema: 'TokenDAO';
155
- name: string;
156
- tokenId: string;
157
- balances: Record<string, number>;
158
- delegations: Record<string, string>;
159
- proposalThreshold: number;
160
- votingPeriodMs: number;
161
- timelockMs: number;
162
- quorum: number;
163
- proposal: TokenProposal | null;
164
- votes: TokenVotes | null;
165
- executedProposals: TokenProposalResult[];
166
- rejectedProposals: TokenProposalResult[];
167
- cancelledProposals: TokenProposal[];
168
- metadata: DAOMetadata;
169
- status: DAOStatus;
170
- }
171
- export interface TokenProposal {
172
- id: string;
173
- title: string;
174
- description: string;
175
- actionType: string;
176
- payload: unknown;
177
- proposer: string;
178
- proposedAt: number;
179
- votingEndsAt: number;
180
- snapshotBlock?: number;
181
- queuedAt?: number;
182
- executableAt?: number;
183
- }
184
- export interface TokenVotes {
185
- for: number;
186
- against: number;
187
- abstain: number;
188
- voters: Record<string, TokenVote>;
189
- }
190
- export interface TokenVote {
191
- vote: VoteChoice;
192
- weight: number;
193
- votedAt: number;
194
- }
195
- export interface TokenProposalResult extends TokenProposal {
196
- votes: TokenVotes;
197
- executedAt?: number;
198
- rejectedAt?: number;
199
- }
200
- /**
201
- * Events for TokenDAO
202
- */
203
- export type TokenEvent = {
204
- eventName: 'propose';
205
- agent: string;
206
- proposalId: string;
207
- title: string;
208
- description: string;
209
- actionType: string;
210
- payload: unknown;
211
- snapshotBlock?: number;
212
- } | {
213
- eventName: 'vote';
214
- agent: string;
215
- vote: VoteChoice;
216
- } | {
217
- eventName: 'queue';
218
- agent: string;
219
- } | {
220
- eventName: 'execute';
221
- agent: string;
222
- } | {
223
- eventName: 'reject';
224
- agent: string;
225
- } | {
226
- eventName: 'cancel';
227
- agent: string;
228
- } | {
229
- eventName: 'delegate';
230
- agent: string;
231
- delegateTo: string;
232
- } | {
233
- eventName: 'undelegate';
234
- agent: string;
235
- };
236
- /**
237
- * Threshold DAO state.
238
- * Reputation-based governance. Minimum reputation required for participation.
239
- */
240
- export interface ThresholdDAOState {
241
- schema: 'ThresholdDAO';
242
- name: string;
243
- members: string[];
244
- memberJoinedAt: Record<string, number>;
245
- memberThreshold: number;
246
- voteThreshold: number;
247
- proposeThreshold: number;
248
- quorum: number;
249
- votingPeriodMs: number;
250
- proposal: ThresholdProposal | null;
251
- votes: ThresholdVotes | null;
252
- history: ThresholdHistoryEntry[];
253
- metadata: DAOMetadata;
254
- status: DAOStatus;
255
- }
256
- export interface ThresholdProposal {
257
- id: string;
258
- title: string;
259
- description?: string;
260
- actionType: string;
261
- payload: unknown;
262
- proposer: string;
263
- proposedAt: number;
264
- deadline: number;
265
- }
266
- export interface ThresholdVotes {
267
- for: string[];
268
- against: string[];
269
- abstain: string[];
270
- }
271
- export interface ThresholdHistoryEntry {
272
- type: 'executed' | 'rejected';
273
- proposal: ThresholdProposal;
274
- votes: ThresholdVotes;
275
- at: number;
276
- }
277
- /**
278
- * Events for ThresholdDAO
279
- * Note: agentReputation is passed in from the reputation oracle
280
- */
281
- export type ThresholdEvent = {
282
- eventName: 'propose';
283
- agent: string;
284
- agentReputation: number;
285
- proposalId: string;
286
- title: string;
287
- description?: string;
288
- actionType: string;
289
- payload: unknown;
290
- } | {
291
- eventName: 'vote';
292
- agent: string;
293
- agentReputation: number;
294
- vote: VoteChoice;
295
- } | {
296
- eventName: 'execute';
297
- agent: string;
298
- } | {
299
- eventName: 'reject';
300
- agent: string;
301
- } | {
302
- eventName: 'join';
303
- agent: string;
304
- agentReputation: number;
305
- } | {
306
- eventName: 'leave';
307
- agent: string;
308
- } | {
309
- eventName: 'propose_threshold_change';
310
- agent: string;
311
- agentReputation: number;
312
- proposalId: string;
313
- memberThreshold?: number;
314
- voteThreshold?: number;
315
- proposeThreshold?: number;
316
- };
317
- /**
318
- * Any DAO state
319
- */
320
- export type DAOState = SingleOwnerDAOState | MultisigDAOState | TokenDAOState | ThresholdDAOState;
321
- /**
322
- * Any DAO event
323
- */
324
- export type DAOEvent = SingleOwnerEvent | MultisigEvent | TokenEvent | ThresholdEvent;
325
- /**
326
- * DAO schema names for type discrimination
327
- */
328
- export type DAOSchema = 'SingleOwnerDAO' | 'MultisigDAO' | 'TokenDAO' | 'ThresholdDAO';
329
- /**
330
- * Type guard for SingleOwnerDAO
331
- */
332
- export declare function isSingleOwnerDAO(state: DAOState): state is SingleOwnerDAOState;
333
- /**
334
- * Type guard for MultisigDAO
335
- */
336
- export declare function isMultisigDAO(state: DAOState): state is MultisigDAOState;
337
- /**
338
- * Type guard for TokenDAO
339
- */
340
- export declare function isTokenDAO(state: DAOState): state is TokenDAOState;
341
- /**
342
- * Type guard for ThresholdDAO
343
- */
344
- export declare function isThresholdDAO(state: DAOState): state is ThresholdDAOState;
@@ -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,155 +0,0 @@
1
- /**
2
- * Markets Application Types
3
- *
4
- * Constants, types, and utilities for the Markets application on OttoChain.
5
- *
6
- * Core types (MarketType, MarketState, Market, Commitment, Resolution) are
7
- * exported from proto-generated types in index.ts.
8
- *
9
- * @packageDocumentation
10
- */
11
- import { MarketType, MarketState } from '../../generated/ottochain/apps/markets/v1/market_pb.js';
12
- /**
13
- * Commitment direction (for prediction markets)
14
- */
15
- export declare enum CommitmentSide {
16
- UNSPECIFIED = 0,
17
- YES = 1,
18
- NO = 2
19
- }
20
- /**
21
- * Market configuration type
22
- */
23
- export interface MarketConfig {
24
- /** Platform fee as percentage (0.01 = 1%) */
25
- platformFeePercent: number;
26
- /** Market creator fee as percentage */
27
- creatorFeePercent: number;
28
- /** Oracle fee as percentage */
29
- oracleFeePercent: number;
30
- /** Minimum quorum for market validity (in tokens) */
31
- minQuorum: bigint;
32
- /** Default resolution window in epochs */
33
- resolutionWindowEpochs: number;
34
- /** Dispute window after resolution in epochs */
35
- disputeWindowEpochs: number;
36
- /** Minimum commitment amount */
37
- minCommitment: bigint;
38
- /** Maximum slippage for AMM-style markets */
39
- maxSlippagePercent: number;
40
- }
41
- /**
42
- * Default market configuration
43
- */
44
- export declare const DEFAULT_MARKET_CONFIG: MarketConfig;
45
- /**
46
- * Type-specific market configurations
47
- */
48
- export declare const MARKET_TYPE_CONFIGS: Record<MarketType, Partial<MarketConfig>>;
49
- /**
50
- * Valid transitions for each market state (aligned with proto MarketState enum)
51
- */
52
- export declare const MARKET_TRANSITIONS: Record<MarketState, readonly string[]>;
53
- /**
54
- * Check if a market state is terminal
55
- */
56
- export declare function isTerminalMarketState(state: MarketState): boolean;
57
- /**
58
- * Calculate effective commitment after fees
59
- *
60
- * @param amount - Raw commitment amount
61
- * @param config - Market configuration (uses defaults if not provided)
62
- * @returns Net commitment amount after platform fees
63
- */
64
- export declare function calculateNetCommitment(amount: bigint, config?: Partial<MarketConfig>): bigint;
65
- /**
66
- * Calculate total fees for a commitment
67
- *
68
- * @param amount - Commitment amount
69
- * @param marketType - Type of market for type-specific fees
70
- * @returns Fee breakdown object
71
- */
72
- export declare function calculateFees(amount: bigint, marketType?: MarketType): {
73
- platform: bigint;
74
- creator: bigint;
75
- oracle: bigint;
76
- total: bigint;
77
- };
78
- /**
79
- * Outcome shares for payout calculation
80
- */
81
- export interface OutcomeShares {
82
- /** Total committed to winning outcome */
83
- winningPool: bigint;
84
- /** Total committed to losing outcome(s) */
85
- losingPool: bigint;
86
- /** Individual's commitment to winning outcome */
87
- userCommitment: bigint;
88
- }
89
- /**
90
- * Calculate payout for a winning commitment in a prediction market
91
- *
92
- * Winner receives: their original + proportional share of losing pool (minus fees)
93
- *
94
- * @param shares - Pool and commitment details
95
- * @param marketType - Type of market for fee calculation
96
- * @returns Payout amount
97
- */
98
- export declare function calculatePayout(shares: OutcomeShares, marketType?: MarketType): bigint;
99
- /**
100
- * Calculate refund for cancelled market
101
- *
102
- * @param commitment - Original commitment amount
103
- * @param refundFeePercent - Optional fee retained on refund (default 0)
104
- * @returns Refund amount
105
- */
106
- export declare function calculateRefund(commitment: bigint, refundFeePercent?: number): bigint;
107
- /**
108
- * Validate a commitment meets market requirements
109
- */
110
- export interface CommitmentValidation {
111
- valid: boolean;
112
- reason?: string;
113
- }
114
- /**
115
- * Validate a commitment against market rules
116
- */
117
- export declare function validateCommitment(amount: bigint, marketState: MarketState, config?: Partial<MarketConfig>): CommitmentValidation;
118
- /**
119
- * Calculate crowdfund progress
120
- */
121
- export interface CrowdfundProgress {
122
- /** Current total committed */
123
- current: bigint;
124
- /** Target goal */
125
- goal: bigint;
126
- /** Percentage complete (0-100) */
127
- percentComplete: number;
128
- /** Whether goal has been reached */
129
- goalReached: boolean;
130
- }
131
- /**
132
- * Calculate crowdfund campaign progress
133
- */
134
- export declare function calculateCrowdfundProgress(current: bigint, goal: bigint): CrowdfundProgress;
135
- /**
136
- * Tier definition for group buys
137
- */
138
- export interface GroupBuyTier {
139
- /** Minimum participants for this tier */
140
- minParticipants: number;
141
- /** Discount percentage for this tier */
142
- discountPercent: number;
143
- }
144
- /**
145
- * Calculate applicable discount based on participant count
146
- */
147
- export declare function calculateGroupBuyDiscount(participantCount: number, tiers: GroupBuyTier[]): number;
148
- /**
149
- * Check if a value is a valid MarketState
150
- */
151
- export declare function isMarketState(value: unknown): value is MarketState;
152
- /**
153
- * Check if a value is a valid MarketType
154
- */
155
- export declare function isMarketType(value: unknown): value is MarketType;