@exagent/agent 0.1.35 → 0.1.37
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-FAFMOHYQ.mjs +5873 -0
- package/dist/chunk-H7HKHVR7.mjs +5873 -0
- package/dist/chunk-O76YFRK5.mjs +5873 -0
- package/dist/chunk-TDG46HJJ.mjs +5871 -0
- package/dist/cli.js +27 -24
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +18 -6
- package/dist/index.d.ts +18 -6
- package/dist/index.js +27 -24
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -33,11 +33,12 @@ var path2 = __toESM(require("path"));
|
|
|
33
33
|
// src/runtime.ts
|
|
34
34
|
var import_sdk = require("@exagent/sdk");
|
|
35
35
|
var import_viem7 = require("viem");
|
|
36
|
-
var
|
|
36
|
+
var import_chains5 = require("viem/chains");
|
|
37
37
|
var import_accounts5 = require("viem/accounts");
|
|
38
38
|
|
|
39
39
|
// src/trading/market.ts
|
|
40
40
|
var import_viem2 = require("viem");
|
|
41
|
+
var import_chains = require("viem/chains");
|
|
41
42
|
|
|
42
43
|
// src/trading/token-resolver.ts
|
|
43
44
|
var import_viem = require("viem");
|
|
@@ -508,6 +509,7 @@ var MarketDataService = class {
|
|
|
508
509
|
constructor(rpcUrl, store) {
|
|
509
510
|
this.rpcUrl = rpcUrl;
|
|
510
511
|
this.client = (0, import_viem2.createPublicClient)({
|
|
512
|
+
chain: import_chains.base,
|
|
511
513
|
transport: (0, import_viem2.http)(rpcUrl, { timeout: 6e4 })
|
|
512
514
|
});
|
|
513
515
|
this.resolver = new TokenResolver(this.client, store);
|
|
@@ -705,7 +707,7 @@ var MarketDataService = class {
|
|
|
705
707
|
try {
|
|
706
708
|
const results = await this.client.multicall({
|
|
707
709
|
contracts: batch.map((addr) => ({
|
|
708
|
-
address: addr,
|
|
710
|
+
address: addr.toLowerCase(),
|
|
709
711
|
abi: import_viem2.erc20Abi,
|
|
710
712
|
functionName: "balanceOf",
|
|
711
713
|
args: [wallet]
|
|
@@ -745,7 +747,7 @@ var MarketDataService = class {
|
|
|
745
747
|
const promises = tokenAddresses.map(async (tokenAddress) => {
|
|
746
748
|
try {
|
|
747
749
|
const balance = await this.client.readContract({
|
|
748
|
-
address: tokenAddress,
|
|
750
|
+
address: tokenAddress.toLowerCase(),
|
|
749
751
|
abi: import_viem2.erc20Abi,
|
|
750
752
|
functionName: "balanceOf",
|
|
751
753
|
args: [wallet]
|
|
@@ -2478,7 +2480,7 @@ var FileStore = class {
|
|
|
2478
2480
|
// src/vault/manager.ts
|
|
2479
2481
|
var import_viem3 = require("viem");
|
|
2480
2482
|
var import_accounts = require("viem/accounts");
|
|
2481
|
-
var
|
|
2483
|
+
var import_chains2 = require("viem/chains");
|
|
2482
2484
|
var ADDRESSES = {
|
|
2483
2485
|
mainnet: {
|
|
2484
2486
|
vaultFactory: process.env.EXAGENT_VAULT_FACTORY_ADDRESS || "0x0000000000000000000000000000000000000000",
|
|
@@ -2549,13 +2551,10 @@ var VAULT_ABI = [
|
|
|
2549
2551
|
];
|
|
2550
2552
|
var VaultManager = class {
|
|
2551
2553
|
config;
|
|
2552
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2553
2554
|
publicClient;
|
|
2554
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2555
2555
|
walletClient;
|
|
2556
2556
|
addresses;
|
|
2557
2557
|
account;
|
|
2558
|
-
chain;
|
|
2559
2558
|
cachedVaultAddress = null;
|
|
2560
2559
|
lastVaultCheck = 0;
|
|
2561
2560
|
VAULT_CACHE_TTL = 6e4;
|
|
@@ -2565,16 +2564,15 @@ var VaultManager = class {
|
|
|
2565
2564
|
this.config = config;
|
|
2566
2565
|
this.addresses = ADDRESSES[config.network];
|
|
2567
2566
|
this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
|
|
2568
|
-
this.chain = import_chains.base;
|
|
2569
2567
|
const rpcUrl = getRpcUrl();
|
|
2570
2568
|
const transport = (0, import_viem3.http)(rpcUrl, { timeout: 6e4 });
|
|
2571
2569
|
this.publicClient = (0, import_viem3.createPublicClient)({
|
|
2572
|
-
chain:
|
|
2570
|
+
chain: import_chains2.base,
|
|
2573
2571
|
transport
|
|
2574
2572
|
});
|
|
2575
2573
|
this.walletClient = (0, import_viem3.createWalletClient)({
|
|
2576
2574
|
account: this.account,
|
|
2577
|
-
chain:
|
|
2575
|
+
chain: import_chains2.base,
|
|
2578
2576
|
transport
|
|
2579
2577
|
});
|
|
2580
2578
|
if (this.addresses.vaultFactory === "0x0000000000000000000000000000000000000000") {
|
|
@@ -2713,7 +2711,7 @@ var VaultManager = class {
|
|
|
2713
2711
|
vaultSymbol,
|
|
2714
2712
|
feeRecipient
|
|
2715
2713
|
],
|
|
2716
|
-
chain:
|
|
2714
|
+
chain: import_chains2.base,
|
|
2717
2715
|
account: this.account
|
|
2718
2716
|
});
|
|
2719
2717
|
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
@@ -2761,7 +2759,7 @@ var VaultManager = class {
|
|
|
2761
2759
|
params.swapData,
|
|
2762
2760
|
deadline
|
|
2763
2761
|
],
|
|
2764
|
-
chain:
|
|
2762
|
+
chain: import_chains2.base,
|
|
2765
2763
|
account: this.account
|
|
2766
2764
|
});
|
|
2767
2765
|
return { usedVault: true, txHash: hash };
|
|
@@ -3635,7 +3633,7 @@ var HyperliquidWebSocket = class {
|
|
|
3635
3633
|
|
|
3636
3634
|
// src/perp/recorder.ts
|
|
3637
3635
|
var import_viem5 = require("viem");
|
|
3638
|
-
var
|
|
3636
|
+
var import_chains3 = require("viem/chains");
|
|
3639
3637
|
var import_accounts2 = require("viem/accounts");
|
|
3640
3638
|
var ROUTER_ADDRESS = "0x1BCFa13f677fDCf697D8b7d5120f544817F1de1A";
|
|
3641
3639
|
var ROUTER_ABI = [
|
|
@@ -3658,11 +3656,8 @@ var ROUTER_ABI = [
|
|
|
3658
3656
|
var MAX_RETRIES = 3;
|
|
3659
3657
|
var RETRY_DELAY_MS = 5e3;
|
|
3660
3658
|
var PerpTradeRecorder = class {
|
|
3661
|
-
// Use `any` for viem client types to avoid L2 chain type conflicts (Base has "deposit" tx type)
|
|
3662
3659
|
publicClient;
|
|
3663
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
3664
3660
|
walletClient;
|
|
3665
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
3666
3661
|
account;
|
|
3667
3662
|
agentId;
|
|
3668
3663
|
configHash;
|
|
@@ -3679,11 +3674,11 @@ var PerpTradeRecorder = class {
|
|
|
3679
3674
|
const rpcUrl = opts.rpcUrl || "https://mainnet.base.org";
|
|
3680
3675
|
const transport = (0, import_viem5.http)(rpcUrl, { timeout: 6e4 });
|
|
3681
3676
|
this.publicClient = (0, import_viem5.createPublicClient)({
|
|
3682
|
-
chain:
|
|
3677
|
+
chain: import_chains3.base,
|
|
3683
3678
|
transport
|
|
3684
3679
|
});
|
|
3685
3680
|
this.walletClient = (0, import_viem5.createWalletClient)({
|
|
3686
|
-
chain:
|
|
3681
|
+
chain: import_chains3.base,
|
|
3687
3682
|
transport,
|
|
3688
3683
|
account: this.account
|
|
3689
3684
|
});
|
|
@@ -3991,8 +3986,16 @@ var PerpOnboarding = class {
|
|
|
3991
3986
|
|
|
3992
3987
|
// src/perp/funding.ts
|
|
3993
3988
|
var import_viem6 = require("viem");
|
|
3994
|
-
var
|
|
3989
|
+
var import_chains4 = require("viem/chains");
|
|
3995
3990
|
var import_accounts3 = require("viem/accounts");
|
|
3991
|
+
var hyperEVM = (0, import_viem6.defineChain)({
|
|
3992
|
+
id: 999,
|
|
3993
|
+
name: "HyperEVM",
|
|
3994
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
3995
|
+
rpcUrls: {
|
|
3996
|
+
default: { http: ["https://rpc.hyperliquid.xyz/evm"] }
|
|
3997
|
+
}
|
|
3998
|
+
});
|
|
3996
3999
|
var ERC20_ABI = (0, import_viem6.parseAbi)([
|
|
3997
4000
|
"function approve(address spender, uint256 amount) external returns (bool)",
|
|
3998
4001
|
"function balanceOf(address account) external view returns (uint256)",
|
|
@@ -4195,7 +4198,7 @@ function loadSecureEnv(basePath, passphrase) {
|
|
|
4195
4198
|
}
|
|
4196
4199
|
|
|
4197
4200
|
// src/index.ts
|
|
4198
|
-
var AGENT_VERSION = "0.1.
|
|
4201
|
+
var AGENT_VERSION = "0.1.37";
|
|
4199
4202
|
|
|
4200
4203
|
// src/relay.ts
|
|
4201
4204
|
var RelayClient = class {
|
|
@@ -4888,7 +4891,7 @@ var AgentRuntime = class {
|
|
|
4888
4891
|
if (message.includes("insufficient funds") || message.includes("intrinsic gas too low") || message.includes("exceeds the balance")) {
|
|
4889
4892
|
const ccUrl = `https://exagent.io/agents/${encodeURIComponent(this.config.name)}/command-center`;
|
|
4890
4893
|
const publicClientInstance = (0, import_viem7.createPublicClient)({
|
|
4891
|
-
chain:
|
|
4894
|
+
chain: import_chains5.base,
|
|
4892
4895
|
transport: (0, import_viem7.http)(this.getRpcUrl(), { timeout: 6e4 })
|
|
4893
4896
|
});
|
|
4894
4897
|
console.log("");
|
|
@@ -5618,8 +5621,8 @@ var AgentRuntime = class {
|
|
|
5618
5621
|
* for Frontier agents trading outside the whitelist) stay visible.
|
|
5619
5622
|
*/
|
|
5620
5623
|
getTokensToTrack() {
|
|
5621
|
-
const
|
|
5622
|
-
const baseSet = new Set(
|
|
5624
|
+
const base6 = this.config.allowedTokens || this.getDefaultTokens();
|
|
5625
|
+
const baseSet = new Set(base6.map((t) => t.toLowerCase()));
|
|
5623
5626
|
const trackedPositions = this.positionTracker.getPositions();
|
|
5624
5627
|
const extras = [];
|
|
5625
5628
|
for (const pos of trackedPositions) {
|
|
@@ -5642,7 +5645,7 @@ var AgentRuntime = class {
|
|
|
5642
5645
|
console.log(`Auto-tracking ${extras.length} additional token(s) from position history`);
|
|
5643
5646
|
}
|
|
5644
5647
|
const resolver = this.marketData.getResolver();
|
|
5645
|
-
const allTokens = [...
|
|
5648
|
+
const allTokens = [...base6, ...extras];
|
|
5646
5649
|
const filtered = allTokens.filter((t) => !resolver.isUnresolvable(t.toLowerCase()));
|
|
5647
5650
|
const dropped = allTokens.length - filtered.length;
|
|
5648
5651
|
if (dropped > 0) {
|
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, {
|
|
343
|
+
agentId: string | number;
|
|
342
344
|
name: string;
|
|
343
345
|
network: "mainnet";
|
|
344
|
-
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
|
-
name: string;
|
|
392
392
|
agentId: string | number;
|
|
393
|
+
name: string;
|
|
393
394
|
llm: {
|
|
394
395
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
395
396
|
model?: string | undefined;
|
|
@@ -616,7 +617,6 @@ declare class VaultManager {
|
|
|
616
617
|
private readonly walletClient;
|
|
617
618
|
private readonly addresses;
|
|
618
619
|
private readonly account;
|
|
619
|
-
private readonly chain;
|
|
620
620
|
private cachedVaultAddress;
|
|
621
621
|
private lastVaultCheck;
|
|
622
622
|
private readonly VAULT_CACHE_TTL;
|
|
@@ -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.37";
|
|
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, {
|
|
343
|
+
agentId: string | number;
|
|
342
344
|
name: string;
|
|
343
345
|
network: "mainnet";
|
|
344
|
-
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
|
-
name: string;
|
|
392
392
|
agentId: string | number;
|
|
393
|
+
name: string;
|
|
393
394
|
llm: {
|
|
394
395
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
395
396
|
model?: string | undefined;
|
|
@@ -616,7 +617,6 @@ declare class VaultManager {
|
|
|
616
617
|
private readonly walletClient;
|
|
617
618
|
private readonly addresses;
|
|
618
619
|
private readonly account;
|
|
619
|
-
private readonly chain;
|
|
620
620
|
private cachedVaultAddress;
|
|
621
621
|
private lastVaultCheck;
|
|
622
622
|
private readonly VAULT_CACHE_TTL;
|
|
@@ -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.37";
|
|
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
|
@@ -86,11 +86,12 @@ module.exports = __toCommonJS(index_exports);
|
|
|
86
86
|
// src/runtime.ts
|
|
87
87
|
var import_sdk = require("@exagent/sdk");
|
|
88
88
|
var import_viem7 = require("viem");
|
|
89
|
-
var
|
|
89
|
+
var import_chains5 = require("viem/chains");
|
|
90
90
|
var import_accounts5 = require("viem/accounts");
|
|
91
91
|
|
|
92
92
|
// src/trading/market.ts
|
|
93
93
|
var import_viem2 = require("viem");
|
|
94
|
+
var import_chains = require("viem/chains");
|
|
94
95
|
|
|
95
96
|
// src/trading/token-resolver.ts
|
|
96
97
|
var import_viem = require("viem");
|
|
@@ -561,6 +562,7 @@ var MarketDataService = class {
|
|
|
561
562
|
constructor(rpcUrl, store) {
|
|
562
563
|
this.rpcUrl = rpcUrl;
|
|
563
564
|
this.client = (0, import_viem2.createPublicClient)({
|
|
565
|
+
chain: import_chains.base,
|
|
564
566
|
transport: (0, import_viem2.http)(rpcUrl, { timeout: 6e4 })
|
|
565
567
|
});
|
|
566
568
|
this.resolver = new TokenResolver(this.client, store);
|
|
@@ -758,7 +760,7 @@ var MarketDataService = class {
|
|
|
758
760
|
try {
|
|
759
761
|
const results = await this.client.multicall({
|
|
760
762
|
contracts: batch.map((addr) => ({
|
|
761
|
-
address: addr,
|
|
763
|
+
address: addr.toLowerCase(),
|
|
762
764
|
abi: import_viem2.erc20Abi,
|
|
763
765
|
functionName: "balanceOf",
|
|
764
766
|
args: [wallet]
|
|
@@ -798,7 +800,7 @@ var MarketDataService = class {
|
|
|
798
800
|
const promises = tokenAddresses.map(async (tokenAddress) => {
|
|
799
801
|
try {
|
|
800
802
|
const balance = await this.client.readContract({
|
|
801
|
-
address: tokenAddress,
|
|
803
|
+
address: tokenAddress.toLowerCase(),
|
|
802
804
|
abi: import_viem2.erc20Abi,
|
|
803
805
|
functionName: "balanceOf",
|
|
804
806
|
args: [wallet]
|
|
@@ -2566,7 +2568,7 @@ var FileStore = class {
|
|
|
2566
2568
|
// src/vault/manager.ts
|
|
2567
2569
|
var import_viem3 = require("viem");
|
|
2568
2570
|
var import_accounts = require("viem/accounts");
|
|
2569
|
-
var
|
|
2571
|
+
var import_chains2 = require("viem/chains");
|
|
2570
2572
|
var ADDRESSES = {
|
|
2571
2573
|
mainnet: {
|
|
2572
2574
|
vaultFactory: process.env.EXAGENT_VAULT_FACTORY_ADDRESS || "0x0000000000000000000000000000000000000000",
|
|
@@ -2637,13 +2639,10 @@ var VAULT_ABI = [
|
|
|
2637
2639
|
];
|
|
2638
2640
|
var VaultManager = class {
|
|
2639
2641
|
config;
|
|
2640
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2641
2642
|
publicClient;
|
|
2642
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2643
2643
|
walletClient;
|
|
2644
2644
|
addresses;
|
|
2645
2645
|
account;
|
|
2646
|
-
chain;
|
|
2647
2646
|
cachedVaultAddress = null;
|
|
2648
2647
|
lastVaultCheck = 0;
|
|
2649
2648
|
VAULT_CACHE_TTL = 6e4;
|
|
@@ -2653,16 +2652,15 @@ var VaultManager = class {
|
|
|
2653
2652
|
this.config = config;
|
|
2654
2653
|
this.addresses = ADDRESSES[config.network];
|
|
2655
2654
|
this.account = (0, import_accounts.privateKeyToAccount)(config.walletKey);
|
|
2656
|
-
this.chain = import_chains.base;
|
|
2657
2655
|
const rpcUrl = getRpcUrl();
|
|
2658
2656
|
const transport = (0, import_viem3.http)(rpcUrl, { timeout: 6e4 });
|
|
2659
2657
|
this.publicClient = (0, import_viem3.createPublicClient)({
|
|
2660
|
-
chain:
|
|
2658
|
+
chain: import_chains2.base,
|
|
2661
2659
|
transport
|
|
2662
2660
|
});
|
|
2663
2661
|
this.walletClient = (0, import_viem3.createWalletClient)({
|
|
2664
2662
|
account: this.account,
|
|
2665
|
-
chain:
|
|
2663
|
+
chain: import_chains2.base,
|
|
2666
2664
|
transport
|
|
2667
2665
|
});
|
|
2668
2666
|
if (this.addresses.vaultFactory === "0x0000000000000000000000000000000000000000") {
|
|
@@ -2801,7 +2799,7 @@ var VaultManager = class {
|
|
|
2801
2799
|
vaultSymbol,
|
|
2802
2800
|
feeRecipient
|
|
2803
2801
|
],
|
|
2804
|
-
chain:
|
|
2802
|
+
chain: import_chains2.base,
|
|
2805
2803
|
account: this.account
|
|
2806
2804
|
});
|
|
2807
2805
|
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
@@ -2849,7 +2847,7 @@ var VaultManager = class {
|
|
|
2849
2847
|
params.swapData,
|
|
2850
2848
|
deadline
|
|
2851
2849
|
],
|
|
2852
|
-
chain:
|
|
2850
|
+
chain: import_chains2.base,
|
|
2853
2851
|
account: this.account
|
|
2854
2852
|
});
|
|
2855
2853
|
return { usedVault: true, txHash: hash };
|
|
@@ -3988,7 +3986,7 @@ var HyperliquidWebSocket = class {
|
|
|
3988
3986
|
|
|
3989
3987
|
// src/perp/recorder.ts
|
|
3990
3988
|
var import_viem5 = require("viem");
|
|
3991
|
-
var
|
|
3989
|
+
var import_chains3 = require("viem/chains");
|
|
3992
3990
|
var import_accounts3 = require("viem/accounts");
|
|
3993
3991
|
var ROUTER_ADDRESS = "0x1BCFa13f677fDCf697D8b7d5120f544817F1de1A";
|
|
3994
3992
|
var ROUTER_ABI = [
|
|
@@ -4011,11 +4009,8 @@ var ROUTER_ABI = [
|
|
|
4011
4009
|
var MAX_RETRIES = 3;
|
|
4012
4010
|
var RETRY_DELAY_MS = 5e3;
|
|
4013
4011
|
var PerpTradeRecorder = class {
|
|
4014
|
-
// Use `any` for viem client types to avoid L2 chain type conflicts (Base has "deposit" tx type)
|
|
4015
4012
|
publicClient;
|
|
4016
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4017
4013
|
walletClient;
|
|
4018
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4019
4014
|
account;
|
|
4020
4015
|
agentId;
|
|
4021
4016
|
configHash;
|
|
@@ -4032,11 +4027,11 @@ var PerpTradeRecorder = class {
|
|
|
4032
4027
|
const rpcUrl = opts.rpcUrl || "https://mainnet.base.org";
|
|
4033
4028
|
const transport = (0, import_viem5.http)(rpcUrl, { timeout: 6e4 });
|
|
4034
4029
|
this.publicClient = (0, import_viem5.createPublicClient)({
|
|
4035
|
-
chain:
|
|
4030
|
+
chain: import_chains3.base,
|
|
4036
4031
|
transport
|
|
4037
4032
|
});
|
|
4038
4033
|
this.walletClient = (0, import_viem5.createWalletClient)({
|
|
4039
|
-
chain:
|
|
4034
|
+
chain: import_chains3.base,
|
|
4040
4035
|
transport,
|
|
4041
4036
|
account: this.account
|
|
4042
4037
|
});
|
|
@@ -4344,8 +4339,16 @@ var PerpOnboarding = class {
|
|
|
4344
4339
|
|
|
4345
4340
|
// src/perp/funding.ts
|
|
4346
4341
|
var import_viem6 = require("viem");
|
|
4347
|
-
var
|
|
4342
|
+
var import_chains4 = require("viem/chains");
|
|
4348
4343
|
var import_accounts4 = require("viem/accounts");
|
|
4344
|
+
var hyperEVM = (0, import_viem6.defineChain)({
|
|
4345
|
+
id: 999,
|
|
4346
|
+
name: "HyperEVM",
|
|
4347
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
4348
|
+
rpcUrls: {
|
|
4349
|
+
default: { http: ["https://rpc.hyperliquid.xyz/evm"] }
|
|
4350
|
+
}
|
|
4351
|
+
});
|
|
4349
4352
|
var ERC20_ABI = (0, import_viem6.parseAbi)([
|
|
4350
4353
|
"function approve(address spender, uint256 amount) external returns (bool)",
|
|
4351
4354
|
"function balanceOf(address account) external view returns (uint256)",
|
|
@@ -4790,7 +4793,7 @@ var AgentRuntime = class {
|
|
|
4790
4793
|
if (message.includes("insufficient funds") || message.includes("intrinsic gas too low") || message.includes("exceeds the balance")) {
|
|
4791
4794
|
const ccUrl = `https://exagent.io/agents/${encodeURIComponent(this.config.name)}/command-center`;
|
|
4792
4795
|
const publicClientInstance = (0, import_viem7.createPublicClient)({
|
|
4793
|
-
chain:
|
|
4796
|
+
chain: import_chains5.base,
|
|
4794
4797
|
transport: (0, import_viem7.http)(this.getRpcUrl(), { timeout: 6e4 })
|
|
4795
4798
|
});
|
|
4796
4799
|
console.log("");
|
|
@@ -5520,8 +5523,8 @@ var AgentRuntime = class {
|
|
|
5520
5523
|
* for Frontier agents trading outside the whitelist) stay visible.
|
|
5521
5524
|
*/
|
|
5522
5525
|
getTokensToTrack() {
|
|
5523
|
-
const
|
|
5524
|
-
const baseSet = new Set(
|
|
5526
|
+
const base6 = this.config.allowedTokens || this.getDefaultTokens();
|
|
5527
|
+
const baseSet = new Set(base6.map((t) => t.toLowerCase()));
|
|
5525
5528
|
const trackedPositions = this.positionTracker.getPositions();
|
|
5526
5529
|
const extras = [];
|
|
5527
5530
|
for (const pos of trackedPositions) {
|
|
@@ -5544,7 +5547,7 @@ var AgentRuntime = class {
|
|
|
5544
5547
|
console.log(`Auto-tracking ${extras.length} additional token(s) from position history`);
|
|
5545
5548
|
}
|
|
5546
5549
|
const resolver = this.marketData.getResolver();
|
|
5547
|
-
const allTokens = [...
|
|
5550
|
+
const allTokens = [...base6, ...extras];
|
|
5548
5551
|
const filtered = allTokens.filter((t) => !resolver.isUnresolvable(t.toLowerCase()));
|
|
5549
5552
|
const dropped = allTokens.length - filtered.length;
|
|
5550
5553
|
if (dropped > 0) {
|
|
@@ -5881,7 +5884,7 @@ function loadSecureEnv(basePath, passphrase) {
|
|
|
5881
5884
|
}
|
|
5882
5885
|
|
|
5883
5886
|
// src/index.ts
|
|
5884
|
-
var AGENT_VERSION = "0.1.
|
|
5887
|
+
var AGENT_VERSION = "0.1.37";
|
|
5885
5888
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5886
5889
|
0 && (module.exports = {
|
|
5887
5890
|
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.37",
|
|
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.15",
|
|
33
33
|
"@nktkas/hyperliquid": "^0.31.0",
|
|
34
34
|
"chalk": "^5.3.0",
|
|
35
35
|
"commander": "^12.0.0",
|