@zyfai/sdk 0.2.48 → 0.2.49

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 CHANGED
@@ -322,7 +322,7 @@ Deploy a Safe smart wallet for a user. **Deployment is handled by the backend AP
322
322
 
323
323
  - User must be authenticated (automatically done via `connectAccount()`)
324
324
  - Backend handles all RPC calls, avoiding rate limiting
325
- - Protocol / asset patching is **not** done in `deploySafe` — it runs once on the account's **first** `depositFunds` call (see Deposit Funds below)
325
+ - Protocol / asset patching runs in `deploySafe` (all paths). `depositFunds` still patches on the account's **first** deposit if USDC `chains` are empty (see Deposit Funds below)
326
326
 
327
327
  ##### `addWalletToSdk(walletAddress: string): Promise<AddWalletToSdkResponse>`
328
328
 
@@ -380,7 +380,7 @@ console.log("User ID:", result.userId);
380
380
  - User must be authenticated (automatically done via `connectAccount()`)
381
381
  - The SDK proactively checks if the user already has an active session key and returns early without requiring any signature if one exists
382
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
383
+ - Protocol selection is **not** touched by `createSessionKey` — it's set by `deploySafe` and on the first `depositFunds` call if USDC `chains` are still empty
384
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
 
package/dist/index.d.mts CHANGED
@@ -849,8 +849,8 @@ declare class ZyfaiSDK {
849
849
  */
850
850
  updateMinSplits(minSplits: number): Promise<UpdateUserProfileResponse>;
851
851
  /**
852
- * Initialize user after Safe deployment
853
- * This method is automatically called after deploySafe to initialize user state
852
+ * Initialize earnings tracking for a smart wallet on the Data API.
853
+ * Called from `deploySafe` after a fresh deploy and for predeployed wallets.
854
854
  *
855
855
  * @param smartWallet - Safe smart wallet address
856
856
  * @param chainId - Target chain ID
@@ -992,7 +992,8 @@ declare class ZyfaiSDK {
992
992
  * asset/chain/strategy combo.
993
993
  * 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
994
994
  *
995
- * Called once from `depositFunds` on the account's first deposit.
995
+ * Called from `deploySafe` after every path, and from `depositFunds` on
996
+ * the account's first deposit (when USDC chains are still empty).
996
997
  *
997
998
  * @internal
998
999
  */
package/dist/index.d.ts CHANGED
@@ -849,8 +849,8 @@ declare class ZyfaiSDK {
849
849
  */
850
850
  updateMinSplits(minSplits: number): Promise<UpdateUserProfileResponse>;
851
851
  /**
852
- * Initialize user after Safe deployment
853
- * This method is automatically called after deploySafe to initialize user state
852
+ * Initialize earnings tracking for a smart wallet on the Data API.
853
+ * Called from `deploySafe` after a fresh deploy and for predeployed wallets.
854
854
  *
855
855
  * @param smartWallet - Safe smart wallet address
856
856
  * @param chainId - Target chain ID
@@ -992,7 +992,8 @@ declare class ZyfaiSDK {
992
992
  * asset/chain/strategy combo.
993
993
  * 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
994
994
  *
995
- * Called once from `depositFunds` on the account's first deposit.
995
+ * Called from `deploySafe` after every path, and from `depositFunds` on
996
+ * the account's first deposit (when USDC chains are still empty).
996
997
  *
997
998
  * @internal
998
999
  */
package/dist/index.js CHANGED
@@ -1706,8 +1706,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1706
1706
  }
1707
1707
  }
1708
1708
  /**
1709
- * Initialize user after Safe deployment
1710
- * This method is automatically called after deploySafe to initialize user state
1709
+ * Initialize earnings tracking for a smart wallet on the Data API.
1710
+ * Called from `deploySafe` after a fresh deploy and for predeployed wallets.
1711
1711
  *
1712
1712
  * @param smartWallet - Safe smart wallet address
1713
1713
  * @param chainId - Target chain ID
@@ -2033,6 +2033,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2033
2033
  userAddress,
2034
2034
  chainId
2035
2035
  );
2036
+ try {
2037
+ await this.initializeUser(predeployedAddress, chainId);
2038
+ } catch (initError) {
2039
+ console.warn(
2040
+ "Failed to initialize user after Safe deployment:",
2041
+ initError.message
2042
+ );
2043
+ }
2036
2044
  await this.updateUserProtocols(strategy);
2037
2045
  return {
2038
2046
  success: true,
@@ -2094,6 +2102,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2094
2102
  initError.message
2095
2103
  );
2096
2104
  }
2105
+ await this.updateUserProtocols(strategy);
2097
2106
  let sessionKeyCreated = false;
2098
2107
  if (createSessionKey) {
2099
2108
  try {
@@ -2283,7 +2292,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2283
2292
  * asset/chain/strategy combo.
2284
2293
  * 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
2285
2294
  *
2286
- * Called once from `depositFunds` on the account's first deposit.
2295
+ * Called from `deploySafe` after every path, and from `depositFunds` on
2296
+ * the account's first deposit (when USDC chains are still empty).
2287
2297
  *
2288
2298
  * @internal
2289
2299
  */
package/dist/index.mjs CHANGED
@@ -1674,8 +1674,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1674
1674
  }
1675
1675
  }
1676
1676
  /**
1677
- * Initialize user after Safe deployment
1678
- * This method is automatically called after deploySafe to initialize user state
1677
+ * Initialize earnings tracking for a smart wallet on the Data API.
1678
+ * Called from `deploySafe` after a fresh deploy and for predeployed wallets.
1679
1679
  *
1680
1680
  * @param smartWallet - Safe smart wallet address
1681
1681
  * @param chainId - Target chain ID
@@ -2001,6 +2001,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2001
2001
  userAddress,
2002
2002
  chainId
2003
2003
  );
2004
+ try {
2005
+ await this.initializeUser(predeployedAddress, chainId);
2006
+ } catch (initError) {
2007
+ console.warn(
2008
+ "Failed to initialize user after Safe deployment:",
2009
+ initError.message
2010
+ );
2011
+ }
2004
2012
  await this.updateUserProtocols(strategy);
2005
2013
  return {
2006
2014
  success: true,
@@ -2062,6 +2070,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2062
2070
  initError.message
2063
2071
  );
2064
2072
  }
2073
+ await this.updateUserProtocols(strategy);
2065
2074
  let sessionKeyCreated = false;
2066
2075
  if (createSessionKey) {
2067
2076
  try {
@@ -2251,7 +2260,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2251
2260
  * asset/chain/strategy combo.
2252
2261
  * 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
2253
2262
  *
2254
- * Called once from `depositFunds` on the account's first deposit.
2263
+ * Called from `deploySafe` after every path, and from `depositFunds` on
2264
+ * the account's first deposit (when USDC chains are still empty).
2255
2265
  *
2256
2266
  * @internal
2257
2267
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.48",
3
+ "version": "0.2.49",
4
4
  "description": "TypeScript SDK for Zyfai Yield Optimization Engine - Deploy Safe smart wallets, manage session keys, and interact with DeFi protocols",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",