@t2000/sdk 0.16.0 → 0.16.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/dist/index.cjs CHANGED
@@ -3097,15 +3097,14 @@ var StrategyManager = class {
3097
3097
  }
3098
3098
  }
3099
3099
  validateMinAmount(allocations, totalUsd) {
3100
- const assetCount = Object.keys(allocations).length;
3101
- for (const [asset, pct] of Object.entries(allocations)) {
3102
- const assetUsd = totalUsd * (pct / 100);
3103
- if (assetUsd < 1) {
3104
- throw new T2000Error(
3105
- "STRATEGY_MIN_AMOUNT",
3106
- `Minimum $1 per asset in strategy. Need at least $${assetCount} for ${assetCount}-asset strategy.`
3107
- );
3108
- }
3100
+ const smallestPct = Math.min(...Object.values(allocations));
3101
+ const minRequired = Math.ceil(100 / smallestPct);
3102
+ if (totalUsd < minRequired) {
3103
+ const smallestAsset = Object.entries(allocations).find(([, p]) => p === smallestPct)?.[0] ?? "?";
3104
+ throw new T2000Error(
3105
+ "STRATEGY_MIN_AMOUNT",
3106
+ `Minimum $${minRequired} for this strategy (${smallestAsset} at ${smallestPct}% needs at least $1)`
3107
+ );
3109
3108
  }
3110
3109
  }
3111
3110
  };