@belugafinancial/advisor-cli 0.5.0 → 0.5.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 +159 -0
- package/dist/commands/accept.d.ts +5 -2
- package/dist/commands/accept.js +5 -1
- package/dist/commands/accept.js.map +1 -1
- package/dist/commands/init.js +20 -18
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/watch.d.ts +13 -0
- package/dist/commands/watch.js +36 -9
- package/dist/commands/watch.js.map +1 -1
- package/dist/fee.d.ts +24 -0
- package/dist/fee.js +37 -0
- package/dist/fee.js.map +1 -0
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/skill/SKILL.md +39 -20
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# @belugafinancial/advisor-cli
|
|
2
|
+
|
|
3
|
+
`beluga-advisor` operates the advisor side of a [Beluga](https://beluga.financial)
|
|
4
|
+
advisory account from the command line.
|
|
5
|
+
|
|
6
|
+
On Beluga, an **advisor** key proposes swaps on a **client's** vault on Solana.
|
|
7
|
+
The client approves each one, or chooses automatic trading for that advisor.
|
|
8
|
+
The advisor can trade the vault and can never withdraw from it; only the client
|
|
9
|
+
can. This CLI holds the advisor key: it accepts invitations, submits encrypted
|
|
10
|
+
swap proposals, executes approved ones, and can run a watcher that does the
|
|
11
|
+
routine parts on its own.
|
|
12
|
+
|
|
13
|
+
It also ships the `beluga-advisor` skill for [OpenClaw](https://docs.openclaw.ai),
|
|
14
|
+
so an AI agent can be the advisor on your own vault. The full walkthrough is
|
|
15
|
+
the [OpenClaw guide](https://docs.beluga.financial/guides/openclaw-integration/).
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
Node 20 or newer.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g @belugafinancial/advisor-cli
|
|
23
|
+
beluga-advisor --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Set up an advisor
|
|
27
|
+
|
|
28
|
+
### 1. Create the advisor key
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
beluga-advisor init
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`init` generates a new Solana keypair for the advisor, writes its settings to
|
|
35
|
+
`~/.openclaw/openclaw.json` (merging into a file that already exists), installs
|
|
36
|
+
the OpenClaw skill, and prints the advisor's public key and an invite link.
|
|
37
|
+
On a terminal it asks a few questions; `--yes` takes the defaults.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
beluga-advisor init --yes \
|
|
41
|
+
--rpc-url https://your-rpc-url \
|
|
42
|
+
--fee-bps 75 \
|
|
43
|
+
--auto-execute false
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Other flags: `--keypair-base64 <secret>` or `--keypair-file <path>` to use a
|
|
47
|
+
keypair you already have, `--auto-accept true|false` (whether the watcher
|
|
48
|
+
accepts client invitations by itself, default true), `--config-path <path>`,
|
|
49
|
+
`--no-install-skill`.
|
|
50
|
+
|
|
51
|
+
`--fee-bps` is the fee the advisor takes on each executed swap, in basis
|
|
52
|
+
points. It is a whole number from 0 to 100 (1%), which is the on-chain
|
|
53
|
+
program's maximum; the default is 50.
|
|
54
|
+
|
|
55
|
+
The config file holds the advisor's secret key. Treat it like a wallet file.
|
|
56
|
+
|
|
57
|
+
### 2. Fund the printed key
|
|
58
|
+
|
|
59
|
+
Send a little SOL to the advisor public key that `init` printed. It pays the
|
|
60
|
+
transaction fees for everything the advisor signs, and it cannot accept an
|
|
61
|
+
invitation or execute a proposal until it holds some. About 0.05 SOL is
|
|
62
|
+
plenty for low-volume use.
|
|
63
|
+
|
|
64
|
+
### 3. Open the invite link
|
|
65
|
+
|
|
66
|
+
`init` prints a link of the form
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
https://app.beluga.financial/invite?advisor=<advisor public key>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Open it and sign in to Beluga with the wallet that will own the vault. The
|
|
73
|
+
Add an Advisor form opens with the advisor's address filled in and asks how
|
|
74
|
+
the advisor's trades are approved. "Approve each trade" is selected to start
|
|
75
|
+
with.
|
|
76
|
+
|
|
77
|
+
- **Approve each trade**: the advisor proposes a swap, and nothing moves
|
|
78
|
+
until you approve it in the Beluga app.
|
|
79
|
+
- **Trade automatically**: the advisor's swaps run without asking you. The
|
|
80
|
+
key can never withdraw. Nothing today caps how much of the vault one swap
|
|
81
|
+
uses, how often it trades, or which tokens it buys. Every swap pays the
|
|
82
|
+
key's fee, set when it accepts, 1% at most. The limits that exist are your
|
|
83
|
+
trade conditions (a minimum pool depth, a maximum price impact, a maximum
|
|
84
|
+
share of a pool), which are off until you set them.
|
|
85
|
+
|
|
86
|
+
Check that the address is the key `init` printed, make your choice, and
|
|
87
|
+
confirm: that creates the vault and gives the advisor key authority to trade
|
|
88
|
+
it.
|
|
89
|
+
|
|
90
|
+
You can change the choice later from the advisor's menu on the Advisors
|
|
91
|
+
page, where it is shown as "Auto-accept: On/Off". After the account is
|
|
92
|
+
created, the page walks you through email alerts, trade conditions (if you
|
|
93
|
+
chose automatic trading) and funding the vault, and shows the account as
|
|
94
|
+
waiting until the advisor key accepts.
|
|
95
|
+
|
|
96
|
+
### 4. Start the watcher
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
beluga-advisor watch start
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
It runs in the foreground until stopped. Every 30 seconds it accepts pending
|
|
103
|
+
invitations at the configured fee (unless `BELUGA_AUTO_ACCEPT` is false) and
|
|
104
|
+
executes proposals that have been approved. It does not propose trades; that
|
|
105
|
+
is the advisor's own decision. From another terminal,
|
|
106
|
+
`beluga-advisor watch status` reports on it and `beluga-advisor watch stop`
|
|
107
|
+
stops it.
|
|
108
|
+
|
|
109
|
+
Under OpenClaw, restart OpenClaw after `init` and the agent runs these
|
|
110
|
+
commands for you with the settings from its config. From your own shell, the
|
|
111
|
+
commands below read the same settings from environment variables, which you
|
|
112
|
+
set yourself: `init` wrote the values to the `skills.entries["beluga-advisor"].env`
|
|
113
|
+
block of the config file.
|
|
114
|
+
|
|
115
|
+
## Commands
|
|
116
|
+
|
|
117
|
+
| Command | What it does |
|
|
118
|
+
|---|---|
|
|
119
|
+
| `init` | Create or import the advisor key, write the config, install the skill |
|
|
120
|
+
| `pubkey` | Print the advisor's public key |
|
|
121
|
+
| `status` | Advisory accounts this key advises, with status and fee |
|
|
122
|
+
| `portfolio` | Each account's holdings, plus what is waiting on the advisor: pending invitations and approved proposals |
|
|
123
|
+
| `accept [<advisory-account>] [--fee-bps <n>]` | Accept one pending invitation, or all of them |
|
|
124
|
+
| `propose <advisory-account> [--payload <file\|->] [--payload-json <json>] [--auto-execute true\|false]` | Submit an encrypted swap proposal |
|
|
125
|
+
| `execute [<proposal>] [--account <advisory-account>]` | Execute approved proposals |
|
|
126
|
+
| `watch start` / `watch stop` / `watch status` | The background watcher |
|
|
127
|
+
| `install-skill [--destination <dir>]` | Copy the bundled OpenClaw skill into place |
|
|
128
|
+
| `upgrade [--skip-npm]` | Update the CLI from npm and reinstall the skill |
|
|
129
|
+
|
|
130
|
+
Commands print their result as JSON on stdout and log progress to stderr.
|
|
131
|
+
|
|
132
|
+
## Environment
|
|
133
|
+
|
|
134
|
+
All of these except the key have defaults. `init` sets them in the OpenClaw
|
|
135
|
+
config.
|
|
136
|
+
|
|
137
|
+
| Variable | Meaning |
|
|
138
|
+
|---|---|
|
|
139
|
+
| `BELUGA_ADVISOR_KEYPAIR` | Base64 of the advisor's 64-byte secret key. Required by every command except `init`, `install-skill` and `upgrade` |
|
|
140
|
+
| `SOLANA_RPC_URL` | RPC endpoint. Defaults to public mainnet; use your own for the watcher |
|
|
141
|
+
| `BELUGA_PROGRAM_ID` | Beluga program id. Defaults to mainnet |
|
|
142
|
+
| `BELUGA_ACCEPT_FEE_BPS` | Fee charged when accepting, 0 to 100. Default 50 |
|
|
143
|
+
| `BELUGA_AUTO_ACCEPT` | Watcher accepts client invitations by itself. Default true |
|
|
144
|
+
| `BELUGA_AUTO_EXECUTE` | Watcher executes approved proposals. Default true |
|
|
145
|
+
| `BELUGA_AUTO_CLOSE` | Watcher closes settled proposals to reclaim their rent. Default false |
|
|
146
|
+
| `BELUGA_CLOSE_RETENTION_MS` | How long a settled proposal stays readable before the watcher closes it. Default 24 hours |
|
|
147
|
+
| `BELUGA_WATCH_INTERVAL_MS` | Watcher poll interval. Default 30000 |
|
|
148
|
+
|
|
149
|
+
## Two settings with similar names
|
|
150
|
+
|
|
151
|
+
- `--auto-accept` / `BELUGA_AUTO_ACCEPT` is the advisor's setting. It
|
|
152
|
+
decides whether the watcher accepts client invitations by itself.
|
|
153
|
+
- Automatic trading (shown as Auto-accept on the Advisors page) is the vault
|
|
154
|
+
owner's setting, chosen on the invite page: approve each trade, or trade
|
|
155
|
+
automatically. Only the owner can set it. This CLI cannot.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { BelugaAdvisor } from "@belugafinancial/advisor-sdk";
|
|
2
|
-
export declare function acceptCommand(advisor: BelugaAdvisor, args: {
|
|
2
|
+
export declare function acceptCommand(advisor: Pick<BelugaAdvisor, "listAdvisoryAccounts" | "accept">, args: {
|
|
3
3
|
address?: string;
|
|
4
|
-
|
|
4
|
+
/** As given: the `--fee-bps` text, or the configured default. */
|
|
5
|
+
feeBps: string | number;
|
|
6
|
+
/** Where `feeBps` came from, for the refusal. */
|
|
7
|
+
feeSource?: string;
|
|
5
8
|
}): Promise<void>;
|
package/dist/commands/accept.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { parseFeeBps } from "../fee.js";
|
|
1
2
|
export async function acceptCommand(advisor, args) {
|
|
3
|
+
// Before anything is read or sent: a fee the program would refuse is a
|
|
4
|
+
// mistake in the command, not something to discover per account.
|
|
5
|
+
const feeBps = parseFeeBps(args.feeBps, args.feeSource ?? "fee");
|
|
2
6
|
// If no address given, accept all pending advisory accounts.
|
|
3
7
|
const accounts = await advisor.listAdvisoryAccounts();
|
|
4
8
|
const targets = args.address
|
|
@@ -14,7 +18,7 @@ export async function acceptCommand(advisor, args) {
|
|
|
14
18
|
process.stderr.write(`[accept] skipping ${account.address}: status is ${account.status}\n`);
|
|
15
19
|
continue;
|
|
16
20
|
}
|
|
17
|
-
const signature = await advisor.accept(account.address,
|
|
21
|
+
const signature = await advisor.accept(account.address, feeBps);
|
|
18
22
|
accepted.push({ address: account.address, signature });
|
|
19
23
|
process.stderr.write(`[accept] ${account.address} → ${signature}\n`);
|
|
20
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../src/commands/accept.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../src/commands/accept.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAA+D,EAC/D,IAMC;IAED,uEAAuE;IACvE,iEAAiE;IACjE,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC;IAEjE,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC;IACtD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO;QAC1B,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC;QACpD,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;IAEnD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9D,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAA6C,EAAE,CAAC;IAC9D,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,qBAAqB,OAAO,CAAC,OAAO,eAAe,OAAO,CAAC,MAAM,IAAI,CACtE,CAAC;YACF,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,CAAC,OAAO,MAAM,SAAS,IAAI,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/commands/init.js
CHANGED
|
@@ -6,6 +6,7 @@ import { stdin, stdout } from "node:process";
|
|
|
6
6
|
import { Keypair } from "@solana/web3.js";
|
|
7
7
|
import { BELUGA_PROGRAM_ID_MAINNET, loadKeypairFromBase64, } from "@belugafinancial/advisor-sdk";
|
|
8
8
|
import { installSkillCommand } from "./install-skill.js";
|
|
9
|
+
import { MAX_ADVISOR_FEE_BPS, parseFeeBps } from "../fee.js";
|
|
9
10
|
const DEFAULT_CONFIG_PATH = join(homedir(), ".openclaw", "openclaw.json");
|
|
10
11
|
const DEFAULT_RPC = "https://api.mainnet-beta.solana.com";
|
|
11
12
|
const DEFAULT_FEE_BPS = 50;
|
|
@@ -43,18 +44,13 @@ async function promptString(rl, question, defaultValue) {
|
|
|
43
44
|
const answer = (await rl.question(`${question} [${defaultValue}]: `)).trim();
|
|
44
45
|
return answer || defaultValue;
|
|
45
46
|
}
|
|
46
|
-
async function promptInt(rl, question, defaultValue) {
|
|
47
|
-
const answer = (await rl.question(`${question} [${defaultValue}]: `)).trim();
|
|
48
|
-
if (!answer)
|
|
49
|
-
return defaultValue;
|
|
50
|
-
const n = parseInt(answer, 10);
|
|
51
|
-
if (!Number.isFinite(n)) {
|
|
52
|
-
throw new Error(`${question}: expected an integer, got ${answer}`);
|
|
53
|
-
}
|
|
54
|
-
return n;
|
|
55
|
-
}
|
|
56
47
|
async function resolveConfig(args) {
|
|
57
48
|
const interactive = !args.yes && stdin.isTTY;
|
|
49
|
+
// First, before a key is generated or a question asked: nothing below may
|
|
50
|
+
// write a fee the program would refuse at accept time.
|
|
51
|
+
const flagFeeBps = args.feeBps === undefined
|
|
52
|
+
? undefined
|
|
53
|
+
: parseFeeBps(args.feeBps, "--fee-bps");
|
|
58
54
|
const keypair = resolveKeypair(args);
|
|
59
55
|
const keypairBase64 = Buffer.from(keypair.secretKey).toString("base64");
|
|
60
56
|
if (!interactive) {
|
|
@@ -63,7 +59,7 @@ async function resolveConfig(args) {
|
|
|
63
59
|
pubkey: keypair.publicKey.toBase58(),
|
|
64
60
|
rpcUrl: args.rpcUrl ?? DEFAULT_RPC,
|
|
65
61
|
programId: args.programId ?? BELUGA_PROGRAM_ID_MAINNET,
|
|
66
|
-
feeBps:
|
|
62
|
+
feeBps: flagFeeBps ?? DEFAULT_FEE_BPS,
|
|
67
63
|
autoAccept: args.autoAccept ?? true,
|
|
68
64
|
autoExecute: args.autoExecute ?? true,
|
|
69
65
|
watchIntervalMs: args.watchIntervalMs ?? DEFAULT_WATCH_INTERVAL_MS,
|
|
@@ -74,10 +70,10 @@ async function resolveConfig(args) {
|
|
|
74
70
|
try {
|
|
75
71
|
process.stderr.write(`\nGenerated advisor pubkey: ${keypair.publicKey.toBase58()}\n\n`);
|
|
76
72
|
const rpcUrl = args.rpcUrl ?? (await promptString(rl, "Solana RPC URL", DEFAULT_RPC));
|
|
77
|
-
const feeBps =
|
|
78
|
-
(await
|
|
73
|
+
const feeBps = flagFeeBps ??
|
|
74
|
+
parseFeeBps(await promptString(rl, `Default advisor fee (bps, 0-${MAX_ADVISOR_FEE_BPS})`, String(DEFAULT_FEE_BPS)), "Default advisor fee");
|
|
79
75
|
const autoAccept = args.autoAccept ??
|
|
80
|
-
(await promptYesNo(rl, "
|
|
76
|
+
(await promptYesNo(rl, "Accept client invitations automatically in watch mode?", true));
|
|
81
77
|
const autoExecute = args.autoExecute ??
|
|
82
78
|
(await promptYesNo(rl, "Auto-execute approved proposals in watch mode?", true));
|
|
83
79
|
const configPath = args.configPath ?? DEFAULT_CONFIG_PATH;
|
|
@@ -167,10 +163,16 @@ export async function initCommand(args) {
|
|
|
167
163
|
` This is the agent's address — it pays gas on every transaction\n` +
|
|
168
164
|
` it signs (accepting your invitation, executing your approved\n` +
|
|
169
165
|
` proposals). ~${RECOMMENDED_FUNDING_SOL} SOL is plenty for low-volume use.\n` +
|
|
170
|
-
` 2. Open the invite URL in
|
|
171
|
-
`
|
|
172
|
-
` to
|
|
173
|
-
`
|
|
166
|
+
` 2. Open the invite URL and sign in to Beluga with the wallet that\n` +
|
|
167
|
+
` will own the vault. The form opens with this address filled in\n` +
|
|
168
|
+
` and asks you to choose whether to approve each trade or let the\n` +
|
|
169
|
+
` agent trade automatically (approving each trade is selected to\n` +
|
|
170
|
+
` start with). Confirming creates the vault and gives the agent\n` +
|
|
171
|
+
` authority to trade it, never to withdraw.\n` +
|
|
172
|
+
` 3. Restart your OpenClaw agent so it picks up the new skill config.\n` +
|
|
173
|
+
`\nThe --auto-accept setting is only about this agent accepting client\n` +
|
|
174
|
+
`invitations. How trades are approved is chosen by the vault's owner\n` +
|
|
175
|
+
`on the invite page.\n`);
|
|
174
176
|
process.stdout.write(JSON.stringify({
|
|
175
177
|
pubkey: resolved.pubkey,
|
|
176
178
|
inviteUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBA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,EAAE,QAAQ,CAAC,MAAM;QACvB,SAAS;QACT,cAAc,EAAE,QAAQ,CAAC,MAAM;QAC/B,qBAAqB,EAAE,uBAAuB;QAC9C,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,WAAW,KAAK,IAAI;QACpC,KAAK,EAAE,WAAW;KACnB,EACD,IAAI,EACJ,CAAC,CACF,GAAG,IAAI,CACT,CAAC;AACJ,CAAC"}
|
package/dist/commands/watch.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { BelugaAdvisor } from "@belugafinancial/advisor-sdk";
|
|
2
2
|
import type { CliEnv } from "../env.js";
|
|
3
|
+
/**
|
|
4
|
+
* Accept every pending invitation at the configured fee.
|
|
5
|
+
*
|
|
6
|
+
* A fee the program would refuse is caught here, once, in words: sending it
|
|
7
|
+
* anyway costs an RPC round trip per invitation per tick and reports an
|
|
8
|
+
* Anchor simulation error that names neither the setting nor the limit. The
|
|
9
|
+
* rest of the tick (executing, closing) is unaffected, so one bad setting
|
|
10
|
+
* does not stop approved proposals from running. Exported for tests.
|
|
11
|
+
*/
|
|
12
|
+
export declare function acceptPending(advisor: Pick<BelugaAdvisor, "accept">, accounts: {
|
|
13
|
+
address: string;
|
|
14
|
+
status: string;
|
|
15
|
+
}[], acceptFeeBps: number, log?: (line: string) => void): Promise<string[]>;
|
|
3
16
|
/**
|
|
4
17
|
* Return the rent of every settled proposal once it has been settled for the
|
|
5
18
|
* retention window (BEL-13). Not limited to active accounts: a revoked or
|
package/dist/commands/watch.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync, } from
|
|
|
2
2
|
import { homedir } from "os";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { autoCloseDue } from "@belugafinancial/advisor-sdk";
|
|
5
|
+
import { parseFeeBps } from "../fee.js";
|
|
5
6
|
const STATE_DIR = join(homedir(), ".beluga-advisor");
|
|
6
7
|
const PID_FILE = join(STATE_DIR, "watch.pid");
|
|
7
8
|
function ensureStateDir() {
|
|
@@ -25,15 +26,7 @@ function readPid() {
|
|
|
25
26
|
async function tick(advisor, env) {
|
|
26
27
|
const accounts = await advisor.listAdvisoryAccounts();
|
|
27
28
|
if (env.autoAccept) {
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const sig = await advisor.accept(account.address, env.acceptFeeBps);
|
|
31
|
-
process.stderr.write(`[watch] accepted ${account.address} (${sig})\n`);
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
process.stderr.write(`[watch] accept ${account.address} failed: ${err instanceof Error ? err.message : err}\n`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
29
|
+
await acceptPending(advisor, accounts, env.acceptFeeBps);
|
|
37
30
|
}
|
|
38
31
|
if (env.autoExecute) {
|
|
39
32
|
for (const account of accounts.filter((a) => a.status === "active")) {
|
|
@@ -53,6 +46,40 @@ async function tick(advisor, env) {
|
|
|
53
46
|
await closeSettled(advisor, accounts, env.closeRetentionMs);
|
|
54
47
|
}
|
|
55
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Accept every pending invitation at the configured fee.
|
|
51
|
+
*
|
|
52
|
+
* A fee the program would refuse is caught here, once, in words: sending it
|
|
53
|
+
* anyway costs an RPC round trip per invitation per tick and reports an
|
|
54
|
+
* Anchor simulation error that names neither the setting nor the limit. The
|
|
55
|
+
* rest of the tick (executing, closing) is unaffected, so one bad setting
|
|
56
|
+
* does not stop approved proposals from running. Exported for tests.
|
|
57
|
+
*/
|
|
58
|
+
export async function acceptPending(advisor, accounts, acceptFeeBps, log = (line) => process.stderr.write(line)) {
|
|
59
|
+
const pending = accounts.filter((a) => a.status === "pending");
|
|
60
|
+
if (pending.length === 0)
|
|
61
|
+
return [];
|
|
62
|
+
let feeBps;
|
|
63
|
+
try {
|
|
64
|
+
feeBps = parseFeeBps(acceptFeeBps, "BELUGA_ACCEPT_FEE_BPS");
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
log(`[watch] not accepting ${pending.length} pending invitation(s): ${err instanceof Error ? err.message : err}\n`);
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const accepted = [];
|
|
71
|
+
for (const account of pending) {
|
|
72
|
+
try {
|
|
73
|
+
const sig = await advisor.accept(account.address, feeBps);
|
|
74
|
+
accepted.push(account.address);
|
|
75
|
+
log(`[watch] accepted ${account.address} (${sig})\n`);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
log(`[watch] accept ${account.address} failed: ${err instanceof Error ? err.message : err}\n`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return accepted;
|
|
82
|
+
}
|
|
56
83
|
/**
|
|
57
84
|
* Return the rent of every settled proposal once it has been settled for the
|
|
58
85
|
* retention window (BEL-13). Not limited to active accounts: a revoked or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAA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,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,UAAU,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,GAAG,IAAI,CACjE,CAAC;QACF,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,GAAG,IAAI,CACnE,CAAC;AACJ,CAAC"}
|
package/dist/fee.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The program's ceiling on an advisor's fee, in basis points: `MAX_FEE_BPS`
|
|
3
|
+
* in programs/beluga/src/constants.rs. `accept_advisory_account` refuses
|
|
4
|
+
* anything above it with `FeeBpsTooHigh`.
|
|
5
|
+
*
|
|
6
|
+
* Copied rather than read from chain because it is a compiled-in constant of
|
|
7
|
+
* the program, and because the place it matters most is `init`, which runs
|
|
8
|
+
* before there is a funded key or a working RPC. If the program's constant
|
|
9
|
+
* ever moves, this one moves in the same change.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MAX_ADVISOR_FEE_BPS = 100;
|
|
12
|
+
/**
|
|
13
|
+
* A fee in whole basis points the program will accept, or a refusal that
|
|
14
|
+
* says where the value came from.
|
|
15
|
+
*
|
|
16
|
+
* Refused here, before it is stored or sent, because the alternative is the
|
|
17
|
+
* failure this replaced: `init --fee-bps 250` wrote the value to the skill
|
|
18
|
+
* config without complaint, and it surfaced only as a simulation error each
|
|
19
|
+
* time the watcher tried to accept an invitation it could never accept.
|
|
20
|
+
*
|
|
21
|
+
* Strict about the text as well as the range. `parseInt` reads "7.5" as 7 and
|
|
22
|
+
* "75abc" as 75, and a fee is not something to round on someone's behalf.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseFeeBps(raw: string | number, source: string): number;
|
package/dist/fee.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The program's ceiling on an advisor's fee, in basis points: `MAX_FEE_BPS`
|
|
3
|
+
* in programs/beluga/src/constants.rs. `accept_advisory_account` refuses
|
|
4
|
+
* anything above it with `FeeBpsTooHigh`.
|
|
5
|
+
*
|
|
6
|
+
* Copied rather than read from chain because it is a compiled-in constant of
|
|
7
|
+
* the program, and because the place it matters most is `init`, which runs
|
|
8
|
+
* before there is a funded key or a working RPC. If the program's constant
|
|
9
|
+
* ever moves, this one moves in the same change.
|
|
10
|
+
*/
|
|
11
|
+
export const MAX_ADVISOR_FEE_BPS = 100;
|
|
12
|
+
/**
|
|
13
|
+
* A fee in whole basis points the program will accept, or a refusal that
|
|
14
|
+
* says where the value came from.
|
|
15
|
+
*
|
|
16
|
+
* Refused here, before it is stored or sent, because the alternative is the
|
|
17
|
+
* failure this replaced: `init --fee-bps 250` wrote the value to the skill
|
|
18
|
+
* config without complaint, and it surfaced only as a simulation error each
|
|
19
|
+
* time the watcher tried to accept an invitation it could never accept.
|
|
20
|
+
*
|
|
21
|
+
* Strict about the text as well as the range. `parseInt` reads "7.5" as 7 and
|
|
22
|
+
* "75abc" as 75, and a fee is not something to round on someone's behalf.
|
|
23
|
+
*/
|
|
24
|
+
export function parseFeeBps(raw, source) {
|
|
25
|
+
const value = typeof raw === "number"
|
|
26
|
+
? raw
|
|
27
|
+
: /^\d+$/.test(raw.trim())
|
|
28
|
+
? Number(raw.trim())
|
|
29
|
+
: NaN;
|
|
30
|
+
if (!Number.isInteger(value) || value < 0 || value > MAX_ADVISOR_FEE_BPS) {
|
|
31
|
+
throw new Error(`${source}: the advisor fee must be a whole number of basis points ` +
|
|
32
|
+
`from 0 to ${MAX_ADVISOR_FEE_BPS} (${MAX_ADVISOR_FEE_BPS} bps = ` +
|
|
33
|
+
`${MAX_ADVISOR_FEE_BPS / 100}%, the program's maximum), got "${raw}".`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=fee.js.map
|
package/dist/fee.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee.js","sourceRoot":"","sources":["../src/fee.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,GAAoB,EAAE,MAAc;IAC9D,MAAM,KAAK,GACT,OAAO,GAAG,KAAK,QAAQ;QACrB,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACxB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACpB,CAAC,CAAC,GAAG,CAAC;IACZ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,mBAAmB,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,2DAA2D;YAClE,aAAa,mBAAmB,KAAK,mBAAmB,SAAS;YACjE,GAAG,mBAAmB,GAAG,GAAG,mCAAmC,GAAG,IAAI,CACzE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { installSkillCommand } from "./commands/install-skill.js";
|
|
|
9
9
|
import { portfolioCommand } from "./commands/portfolio.js";
|
|
10
10
|
import { upgradeCommand } from "./commands/upgrade.js";
|
|
11
11
|
import { watchStartCommand, watchStatusCommand, watchStopCommand, } from "./commands/watch.js";
|
|
12
|
+
import { MAX_ADVISOR_FEE_BPS, parseFeeBps } from "./fee.js";
|
|
12
13
|
const HELP = `beluga-advisor — operate a Beluga advisor account from the command line.
|
|
13
14
|
|
|
14
15
|
Usage:
|
|
@@ -34,11 +35,14 @@ Environment (set automatically by \`init\`):
|
|
|
34
35
|
SOLANA_RPC_URL RPC endpoint (default: mainnet-beta)
|
|
35
36
|
BELUGA_PROGRAM_ID program ID (default: mainnet)
|
|
36
37
|
BELUGA_WATCH_INTERVAL_MS watch tick interval in ms (default: 30000)
|
|
37
|
-
BELUGA_AUTO_ACCEPT
|
|
38
|
+
BELUGA_AUTO_ACCEPT watcher accepts client invitations by itself (default: true);
|
|
39
|
+
not the owner's automatic-trading setting, which only
|
|
40
|
+
the vault's owner can choose
|
|
38
41
|
BELUGA_AUTO_EXECUTE auto-execute approved proposals in watch mode (default: true);
|
|
39
42
|
also the default for propose's --auto-execute, which records
|
|
40
43
|
on the proposal that you will execute it once approved
|
|
41
|
-
BELUGA_ACCEPT_FEE_BPS fee bps to charge when accepting (default: 50
|
|
44
|
+
BELUGA_ACCEPT_FEE_BPS fee bps to charge when accepting (default: 50,
|
|
45
|
+
0 to ${MAX_ADVISOR_FEE_BPS}: the program refuses more)
|
|
42
46
|
`;
|
|
43
47
|
function getFlag(argv, name) {
|
|
44
48
|
const i = argv.indexOf(`--${name}`);
|
|
@@ -87,12 +91,13 @@ async function main() {
|
|
|
87
91
|
}
|
|
88
92
|
if (command === "init") {
|
|
89
93
|
const parseInt10 = (v) => v === undefined ? undefined : parseInt(v, 10);
|
|
94
|
+
const feeFlag = getFlag(rest, "fee-bps");
|
|
90
95
|
return initCommand({
|
|
91
96
|
keypairBase64: getFlag(rest, "keypair-base64"),
|
|
92
97
|
keypairFile: getFlag(rest, "keypair-file"),
|
|
93
98
|
rpcUrl: getFlag(rest, "rpc-url"),
|
|
94
99
|
programId: getFlag(rest, "program-id"),
|
|
95
|
-
feeBps:
|
|
100
|
+
feeBps: feeFlag === undefined ? undefined : parseFeeBps(feeFlag, "--fee-bps"),
|
|
96
101
|
autoAccept: parseBool(getFlag(rest, "auto-accept")),
|
|
97
102
|
autoExecute: parseBool(getFlag(rest, "auto-execute")),
|
|
98
103
|
watchIntervalMs: parseInt10(getFlag(rest, "watch-interval-ms")),
|
|
@@ -119,8 +124,12 @@ async function main() {
|
|
|
119
124
|
await statusCommand(advisor);
|
|
120
125
|
return;
|
|
121
126
|
case "accept": {
|
|
122
|
-
const
|
|
123
|
-
await acceptCommand(advisor, {
|
|
127
|
+
const flag = getFlag(rest, "fee-bps");
|
|
128
|
+
await acceptCommand(advisor, {
|
|
129
|
+
address: positional[0],
|
|
130
|
+
feeBps: flag ?? env.acceptFeeBps,
|
|
131
|
+
feeSource: flag !== undefined ? "--fee-bps" : "BELUGA_ACCEPT_FEE_BPS",
|
|
132
|
+
});
|
|
124
133
|
return;
|
|
125
134
|
}
|
|
126
135
|
case "propose": {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,U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,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC/D,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/skill/SKILL.md
CHANGED
|
@@ -17,8 +17,9 @@ metadata:
|
|
|
17
17
|
Beluga is a Solana investment advisory platform. A *client* owns a vault and
|
|
18
18
|
custodies the assets themselves; an *advisor* holds a Solana keypair that
|
|
19
19
|
authorizes them to propose encrypted swap trades against the client's vault.
|
|
20
|
-
The client approves or rejects each proposal in the Beluga app
|
|
21
|
-
|
|
20
|
+
The client approves or rejects each proposal in the Beluga app, unless
|
|
21
|
+
they chose automatic trading for the advisor. Only after approval can the
|
|
22
|
+
advisor execute the swap on-chain via Raydium AMMs.
|
|
22
23
|
|
|
23
24
|
## Your role
|
|
24
25
|
|
|
@@ -30,7 +31,8 @@ configured fee for trades you successfully execute.
|
|
|
30
31
|
**The user is the client.** They own a Beluga vault, they invited your
|
|
31
32
|
pubkey to advise it, they bear custody of the assets, and every proposal
|
|
32
33
|
you submit must be approved by them in the Beluga app before you can
|
|
33
|
-
execute it
|
|
34
|
+
execute it, unless they chose automatic trading for you. You cannot
|
|
35
|
+
withdraw their funds.
|
|
34
36
|
|
|
35
37
|
Speak from this perspective. "Your vault holds $4,200 in USDC" — not "the
|
|
36
38
|
client's vault." "I think we should swap 30% to SOL" — not "the advisor
|
|
@@ -193,11 +195,12 @@ The payload JSON shape is:
|
|
|
193
195
|
The proposal is encrypted with the client's x25519 public key (read from
|
|
194
196
|
the advisory account on-chain) so only the client and you can decrypt it.
|
|
195
197
|
|
|
196
|
-
If the client
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
them to
|
|
198
|
+
If the client chose **automatic trading** for you (shown as Auto-accept
|
|
199
|
+
on their Advisors page), the proposal is created already approved and
|
|
200
|
+
the output says `"autoApproved": true` — there is nothing for them to
|
|
201
|
+
approve. Execute it within the hour (the watcher does this on its next
|
|
202
|
+
tick), and tell the user what you traded rather than asking them to
|
|
203
|
+
approve it.
|
|
201
204
|
|
|
202
205
|
Otherwise (`"autoApproved": false`), **always tell the user to open the
|
|
203
206
|
Beluga app and approve the proposal**. Until they approve, you cannot
|
|
@@ -223,13 +226,15 @@ beluga-advisor watch status # is it running?
|
|
|
223
226
|
beluga-advisor watch stop # kill the daemon
|
|
224
227
|
```
|
|
225
228
|
|
|
226
|
-
The watcher polls every 30 seconds and, by default,
|
|
227
|
-
|
|
229
|
+
The watcher polls every 30 seconds and, by default, accepts client
|
|
230
|
+
invitations and executes approved proposals. It does NOT
|
|
228
231
|
auto-propose — proposing is your job (you, the agent, decide what to
|
|
229
232
|
suggest).
|
|
230
233
|
|
|
231
|
-
To
|
|
232
|
-
in the skill config
|
|
234
|
+
To stop the watcher accepting client invitations, set
|
|
235
|
+
`BELUGA_AUTO_ACCEPT=false` in the skill config; to stop it executing,
|
|
236
|
+
set `BELUGA_AUTO_EXECUTE=false`. Neither changes how the client approves
|
|
237
|
+
trades: that is their choice in the Beluga app.
|
|
233
238
|
|
|
234
239
|
Closing settled proposals is off by default. Set `BELUGA_AUTO_CLOSE=true`
|
|
235
240
|
and the watcher also closes every executed, rejected or expired proposal
|
|
@@ -257,10 +262,12 @@ opinion on:
|
|
|
257
262
|
Default: `https://api.mainnet-beta.solana.com`. Recommend a private
|
|
258
263
|
RPC (QuikNode/Helius/Triton) if they plan to run watch mode.
|
|
259
264
|
3. **Fee** — "What fee should I charge per trade, in basis points?"
|
|
260
|
-
Default: 50 (0.5%). Range: 0
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
Default: 50 (0.5%). Range: 0 to 100 (1%), a whole number. 100 is the
|
|
266
|
+
on-chain program's maximum: `init` and `accept` refuse anything higher,
|
|
267
|
+
because an accept above it fails on chain. (This is the fee you collect
|
|
268
|
+
on every executed trade, paid out of the input mint.)
|
|
269
|
+
4. **Accept invitations** — "Should the watcher accept client invitations
|
|
270
|
+
I receive by itself?" Default: yes.
|
|
264
271
|
5. **Auto-execute** — "Should the watcher auto-execute proposals once
|
|
265
272
|
you've approved them in the Beluga app?" Default: yes.
|
|
266
273
|
|
|
@@ -288,9 +295,20 @@ because you can't transact without SOL):
|
|
|
288
295
|
and tell them to send a small amount of SOL to it (~0.05 SOL is plenty
|
|
289
296
|
for low-volume use). You can't accept their invitation or execute
|
|
290
297
|
proposals until this address holds SOL.
|
|
291
|
-
2. **Open the invite URL** in the Beluga app
|
|
292
|
-
|
|
293
|
-
|
|
298
|
+
2. **Open the invite URL** and sign in to the Beluga app with the wallet
|
|
299
|
+
that will own the vault. The Add an Advisor form opens with your pubkey
|
|
300
|
+
already filled in. Before they confirm, the form asks them to choose
|
|
301
|
+
between approving each trade and letting you trade automatically;
|
|
302
|
+
approving each trade is selected to start with. Confirming creates
|
|
303
|
+
the vault and invites you (the advisor) on-chain. Tell them plainly
|
|
304
|
+
what automatic means, and do not steer them toward it: your swaps run
|
|
305
|
+
without asking them; you
|
|
306
|
+
can never withdraw; nothing today caps how much of the vault one swap
|
|
307
|
+
uses, how often you trade, or which tokens you buy; every swap pays
|
|
308
|
+
your fee (set when you accept, 1% at most); the limits that exist are
|
|
309
|
+
their trade conditions (a minimum pool depth, a maximum price impact,
|
|
310
|
+
a maximum share of a pool), which are off until they set them. They
|
|
311
|
+
can change the choice later from your menu on their Advisors page.
|
|
294
312
|
3. **Restart OpenClaw** so it picks up the new env from
|
|
295
313
|
`~/.openclaw/openclaw.json`.
|
|
296
314
|
|
|
@@ -327,6 +345,7 @@ execution), so a race only produces a harmless failed transaction.
|
|
|
327
345
|
limits enforced by the on-chain program. You cannot withdraw the
|
|
328
346
|
client's funds.
|
|
329
347
|
- The client retains custody of their vault assets and must approve every
|
|
330
|
-
proposal in the Beluga app before you can execute it
|
|
348
|
+
proposal in the Beluga app before you can execute it, unless they chose
|
|
349
|
+
automatic trading for you.
|
|
331
350
|
- Encrypted proposal payloads are decryptable by you and the client only
|
|
332
351
|
— not by anyone observing the chain.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@belugafinancial/advisor-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Command-line tool to operate a Beluga advisor account: accept invitations, propose encrypted swaps, execute approved proposals, and run a watch daemon for the boring lifecycle bits.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|