@buildaureon/sdk 0.1.8 → 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 -658
- package/config/network.json +6 -6
- package/dist/index.d.ts +31 -26
- package/dist/index.js +30 -20
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +210 -208
- package/docs/auth.md +176 -176
- package/docs/client-api.md +788 -788
- package/docs/data-contracts.md +3 -3
- package/docs/error-model.md +217 -217
- package/docs/integration-guide.md +400 -400
- package/docs/receipt-validation.md +66 -66
- package/docs/security.md +120 -120
- package/docs/transport.md +143 -143
- package/examples/ai-to-objective-to-portfolio/main.ts +1 -1
- package/examples/drift-detect-restore/main.ts +1 -1
- package/examples/e2e-policy-rebalance/main.ts +431 -431
- package/examples/e2e-policy-rebalance/underrun.ts +143 -143
- package/examples/e2e-policy-rebalance/verify-sizing.ts +155 -155
- package/examples/e2e-vault-flow/main.ts +221 -221
- package/examples/full-aureon-loop/main.ts +1 -1
- package/examples/green-vs-plan/main.ts +1 -1
- package/examples/market-event/main.ts +1 -1
- package/examples/portfolio-watch/main.ts +1 -1
- package/examples/quickstart/main.ts +75 -75
- package/examples/receipt-verification/main.ts +1 -1
- package/examples/sdk-demo-terminal/main.ts +2 -2
- package/package.json +2 -1
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Live vault deposit/withdraw + Automatic objective against the AUREON API.
|
|
3
|
-
*
|
|
4
|
-
* Env (integrators only — no local repo files):
|
|
5
|
-
* AUREON_API_KEY issued developer key (required)
|
|
6
|
-
* AUREON_NETWORK optional; omit for
|
|
7
|
-
* AUREON_API_URL optional override
|
|
8
|
-
* AUREON_WALLET_PRIVATE_KEY 0x… key used to sign auth + broadcast vault txs (required)
|
|
9
|
-
* AUREON_RPC_URL optional (defaults from resolved chain)
|
|
10
|
-
* AUREON_CHAIN_ID optional (defaults from resolved network)
|
|
11
|
-
*
|
|
12
|
-
* pnpm --filter @buildaureon/sdk example:e2e
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
createPublicClient,
|
|
17
|
-
createWalletClient,
|
|
18
|
-
http,
|
|
19
|
-
type Hex,
|
|
20
|
-
} from "viem";
|
|
21
|
-
import { privateKeyToAccount } from "viem/accounts";
|
|
22
|
-
import {
|
|
23
|
-
createAureonClient,
|
|
24
|
-
createSessionTokenProvider,
|
|
25
|
-
resolveAureonNetworkFromEnv,
|
|
26
|
-
isAureonError,
|
|
27
|
-
} from "../../src/index.js";
|
|
28
|
-
|
|
29
|
-
function requireEnv(name: string): string {
|
|
30
|
-
const value = process.env[name]?.trim();
|
|
31
|
-
if (!value) throw new Error(`Set ${name}`);
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function loadPrivateKey(): Hex {
|
|
36
|
-
const key = requireEnv("AUREON_WALLET_PRIVATE_KEY");
|
|
37
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
38
|
-
throw new Error("AUREON_WALLET_PRIVATE_KEY must be a 0x-prefixed 32-byte hex key");
|
|
39
|
-
}
|
|
40
|
-
return key as Hex;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function log(step: string, data?: unknown): void {
|
|
44
|
-
if (data === undefined) {
|
|
45
|
-
console.log(`✓ ${step}`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
console.log(`✓ ${step}`, data);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function main(): Promise<void> {
|
|
52
|
-
const resolved = resolveAureonNetworkFromEnv();
|
|
53
|
-
const baseUrl = resolved.baseUrl;
|
|
54
|
-
const apiKey = requireEnv("AUREON_API_KEY");
|
|
55
|
-
const chainId = Number(process.env.AUREON_CHAIN_ID ?? resolved.chainId);
|
|
56
|
-
const rpcUrl =
|
|
57
|
-
process.env.AUREON_RPC_URL?.trim() ||
|
|
58
|
-
(chainId === 4663
|
|
59
|
-
? "https://rpc.mainnet.chain.robinhood.com"
|
|
60
|
-
: "https://rpc.testnet.chain.robinhood.com");
|
|
61
|
-
|
|
62
|
-
const account = privateKeyToAccount(loadPrivateKey());
|
|
63
|
-
const publicClient = createPublicClient({ transport: http(rpcUrl) });
|
|
64
|
-
const walletClient = createWalletClient({
|
|
65
|
-
account,
|
|
66
|
-
transport: http(rpcUrl),
|
|
67
|
-
});
|
|
68
|
-
const chain = {
|
|
69
|
-
id: chainId,
|
|
70
|
-
name: chainId === 4663 ? "Robinhood Chain" : "Robinhood Chain Testnet",
|
|
71
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
72
|
-
rpcUrls: { default: { http: [rpcUrl] } },
|
|
73
|
-
} as const;
|
|
74
|
-
|
|
75
|
-
const session = createSessionTokenProvider(null);
|
|
76
|
-
const aureon = createAureonClient({
|
|
77
|
-
network: resolved.network,
|
|
78
|
-
baseUrl,
|
|
79
|
-
apiKey,
|
|
80
|
-
getAccessToken: session.getAccessToken,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const ping = await aureon.ping();
|
|
84
|
-
log("ping", ping);
|
|
85
|
-
|
|
86
|
-
const { message } = await aureon.getAuthNonce(account.address);
|
|
87
|
-
const signature = await walletClient.signMessage({ account, message });
|
|
88
|
-
const login = await aureon.verifyWallet({
|
|
89
|
-
address: account.address,
|
|
90
|
-
message,
|
|
91
|
-
signature,
|
|
92
|
-
});
|
|
93
|
-
session.setToken(login.token);
|
|
94
|
-
log("auth", { wallet: login.walletAddress });
|
|
95
|
-
|
|
96
|
-
const synced = await aureon.syncPortfolio();
|
|
97
|
-
log("syncPortfolio", {
|
|
98
|
-
chainId: synced.chainId,
|
|
99
|
-
positions: synced.portfolio.positions.length,
|
|
100
|
-
totalNotionalUsd: synced.portfolio.totalNotionalUsd,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const vaultBefore = await aureon.getVault();
|
|
104
|
-
const statusBefore = await aureon.getVaultStatus();
|
|
105
|
-
const wethBefore =
|
|
106
|
-
vaultBefore.balances.find((b) => b.symbol.toUpperCase() === "WETH")
|
|
107
|
-
?.quantity ?? 0;
|
|
108
|
-
log("vault before", {
|
|
109
|
-
address: vaultBefore.address,
|
|
110
|
-
empty: statusBefore.empty,
|
|
111
|
-
weth: wethBefore,
|
|
112
|
-
canRestore: statusBefore.canRestore,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const depositAmount = "0.0001";
|
|
116
|
-
const ethBal = await publicClient.getBalance({ address: account.address });
|
|
117
|
-
if (ethBal < 200000000000000n) {
|
|
118
|
-
throw new Error(
|
|
119
|
-
`Wallet ${account.address} needs ≥0.0002 ETH for deposit+gas (have ${ethBal})`
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const deposit = await aureon.prepareVaultDeposit({
|
|
124
|
-
symbol: "ETH",
|
|
125
|
-
amount: depositAmount,
|
|
126
|
-
});
|
|
127
|
-
log("prepareVaultDeposit", {
|
|
128
|
-
steps: deposit.steps.map((s) => s.functionName),
|
|
129
|
-
amountHuman: deposit.amountHuman,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
for (const step of deposit.steps) {
|
|
133
|
-
const hash = await walletClient.sendTransaction({
|
|
134
|
-
account,
|
|
135
|
-
chain,
|
|
136
|
-
to: step.to as `0x${string}`,
|
|
137
|
-
data: step.data as Hex,
|
|
138
|
-
value: BigInt(step.value),
|
|
139
|
-
});
|
|
140
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
141
|
-
log(`deposit tx ${step.functionName}`, { hash });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const vaultAfterDeposit = await aureon.getVault();
|
|
145
|
-
const wethAfterDeposit =
|
|
146
|
-
vaultAfterDeposit.balances.find((b) => b.symbol.toUpperCase() === "WETH")
|
|
147
|
-
?.quantity ?? 0;
|
|
148
|
-
log("vault after deposit", { weth: wethAfterDeposit });
|
|
149
|
-
if (!(wethAfterDeposit > wethBefore)) {
|
|
150
|
-
throw new Error("expected vault WETH to increase after depositETH");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const withdraw = await aureon.prepareVaultWithdraw({ amount: "0.00005" });
|
|
154
|
-
for (const step of withdraw.steps) {
|
|
155
|
-
const hash = await walletClient.sendTransaction({
|
|
156
|
-
account,
|
|
157
|
-
chain,
|
|
158
|
-
to: step.to as `0x${string}`,
|
|
159
|
-
data: step.data as Hex,
|
|
160
|
-
value: BigInt(step.value),
|
|
161
|
-
});
|
|
162
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
163
|
-
log(`withdraw tx ${step.functionName}`, { hash });
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const vaultAfterWithdraw = await aureon.getVault();
|
|
167
|
-
const wethAfterWithdraw =
|
|
168
|
-
vaultAfterWithdraw.balances.find((b) => b.symbol.toUpperCase() === "WETH")
|
|
169
|
-
?.quantity ?? 0;
|
|
170
|
-
log("vault after withdraw", { weth: wethAfterWithdraw });
|
|
171
|
-
|
|
172
|
-
await aureon.syncPortfolio();
|
|
173
|
-
|
|
174
|
-
const objective = await aureon.createObjective({
|
|
175
|
-
name: `SDK E2E Auto ${Date.now()}`,
|
|
176
|
-
kind: "balanced_portfolio",
|
|
177
|
-
targetWeight: 0.2,
|
|
178
|
-
tolerance: 0.05,
|
|
179
|
-
targetSymbol: "WETH",
|
|
180
|
-
priority: "high",
|
|
181
|
-
});
|
|
182
|
-
log("createObjective", {
|
|
183
|
-
id: objective.id,
|
|
184
|
-
automationMode: objective.automationMode,
|
|
185
|
-
});
|
|
186
|
-
if (objective.automationMode !== "auto") {
|
|
187
|
-
throw new Error(`expected automationMode auto, got ${objective.automationMode}`);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const health = await aureon.getHealth(objective.id);
|
|
191
|
-
log("health", health[0] ? { state: health[0].state, message: health[0].message } : null);
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
const plan = await aureon.getRestorePlan(objective.id);
|
|
195
|
-
log("getRestorePlan", {
|
|
196
|
-
kind: plan.kind,
|
|
197
|
-
amountHuman: plan.amountHuman,
|
|
198
|
-
message: plan.message,
|
|
199
|
-
});
|
|
200
|
-
} catch (err) {
|
|
201
|
-
if (isAureonError(err)) {
|
|
202
|
-
log("getRestorePlan (ok if already in band)", {
|
|
203
|
-
code: err.code,
|
|
204
|
-
message: err.message,
|
|
205
|
-
});
|
|
206
|
-
} else {
|
|
207
|
-
throw err;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
console.log("\nE2E OK — vault deposit/withdraw + Automatic objective");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
main().catch((error) => {
|
|
215
|
-
if (isAureonError(error)) {
|
|
216
|
-
console.error(`${error.code}: ${error.message}`);
|
|
217
|
-
} else {
|
|
218
|
-
console.error(error instanceof Error ? error.message : error);
|
|
219
|
-
}
|
|
220
|
-
process.exitCode = 1;
|
|
221
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Live vault deposit/withdraw + Automatic objective against the AUREON API.
|
|
3
|
+
*
|
|
4
|
+
* Env (integrators only — no local repo files):
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; mainnet = chain 4663
|
|
7
|
+
* AUREON_API_URL optional override
|
|
8
|
+
* AUREON_WALLET_PRIVATE_KEY 0x… key used to sign auth + broadcast vault txs (required)
|
|
9
|
+
* AUREON_RPC_URL optional (defaults from resolved chain)
|
|
10
|
+
* AUREON_CHAIN_ID optional (defaults from resolved network)
|
|
11
|
+
*
|
|
12
|
+
* pnpm --filter @buildaureon/sdk example:e2e
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
createPublicClient,
|
|
17
|
+
createWalletClient,
|
|
18
|
+
http,
|
|
19
|
+
type Hex,
|
|
20
|
+
} from "viem";
|
|
21
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
22
|
+
import {
|
|
23
|
+
createAureonClient,
|
|
24
|
+
createSessionTokenProvider,
|
|
25
|
+
resolveAureonNetworkFromEnv,
|
|
26
|
+
isAureonError,
|
|
27
|
+
} from "../../src/index.js";
|
|
28
|
+
|
|
29
|
+
function requireEnv(name: string): string {
|
|
30
|
+
const value = process.env[name]?.trim();
|
|
31
|
+
if (!value) throw new Error(`Set ${name}`);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function loadPrivateKey(): Hex {
|
|
36
|
+
const key = requireEnv("AUREON_WALLET_PRIVATE_KEY");
|
|
37
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
38
|
+
throw new Error("AUREON_WALLET_PRIVATE_KEY must be a 0x-prefixed 32-byte hex key");
|
|
39
|
+
}
|
|
40
|
+
return key as Hex;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function log(step: string, data?: unknown): void {
|
|
44
|
+
if (data === undefined) {
|
|
45
|
+
console.log(`✓ ${step}`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
console.log(`✓ ${step}`, data);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function main(): Promise<void> {
|
|
52
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
53
|
+
const baseUrl = resolved.baseUrl;
|
|
54
|
+
const apiKey = requireEnv("AUREON_API_KEY");
|
|
55
|
+
const chainId = Number(process.env.AUREON_CHAIN_ID ?? resolved.chainId);
|
|
56
|
+
const rpcUrl =
|
|
57
|
+
process.env.AUREON_RPC_URL?.trim() ||
|
|
58
|
+
(chainId === 4663
|
|
59
|
+
? "https://rpc.mainnet.chain.robinhood.com"
|
|
60
|
+
: "https://rpc.testnet.chain.robinhood.com");
|
|
61
|
+
|
|
62
|
+
const account = privateKeyToAccount(loadPrivateKey());
|
|
63
|
+
const publicClient = createPublicClient({ transport: http(rpcUrl) });
|
|
64
|
+
const walletClient = createWalletClient({
|
|
65
|
+
account,
|
|
66
|
+
transport: http(rpcUrl),
|
|
67
|
+
});
|
|
68
|
+
const chain = {
|
|
69
|
+
id: chainId,
|
|
70
|
+
name: chainId === 4663 ? "Robinhood Chain" : "Robinhood Chain Testnet",
|
|
71
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
72
|
+
rpcUrls: { default: { http: [rpcUrl] } },
|
|
73
|
+
} as const;
|
|
74
|
+
|
|
75
|
+
const session = createSessionTokenProvider(null);
|
|
76
|
+
const aureon = createAureonClient({
|
|
77
|
+
network: resolved.network,
|
|
78
|
+
baseUrl,
|
|
79
|
+
apiKey,
|
|
80
|
+
getAccessToken: session.getAccessToken,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const ping = await aureon.ping();
|
|
84
|
+
log("ping", ping);
|
|
85
|
+
|
|
86
|
+
const { message } = await aureon.getAuthNonce(account.address);
|
|
87
|
+
const signature = await walletClient.signMessage({ account, message });
|
|
88
|
+
const login = await aureon.verifyWallet({
|
|
89
|
+
address: account.address,
|
|
90
|
+
message,
|
|
91
|
+
signature,
|
|
92
|
+
});
|
|
93
|
+
session.setToken(login.token);
|
|
94
|
+
log("auth", { wallet: login.walletAddress });
|
|
95
|
+
|
|
96
|
+
const synced = await aureon.syncPortfolio();
|
|
97
|
+
log("syncPortfolio", {
|
|
98
|
+
chainId: synced.chainId,
|
|
99
|
+
positions: synced.portfolio.positions.length,
|
|
100
|
+
totalNotionalUsd: synced.portfolio.totalNotionalUsd,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const vaultBefore = await aureon.getVault();
|
|
104
|
+
const statusBefore = await aureon.getVaultStatus();
|
|
105
|
+
const wethBefore =
|
|
106
|
+
vaultBefore.balances.find((b) => b.symbol.toUpperCase() === "WETH")
|
|
107
|
+
?.quantity ?? 0;
|
|
108
|
+
log("vault before", {
|
|
109
|
+
address: vaultBefore.address,
|
|
110
|
+
empty: statusBefore.empty,
|
|
111
|
+
weth: wethBefore,
|
|
112
|
+
canRestore: statusBefore.canRestore,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const depositAmount = "0.0001";
|
|
116
|
+
const ethBal = await publicClient.getBalance({ address: account.address });
|
|
117
|
+
if (ethBal < 200000000000000n) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Wallet ${account.address} needs ≥0.0002 ETH for deposit+gas (have ${ethBal})`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const deposit = await aureon.prepareVaultDeposit({
|
|
124
|
+
symbol: "ETH",
|
|
125
|
+
amount: depositAmount,
|
|
126
|
+
});
|
|
127
|
+
log("prepareVaultDeposit", {
|
|
128
|
+
steps: deposit.steps.map((s) => s.functionName),
|
|
129
|
+
amountHuman: deposit.amountHuman,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
for (const step of deposit.steps) {
|
|
133
|
+
const hash = await walletClient.sendTransaction({
|
|
134
|
+
account,
|
|
135
|
+
chain,
|
|
136
|
+
to: step.to as `0x${string}`,
|
|
137
|
+
data: step.data as Hex,
|
|
138
|
+
value: BigInt(step.value),
|
|
139
|
+
});
|
|
140
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
141
|
+
log(`deposit tx ${step.functionName}`, { hash });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const vaultAfterDeposit = await aureon.getVault();
|
|
145
|
+
const wethAfterDeposit =
|
|
146
|
+
vaultAfterDeposit.balances.find((b) => b.symbol.toUpperCase() === "WETH")
|
|
147
|
+
?.quantity ?? 0;
|
|
148
|
+
log("vault after deposit", { weth: wethAfterDeposit });
|
|
149
|
+
if (!(wethAfterDeposit > wethBefore)) {
|
|
150
|
+
throw new Error("expected vault WETH to increase after depositETH");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const withdraw = await aureon.prepareVaultWithdraw({ amount: "0.00005" });
|
|
154
|
+
for (const step of withdraw.steps) {
|
|
155
|
+
const hash = await walletClient.sendTransaction({
|
|
156
|
+
account,
|
|
157
|
+
chain,
|
|
158
|
+
to: step.to as `0x${string}`,
|
|
159
|
+
data: step.data as Hex,
|
|
160
|
+
value: BigInt(step.value),
|
|
161
|
+
});
|
|
162
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
163
|
+
log(`withdraw tx ${step.functionName}`, { hash });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const vaultAfterWithdraw = await aureon.getVault();
|
|
167
|
+
const wethAfterWithdraw =
|
|
168
|
+
vaultAfterWithdraw.balances.find((b) => b.symbol.toUpperCase() === "WETH")
|
|
169
|
+
?.quantity ?? 0;
|
|
170
|
+
log("vault after withdraw", { weth: wethAfterWithdraw });
|
|
171
|
+
|
|
172
|
+
await aureon.syncPortfolio();
|
|
173
|
+
|
|
174
|
+
const objective = await aureon.createObjective({
|
|
175
|
+
name: `SDK E2E Auto ${Date.now()}`,
|
|
176
|
+
kind: "balanced_portfolio",
|
|
177
|
+
targetWeight: 0.2,
|
|
178
|
+
tolerance: 0.05,
|
|
179
|
+
targetSymbol: "WETH",
|
|
180
|
+
priority: "high",
|
|
181
|
+
});
|
|
182
|
+
log("createObjective", {
|
|
183
|
+
id: objective.id,
|
|
184
|
+
automationMode: objective.automationMode,
|
|
185
|
+
});
|
|
186
|
+
if (objective.automationMode !== "auto") {
|
|
187
|
+
throw new Error(`expected automationMode auto, got ${objective.automationMode}`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const health = await aureon.getHealth(objective.id);
|
|
191
|
+
log("health", health[0] ? { state: health[0].state, message: health[0].message } : null);
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
const plan = await aureon.getRestorePlan(objective.id);
|
|
195
|
+
log("getRestorePlan", {
|
|
196
|
+
kind: plan.kind,
|
|
197
|
+
amountHuman: plan.amountHuman,
|
|
198
|
+
message: plan.message,
|
|
199
|
+
});
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (isAureonError(err)) {
|
|
202
|
+
log("getRestorePlan (ok if already in band)", {
|
|
203
|
+
code: err.code,
|
|
204
|
+
message: err.message,
|
|
205
|
+
});
|
|
206
|
+
} else {
|
|
207
|
+
throw err;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
console.log("\nE2E OK — vault deposit/withdraw + Automatic objective");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
main().catch((error) => {
|
|
215
|
+
if (isAureonError(error)) {
|
|
216
|
+
console.error(`${error.code}: ${error.message}`);
|
|
217
|
+
} else {
|
|
218
|
+
console.error(error instanceof Error ? error.message : error);
|
|
219
|
+
}
|
|
220
|
+
process.exitCode = 1;
|
|
221
|
+
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Env:
|
|
5
5
|
* AUREON_API_KEY issued developer key (required)
|
|
6
|
-
* AUREON_NETWORK optional; omit for
|
|
6
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; set mainnet for chain 4663
|
|
7
7
|
* AUREON_API_URL optional override (must match network if both set)
|
|
8
8
|
*
|
|
9
9
|
* pnpm example:full-aureon-loop
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Env:
|
|
8
8
|
* AUREON_API_KEY issued developer key (required)
|
|
9
|
-
* AUREON_NETWORK optional; omit for
|
|
9
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; set mainnet for chain 4663
|
|
10
10
|
* AUREON_API_URL optional override (must match network if both set)
|
|
11
11
|
*
|
|
12
12
|
* pnpm example:green-vs-plan
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Env:
|
|
5
5
|
* AUREON_API_KEY issued developer key (required)
|
|
6
|
-
* AUREON_NETWORK optional; omit for
|
|
6
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; set mainnet for chain 4663
|
|
7
7
|
* AUREON_API_URL optional override (must match network if both set)
|
|
8
8
|
*
|
|
9
9
|
* pnpm --filter @buildaureon/sdk example:market
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Env:
|
|
5
5
|
* AUREON_API_KEY issued developer key (required)
|
|
6
|
-
* AUREON_NETWORK optional; omit for
|
|
6
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; set mainnet for chain 4663
|
|
7
7
|
* AUREON_API_URL optional override (must match network if both set)
|
|
8
8
|
*
|
|
9
9
|
* pnpm example:portfolio-watch
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Quickstart — control-plane calls with an issued developer API key.
|
|
3
|
-
*
|
|
4
|
-
* Env (required for integrators — nothing else):
|
|
5
|
-
* AUREON_API_KEY issued key from Developers
|
|
6
|
-
* AUREON_NETWORK optional; omit for
|
|
7
|
-
* AUREON_API_URL optional override (must match network if both set)
|
|
8
|
-
*
|
|
9
|
-
* pnpm --filter @buildaureon/sdk example:quickstart
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
createAureonClient,
|
|
14
|
-
formatWeight,
|
|
15
|
-
isAureonError,
|
|
16
|
-
resolveAureonNetworkFromEnv,
|
|
17
|
-
} from "../../src/index.js";
|
|
18
|
-
|
|
19
|
-
async function main(): Promise<void> {
|
|
20
|
-
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
21
|
-
if (!apiKey) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
"Set AUREON_API_KEY to an issued developer key from the AUREON Developers page."
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const resolved = resolveAureonNetworkFromEnv();
|
|
28
|
-
const aureon = createAureonClient({
|
|
29
|
-
network: resolved.network,
|
|
30
|
-
baseUrl: resolved.baseUrl,
|
|
31
|
-
apiKey,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const ping = await aureon.ping();
|
|
35
|
-
console.log("connected", ping);
|
|
36
|
-
|
|
37
|
-
const me = await aureon.me();
|
|
38
|
-
console.log("wallet", me.walletAddress);
|
|
39
|
-
|
|
40
|
-
const synced = await aureon.syncPortfolio();
|
|
41
|
-
console.log("synced", {
|
|
42
|
-
chainId: synced.chainId,
|
|
43
|
-
positions: synced.portfolio.positions.length,
|
|
44
|
-
stableWeight: formatWeight(synced.portfolio.stableWeight),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const vault = await aureon.getVaultStatus();
|
|
48
|
-
console.log("vault", {
|
|
49
|
-
empty: vault.empty,
|
|
50
|
-
canRestore: vault.canRestore,
|
|
51
|
-
totalNotionalUsd: vault.totalNotionalUsd,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const objectives = await aureon.listObjectives();
|
|
55
|
-
console.log(
|
|
56
|
-
"objectives",
|
|
57
|
-
objectives.map((o) => ({
|
|
58
|
-
name: o.name,
|
|
59
|
-
automationMode: o.automationMode,
|
|
60
|
-
}))
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
console.log(
|
|
64
|
-
"hint: empty vault restore is 409. prepare-deposit is unsigned — the user broadcasts when they fund. Agents do not."
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
main().catch((error) => {
|
|
69
|
-
if (isAureonError(error)) {
|
|
70
|
-
console.error(`${error.code}: ${error.message}`);
|
|
71
|
-
} else {
|
|
72
|
-
console.error(error instanceof Error ? error.message : error);
|
|
73
|
-
}
|
|
74
|
-
process.exitCode = 1;
|
|
75
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Quickstart — control-plane calls with an issued developer API key.
|
|
3
|
+
*
|
|
4
|
+
* Env (required for integrators — nothing else):
|
|
5
|
+
* AUREON_API_KEY issued key from Developers
|
|
6
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; set mainnet for chain 4663
|
|
7
|
+
* AUREON_API_URL optional override (must match network if both set)
|
|
8
|
+
*
|
|
9
|
+
* pnpm --filter @buildaureon/sdk example:quickstart
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createAureonClient,
|
|
14
|
+
formatWeight,
|
|
15
|
+
isAureonError,
|
|
16
|
+
resolveAureonNetworkFromEnv,
|
|
17
|
+
} from "../../src/index.js";
|
|
18
|
+
|
|
19
|
+
async function main(): Promise<void> {
|
|
20
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
21
|
+
if (!apiKey) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"Set AUREON_API_KEY to an issued developer key from the AUREON Developers page."
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
28
|
+
const aureon = createAureonClient({
|
|
29
|
+
network: resolved.network,
|
|
30
|
+
baseUrl: resolved.baseUrl,
|
|
31
|
+
apiKey,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const ping = await aureon.ping();
|
|
35
|
+
console.log("connected", ping);
|
|
36
|
+
|
|
37
|
+
const me = await aureon.me();
|
|
38
|
+
console.log("wallet", me.walletAddress);
|
|
39
|
+
|
|
40
|
+
const synced = await aureon.syncPortfolio();
|
|
41
|
+
console.log("synced", {
|
|
42
|
+
chainId: synced.chainId,
|
|
43
|
+
positions: synced.portfolio.positions.length,
|
|
44
|
+
stableWeight: formatWeight(synced.portfolio.stableWeight),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const vault = await aureon.getVaultStatus();
|
|
48
|
+
console.log("vault", {
|
|
49
|
+
empty: vault.empty,
|
|
50
|
+
canRestore: vault.canRestore,
|
|
51
|
+
totalNotionalUsd: vault.totalNotionalUsd,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const objectives = await aureon.listObjectives();
|
|
55
|
+
console.log(
|
|
56
|
+
"objectives",
|
|
57
|
+
objectives.map((o) => ({
|
|
58
|
+
name: o.name,
|
|
59
|
+
automationMode: o.automationMode,
|
|
60
|
+
}))
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
"hint: empty vault restore is 409. prepare-deposit is unsigned — the user broadcasts when they fund. Agents do not."
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main().catch((error) => {
|
|
69
|
+
if (isAureonError(error)) {
|
|
70
|
+
console.error(`${error.code}: ${error.message}`);
|
|
71
|
+
} else {
|
|
72
|
+
console.error(error instanceof Error ? error.message : error);
|
|
73
|
+
}
|
|
74
|
+
process.exitCode = 1;
|
|
75
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Env:
|
|
7
7
|
* AUREON_API_KEY issued developer key (required)
|
|
8
|
-
* AUREON_NETWORK optional; omit for
|
|
8
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; set mainnet for chain 4663
|
|
9
9
|
* AUREON_API_URL optional override (must match network if both set)
|
|
10
10
|
*
|
|
11
11
|
* pnpm example:receipt-verification
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Env:
|
|
5
5
|
* AUREON_API_KEY issued developer key (required)
|
|
6
|
-
* AUREON_NETWORK optional; omit for
|
|
6
|
+
* AUREON_NETWORK optional; omit for official API / testnet 46630; set mainnet for chain 4663
|
|
7
7
|
* AUREON_API_URL optional override (must match network if both set)
|
|
8
8
|
*
|
|
9
9
|
* pnpm --filter @buildaureon/sdk example:sdk-demo-terminal
|
|
@@ -75,7 +75,7 @@ async function main(): Promise<void> {
|
|
|
75
75
|
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
const resolved = resolveAureonNetworkFromEnv();
|
|
78
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
79
79
|
const baseUrl = resolved.baseUrl;
|
|
80
80
|
line(
|
|
81
81
|
"meta",
|