@zyfai/sdk 0.2.31 → 0.2.33

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
@@ -688,8 +688,8 @@ Earnings are returned per-token (multi-asset support).
688
688
  const earnings = await sdk.getOnchainEarnings(walletAddress);
689
689
  // Per-token earnings: { "USDC": "0.020667", "WETH": "0.000009" }
690
690
  console.log("Total by token:", earnings.data.totalEarningsByToken);
691
- console.log("Lifetime by token:", earnings.data.lifetimeEarningsByToken);
692
- console.log("By chain:", earnings.data.currentEarningsByChain);
691
+ // Per-chain totals (chain token → amount): { "8453": { "USDC": "0.01" }, "42161": {...} }
692
+ console.log("Total by chain:", earnings.data.totalEarningsByChain);
693
693
  ```
694
694
 
695
695
  #### Calculate Onchain Earnings (Refresh)
package/dist/index.d.mts CHANGED
@@ -269,9 +269,11 @@ interface HistoryResponse {
269
269
  total: number;
270
270
  }
271
271
  type TokenEarnings = Record<string, string>;
272
+ type ChainTokenEarnings = Record<string, TokenEarnings>;
272
273
  interface OnchainEarnings {
273
274
  walletAddress: string;
274
275
  totalEarningsByToken: TokenEarnings;
276
+ totalEarningsByChain?: ChainTokenEarnings;
275
277
  lastCheckTimestamp?: string;
276
278
  lastLogDate?: Record<string, string | null>;
277
279
  }
@@ -401,8 +403,9 @@ interface SdkKeyTVLResponse {
401
403
  success: boolean;
402
404
  allowedWallets: Address[];
403
405
  totalTvl: number;
406
+ totalVolume: number;
404
407
  tvlByWallet: WalletTVL[];
405
- metadata?: {
408
+ metadata: {
406
409
  sdkKeyId: string;
407
410
  clientName: string;
408
411
  walletsCount: number;
@@ -1086,6 +1089,7 @@ declare class ZyfaiSDK {
1086
1089
  * ```typescript
1087
1090
  * const earnings = await sdk.getOnchainEarnings("0x...");
1088
1091
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
1092
+ * console.log("Total on Arbitrum:", earnings.data.totalEarningsByChain?.["42161"]);
1089
1093
  * ```
1090
1094
  */
1091
1095
  getOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
@@ -1100,6 +1104,7 @@ declare class ZyfaiSDK {
1100
1104
  * ```typescript
1101
1105
  * const earnings = await sdk.calculateOnchainEarnings("0x...");
1102
1106
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
1107
+ * console.log("Per-chain total:", earnings.data.totalEarningsByChain);
1103
1108
  * ```
1104
1109
  */
1105
1110
  calculateOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
@@ -1506,4 +1511,4 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
1506
1511
 
1507
1512
  declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
1508
1513
 
1509
- 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 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 };
1514
+ 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 };
package/dist/index.d.ts CHANGED
@@ -269,9 +269,11 @@ interface HistoryResponse {
269
269
  total: number;
270
270
  }
271
271
  type TokenEarnings = Record<string, string>;
272
+ type ChainTokenEarnings = Record<string, TokenEarnings>;
272
273
  interface OnchainEarnings {
273
274
  walletAddress: string;
274
275
  totalEarningsByToken: TokenEarnings;
276
+ totalEarningsByChain?: ChainTokenEarnings;
275
277
  lastCheckTimestamp?: string;
276
278
  lastLogDate?: Record<string, string | null>;
277
279
  }
@@ -401,8 +403,9 @@ interface SdkKeyTVLResponse {
401
403
  success: boolean;
402
404
  allowedWallets: Address[];
403
405
  totalTvl: number;
406
+ totalVolume: number;
404
407
  tvlByWallet: WalletTVL[];
405
- metadata?: {
408
+ metadata: {
406
409
  sdkKeyId: string;
407
410
  clientName: string;
408
411
  walletsCount: number;
@@ -1086,6 +1089,7 @@ declare class ZyfaiSDK {
1086
1089
  * ```typescript
1087
1090
  * const earnings = await sdk.getOnchainEarnings("0x...");
1088
1091
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
1092
+ * console.log("Total on Arbitrum:", earnings.data.totalEarningsByChain?.["42161"]);
1089
1093
  * ```
1090
1094
  */
1091
1095
  getOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
@@ -1100,6 +1104,7 @@ declare class ZyfaiSDK {
1100
1104
  * ```typescript
1101
1105
  * const earnings = await sdk.calculateOnchainEarnings("0x...");
1102
1106
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
1107
+ * console.log("Per-chain total:", earnings.data.totalEarningsByChain);
1103
1108
  * ```
1104
1109
  */
1105
1110
  calculateOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
@@ -1506,4 +1511,4 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
1506
1511
 
1507
1512
  declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
1508
1513
 
1509
- 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 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 };
1514
+ 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 };
package/dist/index.js CHANGED
@@ -1531,17 +1531,6 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1531
1531
  safeAddress,
1532
1532
  chainConfig.publicClient
1533
1533
  );
1534
- if (!alreadyDeployed) {
1535
- const accountType = await getAccountType(
1536
- userAddress,
1537
- chainConfig.publicClient
1538
- );
1539
- if (accountType !== "EOA") {
1540
- throw new Error(
1541
- `Address ${userAddress} is not an EOA. Only EOA addresses can deploy Safe smart wallets.`
1542
- );
1543
- }
1544
- }
1545
1534
  if (alreadyDeployed) {
1546
1535
  let sessionKeyCreated2 = false;
1547
1536
  if (createSessionKey) {
@@ -2473,6 +2462,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2473
2462
  * ```typescript
