@exagent/agent 0.1.30 → 0.1.32
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-27UBREN6.mjs +5536 -0
- package/dist/chunk-4NASRDHJ.mjs +5536 -0
- package/dist/chunk-BAOLHULW.mjs +5551 -0
- package/dist/cli.js +92 -18
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +92 -18
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -118,6 +118,7 @@ var TOKEN_DECIMALS = {
|
|
|
118
118
|
// SKI
|
|
119
119
|
};
|
|
120
120
|
var decimalsCache = {};
|
|
121
|
+
var symbolCache = {};
|
|
121
122
|
function getTokenDecimals(address) {
|
|
122
123
|
const key = address.toLowerCase();
|
|
123
124
|
const known = TOKEN_DECIMALS[key];
|
|
@@ -127,26 +128,43 @@ function getTokenDecimals(address) {
|
|
|
127
128
|
console.warn(`Unknown token decimals for ${address}, defaulting to 18. Call fetchTokenDecimals() first for accuracy.`);
|
|
128
129
|
return 18;
|
|
129
130
|
}
|
|
131
|
+
function getTokenSymbol(address) {
|
|
132
|
+
return symbolCache[address.toLowerCase()];
|
|
133
|
+
}
|
|
130
134
|
async function fetchTokenDecimals(client, address) {
|
|
131
135
|
const key = address.toLowerCase();
|
|
132
136
|
const known = TOKEN_DECIMALS[key];
|
|
133
137
|
if (known !== void 0) return known;
|
|
134
138
|
const cached = decimalsCache[key];
|
|
135
139
|
if (cached !== void 0) return cached;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
141
|
+
try {
|
|
142
|
+
const [decimals, symbol] = await Promise.all([
|
|
143
|
+
client.readContract({
|
|
144
|
+
address,
|
|
145
|
+
abi: import_viem.erc20Abi,
|
|
146
|
+
functionName: "decimals"
|
|
147
|
+
}),
|
|
148
|
+
client.readContract({
|
|
149
|
+
address,
|
|
150
|
+
abi: import_viem.erc20Abi,
|
|
151
|
+
functionName: "symbol"
|
|
152
|
+
}).catch(() => void 0)
|
|
153
|
+
// symbol is optional — some tokens don't have it
|
|
154
|
+
]);
|
|
155
|
+
const result = Number(decimals);
|
|
156
|
+
decimalsCache[key] = result;
|
|
157
|
+
if (symbol) symbolCache[key] = String(symbol);
|
|
158
|
+
return result;
|
|
159
|
+
} catch {
|
|
160
|
+
if (attempt === 0) {
|
|
161
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
149
164
|
}
|
|
165
|
+
console.warn(`Failed to fetch decimals for ${address} after 2 attempts, defaulting to 18`);
|
|
166
|
+
decimalsCache[key] = 18;
|
|
167
|
+
return 18;
|
|
150
168
|
}
|
|
151
169
|
var TOKEN_TO_COINGECKO = {
|
|
152
170
|
[NATIVE_ETH.toLowerCase()]: "ethereum",
|
|
@@ -359,6 +377,46 @@ var MarketDataService = class {
|
|
|
359
377
|
} catch {
|
|
360
378
|
}
|
|
361
379
|
}
|
|
380
|
+
const stillMissing = tokenAddresses.filter(
|
|
381
|
+
(addr) => !prices[addr.toLowerCase()]
|
|
382
|
+
);
|
|
383
|
+
if (stillMissing.length > 0) {
|
|
384
|
+
const batches = [];
|
|
385
|
+
for (let i = 0; i < stillMissing.length; i += 30) {
|
|
386
|
+
batches.push(stillMissing.slice(i, i + 30));
|
|
387
|
+
}
|
|
388
|
+
for (const batch of batches) {
|
|
389
|
+
try {
|
|
390
|
+
const addrs = batch.join(",");
|
|
391
|
+
const dsResponse = await fetch(
|
|
392
|
+
`https://api.dexscreener.com/tokens/v1/base/${addrs}`,
|
|
393
|
+
{ signal: AbortSignal.timeout(5e3) }
|
|
394
|
+
);
|
|
395
|
+
if (dsResponse.ok) {
|
|
396
|
+
const pairs = await dsResponse.json();
|
|
397
|
+
const bestPrices = {};
|
|
398
|
+
for (const pair of pairs || []) {
|
|
399
|
+
if (!pair.priceUsd || !pair.baseToken?.address) continue;
|
|
400
|
+
const addr = pair.baseToken.address.toLowerCase();
|
|
401
|
+
const price = parseFloat(pair.priceUsd);
|
|
402
|
+
const liq = pair.liquidity?.usd || 0;
|
|
403
|
+
if (price > 0 && (!bestPrices[addr] || liq > bestPrices[addr].liquidity)) {
|
|
404
|
+
bestPrices[addr] = { price, liquidity: liq };
|
|
405
|
+
if (pair.baseToken.symbol && !symbolCache[addr]) {
|
|
406
|
+
symbolCache[addr] = pair.baseToken.symbol;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
for (const [addr, { price }] of Object.entries(bestPrices)) {
|
|
411
|
+
prices[addr] = price;
|
|
412
|
+
const sym = symbolCache[addr] || addr.slice(0, 10);
|
|
413
|
+
console.log(`DexScreener price for ${sym}: $${price}`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
} catch {
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
362
420
|
if (Object.keys(prices).length > 0) {
|
|
363
421
|
this.cachedPrices = prices;
|
|
364
422
|
}
|
|
@@ -368,7 +426,8 @@ var MarketDataService = class {
|
|
|
368
426
|
}
|
|
369
427
|
for (const addr of tokenAddresses) {
|
|
370
428
|
if (!prices[addr.toLowerCase()]) {
|
|
371
|
-
|
|
429
|
+
const sym = symbolCache[addr.toLowerCase()];
|
|
430
|
+
console.warn(`No price available for ${sym ? `${sym} (${addr})` : addr} \u2014 CoinGecko, DeFi Llama, and DexScreener all returned nothing`);
|
|
372
431
|
prices[addr.toLowerCase()] = 0;
|
|
373
432
|
}
|
|
374
433
|
}
|
|
@@ -535,7 +594,7 @@ var PositionTracker = class {
|
|
|
535
594
|
} else {
|
|
536
595
|
this.positions[token] = {
|
|
537
596
|
token,
|
|
538
|
-
symbol: TOKEN_SYMBOLS[token],
|
|
597
|
+
symbol: TOKEN_SYMBOLS[token] || getTokenSymbol(token),
|
|
539
598
|
entryPrice: priceUSD,
|
|
540
599
|
averageEntryPrice: priceUSD,
|
|
541
600
|
totalCostBasis: costUSD,
|
|
@@ -588,7 +647,7 @@ var PositionTracker = class {
|
|
|
588
647
|
const price = prices[token] || 0;
|
|
589
648
|
this.positions[token] = {
|
|
590
649
|
token,
|
|
591
|
-
symbol: TOKEN_SYMBOLS[token],
|
|
650
|
+
symbol: TOKEN_SYMBOLS[token] || getTokenSymbol(token),
|
|
592
651
|
entryPrice: price,
|
|
593
652
|
averageEntryPrice: price,
|
|
594
653
|
totalCostBasis: amount * price,
|
|
@@ -599,7 +658,7 @@ var PositionTracker = class {
|
|
|
599
658
|
txHashes: []
|
|
600
659
|
};
|
|
601
660
|
if (price > 0) {
|
|
602
|
-
console.log(`Position tracker: detected new holding ${TOKEN_SYMBOLS[token] || token.slice(0, 10)} (${amount.toFixed(4)} units @ $${price.toFixed(4)})`);
|
|
661
|
+
console.log(`Position tracker: detected new holding ${TOKEN_SYMBOLS[token] || getTokenSymbol(token) || token.slice(0, 10)} (${amount.toFixed(4)} units @ $${price.toFixed(4)})`);
|
|
603
662
|
}
|
|
604
663
|
changed = true;
|
|
605
664
|
}
|
|
@@ -3826,7 +3885,7 @@ function loadSecureEnv(basePath, passphrase) {
|
|
|
3826
3885
|
}
|
|
3827
3886
|
|
|
3828
3887
|
// src/index.ts
|
|
3829
|
-
var AGENT_VERSION = "0.1.
|
|
3888
|
+
var AGENT_VERSION = "0.1.32";
|
|
3830
3889
|
|
|
3831
3890
|
// src/relay.ts
|
|
3832
3891
|
var RelayClient = class {
|
|
@@ -4582,6 +4641,21 @@ var AgentRuntime = class {
|
|
|
4582
4641
|
console.log("Visit https://exagent.io to start trading from the dashboard.");
|
|
4583
4642
|
console.log("");
|
|
4584
4643
|
this.mode = "idle";
|
|
4644
|
+
try {
|
|
4645
|
+
const tokens = this.getTokensToTrack();
|
|
4646
|
+
const initData = await this.marketData.fetchMarketData(this.client.address, tokens);
|
|
4647
|
+
this.positionTracker.syncBalances(initData.balances, initData.prices);
|
|
4648
|
+
this.lastPortfolioValue = initData.portfolioValue;
|
|
4649
|
+
this.lastPrices = initData.prices;
|
|
4650
|
+
const nativeEthBal = initData.balances[NATIVE_ETH.toLowerCase()] || BigInt(0);
|
|
4651
|
+
this.lastEthBalance = (Number(nativeEthBal) / 1e18).toFixed(6);
|
|
4652
|
+
const posCount = this.positionTracker.getPositions().length;
|
|
4653
|
+
if (posCount > 0) {
|
|
4654
|
+
console.log(`Initial sync: ${posCount} position(s) rebuilt from on-chain balances`);
|
|
4655
|
+
}
|
|
4656
|
+
} catch (error) {
|
|
4657
|
+
console.warn("Initial balance sync failed (non-fatal):", error instanceof Error ? error.message : error);
|
|
4658
|
+
}
|
|
4585
4659
|
this.sendRelayStatus();
|
|
4586
4660
|
this.relay.sendMessage(
|
|
4587
4661
|
"system",
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -2114,6 +2114,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
|
|
|
2114
2114
|
declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
|
|
2115
2115
|
|
|
2116
2116
|
/** @exagent/agent package version — update alongside package.json */
|
|
2117
|
-
declare const AGENT_VERSION = "0.1.
|
|
2117
|
+
declare const AGENT_VERSION = "0.1.32";
|
|
2118
2118
|
|
|
2119
2119
|
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
|
@@ -2114,6 +2114,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
|
|
|
2114
2114
|
declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
|
|
2115
2115
|
|
|
2116
2116
|
/** @exagent/agent package version — update alongside package.json */
|
|
2117
|
-
declare const AGENT_VERSION = "0.1.
|
|
2117
|
+
declare const AGENT_VERSION = "0.1.32";
|
|
2118
2118
|
|
|
2119
2119
|
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
|
@@ -171,6 +171,7 @@ var TOKEN_DECIMALS = {
|
|
|
171
171
|
// SKI
|
|
172
172
|
};
|
|
173
173
|
var decimalsCache = {};
|
|
174
|
+
var symbolCache = {};
|
|
174
175
|
function getTokenDecimals(address) {
|
|
175
176
|
const key = address.toLowerCase();
|
|
176
177
|
const known = TOKEN_DECIMALS[key];
|
|
@@ -180,26 +181,43 @@ function getTokenDecimals(address) {
|
|
|
180
181
|
console.warn(`Unknown token decimals for ${address}, defaulting to 18. Call fetchTokenDecimals() first for accuracy.`);
|
|
181
182
|
return 18;
|
|
182
183
|
}
|
|
184
|
+
function getTokenSymbol(address) {
|
|
185
|
+
return symbolCache[address.toLowerCase()];
|
|
186
|
+
}
|
|
183
187
|
async function fetchTokenDecimals(client, address) {
|
|
184
188
|
const key = address.toLowerCase();
|
|
185
189
|
const known = TOKEN_DECIMALS[key];
|
|
186
190
|
if (known !== void 0) return known;
|
|
187
191
|
const cached = decimalsCache[key];
|
|
188
192
|
if (cached !== void 0) return cached;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
193
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
194
|
+
try {
|
|
195
|
+
const [decimals, symbol] = await Promise.all([
|
|
196
|
+
client.readContract({
|
|
197
|
+
address,
|
|
198
|
+
abi: import_viem.erc20Abi,
|
|
199
|
+
functionName: "decimals"
|
|
200
|
+
}),
|
|
201
|
+
client.readContract({
|
|
202
|
+
address,
|
|
203
|
+
abi: import_viem.erc20Abi,
|
|
204
|
+
functionName: "symbol"
|
|
205
|
+
}).catch(() => void 0)
|
|
206
|
+
// symbol is optional — some tokens don't have it
|
|
207
|
+
]);
|
|
208
|
+
const result = Number(decimals);
|
|
209
|
+
decimalsCache[key] = result;
|
|
210
|
+
if (symbol) symbolCache[key] = String(symbol);
|
|
211
|
+
return result;
|
|
212
|
+
} catch {
|
|
213
|
+
if (attempt === 0) {
|
|
214
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
202
217
|
}
|
|
218
|
+
console.warn(`Failed to fetch decimals for ${address} after 2 attempts, defaulting to 18`);
|
|
219
|
+
decimalsCache[key] = 18;
|
|
220
|
+
return 18;
|
|
203
221
|
}
|
|
204
222
|
var TOKEN_TO_COINGECKO = {
|
|
205
223
|
[NATIVE_ETH.toLowerCase()]: "ethereum",
|
|
@@ -412,6 +430,46 @@ var MarketDataService = class {
|
|
|
412
430
|
} catch {
|
|
413
431
|
}
|
|
414
432
|
}
|
|
433
|
+
const stillMissing = tokenAddresses.filter(
|
|
434
|
+
(addr) => !prices[addr.toLowerCase()]
|
|
435
|
+
);
|
|
436
|
+
if (stillMissing.length > 0) {
|
|
437
|
+
const batches = [];
|
|
438
|
+
for (let i = 0; i < stillMissing.length; i += 30) {
|
|
439
|
+
batches.push(stillMissing.slice(i, i + 30));
|
|
440
|
+
}
|
|
441
|
+
for (const batch of batches) {
|
|
442
|
+
try {
|
|
443
|
+
const addrs = batch.join(",");
|
|
444
|
+
const dsResponse = await fetch(
|
|
445
|
+
`https://api.dexscreener.com/tokens/v1/base/${addrs}`,
|
|
446
|
+
{ signal: AbortSignal.timeout(5e3) }
|
|
447
|
+
);
|
|
448
|
+
if (dsResponse.ok) {
|
|
449
|
+
const pairs = await dsResponse.json();
|
|
450
|
+
const bestPrices = {};
|
|
451
|
+
for (const pair of pairs || []) {
|
|
452
|
+
if (!pair.priceUsd || !pair.baseToken?.address) continue;
|
|
453
|
+
const addr = pair.baseToken.address.toLowerCase();
|
|
454
|
+
const price = parseFloat(pair.priceUsd);
|
|
455
|
+
const liq = pair.liquidity?.usd || 0;
|
|
456
|
+
if (price > 0 && (!bestPrices[addr] || liq > bestPrices[addr].liquidity)) {
|
|
457
|
+
bestPrices[addr] = { price, liquidity: liq };
|
|
458
|
+
if (pair.baseToken.symbol && !symbolCache[addr]) {
|
|
459
|
+
symbolCache[addr] = pair.baseToken.symbol;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
for (const [addr, { price }] of Object.entries(bestPrices)) {
|
|
464
|
+
prices[addr] = price;
|
|
465
|
+
const sym = symbolCache[addr] || addr.slice(0, 10);
|
|
466
|
+
console.log(`DexScreener price for ${sym}: $${price}`);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
} catch {
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
415
473
|
if (Object.keys(prices).length > 0) {
|
|
416
474
|
this.cachedPrices = prices;
|
|
417
475
|
}
|
|
@@ -421,7 +479,8 @@ var MarketDataService = class {
|
|
|
421
479
|
}
|
|
422
480
|
for (const addr of tokenAddresses) {
|
|
423
481
|
if (!prices[addr.toLowerCase()]) {
|
|
424
|
-
|
|
482
|
+
const sym = symbolCache[addr.toLowerCase()];
|
|
483
|
+
console.warn(`No price available for ${sym ? `${sym} (${addr})` : addr} \u2014 CoinGecko, DeFi Llama, and DexScreener all returned nothing`);
|
|
425
484
|
prices[addr.toLowerCase()] = 0;
|
|
426
485
|
}
|
|
427
486
|
}
|
|
@@ -588,7 +647,7 @@ var PositionTracker = class {
|
|
|
588
647
|
} else {
|
|
589
648
|
this.positions[token] = {
|
|
590
649
|
token,
|
|
591
|
-
symbol: TOKEN_SYMBOLS[token],
|
|
650
|
+
symbol: TOKEN_SYMBOLS[token] || getTokenSymbol(token),
|
|
592
651
|
entryPrice: priceUSD,
|
|
593
652
|
averageEntryPrice: priceUSD,
|
|
594
653
|
totalCostBasis: costUSD,
|
|
@@ -641,7 +700,7 @@ var PositionTracker = class {
|
|
|
641
700
|
const price = prices[token] || 0;
|
|
642
701
|
this.positions[token] = {
|
|
643
702
|
token,
|
|
644
|
-
symbol: TOKEN_SYMBOLS[token],
|
|
703
|
+
symbol: TOKEN_SYMBOLS[token] || getTokenSymbol(token),
|
|
645
704
|
entryPrice: price,
|
|
646
705
|
averageEntryPrice: price,
|
|
647
706
|
totalCostBasis: amount * price,
|
|
@@ -652,7 +711,7 @@ var PositionTracker = class {
|
|
|
652
711
|
txHashes: []
|
|
653
712
|
};
|
|
654
713
|
if (price > 0) {
|
|
655
|
-
console.log(`Position tracker: detected new holding ${TOKEN_SYMBOLS[token] || token.slice(0, 10)} (${amount.toFixed(4)} units @ $${price.toFixed(4)})`);
|
|
714
|
+
console.log(`Position tracker: detected new holding ${TOKEN_SYMBOLS[token] || getTokenSymbol(token) || token.slice(0, 10)} (${amount.toFixed(4)} units @ $${price.toFixed(4)})`);
|
|
656
715
|
}
|
|
657
716
|
changed = true;
|
|
658
717
|
}
|
|
@@ -4484,6 +4543,21 @@ var AgentRuntime = class {
|
|
|
4484
4543
|
console.log("Visit https://exagent.io to start trading from the dashboard.");
|
|
4485
4544
|
console.log("");
|
|
4486
4545
|
this.mode = "idle";
|
|
4546
|
+
try {
|
|
4547
|
+
const tokens = this.getTokensToTrack();
|
|
4548
|
+
const initData = await this.marketData.fetchMarketData(this.client.address, tokens);
|
|
4549
|
+
this.positionTracker.syncBalances(initData.balances, initData.prices);
|
|
4550
|
+
this.lastPortfolioValue = initData.portfolioValue;
|
|
4551
|
+
this.lastPrices = initData.prices;
|
|
4552
|
+
const nativeEthBal = initData.balances[NATIVE_ETH.toLowerCase()] || BigInt(0);
|
|
4553
|
+
this.lastEthBalance = (Number(nativeEthBal) / 1e18).toFixed(6);
|
|
4554
|
+
const posCount = this.positionTracker.getPositions().length;
|
|
4555
|
+
if (posCount > 0) {
|
|
4556
|
+
console.log(`Initial sync: ${posCount} position(s) rebuilt from on-chain balances`);
|
|
4557
|
+
}
|
|
4558
|
+
} catch (error) {
|
|
4559
|
+
console.warn("Initial balance sync failed (non-fatal):", error instanceof Error ? error.message : error);
|
|
4560
|
+
}
|
|
4487
4561
|
this.sendRelayStatus();
|
|
4488
4562
|
this.relay.sendMessage(
|
|
4489
4563
|
"system",
|
|
@@ -5489,7 +5563,7 @@ function loadSecureEnv(basePath, passphrase) {
|
|
|
5489
5563
|
}
|
|
5490
5564
|
|
|
5491
5565
|
// src/index.ts
|
|
5492
|
-
var AGENT_VERSION = "0.1.
|
|
5566
|
+
var AGENT_VERSION = "0.1.32";
|
|
5493
5567
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5494
5568
|
0 && (module.exports = {
|
|
5495
5569
|
AGENT_VERSION,
|
package/dist/index.mjs
CHANGED