@buildaureon/sdk 0.1.1 → 0.1.7

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.
@@ -1,635 +1,710 @@
1
- # Data Contracts Reference
2
-
3
- This document defines the field-level data contracts used across `@buildaureon/sdk`. These structures are exported directly from `src/types/*` and match the JSON schemas returned by the hosted AUREON API.
4
-
5
- Cross-links: [Client API Reference](./client-api.md) | [Architecture Guide](./architecture.md) | [Authentication Guide](./auth.md) | [Integration Guide](./integration-guide.md)
6
-
7
- ---
8
-
9
- ## 1. Document Overview
10
-
11
- Every domain model in the AUREON system has a corresponding TypeScript type and representation in our public API.
12
-
13
- ```mermaid
14
- flowchart LR
15
- API[AUREON API JSON] --> Types[sdk/src/types]
16
- Types --> Client[AureonClient Outputs]
17
- Types --> Docs[This Reference Document]
18
- ```
19
-
20
- This guide details each model, its fields, TypeScript types, constraints, and includes mock JSON examples.
21
-
22
- ---
23
-
24
- ## 2. Objective Domain
25
-
26
- Objectives represent the core primitives of AUREON. Instead of executing one-off transactions, operators register continuous rules (e.g., "Maintain a 20% stablecoin reserve").
27
-
28
- ### ObjectiveStatus
29
-
30
- Describes the lifecycle state of a registered financial compass objective:
31
-
32
- * `draft`: The objective is created but not active in background evaluation loops.
33
- * `validated`: The objective has passed initial syntax and balance sanity checks.
34
- * `active`: The objective is being actively checked by the live-mark watchdog engine.
35
- * `paused`: Evaluation is suspended. No automated alerts or restores will trigger.
36
- * `cancelled`: The objective is terminated permanently. It cannot be reactivated.
37
- * `completed`: The objective successfully achieved its policy goals and is now archived.
38
-
39
- ```ts
40
- export type ObjectiveStatus = "draft" | "validated" | "active" | "paused" | "cancelled" | "completed";
41
- ```
42
-
43
- ### ObjectiveKind
44
-
45
- Defines the rule or mathematical formula governing the objective:
46
-
47
- * `stable_allocation`: Monitors stablecoin assets to keep them at a specific proportion of the total portfolio value.
48
- * `balanced_portfolio`: Rebalances multiple assets to keep them near defined target weights relative to each other.
49
- * `risk_ceiling`: Monitors the volatility or risk score of portfolio assets, alerting or rebalancing if it crosses a configured limit.
50
- * `reward_reinvestment`: Automatically redirects yield, rewards, or idle gas tokens back into designated asset sleeves.
51
-
52
- ```ts
53
- export type ObjectiveKind = "stable_allocation" | "balanced_portfolio" | "risk_ceiling" | "reward_reinvestment";
54
- ```
55
-
56
- ### ObjectivePriority
57
-
58
- Prioritizes resource allocation and execution order when multiple rules compete for liquidity or gas limits:
59
- `low` · `medium` · `high` · `critical` (default is `high`).
60
-
61
- ```ts
62
- export type ObjectivePriority = "low" | "medium" | "high" | "critical";
63
- ```
64
-
65
- ### ObjectiveAutomationMode
66
-
67
- Determines how policy violations are corrected:
68
-
69
- * `auto` — Automatic restore coordination (SDK **only** supported mode; default).
70
- * `manual` — Operator utility Approve flow. Not used for SDK agent integrations.
71
-
72
- ```ts
73
- export type ObjectiveAutomationMode = "manual" | "auto";
74
- ```
75
-
76
- For `@buildaureon/sdk`, always omit `automationMode` or pass `"auto"`.
77
-
78
- ### ObjectivePolicy
79
-
80
- Specifies the mathematical parameters governing target bounds:
81
-
82
- ```ts
83
- export interface ObjectivePolicy {
84
- /** Target weight fraction between 0.0 and 1.0 (e.g., 0.25 represents 25%) */
85
- targetWeight: number;
86
- /** Allowed deviation tolerance (e.g., 0.05 represents +-5% deviation window) */
87
- tolerance: number;
88
- /** Optional risk ceiling score when kind is risk_ceiling */
89
- maxRiskScore?: number;
90
- /** Optional fraction of rewards to redirect when kind is reward_reinvestment */
91
- reinvestRatio?: number;
92
- /** Holding symbol when tracking a specific asset (e.g., "WETH") */
93
- targetSymbol?: string;
94
- /** Automatically generated human-readable policy summary */
95
- summary: string;
96
- }
97
- ```
98
-
99
- ### Objective
100
-
101
- The main database record returned by objective endpoints:
102
-
103
- ```ts
104
- export interface Objective {
105
- id: string;
106
- name: string;
107
- kind: ObjectiveKind;
108
- status: ObjectiveStatus;
109
- priority: ObjectivePriority;
110
- automationMode: ObjectiveAutomationMode;
111
- policy: ObjectivePolicy;
112
- ownerId: string;
113
- createdAt: string;
114
- updatedAt: string;
115
- lastEvaluatedAt: string | null;
116
- lastExecutionId: string | null;
117
- }
118
- ```
119
-
120
- #### JSON Representation Example
121
- ```json
122
- {
123
- "id": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
124
- "name": "USDG Buffer Protection",
125
- "kind": "stable_allocation",
126
- "status": "active",
127
- "priority": "high",
128
- "automationMode": "auto",
129
- "policy": {
130
- "targetWeight": 0.2,
131
- "tolerance": 0.02,
132
- "summary": "Maintain 20.0% stable allocation within ±2.0%"
133
- },
134
- "ownerId": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
135
- "createdAt": "2026-07-15T12:00:00.000Z",
136
- "updatedAt": "2026-07-15T12:30:00.000Z",
137
- "lastEvaluatedAt": "2026-07-15T22:45:00.000Z",
138
- "lastExecutionId": "exec_01h8v5t7p8p3z2v1q45r3m2e99"
139
- }
140
- ```
141
-
142
- ### Inputs
143
-
144
- #### `CreateObjectiveInput`
145
- Passed to `createObjective` to register a new rule:
146
- * `name` (Required): String, minimum length of 3 characters.
147
- * `kind` (Required): Supported kind enum.
148
- * `targetWeight` (Required): Number between 0.0 and 1.0.
149
- * `tolerance` (Required): Number between 0.0 and 0.5.
150
- * `priority` (Optional): Defaults to `high`.
151
- * `targetSymbol` (Required if kind is `balanced_portfolio`): Token symbol.
152
- * `automationMode` (Optional): Defaults to `auto` in the SDK.
153
-
154
- #### `UpdateObjectiveInput`
155
- Passed to `updateObjective` for partial updates. `targetSymbol` and `automationMode` are fixed at creation and cannot be updated.
156
-
157
- ```ts
158
- export interface UpdateObjectiveInput {
159
- name?: string;
160
- priority?: ObjectivePriority;
161
- targetWeight?: number;
162
- tolerance?: number;
163
- maxRiskScore?: number;
164
- reinvestRatio?: number;
165
- targetSymbol?: never; // Disallowed on updates
166
- automationMode?: never; // Disallowed on updates
167
- }
168
- ```
169
-
170
- ---
171
-
172
- ## 3. Portfolio Domain
173
-
174
- Tracks the capital distribution of an authenticated wallet address. Portfolios are divided into asset sleeves (e.g., stablecoins, stocks, gas).
175
-
176
- ### PortfolioPosition
177
-
178
- Represents a single asset holding:
179
-
180
- ```ts
181
- export interface PortfolioPosition {
182
- id: string;
183
- symbol: string;
184
- name: string;
185
- category: "stable" | "stock_token" | "gas" | "other";
186
- quantity: number;
187
- markPriceUsd: number;
188
- notionalUsd: number;
189
- weight: number;
190
- updatedAt: string;
191
- }
192
- ```
193
-
194
- ### PortfolioSnapshot
195
-
196
- An immutable snapshot of the total wallet allocation:
197
-
198
- ```ts
199
- export interface PortfolioSnapshot {
200
- portfolioId: string;
201
- totalNotionalUsd: number;
202
- stableWeight: number;
203
- stockTokenWeight: number;
204
- gasWeight: number;
205
- positions: PortfolioPosition[];
206
- asOf: string;
207
- }
208
- ```
209
-
210
- #### JSON Representation Example
211
- ```json
212
- {
213
- "portfolioId": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
214
- "totalNotionalUsd": 50000.0,
215
- "stableWeight": 0.205,
216
- "stockTokenWeight": 0.702,
217
- "gasWeight": 0.093,
218
- "positions": [
219
- {
220
- "id": "pos_usdg",
221
- "symbol": "USDG",
222
- "name": "Aureon Stable Dollar",
223
- "category": "stable",
224
- "quantity": 10250,
225
- "markPriceUsd": 1.0,
226
- "notionalUsd": 10250.0,
227
- "weight": 0.205,
228
- "updatedAt": "2026-07-15T22:45:00.000Z"
229
- },
230
- {
231
- "id": "pos_weth",
232
- "symbol": "WETH",
233
- "name": "Wrapped Ether",
234
- "category": "gas",
235
- "quantity": 2.5,
236
- "markPriceUsd": 1860.0,
237
- "notionalUsd": 4650.0,
238
- "weight": 0.093,
239
- "updatedAt": "2026-07-15T22:45:00.000Z"
240
- }
241
- ],
242
- "asOf": "2026-07-15T22:45:00.000Z"
243
- }
244
- ```
245
-
246
- ---
247
-
248
- ## 4. Health Domain
249
-
250
- Evaluates how closely the actual portfolio balances match the active objective policies.
251
-
252
- ### HealthState
253
-
254
- Indicates the deviation status:
255
- * `healthy`: The deviation is within the configured tolerance bounds.
256
- * `warning`: The deviation is approaching a breach, requiring monitoring.
257
- * `violation`: The deviation has exceeded tolerance bounds, triggering restore plan execution.
258
- * `paused`: The objective is paused and is excluded from monitoring status.
259
-
260
- ```ts
261
- export type HealthState = "healthy" | "warning" | "violation" | "paused";
262
- ```
263
-
264
- ### ObjectiveHealth
265
-
266
- Structured health metrics for a single objective:
267
-
268
- ```ts
269
- export interface ObjectiveHealth {
270
- objectiveId: string;
271
- state: HealthState;
272
- score: number;
273
- currentMetric: number;
274
- targetMetric: number;
275
- deviation: number;
276
- message: string;
277
- evaluatedAt: string;
278
- }
279
- ```
280
-
281
- #### JSON Representation Example
282
- ```json
283
- {
284
- "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
285
- "state": "violation",
286
- "score": 45.0,
287
- "currentMetric": 0.125,
288
- "targetMetric": 0.20,
289
- "deviation": -0.075,
290
- "message": "Stable allocation at 12.5% (Target: 20.0% +- 2.0%)",
291
- "evaluatedAt": "2026-07-15T22:45:00.000Z"
292
- }
293
- ```
294
-
295
- ---
296
-
297
- ## 5. Timeline Domain
298
-
299
- An append-only audit trail logging major system actions and states.
300
-
301
- ### TimelineEventType
302
-
303
- Standardized event categories:
304
- * `objective_created` or `objective_updated`: Configuration additions and changes.
305
- * `objective_paused` or `objective_resumed`: State lifecycle modifications.
306
- * `health_changed` or `violation_detected` or `objective_restored`: State transition checks.
307
- * `evaluation_started`: Heartbeat watchdog runs.
308
- * `execution_started` or `execution_completed`: Rebalance execution tracking.
309
- * `market_event_applied`: Controlled mock changes for system testing.
310
- * `capital_provisioned` or `capital_synced` or `capital_cleared`: Portfolio ledger events.
311
-
312
- ```ts
313
- export type TimelineEventType =
314
- | "objective_created"
315
- | "objective_updated"
316
- | "objective_paused"
317
- | "objective_resumed"
318
- | "health_changed"
319
- | "violation_detected"
320
- | "evaluation_started"
321
- | "execution_started"
322
- | "execution_completed"
323
- | "market_event_applied"
324
- | "objective_restored"
325
- | "capital_provisioned"
326
- | "capital_cleared"
327
- | "capital_synced";
328
- ```
329
-
330
- ### TimelineEvent
331
-
332
- An audit event:
333
-
334
- ```ts
335
- export interface TimelineEvent {
336
- id: string;
337
- objectiveId: string | null;
338
- type: TimelineEventType;
339
- message: string;
340
- payload: Record<string, unknown>;
341
- createdAt: string;
342
- }
343
- ```
344
-
345
- #### JSON Representation Example
346
- ```json
347
- {
348
- "id": "evt_01h8v6x7p8p3z2v1q45r3m2e11",
349
- "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
350
- "type": "violation_detected",
351
- "message": "Objective USDG Buffer Protection is in violation: Stable allocation fell below tolerance limit",
352
- "payload": {
353
- "currentStableWeight": 0.125,
354
- "targetStableWeight": 0.20,
355
- "tolerance": 0.02
356
- },
357
- "createdAt": "2026-07-15T22:45:01.000Z"
358
- }
359
- ```
360
-
361
- ---
362
-
363
- ## 6. Execution Domain
364
-
365
- Defines the steps and receipts involved in restoring an objective back to policy compliance.
366
-
367
- ### RestorePlanKind
368
-
369
- * `wrap_eth`: Converts native ETH to Wrapped Ether (WETH) on the host wallet. This is client-side.
370
- * `unwrap_weth`: Converts WETH back to ETH on the host wallet. This is client-side.
371
- * `vault_swap`: Conducts an on-chain rebalancing swap within the smart vault via Hono API/keepers.
372
-
373
- ```ts
374
- export type RestorePlanKind = "wrap_eth" | "unwrap_weth" | "vault_swap";
375
- ```
376
-
377
- ### RestorePlan
378
-
379
- ```ts
380
- export interface RestorePlan {
381
- kind: RestorePlanKind;
382
- amountHuman: string;
383
- approxUsd: number;
384
- message: string;
385
- sellSymbol?: string;
386
- buySymbol?: string;
387
- }
388
- ```
389
-
390
- ### ExecutionReceipt
391
-
392
- The logged result of a run execution:
393
-
394
- ```ts
395
- export interface ExecutionReceipt {
396
- id: string;
397
- objectiveId: string;
398
- status: "pending" | "submitted" | "confirmed" | "failed";
399
- transactionHash: string;
400
- action: string;
401
- notionalAdjustedUsd: number;
402
- result: string;
403
- createdAt: string;
404
- confirmedAt: string | null;
405
- /**
406
- * vault represents keeper rebalances on the Robinhood Chain.
407
- * staged represents simulated/book-only ledger updates.
408
- */
409
- settlement?: "staged" | "vault";
410
- }
411
- ```
412
-
413
- #### JSON Representation Example
414
- ```json
415
- {
416
- "id": "exec_01h8v5t7p8p3z2v1q45r3m2e99",
417
- "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
418
- "status": "confirmed",
419
- "transactionHash": "0xe295c2763f0d4681a8b54dfd38a0f8bfd21051515fcd9185a494ff3c8a99478f",
420
- "action": "Restore stablecoin sleeve: Swap stock tokens for USDG",
421
- "notionalAdjustedUsd": 3750.0,
422
- "result": "Exchanged stock tokens for 3750.0 USDG on Robinhood Chain",
423
- "createdAt": "2026-07-15T22:46:00.000Z",
424
- "confirmedAt": "2026-07-15T22:46:05.000Z",
425
- "settlement": "vault"
426
- }
427
- ```
428
-
429
- ---
430
-
431
- ## 7. Vault Domain
432
-
433
- AUREON operates non-custodial Smart Vaults on the Robinhood Chain. Users interact with vault balances by preparing transaction calldata via the API, then signing and broadcasting locally.
434
-
435
- ### VaultToken
436
-
437
- ```ts
438
- export interface VaultToken {
439
- symbol: string;
440
- name: string;
441
- address: string;
442
- decimals: number;
443
- category?: string;
444
- }
445
- ```
446
-
447
- ### VaultBalance
448
-
449
- ```ts
450
- export interface VaultBalance {
451
- symbol: string;
452
- name: string;
453
- token: string;
454
- decimals: number;
455
- category?: string;
456
- raw: string;
457
- quantity: number;
458
- markPriceUsd: number | null;
459
- notionalUsd: number | null;
460
- }
461
- ```
462
-
463
- ### VaultOverview
464
-
465
- ```ts
466
- export interface VaultOverview {
467
- address: string;
468
- chainId: number;
469
- tokens: VaultToken[];
470
- balances: VaultBalance[];
471
- poolAddress: string | null;
472
- explorerBase: string;
473
- keeperAddress: string | null;
474
- }
475
- ```
476
-
477
- ### VaultPreparedStep
478
-
479
- An individual calldata instruction:
480
-
481
- ```ts
482
- export interface VaultPreparedStep {
483
- to: string;
484
- data: string;
485
- value: string;
486
- functionName: "approve" | "deposit" | "depositETH" | "withdraw";
487
- label: string;
488
- }
489
- ```
490
-
491
- ### VaultPrepareResult
492
-
493
- The aggregated calldata bundle returned by the API:
494
-
495
- ```ts
496
- export interface VaultPrepareResult {
497
- chainId: number;
498
- vaultAddress: string;
499
- explorerBase: string;
500
- symbol: string;
501
- amountRaw: string;
502
- amountHuman: string;
503
- steps: VaultPreparedStep[];
504
- }
505
- ```
506
-
507
- #### JSON Representation Example
508
- ```json
509
- {
510
- "chainId": 46630,
511
- "vaultAddress": "0x1234567890123456789012345678901234567890",
512
- "explorerBase": "https://explorer.robinhoodnet.org",
513
- "symbol": "WETH",
514
- "amountRaw": "1000000000000000000",
515
- "amountHuman": "1.0",
516
- "steps": [
517
- {
518
- "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
519
- "data": "0x095cae9a0000000000000000000000001234567890123456789012345678901234567890ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
520
- "value": "0",
521
- "functionName": "approve",
522
- "label": "Approve WETH allowance for Vault"
523
- },
524
- {
525
- "to": "0x1234567890123456789012345678901234567890",
526
- "data": "0xb6b55f250000000000000000000000000000000000000000000000000de0b6b3a7640000",
527
- "value": "0",
528
- "functionName": "deposit",
529
- "label": "Deposit 1.0 WETH into Vault"
530
- }
531
- ]
532
- }
533
- ```
534
-
535
- ---
536
-
537
- ## 8. Market Domain
538
-
539
- Supports simulation and pricing variables for testing rebalances.
540
-
541
- ### MarketEvent
542
-
543
- ```ts
544
- export interface MarketEvent {
545
- id: string;
546
- name: string;
547
- description: string;
548
- symbol: string;
549
- priceChangeRatio: number;
550
- appliedAt: string;
551
- }
552
- ```
553
-
554
- ### ApplyMarketEventInput
555
-
556
- ```ts
557
- export interface ApplyMarketEventInput {
558
- name?: string;
559
- description?: string;
560
- symbol: string;
561
- priceChangeRatio: number;
562
- autoRestore?: boolean;
563
- }
564
- ```
565
-
566
- ---
567
-
568
- ## 9. Dashboard Overview
569
-
570
- Provides a high-level summary of all objectives, health states, historical scores, and execution events.
571
-
572
- ### DashboardOverview
573
-
574
- ```ts
575
- export interface DashboardOverview {
576
- activeObjectives: number;
577
- healthyCount: number;
578
- warningCount: number;
579
- violationCount: number;
580
- pausedCount: number;
581
- totalNotionalUsd: number;
582
- stableWeight: number;
583
- assetCount: number;
584
- change24hUsd: number | null;
585
- change24hPct: number | null;
586
- change24hBaselineOnly: boolean;
587
- change24hHasSnapshot: boolean;
588
- globalHealthScore: number | null;
589
- healthHistory: Array<{ at: string; score: number }>;
590
- attentionCount: number;
591
- lastEvaluationAt: string | null;
592
- nextEvaluationAt: string | null;
593
- watchdogIntervalMs: number | null;
594
- lastWatchdogError: string | null;
595
- lastSyncedAt: string | null;
596
- recentExecutions: ExecutionReceipt[];
597
- recentEvents: TimelineEvent[];
598
- }
599
- ```
600
-
601
- ---
602
-
603
- ## 10. Client Options (Config Contract)
604
-
605
- Configuration block supplied to the `AureonClient` constructor.
606
-
607
- ```ts
608
- export interface AureonClientOptions {
609
- baseUrl?: string;
610
- apiKey?: string | null;
611
- getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
612
- fetch?: typeof fetch;
613
- headers?: Record<string, string>;
614
- timeoutMs?: number;
615
- authToken?: string | null;
616
- getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
617
- logger?: AureonLogger;
618
- maxRetries?: number;
619
- retryDelayMs?: number;
620
- }
621
- ```
622
-
623
- ---
624
-
625
- ## 11. Invariants Checklist
626
-
627
- * `targetWeight` must be inside the `[0, 1]` closed interval.
628
- * `tolerance` must be inside the `[0, 0.5]` closed interval.
629
- * Objective display names must have a trimmed length of at least 3 characters.
630
- * `balanced_portfolio` objectives must specify a valid targetSymbol string.
631
- * SDK client creations default to Automatic restore mode (`automationMode: "auto"`).
632
- * Any base URL passed must use an absolute `http://` or `https://` scheme.
633
- * The portfolio book may be empty, which is evaluated as 0 notional value.
634
- * Execution receipts must label the settlement mechanism cleanly (`staged` versus `vault`).
635
- * Vault preparation endpoints only produce unsigned calldata, keeping private signing operations strictly local.
1
+ # Data Contracts Reference
2
+
3
+ This document defines the field-level data contracts used across `@buildaureon/sdk`. These structures are exported directly from `src/types/*` and match the JSON schemas returned by the hosted AUREON API.
4
+
5
+ Cross-links: [Client API Reference](./client-api.md) | [Architecture Guide](./architecture.md) | [Authentication Guide](./auth.md) | [Integration Guide](./integration-guide.md)
6
+
7
+ ---
8
+
9
+ ## 1. Document Overview
10
+
11
+ Every domain model in the AUREON system has a corresponding TypeScript type and representation in our public API.
12
+
13
+ ```mermaid
14
+ flowchart LR
15
+ API[AUREON API JSON] --> Types[sdk/src/types]
16
+ Types --> Client[AureonClient Outputs]
17
+ Types --> Docs[This Reference Document]
18
+ ```
19
+
20
+ This guide details each model, its fields, TypeScript types, constraints, and includes mock JSON examples.
21
+
22
+ ---
23
+
24
+ ## 2. Objective Domain
25
+
26
+ Objectives represent the core primitives of AUREON. Instead of executing one-off transactions, operators register continuous rules (e.g., "Maintain a 20% stablecoin reserve").
27
+
28
+ ### ObjectiveStatus
29
+
30
+ Describes the lifecycle state of a registered financial compass objective:
31
+
32
+ * `draft`: The objective is created but not active in background evaluation loops.
33
+ * `validated`: The objective has passed initial syntax and balance sanity checks.
34
+ * `active`: The objective is being actively checked by the live-mark watchdog engine.
35
+ * `paused`: Evaluation is suspended. No automated alerts or restores will trigger.
36
+ * `cancelled`: The objective is terminated permanently. It cannot be reactivated.
37
+ * `completed`: The objective successfully achieved its policy goals and is now archived.
38
+
39
+ ```ts
40
+ export type ObjectiveStatus = "draft" | "validated" | "active" | "paused" | "cancelled" | "completed";
41
+ ```
42
+
43
+ ### ObjectiveKind
44
+
45
+ Defines the rule or mathematical formula governing the objective:
46
+
47
+ * `stable_allocation`: Monitors stablecoin assets to keep them at a specific proportion of the total portfolio value.
48
+ * `balanced_portfolio`: Rebalances multiple assets to keep them near defined target weights relative to each other.
49
+ * `risk_ceiling`: Monitors the volatility or risk score of portfolio assets, alerting or rebalancing if it crosses a configured limit.
50
+ * `reward_reinvestment`: Automatically redirects yield, rewards, or idle gas tokens back into designated asset sleeves.
51
+
52
+ ```ts
53
+ export type ObjectiveKind = "stable_allocation" | "balanced_portfolio" | "risk_ceiling" | "reward_reinvestment";
54
+ ```
55
+
56
+ ### ObjectivePriority
57
+
58
+ Prioritizes resource allocation and execution order when multiple rules compete for liquidity or gas limits:
59
+ `low` · `medium` · `high` · `critical` (default is `high`).
60
+
61
+ ```ts
62
+ export type ObjectivePriority = "low" | "medium" | "high" | "critical";
63
+ ```
64
+
65
+ ### ObjectiveAutomationMode
66
+
67
+ Determines how policy violations are corrected:
68
+
69
+ * `auto` — Automatic restore coordination (SDK **only** supported mode; default).
70
+ * `manual` — Operator utility Approve flow. Not used for SDK agent integrations.
71
+
72
+ ```ts
73
+ export type ObjectiveAutomationMode = "manual" | "auto";
74
+ ```
75
+
76
+ For `@buildaureon/sdk`, always omit `automationMode` or pass `"auto"`.
77
+
78
+ ### ObjectivePolicy
79
+
80
+ Specifies the mathematical parameters governing target bounds:
81
+
82
+ ```ts
83
+ export interface ObjectivePolicy {
84
+ /** Target weight fraction between 0.0 and 1.0 (e.g., 0.25 represents 25%) */
85
+ targetWeight: number;
86
+ /** Allowed deviation tolerance (e.g., 0.05 represents +-5% deviation window) */
87
+ tolerance: number;
88
+ /** Optional risk ceiling score when kind is risk_ceiling */
89
+ maxRiskScore?: number;
90
+ /** Optional fraction of rewards to redirect when kind is reward_reinvestment */
91
+ reinvestRatio?: number;
92
+ /** Holding symbol when tracking a specific asset (e.g., "WETH") */
93
+ targetSymbol?: string;
94
+ /** Automatically generated human-readable policy summary */
95
+ summary: string;
96
+ }
97
+ ```
98
+
99
+ ### Objective
100
+
101
+ The main database record returned by objective endpoints:
102
+
103
+ ```ts
104
+ export interface Objective {
105
+ id: string;
106
+ name: string;
107
+ kind: ObjectiveKind;
108
+ status: ObjectiveStatus;
109
+ priority: ObjectivePriority;
110
+ automationMode: ObjectiveAutomationMode;
111
+ policy: ObjectivePolicy;
112
+ ownerId: string;
113
+ createdAt: string;
114
+ updatedAt: string;
115
+ lastEvaluatedAt: string | null;
116
+ lastExecutionId: string | null;
117
+ }
118
+ ```
119
+
120
+ #### JSON Representation Example
121
+ ```json
122
+ {
123
+ "id": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
124
+ "name": "USDG Buffer Protection",
125
+ "kind": "stable_allocation",
126
+ "status": "active",
127
+ "priority": "high",
128
+ "automationMode": "auto",
129
+ "policy": {
130
+ "targetWeight": 0.2,
131
+ "tolerance": 0.02,
132
+ "summary": "Maintain 20.0% stable allocation within ±2.0%"
133
+ },
134
+ "ownerId": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
135
+ "createdAt": "2026-07-15T12:00:00.000Z",
136
+ "updatedAt": "2026-07-15T12:30:00.000Z",
137
+ "lastEvaluatedAt": "2026-07-15T22:45:00.000Z",
138
+ "lastExecutionId": "exec_01h8v5t7p8p3z2v1q45r3m2e99"
139
+ }
140
+ ```
141
+
142
+ ### Inputs
143
+
144
+ #### `CreateObjectiveInput`
145
+ Passed to `createObjective` to register a new rule:
146
+ * `name` (Required): String, minimum length of 3 characters.
147
+ * `kind` (Required): Supported kind enum.
148
+ * `targetWeight` (Required): Number between 0.0 and 1.0.
149
+ * `tolerance` (Required): Number between 0.0 and 0.5.
150
+ * `priority` (Optional): Defaults to `high`.
151
+ * `targetSymbol` (Required if kind is `balanced_portfolio`): Token symbol.
152
+ * `automationMode` (Optional): Defaults to `auto` in the SDK.
153
+
154
+ #### `UpdateObjectiveInput`
155
+ Passed to `updateObjective` for partial updates. `targetSymbol` and `automationMode` are fixed at creation and cannot be updated.
156
+
157
+ ```ts
158
+ export interface UpdateObjectiveInput {
159
+ name?: string;
160
+ priority?: ObjectivePriority;
161
+ targetWeight?: number;
162
+ tolerance?: number;
163
+ maxRiskScore?: number;
164
+ reinvestRatio?: number;
165
+ targetSymbol?: never; // Disallowed on updates
166
+ automationMode?: never; // Disallowed on updates
167
+ }
168
+ ```
169
+
170
+ ---
171
+
172
+ ## 3. Portfolio Domain
173
+
174
+ Tracks the capital distribution of an authenticated wallet address. Portfolios are divided into asset sleeves (e.g., stablecoins, stocks, gas).
175
+
176
+ ### PortfolioPosition
177
+
178
+ Represents a single asset holding:
179
+
180
+ ```ts
181
+ export interface PortfolioPosition {
182
+ id: string;
183
+ symbol: string;
184
+ name: string;
185
+ category: "stable" | "stock_token" | "gas" | "other";
186
+ quantity: number;
187
+ markPriceUsd: number;
188
+ notionalUsd: number;
189
+ weight: number;
190
+ updatedAt: string;
191
+ }
192
+ ```
193
+
194
+ ### PortfolioSnapshot
195
+
196
+ An immutable snapshot of the total wallet allocation:
197
+
198
+ ```ts
199
+ export interface PortfolioSnapshot {
200
+ portfolioId: string;
201
+ totalNotionalUsd: number;
202
+ stableWeight: number;
203
+ stockTokenWeight: number;
204
+ gasWeight: number;
205
+ positions: PortfolioPosition[];
206
+ asOf: string;
207
+ }
208
+ ```
209
+
210
+ #### JSON Representation Example
211
+ ```json
212
+ {
213
+ "portfolioId": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
214
+ "totalNotionalUsd": 50000.0,
215
+ "stableWeight": 0.205,
216
+ "stockTokenWeight": 0.702,
217
+ "gasWeight": 0.093,
218
+ "positions": [
219
+ {
220
+ "id": "pos_usdg",
221
+ "symbol": "USDG",
222
+ "name": "Aureon Stable Dollar",
223
+ "category": "stable",
224
+ "quantity": 10250,
225
+ "markPriceUsd": 1.0,
226
+ "notionalUsd": 10250.0,
227
+ "weight": 0.205,
228
+ "updatedAt": "2026-07-15T22:45:00.000Z"
229
+ },
230
+ {
231
+ "id": "pos_weth",
232
+ "symbol": "WETH",
233
+ "name": "Wrapped Ether",
234
+ "category": "gas",
235
+ "quantity": 2.5,
236
+ "markPriceUsd": 1860.0,
237
+ "notionalUsd": 4650.0,
238
+ "weight": 0.093,
239
+ "updatedAt": "2026-07-15T22:45:00.000Z"
240
+ }
241
+ ],
242
+ "asOf": "2026-07-15T22:45:00.000Z"
243
+ }
244
+ ```
245
+
246
+ ---
247
+
248
+ ## 4. Health Domain
249
+
250
+ Evaluates how closely the actual portfolio balances match the active objective policies.
251
+
252
+ ### HealthState
253
+
254
+ Indicates the deviation status:
255
+ * `healthy`: The deviation is within the configured tolerance bounds.
256
+ * `warning`: The deviation is approaching a breach, requiring monitoring.
257
+ * `violation`: The deviation has exceeded tolerance bounds, triggering restore plan execution.
258
+ * `paused`: The objective is paused and is excluded from monitoring status.
259
+
260
+ ```ts
261
+ export type HealthState = "healthy" | "warning" | "violation" | "paused";
262
+ ```
263
+
264
+ ### ObjectiveHealth
265
+
266
+ Structured health metrics for a single objective:
267
+
268
+ ```ts
269
+ export interface ObjectiveHealth {
270
+ objectiveId: string;
271
+ state: HealthState;
272
+ score: number;
273
+ currentMetric: number;
274
+ targetMetric: number;
275
+ deviation: number;
276
+ message: string;
277
+ evaluatedAt: string;
278
+ }
279
+ ```
280
+
281
+ #### JSON Representation Example
282
+ ```json
283
+ {
284
+ "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
285
+ "state": "violation",
286
+ "score": 45.0,
287
+ "currentMetric": 0.125,
288
+ "targetMetric": 0.20,
289
+ "deviation": -0.075,
290
+ "message": "Stable allocation at 12.5% (Target: 20.0% +- 2.0%)",
291
+ "evaluatedAt": "2026-07-15T22:45:00.000Z"
292
+ }
293
+ ```
294
+
295
+ ---
296
+
297
+ ## 5. Timeline Domain
298
+
299
+ An append-only audit trail logging major system actions and states.
300
+
301
+ ### TimelineEventType
302
+
303
+ Standardized event categories:
304
+ * `objective_created` or `objective_updated`: Configuration additions and changes.
305
+ * `objective_paused` or `objective_resumed`: State lifecycle modifications.
306
+ * `health_changed` or `violation_detected` or `objective_restored`: State transition checks.
307
+ * `evaluation_started`: Heartbeat watchdog runs.
308
+ * `execution_started` or `execution_completed`: Rebalance execution tracking.
309
+ * `market_event_applied`: Controlled mock changes for system testing.
310
+ * `capital_provisioned` or `capital_synced` or `capital_cleared`: Portfolio ledger events.
311
+
312
+ ```ts
313
+ export type TimelineEventType =
314
+ | "objective_created"
315
+ | "objective_updated"
316
+ | "objective_paused"
317
+ | "objective_resumed"
318
+ | "health_changed"
319
+ | "violation_detected"
320
+ | "evaluation_started"
321
+ | "execution_started"
322
+ | "execution_completed"
323
+ | "market_event_applied"
324
+ | "objective_restored"
325
+ | "capital_provisioned"
326
+ | "capital_cleared"
327
+ | "capital_synced";
328
+ ```
329
+
330
+ ### TimelineEvent
331
+
332
+ An audit event:
333
+
334
+ ```ts
335
+ export interface TimelineEvent {
336
+ id: string;
337
+ objectiveId: string | null;
338
+ type: TimelineEventType;
339
+ message: string;
340
+ payload: Record<string, unknown>;
341
+ createdAt: string;
342
+ }
343
+ ```
344
+
345
+ #### JSON Representation Example
346
+ ```json
347
+ {
348
+ "id": "evt_01h8v6x7p8p3z2v1q45r3m2e11",
349
+ "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
350
+ "type": "violation_detected",
351
+ "message": "Objective USDG Buffer Protection is in violation: Stable allocation fell below tolerance limit",
352
+ "payload": {
353
+ "currentStableWeight": 0.125,
354
+ "targetStableWeight": 0.20,
355
+ "tolerance": 0.02
356
+ },
357
+ "createdAt": "2026-07-15T22:45:01.000Z"
358
+ }
359
+ ```
360
+
361
+ ---
362
+
363
+ ## 6. Execution Domain
364
+
365
+ Defines the steps and receipts involved in restoring an objective back to policy compliance.
366
+
367
+ ### RestorePlanKind
368
+
369
+ * `wrap_eth`: Converts native ETH to Wrapped Ether (WETH) on the host wallet. This is client-side.
370
+ * `unwrap_weth`: Converts WETH back to ETH on the host wallet. This is client-side.
371
+ * `vault_swap`: Conducts an on-chain rebalancing swap within the smart vault via Hono API/keepers.
372
+
373
+ ```ts
374
+ export type RestorePlanKind = "wrap_eth" | "unwrap_weth" | "vault_swap";
375
+ ```
376
+
377
+ ### RestorePlan
378
+
379
+ ```ts
380
+ export interface RestorePlan {
381
+ kind: RestorePlanKind;
382
+ amountHuman: string;
383
+ approxUsd: number;
384
+ message: string;
385
+ sellSymbol?: string;
386
+ buySymbol?: string;
387
+ }
388
+ ```
389
+
390
+ ### ExecutionReceipt
391
+
392
+ The logged result of a run execution:
393
+
394
+ ```ts
395
+ export interface ExecutionReceipt {
396
+ id: string;
397
+ objectiveId: string;
398
+ status: "pending" | "submitted" | "confirmed" | "failed";
399
+ transactionHash: string;
400
+ action: string;
401
+ notionalAdjustedUsd: number;
402
+ result: string;
403
+ createdAt: string;
404
+ confirmedAt: string | null;
405
+ /** Required. vault = on-chain keeper path; staged = capital-book update only. */
406
+ settlement: "staged" | "vault";
407
+ /** Block explorer link when vault tx is confirmed (`0x…`); null for staged. */
408
+ explorerUrl?: string | null;
409
+ /** Present when the objective is registered on ObjectiveRegistry. */
410
+ registryRef?: RegistryRef;
411
+ /** True when a settlement record exists for this execution (vault only). */
412
+ verifiedOnChain?: boolean;
413
+ /** Populated when `verifiedOnChain` is true. */
414
+ settlementRecord?: SettlementRecord;
415
+ }
416
+ ```
417
+
418
+ ### SettlementRecord (Day 8)
419
+
420
+ Independent on-chain proof from AureonVault `Rebalanced` events:
421
+
422
+ ```ts
423
+ export interface SettlementRecord {
424
+ id: string;
425
+ executionId: string | null;
426
+ objectiveId: string | null;
427
+ walletAddress: string;
428
+ settlement: "vault";
429
+ transactionHash: string;
430
+ blockNumber: number;
431
+ logIndex: number;
432
+ vaultAddress: string;
433
+ tokenSell: string;
434
+ tokenBuy: string;
435
+ amountIn: string;
436
+ amountOut: string;
437
+ explorerUrl: string;
438
+ verifiedAt: string;
439
+ status: "confirmed" | "orphan";
440
+ registryRef?: RegistryRef;
441
+ }
442
+ ```
443
+
444
+ Client methods: `getExecutionSettlement`, `listSettlements`, `confirmExecutionSettlement`.
445
+
446
+ ---
447
+
448
+ ## 6.1 Receipt validation (Day 9)
449
+
450
+ Validate receipts locally before trusting them in automation:
451
+
452
+ ```ts
453
+ import {
454
+ validateExecutionReceipt,
455
+ assertValidExecutionReceipt,
456
+ } from "@buildaureon/sdk";
457
+
458
+ const result = validateExecutionReceipt(receipt);
459
+ if (!result.valid) {
460
+ console.error(result.issues);
461
+ }
462
+
463
+ assertValidExecutionReceipt(receipt); // throws AureonValidationError
464
+ ```
465
+
466
+ `ReceiptValidationResult`:
467
+
468
+ ```ts
469
+ export type ReceiptValidationIssue = {
470
+ code: string;
471
+ message: string;
472
+ path?: string;
473
+ };
474
+
475
+ export type ReceiptValidationResult = {
476
+ valid: boolean;
477
+ issues: ReceiptValidationIssue[];
478
+ };
479
+ ```
480
+
481
+ Enforces required fields, `vault` vs `staged` honesty, explorer rules, and `verifiedOnChain` / `settlementRecord` consistency. See [receipt-validation.md](./receipt-validation.md).
482
+
483
+ #### JSON Representation Example
484
+ ```json
485
+ {
486
+ "id": "exec_01h8v5t7p8p3z2v1q45r3m2e99",
487
+ "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
488
+ "status": "confirmed",
489
+ "transactionHash": "0xe295c2763f0d4681a8b54dfd38a0f8bfd21051515fcd9185a494ff3c8a99478f",
490
+ "action": "Restore stablecoin sleeve: Swap stock tokens for USDG",
491
+ "notionalAdjustedUsd": 3750.0,
492
+ "result": "Exchanged stock tokens for 3750.0 USDG on Robinhood Chain",
493
+ "createdAt": "2026-07-15T22:46:00.000Z",
494
+ "confirmedAt": "2026-07-15T22:46:05.000Z",
495
+ "settlement": "vault",
496
+ "explorerUrl": "https://explorer.testnet.chain.robinhood.com/tx/0xe295c2763f0d4681a8b54dfd38a0f8bfd21051515fcd9185a494ff3c8a99478f",
497
+ "registryRef": {
498
+ "objectiveKey": "0xabc…",
499
+ "contractAddress": "0x76d8f088d2abba3c73ff93f92308f8b59b250ea5"
500
+ }
501
+ }
502
+ ```
503
+
504
+ ---
505
+
506
+ ## 7. Vault Domain
507
+
508
+ AUREON operates non-custodial Smart Vaults on the Robinhood Chain. Users interact with vault balances by preparing transaction calldata via the API, then signing and broadcasting locally.
509
+
510
+ ### VaultToken
511
+
512
+ ```ts
513
+ export interface VaultToken {
514
+ symbol: string;
515
+ name: string;
516
+ address: string;
517
+ decimals: number;
518
+ category?: string;
519
+ }
520
+ ```
521
+
522
+ ### VaultBalance
523
+
524
+ ```ts
525
+ export interface VaultBalance {
526
+ symbol: string;
527
+ name: string;
528
+ token: string;
529
+ decimals: number;
530
+ category?: string;
531
+ raw: string;
532
+ quantity: number;
533
+ markPriceUsd: number | null;
534
+ notionalUsd: number | null;
535
+ }
536
+ ```
537
+
538
+ ### VaultOverview
539
+
540
+ ```ts
541
+ export interface VaultOverview {
542
+ address: string;
543
+ chainId: number;
544
+ tokens: VaultToken[];
545
+ balances: VaultBalance[];
546
+ poolAddress: string | null;
547
+ explorerBase: string;
548
+ keeperAddress: string | null;
549
+ }
550
+ ```
551
+
552
+ ### VaultPreparedStep
553
+
554
+ An individual calldata instruction:
555
+
556
+ ```ts
557
+ export interface VaultPreparedStep {
558
+ to: string;
559
+ data: string;
560
+ value: string;
561
+ functionName: "approve" | "deposit" | "depositETH" | "withdraw";
562
+ label: string;
563
+ }
564
+ ```
565
+
566
+ ### VaultPrepareResult
567
+
568
+ The aggregated calldata bundle returned by the API:
569
+
570
+ ```ts
571
+ export interface VaultPrepareResult {
572
+ chainId: number;
573
+ vaultAddress: string;
574
+ explorerBase: string;
575
+ symbol: string;
576
+ amountRaw: string;
577
+ amountHuman: string;
578
+ steps: VaultPreparedStep[];
579
+ }
580
+ ```
581
+
582
+ #### JSON Representation Example
583
+ ```json
584
+ {
585
+ "chainId": 46630,
586
+ "vaultAddress": "0x1234567890123456789012345678901234567890",
587
+ "explorerBase": "https://explorer.robinhoodnet.org",
588
+ "symbol": "WETH",
589
+ "amountRaw": "1000000000000000000",
590
+ "amountHuman": "1.0",
591
+ "steps": [
592
+ {
593
+ "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
594
+ "data": "0x095cae9a0000000000000000000000001234567890123456789012345678901234567890ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
595
+ "value": "0",
596
+ "functionName": "approve",
597
+ "label": "Approve WETH allowance for Vault"
598
+ },
599
+ {
600
+ "to": "0x1234567890123456789012345678901234567890",
601
+ "data": "0xb6b55f250000000000000000000000000000000000000000000000000de0b6b3a7640000",
602
+ "value": "0",
603
+ "functionName": "deposit",
604
+ "label": "Deposit 1.0 WETH into Vault"
605
+ }
606
+ ]
607
+ }
608
+ ```
609
+
610
+ ---
611
+
612
+ ## 8. Market Domain
613
+
614
+ Supports simulation and pricing variables for testing rebalances.
615
+
616
+ ### MarketEvent
617
+
618
+ ```ts
619
+ export interface MarketEvent {
620
+ id: string;
621
+ name: string;
622
+ description: string;
623
+ symbol: string;
624
+ priceChangeRatio: number;
625
+ appliedAt: string;
626
+ }
627
+ ```
628
+
629
+ ### ApplyMarketEventInput
630
+
631
+ ```ts
632
+ export interface ApplyMarketEventInput {
633
+ name?: string;
634
+ description?: string;
635
+ symbol: string;
636
+ priceChangeRatio: number;
637
+ autoRestore?: boolean;
638
+ }
639
+ ```
640
+
641
+ ---
642
+
643
+ ## 9. Dashboard Overview
644
+
645
+ Provides a high-level summary of all objectives, health states, historical scores, and execution events.
646
+
647
+ ### DashboardOverview
648
+
649
+ ```ts
650
+ export interface DashboardOverview {
651
+ activeObjectives: number;
652
+ healthyCount: number;
653
+ warningCount: number;
654
+ violationCount: number;
655
+ pausedCount: number;
656
+ totalNotionalUsd: number;
657
+ stableWeight: number;
658
+ assetCount: number;
659
+ change24hUsd: number | null;
660
+ change24hPct: number | null;
661
+ change24hBaselineOnly: boolean;
662
+ change24hHasSnapshot: boolean;
663
+ globalHealthScore: number | null;
664
+ healthHistory: Array<{ at: string; score: number }>;
665
+ attentionCount: number;
666
+ lastEvaluationAt: string | null;
667
+ nextEvaluationAt: string | null;
668
+ watchdogIntervalMs: number | null;
669
+ lastWatchdogError: string | null;
670
+ lastSyncedAt: string | null;
671
+ recentExecutions: ExecutionReceipt[];
672
+ recentEvents: TimelineEvent[];
673
+ }
674
+ ```
675
+
676
+ ---
677
+
678
+ ## 10. Client Options (Config Contract)
679
+
680
+ Configuration block supplied to the `AureonClient` constructor.
681
+
682
+ ```ts
683
+ export interface AureonClientOptions {
684
+ baseUrl?: string;
685
+ apiKey?: string | null;
686
+ getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
687
+ fetch?: typeof fetch;
688
+ headers?: Record<string, string>;
689
+ timeoutMs?: number;
690
+ authToken?: string | null;
691
+ getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
692
+ logger?: AureonLogger;
693
+ maxRetries?: number;
694
+ retryDelayMs?: number;
695
+ }
696
+ ```
697
+
698
+ ---
699
+
700
+ ## 11. Invariants Checklist
701
+
702
+ * `targetWeight` must be inside the `[0, 1]` closed interval.
703
+ * `tolerance` must be inside the `[0, 0.5]` closed interval.
704
+ * Objective display names must have a trimmed length of at least 3 characters.
705
+ * `balanced_portfolio` objectives must specify a valid targetSymbol string.
706
+ * SDK client creations default to Automatic restore mode (`automationMode: "auto"`).
707
+ * Any base URL passed must use an absolute `http://` or `https://` scheme.
708
+ * The portfolio book may be empty, which is evaluated as 0 notional value.
709
+ * Execution receipts must label the settlement mechanism cleanly (`staged` versus `vault`).
710
+ * Vault preparation endpoints only produce unsigned calldata, keeping private signing operations strictly local.