@zyfai/sdk 0.2.44 → 0.2.46
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 +43 -3
- package/dist/index.d.mts +47 -15
- package/dist/index.d.ts +47 -15
- package/dist/index.js +371 -31
- package/dist/index.mjs +371 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -403,9 +403,13 @@ Only deposits on Mainnet in USDC that would leave the Safe below 5 USDC are reje
|
|
|
403
403
|
const result = await sdk.depositFunds(
|
|
404
404
|
userAddress,
|
|
405
405
|
8453, // Chain ID
|
|
406
|
-
"10000000" // Amount: 10 USDC = 10 * 10^6
|
|
406
|
+
"10000000", // Amount: 10 USDC = 10 * 10^6
|
|
407
|
+
"USDC"
|
|
407
408
|
);
|
|
408
409
|
|
|
410
|
+
// First deposit with aggressive strategy (protocol patching)
|
|
411
|
+
await sdk.depositFunds(userAddress, 8453, "10000000", "USDC", "aggressive");
|
|
412
|
+
|
|
409
413
|
if (result.success) {
|
|
410
414
|
console.log("Deposit successful!");
|
|
411
415
|
console.log("Transaction Hash:", result.txHash);
|
|
@@ -415,10 +419,10 @@ if (result.success) {
|
|
|
415
419
|
**Note:**
|
|
416
420
|
|
|
417
421
|
- Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
|
|
418
|
-
-
|
|
422
|
+
- `asset` is required (`"USDC"`, `"WETH"`, or `"EURC"` — EURC on Mainnet/Base only); token address is selected from that for the chain
|
|
419
423
|
- On Ethereum Mainnet, the total Safe balance in USDC must be at least 5 USDC after the deposit (test threshold); smaller top-ups are allowed if the Safe already holds enough USDC to meet the minimum
|
|
420
424
|
- 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
|
|
421
|
-
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, and EURC** across all supported chains (EURC on Mainnet/Base only → `assetTypeSettings.[usdc|eth|eurc]`). Later deposits skip this.
|
|
425
|
+
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, and EURC** across all supported chains (EURC on Mainnet/Base only → `assetTypeSettings.[usdc|eth|eurc]`). Pass optional `strategy` (`"conservative"` default or `"aggressive"`) — same role as the former `deploySafe` strategy argument. Later deposits skip this.
|
|
422
426
|
|
|
423
427
|
#### Log External Deposit (For Sponsored Transactions)
|
|
424
428
|
|
|
@@ -528,6 +532,32 @@ positions.positions.forEach((bundle) => {
|
|
|
528
532
|
|
|
529
533
|
**Note**: This endpoint uses `/api/v1/data/position?walletAddress={address}` (Smart wallet address) and returns bundles with nested slot data. Use each slot's `underlyingAmount` for the canonical token balance.
|
|
530
534
|
|
|
535
|
+
#### Get Portfolio (with fee-adjusted balances)
|
|
536
|
+
|
|
537
|
+
Returns the full wallet portfolio plus net-of-pending-fee fields. Pending fee is
|
|
538
|
+
`current` onchain earnings × 10%. Gross balances are unchanged.
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
const { portfolio } = await sdk.getPortfolio(userAddress);
|
|
542
|
+
|
|
543
|
+
// Gross vs net (after pending Zyfi fee)
|
|
544
|
+
console.log(portfolio.portfolioByAssetType?.usdc?.balance);
|
|
545
|
+
console.log(portfolio.portfolioByAssetType?.usdc?.balanceWithFee);
|
|
546
|
+
|
|
547
|
+
portfolio.positions?.forEach((slot) => {
|
|
548
|
+
console.log(slot.pool, slot.underlyingAmount, slot.underlyingAmountWithFee);
|
|
549
|
+
});
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
**Fee formula**
|
|
553
|
+
|
|
554
|
+
- Pending fee = `current_earnings × 0.1` (unrealised yield only)
|
|
555
|
+
- `balanceWithFee` / `underlyingAmountWithFee` = live − pending fee share
|
|
556
|
+
- If earnings cannot be fetched, `*WithFee` equals the gross value
|
|
557
|
+
|
|
558
|
+
**Note**: Portfolio balances are live; earnings used for the fee may come from a
|
|
559
|
+
snapshot, so net values can differ slightly from a fully live calculation.
|
|
560
|
+
|
|
531
561
|
### 8. Analytics & Data Endpoints
|
|
532
562
|
|
|
533
563
|
The SDK provides access to various analytics and data endpoints:
|
|
@@ -725,13 +755,23 @@ const earnings = await sdk.getOnchainEarnings(walletAddress);
|
|
|
725
755
|
console.log("Total by token:", earnings.data.totalEarningsByToken);
|
|
726
756
|
// Per-chain totals (chain → token → amount): { "8453": { "USDC": "0.01" }, "42161": {...} }
|
|
727
757
|
console.log("Total by chain:", earnings.data.totalEarningsByChain);
|
|
758
|
+
// Net totals: lifetime + unrealized + current × 0.9 (never total × 0.9)
|
|
759
|
+
console.log("Net by token:", earnings.data.totalEarningsByTokenWithFee);
|
|
760
|
+
console.log("Net by chain:", earnings.data.totalEarningsByChainWithFee);
|
|
728
761
|
```
|
|
729
762
|
|
|
763
|
+
**Fee formula for `*WithFee` earnings fields**
|
|
764
|
+
|
|
765
|
+
- `totalWithFee = lifetime + unrealized + current × 0.9`
|
|
766
|
+
- Do **not** apply `× 0.9` to lifetime or unrealized
|
|
767
|
+
- Aligns with portfolio: pending fee = `current × 0.1` only
|
|
768
|
+
|
|
730
769
|
#### Calculate Onchain Earnings (Refresh)
|
|
731
770
|
|
|
732
771
|
```typescript
|
|
733
772
|
const updated = await sdk.calculateOnchainEarnings(walletAddress);
|
|
734
773
|
console.log("Updated earnings:", updated.data.totalEarningsByToken);
|
|
774
|
+
console.log("Net earnings:", updated.data.totalEarningsByTokenWithFee);
|
|
735
775
|
```
|
|
736
776
|
|
|
737
777
|
#### Get Daily Earnings
|
package/dist/index.d.mts
CHANGED
|
@@ -142,6 +142,8 @@ interface Portfolio {
|
|
|
142
142
|
}
|
|
143
143
|
interface PortfolioAssetBalance {
|
|
144
144
|
balance: Hex;
|
|
145
|
+
/** Net balance after pending Zyfi fee (live − current × feeRate). */
|
|
146
|
+
balanceWithFee?: Hex;
|
|
145
147
|
decimals: number;
|
|
146
148
|
}
|
|
147
149
|
type PortfolioByAssetType = Record<string, PortfolioAssetBalance>;
|
|
@@ -175,8 +177,12 @@ interface PositionSlot {
|
|
|
175
177
|
token_id?: string;
|
|
176
178
|
token_symbol?: string;
|
|
177
179
|
token_icon?: string;
|
|
180
|
+
assetType?: string;
|
|
181
|
+
decimals?: number;
|
|
178
182
|
amount?: string;
|
|
179
183
|
underlyingAmount?: string;
|
|
184
|
+
/** Net underlying amount after this position's share of pending Zyfi fee. */
|
|
185
|
+
underlyingAmountWithFee?: string;
|
|
180
186
|
pool_apy?: number;
|
|
181
187
|
pool_tvl?: number;
|
|
182
188
|
liquidity?: number;
|
|
@@ -288,6 +294,13 @@ interface OnchainEarnings {
|
|
|
288
294
|
walletAddress: string;
|
|
289
295
|
totalEarningsByToken: TokenEarnings;
|
|
290
296
|
totalEarningsByChain?: ChainTokenEarnings;
|
|
297
|
+
/**
|
|
298
|
+
* Net totals: lifetime + unrealized + current × (1 - feeRate).
|
|
299
|
+
* Unrealized is treated like lifetime (no pending fee).
|
|
300
|
+
* Does not apply feeRate to lifetime (already crystallised).
|
|
301
|
+
*/
|
|
302
|
+
totalEarningsByTokenWithFee: TokenEarnings;
|
|
303
|
+
totalEarningsByChainWithFee?: ChainTokenEarnings;
|
|
291
304
|
lastCheckTimestamp?: string;
|
|
292
305
|
lastLogDate?: Record<string, string | null>;
|
|
293
306
|
}
|
|
@@ -1009,12 +1022,15 @@ declare class ZyfaiSDK {
|
|
|
1009
1022
|
* Deposit funds from EOA to Safe smart wallet
|
|
1010
1023
|
* Transfers tokens from the connected wallet to the user's Safe and logs the deposit
|
|
1011
1024
|
*
|
|
1012
|
-
* Token is
|
|
1013
|
-
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
|
|
1025
|
+
* Token address is selected from `asset` for the given chain:
|
|
1026
|
+
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC or WETH
|
|
1027
|
+
* - Ethereum Mainnet (1), Base (8453): EURC
|
|
1014
1028
|
*
|
|
1015
1029
|
* On the account's first deposit (USDC profile has no chains yet), patches
|
|
1016
1030
|
* protocol selection for USDC, WETH, and EURC across all supported chains
|
|
1017
1031
|
* (EURC on Mainnet/Base only) before the transfer and log_deposit.
|
|
1032
|
+
* Pass `strategy` to select protocols for that first-deposit setup
|
|
1033
|
+
* (same role as the former `deploySafe` strategy argument).
|
|
1018
1034
|
*
|
|
1019
1035
|
* Minimum portfolio balance enforced (Safe balance + deposit amount),
|
|
1020
1036
|
* configured per-chain in `MIN_PORTFOLIO_BALANCE`:
|
|
@@ -1027,8 +1043,10 @@ declare class ZyfaiSDK {
|
|
|
1027
1043
|
* @param userAddress - User's address (owner of the Safe)
|
|
1028
1044
|
* @param chainId - Target chain ID
|
|
1029
1045
|
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
1030
|
-
* @param asset -
|
|
1046
|
+
* @param asset - Asset symbol: "USDC", "WETH", or "EURC".
|
|
1031
1047
|
* EURC is supported on Ethereum Mainnet and Base only.
|
|
1048
|
+
* @param strategy - Optional strategy for first-deposit protocol patching:
|
|
1049
|
+
* "conservative" (default) or "aggressive"
|
|
1032
1050
|
* @returns Deposit response with transaction hash
|
|
1033
1051
|
*
|
|
1034
1052
|
* @example
|
|
@@ -1037,11 +1055,15 @@ declare class ZyfaiSDK {
|
|
|
1037
1055
|
* const result = await sdk.depositFunds(
|
|
1038
1056
|
* "0xUser...",
|
|
1039
1057
|
* 8453,
|
|
1040
|
-
* "10000000000"
|
|
1058
|
+
* "10000000000",
|
|
1059
|
+
* "USDC"
|
|
1041
1060
|
* );
|
|
1061
|
+
*
|
|
1062
|
+
* // First deposit with aggressive strategy
|
|
1063
|
+
* await sdk.depositFunds(userAddress, 8453, "10000000000", "USDC", "aggressive");
|
|
1042
1064
|
* ```
|
|
1043
1065
|
*/
|
|
1044
|
-
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string, asset?:
|
|
1066
|
+
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1045
1067
|
/**
|
|
1046
1068
|
* Log a deposit that was executed client-side
|
|
1047
1069
|
*
|
|
@@ -1140,19 +1162,23 @@ declare class ZyfaiSDK {
|
|
|
1140
1162
|
*/
|
|
1141
1163
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
1142
1164
|
/**
|
|
1143
|
-
* Get
|
|
1165
|
+
* Get portfolio positions and balances for a user, enriched with
|
|
1166
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`).
|
|
1167
|
+
*
|
|
1168
|
+
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
1169
|
+
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
1170
|
+
* equals the gross value so the response shape stays stable.
|
|
1171
|
+
*
|
|
1172
|
+
* Note: portfolio balances are live; earnings used for the fee may be from
|
|
1173
|
+
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
1144
1174
|
*
|
|
1145
1175
|
* @param userAddress - User's EOA address
|
|
1146
|
-
* @
|
|
1147
|
-
* @returns User's positions across all protocols
|
|
1176
|
+
* @returns Portfolio with optional fee-adjusted balance fields
|
|
1148
1177
|
*
|
|
1149
1178
|
* @example
|
|
1150
1179
|
* ```typescript
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
* // Get positions on a specific chain
|
|
1155
|
-
* const basePositions = await sdk.getPositions(userAddress, 8453);
|
|
1180
|
+
* const { portfolio } = await sdk.getPortfolio(userAddress);
|
|
1181
|
+
* console.log(portfolio.portfolioByAssetType?.usdc?.balanceWithFee);
|
|
1156
1182
|
* ```
|
|
1157
1183
|
*/
|
|
1158
1184
|
getPortfolio(userAddress: string): Promise<PortfolioDetailedResponse>;
|
|
@@ -1275,6 +1301,10 @@ declare class ZyfaiSDK {
|
|
|
1275
1301
|
/**
|
|
1276
1302
|
* Get onchain earnings for a wallet
|
|
1277
1303
|
*
|
|
1304
|
+
* Includes gross totals plus net-of-fee totals:
|
|
1305
|
+
* `totalEarningsByTokenWithFee = lifetime + unrealized + current × (1 - feeRate)`.
|
|
1306
|
+
* Lifetime and unrealized are never multiplied by the keep-rate.
|
|
1307
|
+
*
|
|
1278
1308
|
* @param walletAddress - Smart wallet address
|
|
1279
1309
|
* @returns Onchain earnings data with per-token breakdowns
|
|
1280
1310
|
*
|
|
@@ -1282,13 +1312,15 @@ declare class ZyfaiSDK {
|
|
|
1282
1312
|
* ```typescript
|
|
1283
1313
|
* const earnings = await sdk.getOnchainEarnings("0x...");
|
|
1284
1314
|
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
1315
|
+
* console.log("Net USDC:", earnings.data.totalEarningsByTokenWithFee["USDC"]);
|
|
1285
1316
|
* console.log("Total on Arbitrum:", earnings.data.totalEarningsByChain?.["42161"]);
|
|
1286
1317
|
* ```
|
|
1287
1318
|
*/
|
|
1288
1319
|
getOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
|
|
1289
1320
|
/**
|
|
1290
1321
|
* Calculate/refresh onchain earnings for a wallet
|
|
1291
|
-
* This triggers a recalculation of earnings on the backend
|
|
1322
|
+
* This triggers a recalculation of earnings on the backend.
|
|
1323
|
+
* Response shape matches `getOnchainEarnings` (includes `*WithFee` nets).
|
|
1292
1324
|
*
|
|
1293
1325
|
* @param walletAddress - Smart wallet address
|
|
1294
1326
|
* @returns Updated onchain earnings data with per-token breakdowns
|
|
@@ -1297,7 +1329,7 @@ declare class ZyfaiSDK {
|
|
|
1297
1329
|
* ```typescript
|
|
1298
1330
|
* const earnings = await sdk.calculateOnchainEarnings("0x...");
|
|
1299
1331
|
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
1300
|
-
* console.log("
|
|
1332
|
+
* console.log("Net USDC:", earnings.data.totalEarningsByTokenWithFee["USDC"]);
|
|
1301
1333
|
* ```
|
|
1302
1334
|
*/
|
|
1303
1335
|
calculateOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -142,6 +142,8 @@ interface Portfolio {
|
|
|
142
142
|
}
|
|
143
143
|
interface PortfolioAssetBalance {
|
|
144
144
|
balance: Hex;
|
|
145
|
+
/** Net balance after pending Zyfi fee (live − current × feeRate). */
|
|
146
|
+
balanceWithFee?: Hex;
|
|
145
147
|
decimals: number;
|
|
146
148
|
}
|
|
147
149
|
type PortfolioByAssetType = Record<string, PortfolioAssetBalance>;
|
|
@@ -175,8 +177,12 @@ interface PositionSlot {
|
|
|
175
177
|
token_id?: string;
|
|
176
178
|
token_symbol?: string;
|
|
177
179
|
token_icon?: string;
|
|
180
|
+
assetType?: string;
|
|
181
|
+
decimals?: number;
|
|
178
182
|
amount?: string;
|
|
179
183
|
underlyingAmount?: string;
|
|
184
|
+
/** Net underlying amount after this position's share of pending Zyfi fee. */
|
|
185
|
+
underlyingAmountWithFee?: string;
|
|
180
186
|
pool_apy?: number;
|
|
181
187
|
pool_tvl?: number;
|
|
182
188
|
liquidity?: number;
|
|
@@ -288,6 +294,13 @@ interface OnchainEarnings {
|
|
|
288
294
|
walletAddress: string;
|
|
289
295
|
totalEarningsByToken: TokenEarnings;
|
|
290
296
|
totalEarningsByChain?: ChainTokenEarnings;
|
|
297
|
+
/**
|
|
298
|
+
* Net totals: lifetime + unrealized + current × (1 - feeRate).
|
|
299
|
+
* Unrealized is treated like lifetime (no pending fee).
|
|
300
|
+
* Does not apply feeRate to lifetime (already crystallised).
|
|
301
|
+
*/
|
|
302
|
+
totalEarningsByTokenWithFee: TokenEarnings;
|
|
303
|
+
totalEarningsByChainWithFee?: ChainTokenEarnings;
|
|
291
304
|
lastCheckTimestamp?: string;
|
|
292
305
|
lastLogDate?: Record<string, string | null>;
|
|
293
306
|
}
|
|
@@ -1009,12 +1022,15 @@ declare class ZyfaiSDK {
|
|
|
1009
1022
|
* Deposit funds from EOA to Safe smart wallet
|
|
1010
1023
|
* Transfers tokens from the connected wallet to the user's Safe and logs the deposit
|
|
1011
1024
|
*
|
|
1012
|
-
* Token is
|
|
1013
|
-
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
|
|
1025
|
+
* Token address is selected from `asset` for the given chain:
|
|
1026
|
+
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC or WETH
|
|
1027
|
+
* - Ethereum Mainnet (1), Base (8453): EURC
|
|
1014
1028
|
*
|
|
1015
1029
|
* On the account's first deposit (USDC profile has no chains yet), patches
|
|
1016
1030
|
* protocol selection for USDC, WETH, and EURC across all supported chains
|
|
1017
1031
|
* (EURC on Mainnet/Base only) before the transfer and log_deposit.
|
|
1032
|
+
* Pass `strategy` to select protocols for that first-deposit setup
|
|
1033
|
+
* (same role as the former `deploySafe` strategy argument).
|
|
1018
1034
|
*
|
|
1019
1035
|
* Minimum portfolio balance enforced (Safe balance + deposit amount),
|
|
1020
1036
|
* configured per-chain in `MIN_PORTFOLIO_BALANCE`:
|
|
@@ -1027,8 +1043,10 @@ declare class ZyfaiSDK {
|
|
|
1027
1043
|
* @param userAddress - User's address (owner of the Safe)
|
|
1028
1044
|
* @param chainId - Target chain ID
|
|
1029
1045
|
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
1030
|
-
* @param asset -
|
|
1046
|
+
* @param asset - Asset symbol: "USDC", "WETH", or "EURC".
|
|
1031
1047
|
* EURC is supported on Ethereum Mainnet and Base only.
|
|
1048
|
+
* @param strategy - Optional strategy for first-deposit protocol patching:
|
|
1049
|
+
* "conservative" (default) or "aggressive"
|
|
1032
1050
|
* @returns Deposit response with transaction hash
|
|
1033
1051
|
*
|
|
1034
1052
|
* @example
|
|
@@ -1037,11 +1055,15 @@ declare class ZyfaiSDK {
|
|
|
1037
1055
|
* const result = await sdk.depositFunds(
|
|
1038
1056
|
* "0xUser...",
|
|
1039
1057
|
* 8453,
|
|
1040
|
-
* "10000000000"
|
|
1058
|
+
* "10000000000",
|
|
1059
|
+
* "USDC"
|
|
1041
1060
|
* );
|
|
1061
|
+
*
|
|
1062
|
+
* // First deposit with aggressive strategy
|
|
1063
|
+
* await sdk.depositFunds(userAddress, 8453, "10000000000", "USDC", "aggressive");
|
|
1042
1064
|
* ```
|
|
1043
1065
|
*/
|
|
1044
|
-
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string, asset?:
|
|
1066
|
+
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1045
1067
|
/**
|
|
1046
1068
|
* Log a deposit that was executed client-side
|
|
1047
1069
|
*
|
|
@@ -1140,19 +1162,23 @@ declare class ZyfaiSDK {
|
|
|
1140
1162
|
*/
|
|
1141
1163
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
1142
1164
|
/**
|
|
1143
|
-
* Get
|
|
1165
|
+
* Get portfolio positions and balances for a user, enriched with
|
|
1166
|
+
* net-of-pending-fee fields (`balanceWithFee`, `underlyingAmountWithFee`).
|
|
1167
|
+
*
|
|
1168
|
+
* Pending fee is derived from onchain `current` earnings × fee rate.
|
|
1169
|
+
* Gross balances are unchanged. If earnings cannot be fetched, `*WithFee`
|
|
1170
|
+
* equals the gross value so the response shape stays stable.
|
|
1171
|
+
*
|
|
1172
|
+
* Note: portfolio balances are live; earnings used for the fee may be from
|
|
1173
|
+
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
1144
1174
|
*
|
|
1145
1175
|
* @param userAddress - User's EOA address
|
|
1146
|
-
* @
|
|
1147
|
-
* @returns User's positions across all protocols
|
|
1176
|
+
* @returns Portfolio with optional fee-adjusted balance fields
|
|
1148
1177
|
*
|
|
1149
1178
|
* @example
|
|
1150
1179
|
* ```typescript
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
* // Get positions on a specific chain
|
|
1155
|
-
* const basePositions = await sdk.getPositions(userAddress, 8453);
|
|
1180
|
+
* const { portfolio } = await sdk.getPortfolio(userAddress);
|
|
1181
|
+
* console.log(portfolio.portfolioByAssetType?.usdc?.balanceWithFee);
|
|
1156
1182
|
* ```
|
|
1157
1183
|
*/
|
|
1158
1184
|
getPortfolio(userAddress: string): Promise<PortfolioDetailedResponse>;
|
|
@@ -1275,6 +1301,10 @@ declare class ZyfaiSDK {
|
|
|
1275
1301
|
/**
|
|
1276
1302
|
* Get onchain earnings for a wallet
|
|
1277
1303
|
*
|
|
1304
|
+
* Includes gross totals plus net-of-fee totals:
|
|
1305
|
+
* `totalEarningsByTokenWithFee = lifetime + unrealized + current × (1 - feeRate)`.
|
|
1306
|
+
* Lifetime and unrealized are never multiplied by the keep-rate.
|
|
1307
|
+
*
|
|
1278
1308
|
* @param walletAddress - Smart wallet address
|
|
1279
1309
|
* @returns Onchain earnings data with per-token breakdowns
|
|
1280
1310
|
*
|
|
@@ -1282,13 +1312,15 @@ declare class ZyfaiSDK {
|
|
|
1282
1312
|
* ```typescript
|
|
1283
1313
|
* const earnings = await sdk.getOnchainEarnings("0x...");
|
|
1284
1314
|
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
1315
|
+
* console.log("Net USDC:", earnings.data.totalEarningsByTokenWithFee["USDC"]);
|
|
1285
1316
|
* console.log("Total on Arbitrum:", earnings.data.totalEarningsByChain?.["42161"]);
|
|
1286
1317
|
* ```
|
|
1287
1318
|
*/
|
|
1288
1319
|
getOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
|
|
1289
1320
|
/**
|
|
1290
1321
|
* Calculate/refresh onchain earnings for a wallet
|
|
1291
|
-
* This triggers a recalculation of earnings on the backend
|
|
1322
|
+
* This triggers a recalculation of earnings on the backend.
|
|
1323
|
+
* Response shape matches `getOnchainEarnings` (includes `*WithFee` nets).
|
|
1292
1324
|
*
|
|
1293
1325
|
* @param walletAddress - Smart wallet address
|
|
1294
1326
|
* @returns Updated onchain earnings data with per-token breakdowns
|
|
@@ -1297,7 +1329,7 @@ declare class ZyfaiSDK {
|
|
|
1297
1329
|
* ```typescript
|
|
1298
1330
|
* const earnings = await sdk.calculateOnchainEarnings("0x...");
|
|
1299
1331
|
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
1300
|
-
* console.log("
|
|
1332
|
+
* console.log("Net USDC:", earnings.data.totalEarningsByTokenWithFee["USDC"]);
|
|
1301
1333
|
* ```
|
|
1302
1334
|
*/
|
|
1303
1335
|
calculateOnchainEarnings(walletAddress: string): Promise<OnchainEarningsResponse>;
|