@zyfai/sdk 0.1.20 → 0.1.22

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/README.md CHANGED
@@ -342,14 +342,16 @@ console.log("User ID:", result.userId);
342
342
 
343
343
  ### 4. Deposit Funds
344
344
 
345
- Transfer tokens to your Safe smart wallet:
345
+ Transfer tokens to your Safe smart wallet. Token address is automatically selected based on chain:
346
+
347
+ - **Base (8453) and Arbitrum (42161)**: USDC
348
+ - **Plasma (9745)**: USDT
346
349
 
347
350
  ```typescript
348
351
  // Deposit 100 USDC (6 decimals) to Safe on Base
349
352
  const result = await sdk.depositFunds(
350
353
  userAddress,
351
354
  8453, // Chain ID
352
- "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
353
355
  "100000000" // Amount: 100 USDC = 100 * 10^6
354
356
  );
355
357
 
@@ -359,12 +361,16 @@ if (result.success) {
359
361
  }
360
362
  ```
361
363
 
362
- **Note:** Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
363
- The SDK automatically authenticates via SIWE before logging the deposit with ZyFAI's API, so no extra steps are required on your end once the transfer confirms.
364
+ **Note:**
365
+
366
+ - Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
367
+ - Token address is automatically selected based on chain (USDC for Base/Arbitrum, USDT for Plasma)
368
+ - The SDK automatically authenticates via SIWE before logging the deposit with ZyFAI's API, so no extra steps are required on your end once the transfer confirms
364
369
 
365
370
  ### 5. Withdraw Funds
366
371
 
367
372
  Initiate a withdrawal from your Safe. **Note: Withdrawals are processed asynchronously by the backend.**
373
+ Funds are always withdrawn to the Safe owner's address (userAddress).
368
374
 
369
375
  ```typescript
370
376
  // Full withdrawal
@@ -374,8 +380,7 @@ const result = await sdk.withdrawFunds(userAddress, 8453);
374
380
  const result = await sdk.withdrawFunds(
375
381
  userAddress,
376
382
  8453,
377
- "50000000", // Amount: 50 USDC = 50 * 10^6
378
- "0xReceiverAddress" // Optional: receiver address
383
+ "50000000" // Amount: 50 USDC = 50 * 10^6
379
384
  );
380
385
 
381
386
  if (result.success) {
package/dist/index.d.mts CHANGED
@@ -339,7 +339,6 @@ interface DepositResponse {
339
339
  txHash: string;
340
340
  smartWallet: string;
341
341
  amount: string;
342
- status: "pending" | "confirmed" | "failed";
343
342
  }
344
343
  interface WithdrawResponse {
345
344
  success: boolean;
@@ -347,8 +346,6 @@ interface WithdrawResponse {
347
346
  txHash?: string;
348
347
  type: "full" | "partial";
349
348
  amount: string;
350
- receiver: string;
351
- status: "pending" | "confirmed" | "failed";
352
349
  }
353
350
  interface AddWalletToSdkResponse {
354
351
  success: boolean;
@@ -388,6 +385,8 @@ interface ChainConfig {
388
385
  rpcUrl: string;
389
386
  publicClient: PublicClient;
390
387
  }
388
+ declare const DEFAULT_TOKEN_ADDRESSES: Record<SupportedChainId, string>;
389
+ declare const getDefaultTokenAddress: (chainId: SupportedChainId) => string;
391
390
  /**
392
391
  * Get chain configuration for a given chain ID
393
392
  */
@@ -553,9 +552,12 @@ declare class ZyfaiSDK {
553
552
  * Deposit funds from EOA to Safe smart wallet
554
553
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
555
554
  *
555
+ * Token is automatically selected based on chain:
556
+ * - Base (8453) and Arbitrum (42161): USDC
557
+ * - Plasma (9745): USDT
558
+ *
556
559
  * @param userAddress - User's address (owner of the Safe)
557
560
  * @param chainId - Target chain ID
558
- * @param tokenAddress - Token contract address to deposit
559
561
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
560
562
  * @returns Deposit response with transaction hash
561
563
  *
@@ -565,21 +567,20 @@ declare class ZyfaiSDK {
565
567
  * const result = await sdk.depositFunds(
566
568
  * "0xUser...",
567
569
  * 8453,
568
- * "0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC
569
570
  * "100000000" // 100 USDC = 100 * 10^6
570
571
  * );
571
572
  * ```
