@vizzor/cli 0.7.0 → 0.8.5

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
@@ -737,6 +737,63 @@ var init_adapter = __esm({
737
737
  }
738
738
  });
739
739
 
740
+ // src/chains/zk/adapter.ts
741
+ function getZkChainIds() {
742
+ return Object.keys(ZK_CHAIN_CONFIG);
743
+ }
744
+ var ZK_CHAIN_CONFIG, ZkEvmAdapter;
745
+ var init_adapter2 = __esm({
746
+ "src/chains/zk/adapter.ts"() {
747
+ "use strict";
748
+ init_adapter();
749
+ ZK_CHAIN_CONFIG = {
750
+ zksync: {
751
+ name: "zkSync Era",
752
+ rpcUrl: "https://mainnet.era.zksync.io",
753
+ explorerApi: "https://block-explorer-api.mainnet.zksync.io/api",
754
+ nativeCurrency: { symbol: "ETH", decimals: 18 },
755
+ isEvm: true
756
+ },
757
+ "polygon-zkevm": {
758
+ name: "Polygon zkEVM",
759
+ rpcUrl: "https://zkevm-rpc.com",
760
+ explorerApi: "https://api-zkevm.polygonscan.com/api",
761
+ nativeCurrency: { symbol: "ETH", decimals: 18 },
762
+ isEvm: true
763
+ },
764
+ scroll: {
765
+ name: "Scroll",
766
+ rpcUrl: "https://rpc.scroll.io",
767
+ explorerApi: "https://api.scrollscan.com/api",
768
+ nativeCurrency: { symbol: "ETH", decimals: 18 },
769
+ isEvm: true
770
+ },
771
+ linea: {
772
+ name: "Linea",
773
+ rpcUrl: "https://rpc.linea.build",
774
+ explorerApi: "https://api.lineascan.build/api",
775
+ nativeCurrency: { symbol: "ETH", decimals: 18 },
776
+ isEvm: true
777
+ }
778
+ };
779
+ ZkEvmAdapter = class extends EvmAdapter {
780
+ zkType;
781
+ zkName;
782
+ constructor(chainId) {
783
+ super(chainId);
784
+ this.zkType = chainId;
785
+ this.zkName = ZK_CHAIN_CONFIG[chainId]?.name ?? `ZK-${chainId}`;
786
+ }
787
+ getZkName() {
788
+ return this.zkName;
789
+ }
790
+ getDefaultRpcUrl() {
791
+ return ZK_CHAIN_CONFIG[this.chainId]?.rpcUrl ?? "";
792
+ }
793
+ };
794
+ }
795
+ });
796
+
740
797
  // src/chains/registry.ts
741
798
  function getAdapter(chainId) {
742
799
  const factory = registry.get(chainId);
@@ -750,17 +807,22 @@ function getAdapter(chainId) {
750
807
  function getSupportedChains() {
751
808
  return [...registry.keys()];
752
809
  }
753
- var registry, evmFactory, BUILTIN_EVM_CHAINS;
810
+ var registry, evmFactory, BUILTIN_EVM_CHAINS, zkFactory;
754
811
  var init_registry = __esm({
755
812
  "src/chains/registry.ts"() {
756
813
  "use strict";
757
814
  init_adapter();
815
+ init_adapter2();
758
816
  registry = /* @__PURE__ */ new Map();
759
817
  evmFactory = (chainId) => new EvmAdapter(chainId);
760
818
  BUILTIN_EVM_CHAINS = ["ethereum", "polygon", "arbitrum", "optimism", "base"];
761
819
  for (const chainId of BUILTIN_EVM_CHAINS) {
762
820
  registry.set(chainId, evmFactory);
763
821
  }
822
+ zkFactory = (chainId) => new ZkEvmAdapter(chainId);
823
+ for (const chainId of getZkChainIds()) {
824
+ registry.set(chainId, zkFactory);
825
+ }
764
826
  }
765
827
  });
766
828
 
@@ -5973,6 +6035,106 @@ var init_trend_following = __esm({
5973
6035
  }
5974
6036
  });
5975
6037
 
6038
+ // src/core/agent/strategies/ml-adaptive.ts
6039
+ function evaluateWithRules(signals) {
6040
+ const reasoning = [];
6041
+ let score = 0;
6042
+ if (signals.rsi !== null) {
6043
+ if (signals.rsi < 25) {
6044
+ score += 35;
6045
+ reasoning.push(`RSI deeply oversold (${signals.rsi.toFixed(0)})`);
6046
+ } else if (signals.rsi < 35) {
6047
+ score += 20;
6048
+ reasoning.push(`RSI oversold zone (${signals.rsi.toFixed(0)})`);
6049
+ } else if (signals.rsi > 75) {
6050
+ score -= 35;
6051
+ reasoning.push(`RSI deeply overbought (${signals.rsi.toFixed(0)})`);
6052
+ } else if (signals.rsi > 65) {
6053
+ score -= 20;
6054
+ reasoning.push(`RSI overbought zone (${signals.rsi.toFixed(0)})`);
6055
+ }
6056
+ }
6057
+ if (signals.macdHistogram !== null) {
6058
+ if (signals.macdHistogram > 0) {
6059
+ score += 15;
6060
+ reasoning.push("MACD bullish momentum");
6061
+ } else {
6062
+ score -= 15;
6063
+ reasoning.push("MACD bearish momentum");
6064
+ }
6065
+ }
6066
+ if (signals.ema12 !== null && signals.ema26 !== null) {
6067
+ const crossPct = signals.ema26 !== 0 ? (signals.ema12 - signals.ema26) / signals.ema26 * 100 : 0;
6068
+ if (crossPct > 0.5) {
6069
+ score += 20;
6070
+ reasoning.push(`Golden cross (EMA12 > EMA26 by ${crossPct.toFixed(2)}%)`);
6071
+ } else if (crossPct < -0.5) {
6072
+ score -= 20;
6073
+ reasoning.push(`Death cross (EMA12 < EMA26 by ${Math.abs(crossPct).toFixed(2)}%)`);
6074
+ }
6075
+ }
6076
+ if (signals.bollingerPercentB !== null) {
6077
+ if (signals.bollingerPercentB < 0.1) {
6078
+ score += 15;
6079
+ reasoning.push("Price at lower Bollinger Band \u2014 potential bounce");
6080
+ } else if (signals.bollingerPercentB > 0.9) {
6081
+ score -= 15;
6082
+ reasoning.push("Price at upper Bollinger Band \u2014 potential resistance");
6083
+ }
6084
+ }
6085
+ if (signals.fundingRate !== null) {
6086
+ if (signals.fundingRate > 5e-4) {
6087
+ score -= 10;
6088
+ reasoning.push("High funding rate \u2014 overleveraged longs");
6089
+ } else if (signals.fundingRate < -3e-4) {
6090
+ score += 10;
6091
+ reasoning.push("Negative funding \u2014 capitulation signal");
6092
+ }
6093
+ }
6094
+ if (signals.fearGreed !== null) {
6095
+ if (signals.fearGreed < 20) {
6096
+ score += 10;
6097
+ reasoning.push("Extreme fear \u2014 contrarian bullish");
6098
+ } else if (signals.fearGreed > 80) {
6099
+ score -= 10;
6100
+ reasoning.push("Extreme greed \u2014 contrarian bearish");
6101
+ }
6102
+ }
6103
+ if (signals.priceChange24h !== null) {
6104
+ if (signals.priceChange24h > 5) {
6105
+ score += 10;
6106
+ } else if (signals.priceChange24h < -5) {
6107
+ score -= 10;
6108
+ }
6109
+ }
6110
+ const confidence = Math.min(95, Math.abs(score));
6111
+ if (score > 20) {
6112
+ return { action: "buy", confidence, reasoning };
6113
+ } else if (score < -20) {
6114
+ return { action: "sell", confidence, reasoning };
6115
+ }
6116
+ return {
6117
+ action: "hold",
6118
+ confidence: Math.max(30, 50 - Math.abs(score)),
6119
+ reasoning: [...reasoning, "Mixed signals \u2014 holding"]
6120
+ };
6121
+ }
6122
+ var mlAdaptiveStrategy;
6123
+ var init_ml_adaptive = __esm({
6124
+ "src/core/agent/strategies/ml-adaptive.ts"() {
6125
+ "use strict";
6126
+ init_client();
6127
+ init_feature_engineer();
6128
+ mlAdaptiveStrategy = {
6129
+ name: "ml-adaptive",
6130
+ description: "ML-powered strategy using contextual bandit approach. Uses LSTM/RF predictions when available, falls back to rule-based when < 100 training samples.",
6131
+ evaluate(signals) {
6132
+ return evaluateWithRules(signals);
6133
+ }
6134
+ };
6135
+ }
6136
+ });
6137
+
5976
6138
  // src/core/agent/manager.ts
5977
6139
  import { randomUUID } from "crypto";
5978
6140
  function getStrategy(name) {
@@ -6143,9 +6305,11 @@ var init_manager = __esm({
6143
6305
  init_engine();
6144
6306
  init_momentum();
6145
6307
  init_trend_following();
6308
+ init_ml_adaptive();
6146
6309
  STRATEGIES = {
6147
6310
  momentum: momentumStrategy,
6148
- "trend-following": trendFollowingStrategy
6311
+ "trend-following": trendFollowingStrategy,
6312
+ "ml-adaptive": mlAdaptiveStrategy
6149
6313
  };
6150
6314
  engines = /* @__PURE__ */ new Map();
6151
6315
  }