@buildaureon/sdk 0.1.0 → 0.1.1
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/README.md +353 -245
- package/dist/index.d.ts +15 -6
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +139 -138
- package/docs/auth.md +127 -168
- package/docs/client-api.md +5 -4
- package/docs/data-contracts.md +7 -4
- package/docs/error-model.md +151 -116
- package/docs/integration-guide.md +173 -112
- package/docs/security.md +87 -41
- package/docs/transport.md +91 -77
- package/examples/e2e-policy-rebalance/main.ts +24 -36
- package/examples/e2e-policy-rebalance/underrun.ts +28 -24
- package/examples/e2e-policy-rebalance/verify-sizing.ts +29 -26
- package/examples/e2e-vault-flow/main.ts +36 -90
- package/examples/market-event/main.ts +9 -9
- package/examples/quickstart/main.ts +17 -16
- package/examples/sdk-demo-terminal/main.ts +171 -0
- package/package.json +5 -8
package/docs/architecture.md
CHANGED
|
@@ -1,205 +1,206 @@
|
|
|
1
1
|
# Architecture Guide
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
4
6
|
|
|
5
7
|
---
|
|
6
8
|
|
|
7
|
-
## 1.
|
|
9
|
+
## 1. Vision
|
|
8
10
|
|
|
9
|
-
AUREON
|
|
10
|
-
1. **Continuous Policy Tracking**: The AUREON Health and Watchdog Engines continuously monitor capital allocations against user-defined objectives (e.g. maintaining a 20% stablecoin sleeve).
|
|
11
|
-
2. **Non-Custodial execution**: When allocations drift outside the allowed tolerance, the system generates execution plans. Rebalances are executed on-chain via Smart Vaults, but transaction signatures are produced locally by the user's wallet.
|
|
11
|
+
AUREON is a non-custodial Financial Compass for onchain agents on Robinhood Chain:
|
|
12
12
|
|
|
13
|
-
|
|
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.
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
---
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
## 2. Component layers
|
|
18
21
|
|
|
19
22
|
```mermaid
|
|
20
23
|
graph TB
|
|
21
|
-
subgraph ClientBoundary [
|
|
22
|
-
App[
|
|
23
|
-
SDK["@buildaureon/sdk
|
|
24
|
-
Session[
|
|
25
|
-
Signer[
|
|
24
|
+
subgraph ClientBoundary [Client_boundary]
|
|
25
|
+
App[Agent_or_script]
|
|
26
|
+
SDK["@buildaureon/sdk"]
|
|
27
|
+
Session[Session_provider_optional]
|
|
28
|
+
Signer[Local_wallet_signer]
|
|
26
29
|
|
|
27
30
|
App --> SDK
|
|
28
31
|
App --> Session
|
|
29
32
|
App --> Signer
|
|
30
33
|
end
|
|
31
34
|
|
|
32
|
-
subgraph GatewayBoundary [
|
|
33
|
-
API[
|
|
34
|
-
DB[(
|
|
35
|
-
Oracles[
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Watchdog[Watchdog Engine]
|
|
40
|
-
Planner[Restoration Planner]
|
|
41
|
-
end
|
|
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
42
|
|
|
43
43
|
API --> DB
|
|
44
|
-
API -->
|
|
45
|
-
|
|
44
|
+
API --> Health
|
|
45
|
+
API --> Watchdog
|
|
46
|
+
API --> Planner
|
|
47
|
+
Oracles --> Health
|
|
46
48
|
end
|
|
47
49
|
|
|
48
|
-
subgraph ChainBoundary [
|
|
49
|
-
RPC[
|
|
50
|
-
Vaults[
|
|
51
|
-
Keepers[
|
|
50
|
+
subgraph ChainBoundary [Robinhood_Chain]
|
|
51
|
+
RPC[RPC]
|
|
52
|
+
Vaults[Smart_Vault]
|
|
53
|
+
Keepers[Keeper_network]
|
|
52
54
|
|
|
53
55
|
RPC --> Vaults
|
|
54
56
|
Keepers --> Vaults
|
|
55
57
|
end
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Keepers -->|"Automated Rebalance Swaps"| Vaults
|
|
59
|
+
SDK -->|HTTPS_API_key| API
|
|
60
|
+
Signer -->|broadcast_owner_txs| RPC
|
|
61
|
+
API -->|read_balances| RPC
|
|
62
|
+
Keepers -->|allowlisted_swaps| Vaults
|
|
62
63
|
```
|
|
63
64
|
|
|
64
|
-
### 2.1
|
|
65
|
-
* **AureonClient**: The main class exported by `@buildaureon/sdk`. It coordinates REST requests, implements pre-flight input validation, maps HTTP errors to TypeScript classes, and manages retries.
|
|
66
|
-
* **Session Token Provider**: A stateful container that maintains the ephemeral JSON Web Token (JWT) retrieved during wallet signature verification.
|
|
67
|
-
* **Local Wallet Signer**: A private key management module (e.g. Viem, Ethers, or an HSM) controlled by the integrator. It signs transaction steps returned by the vault preparation endpoints.
|
|
65
|
+
### 2.1 Client layer (`@buildaureon/sdk`)
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* **Restoration Planner**: Computes the trade sizes and asset swaps needed to return a violating objective back to its target policy.
|
|
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 |
|
|
76
73
|
|
|
77
|
-
### 2.
|
|
78
|
-
* **AUREON Smart Vaults**: ERC-20 and ERC-4626 compatible smart contracts deployed on the Robinhood Chain. They hold the user's custody-free rebalancing capital.
|
|
79
|
-
* **Automated Keeper Network**: Off-chain worker bots that listen for restoration plans, call the smart vaults with keeper signatures, and execute swaps via decentralized liquidity pools.
|
|
74
|
+
### 2.2 Gateway layer
|
|
80
75
|
|
|
81
|
-
|
|
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) |
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
### 2.3 On-chain layer
|
|
84
86
|
|
|
85
|
-
|
|
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
|
|
86
96
|
|
|
87
97
|
```mermaid
|
|
88
98
|
sequenceDiagram
|
|
89
99
|
autonumber
|
|
90
|
-
participant Host as
|
|
91
|
-
participant SDK as
|
|
92
|
-
participant API as
|
|
93
|
-
participant Vault as
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
+
```
|
|
104
119
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
API-->>SDK: RestorePlan (vault_swap, amount, assets)
|
|
111
|
-
SDK-->>Host: Returns plan details
|
|
112
|
-
end
|
|
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.
|
|
113
125
|
|
|
114
|
-
|
|
115
|
-
Note over Host, Vault: Phase 3: Execution and Settlement
|
|
116
|
-
Host->>SDK: restoreObjective(objectiveId) (or runExecution)
|
|
117
|
-
SDK->>API: POST /executions/run
|
|
118
|
-
API->>Vault: Submit keeper-signed swap instruction
|
|
119
|
-
Vault->>Vault: Execute decentralized exchange swap
|
|
120
|
-
Vault-->>API: Emit Swap Log and TX Receipt
|
|
121
|
-
API-->>SDK: ExecutionReceipt (settlement: "vault", status: "confirmed")
|
|
122
|
-
SDK-->>Host: Return receipt with Transaction Hash
|
|
123
|
-
end
|
|
124
|
-
```
|
|
126
|
+
### Capital book vs vault
|
|
125
127
|
|
|
126
|
-
|
|
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 restores cannot meaningfully settle on-chain even if policy exists.
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
If the current allocation drifts beyond the tolerance window, the Health Engine flags the objective's state as `violation` and creates a `TimelineEvent` of type `violation_detected`.
|
|
132
|
+
---
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
The restoration planner calculates the difference between the current weight and the target weight. It translates this difference into a target amount of tokens to buy or sell, package-wrapped inside a `RestorePlan`.
|
|
134
|
+
## 4. Health evaluation (summary)
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
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 |
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
The transaction completes on the Robinhood Chain, and the gateway records an `ExecutionReceipt` with `settlement: "vault"` and `status: "confirmed"`, marking the objective status back to `healthy`.
|
|
143
|
+
Exact fields live in [data-contracts.md](./data-contracts.md).
|
|
140
144
|
|
|
141
145
|
---
|
|
142
146
|
|
|
143
|
-
##
|
|
147
|
+
## 5. Objective immutability
|
|
144
148
|
|
|
145
|
-
|
|
146
|
-
The Health Engine evaluates each of the four objective types using specific mathematical parameters:
|
|
149
|
+
At create time the SDK records:
|
|
147
150
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
* **Condition**: Target Weight $T$ and Tolerance $t$. The sleeve is healthy if $|W_{stable} - T| \le t$.
|
|
151
|
-
* **Breach**: If $W_{stable} > T + t$, the planner generates a plan to sell stables. If $W_{stable} < T - t$, the planner generates a plan to buy stables.
|
|
151
|
+
- `targetSymbol` (optional / required by kind)
|
|
152
|
+
- `automationMode` (SDK default **`auto`**)
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
* **Metric**: $W_{targetSymbol} = \frac{\text{Notional}(TargetSymbol)}{\text{Total Portfolio Notional}}$
|
|
155
|
-
* **Condition**: Target Weight $T$ and Tolerance $t$.
|
|
156
|
-
* **Breach**: Triggers rebalancing if the target asset drifts outside the tolerance window.
|
|
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.
|
|
157
155
|
|
|
158
|
-
|
|
159
|
-
* **Metric**: $\text{RiskScore} = \sum (W_{asset} \times \text{VolatilityRisk}(Asset))$
|
|
160
|
-
* **Condition**: Risk Score must remain below $\text{maxRiskScore}$.
|
|
161
|
-
* **Breach**: Generates plans to swap highly volatile assets for stable assets if the portfolio risk exceeds the ceiling.
|
|
162
|
-
|
|
163
|
-
4. **Reward Reinvestment (`reward_reinvestment`)**:
|
|
164
|
-
* **Metric**: $\text{AccumulatedRewards}$
|
|
165
|
-
* **Condition**: Automatically sweeps yield generated by vault positions.
|
|
166
|
-
* **Breach**: Triggers when accrued reward tokens exceed a cost-effective gas threshold, reinvesting them into the target sleeve.
|
|
156
|
+
---
|
|
167
157
|
|
|
168
|
-
|
|
169
|
-
While rebalancing is handled by automated keepers, adding or removing funds from the vault requires manual developer wallet signatures.
|
|
158
|
+
## 6. Non-custodial deposit / withdraw
|
|
170
159
|
|
|
171
160
|
```mermaid
|
|
172
161
|
flowchart TD
|
|
173
|
-
Host
|
|
174
|
-
SDK -->|
|
|
175
|
-
API -->|
|
|
176
|
-
SDK -->|
|
|
177
|
-
Host -->|
|
|
178
|
-
Wallet -->|6. Broadcast Signed Calldata| Chain[Robinhood Chain RPC]
|
|
162
|
+
Host -->|prepare| SDK
|
|
163
|
+
SDK -->|POST_prepare| API
|
|
164
|
+
API -->|unsigned_steps| SDK
|
|
165
|
+
SDK -->|steps| Host
|
|
166
|
+
Host -->|sign_broadcast| Chain
|
|
179
167
|
```
|
|
180
168
|
|
|
181
|
-
1.
|
|
182
|
-
2.
|
|
183
|
-
3.
|
|
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.
|
|
184
173
|
|
|
185
174
|
---
|
|
186
175
|
|
|
187
|
-
##
|
|
176
|
+
## 7. Trust posture
|
|
188
177
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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 |
|
|
194
184
|
|
|
195
185
|
---
|
|
196
186
|
|
|
197
|
-
##
|
|
187
|
+
## 8. Network (early access testnet)
|
|
188
|
+
|
|
189
|
+
| Item | Value |
|
|
190
|
+
| --- | --- |
|
|
191
|
+
| Chain | Robinhood Chain testnet |
|
|
192
|
+
| Chain ID | `46630` |
|
|
193
|
+
| API | `https://api.aureonlabs.network` |
|
|
194
|
+
| Explorer | Configure via product / env (`AUREON_EXPLORER_BASE`) |
|
|
195
|
+
|
|
196
|
+
Confirm live addresses and allowlisted symbols from the operator utility and API responses — do not hardcode stale addresses in agents.
|
|
197
|
+
|
|
198
|
+
---
|
|
198
199
|
|
|
199
|
-
|
|
200
|
+
## 9. Related docs
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
- [Integration guide](./integration-guide.md)
|
|
203
|
+
- [Auth](./auth.md)
|
|
204
|
+
- [Security](./security.md)
|
|
205
|
+
- [Client API](./client-api.md)
|
|
206
|
+
- [Data contracts](./data-contracts.md)
|