572
573
  */
573
- depositFunds(userAddress: string, chainId: SupportedChainId, tokenAddress: string, amount: string): Promise<DepositResponse>;
574
+ depositFunds(userAddress: string, chainId: SupportedChainId, amount: string): Promise<DepositResponse>;
574
575
  /**
575
576
  * Withdraw funds from Safe smart wallet
576
577
  * Initiates a withdrawal request to the ZyFAI API
577
578
  * Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
579
+ * Funds are always withdrawn to the Safe owner's address (userAddress)
578
580
  *
579
581
  * @param userAddress - User's address (owner of the Safe)
580
582
  * @param chainId - Target chain ID
581
583
  * @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
582
- * @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
583
584
  * @returns Withdraw response with message and optional transaction hash (available once processed)
584
585
  *
585
586
  * @example
@@ -592,12 +593,11 @@ declare class ZyfaiSDK {
592
593
  * const result = await sdk.withdrawFunds(
593
594
  * "0xUser...",
594
595
  * 8453,
595
- * "50000000", // 50 USDC = 50 * 10^6
596
- * "0xReceiver..."
596
+ * "50000000" // 50 USDC = 50 * 10^6
597
597
  * );
598
598
  * ```
599
599
  */
600
- withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string, receiver?: string): Promise<WithdrawResponse>;
600
+ withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string): Promise<WithdrawResponse>;
601
601
  /**
602
602
  * Get available DeFi protocols and pools for a specific chain
603
603
  *
@@ -857,4 +857,4 @@ declare class ZyfaiSDK {
857
857
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
858
858
  }
859
859
 
860
- export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getSupportedChainIds, isSupportedChain };
860
+ export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.d.ts CHANGED
@@ -339,7 +339,6 @@ interface DepositResponse {
339
339
  txHash: string;
340
340
  smartWallet: string;
341
341
  amount: string;
342
- status: "pending" | "confirmed" | "failed";
343
342
  }
344
343
  interface WithdrawResponse {
345
344
  success: boolean;
@@ -347,8 +346,6 @@ interface WithdrawResponse {
347
346
  txHash?: string;
348
347
  type: "full" | "partial";
349
348
  amount: string;
350
- receiver: string;
351
- status: "pending" | "confirmed" | "failed";
352
349
  }
353
350
  interface AddWalletToSdkResponse {
354
351
  success: boolean;
@@ -388,6 +385,8 @@ interface ChainConfig {
388
385
  rpcUrl: string;
389
386
  publicClient: PublicClient;
390
387
  }
388
+ declare const DEFAULT_TOKEN_ADDRESSES: Record<SupportedChainId, string>;
389
+ declare const getDefaultTokenAddress: (chainId: SupportedChainId) => string;
391
390
  /**
392
391
  * Get chain configuration for a given chain ID
393
392
  */
