@zyfai/sdk 0.1.20 → 0.1.21

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,8 +361,11 @@ 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
 
package/dist/index.d.mts CHANGED
@@ -388,6 +388,8 @@ interface ChainConfig {
388
388
  rpcUrl: string;
389
389
  publicClient: PublicClient;
390
390
  }
391
+ declare const DEFAULT_TOKEN_ADDRESSES: Record<SupportedChainId, string>;
392
+ declare const getDefaultTokenAddress: (chainId: SupportedChainId) => string;
391
393
  /**
392
394
  * Get chain configuration for a given chain ID
393
395
  */
@@ -553,9 +555,12 @@ declare class ZyfaiSDK {
553
555
  * Deposit funds from EOA to Safe smart wallet
554
556
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
555
557
  *
558
+ * Token is automatically selected based on chain:
559
+ * - Base (8453) and Arbitrum (42161): USDC
560
+ * - Plasma (9745): USDT
561
+ *
556
562
  * @param userAddress - User's address (owner of the Safe)
557
563
  * @param chainId - Target chain ID
558
- * @param tokenAddress - Token contract address to deposit
559
564
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
560
565
  * @returns Deposit response with transaction hash
561
566
  *
@@ -565,12 +570,11 @@ declare class ZyfaiSDK {
565
570
  * const result = await sdk.depositFunds(
566
571
  * "0xUser...",
567
572
  * 8453,
568
- * "0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC
569
573
  * "100000000" // 100 USDC = 100 * 10^6
570
574
  * );
571
575
  * ```
572
576
  */
573
- depositFunds(userAddress: string, chainId: SupportedChainId, tokenAddress: string, amount: string): Promise<DepositResponse>;
577
+ depositFunds(userAddress: string, chainId: SupportedChainId, amount: string): Promise<DepositResponse>;
574
578
  /**
575
579
  * Withdraw funds from Safe smart wallet
576
580
  * Initiates a withdrawal request to the ZyFAI API
@@ -857,4 +861,4 @@ declare class ZyfaiSDK {
857
861
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
858
862
  }
859
863
 
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 };
864
+ 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
@@ -388,6 +388,8 @@ interface ChainConfig {
388
388
  rpcUrl: string;
389
389
  publicClient: PublicClient;
390
390
  }
391
+ declare const DEFAULT_TOKEN_ADDRESSES: Record<SupportedChainId, string>;
392
+ declare const getDefaultTokenAddress: (chainId: SupportedChainId) => string;
391
393
  /**
392
394
  * Get chain configuration for a given chain ID
393
395
  */
@@ -553,9 +555,12 @@ declare class ZyfaiSDK {
553
555
  * Deposit funds from EOA to Safe smart wallet
554
556
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
555
557
  *
558
+ * Token is automatically selected based on chain:
559
+ * - Base (8453) and Arbitrum (42161): USDC
560
+ * - Plasma (9745): USDT
561
+ *
556
562
  * @param userAddress - User's address (owner of the Safe)
557
563
  * @param chainId - Target chain ID
558
- * @param tokenAddress - Token contract address to deposit
559
564
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
560
565
  * @returns Deposit response with transaction hash
561
566
  *
@@ -565,12 +570,11 @@ declare class ZyfaiSDK {
565
570
  * const result = await sdk.depositFunds(
566
571
  * "0xUser...",
567
572
  * 8453,
568
- * "0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC
569
573
  * "100000000" // 100 USDC = 100 * 10^6
570
574
  * );
571
575
  * ```
572
576
  */
573
- depositFunds(userAddress: string, chainId: SupportedChainId, tokenAddress: string, amount: string): Promise<DepositResponse>;
577
+ depositFunds(userAddress: string, chainId: SupportedChainId, amount: string): Promise<DepositResponse>;
574
578
  /**
575
579
  * Withdraw funds from Safe smart wallet
576
580
  * Initiates a withdrawal request to the ZyFAI API
@@ -857,4 +861,4 @@ declare class ZyfaiSDK {
857
861
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
858
862
  }
859
863
 
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 };
864
+ 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],
@@ -2342,8 +2361,10 @@ var ZyfaiSDK = class {
2342
2361
  };
2343
2362
  // Annotate the CommonJS export names for ESM import in node:
2344
2363
  0 && (module.exports = {
2364
+ DEFAULT_TOKEN_ADDRESSES,
2345
2365
  ZyfaiSDK,
2346
2366
  getChainConfig,
2367
+ getDefaultTokenAddress,
2347
2368
  getSupportedChainIds,
2348
2369
  isSupportedChain
2349
2370
  });
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],
@@ -2328,8 +2345,10 @@ var ZyfaiSDK = class {
2328
2345
  }
2329
2346
  };
2330
2347
  export {
2348
+ DEFAULT_TOKEN_ADDRESSES,
2331
2349
  ZyfaiSDK,
2332
2350
  getChainConfig,
2351
+ getDefaultTokenAddress,
2333
2352
  getSupportedChainIds,
2334
2353
  isSupportedChain
2335
2354
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
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",