@exagent/sdk 0.1.6 → 0.1.8

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.d.mts CHANGED
@@ -87,6 +87,8 @@ interface TradeIntent {
87
87
  minAmountOut?: bigint;
88
88
  maxSlippageBps?: number;
89
89
  deadline?: number;
90
+ /** LLM config hash (bytes32) for epoch attribution — passed to on-chain router */
91
+ configHash?: `0x${string}`;
90
92
  }
91
93
  /**
92
94
  * M2M service request
@@ -1833,6 +1835,10 @@ declare class ExagentClient {
1833
1835
  * Useful for simulation or multi-step workflows
1834
1836
  */
1835
1837
  buildRouterTrade(intent: Omit<TradeIntent, 'action'>, agentId?: bigint): Promise<RouterTradeResponse>;
1838
+ /**
1839
+ * Read current ERC-20 allowance for a (token, spender) pair
1840
+ */
1841
+ private getAllowance;
1836
1842
  /**
1837
1843
  * Approve token spending for router
1838
1844
  */
package/dist/index.d.ts CHANGED
@@ -87,6 +87,8 @@ interface TradeIntent {
87
87
  minAmountOut?: bigint;
88
88
  maxSlippageBps?: number;
89
89
  deadline?: number;
90
+ /** LLM config hash (bytes32) for epoch attribution — passed to on-chain router */
91
+ configHash?: `0x${string}`;
90
92
  }
91
93
  /**
92
94
  * M2M service request
@@ -1833,6 +1835,10 @@ declare class ExagentClient {
1833
1835
  * Useful for simulation or multi-step workflows
1834
1836
  */
1835
1837
  buildRouterTrade(intent: Omit<TradeIntent, 'action'>, agentId?: bigint): Promise<RouterTradeResponse>;
1838
+ /**
1839
+ * Read current ERC-20 allowance for a (token, spender) pair
1840
+ */
1841
+ private getAllowance;
1836
1842
  /**
1837
1843
  * Approve token spending for router
1838
1844
  */
package/dist/index.js CHANGED
@@ -2076,13 +2076,10 @@ var CONTRACT_ADDRESSES = {
2076
2076
  exaToken: "0x13403Fb738C97cF7564F279288468c140AaEd05c",
2077
2077
  staking: "0xAF1729D1519A72f7d9b87aa23a305b775e2849DA",
2078
2078
  router: "0x11daD5366D903a3eF5d8f07EFF87ce6b173859a9",
2079
- vaultFactory: "0x0000000000000000000000000000000000000000",
2080
- // Phase 2 — pending deploy
2079
+ vaultFactory: "0xe9F1F6393448921bD29a1cBAbd951Bb8F8EA4A6f",
2081
2080
  feeCollector: "0xe66328a964AF93bEF2eDB226D039C35aE6e66De1",
2082
- buyback: "0x0000000000000000000000000000000000000000",
2083
- // Phase 2 — pending deploy
2084
- serviceEscrow: "0x0000000000000000000000000000000000000000"
2085
- // Phase 2 — pending deploy
2081
+ buyback: "0x39967532b640B2f735548c7a5b46d8D890A0B2f2",
2082
+ serviceEscrow: "0x63A4d1dA774422EFC2cc57d71F948231BD812516"
2086
2083
  }
2087
2084
  };
