@buildaureon/sdk 0.1.0

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.
@@ -0,0 +1,632 @@
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
+ * `auto`: Fully automated restore loops. The system generates execution receipts immediately upon detecting a violation (SDK default).
69
+ * `manual`: The operator utility flags the violation, requiring an explicit approval step in the UI.
70
+
71
+ ```ts
72
+ export type ObjectiveAutomationMode = "manual" | "auto";
73
+ ```
74
+
75
+ ### ObjectivePolicy
76
+
77
+ Specifies the mathematical parameters governing target bounds:
78
+
79
+ ```ts
80
+ export interface ObjectivePolicy {
81
+ /** Target weight fraction between 0.0 and 1.0 (e.g., 0.25 represents 25%) */
82
+ targetWeight: number;
83
+ /** Allowed deviation tolerance (e.g., 0.05 represents +-5% deviation window) */
84
+ tolerance: number;
85
+ /** Optional risk ceiling score when kind is risk_ceiling */
86
+ maxRiskScore?: number;
87
+ /** Optional fraction of rewards to redirect when kind is reward_reinvestment */
88
+ reinvestRatio?: number;
89
+ /** Holding symbol when tracking a specific asset (e.g., "WETH") */
90
+ targetSymbol?: string;
91
+ /** Automatically generated human-readable policy summary */
92
+ summary: string;
93
+ }
94
+ ```
95
+
96
+ ### Objective
97
+
98
+ The main database record returned by objective endpoints:
99
+
100
+ ```ts
101
+ export interface Objective {
102
+ id: string;
103
+ name: string;
104
+ kind: ObjectiveKind;
105
+ status: ObjectiveStatus;
106
+ priority: ObjectivePriority;
107
+ automationMode: ObjectiveAutomationMode;
108
+ policy: ObjectivePolicy;
109
+ ownerId: string;
110
+ createdAt: string;
111
+ updatedAt: string;
112
+ lastEvaluatedAt: string | null;
113
+ lastExecutionId: string | null;
114
+ }
115
+ ```
116
+
117
+ #### JSON Representation Example
118
+ ```json
119
+ {
120
+ "id": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
121
+ "name": "USDG Buffer Protection",
122
+ "kind": "stable_allocation",
123
+ "status": "active",
124
+ "priority": "high",
125
+ "automationMode": "auto",
126
+ "policy": {
127
+ "targetWeight": 0.2,
128
+ "tolerance": 0.02,
129
+ "summary": "Maintain 20.0% stable allocation within ±2.0%"
130
+ },
131
+ "ownerId": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
132
+ "createdAt": "2026-07-15T12:00:00.000Z",
133
+ "updatedAt": "2026-07-15T12:30:00.000Z",
134
+ "lastEvaluatedAt": "2026-07-15T22:45:00.000Z",
135
+ "lastExecutionId": "exec_01h8v5t7p8p3z2v1q45r3m2e99"
136
+ }
137
+ ```
138
+
139
+ ### Inputs
140
+
141
+ #### `CreateObjectiveInput`
142
+ Passed to `createObjective` to register a new rule:
143
+ * `name` (Required): String, minimum length of 3 characters.
144
+ * `kind` (Required): Supported kind enum.
145
+ * `targetWeight` (Required): Number between 0.0 and 1.0.
146
+ * `tolerance` (Required): Number between 0.0 and 0.5.
147
+ * `priority` (Optional): Defaults to `high`.
148
+ * `targetSymbol` (Required if kind is `balanced_portfolio`): Token symbol.
149
+ * `automationMode` (Optional): Defaults to `auto` in the SDK.
150
+
151
+ #### `UpdateObjectiveInput`
152
+ Passed to `updateObjective` for partial updates. Note that `automationMode` is fixed at creation and cannot be updated.
153
+
154
+ ```ts
155
+ export interface UpdateObjectiveInput {
156
+ name?: string;
157
+ priority?: ObjectivePriority;
158
+ targetWeight?: number;
159
+ tolerance?: number;
160
+ maxRiskScore?: number;
161
+ reinvestRatio?: number;
162
+ targetSymbol?: string | null;
163
+ automationMode?: never; // Disallowed on updates
164
+ }
165
+ ```
166
+
167
+ ---
168
+
169
+ ## 3. Portfolio Domain
170
+
171
+ Tracks the capital distribution of an authenticated wallet address. Portfolios are divided into asset sleeves (e.g., stablecoins, stocks, gas).
172
+
173
+ ### PortfolioPosition
174
+
175
+ Represents a single asset holding:
176
+
177
+ ```ts
178
+ export interface PortfolioPosition {
179
+ id: string;
180
+ symbol: string;
181
+ name: string;
182
+ category: "stable" | "stock_token" | "gas" | "other";
183
+ quantity: number;
184
+ markPriceUsd: number;
185
+ notionalUsd: number;
186
+ weight: number;
187
+ updatedAt: string;
188
+ }
189
+ ```
190
+
191
+ ### PortfolioSnapshot
192
+
193
+ An immutable snapshot of the total wallet allocation:
194
+
195
+ ```ts
196
+ export interface PortfolioSnapshot {
197
+ portfolioId: string;
198
+ totalNotionalUsd: number;
199
+ stableWeight: number;
200
+ stockTokenWeight: number;
201
+ gasWeight: number;
202
+ positions: PortfolioPosition[];
203
+ asOf: string;
204
+ }
205
+ ```
206
+
207
+ #### JSON Representation Example
208
+ ```json
209
+ {
210
+ "portfolioId": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
211
+ "totalNotionalUsd": 50000.0,
212
+ "stableWeight": 0.205,
213
+ "stockTokenWeight": 0.702,
214
+ "gasWeight": 0.093,
215
+ "positions": [
216
+ {
217
+ "id": "pos_usdg",
218
+ "symbol": "USDG",
219
+ "name": "Aureon Stable Dollar",
220
+ "category": "stable",
221
+ "quantity": 10250,
222
+ "markPriceUsd": 1.0,
223
+ "notionalUsd": 10250.0,
224
+ "weight": 0.205,
225
+ "updatedAt": "2026-07-15T22:45:00.000Z"
226
+ },
227
+ {
228
+ "id": "pos_weth",
229
+ "symbol": "WETH",
230
+ "name": "Wrapped Ether",
231
+ "category": "gas",
232
+ "quantity": 2.5,
233
+ "markPriceUsd": 1860.0,
234
+ "notionalUsd": 4650.0,
235
+ "weight": 0.093,
236
+ "updatedAt": "2026-07-15T22:45:00.000Z"
237
+ }
238
+ ],
239
+ "asOf": "2026-07-15T22:45:00.000Z"
240
+ }
241
+ ```
242
+
243
+ ---
244
+
245
+ ## 4. Health Domain
246
+
247
+ Evaluates how closely the actual portfolio balances match the active objective policies.
248
+
249
+ ### HealthState
250
+
251
+ Indicates the deviation status:
252
+ * `healthy`: The deviation is within the configured tolerance bounds.
253
+ * `warning`: The deviation is approaching a breach, requiring monitoring.
254
+ * `violation`: The deviation has exceeded tolerance bounds, triggering restore plan execution.
255
+ * `paused`: The objective is paused and is excluded from monitoring status.
256
+
257
+ ```ts
258
+ export type HealthState = "healthy" | "warning" | "violation" | "paused";
259
+ ```
260
+
261
+ ### ObjectiveHealth
262
+
263
+ Structured health metrics for a single objective:
264
+
265
+ ```ts
266
+ export interface ObjectiveHealth {
267
+ objectiveId: string;
268
+ state: HealthState;
269
+ score: number;
270
+ currentMetric: number;
271
+ targetMetric: number;
272
+ deviation: number;
273
+ message: string;
274
+ evaluatedAt: string;
275
+ }
276
+ ```
277
+
278
+ #### JSON Representation Example
279
+ ```json
280
+ {
281
+ "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
282
+ "state": "violation",
283
+ "score": 45.0,
284
+ "currentMetric": 0.125,
285
+ "targetMetric": 0.20,
286
+ "deviation": -0.075,
287
+ "message": "Stable allocation at 12.5% (Target: 20.0% +- 2.0%)",
288
+ "evaluatedAt": "2026-07-15T22:45:00.000Z"
289
+ }
290
+ ```
291
+
292
+ ---
293
+
294
+ ## 5. Timeline Domain
295
+
296
+ An append-only audit trail logging major system actions and states.
297
+
298
+ ### TimelineEventType
299
+
300
+ Standardized event categories:
301
+ * `objective_created` or `objective_updated`: Configuration additions and changes.
302
+ * `objective_paused` or `objective_resumed`: State lifecycle modifications.
303
+ * `health_changed` or `violation_detected` or `objective_restored`: State transition checks.
304
+ * `evaluation_started`: Heartbeat watchdog runs.
305
+ * `execution_started` or `execution_completed`: Rebalance execution tracking.
306
+ * `market_event_applied`: Controlled mock changes for system testing.
307
+ * `capital_provisioned` or `capital_synced` or `capital_cleared`: Portfolio ledger events.
308
+
309
+ ```ts
310
+ export type TimelineEventType =
311
+ | "objective_created"
312
+ | "objective_updated"
313
+ | "objective_paused"
314
+ | "objective_resumed"
315
+ | "health_changed"
316
+ | "violation_detected"
317
+ | "evaluation_started"
318
+ | "execution_started"
319
+ | "execution_completed"
320
+ | "market_event_applied"
321
+ | "objective_restored"
322
+ | "capital_provisioned"
323
+ | "capital_cleared"
324
+ | "capital_synced";
325
+ ```
326
+
327
+ ### TimelineEvent
328
+
329
+ An audit event:
330
+
331
+ ```ts
332
+ export interface TimelineEvent {
333
+ id: string;
334
+ objectiveId: string | null;
335
+ type: TimelineEventType;
336
+ message: string;
337
+ payload: Record<string, unknown>;
338
+ createdAt: string;
339
+ }
340
+ ```
341
+
342
+ #### JSON Representation Example
343
+ ```json
344
+ {
345
+ "id": "evt_01h8v6x7p8p3z2v1q45r3m2e11",
346
+ "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
347
+ "type": "violation_detected",
348
+ "message": "Objective USDG Buffer Protection is in violation: Stable allocation fell below tolerance limit",
349
+ "payload": {
350
+ "currentStableWeight": 0.125,
351
+ "targetStableWeight": 0.20,
352
+ "tolerance": 0.02
353
+ },
354
+ "createdAt": "2026-07-15T22:45:01.000Z"
355
+ }
356
+ ```
357
+
358
+ ---
359
+
360
+ ## 6. Execution Domain
361
+
362
+ Defines the steps and receipts involved in restoring an objective back to policy compliance.
363
+
364
+ ### RestorePlanKind
365
+
366
+ * `wrap_eth`: Converts native ETH to Wrapped Ether (WETH) on the host wallet. This is client-side.
367
+ * `unwrap_weth`: Converts WETH back to ETH on the host wallet. This is client-side.
368
+ * `vault_swap`: Conducts an on-chain rebalancing swap within the smart vault via Hono API/keepers.
369
+
370
+ ```ts
371
+ export type RestorePlanKind = "wrap_eth" | "unwrap_weth" | "vault_swap";
372
+ ```
373
+
374
+ ### RestorePlan
375
+
376
+ ```ts
377
+ export interface RestorePlan {
378
+ kind: RestorePlanKind;
379
+ amountHuman: string;
380
+ approxUsd: number;
381
+ message: string;
382
+ sellSymbol?: string;
383
+ buySymbol?: string;
384
+ }
385
+ ```
386
+
387
+ ### ExecutionReceipt
388
+
389
+ The logged result of a run execution:
390
+
391
+ ```ts
392
+ export interface ExecutionReceipt {
393
+ id: string;
394
+ objectiveId: string;
395
+ status: "pending" | "submitted" | "confirmed" | "failed";
396
+ transactionHash: string;
397
+ action: string;
398
+ notionalAdjustedUsd: number;
399
+ result: string;
400
+ createdAt: string;
401
+ confirmedAt: string | null;
402
+ /**
403
+ * vault represents keeper rebalances on the Robinhood Chain.
404
+ * staged represents simulated/book-only ledger updates.
405
+ */
406
+ settlement?: "staged" | "vault";
407
+ }
408
+ ```
409
+
410
+ #### JSON Representation Example
411
+ ```json
412
+ {
413
+ "id": "exec_01h8v5t7p8p3z2v1q45r3m2e99",
414
+ "objectiveId": "obj_01h8v12x8p8p3z2v1q45r3m2e1",
415
+ "status": "confirmed",
416
+ "transactionHash": "0xe295c2763f0d4681a8b54dfd38a0f8bfd21051515fcd9185a494ff3c8a99478f",
417
+ "action": "Restore stablecoin sleeve: Swap stock tokens for USDG",
418
+ "notionalAdjustedUsd": 3750.0,
419
+ "result": "Exchanged stock tokens for 3750.0 USDG on Robinhood Chain",
420
+ "createdAt": "2026-07-15T22:46:00.000Z",
421
+ "confirmedAt": "2026-07-15T22:46:05.000Z",
422
+ "settlement": "vault"
423
+ }
424
+ ```
425
+
426
+ ---
427
+
428
+ ## 7. Vault Domain
429
+
430
+ 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.
431
+
432
+ ### VaultToken
433
+
434
+ ```ts
435
+ export interface VaultToken {
436
+ symbol: string;
437
+ name: string;
438
+ address: string;
439
+ decimals: number;
440
+ category?: string;
441
+ }
442
+ ```
443
+
444
+ ### VaultBalance
445
+
446
+ ```ts
447
+ export interface VaultBalance {
448
+ symbol: string;
449
+ name: string;
450
+ token: string;
451
+ decimals: number;
452
+ category?: string;
453
+ raw: string;
454
+ quantity: number;
455
+ markPriceUsd: number | null;
456
+ notionalUsd: number | null;
457
+ }
458
+ ```
459
+
460
+ ### VaultOverview
461
+
462
+ ```ts
463
+ export interface VaultOverview {
464
+ address: string;
465
+ chainId: number;
466
+ tokens: VaultToken[];
467
+ balances: VaultBalance[];
468
+ poolAddress: string | null;
469
+ explorerBase: string;
470
+ keeperAddress: string | null;
471
+ }
472
+ ```
473
+
474
+ ### VaultPreparedStep
475
+
476
+ An individual calldata instruction:
477
+
478
+ ```ts
479
+ export interface VaultPreparedStep {
480
+ to: string;
481
+ data: string;
482
+ value: string;
483
+ functionName: "approve" | "deposit" | "depositETH" | "withdraw";
484
+ label: string;
485
+ }
486
+ ```
487
+
488
+ ### VaultPrepareResult
489
+
490
+ The aggregated calldata bundle returned by the API:
491
+
492
+ ```ts
493
+ export interface VaultPrepareResult {
494
+ chainId: number;
495
+ vaultAddress: string;
496
+ explorerBase: string;
497
+ symbol: string;
498
+ amountRaw: string;
499
+ amountHuman: string;
500
+ steps: VaultPreparedStep[];
501
+ }
502
+ ```
503
+
504
+ #### JSON Representation Example
505
+ ```json
506
+ {
507
+ "chainId": 46630,
508
+ "vaultAddress": "0x1234567890123456789012345678901234567890",
509
+ "explorerBase": "https://explorer.robinhoodnet.org",
510
+ "symbol": "WETH",
511
+ "amountRaw": "1000000000000000000",
512
+ "amountHuman": "1.0",
513
+ "steps": [
514
+ {
515
+ "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
516
+ "data": "0x095cae9a0000000000000000000000001234567890123456789012345678901234567890ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
517
+ "value": "0",
518
+ "functionName": "approve",
519
+ "label": "Approve WETH allowance for Vault"
520
+ },
521
+ {
522
+ "to": "0x1234567890123456789012345678901234567890",
523
+ "data": "0xb6b55f250000000000000000000000000000000000000000000000000de0b6b3a7640000",
524
+ "value": "0",
525
+ "functionName": "deposit",
526
+ "label": "Deposit 1.0 WETH into Vault"
527
+ }
528
+ ]
529
+ }
530
+ ```
531
+
532
+ ---
533
+
534
+ ## 8. Market Domain
535
+
536
+ Supports simulation and pricing variables for testing rebalances.
537
+
538
+ ### MarketEvent
539
+
540
+ ```ts
541
+ export interface MarketEvent {
542
+ id: string;
543
+ name: string;
544
+ description: string;
545
+ symbol: string;
546
+ priceChangeRatio: number;
547
+ appliedAt: string;
548
+ }
549
+ ```
550
+
551
+ ### ApplyMarketEventInput
552
+
553
+ ```ts
554
+ export interface ApplyMarketEventInput {
555
+ name?: string;
556
+ description?: string;
557
+ symbol: string;
558
+ priceChangeRatio: number;
559
+ autoRestore?: boolean;
560
+ }
561
+ ```
562
+
563
+ ---
564
+
565
+ ## 9. Dashboard Overview
566
+
567
+ Provides a high-level summary of all objectives, health states, historical scores, and execution events.
568
+
569
+ ### DashboardOverview
570
+
571
+ ```ts
572
+ export interface DashboardOverview {
573
+ activeObjectives: number;
574
+ healthyCount: number;
575
+ warningCount: number;
576
+ violationCount: number;
577
+ pausedCount: number;
578
+ totalNotionalUsd: number;
579
+ stableWeight: number;
580
+ assetCount: number;
581
+ change24hUsd: number | null;
582
+ change24hPct: number | null;
583
+ change24hBaselineOnly: boolean;
584
+ change24hHasSnapshot: boolean;
585
+ globalHealthScore: number | null;
586
+ healthHistory: Array<{ at: string; score: number }>;
587
+ attentionCount: number;
588
+ lastEvaluationAt: string | null;
589
+ nextEvaluationAt: string | null;
590
+ watchdogIntervalMs: number | null;
591
+ lastWatchdogError: string | null;
592
+ lastSyncedAt: string | null;
593
+ recentExecutions: ExecutionReceipt[];
594
+ recentEvents: TimelineEvent[];
595
+ }
596
+ ```
597
+
598
+ ---
599
+
600
+ ## 10. Client Options (Config Contract)
601
+
602
+ Configuration block supplied to the `AureonClient` constructor.
603
+
604
+ ```ts
605
+ export interface AureonClientOptions {
606
+ baseUrl?: string;
607
+ apiKey?: string | null;
608
+ getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
609
+ fetch?: typeof fetch;
610
+ headers?: Record<string, string>;
611
+ timeoutMs?: number;
612
+ authToken?: string | null;
613
+ getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
614
+ logger?: AureonLogger;
615
+ maxRetries?: number;
616
+ retryDelayMs?: number;
617
+ }
618
+ ```
619
+
620
+ ---
621
+
622
+ ## 11. Invariants Checklist
623
+
624
+ * `targetWeight` must be inside the `[0, 1]` closed interval.
625
+ * `tolerance` must be inside the `[0, 0.5]` closed interval.
626
+ * Objective display names must have a trimmed length of at least 3 characters.
627
+ * `balanced_portfolio` objectives must specify a valid targetSymbol string.
628
+ * SDK client creations default to Automatic restore mode (`automationMode: "auto"`).
629
+ * Any base URL passed must use an absolute `http://` or `https://` scheme.
630
+ * The portfolio book may be empty, which is evaluated as 0 notional value.
631
+ * Execution receipts must label the settlement mechanism cleanly (`staged` versus `vault`).
632
+ * Vault preparation endpoints only produce unsigned calldata, keeping private signing operations strictly local.