@zyfai/sdk 0.5.0 → 0.7.1

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
@@ -45,7 +45,7 @@ Commit the generated file in `.changeset/` with your PR.
45
45
 
46
46
  ### Publishing (maintainers)
47
47
 
48
- After changesets merge to `main`, a maintainer runs `npm run version-packages`, then `npm publish`. Details: [`docs/RELEASING.md`](docs/RELEASING.md).
48
+ After changesets merge to `release`, a maintainer runs `npm run version-packages` (`changeset version`), then `npm publish`. Details: [`docs/RELEASING.md`](docs/RELEASING.md).
49
49
 
50
50
  ## Prerequisites
51
51
 
@@ -472,10 +472,10 @@ if (credited.status === "credited") {
472
472
  - `depositFunds()` remains a compatibility wrapper that calls both steps and waits through the normal completion window; it **rejects** if credit is not confirmed in that window (track in-flight deposits with `getDepositStatus()` or call `waitForDepositCredit()` with a longer `timeoutMs`).
473
473
  - If first-deposit protocol patching fails, the transfer still runs. `sendDeposit()` throws if deposit registration is not accepted; retry `logDeposit()` after `connectAccount()`.
474
474
  - **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, EURC, and NVDAc**, each across the chains it exists on (EURC on Mainnet/Base, NVDAc on Base → `assetTypeSettings.[usdc|eth|eurc|nvdac]`). Pass optional `strategy` (`"conservative"` default, `"aggressive"` or `"yieldmaxxing"`) — same role as the former `deploySafe` strategy argument. Later deposits skip this.
475
- - **`strategy` is ignored on later deposits, and no error is raised.** Re-running the patch would overwrite a protocol selection the user may have customised, so passing `"yieldmaxxing"` to an account that has already deposited leaves it on its current strategy. To change an existing account, call `updateUserProfile({ asset, strategy })` for each asset concerned:
475
+ - **`strategy` is ignored on later deposits, and no error is raised.** Re-running the patch would overwrite a protocol selection the user may have customised, so passing `"yieldmaxxing"` to an account that has already deposited leaves it on its current strategy. To change an existing account, use `setStrategyWithProtocols` or `setAssetStrategy` (not `updateUserProfile` alone):
476
476
 
477
477
  ```typescript
478
- await sdk.updateUserProfile({ asset: "USDC", strategy: "yieldmaxxing" });
478
+ await sdk.setStrategyWithProtocols({ strategy: "yieldmaxxing" });
479
479
  ```
480
480
 
481
481
  #### Deposit With an External Wallet (Sponsored Transactions)
@@ -1098,9 +1098,15 @@ but the funds are in flight in between. See
1098
1098
 
1099
1099
  `updateUserProfile({ asset, strategy })` stores a strategy but does **not**
1100
1100
  compute the protocol list that goes with it, so on its own it leaves the asset
1101
- with nothing to deploy into. `setAssetStrategy` does both in one call:
1101
+ with nothing to deploy into. `setAssetStrategy` does both in one call for one
1102
+ asset. `setStrategyWithProtocols` does the same for one asset or for every
1103
+ entry in `getManagedAssets()` when `asset` is omitted:
1102
1104
 
1103
1105
  ```typescript
1106
+ const profiles = await sdk.setStrategyWithProtocols({
1107
+ strategy: "yieldmaxxing",
1108
+ });
1109
+ // Or a single asset:
1104
1110
  const profile = await sdk.setAssetStrategy({
1105
1111
  asset: "NVDAc",
1106
1112
  strategy: "yieldmaxxing",
package/dist/index.d.mts CHANGED
@@ -1474,6 +1474,19 @@ declare class ZyfaiSDK {
1474
1474
  strategy?: Strategy;
1475
1475
  chains?: SupportedChainId[];
1476
1476
  }): Promise<UpdateUserProfileResponse>;
1477
+ /**
1478
+ * Apply a strategy and auto-select matching protocols for one or all managed
1479
+ * assets ({@link getManagedAssets}). Prefer this over
1480
+ * {@link updateUserProfile} when changing strategy so protocols stay aligned
1481
+ * with the tier (including `yieldmaxxing` async venues).
1482
+ *
1483
+ * @group Portfolio and execution
1484
+ */
1485
+ setStrategyWithProtocols(params: {
1486
+ strategy: Strategy;
1487
+ asset?: SupportedAsset;
1488
+ chains?: SupportedChainId[];
1489
+ }): Promise<UpdateUserProfileResponse[]>;
1477
1490
  /**
1478
1491
  * Drop protocols that have no pools on any of the selected chains for the
1479
1492
  * requested asset. The /customization/pools endpoint filters server-side on
@@ -2672,6 +2685,13 @@ declare function createBankrProvider(config: BankrProviderConfig): {
2672
2685
  };
2673
2686
  type BankrProvider = ReturnType<typeof createBankrProvider>;
2674
2687
 
2688
+ /**
2689
+ * Assets the agent manages for pause, resume, first-deposit protocol setup,
2690
+ * and bulk strategy changes. Derived from {@link ASSET_CONFIGS} where
2691
+ * `enabled === true`, with a stable product order for known symbols.
2692
+ */
2693
+ declare function getManagedAssets(): SupportedAsset[];
2694
+
2675
2695
  /**
2676
2696
  * API Endpoints Configuration
2677
2697
  *
@@ -2771,4 +2791,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
2771
2791
  */
2772
2792
  declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
2773
2793
 
2774
- export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, 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, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, 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, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
2794
+ export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, 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, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, 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, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
package/dist/index.d.ts CHANGED
@@ -1474,6 +1474,19 @@ declare class ZyfaiSDK {
1474
1474
  strategy?: Strategy;
1475
1475
  chains?: SupportedChainId[];
1476
1476
  }): Promise<UpdateUserProfileResponse>;
1477
+ /**
1478
+ * Apply a strategy and auto-select matching protocols for one or all managed
1479
+ * assets ({@link getManagedAssets}). Prefer this over
1480
+ * {@link updateUserProfile} when changing strategy so protocols stay aligned
1481
+ * with the tier (including `yieldmaxxing` async venues).
1482
+ *
1483
+ * @group Portfolio and execution
1484
+ */
1485
+ setStrategyWithProtocols(params: {
1486
+ strategy: Strategy;
1487
+ asset?: SupportedAsset;
1488
+ chains?: SupportedChainId[];
1489
+ }): Promise<UpdateUserProfileResponse[]>;
1477
1490
  /**
1478
1491
  * Drop protocols that have no pools on any of the selected chains for the
1479
1492
  * requested asset. The /customization/pools endpoint filters server-side on
@@ -2672,6 +2685,13 @@ declare function createBankrProvider(config: BankrProviderConfig): {
2672
2685
  };
2673
2686
  type BankrProvider = ReturnType<typeof createBankrProvider>;
2674
2687
 
2688
+ /**
2689
+ * Assets the agent manages for pause, resume, first-deposit protocol setup,
2690
+ * and bulk strategy changes. Derived from {@link ASSET_CONFIGS} where
2691
+ * `enabled === true`, with a stable product order for known symbols.
2692
+ */
2693
+ declare function getManagedAssets(): SupportedAsset[];
2694
+
2675
2695
  /**
2676
2696
  * API Endpoints Configuration
2677
2697
  *
@@ -2771,4 +2791,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
2771
2791
  */
2772
2792
  declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
2773
2793
 
2774
- export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, 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, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, 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, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
2794
+ export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, 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, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, 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, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
package/dist/index.js CHANGED
@@ -60,6 +60,7 @@ __export(index_exports, {
60
60
  getDataApiBaseUrl: () => getDataApiBaseUrl,
61
61
  getDefaultTokenAddress: () => getDefaultTokenAddress,
62
62
  getExecutionApiBaseUrl: () => getExecutionApiBaseUrl,
63
+ getManagedAssets: () => getManagedAssets,
63
64
  getSupportedChainIds: () => getSupportedChainIds,
64
65
  getWsUrl: () => getWsUrl,
65
66
  isSupportedChain: () => isSupportedChain
@@ -890,6 +891,22 @@ var getSupportedChainIds = () => {
890
891
  return Object.keys(CHAINS).map(Number);
891
892
  };
892
893
 
894
+ // src/config/managed-assets.ts
895
+ var MANAGED_ASSET_ORDER = [
896
+ "USDC",
897
+ "WETH",
898
+ "EURC",
899
+ "NVDAc"
900
+ ];
901
+ function getManagedAssets() {
902
+ const enabled = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([key]) => key);
903
+ const ordered = MANAGED_ASSET_ORDER.filter(
904
+ (symbol) => enabled.includes(symbol)
905
+ );
906
+ const remainder = enabled.filter((symbol) => !MANAGED_ASSET_ORDER.includes(symbol)).sort((a, b) => a.localeCompare(b));
907
+ return [...ordered, ...remainder];
908
+ }
909
+
893
910
  // src/utils/safe-account.ts
894
911
  var import_module_sdk = require("@rhinestone/module-sdk");
895
912
  var import_accounts = require("permissionless/accounts");
@@ -1672,7 +1689,6 @@ var AgentDepositIntentTimeoutError = class extends Error {
1672
1689
  this.name = "AgentDepositIntentTimeoutError";
1673
1690
  }
1674
1691
  };
1675
- var MANAGED_ASSETS = ["USDC", "WETH", "EURC", "NVDAc"];
1676
1692
  var _ZyfaiSDK = class _ZyfaiSDK {
1677
1693
  /**
1678
1694
  * Create an SDK instance bound to a partner API key.
@@ -1978,7 +1994,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1978
1994
  async pauseAgent() {
1979
1995
  try {
1980
1996
  let latest;
1981
- for (const asset of MANAGED_ASSETS) {
1997
+ for (const asset of getManagedAssets()) {
1982
1998
  latest = await this.updateUserProfile({ asset, protocols: [] });
1983
1999
  }
1984
2000
  if (!latest) {
@@ -2017,7 +2033,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2017
2033
  ENDPOINTS.PROTOCOLS()
2018
2034
  );
2019
2035
  let latest;
2020
- for (const asset of MANAGED_ASSETS) {
2036
+ for (const asset of getManagedAssets()) {
2021
2037
  latest = await this.updateUserProtocolsForAsset(
2022
2038
  asset,
2023
2039
  getAssetChainIds(asset),
@@ -2796,7 +2812,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2796
2812
  const allProtocols = await this.httpClient.get(
2797
2813
  ENDPOINTS.PROTOCOLS()
2798
2814
  );
2799
- for (const asset of MANAGED_ASSETS) {
2815
+ for (const asset of getManagedAssets()) {
2800
2816
  try {
2801
2817
  await this.updateUserProtocolsForAsset(
2802
2818
  asset,
@@ -2969,6 +2985,77 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2969
2985
  );
2970
2986
  }
2971
2987
  }
2988
+ /**
2989
+ * Apply a strategy and auto-select matching protocols for one or all managed
2990
+ * assets ({@link getManagedAssets}). Prefer this over
2991
+ * {@link updateUserProfile} when changing strategy so protocols stay aligned
2992
+ * with the tier (including `yieldmaxxing` async venues).
2993
+ *
2994
+ * @group Portfolio and execution
2995
+ */
2996
+ async setStrategyWithProtocols(params) {
2997
+ const { strategy, asset, chains } = params;
2998
+ if (!isValidPublicStrategy(strategy)) {
2999
+ throw new Error(
3000
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
3001
+ );
3002
+ }
3003
+ const assets = asset ? [asset] : getManagedAssets();
3004
+ if (assets.length === 0) {
3005
+ throw new Error("No managed assets available to configure.");
3006
+ }
3007
+ const plannedUpdates = [];
3008
+ const validationErrors = [];
3009
+ for (const targetAsset of assets) {
3010
+ const supported = getAssetChainIds(targetAsset);
3011
+ if (supported.length === 0) {
3012
+ validationErrors.push(`${targetAsset}: Unsupported asset: ${targetAsset}.`);
3013
+ continue;
3014
+ }
3015
+ const targetChains = chains ?? supported;
3016
+ const unsupported = targetChains.filter((c) => !supported.includes(c));
3017
+ if (unsupported.length > 0) {
3018
+ validationErrors.push(
3019
+ `${targetAsset}: ${targetAsset} is not available on chain ${unsupported.join(
3020
+ ", "
3021
+ )}. Supported chains: ${supported.join(", ")}.`
3022
+ );
3023
+ continue;
3024
+ }
3025
+ plannedUpdates.push({ targetAsset, targetChains });
3026
+ }
3027
+ if (validationErrors.length > 0) {
3028
+ throw new Error(
3029
+ `Failed to set strategy with protocols: ${validationErrors.join("; ")}`
3030
+ );
3031
+ }
3032
+ const allProtocols = await this.httpClient.get(
3033
+ ENDPOINTS.PROTOCOLS()
3034
+ );
3035
+ const results = [];
3036
+ const errors = [];
3037
+ for (const { targetAsset, targetChains } of plannedUpdates) {
3038
+ try {
3039
+ const profile = await this.updateUserProtocolsForAsset(
3040
+ targetAsset,
3041
+ targetChains,
3042
+ strategy,
3043
+ allProtocols
3044
+ );
3045
+ results.push(profile);
3046
+ } catch (error) {
3047
+ errors.push(
3048
+ `${targetAsset}: ${error instanceof Error ? error.message : String(error)}`
3049
+ );
3050
+ }
3051
+ }
3052
+ if (errors.length > 0) {
3053
+ throw new Error(
3054
+ `Failed to set strategy with protocols: ${errors.join("; ")}`
3055
+ );
3056
+ }
3057
+ return results;
3058
+ }
2972
3059
  /**
2973
3060
  * Drop protocols that have no pools on any of the selected chains for the
2974
3061
  * requested asset. The /customization/pools endpoint filters server-side on
@@ -5923,6 +6010,7 @@ function createBankrProvider(config) {
5923
6010
  getDataApiBaseUrl,
5924
6011
  getDefaultTokenAddress,
5925
6012
  getExecutionApiBaseUrl,
6013
+ getManagedAssets,
5926
6014
  getSupportedChainIds,
5927
6015
  getWsUrl,
5928
6016
  isSupportedChain
package/dist/index.mjs CHANGED
@@ -828,6 +828,22 @@ var getSupportedChainIds = () => {
828
828
  return Object.keys(CHAINS).map(Number);
829
829
  };
830
830
 
831
+ // src/config/managed-assets.ts
832
+ var MANAGED_ASSET_ORDER = [
833
+ "USDC",
834
+ "WETH",
835
+ "EURC",
836
+ "NVDAc"
837
+ ];
838
+ function getManagedAssets() {
839
+ const enabled = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([key]) => key);
840
+ const ordered = MANAGED_ASSET_ORDER.filter(
841
+ (symbol) => enabled.includes(symbol)
842
+ );
843
+ const remainder = enabled.filter((symbol) => !MANAGED_ASSET_ORDER.includes(symbol)).sort((a, b) => a.localeCompare(b));
844
+ return [...ordered, ...remainder];
845
+ }
846
+
831
847
  // src/utils/safe-account.ts
832
848
  import {
833
849
  RHINESTONE_ATTESTER_ADDRESS,
@@ -1624,7 +1640,6 @@ var AgentDepositIntentTimeoutError = class extends Error {
1624
1640
  this.name = "AgentDepositIntentTimeoutError";
1625
1641
  }
1626
1642
  };
1627
- var MANAGED_ASSETS = ["USDC", "WETH", "EURC", "NVDAc"];
1628
1643
  var _ZyfaiSDK = class _ZyfaiSDK {
1629
1644
  /**
1630
1645
  * Create an SDK instance bound to a partner API key.
@@ -1930,7 +1945,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1930
1945
  async pauseAgent() {
1931
1946
  try {
1932
1947
  let latest;
1933
- for (const asset of MANAGED_ASSETS) {
1948
+ for (const asset of getManagedAssets()) {
1934
1949
  latest = await this.updateUserProfile({ asset, protocols: [] });
1935
1950
  }
1936
1951
  if (!latest) {
@@ -1969,7 +1984,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
1969
1984
  ENDPOINTS.PROTOCOLS()
1970
1985
  );
1971
1986
  let latest;
1972
- for (const asset of MANAGED_ASSETS) {
1987
+ for (const asset of getManagedAssets()) {
1973
1988
  latest = await this.updateUserProtocolsForAsset(
1974
1989
  asset,
1975
1990
  getAssetChainIds(asset),
@@ -2748,7 +2763,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2748
2763
  const allProtocols = await this.httpClient.get(
2749
2764
  ENDPOINTS.PROTOCOLS()
2750
2765
  );
2751
- for (const asset of MANAGED_ASSETS) {
2766
+ for (const asset of getManagedAssets()) {
2752
2767
  try {
2753
2768
  await this.updateUserProtocolsForAsset(
2754
2769
  asset,
@@ -2921,6 +2936,77 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2921
2936
  );
2922
2937
  }
2923
2938
  }
2939
+ /**
2940
+ * Apply a strategy and auto-select matching protocols for one or all managed
2941
+ * assets ({@link getManagedAssets}). Prefer this over
2942
+ * {@link updateUserProfile} when changing strategy so protocols stay aligned
2943
+ * with the tier (including `yieldmaxxing` async venues).
2944
+ *
2945
+ * @group Portfolio and execution
2946
+ */
2947
+ async setStrategyWithProtocols(params) {
2948
+ const { strategy, asset, chains } = params;
2949
+ if (!isValidPublicStrategy(strategy)) {
2950
+ throw new Error(
2951
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
2952
+ );
2953
+ }
2954
+ const assets = asset ? [asset] : getManagedAssets();
2955
+ if (assets.length === 0) {
2956
+ throw new Error("No managed assets available to configure.");
2957
+ }
2958
+ const plannedUpdates = [];
2959
+ const validationErrors = [];
2960
+ for (const targetAsset of assets) {
2961
+ const supported = getAssetChainIds(targetAsset);
2962
+ if (supported.length === 0) {
2963
+ validationErrors.push(`${targetAsset}: Unsupported asset: ${targetAsset}.`);
2964
+ continue;
2965
+ }
2966
+ const targetChains = chains ?? supported;
2967
+ const unsupported = targetChains.filter((c) => !supported.includes(c));
2968
+ if (unsupported.length > 0) {
2969
+ validationErrors.push(
2970
+ `${targetAsset}: ${targetAsset} is not available on chain ${unsupported.join(
2971
+ ", "
2972
+ )}. Supported chains: ${supported.join(", ")}.`
2973
+ );
2974
+ continue;
2975
+ }
2976
+ plannedUpdates.push({ targetAsset, targetChains });
2977
+ }
2978
+ if (validationErrors.length > 0) {
2979
+ throw new Error(
2980
+ `Failed to set strategy with protocols: ${validationErrors.join("; ")}`
2981
+ );
2982
+ }
2983
+ const allProtocols = await this.httpClient.get(
2984
+ ENDPOINTS.PROTOCOLS()
2985
+ );
2986
+ const results = [];
2987
+ const errors = [];
2988
+ for (const { targetAsset, targetChains } of plannedUpdates) {
2989
+ try {
2990
+ const profile = await this.updateUserProtocolsForAsset(
2991
+ targetAsset,
2992
+ targetChains,
2993
+ strategy,
2994
+ allProtocols
2995
+ );
2996
+ results.push(profile);
2997
+ } catch (error) {
2998
+ errors.push(
2999
+ `${targetAsset}: ${error instanceof Error ? error.message : String(error)}`
3000
+ );
3001
+ }
3002
+ }
3003
+ if (errors.length > 0) {
3004
+ throw new Error(
3005
+ `Failed to set strategy with protocols: ${errors.join("; ")}`
3006
+ );
3007
+ }
3008
+ return results;
3009
+ }
2924
3010
  /**
2925
3011
  * Drop protocols that have no pools on any of the selected chains for the
2926
3012
  * requested asset. The /customization/pools endpoint filters server-side on
@@ -5874,6 +5960,7 @@ export {
5874
5960
  getDataApiBaseUrl,
5875
5961
  getDefaultTokenAddress,
5876
5962
  getExecutionApiBaseUrl,
5963
+ getManagedAssets,
5877
5964
  getSupportedChainIds,
5878
5965
  getWsUrl,
5879
5966
  isSupportedChain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.1",
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",
@@ -34,6 +34,7 @@
34
34
  "changeset": "changeset",
35
35
  "version-packages": "changeset version",
36
36
  "prepublishOnly": "npm run build",
37
+ "prepare": "npm run build",
37
38
  "docs": "typedoc",
38
39
  "docs:watch": "typedoc --watch",
39
40
  "docs:json": "typedoc --json docs/api.json",