@buildaureon/sdk 0.1.0 → 0.1.2
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/LICENSE +21 -21
- package/README.md +640 -532
- package/config/network.json +10 -10
- package/dist/index.d.ts +88 -9
- package/dist/index.js +56 -5
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +206 -205
- package/docs/auth.md +174 -215
- package/docs/client-api.md +605 -604
- package/docs/data-contracts.md +635 -632
- package/docs/error-model.md +217 -182
- package/docs/integration-guide.md +257 -196
- package/docs/security.md +120 -74
- package/docs/transport.md +142 -128
- 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 +65 -65
- package/examples/quickstart/main.ts +72 -71
- package/examples/registry-register/main.ts +44 -0
- package/examples/sdk-demo-terminal/main.ts +171 -0
- package/fixtures/reference-objectives.json +18 -18
- package/fixtures/reference-portfolio.json +10 -10
- package/package.json +61 -64
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Console demo of an Automatic SDK loop against the live API.
|
|
3
|
+
*
|
|
4
|
+
* Env:
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
+
*
|
|
8
|
+
* pnpm --filter @buildaureon/sdk example:sdk-demo-terminal
|
|
9
|
+
* pnpm --filter @buildaureon/sdk example:sdk-demo-terminal -- --create-only
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createAureonClient,
|
|
14
|
+
DEFAULT_API_BASE_URL,
|
|
15
|
+
formatWeight,
|
|
16
|
+
isAureonError,
|
|
17
|
+
type PortfolioPositionInput,
|
|
18
|
+
} from "../../src/index.js";
|
|
19
|
+
|
|
20
|
+
const CREATE_ONLY = process.argv.includes("--create-only");
|
|
21
|
+
|
|
22
|
+
const DEMO_POSITIONS: PortfolioPositionInput[] = [
|
|
23
|
+
{
|
|
24
|
+
symbol: "USDG",
|
|
25
|
+
name: "Paxos USDG",
|
|
26
|
+
category: "stable",
|
|
27
|
+
quantity: 24_000,
|
|
28
|
+
markPriceUsd: 1,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
symbol: "NVDA",
|
|
32
|
+
name: "NVIDIA Stock Token",
|
|
33
|
+
category: "stock_token",
|
|
34
|
+
quantity: 45,
|
|
35
|
+
markPriceUsd: 920,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
symbol: "AAPL",
|
|
39
|
+
name: "Apple Stock Token",
|
|
40
|
+
category: "stock_token",
|
|
41
|
+
quantity: 80,
|
|
42
|
+
markPriceUsd: 210,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
symbol: "GOOGL",
|
|
46
|
+
name: "Alphabet Stock Token",
|
|
47
|
+
category: "stock_token",
|
|
48
|
+
quantity: 60,
|
|
49
|
+
markPriceUsd: 175,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
symbol: "ETH",
|
|
53
|
+
name: "Ether",
|
|
54
|
+
category: "gas",
|
|
55
|
+
quantity: 8.5,
|
|
56
|
+
markPriceUsd: 3400,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
function shortHash(hash: string, head = 10, tail = 6): string {
|
|
61
|
+
if (hash.length <= head + tail + 1) return hash;
|
|
62
|
+
return `${hash.slice(0, head)}…${hash.slice(-tail)}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function line(kind: "cmd" | "out" | "err" | "meta", text: string): void {
|
|
66
|
+
const prefix =
|
|
67
|
+
kind === "cmd" ? "$ " : kind === "err" ? "! " : kind === "meta" ? "# " : " ";
|
|
68
|
+
console.log(`${prefix}${text}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function main(): Promise<void> {
|
|
72
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
73
|
+
if (!apiKey) {
|
|
74
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const baseUrl = process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL;
|
|
78
|
+
line(
|
|
79
|
+
"meta",
|
|
80
|
+
CREATE_ONLY
|
|
81
|
+
? `@buildaureon/sdk · create-only · ${baseUrl}`
|
|
82
|
+
: `@buildaureon/sdk · Automatic demo loop · ${baseUrl}`
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const aureon = createAureonClient({ baseUrl, apiKey });
|
|
86
|
+
|
|
87
|
+
line("cmd", "aureon.ping()");
|
|
88
|
+
const ping = await aureon.ping();
|
|
89
|
+
line(
|
|
90
|
+
"out",
|
|
91
|
+
`connected ok=${String(ping.ok)} service=${ping.service} version=${ping.version}`
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
line("cmd", "aureon.me()");
|
|
95
|
+
const me = await aureon.me();
|
|
96
|
+
line("out", `me wallet=${me.walletAddress}`);
|
|
97
|
+
|
|
98
|
+
line("cmd", "aureon.setPortfolio(/* rehearsal book */)");
|
|
99
|
+
const book = await aureon.setPortfolio(DEMO_POSITIONS);
|
|
100
|
+
line(
|
|
101
|
+
"out",
|
|
102
|
+
`portfolio notional=${book.totalNotionalUsd.toFixed(0)} stable=${formatWeight(book.stableWeight)} positions=${book.positions.length}`
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
line(
|
|
106
|
+
"cmd",
|
|
107
|
+
'aureon.createObjective({ kind: "stable_allocation", targetWeight: 0.2, … })'
|
|
108
|
+
);
|
|
109
|
+
const objective = await aureon.createObjective({
|
|
110
|
+
name: "Maintain 20% Stable Assets",
|
|
111
|
+
kind: "stable_allocation",
|
|
112
|
+
targetWeight: 0.2,
|
|
113
|
+
tolerance: 0.02,
|
|
114
|
+
priority: "high",
|
|
115
|
+
});
|
|
116
|
+
line(
|
|
117
|
+
"out",
|
|
118
|
+
`objective id=${objective.id} status=${objective.status} mode=${objective.automationMode}`
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
if (CREATE_ONLY) {
|
|
122
|
+
line("meta", "create-only complete");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
line(
|
|
127
|
+
"cmd",
|
|
128
|
+
'aureon.applyMarketEvent({ symbol: "NVDA", priceChangeRatio: 0.45, autoRestore: true })'
|
|
129
|
+
);
|
|
130
|
+
const market = await aureon.applyMarketEvent({
|
|
131
|
+
name: "NVDA Stock Token Rally",
|
|
132
|
+
description: "Controlled mark appreciation on NVIDIA Stock Token",
|
|
133
|
+
symbol: "NVDA",
|
|
134
|
+
priceChangeRatio: 0.45,
|
|
135
|
+
autoRestore: true,
|
|
136
|
+
});
|
|
137
|
+
line(
|
|
138
|
+
"out",
|
|
139
|
+
`market event=${market.event.id} ${market.event.symbol} ${(market.event.priceChangeRatio * 100).toFixed(0)}%`
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const executions =
|
|
143
|
+
market.executions.length > 0
|
|
144
|
+
? market.executions
|
|
145
|
+
: await aureon.listExecutions(objective.id);
|
|
146
|
+
for (const receipt of executions) {
|
|
147
|
+
line(
|
|
148
|
+
"out",
|
|
149
|
+
`execution id=${receipt.id} status=${receipt.status} settlement=${receipt.settlement ?? "n/a"} hash=${shortHash(receipt.transactionHash)}`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const finalHealth = (await aureon.getHealth(objective.id))[0];
|
|
154
|
+
if (finalHealth) {
|
|
155
|
+
line(
|
|
156
|
+
"out",
|
|
157
|
+
`health state=${finalHealth.state} current=${formatWeight(finalHealth.currentMetric)} target=${formatWeight(finalHealth.targetMetric)}`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
line("meta", "done — check settlement field before claiming on-chain");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
main().catch((error) => {
|
|
165
|
+
if (isAureonError(error)) {
|
|
166
|
+
line("err", `${error.code}: ${error.message}`);
|
|
167
|
+
} else {
|
|
168
|
+
line("err", error instanceof Error ? error.message : String(error));
|
|
169
|
+
}
|
|
170
|
+
process.exitCode = 1;
|
|
171
|
+
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"objectives": [
|
|
3
|
-
{
|
|
4
|
-
"name": "Maintain 20% Stable Assets",
|
|
5
|
-
"kind": "stable_allocation",
|
|
6
|
-
"targetWeight": 0.2,
|
|
7
|
-
"tolerance": 0.02,
|
|
8
|
-
"priority": "high"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "Balanced Stock Token Sleeve",
|
|
12
|
-
"kind": "balanced_portfolio",
|
|
13
|
-
"targetWeight": 0.55,
|
|
14
|
-
"tolerance": 0.05,
|
|
15
|
-
"priority": "medium"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"objectives": [
|
|
3
|
+
{
|
|
4
|
+
"name": "Maintain 20% Stable Assets",
|
|
5
|
+
"kind": "stable_allocation",
|
|
6
|
+
"targetWeight": 0.2,
|
|
7
|
+
"tolerance": 0.02,
|
|
8
|
+
"priority": "high"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Balanced Stock Token Sleeve",
|
|
12
|
+
"kind": "balanced_portfolio",
|
|
13
|
+
"targetWeight": 0.55,
|
|
14
|
+
"tolerance": 0.05,
|
|
15
|
+
"priority": "medium"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"portfolioId": "portfolio_operator_primary",
|
|
3
|
-
"positions": [
|
|
4
|
-
{ "symbol": "USDG", "category": "stable", "quantity": 24000, "markPriceUsd": 1 },
|
|
5
|
-
{ "symbol": "NVDA", "category": "stock_token", "quantity": 45, "markPriceUsd": 920 },
|
|
6
|
-
{ "symbol": "AAPL", "category": "stock_token", "quantity": 80, "markPriceUsd": 210 },
|
|
7
|
-
{ "symbol": "GOOGL", "category": "stock_token", "quantity": 60, "markPriceUsd": 175 },
|
|
8
|
-
{ "symbol": "ETH", "category": "gas", "quantity": 8.5, "markPriceUsd": 3400 }
|
|
9
|
-
]
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"portfolioId": "portfolio_operator_primary",
|
|
3
|
+
"positions": [
|
|
4
|
+
{ "symbol": "USDG", "category": "stable", "quantity": 24000, "markPriceUsd": 1 },
|
|
5
|
+
{ "symbol": "NVDA", "category": "stock_token", "quantity": 45, "markPriceUsd": 920 },
|
|
6
|
+
{ "symbol": "AAPL", "category": "stock_token", "quantity": 80, "markPriceUsd": 210 },
|
|
7
|
+
{ "symbol": "GOOGL", "category": "stock_token", "quantity": 60, "markPriceUsd": 175 },
|
|
8
|
+
{ "symbol": "ETH", "category": "gas", "quantity": 8.5, "markPriceUsd": 3400 }
|
|
9
|
+
]
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,64 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@buildaureon/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Official TypeScript SDK for AUREON Financial Compass on Robinhood Chain",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"README.md",
|
|
18
|
-
"LICENSE",
|
|
19
|
-
"docs",
|
|
20
|
-
"examples",
|
|
21
|
-
"config",
|
|
22
|
-
"fixtures"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsup",
|
|
26
|
-
"dev": "tsup --watch",
|
|
27
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
-
"test": "tsx --test tests/**/*.test.ts",
|
|
29
|
-
"bench": "tsx benchmarks/client-throughput.ts",
|
|
30
|
-
"example:quickstart": "tsx examples/quickstart/main.ts",
|
|
31
|
-
"example:market": "tsx examples/market-event/main.ts",
|
|
32
|
-
"example:
|
|
33
|
-
"example:e2e
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
},
|
|
54
|
-
"
|
|
55
|
-
"node": "
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"viem": "^2.55.1"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@buildaureon/sdk",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Official TypeScript SDK for AUREON Financial Compass on Robinhood Chain",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"docs",
|
|
20
|
+
"examples",
|
|
21
|
+
"config",
|
|
22
|
+
"fixtures"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch",
|
|
27
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
+
"test": "tsx --test tests/**/*.test.ts",
|
|
29
|
+
"bench": "tsx benchmarks/client-throughput.ts",
|
|
30
|
+
"example:quickstart": "tsx examples/quickstart/main.ts",
|
|
31
|
+
"example:market": "tsx examples/market-event/main.ts",
|
|
32
|
+
"example:sdk-demo-terminal": "tsx examples/sdk-demo-terminal/main.ts",
|
|
33
|
+
"example:e2e": "tsx examples/e2e-vault-flow/main.ts",
|
|
34
|
+
"example:e2e-policy": "tsx examples/e2e-policy-rebalance/main.ts",
|
|
35
|
+
"cli": "tsx cli/aureon-cli.ts",
|
|
36
|
+
"prepublishOnly": "pnpm build"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"aureon",
|
|
40
|
+
"robinhood-chain",
|
|
41
|
+
"fco",
|
|
42
|
+
"financial-compass",
|
|
43
|
+
"sdk",
|
|
44
|
+
"typescript"
|
|
45
|
+
],
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/buildaureon/aureon-sdk"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=20"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^22.13.10",
|
|
56
|
+
"tsup": "^8.4.0",
|
|
57
|
+
"tsx": "^4.19.3",
|
|
58
|
+
"typescript": "^5.8.2",
|
|
59
|
+
"viem": "^2.55.1"
|
|
60
|
+
}
|
|
61
|
+
}
|