@dimcool/dimclaw 0.1.10 → 0.1.11
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/index.js +187 -20
- package/index.ts +190 -17
- package/openclaw.plugin.json +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55022,10 +55022,12 @@ var Wallet = class {
|
|
|
55022
55022
|
*/
|
|
55023
55023
|
async getBalances() {
|
|
55024
55024
|
try {
|
|
55025
|
-
const
|
|
55026
|
-
|
|
55027
|
-
|
|
55028
|
-
|
|
55025
|
+
const raw = await this.http.get("/wallets/me/balance");
|
|
55026
|
+
const usdcDollars = raw.usdc / 1e6;
|
|
55027
|
+
return {
|
|
55028
|
+
...raw,
|
|
55029
|
+
usdcFormatted: `$${usdcDollars.toFixed(2)}`
|
|
55030
|
+
};
|
|
55029
55031
|
} catch (error) {
|
|
55030
55032
|
this.logger.error("Failed to get balances", {
|
|
55031
55033
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -57444,26 +57446,37 @@ function register(api) {
|
|
|
57444
57446
|
}
|
|
57445
57447
|
api.registerTool({
|
|
57446
57448
|
name: "dim_login",
|
|
57447
|
-
description: "Authenticate with DIM using the configured wallet.
|
|
57449
|
+
description: "Authenticate with DIM using the configured wallet. After login: set a username with dim_set_username, check balance with dim_get_balance, list games with dim_list_games, or apply a referral code with dim_apply_referral_code for a 10% fee discount.",
|
|
57448
57450
|
parameters: { type: "object", properties: {}, additionalProperties: false },
|
|
57449
57451
|
async execute() {
|
|
57450
57452
|
const c = await requireClient();
|
|
57451
57453
|
if ("error" in c) return c.error;
|
|
57452
57454
|
try {
|
|
57453
57455
|
const result = await c.authenticate();
|
|
57454
|
-
const
|
|
57455
|
-
|
|
57456
|
-
|
|
57457
|
-
|
|
57458
|
-
|
|
57459
|
-
}
|
|
57456
|
+
const nextSteps = [];
|
|
57457
|
+
if (result.username == null || result.username === "") {
|
|
57458
|
+
nextSteps.push(
|
|
57459
|
+
"No username set \u2014 call dim_set_username to claim one"
|
|
57460
|
+
);
|
|
57461
|
+
}
|
|
57462
|
+
nextSteps.push("Check your balance with dim_get_balance");
|
|
57463
|
+
nextSteps.push("Explore available games with dim_list_games");
|
|
57460
57464
|
try {
|
|
57461
57465
|
const summary = await c.sdk.referrals.getSummary();
|
|
57462
57466
|
if (!summary.hasReferrer) {
|
|
57463
|
-
|
|
57467
|
+
nextSteps.push(
|
|
57468
|
+
"No referrer yet \u2014 call dim_apply_referral_code for 10% fee discount"
|
|
57469
|
+
);
|
|
57464
57470
|
}
|
|
57465
57471
|
} catch {
|
|
57466
57472
|
}
|
|
57473
|
+
const response = {
|
|
57474
|
+
success: true,
|
|
57475
|
+
userId: result.userId,
|
|
57476
|
+
username: result.username ?? null,
|
|
57477
|
+
walletAddress: c.walletAddress,
|
|
57478
|
+
nextSteps
|
|
57479
|
+
};
|
|
57467
57480
|
return textResult(JSON.stringify(response, null, 2));
|
|
57468
57481
|
} catch (err) {
|
|
57469
57482
|
return textResult(
|
|
@@ -57529,9 +57542,165 @@ function register(api) {
|
|
|
57529
57542
|
}
|
|
57530
57543
|
}
|
|
57531
57544
|
});
|
|
57545
|
+
const DIM_INSTRUCTIONS = [
|
|
57546
|
+
{
|
|
57547
|
+
name: "dim_login",
|
|
57548
|
+
description: "Authenticate with DIM. Call first; then set username, check balance, list games, or apply referral code."
|
|
57549
|
+
},
|
|
57550
|
+
{
|
|
57551
|
+
name: "dim_get_profile",
|
|
57552
|
+
description: "Get current user profile (username, avatar, bio, chess ELO)."
|
|
57553
|
+
},
|
|
57554
|
+
{
|
|
57555
|
+
name: "dim_set_username",
|
|
57556
|
+
description: "Set or update your username (alphanumeric, 3\u201320 chars)."
|
|
57557
|
+
},
|
|
57558
|
+
{
|
|
57559
|
+
name: "dim_list_instructions",
|
|
57560
|
+
description: "List all available DIM tools and short descriptions (this list)."
|
|
57561
|
+
},
|
|
57562
|
+
{
|
|
57563
|
+
name: "dim_get_balance",
|
|
57564
|
+
description: "Get SOL and USDC balance; usdcFormatted is always present (e.g. $0.00)."
|
|
57565
|
+
},
|
|
57566
|
+
{
|
|
57567
|
+
name: "dim_send_usdc",
|
|
57568
|
+
description: "Send USDC to a user by username or address. 1\xA2 fee; amount in dollars."
|
|
57569
|
+
},
|
|
57570
|
+
{
|
|
57571
|
+
name: "dim_tip_user",
|
|
57572
|
+
description: "Tip a user with USDC; broadcast to global chat. 1\xA2 fee."
|
|
57573
|
+
},
|
|
57574
|
+
{
|
|
57575
|
+
name: "dim_get_wallet_activity",
|
|
57576
|
+
description: "Get recent wallet activity (deposits, payouts, transfers)."
|
|
57577
|
+
},
|
|
57578
|
+
{ name: "dim_search_users", description: "Search users by username." },
|
|
57579
|
+
{
|
|
57580
|
+
name: "dim_send_friend_request",
|
|
57581
|
+
description: "Send friend request by user ID."
|
|
57582
|
+
},
|
|
57583
|
+
{
|
|
57584
|
+
name: "dim_accept_friend_request",
|
|
57585
|
+
description: "Accept an incoming friend request."
|
|
57586
|
+
},
|
|
57587
|
+
{
|
|
57588
|
+
name: "dim_list_friends",
|
|
57589
|
+
description: "List your friends with pagination."
|
|
57590
|
+
},
|
|
57591
|
+
{
|
|
57592
|
+
name: "dim_get_incoming_friend_requests",
|
|
57593
|
+
description: "List pending incoming friend requests."
|
|
57594
|
+
},
|
|
57595
|
+
{
|
|
57596
|
+
name: "dim_send_message",
|
|
57597
|
+
description: "Send chat in a context (lobby, game, dm, global)."
|
|
57598
|
+
},
|
|
57599
|
+
{
|
|
57600
|
+
name: "dim_get_chat_history",
|
|
57601
|
+
description: "Get chat history for a context."
|
|
57602
|
+
},
|
|
57603
|
+
{
|
|
57604
|
+
name: "dim_send_dm",
|
|
57605
|
+
description: "Send a direct message to a user by ID."
|
|
57606
|
+
},
|
|
57607
|
+
{
|
|
57608
|
+
name: "dim_list_dm_threads",
|
|
57609
|
+
description: "List DM threads with last message and unread counts."
|
|
57610
|
+
},
|
|
57611
|
+
{
|
|
57612
|
+
name: "dim_list_games",
|
|
57613
|
+
description: "List available game types (RPS, Chess, Tic-Tac-Toe, etc.)."
|
|
57614
|
+
},
|
|
57615
|
+
{
|
|
57616
|
+
name: "dim_get_game_metrics",
|
|
57617
|
+
description: "Get real-time metrics: active players, live games, money in play."
|
|
57618
|
+
},
|
|
57619
|
+
{
|
|
57620
|
+
name: "dim_create_lobby",
|
|
57621
|
+
description: "Create a game lobby; bet in USDC minor units."
|
|
57622
|
+
},
|
|
57623
|
+
{
|
|
57624
|
+
name: "dim_join_queue",
|
|
57625
|
+
description: "Join matchmaking queue for a game type."
|
|
57626
|
+
},
|
|
57627
|
+
{ name: "dim_get_lobby", description: "Get lobby details by ID." },
|
|
57628
|
+
{
|
|
57629
|
+
name: "dim_get_game_state",
|
|
57630
|
+
description: "Get current state of a game (for submitting moves)."
|
|
57631
|
+
},
|
|
57632
|
+
{
|
|
57633
|
+
name: "dim_submit_action",
|
|
57634
|
+
description: "Submit a move/action in a game."
|
|
57635
|
+
},
|
|
57636
|
+
{ name: "dim_donate_to_pot", description: "Add to the pot in a lobby." },
|
|
57637
|
+
{ name: "dim_get_game", description: "Get game summary by ID." },
|
|
57638
|
+
{
|
|
57639
|
+
name: "dim_challenge_user",
|
|
57640
|
+
description: "Challenge another user to a game."
|
|
57641
|
+
},
|
|
57642
|
+
{ name: "dim_accept_challenge", description: "Accept a game challenge." },
|
|
57643
|
+
{
|
|
57644
|
+
name: "dim_get_referral_summary",
|
|
57645
|
+
description: "Get your referral stats and rewards."
|
|
57646
|
+
},
|
|
57647
|
+
{ name: "dim_get_referral_tree", description: "Get your referral tree." },
|
|
57648
|
+
{
|
|
57649
|
+
name: "dim_get_referral_rewards",
|
|
57650
|
+
description: "Get claimable referral rewards."
|
|
57651
|
+
},
|
|
57652
|
+
{
|
|
57653
|
+
name: "dim_claim_referral_rewards",
|
|
57654
|
+
description: "Claim referral rewards to your wallet."
|
|
57655
|
+
},
|
|
57656
|
+
{
|
|
57657
|
+
name: "dim_apply_referral_code",
|
|
57658
|
+
description: "Apply a referral code for 10% fee discount."
|
|
57659
|
+
},
|
|
57660
|
+
{
|
|
57661
|
+
name: "dim_create_support_ticket",
|
|
57662
|
+
description: "Create a support ticket."
|
|
57663
|
+
},
|
|
57664
|
+
{ name: "dim_get_my_tickets", description: "List your support tickets." },
|
|
57665
|
+
{ name: "dim_get_ticket", description: "Get a ticket by ID." },
|
|
57666
|
+
{
|
|
57667
|
+
name: "dim_add_ticket_message",
|
|
57668
|
+
description: "Add a message to a ticket."
|
|
57669
|
+
},
|
|
57670
|
+
{ name: "dim_close_ticket", description: "Close a support ticket." },
|
|
57671
|
+
{
|
|
57672
|
+
name: "dim_get_market",
|
|
57673
|
+
description: "Get prediction market for a game."
|
|
57674
|
+
},
|
|
57675
|
+
{ name: "dim_buy_shares", description: "Buy prediction market shares." },
|
|
57676
|
+
{ name: "dim_sell_shares", description: "Sell prediction market shares." },
|
|
57677
|
+
{ name: "dim_get_positions", description: "Get your market positions." },
|
|
57678
|
+
{
|
|
57679
|
+
name: "dim_redeem_shares",
|
|
57680
|
+
description: "Redeem shares after market resolution."
|
|
57681
|
+
},
|
|
57682
|
+
{ name: "dim_get_market_analytics", description: "Get market analytics." }
|
|
57683
|
+
];
|
|
57684
|
+
api.registerTool({
|
|
57685
|
+
name: "dim_list_instructions",
|
|
57686
|
+
description: "List all available DIM tools (instructions) with short descriptions. Use this to discover what you can do after dim_login.",
|
|
57687
|
+
parameters: { type: "object", properties: {}, additionalProperties: false },
|
|
57688
|
+
async execute() {
|
|
57689
|
+
return textResult(
|
|
57690
|
+
JSON.stringify(
|
|
57691
|
+
{
|
|
57692
|
+
instructions: DIM_INSTRUCTIONS,
|
|
57693
|
+
hint: "Call dim_login first if you have not authenticated. Then use any tool above by name."
|
|
57694
|
+
},
|
|
57695
|
+
null,
|
|
57696
|
+
2
|
|
57697
|
+
)
|
|
57698
|
+
);
|
|
57699
|
+
}
|
|
57700
|
+
});
|
|
57532
57701
|
api.registerTool({
|
|
57533
57702
|
name: "dim_get_balance",
|
|
57534
|
-
description: "Get the wallet balance for the authenticated user. Returns SOL and USDC
|
|
57703
|
+
description: "Get the wallet balance for the authenticated user. Returns SOL and USDC (usdc in minor units; usdcFormatted is always present, e.g. $0.00 or $1.50, so you do not need to convert).",
|
|
57535
57704
|
parameters: { type: "object", properties: {}, additionalProperties: false },
|
|
57536
57705
|
async execute() {
|
|
57537
57706
|
const c = await requireClient();
|
|
@@ -57539,13 +57708,11 @@ function register(api) {
|
|
|
57539
57708
|
try {
|
|
57540
57709
|
const balance = await c.sdk.wallet.getBalances();
|
|
57541
57710
|
const usdcDollars = balance.usdc / 1e6;
|
|
57542
|
-
|
|
57543
|
-
|
|
57544
|
-
|
|
57545
|
-
|
|
57546
|
-
|
|
57547
|
-
)
|
|
57548
|
-
);
|
|
57711
|
+
const payload = {
|
|
57712
|
+
...balance,
|
|
57713
|
+
usdcFormatted: `$${usdcDollars.toFixed(2)}`
|
|
57714
|
+
};
|
|
57715
|
+
return textResult(JSON.stringify(payload, null, 2));
|
|
57549
57716
|
} catch (err) {
|
|
57550
57717
|
return textResult(
|
|
57551
57718
|
`Failed to get balance: ${err instanceof Error ? err.message : String(err)}`,
|
package/index.ts
CHANGED
|
@@ -149,28 +149,38 @@ export default function register(api: {
|
|
|
149
149
|
api.registerTool({
|
|
150
150
|
name: 'dim_login',
|
|
151
151
|
description:
|
|
152
|
-
'Authenticate with DIM using the configured wallet.
|
|
152
|
+
'Authenticate with DIM using the configured wallet. After login: set a username with dim_set_username, check balance with dim_get_balance, list games with dim_list_games, or apply a referral code with dim_apply_referral_code for a 10% fee discount.',
|
|
153
153
|
parameters: { type: 'object', properties: {}, additionalProperties: false },
|
|
154
154
|
async execute() {
|
|
155
155
|
const c = await requireClient();
|
|
156
156
|
if ('error' in c) return c.error;
|
|
157
157
|
try {
|
|
158
158
|
const result = await c.authenticate();
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
159
|
+
const nextSteps: string[] = [];
|
|
160
|
+
if (result.username == null || result.username === '') {
|
|
161
|
+
nextSteps.push(
|
|
162
|
+
'No username set — call dim_set_username to claim one',
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
nextSteps.push('Check your balance with dim_get_balance');
|
|
166
|
+
nextSteps.push('Explore available games with dim_list_games');
|
|
165
167
|
try {
|
|
166
168
|
const summary = await c.sdk.referrals.getSummary();
|
|
167
169
|
if (!summary.hasReferrer) {
|
|
168
|
-
|
|
169
|
-
'
|
|
170
|
+
nextSteps.push(
|
|
171
|
+
'No referrer yet — call dim_apply_referral_code for 10% fee discount',
|
|
172
|
+
);
|
|
170
173
|
}
|
|
171
174
|
} catch {
|
|
172
175
|
/* non-critical */
|
|
173
176
|
}
|
|
177
|
+
const response: Record<string, unknown> = {
|
|
178
|
+
success: true,
|
|
179
|
+
userId: result.userId,
|
|
180
|
+
username: result.username ?? null,
|
|
181
|
+
walletAddress: c.walletAddress,
|
|
182
|
+
nextSteps,
|
|
183
|
+
};
|
|
174
184
|
return textResult(JSON.stringify(response, null, 2));
|
|
175
185
|
} catch (err) {
|
|
176
186
|
return textResult(
|
|
@@ -242,11 +252,176 @@ export default function register(api: {
|
|
|
242
252
|
},
|
|
243
253
|
});
|
|
244
254
|
|
|
255
|
+
// --- Instructions (discovery) ---
|
|
256
|
+
const DIM_INSTRUCTIONS = [
|
|
257
|
+
{
|
|
258
|
+
name: 'dim_login',
|
|
259
|
+
description:
|
|
260
|
+
'Authenticate with DIM. Call first; then set username, check balance, list games, or apply referral code.',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'dim_get_profile',
|
|
264
|
+
description:
|
|
265
|
+
'Get current user profile (username, avatar, bio, chess ELO).',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'dim_set_username',
|
|
269
|
+
description: 'Set or update your username (alphanumeric, 3–20 chars).',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: 'dim_list_instructions',
|
|
273
|
+
description:
|
|
274
|
+
'List all available DIM tools and short descriptions (this list).',
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: 'dim_get_balance',
|
|
278
|
+
description:
|
|
279
|
+
'Get SOL and USDC balance; usdcFormatted is always present (e.g. $0.00).',
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: 'dim_send_usdc',
|
|
283
|
+
description:
|
|
284
|
+
'Send USDC to a user by username or address. 1¢ fee; amount in dollars.',
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
name: 'dim_tip_user',
|
|
288
|
+
description: 'Tip a user with USDC; broadcast to global chat. 1¢ fee.',
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: 'dim_get_wallet_activity',
|
|
292
|
+
description: 'Get recent wallet activity (deposits, payouts, transfers).',
|
|
293
|
+
},
|
|
294
|
+
{ name: 'dim_search_users', description: 'Search users by username.' },
|
|
295
|
+
{
|
|
296
|
+
name: 'dim_send_friend_request',
|
|
297
|
+
description: 'Send friend request by user ID.',
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'dim_accept_friend_request',
|
|
301
|
+
description: 'Accept an incoming friend request.',
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
name: 'dim_list_friends',
|
|
305
|
+
description: 'List your friends with pagination.',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: 'dim_get_incoming_friend_requests',
|
|
309
|
+
description: 'List pending incoming friend requests.',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'dim_send_message',
|
|
313
|
+
description: 'Send chat in a context (lobby, game, dm, global).',
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
name: 'dim_get_chat_history',
|
|
317
|
+
description: 'Get chat history for a context.',
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: 'dim_send_dm',
|
|
321
|
+
description: 'Send a direct message to a user by ID.',
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: 'dim_list_dm_threads',
|
|
325
|
+
description: 'List DM threads with last message and unread counts.',
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'dim_list_games',
|
|
329
|
+
description: 'List available game types (RPS, Chess, Tic-Tac-Toe, etc.).',
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: 'dim_get_game_metrics',
|
|
333
|
+
description:
|
|
334
|
+
'Get real-time metrics: active players, live games, money in play.',
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: 'dim_create_lobby',
|
|
338
|
+
description: 'Create a game lobby; bet in USDC minor units.',
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: 'dim_join_queue',
|
|
342
|
+
description: 'Join matchmaking queue for a game type.',
|
|
343
|
+
},
|
|
344
|
+
{ name: 'dim_get_lobby', description: 'Get lobby details by ID.' },
|
|
345
|
+
{
|
|
346
|
+
name: 'dim_get_game_state',
|
|
347
|
+
description: 'Get current state of a game (for submitting moves).',
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: 'dim_submit_action',
|
|
351
|
+
description: 'Submit a move/action in a game.',
|
|
352
|
+
},
|
|
353
|
+
{ name: 'dim_donate_to_pot', description: 'Add to the pot in a lobby.' },
|
|
354
|
+
{ name: 'dim_get_game', description: 'Get game summary by ID.' },
|
|
355
|
+
{
|
|
356
|
+
name: 'dim_challenge_user',
|
|
357
|
+
description: 'Challenge another user to a game.',
|
|
358
|
+
},
|
|
359
|
+
{ name: 'dim_accept_challenge', description: 'Accept a game challenge.' },
|
|
360
|
+
{
|
|
361
|
+
name: 'dim_get_referral_summary',
|
|
362
|
+
description: 'Get your referral stats and rewards.',
|
|
363
|
+
},
|
|
364
|
+
{ name: 'dim_get_referral_tree', description: 'Get your referral tree.' },
|
|
365
|
+
{
|
|
366
|
+
name: 'dim_get_referral_rewards',
|
|
367
|
+
description: 'Get claimable referral rewards.',
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: 'dim_claim_referral_rewards',
|
|
371
|
+
description: 'Claim referral rewards to your wallet.',
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: 'dim_apply_referral_code',
|
|
375
|
+
description: 'Apply a referral code for 10% fee discount.',
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: 'dim_create_support_ticket',
|
|
379
|
+
description: 'Create a support ticket.',
|
|
380
|
+
},
|
|
381
|
+
{ name: 'dim_get_my_tickets', description: 'List your support tickets.' },
|
|
382
|
+
{ name: 'dim_get_ticket', description: 'Get a ticket by ID.' },
|
|
383
|
+
{
|
|
384
|
+
name: 'dim_add_ticket_message',
|
|
385
|
+
description: 'Add a message to a ticket.',
|
|
386
|
+
},
|
|
387
|
+
{ name: 'dim_close_ticket', description: 'Close a support ticket.' },
|
|
388
|
+
{
|
|
389
|
+
name: 'dim_get_market',
|
|
390
|
+
description: 'Get prediction market for a game.',
|
|
391
|
+
},
|
|
392
|
+
{ name: 'dim_buy_shares', description: 'Buy prediction market shares.' },
|
|
393
|
+
{ name: 'dim_sell_shares', description: 'Sell prediction market shares.' },
|
|
394
|
+
{ name: 'dim_get_positions', description: 'Get your market positions.' },
|
|
395
|
+
{
|
|
396
|
+
name: 'dim_redeem_shares',
|
|
397
|
+
description: 'Redeem shares after market resolution.',
|
|
398
|
+
},
|
|
399
|
+
{ name: 'dim_get_market_analytics', description: 'Get market analytics.' },
|
|
400
|
+
];
|
|
401
|
+
api.registerTool({
|
|
402
|
+
name: 'dim_list_instructions',
|
|
403
|
+
description:
|
|
404
|
+
'List all available DIM tools (instructions) with short descriptions. Use this to discover what you can do after dim_login.',
|
|
405
|
+
parameters: { type: 'object', properties: {}, additionalProperties: false },
|
|
406
|
+
async execute() {
|
|
407
|
+
return textResult(
|
|
408
|
+
JSON.stringify(
|
|
409
|
+
{
|
|
410
|
+
instructions: DIM_INSTRUCTIONS,
|
|
411
|
+
hint: 'Call dim_login first if you have not authenticated. Then use any tool above by name.',
|
|
412
|
+
},
|
|
413
|
+
null,
|
|
414
|
+
2,
|
|
415
|
+
),
|
|
416
|
+
);
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
|
|
245
420
|
// --- Wallet ---
|
|
246
421
|
api.registerTool({
|
|
247
422
|
name: 'dim_get_balance',
|
|
248
423
|
description:
|
|
249
|
-
'Get the wallet balance for the authenticated user. Returns SOL and USDC
|
|
424
|
+
'Get the wallet balance for the authenticated user. Returns SOL and USDC (usdc in minor units; usdcFormatted is always present, e.g. $0.00 or $1.50, so you do not need to convert).',
|
|
250
425
|
parameters: { type: 'object', properties: {}, additionalProperties: false },
|
|
251
426
|
async execute() {
|
|
252
427
|
const c = await requireClient();
|
|
@@ -254,13 +429,11 @@ export default function register(api: {
|
|
|
254
429
|
try {
|
|
255
430
|
const balance = await c.sdk.wallet.getBalances();
|
|
256
431
|
const usdcDollars = balance.usdc / 1_000_000;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
),
|
|
263
|
-
);
|
|
432
|
+
const payload = {
|
|
433
|
+
...balance,
|
|
434
|
+
usdcFormatted: `$${usdcDollars.toFixed(2)}`,
|
|
435
|
+
};
|
|
436
|
+
return textResult(JSON.stringify(payload, null, 2));
|
|
264
437
|
} catch (err) {
|
|
265
438
|
return textResult(
|
|
266
439
|
`Failed to get balance: ${err instanceof Error ? err.message : String(err)}`,
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED