@zyfai/sdk 0.2.5 → 0.2.6
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 +71 -1
- package/dist/index.d.ts +71 -1
- package/dist/index.js +40 -1
- package/dist/index.mjs +40 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -376,6 +376,50 @@ interface SdkKeyTVLResponse {
|
|
|
376
376
|
walletsCount: number;
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
+
interface OpportunityPosition {
|
|
380
|
+
protocol: string;
|
|
381
|
+
pool: string;
|
|
382
|
+
apy: number;
|
|
383
|
+
tvl?: number;
|
|
384
|
+
}
|
|
385
|
+
interface BestOpportunityDetails {
|
|
386
|
+
protocol: string;
|
|
387
|
+
pool: string;
|
|
388
|
+
apy: number;
|
|
389
|
+
tvl: number;
|
|
390
|
+
zyfiTvl?: number;
|
|
391
|
+
poolApy?: number;
|
|
392
|
+
rewardsApy?: number;
|
|
393
|
+
protocolApy?: number;
|
|
394
|
+
}
|
|
395
|
+
interface BestOpportunityResponse {
|
|
396
|
+
success: boolean;
|
|
397
|
+
error?: string;
|
|
398
|
+
wallet?: Address;
|
|
399
|
+
chainId?: number;
|
|
400
|
+
strategy?: string;
|
|
401
|
+
token?: {
|
|
402
|
+
symbol: string;
|
|
403
|
+
address: string;
|
|
404
|
+
decimals: number;
|
|
405
|
+
};
|
|
406
|
+
currentPosition?: OpportunityPosition | null;
|
|
407
|
+
bestOpportunity?: BestOpportunityDetails | null;
|
|
408
|
+
shouldRebalance?: boolean;
|
|
409
|
+
apyImprovement?: number | null;
|
|
410
|
+
allOpportunities?: Array<{
|
|
411
|
+
protocol: string;
|
|
412
|
+
pool: string;
|
|
413
|
+
apy: number;
|
|
414
|
+
tvl: number;
|
|
415
|
+
zyfiTvl?: number;
|
|
416
|
+
}>;
|
|
417
|
+
userConfig?: {
|
|
418
|
+
autoSelectProtocols: boolean;
|
|
419
|
+
enabledProtocols: string[];
|
|
420
|
+
};
|
|
421
|
+
enabledChains?: number[];
|
|
422
|
+
}
|
|
379
423
|
interface PolicyData {
|
|
380
424
|
policy: Address;
|
|
381
425
|
initData: Hex;
|
|
@@ -929,6 +973,32 @@ declare class ZyfaiSDK {
|
|
|
929
973
|
* ```
|
|
930
974
|
*/
|
|
931
975
|
getSdkKeyTVL(): Promise<SdkKeyTVLResponse>;
|
|
976
|
+
/**
|
|
977
|
+
* Get the best yield opportunity for a registered wallet.
|
|
978
|
+
*
|
|
979
|
+
* Returns the highest-APY opportunity available based on the wallet's strategy
|
|
980
|
+
* and enabled protocols. This reflects what the rebalance engine would select.
|
|
981
|
+
*
|
|
982
|
+
* @param walletAddress - The smart wallet address (must be registered)
|
|
983
|
+
* @param chainId - The chain ID to check opportunities on
|
|
984
|
+
* @returns Best opportunity details with comparison to current position
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
* ```typescript
|
|
988
|
+
* const result = await sdk.getBestOpportunity(walletAddress, 8453);
|
|
989
|
+
*
|
|
990
|
+
* console.log("Current position:", result.currentPosition);
|
|
991
|
+
* console.log("Best opportunity:", result.bestOpportunity);
|
|
992
|
+
* console.log("Should rebalance:", result.shouldRebalance);
|
|
993
|
+
* console.log("APY improvement:", result.apyImprovement);
|
|
994
|
+
*
|
|
995
|
+
* // List all available opportunities
|
|
996
|
+
* result.allOpportunities?.forEach(opp => {
|
|
997
|
+
* console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
|
|
998
|
+
* });
|
|
999
|
+
* ```
|
|
1000
|
+
*/
|
|
1001
|
+
getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
|
|
932
1002
|
}
|
|
933
1003
|
|
|
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 };
|
|
1004
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, 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 OpportunityPosition, 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
|
@@ -376,6 +376,50 @@ interface SdkKeyTVLResponse {
|
|
|
376
376
|
walletsCount: number;
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
+
interface OpportunityPosition {
|
|
380
|
+
protocol: string;
|
|
381
|
+
pool: string;
|
|
382
|
+
apy: number;
|
|
383
|
+
tvl?: number;
|
|
384
|
+
}
|
|
385
|
+
interface BestOpportunityDetails {
|
|
386
|
+
protocol: string;
|
|
387
|
+
pool: string;
|
|
388
|
+
apy: number;
|
|
389
|
+
tvl: number;
|
|
390
|
+
zyfiTvl?: number;
|
|
391
|
+
poolApy?: number;
|
|
392
|
+
rewardsApy?: number;
|
|
393
|
+
protocolApy?: number;
|
|
394
|
+
}
|
|
395
|
+
interface BestOpportunityResponse {
|
|
396
|
+
success: boolean;
|
|
397
|
+
error?: string;
|
|
398
|
+
wallet?: Address;
|
|
399
|
+
chainId?: number;
|
|
400
|
+
strategy?: string;
|
|
401
|
+
token?: {
|
|
402
|
+
symbol: string;
|
|
403
|
+
address: string;
|
|
404
|
+
decimals: number;
|
|
405
|
+
};
|
|
406
|
+
currentPosition?: OpportunityPosition | null;
|
|
407
|
+
bestOpportunity?: BestOpportunityDetails | null;
|
|
408
|
+
shouldRebalance?: boolean;
|
|
409
|
+
apyImprovement?: number | null;
|
|
410
|
+
allOpportunities?: Array<{
|
|
411
|
+
protocol: string;
|
|
412
|
+
pool: string;
|
|
413
|
+
apy: number;
|
|
414
|
+
tvl: number;
|
|
415
|
+
zyfiTvl?: number;
|
|
416
|
+
}>;
|
|
417
|
+
userConfig?: {
|
|
418
|
+
autoSelectProtocols: boolean;
|
|
419
|
+
enabledProtocols: string[];
|
|
420
|
+
};
|
|
421
|
+
enabledChains?: number[];
|
|
422
|
+
}
|
|
379
423
|
interface PolicyData {
|
|
380
424
|
policy: Address;
|
|
381
425
|
initData: Hex;
|
|
@@ -929,6 +973,32 @@ declare class ZyfaiSDK {
|
|
|
929
973
|
* ```
|
|
930
974
|
*/
|
|
931
975
|
getSdkKeyTVL(): Promise<SdkKeyTVLResponse>;
|
|
976
|
+
/**
|
|
977
|
+
* Get the best yield opportunity for a registered wallet.
|
|
978
|
+
*
|
|
979
|
+
* Returns the highest-APY opportunity available based on the wallet's strategy
|
|
980
|
+
* and enabled protocols. This reflects what the rebalance engine would select.
|
|
981
|
+
*
|
|
982
|
+
* @param walletAddress - The smart wallet address (must be registered)
|
|
983
|
+
* @param chainId - The chain ID to check opportunities on
|
|
984
|
+
* @returns Best opportunity details with comparison to current position
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
* ```typescript
|
|
988
|
+
* const result = await sdk.getBestOpportunity(walletAddress, 8453);
|
|
989
|
+
*
|
|
990
|
+
* console.log("Current position:", result.currentPosition);
|
|
991
|
+
* console.log("Best opportunity:", result.bestOpportunity);
|
|
992
|
+
* console.log("Should rebalance:", result.shouldRebalance);
|
|
993
|
+
* console.log("APY improvement:", result.apyImprovement);
|
|
994
|
+
*
|
|
995
|
+
* // List all available opportunities
|
|
996
|
+
* result.allOpportunities?.forEach(opp => {
|
|
997
|
+
* console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
|
|
998
|
+
* });
|
|
999
|
+
* ```
|
|
1000
|
+
*/
|
|
1001
|
+
getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
|
|
932
1002
|
}
|
|
933
1003
|
|
|
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 };
|
|
1004
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, 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 OpportunityPosition, 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
|
@@ -74,7 +74,9 @@ var ENDPOINTS = {
|
|
|
74
74
|
DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`,
|
|
75
75
|
// SDK Keys
|
|
76
76
|
SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
|
|
77
|
-
SDK_TVL: "/data/sdk-tvl"
|
|
77
|
+
SDK_TVL: "/data/sdk-tvl",
|
|
78
|
+
// Best Opportunity
|
|
79
|
+
BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`
|
|
78
80
|
};
|
|
79
81
|
var DATA_ENDPOINTS = {
|
|
80
82
|
// User Initialization
|
|
@@ -2262,6 +2264,43 @@ var ZyfaiSDK = class {
|
|
|
2262
2264
|
);
|
|
2263
2265
|
}
|
|
2264
2266
|
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Get the best yield opportunity for a registered wallet.
|
|
2269
|
+
*
|
|
2270
|
+
* Returns the highest-APY opportunity available based on the wallet's strategy
|
|
2271
|
+
* and enabled protocols. This reflects what the rebalance engine would select.
|
|
2272
|
+
*
|
|
2273
|
+
* @param walletAddress - The smart wallet address (must be registered)
|
|
2274
|
+
* @param chainId - The chain ID to check opportunities on
|
|
2275
|
+
* @returns Best opportunity details with comparison to current position
|
|
2276
|
+
*
|
|
2277
|
+
* @example
|
|
2278
|
+
* ```typescript
|
|
2279
|
+
* const result = await sdk.getBestOpportunity(walletAddress, 8453);
|
|
2280
|
+
*
|
|
2281
|
+
* console.log("Current position:", result.currentPosition);
|
|
2282
|
+
* console.log("Best opportunity:", result.bestOpportunity);
|
|
2283
|
+
* console.log("Should rebalance:", result.shouldRebalance);
|
|
2284
|
+
* console.log("APY improvement:", result.apyImprovement);
|
|
2285
|
+
*
|
|
2286
|
+
* // List all available opportunities
|
|
2287
|
+
* result.allOpportunities?.forEach(opp => {
|
|
2288
|
+
* console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
|
|
2289
|
+
* });
|
|
2290
|
+
* ```
|
|
2291
|
+
*/
|
|
2292
|
+
async getBestOpportunity(walletAddress, chainId) {
|
|
2293
|
+
try {
|
|
2294
|
+
const response = await this.httpClient.get(
|
|
2295
|
+
ENDPOINTS.BEST_OPPORTUNITY(walletAddress, chainId)
|
|
2296
|
+
);
|
|
2297
|
+
return response;
|
|
2298
|
+
} catch (error) {
|
|
2299
|
+
throw new Error(
|
|
2300
|
+
`Failed to get best opportunity: ${error.message}`
|
|
2301
|
+
);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2265
2304
|
};
|
|
2266
2305
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2267
2306
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,9 @@ var ENDPOINTS = {
|
|
|
33
33
|
DATA_REBALANCE_FREQUENCY: (walletAddress) => `/data/rebalance-frequency?walletAddress=${walletAddress}`,
|
|
34
34
|
// SDK Keys
|
|
35
35
|
SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
|
|
36
|
-
SDK_TVL: "/data/sdk-tvl"
|
|
36
|
+
SDK_TVL: "/data/sdk-tvl",
|
|
37
|
+
// Best Opportunity
|
|
38
|
+
BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`
|
|
37
39
|
};
|
|
38
40
|
var DATA_ENDPOINTS = {
|
|
39
41
|
// User Initialization
|
|
@@ -2239,6 +2241,43 @@ var ZyfaiSDK = class {
|
|
|
2239
2241
|
);
|
|
2240
2242
|
}
|
|
2241
2243
|
}
|
|
2244
|
+
/**
|
|
2245
|
+
* Get the best yield opportunity for a registered wallet.
|
|
2246
|
+
*
|
|
2247
|
+
* Returns the highest-APY opportunity available based on the wallet's strategy
|
|
2248
|
+
* and enabled protocols. This reflects what the rebalance engine would select.
|
|
2249
|
+
*
|
|
2250
|
+
* @param walletAddress - The smart wallet address (must be registered)
|
|
2251
|
+
* @param chainId - The chain ID to check opportunities on
|
|
2252
|
+
* @returns Best opportunity details with comparison to current position
|
|
2253
|
+
*
|
|
2254
|
+
* @example
|
|
2255
|
+
* ```typescript
|
|
2256
|
+
* const result = await sdk.getBestOpportunity(walletAddress, 8453);
|
|
2257
|
+
*
|
|
2258
|
+
* console.log("Current position:", result.currentPosition);
|
|
2259
|
+
* console.log("Best opportunity:", result.bestOpportunity);
|
|
2260
|
+
* console.log("Should rebalance:", result.shouldRebalance);
|
|
2261
|
+
* console.log("APY improvement:", result.apyImprovement);
|
|
2262
|
+
*
|
|
2263
|
+
* // List all available opportunities
|
|
2264
|
+
* result.allOpportunities?.forEach(opp => {
|
|
2265
|
+
* console.log(`${opp.protocol} - ${opp.pool}: ${opp.apy}%`);
|
|
2266
|
+
* });
|
|
2267
|
+
* ```
|
|
2268
|
+
*/
|
|
2269
|
+
async getBestOpportunity(walletAddress, chainId) {
|
|
2270
|
+
try {
|
|
2271
|
+
const response = await this.httpClient.get(
|
|
2272
|
+
ENDPOINTS.BEST_OPPORTUNITY(walletAddress, chainId)
|
|
2273
|
+
);
|
|
2274
|
+
return response;
|
|
2275
|
+
} catch (error) {
|
|
2276
|
+
throw new Error(
|
|
2277
|
+
`Failed to get best opportunity: ${error.message}`
|
|
2278
|
+
);
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2242
2281
|
};
|
|
2243
2282
|
export {
|
|
2244
2283
|
DEFAULT_TOKEN_ADDRESSES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
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",
|