@solworks/poll-mcp 0.1.10 → 0.1.12

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.
@@ -4,6 +4,10 @@ function errorResult(message) {
4
4
  function textResult(text) {
5
5
  return { content: [{ type: 'text', text }] };
6
6
  }
7
+ /** Format a raw USDC micro-unit amount (6 decimals) as a human-readable dollar string. */
8
+ function formatUsdc(raw) {
9
+ return `$${(raw / 1e6).toFixed(2)}`;
10
+ }
7
11
  export const TOOL_DEFINITIONS = {
8
12
  // ── Read tools (scope: read) ───────────────────────────────────────
9
13
  get_account: {
@@ -93,9 +97,9 @@ export const TOOL_DEFINITIONS = {
93
97
  const bets = await client.listPublicBets({ page });
94
98
  const display = bets.slice(0, 20);
95
99
  const lines = display.map((b, i) => {
96
- const volume = `$${(b.totalOiFor + b.totalOiAgainst).toFixed(2)}`;
100
+ const volume = formatUsdc(b.totalOiFor + b.totalOiAgainst);
97
101
  const participants = Array.isArray(b.wagers) ? b.wagers.length : 0;
98
- return `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${volume} (For: $${b.totalOiFor.toFixed(2)} / Against: $${b.totalOiAgainst.toFixed(2)}), Participants: ${participants}, Address: ${b.betAddress}`;
102
+ return `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${volume} (For: ${formatUsdc(b.totalOiFor)} / Against: ${formatUsdc(b.totalOiAgainst)}), Participants: ${participants}, Address: ${b.betAddress}`;
99
103
  });
100
104
  let text = `Public Bets:\n${lines.join('\n')}`;
101
105
  if (bets.length > 20)
@@ -118,7 +122,7 @@ export const TOOL_DEFINITIONS = {
118
122
  try {
119
123
  const bets = await client.getTrendingBets();
120
124
  const display = bets.slice(0, 20);
121
- const lines = display.map((b, i) => `${i + 1}. ${b.question} — Volume: $${(b.totalOiFor + b.totalOiAgainst).toFixed(2)} (For: $${b.totalOiFor.toFixed(2)} / Against: $${b.totalOiAgainst.toFixed(2)}), Address: ${b.betAddress}`);
125
+ const lines = display.map((b, i) => `${i + 1}. ${b.question} — Volume: ${formatUsdc(b.totalOiFor + b.totalOiAgainst)} (For: ${formatUsdc(b.totalOiFor)} / Against: ${formatUsdc(b.totalOiAgainst)}), Address: ${b.betAddress}`);
122
126
  let text = `Trending Bets:\n${lines.join('\n')}`;
123
127
  if (bets.length > 20)
124
128
  text += `\n\n(Showing 20 of ${bets.length})`;
@@ -148,12 +152,13 @@ export const TOOL_DEFINITIONS = {
148
152
  return errorResult('Missing required parameter: id');
149
153
  try {
150
154
  const bet = await client.getBet(id);
155
+ const volume = formatUsdc(bet.totalOiFor + bet.totalOiAgainst);
151
156
  const lines = [
152
157
  `Bet Details:`,
153
158
  ` Question: ${bet.question}`,
154
159
  ` Status: ${bet.status}`,
155
160
  ` Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}`,
156
- ` Volume: ${bet.totalVolume ?? 'N/A'}`,
161
+ ` Volume: ${volume} (For: ${formatUsdc(bet.totalOiFor)} / Against: ${formatUsdc(bet.totalOiAgainst)})`,
157
162
  ` Created: ${bet.createdAt}`,
158
163
  ];
159
164
  if (bet.betAddress)
@@ -181,7 +186,12 @@ export const TOOL_DEFINITIONS = {
181
186
  const wagers = await client.getMyWagers({ active });
182
187
  if (wagers.length === 0)
183
188
  return textResult('No wagers found.');
184
- const lines = wagers.map((w, i) => `${i + 1}. Bet: ${w.betAddress} — Option: ${w.optionIndex}, Amount: ${w.amount}, Status: ${w.status}`);
189
+ const lines = wagers.map((w, i) => {
190
+ const bet = w.ProgramBet;
191
+ const betName = bet?.question ?? 'Unknown';
192
+ const betAddr = w.betAddress ?? w.programBetBetAddress ?? '?';
193
+ return `${i + 1}. ${betName} — Side: ${w.outcome}, Amount: ${formatUsdc(w.amount)}, Status: ${w.status}, Address: ${betAddr}`;
194
+ });
185
195
  return textResult(`Your Wagers:\n${lines.join('\n')}`);
186
196
  }
187
197
  catch (err) {
@@ -240,7 +250,7 @@ export const TOOL_DEFINITIONS = {
240
250
  const txns = await client.getWalletTransactions();
241
251
  if (txns.length === 0)
242
252
  return textResult('No transactions found.');
243
- const lines = txns.map((t, i) => `${i + 1}. ${t.type} — Amount: ${t.amount}, Date: ${t.createdAt}`);
253
+ const lines = txns.map((t, i) => `${i + 1}. ${t.type} — Amount: ${formatUsdc(t.amount)}, Date: ${t.createdAt}`);
244
254
  return textResult(`Wallet Transactions:\n${lines.join('\n')}`);
245
255
  }
246
256
  catch (err) {
@@ -324,7 +334,7 @@ export const TOOL_DEFINITIONS = {
324
334
  const bets = await client.getFavouriteBets();
325
335
  if (bets.length === 0)
326
336
  return textResult('No favourite bets found.');
327
- const lines = bets.map((b, i) => `${i + 1}. ${b.question} — Status: ${b.status}, Volume: $${(b.totalOiFor + b.totalOiAgainst).toFixed(2)} (For: $${b.totalOiFor.toFixed(2)} / Against: $${b.totalOiAgainst.toFixed(2)}), Address: ${b.betAddress}`);
337
+ const lines = bets.map((b, i) => `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${formatUsdc(b.totalOiFor + b.totalOiAgainst)} (For: ${formatUsdc(b.totalOiFor)} / Against: ${formatUsdc(b.totalOiAgainst)}), Address: ${b.betAddress}`);
328
338
  return textResult(`Favourite Bets:\n${lines.join('\n')}`);
329
339
  }
330
340
  catch (err) {
@@ -394,7 +404,7 @@ export const TOOL_DEFINITIONS = {
394
404
  amount: args.amount,
395
405
  expiresAt: args.expiresAt,
396
406
  });
397
- return textResult(`Bet created successfully!\n Question: ${bet.question}\n Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}\n Status: ${bet.status}\n ID: ${bet.betAddress}`);
407
+ return textResult(`Bet created successfully!\n Question: ${bet.question}\n Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}\n Status: ${bet.status}\n Address: ${bet.betAddress}`);
398
408
  }
399
409
  catch (err) {
400
410
  return errorResult(err.message);
@@ -450,6 +460,7 @@ export const TOOL_DEFINITIONS = {
450
460
  return errorResult('Missing required parameter: amount');
451
461
  try {
452
462
  const side = optionIndex === 0 ? 'for' : 'against';
463
+ await client.validateWagerSide(betAddress, side);
453
464
  await client.placeWager({ marketPubkey: betAddress, amount, side: side });
454
465
  return textResult(`Wager placed successfully!\n Bet: ${betAddress}\n Option: ${optionIndex} (${side})\n Amount: ${amount}`);
455
466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solworks/poll-mcp",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "MCP server for Poll.fun. See documentation at https://dev.poll.fun",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@modelcontextprotocol/sdk": "^1.12.1",
21
- "@solworks/poll-api-client": "^0.1.6",
21
+ "@solworks/poll-api-client": "file:../poll-api-client",
22
22
  "zod": "^3.24.0"
23
23
  },
24
24
  "devDependencies": {