@exagent/agent 0.1.36 → 0.1.38
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/chunk-27O4UUAA.mjs +5891 -0
- package/dist/chunk-2RZBOQG3.mjs +5891 -0
- package/dist/chunk-CAGJYKJQ.mjs +5885 -0
- package/dist/chunk-FAFMOHYQ.mjs +5873 -0
- package/dist/chunk-H7HKHVR7.mjs +5873 -0
- package/dist/chunk-O76YFRK5.mjs +5873 -0
- package/dist/chunk-Y6U3JW2V.mjs +5867 -0
- package/dist/cli.js +43 -24
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +22 -10
- package/dist/index.d.ts +22 -10
- package/dist/index.js +43 -24
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -2160,6 +2160,24 @@ function classifyTradeError(message) {
|
|
|
2160
2160
|
userMessage: "DEX aggregator not whitelisted on the router. Contact support."
|
|
2161
2161
|
};
|
|
2162
2162
|
}
|
|
2163
|
+
if (lower.includes("token approval reverted")) {
|
|
2164
|
+
return {
|
|
2165
|
+
category: "approval_failed",
|
|
2166
|
+
userMessage: "Token approval failed \u2014 this token may have non-standard approval behavior or be blocked. Skipping."
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
if (lower.includes("exceeds allowance") || lower.includes("allowance")) {
|
|
2170
|
+
return {
|
|
2171
|
+
category: "allowance",
|
|
2172
|
+
userMessage: "Token allowance insufficient \u2014 approval may not have propagated. Will retry next cycle."
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
if (lower.includes("swapfailed")) {
|
|
2176
|
+
return {
|
|
2177
|
+
category: "swap_failed",
|
|
2178
|
+
userMessage: "DEX swap failed \u2014 likely insufficient liquidity for this token. Will retry next cycle."
|
|
2179
|
+
};
|
|
2180
|
+
}
|
|
2163
2181
|
if (lower.includes("reverted") || lower.includes("execution reverted")) {
|
|
2164
2182
|
return {
|
|
2165
2183
|
category: "reverted",
|
|
@@ -2186,8 +2204,11 @@ var RiskManager = class {
|
|
|
2186
2204
|
lastResetDate = "";
|
|
2187
2205
|
/** Minimum trade value in USD — trades below this are rejected as dust */
|
|
2188
2206
|
minTradeValueUSD;
|
|
2189
|
-
|
|
2207
|
+
/** Risk universe (0-4). Frontier (4) bypasses buy-only guardrails. */
|
|
2208
|
+
riskUniverse;
|
|
2209
|
+
constructor(config, riskUniverse = 0) {
|
|
2190
2210
|
this.config = config;
|
|
2211
|
+
this.riskUniverse = riskUniverse;
|
|
2191
2212
|
this.minTradeValueUSD = config.minTradeValueUSD ?? 1;
|
|
2192
2213
|
}
|
|
2193
2214
|
/**
|
|
@@ -2223,6 +2244,9 @@ var RiskManager = class {
|
|
|
2223
2244
|
if (signal.action === "sell") {
|
|
2224
2245
|
return true;
|
|
2225
2246
|
}
|
|
2247
|
+
if (this.riskUniverse === 4) {
|
|
2248
|
+
return true;
|
|
2249
|
+
}
|
|
2226
2250
|
const signalValue = this.estimateSignalValue(signal, marketData);
|
|
2227
2251
|
const maxPositionValue = marketData.portfolioValue * this.config.maxPositionSizeBps / 1e4;
|
|
2228
2252
|
if (signalValue > maxPositionValue) {
|
|
@@ -2551,13 +2575,10 @@ var VAULT_ABI = [
|
|
|
2551
2575
|
];
|
|
2552
2576
|
var VaultManager = class {
|
|
2553
2577
|
config;
|
|
2554
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2555
2578
|
publicClient;
|
|
2556
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2557
2579
|
walletClient;
|
|
2558
2580
|
addresses;
|
|
2559
2581
|
account;
|
|
2560
|
-
chain;
|
|
2561
2582
|
cachedVaultAddress = null;
|
|
2562
2583
|
lastVaultCheck = 0;
|
|
2563
2584
|
VAULT_CACHE_TTL = 6e4;
|
|
@@ -2567,16 +2588,15 @@ var VaultManager = class {
|
|
|
2567
2588
|
this.config = config;
|
|
2568
2589
|
this.addresses = ADDRESSES[config.network];
|
|
2569
2590
|
this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
|
|
2570
|
-
this.chain = import_chains2.base;
|
|
2571
2591
|
const rpcUrl = getRpcUrl();
|
|
2572
2592
|
const transport = (0, import_viem3.http)(rpcUrl, { timeout: 6e4 });
|
|
2573
2593
|
this.publicClient = (0, import_viem3.createPublicClient)({
|
|
2574
|
-
chain:
|
|
2594
|
+
chain: import_chains2.base,
|
|
2575
2595
|
transport
|
|
2576
2596
|
});
|
|
2577
2597
|
this.walletClient = (0, import_viem3.createWalletClient)({
|
|
2578
2598
|
account: this.account,
|
|
2579
|
-
chain:
|
|
2599
|
+
chain: import_chains2.base,
|
|
2580
2600
|
transport
|
|
2581
2601
|
});
|
|
2582
2602
|
if (this.addresses.vaultFactory === "0x0000000000000000000000000000000000000000") {
|
|
@@ -2608,7 +2628,7 @@ var VaultManager = class {
|
|
|
2608
2628
|
canCreateVault: false,
|
|
2609
2629
|
cannotCreateReason: "Vault operations disabled (contract address not set)",
|
|
2610
2630
|
requirementsMet: false,
|
|
2611
|
-
requirements: {
|
|
2631
|
+
requirements: { isBypassed: false }
|
|
2612
2632
|
};
|
|
2613
2633
|
}
|
|
2614
2634
|
const vaultAddress = await this.getVaultAddress();
|
|
@@ -2645,16 +2665,10 @@ var VaultManager = class {
|
|
|
2645
2665
|
}
|
|
2646
2666
|
/**
|
|
2647
2667
|
* Get vault creation requirements
|
|
2648
|
-
* Note:
|
|
2668
|
+
* Note: StakingStub always returns hasVaultAccess=true — no gate.
|
|
2649
2669
|
*/
|
|
2650
2670
|
async getRequirements() {
|
|
2651
|
-
|
|
2652
|
-
address: this.addresses.vaultFactory,
|
|
2653
|
-
abi: VAULT_FACTORY_ABI,
|
|
2654
|
-
functionName: "minimumVeEXARequired"
|
|
2655
|
-
});
|
|
2656
|
-
const isBypassed = veXARequired === BigInt(0);
|
|
2657
|
-
return { veXARequired, isBypassed };
|
|
2671
|
+
return { isBypassed: true };
|
|
2658
2672
|
}
|
|
2659
2673
|
/**
|
|
2660
2674
|
* Get the agent's vault address (cached)
|
|
@@ -2715,7 +2729,7 @@ var VaultManager = class {
|
|
|
2715
2729
|
vaultSymbol,
|
|
2716
2730
|
feeRecipient
|
|
2717
2731
|
],
|
|
2718
|
-
chain:
|
|
2732
|
+
chain: import_chains2.base,
|
|
2719
2733
|
account: this.account
|
|
2720
2734
|
});
|
|
2721
2735
|
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
@@ -2763,7 +2777,7 @@ var VaultManager = class {
|
|
|
2763
2777
|
params.swapData,
|
|
2764
2778
|
deadline
|
|
2765
2779
|
],
|
|
2766
|
-
chain:
|
|
2780
|
+
chain: import_chains2.base,
|
|
2767
2781
|
account: this.account
|
|
2768
2782
|
});
|
|
2769
2783
|
return { usedVault: true, txHash: hash };
|
|
@@ -3660,11 +3674,8 @@ var ROUTER_ABI = [
|
|
|
3660
3674
|
var MAX_RETRIES = 3;
|
|
3661
3675
|
var RETRY_DELAY_MS = 5e3;
|
|
3662
3676
|
var PerpTradeRecorder = class {
|
|
3663
|
-
// Use `any` for viem client types to avoid L2 chain type conflicts (Base has "deposit" tx type)
|
|
3664
3677
|
publicClient;
|
|
3665
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
3666
3678
|
walletClient;
|
|
3667
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
3668
3679
|
account;
|
|
3669
3680
|
agentId;
|
|
3670
3681
|
configHash;
|
|
@@ -3995,6 +4006,14 @@ var PerpOnboarding = class {
|
|
|
3995
4006
|
var import_viem6 = require("viem");
|
|
3996
4007
|
var import_chains4 = require("viem/chains");
|
|
3997
4008
|
var import_accounts3 = require("viem/accounts");
|
|
4009
|
+
var hyperEVM = (0, import_viem6.defineChain)({
|
|
4010
|
+
id: 999,
|
|
4011
|
+
name: "HyperEVM",
|
|
4012
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
4013
|
+
rpcUrls: {
|
|
4014
|
+
default: { http: ["https://rpc.hyperliquid.xyz/evm"] }
|
|
4015
|
+
}
|
|
4016
|
+
});
|
|
3998
4017
|
var ERC20_ABI = (0, import_viem6.parseAbi)([
|
|
3999
4018
|
"function approve(address spender, uint256 amount) external returns (bool)",
|
|
4000
4019
|
"function balanceOf(address account) external view returns (uint256)",
|
|
@@ -4197,7 +4216,7 @@ function loadSecureEnv(basePath, passphrase) {
|
|
|
4197
4216
|
}
|
|
4198
4217
|
|
|
4199
4218
|
// src/index.ts
|
|
4200
|
-
var AGENT_VERSION = "0.1.
|
|
4219
|
+
var AGENT_VERSION = "0.1.38";
|
|
4201
4220
|
|
|
4202
4221
|
// src/relay.ts
|
|
4203
4222
|
var RelayClient = class {
|
|
@@ -4548,7 +4567,7 @@ var AgentRuntime = class {
|
|
|
4548
4567
|
};
|
|
4549
4568
|
this.positionTracker = new PositionTracker(store, { maxTradeHistory: 50 });
|
|
4550
4569
|
this.executor = new TradeExecutor(this.client, this.config, () => this.getConfigHash());
|
|
4551
|
-
this.riskManager = new RiskManager(this.config.trading);
|
|
4570
|
+
this.riskManager = new RiskManager(this.config.trading, this.riskUniverse);
|
|
4552
4571
|
this.marketData = new MarketDataService(this.getRpcUrl(), store);
|
|
4553
4572
|
setGlobalResolver(this.marketData.getResolver());
|
|
4554
4573
|
const savedRisk = this.positionTracker.getRiskState();
|
|
@@ -5078,7 +5097,7 @@ var AgentRuntime = class {
|
|
|
5078
5097
|
updated = true;
|
|
5079
5098
|
}
|
|
5080
5099
|
if (updated) {
|
|
5081
|
-
this.riskManager = new RiskManager(this.config.trading);
|
|
5100
|
+
this.riskManager = new RiskManager(this.config.trading, this.riskUniverse);
|
|
5082
5101
|
const savedRiskState = this.positionTracker.getRiskState();
|
|
5083
5102
|
if (savedRiskState.lastResetDate) {
|
|
5084
5103
|
this.riskManager.restoreState(savedRiskState);
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Address, Hash, PublicClient, WalletClient } from 'viem';
|
|
2
|
+
import { Address, Hash, PublicClient, HttpTransport, WalletClient } from 'viem';
|
|
3
3
|
import { ExagentClient } from '@exagent/sdk';
|
|
4
|
+
import { base } from 'viem/chains';
|
|
4
5
|
|
|
5
6
|
/** Risk state persisted across restarts */
|
|
6
7
|
interface RiskState {
|
|
@@ -339,9 +340,9 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
339
340
|
}>>;
|
|
340
341
|
allowedTokens: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
341
342
|
}, "strip", z.ZodTypeAny, {
|
|
342
|
-
agentId: string | number;
|
|
343
343
|
name: string;
|
|
344
344
|
network: "mainnet";
|
|
345
|
+
agentId: string | number;
|
|
345
346
|
llm: {
|
|
346
347
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
347
348
|
temperature: number;
|
|
@@ -388,8 +389,8 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
388
389
|
} | undefined;
|
|
389
390
|
allowedTokens?: string[] | undefined;
|
|
390
391
|
}, {
|
|
391
|
-
agentId: string | number;
|
|
392
392
|
name: string;
|
|
393
|
+
agentId: string | number;
|
|
393
394
|
llm: {
|
|
394
395
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
395
396
|
model?: string | undefined;
|
|
@@ -596,7 +597,6 @@ interface VaultStatus {
|
|
|
596
597
|
cannotCreateReason: string | null;
|
|
597
598
|
requirementsMet: boolean;
|
|
598
599
|
requirements: {
|
|
599
|
-
veXARequired: bigint;
|
|
600
600
|
isBypassed: boolean;
|
|
601
601
|
};
|
|
602
602
|
}
|
|
@@ -616,7 +616,6 @@ declare class VaultManager {
|
|
|
616
616
|
private readonly walletClient;
|
|
617
617
|
private readonly addresses;
|
|
618
618
|
private readonly account;
|
|
619
|
-
private readonly chain;
|
|
620
619
|
private cachedVaultAddress;
|
|
621
620
|
private lastVaultCheck;
|
|
622
621
|
private readonly VAULT_CACHE_TTL;
|
|
@@ -636,10 +635,9 @@ declare class VaultManager {
|
|
|
636
635
|
getVaultStatus(): Promise<VaultStatus>;
|
|
637
636
|
/**
|
|
638
637
|
* Get vault creation requirements
|
|
639
|
-
* Note:
|
|
638
|
+
* Note: StakingStub always returns hasVaultAccess=true — no gate.
|
|
640
639
|
*/
|
|
641
640
|
getRequirements(): Promise<{
|
|
642
|
-
veXARequired: bigint;
|
|
643
641
|
isBypassed: boolean;
|
|
644
642
|
}>;
|
|
645
643
|
/**
|
|
@@ -1340,7 +1338,9 @@ declare class RiskManager {
|
|
|
1340
1338
|
private lastResetDate;
|
|
1341
1339
|
/** Minimum trade value in USD — trades below this are rejected as dust */
|
|
1342
1340
|
private minTradeValueUSD;
|
|
1343
|
-
|
|
1341
|
+
/** Risk universe (0-4). Frontier (4) bypasses buy-only guardrails. */
|
|
1342
|
+
private riskUniverse;
|
|
1343
|
+
constructor(config: TradingConfig, riskUniverse?: number);
|
|
1344
1344
|
/**
|
|
1345
1345
|
* Filter signals through risk checks
|
|
1346
1346
|
* Returns only signals that pass all guardrails
|
|
@@ -1446,7 +1446,7 @@ declare class TokenResolver {
|
|
|
1446
1446
|
private store;
|
|
1447
1447
|
private cache;
|
|
1448
1448
|
private unresolvable;
|
|
1449
|
-
constructor(client:
|
|
1449
|
+
constructor(client: BasePublicClient, store?: StrategyStore);
|
|
1450
1450
|
/**
|
|
1451
1451
|
* Get decimals for a token (synchronous).
|
|
1452
1452
|
* Returns undefined if the token has never been resolved and is not hardcoded.
|
|
@@ -1495,6 +1495,18 @@ declare class TokenResolver {
|
|
|
1495
1495
|
private persistUnresolvable;
|
|
1496
1496
|
}
|
|
1497
1497
|
|
|
1498
|
+
/**
|
|
1499
|
+
* Properly typed viem client for Base chain.
|
|
1500
|
+
*
|
|
1501
|
+
* viem's `createPublicClient({ chain: base })` returns a chain-specific type
|
|
1502
|
+
* that includes OP Stack deposit transaction serializers. The generic
|
|
1503
|
+
* `PublicClient` type (= `PublicClient<Transport, Chain | undefined>`) is
|
|
1504
|
+
* invariant in its chain parameter, so the return value is NOT assignable to
|
|
1505
|
+
* it without a cast. Using the exact parameterized type avoids the cast and
|
|
1506
|
+
* keeps full type safety.
|
|
1507
|
+
*/
|
|
1508
|
+
type BasePublicClient = PublicClient<HttpTransport, typeof base>;
|
|
1509
|
+
|
|
1498
1510
|
/**
|
|
1499
1511
|
* Market Data Service
|
|
1500
1512
|
* Fetches real prices from CoinGecko and on-chain balances for strategy analysis.
|
|
@@ -2191,6 +2203,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
|
|
|
2191
2203
|
declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
|
|
2192
2204
|
|
|
2193
2205
|
/** @exagent/agent package version — update alongside package.json */
|
|
2194
|
-
declare const AGENT_VERSION = "0.1.
|
|
2206
|
+
declare const AGENT_VERSION = "0.1.38";
|
|
2195
2207
|
|
|
2196
2208
|
export { AGENT_VERSION, type AccountSummary, type AgentConfig, AgentConfigSchema, type AgentMode, AgentRuntime, type AgentStatusPayload, AnthropicAdapter, BaseLLMAdapter, type CommandType, DeepSeekAdapter, FileStore, type FillCallback, type FundingCallback, type FundingPayment, GoogleAdapter, GroqAdapter, HYPERLIQUID_DOMAIN, HyperliquidClient, HyperliquidSigner, HyperliquidWebSocket, type LLMAdapter, type LLMConfig, LLMConfigSchema, type LLMMessage, type LLMMetadata, type LLMProvider, LLMProviderSchema, type LLMResponse, type LiquidationCallback, type MarketData, MarketDataService, type MessageLevel, type MessageType, MistralAdapter, OllamaAdapter, type OnboardingStatus, OpenAIAdapter, OrderManager, type OrderResult, type PerpAction, type PerpConfig$1 as PerpConfig, PerpConfigSchema, type PerpFill, type PerpMarketData, PerpOnboarding, type PerpPosition, type PerpStrategyFunction, PerpTradeRecorder, type PerpTradeSignal, type PerpConfig as PerpTradingConfig, PositionManager, type PositionSummary, PositionTracker, type RecordPerpTradeParams, RelayClient, type RelayCommand, type RelayConfig$1 as RelayConfig, RelayConfigSchema, RiskManager, type RiskState, type RiskUniverse, RiskUniverseSchema, type RuntimeConfig, STRATEGY_TEMPLATES, type StrategyContext, type StrategyFunction, type StrategyStore, type StrategyTemplate, TogetherAdapter, type TrackedPosition, TradeExecutor, type TradeRecord, type TradeSignal, type TradingConfig, TradingConfigSchema, type VaultConfig, VaultConfigSchema, VaultManager, type VaultManagerConfig, type VaultPolicy, VaultPolicySchema, type VaultStatus, createLLMAdapter, createSampleConfig, decryptEnvFile, encryptEnvFile, fillHashToBytes32, fillOidToBytes32, getAllStrategyTemplates, getNextNonce, getStrategyTemplate, loadConfig, loadSecureEnv, loadStrategy, validateConfig, validateStrategy };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Address, Hash, PublicClient, WalletClient } from 'viem';
|
|
2
|
+
import { Address, Hash, PublicClient, HttpTransport, WalletClient } from 'viem';
|
|
3
3
|
import { ExagentClient } from '@exagent/sdk';
|
|
4
|
+
import { base } from 'viem/chains';
|
|
4
5
|
|
|
5
6
|
/** Risk state persisted across restarts */
|
|
6
7
|
interface RiskState {
|
|
@@ -339,9 +340,9 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
339
340
|
}>>;
|
|
340
341
|
allowedTokens: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
341
342
|
}, "strip", z.ZodTypeAny, {
|
|
342
|
-
agentId: string | number;
|
|
343
343
|
name: string;
|
|
344
344
|
network: "mainnet";
|
|
345
|
+
agentId: string | number;
|
|
345
346
|
llm: {
|
|
346
347
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
347
348
|
temperature: number;
|
|
@@ -388,8 +389,8 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
388
389
|
} | undefined;
|
|
389
390
|
allowedTokens?: string[] | undefined;
|
|
390
391
|
}, {
|
|
391
|
-
agentId: string | number;
|
|
392
392
|
name: string;
|
|
393
|
+
agentId: string | number;
|
|
393
394
|
llm: {
|
|
394
395
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
395
396
|
model?: string | undefined;
|
|
@@ -596,7 +597,6 @@ interface VaultStatus {
|
|
|
596
597
|
cannotCreateReason: string | null;
|
|
597
598
|
requirementsMet: boolean;
|
|
598
599
|
requirements: {
|
|
599
|
-
veXARequired: bigint;
|
|
600
600
|
isBypassed: boolean;
|
|
601
601
|
};
|
|
602
602
|
}
|
|
@@ -616,7 +616,6 @@ declare class VaultManager {
|
|
|
616
616
|
private readonly walletClient;
|
|
617
617
|
private readonly addresses;
|
|
618
618
|
private readonly account;
|
|
619
|
-
private readonly chain;
|
|
620
619
|
private cachedVaultAddress;
|
|
621
620
|
private lastVaultCheck;
|
|
622
621
|
private readonly VAULT_CACHE_TTL;
|
|
@@ -636,10 +635,9 @@ declare class VaultManager {
|
|
|
636
635
|
getVaultStatus(): Promise<VaultStatus>;
|
|
637
636
|
/**
|
|
638
637
|
* Get vault creation requirements
|
|
639
|
-
* Note:
|
|
638
|
+
* Note: StakingStub always returns hasVaultAccess=true — no gate.
|
|
640
639
|
*/
|
|
641
640
|
getRequirements(): Promise<{
|
|
642
|
-
veXARequired: bigint;
|
|
643
641
|
isBypassed: boolean;
|
|
644
642
|
}>;
|
|
645
643
|
/**
|
|
@@ -1340,7 +1338,9 @@ declare class RiskManager {
|
|
|
1340
1338
|
private lastResetDate;
|
|
1341
1339
|
/** Minimum trade value in USD — trades below this are rejected as dust */
|
|
1342
1340
|
private minTradeValueUSD;
|
|
1343
|
-
|
|
1341
|
+
/** Risk universe (0-4). Frontier (4) bypasses buy-only guardrails. */
|
|
1342
|
+
private riskUniverse;
|
|
1343
|
+
constructor(config: TradingConfig, riskUniverse?: number);
|
|
1344
1344
|
/**
|
|
1345
1345
|
* Filter signals through risk checks
|
|
1346
1346
|
* Returns only signals that pass all guardrails
|
|
@@ -1446,7 +1446,7 @@ declare class TokenResolver {
|
|
|
1446
1446
|
private store;
|
|
1447
1447
|
private cache;
|
|
1448
1448
|
private unresolvable;
|
|
1449
|
-
constructor(client:
|
|
1449
|
+
constructor(client: BasePublicClient, store?: StrategyStore);
|
|
1450
1450
|
/**
|
|
1451
1451
|
* Get decimals for a token (synchronous).
|
|
1452
1452
|
* Returns undefined if the token has never been resolved and is not hardcoded.
|
|
@@ -1495,6 +1495,18 @@ declare class TokenResolver {
|
|
|
1495
1495
|
private persistUnresolvable;
|
|
1496
1496
|
}
|
|
1497
1497
|
|
|
1498
|
+
/**
|
|
1499
|
+
* Properly typed viem client for Base chain.
|
|
1500
|
+
*
|
|
1501
|
+
* viem's `createPublicClient({ chain: base })` returns a chain-specific type
|
|
1502
|
+
* that includes OP Stack deposit transaction serializers. The generic
|
|
1503
|
+
* `PublicClient` type (= `PublicClient<Transport, Chain | undefined>`) is
|
|
1504
|
+
* invariant in its chain parameter, so the return value is NOT assignable to
|
|
1505
|
+
* it without a cast. Using the exact parameterized type avoids the cast and
|
|
1506
|
+
* keeps full type safety.
|
|
1507
|
+
*/
|
|
1508
|
+
type BasePublicClient = PublicClient<HttpTransport, typeof base>;
|
|
1509
|
+
|
|
1498
1510
|
/**
|
|
1499
1511
|
* Market Data Service
|
|
1500
1512
|
* Fetches real prices from CoinGecko and on-chain balances for strategy analysis.
|
|
@@ -2191,6 +2203,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
|
|
|
2191
2203
|
declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
|
|
2192
2204
|
|
|
2193
2205
|
/** @exagent/agent package version — update alongside package.json */
|
|
2194
|
-
declare const AGENT_VERSION = "0.1.
|
|
2206
|
+
declare const AGENT_VERSION = "0.1.38";
|
|
2195
2207
|
|
|
2196
2208
|
export { AGENT_VERSION, type AccountSummary, type AgentConfig, AgentConfigSchema, type AgentMode, AgentRuntime, type AgentStatusPayload, AnthropicAdapter, BaseLLMAdapter, type CommandType, DeepSeekAdapter, FileStore, type FillCallback, type FundingCallback, type FundingPayment, GoogleAdapter, GroqAdapter, HYPERLIQUID_DOMAIN, HyperliquidClient, HyperliquidSigner, HyperliquidWebSocket, type LLMAdapter, type LLMConfig, LLMConfigSchema, type LLMMessage, type LLMMetadata, type LLMProvider, LLMProviderSchema, type LLMResponse, type LiquidationCallback, type MarketData, MarketDataService, type MessageLevel, type MessageType, MistralAdapter, OllamaAdapter, type OnboardingStatus, OpenAIAdapter, OrderManager, type OrderResult, type PerpAction, type PerpConfig$1 as PerpConfig, PerpConfigSchema, type PerpFill, type PerpMarketData, PerpOnboarding, type PerpPosition, type PerpStrategyFunction, PerpTradeRecorder, type PerpTradeSignal, type PerpConfig as PerpTradingConfig, PositionManager, type PositionSummary, PositionTracker, type RecordPerpTradeParams, RelayClient, type RelayCommand, type RelayConfig$1 as RelayConfig, RelayConfigSchema, RiskManager, type RiskState, type RiskUniverse, RiskUniverseSchema, type RuntimeConfig, STRATEGY_TEMPLATES, type StrategyContext, type StrategyFunction, type StrategyStore, type StrategyTemplate, TogetherAdapter, type TrackedPosition, TradeExecutor, type TradeRecord, type TradeSignal, type TradingConfig, TradingConfigSchema, type VaultConfig, VaultConfigSchema, VaultManager, type VaultManagerConfig, type VaultPolicy, VaultPolicySchema, type VaultStatus, createLLMAdapter, createSampleConfig, decryptEnvFile, encryptEnvFile, fillHashToBytes32, fillOidToBytes32, getAllStrategyTemplates, getNextNonce, getStrategyTemplate, loadConfig, loadSecureEnv, loadStrategy, validateConfig, validateStrategy };
|
package/dist/index.js
CHANGED
|
@@ -2248,6 +2248,24 @@ function classifyTradeError(message) {
|
|
|
2248
2248
|
userMessage: "DEX aggregator not whitelisted on the router. Contact support."
|
|
2249
2249
|
};
|
|
2250
2250
|
}
|
|
2251
|
+
if (lower.includes("token approval reverted")) {
|
|
2252
|
+
return {
|
|
2253
|
+
category: "approval_failed",
|
|
2254
|
+
userMessage: "Token approval failed \u2014 this token may have non-standard approval behavior or be blocked. Skipping."
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
if (lower.includes("exceeds allowance") || lower.includes("allowance")) {
|
|
2258
|
+
return {
|
|
2259
|
+
category: "allowance",
|
|
2260
|
+
userMessage: "Token allowance insufficient \u2014 approval may not have propagated. Will retry next cycle."
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
if (lower.includes("swapfailed")) {
|
|
2264
|
+
return {
|
|
2265
|
+
category: "swap_failed",
|
|
2266
|
+
userMessage: "DEX swap failed \u2014 likely insufficient liquidity for this token. Will retry next cycle."
|
|
2267
|
+
};
|
|
2268
|
+
}
|
|
2251
2269
|
if (lower.includes("reverted") || lower.includes("execution reverted")) {
|
|
2252
2270
|
return {
|
|
2253
2271
|
category: "reverted",
|
|
@@ -2274,8 +2292,11 @@ var RiskManager = class {
|
|
|
2274
2292
|
lastResetDate = "";
|
|
2275
2293
|
/** Minimum trade value in USD — trades below this are rejected as dust */
|
|
2276
2294
|
minTradeValueUSD;
|
|
2277
|
-
|
|
2295
|
+
/** Risk universe (0-4). Frontier (4) bypasses buy-only guardrails. */
|
|
2296
|
+
riskUniverse;
|
|
2297
|
+
constructor(config, riskUniverse = 0) {
|
|
2278
2298
|
this.config = config;
|
|
2299
|
+
this.riskUniverse = riskUniverse;
|
|
2279
2300
|
this.minTradeValueUSD = config.minTradeValueUSD ?? 1;
|
|
2280
2301
|
}
|
|
2281
2302
|
/**
|
|
@@ -2311,6 +2332,9 @@ var RiskManager = class {
|
|
|
2311
2332
|
if (signal.action === "sell") {
|
|
2312
2333
|
return true;
|
|
2313
2334
|
}
|
|
2335
|
+
if (this.riskUniverse === 4) {
|
|
2336
|
+
return true;
|
|
2337
|
+
}
|
|
2314
2338
|
const signalValue = this.estimateSignalValue(signal, marketData);
|
|
2315
2339
|
const maxPositionValue = marketData.portfolioValue * this.config.maxPositionSizeBps / 1e4;
|
|
2316
2340
|
if (signalValue > maxPositionValue) {
|
|
@@ -2639,13 +2663,10 @@ var VAULT_ABI = [
|
|
|
2639
2663
|
];
|
|
2640
2664
|
var VaultManager = class {
|
|
2641
2665
|
config;
|
|
2642
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2643
2666
|
publicClient;
|
|
2644
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2645
2667
|
walletClient;
|
|
2646
2668
|
addresses;
|
|
2647
2669
|
account;
|
|
2648
|
-
chain;
|
|
2649
2670
|
cachedVaultAddress = null;
|
|
2650
2671
|
lastVaultCheck = 0;
|
|
2651
2672
|
VAULT_CACHE_TTL = 6e4;
|
|
@@ -2655,16 +2676,15 @@ var VaultManager = class {
|
|
|
2655
2676
|
this.config = config;
|
|
2656
2677
|
this.addresses = ADDRESSES[config.network];
|
|
2657
2678
|
this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
|
|
2658
|
-
this.chain = import_chains2.base;
|
|
2659
2679
|
const rpcUrl = getRpcUrl();
|
|
2660
2680
|
const transport = (0, import_viem3.http)(rpcUrl, { timeout: 6e4 });
|
|
2661
2681
|
this.publicClient = (0, import_viem3.createPublicClient)({
|
|
2662
|
-
chain:
|
|
2682
|
+
chain: import_chains2.base,
|
|
2663
2683
|
transport
|
|
2664
2684
|
});
|
|
2665
2685
|
this.walletClient = (0, import_viem3.createWalletClient)({
|
|
2666
2686
|
account: this.account,
|
|
2667
|
-
chain:
|
|
2687
|
+
chain: import_chains2.base,
|
|
2668
2688
|
transport
|
|
2669
2689
|
});
|
|
2670
2690
|
if (this.addresses.vaultFactory === "0x0000000000000000000000000000000000000000") {
|
|
@@ -2696,7 +2716,7 @@ var VaultManager = class {
|
|
|
2696
2716
|
canCreateVault: false,
|
|
2697
2717
|
cannotCreateReason: "Vault operations disabled (contract address not set)",
|
|
2698
2718
|
requirementsMet: false,
|
|
2699
|
-
requirements: {
|
|
2719
|
+
requirements: { isBypassed: false }
|
|
2700
2720
|
};
|
|
2701
2721
|
}
|
|
2702
2722
|
const vaultAddress = await this.getVaultAddress();
|
|
@@ -2733,16 +2753,10 @@ var VaultManager = class {
|
|
|
2733
2753
|
}
|
|
2734
2754
|
/**
|
|
2735
2755
|
* Get vault creation requirements
|
|
2736
|
-
* Note:
|
|
2756
|
+
* Note: StakingStub always returns hasVaultAccess=true — no gate.
|
|
2737
2757
|
*/
|
|
2738
2758
|
async getRequirements() {
|
|
2739
|
-
|
|
2740
|
-
address: this.addresses.vaultFactory,
|
|
2741
|
-
abi: VAULT_FACTORY_ABI,
|
|
2742
|
-
functionName: "minimumVeEXARequired"
|
|
2743
|
-
});
|
|
2744
|
-
const isBypassed = veXARequired === BigInt(0);
|
|
2745
|
-
return { veXARequired, isBypassed };
|
|
2759
|
+
return { isBypassed: true };
|
|
2746
2760
|
}
|
|
2747
2761
|
/**
|
|
2748
2762
|
* Get the agent's vault address (cached)
|
|
@@ -2803,7 +2817,7 @@ var VaultManager = class {
|
|
|
2803
2817
|
vaultSymbol,
|
|
2804
2818
|
feeRecipient
|
|
2805
2819
|
],
|
|
2806
|
-
chain:
|
|
2820
|
+
chain: import_chains2.base,
|
|
2807
2821
|
account: this.account
|
|
2808
2822
|
});
|
|
2809
2823
|
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
@@ -2851,7 +2865,7 @@ var VaultManager = class {
|
|
|
2851
2865
|
params.swapData,
|
|
2852
2866
|
deadline
|
|
2853
2867
|
],
|
|
2854
|
-
chain:
|
|
2868
|
+
chain: import_chains2.base,
|
|
2855
2869
|
account: this.account
|
|
2856
2870
|
});
|
|
2857
2871
|
return { usedVault: true, txHash: hash };
|
|
@@ -4013,11 +4027,8 @@ var ROUTER_ABI = [
|
|
|
4013
4027
|
var MAX_RETRIES = 3;
|
|
4014
4028
|
var RETRY_DELAY_MS = 5e3;
|
|
4015
4029
|
var PerpTradeRecorder = class {
|
|
4016
|
-
// Use `any` for viem client types to avoid L2 chain type conflicts (Base has "deposit" tx type)
|
|
4017
4030
|
publicClient;
|
|
4018
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4019
4031
|
walletClient;
|
|
4020
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4021
4032
|
account;
|
|
4022
4033
|
agentId;
|
|
4023
4034
|
configHash;
|
|
@@ -4348,6 +4359,14 @@ var PerpOnboarding = class {
|
|
|
4348
4359
|
var import_viem6 = require("viem");
|
|
4349
4360
|
var import_chains4 = require("viem/chains");
|
|
4350
4361
|
var import_accounts4 = require("viem/accounts");
|
|
4362
|
+
var hyperEVM = (0, import_viem6.defineChain)({
|
|
4363
|
+
id: 999,
|
|
4364
|
+
name: "HyperEVM",
|
|
4365
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
4366
|
+
rpcUrls: {
|
|
4367
|
+
default: { http: ["https://rpc.hyperliquid.xyz/evm"] }
|
|
4368
|
+
}
|
|
4369
|
+
});
|
|
4351
4370
|
var ERC20_ABI = (0, import_viem6.parseAbi)([
|
|
4352
4371
|
"function approve(address spender, uint256 amount) external returns (bool)",
|
|
4353
4372
|
"function balanceOf(address account) external view returns (uint256)",
|
|
@@ -4450,7 +4469,7 @@ var AgentRuntime = class {
|
|
|
4450
4469
|
};
|
|
4451
4470
|
this.positionTracker = new PositionTracker(store, { maxTradeHistory: 50 });
|
|
4452
4471
|
this.executor = new TradeExecutor(this.client, this.config, () => this.getConfigHash());
|
|
4453
|
-
this.riskManager = new RiskManager(this.config.trading);
|
|
4472
|
+
this.riskManager = new RiskManager(this.config.trading, this.riskUniverse);
|
|
4454
4473
|
this.marketData = new MarketDataService(this.getRpcUrl(), store);
|
|
4455
4474
|
setGlobalResolver(this.marketData.getResolver());
|
|
4456
4475
|
const savedRisk = this.positionTracker.getRiskState();
|
|
@@ -4980,7 +4999,7 @@ var AgentRuntime = class {
|
|
|
4980
4999
|
updated = true;
|
|
4981
5000
|
}
|
|
4982
5001
|
if (updated) {
|
|
4983
|
-
this.riskManager = new RiskManager(this.config.trading);
|
|
5002
|
+
this.riskManager = new RiskManager(this.config.trading, this.riskUniverse);
|
|
4984
5003
|
const savedRiskState = this.positionTracker.getRiskState();
|
|
4985
5004
|
if (savedRiskState.lastResetDate) {
|
|
4986
5005
|
this.riskManager.restoreState(savedRiskState);
|
|
@@ -5883,7 +5902,7 @@ function loadSecureEnv(basePath, passphrase) {
|
|
|
5883
5902
|
}
|
|
5884
5903
|
|
|
5885
5904
|
// src/index.ts
|
|
5886
|
-
var AGENT_VERSION = "0.1.
|
|
5905
|
+
var AGENT_VERSION = "0.1.38";
|
|
5887
5906
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5888
5907
|
0 && (module.exports = {
|
|
5889
5908
|
AGENT_VERSION,
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exagent/agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "Autonomous trading agent runtime for Exagent",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"clean": "rm -rf dist"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@exagent/sdk": "^0.1.
|
|
32
|
+
"@exagent/sdk": "^0.1.16",
|
|
33
33
|
"@nktkas/hyperliquid": "^0.31.0",
|
|
34
34
|
"chalk": "^5.3.0",
|
|
35
35
|
"commander": "^12.0.0",
|