@@ -553,9 +552,12 @@ declare class ZyfaiSDK {
553
552
  * Deposit funds from EOA to Safe smart wallet
554
553
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
555
554
  *
555
+ * Token is automatically selected based on chain:
556
+ * - Base (8453) and Arbitrum (42161): USDC
557
+ * - Plasma (9745): USDT
558
+ *
556
559
  * @param userAddress - User's address (owner of the Safe)
557
560
  * @param chainId - Target chain ID
558
- * @param tokenAddress - Token contract address to deposit
559
561
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
560
562
  * @returns Deposit response with transaction hash
561
563
  *
@@ -565,21 +567,20 @@ declare class ZyfaiSDK {
565
567
  * const result = await sdk.depositFunds(
566
568
  * "0xUser...",
567
569
  * 8453,
568
- * "0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC
569
570
  * "100000000" // 100 USDC = 100 * 10^6
570
571
  * );
571
572
  * ```
572
573
  */
573
- depositFunds(userAddress: string, chainId: SupportedChainId, tokenAddress: string, amount: string): Promise<DepositResponse>;
574
+ depositFunds(userAddress: string, chainId: SupportedChainId, amount: string): Promise<DepositResponse>;
574
575
  /**
575
576
  * Withdraw funds from Safe smart wallet
576
577
  * Initiates a withdrawal request to the ZyFAI API
577
578
  * Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
579
+ * Funds are always withdrawn to the Safe owner's address (userAddress)
578
580
  *
579
581
  * @param userAddress - User's address (owner of the Safe)
580
582
  * @param chainId - Target chain ID
581
583
  * @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
582
- * @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
583
584
  * @returns Withdraw response with message and optional transaction hash (available once processed)
584
585
  *
585
586
  * @example
@@ -592,12 +593,11 @@ declare class ZyfaiSDK {
592
593
  * const result = await sdk.withdrawFunds(
593
594
  * "0xUser...",
594
595
  * 8453,
595
- * "50000000", // 50 USDC = 50 * 10^6
596
- * "0xReceiver..."
596
+ * "50000000" // 50 USDC = 50 * 10^6
597
597
  * );
598
598
  * ```
599
599
  */
600
- withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string, receiver?: string): Promise<WithdrawResponse>;
600
+ withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string): Promise<WithdrawResponse>;
601
601
  /**
602
602
  * Get available DeFi protocols and pools for a specific chain
603
603
  *
@@ -857,4 +857,4 @@ declare class ZyfaiSDK {
857
857
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
858
858
  }
859
859
 
860
- export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getSupportedChainIds, isSupportedChain };
860
+ export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.js CHANGED
@@ -30,8 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ DEFAULT_TOKEN_ADDRESSES: () => DEFAULT_TOKEN_ADDRESSES,
33
34
  ZyfaiSDK: () => ZyfaiSDK,
34
35
  getChainConfig: () => getChainConfig,
36
+ getDefaultTokenAddress: () => getDefaultTokenAddress,
35
37
  getSupportedChainIds: () => getSupportedChainIds,
36
38
  isSupportedChain: () => isSupportedChain
37
39
  });
@@ -382,6 +384,23 @@ var plasma = (0, import_viem2.defineChain)({
382
384
  }
383
385
  }
384
386
  });
387
+ var DEFAULT_TOKEN_ADDRESSES = {
388
+ 8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
389
+ // USDC on Base
390
+ 42161: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
391
+ // USDC on Arbitrum
392
+ 9745: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb"
393
+ // USDT on Plasma
394
+ };
395
+ var getDefaultTokenAddress = (chainId) => {
396
+ const address = DEFAULT_TOKEN_ADDRESSES[chainId];
397
+ if (!address || address === "0x0000000000000000000000000000000000000000") {
398
+ throw new Error(
399
+ `Default token address not configured for chain ${chainId}. Please provide tokenAddress explicitly.`
400
+ );
401
+ }
402
+ return address;
403
+ };
385
404
  var DEFAULT_RPC_URLS = {
386
405
  8453: "https://mainnet.base.org",
387
406
  42161: "https://arb1.arbitrum.io/rpc",
@@ -1472,9 +1491,12 @@ var ZyfaiSDK = class {
1472
1491
  * Deposit funds from EOA to Safe smart wallet
1473
1492
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
1474
1493
  *
1494
+ * Token is automatically selected based on chain:
1495
+ * - Base (8453) and Arbitrum (42161): USDC
1496
+ * - Plasma (9745): USDT
1497
+ *
1475
1498
  * @param userAddress - User's address (owner of the Safe)
1476
1499
  * @param chainId - Target chain ID
1477
- * @param tokenAddress - Token contract address to deposit
1478
1500
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
1479
1501
  * @returns Deposit response with transaction hash
1480
1502
  *
@@ -1484,12 +1506,11 @@ var ZyfaiSDK = class {
1484
1506
  * const result = await sdk.depositFunds(
1485
1507
  * "0xUser...",
1486
1508
  * 8453,
1487
- * "0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC
1488
1509
  * "100000000" // 100 USDC = 100 * 10^6
1489
1510
  * );
1490
1511
  * ```
1491
1512
  */
