@zyfai/sdk 0.2.43 → 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 +15 -13
- package/dist/index.d.mts +51 -21
- package/dist/index.d.ts +51 -21
- package/dist/index.js +187 -60
- package/dist/index.mjs +188 -60
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -295,6 +295,8 @@ Get the Smart Wallet (Safe) address for a user.
|
|
|
295
295
|
|
|
296
296
|
##### `deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy): Promise<DeploySafeResponse>`
|
|
297
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
|
+
|
|
298
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.
|
|
299
301
|
|
|
300
302
|
**Parameters:**
|
|
@@ -320,12 +322,7 @@ Deploy a Safe smart wallet for a user. **Deployment is handled by the backend AP
|
|
|
320
322
|
|
|
321
323
|
- User must be authenticated (automatically done via `connectAccount()`)
|
|
322
324
|
- Backend handles all RPC calls, avoiding rate limiting
|
|
323
|
-
-
|
|
324
|
-
- Fetches protocols compatible with the strategy (`aggressive` includes both `safe` and `degen` protocols)
|
|
325
|
-
- Drops any protocol that has no pool available for the asset/chain (via `/customization/pools`)
|
|
326
|
-
- **Merges** the new `chainId` with the user's existing chains (never overwrites — safe to call again on a new chain)
|
|
327
|
-
- Persists via `updateUserProfile` into `assetTypeSettings.[usdc|eth]`
|
|
328
|
-
- 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)
|
|
329
326
|
|
|
330
327
|
##### `addWalletToSdk(walletAddress: string): Promise<AddWalletToSdkResponse>`
|
|
331
328
|
|
|
@@ -350,7 +347,9 @@ Add a wallet address to the SDK API key's allowedWallets list. This endpoint req
|
|
|
350
347
|
|
|
351
348
|
Session keys enable delegated transaction execution without exposing the main private key.
|
|
352
349
|
|
|
353
|
-
#### 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.
|
|
354
353
|
|
|
355
354
|
The SDK automatically fetches optimal session configuration from Zyfai API:
|
|
356
355
|
|
|
@@ -380,8 +379,9 @@ console.log("User ID:", result.userId);
|
|
|
380
379
|
|
|
381
380
|
- User must be authenticated (automatically done via `connectAccount()`)
|
|
382
381
|
- The SDK proactively checks if the user already has an active session key and returns early without requiring any signature if one exists
|
|
383
|
-
- The user record must have `smartWallet` and `chainId` set (
|
|
384
|
-
- 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
|
|
385
385
|
- When `alreadyActive` is `true`, `sessionKeyAddress` and `signature` are not available in the response
|
|
386
386
|
|
|
387
387
|
### 4. Deposit Funds
|
|
@@ -389,13 +389,14 @@ console.log("User ID:", result.userId);
|
|
|
389
389
|
Transfer tokens to your Safe smart wallet. Token address is automatically selected based on chain and the requested asset (defaults to USDC):
|
|
390
390
|
|
|
391
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)
|
|
392
393
|
|
|
393
394
|
**Minimum portfolio balance (enforced on Safe balance + deposit amount):**
|
|
394
395
|
|
|
395
396
|
- Ethereum Mainnet (1) / USDC: 5 USDC (test threshold — will be raised before production)
|
|
396
397
|
- All other (chain, asset) pairs: no minimum enforced
|
|
397
398
|
|
|
398
|
-
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.
|
|
399
400
|
|
|
400
401
|
```typescript
|
|
401
402
|
// Deposit 10 USDC (6 decimals) to Safe on Base — no minimum on Base
|
|
@@ -414,9 +415,10 @@ if (result.success) {
|
|
|
414
415
|
**Note:**
|
|
415
416
|
|
|
416
417
|
- Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
|
|
417
|
-
- 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)
|
|
418
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
|
|
419
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.
|
|
420
422
|
|
|
421
423
|
#### Log External Deposit (For Sponsored Transactions)
|
|
422
424
|
|
|
@@ -586,8 +588,8 @@ console.log("Active protocols:", userDetails.user.protocols.length); // Should b
|
|
|
586
588
|
|
|
587
589
|
**Note**:
|
|
588
590
|
- User must be authenticated (automatically done via `connectAccount()`)
|
|
589
|
-
-
|
|
590
|
-
- 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
|
|
591
593
|
|
|
592
594
|
#### Splitting Management
|
|
593
595
|
|
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,8 @@ import { Chain, PublicClient, Address as Address$1 } 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;
|
|
@@ -699,6 +708,11 @@ declare class ZyfaiSDK {
|
|
|
699
708
|
private currentChainId;
|
|
700
709
|
private rpcUrls?;
|
|
701
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;
|
|
702
716
|
constructor(config: SDKConfig | string);
|
|
703
717
|
/**
|
|
704
718
|
* Authenticate user with SIWE (Sign-In with Ethereum) & JWT token
|
|
@@ -894,16 +908,23 @@ declare class ZyfaiSDK {
|
|
|
894
908
|
private getSafeAddressFor;
|
|
895
909
|
/**
|
|
896
910
|
* Get smart wallet address for a user
|
|
897
|
-
* Returns the
|
|
911
|
+
* Returns the Safe address for an EOA (deterministic for legacy wallets,
|
|
912
|
+
* backend-assigned for predeployed pool wallets).
|
|
898
913
|
*
|
|
899
914
|
* @param userAddress - User's EOA address
|
|
900
915
|
* @param chainId - Target chain ID
|
|
901
|
-
* @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)
|
|
902
919
|
*/
|
|
903
920
|
getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
|
|
904
921
|
/**
|
|
905
922
|
* Deploy Safe Smart Wallet for a user
|
|
906
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
|
+
*
|
|
907
928
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
908
929
|
* @param chainId - Target chain ID
|
|
909
930
|
* @param strategy - Optional strategy selection: "conservative" (default) or "aggressive"
|
|
@@ -912,14 +933,11 @@ declare class ZyfaiSDK {
|
|
|
912
933
|
*
|
|
913
934
|
* @example
|
|
914
935
|
* ```typescript
|
|
915
|
-
* //
|
|
916
|
-
* await sdk.
|
|
936
|
+
* // Preferred: depositFunds handles predeployed wallet onboarding
|
|
937
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
917
938
|
*
|
|
918
|
-
* //
|
|
919
|
-
* await sdk.deploySafe(userAddress, 8453
|
|
920
|
-
*
|
|
921
|
-
* // Deploy and automatically create session key
|
|
922
|
-
* await sdk.deploySafe(userAddress, 8453, "conservative", true);
|
|
939
|
+
* // Legacy: deploy with default conservative strategy
|
|
940
|
+
* await sdk.deploySafe(userAddress, 8453);
|
|
923
941
|
* ```
|
|
924
942
|
*/
|
|
925
943
|
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy, createSessionKey?: boolean): Promise<DeploySafeResponse>;
|
|
@@ -927,15 +945,21 @@ declare class ZyfaiSDK {
|
|
|
927
945
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
928
946
|
* This is the simplified method that automatically fetches session configuration
|
|
929
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
|
+
*
|
|
930
952
|
* @param userAddress - User's EOA or Safe address
|
|
931
953
|
* @param chainId - Target chain ID
|
|
932
954
|
* @returns Session key response with signature and nonces
|
|
933
955
|
*
|
|
934
956
|
* @example
|
|
935
957
|
* ```typescript
|
|
936
|
-
* //
|
|
958
|
+
* // Preferred: depositFunds handles session onboarding for predeployed wallets
|
|
959
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
960
|
+
*
|
|
961
|
+
* // Legacy:
|
|
937
962
|
* const result = await sdk.createSessionKey(userAddress, 8453);
|
|
938
|
-
* console.log("Session created:", result.signature);
|
|
939
963
|
* ```
|
|
940
964
|
*/
|
|
941
965
|
createSessionKey(userAddress: string, chainId: SupportedChainId): Promise<SessionKeyResponse>;
|
|
@@ -945,16 +969,17 @@ declare class ZyfaiSDK {
|
|
|
945
969
|
*/
|
|
946
970
|
private signSessionKey;
|
|
947
971
|
/**
|
|
948
|
-
* Patch the user's protocol selection
|
|
949
|
-
*
|
|
950
|
-
*
|
|
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
|
|
951
976
|
* (never overwrite already-configured chains).
|
|
952
977
|
* 2. Filter protocols by strategy, chain and asset support.
|
|
953
978
|
* 3. Drop protocols that don't have any pools available for the
|
|
954
979
|
* asset/chain/strategy combo.
|
|
955
980
|
* 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
|
|
956
981
|
*
|
|
957
|
-
* Called from `
|
|
982
|
+
* Called once from `depositFunds` on the account's first deposit.
|
|
958
983
|
*
|
|
959
984
|
* @internal
|
|
960
985
|
*/
|
|
@@ -987,6 +1012,10 @@ declare class ZyfaiSDK {
|
|
|
987
1012
|
* Token is automatically selected based on chain (USDC by default):
|
|
988
1013
|
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
|
|
989
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
|
+
*
|
|
990
1019
|
* Minimum portfolio balance enforced (Safe balance + deposit amount),
|
|
991
1020
|
* configured per-chain in `MIN_PORTFOLIO_BALANCE`:
|
|
992
1021
|
* - Ethereum Mainnet (1): 5 USDC (test threshold)
|
|
@@ -998,7 +1027,8 @@ declare class ZyfaiSDK {
|
|
|
998
1027
|
* @param userAddress - User's address (owner of the Safe)
|
|
999
1028
|
* @param chainId - Target chain ID
|
|
1000
1029
|
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
1001
|
-
* @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.
|
|
1002
1032
|
* @returns Deposit response with transaction hash
|
|
1003
1033
|
*
|
|
1004
1034
|
* @example
|
|
@@ -1140,7 +1170,7 @@ declare class ZyfaiSDK {
|
|
|
1140
1170
|
* console.log("Chains:", user.user.chains);
|
|
1141
1171
|
* ```
|
|
1142
1172
|
*/
|
|
1143
|
-
getUserDetails(asset?:
|
|
1173
|
+
getUserDetails(asset?: SupportedAsset): Promise<UpdateUserProfileResponse>;
|
|
1144
1174
|
/**
|
|
1145
1175
|
* Get total value locked (TVL) across all Zyfai accounts
|
|
1146
1176
|
*
|
|
@@ -1181,7 +1211,7 @@ declare class ZyfaiSDK {
|
|
|
1181
1211
|
* console.log("Total Volume:", volume.volumeInUSD);
|
|
1182
1212
|
* ```
|
|
1183
1213
|
*/
|
|
1184
|
-
getVolume(assetType?: "usdc" | "eth"): Promise<VolumeResponse>;
|
|
1214
|
+
getVolume(assetType?: "usdc" | "eth" | "eurc"): Promise<VolumeResponse>;
|
|
1185
1215
|
/**
|
|
1186
1216
|
* Get active wallets for a specific chain
|
|
1187
1217
|
*
|
|
@@ -1775,4 +1805,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
1775
1805
|
*/
|
|
1776
1806
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1777
1807
|
|
|
1778
|
-
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 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 };
|
|
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
|
@@ -6,6 +6,8 @@ import { Chain, PublicClient, Address as Address$1 } 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;
|
|
@@ -699,6 +708,11 @@ declare class ZyfaiSDK {
|
|
|
699
708
|
private currentChainId;
|
|
700
709
|
private rpcUrls?;
|
|
701
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;
|
|
702
716
|
constructor(config: SDKConfig | string);
|
|
703
717
|
/**
|
|
704
718
|
* Authenticate user with SIWE (Sign-In with Ethereum) & JWT token
|
|
@@ -894,16 +908,23 @@ declare class ZyfaiSDK {
|
|
|
894
908
|
private getSafeAddressFor;
|
|
895
909
|
/**
|
|
896
910
|
* Get smart wallet address for a user
|
|
897
|
-
* Returns the
|
|
911
|
+
* Returns the Safe address for an EOA (deterministic for legacy wallets,
|
|
912
|
+
* backend-assigned for predeployed pool wallets).
|
|
898
913
|
*
|
|
899
914
|
* @param userAddress - User's EOA address
|
|
900
915
|
* @param chainId - Target chain ID
|
|
901
|
-
* @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)
|
|
902
919
|
*/
|
|
903
920
|
getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
|
|
904
921
|
/**
|
|
905
922
|
* Deploy Safe Smart Wallet for a user
|
|
906
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
|
+
*
|
|
907
928
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
908
929
|
* @param chainId - Target chain ID
|
|
909
930
|
* @param strategy - Optional strategy selection: "conservative" (default) or "aggressive"
|
|
@@ -912,14 +933,11 @@ declare class ZyfaiSDK {
|
|
|
912
933
|
*
|
|
913
934
|
* @example
|
|
914
935
|
* ```typescript
|
|
915
|
-
* //
|
|
916
|
-
* await sdk.
|
|
936
|
+
* // Preferred: depositFunds handles predeployed wallet onboarding
|
|
937
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
917
938
|
*
|
|
918
|
-
* //
|
|
919
|
-
* await sdk.deploySafe(userAddress, 8453
|
|
920
|
-
*
|
|
921
|
-
* // Deploy and automatically create session key
|
|
922
|
-
* await sdk.deploySafe(userAddress, 8453, "conservative", true);
|
|
939
|
+
* // Legacy: deploy with default conservative strategy
|
|
940
|
+
* await sdk.deploySafe(userAddress, 8453);
|
|
923
941
|
* ```
|
|
924
942
|
*/
|
|
925
943
|
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy, createSessionKey?: boolean): Promise<DeploySafeResponse>;
|
|
@@ -927,15 +945,21 @@ declare class ZyfaiSDK {
|
|
|
927
945
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
928
946
|
* This is the simplified method that automatically fetches session configuration
|
|
929
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
|
+
*
|
|
930
952
|
* @param userAddress - User's EOA or Safe address
|
|
931
953
|
* @param chainId - Target chain ID
|
|
932
954
|
* @returns Session key response with signature and nonces
|
|
933
955
|
*
|
|
934
956
|
* @example
|
|
935
957
|
* ```typescript
|
|
936
|
-
* //
|
|
958
|
+
* // Preferred: depositFunds handles session onboarding for predeployed wallets
|
|
959
|
+
* await sdk.depositFunds(userAddress, 8453, amount, "USDC");
|
|
960
|
+
*
|
|
961
|
+
* // Legacy:
|
|
937
962
|
* const result = await sdk.createSessionKey(userAddress, 8453);
|
|
938
|
-
* console.log("Session created:", result.signature);
|
|
939
963
|
* ```
|
|
940
964
|
*/
|
|
941
965
|
createSessionKey(userAddress: string, chainId: SupportedChainId): Promise<SessionKeyResponse>;
|
|
@@ -945,16 +969,17 @@ declare class ZyfaiSDK {
|
|
|
945
969
|
*/
|
|
946
970
|
private signSessionKey;
|
|
947
971
|
/**
|
|
948
|
-
* Patch the user's protocol selection
|
|
949
|
-
*
|
|
950
|
-
*
|
|
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
|
|
951
976
|
* (never overwrite already-configured chains).
|
|
952
977
|
* 2. Filter protocols by strategy, chain and asset support.
|
|
953
978
|
* 3. Drop protocols that don't have any pools available for the
|
|
954
979
|
* asset/chain/strategy combo.
|
|
955
980
|
* 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
|
|
956
981
|
*
|
|
957
|
-
* Called from `
|
|
982
|
+
* Called once from `depositFunds` on the account's first deposit.
|
|
958
983
|
*
|
|
959
984
|
* @internal
|
|
960
985
|
*/
|
|
@@ -987,6 +1012,10 @@ declare class ZyfaiSDK {
|
|
|
987
1012
|
* Token is automatically selected based on chain (USDC by default):
|
|
988
1013
|
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
|
|
989
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
|
+
*
|
|
990
1019
|
* Minimum portfolio balance enforced (Safe balance + deposit amount),
|
|
991
1020
|
* configured per-chain in `MIN_PORTFOLIO_BALANCE`:
|
|
992
1021
|
* - Ethereum Mainnet (1): 5 USDC (test threshold)
|
|
@@ -998,7 +1027,8 @@ declare class ZyfaiSDK {
|
|
|
998
1027
|
* @param userAddress - User's address (owner of the Safe)
|
|
999
1028
|
* @param chainId - Target chain ID
|
|
1000
1029
|
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
1001
|
-
* @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.
|
|
1002
1032
|
* @returns Deposit response with transaction hash
|
|
1003
1033
|
*
|
|
1004
1034
|
* @example
|
|
@@ -1140,7 +1170,7 @@ declare class ZyfaiSDK {
|
|
|
1140
1170
|
* console.log("Chains:", user.user.chains);
|
|
1141
1171
|
* ```
|
|
1142
1172
|
*/
|
|
1143
|
-
getUserDetails(asset?:
|
|
1173
|
+
getUserDetails(asset?: SupportedAsset): Promise<UpdateUserProfileResponse>;
|
|
1144
1174
|
/**
|
|
1145
1175
|
* Get total value locked (TVL) across all Zyfai accounts
|
|
1146
1176
|
*
|
|
@@ -1181,7 +1211,7 @@ declare class ZyfaiSDK {
|
|
|
1181
1211
|
* console.log("Total Volume:", volume.volumeInUSD);
|
|
1182
1212
|
* ```
|
|
1183
1213
|
*/
|
|
1184
|
-
getVolume(assetType?: "usdc" | "eth"): Promise<VolumeResponse>;
|
|
1214
|
+
getVolume(assetType?: "usdc" | "eth" | "eurc"): Promise<VolumeResponse>;
|
|
1185
1215
|
/**
|
|
1186
1216
|
* Get active wallets for a specific chain
|
|
1187
1217
|
*
|
|
@@ -1775,4 +1805,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
1775
1805
|
*/
|
|
1776
1806
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1777
1807
|
|
|
1778
|
-
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 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 };
|
|
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 };
|