@zyfai/sdk 0.1.9 → 0.1.11
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 +9 -53
- package/dist/index.mjs +9 -53
- 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
|
@@ -57,10 +57,8 @@ var ENDPOINTS = {
|
|
|
57
57
|
AUTH_CHALLENGE: "/auth/challenge",
|
|
58
58
|
// User
|
|
59
59
|
USER_ME: "/users/me",
|
|
60
|
-
USER_INITIALIZE: "/users/initialize",
|
|
61
60
|
USER_WITHDRAW: "/users/withdraw",
|
|
62
61
|
PARTIAL_WITHDRAW: "/users/partial-withdraw",
|
|
63
|
-
USER_ADD_WALLET_TO_SDK: "/users/add-wallet-to-sdk",
|
|
64
62
|
// Session Keys
|
|
65
63
|
SESSION_KEYS_CONFIG: "/session-keys/config",
|
|
66
64
|
SESSION_KEYS_ADD: "/session-keys/add",
|
|
@@ -77,6 +75,8 @@ var ENDPOINTS = {
|
|
|
77
75
|
DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`
|
|
78
76
|
};
|
|
79
77
|
var DATA_ENDPOINTS = {
|
|
78
|
+
// User Initialization
|
|
79
|
+
USER_INITIALIZE: "/earnings/initialize",
|
|
80
80
|
// Earnings
|
|
81
81
|
ONCHAIN_EARNINGS: (walletAddress) => `/usercheck/onchain-earnings?walletAddress=${walletAddress}`,
|
|
82
82
|
CALCULATE_ONCHAIN_EARNINGS: "/usercheck/calculate-onchain-earnings",
|
|
@@ -762,19 +762,18 @@ var ZyfaiSDK = class {
|
|
|
762
762
|
async initializeUser(smartWallet, chainId) {
|
|
763
763
|
try {
|
|
764
764
|
await this.authenticateUser();
|
|
765
|
-
const response = await this.httpClient.
|
|
766
|
-
|
|
765
|
+
const response = await this.httpClient.dataPost(
|
|
766
|
+
DATA_ENDPOINTS.USER_INITIALIZE,
|
|
767
767
|
{
|
|
768
|
-
smartWallet
|
|
769
|
-
chainId
|
|
768
|
+
walletAddress: smartWallet
|
|
770
769
|
}
|
|
771
770
|
);
|
|
772
771
|
return {
|
|
773
|
-
success: true,
|
|
772
|
+
success: response.status === "success" || true,
|
|
774
773
|
userId: response.userId || response.id,
|
|
775
|
-
smartWallet: response.smartWallet,
|
|
776
|
-
chainId: response.chainId,
|
|
777
|
-
message: response.message
|
|
774
|
+
smartWallet: response.smartWallet || smartWallet,
|
|
775
|
+
chainId: response.chainId || chainId,
|
|
776
|
+
message: response.message || response.status || "User initialized successfully"
|
|
778
777
|
};
|
|
779
778
|
} catch (error) {
|
|
780
779
|
throw new Error(`Failed to initialize user: ${error.message}`);
|
|
@@ -2132,49 +2131,6 @@ var ZyfaiSDK = class {
|
|
|
2132
2131
|
);
|
|
2133
2132
|
}
|
|
2134
2133
|
}
|
|
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
2134
|
};
|
|
2179
2135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2180
2136
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -18,10 +18,8 @@ var ENDPOINTS = {
|
|
|
18
18
|
AUTH_CHALLENGE: "/auth/challenge",
|
|
19
19
|
// User
|
|
20
20
|
USER_ME: "/users/me",
|
|
21
|
-
USER_INITIALIZE: "/users/initialize",
|
|
22
21
|
USER_WITHDRAW: "/users/withdraw",
|
|
23
22
|
PARTIAL_WITHDRAW: "/users/partial-withdraw",
|
|
24
|
-
USER_ADD_WALLET_TO_SDK: "/users/add-wallet-to-sdk",
|
|
25
23
|
// Session Keys
|
|
26
24
|
SESSION_KEYS_CONFIG: "/session-keys/config",
|
|
27
25
|
SESSION_KEYS_ADD: "/session-keys/add",
|
|
@@ -38,6 +36,8 @@ var ENDPOINTS = {
|
|
|
38
36
|
DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`
|
|
39
37
|
};
|
|
40
38
|
var DATA_ENDPOINTS = {
|
|
39
|
+
// User Initialization
|
|
40
|
+
USER_INITIALIZE: "/earnings/initialize",
|
|
41
41
|
// Earnings
|
|
42
42
|
ONCHAIN_EARNINGS: (walletAddress) => `/usercheck/onchain-earnings?walletAddress=${walletAddress}`,
|
|
43
43
|
CALCULATE_ONCHAIN_EARNINGS: "/usercheck/calculate-onchain-earnings",
|
|
@@ -742,19 +742,18 @@ var ZyfaiSDK = class {
|
|
|
742
742
|
async initializeUser(smartWallet, chainId) {
|
|
743
743
|
try {
|
|
744
744
|
await this.authenticateUser();
|
|
745
|
-
const response = await this.httpClient.
|
|
746
|
-
|
|
745
|
+
const response = await this.httpClient.dataPost(
|
|
746
|
+
DATA_ENDPOINTS.USER_INITIALIZE,
|
|
747
747
|
{
|
|
748
|
-
smartWallet
|
|
749
|
-
chainId
|
|
748
|
+
walletAddress: smartWallet
|
|
750
749
|
}
|
|
751
750
|
);
|
|
752
751
|
return {
|
|
753
|
-
success: true,
|
|
752
|
+
success: response.status === "success" || true,
|
|
754
753
|
userId: response.userId || response.id,
|
|
755
|
-
smartWallet: response.smartWallet,
|
|
756
|
-
chainId: response.chainId,
|
|
757
|
-
message: response.message
|
|
754
|
+
smartWallet: response.smartWallet || smartWallet,
|
|
755
|
+
chainId: response.chainId || chainId,
|
|
756
|
+
message: response.message || response.status || "User initialized successfully"
|
|
758
757
|
};
|
|
759
758
|
} catch (error) {
|
|
760
759
|
throw new Error(`Failed to initialize user: ${error.message}`);
|
|
@@ -2112,49 +2111,6 @@ var ZyfaiSDK = class {
|
|
|
2112
2111
|
);
|
|
2113
2112
|
}
|
|
2114
2113
|
}
|
|
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
2114
|
};
|
|
2159
2115
|
export {
|
|
2160
2116
|
ZyfaiSDK,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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",
|