1492
- async depositFunds(userAddress, chainId, tokenAddress, amount) {
1513
+ async depositFunds(userAddress, chainId, amount) {
1493
1514
  try {
1494
1515
  if (!userAddress) {
1495
1516
  throw new Error("User address is required");
@@ -1497,12 +1518,10 @@ var ZyfaiSDK = class {
1497
1518
  if (!isSupportedChain(chainId)) {
1498
1519
  throw new Error(`Unsupported chain ID: ${chainId}`);
1499
1520
  }
1500
- if (!tokenAddress) {
1501
- throw new Error("Token address is required");
1502
- }
1503
1521
  if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
1504
1522
  throw new Error("Valid amount is required");
1505
1523
  }
1524
+ const token = getDefaultTokenAddress(chainId);
1506
1525
  const walletClient = this.getWalletClient();
1507
1526
  const chainConfig = getChainConfig(chainId);
1508
1527
  const safeAddress = await getDeterministicSafeAddress({
@@ -1523,7 +1542,7 @@ var ZyfaiSDK = class {
1523
1542
  }
1524
1543
  const amountBigInt = BigInt(amount);
1525
1544
  const txHash = await walletClient.writeContract({
1526
- address: tokenAddress,
1545
+ address: token,
1527
1546
  abi: ERC20_ABI,
1528
1547
  functionName: "transfer",
1529
1548
  args: [safeAddress, amountBigInt],
@@ -1540,8 +1559,7 @@ var ZyfaiSDK = class {
1540
1559
  success: true,
1541
1560
  txHash,
1542
1561
  smartWallet: safeAddress,
1543
- amount: amountBigInt.toString(),
1544
- status: "confirmed"
1562
+ amount: amountBigInt.toString()
1545
1563
  };
1546
1564
  } catch (error) {
1547
1565
  throw new Error(`Deposit failed: ${error.message}`);
@@ -1551,11 +1569,11 @@ var ZyfaiSDK = class {
1551
1569
  * Withdraw funds from Safe smart wallet
1552
1570
  * Initiates a withdrawal request to the ZyFAI API
1553
1571
  * Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
1572
+ * Funds are always withdrawn to the Safe owner's address (userAddress)
1554
1573
  *
1555
1574
  * @param userAddress - User's address (owner of the Safe)
1556
1575
  * @param chainId - Target chain ID
1557
1576
  * @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
1558
- * @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
1559
1577
  * @returns Withdraw response with message and optional transaction hash (available once processed)
1560
1578
  *
1561
1579
  * @example
@@ -1568,12 +1586,11 @@ var ZyfaiSDK = class {
1568
1586
  * const result = await sdk.withdrawFunds(
1569
1587
  * "0xUser...",
1570
1588
  * 8453,
1571
- * "50000000", // 50 USDC = 50 * 10^6
1572
- * "0xReceiver..."
1589
+ * "50000000" // 50 USDC = 50 * 10^6
1573
1590
  * );
1574
1591
  * ```
1575
1592
  */
1576
- async withdrawFunds(userAddress, chainId, amount, receiver) {
1593
+ async withdrawFunds(userAddress, chainId, amount) {
1577
1594
  try {
1578
1595
  if (!userAddress) {
1579
1596
  throw new Error("User address is required");
@@ -1621,8 +1638,7 @@ var ZyfaiSDK = class {
1621
1638
  if (amount) {
1622
1639
  response = await this.httpClient.post(ENDPOINTS.PARTIAL_WITHDRAW, {
1623
1640
  chainId,
1624
- amount,
1625
- receiver: receiver || userAddress
1641
+ amount
1626
1642
  });
1627
1643
  } else {
1628
1644
  response = await this.httpClient.get(ENDPOINTS.USER_WITHDRAW, {
@@ -1637,9 +1653,7 @@ var ZyfaiSDK = class {
1637
1653
  message,
1638
1654
  txHash,
1639
1655
  type: amount ? "partial" : "full",
1640
- amount: amount || "all",
1641
- receiver: receiver || userAddress,
1642
- status: success ? "pending" : "failed"
1656
+ amount: amount || "all"
1643
1657
  };
1644
1658
  } catch (error) {
1645
1659
  throw new Error(`Withdrawal failed: ${error.message}`);
@@ -2342,8 +2356,10 @@ var ZyfaiSDK = class {
2342
2356
  };
2343
2357
  // Annotate the CommonJS export names for ESM import in node:
2344
2358
  0 && (module.exports = {
2359
+ DEFAULT_TOKEN_ADDRESSES,
2345
2360
  ZyfaiSDK,
2346
2361
  getChainConfig,
2362
+ getDefaultTokenAddress,
2347
2363
  getSupportedChainIds,
2348
2364
  isSupportedChain
2349
2365
  });
package/dist/index.mjs CHANGED
@@ -348,6 +348,23 @@ var plasma = defineChain({
348
348
  }
349
349
  }
350
350
  });
351
+ var DEFAULT_TOKEN_ADDRESSES = {
352
+ 8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
353
+ // USDC on Base
354
+ 42161: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
355
+ // USDC on Arbitrum
356
+ 9745: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb"
357
+ // USDT on Plasma
358
+ };
359
+ var getDefaultTokenAddress = (chainId) => {
360
+ const address = DEFAULT_TOKEN_ADDRESSES[chainId];
361
+ if (!address || address === "0x0000000000000000000000000000000000000000") {
362
+ throw new Error(
363
+ `Default token address not configured for chain ${chainId}. Please provide tokenAddress explicitly.`
364
+ );
365
+ }
366
+ return address;
367
+ };
351
368
  var DEFAULT_RPC_URLS = {
352
369
  8453: "https://mainnet.base.org",
353
370
  42161: "https://arb1.arbitrum.io/rpc",
@@ -1459,9 +1476,12 @@ var ZyfaiSDK = class {
1459
1476
  * Deposit funds from EOA to Safe smart wallet
1460
1477
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
1461
1478
  *
1479
+ * Token is automatically selected based on chain:
1480
+ * - Base (8453) and Arbitrum (42161): USDC
1481
+ * - Plasma (9745): USDT
1482
+ *
1462
1483
  * @param userAddress - User's address (owner of the Safe)
1463
1484
  * @param chainId - Target chain ID
1464
- * @param tokenAddress - Token contract address to deposit
1465
1485
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
1466
1486
  * @returns Deposit response with transaction hash
1467
1487
  *
@@ -1471,12 +1491,11 @@ var ZyfaiSDK = class {
1471
1491
  * const result = await sdk.depositFunds(
1472
1492
  * "0xUser...",
1473
1493
  * 8453,
1474
- * "0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC
1475
1494
  * "100000000" // 100 USDC = 100 * 10^6
1476
1495
  * );
1477
1496
  * ```
1478
1497
  */
1479
- async depositFunds(userAddress, chainId, tokenAddress, amount) {
1498
+ async depositFunds(userAddress, chainId, amount) {
1480
1499
  try {
1481
1500
  if (!userAddress) {
1482
1501
  throw new Error("User address is required");
@@ -1484,12 +1503,10 @@ var ZyfaiSDK = class {
1484
1503
  if (!isSupportedChain(chainId)) {
1485
1504
  throw new Error(`Unsupported chain ID: ${chainId}`);
1486
1505
  }
1487
- if (!tokenAddress) {
1488
- throw new Error("Token address is required");
1489
- }
1490
1506
  if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
1491
1507
  throw new Error("Valid amount is required");
1492
1508
  }
1509
+ const token = getDefaultTokenAddress(chainId);
1493
1510
  const walletClient = this.getWalletClient();
1494
1511
  const chainConfig = getChainConfig(chainId);
1495
1512
  const safeAddress = await getDeterministicSafeAddress({
@@ -1510,7 +1527,7 @@ var ZyfaiSDK = class {
1510
1527
  }
1511
1528
  const amountBigInt = BigInt(amount);
1512
1529
  const txHash = await walletClient.writeContract({
1513
- address: tokenAddress,
1530
+ address: token,
1514
1531
  abi: ERC20_ABI,
1515
1532
  functionName: "transfer",
1516
1533
  args: [safeAddress, amountBigInt],
@@ -1527,8 +1544,7 @@ var ZyfaiSDK = class {
1527
1544
  success: true,
1528
1545
  txHash,
1529
1546
  smartWallet: safeAddress,
1530
- amount: amountBigInt.toString(),
1531
- status: "confirmed"
1547
+ amount: amountBigInt.toString()
1532
1548
  };
1533
1549
  } catch (error) {
1534
1550
  throw new Error(`Deposit failed: ${error.message}`);
@@ -1538,11 +1554,11 @@ var ZyfaiSDK = class {
1538
1554
  * Withdraw funds from Safe smart wallet
1539
1555
  * Initiates a withdrawal request to the ZyFAI API
1540
1556
  * Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
1557
+ * Funds are always withdrawn to the Safe owner's address (userAddress)
1541
1558
  *
1542
1559
  * @param userAddress - User's address (owner of the Safe)
1543
1560
  * @param chainId - Target chain ID
1544
1561
  * @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
1545
- * @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
1546
1562
  * @returns Withdraw response with message and optional transaction hash (available once processed)
1547
1563
  *
1548
1564
  * @example
@@ -1555,12 +1571,11 @@ var ZyfaiSDK = class {
1555
1571
  * const result = await sdk.withdrawFunds(
1556
1572
  * "0xUser...",
1557
1573
  * 8453,
1558
- * "50000000", // 50 USDC = 50 * 10^6
1559
- * "0xReceiver..."
1574
+ * "50000000" // 50 USDC = 50 * 10^6
1560
1575
  * );
1561
1576
  * ```
1562
1577
  */
1563
- async withdrawFunds(userAddress, chainId, amount, receiver) {
1578
+ async withdrawFunds(userAddress, chainId, amount) {
1564
1579
  try {
1565
1580
  if (!userAddress) {
1566
1581
  throw new Error("User address is required");
@@ -1608,8 +1623,7 @@ var ZyfaiSDK = class {
1608
1623
  if (amount) {
1609
1624
  response = await this.httpClient.post(ENDPOINTS.PARTIAL_WITHDRAW, {
1610
1625
  chainId,
1611
- amount,
1612
- receiver: receiver || userAddress
1626
+ amount
1613
1627
  });
1614
1628
  } else {
1615
1629
  response = await this.httpClient.get(ENDPOINTS.USER_WITHDRAW, {
@@ -1624,9 +1638,7 @@ var ZyfaiSDK = class {
1624
1638
  message,
1625
1639
  txHash,
1626
1640
  type: amount ? "partial" : "full",
1627
- amount: amount || "all",
1628
- receiver: receiver || userAddress,
1629
- status: success ? "pending" : "failed"
1641
+ amount: amount || "all"
1630
1642
  };
1631
1643
  } catch (error) {
1632
1644
  throw new Error(`Withdrawal failed: ${error.message}`);
@@ -2328,8 +2340,10 @@ var ZyfaiSDK = class {
2328
2340
  }
2329
2341
  };
2330
2342
  export {
2343
+ DEFAULT_TOKEN_ADDRESSES,
2331
2344
  ZyfaiSDK,
2332
2345
  getChainConfig,
2346
+ getDefaultTokenAddress,
2333
2347
  getSupportedChainIds,
2334
2348
  isSupportedChain
2335
2349
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "TypeScript SDK for ZyFAI Yield Optimization Engine - Deploy Safe smart wallets, manage session keys, and interact with DeFi protocols",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",