@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.
package/dist/index.js ADDED
@@ -0,0 +1,345 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AGENT_REGISTRY_ABI: () => AGENT_REGISTRY_ABI,
24
+ AMM_ABI: () => AMM_ABI,
25
+ BASE_CHAIN: () => BASE_CHAIN,
26
+ DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
27
+ ERC20_ABI: () => ERC20_ABI,
28
+ ORACLE_ABI: () => ORACLE_ABI,
29
+ THRYX_CHAIN: () => THRYX_CHAIN,
30
+ THRYX_TOKEN_ABI: () => THRYX_TOKEN_ABI,
31
+ ThryxSDK: () => ThryxSDK,
32
+ WELCOME_BONUS_ABI: () => WELCOME_BONUS_ABI,
33
+ default: () => index_default,
34
+ formatEther: () => import_viem2.formatEther,
35
+ parseEther: () => import_viem2.parseEther
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_viem = require("viem");
39
+ var import_accounts = require("viem/accounts");
40
+ var import_viem2 = require("viem");
41
+ var THRYX_CHAIN = {
42
+ id: 77777,
43
+ name: "THRYX Mainnet",
44
+ nativeCurrency: {
45
+ decimals: 18,
46
+ name: "Ether",
47
+ symbol: "ETH"
48
+ },
49
+ rpcUrls: {
50
+ default: { http: ["https://rpc.thryx.mom"] },
51
+ public: { http: ["https://rpc.thryx.mom"] }
52
+ },
53
+ blockExplorers: {
54
+ default: { name: "THRYX Explorer", url: "https://explorer.thryx.mom" }
55
+ }
56
+ };
57
+ var BASE_CHAIN = {
58
+ id: 8453,
59
+ name: "Base",
60
+ nativeCurrency: {
61
+ decimals: 18,
62
+ name: "Ether",
63
+ symbol: "ETH"
64
+ },
65
+ rpcUrls: {
66
+ default: { http: ["https://mainnet.base.org"] },
67
+ public: { http: ["https://mainnet.base.org"] }
68
+ },
69
+ blockExplorers: {
70
+ default: { name: "Basescan", url: "https://basescan.org" }
71
+ }
72
+ };
73
+ var ERC20_ABI = (0, import_viem.parseAbi)([
74
+ "function name() view returns (string)",
75
+ "function symbol() view returns (string)",
76
+ "function decimals() view returns (uint8)",
77
+ "function totalSupply() view returns (uint256)",
78
+ "function balanceOf(address owner) view returns (uint256)",
79
+ "function allowance(address owner, address spender) view returns (uint256)",
80
+ "function approve(address spender, uint256 amount) returns (bool)",
81
+ "function transfer(address to, uint256 amount) returns (bool)",
82
+ "function transferFrom(address from, address to, uint256 amount) returns (bool)",
83
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
84
+ "event Approval(address indexed owner, address indexed spender, uint256 value)"
85
+ ]);
86
+ var AMM_ABI = (0, import_viem.parseAbi)([
87
+ "function tokenA() view returns (address)",
88
+ "function tokenB() view returns (address)",
89
+ "function reserveA() view returns (uint256)",
90
+ "function reserveB() view returns (uint256)",
91
+ "function getPrice() view returns (uint256)",
92
+ "function getAmountOut(address tokenIn, uint256 amountIn) view returns (uint256)",
93
+ "function swap(address tokenIn, uint256 amountIn, uint256 minAmountOut) returns (uint256)",
94
+ "function addLiquidity(uint256 amountA, uint256 amountB) returns (uint256)",
95
+ "function removeLiquidity(uint256 lpAmount) returns (uint256, uint256)",
96
+ "function balanceOf(address owner) view returns (uint256)",
97
+ "event Swap(address indexed user, address tokenIn, uint256 amountIn, uint256 amountOut)",
98
+ "event LiquidityAdded(address indexed user, uint256 amountA, uint256 amountB, uint256 liquidity)"
99
+ ]);
100
+ var ORACLE_ABI = (0, import_viem.parseAbi)([
101
+ "function getPrice(bytes32 pair) view returns (uint256 price, uint256 timestamp, bool isStale)",
102
+ "function submitPrice(bytes32 pair, uint256 price)",
103
+ "function getSubmissionCount(bytes32 pair) view returns (uint256)"
104
+ ]);
105
+ var AGENT_REGISTRY_ABI = (0, import_viem.parseAbi)([
106
+ "function getAgentCount() view returns (uint256)",
107
+ "function getActiveAgents() view returns (address[])",
108
+ "function validateAgent(address agent) view returns (bool)",
109
+ "function getRemainingBudget(address agent) view returns (uint256)"
110
+ ]);
111
+ var WELCOME_BONUS_ABI = (0, import_viem.parseAbi)([
112
+ "function claim()",
113
+ "function claimFor(address beneficiary)",
114
+ "function canClaim(address user) view returns (bool canClaimResult, uint256 amount)",
115
+ "function claimed(address user) view returns (bool)",
116
+ "function bonusAmount() view returns (uint256)",
117
+ "function totalClaims() view returns (uint256)"
118
+ ]);
119
+ var THRYX_TOKEN_ABI = (0, import_viem.parseAbi)([
120
+ "function name() view returns (string)",
121
+ "function symbol() view returns (string)",
122
+ "function decimals() view returns (uint8)",
123
+ "function totalSupply() view returns (uint256)",
124
+ "function balanceOf(address owner) view returns (uint256)",
125
+ "function transfer(address to, uint256 amount) returns (bool)",
126
+ "function approve(address spender, uint256 amount) returns (bool)"
127
+ ]);
128
+ var DEFAULT_CONTRACTS = {
129
+ usdc: "0x5f3f1dBD7B74C6B46e8c44f98792A1dAf8d69154",
130
+ weth: "0xb7278A61aa25c888815aFC32Ad3cC52fF24fE575",
131
+ amm: "0x2bdCC0de6bE1f7D2ee689a0342D76F52E8EFABa3",
132
+ oracle: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
133
+ registry: "0xCD8a1C3ba11CF5ECfa6267617243239504a98d90",
134
+ thryxToken: "0x2B0d36FACD61B71CC05ab8F3D2355ec3631C0dd5",
135
+ welcomeBonus: "0xCace1b78160AE76398F486c8a18044da0d66d86D"
136
+ };
137
+ var ThryxSDK = class {
138
+ constructor(config = {}) {
139
+ this.chainId = 77777;
140
+ const rpcUrl = config.rpcUrl || "http://localhost:8545";
141
+ this.contracts = { ...DEFAULT_CONTRACTS, ...config.contracts };
142
+ this.publicClient = (0, import_viem.createPublicClient)({
143
+ chain: THRYX_CHAIN,
144
+ transport: (0, import_viem.http)(rpcUrl)
145
+ });
146
+ if (config.privateKey) {
147
+ this.account = (0, import_accounts.privateKeyToAccount)(config.privateKey);
148
+ this.walletClient = (0, import_viem.createWalletClient)({
149
+ account: this.account,
150
+ chain: THRYX_CHAIN,
151
+ transport: (0, import_viem.http)(rpcUrl)
152
+ });
153
+ } else {
154
+ this.account = null;
155
+ this.walletClient = null;
156
+ }
157
+ }
158
+ // ==================== Connection ====================
159
+ get address() {
160
+ return this.account?.address || null;
161
+ }
162
+ async getBlockNumber() {
163
+ return this.publicClient.getBlockNumber();
164
+ }
165
+ async getBalance(address) {
166
+ const addr = address || this.address;
167
+ if (!addr) throw new Error("No address provided");
168
+ return this.publicClient.getBalance({ address: addr });
169
+ }
170
+ async getChainId() {
171
+ return this.publicClient.getChainId();
172
+ }
173
+ // ==================== Token Operations ====================
174
+ async getTokenBalance(tokenAddress, owner) {
175
+ const addr = owner || this.address;
176
+ if (!addr) throw new Error("No address provided");
177
+ return this.publicClient.readContract({
178
+ address: tokenAddress,
179
+ abi: ERC20_ABI,
180
+ functionName: "balanceOf",
181
+ args: [addr]
182
+ });
183
+ }
184
+ async getUsdcBalance(owner) {
185
+ if (!this.contracts.usdc) throw new Error("USDC address not configured");
186
+ return this.getTokenBalance(this.contracts.usdc, owner);
187
+ }
188
+ async getWethBalance(owner) {
189
+ if (!this.contracts.weth) throw new Error("WETH address not configured");
190
+ return this.getTokenBalance(this.contracts.weth, owner);
191
+ }
192
+ async getThryxBalance(owner) {
193
+ if (!this.contracts.thryxToken) throw new Error("THRYX Token address not configured");
194
+ return this.getTokenBalance(this.contracts.thryxToken, owner);
195
+ }
196
+ async approve(tokenAddress, spender, amount) {
197
+ if (!this.walletClient || !this.account) throw new Error("Wallet not connected");
198
+ return this.walletClient.writeContract({
199
+ address: tokenAddress,
200
+ abi: ERC20_ABI,
201
+ functionName: "approve",
202
+ args: [spender, amount],
203
+ chain: THRYX_CHAIN,
204
+ account: this.account
205
+ });
206
+ }
207
+ // ==================== AMM Operations ====================
208
+ async getPoolState() {
209
+ if (!this.contracts.amm) throw new Error("AMM address not configured");
210
+ const [reserveA, reserveB, price] = await Promise.all([
211
+ this.publicClient.readContract({
212
+ address: this.contracts.amm,
213
+ abi: AMM_ABI,
214
+ functionName: "reserveA"
215
+ }),
216
+ this.publicClient.readContract({
217
+ address: this.contracts.amm,
218
+ abi: AMM_ABI,
219
+ functionName: "reserveB"
220
+ }),
221
+ this.publicClient.readContract({
222
+ address: this.contracts.amm,
223
+ abi: AMM_ABI,
224
+ functionName: "getPrice"
225
+ })
226
+ ]);
227
+ return { reserveA, reserveB, price };
228
+ }
229
+ async getAmountOut(tokenIn, amountIn) {
230
+ if (!this.contracts.amm) throw new Error("AMM address not configured");
231
+ return this.publicClient.readContract({
232
+ address: this.contracts.amm,
233
+ abi: AMM_ABI,
234
+ functionName: "getAmountOut",
235
+ args: [tokenIn, amountIn]
236
+ });
237
+ }
238
+ async swap(tokenIn, amountIn, minAmountOut) {
239
+ if (!this.walletClient || !this.account) throw new Error("Wallet not connected");
240
+ if (!this.contracts.amm) throw new Error("AMM address not configured");
241
+ await this.approve(tokenIn, this.contracts.amm, amountIn);
242
+ return this.walletClient.writeContract({
243
+ address: this.contracts.amm,
244
+ abi: AMM_ABI,
245
+ functionName: "swap",
246
+ args: [tokenIn, amountIn, minAmountOut],
247
+ chain: THRYX_CHAIN,
248
+ account: this.account
249
+ });
250
+ }
251
+ // ==================== Oracle Operations ====================
252
+ async getPrice(pair) {
253
+ if (!this.contracts.oracle) throw new Error("Oracle address not configured");
254
+ const pairHash = this.hashPair(pair);
255
+ const [price, timestamp, isStale] = await this.publicClient.readContract({
256
+ address: this.contracts.oracle,
257
+ abi: ORACLE_ABI,
258
+ functionName: "getPrice",
259
+ args: [pairHash]
260
+ });
261
+ return {
262
+ price,
263
+ timestamp: Number(timestamp),
264
+ isStale
265
+ };
266
+ }
267
+ // ==================== Welcome Bonus ====================
268
+ async canClaimBonus(address) {
269
+ if (!this.contracts.welcomeBonus) throw new Error("WelcomeBonus address not configured");
270
+ const addr = address || this.address;
271
+ if (!addr) throw new Error("No address provided");
272
+ const [canClaim, amount] = await this.publicClient.readContract({
273
+ address: this.contracts.welcomeBonus,
274
+ abi: WELCOME_BONUS_ABI,
275
+ functionName: "canClaim",
276
+ args: [addr]
277
+ });
278
+ return { canClaim, amount };
279
+ }
280
+ async claimBonus() {
281
+ if (!this.walletClient || !this.account) throw new Error("Wallet not connected");
282
+ if (!this.contracts.welcomeBonus) throw new Error("WelcomeBonus address not configured");
283
+ return this.walletClient.writeContract({
284
+ address: this.contracts.welcomeBonus,
285
+ abi: WELCOME_BONUS_ABI,
286
+ functionName: "claim",
287
+ chain: THRYX_CHAIN,
288
+ account: this.account
289
+ });
290
+ }
291
+ // ==================== Agent Registry ====================
292
+ async getAgentCount() {
293
+ if (!this.contracts.registry) throw new Error("Registry address not configured");
294
+ return this.publicClient.readContract({
295
+ address: this.contracts.registry,
296
+ abi: AGENT_REGISTRY_ABI,
297
+ functionName: "getAgentCount"
298
+ });
299
+ }
300
+ async getActiveAgents() {
301
+ if (!this.contracts.registry) throw new Error("Registry address not configured");
302
+ return this.publicClient.readContract({
303
+ address: this.contracts.registry,
304
+ abi: AGENT_REGISTRY_ABI,
305
+ functionName: "getActiveAgents"
306
+ });
307
+ }
308
+ async isAgentValid(agent) {
309
+ if (!this.contracts.registry) throw new Error("Registry address not configured");
310
+ return this.publicClient.readContract({
311
+ address: this.contracts.registry,
312
+ abi: AGENT_REGISTRY_ABI,
313
+ functionName: "validateAgent",
314
+ args: [agent]
315
+ });
316
+ }
317
+ // ==================== Utilities ====================
318
+ hashPair(pair) {
319
+ const encoder = new TextEncoder();
320
+ const data = encoder.encode(pair);
321
+ return `0x${Buffer.from(data).toString("hex").padEnd(64, "0")}`;
322
+ }
323
+ formatEther(wei) {
324
+ return (0, import_viem.formatEther)(wei);
325
+ }
326
+ parseEther(ether) {
327
+ return (0, import_viem.parseEther)(ether);
328
+ }
329
+ };
330
+ var index_default = ThryxSDK;
331
+ // Annotate the CommonJS export names for ESM import in node:
332
+ 0 && (module.exports = {
333
+ AGENT_REGISTRY_ABI,
334
+ AMM_ABI,
335
+ BASE_CHAIN,
336
+ DEFAULT_CONTRACTS,
337
+ ERC20_ABI,
338
+ ORACLE_ABI,
339
+ THRYX_CHAIN,
340
+ THRYX_TOKEN_ABI,
341
+ ThryxSDK,
342
+ WELCOME_BONUS_ABI,
343
+ formatEther,
344
+ parseEther
345
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,316 @@
1
+ // src/index.ts
2
+ import {
3
+ createPublicClient,
4
+ createWalletClient,
5
+ http,
6
+ parseAbi,
7
+ formatEther,
8
+ parseEther
9
+ } from "viem";
10
+ import { privateKeyToAccount } from "viem/accounts";
11
+ import { formatEther as formatEther2, parseEther as parseEther2 } from "viem";
12
+ var THRYX_CHAIN = {
13
+ id: 77777,
14
+ name: "THRYX Mainnet",
15
+ nativeCurrency: {
16
+ decimals: 18,
17
+ name: "Ether",
18
+ symbol: "ETH"
19
+ },
20
+ rpcUrls: {
21
+ default: { http: ["https://rpc.thryx.mom"] },
22
+ public: { http: ["https://rpc.thryx.mom"] }
23
+ },
24
+ blockExplorers: {
25
+ default: { name: "THRYX Explorer", url: "https://explorer.thryx.mom" }
26
+ }
27
+ };
28
+ var BASE_CHAIN = {
29
+ id: 8453,
30
+ name: "Base",
31
+ nativeCurrency: {
32
+ decimals: 18,
33
+ name: "Ether",
34
+ symbol: "ETH"
35
+ },
36
+ rpcUrls: {
37
+ default: { http: ["https://mainnet.base.org"] },
38
+ public: { http: ["https://mainnet.base.org"] }
39
+ },
40
+ blockExplorers: {
41
+ default: { name: "Basescan", url: "https://basescan.org" }
42
+ }
43
+ };
44
+ var ERC20_ABI = parseAbi([
45
+ "function name() view returns (string)",
46
+ "function symbol() view returns (string)",
47
+ "function decimals() view returns (uint8)",
48
+ "function totalSupply() view returns (uint256)",
49
+ "function balanceOf(address owner) view returns (uint256)",
50
+ "function allowance(address owner, address spender) view returns (uint256)",
51
+ "function approve(address spender, uint256 amount) returns (bool)",
52
+ "function transfer(address to, uint256 amount) returns (bool)",
53
+ "function transferFrom(address from, address to, uint256 amount) returns (bool)",
54
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
55
+ "event Approval(address indexed owner, address indexed spender, uint256 value)"
56
+ ]);
57
+ var AMM_ABI = parseAbi([
58
+ "function tokenA() view returns (address)",
59
+ "function tokenB() view returns (address)",
60
+ "function reserveA() view returns (uint256)",
61
+ "function reserveB() view returns (uint256)",
62
+ "function getPrice() view returns (uint256)",
63
+ "function getAmountOut(address tokenIn, uint256 amountIn) view returns (uint256)",
64
+ "function swap(address tokenIn, uint256 amountIn, uint256 minAmountOut) returns (uint256)",
65
+ "function addLiquidity(uint256 amountA, uint256 amountB) returns (uint256)",
66
+ "function removeLiquidity(uint256 lpAmount) returns (uint256, uint256)",
67
+ "function balanceOf(address owner) view returns (uint256)",
68
+ "event Swap(address indexed user, address tokenIn, uint256 amountIn, uint256 amountOut)",
69
+ "event LiquidityAdded(address indexed user, uint256 amountA, uint256 amountB, uint256 liquidity)"
70
+ ]);
71
+ var ORACLE_ABI = parseAbi([
72
+ "function getPrice(bytes32 pair) view returns (uint256 price, uint256 timestamp, bool isStale)",
73
+ "function submitPrice(bytes32 pair, uint256 price)",
74
+ "function getSubmissionCount(bytes32 pair) view returns (uint256)"
75
+ ]);
76
+ var AGENT_REGISTRY_ABI = parseAbi([
77
+ "function getAgentCount() view returns (uint256)",
78
+ "function getActiveAgents() view returns (address[])",
79
+ "function validateAgent(address agent) view returns (bool)",
80
+ "function getRemainingBudget(address agent) view returns (uint256)"
81
+ ]);
82
+ var WELCOME_BONUS_ABI = parseAbi([
83
+ "function claim()",
84
+ "function claimFor(address beneficiary)",
85
+ "function canClaim(address user) view returns (bool canClaimResult, uint256 amount)",
86
+ "function claimed(address user) view returns (bool)",
87
+ "function bonusAmount() view returns (uint256)",
88
+ "function totalClaims() view returns (uint256)"
89
+ ]);
90
+ var THRYX_TOKEN_ABI = parseAbi([
91
+ "function name() view returns (string)",
92
+ "function symbol() view returns (string)",
93
+ "function decimals() view returns (uint8)",
94
+ "function totalSupply() view returns (uint256)",
95
+ "function balanceOf(address owner) view returns (uint256)",
96
+ "function transfer(address to, uint256 amount) returns (bool)",
97
+ "function approve(address spender, uint256 amount) returns (bool)"
98
+ ]);
99
+ var DEFAULT_CONTRACTS = {
100
+ usdc: "0x5f3f1dBD7B74C6B46e8c44f98792A1dAf8d69154",
101
+ weth: "0xb7278A61aa25c888815aFC32Ad3cC52fF24fE575",
102
+ amm: "0x2bdCC0de6bE1f7D2ee689a0342D76F52E8EFABa3",
103
+ oracle: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
104
+ registry: "0xCD8a1C3ba11CF5ECfa6267617243239504a98d90",
105
+ thryxToken: "0x2B0d36FACD61B71CC05ab8F3D2355ec3631C0dd5",
106
+ welcomeBonus: "0xCace1b78160AE76398F486c8a18044da0d66d86D"
107
+ };
108
+ var ThryxSDK = class {
109
+ constructor(config = {}) {
110
+ this.chainId = 77777;
111
+ const rpcUrl = config.rpcUrl || "http://localhost:8545";
112
+ this.contracts = { ...DEFAULT_CONTRACTS, ...config.contracts };
113
+ this.publicClient = createPublicClient({
114
+ chain: THRYX_CHAIN,
115
+ transport: http(rpcUrl)
116
+ });
117
+ if (config.privateKey) {
118
+ this.account = privateKeyToAccount(config.privateKey);
119
+ this.walletClient = createWalletClient({
120
+ account: this.account,
121
+ chain: THRYX_CHAIN,
122
+ transport: http(rpcUrl)
123
+ });
124
+ } else {
125
+ this.account = null;
126
+ this.walletClient = null;
127
+ }
128
+ }
129
+ // ==================== Connection ====================
130
+ get address() {
131
+ return this.account?.address || null;
132
+ }
133
+ async getBlockNumber() {
134
+ return this.publicClient.getBlockNumber();
135
+ }
136
+ async getBalance(address) {
137
+ const addr = address || this.address;
138
+ if (!addr) throw new Error("No address provided");
139
+ return this.publicClient.getBalance({ address: addr });
140
+ }
141
+ async getChainId() {
142
+ return this.publicClient.getChainId();
143
+ }
144
+ // ==================== Token Operations ====================
145
+ async getTokenBalance(tokenAddress, owner) {
146
+ const addr = owner || this.address;
147
+ if (!addr) throw new Error("No address provided");
148
+ return this.publicClient.readContract({
149
+ address: tokenAddress,
150
+ abi: ERC20_ABI,
151
+ functionName: "balanceOf",
152
+ args: [addr]
153
+ });
154
+ }
155
+ async getUsdcBalance(owner) {
156
+ if (!this.contracts.usdc) throw new Error("USDC address not configured");
157
+ return this.getTokenBalance(this.contracts.usdc, owner);
158
+ }
159
+ async getWethBalance(owner) {
160
+ if (!this.contracts.weth) throw new Error("WETH address not configured");
161
+ return this.getTokenBalance(this.contracts.weth, owner);
162
+ }
163
+ async getThryxBalance(owner) {
164
+ if (!this.contracts.thryxToken) throw new Error("THRYX Token address not configured");
165
+ return this.getTokenBalance(this.contracts.thryxToken, owner);
166
+ }
167
+ async approve(tokenAddress, spender, amount) {
168
+ if (!this.walletClient || !this.account) throw new Error("Wallet not connected");
169
+ return this.walletClient.writeContract({
170
+ address: tokenAddress,
171
+ abi: ERC20_ABI,
172
+ functionName: "approve",
173
+ args: [spender, amount],
174
+ chain: THRYX_CHAIN,
175
+ account: this.account
176
+ });
177
+ }
178
+ // ==================== AMM Operations ====================
179
+ async getPoolState() {
180
+ if (!this.contracts.amm) throw new Error("AMM address not configured");
181
+ const [reserveA, reserveB, price] = await Promise.all([
182
+ this.publicClient.readContract({
183
+ address: this.contracts.amm,
184
+ abi: AMM_ABI,
185
+ functionName: "reserveA"
186
+ }),
187
+ this.publicClient.readContract({
188
+ address: this.contracts.amm,
189
+ abi: AMM_ABI,
190
+ functionName: "reserveB"
191
+ }),
192
+ this.publicClient.readContract({
193
+ address: this.contracts.amm,
194
+ abi: AMM_ABI,
195
+ functionName: "getPrice"
196
+ })
197
+ ]);
198
+ return { reserveA, reserveB, price };
199
+ }
200
+ async getAmountOut(tokenIn, amountIn) {
201
+ if (!this.contracts.amm) throw new Error("AMM address not configured");
202
+ return this.publicClient.readContract({
203
+ address: this.contracts.amm,
204
+ abi: AMM_ABI,
205
+ functionName: "getAmountOut",
206
+ args: [tokenIn, amountIn]
207
+ });
208
+ }
209
+ async swap(tokenIn, amountIn, minAmountOut) {
210
+ if (!this.walletClient || !this.account) throw new Error("Wallet not connected");
211
+ if (!this.contracts.amm) throw new Error("AMM address not configured");
212
+ await this.approve(tokenIn, this.contracts.amm, amountIn);
213
+ return this.walletClient.writeContract({
214
+ address: this.contracts.amm,
215
+ abi: AMM_ABI,
216
+ functionName: "swap",
217
+ args: [tokenIn, amountIn, minAmountOut],
218
+ chain: THRYX_CHAIN,
219
+ account: this.account
220
+ });
221
+ }
222
+ // ==================== Oracle Operations ====================
223
+ async getPrice(pair) {
224
+ if (!this.contracts.oracle) throw new Error("Oracle address not configured");
225
+ const pairHash = this.hashPair(pair);
226
+ const [price, timestamp, isStale] = await this.publicClient.readContract({
227
+ address: this.contracts.oracle,
228
+ abi: ORACLE_ABI,
229
+ functionName: "getPrice",
230
+ args: [pairHash]
231
+ });
232
+ return {
233
+ price,
234
+ timestamp: Number(timestamp),
235
+ isStale
236
+ };
237
+ }
238
+ // ==================== Welcome Bonus ====================
239
+ async canClaimBonus(address) {
240
+ if (!this.contracts.welcomeBonus) throw new Error("WelcomeBonus address not configured");
241
+ const addr = address || this.address;
242
+ if (!addr) throw new Error("No address provided");
243
+ const [canClaim, amount] = await this.publicClient.readContract({
244
+ address: this.contracts.welcomeBonus,
245
+ abi: WELCOME_BONUS_ABI,
246
+ functionName: "canClaim",
247
+ args: [addr]
248
+ });
249
+ return { canClaim, amount };
250
+ }
251
+ async claimBonus() {
252
+ if (!this.walletClient || !this.account) throw new Error("Wallet not connected");
253
+ if (!this.contracts.welcomeBonus) throw new Error("WelcomeBonus address not configured");
254
+ return this.walletClient.writeContract({
255
+ address: this.contracts.welcomeBonus,
256
+ abi: WELCOME_BONUS_ABI,
257
+ functionName: "claim",
258
+ chain: THRYX_CHAIN,
259
+ account: this.account
260
+ });
261
+ }
262
+ // ==================== Agent Registry ====================
263
+ async getAgentCount() {
264
+ if (!this.contracts.registry) throw new Error("Registry address not configured");
265
+ return this.publicClient.readContract({
266
+ address: this.contracts.registry,
267
+ abi: AGENT_REGISTRY_ABI,
268
+ functionName: "getAgentCount"
269
+ });
270
+ }
271
+ async getActiveAgents() {
272
+ if (!this.contracts.registry) throw new Error("Registry address not configured");
273
+ return this.publicClient.readContract({
274
+ address: this.contracts.registry,
275
+ abi: AGENT_REGISTRY_ABI,
276
+ functionName: "getActiveAgents"
277
+ });
278
+ }
279
+ async isAgentValid(agent) {
280
+ if (!this.contracts.registry) throw new Error("Registry address not configured");
281
+ return this.publicClient.readContract({
282
+ address: this.contracts.registry,
283
+ abi: AGENT_REGISTRY_ABI,
284
+ functionName: "validateAgent",
285
+ args: [agent]
286
+ });
287
+ }
288
+ // ==================== Utilities ====================
289
+ hashPair(pair) {
290
+ const encoder = new TextEncoder();
291
+ const data = encoder.encode(pair);
292
+ return `0x${Buffer.from(data).toString("hex").padEnd(64, "0")}`;
293
+ }
294
+ formatEther(wei) {
295
+ return formatEther(wei);
296
+ }
297
+ parseEther(ether) {
298
+ return parseEther(ether);
299
+ }
300
+ };
301
+ var index_default = ThryxSDK;
302
+ export {
303
+ AGENT_REGISTRY_ABI,
304
+ AMM_ABI,
305
+ BASE_CHAIN,
306
+ DEFAULT_CONTRACTS,
307
+ ERC20_ABI,
308
+ ORACLE_ABI,
309
+ THRYX_CHAIN,
310
+ THRYX_TOKEN_ABI,
311
+ ThryxSDK,
312
+ WELCOME_BONUS_ABI,
313
+ index_default as default,
314
+ formatEther2 as formatEther,
315
+ parseEther2 as parseEther
316
+ };