@zyfai/sdk 0.2.42 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -13
- package/dist/index.d.mts +114 -22
- package/dist/index.d.ts +114 -22
- package/dist/index.js +277 -82
- package/dist/index.mjs +269 -82
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,25 @@ This method:
|
|
|
100
100
|
|
|
101
101
|
## Core Features
|
|
102
102
|
|
|
103
|
+
> **Predeployed (pool) wallets.** Wallets provisioned by ZyFi's predeployment
|
|
104
|
+
> service are already deployed, already have the agent session enabled, and are
|
|
105
|
+
> backend-owned until the user's first deposit rotates ownership to them. The SDK
|
|
106
|
+
> detects these automatically from the sign-in response (`predeployed: true`) and
|
|
107
|
+
> adjusts, with no extra flags from the integrator:
|
|
108
|
+
>
|
|
109
|
+
> - `deploySafe()` returns the assigned wallet without sending a deploy tx.
|
|
110
|
+
> - `createSessionKey()` returns `{ alreadyActive: true }` without prompting a
|
|
111
|
+
> signature — the pool enabled the session at deploy time.
|
|
112
|
+
> - The address is always the backend-assigned one; it is **never** derived with
|
|
113
|
+
> `getDeterministicSafeAddress`.
|
|
114
|
+
>
|
|
115
|
+
> Net effect: onboarding a predeployed wallet takes a **single signature — the
|
|
116
|
+
> USDC deposit** (no wallet-deploy or session-key signatures).
|
|
117
|
+
>
|
|
118
|
+
> The pool's ERC-7579 module addresses are exported as reference constants
|
|
119
|
+
> (`POOL_MODULE_ADDRESSES`, `INTENT_SMART_SESSIONS`, `PROXY_EXECUTOR`, …) for
|
|
120
|
+
> parity/validation only — the SDK does not install them.
|
|
121
|
+
|
|
103
122
|
### 1. Deploy Safe Smart Wallet
|
|
104
123
|
|
|
105
124
|
Deploy a Safe smart wallet:
|
|
@@ -276,6 +295,8 @@ Get the Smart Wallet (Safe) address for a user.
|
|
|
276
295
|
|
|
277
296
|
##### `deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy): Promise<DeploySafeResponse>`
|
|
278
297
|
|
|
298
|
+
> **Deprecated** for partner integrations. Prefer `depositFunds()` — predeployed Safes and session keys are handled on first deposit. This method remains available for legacy flows and emits a console warning when called.
|
|
299
|
+
|
|
279
300
|
Deploy a Safe smart wallet for a user. **Deployment is handled by the backend API**, which manages all RPC calls and bundler interactions. This avoids rate limiting issues.
|
|
280
301
|
|
|
281
302
|
**Parameters:**
|
|
@@ -301,12 +322,7 @@ Deploy a Safe smart wallet for a user. **Deployment is handled by the backend AP
|
|
|
301
322
|
|
|
302
323
|
- User must be authenticated (automatically done via `connectAccount()`)
|
|
303
324
|
- Backend handles all RPC calls, avoiding rate limiting
|
|
304
|
-
-
|
|
305
|
-
- Fetches protocols compatible with the strategy (`aggressive` includes both `safe` and `degen` protocols)
|
|
306
|
-
- Drops any protocol that has no pool available for the asset/chain (via `/customization/pools`)
|
|
307
|
-
- **Merges** the new `chainId` with the user's existing chains (never overwrites — safe to call again on a new chain)
|
|
308
|
-
- Persists via `updateUserProfile` into `assetTypeSettings.[usdc|eth]`
|
|
309
|
-
- No need to call `updateUserProfile` manually after `deploySafe` — the SDK handles it
|
|
325
|
+
- Protocol / asset patching is **not** done in `deploySafe` — it runs once on the account's **first** `depositFunds` call (see Deposit Funds below)
|
|
310
326
|
|
|
311
327
|
##### `addWalletToSdk(walletAddress: string): Promise<AddWalletToSdkResponse>`
|
|
312
328
|
|
|
@@ -331,7 +347,9 @@ Add a wallet address to the SDK API key's allowedWallets list. This endpoint req
|
|
|
331
347
|
|
|
332
348
|
Session keys enable delegated transaction execution without exposing the main private key.
|
|
333
349
|
|
|
334
|
-
#### Simple Usage (
|
|
350
|
+
#### Simple Usage (Legacy — deprecated)
|
|
351
|
+
|
|
352
|
+
> **Deprecated** for partner integrations. Prefer `depositFunds()` — predeployed wallets already have the agent session enabled. This method remains available for legacy flows and emits a console warning when called.
|
|
335
353
|
|
|
336
354
|
The SDK automatically fetches optimal session configuration from Zyfai API:
|
|
337
355
|
|
|
@@ -361,8 +379,9 @@ console.log("User ID:", result.userId);
|
|
|
361
379
|
|
|
362
380
|
- User must be authenticated (automatically done via `connectAccount()`)
|
|
363
381
|
- The SDK proactively checks if the user already has an active session key and returns early without requiring any signature if one exists
|
|
364
|
-
- The user record must have `smartWallet` and `chainId` set (
|
|
365
|
-
- Protocol selection is **not** touched by `createSessionKey` — it's set
|
|
382
|
+
- The user record must have `smartWallet` and `chainId` set (predeployed assignment / first deposit)
|
|
383
|
+
- Protocol selection is **not** touched by `createSessionKey` — it's set on the first `depositFunds` call
|
|
384
|
+
- **Deprecated**: prefer `depositFunds()` for partner onboarding; `createSessionKey` remains for legacy flows
|
|
366
385
|
- When `alreadyActive` is `true`, `sessionKeyAddress` and `signature` are not available in the response
|
|
367
386
|
|
|
368
387
|
### 4. Deposit Funds
|
|
@@ -370,13 +389,14 @@ console.log("User ID:", result.userId);
|
|
|
370
389
|
Transfer tokens to your Safe smart wallet. Token address is automatically selected based on chain and the requested asset (defaults to USDC):
|
|
371
390
|
|
|
372
391
|
- **Ethereum Mainnet (1), Base (8453), Arbitrum (42161)**: USDC (default) or WETH
|
|
392
|
+
- **Ethereum Mainnet (1), Base (8453)**: EURC (6 decimals; not available on Arbitrum)
|
|
373
393
|
|
|
374
394
|
**Minimum portfolio balance (enforced on Safe balance + deposit amount):**
|
|
375
395
|
|
|
376
396
|
- Ethereum Mainnet (1) / USDC: 5 USDC (test threshold — will be raised before production)
|
|
377
397
|
- All other (chain, asset) pairs: no minimum enforced
|
|
378
398
|
|
|
379
|
-
Only deposits on Mainnet in USDC that would leave the Safe below 5 USDC are rejected. Deposits on Base or Arbitrum, or in WETH, have no minimum today.
|
|
399
|
+
Only deposits on Mainnet in USDC that would leave the Safe below 5 USDC are rejected. Deposits on Base or Arbitrum, or in WETH/EURC, have no minimum today.
|
|
380
400
|
|
|
381
401
|
```typescript
|
|
382
402
|
// Deposit 10 USDC (6 decimals) to Safe on Base — no minimum on Base
|
|
@@ -395,9 +415,10 @@ if (result.success) {
|
|
|
395
415
|
**Note:**
|
|
396
416
|
|
|
397
417
|
- Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
|
|
398
|
-
- Token address is automatically selected based on chain (USDC by default; pass `asset: "WETH"`
|
|
418
|
+
- Token address is automatically selected based on chain (USDC by default; pass `asset: "WETH"` or `asset: "EURC"` — EURC on Mainnet/Base only)
|
|
399
419
|
- On Ethereum Mainnet, the total Safe balance in USDC must be at least 5 USDC after the deposit (test threshold); smaller top-ups are allowed if the Safe already holds enough USDC to meet the minimum
|
|
400
420
|
- The SDK automatically authenticates via SIWE before logging the deposit with Zyfai's API, so no extra steps are required on your end once the transfer confirms
|
|
421
|
+
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, and EURC** across all supported chains (EURC on Mainnet/Base only → `assetTypeSettings.[usdc|eth|eurc]`). Later deposits skip this.
|
|
401
422
|
|
|
402
423
|
#### Log External Deposit (For Sponsored Transactions)
|
|
403
424
|
|
|
@@ -567,8 +588,8 @@ console.log("Active protocols:", userDetails.user.protocols.length); // Should b
|
|
|
567
588
|
|
|
568
589
|
**Note**:
|
|
569
590
|
- User must be authenticated (automatically done via `connectAccount()`)
|
|
570
|
-
-
|
|
571
|
-
- To resume operations, call `updateUserProfile()` with the desired protocols
|
|
591
|
+
- Clears protocols for USDC, WETH, and EURC
|
|
592
|
+
- To resume operations, call `resumeAgent()` or `updateUserProfile()` with the desired protocols
|
|
572
593
|
|
|
573
594
|
#### Splitting Management
|
|
574
595
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, PublicClient } from 'viem';
|
|
1
|
+
import { Chain, PublicClient, Address as Address$1 } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Zyfai SDK Types
|
|
@@ -6,6 +6,8 @@ import { Chain, PublicClient } from 'viem';
|
|
|
6
6
|
type Address = `0x${string}`;
|
|
7
7
|
type Hex = `0x${string}`;
|
|
8
8
|
type Strategy = "conservative" | "aggressive";
|
|
9
|
+
/** Public asset symbols supported by the SDK */
|
|
10
|
+
type SupportedAsset = "USDC" | "WETH" | "EURC";
|
|
9
11
|
interface RpcUrlsConfig {
|
|
10
12
|
1?: string;
|
|
11
13
|
8453?: string;
|
|
@@ -34,7 +36,7 @@ interface UpdateUserProfileRequest {
|
|
|
34
36
|
crosschainStrategy?: boolean;
|
|
35
37
|
splitting?: boolean;
|
|
36
38
|
minSplits?: number;
|
|
37
|
-
asset?:
|
|
39
|
+
asset?: SupportedAsset;
|
|
38
40
|
}
|
|
39
41
|
interface UpdateUserProfileResponse {
|
|
40
42
|
success: boolean;
|
|
@@ -52,7 +54,7 @@ interface UpdateUserProfileResponse {
|
|
|
52
54
|
splitting?: boolean;
|
|
53
55
|
minSplits?: number;
|
|
54
56
|
customization?: Record<string, any>;
|
|
55
|
-
asset?:
|
|
57
|
+
asset?: SupportedAsset;
|
|
56
58
|
}
|
|
57
59
|
/** @internal */
|
|
58
60
|
interface AddSessionKeyResponse {
|
|
@@ -83,6 +85,13 @@ interface SessionKeyResponse {
|
|
|
83
85
|
interface SmartWalletResponse {
|
|
84
86
|
address: Address;
|
|
85
87
|
isDeployed: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* True when userAddress is an OwnableValidator owner of the Safe on-chain.
|
|
90
|
+
* For predeployed (pool) wallets this becomes true only after the first
|
|
91
|
+
* deposit rotates ownership from the backend to the user. Always false when
|
|
92
|
+
* the Safe is not deployed.
|
|
93
|
+
*/
|
|
94
|
+
isOwner: boolean;
|
|
86
95
|
}
|
|
87
96
|
interface Protocol {
|
|
88
97
|
id: string;
|
|
@@ -693,10 +702,17 @@ declare class ZyfaiSDK {
|
|
|
693
702
|
private walletClient;
|
|
694
703
|
private authenticatedUserId;
|
|
695
704
|
private hasActiveSessionKey;
|
|
705
|
+
private isPredeployed;
|
|
706
|
+
private connectedSmartWallet;
|
|
696
707
|
private currentProvider;
|
|
697
708
|
private currentChainId;
|
|
698
709
|
private rpcUrls?;
|
|
699
710
|
private referralSource?;
|
|
711
|
+
/**
|
|
712
|
+
* Warn that a legacy method is deprecated in favor of depositFunds.
|
|
713
|
+
* Predeployed wallets no longer require deploySafe / createSessionKey.
|
|
714
|
+
*/
|
|
715
|
+
private warnDeprecatedOnboardingMethod;
|
|
700
716
|
constructor(config: SDKConfig | string);
|
|
701
717
|
/**
|
|
702
718
|
* Authenticate user with SIWE (Sign-In with Ethereum) & JWT token
|
|
@@ -874,18 +890,41 @@ declare class ZyfaiSDK {
|
|
|
874
890
|
* @private
|
|
875
891
|
*/
|
|
876
892
|
private getWalletClient;
|
|
893
|
+
/**
|
|
894
|
+
* True when userAddress is the currently connected/authenticated wallet.
|
|
895
|
+
* @private
|
|
896
|
+
*/
|
|
897
|
+
private isConnectedUser;
|
|
898
|
+
/**
|
|
899
|
+
* Resolve the Safe smart wallet address for a user on a chain.
|
|
900
|
+
*
|
|
901
|
+
* Predeployed (pool) wallets are provisioned and owned by the backend at
|
|
902
|
+
* deploy time, so their address CANNOT be derived from the user's EOA with
|
|
903
|
+
* getDeterministicSafeAddress (CREATE2 from the EOA yields the wrong address).
|
|
904
|
+
* For the connected predeployed user we always use the backend-assigned
|
|
905
|
+
* address. Legacy wallets keep the API-first, deterministic-fallback behavior.
|
|
906
|
+
* @private
|
|
907
|
+
*/
|
|
908
|
+
private getSafeAddressFor;
|
|
877
909
|
/**
|
|
878
910
|
* Get smart wallet address for a user
|
|
879
|
-
* Returns the
|
|
911
|
+
* Returns the Safe address for an EOA (deterministic for legacy wallets,
|
|
912
|
+
* backend-assigned for predeployed pool wallets).
|
|
880
913
|
*
|
|
881
914
|
* @param userAddress - User's EOA address
|
|
882
915
|
* @param chainId - Target chain ID
|
|
883
|
-
* @returns Smart wallet
|
|
916
|
+
* @returns Smart wallet address, deployment status, and whether userAddress
|
|
917
|
+
* is an on-chain OwnableValidator owner (false for reserved predeployed
|
|
918
|
+
* wallets until the first deposit rotates ownership)
|
|
884
919
|
*/
|
|
885
920
|
getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
|
|
886
921
|
/**
|
|
887
922
|
* Deploy Safe Smart Wallet for a user
|
|
888
923
|
*
|
|
924
|
+
* @deprecated Prefer `depositFunds()`. Predeployed Safes and session keys are
|
|
925
|
+
* managed automatically on first deposit. This method remains available for
|
|
926
|
+
* legacy flows.
|
|
927
|
+
*
|
|
889
928
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
890
929
|
* @param chainId - Target chain ID
|
|
891
930
|
* @param strategy - Optional strategy selection: "conservative" (default) or "aggressive"
|
|
@@ -894,14 +933,11 @@ declare class ZyfaiSDK {
|
|
|
894
933
|
*
|
|
895
934
|
* @example
|
|
896
935
|
* ```typescript
|
|
897
|
-
* //
|
|
898
|
-
* await sdk.
|
|
899
|
-
*
|
|
900
|
-
* // Deploy with aggressive strategy
|
|
901
|
-
* await sdk.deploySafe(userAddress, 8453, "aggressive");
|
|
936
|
+
* // Preferred: depositFunds handles predeployed wallet onboarding
|
|
937
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
902
938
|
*
|
|
903
|
-
* //
|
|
904
|
-
* await sdk.deploySafe(userAddress, 8453
|
|
939
|
+
* // Legacy: deploy with default conservative strategy
|
|
940
|
+
* await sdk.deploySafe(userAddress, 8453);
|
|
905
941
|
* ```
|
|
906
942
|
*/
|
|
907
943
|
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy, createSessionKey?: boolean): Promise<DeploySafeResponse>;
|
|
@@ -909,15 +945,21 @@ declare class ZyfaiSDK {
|
|
|
909
945
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
910
946
|
* This is the simplified method that automatically fetches session configuration
|
|
911
947
|
*
|
|
948
|
+
* @deprecated Prefer `depositFunds()`. Predeployed wallets already have the
|
|
949
|
+
* agent session enabled; session activation is handled after first deposit.
|
|
950
|
+
* This method remains available for legacy flows.
|
|
951
|
+
*
|
|
912
952
|
* @param userAddress - User's EOA or Safe address
|
|
913
953
|
* @param chainId - Target chain ID
|
|
914
954
|
* @returns Session key response with signature and nonces
|
|
915
955
|
*
|
|
916
956
|
* @example
|
|
917
957
|
* ```typescript
|
|
918
|
-
* //
|
|
958
|
+
* // Preferred: depositFunds handles session onboarding for predeployed wallets
|
|
959
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
960
|
+
*
|
|
961
|
+
* // Legacy:
|
|
919
962
|
* const result = await sdk.createSessionKey(userAddress, 8453);
|
|
920
|
-
* console.log("Session created:", result.signature);
|
|
921
963
|
* ```
|
|
922
964
|
*/
|
|
923
965
|
createSessionKey(userAddress: string, chainId: SupportedChainId): Promise<SessionKeyResponse>;
|
|
@@ -927,16 +969,17 @@ declare class ZyfaiSDK {
|
|
|
927
969
|
*/
|
|
928
970
|
private signSessionKey;
|
|
929
971
|
/**
|
|
930
|
-
* Patch the user's protocol selection
|
|
931
|
-
*
|
|
932
|
-
*
|
|
972
|
+
* Patch the user's protocol selection on USDC, WETH, and EURC across all
|
|
973
|
+
* supported chains (EURC limited to Mainnet/Base). Mirrors the front-end
|
|
974
|
+
* customization flow:
|
|
975
|
+
* 1. Merge existing chains from `getUserDetails` with the target chains
|
|
933
976
|
* (never overwrite already-configured chains).
|
|
934
977
|
* 2. Filter protocols by strategy, chain and asset support.
|
|
935
978
|
* 3. Drop protocols that don't have any pools available for the
|
|
936
979
|
* asset/chain/strategy combo.
|
|
937
980
|
* 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
|
|
938
981
|
*
|
|
939
|
-
* Called from `
|
|
982
|
+
* Called once from `depositFunds` on the account's first deposit.
|
|
940
983
|
*
|
|
941
984
|
* @internal
|
|
942
985
|
*/
|
|
@@ -969,6 +1012,10 @@ declare class ZyfaiSDK {
|
|
|
969
1012
|
* Token is automatically selected based on chain (USDC by default):
|
|
970
1013
|
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
|
|
971
1014
|
*
|
|
1015
|
+
* On the account's first deposit (USDC profile has no chains yet), patches
|
|
1016
|
+
* protocol selection for USDC, WETH, and EURC across all supported chains
|
|
1017
|
+
* (EURC on Mainnet/Base only) before the transfer and log_deposit.
|
|
1018
|
+
*
|
|
972
1019
|
* Minimum portfolio balance enforced (Safe balance + deposit amount),
|
|
973
1020
|
* configured per-chain in `MIN_PORTFOLIO_BALANCE`:
|
|
974
1021
|
* - Ethereum Mainnet (1): 5 USDC (test threshold)
|
|
@@ -980,7 +1027,8 @@ declare class ZyfaiSDK {
|
|
|
980
1027
|
* @param userAddress - User's address (owner of the Safe)
|
|
981
1028
|
* @param chainId - Target chain ID
|
|
982
1029
|
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
983
|
-
* @param asset - Optional asset symbol ("USDC" or "
|
|
1030
|
+
* @param asset - Optional asset symbol ("USDC", "WETH", or "EURC"). Defaults to "USDC".
|
|
1031
|
+
* EURC is supported on Ethereum Mainnet and Base only.
|
|
984
1032
|
* @returns Deposit response with transaction hash
|
|
985
1033
|
*
|
|
986
1034
|
* @example
|
|
@@ -1122,7 +1170,7 @@ declare class ZyfaiSDK {
|
|
|
1122
1170
|
* console.log("Chains:", user.user.chains);
|
|
1123
1171
|
* ```
|
|
1124
1172
|
*/
|
|
1125
|
-
getUserDetails(asset?:
|
|
1173
|
+
getUserDetails(asset?: SupportedAsset): Promise<UpdateUserProfileResponse>;
|
|
1126
1174
|
/**
|
|
1127
1175
|
* Get total value locked (TVL) across all Zyfai accounts
|
|
1128
1176
|
*
|
|
@@ -1163,7 +1211,7 @@ declare class ZyfaiSDK {
|
|
|
1163
1211
|
* console.log("Total Volume:", volume.volumeInUSD);
|
|
1164
1212
|
* ```
|
|
1165
1213
|
*/
|
|
1166
|
-
getVolume(assetType?: "usdc" | "eth"): Promise<VolumeResponse>;
|
|
1214
|
+
getVolume(assetType?: "usdc" | "eth" | "eurc"): Promise<VolumeResponse>;
|
|
1167
1215
|
/**
|
|
1168
1216
|
* Get active wallets for a specific chain
|
|
1169
1217
|
*
|
|
@@ -1713,4 +1761,48 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
|
1713
1761
|
|
|
1714
1762
|
declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
1715
1763
|
|
|
1716
|
-
|
|
1764
|
+
/**
|
|
1765
|
+
* Predeployment (pool) module addresses — reference constants.
|
|
1766
|
+
*
|
|
1767
|
+
* These mirror the ERC-7579 module set that ZyFi's predeployment service installs
|
|
1768
|
+
* on a pool smart account. Source of truth: the predeployment repo
|
|
1769
|
+
* `src/infrastructure/chain/modules.ts` — keep these in sync with it.
|
|
1770
|
+
*
|
|
1771
|
+
* FOR PARITY / VALIDATION AND DOCUMENTATION ONLY. The SDK does not install
|
|
1772
|
+
* modules on-chain: legacy wallets are deployed by the backend (SAFE_DEPLOY) and
|
|
1773
|
+
* predeployed wallets are provisioned by the pool. Nothing in the SDK reads these
|
|
1774
|
+
* to build, sign, or derive transactions. They are hardcoded (not recomputed via
|
|
1775
|
+
* `@rhinestone/module-sdk`) on purpose — see SMART_SESSIONS_VALIDATOR below.
|
|
1776
|
+
*/
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* Classic SmartSessions validator (installed empty, session enabled later).
|
|
1780
|
+
*
|
|
1781
|
+
* IMPORTANT: this address is VERSION-DEPENDENT. The pool runs
|
|
1782
|
+
* `@rhinestone/module-sdk` 0.4.0, which yields this address; the SDK's local
|
|
1783
|
+
* 0.2.11 yields the older `0x00000000002B0eCfbD0496EE71e01257dA0E37DE`. We pin
|
|
1784
|
+
* the pool's value so the two never silently diverge.
|
|
1785
|
+
*/
|
|
1786
|
+
declare const SMART_SESSIONS_VALIDATOR: Address$1;
|
|
1787
|
+
/** ERC-7739 compatibility fallback (selector 0x84b0196e). */
|
|
1788
|
+
declare const SMART_SESSIONS_FALLBACK: Address$1;
|
|
1789
|
+
/** Intent (SmartSession v1) executor. */
|
|
1790
|
+
declare const INTENT_EXECUTOR: Address$1;
|
|
1791
|
+
/** Proxy executor used by the intent / omni-account session profile. */
|
|
1792
|
+
declare const PROXY_EXECUTOR: Address$1;
|
|
1793
|
+
/** Intent smart-sessions validator — the emissary the pool enables via setConfig. */
|
|
1794
|
+
declare const INTENT_SMART_SESSIONS: Address$1;
|
|
1795
|
+
/** OwnableValidator — the module whose owner set is rotated to the user on deposit. */
|
|
1796
|
+
declare const OWNABLE_VALIDATOR: Address$1;
|
|
1797
|
+
/** Safe 7579 adapter — matches the pool; already used by the SDK for deploys. */
|
|
1798
|
+
declare const SAFE_7579_ADDRESS: Address$1;
|
|
1799
|
+
/** ERC-7579 launchpad — matches the pool; already used by the SDK for deploys. */
|
|
1800
|
+
declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
1801
|
+
/**
|
|
1802
|
+
* The full module set a predeployed (pool) wallet carries, for validation.
|
|
1803
|
+
* Mirrors predeployment `DEFAULT_MODULES` plus OwnableValidator (the latter is
|
|
1804
|
+
* installed by the Rhinestone SDK at deploy, not in the provisioning batch).
|
|
1805
|
+
*/
|
|
1806
|
+
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1807
|
+
|
|
1808
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, 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, 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, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, PublicClient } from 'viem';
|
|
1
|
+
import { Chain, PublicClient, Address as Address$1 } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Zyfai SDK Types
|
|
@@ -6,6 +6,8 @@ import { Chain, PublicClient } from 'viem';
|
|
|
6
6
|
type Address = `0x${string}`;
|
|
7
7
|
type Hex = `0x${string}`;
|
|
8
8
|
type Strategy = "conservative" | "aggressive";
|
|
9
|
+
/** Public asset symbols supported by the SDK */
|
|
10
|
+
type SupportedAsset = "USDC" | "WETH" | "EURC";
|
|
9
11
|
interface RpcUrlsConfig {
|
|
10
12
|
1?: string;
|
|
11
13
|
8453?: string;
|
|
@@ -34,7 +36,7 @@ interface UpdateUserProfileRequest {
|
|
|
34
36
|
crosschainStrategy?: boolean;
|
|
35
37
|
splitting?: boolean;
|
|
36
38
|
minSplits?: number;
|
|
37
|
-
asset?:
|
|
39
|
+
asset?: SupportedAsset;
|
|
38
40
|
}
|
|
39
41
|
interface UpdateUserProfileResponse {
|
|
40
42
|
success: boolean;
|
|
@@ -52,7 +54,7 @@ interface UpdateUserProfileResponse {
|
|
|
52
54
|
splitting?: boolean;
|
|
53
55
|
minSplits?: number;
|
|
54
56
|
customization?: Record<string, any>;
|
|
55
|
-
asset?:
|
|
57
|
+
asset?: SupportedAsset;
|
|
56
58
|
}
|
|
57
59
|
/** @internal */
|
|
58
60
|
interface AddSessionKeyResponse {
|
|
@@ -83,6 +85,13 @@ interface SessionKeyResponse {
|
|
|
83
85
|
interface SmartWalletResponse {
|
|
84
86
|
address: Address;
|
|
85
87
|
isDeployed: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* True when userAddress is an OwnableValidator owner of the Safe on-chain.
|
|
90
|
+
* For predeployed (pool) wallets this becomes true only after the first
|
|
91
|
+
* deposit rotates ownership from the backend to the user. Always false when
|
|
92
|
+
* the Safe is not deployed.
|
|
93
|
+
*/
|
|
94
|
+
isOwner: boolean;
|
|
86
95
|
}
|
|
87
96
|
interface Protocol {
|
|
88
97
|
id: string;
|
|
@@ -693,10 +702,17 @@ declare class ZyfaiSDK {
|
|
|
693
702
|
private walletClient;
|
|
694
703
|
private authenticatedUserId;
|
|
695
704
|
private hasActiveSessionKey;
|
|
705
|
+
private isPredeployed;
|
|
706
|
+
private connectedSmartWallet;
|
|
696
707
|
private currentProvider;
|
|
697
708
|
private currentChainId;
|
|
698
709
|
private rpcUrls?;
|
|
699
710
|
private referralSource?;
|
|
711
|
+
/**
|
|
712
|
+
* Warn that a legacy method is deprecated in favor of depositFunds.
|
|
713
|
+
* Predeployed wallets no longer require deploySafe / createSessionKey.
|
|
714
|
+
*/
|
|
715
|
+
private warnDeprecatedOnboardingMethod;
|
|
700
716
|
constructor(config: SDKConfig | string);
|
|
701
717
|
/**
|
|
702
718
|
* Authenticate user with SIWE (Sign-In with Ethereum) & JWT token
|
|
@@ -874,18 +890,41 @@ declare class ZyfaiSDK {
|
|
|
874
890
|
* @private
|
|
875
891
|
*/
|
|
876
892
|
private getWalletClient;
|
|
893
|
+
/**
|
|
894
|
+
* True when userAddress is the currently connected/authenticated wallet.
|
|
895
|
+
* @private
|
|
896
|
+
*/
|
|
897
|
+
private isConnectedUser;
|
|
898
|
+
/**
|
|
899
|
+
* Resolve the Safe smart wallet address for a user on a chain.
|
|
900
|
+
*
|
|
901
|
+
* Predeployed (pool) wallets are provisioned and owned by the backend at
|
|
902
|
+
* deploy time, so their address CANNOT be derived from the user's EOA with
|
|
903
|
+
* getDeterministicSafeAddress (CREATE2 from the EOA yields the wrong address).
|
|
904
|
+
* For the connected predeployed user we always use the backend-assigned
|
|
905
|
+
* address. Legacy wallets keep the API-first, deterministic-fallback behavior.
|
|
906
|
+
* @private
|
|
907
|
+
*/
|
|
908
|
+
private getSafeAddressFor;
|
|
877
909
|
/**
|
|
878
910
|
* Get smart wallet address for a user
|
|
879
|
-
* Returns the
|
|
911
|
+
* Returns the Safe address for an EOA (deterministic for legacy wallets,
|
|
912
|
+
* backend-assigned for predeployed pool wallets).
|
|
880
913
|
*
|
|
881
914
|
* @param userAddress - User's EOA address
|
|
882
915
|
* @param chainId - Target chain ID
|
|
883
|
-
* @returns Smart wallet
|
|
916
|
+
* @returns Smart wallet address, deployment status, and whether userAddress
|
|
917
|
+
* is an on-chain OwnableValidator owner (false for reserved predeployed
|
|
918
|
+
* wallets until the first deposit rotates ownership)
|
|
884
919
|
*/
|
|
885
920
|
getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
|
|
886
921
|
/**
|
|
887
922
|
* Deploy Safe Smart Wallet for a user
|
|
888
923
|
*
|
|
924
|
+
* @deprecated Prefer `depositFunds()`. Predeployed Safes and session keys are
|
|
925
|
+
* managed automatically on first deposit. This method remains available for
|
|
926
|
+
* legacy flows.
|
|
927
|
+
*
|
|
889
928
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
890
929
|
* @param chainId - Target chain ID
|
|
891
930
|
* @param strategy - Optional strategy selection: "conservative" (default) or "aggressive"
|
|
@@ -894,14 +933,11 @@ declare class ZyfaiSDK {
|
|
|
894
933
|
*
|
|
895
934
|
* @example
|
|
896
935
|
* ```typescript
|
|
897
|
-
* //
|
|
898
|
-
* await sdk.
|
|
899
|
-
*
|
|
900
|
-
* // Deploy with aggressive strategy
|
|
901
|
-
* await sdk.deploySafe(userAddress, 8453, "aggressive");
|
|
936
|
+
* // Preferred: depositFunds handles predeployed wallet onboarding
|
|
937
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
902
938
|
*
|
|
903
|
-
* //
|
|
904
|
-
* await sdk.deploySafe(userAddress, 8453
|
|
939
|
+
* // Legacy: deploy with default conservative strategy
|
|
940
|
+
* await sdk.deploySafe(userAddress, 8453);
|
|
905
941
|
* ```
|
|
906
942
|
*/
|
|
907
943
|
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy, createSessionKey?: boolean): Promise<DeploySafeResponse>;
|
|
@@ -909,15 +945,21 @@ declare class ZyfaiSDK {
|
|
|
909
945
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
910
946
|
* This is the simplified method that automatically fetches session configuration
|
|
911
947
|
*
|
|
948
|
+
* @deprecated Prefer `depositFunds()`. Predeployed wallets already have the
|
|
949
|
+
* agent session enabled; session activation is handled after first deposit.
|
|
950
|
+
* This method remains available for legacy flows.
|
|
951
|
+
*
|
|
912
952
|
* @param userAddress - User's EOA or Safe address
|
|
913
953
|
* @param chainId - Target chain ID
|
|
914
954
|
* @returns Session key response with signature and nonces
|
|
915
955
|
*
|
|
916
956
|
* @example
|
|
917
957
|
* ```typescript
|
|
918
|
-
* //
|
|
958
|
+
* // Preferred: depositFunds handles session onboarding for predeployed wallets
|
|
959
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
960
|
+
*
|
|
961
|
+
* // Legacy:
|
|
919
962
|
* const result = await sdk.createSessionKey(userAddress, 8453);
|
|
920
|
-
* console.log("Session created:", result.signature);
|
|
921
963
|
* ```
|
|
922
964
|
*/
|
|
923
965
|
createSessionKey(userAddress: string, chainId: SupportedChainId): Promise<SessionKeyResponse>;
|
|
@@ -927,16 +969,17 @@ declare class ZyfaiSDK {
|
|
|
927
969
|
*/
|
|
928
970
|
private signSessionKey;
|
|
929
971
|
/**
|
|
930
|
-
* Patch the user's protocol selection
|
|
931
|
-
*
|
|
932
|
-
*
|
|
972
|
+
* Patch the user's protocol selection on USDC, WETH, and EURC across all
|
|
973
|
+
* supported chains (EURC limited to Mainnet/Base). Mirrors the front-end
|
|
974
|
+
* customization flow:
|
|
975
|
+
* 1. Merge existing chains from `getUserDetails` with the target chains
|
|
933
976
|
* (never overwrite already-configured chains).
|
|
934
977
|
* 2. Filter protocols by strategy, chain and asset support.
|
|
935
978
|
* 3. Drop protocols that don't have any pools available for the
|
|
936
979
|
* asset/chain/strategy combo.
|
|
937
980
|
* 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
|
|
938
981
|
*
|
|
939
|
-
* Called from `
|
|
982
|
+
* Called once from `depositFunds` on the account's first deposit.
|
|
940
983
|
*
|
|
941
984
|
* @internal
|
|
942
985
|
*/
|
|
@@ -969,6 +1012,10 @@ declare class ZyfaiSDK {
|
|
|
969
1012
|
* Token is automatically selected based on chain (USDC by default):
|
|
970
1013
|
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
|
|
971
1014
|
*
|
|
1015
|
+
* On the account's first deposit (USDC profile has no chains yet), patches
|
|
1016
|
+
* protocol selection for USDC, WETH, and EURC across all supported chains
|
|
1017
|
+
* (EURC on Mainnet/Base only) before the transfer and log_deposit.
|
|
1018
|
+
*
|
|
972
1019
|
* Minimum portfolio balance enforced (Safe balance + deposit amount),
|
|
973
1020
|
* configured per-chain in `MIN_PORTFOLIO_BALANCE`:
|
|
974
1021
|
* - Ethereum Mainnet (1): 5 USDC (test threshold)
|
|
@@ -980,7 +1027,8 @@ declare class ZyfaiSDK {
|
|
|
980
1027
|
* @param userAddress - User's address (owner of the Safe)
|
|
981
1028
|
* @param chainId - Target chain ID
|
|
982
1029
|
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
983
|
-
* @param asset - Optional asset symbol ("USDC" or "
|
|
1030
|
+
* @param asset - Optional asset symbol ("USDC", "WETH", or "EURC"). Defaults to "USDC".
|
|
1031
|
+
* EURC is supported on Ethereum Mainnet and Base only.
|
|
984
1032
|
* @returns Deposit response with transaction hash
|
|
985
1033
|
*
|
|
986
1034
|
* @example
|
|
@@ -1122,7 +1170,7 @@ declare class ZyfaiSDK {
|
|
|
1122
1170
|
* console.log("Chains:", user.user.chains);
|
|
1123
1171
|
* ```
|
|
1124
1172
|
*/
|
|
1125
|
-
getUserDetails(asset?:
|
|
1173
|
+
getUserDetails(asset?: SupportedAsset): Promise<UpdateUserProfileResponse>;
|
|
1126
1174
|
/**
|
|
1127
1175
|
* Get total value locked (TVL) across all Zyfai accounts
|
|
1128
1176
|
*
|
|
@@ -1163,7 +1211,7 @@ declare class ZyfaiSDK {
|
|
|
1163
1211
|
* console.log("Total Volume:", volume.volumeInUSD);
|
|
1164
1212
|
* ```
|
|
1165
1213
|
*/
|
|
1166
|
-
getVolume(assetType?: "usdc" | "eth"): Promise<VolumeResponse>;
|
|
1214
|
+
getVolume(assetType?: "usdc" | "eth" | "eurc"): Promise<VolumeResponse>;
|
|
1167
1215
|
/**
|
|
1168
1216
|
* Get active wallets for a specific chain
|
|
1169
1217
|
*
|
|
@@ -1713,4 +1761,48 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
|
1713
1761
|
|
|
1714
1762
|
declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
1715
1763
|
|
|
1716
|
-
|
|
1764
|
+
/**
|
|
1765
|
+
* Predeployment (pool) module addresses — reference constants.
|
|
1766
|
+
*
|
|
1767
|
+
* These mirror the ERC-7579 module set that ZyFi's predeployment service installs
|
|
1768
|
+
* on a pool smart account. Source of truth: the predeployment repo
|
|
1769
|
+
* `src/infrastructure/chain/modules.ts` — keep these in sync with it.
|
|
1770
|
+
*
|
|
1771
|
+
* FOR PARITY / VALIDATION AND DOCUMENTATION ONLY. The SDK does not install
|
|
1772
|
+
* modules on-chain: legacy wallets are deployed by the backend (SAFE_DEPLOY) and
|
|
1773
|
+
* predeployed wallets are provisioned by the pool. Nothing in the SDK reads these
|
|
1774
|
+
* to build, sign, or derive transactions. They are hardcoded (not recomputed via
|
|
1775
|
+
* `@rhinestone/module-sdk`) on purpose — see SMART_SESSIONS_VALIDATOR below.
|
|
1776
|
+
*/
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* Classic SmartSessions validator (installed empty, session enabled later).
|
|
1780
|
+
*
|
|
1781
|
+
* IMPORTANT: this address is VERSION-DEPENDENT. The pool runs
|
|
1782
|
+
* `@rhinestone/module-sdk` 0.4.0, which yields this address; the SDK's local
|
|
1783
|
+
* 0.2.11 yields the older `0x00000000002B0eCfbD0496EE71e01257dA0E37DE`. We pin
|
|
1784
|
+
* the pool's value so the two never silently diverge.
|
|
1785
|
+
*/
|
|
1786
|
+
declare const SMART_SESSIONS_VALIDATOR: Address$1;
|
|
1787
|
+
/** ERC-7739 compatibility fallback (selector 0x84b0196e). */
|
|
1788
|
+
declare const SMART_SESSIONS_FALLBACK: Address$1;
|
|
1789
|
+
/** Intent (SmartSession v1) executor. */
|
|
1790
|
+
declare const INTENT_EXECUTOR: Address$1;
|
|
1791
|
+
/** Proxy executor used by the intent / omni-account session profile. */
|
|
1792
|
+
declare const PROXY_EXECUTOR: Address$1;
|
|
1793
|
+
/** Intent smart-sessions validator — the emissary the pool enables via setConfig. */
|
|
1794
|
+
declare const INTENT_SMART_SESSIONS: Address$1;
|
|
1795
|
+
/** OwnableValidator — the module whose owner set is rotated to the user on deposit. */
|
|
1796
|
+
declare const OWNABLE_VALIDATOR: Address$1;
|
|
1797
|
+
/** Safe 7579 adapter — matches the pool; already used by the SDK for deploys. */
|
|
1798
|
+
declare const SAFE_7579_ADDRESS: Address$1;
|
|
1799
|
+
/** ERC-7579 launchpad — matches the pool; already used by the SDK for deploys. */
|
|
1800
|
+
declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
1801
|
+
/**
|
|
1802
|
+
* The full module set a predeployed (pool) wallet carries, for validation.
|
|
1803
|
+
* Mirrors predeployment `DEFAULT_MODULES` plus OwnableValidator (the latter is
|
|
1804
|
+
* installed by the Rhinestone SDK at deploy, not in the provisioning batch).
|
|
1805
|
+
*/
|
|
1806
|
+
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1807
|
+
|
|
1808
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, 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, 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, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|