@thryx/sdk 1.0.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,581 @@
1
+ import { Chain, Address, PublicClient, WalletClient, Hash } from 'viem';
2
+ export { formatEther, parseEther } from 'viem';
3
+ import { PrivateKeyAccount } from 'viem/accounts';
4
+
5
+ /**
6
+ * @thryx/sdk
7
+ * TypeScript SDK for THRYX - AI-Native Blockchain
8
+ * Chain ID: 77777
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { ThryxSDK, THRYX_CHAIN } from '@thryx/sdk';
13
+ *
14
+ * const sdk = new ThryxSDK({
15
+ * rpcUrl: 'https://rpc.thryx.mom',
16
+ * privateKey: '0x...'
17
+ * });
18
+ *
19
+ * // Get block number
20
+ * const blockNumber = await sdk.getBlockNumber();
21
+ *
22
+ * // Swap tokens
23
+ * await sdk.swap('0xUSDC', '0xWETH', 100n * 10n**6n, 0n);
24
+ * ```
25
+ */
26
+
27
+ /**
28
+ * THRYX Mainnet chain configuration
29
+ */
30
+ declare const THRYX_CHAIN: Chain;
31
+ /**
32
+ * Base Mainnet (L1 for THRYX)
33
+ */
34
+ declare const BASE_CHAIN: Chain;
35
+ declare const ERC20_ABI: readonly [{
36
+ readonly name: "name";
37
+ readonly type: "function";
38
+ readonly stateMutability: "view";
39
+ readonly inputs: readonly [];
40
+ readonly outputs: readonly [{
41
+ readonly type: "string";
42
+ }];
43
+ }, {
44
+ readonly name: "symbol";
45
+ readonly type: "function";
46
+ readonly stateMutability: "view";
47
+ readonly inputs: readonly [];
48
+ readonly outputs: readonly [{
49
+ readonly type: "string";
50
+ }];
51
+ }, {
52
+ readonly name: "decimals";
53
+ readonly type: "function";
54
+ readonly stateMutability: "view";
55
+ readonly inputs: readonly [];
56
+ readonly outputs: readonly [{
57
+ readonly type: "uint8";
58
+ }];
59
+ }, {
60
+ readonly name: "totalSupply";
61
+ readonly type: "function";
62
+ readonly stateMutability: "view";
63
+ readonly inputs: readonly [];
64
+ readonly outputs: readonly [{
65
+ readonly type: "uint256";
66
+ }];
67
+ }, {
68
+ readonly name: "balanceOf";
69
+ readonly type: "function";
70
+ readonly stateMutability: "view";
71
+ readonly inputs: readonly [{
72
+ readonly type: "address";
73
+ readonly name: "owner";
74
+ }];
75
+ readonly outputs: readonly [{
76
+ readonly type: "uint256";
77
+ }];
78
+ }, {
79
+ readonly name: "allowance";
80
+ readonly type: "function";
81
+ readonly stateMutability: "view";
82
+ readonly inputs: readonly [{
83
+ readonly type: "address";
84
+ readonly name: "owner";
85
+ }, {
86
+ readonly type: "address";
87
+ readonly name: "spender";
88
+ }];
89
+ readonly outputs: readonly [{
90
+ readonly type: "uint256";
91
+ }];
92
+ }, {
93
+ readonly name: "approve";
94
+ readonly type: "function";
95
+ readonly stateMutability: "nonpayable";
96
+ readonly inputs: readonly [{
97
+ readonly type: "address";
98
+ readonly name: "spender";
99
+ }, {
100
+ readonly type: "uint256";
101
+ readonly name: "amount";
102
+ }];
103
+ readonly outputs: readonly [{
104
+ readonly type: "bool";
105
+ }];
106
+ }, {
107
+ readonly name: "transfer";
108
+ readonly type: "function";
109
+ readonly stateMutability: "nonpayable";
110
+ readonly inputs: readonly [{
111
+ readonly type: "address";
112
+ readonly name: "to";
113
+ }, {
114
+ readonly type: "uint256";
115
+ readonly name: "amount";
116
+ }];
117
+ readonly outputs: readonly [{
118
+ readonly type: "bool";
119
+ }];
120
+ }, {
121
+ readonly name: "transferFrom";
122
+ readonly type: "function";
123
+ readonly stateMutability: "nonpayable";
124
+ readonly inputs: readonly [{
125
+ readonly type: "address";
126
+ readonly name: "from";
127
+ }, {
128
+ readonly type: "address";
129
+ readonly name: "to";
130
+ }, {
131
+ readonly type: "uint256";
132
+ readonly name: "amount";
133
+ }];
134
+ readonly outputs: readonly [{
135
+ readonly type: "bool";
136
+ }];
137
+ }, {
138
+ readonly name: "Transfer";
139
+ readonly type: "event";
140
+ readonly inputs: readonly [{
141
+ readonly type: "address";
142
+ readonly name: "from";
143
+ readonly indexed: true;
144
+ }, {
145
+ readonly type: "address";
146
+ readonly name: "to";
147
+ readonly indexed: true;
148
+ }, {
149
+ readonly type: "uint256";
150
+ readonly name: "value";
151
+ }];
152
+ }, {
153
+ readonly name: "Approval";
154
+ readonly type: "event";
155
+ readonly inputs: readonly [{
156
+ readonly type: "address";
157
+ readonly name: "owner";
158
+ readonly indexed: true;
159
+ }, {
160
+ readonly type: "address";
161
+ readonly name: "spender";
162
+ readonly indexed: true;
163
+ }, {
164
+ readonly type: "uint256";
165
+ readonly name: "value";
166
+ }];
167
+ }];
168
+ declare const AMM_ABI: readonly [{
169
+ readonly name: "tokenA";
170
+ readonly type: "function";
171
+ readonly stateMutability: "view";
172
+ readonly inputs: readonly [];
173
+ readonly outputs: readonly [{
174
+ readonly type: "address";
175
+ }];
176
+ }, {
177
+ readonly name: "tokenB";
178
+ readonly type: "function";
179
+ readonly stateMutability: "view";
180
+ readonly inputs: readonly [];
181
+ readonly outputs: readonly [{
182
+ readonly type: "address";
183
+ }];
184
+ }, {
185
+ readonly name: "reserveA";
186
+ readonly type: "function";
187
+ readonly stateMutability: "view";
188
+ readonly inputs: readonly [];
189
+ readonly outputs: readonly [{
190
+ readonly type: "uint256";
191
+ }];
192
+ }, {
193
+ readonly name: "reserveB";
194
+ readonly type: "function";
195
+ readonly stateMutability: "view";
196
+ readonly inputs: readonly [];
197
+ readonly outputs: readonly [{
198
+ readonly type: "uint256";
199
+ }];
200
+ }, {
201
+ readonly name: "getPrice";
202
+ readonly type: "function";
203
+ readonly stateMutability: "view";
204
+ readonly inputs: readonly [];
205
+ readonly outputs: readonly [{
206
+ readonly type: "uint256";
207
+ }];
208
+ }, {
209
+ readonly name: "getAmountOut";
210
+ readonly type: "function";
211
+ readonly stateMutability: "view";
212
+ readonly inputs: readonly [{
213
+ readonly type: "address";
214
+ readonly name: "tokenIn";
215
+ }, {
216
+ readonly type: "uint256";
217
+ readonly name: "amountIn";
218
+ }];
219
+ readonly outputs: readonly [{
220
+ readonly type: "uint256";
221
+ }];
222
+ }, {
223
+ readonly name: "swap";
224
+ readonly type: "function";
225
+ readonly stateMutability: "nonpayable";
226
+ readonly inputs: readonly [{
227
+ readonly type: "address";
228
+ readonly name: "tokenIn";
229
+ }, {
230
+ readonly type: "uint256";
231
+ readonly name: "amountIn";
232
+ }, {
233
+ readonly type: "uint256";
234
+ readonly name: "minAmountOut";
235
+ }];
236
+ readonly outputs: readonly [{
237
+ readonly type: "uint256";
238
+ }];
239
+ }, {
240
+ readonly name: "addLiquidity";
241
+ readonly type: "function";
242
+ readonly stateMutability: "nonpayable";
243
+ readonly inputs: readonly [{
244
+ readonly type: "uint256";
245
+ readonly name: "amountA";
246
+ }, {
247
+ readonly type: "uint256";
248
+ readonly name: "amountB";
249
+ }];
250
+ readonly outputs: readonly [{
251
+ readonly type: "uint256";
252
+ }];
253
+ }, {
254
+ readonly name: "removeLiquidity";
255
+ readonly type: "function";
256
+ readonly stateMutability: "nonpayable";
257
+ readonly inputs: readonly [{
258
+ readonly type: "uint256";
259
+ readonly name: "lpAmount";
260
+ }];
261
+ readonly outputs: readonly [{
262
+ readonly type: "uint256";
263
+ }, {
264
+ readonly type: "uint256";
265
+ }];
266
+ }, {
267
+ readonly name: "balanceOf";
268
+ readonly type: "function";
269
+ readonly stateMutability: "view";
270
+ readonly inputs: readonly [{
271
+ readonly type: "address";
272
+ readonly name: "owner";
273
+ }];
274
+ readonly outputs: readonly [{
275
+ readonly type: "uint256";
276
+ }];
277
+ }, {
278
+ readonly name: "Swap";
279
+ readonly type: "event";
280
+ readonly inputs: readonly [{
281
+ readonly type: "address";
282
+ readonly name: "user";
283
+ readonly indexed: true;
284
+ }, {
285
+ readonly type: "address";
286
+ readonly name: "tokenIn";
287
+ }, {
288
+ readonly type: "uint256";
289
+ readonly name: "amountIn";
290
+ }, {
291
+ readonly type: "uint256";
292
+ readonly name: "amountOut";
293
+ }];
294
+ }, {
295
+ readonly name: "LiquidityAdded";
296
+ readonly type: "event";
297
+ readonly inputs: readonly [{
298
+ readonly type: "address";
299
+ readonly name: "user";
300
+ readonly indexed: true;
301
+ }, {
302
+ readonly type: "uint256";
303
+ readonly name: "amountA";
304
+ }, {
305
+ readonly type: "uint256";
306
+ readonly name: "amountB";
307
+ }, {
308
+ readonly type: "uint256";
309
+ readonly name: "liquidity";
310
+ }];
311
+ }];
312
+ declare const ORACLE_ABI: readonly [{
313
+ readonly name: "getPrice";
314
+ readonly type: "function";
315
+ readonly stateMutability: "view";
316
+ readonly inputs: readonly [{
317
+ readonly type: "bytes32";
318
+ readonly name: "pair";
319
+ }];
320
+ readonly outputs: readonly [{
321
+ readonly type: "uint256";
322
+ readonly name: "price";
323
+ }, {
324
+ readonly type: "uint256";
325
+ readonly name: "timestamp";
326
+ }, {
327
+ readonly type: "bool";
328
+ readonly name: "isStale";
329
+ }];
330
+ }, {
331
+ readonly name: "submitPrice";
332
+ readonly type: "function";
333
+ readonly stateMutability: "nonpayable";
334
+ readonly inputs: readonly [{
335
+ readonly type: "bytes32";
336
+ readonly name: "pair";
337
+ }, {
338
+ readonly type: "uint256";
339
+ readonly name: "price";
340
+ }];
341
+ readonly outputs: readonly [];
342
+ }, {
343
+ readonly name: "getSubmissionCount";
344
+ readonly type: "function";
345
+ readonly stateMutability: "view";
346
+ readonly inputs: readonly [{
347
+ readonly type: "bytes32";
348
+ readonly name: "pair";
349
+ }];
350
+ readonly outputs: readonly [{
351
+ readonly type: "uint256";
352
+ }];
353
+ }];
354
+ declare const AGENT_REGISTRY_ABI: readonly [{
355
+ readonly name: "getAgentCount";
356
+ readonly type: "function";
357
+ readonly stateMutability: "view";
358
+ readonly inputs: readonly [];
359
+ readonly outputs: readonly [{
360
+ readonly type: "uint256";
361
+ }];
362
+ }, {
363
+ readonly name: "getActiveAgents";
364
+ readonly type: "function";
365
+ readonly stateMutability: "view";
366
+ readonly inputs: readonly [];
367
+ readonly outputs: readonly [{
368
+ readonly type: "address[]";
369
+ }];
370
+ }, {
371
+ readonly name: "validateAgent";
372
+ readonly type: "function";
373
+ readonly stateMutability: "view";
374
+ readonly inputs: readonly [{
375
+ readonly type: "address";
376
+ readonly name: "agent";
377
+ }];
378
+ readonly outputs: readonly [{
379
+ readonly type: "bool";
380
+ }];
381
+ }, {
382
+ readonly name: "getRemainingBudget";
383
+ readonly type: "function";
384
+ readonly stateMutability: "view";
385
+ readonly inputs: readonly [{
386
+ readonly type: "address";
387
+ readonly name: "agent";
388
+ }];
389
+ readonly outputs: readonly [{
390
+ readonly type: "uint256";
391
+ }];
392
+ }];
393
+ declare const WELCOME_BONUS_ABI: readonly [{
394
+ readonly name: "claim";
395
+ readonly type: "function";
396
+ readonly stateMutability: "nonpayable";
397
+ readonly inputs: readonly [];
398
+ readonly outputs: readonly [];
399
+ }, {
400
+ readonly name: "claimFor";
401
+ readonly type: "function";
402
+ readonly stateMutability: "nonpayable";
403
+ readonly inputs: readonly [{
404
+ readonly type: "address";
405
+ readonly name: "beneficiary";
406
+ }];
407
+ readonly outputs: readonly [];
408
+ }, {
409
+ readonly name: "canClaim";
410
+ readonly type: "function";
411
+ readonly stateMutability: "view";
412
+ readonly inputs: readonly [{
413
+ readonly type: "address";
414
+ readonly name: "user";
415
+ }];
416
+ readonly outputs: readonly [{
417
+ readonly type: "bool";
418
+ readonly name: "canClaimResult";
419
+ }, {
420
+ readonly type: "uint256";
421
+ readonly name: "amount";
422
+ }];
423
+ }, {
424
+ readonly name: "claimed";
425
+ readonly type: "function";
426
+ readonly stateMutability: "view";
427
+ readonly inputs: readonly [{
428
+ readonly type: "address";
429
+ readonly name: "user";
430
+ }];
431
+ readonly outputs: readonly [{
432
+ readonly type: "bool";
433
+ }];
434
+ }, {
435
+ readonly name: "bonusAmount";
436
+ readonly type: "function";
437
+ readonly stateMutability: "view";
438
+ readonly inputs: readonly [];
439
+ readonly outputs: readonly [{
440
+ readonly type: "uint256";
441
+ }];
442
+ }, {
443
+ readonly name: "totalClaims";
444
+ readonly type: "function";
445
+ readonly stateMutability: "view";
446
+ readonly inputs: readonly [];
447
+ readonly outputs: readonly [{
448
+ readonly type: "uint256";
449
+ }];
450
+ }];
451
+ declare const THRYX_TOKEN_ABI: readonly [{
452
+ readonly name: "name";
453
+ readonly type: "function";
454
+ readonly stateMutability: "view";
455
+ readonly inputs: readonly [];
456
+ readonly outputs: readonly [{
457
+ readonly type: "string";
458
+ }];
459
+ }, {
460
+ readonly name: "symbol";
461
+ readonly type: "function";
462
+ readonly stateMutability: "view";
463
+ readonly inputs: readonly [];
464
+ readonly outputs: readonly [{
465
+ readonly type: "string";
466
+ }];
467
+ }, {
468
+ readonly name: "decimals";
469
+ readonly type: "function";
470
+ readonly stateMutability: "view";
471
+ readonly inputs: readonly [];
472
+ readonly outputs: readonly [{
473
+ readonly type: "uint8";
474
+ }];
475
+ }, {
476
+ readonly name: "totalSupply";
477
+ readonly type: "function";
478
+ readonly stateMutability: "view";
479
+ readonly inputs: readonly [];
480
+ readonly outputs: readonly [{
481
+ readonly type: "uint256";
482
+ }];
483
+ }, {
484
+ readonly name: "balanceOf";
485
+ readonly type: "function";
486
+ readonly stateMutability: "view";
487
+ readonly inputs: readonly [{
488
+ readonly type: "address";
489
+ readonly name: "owner";
490
+ }];
491
+ readonly outputs: readonly [{
492
+ readonly type: "uint256";
493
+ }];
494
+ }, {
495
+ readonly name: "transfer";
496
+ readonly type: "function";
497
+ readonly stateMutability: "nonpayable";
498
+ readonly inputs: readonly [{
499
+ readonly type: "address";
500
+ readonly name: "to";
501
+ }, {
502
+ readonly type: "uint256";
503
+ readonly name: "amount";
504
+ }];
505
+ readonly outputs: readonly [{
506
+ readonly type: "bool";
507
+ }];
508
+ }, {
509
+ readonly name: "approve";
510
+ readonly type: "function";
511
+ readonly stateMutability: "nonpayable";
512
+ readonly inputs: readonly [{
513
+ readonly type: "address";
514
+ readonly name: "spender";
515
+ }, {
516
+ readonly type: "uint256";
517
+ readonly name: "amount";
518
+ }];
519
+ readonly outputs: readonly [{
520
+ readonly type: "bool";
521
+ }];
522
+ }];
523
+ interface ThryxSDKConfig {
524
+ rpcUrl?: string;
525
+ privateKey?: string;
526
+ contracts?: ContractAddresses;
527
+ }
528
+ interface ContractAddresses {
529
+ usdc?: Address;
530
+ weth?: Address;
531
+ amm?: Address;
532
+ oracle?: Address;
533
+ registry?: Address;
534
+ thryxToken?: Address;
535
+ welcomeBonus?: Address;
536
+ }
537
+ interface PoolState {
538
+ reserveA: bigint;
539
+ reserveB: bigint;
540
+ price: bigint;
541
+ }
542
+ interface PriceData {
543
+ price: bigint;
544
+ timestamp: number;
545
+ isStale: boolean;
546
+ }
547
+ declare const DEFAULT_CONTRACTS: ContractAddresses;
548
+ declare class ThryxSDK {
549
+ readonly publicClient: PublicClient;
550
+ readonly walletClient: WalletClient | null;
551
+ readonly account: PrivateKeyAccount | null;
552
+ readonly contracts: ContractAddresses;
553
+ readonly chainId = 77777;
554
+ constructor(config?: ThryxSDKConfig);
555
+ get address(): Address | null;
556
+ getBlockNumber(): Promise<bigint>;
557
+ getBalance(address?: Address): Promise<bigint>;
558
+ getChainId(): Promise<number>;
559
+ getTokenBalance(tokenAddress: Address, owner?: Address): Promise<bigint>;
560
+ getUsdcBalance(owner?: Address): Promise<bigint>;
561
+ getWethBalance(owner?: Address): Promise<bigint>;
562
+ getThryxBalance(owner?: Address): Promise<bigint>;
563
+ approve(tokenAddress: Address, spender: Address, amount: bigint): Promise<Hash>;
564
+ getPoolState(): Promise<PoolState>;
565
+ getAmountOut(tokenIn: Address, amountIn: bigint): Promise<bigint>;
566
+ swap(tokenIn: Address, amountIn: bigint, minAmountOut: bigint): Promise<Hash>;
567
+ getPrice(pair: string): Promise<PriceData>;
568
+ canClaimBonus(address?: Address): Promise<{
569
+ canClaim: boolean;
570
+ amount: bigint;
571
+ }>;
572
+ claimBonus(): Promise<Hash>;
573
+ getAgentCount(): Promise<bigint>;
574
+ getActiveAgents(): Promise<readonly Address[]>;
575
+ isAgentValid(agent: Address): Promise<boolean>;
576
+ private hashPair;
577
+ formatEther(wei: bigint): string;
578
+ parseEther(ether: string): bigint;
579
+ }
580
+
581
+ export { AGENT_REGISTRY_ABI, AMM_ABI, BASE_CHAIN, type ContractAddresses, DEFAULT_CONTRACTS, ERC20_ABI, ORACLE_ABI, type PoolState, type PriceData, THRYX_CHAIN, THRYX_TOKEN_ABI, ThryxSDK, type ThryxSDKConfig, WELCOME_BONUS_ABI, ThryxSDK as default };