@trufnetwork/sdk-js 0.5.10 → 0.6.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.
Files changed (60) hide show
  1. package/README.md +45 -0
  2. package/dist/cjs/client/client.cjs +30 -0
  3. package/dist/cjs/client/client.cjs.map +2 -2
  4. package/dist/cjs/contracts-api/action.cjs +22 -0
  5. package/dist/cjs/contracts-api/action.cjs.map +2 -2
  6. package/dist/cjs/contracts-api/action.test.cjs +63 -0
  7. package/dist/cjs/contracts-api/action.test.cjs.map +7 -0
  8. package/dist/cjs/contracts-api/orderbookAction.cjs +880 -0
  9. package/dist/cjs/contracts-api/orderbookAction.cjs.map +7 -0
  10. package/dist/cjs/internal.cjs +9 -0
  11. package/dist/cjs/internal.cjs.map +2 -2
  12. package/dist/cjs/types/bridge.cjs.map +1 -1
  13. package/dist/cjs/types/orderbook.cjs +19 -0
  14. package/dist/cjs/types/orderbook.cjs.map +7 -0
  15. package/dist/cjs/util/AttestationEncoding.cjs +3 -2
  16. package/dist/cjs/util/AttestationEncoding.cjs.map +2 -2
  17. package/dist/cjs/util/orderbookHelpers.cjs +194 -0
  18. package/dist/cjs/util/orderbookHelpers.cjs.map +7 -0
  19. package/dist/cjs/util/orderbookHelpers.test.cjs +217 -0
  20. package/dist/cjs/util/orderbookHelpers.test.cjs.map +7 -0
  21. package/dist/esm/client/client.mjs +30 -0
  22. package/dist/esm/client/client.mjs.map +2 -2
  23. package/dist/esm/contracts-api/action.mjs +22 -0
  24. package/dist/esm/contracts-api/action.mjs.map +2 -2
  25. package/dist/esm/contracts-api/action.test.mjs +61 -0
  26. package/dist/esm/contracts-api/action.test.mjs.map +7 -0
  27. package/dist/esm/contracts-api/orderbookAction.mjs +875 -0
  28. package/dist/esm/contracts-api/orderbookAction.mjs.map +7 -0
  29. package/dist/esm/internal.mjs +16 -0
  30. package/dist/esm/internal.mjs.map +2 -2
  31. package/dist/esm/types/orderbook.mjs +1 -0
  32. package/dist/esm/types/orderbook.mjs.map +7 -0
  33. package/dist/esm/util/AttestationEncoding.mjs +3 -2
  34. package/dist/esm/util/AttestationEncoding.mjs.map +2 -2
  35. package/dist/esm/util/orderbookHelpers.mjs +173 -0
  36. package/dist/esm/util/orderbookHelpers.mjs.map +7 -0
  37. package/dist/esm/util/orderbookHelpers.test.mjs +229 -0
  38. package/dist/esm/util/orderbookHelpers.test.mjs.map +7 -0
  39. package/dist/tsconfig.build.tsbuildinfo +1 -1
  40. package/dist/types/client/client.d.ts +23 -1
  41. package/dist/types/client/client.d.ts.map +1 -1
  42. package/dist/types/contracts-api/action.d.ts +11 -1
  43. package/dist/types/contracts-api/action.d.ts.map +1 -1
  44. package/dist/types/contracts-api/action.test.d.ts +2 -0
  45. package/dist/types/contracts-api/action.test.d.ts.map +1 -0
  46. package/dist/types/contracts-api/orderbookAction.d.ts +303 -0
  47. package/dist/types/contracts-api/orderbookAction.d.ts.map +1 -0
  48. package/dist/types/internal.d.ts +3 -0
  49. package/dist/types/internal.d.ts.map +1 -1
  50. package/dist/types/types/bridge.d.ts +45 -0
  51. package/dist/types/types/bridge.d.ts.map +1 -1
  52. package/dist/types/types/orderbook.d.ts +376 -0
  53. package/dist/types/types/orderbook.d.ts.map +1 -0
  54. package/dist/types/util/AttestationEncoding.d.ts +9 -1
  55. package/dist/types/util/AttestationEncoding.d.ts.map +1 -1
  56. package/dist/types/util/orderbookHelpers.d.ts +161 -0
  57. package/dist/types/util/orderbookHelpers.d.ts.map +1 -0
  58. package/dist/types/util/orderbookHelpers.test.d.ts +2 -0
  59. package/dist/types/util/orderbookHelpers.test.d.ts.map +1 -0
  60. package/package.json +1 -1
