@nuluvium/mcp 0.2.0 → 0.3.0

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 CHANGED
@@ -7,8 +7,18 @@ sent at random times, each bought from a fresh address through the Nuluvium rela
7
7
  It runs **on the agent's own machine**: the secret, the notes and the order schedule never leave it.
8
8
  Privacy is from other readers of the chain, not from Robinhood.
9
9
 
10
- **Testnet only for now** (Robinhood Chain testnet, test tokens). Deposits are capped at 1,000 USDG
11
- each until the audit.
10
+ **Runs on Robinhood Chain mainnet with real USDG** (since 0.3.0). Open to everyone, no deposit cap.
11
+ Testnet stays available as a practice mode with test tokens (see [Practice on testnet](#practice-on-testnet)).
12
+
13
+ ## Before you use real money
14
+
15
+ - **This is real money.** Orders spend real USDG and buy real stock tokens.
16
+ - **The contracts are not audited.** Only deposit what you can afford to lose.
17
+ - **Your deposit can always be taken back.** The wallet that made a deposit can withdraw what is
18
+ left of it (`ragequit`) at any time, with no help from Nuluvium, even if Nuluvium is paused or
19
+ gone. The MCP server has no tool for it yet: use the SDK (`ragequitNote`) with the same mnemonic.
20
+ - **Fees:** 0.10 USDG per piece, paid to the relayer from the piece's USDG. You also pay a little
21
+ ETH for gas on the two deposit transactions.
12
22
 
13
23
  ## Setup
14
24
 
@@ -33,21 +43,21 @@ Then add this to your MCP client config (Claude Code `.mcp.json`, Claude Desktop
33
43
  "command": "npx",
34
44
  "args": ["-y", "@nuluvium/mcp"],
35
45
  "env": {
36
- "NULUVIUM_MNEMONIC": "${NULUVIUM_MNEMONIC}",
37
- "NULUVIUM_NETWORK": "robinhood-testnet"
46
+ "NULUVIUM_MNEMONIC": "${NULUVIUM_MNEMONIC}"
38
47
  }
39
48
  }
40
49
  }
41
50
  }
42
51
  ```
43
52
 
44
- Set `NULUVIUM_MNEMONIC` in the agent's environment: twelve words that only this machine knows. Use a
45
- new testnet mnemonic, never a real wallet's.
53
+ Set `NULUVIUM_MNEMONIC` in the agent's environment: twelve words that only this machine knows. Make
54
+ a new mnemonic for the agent, never one of your own wallets', and keep a backup: it is the only way to
55
+ reach the agent's deposits.
46
56
 
47
57
  | Variable | |
48
58
  |---|---|
49
59
  | `NULUVIUM_MNEMONIC` | required. The agent's secret. Removed from the process environment after reading; never returned |
50
- | `NULUVIUM_NETWORK` | default `robinhood-testnet` |
60
+ | `NULUVIUM_NETWORK` | default `robinhood-mainnet`; `robinhood-testnet` to practise |
51
61
  | `NULUVIUM_RPC_URL` | optional own RPC (for networks that block `*.robinhood.com`) |
52
62
  | `NULUVIUM_HOME` | default `~/.nuluvium` (order schedule and circuit files; local only) |
53
63
  | `NULUVIUM_ARTIFACTS` | optional folder with the circuit files |
@@ -57,15 +67,30 @@ new testnet mnemonic, never a real wallet's.
57
67
  | Tool | Does |
58
68
  |---|---|
59
69
  | `get_balance` | Shielded USDG per note with its status (approved, waiting, rejected), the deposit wallet, tradable tokens |
60
- | `deposit` | Moves USDG from the deposit wallet into the shielded balance (1 to 1,000 USDG) |
70
+ | `deposit` | Moves USDG from the deposit wallet into the shielded balance (at least 1 USDG; common sizes such as 100 blend in better) |
61
71
  | `route_order` | Buys a stock token in pieces over a time window; returns at once, pieces go out in the background |
62
72
  | `cancel_order` | Cancels pieces not sent yet |
63
73
  | `get_orders` | Orders and the status of every piece |
64
74
  | `get_fills` | Executed pieces: USDG spent, fee, tokens received, fresh address, transaction |
65
75
 
66
- The deposit wallet is the mnemonic's first address (`m/44'/60'/0'/0/0`): send it USDG and a little
67
- ETH for gas, then call `deposit`. A deposit is public; what the note pays for later is not linked to
68
- it. Orders run while the server runs.
76
+ The deposit wallet is the mnemonic's first address (`m/44'/60'/0'/0/0`): send it real USDG and a
77
+ little ETH for gas on Robinhood Chain, then call `deposit`. A deposit is public; what the note pays
78
+ for later is not linked to it. Orders run while the server runs. Tradable on mainnet: 21 stock tokens
79
+ with a Uniswap USDG pool (NVDA, TSLA, AAPL, SPY, QQQ and more; `get_balance` lists them).
80
+
81
+ ## Practice on testnet
82
+
83
+ Set `NULUVIUM_NETWORK` to `robinhood-testnet` to try everything with test tokens first: one mock
84
+ stock (MSTK at a fixed price), test USDG and a little test ETH from the Nuluvium faucet
85
+ (`POST https://faucet.nuluvium.com/drip` with `{"address": "<deposit wallet>"}`, once a day). Testnet
86
+ deposits are capped at 1,000 test USDG each. Orders of each network are kept apart (`~/.nuluvium/orders-<network>.json`).
87
+
88
+ ```json
89
+ "env": {
90
+ "NULUVIUM_MNEMONIC": "${NULUVIUM_MNEMONIC}",
91
+ "NULUVIUM_NETWORK": "robinhood-testnet"
92
+ }
93
+ ```
69
94
 
