@exagent/sdk 0.1.17 → 0.1.18

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
@@ -192,6 +192,10 @@ interface RouterTradeResponse {
192
192
  agentId: number;
193
193
  };
194
194
  mock?: boolean;
195
+ /** Present when API's pre-flight simulation failed (for sells) */
196
+ simulationSkipped?: boolean;
197
+ /** Warning message when simulation failed */
198
+ simulationWarning?: string;
195
199
  }
196
200
  /**
197
201
  * Trade execution result
@@ -1083,7 +1087,7 @@ declare class ExagentVault {
1083
1087
  }
1084
1088
 
1085
1089
  /** SDK version — sent to API for version gating */
1086
- declare const SDK_VERSION = "0.1.14";
1090
+ declare const SDK_VERSION = "0.1.18";
1087
1091
  /**
1088
1092
  * Default RPC URL for Base mainnet.
1089
1093
  * Coinbase's official Base RPC — reliable for reads and transactions.
@@ -1575,6 +1579,10 @@ declare class ExagentClient {
1575
1579
  * Useful for simulation or multi-step workflows
1576
1580
  */
1577
1581
  buildRouterTrade(intent: Omit<TradeIntent, 'action'>, agentId?: bigint): Promise<RouterTradeResponse>;
1582
+ /**
1583
+ * Check if an address is the ETH sentinel or WETH
1584
+ */
1585
+ private isETHAddress;
1578
1586
  /**
1579
1587
  * Read current ERC-20 allowance for a (token, spender) pair
1580
1588
  */
package/dist/index.d.ts CHANGED
@@ -192,6 +192,10 @@ interface RouterTradeResponse {
192
192
  agentId: number;
193
193
  };
194
194
  mock?: boolean;
195
+ /** Present when API's pre-flight simulation failed (for sells) */
196
+ simulationSkipped?: boolean;
197
+ /** Warning message when simulation failed */
198
+ simulationWarning?: string;
195
199
  }
196
200
  /**
197
201
  * Trade execution result
@@ -1083,7 +1087,7 @@ declare class ExagentVault {
1083
1087
  }
1084
1088
 
1085
1089
  /** SDK version — sent to API for version gating */
1086
- declare const SDK_VERSION = "0.1.14";
1090
+ declare const SDK_VERSION = "0.1.18";
1087
1091
  /**
1088
1092
  * Default RPC URL for Base mainnet.
1089
1093
  * Coinbase's official Base RPC — reliable for reads and transactions.
@@ -1575,6 +1579,10 @@ declare class ExagentClient {
1575
1579
  * Useful for simulation or multi-step workflows
1576
1580
  */
1577
1581
  buildRouterTrade(intent: Omit<TradeIntent, 'action'>, agentId?: bigint): Promise<RouterTradeResponse>;
1582
+ /**
1583
+ * Check if an address is the ETH sentinel or WETH
1584
+ */
1585
+ private isETHAddress;
1578
1586
  /**
1579
1587
  * Read current ERC-20 allowance for a (token, spender) pair
1580
1588
  */
