@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.d.mts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { Chain, PublicClient, Address as Address$1 } from 'viem';
2
2
 
3
3
  /**
4
- * Zyfai SDK Types
4
+ * Public TypeScript types for `@zyfai/sdk` request/response shapes and events.
5
5
  */
6
+ /** Checksummed Ethereum address. */
6
7
  type Address = `0x${string}`;
8
+ /** Hex-encoded byte string (e.g. signatures, calldata). */
7
9
  type Hex = `0x${string}`;
8
10
  /**
9
11
  * Public strategy names.
@@ -13,14 +15,27 @@ type Hex = `0x${string}`;
13
15
  type Strategy = "conservative" | "aggressive" | "yieldmaxxing";
14
16
  /** Public asset symbols supported by the SDK */
15
17
  type SupportedAsset = "USDC" | "WETH" | "EURC" | "NVDAc";
18
+ /** Optional per-chain RPC URLs for on-chain reads and writes. */
16
19
  interface RpcUrlsConfig {
20
+ /** Ethereum mainnet */
17
21
  1?: string;
22
+ /** Base */
18
23
  8453?: string;
24
+ /** Arbitrum One */
19
25
  42161?: string;
20
26
  }
27
+ /**
28
+ * SDK constructor configuration.
29
+ *
30
+ * @remarks
31
+ * A single partner `apiKey` authenticates both execution and data API calls.
32
+ */
21
33
  interface SDKConfig {
34
+ /** Partner API key from [sdk.zyf.ai](https://sdk.zyf.ai). */
22
35
  apiKey: string;
36
+ /** Override default viem RPC endpoints per chain. */
23
37
  rpcUrls?: RpcUrlsConfig;
38
+ /** Optional attribution string sent on SIWE login. */
24
39
  referralSource?: string;
25
40
  /** @internal Local integration tests only — not part of the public SDK contract. */
26
41
  executionApiUrl?: string;
@@ -29,6 +44,56 @@ interface SDKConfig {
29
44
  /** @internal Override client-side minimum portfolio checks (local integration). */
30
45
  bypassMinPortfolio?: boolean;
31
46
  }
47
+ /**
48
+ * Pre-authenticated user session for server-side SDK clients (e.g. MCP).
49
+ * Skips SIWE `connectAccount` when the Zyfai access token is already known.
50
+ */
51
+ /** Agent autonomy limits for MCP / delegated management. */
52
+ interface AgentMandate {
53
+ id: string;
54
+ oauthClientId: string;
55
+ /** Maximum USD of one deposit. Not total capital under management. */
56
+ maxDepositUsd?: string | null;
57
+ allowedChainIds: number[];
58
+ allowedAssets: string[];
59
+ allowRebalance: boolean;
60
+ allowWithdraw: boolean;
61
+ expiresAt?: string | null;
62
+ }
63
+ interface UpsertAgentMandateRequest {
64
+ oauthClientId: string;
65
+ /** Maximum USD of one deposit. Not total capital under management. */
66
+ maxDepositUsd?: string | null;
67
+ allowedChainIds?: number[];
68
+ allowedAssets?: string[];
69
+ allowRebalance?: boolean;
70
+ allowWithdraw?: boolean;
71
+ expiresAt?: string | null;
72
+ }
73
+ /** One-time prepare → enter binding for MCP deposit flows (least-unit amount). */
74
+ interface CreateAgentEnterIntentRequest {
75
+ chainId: number;
76
+ amount: string;
77
+ asset: SupportedAsset;
78
+ strategy?: Strategy;
79
+ }
80
+ interface AgentEnterIntent {
81
+ actionId: string;
82
+ expiresAt: string;
83
+ }
84
+ interface ConsumeAgentEnterIntentRequest {
85
+ chainId: number;
86
+ amount: string;
87
+ asset: SupportedAsset;
88
+ }
89
+ interface UserSessionAuth {
90
+ /** Zyfai execution API JWT from SIWE login. */
91
+ accessToken: string;
92
+ /** Authenticated user id when available. */
93
+ userId?: string;
94
+ /** User EOA address (checksum) for address binding checks. */
95
+ eoa?: Address;
96
+ }
32
97
  interface DeploySafeResponse {
33
98
  success: boolean;
34
99
  safeAddress: Address;
@@ -68,6 +133,22 @@ interface UpdateUserProfileResponse {
68
133
  asset?: SupportedAsset;
69
134
  }
70
135
  /** @internal */
136
+ interface LoginResponse {
137
+ userId: string;
138
+ accessToken?: string;
139
+ refreshToken?: string;
140
+ tokenExpires?: number;
141
+ hasActiveSessionKey?: boolean;
142
+ smartWallet?: string | null;
143
+ /**
144
+ * True when the smart wallet was provisioned by the predeployment pool
145
+ * (backend-owned at deploy, rotated to the user on first deposit). Such
146
+ * wallets are already deployed with the agent session enabled, so the client
147
+ * skips deploy, never signs a session key, and never derives the address.
148
+ */
149
+ predeployed?: boolean;
150
+ }
151
+ /** @internal */
71
152
  interface AddSessionKeyResponse {
72
153
  id: string;
73
154
  hash: string;
@@ -410,9 +491,8 @@ interface OnchainEarnings {
410
491
  totalEarningsByToken: TokenEarnings;
411
492
  totalEarningsByChain?: ChainTokenEarnings;
412
493
  /**
413
- * Net totals: lifetime + unrealized + current × (1 - feeRate).
414
- * Unrealized is treated like lifetime (no pending fee).
415
- * Does not apply feeRate to lifetime (already crystallised).
494
+ * Net totals: (lifetime + unrealized + current) × (1 - feeRate).
495
+ * Ledger buckets are gross. Crystallized yield is fee × 10.
416
496
  */
417
497
  totalEarningsByTokenWithFee: TokenEarnings;
418
498
  totalEarningsByChainWithFee?: ChainTokenEarnings;
@@ -462,16 +542,20 @@ interface DebankPortfolioResponse {
462
542
  totalValueUsd: number;
463
543
  chains: Record<string, ChainPortfolio>;
464
544
  }
545
+ /** Yield opportunity row from the data API opportunities endpoints. */
465
546
  interface Opportunity {
547
+ /** Opportunity identifier. */
466
548
  id: string;
467
549
  protocolId: string;
468
550
  protocolName: string;
469
551
  poolName: string;
470
552
  chainId: number;
553
+ /** Gross APY percentage. */
471
554
  apy: number;
472
555
  tvl?: number;
473
556
  asset?: string;
474
557
  risk?: string;
558
+ /** Public {@link Strategy} bucket for this pool. */
475
559
  strategyType: Strategy;
476
560
  status?: string;
477
561
  }
@@ -521,19 +605,36 @@ interface RebalanceFrequencyResponse {
521
605
  frequency: number;
522
606
  description?: string;
523
607
  }
608
+ /** Result of {@link ZyfaiSDK.sendDeposit} and {@link ZyfaiSDK.depositFunds}. */
524
609
  interface DepositResponse {
525
610
  success: boolean;
611
+ /** On-chain ERC-20 transfer transaction hash. */
526
612
  txHash: string;
613
+ /** Safe address that received the transfer. */
527
614
  smartWallet: string;
615
+ /** Deposited amount in least units (decimal string). */
528
616
  amount: string;
529
- /** Current lifecycle state; high-level methods return pending after their normal completion window. */
617
+ /**
618
+ * Deposit lifecycle record. After `sendDeposit`, status is usually
619
+ * `handover_pending` until {@link ZyfaiSDK.waitForDepositCredit} completes.
620
+ */
530
621
  registration: DepositLifecycleResponse;
531
622
  }
623
+ /**
624
+ * Custody handover and balance-credit states for a registered deposit.
625
+ *
626
+ * @remarks
627
+ * `credited` with `balanceCredited: true` means funds are investable.
628
+ */
532
629
  type DepositLifecycleStatus = "handover_pending" | "credited" | "recovered_to_eoa";
630
+ /** Deposit registration and credit lifecycle (execution API). */
533
631
  interface DepositLifecycleResponse {
632
+ /** Lifecycle id — pass to {@link ZyfaiSDK.getDepositStatus} / {@link ZyfaiSDK.waitForDepositCredit}. */
534
633
  id: string;
535
634
  status: DepositLifecycleStatus;
635
+ /** True when the Safe balance reflects the deposit. */
536
636
  balanceCredited: boolean;
637
+ /** Backend URL for status polling (informational). */
537
638
  statusUrl: string;
538
639
  }
539
640
  interface LogDepositResponse {
@@ -541,15 +642,21 @@ interface LogDepositResponse {
541
642
  message: string;
542
643
  deposit: DepositLifecycleResponse;
543
644
  }
645
+ /** Polling overrides for {@link ZyfaiSDK.waitForDepositCredit}. */
544
646
  interface WaitForDepositCreditOptions {
647
+ /** Milliseconds between {@link ZyfaiSDK.getDepositStatus} calls. */
545
648
  intervalMs?: number;
649
+ /** Maximum wait before throwing `DepositCreditTimeoutError`. */
546
650
  timeoutMs?: number;
547
651
  }
652
+ /** Result of {@link ZyfaiSDK.withdrawFunds}. */
548
653
  interface WithdrawResponse {
549
654
  success: boolean;
550
655
  message: string;
656
+ /** Present once the withdrawal transaction is submitted on-chain. */
551
657
  txHash?: string;
552
658
  type: "full" | "partial";
659
+ /** Withdrawn amount in least units (decimal string). */
553
660
  amount: string;
554
661
  }
555
662
  interface AddWalletToSdkResponse {
@@ -582,7 +689,9 @@ interface UserPosition {
582
689
  pool: string;
583
690
  tvl: number;
584
691
  }
692
+ /** Input for {@link ZyfaiSDK.simulateBestPositions}. */
585
693
  interface SimulateBestPositionsParams {
694
+ /** Human-readable amount (not least units). */
586
695
  amount: number;
587
696
  token: string;
588
697
  networks: number | number[];
@@ -629,6 +738,7 @@ interface ExcludedPool {
629
738
  detail: string;
630
739
  failed_checks?: string[];
631
740
  }
741
+ /** Simulation result keyed by chain id string. */
632
742
  interface SimulateBestPositionsResponse {
633
743
  success: boolean;
634
744
  data: Record<string, SimulatedPosition[]>;
@@ -685,10 +795,13 @@ interface RegisterAgentResponse {
685
795
  chainId: number;
686
796
  smartWallet: string;
687
797
  }
798
+ /** One protocol/pool customization row for {@link ZyfaiSDK.customizeBatch}. */
688
799
  interface CustomizationConfig {
689
800
  protocolId: string;
801
+ /** Pool display names; empty when `autoselect` is true. */
690
802
  pools: string[];
691
803
  chainId: number;
804
+ /** When true, the engine picks pools automatically. */
692
805
  autoselect: boolean;
693
806
  }
694
807
  interface CustomizeBatchRequest {
@@ -797,11 +910,13 @@ interface LiquidityDropEvent {
797
910
  windowMinutes: number;
798
911
  timestamp: string;
799
912
  }
913
+ /** Optional subscribe filters for {@link ZyfaiSDK.subscribeToEvents}. */
800
914
  interface ZyfaiEventFilters {
801
915
  chains?: string[];
802
916
  protocols?: string[];
803
917
  pools?: string[];
804
918
  }
919
+ /** WebSocket event callbacks for {@link ZyfaiSDK.subscribeToEvents}. */
805
920
  interface ZyfaiEventHandlers {
806
921
  onDepeg?: (data: DepegEvent) => void;
807
922
  onNewCollateralDetected?: (data: NewCollateralDetectedEvent) => void;
@@ -810,32 +925,49 @@ interface ZyfaiEventHandlers {
810
925
  }
811
926
 
812
927
  /**
813
- * Chain Configuration for Zyfai SDK
814
- * Supports Ethereum Mainnet, Arbitrum, and Base networks
928
+ * Chain configuration for SDK execution chains (Ethereum, Base, Arbitrum).
929
+ *
930
+ * @remarks
931
+ * Sonic and other data-only chains may appear in asset metadata but are not
932
+ * {@link SupportedChainId} execution targets.
815
933
  */
816
934
 
935
+ /** Chain IDs supported for deposits, withdrawals, and on-chain SDK calls. */
817
936
  type SupportedChainId = 1 | 8453 | 42161;
937
+ /** viem chain, RPC URL, and public client for a {@link SupportedChainId}. */
818
938
  interface ChainConfig {
819
939
  chain: Chain;
820
940
  rpcUrl: string;
821
941
  publicClient: PublicClient;
822
942
  }
943
+ /** Default USDC token addresses per execution chain. */
823
944
  declare const DEFAULT_TOKEN_ADDRESSES: Record<SupportedChainId, string>;
945
+ /**
946
+ * Resolve the canonical ERC-20 address for an asset on a chain.
947
+ *
948
+ * @param chainId - Execution chain
949
+ * @param asset - Asset symbol (defaults to USDC)
950
+ * @returns Token contract address
951
+ * @throws If the asset is not configured on the chain
952
+ */
824
953
  declare const getDefaultTokenAddress: (chainId: SupportedChainId, asset?: string) => string;
825
954
  /**
826
955
  * Get chain configuration for a given chain ID.
827
956
  *
828
957
  * @param chainId - Supported chain ID
829
- * @param rpcUrls - Optional per-chain RPC URL overrides
958
+ * @param rpcUrls - Optional per-chain RPC URL overrides from {@link SDKConfig}
959
+ * @returns Chain metadata and a viem `PublicClient`
960
+ * @throws If `chainId` is not supported
830
961
  */
831
962
  declare const getChainConfig: (chainId: SupportedChainId, rpcUrls?: RpcUrlsConfig) => ChainConfig;
832
963
  /**
833
- * Check if a chain ID is supported
964
+ * Check whether a numeric chain id is an SDK execution chain.
965
+ *
966
+ * @param chainId - Chain id to test
967
+ * @returns True when `chainId` is {@link SupportedChainId}
834
968
  */
835
969
  declare const isSupportedChain: (chainId: number) => chainId is SupportedChainId;
836
- /**
837
- * Get all supported chain IDs
838
- */
970
+ /** List all {@link SupportedChainId} values. */
839
971
  declare const getSupportedChainIds: () => SupportedChainId[];
840
972
 
841
973
  /**
@@ -852,6 +984,20 @@ type DailyApyHistoryPeriod = `${AllowedHistoryDays}D`;
852
984
  * Zyfai SDK Main Class
853
985
  */
854
986
 
987
+ /**
988
+ * Client for Zyfai execution (`api.zyf.ai`) and intelligence (`defiapi.zyf.ai`) APIs.
989
+ *
990
+ * @remarks
991
+ * The connected wallet from {@link ZyfaiSDK.connectAccount} is used for **signing only**
992
+ * (SIWE, on-chain transfers). Pass the user's **EOA** as `userAddress` on execution
993
+ * methods; the backend resolves the assigned Safe.
994
+ *
995
+ * First-time onboarding uses predeployed Safes: {@link ZyfaiSDK.sendDeposit} handles
996
+ * session and deploy-on-first-deposit without {@link ZyfaiSDK.deploySafe} or
997
+ * {@link ZyfaiSDK.createSessionKey}.
998
+ *
999
+ * @see {@link https://docs.zyf.ai/docs/sdk/agent-quickstart | Agent quickstart}
1000
+ */
855
1001
  declare class ZyfaiSDK {
856
1002
  private httpClient;
857
1003
  private signer;
@@ -864,6 +1010,54 @@ declare class ZyfaiSDK {
864
1010
  private currentChainId;
865
1011
  private rpcUrls?;
866
1012
  private referralSource?;
1013
+ /** EOA of the active user session (bearer or SIWE). Cleared on disconnect. */
1014
+ private sessionEoa;
1015
+ /**
1016
+ * Create an SDK instance with an existing Zyfai user JWT (no wallet connected).
1017
+ *
1018
+ * @group Authentication and wallet
1019
+ */
1020
+ static forUser(config: SDKConfig | string, session: UserSessionAuth): ZyfaiSDK;
1021
+ /** Alias for MCP delegated grants (scoped agent JWT). */
1022
+ static forDelegatedGrant(config: SDKConfig | string, session: UserSessionAuth): ZyfaiSDK;
1023
+ /**
1024
+ * Attach a Zyfai user JWT for API calls without `connectAccount`.
1025
+ *
1026
+ * @group Authentication and wallet
1027
+ */
1028
+ applyUserSession(session: UserSessionAuth): void;
1029
+ /**
1030
+ * @internal Attach headers to execution API requests (MCP server agent channel).
1031
+ */
1032
+ setExecutionRequestHeaders(headers: Record<string, string>): void;
1033
+ /** EOA of the active user session, if one is bound. */
1034
+ getSessionEoa(): Address | null;
1035
+ /**
1036
+ * Complete SIWE login with a prepared message and signature (OAuth consent, MCP).
1037
+ *
1038
+ * @group Authentication and wallet
1039
+ *
1040
+ * @param params.message - SIWE message fields (same shape as login API body)
1041
+ * @param params.signature - Wallet signature over the prepared SIWE string
1042
+ * @param params.origin - Origin header value; must match `message.uri`
1043
+ */
1044
+ authenticateWithSignature(params: {
1045
+ message: {
1046
+ address: string;
1047
+ chainId: number;
1048
+ domain: string;
1049
+ nonce: string;
1050
+ statement?: string;
1051
+ uri: string;
1052
+ version: string;
1053
+ issuedAt: string;
1054
+ resources?: string[];
1055
+ notBefore?: string;
1056
+ expirationTime?: string;
1057
+ };
1058
+ signature: Hex;
1059
+ origin?: string;
1060
+ }): Promise<LoginResponse>;
867
1061
  /**
868
1062
  * Warn that a legacy method is deprecated in favor of sendDeposit.
869
1063
  * Predeployed wallets no longer require deploySafe / createSessionKey.
@@ -871,6 +1065,22 @@ declare class ZyfaiSDK {
871
1065
  private warnDeprecatedOnboardingMethod;
872
1066
  private readonly executionApiUrl;
873
1067
  private readonly bypassMinPortfolio;
1068
+ /**
1069
+ * Create an SDK instance bound to a partner API key.
1070
+ *
1071
+ * @param config - API key string or {@link SDKConfig} with optional `rpcUrls` and `referralSource`
1072
+ *
1073
+ * @remarks
1074
+ * `@internal` fields on {@link SDKConfig} (`executionApiUrl`, `dataApiUrl`,
1075
+ * `bypassMinPortfolio`) are for local integration tests only.
1076
+ *
1077
+ * @throws If `apiKey` is missing
1078
+ *
1079
+ * @example
1080
+ * ```typescript
1081
+ * const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY! });
1082
+ * ```
1083
+ */
874
1084
  constructor(config: SDKConfig | string);
875
1085
  /**
876
1086
  * Authenticate user with SIWE (Sign-In with Ethereum) & JWT token
@@ -884,8 +1094,12 @@ declare class ZyfaiSDK {
884
1094
  * Update user profile with Smart Wallet address and chain configuration
885
1095
  * This method requires SIWE authentication and is automatically called after deploySafe
886
1096
  *
887
- * @param request - User profile update data
888
- * @returns Updated user profile information
1097
+ * @group Portfolio and execution
1098
+ *
1099
+ * @param request - Profile fields to update (per-asset settings supported)
1100
+ * @returns Updated user profile from the execution API
1101
+ *
1102
+ * @throws If strategy is invalid or authentication fails
889
1103
  *
890
1104
  * @example
891
1105
  * ```typescript
@@ -900,8 +1114,12 @@ declare class ZyfaiSDK {
900
1114
  * Pause the agent by clearing all protocols
901
1115
  * Sets the user's protocols to an empty array, effectively pausing automated operations
902
1116
  *
1117
+ * @group Portfolio and execution
1118
+ *
903
1119
  * @returns Response indicating success and updated user details
904
1120
  *
1121
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1122
+ *
905
1123
  * @example
906
1124
  * ```typescript
907
1125
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -919,8 +1137,12 @@ declare class ZyfaiSDK {
919
1137
  * Resume the agent by restoring protocols based on user's strategy for each asset
920
1138
  * Fetches available protocols and assigns them based on each asset's strategy
921
1139
  *
1140
+ * @group Portfolio and execution
1141
+ *
922
1142
  * @returns Response indicating success and updated user details
923
1143
  *
1144
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1145
+ *
924
1146
  * @example
925
1147
  * ```typescript
926
1148
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -938,9 +1160,16 @@ declare class ZyfaiSDK {
938
1160
  * Enable splitting for the user's account
939
1161
  * When enabled, deposits are split across multiple protocols based on minSplits setting
940
1162
  *
941
- * @param minSplits - Optional minimum number of protocols to split across (default: 3)
1163
+ * @group Portfolio and execution
1164
+ *
1165
+ * @param minSplits - Minimum protocols to split across (max 4)
1166
+ * @defaultValue 1
942
1167
  * @returns Response indicating success and updated user details
943
1168
  *
1169
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1170
+ *
1171
+ * @throws If `minSplits` exceeds 4
1172
+ *
944
1173
  * @example
945
1174
  * ```typescript
946
1175
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -958,8 +1187,12 @@ declare class ZyfaiSDK {
958
1187
  * Disable splitting for the user's account
959
1188
  * When disabled, deposits will not be split across multiple protocols
960
1189
  *
1190
+ * @group Portfolio and execution
1191
+ *
961
1192
  * @returns Response indicating success and updated user details
962
1193
  *
1194
+ * @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1195
+ *
963
1196
  * @example
964
1197
  * ```typescript
965
1198
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -977,9 +1210,13 @@ declare class ZyfaiSDK {
977
1210
  * Update the minimum number of splits for the user's account
978
1211
  * This controls across how many protocols deposits should be distributed
979
1212
  *
980
- * @param minSplits - Minimum number of protocols to split across
1213
+ * @group Portfolio and execution
1214
+ *
1215
+ * @param minSplits - Minimum number of protocols to split across (at least 1)
981
1216
  * @returns Response indicating success and updated user details
982
1217
  *
1218
+ * @throws If `minSplits` is less than 1
1219
+ *
983
1220
  * @example
984
1221
  * ```typescript
985
1222
  * const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
@@ -1015,12 +1252,20 @@ declare class ZyfaiSDK {
1015
1252
  */
1016
1253
  private handleAccountsChanged;
1017
1254
  /**
1018
- * Connect account for signing transactions
1019
- * Accepts either a private key string or a modern wallet provider
1255
+ * Connect an account for signing (SIWE and on-chain transfers).
1020
1256
  *
1021
- * @param account - Private key string or wallet provider object
1022
- * @param chainId - Target chain ID (default: 8453 - Base)
1023
- * @returns The connected EOA address
1257
+ * @remarks
1258
+ * Required before user-scoped execution calls (deposits, withdrawals, profile).
1259
+ * Data API reads typically need only the API key.
1260
+ *
1261
+ * @group Authentication and wallet
1262
+ *
1263
+ * @param account - Private key hex string or EIP-1193 wallet provider
1264
+ * @param chainId - Initial chain for RPC and SIWE
1265
+ * @defaultValue 8453
1266
+ * @returns The connected EOA address (checksum)
1267
+ *
1268
+ * @throws If the chain is unsupported or the provider returns no accounts
1024
1269
  *
1025
1270
  * @example
1026
1271
  * // With private key
@@ -1033,8 +1278,11 @@ declare class ZyfaiSDK {
1033
1278
  */
1034
1279
  connectAccount(account: string | any, chainId?: SupportedChainId): Promise<Address>;
1035
1280
  /**
1036
- * Disconnect account and clear authentication state
1037
- * Resets wallet connection, JWT token, and all authentication-related state
1281
+ * Clear the connected wallet, SIWE session, and cached smart-wallet state.
1282
+ *
1283
+ * @group Authentication and wallet
1284
+ *
1285
+ * @returns Resolves when local SDK state is cleared
1038
1286
  *
1039
1287
  * @example
1040
1288
  * ```typescript
@@ -1061,24 +1309,32 @@ declare class ZyfaiSDK {
1061
1309
  */
1062
1310
  private getSafeAddressFor;
1063
1311
  /**
1064
- * Get smart wallet address for a user
1065
- * Returns the Safe address for an EOA (deterministic for legacy wallets,
1066
- * backend-assigned for predeployed pool wallets).
1312
+ * Resolve the Safe smart wallet for an EOA on a chain.
1313
+ *
1314
+ * @remarks
1315
+ * Predeployed pool wallets use a backend-assigned address; legacy wallets use
1316
+ * a deterministic CREATE2 address.
1317
+ *
1318
+ * @group Authentication and wallet
1067
1319
  *
1068
1320
  * @param userAddress - User's EOA address
1069
1321
  * @param chainId - Target chain ID
1070
- * @returns Smart wallet address, deployment status, and whether userAddress
1071
- * is an on-chain OwnableValidator owner (false for reserved predeployed
1072
- * wallets until the first deposit rotates ownership)
1322
+ * @returns Smart wallet address, deployment status, and on-chain ownership flag
1323
+ *
1324
+ * @throws If `userAddress` is missing or `chainId` is unsupported
1073
1325
  */
1074
1326
  getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
1075
1327
  /**
1076
1328
  * Deploy Safe Smart Wallet for a user
1077
1329
  *
1078
- * @deprecated Prefer `sendDeposit()`. Predeployed Safes and session keys are
1330
+ * @deprecated Prefer {@link ZyfaiSDK.sendDeposit}. Predeployed Safes and session keys are
1079
1331
  * managed automatically on first deposit. This method remains available for
1080
1332
  * legacy flows.
1081
1333
  *
1334
+ * @see {@link ZyfaiSDK.sendDeposit}
1335
+ *
1336
+ * @group Deposits and withdrawals
1337
+ *
1082
1338
  * @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
1083
1339
  * @param chainId - Target chain ID
1084
1340
  * @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
@@ -1100,10 +1356,14 @@ declare class ZyfaiSDK {
1100
1356
  * Create session key with auto-fetched configuration from Zyfai API
1101
1357
  * This is the simplified method that automatically fetches session configuration
1102
1358
  *
1103
- * @deprecated Prefer `sendDeposit()`. Predeployed wallets already have the
1359
+ * @deprecated Prefer {@link ZyfaiSDK.sendDeposit}. Predeployed wallets already have the
1104
1360
  * agent session enabled; session activation is handled after first deposit.
1105
1361
  * This method remains available for legacy flows.
1106
1362
  *
1363
+ * @see {@link ZyfaiSDK.sendDeposit}
1364
+ *
1365
+ * @group Deposits and withdrawals
1366
+ *
1107
1367
  * @param userAddress - User's EOA or Safe address
1108
1368
  * @param chainId - Target chain ID
1109
1369
  * @returns Session key response with signature and nonces
@@ -1167,6 +1427,8 @@ declare class ZyfaiSDK {
1167
1427
  * @param params.chains - Chains to enable. Defaults to every chain the asset
1168
1428
  * exists on. **Additive**: chains already enabled are kept, so this cannot
1169
1429
  * be used to disable one.
1430
+ * @group Portfolio and execution
1431
+ *
1170
1432
  * @returns The updated profile for that asset
1171
1433
  *
1172
1434
  * @example
@@ -1216,7 +1478,16 @@ declare class ZyfaiSDK {
1216
1478
  * transfer lands on the counterfactual address and the backend deploys + hands over on first
1217
1479
  * deposit (report-deposit). Use this only to pre-provision chains ahead of time.
1218
1480
  *
1219
- * @param chainIds - Chain IDs to deploy the wallet on (e.g. [1, 42161])
1481
+ * @group Deposits and withdrawals
1482
+ *
1483
+ * @param chainIds - Chain IDs to deploy the wallet on (e.g. `[1, 42161]`)
1484
+ * @returns Deployment summary from the execution API
1485
+ *
1486
+ * @throws If `chainIds` is empty or contains an unsupported chain
1487
+ *
1488
+ * @remarks
1489
+ * Requires {@link ZyfaiSDK.connectAccount} (SIWE). Optional ahead of deposits;
1490
+ * {@link ZyfaiSDK.sendDeposit} can deploy on first deposit for predeployed wallets.
1220
1491
  */
1221
1492
  deployOnChains(chainIds: SupportedChainId[]): Promise<{
1222
1493
  success: boolean;
@@ -1225,22 +1496,60 @@ declare class ZyfaiSDK {
1225
1496
  status: string;
1226
1497
  }>;
1227
1498
  /**
1228
- * Send a deposit from an EOA to its Safe smart wallet.
1499
+ * Transfer funds from the connected EOA to the user's Safe and register the deposit.
1500
+ *
1501
+ * @remarks
1502
+ * Execution API + on-chain ERC-20 `transfer`. Confirms the transaction, then calls
1503
+ * {@link ZyfaiSDK.logDeposit}. Pair with {@link ZyfaiSDK.waitForDepositCredit} for
1504
+ * investable balance. Custom-wallet flows: {@link ZyfaiSDK.buildDepositTransfer},
1505
+ * {@link ZyfaiSDK.logDeposit}, {@link ZyfaiSDK.getDepositStatus}.
1506
+ *
1507
+ * Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
1229
1508
  *
1230
- * Confirms the ERC-20 transfer and starts the custody-credit lifecycle. Use
1231
- * `waitForDepositCredit(result.registration.id, chainId)` to await credit.
1509
+ * @group Deposits and withdrawals
1510
+ *
1511
+ * @param userAddress - Owner EOA (not the Safe)
1512
+ * @param chainId - Chain for the transfer
1513
+ * @param amount - Amount in least units (string integer)
1514
+ * @param asset - Asset symbol (`USDC`, `WETH`, `EURC`, `NVDAc`)
1515
+ * @param strategy - Optional first-deposit {@link Strategy}
1516
+ * @returns Transfer receipt and deposit registration (not yet credited until polled)
1517
+ *
1518
+ * @throws If validation fails, minimum portfolio is not met, Safe is unavailable, or transfer/register fails
1519
+ *
1520
+ * @example
1521
+ * ```typescript
1522
+ * await sdk.connectAccount(provider);
1523
+ * const sent = await sdk.sendDeposit(eoa, 8453, "10000000", "USDC", "conservative");
1524
+ * await sdk.waitForDepositCredit(sent.registration.id, 8453);
1525
+ * ```
1232
1526
  */
1233
1527
  sendDeposit(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
1234
1528
  /**
1235
- * @deprecated Compatibility convenience method. Prefer `sendDeposit()` followed by
1236
- * `waitForDepositCredit()` when the caller owns the completion UX.
1529
+ * @deprecated Compatibility convenience method. Prefer {@link ZyfaiSDK.sendDeposit} followed by
1530
+ * {@link ZyfaiSDK.waitForDepositCredit} when the caller owns the completion UX.
1531
+ *
1532
+ * @see {@link ZyfaiSDK.sendDeposit}
1533
+ *
1534
+ * @group Deposits and withdrawals
1237
1535
  */
1238
1536
  depositFunds(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
1239
1537
  /**
1240
- * Prepare ERC-20 transfer calldata for builders using a custom signer,
1241
- * sponsored transaction provider, or mobile wallet. Most custom-wallet
1242
- * integrations can compose this with `ensureFirstDepositSetup()` and
1243
- * `logDeposit()` instead.
1538
+ * Build ERC-20 transfer calldata for a custom signer or sponsored tx flow.
1539
+ *
1540
+ * @remarks
1541
+ * Compose with {@link ZyfaiSDK.ensureFirstDepositSetup}, submit the transfer, then
1542
+ * {@link ZyfaiSDK.logDeposit} and {@link ZyfaiSDK.waitForDepositCredit}.
1543
+ *
1544
+ * @group Deposits and withdrawals
1545
+ *
1546
+ * @param params.userAddress - Owner EOA
1547
+ * @param params.chainId - Target chain
1548
+ * @param params.amount - Least units (string integer)
1549
+ * @param params.asset - {@link SupportedAsset}
1550
+ * @returns Safe address, token, and encoded `transfer` calldata
1551
+ *
1552
+ * @throws If inputs are invalid or the Safe address cannot be resolved
1244
1553
  */
1245
1554
  buildDepositTransfer(params: {
1246
1555
  userAddress: string;
@@ -1264,10 +1573,42 @@ declare class ZyfaiSDK {
1264
1573
  * When setup runs (`applied: true`), protocol configuration is persisted
1265
1574
  * before returning. Failures throw so callers can abort before submitting a
1266
1575
  * transfer. High-level deposit methods still treat setup as best-effort.
1576
+ *
1577
+ * @group Deposits and withdrawals
1578
+ *
1579
+ * @param strategy - Optional first-deposit {@link Strategy}
1580
+ * @returns `{ applied: true }` when chain/protocol config was written; `false` if already configured
1581
+ *
1582
+ * @throws If strategy is invalid or setup did not persist
1267
1583
  */
1268
1584
  ensureFirstDepositSetup(strategy?: Strategy): Promise<{
1269
1585
  applied: boolean;
1270
1586
  }>;
1587
+ /**
1588
+ * Prepare entering a position: persist first-deposit profile when needed and
1589
+ * return ERC-20 transfer calldata for the user to sign (does not broadcast).
1590
+ *
1591
+ * @group Deposits and withdrawals
1592
+ */
1593
+ prepareEnterPosition(params: {
1594
+ userAddress: string;
1595
+ chainId: SupportedChainId;
1596
+ amount: string;
1597
+ asset: SupportedAsset;
1598
+ strategy?: Strategy;
1599
+ }): Promise<{
1600
+ phase: "prepare_transfer";
1601
+ setup: {
1602
+ applied: boolean;
1603
+ };
1604
+ transfer: {
1605
+ safeAddress: Address;
1606
+ tokenAddress: Address;
1607
+ to: Address;
1608
+ data: Hex;
1609
+ value: "0";
1610
+ };
1611
+ }>;
1271
1612
  /** Best-effort first-deposit setup shared by both high-level deposit flows. */
1272
1613
  private prepareFirstDeposit;
1273
1614
  /** Shared post-transfer registration path for every deposit flow. */
@@ -1299,8 +1640,12 @@ declare class ZyfaiSDK {
1299
1640
  * @param chainId - Chain ID where the deposit was made
1300
1641
  * @param txHash - Transaction hash of the deposit
1301
1642
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
1302
- * @param tokenAddress - Optional: Token address (auto-selected based on chain if not provided)
1303
- * @returns Log deposit response with success status
1643
+ * @param tokenAddress - Optional token contract (defaults per chain)
1644
+ * @returns Log deposit response with lifecycle record
1645
+ *
1646
+ * @group Deposits and withdrawals
1647
+ *
1648
+ * @throws If inputs are invalid or the execution API rejects registration
1304
1649
  *
1305
1650
  * @example
1306
1651
  * ```typescript
@@ -1321,8 +1666,18 @@ declare class ZyfaiSDK {
1321
1666
  */
1322
1667
  logDeposit(chainId: SupportedChainId, txHash: string, amount: string, tokenAddress?: string): Promise<LogDepositResponse>;
1323
1668
  /**
1324
- * Fetch the custody handover and balance-credit lifecycle for a registered
1325
- * deposit. A status of `credited` is required before funds are investable.
1669
+ * Fetch custody handover and balance-credit status for a registered deposit.
1670
+ *
1671
+ * @remarks
1672
+ * `status === "credited"` with `balanceCredited === true` means funds are investable.
1673
+ * Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1674
+ *
1675
+ * @group Deposits and withdrawals
1676
+ *
1677
+ * @param depositId - Id from {@link LogDepositResponse} / {@link DepositResponse.registration}
1678
+ * @returns {@link DepositLifecycleResponse}
1679
+ *
1680
+ * @throws If `depositId` is missing
1326
1681
  */
1327
1682
  getDepositStatus(depositId: string): Promise<DepositLifecycleResponse>;
1328
1683
  /**
@@ -1336,7 +1691,17 @@ declare class ZyfaiSDK {
1336
1691
  * ~250ms) with a ~20 second completion window. Override `timeoutMs` when a
1337
1692
  * caller intentionally wants to wait longer than the normal UX window.
1338
1693
  *
1339
- * Requires `connectAccount()` on the same SDK instance first.
1694
+ * Requires {@link ZyfaiSDK.connectAccount} on the same SDK instance.
1695
+ *
1696
+ * @group Deposits and withdrawals
1697
+ *
1698
+ * @param depositId - Deposit lifecycle id
1699
+ * @param chainId - Chain (controls poll interval and default timeout)
1700
+ * @param options - Optional `intervalMs` and `timeoutMs` overrides
1701
+ * @returns Final lifecycle record when credited
1702
+ *
1703
+ * @throws `DepositCreditTimeoutError` when the poll window elapses without credit
1704
+ * @throws If deposit recovers to EOA or polling fails
1340
1705
  */
1341
1706
  waitForDepositCredit(depositId: string, chainId: SupportedChainId, options?: WaitForDepositCreditOptions): Promise<DepositLifecycleResponse>;
1342
1707
  /**
@@ -1373,8 +1738,13 @@ declare class ZyfaiSDK {
1373
1738
  *
1374
1739
  * @param userAddress - User's address (owner of the Safe)
1375
1740
  * @param chainId - Target chain ID
1376
- * @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
1377
- * @returns Withdraw response with message and optional transaction hash (available once processed)
1741
+ * @param amount - Optional amount in least units (partial withdrawal); omit for full withdraw
1742
+ * @param tokenSymbol - Optional asset symbol when withdrawing a specific token
1743
+ * @returns Withdraw response with message and optional transaction hash
1744
+ *
1745
+ * @group Deposits and withdrawals
1746
+ *
1747
+ * @throws If `userAddress` or `chainId` is invalid, or the execution API rejects the request
1378
1748
  *
1379
1749
  * @example
1380
1750
  * ```typescript
@@ -1400,11 +1770,17 @@ declare class ZyfaiSDK {
1400
1770
  */
1401
1771
  private assertAsyncRedemptionSlotFree;
1402
1772
  /**
1403
- * Get available DeFi protocols and pools for a specific chain
1773
+ * Get available DeFi protocols and pools for a specific chain.
1774
+ *
1775
+ * @group Portfolio and execution
1776
+ *
1777
+ * @remarks Execution API. Partner API key only.
1404
1778
  *
1405
1779
  * @param chainId - Target chain ID
1406
1780
  * @returns List of available protocols with their pools and APY data
1407
1781
  *
1782
+ * @throws If `chainId` is unsupported
1783
+ *
1408
1784
  * @example
1409
1785
  * ```typescript
1410
1786
  * const protocols = await sdk.getAvailableProtocols(8453);
@@ -1415,11 +1791,15 @@ declare class ZyfaiSDK {
1415
1791
  */
1416
1792
  getAvailableProtocols(chainId: SupportedChainId): Promise<ProtocolsResponse>;
1417
1793
  /**
1418
- * Get all active DeFi positions for a user
1794
+ * Get active DeFi positions for a user.
1795
+ *
1796
+ * @group Portfolio and execution
1797
+ *
1798
+ * @remarks Execution API (`/data/position`). Pass the **EOA**; the SDK resolves the Safe.
1419
1799
  *
1420
1800
  * @param userAddress - User's EOA address
1421
- * @param chainId - Optional chain used to resolve the Safe address (defaults to Base 8453)
1422
- * @returns User's positions across all protocols
1801
+ * @param chainId - Chain used to resolve the Safe (defaults to Base `8453`)
1802
+ * @returns User's positions across protocols
1423
1803
  *
1424
1804
  * @example
1425
1805
  * ```typescript
@@ -1466,9 +1846,16 @@ declare class ZyfaiSDK {
1466
1846
  * Do not add `CLAIMED` withdrawals either (the array keeps them for 24
1467
1847
  * hours); their funds are back in the Safe and already counted.
1468
1848
  *
1849
+ * @group Portfolio and execution
1850
+ *
1851
+ * @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
1852
+ * when using {@link Strategy | yieldmaxxing}.
1853
+ *
1469
1854
  * @param userAddress - User's EOA address
1470
1855
  * @returns Portfolio with optional fee-adjusted balance fields
1471
1856
  *
1857
+ * @throws If `userAddress` is missing
1858
+ *
1472
1859
  * @example
1473
1860
  * ```typescript
1474
1861
  * const { portfolio } = await sdk.getPortfolio(userAddress);
@@ -1482,10 +1869,15 @@ declare class ZyfaiSDK {
1482
1869
  */
1483
1870
  getPortfolio(userAddress: string): Promise<PortfolioDetailedResponse>;
1484
1871
  /**
1485
- * Get current authenticated user details
1486
- * Requires SIWE authentication
1872
+ * Get the authenticated user's profile for an asset.
1873
+ *
1874
+ * @group Portfolio and execution
1487
1875
  *
1488
- * @returns User details including smart wallet, chains, protocols, etc.
1876
+ * @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
1877
+ *
1878
+ * @param asset - Asset slice of the profile to return
1879
+ * @defaultValue `"USDC"`
1880
+ * @returns User details including smart wallet, chains, and protocols
1489
1881
  *
1490
1882
  * @example
1491
1883
  * ```typescript
@@ -1497,9 +1889,13 @@ declare class ZyfaiSDK {
1497
1889
  */
1498
1890
  getUserDetails(asset?: SupportedAsset): Promise<UpdateUserProfileResponse>;
1499
1891
  /**
1500
- * Get total value locked (TVL) across all Zyfai accounts
1892
+ * Get total value locked (TVL) across all Zyfai accounts.
1893
+ *
1894
+ * @group Analytics and opportunities
1895
+ *
1896
+ * @remarks Data API. Partner API key only; SIWE not required.
1501
1897
  *
1502
- * @returns Total TVL in USD and breakdown by chain
1898
+ * @returns Total TVL in USD
1503
1899
  *
1504
1900
  * @example
1505
1901
  * ```typescript
@@ -1509,7 +1905,11 @@ declare class ZyfaiSDK {
1509
1905
  */
1510
1906
  getTVL(): Promise<TVLResponse>;
1511
1907
  /**
1512
- * Get APY per strategy for a specific chain
1908
+ * Get APY per strategy for a specific chain.
1909
+ *
1910
+ * @group Analytics and opportunities
1911
+ *
1912
+ * @remarks Data API. Partner API key only.
1513
1913
  *
1514
1914
  * @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
1515
1915
  * @param days - Time period: 7, 14, or 30
@@ -1526,7 +1926,11 @@ declare class ZyfaiSDK {
1526
1926
  */
1527
1927
  getAPYPerStrategy(crossChain?: boolean, days?: number, strategy?: Strategy, chainId?: number, tokenSymbol?: string): Promise<APYPerStrategyResponse>;
1528
1928
  /**
1529
- * Get total volume across all Zyfai accounts
1929
+ * Get total volume across all Zyfai accounts.
1930
+ *
1931
+ * @group Analytics and opportunities
1932
+ *
1933
+ * @remarks Data API. Partner API key only.
1530
1934
  *
1531
1935
  * @returns Total volume in USD
1532
1936
  *
@@ -1538,7 +1942,11 @@ declare class ZyfaiSDK {
1538
1942
  */
1539
1943
  getVolume(assetType?: "usdc" | "eth" | "eurc"): Promise<VolumeResponse>;
1540
1944
  /**
1541
- * Get active wallets for a specific chain
1945
+ * Get active wallets for a specific chain.
1946
+ *
1947
+ * @group Analytics and opportunities
1948
+ *
1949
+ * @remarks Data API. Partner API key only.
1542
1950
  *
1543
1951
  * @param chainId - Chain ID to filter wallets
1544
1952
  * @returns List of active wallets on the specified chain
@@ -1551,7 +1959,11 @@ declare class ZyfaiSDK {
1551
1959
  */
1552
1960
  getActiveWallets(chainId: number): Promise<ActiveWalletsResponse>;
1553
1961
  /**
1554
- * Get smart wallets associated with an EOA address
1962
+ * Get smart wallets associated with an EOA address.
1963
+ *
1964
+ * @group Analytics and opportunities
1965
+ *
1966
+ * @remarks Data API. Partner API key only.
1555
1967
  *
1556
1968
  * @param eoaAddress - EOA (externally owned account) address
1557
1969
  * @returns List of smart wallets owned by the EOA
@@ -1564,7 +1976,11 @@ declare class ZyfaiSDK {
1564
1976
  */
1565
1977
  getSmartWalletByEOA(eoaAddress: string): Promise<SmartWalletByEOAResponse>;
1566
1978
  /**
1567
- * Get the first topup (deposit) information for a wallet
1979
+ * Get the first topup (deposit) information for a wallet.
1980
+ *
1981
+ * @group Analytics and opportunities
1982
+ *
1983
+ * @remarks Data API. Partner API key only.
1568
1984
  *
1569
1985
  * @param walletAddress - Smart wallet address
1570
1986
  * @param chainId - Chain ID
@@ -1578,7 +1994,11 @@ declare class ZyfaiSDK {
1578
1994
  */
1579
1995
  getFirstTopup(walletAddress: string, chainId: number): Promise<FirstTopupResponse>;
1580
1996
  /**
1581
- * Get transaction history for a wallet
1997
+ * Get transaction history for a wallet.
1998
+ *
1999
+ * @group Analytics and opportunities
2000
+ *
2001
+ * @remarks Data API. Partner API key only.
1582
2002
  *
1583
2003
  * @param walletAddress - Smart wallet address
1584
2004
  * @param chainId - Chain ID
@@ -1602,11 +2022,15 @@ declare class ZyfaiSDK {
1602
2022
  assetType?: "usdc" | "eth" | "eurc";
1603
2023
  }): Promise<HistoryResponse>;
1604
2024
  /**
1605
- * Get onchain earnings for a wallet
2025
+ * Get onchain earnings for a wallet.
2026
+ *
2027
+ * @group Analytics and opportunities
2028
+ *
2029
+ * @remarks Data API. Partner API key only.
1606
2030
  *
1607
2031
  * Includes gross totals plus net-of-fee totals:
1608
- * `totalEarningsByTokenWithFee = lifetime + unrealized + current × (1 - feeRate)`.
1609
- * Lifetime and unrealized are never multiplied by the keep-rate.
2032
+ * `totalEarningsByTokenWithFee = (lifetime + unrealized + current) × (1 - feeRate)`.
2033
+ * Ledger buckets are gross, so the keep-rate applies to all three.
1610
2034
  *
1611
2035
  * @param walletAddress - Smart wallet address
1612
2036
  * @returns Onchain earnings data with per-token breakdowns
@@ -1663,7 +2087,11 @@ declare class ZyfaiSDK {
1663
2087
  */
1664
2088
  getDailyEarnings(walletAddress: string, startDate?: string, endDate?: string): Promise<DailyEarningsResponse>;
1665
2089
  /**
1666
- * Get conservative (low-risk) yield opportunities
2090
+ * Get conservative (low-risk) yield opportunities.
2091
+ *
2092
+ * @group Analytics and opportunities
2093
+ *
2094
+ * @remarks Data API. Partner API key only.
1667
2095
  *
1668
2096
  * @param chainId - Optional chain ID filter
1669
2097
  * @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
@@ -1829,6 +2257,10 @@ declare class ZyfaiSDK {
1829
2257
  * Allows granular control over which pools to use for each protocol on each chain.
1830
2258
  * This is useful for advanced users who want to target specific pools with desired APY/risk profiles.
1831
2259
  *
2260
+ * @group Customization and simulation
2261
+ *
2262
+ * @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
2263
+ *
1832
2264
  * @param customizations - Array of customization configurations
1833
2265
  * @returns Response indicating success
1834
2266
  *
@@ -1857,14 +2289,56 @@ declare class ZyfaiSDK {
1857
2289
  * ]);
1858
2290
  * ```
1859
2291
  */
2292
+ /**
2293
+ * Get the user's agent management mandate (autonomy limits).
2294
+ *
2295
+ * @group Agent management
2296
+ */
2297
+ getAgentMandate(oauthClientId?: string): Promise<{
2298
+ data: AgentMandate | null;
2299
+ }>;
2300
+ /**
2301
+ * Create or update the user's agent management mandate.
2302
+ *
2303
+ * @group Agent management
2304
+ */
2305
+ setAgentMandate(request: UpsertAgentMandateRequest): Promise<{
2306
+ data: AgentMandate;
2307
+ }>;
2308
+ /**
2309
+ * Revoke the user's agent management mandate.
2310
+ *
2311
+ * @group Agent management
2312
+ */
2313
+ revokeAgentMandate(oauthClientId: string): Promise<{
2314
+ success: boolean;
2315
+ }>;
2316
+ /**
2317
+ * Reserve a one-time action id before the user signs an ERC-20 transfer.
2318
+ *
2319
+ * @group Agent management
2320
+ */
2321
+ createAgentEnterIntent(request: CreateAgentEnterIntentRequest): Promise<{
2322
+ data: AgentEnterIntent;
2323
+ }>;
2324
+ /**
2325
+ * Consume a one-time action id when registering the signed deposit.
2326
+ *
2327
+ * @group Agent management
2328
+ */
2329
+ consumeAgentEnterIntent(actionId: string, request: ConsumeAgentEnterIntentRequest): Promise<void>;
1860
2330
  customizeBatch(customizations: CustomizationConfig[]): Promise<CustomizeBatchResponse>;
1861
2331
  /**
1862
2332
  * Get available pools for a protocol.
1863
2333
  *
1864
2334
  * Returns the list of pools available for a given protocol, optionally filtered by strategy.
1865
2335
  *
2336
+ * @group Customization and simulation
2337
+ *
2338
+ * @remarks Execution API. Partner API key only.
2339
+ *
1866
2340
  * @param protocolId - The protocol UUID
1867
- * @param strategy - Optional strategy filter ("conservative", "aggressive" or "yieldmaxxing")
2341
+ * @param strategy - Optional {@link Strategy} filter
1868
2342
  * @returns List of available pool names
1869
2343
  *
1870
2344
  * @example
@@ -1889,7 +2363,11 @@ declare class ZyfaiSDK {
1889
2363
  * calldata contains a "<RECEIVER>" placeholder that must be replaced with the
1890
2364
  * actual receiving address (e.g. the user's Safe) before sending the transaction.
1891
2365
  *
1892
- * @param params - Simulation parameters
2366
+ * @group Customization and simulation
2367
+ *
2368
+ * @remarks Data API simulation endpoint. Partner API key only.
2369
+ *
2370
+ * @param params - {@link SimulateBestPositionsParams}
1893
2371
  * @returns Chain-keyed map of simulated positions with calldata
1894
2372
  *
1895
2373
  * @example
@@ -1912,6 +2390,10 @@ declare class ZyfaiSDK {
1912
2390
  * Returns the pools that are currently configured for the authenticated user
1913
2391
  * for a given protocol and chain combination.
1914
2392
  *
2393
+ * @group Customization and simulation
2394
+ *
2395
+ * @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
2396
+ *
1915
2397
  * @param protocolId - The protocol UUID
1916
2398
  * @param chainId - The chain ID
1917
2399
  * @returns Currently selected pools and autoselect status
@@ -1957,10 +2439,13 @@ declare class ZyfaiSDK {
1957
2439
  */
1958
2440
  registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
1959
2441
  /**
1960
- * Deposit assets into the Zyfai Vault
1961
- * Currently only supports USDC on Base chain
2442
+ * Deposit assets into the Zyfai Vault (USDC on Base by default).
2443
+ *
2444
+ * @group Vault
2445
+ *
2446
+ * @remarks On-chain vault flow via connected wallet. Requires {@link ZyfaiSDK.connectAccount}.
1962
2447
  *
1963
- * @param amount - Amount to deposit (in human readable format, e.g., "100" for 100 USDC)
2448
+ * @param amount - Human-readable amount (e.g. `"100"` USDC)
1964
2449
  * @param asset - Asset to deposit (default: "USDC")
1965
2450
  * @returns Deposit transaction result
1966
2451
  *
@@ -2036,9 +2521,14 @@ declare class ZyfaiSDK {
2036
2521
  * Events: depeg, liquidity_trap, liquidity_restored, pool_status_change,
2037
2522
  * new_collateral_detected, liquidity_drop.
2038
2523
  *
2039
- * @param handlers - Callback per event type, plus onError
2040
- * @param filters - Optional protocol/pool filter sent to the server on subscribe
2041
- * @returns Cleanup function — call it to close the connection
2524
+ * @group Realtime events
2525
+ *
2526
+ * @remarks Connects to defi-api WebSocket (`WS_ENDPOINT`). Auto-reconnects every 3s until
2527
+ * the returned cleanup function is called.
2528
+ *
2529
+ * @param handlers - {@link ZyfaiEventHandlers}
2530
+ * @param filters - Optional {@link ZyfaiEventFilters} sent on subscribe
2531
+ * @returns Cleanup function — call it to close the connection and stop reconnecting
2042
2532
  *
2043
2533
  * @example
2044
2534
  * ```typescript
@@ -2088,8 +2578,13 @@ interface BankrProviderConfig {
2088
2578
  * const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY });
2089
2579
  *
2090
2580
  * const address = await sdk.connectAccount(provider);
2091
- * await sdk.deploySafe(address, 8453, 'conservative', true);
2581
+ * const sent = await sdk.sendDeposit(address, 8453, "10000000", "USDC", "conservative");
2582
+ * await sdk.waitForDepositCredit(sent.registration.id, 8453);
2092
2583
  * ```
2584
+ *
2585
+ * @remarks
2586
+ * The provider implements EIP-1193 methods used by the SDK (`eth_requestAccounts`,
2587
+ * `eth_chainId`, `personal_sign`, `eth_sendTransaction`, etc.).
2093
2588
  */
2094
2589
  declare function createBankrProvider(config: BankrProviderConfig): {
2095
2590
  /**
@@ -2124,6 +2619,7 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
2124
2619
  * examples, internal tooling).
2125
2620
  */
2126
2621
 
2622
+ /** Backend stack selector for URL helper functions. */
2127
2623
  type BackendEnvironment = "production" | "staging" | "local";
2128
2624
  /** Execution API (zyfai-api) origin — no `/api/v1` suffix. */
2129
2625
  declare const EXECUTION_API_BASE_URLS: {
@@ -2156,8 +2652,16 @@ declare const STAGING_WS_URL: "wss://staging-defiapi.zyf.ai/ws/events";
2156
2652
  declare const LOCAL_EXECUTION_API_BASE_URL: "http://localhost:3000";
2157
2653
  declare const LOCAL_DATA_API_BASE_URL: "http://localhost:3000";
2158
2654
  declare const LOCAL_WS_URL: "ws://localhost:3000/ws/events";
2655
+ /**
2656
+ * Execution API origin for an environment (no `/api/v1` suffix).
2657
+ *
2658
+ * @remarks The default {@link ZyfaiSDK} instance always uses production unless
2659
+ * `@internal` test overrides are set on {@link SDKConfig}.
2660
+ */
2159
2661
  declare function getExecutionApiBaseUrl(environment?: BackendEnvironment): string;
2662
+ /** Data API origin for an environment (no `/api/v2` suffix). */
2160
2663
  declare function getDataApiBaseUrl(environment?: BackendEnvironment): string;
2664
+ /** Defi-api WebSocket URL (includes `/ws/events`). */
2161
2665
  declare function getWsUrl(environment?: BackendEnvironment): string;
2162
2666
 
2163
2667
  declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
@@ -2206,4 +2710,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
2206
2710
  */
2207
2711
  declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
2208
2712
 
2209
- export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
2713
+ export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AgentMandate, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UpsertAgentMandateRequest, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };