@zyfai/sdk 0.2.19 → 0.2.21
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/dist/index.d.mts +15 -6
- package/dist/index.d.ts +15 -6
- package/dist/index.js +21 -6
- package/dist/index.mjs +21 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -106,20 +106,29 @@ interface ProtocolsResponse {
|
|
|
106
106
|
chainId: number;
|
|
107
107
|
protocols: Protocol[];
|
|
108
108
|
}
|
|
109
|
+
interface staleBalances {
|
|
110
|
+
chainId: number;
|
|
111
|
+
tokenSymbol: string;
|
|
112
|
+
balance: string;
|
|
113
|
+
isPending: boolean;
|
|
114
|
+
}
|
|
109
115
|
interface Position {
|
|
110
116
|
user?: string;
|
|
111
117
|
eoa?: Address;
|
|
112
118
|
chains?: number[];
|
|
113
119
|
strategy?: string;
|
|
114
120
|
smartWallet?: Address;
|
|
115
|
-
positions
|
|
121
|
+
positions?: PositionSlot[];
|
|
116
122
|
hasActiveSessionKey?: boolean;
|
|
117
123
|
hasBalance?: boolean;
|
|
118
124
|
newSessionKeyAvailable?: boolean;
|
|
119
|
-
hasStaleBalance?: string[];
|
|
120
125
|
contracts?: Address[];
|
|
121
126
|
omniAccount?: boolean;
|
|
122
127
|
crosschainStrategy?: boolean;
|
|
128
|
+
staleBalances?: staleBalances[];
|
|
129
|
+
splitting?: boolean;
|
|
130
|
+
minSplits?: number;
|
|
131
|
+
executorProxy?: boolean;
|
|
123
132
|
}
|
|
124
133
|
interface PositionSlot {
|
|
125
134
|
chain?: string;
|
|
@@ -135,10 +144,10 @@ interface PositionSlot {
|
|
|
135
144
|
pool_apy?: number;
|
|
136
145
|
pool_tvl?: number;
|
|
137
146
|
}
|
|
138
|
-
interface
|
|
147
|
+
interface PortfolioResponse {
|
|
139
148
|
success: boolean;
|
|
140
149
|
userAddress: string;
|
|
141
|
-
|
|
150
|
+
portfolio: Position;
|
|
142
151
|
}
|
|
143
152
|
interface UserDetails {
|
|
144
153
|
id: string;
|
|
@@ -856,7 +865,7 @@ declare class ZyfaiSDK {
|
|
|
856
865
|
* const basePositions = await sdk.getPositions(userAddress, 8453);
|
|
857
866
|
* ```
|
|
858
867
|
*/
|
|
859
|
-
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<
|
|
868
|
+
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
860
869
|
/**
|
|
861
870
|
* Get current authenticated user details
|
|
862
871
|
* Requires SIWE authentication
|
|
@@ -1274,4 +1283,4 @@ declare class ZyfaiSDK {
|
|
|
1274
1283
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1275
1284
|
}
|
|
1276
1285
|
|
|
1277
|
-
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type
|
|
1286
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type PortfolioResponse, type PortfolioToken, type Position, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -106,20 +106,29 @@ interface ProtocolsResponse {
|
|
|
106
106
|
chainId: number;
|
|
107
107
|
protocols: Protocol[];
|
|
108
108
|
}
|
|
109
|
+
interface staleBalances {
|
|
110
|
+
chainId: number;
|
|
111
|
+
tokenSymbol: string;
|
|
112
|
+
balance: string;
|
|
113
|
+
isPending: boolean;
|
|
114
|
+
}
|
|
109
115
|
interface Position {
|
|
110
116
|
user?: string;
|
|
111
117
|
eoa?: Address;
|
|
112
118
|
chains?: number[];
|
|
113
119
|
strategy?: string;
|
|
114
120
|
smartWallet?: Address;
|
|
115
|
-
positions
|
|
121
|
+
positions?: PositionSlot[];
|
|
116
122
|
hasActiveSessionKey?: boolean;
|
|
117
123
|
hasBalance?: boolean;
|
|
118
124
|
newSessionKeyAvailable?: boolean;
|
|
119
|
-
hasStaleBalance?: string[];
|
|
120
125
|
contracts?: Address[];
|
|
121
126
|
omniAccount?: boolean;
|
|
122
127
|
crosschainStrategy?: boolean;
|
|
128
|
+
staleBalances?: staleBalances[];
|
|
129
|
+
splitting?: boolean;
|
|
130
|
+
minSplits?: number;
|
|
131
|
+
executorProxy?: boolean;
|
|
123
132
|
}
|
|
124
133
|
interface PositionSlot {
|
|
125
134
|
chain?: string;
|
|
@@ -135,10 +144,10 @@ interface PositionSlot {
|
|
|
135
144
|
pool_apy?: number;
|
|
136
145
|
pool_tvl?: number;
|
|
137
146
|
}
|
|
138
|
-
interface
|
|
147
|
+
interface PortfolioResponse {
|
|
139
148
|
success: boolean;
|
|
140
149
|
userAddress: string;
|
|
141
|
-
|
|
150
|
+
portfolio: Position;
|
|
142
151
|
}
|
|
143
152
|
interface UserDetails {
|
|
144
153
|
id: string;
|
|
@@ -856,7 +865,7 @@ declare class ZyfaiSDK {
|
|
|
856
865
|
* const basePositions = await sdk.getPositions(userAddress, 8453);
|
|
857
866
|
* ```
|
|
858
867
|
*/
|
|
859
|
-
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<
|
|
868
|
+
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
860
869
|
/**
|
|
861
870
|
* Get current authenticated user details
|
|
862
871
|
* Requires SIWE authentication
|
|
@@ -1274,4 +1283,4 @@ declare class ZyfaiSDK {
|
|
|
1274
1283
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1275
1284
|
}
|
|
1276
1285
|
|
|
1277
|
-
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type
|
|
1286
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type PortfolioResponse, type PortfolioToken, type Position, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.js
CHANGED
|
@@ -655,17 +655,32 @@ function isValidPublicStrategy(strategy) {
|
|
|
655
655
|
}
|
|
656
656
|
function convertStrategyToPublic(obj) {
|
|
657
657
|
if (!obj.strategy) {
|
|
658
|
-
|
|
658
|
+
const result = { ...obj };
|
|
659
|
+
if ("hasStaleBalance" in result) {
|
|
660
|
+
delete result.hasStaleBalance;
|
|
661
|
+
}
|
|
662
|
+
return result;
|
|
659
663
|
}
|
|
660
664
|
try {
|
|
661
|
-
|
|
665
|
+
const result = {
|
|
662
666
|
...obj,
|
|
663
667
|
strategy: toPublicStrategy(
|
|
664
668
|
obj.strategy
|
|
665
669
|
)
|
|
666
670
|
};
|
|
671
|
+
if ("hasStaleBalance" in result) {
|
|
672
|
+
delete result.hasStaleBalance;
|
|
673
|
+
}
|
|
674
|
+
if ("staleBalances" in result) {
|
|
675
|
+
result.staleBalances = result.staleBalances?.filter((staleBalance) => staleBalance.balance !== "0x0");
|
|
676
|
+
}
|
|
677
|
+
return result;
|
|
667
678
|
} catch {
|
|
668
|
-
|
|
679
|
+
const result = { ...obj };
|
|
680
|
+
if ("hasStaleBalance" in result) {
|
|
681
|
+
delete result.hasStaleBalance;
|
|
682
|
+
}
|
|
683
|
+
return result;
|
|
669
684
|
}
|
|
670
685
|
}
|
|
671
686
|
function convertStrategiesToPublic(array) {
|
|
@@ -1785,17 +1800,17 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1785
1800
|
return {
|
|
1786
1801
|
success: true,
|
|
1787
1802
|
userAddress,
|
|
1788
|
-
|
|
1803
|
+
portfolio: {}
|
|
1789
1804
|
};
|
|
1790
1805
|
}
|
|
1791
1806
|
const response = await this.httpClient.get(
|
|
1792
1807
|
ENDPOINTS.DATA_POSITION(smartWalletInfo.smartWallet)
|
|
1793
1808
|
);
|
|
1794
|
-
const
|
|
1809
|
+
const convertedPosition = response ? convertStrategyToPublic(response) : void 0;
|
|
1795
1810
|
return {
|
|
1796
1811
|
success: true,
|
|
1797
1812
|
userAddress,
|
|
1798
|
-
|
|
1813
|
+
portfolio: convertedPosition
|
|
1799
1814
|
};
|
|
1800
1815
|
} catch (error) {
|
|
1801
1816
|
throw new Error(`Failed to get positions: ${error.message}`);
|
package/dist/index.mjs
CHANGED
|
@@ -633,17 +633,32 @@ function isValidPublicStrategy(strategy) {
|
|
|
633
633
|
}
|
|
634
634
|
function convertStrategyToPublic(obj) {
|
|
635
635
|
if (!obj.strategy) {
|
|
636
|
-
|
|
636
|
+
const result = { ...obj };
|
|
637
|
+
if ("hasStaleBalance" in result) {
|
|
638
|
+
delete result.hasStaleBalance;
|
|
639
|
+
}
|
|
640
|
+
return result;
|
|
637
641
|
}
|
|
638
642
|
try {
|
|
639
|
-
|
|
643
|
+
const result = {
|
|
640
644
|
...obj,
|
|
641
645
|
strategy: toPublicStrategy(
|
|
642
646
|
obj.strategy
|
|
643
647
|
)
|
|
644
648
|
};
|
|
649
|
+
if ("hasStaleBalance" in result) {
|
|
650
|
+
delete result.hasStaleBalance;
|
|
651
|
+
}
|
|
652
|
+
if ("staleBalances" in result) {
|
|
653
|
+
result.staleBalances = result.staleBalances?.filter((staleBalance) => staleBalance.balance !== "0x0");
|
|
654
|
+
}
|
|
655
|
+
return result;
|
|
645
656
|
} catch {
|
|
646
|
-
|
|
657
|
+
const result = { ...obj };
|
|
658
|
+
if ("hasStaleBalance" in result) {
|
|
659
|
+
delete result.hasStaleBalance;
|
|
660
|
+
}
|
|
661
|
+
return result;
|
|
647
662
|
}
|
|
648
663
|
}
|
|
649
664
|
function convertStrategiesToPublic(array) {
|
|
@@ -1763,17 +1778,17 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1763
1778
|
return {
|
|
1764
1779
|
success: true,
|
|
1765
1780
|
userAddress,
|
|
1766
|
-
|
|
1781
|
+
portfolio: {}
|
|
1767
1782
|
};
|
|
1768
1783
|
}
|
|
1769
1784
|
const response = await this.httpClient.get(
|
|
1770
1785
|
ENDPOINTS.DATA_POSITION(smartWalletInfo.smartWallet)
|
|
1771
1786
|
);
|
|
1772
|
-
const
|
|
1787
|
+
const convertedPosition = response ? convertStrategyToPublic(response) : void 0;
|
|
1773
1788
|
return {
|
|
1774
1789
|
success: true,
|
|
1775
1790
|
userAddress,
|
|
1776
|
-
|
|
1791
|
+
portfolio: convertedPosition
|
|
1777
1792
|
};
|
|
1778
1793
|
} catch (error) {
|
|
1779
1794
|
throw new Error(`Failed to get positions: ${error.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
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",
|