@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/dist/index.mjs CHANGED
@@ -293,6 +293,15 @@ var HttpClient = class {
293
293
 
294
294
  // src/config/abis.ts
295
295
  import { parseAbi } from "viem";
296
+ var OWNABLE_VALIDATOR_ABI = [
297
+ {
298
+ name: "getOwners",
299
+ type: "function",
300
+ stateMutability: "view",
301
+ inputs: [{ name: "account", type: "address" }],
302
+ outputs: [{ name: "ownersArray", type: "address[]" }]
303
+ }
304
+ ];
296
305
  var ERC20_ABI = [
297
306
  {
298
307
  name: "transfer",
@@ -547,6 +556,25 @@ var ASSET_CONFIGS = {
547
556
  // Linea
548
557
  },
549
558
  enabled: true
559
+ },
560
+ EURC: {
561
+ symbol: "EURC",
562
+ assetType: "eurc",
563
+ displayName: "EURC",
564
+ icon: "/ai-dashboard/eurc-token.png",
565
+ decimals: 6,
566
+ tokenSymbols: ["EURC"],
567
+ tokenSymbolsByChainId: {
568
+ 1: "EURC",
569
+ 8453: "EURC"
570
+ },
571
+ addresses: {
572
+ 1: "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",
573
+ // Ethereum
574
+ 8453: "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42"
575
+ // Base
576
+ },
577
+ enabled: true
550
578
  }
551
579
  };
552
580
  var getDefaultTokenAddress = (chainId, asset) => {
@@ -594,6 +622,7 @@ var getSupportedChainIds = () => {
594
622
  // src/utils/safe-account.ts
595
623
  import {
596
624
  RHINESTONE_ATTESTER_ADDRESS,
625
+ OWNABLE_VALIDATOR_ADDRESS,
597
626
  getOwnableValidator,
598
627
  getAccount,
599
628
  getEnableSessionDetails,
@@ -609,8 +638,28 @@ import {
609
638
  import {
610
639
  entryPoint07Address
611
640
  } from "viem/account-abstraction";
641
+
642
+ // src/config/modules.ts
643
+ var SMART_SESSIONS_VALIDATOR = "0x00000000008bDABA73cD9815d79069c247Eb4bDA";
644
+ var SMART_SESSIONS_FALLBACK = "0x12cae64c42f362e7d5a847c2d33388373f629177";
645
+ var INTENT_EXECUTOR = "0x00000000005aD9ce1f5035FD62CA96CEf16AdAAF";
646
+ var PROXY_EXECUTOR = "0xF659d30D4EB88B06A909F20839D8959Bd77d8790";
647
+ var INTENT_SMART_SESSIONS = "0xad568b3f825a8d5ffc06dd3253526b64d810ae89";
648
+ var OWNABLE_VALIDATOR = "0x000000000013fdB5234E4E3162a810F54d9f7E98";
612
649
  var SAFE_7579_ADDRESS = "0x7579EE8307284F293B1927136486880611F20002";
613
650
  var ERC7579_LAUNCHPAD_ADDRESS = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
651
+ var POOL_MODULE_ADDRESSES = [
652
+ SMART_SESSIONS_VALIDATOR,
653
+ SMART_SESSIONS_FALLBACK,
654
+ INTENT_EXECUTOR,
655
+ PROXY_EXECUTOR,
656
+ INTENT_SMART_SESSIONS,
657
+ OWNABLE_VALIDATOR
658
+ ];
659
+
660
+ // src/utils/safe-account.ts
661
+ var SAFE_7579_ADDRESS2 = "0x7579EE8307284F293B1927136486880611F20002";
662
+ var ERC7579_LAUNCHPAD_ADDRESS2 = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
614
663
  var ACCOUNT_SALT = "zyfai";
615
664
  var getSafeAccount = async (config) => {
616
665
  const { safeOwnerAddress, publicClient } = config;
@@ -635,8 +684,8 @@ var getSafeAccount = async (config) => {
635
684
  address: entryPoint07Address,
636
685
  version: "0.7"
637
686
  },
638
- safe4337ModuleAddress: SAFE_7579_ADDRESS,
639
- erc7579LaunchpadAddress: ERC7579_LAUNCHPAD_ADDRESS,
687
+ safe4337ModuleAddress: SAFE_7579_ADDRESS2,
688
+ erc7579LaunchpadAddress: ERC7579_LAUNCHPAD_ADDRESS2,
640
689
  attesters: [RHINESTONE_ATTESTER_ADDRESS],
641
690
  attestersThreshold: 1,
642
691
  validators: [
@@ -668,6 +717,31 @@ var isSafeDeployed = async (address, publicClient) => {
668
717
  return false;
669
718
  }
670
719
  };
720
+ var isOwnableValidatorOwner = async (safeAddress, userAddress, publicClient) => {
721
+ const normalizedUser = getAddress(userAddress);
722
+ const normalizedSafe = getAddress(safeAddress);
723
+ const validatorAddresses = Array.from(
724
+ /* @__PURE__ */ new Set([
725
+ getAddress(OWNABLE_VALIDATOR),
726
+ getAddress(OWNABLE_VALIDATOR_ADDRESS)
727
+ ])
728
+ );
729
+ for (const validatorAddress of validatorAddresses) {
730
+ try {
731
+ const owners = await publicClient.readContract({
732
+ address: validatorAddress,
733
+ abi: OWNABLE_VALIDATOR_ABI,
734
+ functionName: "getOwners",
735
+ args: [normalizedSafe]
736
+ });
737
+ if (owners.some((owner) => getAddress(owner) === normalizedUser)) {
738
+ return true;
739
+ }
740
+ } catch {
741
+ }
742
+ }
743
+ return false;
744
+ };
671
745
  var getAccountType = async (address, publicClient) => {
672
746
  try {
673
747
  const code = await publicClient.getCode({ address });
@@ -710,10 +784,12 @@ var deploySafeAccount = async (config) => {
710
784
  "Wallet not connected. Please connect your wallet first."
711
785
  );
712
786
  }
787
+ console.log("strategy", strategy);
713
788
  const prepareResponse = await httpClient.post(
714
789
  `${ENDPOINTS.SAFE_DEPLOY}?chainId=${chainId}`,
715
790
  { strategy }
716
791
  );
792
+ console.log("prepareResponse", prepareResponse);
717
793
  if (!prepareResponse.userOpHashToSign) {
718
794
  throw new Error(
719
795
  "Backend did not return userOpHashToSign. Response: " + JSON.stringify(prepareResponse)
@@ -859,7 +935,12 @@ function convertAssetInternally(asset) {
859
935
  if (asset === "WETH") {
860
936
  return "eth";
861
937
  }
862
- throw new Error(`Invalid asset: ${asset}. Must be "USDC" or "WETH".`);
938
+ if (asset === "EURC") {
939
+ return "eurc";
940
+ }
941
+ throw new Error(
942
+ `Invalid asset: ${asset}. Must be "USDC", "WETH", or "EURC".`
943
+ );
863
944
  }
864
945
  function convertStrategiesToPublic(array) {
865
946
  return array.map((item) => convertStrategyToPublic(item));
@@ -952,6 +1033,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
952
1033
  this.rpcUrls = rpcUrls;
953
1034
  this.referralSource = referralSource;
954
1035
  }
1036
+ /**
1037
+ * Warn that a legacy method is deprecated in favor of depositFunds.
1038
+ * Predeployed wallets no longer require deploySafe / createSessionKey.
1039
+ */
1040
+ warnDeprecatedOnboardingMethod(methodName) {
1041
+ console.warn(
1042
+ `[ZyfaiSDK] ${methodName}() is deprecated for partner integrations. Prefer depositFunds() \u2014 predeployed Safes and session keys are handled automatically on first deposit.`
1043
+ );
1044
+ }
955
1045
  /**
956
1046
  * Authenticate user with SIWE (Sign-In with Ethereum) & JWT token
957
1047
  * This is required for accessing user-specific endpoints like session-keys/config
@@ -1014,6 +1104,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1014
1104
  }
1015
1105
  this.httpClient.setAuthToken(authToken);
1016
1106
  this.authenticatedUserId = loginResponse.userId || null;
1107
+ console.log("this.authenticatedUserId", loginResponse);
1017
1108
  this.hasActiveSessionKey = loginResponse.hasActiveSessionKey || false;
1018
1109
  this.isPredeployed = loginResponse.predeployed || false;
1019
1110
  this.connectedSmartWallet = loginResponse.smartWallet || null;
@@ -1105,10 +1196,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1105
1196
  asset: "USDC",
1106
1197
  protocols: []
1107
1198
  });
1108
- const response = await this.updateUserProfile({
1199
+ await this.updateUserProfile({
1109
1200
  asset: "WETH",
1110
1201
  protocols: []
1111
1202
  });
1203
+ const response = await this.updateUserProfile({
1204
+ asset: "EURC",
1205
+ protocols: []
1206
+ });
1112
1207
  return response;
1113
1208
  } catch (error) {
1114
1209
  throw new Error(`Failed to pause agent: ${error.message}`);
@@ -1136,16 +1231,19 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1136
1231
  try {
1137
1232
  const userDetailsUSDC = await this.getUserDetails("USDC");
1138
1233
  const userDetailsETH = await this.getUserDetails("WETH");
1234
+ const userDetailsEURC = await this.getUserDetails("EURC");
1139
1235
  const chains = userDetailsUSDC.chains && userDetailsUSDC.chains.length > 0 ? userDetailsUSDC.chains : [8453, 42161];
1236
+ const eurcChains = userDetailsEURC.chains && userDetailsEURC.chains.length > 0 ? userDetailsEURC.chains.filter((c) => c === 1 || c === 8453) : [1, 8453];
1140
1237
  const allProtocols = await this.httpClient.get(
1141
1238
  ENDPOINTS.PROTOCOLS()
1142
1239
  );
1143
1240
  const usdcStrategy = userDetailsUSDC.strategy || "safe_strategy";
1144
1241
  const ethStrategy = userDetailsETH.strategy || "safe_strategy";
1145
- const filterProtocolsByStrategy = (strategy) => {
1242
+ const eurcStrategy = userDetailsEURC.strategy || "safe_strategy";
1243
+ const filterProtocolsByStrategy = (strategy, selectedChains) => {
1146
1244
  return allProtocols.filter((protocol) => {
1147
1245
  const hasMatchingChain = protocol.chains.some(
1148
- (chain) => chains.includes(chain)
1246
+ (chain) => selectedChains.includes(chain)
1149
1247
  );
1150
1248
  if (!hasMatchingChain) {
1151
1249
  return false;
@@ -1156,17 +1254,21 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1156
1254
  return protocol.strategies?.includes("safe_strategy");
1157
1255
  }).map((protocol) => protocol.id);
1158
1256
  };
1159
- const usdcProtocols = filterProtocolsByStrategy(usdcStrategy);
1160
- const ethProtocols = filterProtocolsByStrategy(ethStrategy);
1257
+ const usdcProtocols = filterProtocolsByStrategy(usdcStrategy, chains);
1258
+ const ethProtocols = filterProtocolsByStrategy(ethStrategy, chains);
1259
+ const eurcProtocols = filterProtocolsByStrategy(eurcStrategy, eurcChains);
1161
1260
  await this.updateUserProfile({
1162
1261
  asset: "USDC",
1163
1262
  protocols: usdcProtocols
1164
1263
  });
1165
- const updatedUserDetailsETH = await this.updateUserProfile({
1264
+ await this.updateUserProfile({
1166
1265
  asset: "WETH",
1167
1266
  protocols: ethProtocols
1168
1267
  });
1169
- return updatedUserDetailsETH;
1268
+ return await this.updateUserProfile({
1269
+ asset: "EURC",
1270
+ protocols: eurcProtocols
1271
+ });
1170
1272
  } catch (error) {
1171
1273
  throw new Error(`Failed to resume agent: ${error.message}`);
1172
1274
  }
@@ -1522,11 +1624,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1522
1624
  }
1523
1625
  /**
1524
1626
  * Get smart wallet address for a user
1525
- * Returns the deterministic Safe address for an EOA, or the address itself if already a Safe
1627
+ * Returns the Safe address for an EOA (deterministic for legacy wallets,
1628
+ * backend-assigned for predeployed pool wallets).
1526
1629
  *
1527
1630
  * @param userAddress - User's EOA address
1528
1631
  * @param chainId - Target chain ID
1529
- * @returns Smart wallet information including address and deployment status
1632
+ * @returns Smart wallet address, deployment status, and whether userAddress
1633
+ * is an on-chain OwnableValidator owner (false for reserved predeployed
1634
+ * wallets until the first deposit rotates ownership)
1530
1635
  */
1531
1636
  async getSmartWalletAddress(userAddress, chainId) {
1532
1637
  if (!userAddress) {
@@ -1541,14 +1646,24 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1541
1646
  safeAddress,
1542
1647
  chainConfig.publicClient
1543
1648
  );
1649
+ const isOwner = isDeployed ? await isOwnableValidatorOwner(
1650
+ safeAddress,
1651
+ userAddress,
1652
+ chainConfig.publicClient
1653
+ ) : false;
1544
1654
  return {
1545
1655
  address: safeAddress,
1546
- isDeployed
1656
+ isDeployed,
1657
+ isOwner
1547
1658
  };
1548
1659
  }
1549
1660
  /**
1550
1661
  * Deploy Safe Smart Wallet for a user
1551
1662
  *
1663
+ * @deprecated Prefer `depositFunds()`. Predeployed Safes and session keys are
1664
+ * managed automatically on first deposit. This method remains available for
1665
+ * legacy flows.
1666
+ *
1552
1667
  * @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
1553
1668
  * @param chainId - Target chain ID
1554
1669
  * @param strategy - Optional strategy selection: "conservative" (default) or "aggressive"
@@ -1557,17 +1672,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1557
1672
  *
1558
1673
  * @example
1559
1674
  * ```typescript
1560
- * // Deploy with default conservative strategy
1561
- * await sdk.deploySafe(userAddress, 8453);
1675
+ * // Preferred: depositFunds handles predeployed wallet onboarding
1676
+ * await sdk.depositFunds(userAddress, 8453, amount, "USDC");
1562
1677
  *
1563
- * // Deploy with aggressive strategy
1564
- * await sdk.deploySafe(userAddress, 8453, "aggressive");
1565
- *
1566
- * // Deploy and automatically create session key
1567
- * await sdk.deploySafe(userAddress, 8453, "conservative", true);
1678
+ * // Legacy: deploy with default conservative strategy
1679
+ * await sdk.deploySafe(userAddress, 8453);
1568
1680
  * ```
1569
1681
  */
1570
1682
  async deploySafe(userAddress, chainId, strategy, createSessionKey) {
1683
+ this.warnDeprecatedOnboardingMethod("deploySafe");
1571
1684
  try {
1572
1685
  if (!userAddress) {
1573
1686
  throw new Error("User address is required");
@@ -1581,7 +1694,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1581
1694
  userAddress,
1582
1695
  chainId
1583
1696
  );
1584
- await this.updateUserProtocols(chainId, strategy);
1697
+ await this.updateUserProtocols(strategy);
1585
1698
  return {
1586
1699
  success: true,
1587
1700
  safeAddress: predeployedAddress,
@@ -1602,7 +1715,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1602
1715
  chainConfig.publicClient
1603
1716
  );
1604
1717
  if (alreadyDeployed) {
1605
- await this.updateUserProtocols(chainId, strategy);
1718
+ await this.updateUserProtocols(strategy);
1606
1719
  let sessionKeyCreated2 = false;
1607
1720
  if (createSessionKey) {
1608
1721
  try {
@@ -1642,7 +1755,6 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1642
1755
  initError.message
1643
1756
  );
1644
1757
  }
1645
- await this.updateUserProtocols(chainId, strategy);
1646
1758
  let sessionKeyCreated = false;
1647
1759
  if (createSessionKey) {
1648
1760
  try {
@@ -1664,25 +1776,34 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1664
1776
  };
1665
1777
  } catch (error) {
1666
1778
  console.error("Safe deployment failed:", error);
1667
- throw new Error(`Safe deployment failed: ${error.message}`);
1779
+ throw new Error(
1780
+ `Safe deployment failed: ${error.message}. deploySafe() is deprecated \u2014 prefer depositFunds() for predeployed wallet onboarding.`
1781
+ );
1668
1782
  }
1669
1783
  }
1670
1784
  /**
1671
1785
  * Create session key with auto-fetched configuration from Zyfai API
1672
1786
  * This is the simplified method that automatically fetches session configuration
1673
1787
  *
1788
+ * @deprecated Prefer `depositFunds()`. Predeployed wallets already have the
1789
+ * agent session enabled; session activation is handled after first deposit.
1790
+ * This method remains available for legacy flows.
1791
+ *
1674
1792
  * @param userAddress - User's EOA or Safe address
1675
1793
  * @param chainId - Target chain ID
1676
1794
  * @returns Session key response with signature and nonces
1677
1795
  *
1678
1796
  * @example
1679
1797
  * ```typescript
1680
- * // Simple usage - no need to configure sessions manually
1798
+ * // Preferred: depositFunds handles session onboarding for predeployed wallets
1799
+ * await sdk.depositFunds(userAddress, 8453, amount, "USDC");
1800
+ *
1801
+ * // Legacy:
1681
1802
  * const result = await sdk.createSessionKey(userAddress, 8453);
1682
- * console.log("Session created:", result.signature);
1683
1803
  * ```
1684
1804
  */
1685
1805
  async createSessionKey(userAddress, chainId) {
1806
+ this.warnDeprecatedOnboardingMethod("createSessionKey");
1686
1807
  try {
1687
1808
  await this.authenticateUser();
1688
1809
  if (!this.authenticatedUserId) {
@@ -1756,7 +1877,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1756
1877
  };
1757
1878
  } catch (error) {
1758
1879
  throw new Error(
1759
- `Failed to create session key: ${error.message}`
1880
+ `Failed to create session key: ${error.message}. createSessionKey() is deprecated \u2014 prefer depositFunds() for predeployed wallet onboarding.`
1760
1881
  );
1761
1882
  }
1762
1883
  }
@@ -1813,29 +1934,33 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1813
1934
  }
1814
1935
  }
1815
1936
  /**
1816
- * Patch the user's protocol selection for the given chain + strategy on
1817
- * both USDC and WETH. Mirrors the front-end customization flow:
1818
- * 1. Merge existing chains from `getUserDetails` with the new `chainId`
1937
+ * Patch the user's protocol selection on USDC, WETH, and EURC across all
1938
+ * supported chains (EURC limited to Mainnet/Base). Mirrors the front-end
1939
+ * customization flow:
1940
+ * 1. Merge existing chains from `getUserDetails` with the target chains
1819
1941
  * (never overwrite already-configured chains).
1820
1942
  * 2. Filter protocols by strategy, chain and asset support.
1821
1943
  * 3. Drop protocols that don't have any pools available for the
1822
1944
  * asset/chain/strategy combo.
1823
1945
  * 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
1824
1946
  *
1825
- * Called from `deploySafe` — SDK consumers don't handle protocols manually.
1947
+ * Called once from `depositFunds` on the account's first deposit.
1826
1948
  *
1827
1949
  * @internal
1828
1950
  */
1829
- async updateUserProtocols(chainId, strategy) {
1951
+ async updateUserProtocols(strategy) {
1830
1952
  try {
1831
1953
  const allProtocols = await this.httpClient.get(
1832
1954
  ENDPOINTS.PROTOCOLS()
1833
1955
  );
1834
- for (const asset of ["USDC", "WETH"]) {
1956
+ const allChains = [1, 8453, 42161];
1957
+ const assets = ["USDC", "WETH", "EURC"];
1958
+ for (const asset of assets) {
1835
1959
  try {
1960
+ const chainsForAsset = asset === "EURC" ? [1, 8453] : allChains;
1836
1961
  await this.updateUserProtocolsForAsset(
1837
1962
  asset,
1838
- chainId,
1963
+ chainsForAsset,
1839
1964
  strategy,
1840
1965
  allProtocols
1841
1966
  );
@@ -1855,11 +1980,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1855
1980
  * Compute and persist the protocol selection for a single asset.
1856
1981
  * @internal
1857
1982
  */
1858
- async updateUserProtocolsForAsset(asset, chainId, strategy, allProtocols) {
1983
+ async updateUserProtocolsForAsset(asset, chains, strategy, allProtocols) {
1859
1984
  const userDetails = await this.getUserDetails(asset);
1860
1985
  const existingChains = userDetails.chains ?? [];
1861
1986
  const effectiveChains = Array.from(
1862
- /* @__PURE__ */ new Set([...existingChains, chainId])
1987
+ /* @__PURE__ */ new Set([...existingChains, ...chains])
1863
1988
  );
1864
1989
  const publicStrategy = strategy ?? (isValidPublicStrategy(userDetails.strategy ?? "") ? userDetails.strategy : "conservative");
1865
1990
  const internalStrategy = toInternalStrategy(publicStrategy);
@@ -1874,7 +1999,6 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1874
1999
  effectiveChains,
1875
2000
  asset
1876
2001
  );
1877
- console.log("withPools", withPools, "effectiveChains", effectiveChains, "asset", asset);
1878
2002
  await this.updateUserProfile({
1879
2003
  asset,
1880
2004
  protocols: withPools,
@@ -1941,6 +2065,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1941
2065
  * Token is automatically selected based on chain (USDC by default):
1942
2066
  * - Ethereum Mainnet (1), Base (8453), Arbitrum (42161)
1943
2067
  *
2068
+ * On the account's first deposit (USDC profile has no chains yet), patches
2069
+ * protocol selection for USDC, WETH, and EURC across all supported chains
2070
+ * (EURC on Mainnet/Base only) before the transfer and log_deposit.
2071
+ *
1944
2072
  * Minimum portfolio balance enforced (Safe balance + deposit amount),
1945
2073
  * configured per-chain in `MIN_PORTFOLIO_BALANCE`:
1946
2074
  * - Ethereum Mainnet (1): 5 USDC (test threshold)
@@ -1952,7 +2080,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1952
2080
  * @param userAddress - User's address (owner of the Safe)
1953
2081
  * @param chainId - Target chain ID
1954
2082
  * @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
1955
- * @param asset - Optional asset symbol ("USDC" or "WETH"). Defaults to "USDC".
2083
+ * @param asset - Optional asset symbol ("USDC", "WETH", or "EURC"). Defaults to "USDC".
2084
+ * EURC is supported on Ethereum Mainnet and Base only.
1956
2085
  * @returns Deposit response with transaction hash
1957
2086
  *
1958
2087
  * @example
@@ -1980,7 +2109,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1980
2109
  const assetConfig = ASSET_CONFIGS[assetSymbol];
1981
2110
  if (!assetConfig) {
1982
2111
  throw new Error(
1983
- `Unsupported asset: ${assetSymbol}. Supported: USDC, WETH.`
2112
+ `Unsupported asset: ${assetSymbol}. Supported: USDC, WETH, EURC.`
1984
2113
  );
1985
2114
  }
1986
2115
  const minRequired = MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
@@ -1994,7 +2123,18 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1994
2123
  );
1995
2124
  if (!isDeployed) {
1996
2125
  throw new Error(
1997
- `Safe not deployed for ${userAddress}. Please deploy the Safe first using deploySafe().`
2126
+ `Safe not available for ${userAddress} on chain ${chainId}.`
2127
+ );
2128
+ }
2129
+ try {
2130
+ const usdcDetails = await this.getUserDetails("USDC");
2131
+ if ((usdcDetails.chains?.length ?? 0) === 0) {
2132
+ await this.updateUserProtocols();
2133
+ }
2134
+ } catch (protocolError) {
2135
+ console.warn(
2136
+ "Failed to update user protocols before deposit:",
2137
+ protocolError.message
1998
2138
  );
1999
2139
  }
2000
2140
  const amountBigInt = BigInt(amount);
@@ -2029,6 +2169,12 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2029
2169
  hash: txHash
2030
2170
  });
2031
2171
  try {
2172
+ console.log("Logging deposit to backend", {
2173
+ chainId,
2174
+ transaction: txHash,
2175
+ token,
2176
+ amount
2177
+ });
2032
2178
  await this.httpClient.post(ENDPOINTS.LOG_DEPOSIT, {
2033
2179
  chainId,
2034
2180
  transaction: txHash,
@@ -3960,33 +4106,15 @@ function createBankrProvider(config) {
3960
4106
  };
3961
4107
  return provider;
3962
4108
  }
3963
-
3964
- // src/config/modules.ts
3965
- var SMART_SESSIONS_VALIDATOR = "0x00000000008bDABA73cD9815d79069c247Eb4bDA";
3966
- var SMART_SESSIONS_FALLBACK = "0x12cae64c42f362e7d5a847c2d33388373f629177";
3967
- var INTENT_EXECUTOR = "0x00000000005aD9ce1f5035FD62CA96CEf16AdAAF";
3968
- var PROXY_EXECUTOR = "0xF659d30D4EB88B06A909F20839D8959Bd77d8790";
3969
- var INTENT_SMART_SESSIONS = "0xad568b3f825a8d5ffc06dd3253526b64d810ae89";
3970
- var OWNABLE_VALIDATOR = "0x000000000013fdB5234E4E3162a810F54d9f7E98";
3971
- var SAFE_7579_ADDRESS2 = "0x7579EE8307284F293B1927136486880611F20002";
3972
- var ERC7579_LAUNCHPAD_ADDRESS2 = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
3973
- var POOL_MODULE_ADDRESSES = [
3974
- SMART_SESSIONS_VALIDATOR,
3975
- SMART_SESSIONS_FALLBACK,
3976
- INTENT_EXECUTOR,
3977
- PROXY_EXECUTOR,
3978
- INTENT_SMART_SESSIONS,
3979
- OWNABLE_VALIDATOR
3980
- ];
3981
4109
  export {
3982
4110
  DEFAULT_TOKEN_ADDRESSES,
3983
- ERC7579_LAUNCHPAD_ADDRESS2 as ERC7579_LAUNCHPAD_ADDRESS,
4111
+ ERC7579_LAUNCHPAD_ADDRESS,
3984
4112
  INTENT_EXECUTOR,
3985
4113
  INTENT_SMART_SESSIONS,
3986
4114
  OWNABLE_VALIDATOR,
3987
4115
  POOL_MODULE_ADDRESSES,
3988
4116
  PROXY_EXECUTOR,
3989
- SAFE_7579_ADDRESS2 as SAFE_7579_ADDRESS,
4117
+ SAFE_7579_ADDRESS,
3990
4118
  SMART_SESSIONS_FALLBACK,
3991
4119
  SMART_SESSIONS_VALIDATOR,
3992
4120
  VAULT_ADDRESS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
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",