package/dist/index.js CHANGED
@@ -1199,7 +1199,7 @@ var ExagentVault = class {
1199
1199
 
1200
1200
  // src/constants.ts
1201
1201
  var import_chains = require("viem/chains");
1202
- var SDK_VERSION = "0.1.14";
1202
+ var SDK_VERSION = "0.1.18";
1203
1203
  var DEFAULT_RPC_URL = "https://mainnet.base.org";
1204
1204
  function getRpcUrl() {
1205
1205
  if (typeof process !== "undefined" && process.env) {
@@ -1468,6 +1468,7 @@ var ExagentClient = class {
1468
1468
  data: routerTrade.transaction.data,
1469
1469
  value: BigInt(routerTrade.transaction.value)
1470
1470
  };
1471
+ const isETHInput = this.isETHAddress(intent.tokenIn);
1471
1472
  try {
1472
1473
  const estimated = await this.publicClient.estimateGas({
1473
1474
  account: this.account,
@@ -1478,20 +1479,34 @@ var ExagentClient = class {
1478
1479
  txParams.gas = estimated * 150n / 100n;
1479
1480
  } catch (err) {
1480
1481
  const errorData = err?.data;
1481
- if (errorData && errorData.length > 2) {
1482
- console.error(`Gas estimation revert data: ${errorData}`);
1483
- try {
1484
- const decoded = (0, import_viem2.decodeErrorResult)({
1485
- abi: [...EXAGENT_ROUTER_ABI, ...EXAGENT_REGISTRY_ABI],
1486
- data: errorData
1487
- });
1488
- throw new Error(`Trade will revert: ${decoded.errorName}${decoded.args ? ` (${decoded.args.join(", ")})` : ""}`);
1489
- } catch (decodeErr) {
1490
- if (decodeErr instanceof Error && decodeErr.message.startsWith("Trade will revert:")) throw decodeErr;
1491
- throw new Error(`Trade will revert: unknown error selector ${errorData.slice(0, 10)} (raw: ${errorData.slice(0, 66)})`);
1482
+ if (isETHInput) {
1483
+ if (errorData && errorData.length > 2) {
1484
+ console.error(`Gas estimation revert data: ${errorData}`);
1485
+ try {
1486
+ const decoded = (0, import_viem2.decodeErrorResult)({
1487
+ abi: [...EXAGENT_ROUTER_ABI, ...EXAGENT_REGISTRY_ABI],
1488
+ data: errorData
1489
+ });
1490
+ throw new Error(`Trade will revert: ${decoded.errorName}${decoded.args ? ` (${decoded.args.join(", ")})` : ""}`);
1491
+ } catch (decodeErr) {
1492
+ if (decodeErr instanceof Error && decodeErr.message.startsWith("Trade will revert:")) throw decodeErr;
1493
+ throw new Error(`Trade will revert: unknown error selector ${errorData.slice(0, 10)} (raw: ${errorData.slice(0, 66)})`);
1494
+ }
1492
1495
  }
1496
+ throw new Error(`Trade will revert: gas estimation failed. ${err?.message || "Unknown reason"}`);
1497
+ }
1498
+ if (routerTrade.gasEstimate) {
1499
+ const apiGas = BigInt(routerTrade.gasEstimate);
1500
+ txParams.gas = apiGas * 200n / 100n;
1501
+ console.warn(
1502
+ `[SDK] Local gas estimation failed for sell, using API estimate with 100% buffer: ${txParams.gas}. This is expected for some DEX routes. Warning: ${routerTrade.simulationWarning || "none"}`
1503
+ );
1504
+ } else {
1505
+ txParams.gas = 800000n;
1506
+ console.warn(
1507
+ `[SDK] Local gas estimation failed for sell and no API estimate available. Using safe default: 800000. This may result in wasted gas if the transaction reverts.`
1508
+ );
1493
1509
  }
1494
- throw new Error(`Trade will revert: gas estimation failed. ${err?.message || "Unknown reason"}`);
1495
1510
  }
1496
1511
  const hash = await this.walletClient.sendTransaction(txParams);
1497
1512
  return {
@@ -1537,6 +1552,13 @@ var ExagentClient = class {
1537
1552
  }
1538
1553
  return response.json();
1539
1554
  }
1555
+ /**
1556
+ * Check if an address is the ETH sentinel or WETH
1557
+ */
1558
+ isETHAddress(addr) {
1559
+ const lower = addr.toLowerCase();
1560
+ return lower === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" || lower === "0x0000000000000000000000000000000000000000" || lower === "0x4200000000000000000000000000000000000006";
1561
+ }
1540
1562
  /**
1541
1563
  * Read current ERC-20 allowance for a (token, spender) pair
1542
1564
  */
package/dist/index.mjs CHANGED
@@ -1166,7 +1166,7 @@ var ExagentVault = class {
1166
1166
 
1167
1167
  // src/constants.ts
1168
1168
  import { base } from "viem/chains";
1169
- var SDK_VERSION = "0.1.14";
1169
+ var SDK_VERSION = "0.1.18";
1170
1170
  var DEFAULT_RPC_URL = "https://mainnet.base.org";
1171
1171
  function getRpcUrl() {
1172
1172
  if (typeof process !== "undefined" && process.env) {
@@ -1435,6 +1435,7 @@ var ExagentClient = class {
1435
1435
  data: routerTrade.transaction.data,
1436
1436
  value: BigInt(routerTrade.transaction.value)
1437
1437
  };
1438
+ const isETHInput = this.isETHAddress(intent.tokenIn);
1438
1439
  try {
1439
1440
  const estimated = await this.publicClient.estimateGas({
1440
1441
  account: this.account,
@@ -1445,20 +1446,34 @@ var ExagentClient = class {
1445
1446
  txParams.gas = estimated * 150n / 100n;
1446
1447
  } catch (err) {
1447
1448
  const errorData = err?.data;
1448
- if (errorData && errorData.length > 2) {
1449
- console.error(`Gas estimation revert data: ${errorData}`);
1450
- try {
1451
- const decoded = decodeErrorResult({
1452
- abi: [...EXAGENT_ROUTER_ABI, ...EXAGENT_REGISTRY_ABI],
1453
- data: errorData
1454
- });
1455
- throw new Error(`Trade will revert: ${decoded.errorName}${decoded.args ? ` (${decoded.args.join(", ")})` : ""}`);
1456
- } catch (decodeErr) {
1457
- if (decodeErr instanceof Error && decodeErr.message.startsWith("Trade will revert:")) throw decodeErr;
1458
- throw new Error(`Trade will revert: unknown error selector ${errorData.slice(0, 10)} (raw: ${errorData.slice(0, 66)})`);
1449
+ if (isETHInput) {
1450
+ if (errorData && errorData.length > 2) {
1451
+ console.error(`Gas estimation revert data: ${errorData}`);
1452
+ try {
1453
+ const decoded = decodeErrorResult({
1454
+ abi: [...EXAGENT_ROUTER_ABI, ...EXAGENT_REGISTRY_ABI],
1455
+ data: errorData
1456
+ });
1457
+ throw new Error(`Trade will revert: ${decoded.errorName}${decoded.args ? ` (${decoded.args.join(", ")})` : ""}`);
1458
+ } catch (decodeErr) {
1459
+ if (decodeErr instanceof Error && decodeErr.message.startsWith("Trade will revert:")) throw decodeErr;
1460
+ throw new Error(`Trade will revert: unknown error selector ${errorData.slice(0, 10)} (raw: ${errorData.slice(0, 66)})`);
1461
+ }
1459
1462
  }
1463
+ throw new Error(`Trade will revert: gas estimation failed. ${err?.message || "Unknown reason"}`);
1464
+ }
1465
+ if (routerTrade.gasEstimate) {
1466
+ const apiGas = BigInt(routerTrade.gasEstimate);
1467
+ txParams.gas = apiGas * 200n / 100n;
1468
+ console.warn(
1469
+ `[SDK] Local gas estimation failed for sell, using API estimate with 100% buffer: ${txParams.gas}. This is expected for some DEX routes. Warning: ${routerTrade.simulationWarning || "none"}`
1470
+ );
1471
+ } else {
1472
+ txParams.gas = 800000n;
1473
+ console.warn(
1474
+ `[SDK] Local gas estimation failed for sell and no API estimate available. Using safe default: 800000. This may result in wasted gas if the transaction reverts.`
1475
+ );
1460
1476
  }
1461
- throw new Error(`Trade will revert: gas estimation failed. ${err?.message || "Unknown reason"}`);
1462
1477
  }
1463
1478
  const hash = await this.walletClient.sendTransaction(txParams);
1464
1479
  return {
@@ -1504,6 +1519,13 @@ var ExagentClient = class {
1504
1519
  }
1505
1520
  return response.json();
1506
1521
  }
1522
+ /**
1523
+ * Check if an address is the ETH sentinel or WETH
1524
+ */
1525
+ isETHAddress(addr) {
1526
+ const lower = addr.toLowerCase();
1527
+ return lower === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" || lower === "0x0000000000000000000000000000000000000000" || lower === "0x4200000000000000000000000000000000000006";
1528
+ }
1507
1529
  /**
1508
1530
  * Read current ERC-20 allowance for a (token, spender) pair
1509
1531
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exagent/sdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "TypeScript SDK for Exagent",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",