2474
2463
  * const earnings = await sdk.getOnchainEarnings("0x...");
2475
2464
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
2465
+ * console.log("Total on Arbitrum:", earnings.data.totalEarningsByChain?.["42161"]);
2476
2466
  * ```
2477
2467
  */
2478
2468
  async getOnchainEarnings(walletAddress) {
@@ -2488,6 +2478,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2488
2478
  data: {
2489
2479
  walletAddress,
2490
2480
  totalEarningsByToken: response.total_earnings_by_token || {},
2481
+ totalEarningsByChain: response.total_earnings_by_chain || {},
2491
2482
  lastCheckTimestamp: response.last_check_timestamp,
2492
2483
  lastLogDate: response.last_log_date
2493
2484
  }
@@ -2509,6 +2500,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2509
2500
  * ```typescript
2510
2501
  * const earnings = await sdk.calculateOnchainEarnings("0x...");
2511
2502
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
2503
+ * console.log("Per-chain total:", earnings.data.totalEarningsByChain);
2512
2504
  * ```
2513
2505
  */
2514
2506
  async calculateOnchainEarnings(walletAddress) {
@@ -2526,6 +2518,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2526
2518
  data: {
2527
2519
  walletAddress,
2528
2520
  totalEarningsByToken: data.total_earnings_by_token || {},
2521
+ totalEarningsByChain: data.total_earnings_by_chain || {},
2529
2522
  lastCheckTimestamp: data.last_check_timestamp,
2530
2523
  lastLogDate: data.last_log_date
2531
2524
  }
@@ -2959,6 +2952,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2959
2952
  success: response.success || true,
2960
2953
  allowedWallets: response.allowedWallets || [],
2961
2954
  totalTvl: response.totalTvl || 0,
2955
+ totalVolume: response.totalVolume || 0,
2962
2956
  tvlByWallet: response.tvlByWallet || [],
2963
2957
  metadata: response.metadata || {
2964
2958
  sdkKeyId: "",
package/dist/index.mjs CHANGED
@@ -1507,17 +1507,6 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1507
1507
  safeAddress,
1508
1508
  chainConfig.publicClient
1509
1509
  );
1510
- if (!alreadyDeployed) {
1511
- const accountType = await getAccountType(
1512
- userAddress,
1513
- chainConfig.publicClient
1514
- );
1515
- if (accountType !== "EOA") {
1516
- throw new Error(
1517
- `Address ${userAddress} is not an EOA. Only EOA addresses can deploy Safe smart wallets.`
1518
- );
1519
- }
1520
- }
1521
1510
  if (alreadyDeployed) {
1522
1511
  let sessionKeyCreated2 = false;
1523
1512
  if (createSessionKey) {
@@ -2449,6 +2438,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2449
2438
  * ```typescript
2450
2439
  * const earnings = await sdk.getOnchainEarnings("0x...");
2451
2440
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
2441
+ * console.log("Total on Arbitrum:", earnings.data.totalEarningsByChain?.["42161"]);
2452
2442
  * ```
2453
2443
  */
2454
2444
  async getOnchainEarnings(walletAddress) {
@@ -2464,6 +2454,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2464
2454
  data: {
2465
2455
  walletAddress,
2466
2456
  totalEarningsByToken: response.total_earnings_by_token || {},
2457
+ totalEarningsByChain: response.total_earnings_by_chain || {},
2467
2458
  lastCheckTimestamp: response.last_check_timestamp,
2468
2459
  lastLogDate: response.last_log_date
2469
2460
  }
@@ -2485,6 +2476,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2485
2476
  * ```typescript
2486
2477
  * const earnings = await sdk.calculateOnchainEarnings("0x...");
2487
2478
  * console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
2479
+ * console.log("Per-chain total:", earnings.data.totalEarningsByChain);
2488
2480
  * ```
2489
2481
  */
2490
2482
  async calculateOnchainEarnings(walletAddress) {
@@ -2502,6 +2494,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2502
2494
  data: {
2503
2495
  walletAddress,
2504
2496
  totalEarningsByToken: data.total_earnings_by_token || {},
2497
+ totalEarningsByChain: data.total_earnings_by_chain || {},
2505
2498
  lastCheckTimestamp: data.last_check_timestamp,
2506
2499
  lastLogDate: data.last_log_date
2507
2500
  }
@@ -2935,6 +2928,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2935
2928
  success: response.success || true,
2936
2929
  allowedWallets: response.allowedWallets || [],
2937
2930
  totalTvl: response.totalTvl || 0,
2931
+ totalVolume: response.totalVolume || 0,
2938
2932
  tvlByWallet: response.tvlByWallet || [],
2939
2933
  metadata: response.metadata || {
2940
2934
  sdkKeyId: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.31",
3
+ "version": "0.2.33",
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",