2088
2085
  var DEX_ADDRESSES = {
@@ -2314,11 +2311,21 @@ var ExagentClient = class {
2314
2311
  const agentId = await this.getAgentId();
2315
2312
  if (!agentId) throw new Error("Agent not registered");
2316
2313
  const routerTrade = await this.buildRouterTrade(intent, agentId);
2314
+ const seen = /* @__PURE__ */ new Set();
2317
2315
  for (const approval of routerTrade.approvals) {
2316
+ const key = `${approval.token.toLowerCase()}:${approval.spender.toLowerCase()}`;
2317
+ if (seen.has(key)) continue;
2318
+ seen.add(key);
2319
+ const amount = BigInt(approval.amount);
2320
+ const existing = await this.getAllowance(
2321
+ approval.token,
2322
+ approval.spender
2323
+ );
2324
+ if (existing >= amount) continue;
2318
2325
  await this.approveToken(
2319
2326
  approval.token,
2320
2327
  approval.spender,
2321
- BigInt(approval.amount)
2328
+ amount
2322
2329
  );
2323
2330
  }
2324
2331
  const hash = await this.walletClient.sendTransaction({
@@ -2354,7 +2361,8 @@ var ExagentClient = class {
2354
2361
  tokenOut: intent.tokenOut,
2355
2362
  amountIn: intent.amountIn.toString(),
2356
2363
  slippageBps: intent.maxSlippageBps ?? 50,
2357
- taker: this.account.address
2364
+ taker: this.account.address,
2365
+ ...intent.configHash && { configHash: intent.configHash }
2358
2366
  })
2359
2367
  });
2360
2368
  if (!response.ok) {
@@ -2363,6 +2371,21 @@ var ExagentClient = class {
2363
2371
  }
2364
2372
  return response.json();
2365
2373
  }
2374
+ /**
2375
+ * Read current ERC-20 allowance for a (token, spender) pair
2376
+ */
2377
+ async getAllowance(token, spender) {
2378
+ try {
2379
+ const data = await this.publicClient.call({
2380
+ to: token,
2381
+ data: `0xdd62ed3e${this.account.address.slice(2).padStart(64, "0")}${spender.slice(2).padStart(64, "0")}`
2382
+ });
2383
+ if (!data.data || data.data === "0x") return 0n;
2384
+ return BigInt(data.data);
2385
+ } catch {
2386
+ return 0n;
2387
+ }
2388
+ }
2366
2389
  /**
2367
2390
  * Approve token spending for router
2368
2391
  */
package/dist/index.mjs CHANGED
@@ -2041,13 +2041,10 @@ var CONTRACT_ADDRESSES = {
2041
2041
  exaToken: "0x13403Fb738C97cF7564F279288468c140AaEd05c",
2042
2042
  staking: "0xAF1729D1519A72f7d9b87aa23a305b775e2849DA",
2043
2043
  router: "0x11daD5366D903a3eF5d8f07EFF87ce6b173859a9",
2044
- vaultFactory: "0x0000000000000000000000000000000000000000",
2045
- // Phase 2 — pending deploy
2044
+ vaultFactory: "0xe9F1F6393448921bD29a1cBAbd951Bb8F8EA4A6f",
2046
2045
  feeCollector: "0xe66328a964AF93bEF2eDB226D039C35aE6e66De1",
2047
- buyback: "0x0000000000000000000000000000000000000000",
2048
- // Phase 2 — pending deploy
2049
- serviceEscrow: "0x0000000000000000000000000000000000000000"
2050
- // Phase 2 — pending deploy
2046
+ buyback: "0x39967532b640B2f735548c7a5b46d8D890A0B2f2",
2047
+ serviceEscrow: "0x63A4d1dA774422EFC2cc57d71F948231BD812516"
2051
2048
  }
2052
2049
  };
2053
2050
  var DEX_ADDRESSES = {
@@ -2279,11 +2276,21 @@ var ExagentClient = class {
2279
2276
  const agentId = await this.getAgentId();
2280
2277
  if (!agentId) throw new Error("Agent not registered");
2281
2278
  const routerTrade = await this.buildRouterTrade(intent, agentId);
2279
+ const seen = /* @__PURE__ */ new Set();
2282
2280
  for (const approval of routerTrade.approvals) {
2281
+ const key = `${approval.token.toLowerCase()}:${approval.spender.toLowerCase()}`;
2282
+ if (seen.has(key)) continue;
2283
+ seen.add(key);
2284
+ const amount = BigInt(approval.amount);
2285
+ const existing = await this.getAllowance(
2286
+ approval.token,
2287
+ approval.spender
2288
+ );
2289
+ if (existing >= amount) continue;
2283
2290
  await this.approveToken(
2284
2291
  approval.token,
2285
2292
  approval.spender,
2286
- BigInt(approval.amount)
2293
+ amount
2287
2294
  );
2288
2295
  }
2289
2296
  const hash = await this.walletClient.sendTransaction({
@@ -2319,7 +2326,8 @@ var ExagentClient = class {
2319
2326
  tokenOut: intent.tokenOut,
2320
2327
  amountIn: intent.amountIn.toString(),
2321
2328
  slippageBps: intent.maxSlippageBps ?? 50,
2322
- taker: this.account.address
2329
+ taker: this.account.address,
2330
+ ...intent.configHash && { configHash: intent.configHash }
2323
2331
  })
2324
2332
  });
2325
2333
  if (!response.ok) {
@@ -2328,6 +2336,21 @@ var ExagentClient = class {
2328
2336
  }
2329
2337
  return response.json();
2330
2338
  }
2339
+ /**
2340
+ * Read current ERC-20 allowance for a (token, spender) pair
2341
+ */
2342
+ async getAllowance(token, spender) {
2343
+ try {
2344
+ const data = await this.publicClient.call({
2345
+ to: token,
2346
+ data: `0xdd62ed3e${this.account.address.slice(2).padStart(64, "0")}${spender.slice(2).padStart(64, "0")}`
2347
+ });
2348
+ if (!data.data || data.data === "0x") return 0n;
2349
+ return BigInt(data.data);
2350
+ } catch {
2351
+ return 0n;
2352
+ }
2353
+ }
2331
2354
  /**
2332
2355
  * Approve token spending for router
2333
2356
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exagent/sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "TypeScript SDK for Exagent",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",