@solworks/poll-mcp 0.1.13 → 0.1.14
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/dist/tools/index.js +13 -9
- package/package.json +1 -1
package/dist/tools/index.js
CHANGED
|
@@ -5,9 +5,13 @@ function textResult(text) {
|
|
|
5
5
|
return { content: [{ type: 'text', text }] };
|
|
6
6
|
}
|
|
7
7
|
/** Format a raw USDC micro-unit amount (6 decimals) as a human-readable dollar string. */
|
|
8
|
-
function
|
|
8
|
+
function formatUsdcRaw(raw) {
|
|
9
9
|
return `$${(raw / 1e6).toFixed(2)}`;
|
|
10
10
|
}
|
|
11
|
+
/** Format a USDC amount that is already in human units (i.e. already divided by 1e6). */
|
|
12
|
+
function formatUsd(value) {
|
|
13
|
+
return `$${value.toFixed(2)}`;
|
|
14
|
+
}
|
|
11
15
|
export const TOOL_DEFINITIONS = {
|
|
12
16
|
// ── Read tools (scope: read) ───────────────────────────────────────
|
|
13
17
|
get_account: {
|
|
@@ -97,9 +101,9 @@ export const TOOL_DEFINITIONS = {
|
|
|
97
101
|
const bets = await client.listPublicBets({ page });
|
|
98
102
|
const display = bets.slice(0, 20);
|
|
99
103
|
const lines = display.map((b, i) => {
|
|
100
|
-
const volume =
|
|
104
|
+
const volume = formatUsd(b.totalOiFor + b.totalOiAgainst);
|
|
101
105
|
const participants = Array.isArray(b.wagers) ? b.wagers.length : 0;
|
|
102
|
-
return `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${volume} (For: ${
|
|
106
|
+
return `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${volume} (For: ${formatUsd(b.totalOiFor)} / Against: ${formatUsd(b.totalOiAgainst)}), Participants: ${participants}, Address: ${b.betAddress}`;
|
|
103
107
|
});
|
|
104
108
|
let text = `Public Bets:\n${lines.join('\n')}`;
|
|
105
109
|
if (bets.length > 20)
|
|
@@ -122,7 +126,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
122
126
|
try {
|
|
123
127
|
const bets = await client.getTrendingBets();
|
|
124
128
|
const display = bets.slice(0, 20);
|
|
125
|
-
const lines = display.map((b, i) => `${i + 1}. ${b.question} — Volume: ${
|
|
129
|
+
const lines = display.map((b, i) => `${i + 1}. ${b.question} — Volume: ${formatUsd(b.totalOiFor + b.totalOiAgainst)} (For: ${formatUsd(b.totalOiFor)} / Against: ${formatUsd(b.totalOiAgainst)}), Address: ${b.betAddress}`);
|
|
126
130
|
let text = `Trending Bets:\n${lines.join('\n')}`;
|
|
127
131
|
if (bets.length > 20)
|
|
128
132
|
text += `\n\n(Showing 20 of ${bets.length})`;
|
|
@@ -152,13 +156,13 @@ export const TOOL_DEFINITIONS = {
|
|
|
152
156
|
return errorResult('Missing required parameter: id');
|
|
153
157
|
try {
|
|
154
158
|
const bet = await client.getBet(id);
|
|
155
|
-
const volume =
|
|
159
|
+
const volume = formatUsd(bet.totalOiFor + bet.totalOiAgainst);
|
|
156
160
|
const lines = [
|
|
157
161
|
`Bet Details:`,
|
|
158
162
|
` Question: ${bet.question}`,
|
|
159
163
|
` Status: ${bet.status}`,
|
|
160
164
|
` Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}`,
|
|
161
|
-
` Volume: ${volume} (For: ${
|
|
165
|
+
` Volume: ${volume} (For: ${formatUsd(bet.totalOiFor)} / Against: ${formatUsd(bet.totalOiAgainst)})`,
|
|
162
166
|
` Created: ${bet.createdAt}`,
|
|
163
167
|
];
|
|
164
168
|
if (bet.betAddress)
|
|
@@ -190,7 +194,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
190
194
|
const bet = w.ProgramBet;
|
|
191
195
|
const betName = bet?.question ?? 'Unknown';
|
|
192
196
|
const betAddr = w.betAddress ?? w.programBetBetAddress ?? '?';
|
|
193
|
-
return `${i + 1}. ${betName} — Side: ${w.outcome}, Amount: ${
|
|
197
|
+
return `${i + 1}. ${betName} — Side: ${w.outcome}, Amount: ${formatUsdcRaw(w.amount)}, Status: ${w.status}, Address: ${betAddr}`;
|
|
194
198
|
});
|
|
195
199
|
return textResult(`Your Wagers:\n${lines.join('\n')}`);
|
|
196
200
|
}
|
|
@@ -250,7 +254,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
250
254
|
const txns = await client.getWalletTransactions();
|
|
251
255
|
if (txns.length === 0)
|
|
252
256
|
return textResult('No transactions found.');
|
|
253
|
-
const lines = txns.map((t, i) => `${i + 1}. ${t.type} — Amount: ${
|
|
257
|
+
const lines = txns.map((t, i) => `${i + 1}. ${t.type} — Amount: ${formatUsd(t.amount)}, Date: ${t.createdAt}`);
|
|
254
258
|
return textResult(`Wallet Transactions:\n${lines.join('\n')}`);
|
|
255
259
|
}
|
|
256
260
|
catch (err) {
|
|
@@ -334,7 +338,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
334
338
|
const bets = await client.getFavouriteBets();
|
|
335
339
|
if (bets.length === 0)
|
|
336
340
|
return textResult('No favourite bets found.');
|
|
337
|
-
const lines = bets.map((b, i) => `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${
|
|
341
|
+
const lines = bets.map((b, i) => `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${formatUsd(b.totalOiFor + b.totalOiAgainst)} (For: ${formatUsd(b.totalOiFor)} / Against: ${formatUsd(b.totalOiAgainst)}), Address: ${b.betAddress}`);
|
|
338
342
|
return textResult(`Favourite Bets:\n${lines.join('\n')}`);
|
|
339
343
|
}
|
|
340
344
|
catch (err) {
|