@zyfai/sdk 0.2.12 → 0.2.13
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/README.md +12 -11
- package/dist/index.d.mts +102 -3
- package/dist/index.d.ts +102 -3
- package/dist/index.js +133 -1
- package/dist/index.mjs +133 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -754,26 +754,27 @@ All examples are available in the `examples/` directory:
|
|
|
754
754
|
9. **`get-user-details.ts`** - Get authenticated user details
|
|
755
755
|
10. **`pause-agent.ts`** - Pause agent by clearing all protocols
|
|
756
756
|
11. **`update-profile-with-protocols.ts`** - Configure user profile with protocols, chains, and advanced features
|
|
757
|
-
12. **`
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
757
|
+
12. **`customize-batch.ts`** - Configure specific pools for protocols across chains
|
|
758
|
+
13. **`get-tvl-volume.ts`** - Get TVL and trading volume
|
|
759
|
+
14. **`get-active-wallets.ts`** - Get active wallets by chain
|
|
760
|
+
15. **`get-smart-wallets-by-eoa.ts`** - Get smart wallets by EOA
|
|
761
|
+
16. **`get-first-topup.ts`** - Get first deposit information
|
|
762
|
+
17. **`get-history.ts`** - Get transaction history
|
|
762
763
|
|
|
763
764
|
### Analytics & Earnings
|
|
764
765
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
766
|
+
18. **`get-onchain-earnings.ts`** - Get/calculate onchain earnings
|
|
767
|
+
19. **`get-daily-earnings.ts`** - Get daily earnings breakdown
|
|
768
|
+
20. **`get-apy-history.ts`** - Get daily APY history with weighted averages
|
|
768
769
|
|
|
769
770
|
### Opportunities & Rebalancing
|
|
770
771
|
|
|
771
|
-
|
|
772
|
-
|
|
772
|
+
21. **`get-opportunities.ts`** - Get conservative and aggressive yield opportunities
|
|
773
|
+
22. **`get-rebalance-info.ts`** - Get rebalance events and frequency tier
|
|
773
774
|
|
|
774
775
|
### Premium Features
|
|
775
776
|
|
|
776
|
-
|
|
777
|
+
23. **`get-debank-portfolio.ts`** - Get Debank multi-chain portfolio
|
|
777
778
|
|
|
778
779
|
### Quick Start: Run the End-to-End Example
|
|
779
780
|
|
package/dist/index.d.mts
CHANGED
|
@@ -23,9 +23,7 @@ interface DeploySafeResponse {
|
|
|
23
23
|
}
|
|
24
24
|
/** @internal */
|
|
25
25
|
interface UpdateUserProfileRequest {
|
|
26
|
-
smartWallet?: string;
|
|
27
26
|
strategy?: string;
|
|
28
|
-
chains?: number[];
|
|
29
27
|
protocols?: string[];
|
|
30
28
|
autoSelectProtocols?: boolean;
|
|
31
29
|
omniAccount?: boolean;
|
|
@@ -448,6 +446,27 @@ interface RegisterAgentResponse {
|
|
|
448
446
|
chainId: number;
|
|
449
447
|
smartWallet: string;
|
|
450
448
|
}
|
|
449
|
+
interface CustomizationConfig {
|
|
450
|
+
protocolId: string;
|
|
451
|
+
pools: string[];
|
|
452
|
+
chainId: number;
|
|
453
|
+
autoselect: boolean;
|
|
454
|
+
}
|
|
455
|
+
interface CustomizeBatchRequest {
|
|
456
|
+
customizations: CustomizationConfig[];
|
|
457
|
+
}
|
|
458
|
+
interface CustomizeBatchResponse {
|
|
459
|
+
success: boolean;
|
|
460
|
+
}
|
|
461
|
+
interface GetPoolsResponse {
|
|
462
|
+
success: boolean;
|
|
463
|
+
pools: string[];
|
|
464
|
+
}
|
|
465
|
+
interface GetSelectedPoolsResponse {
|
|
466
|
+
success: boolean;
|
|
467
|
+
pools: string[];
|
|
468
|
+
autoselect: boolean;
|
|
469
|
+
}
|
|
451
470
|
interface PolicyData {
|
|
452
471
|
policy: Address;
|
|
453
472
|
initData: Hex;
|
|
@@ -1150,6 +1169,86 @@ declare class ZyfaiSDK {
|
|
|
1150
1169
|
* ```
|
|
1151
1170
|
*/
|
|
1152
1171
|
getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Configure protocol and pool customizations in batch.
|
|
1174
|
+
*
|
|
1175
|
+
* Allows granular control over which pools to use for each protocol on each chain.
|
|
1176
|
+
* This is useful for advanced users who want to target specific pools with desired APY/risk profiles.
|
|
1177
|
+
*
|
|
1178
|
+
* @param customizations - Array of customization configurations
|
|
1179
|
+
* @returns Response indicating success
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```typescript
|
|
1183
|
+
* // Configure multiple protocols across different chains
|
|
1184
|
+
* await sdk.customizeBatch([
|
|
1185
|
+
* {
|
|
1186
|
+
* protocolId: "protocol-uuid-1",
|
|
1187
|
+
* pools: ["USDC Pool", "WETH Pool"],
|
|
1188
|
+
* chainId: 8453, // Base
|
|
1189
|
+
* autoselect: false
|
|
1190
|
+
* },
|
|
1191
|
+
* {
|
|
1192
|
+
* protocolId: "protocol-uuid-1",
|
|
1193
|
+
* pools: ["USDC Vault"],
|
|
1194
|
+
* chainId: 42161, // Arbitrum
|
|
1195
|
+
* autoselect: false
|
|
1196
|
+
* },
|
|
1197
|
+
* {
|
|
1198
|
+
* protocolId: "protocol-uuid-2",
|
|
1199
|
+
* pools: [], // Empty array when autoselect is true
|
|
1200
|
+
* chainId: 8453,
|
|
1201
|
+
* autoselect: true // Let engine auto-select best pools
|
|
1202
|
+
* }
|
|
1203
|
+
* ]);
|
|
1204
|
+
* ```
|
|
1205
|
+
*/
|
|
1206
|
+
customizeBatch(customizations: CustomizationConfig[]): Promise<CustomizeBatchResponse>;
|
|
1207
|
+
/**
|
|
1208
|
+
* Get available pools for a protocol.
|
|
1209
|
+
*
|
|
1210
|
+
* Returns the list of pools available for a given protocol, optionally filtered by strategy.
|
|
1211
|
+
*
|
|
1212
|
+
* @param protocolId - The protocol UUID
|
|
1213
|
+
* @param strategy - Optional strategy filter ("conservative" or "aggressive")
|
|
1214
|
+
* @returns List of available pool names
|
|
1215
|
+
*
|
|
1216
|
+
* @example
|
|
1217
|
+
* ```typescript
|
|
1218
|
+
* // Get all available pools for a protocol
|
|
1219
|
+
* const pools = await sdk.getAvailablePools("protocol-uuid");
|
|
1220
|
+
* console.log("Available pools:", pools.pools);
|
|
1221
|
+
*
|
|
1222
|
+
* // Get pools for conservative strategy only
|
|
1223
|
+
* const conservativePools = await sdk.getAvailablePools(
|
|
1224
|
+
* "protocol-uuid",
|
|
1225
|
+
* "conservative"
|
|
1226
|
+
* );
|
|
1227
|
+
* ```
|
|
1228
|
+
*/
|
|
1229
|
+
getAvailablePools(protocolId: string, strategy?: "conservative" | "aggressive"): Promise<GetPoolsResponse>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Get currently selected pools for a protocol on a specific chain.
|
|
1232
|
+
*
|
|
1233
|
+
* Returns the pools that are currently configured for the authenticated user
|
|
1234
|
+
* for a given protocol and chain combination.
|
|
1235
|
+
*
|
|
1236
|
+
* @param protocolId - The protocol UUID
|
|
1237
|
+
* @param chainId - The chain ID
|
|
1238
|
+
* @returns Currently selected pools and autoselect status
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```typescript
|
|
1242
|
+
* const selected = await sdk.getSelectedPools(
|
|
1243
|
+
* "protocol-uuid",
|
|
1244
|
+
* 8453 // Base
|
|
1245
|
+
* );
|
|
1246
|
+
*
|
|
1247
|
+
* console.log("Selected pools:", selected.pools);
|
|
1248
|
+
* console.log("Autoselect enabled:", selected.autoselect);
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
getSelectedPools(protocolId: string, chainId: number): Promise<GetSelectedPoolsResponse>;
|
|
1153
1252
|
/**
|
|
1154
1253
|
* Supported chain IDs for the Identity Registry (ERC-8004)
|
|
1155
1254
|
*/
|
|
@@ -1180,4 +1279,4 @@ declare class ZyfaiSDK {
|
|
|
1180
1279
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1181
1280
|
}
|
|
1182
1281
|
|
|
1183
|
-
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 RegisterAgentResponse, 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 };
|
|
1282
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, 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 RegisterAgentResponse, 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
|
@@ -23,9 +23,7 @@ interface DeploySafeResponse {
|
|
|
23
23
|
}
|
|
24
24
|
/** @internal */
|
|
25
25
|
interface UpdateUserProfileRequest {
|
|
26
|
-
smartWallet?: string;
|
|
27
26
|
strategy?: string;
|
|
28
|
-
chains?: number[];
|
|
29
27
|
protocols?: string[];
|
|
30
28
|
autoSelectProtocols?: boolean;
|
|
31
29
|
omniAccount?: boolean;
|
|
@@ -448,6 +446,27 @@ interface RegisterAgentResponse {
|
|
|
448
446
|
chainId: number;
|
|
449
447
|
smartWallet: string;
|
|
450
448
|
}
|
|
449
|
+
interface CustomizationConfig {
|
|
450
|
+
protocolId: string;
|
|
451
|
+
pools: string[];
|
|
452
|
+
chainId: number;
|
|
453
|
+
autoselect: boolean;
|
|
454
|
+
}
|
|
455
|
+
interface CustomizeBatchRequest {
|
|
456
|
+
customizations: CustomizationConfig[];
|
|
457
|
+
}
|
|
458
|
+
interface CustomizeBatchResponse {
|
|
459
|
+
success: boolean;
|
|
460
|
+
}
|
|
461
|
+
interface GetPoolsResponse {
|
|
462
|
+
success: boolean;
|
|
463
|
+
pools: string[];
|
|
464
|
+
}
|
|
465
|
+
interface GetSelectedPoolsResponse {
|
|
466
|
+
success: boolean;
|
|
467
|
+
pools: string[];
|
|
468
|
+
autoselect: boolean;
|
|
469
|
+
}
|
|
451
470
|
interface PolicyData {
|
|
452
471
|
policy: Address;
|
|
453
472
|
initData: Hex;
|
|
@@ -1150,6 +1169,86 @@ declare class ZyfaiSDK {
|
|
|
1150
1169
|
* ```
|
|
1151
1170
|
*/
|
|
1152
1171
|
getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Configure protocol and pool customizations in batch.
|
|
1174
|
+
*
|
|
1175
|
+
* Allows granular control over which pools to use for each protocol on each chain.
|
|
1176
|
+
* This is useful for advanced users who want to target specific pools with desired APY/risk profiles.
|
|
1177
|
+
*
|
|
1178
|
+
* @param customizations - Array of customization configurations
|
|
1179
|
+
* @returns Response indicating success
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```typescript
|
|
1183
|
+
* // Configure multiple protocols across different chains
|
|
1184
|
+
* await sdk.customizeBatch([
|
|
1185
|
+
* {
|
|
1186
|
+
* protocolId: "protocol-uuid-1",
|
|
1187
|
+
* pools: ["USDC Pool", "WETH Pool"],
|
|
1188
|
+
* chainId: 8453, // Base
|
|
1189
|
+
* autoselect: false
|
|
1190
|
+
* },
|
|
1191
|
+
* {
|
|
1192
|
+
* protocolId: "protocol-uuid-1",
|
|
1193
|
+
* pools: ["USDC Vault"],
|
|
1194
|
+
* chainId: 42161, // Arbitrum
|
|
1195
|
+
* autoselect: false
|
|
1196
|
+
* },
|
|
1197
|
+
* {
|
|
1198
|
+
* protocolId: "protocol-uuid-2",
|
|
1199
|
+
* pools: [], // Empty array when autoselect is true
|
|
1200
|
+
* chainId: 8453,
|
|
1201
|
+
* autoselect: true // Let engine auto-select best pools
|
|
1202
|
+
* }
|
|
1203
|
+
* ]);
|
|
1204
|
+
* ```
|
|
1205
|
+
*/
|
|
1206
|
+
customizeBatch(customizations: CustomizationConfig[]): Promise<CustomizeBatchResponse>;
|
|
1207
|
+
/**
|
|
1208
|
+
* Get available pools for a protocol.
|
|
1209
|
+
*
|
|
1210
|
+
* Returns the list of pools available for a given protocol, optionally filtered by strategy.
|
|
1211
|
+
*
|
|
1212
|
+
* @param protocolId - The protocol UUID
|
|
1213
|
+
* @param strategy - Optional strategy filter ("conservative" or "aggressive")
|
|
1214
|
+
* @returns List of available pool names
|
|
1215
|
+
*
|
|
1216
|
+
* @example
|
|
1217
|
+
* ```typescript
|
|
1218
|
+
* // Get all available pools for a protocol
|
|
1219
|
+
* const pools = await sdk.getAvailablePools("protocol-uuid");
|
|
1220
|
+
* console.log("Available pools:", pools.pools);
|
|
1221
|
+
*
|
|
1222
|
+
* // Get pools for conservative strategy only
|
|
1223
|
+
* const conservativePools = await sdk.getAvailablePools(
|
|
1224
|
+
* "protocol-uuid",
|
|
1225
|
+
* "conservative"
|
|
1226
|
+
* );
|
|
1227
|
+
* ```
|
|
1228
|
+
*/
|
|
1229
|
+
getAvailablePools(protocolId: string, strategy?: "conservative" | "aggressive"): Promise<GetPoolsResponse>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Get currently selected pools for a protocol on a specific chain.
|
|
1232
|
+
*
|
|
1233
|
+
* Returns the pools that are currently configured for the authenticated user
|
|
1234
|
+
* for a given protocol and chain combination.
|
|
1235
|
+
*
|
|
1236
|
+
* @param protocolId - The protocol UUID
|
|
1237
|
+
* @param chainId - The chain ID
|
|
1238
|
+
* @returns Currently selected pools and autoselect status
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```typescript
|
|
1242
|
+
* const selected = await sdk.getSelectedPools(
|
|
1243
|
+
* "protocol-uuid",
|
|
1244
|
+
* 8453 // Base
|
|
1245
|
+
* );
|
|
1246
|
+
*
|
|
1247
|
+
* console.log("Selected pools:", selected.pools);
|
|
1248
|
+
* console.log("Autoselect enabled:", selected.autoselect);
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
getSelectedPools(protocolId: string, chainId: number): Promise<GetSelectedPoolsResponse>;
|
|
1153
1252
|
/**
|
|
1154
1253
|
* Supported chain IDs for the Identity Registry (ERC-8004)
|
|
1155
1254
|
*/
|
|
@@ -1180,4 +1279,4 @@ declare class ZyfaiSDK {
|
|
|
1180
1279
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1181
1280
|
}
|
|
1182
1281
|
|
|
1183
|
-
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 RegisterAgentResponse, 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 };
|
|
1282
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, 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 RegisterAgentResponse, 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
|
@@ -78,7 +78,11 @@ var ENDPOINTS = {
|
|
|
78
78
|
// Best Opportunity
|
|
79
79
|
BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
80
80
|
// Agent Identity Registry
|
|
81
|
-
AGENT_TOKEN_URI: "/users/me/agent-token-uri"
|
|
81
|
+
AGENT_TOKEN_URI: "/users/me/agent-token-uri",
|
|
82
|
+
// Customization
|
|
83
|
+
CUSTOMIZE_BATCH: "/customization/customize-batch",
|
|
84
|
+
CUSTOMIZATION_POOLS: (protocolId, strategy) => `/customization/pools?protocolId=${protocolId}${strategy ? `&strategy=${strategy}` : ""}`,
|
|
85
|
+
CUSTOMIZATION_SELECTED_POOLS: (protocolId, chainId) => `/customization/selected-pools?protocolId=${protocolId}&chainId=${chainId}`
|
|
82
86
|
};
|
|
83
87
|
var DATA_ENDPOINTS = {
|
|
84
88
|
// User Initialization
|
|
@@ -2595,6 +2599,134 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2595
2599
|
);
|
|
2596
2600
|
}
|
|
2597
2601
|
}
|
|
2602
|
+
// ============================================================================
|
|
2603
|
+
// Protocol/Pool Customization
|
|
2604
|
+
// ============================================================================
|
|
2605
|
+
/**
|
|
2606
|
+
* Configure protocol and pool customizations in batch.
|
|
2607
|
+
*
|
|
2608
|
+
* Allows granular control over which pools to use for each protocol on each chain.
|
|
2609
|
+
* This is useful for advanced users who want to target specific pools with desired APY/risk profiles.
|
|
2610
|
+
*
|
|
2611
|
+
* @param customizations - Array of customization configurations
|
|
2612
|
+
* @returns Response indicating success
|
|
2613
|
+
*
|
|
2614
|
+
* @example
|
|
2615
|
+
* ```typescript
|
|
2616
|
+
* // Configure multiple protocols across different chains
|
|
2617
|
+
* await sdk.customizeBatch([
|
|
2618
|
+
* {
|
|
2619
|
+
* protocolId: "protocol-uuid-1",
|
|
2620
|
+
* pools: ["USDC Pool", "WETH Pool"],
|
|
2621
|
+
* chainId: 8453, // Base
|
|
2622
|
+
* autoselect: false
|
|
2623
|
+
* },
|
|
2624
|
+
* {
|
|
2625
|
+
* protocolId: "protocol-uuid-1",
|
|
2626
|
+
* pools: ["USDC Vault"],
|
|
2627
|
+
* chainId: 42161, // Arbitrum
|
|
2628
|
+
* autoselect: false
|
|
2629
|
+
* },
|
|
2630
|
+
* {
|
|
2631
|
+
* protocolId: "protocol-uuid-2",
|
|
2632
|
+
* pools: [], // Empty array when autoselect is true
|
|
2633
|
+
* chainId: 8453,
|
|
2634
|
+
* autoselect: true // Let engine auto-select best pools
|
|
2635
|
+
* }
|
|
2636
|
+
* ]);
|
|
2637
|
+
* ```
|
|
2638
|
+
*/
|
|
2639
|
+
async customizeBatch(customizations) {
|
|
2640
|
+
try {
|
|
2641
|
+
await this.authenticateUser();
|
|
2642
|
+
const response = await this.httpClient.post(
|
|
2643
|
+
ENDPOINTS.CUSTOMIZE_BATCH,
|
|
2644
|
+
customizations
|
|
2645
|
+
);
|
|
2646
|
+
return response;
|
|
2647
|
+
} catch (error) {
|
|
2648
|
+
throw new Error(
|
|
2649
|
+
`Failed to save customizations: ${error.message}`
|
|
2650
|
+
);
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
/**
|
|
2654
|
+
* Get available pools for a protocol.
|
|
2655
|
+
*
|
|
2656
|
+
* Returns the list of pools available for a given protocol, optionally filtered by strategy.
|
|
2657
|
+
*
|
|
2658
|
+
* @param protocolId - The protocol UUID
|
|
2659
|
+
* @param strategy - Optional strategy filter ("conservative" or "aggressive")
|
|
2660
|
+
* @returns List of available pool names
|
|
2661
|
+
*
|
|
2662
|
+
* @example
|
|
2663
|
+
* ```typescript
|
|
2664
|
+
* // Get all available pools for a protocol
|
|
2665
|
+
* const pools = await sdk.getAvailablePools("protocol-uuid");
|
|
2666
|
+
* console.log("Available pools:", pools.pools);
|
|
2667
|
+
*
|
|
2668
|
+
* // Get pools for conservative strategy only
|
|
2669
|
+
* const conservativePools = await sdk.getAvailablePools(
|
|
2670
|
+
* "protocol-uuid",
|
|
2671
|
+
* "conservative"
|
|
2672
|
+
* );
|
|
2673
|
+
* ```
|
|
2674
|
+
*/
|
|
2675
|
+
async getAvailablePools(protocolId, strategy) {
|
|
2676
|
+
try {
|
|
2677
|
+
let internalStrategy;
|
|
2678
|
+
if (strategy) {
|
|
2679
|
+
if (!isValidPublicStrategy(strategy)) {
|
|
2680
|
+
throw new Error(
|
|
2681
|
+
`Invalid strategy: ${strategy}. Must be "conservative" or "aggressive".`
|
|
2682
|
+
);
|
|
2683
|
+
}
|
|
2684
|
+
internalStrategy = toInternalStrategy(strategy);
|
|
2685
|
+
}
|
|
2686
|
+
const response = await this.httpClient.get(
|
|
2687
|
+
ENDPOINTS.CUSTOMIZATION_POOLS(protocolId, internalStrategy)
|
|
2688
|
+
);
|
|
2689
|
+
return response;
|
|
2690
|
+
} catch (error) {
|
|
2691
|
+
throw new Error(
|
|
2692
|
+
`Failed to get available pools: ${error.message}`
|
|
2693
|
+
);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
/**
|
|
2697
|
+
* Get currently selected pools for a protocol on a specific chain.
|
|
2698
|
+
*
|
|
2699
|
+
* Returns the pools that are currently configured for the authenticated user
|
|
2700
|
+
* for a given protocol and chain combination.
|
|
2701
|
+
*
|
|
2702
|
+
* @param protocolId - The protocol UUID
|
|
2703
|
+
* @param chainId - The chain ID
|
|
2704
|
+
* @returns Currently selected pools and autoselect status
|
|
2705
|
+
*
|
|
2706
|
+
* @example
|
|
2707
|
+
* ```typescript
|
|
2708
|
+
* const selected = await sdk.getSelectedPools(
|
|
2709
|
+
* "protocol-uuid",
|
|
2710
|
+
* 8453 // Base
|
|
2711
|
+
* );
|
|
2712
|
+
*
|
|
2713
|
+
* console.log("Selected pools:", selected.pools);
|
|
2714
|
+
* console.log("Autoselect enabled:", selected.autoselect);
|
|
2715
|
+
* ```
|
|
2716
|
+
*/
|
|
2717
|
+
async getSelectedPools(protocolId, chainId) {
|
|
2718
|
+
try {
|
|
2719
|
+
await this.authenticateUser();
|
|
2720
|
+
const response = await this.httpClient.get(
|
|
2721
|
+
ENDPOINTS.CUSTOMIZATION_SELECTED_POOLS(protocolId, chainId)
|
|
2722
|
+
);
|
|
2723
|
+
return response;
|
|
2724
|
+
} catch (error) {
|
|
2725
|
+
throw new Error(
|
|
2726
|
+
`Failed to get selected pools: ${error.message}`
|
|
2727
|
+
);
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2598
2730
|
/**
|
|
2599
2731
|
* Check if a chain ID supports the Identity Registry
|
|
2600
2732
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -37,7 +37,11 @@ var ENDPOINTS = {
|
|
|
37
37
|
// Best Opportunity
|
|
38
38
|
BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
39
39
|
// Agent Identity Registry
|
|
40
|
-
AGENT_TOKEN_URI: "/users/me/agent-token-uri"
|
|
40
|
+
AGENT_TOKEN_URI: "/users/me/agent-token-uri",
|
|
41
|
+
// Customization
|
|
42
|
+
CUSTOMIZE_BATCH: "/customization/customize-batch",
|
|
43
|
+
CUSTOMIZATION_POOLS: (protocolId, strategy) => `/customization/pools?protocolId=${protocolId}${strategy ? `&strategy=${strategy}` : ""}`,
|
|
44
|
+
CUSTOMIZATION_SELECTED_POOLS: (protocolId, chainId) => `/customization/selected-pools?protocolId=${protocolId}&chainId=${chainId}`
|
|
41
45
|
};
|
|
42
46
|
var DATA_ENDPOINTS = {
|
|
43
47
|
// User Initialization
|
|
@@ -2573,6 +2577,134 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2573
2577
|
);
|
|
2574
2578
|
}
|
|
2575
2579
|
}
|
|
2580
|
+
// ============================================================================
|
|
2581
|
+
// Protocol/Pool Customization
|
|
2582
|
+
// ============================================================================
|
|
2583
|
+
/**
|
|
2584
|
+
* Configure protocol and pool customizations in batch.
|
|
2585
|
+
*
|
|
2586
|
+
* Allows granular control over which pools to use for each protocol on each chain.
|
|
2587
|
+
* This is useful for advanced users who want to target specific pools with desired APY/risk profiles.
|
|
2588
|
+
*
|
|
2589
|
+
* @param customizations - Array of customization configurations
|
|
2590
|
+
* @returns Response indicating success
|
|
2591
|
+
*
|
|
2592
|
+
* @example
|
|
2593
|
+
* ```typescript
|
|
2594
|
+
* // Configure multiple protocols across different chains
|
|
2595
|
+
* await sdk.customizeBatch([
|
|
2596
|
+
* {
|
|
2597
|
+
* protocolId: "protocol-uuid-1",
|
|
2598
|
+
* pools: ["USDC Pool", "WETH Pool"],
|
|
2599
|
+
* chainId: 8453, // Base
|
|
2600
|
+
* autoselect: false
|
|
2601
|
+
* },
|
|
2602
|
+
* {
|
|
2603
|
+
* protocolId: "protocol-uuid-1",
|
|
2604
|
+
* pools: ["USDC Vault"],
|
|
2605
|
+
* chainId: 42161, // Arbitrum
|
|
2606
|
+
* autoselect: false
|
|
2607
|
+
* },
|
|
2608
|
+
* {
|
|
2609
|
+
* protocolId: "protocol-uuid-2",
|
|
2610
|
+
* pools: [], // Empty array when autoselect is true
|
|
2611
|
+
* chainId: 8453,
|
|
2612
|
+
* autoselect: true // Let engine auto-select best pools
|
|
2613
|
+
* }
|
|
2614
|
+
* ]);
|
|
2615
|
+
* ```
|
|
2616
|
+
*/
|
|
2617
|
+
async customizeBatch(customizations) {
|
|
2618
|
+
try {
|
|
2619
|
+
await this.authenticateUser();
|
|
2620
|
+
const response = await this.httpClient.post(
|
|
2621
|
+
ENDPOINTS.CUSTOMIZE_BATCH,
|
|
2622
|
+
customizations
|
|
2623
|
+
);
|
|
2624
|
+
return response;
|
|
2625
|
+
} catch (error) {
|
|
2626
|
+
throw new Error(
|
|
2627
|
+
`Failed to save customizations: ${error.message}`
|
|
2628
|
+
);
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
/**
|
|
2632
|
+
* Get available pools for a protocol.
|
|
2633
|
+
*
|
|
2634
|
+
* Returns the list of pools available for a given protocol, optionally filtered by strategy.
|
|
2635
|
+
*
|
|
2636
|
+
* @param protocolId - The protocol UUID
|
|
2637
|
+
* @param strategy - Optional strategy filter ("conservative" or "aggressive")
|
|
2638
|
+
* @returns List of available pool names
|
|
2639
|
+
*
|
|
2640
|
+
* @example
|
|
2641
|
+
* ```typescript
|
|
2642
|
+
* // Get all available pools for a protocol
|
|
2643
|
+
* const pools = await sdk.getAvailablePools("protocol-uuid");
|
|
2644
|
+
* console.log("Available pools:", pools.pools);
|
|
2645
|
+
*
|
|
2646
|
+
* // Get pools for conservative strategy only
|
|
2647
|
+
* const conservativePools = await sdk.getAvailablePools(
|
|
2648
|
+
* "protocol-uuid",
|
|
2649
|
+
* "conservative"
|
|
2650
|
+
* );
|
|
2651
|
+
* ```
|
|
2652
|
+
*/
|
|
2653
|
+
async getAvailablePools(protocolId, strategy) {
|
|
2654
|
+
try {
|
|
2655
|
+
let internalStrategy;
|
|
2656
|
+
if (strategy) {
|
|
2657
|
+
if (!isValidPublicStrategy(strategy)) {
|
|
2658
|
+
throw new Error(
|
|
2659
|
+
`Invalid strategy: ${strategy}. Must be "conservative" or "aggressive".`
|
|
2660
|
+
);
|
|
2661
|
+
}
|
|
2662
|
+
internalStrategy = toInternalStrategy(strategy);
|
|
2663
|
+
}
|
|
2664
|
+
const response = await this.httpClient.get(
|
|
2665
|
+
ENDPOINTS.CUSTOMIZATION_POOLS(protocolId, internalStrategy)
|
|
2666
|
+
);
|
|
2667
|
+
return response;
|
|
2668
|
+
} catch (error) {
|
|
2669
|
+
throw new Error(
|
|
2670
|
+
`Failed to get available pools: ${error.message}`
|
|
2671
|
+
);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
/**
|
|
2675
|
+
* Get currently selected pools for a protocol on a specific chain.
|
|
2676
|
+
*
|
|
2677
|
+
* Returns the pools that are currently configured for the authenticated user
|
|
2678
|
+
* for a given protocol and chain combination.
|
|
2679
|
+
*
|
|
2680
|
+
* @param protocolId - The protocol UUID
|
|
2681
|
+
* @param chainId - The chain ID
|
|
2682
|
+
* @returns Currently selected pools and autoselect status
|
|
2683
|
+
*
|
|
2684
|
+
* @example
|
|
2685
|
+
* ```typescript
|
|
2686
|
+
* const selected = await sdk.getSelectedPools(
|
|
2687
|
+
* "protocol-uuid",
|
|
2688
|
+
* 8453 // Base
|
|
2689
|
+
* );
|
|
2690
|
+
*
|
|
2691
|
+
* console.log("Selected pools:", selected.pools);
|
|
2692
|
+
* console.log("Autoselect enabled:", selected.autoselect);
|
|
2693
|
+
* ```
|
|
2694
|
+
*/
|
|
2695
|
+
async getSelectedPools(protocolId, chainId) {
|
|
2696
|
+
try {
|
|
2697
|
+
await this.authenticateUser();
|
|
2698
|
+
const response = await this.httpClient.get(
|
|
2699
|
+
ENDPOINTS.CUSTOMIZATION_SELECTED_POOLS(protocolId, chainId)
|
|
2700
|
+
);
|
|
2701
|
+
return response;
|
|
2702
|
+
} catch (error) {
|
|
2703
|
+
throw new Error(
|
|
2704
|
+
`Failed to get selected pools: ${error.message}`
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2576
2708
|
/**
|
|
2577
2709
|
* Check if a chain ID supports the Identity Registry
|
|
2578
2710
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
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",
|