@zyfai/sdk 0.2.22 → 0.2.24
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 +60 -10
- package/dist/index.d.mts +145 -114
- package/dist/index.d.ts +145 -114
- package/dist/index.js +327 -192
- package/dist/index.mjs +327 -192
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -385,6 +385,43 @@ if (result.success) {
|
|
|
385
385
|
- Token address is automatically selected based on chain (USDC for Base/Arbitrum, USDT for Plasma)
|
|
386
386
|
- The SDK automatically authenticates via SIWE before logging the deposit with Zyfai's API, so no extra steps are required on your end once the transfer confirms
|
|
387
387
|
|
|
388
|
+
#### Log External Deposit (For Sponsored Transactions)
|
|
389
|
+
|
|
390
|
+
If you execute deposits client-side (e.g., with Privy, Biconomy, or other sponsored/gasless transaction providers), use `logDeposit` to register the deposit with Zyfai's backend:
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
// 1. Execute deposit with your own wallet implementation (e.g., Privy)
|
|
394
|
+
const txHash = await privyWallet.sendTransaction({
|
|
395
|
+
to: safeAddress,
|
|
396
|
+
data: transferData, // ERC20 transfer encoded data
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// 2. Log the deposit to Zyfai backend for tracking and yield optimization
|
|
400
|
+
const result = await sdk.logDeposit(
|
|
401
|
+
8453, // chainId
|
|
402
|
+
txHash, // transaction hash from your wallet
|
|
403
|
+
"100000000" // 100 USDC (6 decimals)
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
if (result.success) {
|
|
407
|
+
console.log("Deposit logged successfully");
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**When to use `logDeposit`:**
|
|
412
|
+
|
|
413
|
+
- You use sponsored/gasless transactions (Privy, Biconomy, Gelato, etc.)
|
|
414
|
+
- You have a custom wallet implementation
|
|
415
|
+
- You need more control over transaction execution
|
|
416
|
+
- You want to pay gas fees for your users
|
|
417
|
+
|
|
418
|
+
**Parameters:**
|
|
419
|
+
|
|
420
|
+
- `chainId`: Chain ID where the deposit was made
|
|
421
|
+
- `txHash`: Transaction hash of the deposit (must start with "0x")
|
|
422
|
+
- `amount`: Amount in least decimal units
|
|
423
|
+
- `tokenAddress` (optional): Token address (auto-selected based on chain if not provided)
|
|
424
|
+
|
|
388
425
|
### 5. Withdraw Funds
|
|
389
426
|
|
|
390
427
|
Initiate a withdrawal from your Safe. **Note: Withdrawals are processed asynchronously by the backend.**
|
|
@@ -645,36 +682,47 @@ history.data.forEach((tx) => console.log(tx.type, tx.amount));
|
|
|
645
682
|
|
|
646
683
|
#### Get Onchain Earnings
|
|
647
684
|
|
|
685
|
+
Earnings are returned per-token (multi-asset support).
|
|
686
|
+
|
|
648
687
|
```typescript
|
|
649
688
|
const earnings = await sdk.getOnchainEarnings(walletAddress);
|
|
650
|
-
|
|
651
|
-
console.log("
|
|
652
|
-
console.log("Lifetime
|
|
689
|
+
// Per-token earnings: { "USDC": "0.020667", "WETH": "0.000009" }
|
|
690
|
+
console.log("Total by token:", earnings.data.totalEarningsByToken);
|
|
691
|
+
console.log("Lifetime by token:", earnings.data.lifetimeEarningsByToken);
|
|
692
|
+
console.log("By chain:", earnings.data.currentEarningsByChain);
|
|
653
693
|
```
|
|
654
694
|
|
|
655
695
|
#### Calculate Onchain Earnings (Refresh)
|
|
656
696
|
|
|
657
697
|
```typescript
|
|
658
698
|
const updated = await sdk.calculateOnchainEarnings(walletAddress);
|
|
659
|
-
console.log("Updated earnings:", updated.data.
|
|
699
|
+
console.log("Updated earnings:", updated.data.totalEarningsByToken);
|
|
660
700
|
```
|
|
661
701
|
|
|
662
702
|
#### Get Daily Earnings
|
|
663
703
|
|
|
704
|
+
Daily earnings snapshots with per-token breakdowns.
|
|
705
|
+
|
|
664
706
|
```typescript
|
|
665
707
|
const daily = await sdk.getDailyEarnings(
|
|
666
708
|
walletAddress,
|
|
667
709
|
"2024-01-01",
|
|
668
710
|
"2024-01-31"
|
|
669
711
|
);
|
|
670
|
-
daily.data.forEach((d) =>
|
|
712
|
+
daily.data.forEach((d) => {
|
|
713
|
+
console.log(d.snapshot_date, d.total_earnings_by_token);
|
|
714
|
+
});
|
|
671
715
|
```
|
|
672
716
|
|
|
673
717
|
#### Get Daily APY History
|
|
674
718
|
|
|
719
|
+
Returns per-position APY breakdowns with per-token weighted averages.
|
|
720
|
+
|
|
675
721
|
```typescript
|
|
676
722
|
const apyHistory = await sdk.getDailyApyHistory(walletAddress, "30D");
|
|
677
|
-
|
|
723
|
+
// Per-token weighted APY: { "USDC": 4.64, "WETH": 1.94 }
|
|
724
|
+
console.log("Weighted APY after fee:", apyHistory.weightedApyAfterFee);
|
|
725
|
+
// Each date entry has positions (with tokenSymbol), and per-token weighted_apy, fee, etc.
|
|
678
726
|
```
|
|
679
727
|
|
|
680
728
|
### 10. Opportunities & Strategies
|
|
@@ -682,7 +730,8 @@ console.log("Average Weighted APY:", apyHistory.averageWeightedApy);
|
|
|
682
730
|
#### Get Conservative Opportunities (Low Risk)
|
|
683
731
|
|
|
684
732
|
```typescript
|
|
685
|
-
|
|
733
|
+
// Filter by chain and/or asset
|
|
734
|
+
const conservativeOpps = await sdk.getConservativeOpportunities(8453, "USDC");
|
|
686
735
|
conservativeOpps.data.forEach((o) => {
|
|
687
736
|
console.log(`${o.protocolName} - ${o.poolName}: ${o.apy}% APY`);
|
|
688
737
|
});
|
|
@@ -691,7 +740,8 @@ conservativeOpps.data.forEach((o) => {
|
|
|
691
740
|
#### Get Aggressive Opportunities (High Risk)
|
|
692
741
|
|
|
693
742
|
```typescript
|
|
694
|
-
|
|
743
|
+
// Filter by chain and/or asset
|
|
744
|
+
const aggressiveOpps = await sdk.getAggressiveOpportunities(8453, "WETH");
|
|
695
745
|
aggressiveOpps.data.forEach((o) => {
|
|
696
746
|
console.log(`${o.protocolName} - ${o.poolName}: ${o.apy}% APY`);
|
|
697
747
|
});
|
|
@@ -702,8 +752,8 @@ aggressiveOpps.data.forEach((o) => {
|
|
|
702
752
|
#### Get APY Per Strategy
|
|
703
753
|
|
|
704
754
|
```typescript
|
|
705
|
-
// Get same-chain rebalances
|
|
706
|
-
const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative");
|
|
755
|
+
// Get same-chain rebalances, optionally filter by chainId and tokenSymbol
|
|
756
|
+
const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative", 8453, "USDC");
|
|
707
757
|
console.log("APY per strategy:", apyPerStrategy.data);
|
|
708
758
|
```
|
|
709
759
|
|
package/dist/index.d.mts
CHANGED
|
@@ -28,17 +28,16 @@ interface UpdateUserProfileRequest {
|
|
|
28
28
|
protocols?: string[];
|
|
29
29
|
autoSelectProtocols?: boolean;
|
|
30
30
|
omniAccount?: boolean;
|
|
31
|
+
chains?: number[];
|
|
31
32
|
autocompounding?: boolean;
|
|
32
33
|
agentName?: string;
|
|
33
34
|
crosschainStrategy?: boolean;
|
|
34
35
|
splitting?: boolean;
|
|
35
36
|
minSplits?: number;
|
|
36
|
-
|
|
37
|
+
asset?: "usdc" | "eth";
|
|
37
38
|
}
|
|
38
|
-
/** @internal */
|
|
39
39
|
interface UpdateUserProfileResponse {
|
|
40
40
|
success: boolean;
|
|
41
|
-
userId: string;
|
|
42
41
|
smartWallet?: Address;
|
|
43
42
|
chains?: number[];
|
|
44
43
|
strategy?: string;
|
|
@@ -49,9 +48,11 @@ interface UpdateUserProfileResponse {
|
|
|
49
48
|
agentName?: string;
|
|
50
49
|
crosschainStrategy?: boolean;
|
|
51
50
|
executorProxy?: boolean;
|
|
51
|
+
hasActiveSessionKey?: boolean;
|
|
52
52
|
splitting?: boolean;
|
|
53
53
|
minSplits?: number;
|
|
54
54
|
customization?: Record<string, any>;
|
|
55
|
+
asset?: "usdc" | "eth";
|
|
55
56
|
}
|
|
56
57
|
/** @internal */
|
|
57
58
|
interface AddSessionKeyResponse {
|
|
@@ -129,6 +130,19 @@ interface Portfolio {
|
|
|
129
130
|
splitting?: boolean;
|
|
130
131
|
minSplits?: number;
|
|
131
132
|
executorProxy?: boolean;
|
|
133
|
+
assetTypeSettings?: AssetTypeSettings;
|
|
134
|
+
}
|
|
135
|
+
interface AssetTypeSettings {
|
|
136
|
+
[assetType: string]: {
|
|
137
|
+
rebalanceStrategy?: string;
|
|
138
|
+
autocompounding?: boolean;
|
|
139
|
+
crosschainStrategy?: boolean;
|
|
140
|
+
splitting?: boolean;
|
|
141
|
+
minSplits?: number;
|
|
142
|
+
chains?: number[];
|
|
143
|
+
autoSelectProtocols?: boolean;
|
|
144
|
+
protocols?: string[];
|
|
145
|
+
};
|
|
132
146
|
}
|
|
133
147
|
interface PositionSlot {
|
|
134
148
|
chain?: string;
|
|
@@ -149,44 +163,9 @@ interface PortfolioResponse {
|
|
|
149
163
|
userAddress: string;
|
|
150
164
|
portfolio: Portfolio;
|
|
151
165
|
}
|
|
152
|
-
interface UserDetails {
|
|
153
|
-
id: string;
|
|
154
|
-
address: string;
|
|
155
|
-
smartWallet: string;
|
|
156
|
-
chains: number[];
|
|
157
|
-
protocols: Protocol[];
|
|
158
|
-
hasActiveSessionKey: boolean;
|
|
159
|
-
email?: string;
|
|
160
|
-
strategy?: string;
|
|
161
|
-
telegramId?: string;
|
|
162
|
-
walletType?: string;
|
|
163
|
-
autoSelectProtocols: boolean;
|
|
164
|
-
autocompounding?: boolean;
|
|
165
|
-
omniAccount?: boolean;
|
|
166
|
-
crosschainStrategy?: boolean;
|
|
167
|
-
agentName?: string;
|
|
168
|
-
customization?: Record<string, any>;
|
|
169
|
-
executorProxy?: boolean;
|
|
170
|
-
splitting?: boolean;
|
|
171
|
-
minSplits?: number;
|
|
172
|
-
registered?: boolean;
|
|
173
|
-
}
|
|
174
|
-
interface UserDetailsResponse {
|
|
175
|
-
success: boolean;
|
|
176
|
-
user: UserDetails;
|
|
177
|
-
}
|
|
178
|
-
interface TVLBreakdown {
|
|
179
|
-
chain_id: number;
|
|
180
|
-
protocol_id: string | null;
|
|
181
|
-
protocol_name: string | null;
|
|
182
|
-
pool: string | null;
|
|
183
|
-
total_balance: number;
|
|
184
|
-
}
|
|
185
166
|
interface TVLResponse {
|
|
186
167
|
success: boolean;
|
|
187
168
|
totalTvl: number;
|
|
188
|
-
byChain?: Record<number, number>;
|
|
189
|
-
breakdown?: TVLBreakdown[];
|
|
190
169
|
}
|
|
191
170
|
interface APYPerStrategy {
|
|
192
171
|
id: string;
|
|
@@ -201,8 +180,12 @@ interface APYPerStrategy {
|
|
|
201
180
|
total_rebalances: number;
|
|
202
181
|
created_at: string;
|
|
203
182
|
strategy: string;
|
|
183
|
+
token_symbol?: string;
|
|
204
184
|
average_apy_with_fee: number;
|
|
205
185
|
average_apy_with_rzfi_with_fee: number;
|
|
186
|
+
average_apy_without_fee?: number;
|
|
187
|
+
average_apy_with_rzfi_without_fee?: number;
|
|
188
|
+
events_average_apy?: Record<string, number>;
|
|
206
189
|
}
|
|
207
190
|
interface APYPerStrategyResponse {
|
|
208
191
|
success: boolean;
|
|
@@ -271,15 +254,15 @@ interface HistoryResponse {
|
|
|
271
254
|
data: HistoryEntry[];
|
|
272
255
|
total: number;
|
|
273
256
|
}
|
|
257
|
+
type TokenEarnings = Record<string, string>;
|
|
274
258
|
interface OnchainEarnings {
|
|
275
259
|
walletAddress: string;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
unrealizedEarnings
|
|
280
|
-
currentEarningsByChain?: Record<string, number>;
|
|
281
|
-
unrealizedEarningsByChain?: Record<string, number>;
|
|
260
|
+
totalEarningsByToken: TokenEarnings;
|
|
261
|
+
lifetimeEarningsByToken: TokenEarnings;
|
|
262
|
+
currentEarningsByChain: Record<string, TokenEarnings>;
|
|
263
|
+
unrealizedEarnings: Record<string, TokenEarnings>;
|
|
282
264
|
lastCheckTimestamp?: string;
|
|
265
|
+
lastLogDate?: Record<string, string | null>;
|
|
283
266
|
}
|
|
284
267
|
interface OnchainEarningsResponse {
|
|
285
268
|
success: boolean;
|
|
@@ -288,14 +271,14 @@ interface OnchainEarningsResponse {
|
|
|
288
271
|
interface DailyEarning {
|
|
289
272
|
wallet_address?: string;
|
|
290
273
|
snapshot_date: string;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
274
|
+
current_earnings_by_token: TokenEarnings;
|
|
275
|
+
lifetime_earnings_by_token: TokenEarnings;
|
|
276
|
+
unrealized_earnings_by_token: TokenEarnings;
|
|
277
|
+
total_earnings_by_token: TokenEarnings;
|
|
278
|
+
daily_current_delta_by_token: TokenEarnings;
|
|
279
|
+
daily_lifetime_delta_by_token: TokenEarnings;
|
|
280
|
+
daily_unrealized_delta_by_token: TokenEarnings;
|
|
281
|
+
daily_total_delta_by_token: TokenEarnings;
|
|
299
282
|
created_at?: string;
|
|
300
283
|
}
|
|
301
284
|
interface DailyEarningsResponse {
|
|
@@ -345,13 +328,23 @@ interface OpportunitiesResponse {
|
|
|
345
328
|
strategyType: "conservative" | "aggressive";
|
|
346
329
|
data: Opportunity[];
|
|
347
330
|
}
|
|
348
|
-
interface
|
|
349
|
-
date: string;
|
|
331
|
+
interface ApyPosition {
|
|
350
332
|
apy: number;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
protocol
|
|
354
|
-
pool
|
|
333
|
+
balance: number;
|
|
334
|
+
chainId: number;
|
|
335
|
+
protocol: string;
|
|
336
|
+
pool: string;
|
|
337
|
+
strategy: string;
|
|
338
|
+
tokenSymbol?: string;
|
|
339
|
+
}
|
|
340
|
+
type TokenApy = Record<string, number>;
|
|
341
|
+
interface DailyApyEntry {
|
|
342
|
+
positions: ApyPosition[];
|
|
343
|
+
weighted_apy: TokenApy;
|
|
344
|
+
fee: TokenApy;
|
|
345
|
+
weighted_apy_after_fee: TokenApy;
|
|
346
|
+
rzfi_merkl_apr: TokenApy;
|
|
347
|
+
final_weighted_apy: TokenApy;
|
|
355
348
|
}
|
|
356
349
|
interface DailyApyHistoryResponse {
|
|
357
350
|
success: boolean;
|
|
@@ -359,8 +352,8 @@ interface DailyApyHistoryResponse {
|
|
|
359
352
|
history: Record<string, DailyApyEntry>;
|
|
360
353
|
totalDays: number;
|
|
361
354
|
requestedDays?: number;
|
|
362
|
-
weightedApyWithRzfiAfterFee?:
|
|
363
|
-
weightedApyAfterFee?:
|
|
355
|
+
weightedApyWithRzfiAfterFee?: TokenApy;
|
|
356
|
+
weightedApyAfterFee?: TokenApy;
|
|
364
357
|
}
|
|
365
358
|
interface RebalanceFrequencyResponse {
|
|
366
359
|
success: boolean;
|
|
@@ -375,6 +368,10 @@ interface DepositResponse {
|
|
|
375
368
|
smartWallet: string;
|
|
376
369
|
amount: string;
|
|
377
370
|
}
|
|
371
|
+
interface LogDepositResponse {
|
|
372
|
+
success: boolean;
|
|
373
|
+
message: string;
|
|
374
|
+
}
|
|
378
375
|
interface WithdrawResponse {
|
|
379
376
|
success: boolean;
|
|
380
377
|
message: string;
|
|
@@ -512,7 +509,7 @@ interface ChainConfig {
|
|
|
512
509
|
publicClient: PublicClient;
|
|
513
510
|
}
|
|
514
511
|
declare const DEFAULT_TOKEN_ADDRESSES: Record<SupportedChainId, string>;
|
|
515
|
-
declare const getDefaultTokenAddress: (chainId: SupportedChainId) => string;
|
|
512
|
+
declare const getDefaultTokenAddress: (chainId: SupportedChainId, asset?: string) => string;
|
|
516
513
|
/**
|
|
517
514
|
* Get chain configuration for a given chain ID.
|
|
518
515
|
*
|
|
@@ -588,23 +585,23 @@ declare class ZyfaiSDK {
|
|
|
588
585
|
*/
|
|
589
586
|
pauseAgent(): Promise<UpdateUserProfileResponse>;
|
|
590
587
|
/**
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
588
|
+
* Resume the agent by restoring protocols based on user's strategy for each asset
|
|
589
|
+
* Fetches available protocols and assigns them based on each asset's strategy
|
|
590
|
+
*
|
|
591
|
+
* @returns Response indicating success and updated user details
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```typescript
|
|
595
|
+
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
596
|
+
*
|
|
597
|
+
* // Connect account first
|
|
598
|
+
* await sdk.connectAccount();
|
|
599
|
+
*
|
|
600
|
+
* // Resume the agent
|
|
601
|
+
* const result = await sdk.resumeAgent();
|
|
602
|
+
* console.log('Agent resumed:', result.success);
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
608
605
|
resumeAgent(): Promise<UpdateUserProfileResponse>;
|
|
609
606
|
/**
|
|
610
607
|
* Enable splitting for the user's account
|
|
@@ -807,7 +804,47 @@ declare class ZyfaiSDK {
|
|
|
807
804
|
* );
|
|
808
805
|
* ```
|
|
809
806
|
*/
|
|
810
|
-
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string): Promise<DepositResponse>;
|
|
807
|
+
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string, asset?: string): Promise<DepositResponse>;
|
|
808
|
+
/**
|
|
809
|
+
* Log a deposit that was executed client-side
|
|
810
|
+
*
|
|
811
|
+
* Use this method when you execute the deposit transaction yourself (e.g., with Privy,
|
|
812
|
+
* sponsored transactions, or any custom wallet implementation) and need to register
|
|
813
|
+
* the deposit with the Zyfai backend for tracking and yield optimization.
|
|
814
|
+
*
|
|
815
|
+
* This is useful for partners who:
|
|
816
|
+
* - Use sponsored/gasless transactions (Privy, Biconomy, etc.)
|
|
817
|
+
* - Have custom wallet implementations
|
|
818
|
+
* - Need more control over transaction execution
|
|
819
|
+
*
|
|
820
|
+
* Token is automatically selected based on chain if not provided:
|
|
821
|
+
* - Base (8453) and Arbitrum (42161): USDC
|
|
822
|
+
* - Plasma (9745): USDT
|
|
823
|
+
*
|
|
824
|
+
* @param chainId - Chain ID where the deposit was made
|
|
825
|
+
* @param txHash - Transaction hash of the deposit
|
|
826
|
+
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
827
|
+
* @param tokenAddress - Optional: Token address (auto-selected based on chain if not provided)
|
|
828
|
+
* @returns Log deposit response with success status
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```typescript
|
|
832
|
+
* // Execute deposit with Privy (sponsored transaction)
|
|
833
|
+
* const txHash = await privyWallet.sendTransaction({
|
|
834
|
+
* to: safeAddress,
|
|
835
|
+
* data: transferData,
|
|
836
|
+
* });
|
|
837
|
+
*
|
|
838
|
+
* // Log the deposit to Zyfai backend
|
|
839
|
+
* const result = await sdk.logDeposit(
|
|
840
|
+
* 8453, // chainId
|
|
841
|
+
* txHash, // transaction hash from Privy
|
|
842
|
+
* "100000000" // 100 USDC
|
|
843
|
+
* );
|
|
844
|
+
* console.log(result.success); // true
|
|
845
|
+
* ```
|
|
846
|
+
*/
|
|
847
|
+
logDeposit(chainId: SupportedChainId, txHash: string, amount: string, tokenAddress?: string): Promise<LogDepositResponse>;
|
|
811
848
|
/**
|
|
812
849
|
* Withdraw funds from Safe smart wallet
|
|
813
850
|
* Initiates a withdrawal request to the Zyfai API
|
|
@@ -833,7 +870,7 @@ declare class ZyfaiSDK {
|
|
|
833
870
|
* );
|
|
834
871
|
* ```
|
|
835
872
|
*/
|
|
836
|
-
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string): Promise<WithdrawResponse>;
|
|
873
|
+
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string, tokenSymbol?: string): Promise<WithdrawResponse>;
|
|
837
874
|
/**
|
|
838
875
|
* Get available DeFi protocols and pools for a specific chain
|
|
839
876
|
*
|
|
@@ -880,7 +917,7 @@ declare class ZyfaiSDK {
|
|
|
880
917
|
* console.log("Chains:", user.user.chains);
|
|
881
918
|
* ```
|
|
882
919
|
*/
|
|
883
|
-
getUserDetails(): Promise<
|
|
920
|
+
getUserDetails(asset?: "usdc" | "eth"): Promise<UpdateUserProfileResponse>;
|
|
884
921
|
/**
|
|
885
922
|
* Get total value locked (TVL) across all Zyfai accounts
|
|
886
923
|
*
|
|
@@ -899,15 +936,17 @@ declare class ZyfaiSDK {
|
|
|
899
936
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
900
937
|
* @param days - Time period: 7, 14, or 30
|
|
901
938
|
* @param strategy - Strategy type: "conservative" (default) or "aggressive"
|
|
939
|
+
* @param chainId - Optional chain ID filter
|
|
940
|
+
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
902
941
|
* @returns APY per strategy for a specific chain
|
|
903
942
|
*
|
|
904
943
|
* @example
|
|
905
944
|
* ```typescript
|
|
906
|
-
* const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative");
|
|
945
|
+
* const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative", 8453, "USDC");
|
|
907
946
|
* console.log("APY per strategy per chain:", apyPerStrategy.data);
|
|
908
947
|
* ```
|
|
909
948
|
*/
|
|
910
|
-
getAPYPerStrategy(crossChain?: boolean, days?: number, strategy?: Strategy): Promise<APYPerStrategyResponse>;
|
|
949
|
+
getAPYPerStrategy(crossChain?: boolean, days?: number, strategy?: Strategy, chainId?: number, tokenSymbol?: string): Promise<APYPerStrategyResponse>;
|
|
911
950
|
/**
|
|
912
951
|
* Get total volume across all Zyfai accounts
|
|
913
952
|
*
|
|
@@ -919,7 +958,7 @@ declare class ZyfaiSDK {
|
|
|
919
958
|
* console.log("Total Volume:", volume.volumeInUSD);
|
|
920
959
|
* ```
|
|
921
960
|
*/
|
|
922
|
-
getVolume(): Promise<VolumeResponse>;
|
|
961
|
+
getVolume(assetType?: "usdc" | "eth"): Promise<VolumeResponse>;
|
|
923
962
|
/**
|
|
924
963
|
* Get active wallets for a specific chain
|
|
925
964
|
*
|
|
@@ -984,12 +1023,12 @@ declare class ZyfaiSDK {
|
|
|
984
1023
|
* Get onchain earnings for a wallet
|
|
985
1024
|
*
|
|
986
1025
|
* @param walletAddress - Smart wallet address
|
|
987
|
-
* @returns Onchain earnings data
|
|
1026
|
+
* @returns Onchain earnings data with per-token breakdowns
|
|
988
1027
|
*
|
|
989
1028
|
* @example
|
|
990
1029
|
* ```typescript
|
|
991
1030
|
* const earnings = await sdk.getOnchainEarnings("0x...");
|
|
992
|
-
* console.log("Total
|
|
1031
|
+
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
993
1032
|
* ```
|
|
994
1033
|
*/
|
|
995
1034
|
getOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
|
|
@@ -998,12 +1037,12 @@ declare class ZyfaiSDK {
|
|
|
998
1037
|
* This triggers a recalculation of earnings on the backend
|
|
999
1038
|
*
|
|
1000
1039
|
* @param walletAddress - Smart wallet address
|
|
1001
|
-
* @returns Updated onchain earnings data
|
|
1040
|
+
* @returns Updated onchain earnings data with per-token breakdowns
|
|
1002
1041
|
*
|
|
1003
1042
|
* @example
|
|
1004
1043
|
* ```typescript
|
|
1005
1044
|
* const earnings = await sdk.calculateOnchainEarnings("0x...");
|
|
1006
|
-
* console.log("
|
|
1045
|
+
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
1007
1046
|
* ```
|
|
1008
1047
|
*/
|
|
1009
1048
|
calculateOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
|
|
@@ -1018,55 +1057,44 @@ declare class ZyfaiSDK {
|
|
|
1018
1057
|
* @example
|
|
1019
1058
|
* ```typescript
|
|
1020
1059
|
* const daily = await sdk.getDailyEarnings("0x...", "2024-01-01", "2024-01-31");
|
|
1021
|
-
* daily.data.forEach(d => console.log(d.
|
|
1060
|
+
* daily.data.forEach(d => console.log(d.snapshot_date, d.total_earnings_by_token));
|
|
1022
1061
|
* ```
|
|
1023
1062
|
*/
|
|
1024
1063
|
getDailyEarnings(walletAddress: string, startDate?: string, endDate?: string): Promise<DailyEarningsResponse>;
|
|
1025
|
-
/**
|
|
1026
|
-
* Get Debank portfolio for a wallet across multiple chains
|
|
1027
|
-
* Note: This is a paid endpoint and may require authorization
|
|
1028
|
-
*
|
|
1029
|
-
* @param walletAddress - Smart wallet address
|
|
1030
|
-
* @returns Multi-chain portfolio data
|
|
1031
|
-
*
|
|
1032
|
-
* @example
|
|
1033
|
-
* ```typescript
|
|
1034
|
-
* const portfolio = await sdk.getDebankPortfolio("0x...");
|
|
1035
|
-
* console.log("Total value:", portfolio.totalValueUsd);
|
|
1036
|
-
* ```
|
|
1037
|
-
*/
|
|
1038
|
-
getDebankPortfolio(walletAddress: string): Promise<DebankPortfolioResponse>;
|
|
1039
1064
|
/**
|
|
1040
1065
|
* Get conservative (low-risk) yield opportunities
|
|
1041
1066
|
*
|
|
1042
1067
|
* @param chainId - Optional chain ID filter
|
|
1068
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
1043
1069
|
* @returns List of conservative yield opportunities
|
|
1044
1070
|
*
|
|
1045
1071
|
* @example
|
|
1046
1072
|
* ```typescript
|
|
1047
|
-
* const opportunities = await sdk.getConservativeOpportunities(8453);
|
|
1073
|
+
* const opportunities = await sdk.getConservativeOpportunities(8453, "USDC");
|
|
1048
1074
|
* opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
|
|
1049
1075
|
* ```
|
|
1050
1076
|
*/
|
|
1051
|
-
getConservativeOpportunities(chainId?: number): Promise<OpportunitiesResponse>;
|
|
1077
|
+
getConservativeOpportunities(chainId?: number, asset?: string, status?: "live" | "not_live"): Promise<OpportunitiesResponse>;
|
|
1052
1078
|
/**
|
|
1053
1079
|
* Get aggressive (high-risk, high-reward) yield opportunities
|
|
1054
1080
|
*
|
|
1055
1081
|
* @param chainId - Optional chain ID filter
|
|
1082
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
1056
1083
|
* @returns List of aggressive opportunities
|
|
1057
1084
|
*
|
|
1058
1085
|
* @example
|
|
1059
1086
|
* ```typescript
|
|
1060
|
-
* const opportunities = await sdk.getAggressiveOpportunities(8453);
|
|
1087
|
+
* const opportunities = await sdk.getAggressiveOpportunities(8453, "WETH");
|
|
1061
1088
|
* opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
|
|
1062
1089
|
* ```
|
|
1063
1090
|
*/
|
|
1064
|
-
getAggressiveOpportunities(chainId?: number): Promise<OpportunitiesResponse>;
|
|
1091
|
+
getAggressiveOpportunities(chainId?: number, asset?: string, status?: "live" | "not_live"): Promise<OpportunitiesResponse>;
|
|
1065
1092
|
/**
|
|
1066
1093
|
* Get active conservative opportunities (status = "live") with risk and utilization data
|
|
1067
1094
|
* Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
|
|
1068
1095
|
*
|
|
1069
1096
|
* @param chainId - Optional chain ID filter
|
|
1097
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
1070
1098
|
* @returns Active conservative opportunities with risk data
|
|
1071
1099
|
*
|
|
1072
1100
|
* @example
|
|
@@ -1075,12 +1103,13 @@ declare class ZyfaiSDK {
|
|
|
1075
1103
|
* console.log(JSON.stringify(opps, null, 2));
|
|
1076
1104
|
* ```
|
|
1077
1105
|
*/
|
|
1078
|
-
getActiveConservativeOppsRisk(chainId?: number): Promise<any>;
|
|
1106
|
+
getActiveConservativeOppsRisk(chainId?: number, asset?: string): Promise<any>;
|
|
1079
1107
|
/**
|
|
1080
1108
|
* Get active aggressive opportunities (status = "live") with risk and utilization data
|
|
1081
1109
|
* Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
|
|
1082
1110
|
*
|
|
1083
1111
|
* @param chainId - Optional chain ID filter
|
|
1112
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
1084
1113
|
* @returns Active aggressive opportunities with risk data
|
|
1085
1114
|
*
|
|
1086
1115
|
* @example
|
|
@@ -1089,35 +1118,37 @@ declare class ZyfaiSDK {
|
|
|
1089
1118
|
* console.log(JSON.stringify(opps, null, 2));
|
|
1090
1119
|
* ```
|
|
1091
1120
|
*/
|
|
1092
|
-
getActiveAggressiveOppsRisk(chainId?: number): Promise<any>;
|
|
1121
|
+
getActiveAggressiveOppsRisk(chainId?: number, asset?: string): Promise<any>;
|
|
1093
1122
|
/**
|
|
1094
1123
|
* Get conservative pool status with derived health, risk, APY trend, and yield consistency
|
|
1095
1124
|
* Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
|
|
1096
1125
|
*
|
|
1097
1126
|
* @param chainId - Optional chain ID filter
|
|
1127
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
1098
1128
|
* @returns Conservative pools with status data
|
|
1099
1129
|
*/
|
|
1100
|
-
getConservativePoolStatus(chainId?: number): Promise<any>;
|
|
1130
|
+
getConservativePoolStatus(chainId?: number, asset?: string): Promise<any>;
|
|
1101
1131
|
/**
|
|
1102
1132
|
* Get aggressive pool status with derived health, risk, APY trend, and yield consistency
|
|
1103
1133
|
* Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
|
|
1104
1134
|
*
|
|
1105
1135
|
* @param chainId - Optional chain ID filter
|
|
1136
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
1106
1137
|
* @returns Aggressive pools with status data
|
|
1107
1138
|
*/
|
|
1108
|
-
getAggressivePoolStatus(chainId?: number): Promise<any>;
|
|
1139
|
+
getAggressivePoolStatus(chainId?: number, asset?: string): Promise<any>;
|
|
1109
1140
|
private derivePoolStatus;
|
|
1110
1141
|
/**
|
|
1111
1142
|
* Get daily APY history with weighted average for a wallet
|
|
1112
1143
|
*
|
|
1113
1144
|
* @param walletAddress - Smart wallet address
|
|
1114
1145
|
* @param days - Period: "7D", "14D", or "30D" (default: "7D")
|
|
1115
|
-
* @returns Daily APY history with weighted averages
|
|
1146
|
+
* @returns Daily APY history with per-position breakdowns and weighted averages
|
|
1116
1147
|
*
|
|
1117
1148
|
* @example
|
|
1118
1149
|
* ```typescript
|
|
1119
1150
|
* const apyHistory = await sdk.getDailyApyHistory("0x...", "30D");
|
|
1120
|
-
* console.log("
|
|
1151
|
+
* console.log("Weighted APY after fee:", apyHistory.weightedApyAfterFee); // { "USDC": 4.64, "WETH": 1.94 }
|
|
1121
1152
|
* ```
|
|
1122
1153
|
*/
|
|
1123
1154
|
getDailyApyHistory(walletAddress: string, days?: "7D" | "14D" | "30D"): Promise<DailyApyHistoryResponse>;
|
|
@@ -1283,4 +1314,4 @@ declare class ZyfaiSDK {
|
|
|
1283
1314
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1284
1315
|
}
|
|
1285
1316
|
|
|
1286
|
-
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 Portfolio, type PortfolioResponse, type PortfolioToken, type PositionSlot, 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
|
|
1317
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ApyPosition, 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 LogDepositResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type Portfolio, type PortfolioResponse, type PortfolioToken, type PositionSlot, 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 TokenApy, type TokenEarnings, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|