@@ -0,0 +1,376 @@
1
+ /**
2
+ * Order Book Types for TRUF.NETWORK Prediction Markets
3
+ *
4
+ * Binary prediction markets where outcomes are YES (true) or NO (false).
5
+ * Prices are in cents (1-99), representing probability.
6
+ */
7
+ /** Valid bridge identifiers for collateral */
8
+ export type BridgeIdentifier = "hoodi_tt2" | "sepolia_bridge" | "ethereum_bridge";
9
+ /** Full market information */
10
+ export interface MarketInfo {
11
+ /** Unique market identifier */
12
+ id: number;
13
+ /** SHA256 hash of query components (32 bytes) */
14
+ hash: Uint8Array;
15
+ /** ABI-encoded query tuple */
16
+ queryComponents: Uint8Array;
17
+ /** Bridge used for collateral */
18
+ bridge: BridgeIdentifier;
19
+ /** Unix timestamp when market settles */
20
+ settleTime: number;
21
+ /** Whether market has been settled */
22
+ settled: boolean;
23
+ /** Winning outcome (null if not settled) */
24
+ winningOutcome: boolean | null;
25
+ /** Unix timestamp when settled (null if not settled) */
26
+ settledAt: number | null;
27
+ /** Maximum bid-ask spread allowed (1-50 cents) */
28
+ maxSpread: number;
29
+ /** Minimum order size (string for large values) */
30
+ minOrderSize: string;
31
+ /** Unix timestamp when market was created */
32
+ createdAt: number;
33
+ /** Creator's wallet address (20 bytes) */
34
+ creator: Uint8Array;
35
+ }
36
+ /** Lighter market summary for listings */
37
+ export interface MarketSummary {
38
+ /** Unique market identifier */
39
+ id: number;
40
+ /** SHA256 hash of query components (32 bytes) */
41
+ hash: Uint8Array;
42
+ /** Unix timestamp when market settles */
43
+ settleTime: number;
44
+ /** Whether market has been settled */
45
+ settled: boolean;
46
+ /** Winning outcome (null if not settled) */
47
+ winningOutcome: boolean | null;
48
+ /** Maximum bid-ask spread allowed (1-50 cents) */
49
+ maxSpread: number;
50
+ /** Minimum order size (string for large values) */
51
+ minOrderSize: string;
52
+ /** Unix timestamp when market was created */
53
+ createdAt: number;
54
+ }
55
+ /** Market collateral validation result */
56
+ export interface MarketValidation {
57
+ /** Whether YES/NO token counts match */
58
+ validTokenBinaries: boolean;
59
+ /** Whether vault balance matches expected collateral */
60
+ validCollateral: boolean;
61
+ /** Total YES shares (NUMERIC as string) */
62
+ totalTrue: string;
63
+ /** Total NO shares (NUMERIC as string) */
64
+ totalFalse: string;
65
+ /** Vault balance (NUMERIC as string) */
66
+ vaultBalance: string;
67
+ /** Expected collateral (NUMERIC as string) */
68
+ expectedCollateral: string;
69
+ /** Value locked in open buy orders (NUMERIC as string) */
70
+ openBuysValue: string;
71
+ }
72
+ /** Single order book entry */
73
+ export interface OrderBookEntry {
74
+ /** Wallet address of order owner (20 bytes) */
75
+ walletAddress: Uint8Array;
76
+ /**
77
+ * Price in cents:
78
+ * - Negative (-99 to -1): Buy order at |price| cents
79
+ * - Zero (0): Holding (shares owned, not listed)
80
+ * - Positive (1 to 99): Sell order at price cents
81
+ */
82
+ price: number;
83
+ /** Number of shares */
84
+ amount: number;
85
+ /** Unix timestamp of last update (used for FIFO ordering) */
86
+ lastUpdated: number;
87
+ }
88
+ /** User's position in a market */
89
+ export interface UserPosition {
90
+ /** Market identifier */
91
+ queryId: number;
92
+ /** Outcome: true=YES, false=NO */
93
+ outcome: boolean;
94
+ /**
95
+ * Price in cents:
96
+ * - Negative: Buy order
97
+ * - Zero: Holding
98
+ * - Positive: Sell order
99
+ */
100
+ price: number;
101
+ /** Number of shares */
102
+ amount: number;
103
+ /** Unix timestamp of last update */
104
+ lastUpdated: number;
105
+ }
106
+ /** Aggregated depth at a price level */
107
+ export interface DepthLevel {
108
+ /** Price level in cents */
109
+ price: number;
110
+ /** Total shares in buy orders at this price */
111
+ buyVolume: number;
112
+ /** Total shares in sell orders at this price */
113
+ sellVolume: number;
114
+ }
115
+ /** Best bid/ask prices for a market outcome */
116
+ export interface BestPrices {
117
+ /** Best bid price (null if no bids) */
118
+ bestBid: number | null;
119
+ /** Best ask price (null if no asks) */
120
+ bestAsk: number | null;
121
+ /** Spread between best ask and bid (null if either missing) */
122
+ spread: number | null;
123
+ }
124
+ /** User's locked collateral across all markets */
125
+ export interface UserCollateral {
126
+ /** Total locked collateral in wei (NUMERIC(78,0) as string) */
127
+ totalLocked: string;
128
+ /** Collateral locked in buy orders (NUMERIC as string) */
129
+ buyOrdersLocked: string;
130
+ /** Value of owned shares (NUMERIC as string) */
131
+ sharesValue: string;
132
+ }
133
+ /** Fee distribution summary for a market */
134
+ export interface DistributionSummary {
135
+ /** Unique distribution identifier */
136
+ distributionId: number;
137
+ /** Market identifier */
138
+ queryId: number;
139
+ /** Total fees distributed (NUMERIC as string) */
140
+ totalFees: string;
141
+ /** Unix timestamp when distributed */
142
+ distributedAt: number;
143
+ }
144
+ /** Per-LP reward detail */
145
+ export interface LPRewardDetail {
146
+ /** LP's wallet address (20 bytes) */
147
+ walletAddress: Uint8Array;
148
+ /** Reward amount (NUMERIC as string) */
149
+ rewardAmount: string;
150
+ /** Share percentage of total rewards (0-100) */
151
+ sharePercentage: number;
152
+ }
153
+ /** Reward history for a participant */
154
+ export interface RewardHistory {
155
+ /** Distribution identifier */
156
+ distributionId: number;
157
+ /** Market identifier */
158
+ queryId: number;
159
+ /** Reward amount (NUMERIC as string) */
160
+ rewardAmount: string;
161
+ /** Share percentage of total rewards */
162
+ totalRewardPercent: number;
163
+ /** Unix timestamp when distributed */
164
+ distributedAt: number;
165
+ }
166
+ /** Input for creating a new market */
167
+ export interface CreateMarketInput {
168
+ /** Bridge identifier for collateral */
169
+ bridge: BridgeIdentifier;
170
+ /** ABI-encoded query components */
171
+ queryComponents: Uint8Array;
172
+ /** Unix timestamp for market settlement */
173
+ settleTime: number;
174
+ /** Maximum bid-ask spread (1-50 cents) */
175
+ maxSpread: number;
176
+ /** Minimum order size (use string for large values to avoid JS safe integer limits) */
177
+ minOrderSize: number | string;
178
+ }
179
+ /** Input for placing buy or sell orders */
180
+ export interface PlaceOrderInput {
181
+ /** Market identifier */
182
+ queryId: number;
183
+ /** Outcome: true=YES, false=NO */
184
+ outcome: boolean;
185
+ /** Price in cents (1-99) */
186
+ price: number;
187
+ /** Number of shares */
188
+ amount: number;
189
+ }
190
+ /** Input for split limit orders (market making) */
191
+ export interface PlaceSplitLimitOrderInput {
192
+ /** Market identifier */
193
+ queryId: number;
194
+ /** YES price in cents (1-99). NO price will be 100 - truePrice */
195
+ truePrice: number;
196
+ /** Number of share pairs to create */
197
+ amount: number;
198
+ }
199
+ /** Input for canceling an order */
200
+ export interface CancelOrderInput {
201
+ /** Market identifier */
202
+ queryId: number;
203
+ /** Outcome: true=YES, false=NO */
204
+ outcome: boolean;
205
+ /** Price of order to cancel (cannot be 0) */
206
+ price: number;
207
+ }
208
+ /** Input for modifying a buy order */
209
+ export interface ChangeBidInput {
210
+ /** Market identifier */
211
+ queryId: number;
212
+ /** Outcome: true=YES, false=NO */
213
+ outcome: boolean;
214
+ /** Current price (must be negative) */
215
+ oldPrice: number;
216
+ /** New price (must be negative) */
217
+ newPrice: number;
218
+ /** New amount */
219
+ newAmount: number;
220
+ }
221
+ /** Input for modifying a sell order */
222
+ export interface ChangeAskInput {
223
+ /** Market identifier */
224
+ queryId: number;
225
+ /** Outcome: true=YES, false=NO */
226
+ outcome: boolean;
227
+ /** Current price (must be non-negative) */
228
+ oldPrice: number;
229
+ /** New price (must be non-negative) */
230
+ newPrice: number;
231
+ /** New amount */
232
+ newAmount: number;
233
+ }
234
+ /** Input for listing markets */
235
+ export interface ListMarketsInput {
236
+ /**
237
+ * Filter by settlement status:
238
+ * - null/undefined: All markets
239
+ * - true: Unsettled markets only
240
+ * - false: Settled markets only
241
+ */
242
+ settledFilter?: boolean | null;
243
+ /** Maximum number of markets to return */
244
+ limit?: number;
245
+ /** Offset for pagination */
246
+ offset?: number;
247
+ }
248
+ /** Base input for binary market creation helpers */
249
+ export interface BaseBinaryMarketInput {
250
+ /** Data provider's Ethereum address */
251
+ dataProvider: string;
252
+ /** Stream ID (32 characters) */
253
+ streamId: string;
254
+ /** Unix timestamp for price/value check */
255
+ timestamp: number;
256
+ /** Block height for data snapshot */
257
+ frozenAt: number;
258
+ /** Bridge identifier for collateral */
259
+ bridge: BridgeIdentifier;
260
+ /** Unix timestamp for market settlement */
261
+ settleTime: number;
262
+ /** Maximum bid-ask spread (1-50 cents) */
263
+ maxSpread: number;
264
+ /** Minimum order size (use string for large values to avoid JS safe integer limits) */
265
+ minOrderSize: number | string;
266
+ }
267
+ /** Input for price above/below threshold markets */
268
+ export interface CreatePriceThresholdMarketInput extends BaseBinaryMarketInput {
269
+ /** Price threshold (as decimal string, e.g., "50000.00") */
270
+ threshold: string;
271
+ }
272
+ /** Input for value in range markets */
273
+ export interface CreateValueInRangeMarketInput extends BaseBinaryMarketInput {
274
+ /** Minimum value of range (as decimal string) */
275
+ minValue: string;
276
+ /** Maximum value of range (as decimal string) */
277
+ maxValue: string;
278
+ }
279
+ /** Input for value equals markets */
280
+ export interface CreateValueEqualsMarketInput extends BaseBinaryMarketInput {
281
+ /** Target value (as decimal string) */
282
+ targetValue: string;
283
+ /** Acceptable tolerance (as decimal string) */
284
+ tolerance: string;
285
+ }
286
+ /** @internal Raw market info from database */
287
+ export interface RawMarketInfo {
288
+ id: number;
289
+ hash: string;
290
+ query_components: string;
291
+ bridge: string;
292
+ settle_time: number;
293
+ settled: boolean;
294
+ winning_outcome: boolean | null;
295
+ settled_at: number | null;
296
+ max_spread: number;
297
+ min_order_size: string | number;
298
+ created_at: number;
299
+ creator: string;
300
+ }
301
+ /** @internal Raw market summary from database */
302
+ export interface RawMarketSummary {
303
+ id: number;
304
+ hash: string;
305
+ settle_time: number;
306
+ settled: boolean;
307
+ winning_outcome: boolean | null;
308
+ max_spread: number;
309
+ min_order_size: string | number;
310
+ created_at: number;
311
+ }
312
+ /** @internal Raw order book entry from database */
313
+ export interface RawOrderBookEntry {
314
+ wallet_address: string;
315
+ price: number;
316
+ amount: number;
317
+ last_updated: number;
318
+ }
319
+ /** @internal Raw user position from database */
320
+ export interface RawUserPosition {
321
+ query_id: number;
322
+ outcome: boolean;
323
+ price: number;
324
+ amount: number;
325
+ last_updated: number;
326
+ }
327
+ /** @internal Raw depth level from database */
328
+ export interface RawDepthLevel {
329
+ price: number | string;
330
+ buy_volume: number | string;
331
+ sell_volume: number | string;
332
+ }
333
+ /** @internal Raw best prices from database */
334
+ export interface RawBestPrices {
335
+ best_bid: number | null;
336
+ best_ask: number | null;
337
+ spread: number | null;
338
+ }
339
+ /** @internal Raw user collateral from database */
340
+ export interface RawUserCollateral {
341
+ total_locked: string;
342
+ buy_orders_locked: string;
343
+ shares_value: string;
344
+ }
345
+ /** @internal Raw market validation from database */
346
+ export interface RawMarketValidation {
347
+ valid_token_binaries: boolean;
348
+ valid_collateral: boolean;
349
+ total_true: string;
350
+ total_false: string;
351
+ vault_balance: string;
352
+ expected_collateral: string;
353
+ open_buys_value: string;
354
+ }
355
+ /** @internal Raw distribution summary from database */
356
+ export interface RawDistributionSummary {
357
+ distribution_id: number;
358
+ query_id: number;
359
+ total_fees: string;
360
+ distributed_at: number;
361
+ }
362
+ /** @internal Raw LP reward detail from database */
363
+ export interface RawLPRewardDetail {
364
+ wallet_address: string;
365
+ reward_amount: string;
366
+ share_percentage: number;
367
+ }
368
+ /** @internal Raw reward history from database */
369
+ export interface RawRewardHistory {
370
+ distribution_id: number;
371
+ query_id: number;
372
+ reward_amount: string;
373
+ total_reward_percent: number;
374
+ distributed_at: number;
375
+ }
376
+ //# sourceMappingURL=orderbook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderbook.d.ts","sourceRoot":"","sources":["../../../src/types/orderbook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,8CAA8C;AAC9C,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,gBAAgB,GAChB,iBAAiB,CAAC;AAMtB,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,IAAI,EAAE,UAAU,CAAC;IACjB,8BAA8B;IAC9B,eAAe,EAAE,UAAU,CAAC;IAC5B,iCAAiC;IACjC,MAAM,EAAE,gBAAgB,CAAC;IACzB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,4CAA4C;IAC5C,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,wDAAwD;IACxD,SAAS,EAAE,MA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D;AACjD,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -5,6 +5,13 @@
5
5
  * the node's request_attestation action. It uses kwil-js's native encoding