70
95
  Docs: [github.com/nuluviumhq/nuluvium](https://github.com/nuluviumhq/nuluvium/blob/main/docs/mcp.md).
71
96
  License: Apache-2.0.
@@ -1,18 +1,18 @@
1
1
  // The deposit tool's rules, kept apart from the server so they can be tested without a chain.
2
2
  // A deposit is paid from the agent's own wallet (the mnemonic's account 0, see sdk depositAccount):
3
3
  // it needs the USDG and a little ETH for two transactions (approve, then deposit).
4
- /** Beta cap per deposit, the same as the approved-set provider applies (asp/src/screen.js). */
5
- export const DEPOSIT_CAP = 1000n * 1000000n;
6
4
  /** Smallest deposit: one piece of the smallest order (1 USDG). */
7
5
  export const MIN_DEPOSIT = 1000000n;
8
6
  /** Gas reserve for approve + deposit on Robinhood Chain (an L2: well above the real cost). */
9
7
  export const MIN_GAS_WEI = 10n ** 13n; // 0.00001 ETH
10
8
  /** Why this deposit cannot go ahead, or null when it can. Messages are written for the agent. */
11
- export function depositProblem(amount, funds, wallet, faucet) {
9
+ export function depositProblem(amount, funds, wallet, rules = {}) {
10
+ const { cap, faucet } = rules;
12
11
  if (amount < MIN_DEPOSIT)
13
12
  return "The smallest deposit is 1 USDG.";
14
- if (amount > DEPOSIT_CAP)
15
- return "Deposits are capped at 1,000 USDG each until the audit; a larger one would not be approved.";
13
+ if (cap !== undefined && amount > cap) {
14
+ return `Deposits on this network are capped at ${Number(formatUsdg(cap)).toLocaleString("en-US")} USDG each; a larger one would not be approved.`;
15
+ }
16
16
  if (funds.usdg < amount) {
17
17
  return `The deposit wallet ${wallet} holds ${formatUsdg(funds.usdg)} USDG, less than ${formatUsdg(amount)}. Send USDG to it first.`;
18
18
  }
@@ -1,13 +1,15 @@
1
1
  // Networks and tradable tokens. Only allowlisted tokens can be routed. Minimum outputs come from a
2
2
  // QuoterV2 quote at the Router's fee tier for every piece (SDK quotedBuy); on testnet the quoter is
3
3
  // a stand-in for the fixed-price mock router.
4
- import { ROBINHOOD_TESTNET } from "../../sdk/src/index.js";
4
+ import { ROBINHOOD_MAINNET, ROBINHOOD_TESTNET } from "../../sdk/src/index.js";
5
5
  export const NETWORKS = {
6
6
  "robinhood-testnet": {
7
7
  name: "Robinhood Chain testnet",
8
8
  config: ROBINHOOD_TESTNET,
9
9
  explorer: "https://explorer.testnet.chain.robinhood.com",
10
10
  faucet: "https://faucet.testnet.chain.robinhood.com",
11
+ // The testnet approved-set provider keeps its beta cap (asp/src/screen.js).
12
+ depositCap: 1000n * 1000000n,
11
13
  artifactsUrl: "https://nuluvium.com/artifacts",
12
14
  tokens: {
13
15
  MSTK: {
@@ -18,4 +20,37 @@ export const NETWORKS = {
18
20
  },
19
21
  },
20
22
  },
23
+ // Mainnet (the default since 0.3.0): open to everyone, no deposit cap. Real stock tokens: every one
24
+ // with a Uniswap v3 USDG pool (contracts/deployments/4663-tokens.json).
25
+ "robinhood-mainnet": {
26
+ name: "Robinhood Chain mainnet",
27
+ config: ROBINHOOD_MAINNET,
28
+ // Blockscout, the explorer in viem's `robinhood` chain definition (checked 2026-12-02: it shows
29
+ // the shielded pool contract). Not on *.robinhood.com, so it opens where that domain is blocked.
30
+ explorer: "https://robinhoodchain.blockscout.com",
31
+ artifactsUrl: "https://nuluvium.com/artifacts",
32
+ tokens: {
33
+ META: { symbol: "META", address: "0xc0D6457C16Cc70d6790Dd43521C899C87ce02f35", decimals: 18 },
34
+ NVDA: { symbol: "NVDA", address: "0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC", decimals: 18 },
35
+ SPY: { symbol: "SPY", address: "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C", decimals: 18 },
36
+ USO: { symbol: "USO", address: "0xa30FA36Db767ad9eD3f7a60fC79526fB4d56D344", decimals: 18 },
37
+ CRCL: { symbol: "CRCL", address: "0xdF0992E440dD0be65BD8439b609d6D4366bf1CB5", decimals: 18 },
38
+ GLD: { symbol: "GLD", address: "0xC9a981FEE1F9DEc688bb123ccDeCc63D0deBFC4e", decimals: 18 },
39
+ MSTR: { symbol: "MSTR", address: "0xec262a75e413fAfD0dF80480274532C79D42da09", decimals: 18 },
40
+ SPCX: { symbol: "SPCX", address: "0x4a0E65A3EcceC6dBe60AE065F2e7bb85Fae35eEa", decimals: 18 },
41
+ QQQ: { symbol: "QQQ", address: "0xD5f3879160bc7c32ebb4dC785F8a4F505888de68", decimals: 18 },
42
+ AMC: { symbol: "AMC", address: "0x05a3d1Cd21d0C88145E82600E62e7E496e0F222B", decimals: 18 },
43
+ BABA: { symbol: "BABA", address: "0xad25Ac6C84D497db898fa1E8387bf6Af3532a1c4", decimals: 18 },
44
+ RDDT: { symbol: "RDDT", address: "0x05b37Fb53A299a1b874A619e1c4C404D52C36F4C", decimals: 18 },
45
+ TSLA: { symbol: "TSLA", address: "0x322F0929c4625eD5bAd873c95208D54E1c003b2d", decimals: 18 },
46
+ GOOGL: { symbol: "GOOGL", address: "0x2e0847E8910a9732eB3fb1bb4b70a580ADAD4FE3", decimals: 18 },
47
+ PLTR: { symbol: "PLTR", address: "0x894E1EC2D74FFE5AEF8Dc8A9e84686acCB964F2A", decimals: 18 },
48
+ AMZN: { symbol: "AMZN", address: "0x12f190a9F9d7D37a250758b26824B97CE941bF54", decimals: 18 },
49
+ AAPL: { symbol: "AAPL", address: "0xaF3D76f1834A1d425780943C99Ea8A608f8a93f9", decimals: 18 },
50
+ MU: { symbol: "MU", address: "0xfF080c8ce2E5feadaCa0Da81314Ae59D232d4afD", decimals: 18 },
51
+ TSM: { symbol: "TSM", address: "0x58FfE4a942d3885bAa22D7520691F611EF09e7AA", decimals: 18 },
52
+ GME: { symbol: "GME", address: "0x1b0E319c6A659F002271B69dB8A7df2F911c153E", decimals: 18 },
53
+ ANT: { symbol: "ANT", address: "0xbbB6c29bCc3a1028A2B54310DF73F4F7A3bcB373", decimals: 18 },
54
+ },
55
+ },
21
56
  };
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  // Nuluvium MCP server (stdio). Runs on the agent's own machine: the secret, the notes and the
3
- // order schedule never leave it. Pieces are sent through the relayers active in the RelayerRegistry
4
- // (another one when one is down or refuses) to Router v2, which takes the relayer gas fee and a 0.1%
5
- // protocol fee from the USDG of each piece. The agent never holds or pays NLV.
3
+ // order schedule never leave it. Pieces are sent through the network's relayers (another one when one
4
+ // is down or refuses) to the Nuluvium Router, which takes the relayer fee (and on testnet's Router v2
5
+ // a 0.1% protocol fee) from the USDG of each piece. The agent never holds or pays NLV.
6
6
  //
7
7
  // Environment:
8
8
  // NULUVIUM_MNEMONIC required. The agent's secret (BIP-39). Never printed or returned.
9
- // NULUVIUM_NETWORK default "robinhood-testnet"
9
+ // NULUVIUM_NETWORK default "robinhood-mainnet" (real USDG); "robinhood-testnet" to practise
10
10
  // NULUVIUM_RPC_URL optional own RPC (may hold an API key; never printed)
11
11
  // NULUVIUM_LOG_CHUNK blocks per log query with NULUVIUM_RPC_URL (default 10000, Alchemy limit)
12
12
  // NULUVIUM_RELAYERS optional comma-separated relayer URLs instead of the registry's list (each
@@ -22,10 +22,10 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
22
22
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
23
23
  import { formatUnits } from "viem";
24
24
  import { z } from "zod";
25
- import { depositAccount, depositUsdg, erc20Abi, keysFromMnemonic, planPieces, walletClientFor } from "../../sdk/src/index.js";
25
+ import { depositAccount, depositSizeAdvice, depositUsdg, erc20Abi, keysFromMnemonic, planPieces, walletClientFor } from "../../sdk/src/index.js";
26
26
  import { noteApproval, pickNote } from "./approval.js";
27
27
  import { ensureArtifacts, missingArtifacts } from "./artifacts.js";
28
- import { depositProblem } from "./deposit.js";
28
+ import { depositProblem, formatUsdg } from "./deposit.js";
29
29
  import { Engine } from "./engine.js";
30
30
  import { NETWORKS } from "./networks.js";
31
31
  import { OrderStore, orderStatus } from "./store.js";
@@ -35,10 +35,12 @@ console.info = console.error;
35
35
  const USDG = 1000000n;
36
36
  const MIN_PIECE = 1n * USDG;
37
37
  const START_DELAY_SECONDS = 30;
38
- const networkName = process.env.NULUVIUM_NETWORK ?? "robinhood-testnet";
38
+ const networkName = process.env.NULUVIUM_NETWORK ?? "robinhood-mainnet";
39
39
  const baseNetwork = NETWORKS[networkName];
40
40
  if (!baseNetwork)
41
- throw new Error(`unknown NULUVIUM_NETWORK ${networkName}`);
41
+ throw new Error(`unknown NULUVIUM_NETWORK ${networkName} (use ${Object.keys(NETWORKS).join(" or ")})`);
42
+ if (baseNetwork.config.deployBlock === 0n)
43
+ throw new Error(`${baseNetwork.name} is not deployed yet`);
42
44
  // Own RPC (e.g. Alchemy): needed where the public *.robinhood.com RPC is unreachable (some ISPs
43
45
  // block the domain) or rate-limited. Alchemy accepts at most 10,000 blocks per log query.
44
46
  const rpcOverride = process.env.NULUVIUM_RPC_URL;
@@ -89,6 +91,16 @@ const prepareProver = () => {
89
91
  const store = new OrderStore(home, networkName);
90
92
  const engine = new Engine(network, keys, store, artifacts, prepareProver);
91
93
  const usdg = (units) => `${formatUnits(BigInt(units), 6)} USDG`;
94
+ /** USDG units as a plain number with thousands separators, e.g. 1,000. */
95
+ const usdgPlain = (units) => Number(formatUsdg(units)).toLocaleString("en-US");
96
+ /** Deposit-size guidance for an odd amount (advice only; the deposit already went through). */
97
+ function sizeNote(amount) {
98
+ const advice = depositSizeAdvice(amount);
99
+ if (advice.common || advice.split.length === 0)
100
+ return {};
101
+ const split = advice.split.map((size) => formatUnits(size, 6)).join(" + ");
102
+ return { sizeNote: `${usdg(amount)} is not a common size. Next time, deposits of ${split} USDG blend in better while the pool is small.` };
103
+ }
92
104
  const clock = (unix) => new Date(unix * 1000).toISOString().replace(".000Z", "Z");
93
105
  const reply = (body) => ({ content: [{ type: "text", text: JSON.stringify(body, null, 2) }] });
94
106
  const failure = (message) => ({ content: [{ type: "text", text: message }], isError: true });
@@ -136,7 +148,8 @@ async function walletFunds() {
136
148
  ]);
137
149
  return { usdg: usdgBalance, eth };
138
150
  }
139
- const server = new McpServer({ name: "nuluvium", version: "0.1.0" });
151
+ const depositCapText = network.depositCap ? ` Up to ${usdgPlain(network.depositCap)} USDG per deposit on this network.` : "";
152
+ const server = new McpServer({ name: "nuluvium", version: "0.3.0" });
140
153
  server.registerTool("get_balance", {
141
154
  title: "Shielded balance",
142
155
  description: "Shows the agent's shielded USDG balance on Nuluvium, per note, and the deposit wallet that funds new deposits. One order is paid from one note, so the largest note is the largest order you can route right now.",
@@ -163,13 +176,13 @@ server.registerTool("get_balance", {
163
176
  }));
164
177
  server.registerTool("deposit", {
165
178
  title: "Deposit USDG into the shielded balance",
166
- description: "Moves USDG from the agent's deposit wallet (see get_balance) into its shielded balance as a new note. The deposit itself is public: anyone can see this wallet deposited this amount; what the note pays for later is not linked to it. Sends two transactions (approve, deposit) and waits for them. The new note can pay for orders once the clean-funds check approves it, usually within a minute. Up to 1,000 USDG per deposit until the audit.",
179
+ description: `Moves USDG from the agent's deposit wallet (see get_balance) into its shielded balance as a new note. The deposit itself is public: anyone can see this wallet deposited this amount; what the note pays for later is not linked to it. Sends two transactions (approve, deposit) and waits for them. The new note can pay for orders once the clean-funds check approves it, usually within a minute.${depositCapText} Prefer a common size (10, 25, 50, 100, 250, 500 or 1,000 USDG): while few people use the pool, an odd amount is easier to pick out; split an odd amount into several deposits of common sizes.`,
167
180
  inputSchema: {
168
- usdgAmount: z.number().positive().describe("USDG to deposit (1 to 1,000)"),
181
+ usdgAmount: z.number().positive().describe(network.depositCap ? `USDG to deposit (1 to ${usdgPlain(network.depositCap)})` : "USDG to deposit (at least 1)"),
169
182
  },
170
183
  }, safe(async ({ usdgAmount }) => {
171
184
  const amount = BigInt(Math.round(usdgAmount * 1e6));
172
- const problem = depositProblem(amount, await walletFunds(), depositWallet.address, network.faucet);
185
+ const problem = depositProblem(amount, await walletFunds(), depositWallet.address, { cap: network.depositCap, faucet: network.faucet });
173
186
  if (problem)
174
187
  return failure(problem);
175
188
  const wallet = walletClientFor(network.config, depositWallet);
@@ -180,13 +193,14 @@ server.registerTool("deposit", {
180
193
  from: depositWallet.address,
181
194
  transaction: `${network.explorer}/tx/${tx}`,
182
195
  next: "Wait about a minute for the clean-funds check, then route_order can pay from this note.",
196
+ ...sizeNote(amount),
183
197
  });
184
198
  }));
185
199
  server.registerTool("route_order", {
186
200
  title: "Route a private buy order",
187
201
  description: "Buys a stock token with shielded USDG, split into pieces of random size sent at random times inside the window. Each piece goes to its own fresh address, so the trades do not trace back to the agent's wallet. Returns at once; pieces are sent in the background (check with get_orders / get_fills). Privacy is from other readers of the chain, not from Robinhood.",
188
202
  inputSchema: {
189
- token: z.string().describe("Symbol of an allowlisted stock token, e.g. MSTK on testnet"),
203
+ token: z.string().describe("Symbol of an allowlisted stock token, e.g. NVDA on mainnet or MSTK on testnet (see get_balance)"),
190
204
  usdgAmount: z.number().positive().describe("Total USDG to spend"),
191
205
  pieces: z.number().int().min(1).max(20).default(5).describe("How many pieces (1 to 20)"),
192
206
  windowMinutes: z.number().min(1).max(1440).default(10).describe("Spread the pieces over this many minutes"),
@@ -16,6 +16,9 @@ export const erc20Abi = parseAbi([
16
16
  "function approve(address spender, uint256 amount) returns (bool)",
17
17
  "function nonces(address owner) view returns (uint256)",
18
18
  "function eip712Domain() view returns (bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions)",
19
+ "function name() view returns (string)",
20
+ "function version() view returns (string)",
21
+ "function DOMAIN_SEPARATOR() view returns (bytes32)",
19
22
  ]);
20
23
  export function chainFor(config) {
21
24
  return defineChain({
@@ -2,13 +2,15 @@
2
2
  export const ROBINHOOD_TESTNET = {
3
3
  chainId: 46_630,
4
4
  rpcUrl: "https://rpc.testnet.chain.robinhood.com",
5
- logChunk: 5000000n,
5
+ // The public RPC refuses log queries over 100,000 blocks (it allowed millions before).
6
+ logChunk: 100000n,
6
7
  entrypoint: "0x1C7Bd821a61A90BA06e21aac4e03640E3D065536",
7
8
  pool: "0x2B38bF53acc21a51603E68f5BC3bC8943B01fD4a",
8
9
  usdg: "0xd26d58F86cf82c702b558D6E7F159939E97F0Bfa",
9
10
  scope: 20883339666151915200592145183006062909365231028523521475069391119255857699183n,
10
11
  deployBlock: 153603397n,
11
12
  router: "0x2A97D783811ADa610223CeBD56d77d72306F0B9e",
13
+ routerVersion: "2",
12
14
  previousRouters: ["0x3287C2947f137c20c8BfeB628f800D23b8e5D155"],
13
15
  registry: "0xcF69fE69E3B273f66F589c5f912f347144316bB0",
14
16
  protocolFeeBps: 10n,
@@ -16,3 +18,26 @@ export const ROBINHOOD_TESTNET = {
16
18
  relayerUrls: ["https://relayer.nuluvium.com", "https://relayer2.nuluvium.com"],
17
19
  aspUrl: "https://asp.nuluvium.com",
18
20
  };
21
+ /**
22
+ * Robinhood Chain mainnet, phase C (owner-only run, small caps; docs/phase-c-plan.md): Router v1,
23
+ * no registry, no protocol fee. Deployed 2026-12-01 (contracts/deployments/4663.json); owner: the
24
+ * Safe 2-of-2 0x6989882E4000b101696B02d81D5BC714171D9dd6.
25
+ */
26
+ export const ROBINHOOD_MAINNET = {
27
+ chainId: 4_663,
28
+ rpcUrl: "https://rpc.mainnet.chain.robinhood.com",
29
+ logChunk: 100000n,
30
+ entrypoint: "0x53434dc7a0aaad3F60c5a57774837dbce64a3Bf7",
31
+ pool: "0x46c999f2E8932568508EcdBB75e8A31fc626646b",
32
+ usdg: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
33
+ scope: 13682659716543466542946129181970375048908930175606642975055904513151937729705n,
34
+ deployBlock: 127286634n,
35
+ router: "0x70E7d97bD23f4A1f60CEE47317Ed6617DD7F8FF2",
36
+ routerVersion: "1",
37
+ previousRouters: [],
38
+ protocolFeeBps: 0n,
39
+ // Uniswap QuoterV2 on Robinhood Chain (real prices).
40
+ quoter: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",
41
+ relayerUrls: ["https://relayer-mainnet.nuluvium.com", "https://relayer2-mainnet.nuluvium.com"],
42
+ aspUrl: "https://asp-mainnet.nuluvium.com",
43
+ };
@@ -8,7 +8,7 @@
8
8
  // quote minimum outputs from a Uniswap v3 quote (QuoterV2) at the Router's fee tier
9
9
  // routing one piece end to end, or a whole plan on schedule
10
10
  // exit ragequit a deposit back to its wallet; sell a fresh address's tokens for USDG
11
- export { ROBINHOOD_TESTNET } from "./config.js";
11
+ export { ROBINHOOD_MAINNET, ROBINHOOD_TESTNET } from "./config.js";
12
12
  export { KEY_MESSAGE_VERSION, depositAccount, freshAccount, isValidMnemonic, keyMessage, keysFromMnemonic, keysFromSignature, newMnemonic } from "./keys.js";
13
13
  export { changeSecrets, depositSecrets, noteAfterWithdrawal, nullifierHash, recoverNotes } from "./notes.js";
14
14
  export { planPieces, secureRandom } from "./planner.js";
@@ -18,5 +18,6 @@ export { RelayerError, clearRelayerCache, getQuote, listRelayers, markRelayerFai
18
18
  export { quoteSwap, quotedBuy, quotedSellMinimum, quoterAbi, withSlippage } from "./quote.js";
19
19
  export { executePiece, randomNonce, runPlan } from "./routing.js";
20
20
  export { depositUsdg } from "./deposit.js";
21
+ export { COMMON_DEPOSIT_SIZES, depositSizeAdvice } from "./sizes.js";
21
22
  export { proveRagequit, ragequitAbi, ragequitNote, sellAtQuote, sellFromFresh } from "./exit.js";
22
23
  export { chainFor, erc20Abi, publicClientFor, walletClientFor } from "./chain.js";
@@ -2,7 +2,7 @@
2
2
  // Relayers come from the RelayerRegistry (bonded with NLV; tNLV on testnet); orders go to Router v2,
3
3
  // which pays the sending relayer its gas fee plus half of the 0.1% protocol fee (the rest to the
4
4
  // treasury Safe). Traders never hold or pay NLV: both fees come out of the USDG side of the piece.
5
- import { parseAbi, parseSignature } from "viem";
5
+ import { domainSeparator, parseAbi, parseSignature } from "viem";
6
6
  import { erc20Abi, publicClientFor } from "./chain.js";
7
7
  /** Protocol fee the Router takes from `usdgAmount` (Router v2 protocolFeeFor: rounded down). */
8
8
  export function protocolFeeFor(config, usdgAmount) {
@@ -176,7 +176,7 @@ async function postWithFailover(config, path, body, quote, maxFee) {
176
176
  const stringFields = (order) => Object.fromEntries(Object.entries(order).map(([key, value]) => [key, String(value)]));
177
177
  export function signOrder(account, config, order) {
178
178
  return account.signTypedData({
179
- domain: { name: "Nuluvium Router", version: "2", chainId: config.chainId, verifyingContract: config.router },
179
+ domain: { name: "Nuluvium Router", version: config.routerVersion, chainId: config.chainId, verifyingContract: config.router },
180
180
  types: {
181
181
  Order: [
182
182
  { name: "owner", type: "address" },
@@ -193,9 +193,29 @@ export function signOrder(account, config, order) {
193
193
  message: order,
194
194
  });
195
195
  }
196
+ /**
197
+ * The token's EIP-712 name and version. Most tokens publish them through eip712Domain() (EIP-5267);
198
+ * USDG on mainnet does not, so the fallback reads name() and version() (default "1") and accepts them
199
+ * only if they rebuild the token's DOMAIN_SEPARATOR, so a wrong guess never signs a permit.
200
+ */
201
+ export async function permitDomain(client, chainId, token) {
202
+ try {
203
+ const [, name, version] = await client.readContract({ address: token, abi: erc20Abi, functionName: "eip712Domain" });
204
+ return { name, version };
205
+ }
206
+ catch {
207
+ const name = await client.readContract({ address: token, abi: erc20Abi, functionName: "name" });
208
+ const version = await client.readContract({ address: token, abi: erc20Abi, functionName: "version" }).catch(() => "1");
209
+ const separator = await client.readContract({ address: token, abi: erc20Abi, functionName: "DOMAIN_SEPARATOR" });
210
+ if (domainSeparator({ domain: { name, version, chainId, verifyingContract: token } }) !== separator) {
211
+ throw new Error(`Cannot work out the permit domain of token ${token}`);
212
+ }
213
+ return { name, version };
214
+ }
215
+ }
196
216
  /** EIP-2612 permit for `value` of `token` to `spender`, using the token's own EIP-712 domain. */
197
217
  export async function signPermit(account, client, config, token, spender, value, deadline) {
198
- const [, name, version] = await client.readContract({ address: token, abi: erc20Abi, functionName: "eip712Domain" });
218
+ const { name, version } = await permitDomain(client, config.chainId, token);
199
219
  const nonce = await client.readContract({ address: token, abi: erc20Abi, functionName: "nonces", args: [account.address] });
200
220
  const signature = parseSignature(await account.signTypedData({
201
221
  domain: { name, version, chainId: config.chainId, verifyingContract: token },
@@ -0,0 +1,20 @@
1
+ // Deposit-size guidance. A deposit is public, and while few people use the pool an unusual amount
2
+ // (137.42) is easier to pick out than a common one (100). The app and the MCP server suggest common
3
+ // sizes and how to split an odd amount into them. Advice only: any amount still works.
4
+ // No dependencies, so the web app can import it without the rest of the SDK.
5
+ const UNIT = 1000000n; // USDG has 6 decimals
6
+ /** Common deposit sizes in whole USDG, largest first (the per-deposit cap is 1,000 until the audit). */
7
+ export const COMMON_DEPOSIT_SIZES = [1000n, 500n, 250n, 100n, 50n, 25n, 10n].map((size) => size * UNIT);
8
+ /** Splits `amount` (USDG units) into common sizes, largest first. */
9
+ export function depositSizeAdvice(amount) {
10
+ const common = COMMON_DEPOSIT_SIZES.includes(amount);
11
+ const split = [];
12
+ let rest = amount;
13
+ for (const size of COMMON_DEPOSIT_SIZES) {
14
+ while (rest >= size) {
15
+ split.push(size);
16
+ rest -= size;
17
+ }
18
+ }
19
+ return { common, split, rest };
20
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuluvium/mcp",
3
3
  "mcpName": "com.nuluvium/mcp",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "description": "Nuluvium MCP server: lets an AI agent trade Robinhood Chain stock tokens privately, from its own machine",
7
7
  "license": "Apache-2.0",