@zyfai/sdk 0.1.10 → 0.1.12
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 +0 -15
- package/dist/index.d.ts +0 -15
- package/dist/index.js +33 -51
- package/dist/index.mjs +33 -51
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -856,21 +856,6 @@ declare class ZyfaiSDK {
|
|
|
856
856
|
* ```
|
|
857
857
|
*/
|
|
858
858
|
getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
|
|
859
|
-
/**
|
|
860
|
-
* Add wallet to SDK API key allowedWallets list
|
|
861
|
-
* Adds a wallet address to the SDK API key's allowedWallets list.
|
|
862
|
-
* This endpoint requires SDK API key authentication (API key starting with "zyfai_").
|
|
863
|
-
*
|
|
864
|
-
* @param walletAddress - Wallet address to add to the allowed list
|
|
865
|
-
* @returns Response indicating success and status message
|
|
866
|
-
*
|
|
867
|
-
* @example
|
|
868
|
-
* ```typescript
|
|
869
|
-
* const result = await sdk.addWalletToSdk("0x1234...");
|
|
870
|
-
* console.log(result.message); // "Wallet successfully added to allowed list"
|
|
871
|
-
* ```
|
|
872
|
-
*/
|
|
873
|
-
addWalletToSdk(walletAddress: string): Promise<AddWalletToSdkResponse>;
|
|
874
859
|
}
|
|
875
860
|
|
|
876
861
|
export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, 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 SmartWalletByEOAResponse, type SmartWalletResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getSupportedChainIds, isSupportedChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -856,21 +856,6 @@ declare class ZyfaiSDK {
|
|
|
856
856
|
* ```
|
|
857
857
|
*/
|
|
858
858
|
getRebalanceFrequency(walletAddress: string): Promise<RebalanceFrequencyResponse>;
|
|
859
|
-
/**
|
|
860
|
-
* Add wallet to SDK API key allowedWallets list
|
|
861
|
-
* Adds a wallet address to the SDK API key's allowedWallets list.
|
|
862
|
-
* This endpoint requires SDK API key authentication (API key starting with "zyfai_").
|
|
863
|
-
*
|
|
864
|
-
* @param walletAddress - Wallet address to add to the allowed list
|
|
865
|
-
* @returns Response indicating success and status message
|
|
866
|
-
*
|
|
867
|
-
* @example
|
|
868
|
-
* ```typescript
|
|
869
|
-
* const result = await sdk.addWalletToSdk("0x1234...");
|
|
870
|
-
* console.log(result.message); // "Wallet successfully added to allowed list"
|
|
871
|
-
* ```
|
|
872
|
-
*/
|
|
873
|
-
addWalletToSdk(walletAddress: string): Promise<AddWalletToSdkResponse>;
|
|
874
859
|
}
|
|
875
860
|
|
|
876
861
|
export { type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, 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 SmartWalletByEOAResponse, type SmartWalletResponse, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WithdrawResponse, ZyfaiSDK, getChainConfig, getSupportedChainIds, isSupportedChain };
|
package/dist/index.js
CHANGED
|
@@ -59,7 +59,6 @@ var ENDPOINTS = {
|
|
|
59
59
|
USER_ME: "/users/me",
|
|
60
60
|
USER_WITHDRAW: "/users/withdraw",
|
|
61
61
|
PARTIAL_WITHDRAW: "/users/partial-withdraw",
|
|
62
|
-
USER_ADD_WALLET_TO_SDK: "/users/add-wallet-to-sdk",
|
|
63
62
|
// Session Keys
|
|
64
63
|
SESSION_KEYS_CONFIG: "/session-keys/config",
|
|
65
64
|
SESSION_KEYS_ADD: "/session-keys/add",
|
|
@@ -77,7 +76,7 @@ var ENDPOINTS = {
|
|
|
77
76
|
};
|
|
78
77
|
var DATA_ENDPOINTS = {
|
|
79
78
|
// User Initialization
|
|
80
|
-
USER_INITIALIZE: "/earnings/initialize",
|
|
79
|
+
USER_INITIALIZE: "/api/earnings/initialize",
|
|
81
80
|
// Earnings
|
|
82
81
|
ONCHAIN_EARNINGS: (walletAddress) => `/usercheck/onchain-earnings?walletAddress=${walletAddress}`,
|
|
83
82
|
CALCULATE_ONCHAIN_EARNINGS: "/usercheck/calculate-onchain-earnings",
|
|
@@ -111,6 +110,7 @@ var HttpClient = class {
|
|
|
111
110
|
this.authToken = null;
|
|
112
111
|
this.apiKey = apiKey;
|
|
113
112
|
this.dataApiKey = dataApiKey || apiKey;
|
|
113
|
+
this.environment = environment;
|
|
114
114
|
const endpoint = API_ENDPOINTS[environment];
|
|
115
115
|
const parsedUrl = new URL(endpoint);
|
|
116
116
|
this.origin = parsedUrl.origin;
|
|
@@ -215,6 +215,31 @@ var HttpClient = class {
|
|
|
215
215
|
const response = await this.dataClient.post(url, data, config);
|
|
216
216
|
return response.data;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Make a POST request to Data API with a custom path (bypasses /api/v2 baseURL)
|
|
220
|
+
* Useful for endpoints that don't follow the /api/v2 pattern
|
|
221
|
+
*
|
|
222
|
+
* @param path - API path (e.g., "/api/earnings/initialize")
|
|
223
|
+
* @param data - Request body
|
|
224
|
+
* @param config - Additional axios config
|
|
225
|
+
*/
|
|
226
|
+
async dataPostCustom(path, data, config) {
|
|
227
|
+
const fullUrl = `${DATA_API_ENDPOINTS[this.environment]}${path}`;
|
|
228
|
+
const headers = {
|
|
229
|
+
"Content-Type": "application/json",
|
|
230
|
+
"X-API-Key": this.dataApiKey,
|
|
231
|
+
...config?.headers
|
|
232
|
+
};
|
|
233
|
+
if (this.authToken) {
|
|
234
|
+
headers["Authorization"] = `Bearer ${this.authToken}`;
|
|
235
|
+
}
|
|
236
|
+
const response = await import_axios.default.post(fullUrl, data, {
|
|
237
|
+
...config,
|
|
238
|
+
headers,
|
|
239
|
+
timeout: config?.timeout || 3e4
|
|
240
|
+
});
|
|
241
|
+
return response.data;
|
|
242
|
+
}
|
|
218
243
|
setupDataInterceptors() {
|
|
219
244
|
this.dataClient.interceptors.request.use(
|
|
220
245
|
(config) => {
|
|
@@ -763,18 +788,18 @@ var ZyfaiSDK = class {
|
|
|
763
788
|
async initializeUser(smartWallet, chainId) {
|
|
764
789
|
try {
|
|
765
790
|
await this.authenticateUser();
|
|
766
|
-
const
|
|
791
|
+
const responseData = await this.httpClient.dataPostCustom(
|
|
767
792
|
DATA_ENDPOINTS.USER_INITIALIZE,
|
|
768
793
|
{
|
|
769
794
|
walletAddress: smartWallet
|
|
770
795
|
}
|
|
771
796
|
);
|
|
772
797
|
return {
|
|
773
|
-
success:
|
|
774
|
-
userId:
|
|
775
|
-
smartWallet:
|
|
776
|
-
chainId:
|
|
777
|
-
message:
|
|
798
|
+
success: responseData.status === "success" || true,
|
|
799
|
+
userId: responseData.userId || responseData.id,
|
|
800
|
+
smartWallet: responseData.smartWallet || smartWallet,
|
|
801
|
+
chainId: responseData.chainId || chainId,
|
|
802
|
+
message: responseData.message || responseData.status || "User initialized successfully"
|
|
778
803
|
};
|
|
779
804
|
} catch (error) {
|
|
780
805
|
throw new Error(`Failed to initialize user: ${error.message}`);
|
|
@@ -2132,49 +2157,6 @@ var ZyfaiSDK = class {
|
|
|
2132
2157
|
);
|
|
2133
2158
|
}
|
|
2134
2159
|
}
|
|
2135
|
-
// ============================================================================
|
|
2136
|
-
// SDK API Key Management
|
|
2137
|
-
// ============================================================================
|
|
2138
|
-
/**
|
|
2139
|
-
* Add wallet to SDK API key allowedWallets list
|
|
2140
|
-
* Adds a wallet address to the SDK API key's allowedWallets list.
|
|
2141
|
-
* This endpoint requires SDK API key authentication (API key starting with "zyfai_").
|
|
2142
|
-
*
|
|
2143
|
-
* @param walletAddress - Wallet address to add to the allowed list
|
|
2144
|
-
* @returns Response indicating success and status message
|
|
2145
|
-
*
|
|
2146
|
-
* @example
|
|
2147
|
-
* ```typescript
|
|
2148
|
-
* const result = await sdk.addWalletToSdk("0x1234...");
|
|
2149
|
-
* console.log(result.message); // "Wallet successfully added to allowed list"
|
|
2150
|
-
* ```
|
|
2151
|
-
*/
|
|
2152
|
-
async addWalletToSdk(walletAddress) {
|
|
2153
|
-
try {
|
|
2154
|
-
if (!walletAddress) {
|
|
2155
|
-
throw new Error("Wallet address is required");
|
|
2156
|
-
}
|
|
2157
|
-
try {
|
|
2158
|
-
(0, import_viem4.getAddress)(walletAddress);
|
|
2159
|
-
} catch {
|
|
2160
|
-
throw new Error("Invalid wallet address format");
|
|
2161
|
-
}
|
|
2162
|
-
const response = await this.httpClient.post(
|
|
2163
|
-
ENDPOINTS.USER_ADD_WALLET_TO_SDK,
|
|
2164
|
-
{
|
|
2165
|
-
walletAddress
|
|
2166
|
-
}
|
|
2167
|
-
);
|
|
2168
|
-
return {
|
|
2169
|
-
success: response.success ?? true,
|
|
2170
|
-
message: response.message || "Wallet added successfully"
|
|
2171
|
-
};
|
|
2172
|
-
} catch (error) {
|
|
2173
|
-
throw new Error(
|
|
2174
|
-
`Failed to add wallet to SDK: ${error.message}`
|
|
2175
|
-
);
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
2160
|
};
|
|
2179
2161
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2180
2162
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,6 @@ var ENDPOINTS = {
|
|
|
20
20
|
USER_ME: "/users/me",
|
|
21
21
|
USER_WITHDRAW: "/users/withdraw",
|
|
22
22
|
PARTIAL_WITHDRAW: "/users/partial-withdraw",
|
|
23
|
-
USER_ADD_WALLET_TO_SDK: "/users/add-wallet-to-sdk",
|
|
24
23
|
// Session Keys
|
|
25
24
|
SESSION_KEYS_CONFIG: "/session-keys/config",
|
|
26
25
|
SESSION_KEYS_ADD: "/session-keys/add",
|
|
@@ -38,7 +37,7 @@ var ENDPOINTS = {
|
|
|
38
37
|
};
|
|
39
38
|
var DATA_ENDPOINTS = {
|
|
40
39
|
// User Initialization
|
|
41
|
-
USER_INITIALIZE: "/earnings/initialize",
|
|
40
|
+
USER_INITIALIZE: "/api/earnings/initialize",
|
|
42
41
|
// Earnings
|
|
43
42
|
ONCHAIN_EARNINGS: (walletAddress) => `/usercheck/onchain-earnings?walletAddress=${walletAddress}`,
|
|
44
43
|
CALCULATE_ONCHAIN_EARNINGS: "/usercheck/calculate-onchain-earnings",
|
|
@@ -72,6 +71,7 @@ var HttpClient = class {
|
|
|
72
71
|
this.authToken = null;
|
|
73
72
|
this.apiKey = apiKey;
|
|
74
73
|
this.dataApiKey = dataApiKey || apiKey;
|
|
74
|
+
this.environment = environment;
|
|
75
75
|
const endpoint = API_ENDPOINTS[environment];
|
|
76
76
|
const parsedUrl = new URL(endpoint);
|
|
77
77
|
this.origin = parsedUrl.origin;
|
|
@@ -176,6 +176,31 @@ var HttpClient = class {
|
|
|
176
176
|
const response = await this.dataClient.post(url, data, config);
|
|
177
177
|
return response.data;
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Make a POST request to Data API with a custom path (bypasses /api/v2 baseURL)
|
|
181
|
+
* Useful for endpoints that don't follow the /api/v2 pattern
|
|
182
|
+
*
|
|
183
|
+
* @param path - API path (e.g., "/api/earnings/initialize")
|
|
184
|
+
* @param data - Request body
|
|
185
|
+
* @param config - Additional axios config
|
|
186
|
+
*/
|
|
187
|
+
async dataPostCustom(path, data, config) {
|
|
188
|
+
const fullUrl = `${DATA_API_ENDPOINTS[this.environment]}${path}`;
|
|
189
|
+
const headers = {
|
|
190
|
+
"Content-Type": "application/json",
|
|
191
|
+
"X-API-Key": this.dataApiKey,
|
|
192
|
+
...config?.headers
|
|
193
|
+
};
|
|
194
|
+
if (this.authToken) {
|
|
195
|
+
headers["Authorization"] = `Bearer ${this.authToken}`;
|
|
196
|
+
}
|
|
197
|
+
const response = await axios.post(fullUrl, data, {
|
|
198
|
+
...config,
|
|
199
|
+
headers,
|
|
200
|
+
timeout: config?.timeout || 3e4
|
|
201
|
+
});
|
|
202
|
+
return response.data;
|
|
203
|
+
}
|
|
179
204
|
setupDataInterceptors() {
|
|
180
205
|
this.dataClient.interceptors.request.use(
|
|
181
206
|
(config) => {
|
|
@@ -743,18 +768,18 @@ var ZyfaiSDK = class {
|
|
|
743
768
|
async initializeUser(smartWallet, chainId) {
|
|
744
769
|
try {
|
|
745
770
|
await this.authenticateUser();
|
|
746
|
-
const
|
|
771
|
+
const responseData = await this.httpClient.dataPostCustom(
|
|
747
772
|
DATA_ENDPOINTS.USER_INITIALIZE,
|
|
748
773
|
{
|
|
749
774
|
walletAddress: smartWallet
|
|
750
775
|
}
|
|
751
776
|
);
|
|
752
777
|
return {
|
|
753
|
-
success:
|
|
754
|
-
userId:
|
|
755
|
-
smartWallet:
|
|
756
|
-
chainId:
|
|
757
|
-
message:
|
|
778
|
+
success: responseData.status === "success" || true,
|
|
779
|
+
userId: responseData.userId || responseData.id,
|
|
780
|
+
smartWallet: responseData.smartWallet || smartWallet,
|
|
781
|
+
chainId: responseData.chainId || chainId,
|
|
782
|
+
message: responseData.message || responseData.status || "User initialized successfully"
|
|
758
783
|
};
|
|
759
784
|
} catch (error) {
|
|
760
785
|
throw new Error(`Failed to initialize user: ${error.message}`);
|
|
@@ -2112,49 +2137,6 @@ var ZyfaiSDK = class {
|
|
|
2112
2137
|
);
|
|
2113
2138
|
}
|
|
2114
2139
|
}
|
|
2115
|
-
// ============================================================================
|
|
2116
|
-
// SDK API Key Management
|
|
2117
|
-
// ============================================================================
|
|
2118
|
-
/**
|
|
2119
|
-
* Add wallet to SDK API key allowedWallets list
|
|
2120
|
-
* Adds a wallet address to the SDK API key's allowedWallets list.
|
|
2121
|
-
* This endpoint requires SDK API key authentication (API key starting with "zyfai_").
|
|
2122
|
-
*
|
|
2123
|
-
* @param walletAddress - Wallet address to add to the allowed list
|
|
2124
|
-
* @returns Response indicating success and status message
|
|
2125
|
-
*
|
|
2126
|
-
* @example
|
|
2127
|
-
* ```typescript
|
|
2128
|
-
* const result = await sdk.addWalletToSdk("0x1234...");
|
|
2129
|
-
* console.log(result.message); // "Wallet successfully added to allowed list"
|
|
2130
|
-
* ```
|
|
2131
|
-
*/
|
|
2132
|
-
async addWalletToSdk(walletAddress) {
|
|
2133
|
-
try {
|
|
2134
|
-
if (!walletAddress) {
|
|
2135
|
-
throw new Error("Wallet address is required");
|
|
2136
|
-
}
|
|
2137
|
-
try {
|
|
2138
|
-
getAddress2(walletAddress);
|
|
2139
|
-
} catch {
|
|
2140
|
-
throw new Error("Invalid wallet address format");
|
|
2141
|
-
}
|
|
2142
|
-
const response = await this.httpClient.post(
|
|
2143
|
-
ENDPOINTS.USER_ADD_WALLET_TO_SDK,
|
|
2144
|
-
{
|
|
2145
|
-
walletAddress
|
|
2146
|
-
}
|
|
2147
|
-
);
|
|
2148
|
-
return {
|
|
2149
|
-
success: response.success ?? true,
|
|
2150
|
-
message: response.message || "Wallet added successfully"
|
|
2151
|
-
};
|
|
2152
|
-
} catch (error) {
|
|
2153
|
-
throw new Error(
|
|
2154
|
-
`Failed to add wallet to SDK: ${error.message}`
|
|
2155
|
-
);
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
2140
|
};
|
|
2159
2141
|
export {
|
|
2160
2142
|
ZyfaiSDK,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
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",
|