@zyfai/sdk 0.2.4 → 0.2.5

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/dist/index.d.mts CHANGED
@@ -356,6 +356,26 @@ interface AddWalletToSdkResponse {
356
356
  success: boolean;
357
357
  message: string;
358
358
  }
359
+ interface WalletTVL {
360
+ walletAddress: Address;
361
+ tvl: number;
362
+ positions?: {
363
+ chainId: number;
364
+ protocol: string;
365
+ amount: number;
366
+ }[];
367
+ }
368
+ interface SdkKeyTVLResponse {
369
+ success: boolean;
370
+ allowedWallets: Address[];
371
+ totalTvl: number;
372
+ tvlByWallet: WalletTVL[];
373
+ metadata?: {
374
+ sdkKeyId: string;
375
+ clientName: string;
376
+ walletsCount: number;
377
+ };
378
+ }
359
379
  interface PolicyData {
360
380
  policy: Address;
361
381
  initData: Hex;
@@ -872,6 +892,43 @@ declare class ZyfaiSDK {
872
892
  * ```
873
893
  */
874
894
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
895
+ /**
896
+ * Get allowed wallets for the current SDK API key
897
+ * Returns the list of smart wallet addresses created via this SDK key
898
+ *
899
+ * @returns List of allowed wallet addresses with metadata
900
+ *
901
+ * @example
902
+ * ```typescript
903
+ * const result = await sdk.getSdkAllowedWallets();
904
+ * console.log("Allowed wallets:", result.allowedWallets);
905
+ * console.log("Total count:", result.metadata.walletsCount);
906
+ * ```
907
+ */
908
+ getSdkAllowedWallets(): Promise<{
909
+ success: boolean;
910
+ allowedWallets: Address[];
911
+ metadata: {
912
+ sdkKeyId: string;
913
+ clientName: string;
914
+ walletsCount: number;
915
+ };
916
+ }>;
917
+ /**
918
+ * Get total TVL for all wallets under the current SDK API key
919
+ * This method calculates the total value locked across all wallets created via this SDK key
920
+ *
921
+ * @returns SDK key TVL information including allowed wallets and their individual/total TVL
922
+ *
923
+ * @example
924
+ * ```typescript
925
+ * const sdkTvl = await sdk.getSdkKeyTVL();
926
+ * console.log("Total TVL across all SDK wallets:", sdkTvl.totalTvl);
927
+ * console.log("Number of wallets:", sdkTvl.allowedWallets.length);
928
+ * console.log("TVL by wallet:", sdkTvl.tvlByWallet);
929
+ * ```
930
+ */
931
+ getSdkKeyTVL(): Promise<SdkKeyTVLResponse>;
875
932
  }
876
933
 
877
- export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
934
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.d.ts CHANGED
@@ -356,6 +356,26 @@ interface AddWalletToSdkResponse {
356
356
  success: boolean;
357
357
  message: string;
358
358
  }
359
+ interface WalletTVL {
360
+ walletAddress: Address;
361
+ tvl: number;
362
+ positions?: {
363
+ chainId: number;
364
+ protocol: string;
365
+ amount: number;
366
+ }[];
367
+ }
368
+ interface SdkKeyTVLResponse {
369
+ success: boolean;
370
+ allowedWallets: Address[];
371
+ totalTvl: number;
372
+ tvlByWallet: WalletTVL[];
373
+ metadata?: {
374
+ sdkKeyId: string;
375
+ clientName: string;
376
+ walletsCount: number;
377
+ };
378
+ }
359
379
  interface PolicyData {
360
380
  policy: Address;
361
381
  initData: Hex;
@@ -872,6 +892,43 @@ declare class ZyfaiSDK {
872
892
  * ```
873
893
  */
874
894
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
895
+ /**
896
+ * Get allowed wallets for the current SDK API key
897
+ * Returns the list of smart wallet addresses created via this SDK key
898
+ *
899
+ * @returns List of allowed wallet addresses with metadata
900
+ *
901
+ * @example
902
+ * ```typescript
903
+ * const result = await sdk.getSdkAllowedWallets();
904
+ * console.log("Allowed wallets:", result.allowedWallets);
905
+ * console.log("Total count:", result.metadata.walletsCount);
906
+ * ```
907
+ */
908
+ getSdkAllowedWallets(): Promise<{
909
+ success: boolean;
910
+ allowedWallets: Address[];
911
+ metadata: {
912
+ sdkKeyId: string;
913
+ clientName: string;
914
+ walletsCount: number;
915
+ };
916
+ }>;
917
+ /**
918
+ * Get total TVL for all wallets under the current SDK API key
919
+ * This method calculates the total value locked across all wallets created via this SDK key
920
+ *
921
+ * @returns SDK key TVL information including allowed wallets and their individual/total TVL
922
+ *
923
+ * @example
924
+ * ```typescript
925
+ * const sdkTvl = await sdk.getSdkKeyTVL();
926
+ * console.log("Total TVL across all SDK wallets:", sdkTvl.totalTvl);
927
+ * console.log("Number of wallets:", sdkTvl.allowedWallets.length);
928
+ * console.log("TVL by wallet:", sdkTvl.tvlByWallet);
929
+ * ```
930
+ */
931
+ getSdkKeyTVL(): Promise<SdkKeyTVLResponse>;
875
932
  }
876
933
 
877
- export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
934
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ var ENDPOINTS = {
55
55
  USER_ME: "/users/me",
56
56
  USER_WITHDRAW: "/users/withdraw",
57
57
  PARTIAL_WITHDRAW: "/users/partial-withdraw",
58
+ LOG_DEPOSIT: "/users/log_deposit",
58
59
  // Safe Deployment (single endpoint)
59
60
  SAFE_DEPLOY: "/users/safe-deploy",
60
61
  // Session Keys
@@ -70,7 +71,10 @@ var ENDPOINTS = {
70
71
  DATA_FIRST_TOPUP: (walletAddress, chainId) => `/data/first-topup?walletAddress=${walletAddress}&chainId=${chainId}`,
71
72
  DATA_ACTIVE_WALLETS: (chainId) => `/data/active-wallets?chainId=${chainId}`,
72
73
  DATA_BY_EOA: (address) => `/data/by-eoa?address=${address}`,
73
- DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`
74
+ DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`,
75
+ // SDK Keys
76
+ SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
77
+ SDK_TVL: "/data/sdk-tvl"
74
78
  };
75
79
  var DATA_ENDPOINTS = {
76
80
  // User Initialization
@@ -1384,6 +1388,16 @@ var ZyfaiSDK = class {
1384
1388
  const receipt = await chainConfig.publicClient.waitForTransactionReceipt({
1385
1389
  hash: txHash
1386
1390
  });
1391
+ try {
1392
+ await this.httpClient.post(ENDPOINTS.LOG_DEPOSIT, {
1393
+ chainId,
1394
+ transaction: txHash,
1395
+ token,
1396
+ amount
1397
+ });
1398
+ } catch (logError) {
1399
+ console.warn("Failed to log deposit:", logError.message);
1400
+ }
1387
1401
  if (receipt.status !== "success") {
1388
1402
  throw new Error("Deposit transaction failed");
1389
1403
  }
@@ -2178,6 +2192,76 @@ var ZyfaiSDK = class {
2178
2192
  );
2179
2193
  }
2180
2194
  }
2195
+ // ============================================================================
2196
+ // SDK Key Methods
2197
+ // ============================================================================
2198
+ /**
2199
+ * Get allowed wallets for the current SDK API key
2200
+ * Returns the list of smart wallet addresses created via this SDK key
2201
+ *
2202
+ * @returns List of allowed wallet addresses with metadata
2203
+ *
2204
+ * @example
2205
+ * ```typescript
2206
+ * const result = await sdk.getSdkAllowedWallets();
2207
+ * console.log("Allowed wallets:", result.allowedWallets);
2208
+ * console.log("Total count:", result.metadata.walletsCount);
2209
+ * ```
2210
+ */
2211
+ async getSdkAllowedWallets() {
2212
+ try {
2213
+ const response = await this.httpClient.get(
2214
+ ENDPOINTS.SDK_ALLOWED_WALLETS
2215
+ );
2216
+ return {
2217
+ success: response.success || true,
2218
+ allowedWallets: response.allowedWallets || [],
2219
+ metadata: response.metadata || {
2220
+ sdkKeyId: "",
2221
+ clientName: "",
2222
+ walletsCount: 0
2223
+ }
2224
+ };
2225
+ } catch (error) {
2226
+ throw new Error(
2227
+ `Failed to get SDK allowed wallets: ${error.message}`
2228
+ );
2229
+ }
2230
+ }
2231
+ /**
2232
+ * Get total TVL for all wallets under the current SDK API key
2233
+ * This method calculates the total value locked across all wallets created via this SDK key
2234
+ *
2235
+ * @returns SDK key TVL information including allowed wallets and their individual/total TVL
2236
+ *
2237
+ * @example
2238
+ * ```typescript
2239
+ * const sdkTvl = await sdk.getSdkKeyTVL();
2240
+ * console.log("Total TVL across all SDK wallets:", sdkTvl.totalTvl);
2241
+ * console.log("Number of wallets:", sdkTvl.allowedWallets.length);
2242
+ * console.log("TVL by wallet:", sdkTvl.tvlByWallet);
2243
+ * ```
2244
+ */
2245
+ async getSdkKeyTVL() {
2246
+ try {
2247
+ const response = await this.httpClient.get(ENDPOINTS.SDK_TVL);
2248
+ return {
2249
+ success: response.success || true,
2250
+ allowedWallets: response.allowedWallets || [],
2251
+ totalTvl: response.totalTvl || 0,
2252
+ tvlByWallet: response.tvlByWallet || [],
2253
+ metadata: response.metadata || {
2254
+ sdkKeyId: "",
2255
+ clientName: "",
2256
+ walletsCount: 0
2257
+ }
2258
+ };
2259
+ } catch (error) {
2260
+ throw new Error(
2261
+ `Failed to get SDK key TVL: ${error.message}`
2262
+ );
2263
+ }
2264
+ }
2181
2265
  };
2182
2266
  // Annotate the CommonJS export names for ESM import in node:
2183
2267
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -14,6 +14,7 @@ var ENDPOINTS = {
14
14
  USER_ME: "/users/me",
15
15
  USER_WITHDRAW: "/users/withdraw",
16
16
  PARTIAL_WITHDRAW: "/users/partial-withdraw",
17
+ LOG_DEPOSIT: "/users/log_deposit",
17
18
  // Safe Deployment (single endpoint)
18
19
  SAFE_DEPLOY: "/users/safe-deploy",
19
20
  // Session Keys
@@ -29,7 +30,10 @@ var ENDPOINTS = {
29
30
  DATA_FIRST_TOPUP: (walletAddress, chainId) => `/data/first-topup?walletAddress=${walletAddress}&chainId=${chainId}`,
30
31
  DATA_ACTIVE_WALLETS: (chainId) => `/data/active-wallets?chainId=${chainId}`,
31
32
  DATA_BY_EOA: (address) => `/data/by-eoa?address=${address}`,
32
- DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`
33
+ DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`,
34
+ // SDK Keys
35
+ SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
36
+ SDK_TVL: "/data/sdk-tvl"
33
37
  };
34
38
  var DATA_ENDPOINTS = {
35
39
  // User Initialization
@@ -1361,6 +1365,16 @@ var ZyfaiSDK = class {
1361
1365
  const receipt = await chainConfig.publicClient.waitForTransactionReceipt({
1362
1366
  hash: txHash
1363
1367
  });
1368
+ try {
1369
+ await this.httpClient.post(ENDPOINTS.LOG_DEPOSIT, {
1370
+ chainId,
1371
+ transaction: txHash,
1372
+ token,
1373
+ amount
1374
+ });
1375
+ } catch (logError) {
1376
+ console.warn("Failed to log deposit:", logError.message);
1377
+ }
1364
1378
  if (receipt.status !== "success") {
1365
1379
  throw new Error("Deposit transaction failed");
1366
1380
  }
@@ -2155,6 +2169,76 @@ var ZyfaiSDK = class {
2155
2169
  );
2156
2170
  }
2157
2171
  }
2172
+ // ============================================================================
2173
+ // SDK Key Methods
2174
+ // ============================================================================
2175
+ /**
2176
+ * Get allowed wallets for the current SDK API key
2177
+ * Returns the list of smart wallet addresses created via this SDK key
2178
+ *
2179
+ * @returns List of allowed wallet addresses with metadata
2180
+ *
2181
+ * @example
2182
+ * ```typescript
2183
+ * const result = await sdk.getSdkAllowedWallets();
2184
+ * console.log("Allowed wallets:", result.allowedWallets);
2185
+ * console.log("Total count:", result.metadata.walletsCount);
2186
+ * ```
2187
+ */
2188
+ async getSdkAllowedWallets() {
2189
+ try {
2190
+ const response = await this.httpClient.get(
2191
+ ENDPOINTS.SDK_ALLOWED_WALLETS
2192
+ );
2193
+ return {
2194
+ success: response.success || true,
2195
+ allowedWallets: response.allowedWallets || [],
2196
+ metadata: response.metadata || {
2197
+ sdkKeyId: "",
2198
+ clientName: "",
2199
+ walletsCount: 0
2200
+ }
2201
+ };
2202
+ } catch (error) {
2203
+ throw new Error(
2204
+ `Failed to get SDK allowed wallets: ${error.message}`
2205
+ );
2206
+ }
2207
+ }
2208
+ /**
2209
+ * Get total TVL for all wallets under the current SDK API key
2210
+ * This method calculates the total value locked across all wallets created via this SDK key
2211
+ *
2212
+ * @returns SDK key TVL information including allowed wallets and their individual/total TVL
2213
+ *
2214
+ * @example
2215
+ * ```typescript
2216
+ * const sdkTvl = await sdk.getSdkKeyTVL();
2217
+ * console.log("Total TVL across all SDK wallets:", sdkTvl.totalTvl);
2218
+ * console.log("Number of wallets:", sdkTvl.allowedWallets.length);
2219
+ * console.log("TVL by wallet:", sdkTvl.tvlByWallet);
2220
+ * ```
2221
+ */
2222
+ async getSdkKeyTVL() {
2223
+ try {
2224
+ const response = await this.httpClient.get(ENDPOINTS.SDK_TVL);
2225
+ return {
2226
+ success: response.success || true,
2227
+ allowedWallets: response.allowedWallets || [],
2228
+ totalTvl: response.totalTvl || 0,
2229
+ tvlByWallet: response.tvlByWallet || [],
2230
+ metadata: response.metadata || {
2231
+ sdkKeyId: "",
2232
+ clientName: "",
2233
+ walletsCount: 0
2234
+ }
2235
+ };
2236
+ } catch (error) {
2237
+ throw new Error(
2238
+ `Failed to get SDK key TVL: ${error.message}`
2239
+ );
2240
+ }
2241
+ }
2158
2242
  };
2159
2243
  export {
2160
2244
  DEFAULT_TOKEN_ADDRESSES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
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",