@zyfai/sdk 0.3.0 → 0.3.1

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.js CHANGED
@@ -112,6 +112,9 @@ var ENDPOINTS = {
112
112
  AUTH_CHALLENGE: "/auth/challenge",
113
113
  // User
114
114
  USER_ME: "/users/me",
115
+ USER_AGENT_MANDATE: "/users/me/agent-mandate",
116
+ USER_AGENT_ENTER_INTENTS: "/users/me/agent-enter-intents",
117
+ USER_AGENT_ENTER_INTENT_CONSUME: (actionId) => `/users/me/agent-enter-intents/${encodeURIComponent(actionId)}/consume`,
115
118
  USER_WITHDRAW: "/users/withdraw",
116
119
  PARTIAL_WITHDRAW: "/users/partial-withdraw",
117
120
  LOG_DEPOSIT: "/users/log_deposit/v2",
@@ -237,6 +240,8 @@ var HttpClient = class {
237
240
  */
238
241
  constructor(apiKey, config = {}) {
239
242
  this.authToken = null;
243
+ /** @internal Extra headers on execution API requests (e.g. MCP server channel key). */
244
+ this.extraExecutionHeaders = {};
240
245
  this.apiKey = apiKey;
241
246
  const executionApiUrl = config.executionApiUrl ?? API_ENDPOINT;
242
247
  this.dataApiBaseUrl = config.dataApiUrl ?? DATA_API_ENDPOINT;
@@ -265,9 +270,17 @@ var HttpClient = class {
265
270
  setAuthToken(token) {
266
271
  this.authToken = token;
267
272
  }
273
+ /** @internal */
274
+ setExtraExecutionHeaders(headers) {
275
+ this.extraExecutionHeaders = headers;
276
+ }
268
277
  clearAuthToken() {
269
278
  this.authToken = null;
270
279
  }
280
+ /** Whether a user Bearer token is set on this client instance. */
281
+ hasAuthToken() {
282
+ return this.authToken !== null;
283
+ }
271
284
  getOrigin() {
272
285
  return this.origin;
273
286
  }
@@ -281,6 +294,9 @@ var HttpClient = class {
281
294
  if (this.authToken) {
282
295
  config.headers["Authorization"] = `Bearer ${this.authToken}`;
283
296
  }
297
+ for (const [key, value] of Object.entries(this.extraExecutionHeaders)) {
298
+ config.headers[key] = value;
299
+ }
284
300
  return config;
285
301
  },
286
302
  (error) => {
@@ -333,6 +349,10 @@ var HttpClient = class {
333
349
  const response = await this.client.patch(url, data, config);
334
350
  return response.data;
335
351
  }
352
+ async put(url, data, config) {
353
+ const response = await this.client.put(url, data, config);
354
+ return response.data;
355
+ }
336
356
  async delete(url, config) {
337
357
  const response = await this.client.delete(url, config);
338
358
  return response.data;
@@ -679,11 +699,22 @@ function isLocalExecutionApiUrl(executionApiUrl) {
679
699
  return false;
680
700
  }
681
701
  }
702
+ function isStagingExecutionApiUrl(executionApiUrl) {
703
+ if (executionApiUrl === EXECUTION_API_BASE_URLS.staging) {
704
+ return true;
705
+ }
706
+ try {
707
+ const { hostname } = new URL(executionApiUrl);
708
+ return hostname === "staging-api.zyf.ai";
709
+ } catch {
710
+ return false;
711
+ }
712
+ }
682
713
  function shouldBypassMinPortfolioCheck(executionApiUrl) {
683
714
  if (process.env.NODE_ENV === "production") {
684
715
  return false;
685
716
  }
686
- return isLocalExecutionApiUrl(executionApiUrl);
717
+ return isLocalExecutionApiUrl(executionApiUrl) || isStagingExecutionApiUrl(executionApiUrl);
687
718
  }
688
719
 
689
720
  // src/core/ZyfaiSDK.ts
@@ -1567,7 +1598,7 @@ function enrichOnchainEarningsTotals(apiData) {
1567
1598
  const unrealized = unrealizedByToken[symbol] ?? 0;
1568
1599
  const current = currentByToken[symbol] ?? 0;
1569
1600
  totalEarningsByTokenWithFee[symbol] = formatHumanAmount(
1570
- lifetime + unrealized + current * keepRate
1601
+ (lifetime + unrealized + current) * keepRate
1571
1602
  );
1572
1603
  });
1573
1604
  const chainKeys = /* @__PURE__ */ new Set([
@@ -1591,7 +1622,7 @@ function enrichOnchainEarningsTotals(apiData) {
1591
1622
  const unrealized = parseHumanAmount(unrealizedTokens[symbol]);
1592
1623
  const current = parseHumanAmount(currentTokens[symbol]);
1593
1624
  chainMap[symbol] = formatHumanAmount(
1594
- lifetime + unrealized + current * keepRate
1625
+ (lifetime + unrealized + current) * keepRate
1595
1626
  );
1596
1627
  });
1597
1628
  totalEarningsByChainWithFee[chainId] = chainMap;
@@ -1631,6 +1662,22 @@ var DepositCreditTimeoutError = class extends Error {
1631
1662
  };
1632
1663
  var MANAGED_ASSETS = ["USDC", "WETH", "EURC", "NVDAc"];
1633
1664
  var _ZyfaiSDK = class _ZyfaiSDK {
1665
+ /**
1666
+ * Create an SDK instance bound to a partner API key.
1667
+ *
1668
+ * @param config - API key string or {@link SDKConfig} with optional `rpcUrls` and `referralSource`
1669
+ *
1670
+ * @remarks
1671
+ * `@internal` fields on {@link SDKConfig} (`executionApiUrl`, `dataApiUrl`,
1672
+ * `bypassMinPortfolio`) are for local integration tests only.
1673
+ *
1674
+ * @throws If `apiKey` is missing
1675
+ *
1676
+ * @example
1677
+ * ```typescript
1678
+ * const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY! });
1679
+ * ```
1680
+ */
1634
1681
  constructor(config) {
1635
1682
  this.signer = null;
1636
1683
  this.walletClient = null;
@@ -1640,6 +1687,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1640
1687
  this.connectedSmartWallet = null;
1641
1688
  this.currentProvider = null;
1642
1689
  this.currentChainId = null;
1690
+ /** EOA of the active user session (bearer or SIWE). Cleared on disconnect. */
1691
+ this.sessionEoa = null;
1643
1692
  const sdkConfig = typeof config === "string" ? { apiKey: config } : config;
1644
1693
  const {
1645
1694
  apiKey,
@@ -1661,6 +1710,78 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1661
1710
  this.rpcUrls = rpcUrls;
1662
1711
  this.referralSource = referralSource;
1663
1712
  }
1713
+ /**
1714
+ * Create an SDK instance with an existing Zyfai user JWT (no wallet connected).
1715
+ *
1716
+ * @group Authentication and wallet
1717
+ */
1718
+ static forUser(config, session) {
1719
+ const sdk = new _ZyfaiSDK(config);
1720
+ sdk.applyUserSession(session);
1721
+ return sdk;
1722
+ }
1723
+ /** Alias for MCP delegated grants (scoped agent JWT). */
1724
+ static forDelegatedGrant(config, session) {
1725
+ return _ZyfaiSDK.forUser(config, session);
1726
+ }
1727
+ /**
1728
+ * Attach a Zyfai user JWT for API calls without `connectAccount`.
1729
+ *
1730
+ * @group Authentication and wallet
1731
+ */
1732
+ applyUserSession(session) {
1733
+ if (!session.accessToken) {
1734
+ throw new Error("accessToken is required");
1735
+ }
1736
+ this.httpClient.setAuthToken(session.accessToken);
1737
+ this.authenticatedUserId = session.userId ?? "bearer-session";
1738
+ this.sessionEoa = session.eoa ? (0, import_viem4.getAddress)(session.eoa) : null;
1739
+ }
1740
+ /**
1741
+ * @internal Attach headers to execution API requests (MCP server agent channel).
1742
+ */
1743
+ setExecutionRequestHeaders(headers) {
1744
+ this.httpClient.setExtraExecutionHeaders(headers);
1745
+ }
1746
+ /** EOA of the active user session, if one is bound. */
1747
+ getSessionEoa() {
1748
+ return this.sessionEoa;
1749
+ }
1750
+ /**
1751
+ * Complete SIWE login with a prepared message and signature (OAuth consent, MCP).
1752
+ *
1753
+ * @group Authentication and wallet
1754
+ *
1755
+ * @param params.message - SIWE message fields (same shape as login API body)
1756
+ * @param params.signature - Wallet signature over the prepared SIWE string
1757
+ * @param params.origin - Origin header value; must match `message.uri`
1758
+ */
1759
+ async authenticateWithSignature(params) {
1760
+ const origin = params.origin ?? params.message.uri;
1761
+ const loginResponse = await this.httpClient.post(
1762
+ ENDPOINTS.AUTH_LOGIN,
1763
+ {
1764
+ message: params.message,
1765
+ signature: params.signature,
1766
+ referralSource: this.referralSource
1767
+ },
1768
+ {
1769
+ headers: {
1770
+ Origin: origin
1771
+ }
1772
+ }
1773
+ );
1774
+ if (!loginResponse.accessToken) {
1775
+ throw new Error("Authentication response missing access token");
1776
+ }
1777
+ this.httpClient.setAuthToken(loginResponse.accessToken);
1778
+ this.authenticatedUserId = loginResponse.userId || null;
1779
+ this.hasActiveSessionKey = loginResponse.hasActiveSessionKey || false;
1780
+ this.isPredeployed = loginResponse.predeployed || false;
1781
+ this.connectedSmartWallet = loginResponse.smartWallet || null;
1782
+ this.sessionEoa = (0, import_viem4.getAddress)(params.message.address);
1783
+ return loginResponse;
1784
+ }
1664
1785
  /**
1665
1786
  * Warn that a legacy method is deprecated in favor of sendDeposit.
1666
1787
  * Predeployed wallets no longer require deploySafe / createSessionKey.
@@ -1682,6 +1803,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1682
1803
  if (this.authenticatedUserId !== null) {
1683
1804
  return;
1684
1805
  }
1806
+ if (this.httpClient.hasAuthToken()) {
1807
+ return;
1808
+ }
1685
1809
  const walletClient = this.getWalletClient();
1686
1810
  const userAddress = (0, import_viem4.getAddress)(walletClient.account.address);
1687
1811
  const chainId = this.currentChainId || walletClient.chain?.id || 8453;
@@ -1735,6 +1859,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1735
1859
  this.hasActiveSessionKey = loginResponse.hasActiveSessionKey || false;
1736
1860
  this.isPredeployed = loginResponse.predeployed || false;
1737
1861
  this.connectedSmartWallet = loginResponse.smartWallet || null;
1862
+ this.sessionEoa = userAddress;
1738
1863
  } catch (error) {
1739
1864
  throw new Error(
1740
1865
  `Failed to authenticate user: ${error.message}`
@@ -1745,8 +1870,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1745
1870
  * Update user profile with Smart Wallet address and chain configuration
1746
1871
  * This method requires SIWE authentication and is automatically called after deploySafe
1747
1872
  *
1748
- * @param request - User profile update data
1749
- * @returns Updated user profile information
1873
+ * @group Portfolio and execution
1874
+ *
1875
+ * @param request - Profile fields to update (per-asset settings supported)
1876
+ * @returns Updated user profile from the execution API
1877
+ *
1878
+ * @throws If strategy is invalid or authentication fails
1750
1879
  *
1751
1880
  * @example
1752
1881
  * ```typescript
@@ -1807,8 +1936,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1807
1936
  * Pause the agent by clearing all protocols
1808
1937
  * Sets the user's protocols to an empty array, effectively pausing automated operations
1809
1938
  *
1939
+ * @group Portfolio and execution
1940
+ *
1810
1941
  * @returns Response indicating success and updated user details
1811
1942
  *
1943
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1944
+ *
1812
1945
  * @example
1813
1946
  * ```typescript
1814
1947
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -1839,8 +1972,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1839
1972
  * Resume the agent by restoring protocols based on user's strategy for each asset
1840
1973
  * Fetches available protocols and assigns them based on each asset's strategy
1841
1974
  *
1975
+ * @group Portfolio and execution
1976
+ *
1842
1977
  * @returns Response indicating success and updated user details
1843
1978
  *
1979
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1980
+ *
1844
1981
  * @example
1845
1982
  * ```typescript
1846
1983
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -1879,9 +2016,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1879
2016
  * Enable splitting for the user's account
1880
2017
  * When enabled, deposits are split across multiple protocols based on minSplits setting
1881
2018
  *
1882
- * @param minSplits - Optional minimum number of protocols to split across (default: 3)
2019
+ * @group Portfolio and execution
2020
+ *
2021
+ * @param minSplits - Minimum protocols to split across (max 4)
2022
+ * @defaultValue 1
1883
2023
  * @returns Response indicating success and updated user details
1884
2024
  *
2025
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
2026
+ *
2027
+ * @throws If `minSplits` exceeds 4
2028
+ *
1885
2029
  * @example
1886
2030
  * ```typescript
1887
2031
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -1914,8 +2058,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1914
2058
  * Disable splitting for the user's account
1915
2059
  * When disabled, deposits will not be split across multiple protocols
1916
2060
  *
2061
+ * @group Portfolio and execution
2062
+ *
1917
2063
  * @returns Response indicating success and updated user details
1918
2064
  *
2065
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
2066
+ *
1919
2067
  * @example
1920
2068
  * ```typescript
1921
2069
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -1944,9 +2092,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1944
2092
  * Update the minimum number of splits for the user's account
1945
2093
  * This controls across how many protocols deposits should be distributed
1946
2094
  *
1947
- * @param minSplits - Minimum number of protocols to split across
2095
+ * @group Portfolio and execution
2096
+ *
2097
+ * @param minSplits - Minimum number of protocols to split across (at least 1)
1948
2098
  * @returns Response indicating success and updated user details
1949
2099
  *
2100
+ * @throws If `minSplits` is less than 1
2101
+ *
1950
2102
  * @example
1951
2103
  * ```typescript
1952
2104
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -2025,6 +2177,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2025
2177
  }
2026
2178
  this.authenticatedUserId = null;
2027
2179
  this.hasActiveSessionKey = false;
2180
+ this.sessionEoa = null;
2028
2181
  this.httpClient.clearAuthToken();
2029
2182
  if (this.walletClient && this.currentProvider) {
2030
2183
  const chainConfig = getChainConfig(
@@ -2048,12 +2201,20 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2048
2201
  }
2049
2202
  }
2050
2203
  /**
2051
- * Connect account for signing transactions
2052
- * Accepts either a private key string or a modern wallet provider
2204
+ * Connect an account for signing (SIWE and on-chain transfers).
2205
+ *
2206
+ * @remarks
2207
+ * Required before user-scoped execution calls (deposits, withdrawals, profile).
2208
+ * Data API reads typically need only the API key.
2209
+ *
2210
+ * @group Authentication and wallet
2211
+ *
2212
+ * @param account - Private key hex string or EIP-1193 wallet provider
2213
+ * @param chainId - Initial chain for RPC and SIWE
2214
+ * @defaultValue 8453
2215
+ * @returns The connected EOA address (checksum)
2053
2216
  *
2054
- * @param account - Private key string or wallet provider object
2055
- * @param chainId - Target chain ID (default: 8453 - Base)
2056
- * @returns The connected EOA address
2217
+ * @throws If the chain is unsupported or the provider returns no accounts
2057
2218
  *
2058
2219
  * @example
2059
2220
  * // With private key
@@ -2072,6 +2233,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2072
2233
  this.isPredeployed = false;
2073
2234
  this.connectedSmartWallet = null;
2074
2235
  this.currentChainId = null;
2236
+ this.sessionEoa = null;
2075
2237
  this.httpClient.clearAuthToken();
2076
2238
  if (this.currentProvider?.removeAllListeners) {
2077
2239
  try {
@@ -2139,8 +2301,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2139
2301
  return connectedAddress;
2140
2302
  }
2141
2303
  /**
2142
- * Disconnect account and clear authentication state
2143
- * Resets wallet connection, JWT token, and all authentication-related state
2304
+ * Clear the connected wallet, SIWE session, and cached smart-wallet state.
2305
+ *
2306
+ * @group Authentication and wallet
2307
+ *
2308
+ * @returns Resolves when local SDK state is cleared
2144
2309
  *
2145
2310
  * @example
2146
2311
  * ```typescript
@@ -2163,6 +2328,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2163
2328
  this.hasActiveSessionKey = false;
2164
2329
  this.isPredeployed = false;
2165
2330
  this.connectedSmartWallet = null;
2331
+ this.sessionEoa = null;
2166
2332
  this.httpClient.clearAuthToken();
2167
2333
  }
2168
2334
  /**
@@ -2229,15 +2395,19 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2229
2395
  });
2230
2396
  }
2231
2397
  /**
2232
- * Get smart wallet address for a user
2233
- * Returns the Safe address for an EOA (deterministic for legacy wallets,
2234
- * backend-assigned for predeployed pool wallets).
2398
+ * Resolve the Safe smart wallet for an EOA on a chain.
2399
+ *
2400
+ * @remarks
2401
+ * Predeployed pool wallets use a backend-assigned address; legacy wallets use
2402
+ * a deterministic CREATE2 address.
2403
+ *
2404
+ * @group Authentication and wallet
2235
2405
  *
2236
2406
  * @param userAddress - User's EOA address
2237
2407
  * @param chainId - Target chain ID
2238
- * @returns Smart wallet address, deployment status, and whether userAddress
2239
- * is an on-chain OwnableValidator owner (false for reserved predeployed
2240
- * wallets until the first deposit rotates ownership)
2408
+ * @returns Smart wallet address, deployment status, and on-chain ownership flag
2409
+ *
2410
+ * @throws If `userAddress` is missing or `chainId` is unsupported
2241
2411
  */
2242
2412
  async getSmartWalletAddress(userAddress, chainId) {
2243
2413
  if (!userAddress) {
@@ -2269,10 +2439,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2269
2439
  /**
2270
2440
  * Deploy Safe Smart Wallet for a user
2271
2441
  *
2272
- * @deprecated Prefer `sendDeposit()`. Predeployed Safes and session keys are
2442
+ * @deprecated Prefer {@link ZyfaiSDK.sendDeposit}. Predeployed Safes and session keys are
2273
2443
  * managed automatically on first deposit. This method remains available for
2274
2444
  * legacy flows.
2275
2445
  *
2446
+ * @see {@link ZyfaiSDK.sendDeposit}
2447
+ *
2448
+ * @group Deposits and withdrawals
2449
+ *
2276
2450
  * @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
2277
2451
  * @param chainId - Target chain ID
2278
2452
  * @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
@@ -2409,10 +2583,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2409
2583
  * Create session key with auto-fetched configuration from Zyfai API
2410
2584
  * This is the simplified method that automatically fetches session configuration
2411
2585
  *
2412
- * @deprecated Prefer `sendDeposit()`. Predeployed wallets already have the
2586
+ * @deprecated Prefer {@link ZyfaiSDK.sendDeposit}. Predeployed wallets already have the
2413
2587
  * agent session enabled; session activation is handled after first deposit.
2414
2588
  * This method remains available for legacy flows.
2415
2589
  *
2590
+ * @see {@link ZyfaiSDK.sendDeposit}
2591
+ *
2592
+ * @group Deposits and withdrawals
2593
+ *
2416
2594
  * @param userAddress - User's EOA or Safe address
2417
2595
  * @param chainId - Target chain ID
2418
2596
  * @returns Session key response with signature and nonces
@@ -2666,6 +2844,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2666
2844
  * @param params.chains - Chains to enable. Defaults to every chain the asset
2667
2845
  * exists on. **Additive**: chains already enabled are kept, so this cannot
2668
2846
  * be used to disable one.
2847
+ * @group Portfolio and execution
2848
+ *
2669
2849
  * @returns The updated profile for that asset
2670
2850
  *
2671
2851
  * @example
@@ -2783,7 +2963,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2783
2963
  * transfer lands on the counterfactual address and the backend deploys + hands over on first
2784
2964
  * deposit (report-deposit). Use this only to pre-provision chains ahead of time.
2785
2965
  *
2786
- * @param chainIds - Chain IDs to deploy the wallet on (e.g. [1, 42161])
2966
+ * @group Deposits and withdrawals
2967
+ *
2968
+ * @param chainIds - Chain IDs to deploy the wallet on (e.g. `[1, 42161]`)
2969
+ * @returns Deployment summary from the execution API
2970
+ *
2971
+ * @throws If `chainIds` is empty or contains an unsupported chain
2972
+ *
2973
+ * @remarks
2974
+ * Requires {@link ZyfaiSDK.connectAccount} (SIWE). Optional ahead of deposits;
2975
+ * {@link ZyfaiSDK.sendDeposit} can deploy on first deposit for predeployed wallets.
2787
2976
  */
2788
2977
  async deployOnChains(chainIds) {
2789
2978
  if (!chainIds?.length) {
@@ -2796,10 +2985,33 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2796
2985
  return this.httpClient.post(ENDPOINTS.DEPLOY_CHAINS, { chainIds });
2797
2986
  }
2798
2987
  /**
2799
- * Send a deposit from an EOA to its Safe smart wallet.
2988
+ * Transfer funds from the connected EOA to the user's Safe and register the deposit.
2989
+ *
2990
+ * @remarks
2991
+ * Execution API + on-chain ERC-20 `transfer`. Confirms the transaction, then calls
2992
+ * {@link ZyfaiSDK.logDeposit}. Pair with {@link ZyfaiSDK.waitForDepositCredit} for
2993
+ * investable balance. Custom-wallet flows: {@link ZyfaiSDK.buildDepositTransfer},
2994
+ * {@link ZyfaiSDK.logDeposit}, {@link ZyfaiSDK.getDepositStatus}.
2995
+ *
2996
+ * Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
2997
+ *
2998
+ * @group Deposits and withdrawals
2999
+ *
3000
+ * @param userAddress - Owner EOA (not the Safe)
3001
+ * @param chainId - Chain for the transfer
3002
+ * @param amount - Amount in least units (string integer)
3003
+ * @param asset - Asset symbol (`USDC`, `WETH`, `EURC`, `NVDAc`)
3004
+ * @param strategy - Optional first-deposit {@link Strategy}
3005
+ * @returns Transfer receipt and deposit registration (not yet credited until polled)
3006
+ *
3007
+ * @throws If validation fails, minimum portfolio is not met, Safe is unavailable, or transfer/register fails
2800
3008
  *
2801
- * Confirms the ERC-20 transfer and starts the custody-credit lifecycle. Use
2802
- * `waitForDepositCredit(result.registration.id, chainId)` to await credit.
3009
+ * @example
3010
+ * ```typescript
3011
+ * await sdk.connectAccount(provider);
3012
+ * const sent = await sdk.sendDeposit(eoa, 8453, "10000000", "USDC", "conservative");
3013
+ * await sdk.waitForDepositCredit(sent.registration.id, 8453);
3014
+ * ```
2803
3015
  */
2804
3016
  async sendDeposit(userAddress, chainId, amount, asset, strategy) {
2805
3017
  try {
@@ -2918,8 +3130,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2918
3130
  }
2919
3131
  }
2920
3132
  /**
2921
- * @deprecated Compatibility convenience method. Prefer `sendDeposit()` followed by
2922
- * `waitForDepositCredit()` when the caller owns the completion UX.
3133
+ * @deprecated Compatibility convenience method. Prefer {@link ZyfaiSDK.sendDeposit} followed by
3134
+ * {@link ZyfaiSDK.waitForDepositCredit} when the caller owns the completion UX.
3135
+ *
3136
+ * @see {@link ZyfaiSDK.sendDeposit}
3137
+ *
3138
+ * @group Deposits and withdrawals
2923
3139
  */
2924
3140
  async depositFunds(userAddress, chainId, amount, asset, strategy) {
2925
3141
  this.warnDeprecatedOnboardingMethod("depositFunds");
@@ -2939,10 +3155,21 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2939
3155
  };
2940
3156
  }
2941
3157
  /**
2942
- * Prepare ERC-20 transfer calldata for builders using a custom signer,
2943
- * sponsored transaction provider, or mobile wallet. Most custom-wallet
2944
- * integrations can compose this with `ensureFirstDepositSetup()` and
2945
- * `logDeposit()` instead.
3158
+ * Build ERC-20 transfer calldata for a custom signer or sponsored tx flow.
3159
+ *
3160
+ * @remarks
3161
+ * Compose with {@link ZyfaiSDK.ensureFirstDepositSetup}, submit the transfer, then
3162
+ * {@link ZyfaiSDK.logDeposit} and {@link ZyfaiSDK.waitForDepositCredit}.
3163
+ *
3164
+ * @group Deposits and withdrawals
3165
+ *
3166
+ * @param params.userAddress - Owner EOA
3167
+ * @param params.chainId - Target chain
3168
+ * @param params.amount - Least units (string integer)
3169
+ * @param params.asset - {@link SupportedAsset}
3170
+ * @returns Safe address, token, and encoded `transfer` calldata
3171
+ *
3172
+ * @throws If inputs are invalid or the Safe address cannot be resolved
2946
3173
  */
2947
3174
  async buildDepositTransfer(params) {
2948
3175
  const { userAddress, chainId, amount, asset } = params;
@@ -3049,6 +3276,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3049
3276
  * When setup runs (`applied: true`), protocol configuration is persisted
3050
3277
  * before returning. Failures throw so callers can abort before submitting a
3051
3278
  * transfer. High-level deposit methods still treat setup as best-effort.
3279
+ *
3280
+ * @group Deposits and withdrawals
3281
+ *
3282
+ * @param strategy - Optional first-deposit {@link Strategy}
3283
+ * @returns `{ applied: true }` when chain/protocol config was written; `false` if already configured
3284
+ *
3285
+ * @throws If strategy is invalid or setup did not persist
3052
3286
  */
3053
3287
  async ensureFirstDepositSetup(strategy) {
3054
3288
  if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
@@ -3070,6 +3304,30 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3070
3304
  }
3071
3305
  return { applied: true };
3072
3306
  }
3307
+ /**
3308
+ * Prepare entering a position: persist first-deposit profile when needed and
3309
+ * return ERC-20 transfer calldata for the user to sign (does not broadcast).
3310
+ *
3311
+ * @group Deposits and withdrawals
3312
+ */
3313
+ async prepareEnterPosition(params) {
3314
+ const { userAddress, chainId, amount, asset, strategy } = params;
3315
+ if (this.sessionEoa && (0, import_viem4.getAddress)(userAddress) !== this.sessionEoa) {
3316
+ throw new Error("userAddress does not match authenticated session EOA");
3317
+ }
3318
+ const setup = await this.ensureFirstDepositSetup(strategy);
3319
+ const transfer = await this.buildDepositTransfer({
3320
+ userAddress,
3321
+ chainId,
3322
+ amount,
3323
+ asset
3324
+ });
3325
+ return {
3326
+ phase: "prepare_transfer",
3327
+ setup,
3328
+ transfer
3329
+ };
3330
+ }
3073
3331
  /** Best-effort first-deposit setup shared by both high-level deposit flows. */
3074
3332
  async prepareFirstDeposit(strategy) {
3075
3333
  try {
@@ -3125,8 +3383,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3125
3383
  * @param chainId - Chain ID where the deposit was made
3126
3384
  * @param txHash - Transaction hash of the deposit
3127
3385
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
3128
- * @param tokenAddress - Optional: Token address (auto-selected based on chain if not provided)
3129
- * @returns Log deposit response with success status
3386
+ * @param tokenAddress - Optional token contract (defaults per chain)
3387
+ * @returns Log deposit response with lifecycle record
3388
+ *
3389
+ * @group Deposits and withdrawals
3390
+ *
3391
+ * @throws If inputs are invalid or the execution API rejects registration
3130
3392
  *
3131
3393
  * @example
3132
3394
  * ```typescript
@@ -3177,8 +3439,18 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3177
3439
  }
3178
3440
  }
3179
3441
  /**
3180
- * Fetch the custody handover and balance-credit lifecycle for a registered
3181
- * deposit. A status of `credited` is required before funds are investable.
3442
+ * Fetch custody handover and balance-credit status for a registered deposit.
3443
+ *
3444
+ * @remarks
3445
+ * `status === "credited"` with `balanceCredited === true` means funds are investable.
3446
+ * Requires {@link ZyfaiSDK.connectAccount} (SIWE).
3447
+ *
3448
+ * @group Deposits and withdrawals
3449
+ *
3450
+ * @param depositId - Id from {@link LogDepositResponse} / {@link DepositResponse.registration}
3451
+ * @returns {@link DepositLifecycleResponse}
3452
+ *
3453
+ * @throws If `depositId` is missing
3182
3454
  */
3183
3455
  async getDepositStatus(depositId) {
3184
3456
  if (!depositId) {
@@ -3200,7 +3472,17 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3200
3472
  * ~250ms) with a ~20 second completion window. Override `timeoutMs` when a
3201
3473
  * caller intentionally wants to wait longer than the normal UX window.
3202
3474
  *
3203
- * Requires `connectAccount()` on the same SDK instance first.
3475
+ * Requires {@link ZyfaiSDK.connectAccount} on the same SDK instance.
3476
+ *
3477
+ * @group Deposits and withdrawals
3478
+ *
3479
+ * @param depositId - Deposit lifecycle id
3480
+ * @param chainId - Chain (controls poll interval and default timeout)
3481
+ * @param options - Optional `intervalMs` and `timeoutMs` overrides
3482
+ * @returns Final lifecycle record when credited
3483
+ *
3484
+ * @throws `DepositCreditTimeoutError` when the poll window elapses without credit
3485
+ * @throws If deposit recovers to EOA or polling fails
3204
3486
  */
3205
3487
  async waitForDepositCredit(depositId, chainId, options) {
3206
3488
  if (!depositId) {
@@ -3263,8 +3545,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3263
3545
  *
3264
3546
  * @param userAddress - User's address (owner of the Safe)
3265
3547
  * @param chainId - Target chain ID
3266
- * @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
3267
- * @returns Withdraw response with message and optional transaction hash (available once processed)
3548
+ * @param amount - Optional amount in least units (partial withdrawal); omit for full withdraw
3549
+ * @param tokenSymbol - Optional asset symbol when withdrawing a specific token
3550
+ * @returns Withdraw response with message and optional transaction hash
3551
+ *
3552
+ * @group Deposits and withdrawals
3553
+ *
3554
+ * @throws If `userAddress` or `chainId` is invalid, or the execution API rejects the request
3268
3555
  *
3269
3556
  * @example
3270
3557
  * ```typescript
@@ -3361,11 +3648,17 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3361
3648
  );
3362
3649
  }
3363
3650
  /**
3364
- * Get available DeFi protocols and pools for a specific chain
3651
+ * Get available DeFi protocols and pools for a specific chain.
3652
+ *
3653
+ * @group Portfolio and execution
3654
+ *
3655
+ * @remarks Execution API. Partner API key only.
3365
3656
  *
3366
3657
  * @param chainId - Target chain ID
3367
3658
  * @returns List of available protocols with their pools and APY data
3368
3659
  *
3660
+ * @throws If `chainId` is unsupported
3661
+ *
3369
3662
  * @example
3370
3663
  * ```typescript
3371
3664
  * const protocols = await sdk.getAvailableProtocols(8453);
@@ -3394,11 +3687,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3394
3687
  }
3395
3688
  }
3396
3689
  /**
3397
- * Get all active DeFi positions for a user
3690
+ * Get active DeFi positions for a user.
3691
+ *
3692
+ * @group Portfolio and execution
3693
+ *
3694
+ * @remarks Execution API (`/data/position`). Pass the **EOA**; the SDK resolves the Safe.
3398
3695
  *
3399
3696
  * @param userAddress - User's EOA address
3400
- * @param chainId - Optional chain used to resolve the Safe address (defaults to Base 8453)
3401
- * @returns User's positions across all protocols
3697
+ * @param chainId - Chain used to resolve the Safe (defaults to Base `8453`)
3698
+ * @returns User's positions across protocols
3402
3699
  *
3403
3700
  * @example
3404
3701
  * ```typescript
@@ -3478,9 +3775,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3478
3775
  * Do not add `CLAIMED` withdrawals either (the array keeps them for 24
3479
3776
  * hours); their funds are back in the Safe and already counted.
3480
3777
  *
3778
+ * @group Portfolio and execution
3779
+ *
3780
+ * @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
3781
+ * when using {@link Strategy | yieldmaxxing}.
3782
+ *
3481
3783
  * @param userAddress - User's EOA address
3482
3784
  * @returns Portfolio with optional fee-adjusted balance fields
3483
3785
  *
3786
+ * @throws If `userAddress` is missing
3787
+ *
3484
3788
  * @example
3485
3789
  * ```typescript
3486
3790
  * const { portfolio } = await sdk.getPortfolio(userAddress);
@@ -3535,10 +3839,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3535
3839
  // User Details Methods
3536
3840
  // ============================================================================
3537
3841
  /**
3538
- * Get current authenticated user details
3539
- * Requires SIWE authentication
3842
+ * Get the authenticated user's profile for an asset.
3540
3843
  *
3541
- * @returns User details including smart wallet, chains, protocols, etc.
3844
+ * @group Portfolio and execution
3845
+ *
3846
+ * @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
3847
+ *
3848
+ * @param asset - Asset slice of the profile to return
3849
+ * @defaultValue `"USDC"`
3850
+ * @returns User details including smart wallet, chains, and protocols
3542
3851
  *
3543
3852
  * @example
3544
3853
  * ```typescript
@@ -3585,9 +3894,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3585
3894
  // TVL & Volume Methods
3586
3895
  // ============================================================================
3587
3896
  /**
3588
- * Get total value locked (TVL) across all Zyfai accounts
3897
+ * Get total value locked (TVL) across all Zyfai accounts.
3898
+ *
3899
+ * @group Analytics and opportunities
3589
3900
  *
3590
- * @returns Total TVL in USD and breakdown by chain
3901
+ * @remarks Data API. Partner API key only; SIWE not required.
3902
+ *
3903
+ * @returns Total TVL in USD
3591
3904
  *
3592
3905
  * @example
3593
3906
  * ```typescript
@@ -3610,7 +3923,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3610
3923
  // APY Per Strategy Methods
3611
3924
  // ============================================================================
3612
3925
  /**
3613
- * Get APY per strategy for a specific chain
3926
+ * Get APY per strategy for a specific chain.
3927
+ *
3928
+ * @group Analytics and opportunities
3929
+ *
3930
+ * @remarks Data API. Partner API key only.
3614
3931
  *
3615
3932
  * @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
3616
3933
  * @param days - Time period: 7, 14, or 30
@@ -3653,7 +3970,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3653
3970
  }
3654
3971
  }
3655
3972
  /**
3656
- * Get total volume across all Zyfai accounts
3973
+ * Get total volume across all Zyfai accounts.
3974
+ *
3975
+ * @group Analytics and opportunities
3976
+ *
3977
+ * @remarks Data API. Partner API key only.
3657
3978
  *
3658
3979
  * @returns Total volume in USD
3659
3980
  *
@@ -3680,7 +4001,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3680
4001
  // Active Wallets Methods
3681
4002
  // ============================================================================
3682
4003
  /**
3683
- * Get active wallets for a specific chain
4004
+ * Get active wallets for a specific chain.
4005
+ *
4006
+ * @group Analytics and opportunities
4007
+ *
4008
+ * @remarks Data API. Partner API key only.
3684
4009
  *
3685
4010
  * @param chainId - Chain ID to filter wallets
3686
4011
  * @returns List of active wallets on the specified chain
@@ -3717,7 +4042,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3717
4042
  }
3718
4043
  }
3719
4044
  /**
3720
- * Get smart wallets associated with an EOA address
4045
+ * Get smart wallets associated with an EOA address.
4046
+ *
4047
+ * @group Analytics and opportunities
4048
+ *
4049
+ * @remarks Data API. Partner API key only.
3721
4050
  *
3722
4051
  * @param eoaAddress - EOA (externally owned account) address
3723
4052
  * @returns List of smart wallets owned by the EOA
@@ -3754,7 +4083,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3754
4083
  // First Topup & History Methods
3755
4084
  // ============================================================================
3756
4085
  /**
3757
- * Get the first topup (deposit) information for a wallet
4086
+ * Get the first topup (deposit) information for a wallet.
4087
+ *
4088
+ * @group Analytics and opportunities
4089
+ *
4090
+ * @remarks Data API. Partner API key only.
3758
4091
  *
3759
4092
  * @param walletAddress - Smart wallet address
3760
4093
  * @param chainId - Chain ID
@@ -3789,7 +4122,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3789
4122
  }
3790
4123
  }
3791
4124
  /**
3792
- * Get transaction history for a wallet
4125
+ * Get transaction history for a wallet.
4126
+ *
4127
+ * @group Analytics and opportunities
4128
+ *
4129
+ * @remarks Data API. Partner API key only.
3793
4130
  *
3794
4131
  * @param walletAddress - Smart wallet address
3795
4132
  * @param chainId - Chain ID
@@ -3845,11 +4182,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3845
4182
  // Onchain Earnings Methods (Data API v2)
3846
4183
  // ============================================================================
3847
4184
  /**
3848
- * Get onchain earnings for a wallet
4185
+ * Get onchain earnings for a wallet.
4186
+ *
4187
+ * @group Analytics and opportunities
4188
+ *
4189
+ * @remarks Data API. Partner API key only.
3849
4190
  *
3850
4191
  * Includes gross totals plus net-of-fee totals:
3851
- * `totalEarningsByTokenWithFee = lifetime + unrealized + current × (1 - feeRate)`.
3852
- * Lifetime and unrealized are never multiplied by the keep-rate.
4192
+ * `totalEarningsByTokenWithFee = (lifetime + unrealized + current) × (1 - feeRate)`.
4193
+ * Ledger buckets are gross, so the keep-rate applies to all three.
3853
4194
  *
3854
4195
  * @param walletAddress - Smart wallet address
3855
4196
  * @returns Onchain earnings data with per-token breakdowns
@@ -3998,7 +4339,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3998
4339
  // Opportunities Methods (Data API v2)
3999
4340
  // ============================================================================
4000
4341
  /**
4001
- * Get conservative (low-risk) yield opportunities
4342
+ * Get conservative (low-risk) yield opportunities.
4343
+ *
4344
+ * @group Analytics and opportunities
4345
+ *
4346
+ * @remarks Data API. Partner API key only.
4002
4347
  *
4003
4348
  * @param chainId - Optional chain ID filter
4004
4349
  * @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
@@ -4456,6 +4801,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4456
4801
  * Allows granular control over which pools to use for each protocol on each chain.
4457
4802
  * This is useful for advanced users who want to target specific pools with desired APY/risk profiles.
4458
4803
  *
4804
+ * @group Customization and simulation
4805
+ *
4806
+ * @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
4807
+ *
4459
4808
  * @param customizations - Array of customization configurations
4460
4809
  * @returns Response indicating success
4461
4810
  *
@@ -4484,6 +4833,65 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4484
4833
  * ]);
4485
4834
  * ```
4486
4835
  */
4836
+ /**
4837
+ * Get the user's agent management mandate (autonomy limits).
4838
+ *
4839
+ * @group Agent management
4840
+ */
4841
+ async getAgentMandate(oauthClientId) {
4842
+ await this.authenticateUser();
4843
+ const query = oauthClientId ? `?oauthClientId=${encodeURIComponent(oauthClientId)}` : "";
4844
+ return this.httpClient.get(
4845
+ `${ENDPOINTS.USER_AGENT_MANDATE}${query}`
4846
+ );
4847
+ }
4848
+ /**
4849
+ * Create or update the user's agent management mandate.
4850
+ *
4851
+ * @group Agent management
4852
+ */
4853
+ async setAgentMandate(request) {
4854
+ await this.authenticateUser();
4855
+ return this.httpClient.put(
4856
+ ENDPOINTS.USER_AGENT_MANDATE,
4857
+ request
4858
+ );
4859
+ }
4860
+ /**
4861
+ * Revoke the user's agent management mandate.
4862
+ *
4863
+ * @group Agent management
4864
+ */
4865
+ async revokeAgentMandate(oauthClientId) {
4866
+ await this.authenticateUser();
4867
+ return this.httpClient.delete(
4868
+ `${ENDPOINTS.USER_AGENT_MANDATE}?oauthClientId=${encodeURIComponent(oauthClientId)}`
4869
+ );
4870
+ }
4871
+ /**
4872
+ * Reserve a one-time action id before the user signs an ERC-20 transfer.
4873
+ *
4874
+ * @group Agent management
4875
+ */
4876
+ async createAgentEnterIntent(request) {
4877
+ await this.authenticateUser();
4878
+ return this.httpClient.post(
4879
+ ENDPOINTS.USER_AGENT_ENTER_INTENTS,
4880
+ request
4881
+ );
4882
+ }
4883
+ /**
4884
+ * Consume a one-time action id when registering the signed deposit.
4885
+ *
4886
+ * @group Agent management
4887
+ */
4888
+ async consumeAgentEnterIntent(actionId, request) {
4889
+ await this.authenticateUser();
4890
+ await this.httpClient.post(
4891
+ ENDPOINTS.USER_AGENT_ENTER_INTENT_CONSUME(actionId),
4892
+ request
4893
+ );
4894
+ }
4487
4895
  async customizeBatch(customizations) {
4488
4896
  try {
4489
4897
  await this.authenticateUser();
@@ -4503,8 +4911,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4503
4911
  *
4504
4912
  * Returns the list of pools available for a given protocol, optionally filtered by strategy.
4505
4913
  *
4914
+ * @group Customization and simulation
4915
+ *
4916
+ * @remarks Execution API. Partner API key only.
4917
+ *
4506
4918
  * @param protocolId - The protocol UUID
4507
- * @param strategy - Optional strategy filter ("conservative", "aggressive" or "yieldmaxxing")
4919
+ * @param strategy - Optional {@link Strategy} filter
4508
4920
  * @returns List of available pool names
4509
4921
  *
4510
4922
  * @example
@@ -4552,7 +4964,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4552
4964
  * calldata contains a "<RECEIVER>" placeholder that must be replaced with the
4553
4965
  * actual receiving address (e.g. the user's Safe) before sending the transaction.
4554
4966
  *
4555
- * @param params - Simulation parameters
4967
+ * @group Customization and simulation
4968
+ *
4969
+ * @remarks Data API simulation endpoint. Partner API key only.
4970
+ *
4971
+ * @param params - {@link SimulateBestPositionsParams}
4556
4972
  * @returns Chain-keyed map of simulated positions with calldata
4557
4973
  *
4558
4974
  * @example
@@ -4595,6 +5011,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4595
5011
  * Returns the pools that are currently configured for the authenticated user
4596
5012
  * for a given protocol and chain combination.
4597
5013
  *
5014
+ * @group Customization and simulation
5015
+ *
5016
+ * @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
5017
+ *
4598
5018
  * @param protocolId - The protocol UUID
4599
5019
  * @param chainId - The chain ID
4600
5020
  * @returns Currently selected pools and autoselect status
@@ -4702,10 +5122,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4702
5122
  // Vault Methods (Base only)
4703
5123
  // ============================================
4704
5124
  /**
4705
- * Deposit assets into the Zyfai Vault
4706
- * Currently only supports USDC on Base chain
5125
+ * Deposit assets into the Zyfai Vault (USDC on Base by default).
5126
+ *
5127
+ * @group Vault
4707
5128
  *
4708
- * @param amount - Amount to deposit (in human readable format, e.g., "100" for 100 USDC)
5129
+ * @remarks On-chain vault flow via connected wallet. Requires {@link ZyfaiSDK.connectAccount}.
5130
+ *
5131
+ * @param amount - Human-readable amount (e.g. `"100"` USDC)
4709
5132
  * @param asset - Asset to deposit (default: "USDC")
4710
5133
  * @returns Deposit transaction result
4711
5134
  *
@@ -5054,9 +5477,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5054
5477
  * Events: depeg, liquidity_trap, liquidity_restored, pool_status_change,
5055
5478
  * new_collateral_detected, liquidity_drop.
5056
5479
  *
5057
- * @param handlers - Callback per event type, plus onError
5058
- * @param filters - Optional protocol/pool filter sent to the server on subscribe
5059
- * @returns Cleanup function — call it to close the connection
5480
+ * @group Realtime events
5481
+ *
5482
+ * @remarks Connects to defi-api WebSocket (`WS_ENDPOINT`). Auto-reconnects every 3s until
5483
+ * the returned cleanup function is called.
5484
+ *
5485
+ * @param handlers - {@link ZyfaiEventHandlers}
5486
+ * @param filters - Optional {@link ZyfaiEventFilters} sent on subscribe
5487
+ * @returns Cleanup function — call it to close the connection and stop reconnecting
5060
5488
  *
5061
5489
  * @example
5062
5490
  * ```typescript