@zyfai/sdk 0.2.37 → 0.2.39

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;
@@ -422,6 +422,46 @@ interface SdkKeyTVLResponse {
422
422
  walletsCount: number;
423
423
  };
424
424
  }
425
+ interface UserPosition {
426
+ protocol: string;
427
+ pool: string;
428
+ tvl: number;
429
+ }
430
+ interface SimulateBestPositionsParams {
431
+ amount: number;
432
+ token: string;
433
+ networks: number | number[];
434
+ strategy: "conservative" | "aggressive";
435
+ minSplit?: number;
436
+ protocols?: string[];
437
+ pools?: string[];
438
+ userPositions?: UserPosition[];
439
+ }
440
+ interface SimulateCalldataItem {
441
+ contract_address: Address;
442
+ function_name: string;
443
+ parameters: string[];
444
+ value: string;
445
+ description: string;
446
+ }
447
+ interface SimulatedPosition {
448
+ protocol: string;
449
+ pool: string;
450
+ simulated_apy: number;
451
+ combined_apy: number;
452
+ amount: number;
453
+ amount_raw: string;
454
+ url: string;
455
+ tvl: number;
456
+ liquidity: number;
457
+ averageCombinedApy30Days: number;
458
+ calldata: SimulateCalldataItem[];
459
+ }
460
+ interface SimulateBestPositionsResponse {
461
+ success: boolean;
462
+ data: Record<string, SimulatedPosition[]>;
463
+ messages: Record<string, string>;
464
+ }
425
465
  interface OpportunityPosition {
426
466
  protocol: string;
427
467
  pool: string;
@@ -551,8 +591,57 @@ interface VaultSharesResponse {
551
591
  shares: bigint;
552
592
  symbol: string;
553
593
  }
594
+ interface DepegEvent {
595
+ token: string;
596
+ price: number;
597
+ deviation: number;
598
+ severity: "warning" | "critical";
599
+ previousSeverity?: string;
600
+ affectedPools: {
601
+ protocol: string;
602
+ pool: string;
603
+ chain: string;
604
+ }[];
605
+ timestamp: string;
606
+ }
607
+ interface NewCollateralDetectedEvent {
608
+ protocol: string;
609
+ pool: string;
610
+ chain: string;
611
+ asset: string;
612
+ exposureUsd: number;
613
+ percentOfTvl: number;
614
+ timestamp: string;
615
+ }
616
+ interface LiquidityDropEvent {
617
+ protocol: string;
618
+ pool: string;
619
+ chain: string;
620
+ asset: string;
621
+ previousLiquidityUsd: number;
622
+ currentLiquidityUsd: number;
623
+ dropPercent: number;
624
+ windowMinutes: number;
625
+ timestamp: string;
626
+ }
627
+ interface ZyfaiEventFilters {
628
+ chains?: string[];
629
+ protocols?: string[];
630
+ pools?: string[];
631
+ }
632
+ interface ZyfaiEventHandlers {
633
+ onDepeg?: (data: DepegEvent) => void;
634
+ onNewCollateralDetected?: (data: NewCollateralDetectedEvent) => void;
635
+ onLiquidityDrop?: (data: LiquidityDropEvent) => void;
636
+ onError?: (error: unknown) => void;
637
+ }
638
+
639
+ /**
640
+ * Chain Configuration for Zyfai SDK
641
+ * Supports Ethereum Mainnet, Arbitrum, and Base networks
642
+ */
554
643
 
555
- type SupportedChainId = 8453 | 42161 | 9745;
644
+ type SupportedChainId = 1 | 8453 | 42161;
556
645
  interface ChainConfig {
557
646
  chain: Chain;
558
647
  rpcUrl: string;
@@ -839,22 +928,30 @@ declare class ZyfaiSDK {
839
928
  * Deposit funds from EOA to Safe smart wallet
840
929
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
841
930
  *
842
- * Token is automatically selected based on chain:
843
- * - Base (8453) and Arbitrum (42161): USDC
844
- * - Plasma (9745): USDT
931
+ * Token is automatically selected based on chain (USDC by default):
932
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
933
+ *
934
+ * Minimum portfolio balance enforced (Safe balance + deposit amount),
935
+ * configured per-chain in `MIN_PORTFOLIO_BALANCE`:
936
+ * - Ethereum Mainnet (1): 5 USDC (test threshold)
937
+ * - Base (8453) & Arbitrum (42161): no minimum
938
+ *
939
+ * If no minimum is configured for a given (chainId, asset) pair,
940
+ * the check is skipped.
845
941
  *
846
942
  * @param userAddress - User's address (owner of the Safe)
847
943
  * @param chainId - Target chain ID
848
944
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
945
+ * @param asset - Optional asset symbol ("USDC" or "WETH"). Defaults to "USDC".
849
946
  * @returns Deposit response with transaction hash
850
947
  *
851
948
  * @example
852
949
  * ```typescript
853
- * // Deposit 100 USDC (6 decimals) to Safe on Base
950
+ * // Deposit 10,000 USDC (6 decimals) to Safe on Base
854
951
  * const result = await sdk.depositFunds(
855
952
  * "0xUser...",
856
953
  * 8453,
857
- * "100000000" // 100 USDC = 100 * 10^6
954
+ * "10000000000" // 10,000 USDC = 10_000 * 10^6
858
955
  * );
859
956
  * ```
860
957
  */
@@ -872,8 +969,7 @@ declare class ZyfaiSDK {
872
969
  * - Need more control over transaction execution
873
970
  *
874
971
  * Token is automatically selected based on chain if not provided:
875
- * - Base (8453) and Arbitrum (42161): USDC
876
- * - Plasma (9745): USDT
972
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC by default
877
973
  *
878
974
  * @param chainId - Chain ID where the deposit was made
879
975
  * @param txHash - Transaction hash of the deposit
@@ -1342,6 +1438,31 @@ declare class ZyfaiSDK {
1342
1438
  * ```
1343
1439
  */
1344
1440
  getAvailablePools(protocolId: string, strategy?: "conservative" | "aggressive"): Promise<GetPoolsResponse>;
1441
+ /**
1442
+ * Simulate the best yield positions for a given amount, splitting it across
1443
+ * the top-ranked pools (up to minSplit positions) for the requested chains/strategy.
1444
+ *
1445
+ * Returns ready-to-execute calldata (approve + deposit) per position. The deposit
1446
+ * calldata contains a "<RECEIVER>" placeholder that must be replaced with the
1447
+ * actual receiving address (e.g. the user's Safe) before sending the transaction.
1448
+ *
1449
+ * @param params - Simulation parameters
1450
+ * @returns Chain-keyed map of simulated positions with calldata
1451
+ *
1452
+ * @example
1453
+ * ```typescript
1454
+ * const result = await sdk.simulateBestPositions({
1455
+ * amount: 3000,
1456
+ * token: "USDC",
1457
+ * networks: 8453,
1458
+ * strategy: "conservative",
1459
+ * minSplit: 3,
1460
+ * protocols: ["aave", "compound", "morpho"],
1461
+ * });
1462
+ * console.log(result.data["8453"]);
1463
+ * ```
1464
+ */
1465
+ simulateBestPositions(params: SimulateBestPositionsParams): Promise<SimulateBestPositionsResponse>;
1345
1466
  /**
1346
1467
  * Get currently selected pools for a protocol on a specific chain.
1347
1468
  *
@@ -1466,6 +1587,31 @@ declare class ZyfaiSDK {
1466
1587
  * ```
1467
1588
  */
1468
1589
  getVaultShares(userAddress?: string, chainId?: SupportedChainId): Promise<VaultSharesResponse>;
1590
+ /**
1591
+ * Subscribe to real-time Zyfai risk and liquidity events via WebSocket.
1592
+ *
1593
+ * Events: depeg, liquidity_trap, liquidity_restored, pool_status_change,
1594
+ * new_collateral_detected, liquidity_drop.
1595
+ *
1596
+ * @param handlers - Callback per event type, plus onError
1597
+ * @param filters - Optional protocol/pool filter sent to the server on subscribe
1598
+ * @returns Cleanup function — call it to close the connection
1599
+ *
1600
+ * @example
1601
+ * ```typescript
1602
+ * const unsubscribe = sdk.subscribeToEvents(
1603
+ * {
1604
+ * onDepeg: (data) => console.log("Depeg detected:", data.token, data.severity),
1605
+ * onLiquidityDrop: (data) => console.log("Liquidity drop:", data.pool, data.dropPercent),
1606
+ * },
1607
+ * { protocols: ["morpho"], pools: ["gauntlet usdc core"] }
1608
+ * );
1609
+ *
1610
+ * // Later, close the connection:
1611
+ * unsubscribe();
1612
+ * ```
1613
+ */
1614
+ subscribeToEvents(handlers: ZyfaiEventHandlers, filters?: ZyfaiEventFilters): () => void;
1469
1615
  }
1470
1616
 
1471
1617
  /**
@@ -1529,4 +1675,4 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
1529
1675
 
1530
1676
  declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
1531
1677
 
1532
- 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 };
1678
+ 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 DepegEvent, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, 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 SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, 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;
@@ -422,6 +422,46 @@ interface SdkKeyTVLResponse {
422
422
  walletsCount: number;
423
423
  };
424
424
  }
425
+ interface UserPosition {
426
+ protocol: string;
427
+ pool: string;
428
+ tvl: number;
429
+ }
430
+ interface SimulateBestPositionsParams {
431
+ amount: number;
432
+ token: string;
433
+ networks: number | number[];
434
+ strategy: "conservative" | "aggressive";
435
+ minSplit?: number;
436
+ protocols?: string[];
437
+ pools?: string[];
438
+ userPositions?: UserPosition[];
439
+ }
440
+ interface SimulateCalldataItem {
441
+ contract_address: Address;
442
+ function_name: string;
443
+ parameters: string[];
444
+ value: string;
445
+ description: string;
446
+ }
447
+ interface SimulatedPosition {
448
+ protocol: string;
449
+ pool: string;
450
+ simulated_apy: number;
451
+ combined_apy: number;
452
+ amount: number;
453
+ amount_raw: string;
454
+ url: string;
455
+ tvl: number;
456
+ liquidity: number;
457
+ averageCombinedApy30Days: number;
458
+ calldata: SimulateCalldataItem[];
459
+ }
460
+ interface SimulateBestPositionsResponse {
461
+ success: boolean;
462
+ data: Record<string, SimulatedPosition[]>;
463
+ messages: Record<string, string>;
464
+ }
425
465
  interface OpportunityPosition {
426
466
  protocol: string;
427
467
  pool: string;
@@ -551,8 +591,57 @@ interface VaultSharesResponse {
551
591
  shares: bigint;
552
592
  symbol: string;
553
593
  }
594
+ interface DepegEvent {
595
+ token: string;
596
+ price: number;
597
+ deviation: number;
598
+ severity: "warning" | "critical";
599
+ previousSeverity?: string;
600
+ affectedPools: {
601
+ protocol: string;
602
+ pool: string;
603
+ chain: string;
604
+ }[];
605
+ timestamp: string;
606
+ }
607
+ interface NewCollateralDetectedEvent {
608
+ protocol: string;
609
+ pool: string;
610
+ chain: string;
611
+ asset: string;
612
+ exposureUsd: number;
613
+ percentOfTvl: number;
614
+ timestamp: string;
615
+ }
616
+ interface LiquidityDropEvent {
617
+ protocol: string;
618
+ pool: string;
619
+ chain: string;
620
+ asset: string;
621
+ previousLiquidityUsd: number;
622
+ currentLiquidityUsd: number;
623
+ dropPercent: number;
624
+ windowMinutes: number;
625
+ timestamp: string;
626
+ }
627
+ interface ZyfaiEventFilters {
628
+ chains?: string[];
629
+ protocols?: string[];
630
+ pools?: string[];
631
+ }
632
+ interface ZyfaiEventHandlers {
633
+ onDepeg?: (data: DepegEvent) => void;
634
+ onNewCollateralDetected?: (data: NewCollateralDetectedEvent) => void;
635
+ onLiquidityDrop?: (data: LiquidityDropEvent) => void;
636
+ onError?: (error: unknown) => void;
637
+ }
638
+
639
+ /**
640
+ * Chain Configuration for Zyfai SDK
641
+ * Supports Ethereum Mainnet, Arbitrum, and Base networks
642
+ */
554
643
 
555
- type SupportedChainId = 8453 | 42161 | 9745;
644
+ type SupportedChainId = 1 | 8453 | 42161;
556
645
  interface ChainConfig {
557
646
  chain: Chain;
558
647
  rpcUrl: string;
@@ -839,22 +928,30 @@ declare class ZyfaiSDK {
839
928
  * Deposit funds from EOA to Safe smart wallet
840
929
  * Transfers tokens from the connected wallet to the user's Safe and logs the deposit
841
930
  *
842
- * Token is automatically selected based on chain:
843
- * - Base (8453) and Arbitrum (42161): USDC
844
- * - Plasma (9745): USDT
931
+ * Token is automatically selected based on chain (USDC by default):
932
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
933
+ *
934
+ * Minimum portfolio balance enforced (Safe balance + deposit amount),
935
+ * configured per-chain in `MIN_PORTFOLIO_BALANCE`:
936
+ * - Ethereum Mainnet (1): 5 USDC (test threshold)
937
+ * - Base (8453) & Arbitrum (42161): no minimum
938
+ *
939
+ * If no minimum is configured for a given (chainId, asset) pair,
940
+ * the check is skipped.
845
941
  *
846
942
  * @param userAddress - User's address (owner of the Safe)
847
943
  * @param chainId - Target chain ID
848
944
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
945
+ * @param asset - Optional asset symbol ("USDC" or "WETH"). Defaults to "USDC".
849
946
  * @returns Deposit response with transaction hash
850
947
  *
851
948
  * @example
852
949
  * ```typescript
853
- * // Deposit 100 USDC (6 decimals) to Safe on Base
950
+ * // Deposit 10,000 USDC (6 decimals) to Safe on Base
854
951
  * const result = await sdk.depositFunds(
855
952
  * "0xUser...",
856
953
  * 8453,
857
- * "100000000" // 100 USDC = 100 * 10^6
954
+ * "10000000000" // 10,000 USDC = 10_000 * 10^6
858
955
  * );
859
956
  * ```
860
957
  */
@@ -872,8 +969,7 @@ declare class ZyfaiSDK {
872
969
  * - Need more control over transaction execution
873
970
  *
874
971
  * Token is automatically selected based on chain if not provided:
875
- * - Base (8453) and Arbitrum (42161): USDC
876
- * - Plasma (9745): USDT
972
+ * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC by default
877
973
  *
878
974
  * @param chainId - Chain ID where the deposit was made
879
975
  * @param txHash - Transaction hash of the deposit
@@ -1342,6 +1438,31 @@ declare class ZyfaiSDK {
1342
1438
  * ```
1343
1439
  */
1344
1440
  getAvailablePools(protocolId: string, strategy?: "conservative" | "aggressive"): Promise<GetPoolsResponse>;
1441
+ /**
1442
+ * Simulate the best yield positions for a given amount, splitting it across
1443
+ * the top-ranked pools (up to minSplit positions) for the requested chains/strategy.
1444
+ *
1445
+ * Returns ready-to-execute calldata (approve + deposit) per position. The deposit
1446
+ * calldata contains a "<RECEIVER>" placeholder that must be replaced with the
1447
+ * actual receiving address (e.g. the user's Safe) before sending the transaction.
1448
+ *
1449
+ * @param params - Simulation parameters
1450
+ * @returns Chain-keyed map of simulated positions with calldata
1451
+ *
1452
+ * @example
1453
+ * ```typescript
1454
+ * const result = await sdk.simulateBestPositions({
1455
+ * amount: 3000,
1456
+ * token: "USDC",
1457
+ * networks: 8453,
1458
+ * strategy: "conservative",
1459
+ * minSplit: 3,
1460
+ * protocols: ["aave", "compound", "morpho"],
1461
+ * });
1462
+ * console.log(result.data["8453"]);
1463
+ * ```
1464
+ */
1465
+ simulateBestPositions(params: SimulateBestPositionsParams): Promise<SimulateBestPositionsResponse>;
1345
1466
  /**
1346
1467
  * Get currently selected pools for a protocol on a specific chain.
1347
1468
  *
@@ -1466,6 +1587,31 @@ declare class ZyfaiSDK {
1466
1587
  * ```
1467
1588
  */
1468
1589
  getVaultShares(userAddress?: string, chainId?: SupportedChainId): Promise<VaultSharesResponse>;
1590
+ /**
1591
+ * Subscribe to real-time Zyfai risk and liquidity events via WebSocket.
1592
+ *
1593
+ * Events: depeg, liquidity_trap, liquidity_restored, pool_status_change,
1594
+ * new_collateral_detected, liquidity_drop.
1595
+ *
1596
+ * @param handlers - Callback per event type, plus onError
1597
+ * @param filters - Optional protocol/pool filter sent to the server on subscribe
1598
+ * @returns Cleanup function — call it to close the connection
1599
+ *
1600
+ * @example
1601
+ * ```typescript
1602
+ * const unsubscribe = sdk.subscribeToEvents(
1603
+ * {
1604
+ * onDepeg: (data) => console.log("Depeg detected:", data.token, data.severity),
1605
+ * onLiquidityDrop: (data) => console.log("Liquidity drop:", data.pool, data.dropPercent),
1606
+ * },
1607
+ * { protocols: ["morpho"], pools: ["gauntlet usdc core"] }
1608
+ * );
1609
+ *
1610
+ * // Later, close the connection:
1611
+ * unsubscribe();
1612
+ * ```
1613
+ */
1614
+ subscribeToEvents(handlers: ZyfaiEventHandlers, filters?: ZyfaiEventFilters): () => void;
1469
1615
  }
1470
1616
 
1471
1617
  /**
@@ -1529,4 +1675,4 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
1529
1675
 
1530
1676
  declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
1531
1677
 
1532
- 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 };
1678
+ 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 DepegEvent, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, 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 SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };