@exagent/agent 0.1.39 → 0.1.40
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-47FQBTKE.mjs +9394 -0
- package/dist/chunk-6VSAJQU7.mjs +9394 -0
- package/dist/chunk-MVUE6EPJ.mjs +8634 -0
- package/dist/chunk-NNIBSMJQ.mjs +9333 -0
- package/dist/chunk-OBESLXRL.mjs +8634 -0
- package/dist/chunk-TE3P727T.mjs +8634 -0
- package/dist/cli.js +2604 -223
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1051 -6
- package/dist/index.d.ts +1051 -6
- package/dist/index.js +2619 -188
- package/dist/index.mjs +27 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -207,6 +207,108 @@ declare const PerpConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
|
207
207
|
allowedInstruments?: string[] | undefined;
|
|
208
208
|
}>>;
|
|
209
209
|
type PerpConfig$1 = z.infer<typeof PerpConfigSchema>;
|
|
210
|
+
declare const PredictionConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
211
|
+
/** Enable prediction market trading */
|
|
212
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
213
|
+
/** Polymarket CLOB API URL */
|
|
214
|
+
clobApiUrl: z.ZodDefault<z.ZodString>;
|
|
215
|
+
/** Gamma API URL for market discovery */
|
|
216
|
+
gammaApiUrl: z.ZodDefault<z.ZodString>;
|
|
217
|
+
/** Polygon RPC URL */
|
|
218
|
+
polygonRpcUrl: z.ZodOptional<z.ZodString>;
|
|
219
|
+
/** CLOB API key (L2 auth) — derived from wallet signature if not provided */
|
|
220
|
+
clobApiKey: z.ZodOptional<z.ZodString>;
|
|
221
|
+
/** CLOB API secret (L2 auth) */
|
|
222
|
+
clobApiSecret: z.ZodOptional<z.ZodString>;
|
|
223
|
+
/** CLOB API passphrase (L2 auth) */
|
|
224
|
+
clobApiPassphrase: z.ZodOptional<z.ZodString>;
|
|
225
|
+
/** Private key for the prediction relayer (calls recordPerpTrade on Base). Falls back to agent wallet. */
|
|
226
|
+
predictionRelayerKey: z.ZodOptional<z.ZodString>;
|
|
227
|
+
/** Maximum notional per trade in USD (default: 500) */
|
|
228
|
+
maxNotionalUSD: z.ZodDefault<z.ZodNumber>;
|
|
229
|
+
/** Maximum total exposure across all markets in USD (default: 5000) */
|
|
230
|
+
maxTotalExposureUSD: z.ZodDefault<z.ZodNumber>;
|
|
231
|
+
/** Target USDC allocation on Polygon in USD (default: 100) */
|
|
232
|
+
polygonAllocationUSD: z.ZodDefault<z.ZodNumber>;
|
|
233
|
+
/** Allowed market categories (empty = all categories) */
|
|
234
|
+
allowedCategories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
235
|
+
/** Fee bridge threshold in USD — accumulated fees are bridged to Base when exceeded (default: 10) */
|
|
236
|
+
feeBridgeThresholdUSD: z.ZodDefault<z.ZodNumber>;
|
|
237
|
+
/** Prediction vault configuration (ERC-4626 + ERC-1271 on Polygon) */
|
|
238
|
+
vault: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
/** Enable vault mode for prediction trading */
|
|
240
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
241
|
+
/** PredictionVaultFactory address on Polygon */
|
|
242
|
+
factoryAddress: z.ZodString;
|
|
243
|
+
/** PredictionFeeCollector address on Polygon */
|
|
244
|
+
feeCollectorAddress: z.ZodOptional<z.ZodString>;
|
|
245
|
+
/** Existing vault address (if already created) */
|
|
246
|
+
vaultAddress: z.ZodOptional<z.ZodString>;
|
|
247
|
+
/** Agent's fee recipient address */
|
|
248
|
+
feeRecipient: z.ZodOptional<z.ZodString>;
|
|
249
|
+
/** Whether agent is verified (higher deposit cap) */
|
|
250
|
+
isVerified: z.ZodDefault<z.ZodBoolean>;
|
|
251
|
+
}, "strip", z.ZodTypeAny, {
|
|
252
|
+
enabled: boolean;
|
|
253
|
+
factoryAddress: string;
|
|
254
|
+
isVerified: boolean;
|
|
255
|
+
feeRecipient?: string | undefined;
|
|
256
|
+
feeCollectorAddress?: string | undefined;
|
|
257
|
+
vaultAddress?: string | undefined;
|
|
258
|
+
}, {
|
|
259
|
+
factoryAddress: string;
|
|
260
|
+
feeRecipient?: string | undefined;
|
|
261
|
+
enabled?: boolean | undefined;
|
|
262
|
+
feeCollectorAddress?: string | undefined;
|
|
263
|
+
vaultAddress?: string | undefined;
|
|
264
|
+
isVerified?: boolean | undefined;
|
|
265
|
+
}>>;
|
|
266
|
+
}, "strip", z.ZodTypeAny, {
|
|
267
|
+
enabled: boolean;
|
|
268
|
+
maxNotionalUSD: number;
|
|
269
|
+
clobApiUrl: string;
|
|
270
|
+
gammaApiUrl: string;
|
|
271
|
+
maxTotalExposureUSD: number;
|
|
272
|
+
polygonAllocationUSD: number;
|
|
273
|
+
feeBridgeThresholdUSD: number;
|
|
274
|
+
vault?: {
|
|
275
|
+
enabled: boolean;
|
|
276
|
+
factoryAddress: string;
|
|
277
|
+
isVerified: boolean;
|
|
278
|
+
feeRecipient?: string | undefined;
|
|
279
|
+
feeCollectorAddress?: string | undefined;
|
|
280
|
+
vaultAddress?: string | undefined;
|
|
281
|
+
} | undefined;
|
|
282
|
+
polygonRpcUrl?: string | undefined;
|
|
283
|
+
clobApiKey?: string | undefined;
|
|
284
|
+
clobApiSecret?: string | undefined;
|
|
285
|
+
clobApiPassphrase?: string | undefined;
|
|
286
|
+
predictionRelayerKey?: string | undefined;
|
|
287
|
+
allowedCategories?: string[] | undefined;
|
|
288
|
+
}, {
|
|
289
|
+
vault?: {
|
|
290
|
+
factoryAddress: string;
|
|
291
|
+
feeRecipient?: string | undefined;
|
|
292
|
+
enabled?: boolean | undefined;
|
|
293
|
+
feeCollectorAddress?: string | undefined;
|
|
294
|
+
vaultAddress?: string | undefined;
|
|
295
|
+
isVerified?: boolean | undefined;
|
|
296
|
+
} | undefined;
|
|
297
|
+
enabled?: boolean | undefined;
|
|
298
|
+
maxNotionalUSD?: number | undefined;
|
|
299
|
+
clobApiUrl?: string | undefined;
|
|
300
|
+
gammaApiUrl?: string | undefined;
|
|
301
|
+
polygonRpcUrl?: string | undefined;
|
|
302
|
+
clobApiKey?: string | undefined;
|
|
303
|
+
clobApiSecret?: string | undefined;
|
|
304
|
+
clobApiPassphrase?: string | undefined;
|
|
305
|
+
predictionRelayerKey?: string | undefined;
|
|
306
|
+
maxTotalExposureUSD?: number | undefined;
|
|
307
|
+
polygonAllocationUSD?: number | undefined;
|
|
308
|
+
allowedCategories?: string[] | undefined;
|
|
309
|
+
feeBridgeThresholdUSD?: number | undefined;
|
|
310
|
+
}>>;
|
|
311
|
+
type PredictionConfig$1 = z.infer<typeof PredictionConfigSchema>;
|
|
210
312
|
declare const AgentConfigSchema: z.ZodObject<{
|
|
211
313
|
agentId: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
212
314
|
name: z.ZodString;
|
|
@@ -338,11 +440,112 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
338
440
|
maxNotionalUSD?: number | undefined;
|
|
339
441
|
allowedInstruments?: string[] | undefined;
|
|
340
442
|
}>>;
|
|
443
|
+
prediction: z.ZodOptional<z.ZodObject<{
|
|
444
|
+
/** Enable prediction market trading */
|
|
445
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
446
|
+
/** Polymarket CLOB API URL */
|
|
447
|
+
clobApiUrl: z.ZodDefault<z.ZodString>;
|
|
448
|
+
/** Gamma API URL for market discovery */
|
|
449
|
+
gammaApiUrl: z.ZodDefault<z.ZodString>;
|
|
450
|
+
/** Polygon RPC URL */
|
|
451
|
+
polygonRpcUrl: z.ZodOptional<z.ZodString>;
|
|
452
|
+
/** CLOB API key (L2 auth) — derived from wallet signature if not provided */
|
|
453
|
+
clobApiKey: z.ZodOptional<z.ZodString>;
|
|
454
|
+
/** CLOB API secret (L2 auth) */
|
|
455
|
+
clobApiSecret: z.ZodOptional<z.ZodString>;
|
|
456
|
+
/** CLOB API passphrase (L2 auth) */
|
|
457
|
+
clobApiPassphrase: z.ZodOptional<z.ZodString>;
|
|
458
|
+
/** Private key for the prediction relayer (calls recordPerpTrade on Base). Falls back to agent wallet. */
|
|
459
|
+
predictionRelayerKey: z.ZodOptional<z.ZodString>;
|
|
460
|
+
/** Maximum notional per trade in USD (default: 500) */
|
|
461
|
+
maxNotionalUSD: z.ZodDefault<z.ZodNumber>;
|
|
462
|
+
/** Maximum total exposure across all markets in USD (default: 5000) */
|
|
463
|
+
maxTotalExposureUSD: z.ZodDefault<z.ZodNumber>;
|
|
464
|
+
/** Target USDC allocation on Polygon in USD (default: 100) */
|
|
465
|
+
polygonAllocationUSD: z.ZodDefault<z.ZodNumber>;
|
|
466
|
+
/** Allowed market categories (empty = all categories) */
|
|
467
|
+
allowedCategories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
468
|
+
/** Fee bridge threshold in USD — accumulated fees are bridged to Base when exceeded (default: 10) */
|
|
469
|
+
feeBridgeThresholdUSD: z.ZodDefault<z.ZodNumber>;
|
|
470
|
+
/** Prediction vault configuration (ERC-4626 + ERC-1271 on Polygon) */
|
|
471
|
+
vault: z.ZodOptional<z.ZodObject<{
|
|
472
|
+
/** Enable vault mode for prediction trading */
|
|
473
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
474
|
+
/** PredictionVaultFactory address on Polygon */
|
|
475
|
+
factoryAddress: z.ZodString;
|
|
476
|
+
/** PredictionFeeCollector address on Polygon */
|
|
477
|
+
feeCollectorAddress: z.ZodOptional<z.ZodString>;
|
|
478
|
+
/** Existing vault address (if already created) */
|
|
479
|
+
vaultAddress: z.ZodOptional<z.ZodString>;
|
|
480
|
+
/** Agent's fee recipient address */
|
|
481
|
+
feeRecipient: z.ZodOptional<z.ZodString>;
|
|
482
|
+
/** Whether agent is verified (higher deposit cap) */
|
|
483
|
+
isVerified: z.ZodDefault<z.ZodBoolean>;
|
|
484
|
+
}, "strip", z.ZodTypeAny, {
|
|
485
|
+
enabled: boolean;
|
|
486
|
+
factoryAddress: string;
|
|
487
|
+
isVerified: boolean;
|
|
488
|
+
feeRecipient?: string | undefined;
|
|
489
|
+
feeCollectorAddress?: string | undefined;
|
|
490
|
+
vaultAddress?: string | undefined;
|
|
491
|
+
}, {
|
|
492
|
+
factoryAddress: string;
|
|
493
|
+
feeRecipient?: string | undefined;
|
|
494
|
+
enabled?: boolean | undefined;
|
|
495
|
+
feeCollectorAddress?: string | undefined;
|
|
496
|
+
vaultAddress?: string | undefined;
|
|
497
|
+
isVerified?: boolean | undefined;
|
|
498
|
+
}>>;
|
|
499
|
+
}, "strip", z.ZodTypeAny, {
|
|
500
|
+
enabled: boolean;
|
|
501
|
+
maxNotionalUSD: number;
|
|
502
|
+
clobApiUrl: string;
|
|
503
|
+
gammaApiUrl: string;
|
|
504
|
+
maxTotalExposureUSD: number;
|
|
505
|
+
polygonAllocationUSD: number;
|
|
506
|
+
feeBridgeThresholdUSD: number;
|
|
507
|
+
vault?: {
|
|
508
|
+
enabled: boolean;
|
|
509
|
+
factoryAddress: string;
|
|
510
|
+
isVerified: boolean;
|
|
511
|
+
feeRecipient?: string | undefined;
|
|
512
|
+
feeCollectorAddress?: string | undefined;
|
|
513
|
+
vaultAddress?: string | undefined;
|
|
514
|
+
} | undefined;
|
|
515
|
+
polygonRpcUrl?: string | undefined;
|
|
516
|
+
clobApiKey?: string | undefined;
|
|
517
|
+
clobApiSecret?: string | undefined;
|
|
518
|
+
clobApiPassphrase?: string | undefined;
|
|
519
|
+
predictionRelayerKey?: string | undefined;
|
|
520
|
+
allowedCategories?: string[] | undefined;
|
|
521
|
+
}, {
|
|
522
|
+
vault?: {
|
|
523
|
+
factoryAddress: string;
|
|
524
|
+
feeRecipient?: string | undefined;
|
|
525
|
+
enabled?: boolean | undefined;
|
|
526
|
+
feeCollectorAddress?: string | undefined;
|
|
527
|
+
vaultAddress?: string | undefined;
|
|
528
|
+
isVerified?: boolean | undefined;
|
|
529
|
+
} | undefined;
|
|
530
|
+
enabled?: boolean | undefined;
|
|
531
|
+
maxNotionalUSD?: number | undefined;
|
|
532
|
+
clobApiUrl?: string | undefined;
|
|
533
|
+
gammaApiUrl?: string | undefined;
|
|
534
|
+
polygonRpcUrl?: string | undefined;
|
|
535
|
+
clobApiKey?: string | undefined;
|
|
536
|
+
clobApiSecret?: string | undefined;
|
|
537
|
+
clobApiPassphrase?: string | undefined;
|
|
538
|
+
predictionRelayerKey?: string | undefined;
|
|
539
|
+
maxTotalExposureUSD?: number | undefined;
|
|
540
|
+
polygonAllocationUSD?: number | undefined;
|
|
541
|
+
allowedCategories?: string[] | undefined;
|
|
542
|
+
feeBridgeThresholdUSD?: number | undefined;
|
|
543
|
+
}>>;
|
|
341
544
|
allowedTokens: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
342
545
|
}, "strip", z.ZodTypeAny, {
|
|
546
|
+
agentId: string | number;
|
|
343
547
|
name: string;
|
|
344
548
|
network: "mainnet";
|
|
345
|
-
agentId: string | number;
|
|
346
549
|
llm: {
|
|
347
550
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
348
551
|
temperature: number;
|
|
@@ -387,10 +590,33 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
387
590
|
perpRelayerKey?: string | undefined;
|
|
388
591
|
allowedInstruments?: string[] | undefined;
|
|
389
592
|
} | undefined;
|
|
593
|
+
prediction?: {
|
|
594
|
+
enabled: boolean;
|
|
595
|
+
maxNotionalUSD: number;
|
|
596
|
+
clobApiUrl: string;
|
|
597
|
+
gammaApiUrl: string;
|
|
598
|
+
maxTotalExposureUSD: number;
|
|
599
|
+
polygonAllocationUSD: number;
|
|
600
|
+
feeBridgeThresholdUSD: number;
|
|
601
|
+
vault?: {
|
|
602
|
+
enabled: boolean;
|
|
603
|
+
factoryAddress: string;
|
|
604
|
+
isVerified: boolean;
|
|
605
|
+
feeRecipient?: string | undefined;
|
|
606
|
+
feeCollectorAddress?: string | undefined;
|
|
607
|
+
vaultAddress?: string | undefined;
|
|
608
|
+
} | undefined;
|
|
609
|
+
polygonRpcUrl?: string | undefined;
|
|
610
|
+
clobApiKey?: string | undefined;
|
|
611
|
+
clobApiSecret?: string | undefined;
|
|
612
|
+
clobApiPassphrase?: string | undefined;
|
|
613
|
+
predictionRelayerKey?: string | undefined;
|
|
614
|
+
allowedCategories?: string[] | undefined;
|
|
615
|
+
} | undefined;
|
|
390
616
|
allowedTokens?: string[] | undefined;
|
|
391
617
|
}, {
|
|
392
|
-
name: string;
|
|
393
618
|
agentId: string | number;
|
|
619
|
+
name: string;
|
|
394
620
|
llm: {
|
|
395
621
|
provider: "custom" | "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "together" | "ollama";
|
|
396
622
|
model?: string | undefined;
|
|
@@ -436,6 +662,29 @@ declare const AgentConfigSchema: z.ZodObject<{
|
|
|
436
662
|
maxNotionalUSD?: number | undefined;
|
|
437
663
|
allowedInstruments?: string[] | undefined;
|
|
438
664
|
} | undefined;
|
|
665
|
+
prediction?: {
|
|
666
|
+
vault?: {
|
|
667
|
+
factoryAddress: string;
|
|
668
|
+
feeRecipient?: string | undefined;
|
|
669
|
+
enabled?: boolean | undefined;
|
|
670
|
+
feeCollectorAddress?: string | undefined;
|
|
671
|
+
vaultAddress?: string | undefined;
|
|
672
|
+
isVerified?: boolean | undefined;
|
|
673
|
+
} | undefined;
|
|
674
|
+
enabled?: boolean | undefined;
|
|
675
|
+
maxNotionalUSD?: number | undefined;
|
|
676
|
+
clobApiUrl?: string | undefined;
|
|
677
|
+
gammaApiUrl?: string | undefined;
|
|
678
|
+
polygonRpcUrl?: string | undefined;
|
|
679
|
+
clobApiKey?: string | undefined;
|
|
680
|
+
clobApiSecret?: string | undefined;
|
|
681
|
+
clobApiPassphrase?: string | undefined;
|
|
682
|
+
predictionRelayerKey?: string | undefined;
|
|
683
|
+
maxTotalExposureUSD?: number | undefined;
|
|
684
|
+
polygonAllocationUSD?: number | undefined;
|
|
685
|
+
allowedCategories?: string[] | undefined;
|
|
686
|
+
feeBridgeThresholdUSD?: number | undefined;
|
|
687
|
+
} | undefined;
|
|
439
688
|
allowedTokens?: string[] | undefined;
|
|
440
689
|
}>;
|
|
441
690
|
type AgentConfig = z.infer<typeof AgentConfigSchema>;
|
|
@@ -681,13 +930,13 @@ declare class VaultManager {
|
|
|
681
930
|
* Used by both the SDK relay client and the API relay service.
|
|
682
931
|
*/
|
|
683
932
|
type AgentMode = 'idle' | 'trading' | 'paper';
|
|
684
|
-
type CommandType = 'start_trading' | 'stop_trading' | 'start_paper_trading' | 'stop_paper_trading' | 'enable_hyperliquid' | 'disable_hyperliquid' | 'start_perp_trading' | 'stop_perp_trading' | 'update_risk_params' | 'update_perp_params' | 'update_trading_interval' | 'create_vault' | 'refresh_status' | 'shutdown';
|
|
933
|
+
type CommandType = 'start_trading' | 'stop_trading' | 'start_paper_trading' | 'stop_paper_trading' | 'enable_hyperliquid' | 'disable_hyperliquid' | 'start_perp_trading' | 'stop_perp_trading' | 'enable_polymarket' | 'disable_polymarket' | 'start_prediction_trading' | 'stop_prediction_trading' | 'create_prediction_vault' | 'deposit_prediction_vault' | 'withdraw_prediction_vault' | 'update_risk_params' | 'update_perp_params' | 'update_prediction_params' | 'update_trading_interval' | 'create_vault' | 'refresh_status' | 'shutdown';
|
|
685
934
|
interface RelayCommand {
|
|
686
935
|
id: string;
|
|
687
936
|
type: CommandType;
|
|
688
937
|
params?: Record<string, unknown>;
|
|
689
938
|
}
|
|
690
|
-
type MessageType = 'trade_executed' | 'trade_failed' | 'paper_trade_executed' | 'paper_trade_failed' | 'perp_fill' | 'perp_liquidation_warning' | 'perp_funding' | 'funds_low' | 'risk_limit_hit' | 'vault_created' | 'config_updated' | 'llm_error' | 'command_result' | 'system';
|
|
939
|
+
type MessageType = 'trade_executed' | 'trade_failed' | 'paper_trade_executed' | 'paper_trade_failed' | 'perp_fill' | 'perp_liquidation_warning' | 'perp_funding' | 'prediction_fill' | 'prediction_market_resolved' | 'prediction_vault_created' | 'prediction_vault_deposit' | 'prediction_vault_withdraw' | 'funds_low' | 'risk_limit_hit' | 'vault_created' | 'config_updated' | 'llm_error' | 'command_result' | 'system';
|
|
691
940
|
type MessageLevel = 'info' | 'warning' | 'error' | 'success';
|
|
692
941
|
interface AgentStatusPayload {
|
|
693
942
|
mode: AgentMode;
|
|
@@ -726,6 +975,28 @@ interface AgentStatusPayload {
|
|
|
726
975
|
effectiveLeverage: number;
|
|
727
976
|
pendingRecords: number;
|
|
728
977
|
};
|
|
978
|
+
prediction?: {
|
|
979
|
+
enabled: boolean;
|
|
980
|
+
trading: boolean;
|
|
981
|
+
polygonUSDC: number;
|
|
982
|
+
baseUSDC: number;
|
|
983
|
+
totalExposure: number;
|
|
984
|
+
openMarkets: number;
|
|
985
|
+
openPositions: number;
|
|
986
|
+
unrealizedPnl: number;
|
|
987
|
+
pendingFees: number;
|
|
988
|
+
pendingRecords: number;
|
|
989
|
+
/** Prediction vault status (only present in vault mode) */
|
|
990
|
+
vault?: {
|
|
991
|
+
address: string;
|
|
992
|
+
totalAssets: number;
|
|
993
|
+
sharePrice: number;
|
|
994
|
+
cachedCtfValue: number;
|
|
995
|
+
currentExposureBps: number;
|
|
996
|
+
circuitBreakerActive: boolean;
|
|
997
|
+
isPaused: boolean;
|
|
998
|
+
};
|
|
999
|
+
};
|
|
729
1000
|
/** Spot position tracking summary (auto-populated by PositionTracker) */
|
|
730
1001
|
positions?: {
|
|
731
1002
|
openPositions: number;
|
|
@@ -821,6 +1092,23 @@ declare class AgentRuntime {
|
|
|
821
1092
|
private cachedPerpMarginUsed;
|
|
822
1093
|
private cachedPerpLeverage;
|
|
823
1094
|
private cachedPerpOpenPositions;
|
|
1095
|
+
private predictionClient;
|
|
1096
|
+
private predictionOrders;
|
|
1097
|
+
private predictionPositions;
|
|
1098
|
+
private predictionRecorder;
|
|
1099
|
+
private predictionFunding;
|
|
1100
|
+
private predictionBrowser;
|
|
1101
|
+
private predictionStrategy;
|
|
1102
|
+
private predictionConnected;
|
|
1103
|
+
private predictionTradingActive;
|
|
1104
|
+
private cachedPredictionPolygonUSDC;
|
|
1105
|
+
private cachedPredictionBaseUSDC;
|
|
1106
|
+
private cachedPredictionExposure;
|
|
1107
|
+
private cachedPredictionOpenMarkets;
|
|
1108
|
+
private cachedPredictionOpenPositions;
|
|
1109
|
+
private cachedPredictionUnrealizedPnl;
|
|
1110
|
+
private predictionVaultManager;
|
|
1111
|
+
private cachedPredictionVaultStatus;
|
|
824
1112
|
constructor(config: RuntimeConfig, options?: {
|
|
825
1113
|
paperMode?: boolean;
|
|
826
1114
|
paperBalances?: Record<string, bigint>;
|
|
@@ -844,6 +1132,11 @@ declare class AgentRuntime {
|
|
|
844
1132
|
* Only initializes if perp is enabled in config AND risk universe >= 2.
|
|
845
1133
|
*/
|
|
846
1134
|
private initializePerp;
|
|
1135
|
+
/**
|
|
1136
|
+
* Initialize Polymarket prediction market components.
|
|
1137
|
+
* Only initializes if prediction is enabled in config AND risk universe >= 2.
|
|
1138
|
+
*/
|
|
1139
|
+
private initializePrediction;
|
|
847
1140
|
/**
|
|
848
1141
|
* Ensure the current wallet is linked to the agent.
|
|
849
1142
|
* If the trading wallet differs from the owner, enters a recovery loop
|
|
@@ -898,6 +1191,21 @@ declare class AgentRuntime {
|
|
|
898
1191
|
* Called from sendRelayStatus at most every 2.5 minutes (timestamp-throttled).
|
|
899
1192
|
*/
|
|
900
1193
|
private checkPendingConfigApproval;
|
|
1194
|
+
/**
|
|
1195
|
+
* Periodically sync config hash from on-chain to detect external changes.
|
|
1196
|
+
* This catches cases where the config was changed via the website or another
|
|
1197
|
+
* session while this agent is running. Without this, all trades and recordings
|
|
1198
|
+
* fail with ConfigMismatch until the agent is restarted.
|
|
1199
|
+
*
|
|
1200
|
+
* Called from sendRelayStatus at most every 5 minutes (timestamp-throttled).
|
|
1201
|
+
*/
|
|
1202
|
+
private lastConfigSyncAt;
|
|
1203
|
+
private syncConfigHashFromChain;
|
|
1204
|
+
/**
|
|
1205
|
+
* Propagate a config hash update to runtime + all consumers (recorders).
|
|
1206
|
+
* Ensures executor, perp recorder, and prediction recorder all stay in sync.
|
|
1207
|
+
*/
|
|
1208
|
+
private updateConfigHashEverywhere;
|
|
901
1209
|
/**
|
|
902
1210
|
* Send current status to the relay
|
|
903
1211
|
*/
|
|
@@ -912,6 +1220,12 @@ declare class AgentRuntime {
|
|
|
912
1220
|
* Fills arrive async via WebSocket and are auto-recorded on Base.
|
|
913
1221
|
*/
|
|
914
1222
|
private runPerpCycle;
|
|
1223
|
+
/**
|
|
1224
|
+
* Run a single prediction market trading cycle.
|
|
1225
|
+
* Fetches active markets, positions, calls prediction strategy, executes signals.
|
|
1226
|
+
* Fills are recorded on Base via Router.recordPerpTrade() with POLY: prefix.
|
|
1227
|
+
*/
|
|
1228
|
+
private runPredictionCycle;
|
|
915
1229
|
/**
|
|
916
1230
|
* Check if ETH balance is below threshold and notify.
|
|
917
1231
|
* Returns true if trading should continue, false if ETH is critically low.
|
|
@@ -2195,6 +2509,737 @@ interface OnboardingStatus {
|
|
|
2195
2509
|
builderFeeBps: number;
|
|
2196
2510
|
}
|
|
2197
2511
|
|
|
2512
|
+
/**
|
|
2513
|
+
* Polymarket Prediction Market Types
|
|
2514
|
+
*
|
|
2515
|
+
* Core type definitions for prediction market trading via Polymarket CLOB on Polygon.
|
|
2516
|
+
* Agents record fills on-chain via Router.recordPerpTrade() with a POLY: instrument prefix
|
|
2517
|
+
* for leaderboard attribution.
|
|
2518
|
+
*/
|
|
2519
|
+
|
|
2520
|
+
interface PredictionConfig {
|
|
2521
|
+
/** Enable prediction market trading */
|
|
2522
|
+
enabled: boolean;
|
|
2523
|
+
/** Polymarket CLOB API URL */
|
|
2524
|
+
clobApiUrl: string;
|
|
2525
|
+
/** Polymarket Gamma API URL (market discovery) */
|
|
2526
|
+
gammaApiUrl: string;
|
|
2527
|
+
/** Polygon RPC URL for balance queries and CCTP bridging */
|
|
2528
|
+
polygonRpcUrl: string;
|
|
2529
|
+
/** Private key for the prediction relayer (calls recordPerpTrade on Base). Falls back to agent wallet. */
|
|
2530
|
+
predictionRelayerKey?: string;
|
|
2531
|
+
/** Maximum notional per single trade in USD (default: 1000) */
|
|
2532
|
+
maxNotionalUSD: number;
|
|
2533
|
+
/** Maximum total exposure across all prediction markets in USD (default: 5000) */
|
|
2534
|
+
maxTotalExposureUSD: number;
|
|
2535
|
+
/** Target USDC allocation on Polygon in USD (default: 100) */
|
|
2536
|
+
polygonAllocationUSD: number;
|
|
2537
|
+
/** Allowed market categories (if empty, all categories). e.g. ["crypto", "politics", "sports"] */
|
|
2538
|
+
allowedCategories?: string[];
|
|
2539
|
+
/** Fee threshold in USD before triggering CCTP bridge to Base treasury (default: 10) */
|
|
2540
|
+
feeBridgeThresholdUSD: number;
|
|
2541
|
+
}
|
|
2542
|
+
type PredictionAction = 'buy_yes' | 'buy_no' | 'sell_yes' | 'sell_no' | 'hold';
|
|
2543
|
+
interface PredictionTradeSignal {
|
|
2544
|
+
/** Trading action */
|
|
2545
|
+
action: PredictionAction;
|
|
2546
|
+
/** Polymarket condition ID */
|
|
2547
|
+
marketConditionId: string;
|
|
2548
|
+
/** Human-readable market question (for logging/relay) */
|
|
2549
|
+
marketQuestion: string;
|
|
2550
|
+
/** Outcome index (0 = YES, 1 = NO for binary markets) */
|
|
2551
|
+
outcomeIndex: number;
|
|
2552
|
+
/** USDC amount to spend (for buy) or shares to sell (for sell) */
|
|
2553
|
+
amount: number;
|
|
2554
|
+
/** Limit price (0.01 - 0.99, represents probability) */
|
|
2555
|
+
limitPrice: number;
|
|
2556
|
+
/** Order type */
|
|
2557
|
+
orderType: 'limit' | 'market';
|
|
2558
|
+
/** Signal confidence (0.0 - 1.0) */
|
|
2559
|
+
confidence: number;
|
|
2560
|
+
/** LLM reasoning for this signal */
|
|
2561
|
+
reasoning?: string;
|
|
2562
|
+
}
|
|
2563
|
+
interface PredictionPosition {
|
|
2564
|
+
/** Polymarket condition ID */
|
|
2565
|
+
marketConditionId: string;
|
|
2566
|
+
/** Human-readable market question */
|
|
2567
|
+
marketQuestion: string;
|
|
2568
|
+
/** Outcome index (0 = YES, 1 = NO) */
|
|
2569
|
+
outcomeIndex: number;
|
|
2570
|
+
/** Outcome label ("Yes" or "No") */
|
|
2571
|
+
outcomeLabel: string;
|
|
2572
|
+
/** CTF token ID (ERC-1155) */
|
|
2573
|
+
tokenId: string;
|
|
2574
|
+
/** Number of outcome tokens held */
|
|
2575
|
+
balance: number;
|
|
2576
|
+
/** Average price paid per token (0-1) */
|
|
2577
|
+
averageEntryPrice: number;
|
|
2578
|
+
/** Current market price (0-1) */
|
|
2579
|
+
currentPrice: number;
|
|
2580
|
+
/** Unrealized PnL in USD: (currentPrice - averageEntryPrice) * balance */
|
|
2581
|
+
unrealizedPnl: number;
|
|
2582
|
+
/** Total USDC spent acquiring this position */
|
|
2583
|
+
costBasis: number;
|
|
2584
|
+
/** Market end date (unix timestamp) */
|
|
2585
|
+
endDate?: number;
|
|
2586
|
+
/** Market category (e.g., "crypto", "politics") */
|
|
2587
|
+
category?: string;
|
|
2588
|
+
}
|
|
2589
|
+
interface PredictionMarket {
|
|
2590
|
+
/** Polymarket condition ID */
|
|
2591
|
+
conditionId: string;
|
|
2592
|
+
/** Market question (e.g., "Will ETH hit $5000 by July?") */
|
|
2593
|
+
question: string;
|
|
2594
|
+
/** Market description */
|
|
2595
|
+
description: string;
|
|
2596
|
+
/** Category (e.g., "Crypto", "Politics", "Sports") */
|
|
2597
|
+
category: string;
|
|
2598
|
+
/** Outcome labels */
|
|
2599
|
+
outcomes: string[];
|
|
2600
|
+
/** Outcome token IDs (corresponding to outcomes array) */
|
|
2601
|
+
outcomeTokenIds: string[];
|
|
2602
|
+
/** Current prices for each outcome (0-1, sums to ~1) */
|
|
2603
|
+
outcomePrices: number[];
|
|
2604
|
+
/** 24h trading volume in USD */
|
|
2605
|
+
volume24h: number;
|
|
2606
|
+
/** Total liquidity in USD */
|
|
2607
|
+
liquidity: number;
|
|
2608
|
+
/** Market end/resolution date (unix timestamp) */
|
|
2609
|
+
endDate: number;
|
|
2610
|
+
/** Whether the market is still active for trading */
|
|
2611
|
+
active: boolean;
|
|
2612
|
+
/** Whether the market has been resolved */
|
|
2613
|
+
resolved: boolean;
|
|
2614
|
+
/** Winning outcome index (only set if resolved) */
|
|
2615
|
+
winningOutcome?: number;
|
|
2616
|
+
/** Resolution source URL */
|
|
2617
|
+
resolutionSource?: string;
|
|
2618
|
+
/** Number of unique traders */
|
|
2619
|
+
uniqueTraders?: number;
|
|
2620
|
+
}
|
|
2621
|
+
interface PredictionFill {
|
|
2622
|
+
/** Polymarket order ID */
|
|
2623
|
+
orderId: string;
|
|
2624
|
+
/** Polymarket trade ID (unique per fill) */
|
|
2625
|
+
tradeId: string;
|
|
2626
|
+
/** Condition ID */
|
|
2627
|
+
marketConditionId: string;
|
|
2628
|
+
/** Outcome index */
|
|
2629
|
+
outcomeIndex: number;
|
|
2630
|
+
/** Direction */
|
|
2631
|
+
side: 'BUY' | 'SELL';
|
|
2632
|
+
/** Fill price (0-1) */
|
|
2633
|
+
price: string;
|
|
2634
|
+
/** Fill size (number of outcome tokens) */
|
|
2635
|
+
size: string;
|
|
2636
|
+
/** Fee paid in USDC */
|
|
2637
|
+
fee: string;
|
|
2638
|
+
/** Fill timestamp (ms) */
|
|
2639
|
+
timestamp: number;
|
|
2640
|
+
/** Market question (for display) */
|
|
2641
|
+
marketQuestion?: string;
|
|
2642
|
+
/** Whether this was a maker fill */
|
|
2643
|
+
isMaker: boolean;
|
|
2644
|
+
/** CTF token ID (ERC-1155) for this outcome — used for CLOB price lookups */
|
|
2645
|
+
tokenId?: string;
|
|
2646
|
+
}
|
|
2647
|
+
interface PredictionOrderResult {
|
|
2648
|
+
/** Whether the order was accepted */
|
|
2649
|
+
success: boolean;
|
|
2650
|
+
/** Polymarket order ID */
|
|
2651
|
+
orderId?: string;
|
|
2652
|
+
/** Fill status */
|
|
2653
|
+
status: 'filled' | 'partially_filled' | 'resting' | 'cancelled' | 'error';
|
|
2654
|
+
/** Average fill price (if filled or partially filled) */
|
|
2655
|
+
avgPrice?: number;
|
|
2656
|
+
/** Total filled size */
|
|
2657
|
+
filledSize?: number;
|
|
2658
|
+
/** Error message (if error) */
|
|
2659
|
+
error?: string;
|
|
2660
|
+
}
|
|
2661
|
+
interface PredictionAccountSummary {
|
|
2662
|
+
/** USDC balance on Polygon */
|
|
2663
|
+
polygonUSDC: number;
|
|
2664
|
+
/** USDC balance on Base */
|
|
2665
|
+
baseUSDC: number;
|
|
2666
|
+
/** Total cost basis of all open prediction positions */
|
|
2667
|
+
totalExposure: number;
|
|
2668
|
+
/** Total unrealized PnL across all prediction positions */
|
|
2669
|
+
totalUnrealizedPnl: number;
|
|
2670
|
+
/** Number of markets with open positions */
|
|
2671
|
+
openMarketCount: number;
|
|
2672
|
+
/** Number of individual outcome positions */
|
|
2673
|
+
openPositionCount: number;
|
|
2674
|
+
/** Accumulated fees pending bridge to Base treasury */
|
|
2675
|
+
pendingFees: number;
|
|
2676
|
+
}
|
|
2677
|
+
interface RecordPredictionTradeParams {
|
|
2678
|
+
agentId: bigint;
|
|
2679
|
+
configHash: `0x${string}`;
|
|
2680
|
+
/** Encoded instrument: "POLY:{conditionId}:{outcomeIndex}" */
|
|
2681
|
+
instrument: string;
|
|
2682
|
+
/** true = BUY, false = SELL */
|
|
2683
|
+
isLong: boolean;
|
|
2684
|
+
/** USDC amount (6-decimal) */
|
|
2685
|
+
notionalUSD: bigint;
|
|
2686
|
+
/** Platform fee 0.2% (6-decimal) */
|
|
2687
|
+
feeUSD: bigint;
|
|
2688
|
+
/** keccak256(polymarketTradeId) */
|
|
2689
|
+
fillId: `0x${string}`;
|
|
2690
|
+
}
|
|
2691
|
+
/**
|
|
2692
|
+
* Prediction market strategy function signature.
|
|
2693
|
+
* Called once per prediction trading cycle.
|
|
2694
|
+
*
|
|
2695
|
+
* @param markets - Active prediction markets (filtered by config categories)
|
|
2696
|
+
* @param positions - Current open prediction positions
|
|
2697
|
+
* @param account - Account balances and exposure summary
|
|
2698
|
+
* @param llm - LLM adapter for reasoning
|
|
2699
|
+
* @param config - Agent configuration
|
|
2700
|
+
* @returns Array of prediction trade signals
|
|
2701
|
+
*/
|
|
2702
|
+
type PredictionStrategyFunction = (markets: PredictionMarket[], positions: PredictionPosition[], account: PredictionAccountSummary, llm: LLMAdapter, config: Record<string, unknown>) => Promise<PredictionTradeSignal[]>;
|
|
2703
|
+
|
|
2704
|
+
/**
|
|
2705
|
+
* Polymarket Client
|
|
2706
|
+
*
|
|
2707
|
+
* Wraps the @polymarket/clob-client for CLOB interaction (orders, positions)
|
|
2708
|
+
* and the Gamma API for market discovery (browsing, search, trending).
|
|
2709
|
+
*
|
|
2710
|
+
* Key details:
|
|
2711
|
+
* - CLOB is on Polygon (chain 137) — orders are off-chain, settlement is on-chain
|
|
2712
|
+
* - Gamma API is public/unauthenticated — used for market metadata
|
|
2713
|
+
* - EOA signing (SignatureType 0) — agent private key signs directly
|
|
2714
|
+
* - API key (L2 auth) derived once per session from wallet signature
|
|
2715
|
+
*/
|
|
2716
|
+
|
|
2717
|
+
declare class PolymarketClient {
|
|
2718
|
+
private readonly config;
|
|
2719
|
+
private clobClient;
|
|
2720
|
+
private apiCreds;
|
|
2721
|
+
private readonly signer;
|
|
2722
|
+
private readonly walletAddress;
|
|
2723
|
+
/** Vault mode: when true, orders use maker=vaultAddress with POLY_GNOSIS_SAFE signature type */
|
|
2724
|
+
private readonly vaultMode;
|
|
2725
|
+
/** Vault contract address (only set in vault mode) */
|
|
2726
|
+
private readonly vaultAddress;
|
|
2727
|
+
/** Cache for Gamma API market data (conditionId -> market) */
|
|
2728
|
+
private marketCache;
|
|
2729
|
+
private readonly CACHE_TTL_MS;
|
|
2730
|
+
constructor(privateKey: string, config?: Partial<PredictionConfig>, vaultOpts?: {
|
|
2731
|
+
/** Enable vault mode (maker=vaultAddress, signatureType=POLY_GNOSIS_SAFE) */
|
|
2732
|
+
vaultMode: boolean;
|
|
2733
|
+
/** Vault contract address on Polygon */
|
|
2734
|
+
vaultAddress: string;
|
|
2735
|
+
});
|
|
2736
|
+
/**
|
|
2737
|
+
* Initialize the CLOB client with L2 API credentials.
|
|
2738
|
+
* Must be called once before placing orders.
|
|
2739
|
+
*/
|
|
2740
|
+
initialize(): Promise<void>;
|
|
2741
|
+
/**
|
|
2742
|
+
* Check if the client is initialized with CLOB credentials.
|
|
2743
|
+
*/
|
|
2744
|
+
get isInitialized(): boolean;
|
|
2745
|
+
/**
|
|
2746
|
+
* Get the order book for a specific outcome token.
|
|
2747
|
+
*/
|
|
2748
|
+
getOrderBook(tokenId: string): Promise<{
|
|
2749
|
+
bids: OrderBookLevel[];
|
|
2750
|
+
asks: OrderBookLevel[];
|
|
2751
|
+
}>;
|
|
2752
|
+
/**
|
|
2753
|
+
* Get the midpoint price for an outcome token.
|
|
2754
|
+
*/
|
|
2755
|
+
getMidpointPrice(tokenId: string): Promise<number>;
|
|
2756
|
+
/**
|
|
2757
|
+
* Get the last trade price for an outcome token.
|
|
2758
|
+
*/
|
|
2759
|
+
getLastTradePrice(tokenId: string): Promise<number>;
|
|
2760
|
+
/**
|
|
2761
|
+
* Place a limit order on the CLOB.
|
|
2762
|
+
*/
|
|
2763
|
+
placeLimitOrder(params: {
|
|
2764
|
+
tokenId: string;
|
|
2765
|
+
price: number;
|
|
2766
|
+
size: number;
|
|
2767
|
+
side: 'BUY' | 'SELL';
|
|
2768
|
+
}): Promise<{
|
|
2769
|
+
orderId: string;
|
|
2770
|
+
success: boolean;
|
|
2771
|
+
}>;
|
|
2772
|
+
/**
|
|
2773
|
+
* Place a market order (aggressive limit at best available price).
|
|
2774
|
+
*/
|
|
2775
|
+
placeMarketOrder(params: {
|
|
2776
|
+
tokenId: string;
|
|
2777
|
+
amount: number;
|
|
2778
|
+
side: 'BUY' | 'SELL';
|
|
2779
|
+
}): Promise<{
|
|
2780
|
+
orderId: string;
|
|
2781
|
+
success: boolean;
|
|
2782
|
+
}>;
|
|
2783
|
+
/**
|
|
2784
|
+
* Cancel an open order by ID.
|
|
2785
|
+
*/
|
|
2786
|
+
cancelOrder(orderId: string): Promise<boolean>;
|
|
2787
|
+
/**
|
|
2788
|
+
* Cancel all open orders.
|
|
2789
|
+
*/
|
|
2790
|
+
cancelAllOrders(): Promise<boolean>;
|
|
2791
|
+
/**
|
|
2792
|
+
* Get open orders for the agent's wallet.
|
|
2793
|
+
*/
|
|
2794
|
+
getOpenOrders(): Promise<any[]>;
|
|
2795
|
+
/**
|
|
2796
|
+
* Get trade history (fills) for the agent's wallet.
|
|
2797
|
+
*/
|
|
2798
|
+
getTradeHistory(): Promise<PredictionFill[]>;
|
|
2799
|
+
/**
|
|
2800
|
+
* Get active prediction markets from Gamma API.
|
|
2801
|
+
*/
|
|
2802
|
+
getMarkets(params?: {
|
|
2803
|
+
limit?: number;
|
|
2804
|
+
offset?: number;
|
|
2805
|
+
category?: string;
|
|
2806
|
+
active?: boolean;
|
|
2807
|
+
}): Promise<PredictionMarket[]>;
|
|
2808
|
+
/**
|
|
2809
|
+
* Get a single market by condition ID.
|
|
2810
|
+
*/
|
|
2811
|
+
getMarketByConditionId(conditionId: string): Promise<PredictionMarket | null>;
|
|
2812
|
+
/**
|
|
2813
|
+
* Search markets by query string.
|
|
2814
|
+
*/
|
|
2815
|
+
searchMarkets(query: string, limit?: number): Promise<PredictionMarket[]>;
|
|
2816
|
+
/**
|
|
2817
|
+
* Get trending markets sorted by volume.
|
|
2818
|
+
*/
|
|
2819
|
+
getTrendingMarkets(limit?: number): Promise<PredictionMarket[]>;
|
|
2820
|
+
getWalletAddress(): string;
|
|
2821
|
+
/**
|
|
2822
|
+
* Get the effective maker address for CLOB orders.
|
|
2823
|
+
* In vault mode, this is the vault contract address.
|
|
2824
|
+
* In normal mode, this is the agent's EOA address.
|
|
2825
|
+
*/
|
|
2826
|
+
getMakerAddress(): string;
|
|
2827
|
+
/**
|
|
2828
|
+
* Whether the client is operating in vault mode.
|
|
2829
|
+
*/
|
|
2830
|
+
get isVaultMode(): boolean;
|
|
2831
|
+
/**
|
|
2832
|
+
* Get the vault address (null if not in vault mode).
|
|
2833
|
+
*/
|
|
2834
|
+
getVaultAddress(): string | undefined;
|
|
2835
|
+
private ensureInitialized;
|
|
2836
|
+
private parseGammaMarket;
|
|
2837
|
+
private parseRawFill;
|
|
2838
|
+
}
|
|
2839
|
+
interface OrderBookLevel {
|
|
2840
|
+
price: number;
|
|
2841
|
+
size: number;
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
/**
|
|
2845
|
+
* Polymarket Trade ID → bytes32 Helpers
|
|
2846
|
+
*
|
|
2847
|
+
* Converts Polymarket trade/order IDs to bytes32 fill IDs for on-chain recording
|
|
2848
|
+
* via Router.recordPerpTrade(). Uses keccak256 hashing for consistent 32-byte output.
|
|
2849
|
+
*
|
|
2850
|
+
* Unlike Hyperliquid (which has its own EIP-712 signing domain), Polymarket signing
|
|
2851
|
+
* is handled internally by @polymarket/clob-client. This module only handles the
|
|
2852
|
+
* trade-to-fillId conversion needed for on-chain deduplication.
|
|
2853
|
+
*/
|
|
2854
|
+
/**
|
|
2855
|
+
* Convert a Polymarket trade ID to a bytes32 fill ID for on-chain recording.
|
|
2856
|
+
* Uses keccak256 to ensure consistent 32-byte output.
|
|
2857
|
+
*
|
|
2858
|
+
* @param tradeId - Polymarket trade/order ID string
|
|
2859
|
+
* @returns bytes32 hex string for Router.recordPerpTrade fillId param
|
|
2860
|
+
*/
|
|
2861
|
+
declare function tradeIdToBytes32(tradeId: string): `0x${string}`;
|
|
2862
|
+
/**
|
|
2863
|
+
* Convert a Polymarket order ID to a bytes32 fill ID (fallback).
|
|
2864
|
+
*/
|
|
2865
|
+
declare function orderIdToBytes32(orderId: string): `0x${string}`;
|
|
2866
|
+
/**
|
|
2867
|
+
* Encode a prediction trade as a Router.recordPerpTrade instrument string.
|
|
2868
|
+
*
|
|
2869
|
+
* Format: "POLY:{conditionId}:{outcomeIndex}"
|
|
2870
|
+
* Example: "POLY:0x1a2b3c4d5e6f7890:0"
|
|
2871
|
+
*
|
|
2872
|
+
* The indexer detects the "POLY:" prefix and routes to the prediction tables,
|
|
2873
|
+
* parsing the conditionId and outcomeIndex from the string.
|
|
2874
|
+
*
|
|
2875
|
+
* @param conditionId - Polymarket condition ID (hex string)
|
|
2876
|
+
* @param outcomeIndex - 0 = YES, 1 = NO (for binary markets)
|
|
2877
|
+
*/
|
|
2878
|
+
declare function encodePredictionInstrument(conditionId: string, outcomeIndex: number): string;
|
|
2879
|
+
/**
|
|
2880
|
+
* Decode a POLY: instrument string back to its components.
|
|
2881
|
+
* Returns null if the string is not a valid prediction instrument.
|
|
2882
|
+
*
|
|
2883
|
+
* @param instrument - Router instrument string (e.g., "POLY:0x1a2b3c4d5e6f7890:0")
|
|
2884
|
+
*/
|
|
2885
|
+
declare function decodePredictionInstrument(instrument: string): {
|
|
2886
|
+
conditionId: string;
|
|
2887
|
+
outcomeIndex: number;
|
|
2888
|
+
} | null;
|
|
2889
|
+
/**
|
|
2890
|
+
* Calculate the platform fee for a prediction trade.
|
|
2891
|
+
* Fee rate: 0.2% (20 basis points) of notional.
|
|
2892
|
+
*
|
|
2893
|
+
* @param notionalUSD - Trade notional in 6-decimal format (e.g., 65_000000 = $65)
|
|
2894
|
+
* @returns Fee amount in 6-decimal format
|
|
2895
|
+
*/
|
|
2896
|
+
declare function calculatePredictionFee(notionalUSD: bigint): bigint;
|
|
2897
|
+
|
|
2898
|
+
/**
|
|
2899
|
+
* Polymarket Order Management
|
|
2900
|
+
*
|
|
2901
|
+
* Handles order placement and cancellation on the Polymarket CLOB.
|
|
2902
|
+
* Wraps PolymarketClient with trade signal processing and fill tracking.
|
|
2903
|
+
*
|
|
2904
|
+
* Orders are placed on Polygon via the CLOB REST API.
|
|
2905
|
+
* Fills are then recorded on Base via the recorder module.
|
|
2906
|
+
*/
|
|
2907
|
+
|
|
2908
|
+
declare class PredictionOrderManager {
|
|
2909
|
+
private readonly client;
|
|
2910
|
+
private readonly config;
|
|
2911
|
+
/** Recent fills tracked for recording */
|
|
2912
|
+
private readonly recentFills;
|
|
2913
|
+
private readonly MAX_RECENT_FILLS;
|
|
2914
|
+
constructor(client: PolymarketClient, config: PredictionConfig);
|
|
2915
|
+
/**
|
|
2916
|
+
* Execute a prediction trade signal.
|
|
2917
|
+
* Routes to limit or market order based on signal.orderType.
|
|
2918
|
+
*/
|
|
2919
|
+
executeSignal(signal: PredictionTradeSignal): Promise<PredictionOrderResult>;
|
|
2920
|
+
/**
|
|
2921
|
+
* Cancel an open order by ID.
|
|
2922
|
+
*/
|
|
2923
|
+
cancelOrder(orderId: string): Promise<boolean>;
|
|
2924
|
+
/**
|
|
2925
|
+
* Cancel all open orders.
|
|
2926
|
+
*/
|
|
2927
|
+
cancelAllOrders(): Promise<boolean>;
|
|
2928
|
+
/**
|
|
2929
|
+
* Poll for new fills since last check.
|
|
2930
|
+
* Returns fills that haven't been seen before.
|
|
2931
|
+
*/
|
|
2932
|
+
pollNewFills(): Promise<PredictionFill[]>;
|
|
2933
|
+
/**
|
|
2934
|
+
* Get recent fills (from local cache).
|
|
2935
|
+
*/
|
|
2936
|
+
getRecentFills(): PredictionFill[];
|
|
2937
|
+
/**
|
|
2938
|
+
* Check if a signal violates risk limits.
|
|
2939
|
+
* Returns error string if violated, null if OK.
|
|
2940
|
+
*/
|
|
2941
|
+
private checkRiskLimits;
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
/**
|
|
2945
|
+
* Polymarket Position Tracking
|
|
2946
|
+
*
|
|
2947
|
+
* Tracks CTF token balances on Polygon and calculates unrealized PnL.
|
|
2948
|
+
* Positions are ERC-1155 tokens representing market outcomes.
|
|
2949
|
+
*
|
|
2950
|
+
* Cost basis is tracked locally (CLOB fills → entry prices).
|
|
2951
|
+
* Current prices are fetched from the CLOB order book.
|
|
2952
|
+
*/
|
|
2953
|
+
|
|
2954
|
+
declare class PredictionPositionManager {
|
|
2955
|
+
private readonly client;
|
|
2956
|
+
private readonly config;
|
|
2957
|
+
/** Local position tracking (conditionId:outcomeIndex -> position data) */
|
|
2958
|
+
private positions;
|
|
2959
|
+
/** Cache TTL */
|
|
2960
|
+
private lastPriceRefresh;
|
|
2961
|
+
private readonly PRICE_REFRESH_MS;
|
|
2962
|
+
constructor(client: PolymarketClient, config: PredictionConfig);
|
|
2963
|
+
/**
|
|
2964
|
+
* Get all open prediction positions with current prices.
|
|
2965
|
+
*/
|
|
2966
|
+
getPositions(forceRefresh?: boolean): Promise<PredictionPosition[]>;
|
|
2967
|
+
/**
|
|
2968
|
+
* Get a specific position.
|
|
2969
|
+
*/
|
|
2970
|
+
getPosition(conditionId: string, outcomeIndex: number): Promise<PredictionPosition | null>;
|
|
2971
|
+
/**
|
|
2972
|
+
* Get account summary (balances, exposure, PnL).
|
|
2973
|
+
*/
|
|
2974
|
+
getAccountSummary(): Promise<PredictionAccountSummary>;
|
|
2975
|
+
/**
|
|
2976
|
+
* Get total exposure across all positions.
|
|
2977
|
+
*/
|
|
2978
|
+
getTotalExposure(): number;
|
|
2979
|
+
/**
|
|
2980
|
+
* Get total unrealized PnL.
|
|
2981
|
+
*/
|
|
2982
|
+
getTotalUnrealizedPnl(): number;
|
|
2983
|
+
/**
|
|
2984
|
+
* Process a fill and update position tracking.
|
|
2985
|
+
* Called when a new fill is detected by the order manager.
|
|
2986
|
+
*/
|
|
2987
|
+
processFill(fill: PredictionFill): void;
|
|
2988
|
+
/**
|
|
2989
|
+
* Process multiple fills (batch update).
|
|
2990
|
+
*/
|
|
2991
|
+
processFills(fills: PredictionFill[]): void;
|
|
2992
|
+
/**
|
|
2993
|
+
* Mark a market as resolved. Positions settle at $0 or $1.
|
|
2994
|
+
*/
|
|
2995
|
+
resolveMarket(conditionId: string, winningOutcome: number): void;
|
|
2996
|
+
/**
|
|
2997
|
+
* Export position state for persistence across restarts.
|
|
2998
|
+
*/
|
|
2999
|
+
exportState(): LocalPosition[];
|
|
3000
|
+
/**
|
|
3001
|
+
* Import position state from previous session.
|
|
3002
|
+
*/
|
|
3003
|
+
importState(state: LocalPosition[]): void;
|
|
3004
|
+
/**
|
|
3005
|
+
* Refresh current prices for all open positions from CLOB.
|
|
3006
|
+
*/
|
|
3007
|
+
private refreshPrices;
|
|
3008
|
+
private toExternalPosition;
|
|
3009
|
+
}
|
|
3010
|
+
interface LocalPosition {
|
|
3011
|
+
marketConditionId: string;
|
|
3012
|
+
outcomeIndex: number;
|
|
3013
|
+
marketQuestion: string;
|
|
3014
|
+
tokenId: string;
|
|
3015
|
+
balance: number;
|
|
3016
|
+
totalBought: number;
|
|
3017
|
+
totalSold: number;
|
|
3018
|
+
totalCostBasis: number;
|
|
3019
|
+
totalProceeds: number;
|
|
3020
|
+
averageEntryPrice: number;
|
|
3021
|
+
currentPrice: number;
|
|
3022
|
+
category?: string;
|
|
3023
|
+
endDate?: number;
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
/**
|
|
3027
|
+
* Prediction Trade Recorder
|
|
3028
|
+
*
|
|
3029
|
+
* Records Polymarket prediction fills on Base via Router.recordPerpTrade().
|
|
3030
|
+
* Uses the POLY: instrument prefix convention so the indexer can route
|
|
3031
|
+
* prediction trades to dedicated tables.
|
|
3032
|
+
*
|
|
3033
|
+
* This is a direct adaptation of the perp/recorder.ts pattern:
|
|
3034
|
+
* - Each fill is individually recorded on-chain
|
|
3035
|
+
* - Fill ID deduplication prevents double-recording (contract enforces)
|
|
3036
|
+
* - Retry queue handles transient failures
|
|
3037
|
+
* - notionalUSD = price * size * 1e6 (6-decimal)
|
|
3038
|
+
* - feeUSD = notionalUSD * 20 / 10000 (0.2%, 6-decimal)
|
|
3039
|
+
*/
|
|
3040
|
+
|
|
3041
|
+
declare class PredictionTradeRecorder {
|
|
3042
|
+
private readonly publicClient;
|
|
3043
|
+
private readonly walletClient;
|
|
3044
|
+
private readonly account;
|
|
3045
|
+
private readonly agentId;
|
|
3046
|
+
private configHash;
|
|
3047
|
+
/** Retry queue for failed recordings */
|
|
3048
|
+
private retryQueue;
|
|
3049
|
+
/** Set of fill IDs already recorded (or in-progress) to prevent local dups */
|
|
3050
|
+
private recordedFills;
|
|
3051
|
+
/** Timer for processing retry queue */
|
|
3052
|
+
private retryTimer;
|
|
3053
|
+
/** Accumulated fees pending bridge to Base treasury (in USD, 6-decimal) */
|
|
3054
|
+
private accumulatedFees;
|
|
3055
|
+
constructor(opts: {
|
|
3056
|
+
privateKey: `0x${string}`;
|
|
3057
|
+
rpcUrl?: string;
|
|
3058
|
+
agentId: bigint;
|
|
3059
|
+
configHash: `0x${string}`;
|
|
3060
|
+
});
|
|
3061
|
+
/**
|
|
3062
|
+
* Record a prediction fill on-chain.
|
|
3063
|
+
* Converts the Polymarket fill into recordPerpTrade params with POLY: prefix.
|
|
3064
|
+
*/
|
|
3065
|
+
recordFill(fill: PredictionFill): Promise<{
|
|
3066
|
+
success: boolean;
|
|
3067
|
+
txHash?: string;
|
|
3068
|
+
error?: string;
|
|
3069
|
+
}>;
|
|
3070
|
+
/**
|
|
3071
|
+
* Update the config hash (when epoch changes).
|
|
3072
|
+
*/
|
|
3073
|
+
updateConfigHash(configHash: `0x${string}`): void;
|
|
3074
|
+
/**
|
|
3075
|
+
* Get the number of fills pending retry.
|
|
3076
|
+
*/
|
|
3077
|
+
get pendingRetries(): number;
|
|
3078
|
+
/**
|
|
3079
|
+
* Get the number of fills recorded (local dedup set size).
|
|
3080
|
+
*/
|
|
3081
|
+
get recordedCount(): number;
|
|
3082
|
+
/**
|
|
3083
|
+
* Get accumulated fees pending bridge (6-decimal USD).
|
|
3084
|
+
*/
|
|
3085
|
+
get pendingFees(): bigint;
|
|
3086
|
+
/**
|
|
3087
|
+
* Get accumulated fees as human-readable USD.
|
|
3088
|
+
*/
|
|
3089
|
+
get pendingFeesUSD(): number;
|
|
3090
|
+
/**
|
|
3091
|
+
* Reset accumulated fees (after bridge to treasury).
|
|
3092
|
+
*/
|
|
3093
|
+
resetAccumulatedFees(): void;
|
|
3094
|
+
/**
|
|
3095
|
+
* Stop the recorder (clear retry timer).
|
|
3096
|
+
*/
|
|
3097
|
+
stop(): void;
|
|
3098
|
+
/**
|
|
3099
|
+
* Submit a recordPerpTrade transaction on Base.
|
|
3100
|
+
*/
|
|
3101
|
+
private submitRecord;
|
|
3102
|
+
/**
|
|
3103
|
+
* Process the retry queue — attempt to re-submit failed recordings.
|
|
3104
|
+
*/
|
|
3105
|
+
private processRetryQueue;
|
|
3106
|
+
/**
|
|
3107
|
+
* Calculate notional USD from a fill (6-decimal).
|
|
3108
|
+
* notionalUSD = price * size * 1e6
|
|
3109
|
+
*/
|
|
3110
|
+
private calculateNotionalUSD;
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
/**
|
|
3114
|
+
* Polymarket Market Browser
|
|
3115
|
+
*
|
|
3116
|
+
* High-level interface for market discovery via the Gamma API.
|
|
3117
|
+
* Used by the prediction strategy function to get curated market data
|
|
3118
|
+
* for LLM consumption.
|
|
3119
|
+
*
|
|
3120
|
+
* The Gamma API is public and requires no authentication.
|
|
3121
|
+
* Responses are cached for 60 seconds to reduce API load.
|
|
3122
|
+
*/
|
|
3123
|
+
|
|
3124
|
+
/** Known Polymarket market categories */
|
|
3125
|
+
declare const MARKET_CATEGORIES: readonly ["crypto", "politics", "sports", "entertainment", "science", "business", "culture", "weather", "tech"];
|
|
3126
|
+
type MarketCategory = (typeof MARKET_CATEGORIES)[number];
|
|
3127
|
+
declare class MarketBrowser {
|
|
3128
|
+
private readonly gammaUrl;
|
|
3129
|
+
private readonly allowedCategories;
|
|
3130
|
+
/** Cache for market listings */
|
|
3131
|
+
private listCache;
|
|
3132
|
+
private readonly CACHE_TTL_MS;
|
|
3133
|
+
constructor(config?: Partial<PredictionConfig>);
|
|
3134
|
+
/**
|
|
3135
|
+
* Get active markets, optionally filtered by category.
|
|
3136
|
+
* Results are sorted by volume (highest first).
|
|
3137
|
+
*/
|
|
3138
|
+
getActiveMarkets(params?: {
|
|
3139
|
+
category?: string;
|
|
3140
|
+
limit?: number;
|
|
3141
|
+
offset?: number;
|
|
3142
|
+
}): Promise<PredictionMarket[]>;
|
|
3143
|
+
/**
|
|
3144
|
+
* Search markets by query text.
|
|
3145
|
+
*/
|
|
3146
|
+
searchMarkets(query: string, limit?: number): Promise<PredictionMarket[]>;
|
|
3147
|
+
/**
|
|
3148
|
+
* Get trending markets (highest 24h volume).
|
|
3149
|
+
*/
|
|
3150
|
+
getTrendingMarkets(limit?: number): Promise<PredictionMarket[]>;
|
|
3151
|
+
/**
|
|
3152
|
+
* Get markets expiring soon (within N days).
|
|
3153
|
+
*/
|
|
3154
|
+
getExpiringMarkets(withinDays?: number, limit?: number): Promise<PredictionMarket[]>;
|
|
3155
|
+
/**
|
|
3156
|
+
* Get recently resolved markets (for PnL tracking).
|
|
3157
|
+
*/
|
|
3158
|
+
getRecentlyResolved(limit?: number): Promise<PredictionMarket[]>;
|
|
3159
|
+
/**
|
|
3160
|
+
* Get a single market's details by condition ID.
|
|
3161
|
+
*/
|
|
3162
|
+
getMarketDetail(conditionId: string): Promise<PredictionMarket | null>;
|
|
3163
|
+
/**
|
|
3164
|
+
* Build a concise market summary string for LLM context.
|
|
3165
|
+
* Keeps the prompt token count manageable.
|
|
3166
|
+
*/
|
|
3167
|
+
formatMarketsForLLM(markets: PredictionMarket[], maxMarkets?: number): string;
|
|
3168
|
+
private fetchGamma;
|
|
3169
|
+
private parseMarket;
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* Prediction Funding Module
|
|
3174
|
+
*
|
|
3175
|
+
* Manages USDC transfers between Base and Polygon using Circle's CCTP V2.
|
|
3176
|
+
* Adapted from the Hyperliquid funding module (perp/funding.ts).
|
|
3177
|
+
*
|
|
3178
|
+
* Flow:
|
|
3179
|
+
* Deposit: Base USDC → (CCTP burn) → Circle attestation → (CCTP mint) → Polygon USDC
|
|
3180
|
+
* Withdraw: Polygon USDC → (CCTP burn) → Circle attestation → (CCTP mint) → Base USDC
|
|
3181
|
+
*
|
|
3182
|
+
* Simpler than Hyperliquid funding because Polygon supports CCTP V2 directly —
|
|
3183
|
+
* no intermediate chain or core deposit wallet needed.
|
|
3184
|
+
*/
|
|
3185
|
+
|
|
3186
|
+
interface PredictionFundingConfig {
|
|
3187
|
+
privateKey: `0x${string}`;
|
|
3188
|
+
baseRpcUrl?: string;
|
|
3189
|
+
polygonRpcUrl?: string;
|
|
3190
|
+
/** Override mint recipient on Polygon (e.g., vault address in vault mode).
|
|
3191
|
+
* When set, depositToPolygon() sends USDC to this address instead of the agent EOA. */
|
|
3192
|
+
polygonRecipient?: Address;
|
|
3193
|
+
}
|
|
3194
|
+
interface BridgeResult {
|
|
3195
|
+
success: boolean;
|
|
3196
|
+
amount: bigint;
|
|
3197
|
+
burnTxHash?: Hash;
|
|
3198
|
+
receiveTxHash?: Hash;
|
|
3199
|
+
error?: string;
|
|
3200
|
+
duration?: number;
|
|
3201
|
+
}
|
|
3202
|
+
type BridgeStep = 'approve_usdc' | 'cctp_burn' | 'wait_attestation' | 'cctp_receive';
|
|
3203
|
+
declare class PredictionFunding {
|
|
3204
|
+
private readonly basePublic;
|
|
3205
|
+
private readonly baseWallet;
|
|
3206
|
+
private readonly polygonPublic;
|
|
3207
|
+
private readonly polygonWallet;
|
|
3208
|
+
private readonly account;
|
|
3209
|
+
/** Override recipient for deposits to Polygon (vault address in vault mode) */
|
|
3210
|
+
private readonly polygonRecipient;
|
|
3211
|
+
constructor(config: PredictionFundingConfig);
|
|
3212
|
+
/** Get USDC balance on Base (6-decimal) */
|
|
3213
|
+
getBaseUSDCBalance(): Promise<bigint>;
|
|
3214
|
+
/** Get USDC balance on Polygon (6-decimal) */
|
|
3215
|
+
getPolygonUSDCBalance(): Promise<bigint>;
|
|
3216
|
+
/** Get MATIC balance on Polygon for gas (wei) */
|
|
3217
|
+
getPolygonGasBalance(): Promise<bigint>;
|
|
3218
|
+
/**
|
|
3219
|
+
* Bridge USDC from Base to Polygon via CCTP V2.
|
|
3220
|
+
*
|
|
3221
|
+
* Steps:
|
|
3222
|
+
* 1. Approve USDC on Base for TokenMessengerV2
|
|
3223
|
+
* 2. Call depositForBurn (Base → Polygon)
|
|
3224
|
+
* 3. Wait for Circle attestation (~1-5 minutes)
|
|
3225
|
+
* 4. Call receiveMessage on Polygon
|
|
3226
|
+
*/
|
|
3227
|
+
depositToPolygon(amount: bigint, onStep?: (step: BridgeStep) => void): Promise<BridgeResult>;
|
|
3228
|
+
/**
|
|
3229
|
+
* Bridge USDC from Polygon back to Base via CCTP V2.
|
|
3230
|
+
* Used for fee collection (bridge accumulated fees to Base treasury).
|
|
3231
|
+
*/
|
|
3232
|
+
withdrawToBase(amount: bigint, onStep?: (step: BridgeStep) => void): Promise<BridgeResult>;
|
|
3233
|
+
/** Convert address to bytes32 (left-padded) for CCTP mintRecipient */
|
|
3234
|
+
private addressToBytes32;
|
|
3235
|
+
/** Approve USDC spend if needed (maxUint256 pattern) */
|
|
3236
|
+
private approveIfNeeded;
|
|
3237
|
+
/** Extract MessageSent bytes from a CCTP burn transaction receipt */
|
|
3238
|
+
private extractMessageFromReceipt;
|
|
3239
|
+
/** Wait for Circle attestation (polls Iris API) */
|
|
3240
|
+
private waitForAttestation;
|
|
3241
|
+
}
|
|
3242
|
+
|
|
2198
3243
|
/**
|
|
2199
3244
|
* Secure Environment Storage
|
|
2200
3245
|
*
|
|
@@ -2238,6 +3283,6 @@ declare function decryptEnvFile(encPath: string, passphrase: string): Record<str
|
|
|
2238
3283
|
declare function loadSecureEnv(basePath: string, passphrase?: string): boolean;
|
|
2239
3284
|
|
|
2240
3285
|
/** @exagent/agent package version — update alongside package.json */
|
|
2241
|
-
declare const AGENT_VERSION = "0.1.
|
|
3286
|
+
declare const AGENT_VERSION = "0.1.40";
|
|
2242
3287
|
|
|
2243
|
-
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 };
|
|
3288
|
+
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 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, 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 };
|