@zyfai/sdk 0.2.20 → 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 CHANGED
@@ -106,20 +106,26 @@ 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: PositionSlot[];
121
+ positions?: PositionSlot[];
116
122
  hasActiveSessionKey?: boolean;
117
123
  hasBalance?: boolean;
118
124
  newSessionKeyAvailable?: boolean;
119
125
  contracts?: Address[];
120
126
  omniAccount?: boolean;
121
127
  crosschainStrategy?: boolean;
122
- staleBalances?: string[];
128
+ staleBalances?: staleBalances[];
123
129
  splitting?: boolean;
124
130
  minSplits?: number;
125
131
  executorProxy?: boolean;
@@ -138,10 +144,10 @@ interface PositionSlot {
138
144
  pool_apy?: number;
139
145
  pool_tvl?: number;
140
146
  }
141
- interface PositionsResponse {
147
+ interface PortfolioResponse {
142
148
  success: boolean;
143
149
  userAddress: string;
144
- positions: Position[];
150
+ portfolio: Position;
145
151
  }
146
152
  interface UserDetails {
147
153
  id: string;
@@ -859,7 +865,7 @@ declare class ZyfaiSDK {
859
865
  * const basePositions = await sdk.getPositions(userAddress, 8453);
860
866
  * ```
861
867
  */
862
- getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PositionsResponse>;
868
+ getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
863
869
  /**
864
870
  * Get current authenticated user details
865
871
  * Requires SIWE authentication
@@ -1277,4 +1283,4 @@ declare class ZyfaiSDK {
1277
1283
  registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
1278
1284
  }
1279
1285
 
1280
- 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 PortfolioToken, type Position, type PositionSlot, type PositionsResponse, 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 };
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,26 @@ 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: PositionSlot[];
121
+ positions?: PositionSlot[];
116
122
  hasActiveSessionKey?: boolean;
117
123
  hasBalance?: boolean;
118
124
  newSessionKeyAvailable?: boolean;
119
125
  contracts?: Address[];
120
126
  omniAccount?: boolean;
121
127
  crosschainStrategy?: boolean;
122
- staleBalances?: string[];
128
+ staleBalances?: staleBalances[];
123
129
  splitting?: boolean;
124
130
  minSplits?: number;
125
131
  executorProxy?: boolean;
@@ -138,10 +144,10 @@ interface PositionSlot {
138
144
  pool_apy?: number;
139
145
  pool_tvl?: number;
140
146
  }
141
- interface PositionsResponse {
147
+ interface PortfolioResponse {
142
148
  success: boolean;
143
149
  userAddress: string;
144
- positions: Position[];
150
+ portfolio: Position;
145
151
  }
146
152
  interface UserDetails {
147
153
  id: string;
@@ -859,7 +865,7 @@ declare class ZyfaiSDK {
859
865
  * const basePositions = await sdk.getPositions(userAddress, 8453);
860
866
  * ```
861
867
  */
862
- getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PositionsResponse>;
868
+ getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
863
869
  /**
864
870
  * Get current authenticated user details
865
871
  * Requires SIWE authentication
@@ -1277,4 +1283,4 @@ declare class ZyfaiSDK {
1277
1283
  registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
1278
1284
  }
1279
1285
 
1280
- 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 PortfolioToken, type Position, type PositionSlot, type PositionsResponse, 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 };
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
- return obj;
658
+ const result = { ...obj };
659
+ if ("hasStaleBalance" in result) {
660
+ delete result.hasStaleBalance;
661
+ }
662
+ return result;
659
663
  }
660
664
  try {
661
- return {
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
- return obj;
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
- positions: []
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 convertedPositions = response ? [convertStrategyToPublic(response)] : [];
1809
+ const convertedPosition = response ? convertStrategyToPublic(response) : void 0;
1795
1810
  return {
1796
1811
  success: true,
1797
1812
  userAddress,
1798
- positions: convertedPositions
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
- return obj;
636
+ const result = { ...obj };
637
+ if ("hasStaleBalance" in result) {
638
+ delete result.hasStaleBalance;
639
+ }
640
+ return result;
637
641
  }
638
642
  try {
639
- return {
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
- return obj;
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
- positions: []
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 convertedPositions = response ? [convertStrategyToPublic(response)] : [];
1787
+ const convertedPosition = response ? convertStrategyToPublic(response) : void 0;
1773
1788
  return {
1774
1789
  success: true,
1775
1790
  userAddress,
1776
- positions: convertedPositions
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.20",
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",