@agether/sdk 1.5.4 → 1.5.5

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/cli.js CHANGED
@@ -318,26 +318,48 @@ var init_MorphoClient = __esm({
318
318
  tx: txHash
319
319
  };
320
320
  }
321
- /** Get ETH / USDC balances for EOA and AgentAccount. */
321
+ /** Get ETH / USDC / collateral balances for EOA and AgentAccount. */
322
322
  async getBalances() {
323
323
  const eoaAddr = this.wallet.address;
324
324
  const usdc = new import_ethers.Contract(this.config.contracts.usdc, ERC20_ABI, this.provider);
325
325
  const ethBal = await this.provider.getBalance(eoaAddr);
326
326
  const usdcBal = await usdc.balanceOf(eoaAddr);
327
+ const eoaCollateral = {};
328
+ for (const [symbol, info] of Object.entries(BASE_COLLATERALS)) {
329
+ try {
330
+ const token = new import_ethers.Contract(info.address, ERC20_ABI, this.provider);
331
+ const bal = await token.balanceOf(eoaAddr);
332
+ eoaCollateral[symbol] = import_ethers.ethers.formatUnits(bal, info.decimals);
333
+ } catch {
334
+ eoaCollateral[symbol] = "0";
335
+ }
336
+ }
327
337
  const result = {
328
338
  agentId: this.agentId || "?",
329
339
  address: eoaAddr,
330
340
  eth: import_ethers.ethers.formatEther(ethBal),
331
- usdc: import_ethers.ethers.formatUnits(usdcBal, 6)
341
+ usdc: import_ethers.ethers.formatUnits(usdcBal, 6),
342
+ collateral: eoaCollateral
332
343
  };
333
344
  try {
334
345
  const acctAddr = await this.getAccountAddress();
335
346
  const acctEth = await this.provider.getBalance(acctAddr);
336
347
  const acctUsdc = await usdc.balanceOf(acctAddr);
348
+ const acctCollateral = {};
349
+ for (const [symbol, info] of Object.entries(BASE_COLLATERALS)) {
350
+ try {
351
+ const token = new import_ethers.Contract(info.address, ERC20_ABI, this.provider);
352
+ const bal = await token.balanceOf(acctAddr);
353
+ acctCollateral[symbol] = import_ethers.ethers.formatUnits(bal, info.decimals);
354
+ } catch {
355
+ acctCollateral[symbol] = "0";
356
+ }
357
+ }
337
358
  result.agentAccount = {
338
359
  address: acctAddr,
339
360
  eth: import_ethers.ethers.formatEther(acctEth),
340
- usdc: import_ethers.ethers.formatUnits(acctUsdc, 6)
361
+ usdc: import_ethers.ethers.formatUnits(acctUsdc, 6),
362
+ collateral: acctCollateral
341
363
  };
342
364
  } catch {
343
365
  }
package/dist/index.d.mts CHANGED
@@ -206,10 +206,12 @@ interface BalancesResult {
206
206
  address: string;
207
207
  eth: string;
208
208
  usdc: string;
209
+ collateral: Record<string, string>;
209
210
  agentAccount?: {
210
211
  address: string;
211
212
  eth: string;
212
213
  usdc: string;
214
+ collateral: Record<string, string>;
213
215
  };
214
216
  }
215
217
  interface RegisterResult {
@@ -294,7 +296,7 @@ declare class MorphoClient {
294
296
  * If already registered, returns existing state.
295
297
  */
296
298
  register(_name?: string): Promise<RegisterResult>;
297
- /** Get ETH / USDC balances for EOA and AgentAccount. */
299
+ /** Get ETH / USDC / collateral balances for EOA and AgentAccount. */
298
300
  getBalances(): Promise<BalancesResult>;
299
301
  /** Transfer USDC from EOA to AgentAccount. */
300
302
  fundAccount(usdcAmount: string): Promise<FundResult>;
package/dist/index.d.ts CHANGED
@@ -206,10 +206,12 @@ interface BalancesResult {
206
206
  address: string;
207
207
  eth: string;
208
208
  usdc: string;
209
+ collateral: Record<string, string>;
209
210
  agentAccount?: {
210
211
  address: string;
211
212
  eth: string;
212
213
  usdc: string;
214
+ collateral: Record<string, string>;
213
215
  };
214
216
  }
215
217
  interface RegisterResult {
@@ -294,7 +296,7 @@ declare class MorphoClient {
294
296
  * If already registered, returns existing state.
295
297
  */
296
298
  register(_name?: string): Promise<RegisterResult>;
297
- /** Get ETH / USDC balances for EOA and AgentAccount. */
299
+ /** Get ETH / USDC / collateral balances for EOA and AgentAccount. */
298
300
  getBalances(): Promise<BalancesResult>;
299
301
  /** Transfer USDC from EOA to AgentAccount. */
300
302
  fundAccount(usdcAmount: string): Promise<FundResult>;
package/dist/index.js CHANGED
@@ -553,26 +553,48 @@ var MorphoClient = class {
553
553
  tx: txHash
554
554
  };
555
555
  }
556
- /** Get ETH / USDC balances for EOA and AgentAccount. */
556
+ /** Get ETH / USDC / collateral balances for EOA and AgentAccount. */
557
557
  async getBalances() {
558
558
  const eoaAddr = this.wallet.address;
559
559
  const usdc = new import_ethers2.Contract(this.config.contracts.usdc, ERC20_ABI, this.provider);
560
560
  const ethBal = await this.provider.getBalance(eoaAddr);
561
561
  const usdcBal = await usdc.balanceOf(eoaAddr);
562
+ const eoaCollateral = {};
563
+ for (const [symbol, info] of Object.entries(BASE_COLLATERALS)) {
564
+ try {
565
+ const token = new import_ethers2.Contract(info.address, ERC20_ABI, this.provider);
566
+ const bal = await token.balanceOf(eoaAddr);
567
+ eoaCollateral[symbol] = import_ethers2.ethers.formatUnits(bal, info.decimals);
568
+ } catch {
569
+ eoaCollateral[symbol] = "0";
570
+ }
571
+ }
562
572
  const result = {
563
573
  agentId: this.agentId || "?",
564
574
  address: eoaAddr,
565
575
  eth: import_ethers2.ethers.formatEther(ethBal),
566
- usdc: import_ethers2.ethers.formatUnits(usdcBal, 6)
576
+ usdc: import_ethers2.ethers.formatUnits(usdcBal, 6),
577
+ collateral: eoaCollateral
567
578
  };
568
579
  try {
569
580
  const acctAddr = await this.getAccountAddress();
570
581
  const acctEth = await this.provider.getBalance(acctAddr);
571
582
  const acctUsdc = await usdc.balanceOf(acctAddr);
583
+ const acctCollateral = {};
584
+ for (const [symbol, info] of Object.entries(BASE_COLLATERALS)) {
585
+ try {
586
+ const token = new import_ethers2.Contract(info.address, ERC20_ABI, this.provider);
587
+ const bal = await token.balanceOf(acctAddr);
588
+ acctCollateral[symbol] = import_ethers2.ethers.formatUnits(bal, info.decimals);
589
+ } catch {
590
+ acctCollateral[symbol] = "0";
591
+ }
592
+ }
572
593
  result.agentAccount = {
573
594
  address: acctAddr,
574
595
  eth: import_ethers2.ethers.formatEther(acctEth),
575
- usdc: import_ethers2.ethers.formatUnits(acctUsdc, 6)
596
+ usdc: import_ethers2.ethers.formatUnits(acctUsdc, 6),
597
+ collateral: acctCollateral
576
598
  };
577
599
  } catch {
578
600
  }
package/dist/index.mjs CHANGED
@@ -489,26 +489,48 @@ var MorphoClient = class {
489
489
  tx: txHash
490
490
  };
491
491
  }
492
- /** Get ETH / USDC balances for EOA and AgentAccount. */
492
+ /** Get ETH / USDC / collateral balances for EOA and AgentAccount. */
493
493
  async getBalances() {
494
494
  const eoaAddr = this.wallet.address;
495
495
  const usdc = new Contract2(this.config.contracts.usdc, ERC20_ABI, this.provider);
496
496
  const ethBal = await this.provider.getBalance(eoaAddr);
497
497
  const usdcBal = await usdc.balanceOf(eoaAddr);
498
+ const eoaCollateral = {};
499
+ for (const [symbol, info] of Object.entries(BASE_COLLATERALS)) {
500
+ try {
501
+ const token = new Contract2(info.address, ERC20_ABI, this.provider);
502
+ const bal = await token.balanceOf(eoaAddr);
503
+ eoaCollateral[symbol] = ethers2.formatUnits(bal, info.decimals);
504
+ } catch {
505
+ eoaCollateral[symbol] = "0";
506
+ }
507
+ }
498
508
  const result = {
499
509
  agentId: this.agentId || "?",
500
510
  address: eoaAddr,
501
511
  eth: ethers2.formatEther(ethBal),
502
- usdc: ethers2.formatUnits(usdcBal, 6)
512
+ usdc: ethers2.formatUnits(usdcBal, 6),
513
+ collateral: eoaCollateral
503
514
  };
504
515
  try {
505
516
  const acctAddr = await this.getAccountAddress();
506
517
  const acctEth = await this.provider.getBalance(acctAddr);
507
518
  const acctUsdc = await usdc.balanceOf(acctAddr);
519
+ const acctCollateral = {};
520
+ for (const [symbol, info] of Object.entries(BASE_COLLATERALS)) {
521
+ try {
522
+ const token = new Contract2(info.address, ERC20_ABI, this.provider);
523
+ const bal = await token.balanceOf(acctAddr);
524
+ acctCollateral[symbol] = ethers2.formatUnits(bal, info.decimals);
525
+ } catch {
526
+ acctCollateral[symbol] = "0";
527
+ }
528
+ }
508
529
  result.agentAccount = {
509
530
  address: acctAddr,
510
531
  eth: ethers2.formatEther(acctEth),
511
- usdc: ethers2.formatUnits(acctUsdc, 6)
532
+ usdc: ethers2.formatUnits(acctUsdc, 6),
533
+ collateral: acctCollateral
512
534
  };
513
535
  } catch {
514
536
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agether/sdk",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "TypeScript SDK for Agether - autonomous credit for AI agents on Base",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",