@buildaureon/sdk 0.1.7 → 0.1.9
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/CHANGELOG.md +71 -0
- package/README.md +673 -655
- package/config/network.json +17 -7
- package/dist/index.d.ts +71 -14
- package/dist/index.js +109 -10
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +210 -206
- package/docs/auth.md +176 -174
- package/docs/client-api.md +788 -782
- package/docs/data-contracts.md +3 -3
- package/docs/error-model.md +217 -217
- package/docs/integration-guide.md +400 -397
- package/docs/receipt-validation.md +66 -63
- package/docs/security.md +120 -120
- package/docs/transport.md +143 -142
- package/examples/ai-to-objective-to-portfolio/main.ts +6 -3
- package/examples/audit-trail/main.ts +4 -2
- package/examples/drift-detect-restore/main.ts +6 -3
- package/examples/e2e-policy-rebalance/main.ts +431 -426
- package/examples/e2e-policy-rebalance/underrun.ts +143 -138
- package/examples/e2e-policy-rebalance/verify-sizing.ts +155 -150
- package/examples/e2e-vault-flow/main.ts +221 -216
- package/examples/full-aureon-loop/main.ts +6 -3
- package/examples/green-vs-plan/main.ts +6 -3
- package/examples/market-event/main.ts +6 -3
- package/examples/portfolio-watch/main.ts +6 -3
- package/examples/quickstart/main.ts +75 -72
- package/examples/receipt-verification/main.ts +6 -3
- package/examples/sdk-demo-terminal/main.ts +6 -4
- package/package.json +26 -23
package/docs/architecture.md
CHANGED
|
@@ -1,206 +1,210 @@
|
|
|
1
|
-
# Architecture Guide
|
|
2
|
-
|
|
3
|
-
System architecture for AUREON and how `@buildaureon/sdk` fits as the typed client for Automatic agent workflows.
|
|
4
|
-
|
|
5
|
-
**Automation note:** The SDK is built for **Automatic** objectives (`automationMode: "auto"`). Manual Approve operator flows are handled in the utility, not as the primary SDK architecture.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 1. Vision
|
|
10
|
-
|
|
11
|
-
AUREON is a non-custodial Financial Compass for onchain agents on Robinhood Chain:
|
|
12
|
-
|
|
13
|
-
1. **Persistent policy** — objectives define target weights / risk bands and stay registered.
|
|
14
|
-
2. **Continuous health** — watchdog + marks detect drift past tolerance.
|
|
15
|
-
3. **Honest restore** — plans and receipts (`settlement: vault | staged`) make settlement transparent.
|
|
16
|
-
4. **Local signing** — owner deposits/withdraws are prepared by the API and signed by the host.
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## 2. Component layers
|
|
21
|
-
|
|
22
|
-
```mermaid
|
|
23
|
-
graph TB
|
|
24
|
-
subgraph ClientBoundary [Client_boundary]
|
|
25
|
-
App[Agent_or_script]
|
|
26
|
-
SDK["@buildaureon/sdk"]
|
|
27
|
-
Session[Session_provider_optional]
|
|
28
|
-
Signer[Local_wallet_signer]
|
|
29
|
-
|
|
30
|
-
App --> SDK
|
|
31
|
-
App --> Session
|
|
32
|
-
App --> Signer
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
subgraph GatewayBoundary [Hosted_gateway]
|
|
36
|
-
API[AUREON_API]
|
|
37
|
-
DB[(Ledger_store)]
|
|
38
|
-
Oracles[Price_marks]
|
|
39
|
-
Health[Health_engine]
|
|
40
|
-
Watchdog[Watchdog]
|
|
41
|
-
Planner[Restore_planner]
|
|
42
|
-
|
|
43
|
-
API --> DB
|
|
44
|
-
API --> Health
|
|
45
|
-
API --> Watchdog
|
|
46
|
-
API --> Planner
|
|
47
|
-
Oracles --> Health
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
subgraph ChainBoundary [Robinhood_Chain]
|
|
51
|
-
RPC[RPC]
|
|
52
|
-
Vaults[Smart_Vault]
|
|
53
|
-
Keepers[Keeper_network]
|
|
54
|
-
|
|
55
|
-
RPC --> Vaults
|
|
56
|
-
Keepers --> Vaults
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
SDK -->|HTTPS_API_key| API
|
|
60
|
-
Signer -->|broadcast_owner_txs| RPC
|
|
61
|
-
API -->|read_balances| RPC
|
|
62
|
-
Keepers -->|allowlisted_swaps| Vaults
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### 2.1 Client layer (`@buildaureon/sdk`)
|
|
66
|
-
|
|
67
|
-
| Piece | Role |
|
|
68
|
-
| --- | --- |
|
|
69
|
-
| `AureonClient` | Typed REST client, validation, retries, error mapping |
|
|
70
|
-
| Issued API key | Wallet identity for control plane |
|
|
71
|
-
| Session provider | Optional Bearer for utility-style sessions |
|
|
72
|
-
| Host signer | Broadcasts prepare-deposit / prepare-withdraw steps |
|
|
73
|
-
|
|
74
|
-
### 2.2 Gateway layer
|
|
75
|
-
|
|
76
|
-
| Piece | Role |
|
|
77
|
-
| --- | --- |
|
|
78
|
-
| API | Objectives, portfolio sync, vault prepare, restore, timeline |
|
|
79
|
-
| Ledger | Objectives, health snapshots, receipts, events |
|
|
80
|
-
| Marks | Price inputs for weight math |
|
|
81
|
-
| Health engine | Compares weights / risk to policy |
|
|
82
|
-
| Watchdog | Heartbeat evaluation across active Auto objectives |
|
|
83
|
-
| Planner | Builds restore plans (e.g. vault_swap) |
|
|
84
|
-
|
|
85
|
-
### 2.3 On-chain layer
|
|
86
|
-
|
|
87
|
-
| Piece | Role |
|
|
88
|
-
| --- | --- |
|
|
89
|
-
| Smart Vault | Holds rebalancing capital under owner + keeper rules |
|
|
90
|
-
| Keepers | Execute Automatic restore swaps on allowlisted routes |
|
|
91
|
-
| Owner txs | Deposit / withdraw via signed prepare steps |
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## 3. Automatic restore lifecycle
|
|
96
|
-
|
|
97
|
-
```mermaid
|
|
98
|
-
sequenceDiagram
|
|
99
|
-
autonumber
|
|
100
|
-
participant Host as Agent
|
|
101
|
-
participant SDK as SDK
|
|
102
|
-
participant API as API
|
|
103
|
-
participant Vault as Smart_Vault
|
|
104
|
-
|
|
105
|
-
Host->>SDK: refreshWatchdog()
|
|
106
|
-
SDK->>API: POST /watchdog/refresh
|
|
107
|
-
API-->>Host: breaches
|
|
108
|
-
|
|
109
|
-
Host->>SDK: getRestorePlan(id)
|
|
110
|
-
SDK->>API: GET restore-plan
|
|
111
|
-
API-->>Host: RestorePlan
|
|
112
|
-
|
|
113
|
-
Host->>SDK: restoreObjective(id)
|
|
114
|
-
SDK->>API: POST restore
|
|
115
|
-
API->>Vault: keeper_allowlisted_swap
|
|
116
|
-
Vault-->>API: receipt
|
|
117
|
-
API-->>Host: ExecutionReceipt settlement
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
1. **Evaluate** — sync vault + wallet marks, compute weights.
|
|
121
|
-
2. **Detect** — if `|current - target| > tolerance`, health → `violation`.
|
|
122
|
-
3. **Plan** — planner emits a restore plan (often `vault_swap`).
|
|
123
|
-
4. **Execute** — Automatic restore coordinates keeper vault execution.
|
|
124
|
-
5. **Confirm** — receipt + timeline; health returns toward `healthy` when sizing/liquidity succeed.
|
|
125
|
-
|
|
126
|
-
### Capital book vs vault
|
|
127
|
-
|
|
128
|
-
- **Capital Book** — gateway portfolio used for weight math (`syncPortfolio`).
|
|
129
|
-
- **Vault balances** — on-chain capital Automatic restores trade against.
|
|
130
|
-
- Empty vault ⇒ Automatic restore returns 409. It does not
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## 4. Health evaluation (summary)
|
|
135
|
-
|
|
136
|
-
| Kind | Core idea |
|
|
137
|
-
| --- | --- |
|
|
138
|
-
| `stable_allocation` | Stable sleeve weight vs target ± tolerance |
|
|
139
|
-
| `balanced_portfolio` | `targetSymbol` weight vs target ± tolerance |
|
|
140
|
-
| `risk_ceiling` | Aggregate risk score vs `maxRiskScore` |
|
|
141
|
-
| `reward_reinvestment` | Accrued rewards above actionable threshold |
|
|
142
|
-
|
|
143
|
-
Exact fields live in [data-contracts.md](./data-contracts.md).
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## 5. Objective immutability
|
|
148
|
-
|
|
149
|
-
At create time the SDK records:
|
|
150
|
-
|
|
151
|
-
- `targetSymbol` (optional / required by kind)
|
|
152
|
-
- `automationMode` (SDK default **`auto`**)
|
|
153
|
-
|
|
154
|
-
Neither can be patched later via `updateObjective`. Recreate to change token or mode. Updates may change name, weights, tolerance, priority, and kind-specific numeric fields.
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## 6. Non-custodial deposit / withdraw
|
|
159
|
-
|
|
160
|
-
```mermaid
|
|
161
|
-
flowchart TD
|
|
162
|
-
Host -->|prepare| SDK
|
|
163
|
-
SDK -->|POST_prepare| API
|
|
164
|
-
API -->|unsigned_steps| SDK
|
|
165
|
-
SDK -->|steps| Host
|
|
166
|
-
Host -->|sign_broadcast| Chain
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
1. Host calls `prepareVaultDeposit` / `prepareVaultWithdraw`.
|
|
170
|
-
2. API returns approve + deposit/withdraw steps as needed.
|
|
171
|
-
3. Host signs and broadcasts.
|
|
172
|
-
4. Later `syncPortfolio` / `getVault` reflect chain state.
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## 7. Trust posture
|
|
177
|
-
|
|
178
|
-
| Claim | Reality |
|
|
179
|
-
| --- | --- |
|
|
180
|
-
| API key steals funds | No — cannot sign owner withdrawals |
|
|
181
|
-
| Keeper steals funds | No — allowlisted swaps only |
|
|
182
|
-
| Staged = on-chain | No — label `settlement` honestly |
|
|
183
|
-
| SDK holds keys | No — host signer only |
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## 8. Network
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
- [
|
|
1
|
+
# Architecture Guide
|
|
2
|
+
|
|
3
|
+
System architecture for AUREON and how `@buildaureon/sdk` fits as the typed client for Automatic agent workflows.
|
|
4
|
+
|
|
5
|
+
**Automation note:** The SDK is built for **Automatic** objectives (`automationMode: "auto"`). Manual Approve operator flows are handled in the utility, not as the primary SDK architecture.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Vision
|
|
10
|
+
|
|
11
|
+
AUREON is a non-custodial Financial Compass for onchain agents on Robinhood Chain:
|
|
12
|
+
|
|
13
|
+
1. **Persistent policy** — objectives define target weights / risk bands and stay registered.
|
|
14
|
+
2. **Continuous health** — watchdog + marks detect drift past tolerance.
|
|
15
|
+
3. **Honest restore** — plans and receipts (`settlement: vault | staged`) make settlement transparent.
|
|
16
|
+
4. **Local signing** — owner deposits/withdraws are prepared by the API and signed by the host.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 2. Component layers
|
|
21
|
+
|
|
22
|
+
```mermaid
|
|
23
|
+
graph TB
|
|
24
|
+
subgraph ClientBoundary [Client_boundary]
|
|
25
|
+
App[Agent_or_script]
|
|
26
|
+
SDK["@buildaureon/sdk"]
|
|
27
|
+
Session[Session_provider_optional]
|
|
28
|
+
Signer[Local_wallet_signer]
|
|
29
|
+
|
|
30
|
+
App --> SDK
|
|
31
|
+
App --> Session
|
|
32
|
+
App --> Signer
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
subgraph GatewayBoundary [Hosted_gateway]
|
|
36
|
+
API[AUREON_API]
|
|
37
|
+
DB[(Ledger_store)]
|
|
38
|
+
Oracles[Price_marks]
|
|
39
|
+
Health[Health_engine]
|
|
40
|
+
Watchdog[Watchdog]
|
|
41
|
+
Planner[Restore_planner]
|
|
42
|
+
|
|
43
|
+
API --> DB
|
|
44
|
+
API --> Health
|
|
45
|
+
API --> Watchdog
|
|
46
|
+
API --> Planner
|
|
47
|
+
Oracles --> Health
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
subgraph ChainBoundary [Robinhood_Chain]
|
|
51
|
+
RPC[RPC]
|
|
52
|
+
Vaults[Smart_Vault]
|
|
53
|
+
Keepers[Keeper_network]
|
|
54
|
+
|
|
55
|
+
RPC --> Vaults
|
|
56
|
+
Keepers --> Vaults
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
SDK -->|HTTPS_API_key| API
|
|
60
|
+
Signer -->|broadcast_owner_txs| RPC
|
|
61
|
+
API -->|read_balances| RPC
|
|
62
|
+
Keepers -->|allowlisted_swaps| Vaults
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2.1 Client layer (`@buildaureon/sdk`)
|
|
66
|
+
|
|
67
|
+
| Piece | Role |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `AureonClient` | Typed REST client, validation, retries, error mapping |
|
|
70
|
+
| Issued API key | Wallet identity for control plane |
|
|
71
|
+
| Session provider | Optional Bearer for utility-style sessions |
|
|
72
|
+
| Host signer | Broadcasts prepare-deposit / prepare-withdraw steps |
|
|
73
|
+
|
|
74
|
+
### 2.2 Gateway layer
|
|
75
|
+
|
|
76
|
+
| Piece | Role |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| API | Objectives, portfolio sync, vault prepare, restore, timeline |
|
|
79
|
+
| Ledger | Objectives, health snapshots, receipts, events |
|
|
80
|
+
| Marks | Price inputs for weight math |
|
|
81
|
+
| Health engine | Compares weights / risk to policy |
|
|
82
|
+
| Watchdog | Heartbeat evaluation across active Auto objectives |
|
|
83
|
+
| Planner | Builds restore plans (e.g. vault_swap) |
|
|
84
|
+
|
|
85
|
+
### 2.3 On-chain layer
|
|
86
|
+
|
|
87
|
+
| Piece | Role |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| Smart Vault | Holds rebalancing capital under owner + keeper rules |
|
|
90
|
+
| Keepers | Execute Automatic restore swaps on allowlisted routes |
|
|
91
|
+
| Owner txs | Deposit / withdraw via signed prepare steps |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 3. Automatic restore lifecycle
|
|
96
|
+
|
|
97
|
+
```mermaid
|
|
98
|
+
sequenceDiagram
|
|
99
|
+
autonumber
|
|
100
|
+
participant Host as Agent
|
|
101
|
+
participant SDK as SDK
|
|
102
|
+
participant API as API
|
|
103
|
+
participant Vault as Smart_Vault
|
|
104
|
+
|
|
105
|
+
Host->>SDK: refreshWatchdog()
|
|
106
|
+
SDK->>API: POST /watchdog/refresh
|
|
107
|
+
API-->>Host: breaches
|
|
108
|
+
|
|
109
|
+
Host->>SDK: getRestorePlan(id)
|
|
110
|
+
SDK->>API: GET restore-plan
|
|
111
|
+
API-->>Host: RestorePlan
|
|
112
|
+
|
|
113
|
+
Host->>SDK: restoreObjective(id)
|
|
114
|
+
SDK->>API: POST restore
|
|
115
|
+
API->>Vault: keeper_allowlisted_swap
|
|
116
|
+
Vault-->>API: receipt
|
|
117
|
+
API-->>Host: ExecutionReceipt settlement
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
1. **Evaluate** — sync vault + wallet marks, compute weights.
|
|
121
|
+
2. **Detect** — if `|current - target| > tolerance`, health → `violation`.
|
|
122
|
+
3. **Plan** — planner emits a restore plan (often `vault_swap`).
|
|
123
|
+
4. **Execute** — Automatic restore coordinates keeper vault execution.
|
|
124
|
+
5. **Confirm** — receipt + timeline; health returns toward `healthy` when sizing/liquidity succeed.
|
|
125
|
+
|
|
126
|
+
### Capital book vs vault
|
|
127
|
+
|
|
128
|
+
- **Capital Book** — gateway portfolio used for weight math (`syncPortfolio`).
|
|
129
|
+
- **Vault balances** — on-chain capital Automatic restores trade against.
|
|
130
|
+
- Empty vault ⇒ Automatic restore returns 409. It does not record an on-chain restore or rewrite the capital book. The host prepares an unsigned deposit; the user signs when they use the product.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 4. Health evaluation (summary)
|
|
135
|
+
|
|
136
|
+
| Kind | Core idea |
|
|
137
|
+
| --- | --- |
|
|
138
|
+
| `stable_allocation` | Stable sleeve weight vs target ± tolerance |
|
|
139
|
+
| `balanced_portfolio` | `targetSymbol` weight vs target ± tolerance |
|
|
140
|
+
| `risk_ceiling` | Aggregate risk score vs `maxRiskScore` |
|
|
141
|
+
| `reward_reinvestment` | Accrued rewards above actionable threshold |
|
|
142
|
+
|
|
143
|
+
Exact fields live in [data-contracts.md](./data-contracts.md).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 5. Objective immutability
|
|
148
|
+
|
|
149
|
+
At create time the SDK records:
|
|
150
|
+
|
|
151
|
+
- `targetSymbol` (optional / required by kind)
|
|
152
|
+
- `automationMode` (SDK default **`auto`**)
|
|
153
|
+
|
|
154
|
+
Neither can be patched later via `updateObjective`. Recreate to change token or mode. Updates may change name, weights, tolerance, priority, and kind-specific numeric fields.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 6. Non-custodial deposit / withdraw
|
|
159
|
+
|
|
160
|
+
```mermaid
|
|
161
|
+
flowchart TD
|
|
162
|
+
Host -->|prepare| SDK
|
|
163
|
+
SDK -->|POST_prepare| API
|
|
164
|
+
API -->|unsigned_steps| SDK
|
|
165
|
+
SDK -->|steps| Host
|
|
166
|
+
Host -->|sign_broadcast| Chain
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
1. Host calls `prepareVaultDeposit` / `prepareVaultWithdraw`.
|
|
170
|
+
2. API returns approve + deposit/withdraw steps as needed.
|
|
171
|
+
3. Host signs and broadcasts.
|
|
172
|
+
4. Later `syncPortfolio` / `getVault` reflect chain state.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 7. Trust posture
|
|
177
|
+
|
|
178
|
+
| Claim | Reality |
|
|
179
|
+
| --- | --- |
|
|
180
|
+
| API key steals funds | No — cannot sign owner withdrawals |
|
|
181
|
+
| Keeper steals funds | No — allowlisted swaps only |
|
|
182
|
+
| Staged = on-chain | No — label `settlement` honestly |
|
|
183
|
+
| SDK holds keys | No — host signer only |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 8. Network
|
|
188
|
+
|
|
189
|
+
Default omitted SDK/MCP options use the official API `https://api.aureonlabs.network` on **testnet 46630**. Pass `network: "mainnet"` for chain **4663** on the same host. First use is the same on both networks: empty vault → restore 409 → unsigned `prepareVaultDeposit` → host wallet / MetaMask broadcasts. MCP agents never broadcast.
|
|
190
|
+
|
|
191
|
+
| Item | Testnet (default) | Mainnet (`network: "mainnet"`) |
|
|
192
|
+
| --- | --- | --- |
|
|
193
|
+
| Chain | Robinhood Chain testnet | Robinhood Chain mainnet |
|
|
194
|
+
| Chain ID | `46630` | `4663` |
|
|
195
|
+
| API | `https://api.aureonlabs.network` | `https://api.aureonlabs.network` |
|
|
196
|
+
| Cash park | Testnet catalog (see API) | USDG |
|
|
197
|
+
| Explorer | `https://explorer.testnet.chain.robinhood.com` | `https://robinhoodchain.blockscout.com` |
|
|
198
|
+
| Utility | [app.aureonlabs.network](https://app.aureonlabs.network) | [app.aureonlabs.network](https://app.aureonlabs.network) |
|
|
199
|
+
|
|
200
|
+
The official host still serves chain 46630 until that deployment is cut over. Confirm live addresses from the API you actually call.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 9. Related docs
|
|
205
|
+
|
|
206
|
+
- [Integration guide](./integration-guide.md)
|
|
207
|
+
- [Auth](./auth.md)
|
|
208
|
+
- [Security](./security.md)
|
|
209
|
+
- [Client API](./client-api.md)
|
|
210
|
+
- [Data contracts](./data-contracts.md)
|