@zyfai/sdk 0.2.50 → 0.2.51
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 +11 -2
- package/dist/index.d.mts +27 -6
- package/dist/index.d.ts +27 -6
- package/dist/index.js +60 -16
- package/dist/index.mjs +60 -16
- 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
|
|
@@ -803,7 +811,7 @@ console.log("Avg rZFI Merkl APR:", apyHistory.averageRzfiMerklApr);
|
|
|
803
811
|
// Per-chain breakdowns: { "8453": { "USDC": 4.59 }, "42161": { "WETH": 1.82 } }
|
|
804
812
|
console.log("By chain:", apyHistory.weightedApyAfterFeeByChain);
|
|
805
813
|
console.log("By chain (with rZFI):", apyHistory.weightedApyWithRzfiAfterFeeByChain);
|
|
806
|
-
// Each date entry has positions (with tokenSymbol), and per-token weighted_apy, fee, etc.
|
|
814
|
+
// Each date entry has positions (with tokenSymbol and apy_withFee = apy × 0.9), and per-token weighted_apy, fee, etc.
|
|
807
815
|
```
|
|
808
816
|
|
|
809
817
|
### 10. Opportunities & Strategies
|
|
@@ -836,6 +844,7 @@ aggressiveOpps.data.forEach((o) => {
|
|
|
836
844
|
// Get same-chain rebalances, optionally filter by chainId and tokenSymbol
|
|
837
845
|
const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative", 8453, "USDC");
|
|
838
846
|
console.log("APY per strategy:", apyPerStrategy.data);
|
|
847
|
+
// Each item includes average_apy_withFee and average_apy_with_rzfi_withFee
|
|
839
848
|
```
|
|
840
849
|
|
|
841
850
|
### 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;
|
|
@@ -1190,7 +1210,8 @@ declare class ZyfaiSDK {
|
|
|
1190
1210
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
1191
1211
|
/**
|
|
1192
1212
|
* Get portfolio positions and balances for a user, enriched with
|
|
1193
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1213
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1214
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
1194
1215
|
*
|
|
1195
1216
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
1196
1217
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -1868,4 +1889,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
1868
1889
|
*/
|
|
1869
1890
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1870
1891
|
|
|
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 };
|
|
1892
|
+
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 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;
|
|
@@ -1190,7 +1210,8 @@ declare class ZyfaiSDK {
|
|
|
1190
1210
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
1191
1211
|
/**
|
|
1192
1212
|
* Get portfolio positions and balances for a user, enriched with
|
|
1193
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1213
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
1214
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
1194
1215
|
*
|
|
1195
1216
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
1196
1217
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -1868,4 +1889,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
1868
1889
|
*/
|
|
1869
1890
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1870
1891
|
|
|
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 };
|
|
1892
|
+
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 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
|
@@ -990,19 +990,19 @@ function convertStrategyToPublicAndNaming(obj) {
|
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
992
|
if (result.average_apy_without_fee !== void 0) {
|
|
993
|
-
result.
|
|
993
|
+
result.average_apy_withFee = result.average_apy_without_fee;
|
|
994
994
|
delete result.average_apy_without_fee;
|
|
995
995
|
}
|
|
996
996
|
if (result.average_apy_with_rzfi_without_fee !== void 0) {
|
|
997
|
-
result.
|
|
997
|
+
result.average_apy_with_rzfi_withFee = result.average_apy_with_rzfi_without_fee;
|
|
998
998
|
delete result.average_apy_with_rzfi_without_fee;
|
|
999
999
|
}
|
|
1000
1000
|
if (result.events_average_apy_without_fee !== void 0) {
|
|
1001
|
-
result.
|
|
1001
|
+
result.events_average_apy_withFee = result.events_average_apy_without_fee;
|
|
1002
1002
|
delete result.events_average_apy_without_fee;
|
|
1003
1003
|
}
|
|
1004
1004
|
if (result.events_average_apy_with_rzfi_without_fee !== void 0) {
|
|
1005
|
-
result.
|
|
1005
|
+
result.events_average_apy_with_rzfi_withFee = result.events_average_apy_with_rzfi_without_fee;
|
|
1006
1006
|
delete result.events_average_apy_with_rzfi_without_fee;
|
|
1007
1007
|
}
|
|
1008
1008
|
return result;
|
|
@@ -1098,6 +1098,14 @@ function humanAmountToRaw(human, decimals) {
|
|
|
1098
1098
|
const fracPart = BigInt(frac.padEnd(decimals, "0").slice(0, decimals) || "0");
|
|
1099
1099
|
return wholePart * 10n ** BigInt(decimals) + fracPart;
|
|
1100
1100
|
}
|
|
1101
|
+
function applyApyFee(apy) {
|
|
1102
|
+
return apy * (1 - ZYFI_FEE_RATE);
|
|
1103
|
+
}
|
|
1104
|
+
function applyApyFeeToString(apy) {
|
|
1105
|
+
const parsed = Number.parseFloat(apy);
|
|
1106
|
+
if (!Number.isFinite(parsed)) return apy;
|
|
1107
|
+
return String(applyApyFee(parsed));
|
|
1108
|
+
}
|
|
1101
1109
|
function formatHumanAmount(value) {
|
|
1102
1110
|
if (!Number.isFinite(value) || value === 0) return "0";
|
|
1103
1111
|
const fixed = value.toFixed(18);
|
|
@@ -1228,22 +1236,37 @@ function enrichPositions(positions, byChainByToken) {
|
|
|
1228
1236
|
});
|
|
1229
1237
|
});
|
|
1230
1238
|
return positions.map((position, index) => {
|
|
1239
|
+
const enriched = { ...position };
|
|
1240
|
+
if (typeof position.pool_apy === "number") {
|
|
1241
|
+
enriched.pool_apy_withFee = applyApyFee(position.pool_apy);
|
|
1242
|
+
}
|
|
1231
1243
|
const underlying = position.underlyingAmount;
|
|
1232
1244
|
if (underlying === void 0) {
|
|
1233
|
-
return
|
|
1245
|
+
return enriched;
|
|
1234
1246
|
}
|
|
1235
1247
|
const feeShare = feeShareByIndex.get(index) ?? 0;
|
|
1236
1248
|
const decimals = resolvePositionDecimals(position);
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
)
|
|
1244
|
-
};
|
|
1249
|
+
enriched.underlyingAmountWithFee = applyFeeToDecimalWei(
|
|
1250
|
+
underlying,
|
|
1251
|
+
feeShare,
|
|
1252
|
+
decimals
|
|
1253
|
+
);
|
|
1254
|
+
return enriched;
|
|
1245
1255
|
});
|
|
1246
1256
|
}
|
|
1257
|
+
function enrichApyPosition(position) {
|
|
1258
|
+
return {
|
|
1259
|
+
...position,
|
|
1260
|
+
apy_withFee: applyApyFee(position.apy)
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
function enrichRebalanceLog(log) {
|
|
1264
|
+
return {
|
|
1265
|
+
...log,
|
|
1266
|
+
...log.oldApy !== void 0 ? { oldApy_withFee: applyApyFeeToString(log.oldApy) } : {},
|
|
1267
|
+
...log.newApy !== void 0 ? { newApy_withFee: applyApyFeeToString(log.newApy) } : {}
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1247
1270
|
function enrichPortfolioWithFees(portfolio, currentEarningsByChain) {
|
|
1248
1271
|
const { byToken, byChainByToken } = computePendingFees(currentEarningsByChain);
|
|
1249
1272
|
const portfolioByAssetType = portfolio.portfolioByAssetType ? Object.fromEntries(
|
|
@@ -2822,7 +2845,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2822
2845
|
}
|
|
2823
2846
|
/**
|
|
2824
2847
|
* Get portfolio positions and balances for a user, enriched with
|
|
2825
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2848
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2849
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
2826
2850
|
*
|
|
2827
2851
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
2828
2852
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -3162,7 +3186,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3162
3186
|
if (options?.fromDate) endpoint += `&fromDate=${options.fromDate}`;
|
|
3163
3187
|
if (options?.toDate) endpoint += `&toDate=${options.toDate}`;
|
|
3164
3188
|
const response = await this.httpClient.get(endpoint);
|
|
3165
|
-
const convertedData = convertStrategiesToPublic(
|
|
3189
|
+
const convertedData = convertStrategiesToPublic(
|
|
3190
|
+
response.data || []
|
|
3191
|
+
).map(
|
|
3192
|
+
(entry) => entry.rebalanceLog ? {
|
|
3193
|
+
...entry,
|
|
3194
|
+
rebalanceLog: enrichRebalanceLog(entry.rebalanceLog)
|
|
3195
|
+
} : entry
|
|
3196
|
+
);
|
|
3166
3197
|
return {
|
|
3167
3198
|
success: true,
|
|
3168
3199
|
walletAddress,
|
|
@@ -3588,10 +3619,23 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3588
3619
|
DATA_ENDPOINTS.DAILY_APY_HISTORY_WEIGHTED(walletAddress, days)
|
|
3589
3620
|
);
|
|
3590
3621
|
const data = response.data || response;
|
|
3622
|
+
const rawHistory = data.history || {};
|
|
3623
|
+
const history = Object.fromEntries(
|
|
3624
|
+
Object.entries(rawHistory).map(([date, entry]) => {
|
|
3625
|
+
const day = entry;
|
|
3626
|
+
return [
|
|
3627
|
+
date,
|
|
3628
|
+
{
|
|
3629
|
+
...day,
|
|
3630
|
+
positions: (day.positions || []).map(enrichApyPosition)
|
|
3631
|
+
}
|
|
3632
|
+
];
|
|
3633
|
+
})
|
|
3634
|
+
);
|
|
3591
3635
|
return {
|
|
3592
3636
|
success: true,
|
|
3593
3637
|
walletAddress,
|
|
3594
|
-
history
|
|
3638
|
+
history,
|
|
3595
3639
|
totalDays: data.total_days || data.totalDays || 0,
|
|
3596
3640
|
requestedDays: data.requested_days || data.requestedDays,
|
|
3597
3641
|
weightedApyWithRzfiAfterFee: data.average_final_weighted_apy_after_fee_with_rzfi,
|
package/dist/index.mjs
CHANGED
|
@@ -958,19 +958,19 @@ function convertStrategyToPublicAndNaming(obj) {
|
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
960
|
if (result.average_apy_without_fee !== void 0) {
|
|
961
|
-
result.
|
|
961
|
+
result.average_apy_withFee = result.average_apy_without_fee;
|
|
962
962
|
delete result.average_apy_without_fee;
|
|
963
963
|
}
|
|
964
964
|
if (result.average_apy_with_rzfi_without_fee !== void 0) {
|
|
965
|
-
result.
|
|
965
|
+
result.average_apy_with_rzfi_withFee = result.average_apy_with_rzfi_without_fee;
|
|
966
966
|
delete result.average_apy_with_rzfi_without_fee;
|
|
967
967
|
}
|
|
968
968
|
if (result.events_average_apy_without_fee !== void 0) {
|
|
969
|
-
result.
|
|
969
|
+
result.events_average_apy_withFee = result.events_average_apy_without_fee;
|
|
970
970
|
delete result.events_average_apy_without_fee;
|
|
971
971
|
}
|
|
972
972
|
if (result.events_average_apy_with_rzfi_without_fee !== void 0) {
|
|
973
|
-
result.
|
|
973
|
+
result.events_average_apy_with_rzfi_withFee = result.events_average_apy_with_rzfi_without_fee;
|
|
974
974
|
delete result.events_average_apy_with_rzfi_without_fee;
|
|
975
975
|
}
|
|
976
976
|
return result;
|
|
@@ -1066,6 +1066,14 @@ function humanAmountToRaw(human, decimals) {
|
|
|
1066
1066
|
const fracPart = BigInt(frac.padEnd(decimals, "0").slice(0, decimals) || "0");
|
|
1067
1067
|
return wholePart * 10n ** BigInt(decimals) + fracPart;
|
|
1068
1068
|
}
|
|
1069
|
+
function applyApyFee(apy) {
|
|
1070
|
+
return apy * (1 - ZYFI_FEE_RATE);
|
|
1071
|
+
}
|
|
1072
|
+
function applyApyFeeToString(apy) {
|
|
1073
|
+
const parsed = Number.parseFloat(apy);
|
|
1074
|
+
if (!Number.isFinite(parsed)) return apy;
|
|
1075
|
+
return String(applyApyFee(parsed));
|
|
1076
|
+
}
|
|
1069
1077
|
function formatHumanAmount(value) {
|
|
1070
1078
|
if (!Number.isFinite(value) || value === 0) return "0";
|
|
1071
1079
|
const fixed = value.toFixed(18);
|
|
@@ -1196,22 +1204,37 @@ function enrichPositions(positions, byChainByToken) {
|
|
|
1196
1204
|
});
|
|
1197
1205
|
});
|
|
1198
1206
|
return positions.map((position, index) => {
|
|
1207
|
+
const enriched = { ...position };
|
|
1208
|
+
if (typeof position.pool_apy === "number") {
|
|
1209
|
+
enriched.pool_apy_withFee = applyApyFee(position.pool_apy);
|
|
1210
|
+
}
|
|
1199
1211
|
const underlying = position.underlyingAmount;
|
|
1200
1212
|
if (underlying === void 0) {
|
|
1201
|
-
return
|
|
1213
|
+
return enriched;
|
|
1202
1214
|
}
|
|
1203
1215
|
const feeShare = feeShareByIndex.get(index) ?? 0;
|
|
1204
1216
|
const decimals = resolvePositionDecimals(position);
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
)
|
|
1212
|
-
};
|
|
1217
|
+
enriched.underlyingAmountWithFee = applyFeeToDecimalWei(
|
|
1218
|
+
underlying,
|
|
1219
|
+
feeShare,
|
|
1220
|
+
decimals
|
|
1221
|
+
);
|
|
1222
|
+
return enriched;
|
|
1213
1223
|
});
|
|
1214
1224
|
}
|
|
1225
|
+
function enrichApyPosition(position) {
|
|
1226
|
+
return {
|
|
1227
|
+
...position,
|
|
1228
|
+
apy_withFee: applyApyFee(position.apy)
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
function enrichRebalanceLog(log) {
|
|
1232
|
+
return {
|
|
1233
|
+
...log,
|
|
1234
|
+
...log.oldApy !== void 0 ? { oldApy_withFee: applyApyFeeToString(log.oldApy) } : {},
|
|
1235
|
+
...log.newApy !== void 0 ? { newApy_withFee: applyApyFeeToString(log.newApy) } : {}
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1215
1238
|
function enrichPortfolioWithFees(portfolio, currentEarningsByChain) {
|
|
1216
1239
|
const { byToken, byChainByToken } = computePendingFees(currentEarningsByChain);
|
|
1217
1240
|
const portfolioByAssetType = portfolio.portfolioByAssetType ? Object.fromEntries(
|
|
@@ -2790,7 +2813,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2790
2813
|
}
|
|
2791
2814
|
/**
|
|
2792
2815
|
* Get portfolio positions and balances for a user, enriched with
|
|
2793
|
-
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2816
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`)
|
|
2817
|
+
* and net APY (`pool_apy_withFee` = `pool_apy × 0.9`).
|
|
2794
2818
|
*
|
|
2795
2819
|
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
2796
2820
|
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
@@ -3130,7 +3154,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3130
3154
|
if (options?.fromDate) endpoint += `&fromDate=${options.fromDate}`;
|
|
3131
3155
|
if (options?.toDate) endpoint += `&toDate=${options.toDate}`;
|
|
3132
3156
|
const response = await this.httpClient.get(endpoint);
|
|
3133
|
-
const convertedData = convertStrategiesToPublic(
|
|
3157
|
+
const convertedData = convertStrategiesToPublic(
|
|
3158
|
+
response.data || []
|
|
3159
|
+
).map(
|
|
3160
|
+
(entry) => entry.rebalanceLog ? {
|
|
3161
|
+
...entry,
|
|
3162
|
+
rebalanceLog: enrichRebalanceLog(entry.rebalanceLog)
|
|
3163
|
+
} : entry
|
|
3164
|
+
);
|
|
3134
3165
|
return {
|
|
3135
3166
|
success: true,
|
|
3136
3167
|
walletAddress,
|
|
@@ -3556,10 +3587,23 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3556
3587
|
DATA_ENDPOINTS.DAILY_APY_HISTORY_WEIGHTED(walletAddress, days)
|
|
3557
3588
|
);
|
|
3558
3589
|
const data = response.data || response;
|
|
3590
|
+
const rawHistory = data.history || {};
|
|
3591
|
+
const history = Object.fromEntries(
|
|
3592
|
+
Object.entries(rawHistory).map(([date, entry]) => {
|
|
3593
|
+
const day = entry;
|
|
3594
|
+
return [
|
|
3595
|
+
date,
|
|
3596
|
+
{
|
|
3597
|
+
...day,
|
|
3598
|
+
positions: (day.positions || []).map(enrichApyPosition)
|
|
3599
|
+
}
|
|
3600
|
+
];
|
|
3601
|
+
})
|
|
3602
|
+
);
|
|
3559
3603
|
return {
|
|
3560
3604
|
success: true,
|
|
3561
3605
|
walletAddress,
|
|
3562
|
-
history
|
|
3606
|
+
history,
|
|
3563
3607
|
totalDays: data.total_days || data.totalDays || 0,
|
|
3564
3608
|
requestedDays: data.requested_days || data.requestedDays,
|
|
3565
3609
|
weightedApyWithRzfiAfterFee: data.average_final_weighted_apy_after_fee_with_rzfi,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.51",
|
|
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",
|