@zyfai/sdk 0.8.0 → 0.9.0

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.js CHANGED
@@ -755,6 +755,20 @@ function shouldBypassMinPortfolioCheck(executionApiUrl) {
755
755
  return isLocalExecutionApiUrl(executionApiUrl) || isStagingExecutionApiUrl(executionApiUrl);
756
756
  }
757
757
 
758
+ // src/config/min-portfolio-exempt.ts
759
+ var MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES = /* @__PURE__ */ new Set([
760
+ "0x2db791f63c8b12bde9a3fe31afa8ad491f47d60f",
761
+ "0xae72cb0f7d604a8ff742d96031104506186638e3"
762
+ ]);
763
+ function isMainnetMinPortfolioExempt(chainId, ...addresses) {
764
+ if (chainId !== 1) {
765
+ return false;
766
+ }
767
+ return addresses.some(
768
+ (address) => typeof address === "string" && MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES.has(address.toLowerCase())
769
+ );
770
+ }
771
+
758
772
  // src/core/ZyfaiSDK.ts
759
773
  var import_accounts2 = require("viem/accounts");
760
774
  var import_viem4 = require("viem");
@@ -3260,8 +3274,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3260
3274
  )}.`
3261
3275
  );
3262
3276
  }
3263
- let minRequired = this.bypassMinPortfolio ? void 0 : MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
3264
- const minUsd = this.bypassMinPortfolio ? void 0 : MIN_PORTFOLIO_USD[chainId]?.[assetSymbol];
3277
+ const skipMinPortfolio = this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress);
3278
+ let minRequired = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
3279
+ const minUsd = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_USD[chainId]?.[assetSymbol];
3265
3280
  const token = getDefaultTokenAddress(chainId, assetSymbol);
3266
3281
  const walletClient = this.getWalletClient();
3267
3282
  const chainConfig = getChainConfig(chainId, this.rpcUrls);
@@ -3303,6 +3318,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3303
3318
  );
3304
3319
  }
3305
3320
  }
3321
+ if (minRequired !== void 0 && isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
3322
+ minRequired = void 0;
3323
+ }
3306
3324
  if (minRequired !== void 0) {
3307
3325
  const safeBalance = currentSafeBalance;
3308
3326
  const totalAfterDeposit = safeBalance + amountBigInt;
@@ -3427,7 +3445,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3427
3445
  chainId,
3428
3446
  asset,
3429
3447
  amountBigInt,
3430
- safeAddress
3448
+ safeAddress,
3449
+ userAddress
3431
3450
  );
3432
3451
  const tokenAddress = getDefaultTokenAddress(
3433
3452
  chainId,
@@ -3446,8 +3465,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3446
3465
  };
3447
3466
  }
3448
3467
  /** Apply the same per-asset minimum portfolio rule as sendDeposit. */
3449
- async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress) {
3450
- if (this.bypassMinPortfolio) {
3468
+ async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress, userAddress) {
3469
+ if (this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
3451
3470
  return;
3452
3471
  }
3453
3472
  const assetSymbol = resolveAssetSymbol(asset);
package/dist/index.mjs CHANGED
@@ -686,6 +686,20 @@ function shouldBypassMinPortfolioCheck(executionApiUrl) {
686
686
  return isLocalExecutionApiUrl(executionApiUrl) || isStagingExecutionApiUrl(executionApiUrl);
687
687
  }
688
688
 
689
+ // src/config/min-portfolio-exempt.ts
690
+ var MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES = /* @__PURE__ */ new Set([
691
+ "0x2db791f63c8b12bde9a3fe31afa8ad491f47d60f",
692
+ "0xae72cb0f7d604a8ff742d96031104506186638e3"
693
+ ]);
694
+ function isMainnetMinPortfolioExempt(chainId, ...addresses) {
695
+ if (chainId !== 1) {
696
+ return false;
697
+ }
698
+ return addresses.some(
699
+ (address) => typeof address === "string" && MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES.has(address.toLowerCase())
700
+ );
701
+ }
702
+
689
703
  // src/core/ZyfaiSDK.ts
690
704
  import { privateKeyToAccount } from "viem/accounts";
691
705
  import {
@@ -3211,8 +3225,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3211
3225
  )}.`
3212
3226
  );
3213
3227
  }
3214
- let minRequired = this.bypassMinPortfolio ? void 0 : MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
3215
- const minUsd = this.bypassMinPortfolio ? void 0 : MIN_PORTFOLIO_USD[chainId]?.[assetSymbol];
3228
+ const skipMinPortfolio = this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress);
3229
+ let minRequired = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
3230
+ const minUsd = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_USD[chainId]?.[assetSymbol];
3216
3231
  const token = getDefaultTokenAddress(chainId, assetSymbol);
3217
3232
  const walletClient = this.getWalletClient();
3218
3233
  const chainConfig = getChainConfig(chainId, this.rpcUrls);
@@ -3254,6 +3269,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3254
3269
  );
3255
3270
  }
3256
3271
  }
3272
+ if (minRequired !== void 0 && isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
3273
+ minRequired = void 0;
3274
+ }
3257
3275
  if (minRequired !== void 0) {
3258
3276
  const safeBalance = currentSafeBalance;
3259
3277
  const totalAfterDeposit = safeBalance + amountBigInt;
@@ -3378,7 +3396,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3378
3396
  chainId,
3379
3397
  asset,
3380
3398
  amountBigInt,
3381
- safeAddress
3399
+ safeAddress,
3400
+ userAddress
3382
3401
  );
3383
3402
  const tokenAddress = getDefaultTokenAddress(
3384
3403
  chainId,
@@ -3397,8 +3416,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3397
3416
  };
3398
3417
  }
3399
3418
  /** Apply the same per-asset minimum portfolio rule as sendDeposit. */
3400
- async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress) {
3401
- if (this.bypassMinPortfolio) {
3419
+ async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress, userAddress) {
3420
+ if (this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
3402
3421
  return;
3403
3422
  }
3404
3423
  const assetSymbol = resolveAssetSymbol(asset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "TypeScript SDK for self-custodial Zyfai yield agents: discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum, Base, and Arbitrum",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",