@zyfai/sdk 0.2.50 → 0.2.52
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 -2
- package/dist/index.d.mts +39 -8
- package/dist/index.d.ts +39 -8
- package/dist/index.js +64 -17
- package/dist/index.mjs +63 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -546,6 +546,7 @@ console.log(portfolio.portfolioByAssetType?.usdc?.balanceWithFee);
|
|
|
546
546
|
|
|
547
547
|
portfolio.positions?.forEach((slot) => {
|
|
548
548
|
console.log(slot.pool, slot.underlyingAmount, slot.underlyingAmountWithFee);
|
|
549
|
+
console.log(slot.pool_apy, slot.pool_apy_withFee);
|
|
549
550
|
});
|
|
550
551
|
```
|
|
551
552
|
|
|
@@ -553,6 +554,7 @@ portfolio.positions?.forEach((slot) => {
|
|
|
553
554
|
|
|
554
555
|
- Pending fee = `current_earnings × 0.1` (unrealised yield only)
|
|
555
556
|
- `balanceWithFee` / `underlyingAmountWithFee` = live − pending fee share
|
|
557
|
+
- `pool_apy_withFee` = `pool_apy × 0.9`
|
|
556
558
|
- If earnings cannot be fetched, `*WithFee` equals the gross value
|
|
557
559
|
|
|
558
560
|
**Note**: Portfolio balances are live; earnings used for the fee may come from a
|
|
@@ -741,7 +743,13 @@ const history = await sdk.getHistory(walletAddress, 8453, {
|
|
|
741
743
|
fromDate: "2024-01-01",
|
|
742
744
|
assetType: "eth",
|
|
743
745
|
});
|
|
744
|
-
history.data.forEach((tx) =>
|
|
746
|
+
history.data.forEach((tx) => {
|
|
747
|
+
console.log(tx.action, tx.transactionHash);
|
|
748
|
+
if (tx.rebalanceLog) {
|
|
749
|
+
console.log(tx.rebalanceLog.oldApy, tx.rebalanceLog.oldApy_withFee);
|
|
750
|
+
console.log(tx.rebalanceLog.newApy, tx.rebalanceLog.newApy_withFee);
|
|
751
|
+
}
|
|
752
|
+
});
|
|
745
753
|
```
|
|
746
754
|
|
|
747
755
|
### 9. Earnings & Performance
|
|
@@ -796,6 +804,7 @@ Returns per-position APY breakdowns with per-token weighted averages.
|
|
|
796
804
|
|
|
797
805
|
```typescript
|
|
798
806
|
const apyHistory = await sdk.getDailyApyHistory(walletAddress, "30D");
|
|
807
|
+
// days: "7D" | "14D" | "30D" | "60D" | "120D" | "180D" (default "7D")
|
|
799
808
|
// Per-token weighted APY: { "USDC": 4.64, "WETH": 1.94 }
|
|
800
809
|
console.log("Weighted APY after fee:", apyHistory.weightedApyAfterFee);
|
|
801
810
|
console.log("Weighted APY (with rZFI Merkl):", apyHistory.weightedApyWithRzfiAfterFee);
|
|
@@ -803,7 +812,7 @@ console.log("Avg rZFI Merkl APR:", apyHistory.averageRzfiMerklApr);
|
|
|
803
812
|
// Per-chain breakdowns: { "8453": { "USDC": 4.59 }, "42161": { "WETH": 1.82 } }
|
|
804
813
|
console.log("By chain:", apyHistory.weightedApyAfterFeeByChain);
|
|
805
814
|
console.log("By chain (with rZFI):", apyHistory.weightedApyWithRzfiAfterFeeByChain);
|
|
806
|
-
// Each date entry has positions (with tokenSymbol), and per-token weighted_apy, fee, etc.
|
|
815
|
+
// Each date entry has positions (with tokenSymbol and apy_withFee = apy × 0.9), and per-token weighted_apy, fee, etc.
|
|
807
816
|
```
|
|
808
817
|
|
|
809
818
|
### 10. Opportunities & Strategies
|
|
@@ -836,6 +845,7 @@ aggressiveOpps.data.forEach((o) => {
|
|
|
836
845
|
// Get same-chain rebalances, optionally filter by chainId and tokenSymbol
|
|
837
846
|
const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative", 8453, "USDC");
|
|
838
847
|
console.log("APY per strategy:", apyPerStrategy.data);
|
|
848
|
+
// Each item includes average_apy_withFee and average_apy_with_rzfi_withFee
|
|
839
849
|
```
|
|
840
850
|
|
|
841
851
|
### 12. SDK API Key Management
|
package/dist/index.d.mts
CHANGED
|
@@ -184,6 +184,8 @@ interface PositionSlot {
|
|
|
184
184
|
/** Net underlying amount after this position's share of pending Zyfi fee. */
|
|
185
185
|
underlyingAmountWithFee?: string;
|
|
186
186
|
pool_apy?: number;
|
|
187
|
+
/** Net pool APY after Zyfi performance fee (gross × 0.9). */
|
|
188
|
+
pool_apy_withFee?: number;
|
|
187
189
|
pool_tvl?: number;
|
|
188
190
|
liquidity?: number;
|
|
189
191
|
}
|
|
@@ -215,11 +217,11 @@ interface APYPerStrategy {
|
|
|
215
217
|
created_at: string;
|
|
216
218
|
strategy: string;
|
|
217
219
|
token_symbol?: string;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
average_apy_without_fee?: number;
|
|
221
|
-
average_apy_with_rzfi_without_fee?: number;
|
|
220
|
+
average_apy_withFee: number;
|
|
221
|
+
average_apy_with_rzfi_withFee: number;
|
|
222
222
|
events_average_apy?: Record<string, number>;
|
|
223
|
+
events_average_apy_withFee?: Record<string, number>;
|
|
224
|
+
events_average_apy_with_rzfi_withFee?: Record<string, number>;
|
|
223
225
|
}
|
|
224
226
|
interface APYPerStrategyResponse {
|
|
225
227
|
success: boolean;
|
|
@@ -265,6 +267,19 @@ interface HistoryPosition {
|
|
|
265
267
|
protocol_icon?: string;
|
|
266
268
|
protocol_name?: string;
|
|
267
269
|
}
|
|
270
|
+
interface HistoryFeeData {
|
|
271
|
+
gasCostInToken?: string;
|
|
272
|
+
gasDeducted?: boolean;
|
|
273
|
+
actualGasCost?: string;
|
|
274
|
+
}
|
|
275
|
+
interface HistoryRebalanceLog {
|
|
276
|
+
oldApy?: string;
|
|
277
|
+
newApy?: string;
|
|
278
|
+
oldApy_withFee?: string;
|
|
279
|
+
newApy_withFee?: string;
|
|
280
|
+
oldOpportunity?: string;
|
|
281
|
+
newOpportunity?: string;
|
|
282
|
+
}
|
|
268
283
|
interface HistoryEntry {
|
|
269
284
|
id?: string;
|
|
270
285
|
action?: string;
|
|
@@ -272,11 +287,14 @@ interface HistoryEntry {
|
|
|
272
287
|
strategy?: string;
|
|
273
288
|
positions?: HistoryPosition[];
|
|
274
289
|
chainId?: number;
|
|
290
|
+
tokenId?: string;
|
|
275
291
|
transactionHash?: string;
|
|
276
292
|
destinationChainId?: number;
|
|
277
293
|
sourceChains?: number[];
|
|
278
294
|
crosschain?: boolean;
|
|
279
295
|
rebalance?: boolean;
|
|
296
|
+
feeData?: HistoryFeeData;
|
|
297
|
+
rebalanceLog?: HistoryRebalanceLog;
|
|
280
298
|
zkProofIpfsHash?: string;
|
|
281
299
|
validationRegistryTxHash?: string;
|
|
282
300
|
validationRegistryChainId?: number;
|
|
@@ -366,6 +384,8 @@ interface OpportunitiesResponse {
|
|
|
366
384
|
}
|
|
367
385
|
interface ApyPosition {
|
|
368
386
|
apy: number;
|
|
387
|
+
/** Net APY after Zyfi performance fee (gross × 0.9). */
|
|
388
|
+
apy_withFee?: number;
|
|
369
389
|
balance: number;
|
|
370
390
|
chainId: number;
|
|
371
391
|
protocol: string;
|
|
@@ -705,6 +725,16 @@ declare const isSupportedChain: (chainId: number) => chainId is SupportedChainId
|
|
|
705
725
|
*/
|
|
706
726
|
declare const getSupportedChainIds: () => SupportedChainId[];
|
|
707
727
|
|
|
728
|
+
/**
|
|
729
|
+
* Global SDK Constants
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
/** Allowed lookback windows for `getDailyApyHistory`, in days. */
|
|
733
|
+
declare const ALLOWED_HISTORY_DAYS: readonly [7, 14, 30, 60, 120, 180];
|
|
734
|
+
type AllowedHistoryDays = (typeof ALLOWED_HISTORY_DAYS)[number];
|
|
735
|
+
/** Query period passed to the daily APY history endpoint, e.g. `"30D"`. */
|
|
736
|
+
type DailyApyHistoryPeriod = `${AllowedHistoryDays}D`;
|
|
737
|
+
|
|
708
738
|
/**
|
|
709
739
|
* Zyfai SDK Main Class
|
|
710
740
|
*/
|
|
@@ -1190,7 +1220,8 @@ declare class ZyfaiSDK {
|
|
|
1190
1220
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
1191
1221
|
/**
|
|
1192
1222
|
* Get portfolio positions and balances for a user, enriched with
|
|
1193
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1223
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1224
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
1194
1225
|
*
|
|
1195
1226
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
1196
1227
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -1467,7 +1498,7 @@ declare class ZyfaiSDK {
|
|
|
1467
1498
|
* Get daily APY history with weighted average for a wallet
|
|
1468
1499
|
*
|
|
1469
1500
|
* @param walletAddress - Smart wallet address
|
|
1470
|
-
* @param days - Period: "7D", "14D", or "
|
|
1501
|
+
* @param days - Period: "7D", "14D", "30D", "60D", "120D", or "180D" (default: "7D")
|
|
1471
1502
|
* @returns Daily APY history with per-position breakdowns and weighted averages
|
|
1472
1503
|
*
|
|
1473
1504
|
* @example
|
|
@@ -1476,7 +1507,7 @@ declare class ZyfaiSDK {
|
|
|
1476
1507
|
* console.log("Weighted APY after fee:", apyHistory.weightedApyAfterFee); // { "USDC": 4.64, "WETH": 1.94 }
|
|
1477
1508
|
* ```
|
|
1478
1509
|
*/
|
|
1479
|
-
getDailyApyHistory(walletAddress: string, days?:
|
|
1510
|
+
getDailyApyHistory(walletAddress: string, days?: DailyApyHistoryPeriod): Promise<DailyApyHistoryResponse>;
|
|
1480
1511
|
/**
|
|
1481
1512
|
* Get rebalance frequency/tier for a wallet
|
|
1482
1513
|
* Determines how often the wallet can be rebalanced based on tier
|
|
@@ -1868,4 +1899,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
1868
1899
|
*/
|
|
1869
1900
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1870
1901
|
|
|
1871
|
-
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
|
1902
|
+
export { ALLOWED_HISTORY_DAYS, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,8 @@ interface PositionSlot {
|
|
|
184
184
|
/** Net underlying amount after this position's share of pending Zyfi fee. */
|
|
185
185
|
underlyingAmountWithFee?: string;
|
|
186
186
|
pool_apy?: number;
|
|
187
|
+
/** Net pool APY after Zyfi performance fee (gross × 0.9). */
|
|
188
|
+
pool_apy_withFee?: number;
|
|
187
189
|
pool_tvl?: number;
|
|
188
190
|
liquidity?: number;
|
|
189
191
|
}
|
|
@@ -215,11 +217,11 @@ interface APYPerStrategy {
|
|
|
215
217
|
created_at: string;
|
|
216
218
|
strategy: string;
|
|
217
219
|
token_symbol?: string;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
average_apy_without_fee?: number;
|
|
221
|
-
average_apy_with_rzfi_without_fee?: number;
|
|
220
|
+
average_apy_withFee: number;
|
|
221
|
+
average_apy_with_rzfi_withFee: number;
|
|
222
222
|
events_average_apy?: Record<string, number>;
|
|
223
|
+
events_average_apy_withFee?: Record<string, number>;
|
|
224
|
+
events_average_apy_with_rzfi_withFee?: Record<string, number>;
|
|
223
225
|
}
|
|
224
226
|
interface APYPerStrategyResponse {
|
|
225
227
|
success: boolean;
|
|
@@ -265,6 +267,19 @@ interface HistoryPosition {
|
|
|
265
267
|
protocol_icon?: string;
|
|
266
268
|
protocol_name?: string;
|
|
267
269
|
}
|
|
270
|
+
interface HistoryFeeData {
|
|
271
|
+
gasCostInToken?: string;
|
|
272
|
+
gasDeducted?: boolean;
|
|
273
|
+
actualGasCost?: string;
|
|
274
|
+
}
|
|
275
|
+
interface HistoryRebalanceLog {
|
|
276
|
+
oldApy?: string;
|
|
277
|
+
newApy?: string;
|
|
278
|
+
oldApy_withFee?: string;
|
|
279
|
+
newApy_withFee?: string;
|
|
280
|
+
oldOpportunity?: string;
|
|
281
|
+
newOpportunity?: string;
|
|
282
|
+
}
|
|
268
283
|
interface HistoryEntry {
|
|
269
284
|
id?: string;
|
|
270
285
|
action?: string;
|
|
@@ -272,11 +287,14 @@ interface HistoryEntry {
|
|
|
272
287
|
strategy?: string;
|
|
273
288
|
positions?: HistoryPosition[];
|
|
274
289
|
chainId?: number;
|
|
290
|
+
tokenId?: string;
|
|
275
291
|
transactionHash?: string;
|
|
276
292
|
destinationChainId?: number;
|
|
277
293
|
sourceChains?: number[];
|
|
278
294
|
crosschain?: boolean;
|
|
279
295
|
rebalance?: boolean;
|
|
296
|
+
feeData?: HistoryFeeData;
|
|
297
|
+
rebalanceLog?: HistoryRebalanceLog;
|
|
280
298
|
zkProofIpfsHash?: string;
|
|
281
299
|
validationRegistryTxHash?: string;
|
|
282
300
|
validationRegistryChainId?: number;
|
|
@@ -366,6 +384,8 @@ interface OpportunitiesResponse {
|
|
|
366
384
|
}
|
|
367
385
|
interface ApyPosition {
|
|
368
386
|
apy: number;
|
|
387
|
+
/** Net APY after Zyfi performance fee (gross × 0.9). */
|
|
388
|
+
apy_withFee?: number;
|
|
369
389
|
balance: number;
|
|
370
390
|
chainId: number;
|
|
371
391
|
protocol: string;
|
|
@@ -705,6 +725,16 @@ declare const isSupportedChain: (chainId: number) => chainId is SupportedChainId
|
|
|
705
725
|
*/
|
|
706
726
|
declare const getSupportedChainIds: () => SupportedChainId[];
|
|
707
727
|
|
|
728
|
+
/**
|
|
729
|
+
* Global SDK Constants
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
/** Allowed lookback windows for `getDailyApyHistory`, in days. */
|
|
733
|
+
declare const ALLOWED_HISTORY_DAYS: readonly [7, 14, 30, 60, 120, 180];
|
|
734
|
+
type AllowedHistoryDays = (typeof ALLOWED_HISTORY_DAYS)[number];
|
|
735
|
+
/** Query period passed to the daily APY history endpoint, e.g. `"30D"`. */
|
|
736
|
+
type DailyApyHistoryPeriod = `${AllowedHistoryDays}D`;
|
|
737
|
+
|
|
708
738
|
/**
|
|
709
739
|
* Zyfai SDK Main Class
|
|
710
740
|
*/
|
|
@@ -1190,7 +1220,8 @@ declare class ZyfaiSDK {
|
|
|
1190
1220
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
1191
1221
|
/**
|
|
1192
1222
|
* Get portfolio positions and balances for a user, enriched with
|
|
1193
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1223
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1224
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
1194
1225
|
*
|
|
1195
1226
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
1196
1227
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -1467,7 +1498,7 @@ declare class ZyfaiSDK {
|
|
|
1467
1498
|
* Get daily APY history with weighted average for a wallet
|
|
1468
1499
|
*
|
|
1469
1500
|
* @param walletAddress - Smart wallet address
|
|
1470
|
-
* @param days - Period: "7D", "14D", or "
|
|
1501
|
+
* @param days - Period: "7D", "14D", "30D", "60D", "120D", or "180D" (default: "7D")
|
|
1471
1502
|
* @returns Daily APY history with per-position breakdowns and weighted averages
|
|
1472
1503
|
*
|
|
1473
1504
|
* @example
|
|
@@ -1476,7 +1507,7 @@ declare class ZyfaiSDK {
|
|
|
1476
1507
|
* console.log("Weighted APY after fee:", apyHistory.weightedApyAfterFee); // { "USDC": 4.64, "WETH": 1.94 }
|
|
1477
1508
|
* ```
|
|
1478
1509
|
*/
|
|
1479
|
-
getDailyApyHistory(walletAddress: string, days?:
|
|
1510
|
+
getDailyApyHistory(walletAddress: string, days?: DailyApyHistoryPeriod): Promise<DailyApyHistoryResponse>;
|
|
1480
1511
|
/**
|
|
1481
1512
|
* Get rebalance frequency/tier for a wallet
|
|
1482
1513
|
* Determines how often the wallet can be rebalanced based on tier
|
|
@@ -1868,4 +1899,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
1868
1899
|
*/
|
|
1869
1900
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1870
1901
|
|
|
1871
|
-
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
|
1902
|
+
export { ALLOWED_HISTORY_DAYS, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
ALLOWED_HISTORY_DAYS: () => ALLOWED_HISTORY_DAYS,
|
|
33
34
|
DEFAULT_TOKEN_ADDRESSES: () => DEFAULT_TOKEN_ADDRESSES,
|
|
34
35
|
ERC7579_LAUNCHPAD_ADDRESS: () => ERC7579_LAUNCHPAD_ADDRESS,
|
|
35
36
|
INTENT_EXECUTOR: () => INTENT_EXECUTOR,
|
|
@@ -516,6 +517,7 @@ var VAULT_ADDRESS = "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
|
516
517
|
|
|
517
518
|
// src/config/constants.ts
|
|
518
519
|
var ZYFI_FEE_RATE = 0.1;
|
|
520
|
+
var ALLOWED_HISTORY_DAYS = [7, 14, 30, 60, 120, 180];
|
|
519
521
|
var MIN_PORTFOLIO_BALANCE = {
|
|
520
522
|
1: {
|
|
521
523
|
USDC: 100n * 10n ** 6n,
|
|
@@ -990,19 +992,19 @@ function convertStrategyToPublicAndNaming(obj) {
|
|
|
990
992
|
}
|
|
991
993
|
}
|
|
992
994
|
if (result.average_apy_without_fee !== void 0) {
|
|
993
|
-
result.
|
|
995
|
+
result.average_apy_withFee = result.average_apy_without_fee;
|
|
994
996
|
delete result.average_apy_without_fee;
|
|
995
997
|
}
|
|
996
998
|
if (result.average_apy_with_rzfi_without_fee !== void 0) {
|
|
997
|
-
result.
|
|
999
|
+
result.average_apy_with_rzfi_withFee = result.average_apy_with_rzfi_without_fee;
|
|
998
1000
|
delete result.average_apy_with_rzfi_without_fee;
|
|
999
1001
|
}
|
|
1000
1002
|
if (result.events_average_apy_without_fee !== void 0) {
|
|
1001
|
-
result.
|
|
1003
|
+
result.events_average_apy_withFee = result.events_average_apy_without_fee;
|
|
1002
1004
|
delete result.events_average_apy_without_fee;
|
|
1003
1005
|
}
|
|
1004
1006
|
if (result.events_average_apy_with_rzfi_without_fee !== void 0) {
|
|
1005
|
-
result.
|
|
1007
|
+
result.events_average_apy_with_rzfi_withFee = result.events_average_apy_with_rzfi_without_fee;
|
|
1006
1008
|
delete result.events_average_apy_with_rzfi_without_fee;
|
|
1007
1009
|
}
|
|
1008
1010
|
return result;
|
|
@@ -1098,6 +1100,14 @@ function humanAmountToRaw(human, decimals) {
|
|
|
1098
1100
|
const fracPart = BigInt(frac.padEnd(decimals, "0").slice(0, decimals) || "0");
|
|
1099
1101
|
return wholePart * 10n ** BigInt(decimals) + fracPart;
|
|
1100
1102
|
}
|
|
1103
|
+
function applyApyFee(apy) {
|
|
1104
|
+
return apy * (1 - ZYFI_FEE_RATE);
|
|
1105
|
+
}
|
|
1106
|
+
function applyApyFeeToString(apy) {
|
|
1107
|
+
const parsed = Number.parseFloat(apy);
|
|
1108
|
+
if (!Number.isFinite(parsed)) return apy;
|
|
1109
|
+
return String(applyApyFee(parsed));
|
|
1110
|
+
}
|
|
1101
1111
|
function formatHumanAmount(value) {
|
|
1102
1112
|
if (!Number.isFinite(value) || value === 0) return "0";
|
|
1103
1113
|
const fixed = value.toFixed(18);
|
|
@@ -1228,22 +1238,37 @@ function enrichPositions(positions, byChainByToken) {
|
|
|
1228
1238
|
});
|
|
1229
1239
|
});
|
|
1230
1240
|
return positions.map((position, index) => {
|
|
1241
|
+
const enriched = { ...position };
|
|
1242
|
+
if (typeof position.pool_apy === "number") {
|
|
1243
|
+
enriched.pool_apy_withFee = applyApyFee(position.pool_apy);
|
|
1244
|
+
}
|
|
1231
1245
|
const underlying = position.underlyingAmount;
|
|
1232
1246
|
if (underlying === void 0) {
|
|
1233
|
-
return
|
|
1247
|
+
return enriched;
|
|
1234
1248
|
}
|
|
1235
1249
|
const feeShare = feeShareByIndex.get(index) ?? 0;
|
|
1236
1250
|
const decimals = resolvePositionDecimals(position);
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
)
|
|
1244
|
-
};
|
|
1251
|
+
enriched.underlyingAmountWithFee = applyFeeToDecimalWei(
|
|
1252
|
+
underlying,
|
|
1253
|
+
feeShare,
|
|
1254
|
+
decimals
|
|
1255
|
+
);
|
|
1256
|
+
return enriched;
|
|
1245
1257
|
});
|
|
1246
1258
|
}
|
|
1259
|
+
function enrichApyPosition(position) {
|
|
1260
|
+
return {
|
|
1261
|
+
...position,
|
|
1262
|
+
apy_withFee: applyApyFee(position.apy)
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
function enrichRebalanceLog(log) {
|
|
1266
|
+
return {
|
|
1267
|
+
...log,
|
|
1268
|
+
...log.oldApy !== void 0 ? { oldApy_withFee: applyApyFeeToString(log.oldApy) } : {},
|
|
1269
|
+
...log.newApy !== void 0 ? { newApy_withFee: applyApyFeeToString(log.newApy) } : {}
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1247
1272
|
function enrichPortfolioWithFees(portfolio, currentEarningsByChain) {
|
|
1248
1273
|
const { byToken, byChainByToken } = computePendingFees(currentEarningsByChain);
|
|
1249
1274
|
const portfolioByAssetType = portfolio.portfolioByAssetType ? Object.fromEntries(
|
|
@@ -2822,7 +2847,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2822
2847
|
}
|
|
2823
2848
|
/**
|
|
2824
2849
|
* Get portfolio positions and balances for a user, enriched with
|
|
2825
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2850
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2851
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
2826
2852
|
*
|
|
2827
2853
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
2828
2854
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -3162,7 +3188,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3162
3188
|
if (options?.fromDate) endpoint += `&fromDate=${options.fromDate}`;
|
|
3163
3189
|
if (options?.toDate) endpoint += `&toDate=${options.toDate}`;
|
|
3164
3190
|
const response = await this.httpClient.get(endpoint);
|
|
3165
|
-
const convertedData = convertStrategiesToPublic(
|
|
3191
|
+
const convertedData = convertStrategiesToPublic(
|
|
3192
|
+
response.data || []
|
|
3193
|
+
).map(
|
|
3194
|
+
(entry) => entry.rebalanceLog ? {
|
|
3195
|
+
...entry,
|
|
3196
|
+
rebalanceLog: enrichRebalanceLog(entry.rebalanceLog)
|
|
3197
|
+
} : entry
|
|
3198
|
+
);
|
|
3166
3199
|
return {
|
|
3167
3200
|
success: true,
|
|
3168
3201
|
walletAddress,
|
|
@@ -3570,7 +3603,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3570
3603
|
* Get daily APY history with weighted average for a wallet
|
|
3571
3604
|
*
|
|
3572
3605
|
* @param walletAddress - Smart wallet address
|
|
3573
|
-
* @param days - Period: "7D", "14D", or "
|
|
3606
|
+
* @param days - Period: "7D", "14D", "30D", "60D", "120D", or "180D" (default: "7D")
|
|
3574
3607
|
* @returns Daily APY history with per-position breakdowns and weighted averages
|
|
3575
3608
|
*
|
|
3576
3609
|
* @example
|
|
@@ -3588,10 +3621,23 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3588
3621
|
DATA_ENDPOINTS.DAILY_APY_HISTORY_WEIGHTED(walletAddress, days)
|
|
3589
3622
|
);
|
|
3590
3623
|
const data = response.data || response;
|
|
3624
|
+
const rawHistory = data.history || {};
|
|
3625
|
+
const history = Object.fromEntries(
|
|
3626
|
+
Object.entries(rawHistory).map(([date, entry]) => {
|
|
3627
|
+
const day = entry;
|
|
3628
|
+
return [
|
|
3629
|
+
date,
|
|
3630
|
+
{
|
|
3631
|
+
...day,
|
|
3632
|
+
positions: (day.positions || []).map(enrichApyPosition)
|
|
3633
|
+
}
|
|
3634
|
+
];
|
|
3635
|
+
})
|
|
3636
|
+
);
|
|
3591
3637
|
return {
|
|
3592
3638
|
success: true,
|
|
3593
3639
|
walletAddress,
|
|
3594
|
-
history
|
|
3640
|
+
history,
|
|
3595
3641
|
totalDays: data.total_days || data.totalDays || 0,
|
|
3596
3642
|
requestedDays: data.requested_days || data.requestedDays,
|
|
3597
3643
|
weightedApyWithRzfiAfterFee: data.average_final_weighted_apy_after_fee_with_rzfi,
|
|
@@ -4548,6 +4594,7 @@ function createBankrProvider(config) {
|
|
|
4548
4594
|
}
|
|
4549
4595
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4550
4596
|
0 && (module.exports = {
|
|
4597
|
+
ALLOWED_HISTORY_DAYS,
|
|
4551
4598
|
DEFAULT_TOKEN_ADDRESSES,
|
|
4552
4599
|
ERC7579_LAUNCHPAD_ADDRESS,
|
|
4553
4600
|
INTENT_EXECUTOR,
|
package/dist/index.mjs
CHANGED
|
@@ -464,6 +464,7 @@ var VAULT_ADDRESS = "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
|
464
464
|
|
|
465
465
|
// src/config/constants.ts
|
|
466
466
|
var ZYFI_FEE_RATE = 0.1;
|
|
467
|
+
var ALLOWED_HISTORY_DAYS = [7, 14, 30, 60, 120, 180];
|
|
467
468
|
var MIN_PORTFOLIO_BALANCE = {
|
|
468
469
|
1: {
|
|
469
470
|
USDC: 100n * 10n ** 6n,
|
|
@@ -958,19 +959,19 @@ function convertStrategyToPublicAndNaming(obj) {
|
|
|
958
959
|
}
|
|
959
960
|
}
|
|
960
961
|
if (result.average_apy_without_fee !== void 0) {
|
|
961
|
-
result.
|
|
962
|
+
result.average_apy_withFee = result.average_apy_without_fee;
|
|
962
963
|
delete result.average_apy_without_fee;
|
|
963
964
|
}
|
|
964
965
|
if (result.average_apy_with_rzfi_without_fee !== void 0) {
|
|
965
|
-
result.
|
|
966
|
+
result.average_apy_with_rzfi_withFee = result.average_apy_with_rzfi_without_fee;
|
|
966
967
|
delete result.average_apy_with_rzfi_without_fee;
|
|
967
968
|
}
|
|
968
969
|
if (result.events_average_apy_without_fee !== void 0) {
|
|
969
|
-
result.
|
|
970
|
+
result.events_average_apy_withFee = result.events_average_apy_without_fee;
|
|
970
971
|
delete result.events_average_apy_without_fee;
|
|
971
972
|
}
|
|
972
973
|
if (result.events_average_apy_with_rzfi_without_fee !== void 0) {
|
|
973
|
-
result.
|
|
974
|
+
result.events_average_apy_with_rzfi_withFee = result.events_average_apy_with_rzfi_without_fee;
|
|
974
975
|
delete result.events_average_apy_with_rzfi_without_fee;
|
|
975
976
|
}
|
|
976
977
|
return result;
|
|
@@ -1066,6 +1067,14 @@ function humanAmountToRaw(human, decimals) {
|
|
|
1066
1067
|
const fracPart = BigInt(frac.padEnd(decimals, "0").slice(0, decimals) || "0");
|
|
1067
1068
|
return wholePart * 10n ** BigInt(decimals) + fracPart;
|
|
1068
1069
|
}
|
|
1070
|
+
function applyApyFee(apy) {
|
|
1071
|
+
return apy * (1 - ZYFI_FEE_RATE);
|
|
1072
|
+
}
|
|
1073
|
+
function applyApyFeeToString(apy) {
|
|
1074
|
+
const parsed = Number.parseFloat(apy);
|
|
1075
|
+
if (!Number.isFinite(parsed)) return apy;
|
|
1076
|
+
return String(applyApyFee(parsed));
|
|
1077
|
+
}
|
|
1069
1078
|
function formatHumanAmount(value) {
|
|
1070
1079
|
if (!Number.isFinite(value) || value === 0) return "0";
|
|
1071
1080
|
const fixed = value.toFixed(18);
|
|
@@ -1196,22 +1205,37 @@ function enrichPositions(positions, byChainByToken) {
|
|
|
1196
1205
|
});
|
|
1197
1206
|
});
|
|
1198
1207
|
return positions.map((position, index) => {
|
|
1208
|
+
const enriched = { ...position };
|
|
1209
|
+
if (typeof position.pool_apy === "number") {
|
|
1210
|
+
enriched.pool_apy_withFee = applyApyFee(position.pool_apy);
|
|
1211
|
+
}
|
|
1199
1212
|
const underlying = position.underlyingAmount;
|
|
1200
1213
|
if (underlying === void 0) {
|
|
1201
|
-
return
|
|
1214
|
+
return enriched;
|
|
1202
1215
|
}
|
|
1203
1216
|
const feeShare = feeShareByIndex.get(index) ?? 0;
|
|
1204
1217
|
const decimals = resolvePositionDecimals(position);
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
)
|
|
1212
|
-
};
|
|
1218
|
+
enriched.underlyingAmountWithFee = applyFeeToDecimalWei(
|
|
1219
|
+
underlying,
|
|
1220
|
+
feeShare,
|
|
1221
|
+
decimals
|
|
1222
|
+
);
|
|
1223
|
+
return enriched;
|
|
1213
1224
|
});
|
|
1214
1225
|
}
|
|
1226
|
+
function enrichApyPosition(position) {
|
|
1227
|
+
return {
|
|
1228
|
+
...position,
|
|
1229
|
+
apy_withFee: applyApyFee(position.apy)
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
function enrichRebalanceLog(log) {
|
|
1233
|
+
return {
|
|
1234
|
+
...log,
|
|
1235
|
+
...log.oldApy !== void 0 ? { oldApy_withFee: applyApyFeeToString(log.oldApy) } : {},
|
|
1236
|
+
...log.newApy !== void 0 ? { newApy_withFee: applyApyFeeToString(log.newApy) } : {}
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1215
1239
|
function enrichPortfolioWithFees(portfolio, currentEarningsByChain) {
|
|
1216
1240
|
const { byToken, byChainByToken } = computePendingFees(currentEarningsByChain);
|
|
1217
1241
|
const portfolioByAssetType = portfolio.portfolioByAssetType ? Object.fromEntries(
|
|
@@ -2790,7 +2814,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2790
2814
|
}
|
|
2791
2815
|
/**
|
|
2792
2816
|
* Get portfolio positions and balances for a user, enriched with
|
|
2793
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2817
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2818
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
2794
2819
|
*
|
|
2795
2820
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
2796
2821
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -3130,7 +3155,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3130
3155
|
if (options?.fromDate) endpoint += `&fromDate=${options.fromDate}`;
|
|
3131
3156
|
if (options?.toDate) endpoint += `&toDate=${options.toDate}`;
|
|
3132
3157
|
const response = await this.httpClient.get(endpoint);
|
|
3133
|
-
const convertedData = convertStrategiesToPublic(
|
|
3158
|
+
const convertedData = convertStrategiesToPublic(
|
|
3159
|
+
response.data || []
|
|
3160
|
+
).map(
|
|
3161
|
+
(entry) => entry.rebalanceLog ? {
|
|
3162
|
+
...entry,
|
|
3163
|
+
rebalanceLog: enrichRebalanceLog(entry.rebalanceLog)
|
|
3164
|
+
} : entry
|
|
3165
|
+
);
|
|
3134
3166
|
return {
|
|
3135
3167
|
success: true,
|
|
3136
3168
|
walletAddress,
|
|
@@ -3538,7 +3570,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3538
3570
|
* Get daily APY history with weighted average for a wallet
|
|
3539
3571
|
*
|
|
3540
3572
|
* @param walletAddress - Smart wallet address
|
|
3541
|
-
* @param days - Period: "7D", "14D", or "
|
|
3573
|
+
* @param days - Period: "7D", "14D", "30D", "60D", "120D", or "180D" (default: "7D")
|
|
3542
3574
|
* @returns Daily APY history with per-position breakdowns and weighted averages
|
|
3543
3575
|
*
|
|
3544
3576
|
* @example
|
|
@@ -3556,10 +3588,23 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3556
3588
|
DATA_ENDPOINTS.DAILY_APY_HISTORY_WEIGHTED(walletAddress, days)
|
|
3557
3589
|
);
|
|
3558
3590
|
const data = response.data || response;
|
|
3591
|
+
const rawHistory = data.history || {};
|
|
3592
|
+
const history = Object.fromEntries(
|
|
3593
|
+
Object.entries(rawHistory).map(([date, entry]) => {
|
|
3594
|
+
const day = entry;
|
|
3595
|
+
return [
|
|
3596
|
+
date,
|
|
3597
|
+
{
|
|
3598
|
+
...day,
|
|
3599
|
+
positions: (day.positions || []).map(enrichApyPosition)
|
|
3600
|
+
}
|
|
3601
|
+
];
|
|
3602
|
+
})
|
|
3603
|
+
);
|
|
3559
3604
|
return {
|
|
3560
3605
|
success: true,
|
|
3561
3606
|
walletAddress,
|
|
3562
|
-
history
|
|
3607
|
+
history,
|
|
3563
3608
|
totalDays: data.total_days || data.totalDays || 0,
|
|
3564
3609
|
requestedDays: data.requested_days || data.requestedDays,
|
|
3565
3610
|
weightedApyWithRzfiAfterFee: data.average_final_weighted_apy_after_fee_with_rzfi,
|
|
@@ -4515,6 +4560,7 @@ function createBankrProvider(config) {
|
|
|
4515
4560
|
return provider;
|
|
4516
4561
|
}
|
|
4517
4562
|
export {
|
|
4563
|
+
ALLOWED_HISTORY_DAYS,
|
|
4518
4564
|
DEFAULT_TOKEN_ADDRESSES,
|
|
4519
4565
|
ERC7579_LAUNCHPAD_ADDRESS,
|
|
4520
4566
|
INTENT_EXECUTOR,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.52",
|
|
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",
|