6
6
  * to ensure perfect compatibility with kwil-db's EncodedValue.MarshalBinary() format.
7
7
  */
8
+ /**
9
+ * Type hint for specifying explicit types when encoding arguments.
10
+ * Use Utils.DataType from kwil-js (e.g., Utils.DataType.Numeric(36, 18))
11
+ *
12
+ * DataInfo structure: { name: VarType, is_array: boolean, metadata?: number[] }
13
+ */
14
+ export type TypeHint = any;
8
15
  /**
9
16
  * Encodes action arguments into canonical bytes using kwil-js utilities.
10
17
  *
@@ -13,10 +20,11 @@
13
20
  * Each encoded_arg uses kwil-db's EncodedValue.MarshalBinary() format.
14
21
  *
15
22
  * @param args - Array of arguments to encode
23
+ * @param types - Optional map of argument index to type hint (for NUMERIC, etc.)
16
24
  * @returns Encoded bytes
17
25
  * @throws Error if any argument cannot be encoded
18
26
  */
19
- export declare function encodeActionArgs(args: any[]): Uint8Array;
27
+ export declare function encodeActionArgs(args: any[], types?: Record<number, TypeHint>): Uint8Array;
20
28
  /**
21
29
  * Reads a uint32 value in little-endian format
22
30
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AttestationEncoding.d.ts","sourceRoot":"","sources":["../../../src/util/AttestationEncoding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,UAAU,CA2CxD;AAiBD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOvE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MA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AAM,EAAE,GAAG,EAAE,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,GAAG,EAAE,CAAC;IACjB,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AA+CD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,EAClB,MAAM,GAAE,MAAU,GACjB;IAAE,KAAK,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAuChD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,GAAG,CAkClE;AA4CD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,CAsDzE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,CAqClE;AA8BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,UAAU,GAAG,wBAAwB,CA6IrF"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Order Book Helper Utilities
3
+ *
4
+ * Provides encoding functions for query components and byte conversion utilities.
5
+ */
6
+ /**
7
+ * Encodes action arguments for order book queries using Kwil's native encoding.
8
+ *
9
+ * @param dataProvider - Data provider's Ethereum address
10
+ * @param streamId - Stream ID (32 characters)
11
+ * @param timestamp - Unix timestamp for price/value check
12
+ * @param threshold - Threshold value (as decimal string, e.g., "50000.00")
13
+ * @param frozenAt - Block height for data snapshot (0 for latest)
14
+ * @returns Kwil-encoded bytes compatible with call_dispatch
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const args = encodeActionArgs(
19
+ * "0x1234567890abcdef1234567890abcdef12345678",
20
+ * "my_stream_id____________________", // 32 chars
21
+ * 1700000000,
22
+ * "50000.00",
23
+ * 0
24
+ * );
25
+ * ```
26
+ */
27
+ export declare function encodeActionArgs(dataProvider: string, streamId: string, timestamp: number, threshold: string, frozenAt: number): Uint8Array;
28
+ /**
29
+ * Encodes action arguments for range-based markets using Kwil's native encoding.
30
+ *
31
+ * @param dataProvider - Data provider's Ethereum address
32
+ * @param streamId - Stream ID
33
+ * @param timestamp - Unix timestamp
34
+ * @param minValue - Minimum value of range
35
+ * @param maxValue - Maximum value of range
36
+ * @param frozenAt - Block height (0 for latest)
37
+ * @returns Kwil-encoded bytes compatible with call_dispatch
38
+ */
39
+ export declare function encodeRangeActionArgs(dataProvider: string, streamId: string, timestamp: number, minValue: string, maxValue: string, frozenAt: number): Uint8Array;
40
+ /**
41
+ * Encodes action arguments for value equals markets using Kwil's native encoding.
42
+ *
43
+ * @param dataProvider - Data provider's Ethereum address
44
+ * @param streamId - Stream ID
45
+ * @param timestamp - Unix timestamp
46
+ * @param targetValue - Target value
47
+ * @param tolerance - Acceptable tolerance
48
+ * @param frozenAt - Block height (0 for latest)
49
+ * @returns Kwil-encoded bytes compatible with call_dispatch
50
+ */
51
+ export declare function encodeEqualsActionArgs(dataProvider: string, streamId: string, timestamp: number, targetValue: string, tolerance: string, frozenAt: number): Uint8Array;
52
+ /**
53
+ * Encodes full query components for market creation.
54
+ *
55
+ * The query components are ABI-encoded as a tuple:
56
+ * (address dataProvider, bytes32 streamId, string actionId, bytes args)
57
+ *
58
+ * @param dataProvider - Data provider's Ethereum address
59
+ * @param streamId - Stream ID (will be padded to 32 bytes)
60
+ * @param actionId - Action identifier (e.g., "price_above_threshold")
61
+ * @param args - Pre-encoded action arguments from encodeActionArgs()
62
+ * @returns ABI-encoded query components
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const args = encodeActionArgs(...);
67
+ * const queryComponents = encodeQueryComponents(
68
+ * "0x1234567890abcdef1234567890abcdef12345678",
69
+ * "my_stream_id____________________",
70
+ * "price_above_threshold",
71
+ * args
72
+ * );
73
+ * ```
74
+ */
75
+ export declare function encodeQueryComponents(dataProvider: string, streamId: string, actionId: string, args: Uint8Array): Uint8Array;
76
+ /**
77
+ * Converts a string to bytes32, padding with zeros if needed.
78
+ *
79
+ * @param str - String to convert (max 32 characters)
80
+ * @returns bytes32 as hex string
81
+ */
82
+ export declare function stringToBytes32(str: string): string;
83
+ /**
84
+ * Converts a hex string to Uint8Array.
85
+ *
86
+ * @param hex - Hex string (with or without 0x prefix)
87
+ * @returns Uint8Array
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const bytes = hexToBytes("0x1234abcd");
92
+ * const bytes2 = hexToBytes("1234abcd");
93
+ * ```
94
+ */
95
+ export declare function hexToBytes(hex: string): Uint8Array;
96
+ /**
97
+ * Converts a database bytes value (hex or base64) to Uint8Array.
98
+ * kwil-js may return BYTEA as hex or base64 depending on version/context.
99
+ *
100
+ * @param value - Hex string, base64 string, or Uint8Array
101
+ * @returns Uint8Array
102
+ */
103
+ export declare function dbBytesToUint8Array(value: string | Uint8Array): Uint8Array;
104
+ /**
105
+ * Converts a Uint8Array to hex string with 0x prefix.
106
+ *
107
+ * @param bytes - Uint8Array to convert
108
+ * @returns Hex string with 0x prefix
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const hex = bytesToHex(new Uint8Array([0x12, 0x34]));
113
+ * // Returns "0x1234"
114
+ * ```
115
+ */
116
+ export declare function bytesToHex(bytes: Uint8Array): string;
117
+ /**
118
+ * Validates a price value for order operations.
119
+ *
120
+ * @param price - Price to validate (1-99)
121
+ * @param operation - Operation name for error message
122
+ * @throws Error if price is invalid
123
+ */
124
+ export declare function validatePrice(price: number, operation: string): void;
125
+ /**
126
+ * Validates an amount value for order operations.
127
+ *
128
+ * @param amount - Amount to validate (must be positive)
129
+ * @param operation - Operation name for error message
130
+ * @throws Error if amount is invalid
131
+ */
132
+ export declare function validateAmount(amount: number, operation: string): void;
133
+ /**
134
+ * Validates a bridge identifier.
135
+ *
136
+ * @param bridge - Bridge identifier to validate
137
+ * @throws Error if bridge is invalid
138
+ */
139
+ export declare function validateBridge(bridge: string): void;
140
+ /**
141
+ * Validates max spread for market creation.
142
+ *
143
+ * @param maxSpread - Max spread to validate (1-50)
144
+ * @throws Error if maxSpread is invalid
145
+ */
146
+ export declare function validateMaxSpread(maxSpread: number): void;
147
+ /**
148
+ * Validates settle time for market creation.
149
+ *
150
+ * @param settleTime - Unix timestamp to validate (must be in future)
151
+ * @throws Error if settleTime is invalid
152
+ */
153
+ export declare function validateSettleTime(settleTime: number): void;
154
+ /**
155
+ * Converts settled filter boolean to the value for Kuneiform.
156
+ *
157
+ * @param filter - Boolean filter (null/undefined=all, true=unsettled, false=settled)
158
+ * @returns Boolean or null (null=all, true/false=filter by settled status)
159
+ */
160
+ export declare function settledFilterToBoolean(filter: boolean | null | undefined): boolean | null;
161
+ //# sourceMappingURL=orderbookHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderbookHelpers.d.ts","sourceRoot":"","sources":["../../../src/util/orderbookHelpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,UAAU,CAgBZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,UAAU,CAiBZ;AAED;;;;;;;;;;GAUG;AACH,wBA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GACjC,OAAO,GAAG,IAAI,CAKhB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=orderbookHelpers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderbookHelpers.test.d.ts","sourceRoot":"","sources":["../../../src/util/orderbookHelpers.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trufnetwork/sdk-js",
3
- "version": "0.5.10",
3
+ "version": "0.6.1",
4
4
  "description": "TRUF.NETWORK SDK for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "keywords": [