@zyfai/sdk 0.2.23 → 0.2.25
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 +23 -10
- package/dist/index.d.mts +101 -114
- package/dist/index.d.ts +101 -114
- package/dist/index.js +273 -192
- package/dist/index.mjs +273 -192
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25,8 +25,8 @@ var ENDPOINTS = {
|
|
|
25
25
|
// Data (v1)
|
|
26
26
|
DATA_POSITION: (walletAddress) => `/data/position?walletAddress=${walletAddress}`,
|
|
27
27
|
DATA_HISTORY: (walletAddress, chainId) => `/data/history?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
28
|
-
DATA_TVL: "/data/tvl",
|
|
29
|
-
DATA_VOLUME:
|
|
28
|
+
DATA_TVL: "/data/usd-tvl",
|
|
29
|
+
DATA_VOLUME: (assetType) => `/data/volume?assetType=${assetType}`,
|
|
30
30
|
DATA_FIRST_TOPUP: (walletAddress, chainId) => `/data/first-topup?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
31
31
|
DATA_ACTIVE_WALLETS: (chainId) => `/data/active-wallets?chainId=${chainId}`,
|
|
32
32
|
DATA_BY_EOA: (address) => `/data/by-eoa?address=${address}`,
|
|
@@ -45,25 +45,48 @@ var DATA_ENDPOINTS = {
|
|
|
45
45
|
// User Initialization
|
|
46
46
|
USER_INITIALIZE: "/api/earnings/initialize",
|
|
47
47
|
// Earnings
|
|
48
|
-
ONCHAIN_EARNINGS: (walletAddress) => `/
|
|
49
|
-
CALCULATE_ONCHAIN_EARNINGS: "/
|
|
48
|
+
ONCHAIN_EARNINGS: (walletAddress) => `/onchain-earnings/onchain-earnings?walletAddress=${walletAddress}`,
|
|
49
|
+
CALCULATE_ONCHAIN_EARNINGS: "/onchain-earnings/calculate-onchain-earnings",
|
|
50
50
|
DAILY_EARNINGS: (walletAddress, startDate, endDate) => {
|
|
51
|
-
let url = `/
|
|
51
|
+
let url = `/onchain-earnings/daily-earnings?walletAddress=${walletAddress}`;
|
|
52
52
|
if (startDate) url += `&startDate=${startDate}`;
|
|
53
53
|
if (endDate) url += `&endDate=${endDate}`;
|
|
54
54
|
return url;
|
|
55
55
|
},
|
|
56
|
-
// Portfolio
|
|
57
|
-
DEBANK_PORTFOLIO_MULTICHAIN: (address) => `/debank/portfolio/multichain/${address}`,
|
|
58
56
|
// Opportunities
|
|
59
|
-
OPPORTUNITIES_SAFE: (chainId) =>
|
|
60
|
-
|
|
57
|
+
OPPORTUNITIES_SAFE: (chainId, asset, status) => {
|
|
58
|
+
const params = [];
|
|
59
|
+
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
60
|
+
if (asset) params.push(`asset=${asset}`);
|
|
61
|
+
if (status) params.push(`status=${status}`);
|
|
62
|
+
return params.length > 0 ? `/opportunities/safe?${params.join("&")}` : "/opportunities/safe";
|
|
63
|
+
},
|
|
64
|
+
OPPORTUNITIES_DEGEN: (chainId, asset, status) => {
|
|
65
|
+
const params = [];
|
|
66
|
+
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
67
|
+
if (asset) params.push(`asset=${asset}`);
|
|
68
|
+
if (status) params.push(`status=${status}`);
|
|
69
|
+
return params.length > 0 ? `/opportunities/degen-strategies?${params.join("&")}` : "/opportunities/degen-strategies";
|
|
70
|
+
},
|
|
61
71
|
// APY History
|
|
62
|
-
DAILY_APY_HISTORY_WEIGHTED: (walletAddress, days) => `/daily-apy-history/weighted/${walletAddress}${days ? `?days=${days}` : ""}`,
|
|
72
|
+
DAILY_APY_HISTORY_WEIGHTED: (walletAddress, days) => `/daily-apy-history/weighted-multi-asset/${walletAddress}${days ? `?days=${days}` : ""}`,
|
|
63
73
|
// Rebalance
|
|
64
|
-
REBALANCE_INFO: (
|
|
74
|
+
REBALANCE_INFO: (options) => {
|
|
75
|
+
const params = [];
|
|
76
|
+
if (options?.isCrossChain !== void 0) params.push(`isCrossChain=${options.isCrossChain}`);
|
|
77
|
+
if (options?.tokenSymbol) params.push(`tokenSymbol=${options.tokenSymbol}`);
|
|
78
|
+
return params.length > 0 ? `/rebalance/rebalance-info?${params.join("&")}` : "/rebalance/rebalance-info";
|
|
79
|
+
},
|
|
65
80
|
// APY Per Strategy
|
|
66
|
-
APY_PER_STRATEGY: (
|
|
81
|
+
APY_PER_STRATEGY: (options = {}) => {
|
|
82
|
+
const params = [];
|
|
83
|
+
if (options.isCrossChain !== void 0) params.push(`isCrossChain=${options.isCrossChain}`);
|
|
84
|
+
if (options.days !== void 0) params.push(`days=${options.days}`);
|
|
85
|
+
if (options.strategy) params.push(`strategy=${options.strategy}`);
|
|
86
|
+
if (options.chainId !== void 0) params.push(`chainId=${options.chainId}`);
|
|
87
|
+
if (options.tokenSymbol) params.push(`tokenSymbol=${options.tokenSymbol}`);
|
|
88
|
+
return params.length > 0 ? `/rebalance/rebalance-info?${params.join("&")}` : "/rebalance/rebalance-info";
|
|
89
|
+
}
|
|
67
90
|
};
|
|
68
91
|
|
|
69
92
|
// src/utils/http-client.ts
|
|
@@ -368,8 +391,71 @@ var DEFAULT_TOKEN_ADDRESSES = {
|
|
|
368
391
|
9745: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb"
|
|
369
392
|
// USDT on Plasma
|
|
370
393
|
};
|
|
371
|
-
var
|
|
372
|
-
|
|
394
|
+
var ASSET_CONFIGS = {
|
|
395
|
+
USDC: {
|
|
396
|
+
symbol: "USDC",
|
|
397
|
+
assetType: "usdc",
|
|
398
|
+
displayName: "USDC",
|
|
399
|
+
icon: "/ai-dashboard/usdc-token.png",
|
|
400
|
+
decimals: 6,
|
|
401
|
+
tokenSymbols: ["USDC", "USDC.e", "USDT", "USDT0"],
|
|
402
|
+
tokenSymbolsByChainId: {
|
|
403
|
+
8453: "USDC",
|
|
404
|
+
42161: "USDC",
|
|
405
|
+
9745: "USDT0",
|
|
406
|
+
146: "USDC.e",
|
|
407
|
+
1: "USDC"
|
|
408
|
+
},
|
|
409
|
+
addresses: {
|
|
410
|
+
8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
411
|
+
// Base
|
|
412
|
+
42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
413
|
+
// Arbitrum
|
|
414
|
+
9745: "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
|
|
415
|
+
// Plasma
|
|
416
|
+
146: "0x29219dd400f2bf60e5a23d13be72b486d4038894",
|
|
417
|
+
// Sonic
|
|
418
|
+
59144: "0x176211869ca2b568f2a7d4ee941e073a821ee1ff",
|
|
419
|
+
// Linea
|
|
420
|
+
1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
|
421
|
+
// Ethereum
|
|
422
|
+
},
|
|
423
|
+
enabled: true
|
|
424
|
+
},
|
|
425
|
+
WETH: {
|
|
426
|
+
symbol: "WETH",
|
|
427
|
+
assetType: "eth",
|
|
428
|
+
displayName: "WETH",
|
|
429
|
+
icon: "/ai-dashboard/eth-token.png",
|
|
430
|
+
decimals: 18,
|
|
431
|
+
tokenSymbols: ["WETH", "ETH"],
|
|
432
|
+
tokenSymbolsByChainId: {
|
|
433
|
+
8453: "WETH",
|
|
434
|
+
42161: "WETH",
|
|
435
|
+
9745: "WETH",
|
|
436
|
+
146: "WETH",
|
|
437
|
+
59144: "WETH",
|
|
438
|
+
1: "WETH"
|
|
439
|
+
},
|
|
440
|
+
addresses: {
|
|
441
|
+
8453: "0x4200000000000000000000000000000000000006",
|
|
442
|
+
// Base
|
|
443
|
+
42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
444
|
+
// Arbitrum
|
|
445
|
+
9745: "0x4200000000000000000000000000000000000006",
|
|
446
|
+
// Plasma
|
|
447
|
+
146: "0x039e64f90d4199560e7533692f69448878db85c7",
|
|
448
|
+
// Sonic
|
|
449
|
+
59144: "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
|
|
450
|
+
// Linea
|
|
451
|
+
1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
452
|
+
// Ethereum
|
|
453
|
+
},
|
|
454
|
+
enabled: true
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
var getDefaultTokenAddress = (chainId, asset) => {
|
|
458
|
+
const address = ASSET_CONFIGS[asset || "USDC"]?.addresses[chainId];
|
|
373
459
|
if (!address || address === "0x0000000000000000000000000000000000000000") {
|
|
374
460
|
throw new Error(
|
|
375
461
|
`Default token address not configured for chain ${chainId}. Please provide tokenAddress explicitly.`
|
|
@@ -661,6 +747,15 @@ function convertStrategyToPublic(obj) {
|
|
|
661
747
|
return result;
|
|
662
748
|
}
|
|
663
749
|
}
|
|
750
|
+
function convertAssetInternally(asset) {
|
|
751
|
+
if (asset === "USDC") {
|
|
752
|
+
return "usdc";
|
|
753
|
+
}
|
|
754
|
+
if (asset === "WETH") {
|
|
755
|
+
return "eth";
|
|
756
|
+
}
|
|
757
|
+
throw new Error(`Invalid asset: ${asset}. Must be "USDC" or "WETH".`);
|
|
758
|
+
}
|
|
664
759
|
function convertStrategiesToPublic(array) {
|
|
665
760
|
return array.map((item) => convertStrategyToPublic(item));
|
|
666
761
|
}
|
|
@@ -800,38 +895,40 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
800
895
|
async updateUserProfile(request) {
|
|
801
896
|
try {
|
|
802
897
|
await this.authenticateUser();
|
|
803
|
-
const
|
|
804
|
-
|
|
805
|
-
|
|
898
|
+
const asset = request.asset || "USDC";
|
|
899
|
+
const internalAsset = convertAssetInternally(asset);
|
|
900
|
+
let rebalanceStrategy;
|
|
901
|
+
if (request.strategy) {
|
|
902
|
+
if (!isValidPublicStrategy(request.strategy)) {
|
|
806
903
|
throw new Error(
|
|
807
|
-
`Invalid strategy: ${
|
|
904
|
+
`Invalid strategy: ${request.strategy}. Must be "conservative" or "aggressive".`
|
|
808
905
|
);
|
|
809
906
|
}
|
|
810
|
-
|
|
811
|
-
|
|
907
|
+
rebalanceStrategy = toInternalStrategy(
|
|
908
|
+
request.strategy
|
|
812
909
|
);
|
|
813
910
|
}
|
|
814
|
-
const
|
|
911
|
+
const assetSettings = {};
|
|
912
|
+
if (rebalanceStrategy !== void 0) assetSettings.rebalanceStrategy = rebalanceStrategy;
|
|
913
|
+
if (request.autocompounding !== void 0) assetSettings.autocompounding = request.autocompounding;
|
|
914
|
+
if (request.crosschainStrategy !== void 0) assetSettings.crosschainStrategy = request.crosschainStrategy;
|
|
915
|
+
if (request.splitting !== void 0) assetSettings.splitting = request.splitting;
|
|
916
|
+
if (request.minSplits !== void 0) assetSettings.minSplits = request.minSplits;
|
|
917
|
+
if (request.chains !== void 0) assetSettings.chains = request.chains;
|
|
918
|
+
if (request.autoSelectProtocols !== void 0) assetSettings.autoSelectProtocols = request.autoSelectProtocols;
|
|
919
|
+
if (request.protocols !== void 0) assetSettings.protocols = request.protocols;
|
|
920
|
+
const payload = {
|
|
921
|
+
assetTypeSettings: {
|
|
922
|
+
[internalAsset]: assetSettings
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
if (request.omniAccount !== void 0) payload.omniAccount = request.omniAccount;
|
|
926
|
+
if (request.agentName !== void 0) payload.agentName = request.agentName;
|
|
927
|
+
await this.httpClient.patch(
|
|
815
928
|
ENDPOINTS.USER_ME,
|
|
816
929
|
payload
|
|
817
930
|
);
|
|
818
|
-
return
|
|
819
|
-
success: true,
|
|
820
|
-
userId: response.userId || response.id,
|
|
821
|
-
smartWallet: response.smartWallet,
|
|
822
|
-
chains: response.chains,
|
|
823
|
-
strategy: response.strategy,
|
|
824
|
-
protocols: response.protocols,
|
|
825
|
-
autoSelectProtocols: response.autoSelectProtocols,
|
|
826
|
-
omniAccount: response.omniAccount,
|
|
827
|
-
autocompounding: response.autocompounding,
|
|
828
|
-
agentName: response.agentName,
|
|
829
|
-
crosschainStrategy: response.crosschainStrategy,
|
|
830
|
-
executorProxy: response.executorProxy,
|
|
831
|
-
splitting: response.splitting,
|
|
832
|
-
minSplits: response.minSplits,
|
|
833
|
-
customization: response.customization
|
|
834
|
-
};
|
|
931
|
+
return await this.getUserDetails(asset);
|
|
835
932
|
} catch (error) {
|
|
836
933
|
throw new Error(
|
|
837
934
|
`Failed to update user profile: ${error.message}`
|
|
@@ -858,7 +955,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
858
955
|
*/
|
|
859
956
|
async pauseAgent() {
|
|
860
957
|
try {
|
|
958
|
+
await this.updateUserProfile({
|
|
959
|
+
asset: "USDC",
|
|
960
|
+
protocols: []
|
|
961
|
+
});
|
|
861
962
|
const response = await this.updateUserProfile({
|
|
963
|
+
asset: "WETH",
|
|
862
964
|
protocols: []
|
|
863
965
|
});
|
|
864
966
|
return response;
|
|
@@ -867,49 +969,58 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
867
969
|
}
|
|
868
970
|
}
|
|
869
971
|
/**
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
972
|
+
* Resume the agent by restoring protocols based on user's strategy for each asset
|
|
973
|
+
* Fetches available protocols and assigns them based on each asset's strategy
|
|
974
|
+
*
|
|
975
|
+
* @returns Response indicating success and updated user details
|
|
976
|
+
*
|
|
977
|
+
* @example
|
|
978
|
+
* ```typescript
|
|
979
|
+
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
980
|
+
*
|
|
981
|
+
* // Connect account first
|
|
982
|
+
* await sdk.connectAccount();
|
|
983
|
+
*
|
|
984
|
+
* // Resume the agent
|
|
985
|
+
* const result = await sdk.resumeAgent();
|
|
986
|
+
* console.log('Agent resumed:', result.success);
|
|
987
|
+
* ```
|
|
988
|
+
*/
|
|
887
989
|
async resumeAgent() {
|
|
888
990
|
try {
|
|
889
|
-
const
|
|
890
|
-
const
|
|
891
|
-
const
|
|
892
|
-
const convertedStrategy = toInternalStrategy(strategy);
|
|
893
|
-
const chains = userChains && userChains.length > 0 ? userChains : [8453, 42161];
|
|
991
|
+
const userDetailsUSDC = await this.getUserDetails("USDC");
|
|
992
|
+
const userDetailsETH = await this.getUserDetails("WETH");
|
|
993
|
+
const chains = userDetailsUSDC.chains && userDetailsUSDC.chains.length > 0 ? userDetailsUSDC.chains : [8453, 42161];
|
|
894
994
|
const allProtocols = await this.httpClient.get(
|
|
895
995
|
ENDPOINTS.PROTOCOLS()
|
|
896
996
|
);
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
)
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
997
|
+
const usdcStrategy = userDetailsUSDC.strategy || "safe_strategy";
|
|
998
|
+
const ethStrategy = userDetailsETH.strategy || "safe_strategy";
|
|
999
|
+
const filterProtocolsByStrategy = (strategy) => {
|
|
1000
|
+
return allProtocols.filter((protocol) => {
|
|
1001
|
+
const hasMatchingChain = protocol.chains.some(
|
|
1002
|
+
(chain) => chains.includes(chain)
|
|
1003
|
+
);
|
|
1004
|
+
if (!hasMatchingChain) {
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
if (strategy === "degen_strategy") {
|
|
1008
|
+
return protocol.strategies?.includes("safe_strategy") || protocol.strategies?.includes("degen_strategy");
|
|
1009
|
+
}
|
|
1010
|
+
return protocol.strategies?.includes("safe_strategy");
|
|
1011
|
+
}).map((protocol) => protocol.id);
|
|
1012
|
+
};
|
|
1013
|
+
const usdcProtocols = filterProtocolsByStrategy(usdcStrategy);
|
|
1014
|
+
const ethProtocols = filterProtocolsByStrategy(ethStrategy);
|
|
1015
|
+
await this.updateUserProfile({
|
|
1016
|
+
asset: "USDC",
|
|
1017
|
+
protocols: usdcProtocols
|
|
911
1018
|
});
|
|
912
|
-
|
|
1019
|
+
const updatedUserDetailsETH = await this.updateUserProfile({
|
|
1020
|
+
asset: "WETH",
|
|
1021
|
+
protocols: ethProtocols
|
|
1022
|
+
});
|
|
1023
|
+
return updatedUserDetailsETH;
|
|
913
1024
|
} catch (error) {
|
|
914
1025
|
throw new Error(`Failed to resume agent: ${error.message}`);
|
|
915
1026
|
}
|
|
@@ -1496,14 +1607,20 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1496
1607
|
async updateUserProtocols(chainId) {
|
|
1497
1608
|
try {
|
|
1498
1609
|
const protocolsResponse = await this.getAvailableProtocols(chainId);
|
|
1499
|
-
|
|
1610
|
+
const userDetails = await this.getUserDetails();
|
|
1611
|
+
const filteredProtocols = userDetails.strategy ? protocolsResponse.protocols.filter((p) => p.strategies?.includes(userDetails.strategy)) : protocolsResponse.protocols;
|
|
1612
|
+
if (!filteredProtocols || filteredProtocols.length === 0) {
|
|
1500
1613
|
console.warn(`No protocols available for chain ${chainId}`);
|
|
1501
1614
|
return;
|
|
1502
1615
|
}
|
|
1503
|
-
const protocolIds =
|
|
1616
|
+
const protocolIds = filteredProtocols.map((p) => p.id);
|
|
1504
1617
|
await this.updateUserProfile({
|
|
1505
1618
|
protocols: protocolIds
|
|
1506
1619
|
});
|
|
1620
|
+
await this.updateUserProfile({
|
|
1621
|
+
protocols: protocolIds,
|
|
1622
|
+
asset: "WETH"
|
|
1623
|
+
});
|
|
1507
1624
|
} catch (error) {
|
|
1508
1625
|
console.warn(
|
|
1509
1626
|
`Failed to update user protocols: ${error.message}`
|
|
@@ -1565,7 +1682,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1565
1682
|
* );
|
|
1566
1683
|
* ```
|
|
1567
1684
|
*/
|
|
1568
|
-
async depositFunds(userAddress, chainId, amount) {
|
|
1685
|
+
async depositFunds(userAddress, chainId, amount, asset) {
|
|
1569
1686
|
try {
|
|
1570
1687
|
if (!userAddress) {
|
|
1571
1688
|
throw new Error("User address is required");
|
|
@@ -1576,7 +1693,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1576
1693
|
if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
|
|
1577
1694
|
throw new Error("Valid amount is required");
|
|
1578
1695
|
}
|
|
1579
|
-
const token = getDefaultTokenAddress(chainId);
|
|
1696
|
+
const token = getDefaultTokenAddress(chainId, asset);
|
|
1580
1697
|
const walletClient = this.getWalletClient();
|
|
1581
1698
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1582
1699
|
const safeAddress = await getDeterministicSafeAddress({
|
|
@@ -1718,7 +1835,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1718
1835
|
* );
|
|
1719
1836
|
* ```
|
|
1720
1837
|
*/
|
|
1721
|
-
async withdrawFunds(userAddress, chainId, amount) {
|
|
1838
|
+
async withdrawFunds(userAddress, chainId, amount, tokenSymbol) {
|
|
1722
1839
|
try {
|
|
1723
1840
|
if (!userAddress) {
|
|
1724
1841
|
throw new Error("User address is required");
|
|
@@ -1760,12 +1877,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1760
1877
|
if (amount) {
|
|
1761
1878
|
response = await this.httpClient.post(ENDPOINTS.PARTIAL_WITHDRAW, {
|
|
1762
1879
|
chainId,
|
|
1763
|
-
amount
|
|
1880
|
+
amount,
|
|
1881
|
+
tokenSymbol
|
|
1764
1882
|
});
|
|
1765
1883
|
} else {
|
|
1884
|
+
console.log("Full withdrawal", tokenSymbol);
|
|
1766
1885
|
response = await this.httpClient.get(ENDPOINTS.USER_WITHDRAW, {
|
|
1767
|
-
params: { chainId }
|
|
1886
|
+
params: { chainId, tokenSymbol }
|
|
1768
1887
|
});
|
|
1888
|
+
console.log(JSON.stringify(response, null, 2));
|
|
1769
1889
|
}
|
|
1770
1890
|
const success = response?.success ?? true;
|
|
1771
1891
|
const message = response?.message || "Withdrawal request sent";
|
|
@@ -1876,35 +1996,28 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1876
1996
|
* console.log("Chains:", user.user.chains);
|
|
1877
1997
|
* ```
|
|
1878
1998
|
*/
|
|
1879
|
-
async getUserDetails() {
|
|
1999
|
+
async getUserDetails(asset = "USDC") {
|
|
1880
2000
|
try {
|
|
1881
2001
|
await this.authenticateUser();
|
|
1882
2002
|
const response = await this.httpClient.get(ENDPOINTS.USER_ME);
|
|
2003
|
+
const internalAsset = convertAssetInternally(asset);
|
|
1883
2004
|
const convertedResponse = convertStrategyToPublic(response);
|
|
1884
2005
|
return {
|
|
1885
2006
|
success: true,
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
crosschainStrategy: convertedResponse.crosschainStrategy,
|
|
1901
|
-
agentName: convertedResponse.agentName,
|
|
1902
|
-
customization: convertedResponse.customization,
|
|
1903
|
-
executorProxy: convertedResponse.executorProxy,
|
|
1904
|
-
splitting: convertedResponse.splitting,
|
|
1905
|
-
minSplits: convertedResponse.minSplits,
|
|
1906
|
-
registered: convertedResponse.registered
|
|
1907
|
-
}
|
|
2007
|
+
agentName: convertedResponse.agentName,
|
|
2008
|
+
smartWallet: convertedResponse.smartWallet,
|
|
2009
|
+
chains: convertedResponse.assetTypeSettings?.[internalAsset]?.chains || [],
|
|
2010
|
+
hasActiveSessionKey: convertedResponse.hasActiveSessionKey || false,
|
|
2011
|
+
omniAccount: convertedResponse.omniAccount,
|
|
2012
|
+
asset,
|
|
2013
|
+
autoSelectProtocols: convertedResponse.assetTypeSettings?.[internalAsset]?.autoSelectProtocols,
|
|
2014
|
+
strategy: convertedResponse.assetTypeSettings?.[internalAsset]?.rebalanceStrategy,
|
|
2015
|
+
autocompounding: convertedResponse.assetTypeSettings?.[internalAsset]?.autocompounding,
|
|
2016
|
+
crosschainStrategy: convertedResponse.assetTypeSettings?.[internalAsset]?.crosschainStrategy,
|
|
2017
|
+
splitting: convertedResponse.assetTypeSettings?.[internalAsset]?.splitting,
|
|
2018
|
+
minSplits: convertedResponse.assetTypeSettings?.[internalAsset]?.minSplits || 0,
|
|
2019
|
+
protocols: convertedResponse.assetTypeSettings?.[internalAsset]?.protocols || [],
|
|
2020
|
+
customization: convertedResponse.customization
|
|
1908
2021
|
};
|
|
1909
2022
|
} catch (error) {
|
|
1910
2023
|
throw new Error(
|
|
@@ -1929,18 +2042,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1929
2042
|
async getTVL() {
|
|
1930
2043
|
try {
|
|
1931
2044
|
const response = await this.httpClient.get(ENDPOINTS.DATA_TVL);
|
|
1932
|
-
const byChain = {};
|
|
1933
|
-
for (const key of Object.keys(response)) {
|
|
1934
|
-
const numKey = parseInt(key, 10);
|
|
1935
|
-
if (!isNaN(numKey) && typeof response[key] === "number") {
|
|
1936
|
-
byChain[numKey] = response[key];
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
2045
|
return {
|
|
1940
2046
|
success: true,
|
|
1941
|
-
totalTvl: response.total ||
|
|
1942
|
-
byChain,
|
|
1943
|
-
breakdown: response.breakdown
|
|
2047
|
+
totalTvl: response.total || 0
|
|
1944
2048
|
};
|
|
1945
2049
|
} catch (error) {
|
|
1946
2050
|
throw new Error(`Failed to get TVL: ${error.message}`);
|
|
@@ -1955,20 +2059,28 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1955
2059
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
1956
2060
|
* @param days - Time period: 7, 14, or 30
|
|
1957
2061
|
* @param strategy - Strategy type: "conservative" (default) or "aggressive"
|
|
2062
|
+
* @param chainId - Optional chain ID filter
|
|
2063
|
+
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
1958
2064
|
* @returns APY per strategy for a specific chain
|
|
1959
2065
|
*
|
|
1960
2066
|
* @example
|
|
1961
2067
|
* ```typescript
|
|
1962
|
-
* const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative");
|
|
2068
|
+
* const apyPerStrategy = await sdk.getAPYPerStrategy(false, 7, "conservative", 8453, "USDC");
|
|
1963
2069
|
* console.log("APY per strategy per chain:", apyPerStrategy.data);
|
|
1964
2070
|
* ```
|
|
1965
2071
|
*/
|
|
1966
|
-
async getAPYPerStrategy(crossChain = false, days = 7, strategy = "conservative") {
|
|
2072
|
+
async getAPYPerStrategy(crossChain = false, days = 7, strategy = "conservative", chainId, tokenSymbol) {
|
|
1967
2073
|
try {
|
|
1968
2074
|
const internalStrategy = toInternalStrategy(strategy);
|
|
1969
2075
|
const internalStrategyShort = internalStrategy === "safe_strategy" ? "safe" : "degen";
|
|
1970
2076
|
const response = await this.httpClient.dataGet(
|
|
1971
|
-
DATA_ENDPOINTS.APY_PER_STRATEGY(
|
|
2077
|
+
DATA_ENDPOINTS.APY_PER_STRATEGY({
|
|
2078
|
+
isCrossChain: crossChain,
|
|
2079
|
+
days,
|
|
2080
|
+
strategy: internalStrategyShort,
|
|
2081
|
+
chainId,
|
|
2082
|
+
tokenSymbol
|
|
2083
|
+
})
|
|
1972
2084
|
);
|
|
1973
2085
|
const convertedData = convertStrategiesToPublicAndNaming(
|
|
1974
2086
|
response.data || []
|
|
@@ -1995,9 +2107,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1995
2107
|
* console.log("Total Volume:", volume.volumeInUSD);
|
|
1996
2108
|
* ```
|
|
1997
2109
|
*/
|
|
1998
|
-
async getVolume() {
|
|
2110
|
+
async getVolume(assetType = "usdc") {
|
|
1999
2111
|
try {
|
|
2000
|
-
const response = await this.httpClient.get(ENDPOINTS.DATA_VOLUME);
|
|
2112
|
+
const response = await this.httpClient.get(ENDPOINTS.DATA_VOLUME(assetType));
|
|
2001
2113
|
return {
|
|
2002
2114
|
success: true,
|
|
2003
2115
|
volumeInUSD: response.volumeInUSD || "0"
|
|
@@ -2164,12 +2276,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2164
2276
|
* Get onchain earnings for a wallet
|
|
2165
2277
|
*
|
|
2166
2278
|
* @param walletAddress - Smart wallet address
|
|
2167
|
-
* @returns Onchain earnings data
|
|
2279
|
+
* @returns Onchain earnings data with per-token breakdowns
|
|
2168
2280
|
*
|
|
2169
2281
|
* @example
|
|
2170
2282
|
* ```typescript
|
|
2171
2283
|
* const earnings = await sdk.getOnchainEarnings("0x...");
|
|
2172
|
-
* console.log("Total
|
|
2284
|
+
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
2173
2285
|
* ```
|
|
2174
2286
|
*/
|
|
2175
2287
|
async getOnchainEarnings(walletAddress) {
|
|
@@ -2184,13 +2296,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2184
2296
|
success: true,
|
|
2185
2297
|
data: {
|
|
2186
2298
|
walletAddress,
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
unrealizedEarnings: response.unrealized_earnings,
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
lastCheckTimestamp: response.last_check_timestamp
|
|
2299
|
+
totalEarningsByToken: response.total_earnings_by_token || {},
|
|
2300
|
+
lifetimeEarningsByToken: response.lifetime_earnings_by_token || {},
|
|
2301
|
+
currentEarningsByChain: response.current_earnings_by_chain || {},
|
|
2302
|
+
unrealizedEarnings: response.unrealized_earnings || {},
|
|
2303
|
+
lastCheckTimestamp: response.last_check_timestamp,
|
|
2304
|
+
lastLogDate: response.last_log_date
|
|
2194
2305
|
}
|
|
2195
2306
|
};
|
|
2196
2307
|
} catch (error) {
|
|
@@ -2204,12 +2315,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2204
2315
|
* This triggers a recalculation of earnings on the backend
|
|
2205
2316
|
*
|
|
2206
2317
|
* @param walletAddress - Smart wallet address
|
|
2207
|
-
* @returns Updated onchain earnings data
|
|
2318
|
+
* @returns Updated onchain earnings data with per-token breakdowns
|
|
2208
2319
|
*
|
|
2209
2320
|
* @example
|
|
2210
2321
|
* ```typescript
|
|
2211
2322
|
* const earnings = await sdk.calculateOnchainEarnings("0x...");
|
|
2212
|
-
* console.log("
|
|
2323
|
+
* console.log("Total USDC:", earnings.data.totalEarningsByToken["USDC"]);
|
|
2213
2324
|
* ```
|
|
2214
2325
|
*/
|
|
2215
2326
|
async calculateOnchainEarnings(walletAddress) {
|
|
@@ -2226,11 +2337,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2226
2337
|
success: true,
|
|
2227
2338
|
data: {
|
|
2228
2339
|
walletAddress,
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
unrealizedEarnings: data.unrealized_earnings,
|
|
2233
|
-
lastCheckTimestamp: data.last_check_timestamp
|
|
2340
|
+
totalEarningsByToken: data.total_earnings_by_token || {},
|
|
2341
|
+
lifetimeEarningsByToken: data.lifetime_earnings_by_token || {},
|
|
2342
|
+
currentEarningsByChain: data.current_earnings_by_chain || {},
|
|
2343
|
+
unrealizedEarnings: data.unrealized_earnings || {},
|
|
2344
|
+
lastCheckTimestamp: data.last_check_timestamp,
|
|
2345
|
+
lastLogDate: data.last_log_date
|
|
2234
2346
|
}
|
|
2235
2347
|
};
|
|
2236
2348
|
} catch (error) {
|
|
@@ -2250,7 +2362,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2250
2362
|
* @example
|
|
2251
2363
|
* ```typescript
|
|
2252
2364
|
* const daily = await sdk.getDailyEarnings("0x...", "2024-01-01", "2024-01-31");
|
|
2253
|
-
* daily.data.forEach(d => console.log(d.
|
|
2365
|
+
* daily.data.forEach(d => console.log(d.snapshot_date, d.total_earnings_by_token));
|
|
2254
2366
|
* ```
|
|
2255
2367
|
*/
|
|
2256
2368
|
async getDailyEarnings(walletAddress, startDate, endDate) {
|
|
@@ -2278,61 +2390,25 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2278
2390
|
}
|
|
2279
2391
|
}
|
|
2280
2392
|
// ============================================================================
|
|
2281
|
-
// Portfolio Methods (Data API v2)
|
|
2282
|
-
// ============================================================================
|
|
2283
|
-
/**
|
|
2284
|
-
* Get Debank portfolio for a wallet across multiple chains
|
|
2285
|
-
* Note: This is a paid endpoint and may require authorization
|
|
2286
|
-
*
|
|
2287
|
-
* @param walletAddress - Smart wallet address
|
|
2288
|
-
* @returns Multi-chain portfolio data
|
|
2289
|
-
*
|
|
2290
|
-
* @example
|
|
2291
|
-
* ```typescript
|
|
2292
|
-
* const portfolio = await sdk.getDebankPortfolio("0x...");
|
|
2293
|
-
* console.log("Total value:", portfolio.totalValueUsd);
|
|
2294
|
-
* ```
|
|
2295
|
-
*/
|
|
2296
|
-
async getDebankPortfolio(walletAddress) {
|
|
2297
|
-
try {
|
|
2298
|
-
if (!walletAddress) {
|
|
2299
|
-
throw new Error("Wallet address is required");
|
|
2300
|
-
}
|
|
2301
|
-
const response = await this.httpClient.dataGet(
|
|
2302
|
-
DATA_ENDPOINTS.DEBANK_PORTFOLIO_MULTICHAIN(walletAddress)
|
|
2303
|
-
);
|
|
2304
|
-
const data = response.data || response;
|
|
2305
|
-
return {
|
|
2306
|
-
success: true,
|
|
2307
|
-
walletAddress,
|
|
2308
|
-
totalValueUsd: data.totalValueUsd || 0,
|
|
2309
|
-
chains: data.chains || data
|
|
2310
|
-
};
|
|
2311
|
-
} catch (error) {
|
|
2312
|
-
throw new Error(
|
|
2313
|
-
`Failed to get Debank portfolio: ${error.message}`
|
|
2314
|
-
);
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
// ============================================================================
|
|
2318
2393
|
// Opportunities Methods (Data API v2)
|
|
2319
2394
|
// ============================================================================
|
|
2320
2395
|
/**
|
|
2321
2396
|
* Get conservative (low-risk) yield opportunities
|
|
2322
2397
|
*
|
|
2323
2398
|
* @param chainId - Optional chain ID filter
|
|
2399
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2324
2400
|
* @returns List of conservative yield opportunities
|
|
2325
2401
|
*
|
|
2326
2402
|
* @example
|
|
2327
2403
|
* ```typescript
|
|
2328
|
-
* const opportunities = await sdk.getConservativeOpportunities(8453);
|
|
2404
|
+
* const opportunities = await sdk.getConservativeOpportunities(8453, "USDC");
|
|
2329
2405
|
* opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
|
|
2330
2406
|
* ```
|
|
2331
2407
|
*/
|
|
2332
|
-
async getConservativeOpportunities(chainId) {
|
|
2408
|
+
async getConservativeOpportunities(chainId, asset, status) {
|
|
2333
2409
|
try {
|
|
2334
2410
|
const response = await this.httpClient.dataGet(
|
|
2335
|
-
DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId)
|
|
2411
|
+
DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId, asset, status)
|
|
2336
2412
|
);
|
|
2337
2413
|
const data = response.data || response || [];
|
|
2338
2414
|
return {
|
|
@@ -2345,7 +2421,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2345
2421
|
protocolName: o.protocol_name || o.protocolName,
|
|
2346
2422
|
poolName: o.pool_name || o.poolName,
|
|
2347
2423
|
chainId: o.chain_id || o.chainId,
|
|
2348
|
-
apy: o.
|
|
2424
|
+
apy: o.combined_apy || 0,
|
|
2349
2425
|
tvl: o.tvl || o.zyfiTvl,
|
|
2350
2426
|
asset: o.asset || o.underlying_token,
|
|
2351
2427
|
risk: o.risk,
|
|
@@ -2363,18 +2439,19 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2363
2439
|
* Get aggressive (high-risk, high-reward) yield opportunities
|
|
2364
2440
|
*
|
|
2365
2441
|
* @param chainId - Optional chain ID filter
|
|
2442
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2366
2443
|
* @returns List of aggressive opportunities
|
|
2367
2444
|
*
|
|
2368
2445
|
* @example
|
|
2369
2446
|
* ```typescript
|
|
2370
|
-
* const opportunities = await sdk.getAggressiveOpportunities(8453);
|
|
2447
|
+
* const opportunities = await sdk.getAggressiveOpportunities(8453, "WETH");
|
|
2371
2448
|
* opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
|
|
2372
2449
|
* ```
|
|
2373
2450
|
*/
|
|
2374
|
-
async getAggressiveOpportunities(chainId) {
|
|
2451
|
+
async getAggressiveOpportunities(chainId, asset, status) {
|
|
2375
2452
|
try {
|
|
2376
2453
|
const response = await this.httpClient.dataGet(
|
|
2377
|
-
DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId)
|
|
2454
|
+
DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId, asset, status)
|
|
2378
2455
|
);
|
|
2379
2456
|
const data = response.data || response || [];
|
|
2380
2457
|
return {
|
|
@@ -2387,7 +2464,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2387
2464
|
protocolName: o.protocol_name || o.protocolName,
|
|
2388
2465
|
poolName: o.pool_name || o.poolName,
|
|
2389
2466
|
chainId: o.chain_id || o.chainId,
|
|
2390
|
-
apy: o.
|
|
2467
|
+
apy: o.combined_apy || 0,
|
|
2391
2468
|
tvl: o.tvl || o.zyfiTvl,
|
|
2392
2469
|
asset: o.asset || o.underlying_token,
|
|
2393
2470
|
risk: o.risk,
|
|
@@ -2406,6 +2483,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2406
2483
|
* Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
|
|
2407
2484
|
*
|
|
2408
2485
|
* @param chainId - Optional chain ID filter
|
|
2486
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2409
2487
|
* @returns Active conservative opportunities with risk data
|
|
2410
2488
|
*
|
|
2411
2489
|
* @example
|
|
@@ -2414,10 +2492,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2414
2492
|
* console.log(JSON.stringify(opps, null, 2));
|
|
2415
2493
|
* ```
|
|
2416
2494
|
*/
|
|
2417
|
-
async getActiveConservativeOppsRisk(chainId) {
|
|
2495
|
+
async getActiveConservativeOppsRisk(chainId, asset) {
|
|
2418
2496
|
try {
|
|
2419
2497
|
const response = await this.httpClient.dataGet(
|
|
2420
|
-
DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId)
|
|
2498
|
+
DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId, asset)
|
|
2421
2499
|
);
|
|
2422
2500
|
const data = response.data || response || [];
|
|
2423
2501
|
const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
|
|
@@ -2451,6 +2529,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2451
2529
|
* Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
|
|
2452
2530
|
*
|
|
2453
2531
|
* @param chainId - Optional chain ID filter
|
|
2532
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2454
2533
|
* @returns Active aggressive opportunities with risk data
|
|
2455
2534
|
*
|
|
2456
2535
|
* @example
|
|
@@ -2459,10 +2538,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2459
2538
|
* console.log(JSON.stringify(opps, null, 2));
|
|
2460
2539
|
* ```
|
|
2461
2540
|
*/
|
|
2462
|
-
async getActiveAggressiveOppsRisk(chainId) {
|
|
2541
|
+
async getActiveAggressiveOppsRisk(chainId, asset) {
|
|
2463
2542
|
try {
|
|
2464
2543
|
const response = await this.httpClient.dataGet(
|
|
2465
|
-
DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId)
|
|
2544
|
+
DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId, asset)
|
|
2466
2545
|
);
|
|
2467
2546
|
const data = response.data || response || [];
|
|
2468
2547
|
const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
|
|
@@ -2496,10 +2575,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2496
2575
|
* Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
|
|
2497
2576
|
*
|
|
2498
2577
|
* @param chainId - Optional chain ID filter
|
|
2578
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2499
2579
|
* @returns Conservative pools with status data
|
|
2500
2580
|
*/
|
|
2501
|
-
async getConservativePoolStatus(chainId) {
|
|
2502
|
-
const pools = await this.getActiveConservativeOppsRisk(chainId);
|
|
2581
|
+
async getConservativePoolStatus(chainId, asset) {
|
|
2582
|
+
const pools = await this.getActiveConservativeOppsRisk(chainId, asset);
|
|
2503
2583
|
return pools.map((p) => this.derivePoolStatus(p));
|
|
2504
2584
|
}
|
|
2505
2585
|
/**
|
|
@@ -2507,10 +2587,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2507
2587
|
* Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
|
|
2508
2588
|
*
|
|
2509
2589
|
* @param chainId - Optional chain ID filter
|
|
2590
|
+
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2510
2591
|
* @returns Aggressive pools with status data
|
|
2511
2592
|
*/
|
|
2512
|
-
async getAggressivePoolStatus(chainId) {
|
|
2513
|
-
const pools = await this.getActiveAggressiveOppsRisk(chainId);
|
|
2593
|
+
async getAggressivePoolStatus(chainId, asset) {
|
|
2594
|
+
const pools = await this.getActiveAggressiveOppsRisk(chainId, asset);
|
|
2514
2595
|
return pools.map((p) => this.derivePoolStatus(p));
|
|
2515
2596
|
}
|
|
2516
2597
|
derivePoolStatus(p) {
|
|
@@ -2559,12 +2640,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2559
2640
|
*
|
|
2560
2641
|
* @param walletAddress - Smart wallet address
|
|
2561
2642
|
* @param days - Period: "7D", "14D", or "30D" (default: "7D")
|
|
2562
|
-
* @returns Daily APY history with weighted averages
|
|
2643
|
+
* @returns Daily APY history with per-position breakdowns and weighted averages
|
|
2563
2644
|
*
|
|
2564
2645
|
* @example
|
|
2565
2646
|
* ```typescript
|
|
2566
2647
|
* const apyHistory = await sdk.getDailyApyHistory("0x...", "30D");
|
|
2567
|
-
* console.log("
|
|
2648
|
+
* console.log("Weighted APY after fee:", apyHistory.weightedApyAfterFee); // { "USDC": 4.64, "WETH": 1.94 }
|
|
2568
2649
|
* ```
|
|
2569
2650
|
*/
|
|
2570
2651
|
async getDailyApyHistory(walletAddress, days = "7D") {
|