@exagent/agent 0.1.46 → 0.1.48
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-6VBJT53Q.mjs +9838 -0
- package/dist/chunk-CVRY5TKR.mjs +10261 -0
- package/dist/chunk-D22X7J5B.mjs +10259 -0
- package/dist/chunk-ICTDJ7VX.mjs +9879 -0
- package/dist/chunk-PNDPQ22E.mjs +9879 -0
- package/dist/chunk-SS7WXSW4.mjs +10138 -0
- package/dist/chunk-UVIDQKP4.mjs +10232 -0
- package/dist/chunk-V5XCNJWM.mjs +10261 -0
- package/dist/chunk-XRLY7P6A.mjs +10134 -0
- package/dist/chunk-YUBAS5YE.mjs +10195 -0
- package/dist/cli.js +695 -92
- package/dist/cli.mjs +91 -1
- package/dist/index.d.mts +41 -18
- package/dist/index.d.ts +41 -18
- package/dist/index.js +602 -91
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
encryptEnvFile,
|
|
14
14
|
formatSessionReport,
|
|
15
15
|
getAllStrategyTemplates,
|
|
16
|
+
getStrategyTemplate,
|
|
16
17
|
getTokenDecimals,
|
|
17
18
|
init_adapter,
|
|
18
19
|
init_executor,
|
|
@@ -29,7 +30,7 @@ import {
|
|
|
29
30
|
results_exports,
|
|
30
31
|
saveSessionResult,
|
|
31
32
|
validateConfig
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-V5XCNJWM.mjs";
|
|
33
34
|
|
|
34
35
|
// src/backtest/data-loader.ts
|
|
35
36
|
import * as fs from "fs";
|
|
@@ -1107,6 +1108,95 @@ ${llmEnvVar}EXAGENT_LLM_MODEL=${config.llm?.model || ""}
|
|
|
1107
1108
|
loadEnvFile({ path: envPath, override: true });
|
|
1108
1109
|
}
|
|
1109
1110
|
}
|
|
1111
|
+
program.command("init").description("Scaffold a new agent project with strategy template and config").option("-t, --template <template>", "Strategy template (momentum, value, arbitrage, custom)", "momentum").option("--force", "Overwrite existing files without prompting").action(async (options) => {
|
|
1112
|
+
try {
|
|
1113
|
+
const templateId = options.template;
|
|
1114
|
+
const template = getStrategyTemplate(templateId);
|
|
1115
|
+
if (!template) {
|
|
1116
|
+
const templates = getAllStrategyTemplates();
|
|
1117
|
+
console.error(`Unknown template: ${templateId}`);
|
|
1118
|
+
console.error(`Available templates: ${templates.map((t) => t.id).join(", ")}`);
|
|
1119
|
+
process.exit(1);
|
|
1120
|
+
}
|
|
1121
|
+
console.log("");
|
|
1122
|
+
console.log("=".repeat(50));
|
|
1123
|
+
console.log(" EXAGENT INIT");
|
|
1124
|
+
console.log("=".repeat(50));
|
|
1125
|
+
console.log("");
|
|
1126
|
+
console.log(` Template: ${template.name}`);
|
|
1127
|
+
console.log(` Risk: ${template.riskLevel}`);
|
|
1128
|
+
console.log("");
|
|
1129
|
+
const cwd = process.cwd();
|
|
1130
|
+
const strategyPath = path4.join(cwd, "strategy.ts");
|
|
1131
|
+
const configPath = path4.join(cwd, "agent-config.json");
|
|
1132
|
+
const existingFiles = [];
|
|
1133
|
+
if (fs3.existsSync(strategyPath)) existingFiles.push("strategy.ts");
|
|
1134
|
+
if (fs3.existsSync(configPath)) existingFiles.push("agent-config.json");
|
|
1135
|
+
if (existingFiles.length > 0 && !options.force) {
|
|
1136
|
+
console.log(` Files already exist: ${existingFiles.join(", ")}`);
|
|
1137
|
+
const answer = await prompt(" Overwrite? (y/n): ");
|
|
1138
|
+
if (answer.toLowerCase() !== "y") {
|
|
1139
|
+
console.log(" Aborted.");
|
|
1140
|
+
process.exit(0);
|
|
1141
|
+
}
|
|
1142
|
+
console.log("");
|
|
1143
|
+
}
|
|
1144
|
+
fs3.writeFileSync(strategyPath, template.exampleCode.trim() + "\n");
|
|
1145
|
+
console.log(" Created: strategy.ts");
|
|
1146
|
+
const defaultConfig = {
|
|
1147
|
+
agentId: 0,
|
|
1148
|
+
name: "my-agent",
|
|
1149
|
+
network: "mainnet",
|
|
1150
|
+
llm: {
|
|
1151
|
+
provider: "openai",
|
|
1152
|
+
model: "gpt-4o",
|
|
1153
|
+
temperature: 0.7,
|
|
1154
|
+
maxTokens: 4096
|
|
1155
|
+
},
|
|
1156
|
+
riskUniverse: "established",
|
|
1157
|
+
trading: {
|
|
1158
|
+
timeHorizon: "swing",
|
|
1159
|
+
maxPositionSizeBps: 1e3,
|
|
1160
|
+
maxDailyLossBps: 500,
|
|
1161
|
+
maxConcurrentPositions: 5,
|
|
1162
|
+
tradingIntervalMs: 6e4,
|
|
1163
|
+
maxSlippageBps: 100,
|
|
1164
|
+
minTradeValueUSD: 1
|
|
1165
|
+
},
|
|
1166
|
+
wallet: {
|
|
1167
|
+
setup: "generate"
|
|
1168
|
+
},
|
|
1169
|
+
relay: {
|
|
1170
|
+
enabled: true,
|
|
1171
|
+
apiUrl: "https://exagent-api.onrender.com"
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
if (!fs3.existsSync(configPath) || options.force || existingFiles.includes("agent-config.json")) {
|
|
1175
|
+
fs3.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2) + "\n");
|
|
1176
|
+
console.log(" Created: agent-config.json");
|
|
1177
|
+
}
|
|
1178
|
+
console.log("");
|
|
1179
|
+
console.log("=".repeat(50));
|
|
1180
|
+
console.log(" NEXT STEPS");
|
|
1181
|
+
console.log("=".repeat(50));
|
|
1182
|
+
console.log("");
|
|
1183
|
+
console.log(" 1. Register your agent at https://exagent.io/deploy");
|
|
1184
|
+
console.log(" 2. Copy your agent ID into agent-config.json");
|
|
1185
|
+
console.log(" 3. Update agent-config.json with your name and LLM provider");
|
|
1186
|
+
console.log(" 4. Run: npx @exagent/agent paper");
|
|
1187
|
+
console.log(" (paper trade first to validate your strategy)");
|
|
1188
|
+
console.log("");
|
|
1189
|
+
console.log(" 5. When ready for real trading:");
|
|
1190
|
+
console.log(" npx @exagent/agent run");
|
|
1191
|
+
console.log("");
|
|
1192
|
+
console.log("=".repeat(50));
|
|
1193
|
+
console.log("");
|
|
1194
|
+
process.exit(0);
|
|
1195
|
+
} catch (error) {
|
|
1196
|
+
console.error("Error:", error instanceof Error ? error.message : error);
|
|
1197
|
+
process.exit(1);
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1110
1200
|
program.command("run").description("Start the trading agent").option("-c, --config <path>", "Path to agent-config.json", "agent-config.json").option("-p, --passphrase <passphrase>", "Passphrase to decrypt .env.enc").action(async (options) => {
|
|
1111
1201
|
try {
|
|
1112
1202
|
await checkFirstRunSetup(options.config);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Address, Hash, PublicClient, HttpTransport, WalletClient } from 'viem';
|
|
3
|
-
import { ExagentClient } from '@exagent/sdk';
|
|
3
|
+
import { VaultTradeParams, ExagentClient } from '@exagent/sdk';
|
|
4
4
|
import { base } from 'viem/chains';
|
|
5
5
|
|
|
6
6
|
/** Risk state persisted across restarts */
|
|
@@ -596,6 +596,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
596
596
|
isVerified?: boolean | undefined;
|
|
597
597
|
} | undefined;
|
|
598
598
|
}>>;
|
|
599
|
+
strategyPrompt: z.ZodOptional<z.ZodString>;
|
|
599
600
|
allowedTokens: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
600
601
|
}, "strip", z.ZodTypeAny, {
|
|
601
602
|
name: string;
|
|
@@ -668,6 +669,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
668
669
|
vaultAddress?: string | undefined;
|
|
669
670
|
} | undefined;
|
|
670
671
|
} | undefined;
|
|
672
|
+
strategyPrompt?: string | undefined;
|
|
671
673
|
allowedTokens?: string[] | undefined;
|
|
672
674
|
}, {
|
|
673
675
|
name: string;
|
|
@@ -740,6 +742,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
740
742
|
isVerified?: boolean | undefined;
|
|
741
743
|
} | undefined;
|
|
742
744
|
} | undefined;
|
|
745
|
+
strategyPrompt?: string | undefined;
|
|
743
746
|
allowedTokens?: string[] | undefined;
|
|
744
747
|
}>;
|
|
745
748
|
type AgentConfig = z.infer<typeof AgentConfigSchema>;
|
|
@@ -762,6 +765,11 @@ interface MarketData {
|
|
|
762
765
|
chainId: number;
|
|
763
766
|
blockNumber?: number;
|
|
764
767
|
};
|
|
768
|
+
/** Hourly price history (last 24h) per token. Array ordered oldest→newest. */
|
|
769
|
+
priceHistory?: Record<string, Array<{
|
|
770
|
+
timestamp: number;
|
|
771
|
+
price: number;
|
|
772
|
+
}>>;
|
|
765
773
|
}
|
|
766
774
|
interface TradeSignal {
|
|
767
775
|
action: 'buy' | 'sell' | 'hold';
|
|
@@ -967,16 +975,16 @@ declare class VaultManager {
|
|
|
967
975
|
error?: string;
|
|
968
976
|
}>;
|
|
969
977
|
/**
|
|
970
|
-
* Execute a trade through the vault
|
|
971
|
-
*
|
|
978
|
+
* Execute a trade through the vault using API-provided vaultParams.
|
|
979
|
+
* Dispatches to the correct vault function based on swapType.
|
|
980
|
+
* Returns null if vault trading shouldn't be used (no vault, policy disabled).
|
|
972
981
|
*/
|
|
973
982
|
executeVaultTrade(params: {
|
|
974
983
|
tokenIn: Address;
|
|
975
984
|
tokenOut: Address;
|
|
976
985
|
amountIn: bigint;
|
|
977
986
|
minAmountOut: bigint;
|
|
978
|
-
|
|
979
|
-
swapData: `0x${string}`;
|
|
987
|
+
vaultParams: VaultTradeParams;
|
|
980
988
|
deadline?: bigint;
|
|
981
989
|
}): Promise<{
|
|
982
990
|
usedVault: boolean;
|
|
@@ -1505,16 +1513,15 @@ declare function loadStrategy(strategyPath?: string): Promise<StrategyFunction>;
|
|
|
1505
1513
|
declare function validateStrategy(fn: unknown): fn is StrategyFunction;
|
|
1506
1514
|
|
|
1507
1515
|
/**
|
|
1508
|
-
*
|
|
1516
|
+
* Strategy Templates
|
|
1509
1517
|
*
|
|
1510
|
-
*
|
|
1511
|
-
* Each template includes
|
|
1512
|
-
*
|
|
1513
|
-
* - Risk warnings
|
|
1514
|
-
* - Example implementation
|
|
1518
|
+
* Self-contained, runnable strategy templates that users can scaffold via `init`.
|
|
1519
|
+
* Each template includes all helper functions inline — no external imports needed
|
|
1520
|
+
* beyond the @exagent/agent types.
|
|
1515
1521
|
*
|
|
1516
|
-
*
|
|
1517
|
-
*
|
|
1522
|
+
* Templates output TradeSignal[] where amountIn is a bigint in token-native units (wei).
|
|
1523
|
+
* The LLM returns a percentage (0-100) of the relevant balance, and the template
|
|
1524
|
+
* converts it to the correct bigint amount.
|
|
1518
1525
|
*/
|
|
1519
1526
|
interface StrategyTemplate {
|
|
1520
1527
|
id: string;
|
|
@@ -1538,17 +1545,23 @@ declare function getAllStrategyTemplates(): StrategyTemplate[];
|
|
|
1538
1545
|
/**
|
|
1539
1546
|
* Trade Executor
|
|
1540
1547
|
* Handles execution of trade signals through the ExagentRouter.
|
|
1541
|
-
*
|
|
1542
|
-
*
|
|
1548
|
+
* Tries vault trading first (if vault exists and policy allows),
|
|
1549
|
+
* then falls back to wallet trading. All trades route through the router.
|
|
1543
1550
|
*/
|
|
1544
1551
|
declare class TradeExecutor {
|
|
1545
1552
|
private client;
|
|
1546
1553
|
private config;
|
|
1547
1554
|
private allowedTokens;
|
|
1548
1555
|
private configHashFn?;
|
|
1549
|
-
|
|
1556
|
+
private vaultManager?;
|
|
1557
|
+
constructor(client: ExagentClient, config: RuntimeConfig, configHashFn?: () => string, vaultManager?: VaultManager);
|
|
1558
|
+
/**
|
|
1559
|
+
* Set the vault manager (allows wiring after construction)
|
|
1560
|
+
*/
|
|
1561
|
+
setVaultManager(vm: VaultManager): void;
|
|
1550
1562
|
/**
|
|
1551
|
-
* Execute a single trade signal
|
|
1563
|
+
* Execute a single trade signal.
|
|
1564
|
+
* Tries vault trading first if vault exists, falls back to wallet trading.
|
|
1552
1565
|
*/
|
|
1553
1566
|
execute(signal: TradeSignal): Promise<{
|
|
1554
1567
|
success: boolean;
|
|
@@ -1943,6 +1956,10 @@ declare class MarketDataService {
|
|
|
1943
1956
|
private cachedVolume24h;
|
|
1944
1957
|
/** Cached price change data */
|
|
1945
1958
|
private cachedPriceChange24h;
|
|
1959
|
+
/** Cached 24h hourly price history per token address */
|
|
1960
|
+
private cachedPriceHistory;
|
|
1961
|
+
/** Timestamp of last successful price history fetch */
|
|
1962
|
+
private lastHistoryFetchAt;
|
|
1946
1963
|
constructor(rpcUrl: string, store?: StrategyStore);
|
|
1947
1964
|
/** Get the underlying TokenResolver for direct access */
|
|
1948
1965
|
getResolver(): TokenResolver;
|
|
@@ -1965,6 +1982,12 @@ declare class MarketDataService {
|
|
|
1965
1982
|
* Returns cached prices if still fresh (<60s old)
|
|
1966
1983
|
*/
|
|
1967
1984
|
private fetchPrices;
|
|
1985
|
+
/**
|
|
1986
|
+
* Fetch 24h hourly price history from CoinGecko.
|
|
1987
|
+
* Returns cached data if still fresh (< 60 min old).
|
|
1988
|
+
* Only fetches for tokens with known CoinGecko IDs.
|
|
1989
|
+
*/
|
|
1990
|
+
private fetchPriceHistory;
|
|
1968
1991
|
/**
|
|
1969
1992
|
* Fetch real on-chain balances: native ETH + ERC-20 tokens.
|
|
1970
1993
|
* Uses Multicall3 to batch all balanceOf calls into a single RPC request.
|
|
@@ -3353,6 +3376,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
|
|
|
3353
3376
|
declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
|
|
3354
3377
|
|
|
3355
3378
|
/** @exagent/agent package version — update alongside package.json */
|
|
3356
|
-
declare const AGENT_VERSION = "0.1.
|
|
3379
|
+
declare const AGENT_VERSION = "0.1.48";
|
|
3357
3380
|
|
|
3358
3381
|
export { AGENT_VERSION, type AccountSummary, type AgentConfig, AgentConfigSchema, type AgentMode, AgentRuntime, type AgentStatusPayload, AnthropicAdapter, BaseLLMAdapter, type BridgeResult, type BridgeStep, type CommandType, DeepSeekAdapter, FileStore, type FillCallback, type FundingCallback, type FundingPayment, GoogleAdapter, GroqAdapter, HYPERLIQUID_DOMAIN, HyperliquidClient, HyperliquidSigner, HyperliquidWebSocket, type InferredExit, type LLMAdapter, type LLMConfig, LLMConfigSchema, type LLMMessage, type LLMMetadata, type LLMProvider, LLMProviderSchema, type LLMResponse, type LiquidationCallback, type LocalPosition, MARKET_CATEGORIES, MarketBrowser, type MarketCategory, 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, PolymarketClient, PositionManager, type PositionSummary, PositionTracker, type PredictionAccountSummary, type PredictionAction, type PredictionConfig$1 as PredictionConfig, PredictionConfigSchema, type PredictionFill, PredictionFunding, type PredictionFundingConfig, type PredictionMarket, PredictionOrderManager, type PredictionPosition, PredictionPositionManager, type PredictionStrategyFunction, PredictionTradeRecorder, type PredictionTradeSignal, type PredictionConfig as PredictionTradingConfig, type RecordPerpTradeParams, type RecordPredictionTradeParams, 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, type StuckPosition, TogetherAdapter, type TrackedPosition, TradeExecutor, type TradeRecord, type TradeSignal, type TradingConfig, TradingConfigSchema, type VaultConfig, VaultConfigSchema, VaultManager, type VaultManagerConfig, type VaultPolicy, VaultPolicySchema, type VaultStatus, calculatePredictionFee, createLLMAdapter, createSampleConfig, decodePredictionInstrument, decryptEnvFile, encodePredictionInstrument, encryptEnvFile, fillHashToBytes32, fillOidToBytes32, getAllStrategyTemplates, getNextNonce, getStrategyTemplate, loadConfig, loadSecureEnv, loadStrategy, orderIdToBytes32, tradeIdToBytes32, validateConfig, validateStrategy };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Address, Hash, PublicClient, HttpTransport, WalletClient } from 'viem';
|
|
3
|
-
import { ExagentClient } from '@exagent/sdk';
|
|
3
|
+
import { VaultTradeParams, ExagentClient } from '@exagent/sdk';
|
|
4
4
|
import { base } from 'viem/chains';
|
|
5
5
|
|
|
6
6
|
/** Risk state persisted across restarts */
|
|
@@ -596,6 +596,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
596
596
|
isVerified?: boolean | undefined;
|
|
597
597
|
} | undefined;
|
|
598
598
|
}>>;
|
|
599
|
+
strategyPrompt: z.ZodOptional<z.ZodString>;
|
|
599
600
|
allowedTokens: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
600
601
|
}, "strip", z.ZodTypeAny, {
|
|
601
602
|
name: string;
|
|
@@ -668,6 +669,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
668
669
|
vaultAddress?: string | undefined;
|
|
669
670
|
} | undefined;
|
|
670
671
|
} | undefined;
|
|
672
|
+
strategyPrompt?: string | undefined;
|
|
671
673
|
allowedTokens?: string[] | undefined;
|
|
672
674
|
}, {
|
|
673
675
|
name: string;
|
|
@@ -740,6 +742,7 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
740
742
|
isVerified?: boolean | undefined;
|
|
741
743
|
} | undefined;
|
|
742
744
|
} | undefined;
|
|
745
|
+
strategyPrompt?: string | undefined;
|
|
743
746
|
allowedTokens?: string[] | undefined;
|
|
744
747
|
}>;
|
|
745
748
|
type AgentConfig = z.infer<typeof AgentConfigSchema>;
|
|
@@ -762,6 +765,11 @@ interface MarketData {
|
|
|
762
765
|
chainId: number;
|
|
763
766
|
blockNumber?: number;
|
|
764
767
|
};
|
|
768
|
+
/** Hourly price history (last 24h) per token. Array ordered oldest→newest. */
|
|
769
|
+
priceHistory?: Record<string, Array<{
|
|
770
|
+
timestamp: number;
|
|
771
|
+
price: number;
|
|
772
|
+
}>>;
|
|
765
773
|
}
|
|
766
774
|
interface TradeSignal {
|
|
767
775
|
action: 'buy' | 'sell' | 'hold';
|
|
@@ -967,16 +975,16 @@ declare class VaultManager {
|
|
|
967
975
|
error?: string;
|
|
968
976
|
}>;
|
|
969
977
|
/**
|
|
970
|
-
* Execute a trade through the vault
|
|
971
|
-
*
|
|
978
|
+
* Execute a trade through the vault using API-provided vaultParams.
|
|
979
|
+
* Dispatches to the correct vault function based on swapType.
|
|
980
|
+
* Returns null if vault trading shouldn't be used (no vault, policy disabled).
|
|
972
981
|
*/
|
|
973
982
|
executeVaultTrade(params: {
|
|
974
983
|
tokenIn: Address;
|
|
975
984
|
tokenOut: Address;
|
|
976
985
|
amountIn: bigint;
|
|
977
986
|
minAmountOut: bigint;
|
|
978
|
-
|
|
979
|
-
swapData: `0x${string}`;
|
|
987
|
+
vaultParams: VaultTradeParams;
|
|
980
988
|
deadline?: bigint;
|
|
981
989
|
}): Promise<{
|
|
982
990
|
usedVault: boolean;
|
|
@@ -1505,16 +1513,15 @@ declare function loadStrategy(strategyPath?: string): Promise<StrategyFunction>;
|
|
|
1505
1513
|
declare function validateStrategy(fn: unknown): fn is StrategyFunction;
|
|
1506
1514
|
|
|
1507
1515
|
/**
|
|
1508
|
-
*
|
|
1516
|
+
* Strategy Templates
|
|
1509
1517
|
*
|
|
1510
|
-
*
|
|
1511
|
-
* Each template includes
|
|
1512
|
-
*
|
|
1513
|
-
* - Risk warnings
|
|
1514
|
-
* - Example implementation
|
|
1518
|
+
* Self-contained, runnable strategy templates that users can scaffold via `init`.
|
|
1519
|
+
* Each template includes all helper functions inline — no external imports needed
|
|
1520
|
+
* beyond the @exagent/agent types.
|
|
1515
1521
|
*
|
|
1516
|
-
*
|
|
1517
|
-
*
|
|
1522
|
+
* Templates output TradeSignal[] where amountIn is a bigint in token-native units (wei).
|
|
1523
|
+
* The LLM returns a percentage (0-100) of the relevant balance, and the template
|
|
1524
|
+
* converts it to the correct bigint amount.
|
|
1518
1525
|
*/
|
|
1519
1526
|
interface StrategyTemplate {
|
|
1520
1527
|
id: string;
|
|
@@ -1538,17 +1545,23 @@ declare function getAllStrategyTemplates(): StrategyTemplate[];
|
|
|
1538
1545
|
/**
|
|
1539
1546
|
* Trade Executor
|
|
1540
1547
|
* Handles execution of trade signals through the ExagentRouter.
|
|
1541
|
-
*
|
|
1542
|
-
*
|
|
1548
|
+
* Tries vault trading first (if vault exists and policy allows),
|
|
1549
|
+
* then falls back to wallet trading. All trades route through the router.
|
|
1543
1550
|
*/
|
|
1544
1551
|
declare class TradeExecutor {
|
|
1545
1552
|
private client;
|
|
1546
1553
|
private config;
|
|
1547
1554
|
private allowedTokens;
|
|
1548
1555
|
private configHashFn?;
|
|
1549
|
-
|
|
1556
|
+
private vaultManager?;
|
|
1557
|
+
constructor(client: ExagentClient, config: RuntimeConfig, configHashFn?: () => string, vaultManager?: VaultManager);
|
|
1558
|
+
/**
|
|
1559
|
+
* Set the vault manager (allows wiring after construction)
|
|
1560
|
+
*/
|
|
1561
|
+
setVaultManager(vm: VaultManager): void;
|
|
1550
1562
|
/**
|
|
1551
|
-
* Execute a single trade signal
|
|
1563
|
+
* Execute a single trade signal.
|
|
1564
|
+
* Tries vault trading first if vault exists, falls back to wallet trading.
|
|
1552
1565
|
*/
|
|
1553
1566
|
execute(signal: TradeSignal): Promise<{
|
|
1554
1567
|
success: boolean;
|
|
@@ -1943,6 +1956,10 @@ declare class MarketDataService {
|
|
|
1943
1956
|
private cachedVolume24h;
|
|
1944
1957
|
/** Cached price change data */
|
|
1945
1958
|
private cachedPriceChange24h;
|
|
1959
|
+
/** Cached 24h hourly price history per token address */
|
|
1960
|
+
private cachedPriceHistory;
|
|
1961
|
+
/** Timestamp of last successful price history fetch */
|
|
1962
|
+
private lastHistoryFetchAt;
|
|
1946
1963
|
constructor(rpcUrl: string, store?: StrategyStore);
|
|
1947
1964
|
/** Get the underlying TokenResolver for direct access */
|
|
1948
1965
|
getResolver(): TokenResolver;
|
|
@@ -1965,6 +1982,12 @@ declare class MarketDataService {
|
|
|
1965
1982
|
* Returns cached prices if still fresh (<60s old)
|
|
1966
1983
|
*/
|
|
1967
1984
|
private fetchPrices;
|
|
1985
|
+
/**
|
|
1986
|
+
* Fetch 24h hourly price history from CoinGecko.
|
|
1987
|
+
* Returns cached data if still fresh (< 60 min old).
|
|
1988
|
+
* Only fetches for tokens with known CoinGecko IDs.
|
|
1989
|
+
*/
|
|
1990
|
+
private fetchPriceHistory;
|
|
1968
1991
|
/**
|
|
1969
1992
|
* Fetch real on-chain balances: native ETH + ERC-20 tokens.
|
|
1970
1993
|
* Uses Multicall3 to batch all balanceOf calls into a single RPC request.
|
|
@@ -3353,6 +3376,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
|
|
|
3353
3376
|
declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
|
|
3354
3377
|
|
|
3355
3378
|
/** @exagent/agent package version — update alongside package.json */
|
|
3356
|
-
declare const AGENT_VERSION = "0.1.
|
|
3379
|
+
declare const AGENT_VERSION = "0.1.48";
|
|
3357
3380
|
|
|
3358
3381
|
export { AGENT_VERSION, type AccountSummary, type AgentConfig, AgentConfigSchema, type AgentMode, AgentRuntime, type AgentStatusPayload, AnthropicAdapter, BaseLLMAdapter, type BridgeResult, type BridgeStep, type CommandType, DeepSeekAdapter, FileStore, type FillCallback, type FundingCallback, type FundingPayment, GoogleAdapter, GroqAdapter, HYPERLIQUID_DOMAIN, HyperliquidClient, HyperliquidSigner, HyperliquidWebSocket, type InferredExit, type LLMAdapter, type LLMConfig, LLMConfigSchema, type LLMMessage, type LLMMetadata, type LLMProvider, LLMProviderSchema, type LLMResponse, type LiquidationCallback, type LocalPosition, MARKET_CATEGORIES, MarketBrowser, type MarketCategory, 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, PolymarketClient, PositionManager, type PositionSummary, PositionTracker, type PredictionAccountSummary, type PredictionAction, type PredictionConfig$1 as PredictionConfig, PredictionConfigSchema, type PredictionFill, PredictionFunding, type PredictionFundingConfig, type PredictionMarket, PredictionOrderManager, type PredictionPosition, PredictionPositionManager, type PredictionStrategyFunction, PredictionTradeRecorder, type PredictionTradeSignal, type PredictionConfig as PredictionTradingConfig, type RecordPerpTradeParams, type RecordPredictionTradeParams, 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, type StuckPosition, TogetherAdapter, type TrackedPosition, TradeExecutor, type TradeRecord, type TradeSignal, type TradingConfig, TradingConfigSchema, type VaultConfig, VaultConfigSchema, VaultManager, type VaultManagerConfig, type VaultPolicy, VaultPolicySchema, type VaultStatus, calculatePredictionFee, createLLMAdapter, createSampleConfig, decodePredictionInstrument, decryptEnvFile, encodePredictionInstrument, encryptEnvFile, fillHashToBytes32, fillOidToBytes32, getAllStrategyTemplates, getNextNonce, getStrategyTemplate, loadConfig, loadSecureEnv, loadStrategy, orderIdToBytes32, tradeIdToBytes32, validateConfig, validateStrategy };
|