@zyfai/sdk 0.1.1 → 0.1.2

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
@@ -7,9 +7,9 @@ type Address = `0x${string}`;
7
7
  type Hex = `0x${string}`;
8
8
  type Environment = "staging" | "production";
9
9
  interface SDKConfig {
10
- /** API key for the Execution API (Utkir's backend) */
10
+ /** API key for the Execution API */
11
11
  apiKey: string;
12
- /** API key for the Data API (Sunny's backend) - defaults to apiKey if not provided */
12
+ /** API key for the Data API - defaults to apiKey if not provided */
13
13
  dataApiKey?: string;
14
14
  /** Environment: 'staging' or 'production' (default: 'production') */
15
15
  environment?: Environment;
@@ -86,19 +86,25 @@ interface ProtocolsResponse {
86
86
  protocols: Protocol[];
87
87
  }
88
88
  interface Position {
89
- id?: string;
90
- chain?: string;
89
+ user?: string;
90
+ eoa?: Address;
91
+ chains?: number[];
91
92
  strategy?: string;
92
93
  smartWallet?: Address;
93
94
  positions: PositionSlot[];
94
95
  hasActiveSessionKey?: boolean;
95
96
  hasBalance?: boolean;
97
+ newSessionKeyAvailable?: boolean;
98
+ hasStaleBalance?: string[];
99
+ contracts?: Address[];
100
+ omniAccount?: boolean;
96
101
  crosschainStrategy?: boolean;
97
102
  }
98
103
  interface PositionSlot {
99
104
  chain?: string;
100
105
  protocol_id?: string;
101
106
  protocol_name?: string;
107
+ protocol_icon?: string;
102
108
  pool?: string;
103
109
  token_id?: string;
104
110
  token_symbol?: string;
@@ -106,7 +112,7 @@ interface PositionSlot {
106
112
  amount?: string;
107
113
  underlyingAmount?: string;
108
114
  pool_apy?: number;
109
- pool_tvl?: string;
115
+ pool_tvl?: number;
110
116
  }
111
117
  interface PositionsResponse {
112
118
  success: boolean;
@@ -159,7 +165,9 @@ interface ActiveWalletsResponse {
159
165
  interface SmartWalletsByEOAResponse {
160
166
  success: boolean;
161
167
  eoa: string;
168
+ smartWallet: string | null;
162
169
  smartWallets: string[];
170
+ chains: number[];
163
171
  }
164
172
  interface FirstTopupResponse {
165
173
  success: boolean;
@@ -168,16 +176,33 @@ interface FirstTopupResponse {
168
176
  amount?: string;
169
177
  chainId?: number;
170
178
  }
179
+ interface HistoryPosition {
180
+ pool?: string;
181
+ amount?: string;
182
+ token_id?: string;
183
+ token_icon?: string;
184
+ amountInUSD?: string;
185
+ protocol_id?: string;
186
+ token_symbol?: string;
187
+ protocol_icon?: string;
188
+ protocol_name?: string;
189
+ }
171
190
  interface HistoryEntry {
172
191
  id?: string;
173
- timestamp: string;
174
- type: string;
175
- amount: string;
176
- token?: string;
177
- txHash?: string;
192
+ action?: string;
193
+ date?: string;
194
+ strategy?: string;
195
+ positions?: HistoryPosition[];
178
196
  chainId?: number;
179
- protocol?: string;
180
- pool?: string;
197
+ transactionHash?: string;
198
+ destinationChainId?: number;
199
+ sourceChains?: number[];
200
+ crosschain?: boolean;
201
+ rebalance?: boolean;
202
+ zkProofIpfsHash?: string;
203
+ validationRegistryTxHash?: string;
204
+ validationRegistryChainId?: number;
205
+ validationRegistryAddress?: string;
181
206
  }
182
207
  interface HistoryResponse {
183
208
  success: boolean;
@@ -200,10 +225,17 @@ interface OnchainEarningsResponse {
200
225
  data: OnchainEarnings;
201
226
  }
202
227
  interface DailyEarning {
203
- date: string;
204
- earnings: number;
205
- balance?: number;
206
- apy?: number;
228
+ wallet_address?: string;
229
+ snapshot_date: string;
230
+ total_current_earnings: number;
231
+ total_lifetime_earnings: number;
232
+ total_unrealized_earnings: number;
233
+ total_earnings: number;
234
+ daily_current_delta: number;
235
+ daily_lifetime_delta: number;
236
+ daily_unrealized_delta: number;
237
+ daily_total_delta: number;
238
+ created_at?: string;
207
239
  }
208
240
  interface DailyEarningsResponse {
209
241
  success: boolean;
@@ -766,4 +798,4 @@ declare class ZyfaiSDK {
766
798
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
767
799
  }
768
800
 
769
- export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type Address, type ChainConfig, type ChainPortfolio, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletResponse, type SmartWalletsByEOAResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getSupportedChainIds, isSupportedChain };
801
+ export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type Address, type ChainConfig, type ChainPortfolio, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletResponse, type SmartWalletsByEOAResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, 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 Environment = "staging" | "production";
9
9
  interface SDKConfig {
10
- /** API key for the Execution API (Utkir's backend) */
10
+ /** API key for the Execution API */
11
11
  apiKey: string;
12
- /** API key for the Data API (Sunny's backend) - defaults to apiKey if not provided */
12
+ /** API key for the Data API - defaults to apiKey if not provided */
13
13
  dataApiKey?: string;
14
14
  /** Environment: 'staging' or 'production' (default: 'production') */
15
15
  environment?: Environment;
@@ -86,19 +86,25 @@ interface ProtocolsResponse {
86
86
  protocols: Protocol[];
87
87
  }
88
88
  interface Position {
89
- id?: string;
90
- chain?: string;
89
+ user?: string;
90
+ eoa?: Address;
91
+ chains?: number[];
91
92
  strategy?: string;
92
93
  smartWallet?: Address;
93
94
  positions: PositionSlot[];
94
95
  hasActiveSessionKey?: boolean;
95
96
  hasBalance?: boolean;
97
+ newSessionKeyAvailable?: boolean;
98
+ hasStaleBalance?: string[];
99
+ contracts?: Address[];
100
+ omniAccount?: boolean;
96
101
  crosschainStrategy?: boolean;
97
102
  }
98
103
  interface PositionSlot {
99
104
  chain?: string;
100
105
  protocol_id?: string;
101
106
  protocol_name?: string;
107
+ protocol_icon?: string;
102
108
  pool?: string;
103
109
  token_id?: string;
104
110
  token_symbol?: string;
@@ -106,7 +112,7 @@ interface PositionSlot {
106
112
  amount?: string;
107
113
  underlyingAmount?: string;
108
114
  pool_apy?: number;
109
- pool_tvl?: string;
115
+ pool_tvl?: number;
110
116
  }
111
117
  interface PositionsResponse {
112
118
  success: boolean;
@@ -159,7 +165,9 @@ interface ActiveWalletsResponse {
159
165
  interface SmartWalletsByEOAResponse {
160
166
  success: boolean;
161
167
  eoa: string;
168
+ smartWallet: string | null;
162
169
  smartWallets: string[];
170
+ chains: number[];
163
171
  }
164
172
  interface FirstTopupResponse {
165
173
  success: boolean;
@@ -168,16 +176,33 @@ interface FirstTopupResponse {
168
176
  amount?: string;
169
177
  chainId?: number;
170
178
  }
179
+ interface HistoryPosition {
180
+ pool?: string;
181
+ amount?: string;
182
+ token_id?: string;
183
+ token_icon?: string;
184
+ amountInUSD?: string;
185
+ protocol_id?: string;
186
+ token_symbol?: string;
187
+ protocol_icon?: string;
188
+ protocol_name?: string;
189
+ }
171
190
  interface HistoryEntry {
172
191
  id?: string;
173
- timestamp: string;
174
- type: string;
175
- amount: string;
176
- token?: string;
177
- txHash?: string;
192
+ action?: string;
193
+ date?: string;
194
+ strategy?: string;
195
+ positions?: HistoryPosition[];
178
196
  chainId?: number;
179
- protocol?: string;
180
- pool?: string;
197
+ transactionHash?: string;
198
+ destinationChainId?: number;
199
+ sourceChains?: number[];
200
+ crosschain?: boolean;
201
+ rebalance?: boolean;
202
+ zkProofIpfsHash?: string;
203
+ validationRegistryTxHash?: string;
204
+ validationRegistryChainId?: number;
205
+ validationRegistryAddress?: string;
181
206
  }
182
207
  interface HistoryResponse {
183
208
  success: boolean;
@@ -200,10 +225,17 @@ interface OnchainEarningsResponse {
200
225
  data: OnchainEarnings;
201
226
  }
202
227
  interface DailyEarning {
203
- date: string;
204
- earnings: number;
205
- balance?: number;
206
- apy?: number;
228
+ wallet_address?: string;
229
+ snapshot_date: string;
230
+ total_current_earnings: number;
231
+ total_lifetime_earnings: number;
232
+ total_unrealized_earnings: number;
233
+ total_earnings: number;
234
+ daily_current_delta: number;
235
+ daily_lifetime_delta: number;
236
+ daily_unrealized_delta: number;
237
+ daily_total_delta: number;
238
+ created_at?: string;
207
239
  }
208
240
  interface DailyEarningsResponse {
209
241
  success: boolean;
@@ -766,4 +798,4 @@ declare class ZyfaiSDK {
766
798
  getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
767
799
  }
768
800
 
769
- export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type Address, type ChainConfig, type ChainPortfolio, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletResponse, type SmartWalletsByEOAResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getSupportedChainIds, isSupportedChain };
801
+ export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type Address, type ChainConfig, type ChainPortfolio, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type Environment, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RebalanceInfo, type RebalanceInfoResponse, type SDKConfig, type Session, type SessionKeyResponse, type SmartWalletResponse, type SmartWalletsByEOAResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getSupportedChainIds, isSupportedChain };
package/dist/index.js CHANGED
@@ -100,9 +100,9 @@ var HttpClient = class {
100
100
  /**
101
101
  * Create HTTP client for both Execution API and Data API
102
102
  *
103
- * @param apiKey - API key for Execution API (Utkir's backend)
103
+ * @param apiKey - API key for Execution API
104
104
  * @param environment - 'staging' or 'production'
105
- * @param dataApiKey - API key for Data API (Sunny's backend) - defaults to apiKey
105
+ * @param dataApiKey - API key for Data API - defaults to apiKey
106
106
  */
107
107
  constructor(apiKey, environment = "production", dataApiKey) {
108
108
  this.authToken = null;
@@ -608,12 +608,11 @@ var signSessionKey = async (config, sessions) => {
608
608
  // src/core/ZyfaiSDK.ts
609
609
  var import_siwe = require("siwe");
610
610
  var ZyfaiSDK = class {
611
- // TODO: The encironment should be removed. Having the same key for staging and production is not ideal, but for now it's fine.
611
+ // TODO: The environment should be removed. Having the same key for staging and production is not ideal, but for now it's fine.
612
612
  constructor(config) {
613
613
  this.signer = null;
614
614
  this.walletClient = null;
615
615
  this.isAuthenticated = false;
616
- // TODO: Check with Utkir for how long the authentication token is valid for.
617
616
  this.authenticatedUserId = null;
618
617
  const sdkConfig = typeof config === "string" ? { apiKey: config } : config;
619
618
  const { apiKey, dataApiKey, environment, bundlerApiKey } = sdkConfig;
@@ -1429,11 +1428,15 @@ var ZyfaiSDK = class {
1429
1428
  const response = await this.httpClient.get(
1430
1429
  ENDPOINTS.DATA_BY_EOA(eoaAddress)
1431
1430
  );
1432
- const smartWallets = Array.isArray(response) ? response : response.smartWallets || [response.smartWallet].filter(Boolean);
1431
+ const smartWallet = response.agent || response.smartWallet || response.smartWallets?.[0];
1432
+ const smartWallets = smartWallet ? [smartWallet] : [];
1433
+ const chains = response.chains || [];
1433
1434
  return {
1434
1435
  success: true,
1435
1436
  eoa: eoaAddress,
1436
- smartWallets
1437
+ smartWallet: smartWallet || null,
1438
+ smartWallets,
1439
+ chains
1437
1440
  };
1438
1441
  } catch (error) {
1439
1442
  throw new Error(
package/dist/index.mjs CHANGED
@@ -61,9 +61,9 @@ var HttpClient = class {
61
61
  /**
62
62
  * Create HTTP client for both Execution API and Data API
63
63
  *
64
- * @param apiKey - API key for Execution API (Utkir's backend)
64
+ * @param apiKey - API key for Execution API
65
65
  * @param environment - 'staging' or 'production'
66
- * @param dataApiKey - API key for Data API (Sunny's backend) - defaults to apiKey
66
+ * @param dataApiKey - API key for Data API - defaults to apiKey
67
67
  */
68
68
  constructor(apiKey, environment = "production", dataApiKey) {
69
69
  this.authToken = null;
@@ -588,12 +588,11 @@ var signSessionKey = async (config, sessions) => {
588
588
  // src/core/ZyfaiSDK.ts
589
589
  import { SiweMessage } from "siwe";
590
590
  var ZyfaiSDK = class {
591
- // TODO: The encironment should be removed. Having the same key for staging and production is not ideal, but for now it's fine.
591
+ // TODO: The environment should be removed. Having the same key for staging and production is not ideal, but for now it's fine.
592
592
  constructor(config) {
593
593
  this.signer = null;
594
594
  this.walletClient = null;
595
595
  this.isAuthenticated = false;
596
- // TODO: Check with Utkir for how long the authentication token is valid for.
597
596
  this.authenticatedUserId = null;
598
597
  const sdkConfig = typeof config === "string" ? { apiKey: config } : config;
599
598
  const { apiKey, dataApiKey, environment, bundlerApiKey } = sdkConfig;
@@ -1409,11 +1408,15 @@ var ZyfaiSDK = class {
1409
1408
  const response = await this.httpClient.get(
1410
1409
  ENDPOINTS.DATA_BY_EOA(eoaAddress)
1411
1410
  );
1412
- const smartWallets = Array.isArray(response) ? response : response.smartWallets || [response.smartWallet].filter(Boolean);
1411
+ const smartWallet = response.agent || response.smartWallet || response.smartWallets?.[0];
1412
+ const smartWallets = smartWallet ? [smartWallet] : [];
1413
+ const chains = response.chains || [];
1413
1414
  return {
1414
1415
  success: true,
1415
1416
  eoa: eoaAddress,
1416
- smartWallets
1417
+ smartWallet: smartWallet || null,
1418
+ smartWallets,
1419
+ chains
1417
1420
  };
1418
1421
  } catch (error) {
1419
1422
  throw new Error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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",