@zyfai/sdk 0.2.36 → 0.2.38

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
@@ -11,7 +11,7 @@ You can generate an api key from here: https://sdk.zyf.ai/
11
11
 
12
12
  - **Safe Smart Wallet Deployment**: Deploy Safe wallets with deterministic addresses
13
13
  - **Flexible Authentication**: Support for private keys and modern wallet providers
14
- - **Multi-Chain Support**: Works on Arbitrum, Base, and Plasma
14
+ - **Multi-Chain Support**: Works on Ethereum Mainnet, Base, and Arbitrum
15
15
  - **Yield Optimization**: Access to multiple DeFi protocols and strategies
16
16
  - **Position Tracking**: Monitor and manage your DeFi positions across chains
17
17
 
@@ -136,11 +136,11 @@ if (result.success) {
136
136
 
137
137
  The SDK supports the following chains:
138
138
 
139
- | Chain | Chain ID | Status |
140
- | -------- | -------- | ------ |
141
- | Arbitrum | 42161 | ✅ |
142
- | Base | 8453 | ✅ |
143
- | Plasma | 9745 | ✅ |
139
+ | Chain | Chain ID | Status |
140
+ | ---------------- | -------- | ------ |
141
+ | Ethereum Mainnet | 1 | ✅ |
142
+ | Base | 8453 | ✅ |
143
+ | Arbitrum | 42161 | ✅ |
144
144
 
145
145
  Example with different chains:
146
146
 
@@ -175,9 +175,9 @@ new ZyfaiSDK(config: SDKConfig | string)
175
175
  - If an object is provided:
176
176
  - `apiKey` (string): Your Zyfai API key (required)
177
177
  - `rpcUrls` (object, optional): Custom RPC URLs per chain to avoid rate limiting (optional, only needed for local operations like `getSmartWalletAddress`)
178
+ - `1` (string, optional): Ethereum Mainnet RPC URL
178
179
  - `8453` (string, optional): Base Mainnet RPC URL
179
180
  - `42161` (string, optional): Arbitrum One RPC URL
180
- - `9745` (string, optional): Plasma Mainnet RPC URL
181
181
 
182
182
  **Examples:**
183
183
 
@@ -194,9 +194,9 @@ const sdk = new ZyfaiSDK({
194
194
  const sdk = new ZyfaiSDK({
195
195
  apiKey: "your-api-key",
196
196
  rpcUrls: {
197
+ 1: "https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY", // Ethereum Mainnet
197
198
  8453: "https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY", // Base
198
199
  42161: "https://arb-mainnet.g.alchemy.com/v2/YOUR_API_KEY", // Arbitrum
199
- 9745: "https://your-plasma-rpc-provider.com", // Plasma
200
200
  },
201
201
  });
202
202
  ```
@@ -360,17 +360,23 @@ console.log("User ID:", result.userId);
360
360
 
361
361
  ### 4. Deposit Funds
362
362
 
363
- Transfer tokens to your Safe smart wallet. Token address is automatically selected based on chain:
363
+ Transfer tokens to your Safe smart wallet. Token address is automatically selected based on chain and the requested asset (defaults to USDC):
364
364
 
365
- - **Base (8453) and Arbitrum (42161)**: USDC
366
- - **Plasma (9745)**: USDT
365
+ - **Ethereum Mainnet (1), Base (8453), Arbitrum (42161)**: USDC (default) or WETH
366
+
367
+ **Minimum portfolio balance (enforced on Safe balance + deposit amount):**
368
+
369
+ - Ethereum Mainnet (1) / USDC: 5 USDC (test threshold — will be raised before production)
370
+ - All other (chain, asset) pairs: no minimum enforced
371
+
372
+ Only deposits on Mainnet in USDC that would leave the Safe below 5 USDC are rejected. Deposits on Base or Arbitrum, or in WETH, have no minimum today.
367
373
 
368
374
  ```typescript
369
- // Deposit 100 USDC (6 decimals) to Safe on Base
375
+ // Deposit 10 USDC (6 decimals) to Safe on Base — no minimum on Base
370
376
  const result = await sdk.depositFunds(
371
377
  userAddress,
372
378
  8453, // Chain ID
373
- "100000000" // Amount: 100 USDC = 100 * 10^6
379
+ "10000000" // Amount: 10 USDC = 10 * 10^6
374
380
  );
375
381
 
376
382
  if (result.success) {
@@ -382,7 +388,8 @@ if (result.success) {
382
388
  **Note:**
383
389
 
384
390
  - Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
385
- - Token address is automatically selected based on chain (USDC for Base/Arbitrum, USDT for Plasma)
391
+ - Token address is automatically selected based on chain (USDC by default; pass `asset: "WETH"` to deposit WETH instead)
392
+ - On Ethereum Mainnet, the total Safe balance in USDC must be at least 5 USDC after the deposit (test threshold); smaller top-ups are allowed if the Safe already holds enough USDC to meet the minimum
386
393
  - 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
387
394
 
388
395
  #### Log External Deposit (For Sponsored Transactions)
@@ -996,7 +1003,7 @@ try {
996
1003
  2. **Use Environment Variables**: Store keys in `.env` files
997
1004
  3. **Check Deployment Status**: Always check if Safe is already deployed before deploying
998
1005
  4. **Handle Errors Gracefully**: Implement proper error handling for all SDK methods
999
- 5. **Validate Chain IDs**: Ensure you're using supported chains (Arbitrum, Base, Plasma)
1006
+ 5. **Validate Chain IDs**: Ensure you're using supported chains (Ethereum Mainnet, Base, Arbitrum)
1000
1007
  6. **Use Explicit Parameters**: Always pass explicit `userAddress` and `chainId` to methods
1001
1008
 
1002
1009
  ## Environment Variables
@@ -1012,7 +1019,7 @@ ZYFAI_API_KEY=your-api-key
1012
1019
  PRIVATE_KEY=0x...
1013
1020
 
1014
1021
  # Optional: Chain ID (default: 8453 for Base)
1015
- # Supported: 42161 (Arbitrum), 8453 (Base), 9745 (Plasma)
1022
+ # Supported: 1 (Ethereum Mainnet), 8453 (Base), 42161 (Arbitrum)
1016
1023
  CHAIN_ID=8453
1017
1024
  ```
1018
1025
 
@@ -1024,7 +1031,7 @@ Make sure to call `connectAccount()` before calling methods that require **signi
1024
1031
 
1025
1032
  ### "Unsupported chain" Error
1026
1033
 
1027
- Check that the chain ID is in the supported chains list: Arbitrum (42161), Base (8453), or Plasma (9745).
1034
+ Check that the chain ID is in the supported chains list: Ethereum Mainnet (1), Base (8453), or Arbitrum (42161).
1028
1035
 
1029
1036
  ### SIWE Authentication Issues in Browser
1030
1037
 
package/dist/index.d.mts CHANGED
@@ -7,9 +7,9 @@ type Address = `0x${string}`;
7
7
  type Hex = `0x${string}`;
8
8
  type Strategy = "conservative" | "aggressive";
9
9
  interface RpcUrlsConfig {
10
+ 1?: string;
10
11
  8453?: string;
11
12
  42161?: string;
12
- 9745?: string;
13
13
  }
14
14
  interface SDKConfig {
15
15
  apiKey: string;
@@ -131,15 +131,19 @@ interface Portfolio {
131
131
  executorProxy?: boolean;
132
132
  assetTypeSettings?: AssetTypeSettings;
133
133
  }
134
+ interface PortfolioAssetBalance {
135
+ balance: Hex;
136
+ decimals: number;
137
+ }
138
+ type PortfolioByAssetType = Record<string, PortfolioAssetBalance>;
139
+ type PortfolioByChain = Record<string, PortfolioByAssetType>;
134
140
  interface PortfolioDetailed {
135
141
  hasBalance?: boolean;
136
142
  staleBalances?: string[];
137
143
  hasActiveSessionKey?: boolean;
138
144
  positions?: PositionSlot[];
139
- portfolioByAssetType?: Record<string, {
140
- balance: string;
141
- decimals: number;
142
- }>;
145
+ portfolioByAssetType?: PortfolioByAssetType;
146
+ portfolioByChain?: PortfolioByChain;
143
147
  }
144
148
  interface AssetTypeSettings {
145
149
  [assetType: string]: {
@@ -166,6 +170,7 @@ interface PositionSlot {
166
170
  underlyingAmount?: string;
167
171
  pool_apy?: number;
168
172
  pool_tvl?: number;
173
+ liquidity?: number;
169
174
  }
170
175
  interface PortfolioResponse {
171
176
  success: boolean;
@@ -547,7 +552,12 @@ interface VaultSharesResponse {
547
552
  symbol: string;
548
553
  }
549
554
 
550
- type SupportedChainId = 8453 | 42161 | 9745;
555
+ /**
556
+ * Chain Configuration for Zyfai SDK
557
+ * Supports Ethereum Mainnet, Arbitrum, and Base networks
558
+ */
559
+
560
+ type SupportedChainId = 1 | 8453 | 42161;
551
561
  interface ChainConfig {
552
562
  chain: Chain;
553
563
  rpcUrl: string;
@@ -834,22 +844,30 @@ declare class ZyfaiSDK {
834
844
  * Deposit funds from EOA to Safe smart wallet
835
845
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
836
846
  *
837
- * Token is automatically selected based on chain:
838
- * - Base (8453) and Arbitrum (42161): USDC
839
- * - Plasma (9745): USDT
847
+ * Token is automatically selected based on chain (USDC by default):
848
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
849
+ *
850
+ * Minimum portfolio balance enforced (Safe balance + deposit amount),
851
+ * configured per-chain in `MIN_PORTFOLIO_BALANCE`:
852
+ * - Ethereum Mainnet (1): 5 USDC (test threshold)
853
+ * - Base (8453) & Arbitrum (42161): no minimum
854
+ *
855
+ * If no minimum is configured for a given (chainId, asset) pair,
856
+ * the check is skipped.
840
857
  *
841
858
  * @param userAddress - User's address (owner of the Safe)
842
859
  * @param chainId - Target chain ID
843
860
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
861
+ * @param asset - Optional asset symbol ("USDC" or "WETH"). Defaults to "USDC".
844
862
  * @returns Deposit response with transaction hash
845
863
  *
846
864
  * @example
847
865
  * ```typescript
848
- * // Deposit 100 USDC (6 decimals) to Safe on Base
866
+ * // Deposit 10,000 USDC (6 decimals) to Safe on Base
849
867
  * const result = await sdk.depositFunds(
850
868
  * "0xUser...",
851
869
  * 8453,
852
- * "100000000" // 100 USDC = 100 * 10^6
870
+ * "10000000000" // 10,000 USDC = 10_000 * 10^6
853
871
  * );
854
872
  * ```
855
873
  */
@@ -867,8 +885,7 @@ declare class ZyfaiSDK {
867
885
  * - Need more control over transaction execution
868
886
  *
869
887
  * Token is automatically selected based on chain if not provided:
870
- * - Base (8453) and Arbitrum (42161): USDC
871
- * - Plasma (9745): USDT
888
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC by default
872
889
  *
873
890
  * @param chainId - Chain ID where the deposit was made
874
891
  * @param txHash - Transaction hash of the deposit
@@ -1524,4 +1541,4 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
1524
1541
 
1525
1542
  declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
1526
1543
 
1527
- export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LogDepositResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type Portfolio, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
1544
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LogDepositResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.d.ts CHANGED
@@ -7,9 +7,9 @@ type Address = `0x${string}`;
7
7
  type Hex = `0x${string}`;
8
8
  type Strategy = "conservative" | "aggressive";
9
9
  interface RpcUrlsConfig {
10
+ 1?: string;
10
11
  8453?: string;
11
12
  42161?: string;
12
- 9745?: string;
13
13
  }
14
14
  interface SDKConfig {
15
15
  apiKey: string;
@@ -131,15 +131,19 @@ interface Portfolio {
131
131
  executorProxy?: boolean;
132
132
  assetTypeSettings?: AssetTypeSettings;
133
133
  }
134
+ interface PortfolioAssetBalance {
135
+ balance: Hex;
136
+ decimals: number;
137
+ }
138
+ type PortfolioByAssetType = Record<string, PortfolioAssetBalance>;
139
+ type PortfolioByChain = Record<string, PortfolioByAssetType>;
134
140
  interface PortfolioDetailed {
135
141
  hasBalance?: boolean;
136
142
  staleBalances?: string[];
137
143
  hasActiveSessionKey?: boolean;
138
144
  positions?: PositionSlot[];
139
- portfolioByAssetType?: Record<string, {
140
- balance: string;
141
- decimals: number;
142
- }>;
145
+ portfolioByAssetType?: PortfolioByAssetType;
146
+ portfolioByChain?: PortfolioByChain;
143
147
  }
144
148
  interface AssetTypeSettings {
145
149
  [assetType: string]: {
@@ -166,6 +170,7 @@ interface PositionSlot {
166
170
  underlyingAmount?: string;
167
171
  pool_apy?: number;
168
172
  pool_tvl?: number;
173
+ liquidity?: number;
169
174
  }
170
175
  interface PortfolioResponse {
171
176
  success: boolean;
@@ -547,7 +552,12 @@ interface VaultSharesResponse {
547
552
  symbol: string;
548
553
  }
549
554
 
550
- type SupportedChainId = 8453 | 42161 | 9745;
555
+ /**
556
+ * Chain Configuration for Zyfai SDK
557
+ * Supports Ethereum Mainnet, Arbitrum, and Base networks
558
+ */
559
+
560
+ type SupportedChainId = 1 | 8453 | 42161;
551
561
  interface ChainConfig {
552
562
  chain: Chain;
553
563
  rpcUrl: string;
@@ -834,22 +844,30 @@ declare class ZyfaiSDK {
834
844
  * Deposit funds from EOA to Safe smart wallet
835
845
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
836
846
  *
837
- * Token is automatically selected based on chain:
838
- * - Base (8453) and Arbitrum (42161): USDC
839
- * - Plasma (9745): USDT
847
+ * Token is automatically selected based on chain (USDC by default):
848
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
849
+ *
850
+ * Minimum portfolio balance enforced (Safe balance + deposit amount),
851
+ * configured per-chain in `MIN_PORTFOLIO_BALANCE`:
852
+ * - Ethereum Mainnet (1): 5 USDC (test threshold)
853
+ * - Base (8453) & Arbitrum (42161): no minimum
854
+ *
855
+ * If no minimum is configured for a given (chainId, asset) pair,
856
+ * the check is skipped.
840
857
  *
841
858
  * @param userAddress - User's address (owner of the Safe)
842
859
  * @param chainId - Target chain ID
843
860
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
861
+ * @param asset - Optional asset symbol ("USDC" or "WETH"). Defaults to "USDC".
844
862
  * @returns Deposit response with transaction hash
845
863
  *
846
864
  * @example
847
865
  * ```typescript
848
- * // Deposit 100 USDC (6 decimals) to Safe on Base
866
+ * // Deposit 10,000 USDC (6 decimals) to Safe on Base
849
867
  * const result = await sdk.depositFunds(
850
868
  * "0xUser...",
851
869
  * 8453,
852
- * "100000000" // 100 USDC = 100 * 10^6
870
+ * "10000000000" // 10,000 USDC = 10_000 * 10^6
853
871
  * );
854
872
  * ```
855
873
  */
@@ -867,8 +885,7 @@ declare class ZyfaiSDK {
867
885
  * - Need more control over transaction execution
868
886
  *
869
887
  * Token is automatically selected based on chain if not provided:
870
- * - Base (8453) and Arbitrum (42161): USDC
871
- * - Plasma (9745): USDT
888
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC by default
872
889
  *
873
890
  * @param chainId - Chain ID where the deposit was made
874
891
  * @param txHash - Transaction hash of the deposit
@@ -1524,4 +1541,4 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
1524
1541
 
1525
1542
  declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
1526
1543
 
1527
- export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LogDepositResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type Portfolio, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
1544
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LogDepositResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.js CHANGED
@@ -476,41 +476,34 @@ var VAULT_ABI = [
476
476
  ];
477
477
  var VAULT_ADDRESS = "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
478
478
 
479
+ // src/config/constants.ts
480
+ var MIN_PORTFOLIO_BALANCE = {
481
+ 1: {
482
+ USDC: 10000n * 10n ** 6n,
483
+ // 10,000 USDC (6 decimals)
484
+ WETH: 5n * 10n ** 18n
485
+ // 5 WETH (18 decimals)
486
+ }
487
+ };
488
+ var formatMinPortfolioLabel = (raw, decimals, symbol) => {
489
+ const whole = raw / 10n ** BigInt(decimals);
490
+ return `${whole.toString()} ${symbol}`;
491
+ };
492
+
479
493
  // src/core/ZyfaiSDK.ts
480
494
  var import_accounts2 = require("viem/accounts");
481
- var import_viem5 = require("viem");
495
+ var import_viem4 = require("viem");
482
496
 
483
497
  // src/config/chains.ts
484
498
  var import_viem2 = require("viem");
485
499
  var import_chains = require("viem/chains");
486
- var import_viem3 = require("viem");
487
- var plasma = (0, import_viem3.defineChain)({
488
- id: 9745,
489
- name: "Plasma",
490
- nativeCurrency: {
491
- decimals: 18,
492
- name: "Plasma",
493
- symbol: "PLSM"
494
- },
495
- rpcUrls: {
496
- default: {
497
- http: ["https://rpc.plasma.to"]
498
- }
499
- },
500
- blockExplorers: {
501
- default: {
502
- name: "Plasma Explorer",
503
- url: "https://explorer.plasma.io"
504
- }
505
- }
506
- });
507
500
  var DEFAULT_TOKEN_ADDRESSES = {
501
+ 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
502
+ // USDC on Ethereum Mainnet
508
503
  8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
509
504
  // USDC on Base
510
- 42161: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
505
+ 42161: "0xaf88d065e77c8cc2239327c5edb3a432268e5831"
511
506
  // USDC on Arbitrum
512
- 9745: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb"
513
- // USDT on Plasma
514
507
  };
515
508
  var ASSET_CONFIGS = {
516
509
  USDC: {
@@ -521,25 +514,23 @@ var ASSET_CONFIGS = {
521
514
  decimals: 6,
522
515
  tokenSymbols: ["USDC", "USDC.e", "USDT", "USDT0"],
523
516
  tokenSymbolsByChainId: {
517
+ 1: "USDC",
524
518
  8453: "USDC",
525
519
  42161: "USDC",
526
- 9745: "USDT0",
527
520
  146: "USDC.e",
528
- 1: "USDC"
521
+ 59144: "USDC"
529
522
  },
530
523
  addresses: {
524
+ 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
525
+ // Ethereum
531
526
  8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
532
527
  // Base
533
528
  42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
534
529
  // Arbitrum
535
- 9745: "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
536
- // Plasma
537
530
  146: "0x29219dd400f2bf60e5a23d13be72b486d4038894",
538
531
  // Sonic
539
- 59144: "0x176211869ca2b568f2a7d4ee941e073a821ee1ff",
532
+ 59144: "0x176211869ca2b568f2a7d4ee941e073a821ee1ff"
540
533
  // Linea
541
- 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
542
- // Ethereum
543
534
  },
544
535
  enabled: true
545
536
  },
@@ -551,26 +542,23 @@ var ASSET_CONFIGS = {
551
542
  decimals: 18,
552
543
  tokenSymbols: ["WETH", "ETH"],
553
544
  tokenSymbolsByChainId: {
545
+ 1: "WETH",
554
546
  8453: "WETH",
555
547
  42161: "WETH",
556
- 9745: "WETH",
557
548
  146: "WETH",
558
- 59144: "WETH",
559
- 1: "WETH"
549
+ 59144: "WETH"
560
550
  },
561
551
  addresses: {
552
+ 1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
553
+ // Ethereum
562
554
  8453: "0x4200000000000000000000000000000000000006",
563
555
  // Base
564
556
  42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
565
557
  // Arbitrum
566
- 9745: "0x4200000000000000000000000000000000000006",
567
- // Plasma
568
558
  146: "0x039e64f90d4199560e7533692f69448878db85c7",
569
559
  // Sonic
570
- 59144: "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
560
+ 59144: "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f"
571
561
  // Linea
572
- 1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
573
- // Ethereum
574
562
  },
575
563
  enabled: true
576
564
  }
@@ -585,14 +573,14 @@ var getDefaultTokenAddress = (chainId, asset) => {
585
573
  return address;
586
574
  };
587
575
  var DEFAULT_RPC_URLS = {
576
+ 1: "https://mainnet.infura.io/v3/8e6cdd06e30d40ac9990bf61bed3a3d0",
588
577
  8453: "https://mainnet.base.org",
589
- 42161: "https://arb1.arbitrum.io/rpc",
590
- 9745: "https://rpc.plasma.to"
578
+ 42161: "https://arb1.arbitrum.io/rpc"
591
579
  };
592
580
  var CHAINS = {
581
+ 1: import_chains.mainnet,
593
582
  8453: import_chains.base,
594
- 42161: import_chains.arbitrum,
595
- 9745: plasma
583
+ 42161: import_chains.arbitrum
596
584
  };
597
585
  var getChainConfig = (chainId, rpcUrls) => {
598
586
  const chain = CHAINS[chainId];
@@ -620,7 +608,7 @@ var getSupportedChainIds = () => {
620
608
  // src/utils/safe-account.ts
621
609
  var import_module_sdk = require("@rhinestone/module-sdk");
622
610
  var import_accounts = require("permissionless/accounts");
623
- var import_viem4 = require("viem");
611
+ var import_viem3 = require("viem");
624
612
  var import_account_abstraction = require("viem/account-abstraction");
625
613
  var SAFE_7579_ADDRESS = "0x7579EE8307284F293B1927136486880611F20002";
626
614
  var ERC7579_LAUNCHPAD_ADDRESS = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
@@ -630,12 +618,12 @@ var getSafeAccount = async (config) => {
630
618
  if (!safeOwnerAddress) {
631
619
  throw new Error("Safe owner address is required");
632
620
  }
633
- const formattedOwnerAddress = (0, import_viem4.getAddress)(safeOwnerAddress);
621
+ const formattedOwnerAddress = (0, import_viem3.getAddress)(safeOwnerAddress);
634
622
  const ownableValidator = (0, import_module_sdk.getOwnableValidator)({
635
623
  owners: [formattedOwnerAddress],
636
624
  threshold: 1
637
625
  });
638
- const saltHex = (0, import_viem4.fromHex)((0, import_viem4.toHex)(ACCOUNT_SALT), "bigint");
626
+ const saltHex = (0, import_viem3.fromHex)((0, import_viem3.toHex)(ACCOUNT_SALT), "bigint");
639
627
  const tempOwner = {
640
628
  address: formattedOwnerAddress,
641
629
  type: "json-rpc"
@@ -939,7 +927,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
939
927
  return;
940
928
  }
941
929
  const walletClient = this.getWalletClient();
942
- const userAddress = (0, import_viem5.getAddress)(walletClient.account.address);
930
+ const userAddress = (0, import_viem4.getAddress)(walletClient.account.address);
943
931
  const chainId = this.currentChainId || walletClient.chain?.id || 8453;
944
932
  const challengeResponse = await this.httpClient.post(ENDPOINTS.AUTH_CHALLENGE, {});
945
933
  let uri;
@@ -1293,10 +1281,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1293
1281
  this.walletClient.chain?.id || 8453,
1294
1282
  this.rpcUrls
1295
1283
  );
1296
- this.walletClient = (0, import_viem5.createWalletClient)({
1284
+ this.walletClient = (0, import_viem4.createWalletClient)({
1297
1285
  account: newAddress,
1298
1286
  chain: chainConfig.chain,
1299
- transport: (0, import_viem5.custom)(this.currentProvider)
1287
+ transport: (0, import_viem4.custom)(this.currentProvider)
1300
1288
  });
1301
1289
  this.currentChainId = this.walletClient.chain?.id || null;
1302
1290
  try {
@@ -1348,10 +1336,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1348
1336
  }
1349
1337
  this.signer = (0, import_accounts2.privateKeyToAccount)(privateKey);
1350
1338
  this.currentChainId = chainId;
1351
- this.walletClient = (0, import_viem5.createWalletClient)({
1339
+ this.walletClient = (0, import_viem4.createWalletClient)({
1352
1340
  account: this.signer,
1353
1341
  chain: chainConfig.chain,
1354
- transport: (0, import_viem5.http)(chainConfig.rpcUrl)
1342
+ transport: (0, import_viem4.http)(chainConfig.rpcUrl)
1355
1343
  });
1356
1344
  connectedAddress = this.signer.address;
1357
1345
  this.currentProvider = null;
@@ -1369,10 +1357,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1369
1357
  if (!accounts || accounts.length === 0) {
1370
1358
  throw new Error("No accounts found in wallet provider");
1371
1359
  }
1372
- this.walletClient = (0, import_viem5.createWalletClient)({
1360
+ this.walletClient = (0, import_viem4.createWalletClient)({
1373
1361
  account: accounts[0],
1374
1362
  chain: chainConfig.chain,
1375
- transport: (0, import_viem5.custom)(provider)
1363
+ transport: (0, import_viem4.custom)(provider)
1376
1364
  });
1377
1365
  connectedAddress = accounts[0];
1378
1366
  this.currentProvider = provider;
@@ -1381,7 +1369,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1381
1369
  provider.on("accountsChanged", this.handleAccountsChanged.bind(this));
1382
1370
  }
1383
1371
  } else if (provider.account && provider.transport) {
1384
- this.walletClient = (0, import_viem5.createWalletClient)({
1372
+ this.walletClient = (0, import_viem4.createWalletClient)({
1385
1373
  account: provider.account,
1386
1374
  chain: chainConfig.chain,
1387
1375
  transport: provider.transport
@@ -1434,10 +1422,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1434
1422
  targetChainId,
1435
1423
  this.rpcUrls
1436
1424
  );
1437
- return (0, import_viem5.createWalletClient)({
1425
+ return (0, import_viem4.createWalletClient)({
1438
1426
  account: this.signer,
1439
1427
  chain: targetChainConfig.chain,
1440
- transport: (0, import_viem5.http)(targetChainConfig.rpcUrl)
1428
+ transport: (0, import_viem4.http)(targetChainConfig.rpcUrl)
1441
1429
  });
1442
1430
  } else {
1443
1431
  if (!this.walletClient) {
@@ -1800,22 +1788,30 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1800
1788
  * Deposit funds from EOA to Safe smart wallet
1801
1789
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
1802
1790
  *
1803
- * Token is automatically selected based on chain:
1804
- * - Base (8453) and Arbitrum (42161): USDC
1805
- * - Plasma (9745): USDT
1791
+ * Token is automatically selected based on chain (USDC by default):
1792
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
1793
+ *
1794
+ * Minimum portfolio balance enforced (Safe balance + deposit amount),
1795
+ * configured per-chain in `MIN_PORTFOLIO_BALANCE`:
1796
+ * - Ethereum Mainnet (1): 5 USDC (test threshold)
1797
+ * - Base (8453) & Arbitrum (42161): no minimum
1798
+ *
1799
+ * If no minimum is configured for a given (chainId, asset) pair,
1800
+ * the check is skipped.
1806
1801
  *
1807
1802
  * @param userAddress - User's address (owner of the Safe)
1808
1803
  * @param chainId - Target chain ID
1809
1804
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
1805
+ * @param asset - Optional asset symbol ("USDC" or "WETH"). Defaults to "USDC".
1810
1806
  * @returns Deposit response with transaction hash
1811
1807
  *
1812
1808
  * @example
1813
1809
  * ```typescript
1814
- * // Deposit 100 USDC (6 decimals) to Safe on Base
1810
+ * // Deposit 10,000 USDC (6 decimals) to Safe on Base
1815
1811
  * const result = await sdk.depositFunds(
1816
1812
  * "0xUser...",
1817
1813
  * 8453,
1818
- * "100000000" // 100 USDC = 100 * 10^6
1814
+ * "10000000000" // 10,000 USDC = 10_000 * 10^6
1819
1815
  * );
1820
1816
  * ```
1821
1817
  */
@@ -1830,7 +1826,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1830
1826
  if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
1831
1827
  throw new Error("Valid amount is required");
1832
1828
  }
1833
- const token = getDefaultTokenAddress(chainId, asset);
1829
+ const assetSymbol = (asset || "USDC").toUpperCase();
1830
+ const assetConfig = ASSET_CONFIGS[assetSymbol];
1831
+ if (!assetConfig) {
1832
+ throw new Error(
1833
+ `Unsupported asset: ${assetSymbol}. Supported: USDC, WETH.`
1834
+ );
1835
+ }
1836
+ const minRequired = MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
1837
+ const token = getDefaultTokenAddress(chainId, assetSymbol);
1834
1838
  const walletClient = this.getWalletClient();
1835
1839
  const chainConfig = getChainConfig(chainId, this.rpcUrls);
1836
1840
  const safeAddress = await getDeterministicSafeAddress({
@@ -1848,6 +1852,25 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1848
1852
  );
1849
1853
  }
1850
1854
  const amountBigInt = BigInt(amount);
1855
+ if (minRequired !== void 0) {
1856
+ const currentSafeBalance = await chainConfig.publicClient.readContract({
1857
+ address: token,
1858
+ abi: ERC20_ABI,
1859
+ functionName: "balanceOf",
1860
+ args: [safeAddress]
1861
+ });
1862
+ const totalAfterDeposit = currentSafeBalance + amountBigInt;
1863
+ if (totalAfterDeposit < minRequired) {
1864
+ const minLabel = formatMinPortfolioLabel(
1865
+ minRequired,
1866
+ assetConfig.decimals,
1867
+ assetSymbol
1868
+ );
1869
+ throw new Error(
1870
+ `Minimum portfolio balance not met on chain ${chainId}. Total portfolio must be at least ${minLabel}. Current Safe balance: ${currentSafeBalance.toString()}, deposit amount: ${amountBigInt.toString()}, total after deposit: ${totalAfterDeposit.toString()} (raw units, ${assetConfig.decimals} decimals).`
1871
+ );
1872
+ }
1873
+ }
1851
1874
  const txHash = await walletClient.writeContract({
1852
1875
  address: token,
1853
1876
  abi: ERC20_ABI,
@@ -1895,8 +1918,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1895
1918
  * - Need more control over transaction execution
1896
1919
  *
1897
1920
  * Token is automatically selected based on chain if not provided:
1898
- * - Base (8453) and Arbitrum (42161): USDC
1899
- * - Plasma (9745): USDT
1921
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC by default
1900
1922
  *
1901
1923
  * @param chainId - Chain ID where the deposit was made
1902
1924
  * @param txHash - Transaction hash of the deposit
@@ -3149,7 +3171,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3149
3171
  if (!tokenUriResponse.tokenUri) {
3150
3172
  throw new Error("API did not return a tokenUri");
3151
3173
  }
3152
- const callData = (0, import_viem5.encodeFunctionData)({
3174
+ const callData = (0, import_viem4.encodeFunctionData)({
3153
3175
  abi: IDENTITY_REGISTRY_ABI,
3154
3176
  functionName: "register",
3155
3177
  args: [tokenUriResponse.tokenUri]
package/dist/index.mjs CHANGED
@@ -433,6 +433,20 @@ var VAULT_ABI = [
433
433
  ];
434
434
  var VAULT_ADDRESS = "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
435
435
 
436
+ // src/config/constants.ts
437
+ var MIN_PORTFOLIO_BALANCE = {
438
+ 1: {
439
+ USDC: 10000n * 10n ** 6n,
440
+ // 10,000 USDC (6 decimals)
441
+ WETH: 5n * 10n ** 18n
442
+ // 5 WETH (18 decimals)
443
+ }
444
+ };
445
+ var formatMinPortfolioLabel = (raw, decimals, symbol) => {
446
+ const whole = raw / 10n ** BigInt(decimals);
447
+ return `${whole.toString()} ${symbol}`;
448
+ };
449
+
436
450
  // src/core/ZyfaiSDK.ts
437
451
  import { privateKeyToAccount } from "viem/accounts";
438
452
  import {
@@ -445,35 +459,14 @@ import {
445
459
 
446
460
  // src/config/chains.ts
447
461
  import { createPublicClient, http } from "viem";
448
- import { arbitrum, base } from "viem/chains";
449
- import { defineChain } from "viem";
450
- var plasma = defineChain({
451
- id: 9745,
452
- name: "Plasma",
453
- nativeCurrency: {
454
- decimals: 18,
455
- name: "Plasma",
456
- symbol: "PLSM"
457
- },
458
- rpcUrls: {
459
- default: {
460
- http: ["https://rpc.plasma.to"]
461
- }
462
- },
463
- blockExplorers: {
464
- default: {
465
- name: "Plasma Explorer",
466
- url: "https://explorer.plasma.io"
467
- }
468
- }
469
- });
462
+ import { arbitrum, base, mainnet } from "viem/chains";
470
463
  var DEFAULT_TOKEN_ADDRESSES = {
464
+ 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
465
+ // USDC on Ethereum Mainnet
471
466
  8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
472
467
  // USDC on Base
473
- 42161: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
468
+ 42161: "0xaf88d065e77c8cc2239327c5edb3a432268e5831"
474
469
  // USDC on Arbitrum
475
- 9745: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb"
476
- // USDT on Plasma
477
470
  };
478
471
  var ASSET_CONFIGS = {
479
472
  USDC: {
@@ -484,25 +477,23 @@ var ASSET_CONFIGS = {
484
477
  decimals: 6,
485
478
  tokenSymbols: ["USDC", "USDC.e", "USDT", "USDT0"],
486
479
  tokenSymbolsByChainId: {
480
+ 1: "USDC",
487
481
  8453: "USDC",
488
482
  42161: "USDC",
489
- 9745: "USDT0",
490
483
  146: "USDC.e",
491
- 1: "USDC"
484
+ 59144: "USDC"
492
485
  },
493
486
  addresses: {
487
+ 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
488
+ // Ethereum
494
489
  8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
495
490
  // Base
496
491
  42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
497
492
  // Arbitrum
498
- 9745: "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
499
- // Plasma
500
493
  146: "0x29219dd400f2bf60e5a23d13be72b486d4038894",
501
494
  // Sonic
502
- 59144: "0x176211869ca2b568f2a7d4ee941e073a821ee1ff",
495
+ 59144: "0x176211869ca2b568f2a7d4ee941e073a821ee1ff"
503
496
  // Linea
504
- 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
505
- // Ethereum
506
497
  },
507
498
  enabled: true
508
499
  },
@@ -514,26 +505,23 @@ var ASSET_CONFIGS = {
514
505
  decimals: 18,
515
506
  tokenSymbols: ["WETH", "ETH"],
516
507
  tokenSymbolsByChainId: {
508
+ 1: "WETH",
517
509
  8453: "WETH",
518
510
  42161: "WETH",
519
- 9745: "WETH",
520
511
  146: "WETH",
521
- 59144: "WETH",
522
- 1: "WETH"
512
+ 59144: "WETH"
523
513
  },
524
514
  addresses: {
515
+ 1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
516
+ // Ethereum
525
517
  8453: "0x4200000000000000000000000000000000000006",
526
518
  // Base
527
519
  42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
528
520
  // Arbitrum
529
- 9745: "0x4200000000000000000000000000000000000006",
530
- // Plasma
531
521
  146: "0x039e64f90d4199560e7533692f69448878db85c7",
532
522
  // Sonic
533
- 59144: "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
523
+ 59144: "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f"
534
524
  // Linea
535
- 1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
536
- // Ethereum
537
525
  },
538
526
  enabled: true
539
527
  }
@@ -548,14 +536,14 @@ var getDefaultTokenAddress = (chainId, asset) => {
548
536
  return address;
549
537
  };
550
538
  var DEFAULT_RPC_URLS = {
539
+ 1: "https://mainnet.infura.io/v3/8e6cdd06e30d40ac9990bf61bed3a3d0",
551
540
  8453: "https://mainnet.base.org",
552
- 42161: "https://arb1.arbitrum.io/rpc",
553
- 9745: "https://rpc.plasma.to"
541
+ 42161: "https://arb1.arbitrum.io/rpc"
554
542
  };
555
543
  var CHAINS = {
544
+ 1: mainnet,
556
545
  8453: base,
557
- 42161: arbitrum,
558
- 9745: plasma
546
+ 42161: arbitrum
559
547
  };
560
548
  var getChainConfig = (chainId, rpcUrls) => {
561
549
  const chain = CHAINS[chainId];
@@ -1776,22 +1764,30 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1776
1764
  * Deposit funds from EOA to Safe smart wallet
1777
1765
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
1778
1766
  *
1779
- * Token is automatically selected based on chain:
1780
- * - Base (8453) and Arbitrum (42161): USDC
1781
- * - Plasma (9745): USDT
1767
+ * Token is automatically selected based on chain (USDC by default):
1768
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
1769
+ *
1770
+ * Minimum portfolio balance enforced (Safe balance + deposit amount),
1771
+ * configured per-chain in `MIN_PORTFOLIO_BALANCE`:
1772
+ * - Ethereum Mainnet (1): 5 USDC (test threshold)
1773
+ * - Base (8453) & Arbitrum (42161): no minimum
1774
+ *
1775
+ * If no minimum is configured for a given (chainId, asset) pair,
1776
+ * the check is skipped.
1782
1777
  *
1783
1778
  * @param userAddress - User's address (owner of the Safe)
1784
1779
  * @param chainId - Target chain ID
1785
1780
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
1781
+ * @param asset - Optional asset symbol ("USDC" or "WETH"). Defaults to "USDC".
1786
1782
  * @returns Deposit response with transaction hash
1787
1783
  *
1788
1784
  * @example
1789
1785
  * ```typescript
1790
- * // Deposit 100 USDC (6 decimals) to Safe on Base
1786
+ * // Deposit 10,000 USDC (6 decimals) to Safe on Base
1791
1787
  * const result = await sdk.depositFunds(
1792
1788
  * "0xUser...",
1793
1789
  * 8453,
1794
- * "100000000" // 100 USDC = 100 * 10^6
1790
+ * "10000000000" // 10,000 USDC = 10_000 * 10^6
1795
1791
  * );
1796
1792
  * ```
1797
1793
  */
@@ -1806,7 +1802,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1806
1802
  if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
1807
1803
  throw new Error("Valid amount is required");
1808
1804
  }
1809
- const token = getDefaultTokenAddress(chainId, asset);
1805
+ const assetSymbol = (asset || "USDC").toUpperCase();
1806
+ const assetConfig = ASSET_CONFIGS[assetSymbol];
1807
+ if (!assetConfig) {
1808
+ throw new Error(
1809
+ `Unsupported asset: ${assetSymbol}. Supported: USDC, WETH.`
1810
+ );
1811
+ }
1812
+ const minRequired = MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
1813
+ const token = getDefaultTokenAddress(chainId, assetSymbol);
1810
1814
  const walletClient = this.getWalletClient();
1811
1815
  const chainConfig = getChainConfig(chainId, this.rpcUrls);
1812
1816
  const safeAddress = await getDeterministicSafeAddress({
@@ -1824,6 +1828,25 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1824
1828
  );
1825
1829
  }
1826
1830
  const amountBigInt = BigInt(amount);
1831
+ if (minRequired !== void 0) {
1832
+ const currentSafeBalance = await chainConfig.publicClient.readContract({
1833
+ address: token,
1834
+ abi: ERC20_ABI,
1835
+ functionName: "balanceOf",
1836
+ args: [safeAddress]
1837
+ });
1838
+ const totalAfterDeposit = currentSafeBalance + amountBigInt;
1839
+ if (totalAfterDeposit < minRequired) {
1840
+ const minLabel = formatMinPortfolioLabel(
1841
+ minRequired,
1842
+ assetConfig.decimals,
1843
+ assetSymbol
1844
+ );
1845
+ throw new Error(
1846
+ `Minimum portfolio balance not met on chain ${chainId}. Total portfolio must be at least ${minLabel}. Current Safe balance: ${currentSafeBalance.toString()}, deposit amount: ${amountBigInt.toString()}, total after deposit: ${totalAfterDeposit.toString()} (raw units, ${assetConfig.decimals} decimals).`
1847
+ );
1848
+ }
1849
+ }
1827
1850
  const txHash = await walletClient.writeContract({
1828
1851
  address: token,
1829
1852
  abi: ERC20_ABI,
@@ -1871,8 +1894,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1871
1894
  * - Need more control over transaction execution
1872
1895
  *
1873
1896
  * Token is automatically selected based on chain if not provided:
1874
- * - Base (8453) and Arbitrum (42161): USDC
1875
- * - Plasma (9745): USDT
1897
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC by default
1876
1898
  *
1877
1899
  * @param chainId - Chain ID where the deposit was made
1878
1900
  * @param txHash - Transaction hash of the deposit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
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",