Skip to content

Commit 6ec1984

Browse files
alsk1992claude
andcommitted
Add credential setup tools for all trading platforms (Binance, Bybit, Hyperliquid, MEXC, Betfair)
Users can now send their API keys via chat and the bot stores them encrypted. Added proper TypeScript interfaces for each platform's credentials. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fdd54c8 commit 6ec1984

File tree

6 files changed

+174
-7
lines changed

6 files changed

+174
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clodds",
3-
"version": "1.7.4",
3+
"version": "1.7.5",
44
"description": "Open-source AI trading terminal. Trade Polymarket, Kalshi, Betfair, Binance, Bybit, Hyperliquid, Solana DEXs from Telegram, Discord, Slack or web. Arbitrage detection, whale tracking, copy trading, perpetual futures up to 200x, DeFi swaps, MEV protection. Self-hosted, 119 skills, powered by Claude.",
55
"main": "dist/index.js",
66
"bin": {

src/agents/index.ts

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7499,6 +7499,66 @@ function buildTools(): ToolDefinition[] {
74997499
required: ['api_key'],
75007500
},
75017501
},
7502+
{
7503+
name: 'setup_binance_credentials',
7504+
description: 'Set up Binance Futures trading credentials. Required before trading futures on Binance.',
7505+
input_schema: {
7506+
type: 'object',
7507+
properties: {
7508+
api_key: { type: 'string', description: 'Binance API key' },
7509+
api_secret: { type: 'string', description: 'Binance API secret' },
7510+
},
7511+
required: ['api_key', 'api_secret'],
7512+
},
7513+
},
7514+
{
7515+
name: 'setup_bybit_credentials',
7516+
description: 'Set up Bybit Futures trading credentials. Required before trading futures on Bybit.',
7517+
input_schema: {
7518+
type: 'object',
7519+
properties: {
7520+
api_key: { type: 'string', description: 'Bybit API key' },
7521+
api_secret: { type: 'string', description: 'Bybit API secret' },
7522+
},
7523+
required: ['api_key', 'api_secret'],
7524+
},
7525+
},
7526+
{
7527+
name: 'setup_hyperliquid_credentials',
7528+
description: 'Set up Hyperliquid trading credentials. Required before trading on Hyperliquid.',
7529+
input_schema: {
7530+
type: 'object',
7531+
properties: {
7532+
private_key: { type: 'string', description: 'Ethereum private key (0x...) for signing' },
7533+
wallet_address: { type: 'string', description: 'Wallet address (0x...)' },
7534+
},
7535+
required: ['private_key'],
7536+
},
7537+
},
7538+
{
7539+
name: 'setup_mexc_credentials',
7540+
description: 'Set up MEXC Futures trading credentials. Required before trading futures on MEXC.',
7541+
input_schema: {
7542+
type: 'object',
7543+
properties: {
7544+
api_key: { type: 'string', description: 'MEXC API key' },
7545+
api_secret: { type: 'string', description: 'MEXC API secret' },
7546+
},
7547+
required: ['api_key', 'api_secret'],
7548+
},
7549+
},
7550+
{
7551+
name: 'setup_betfair_credentials',
7552+
description: 'Set up Betfair trading credentials. Required before trading on Betfair.',
7553+
input_schema: {
7554+
type: 'object',
7555+
properties: {
7556+
app_key: { type: 'string', description: 'Betfair application key' },
7557+
session_token: { type: 'string', description: 'Betfair session token (SSOID)' },
7558+
},
7559+
required: ['app_key', 'session_token'],
7560+
},
7561+
},
75027562
{
75037563
name: 'list_trading_credentials',
75047564
description: 'List which platforms the user has trading credentials set up for',
@@ -7516,7 +7576,7 @@ function buildTools(): ToolDefinition[] {
75167576
platform: {
75177577
type: 'string',
75187578
description: 'Platform to delete credentials for',
7519-
enum: ['polymarket', 'kalshi', 'manifold'],
7579+
enum: ['polymarket', 'kalshi', 'manifold', 'binance', 'bybit', 'hyperliquid', 'mexc', 'betfair'],
75207580
},
75217581
},
75227582
required: ['platform'],
@@ -9794,6 +9854,61 @@ async function executeTool(
97949854
});
97959855
}
97969856

9857+
case 'setup_binance_credentials': {
9858+
await context.credentials.setCredentials(userId, 'binance', {
9859+
apiKey: toolInput.api_key as string,
9860+
apiSecret: toolInput.api_secret as string,
9861+
});
9862+
return JSON.stringify({
9863+
result: 'Binance credentials saved! You can now trade futures on Binance.',
9864+
security_notice: 'Your credentials are encrypted with AES-256-GCM. Use IP-restricted API keys for maximum security.',
9865+
});
9866+
}
9867+
9868+
case 'setup_bybit_credentials': {
9869+
await context.credentials.setCredentials(userId, 'bybit', {
9870+
apiKey: toolInput.api_key as string,
9871+
apiSecret: toolInput.api_secret as string,
9872+
});
9873+
return JSON.stringify({
9874+
result: 'Bybit credentials saved! You can now trade futures on Bybit.',
9875+
security_notice: 'Your credentials are encrypted with AES-256-GCM. Use IP-restricted API keys for maximum security.',
9876+
});
9877+
}
9878+
9879+
case 'setup_hyperliquid_credentials': {
9880+
await context.credentials.setCredentials(userId, 'hyperliquid', {
9881+
privateKey: toolInput.private_key as string,
9882+
walletAddress: (toolInput.wallet_address as string) || '',
9883+
});
9884+
return JSON.stringify({
9885+
result: 'Hyperliquid credentials saved! You can now trade on Hyperliquid.',
9886+
security_notice: 'Your private key is encrypted with AES-256-GCM. Consider using a dedicated trading wallet.',
9887+
});
9888+
}
9889+
9890+
case 'setup_mexc_credentials': {
9891+
await context.credentials.setCredentials(userId, 'mexc', {
9892+
apiKey: toolInput.api_key as string,
9893+
apiSecret: toolInput.api_secret as string,
9894+
});
9895+
return JSON.stringify({
9896+
result: 'MEXC credentials saved! You can now trade futures on MEXC.',
9897+
security_notice: 'Your credentials are encrypted with AES-256-GCM. Use IP-restricted API keys for maximum security.',
9898+
});
9899+
}
9900+
9901+
case 'setup_betfair_credentials': {
9902+
await context.credentials.setCredentials(userId, 'betfair', {
9903+
appKey: toolInput.app_key as string,
9904+
sessionToken: toolInput.session_token as string,
9905+
});
9906+
return JSON.stringify({
9907+
result: 'Betfair credentials saved! You can now trade on Betfair.',
9908+
security_notice: 'Your credentials are encrypted with AES-256-GCM. Session tokens expire — you may need to refresh periodically.',
9909+
});
9910+
}
9911+
97979912
case 'list_trading_credentials': {
97989913
const platforms = await context.credentials.listUserPlatforms(userId);
97999914

src/agents/tool-registry.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,15 @@ export const CORE_TOOL_NAMES = new Set([
466466
'save_session_checkpoint',
467467
'restore_session_checkpoint',
468468

469-
// Credentials (3) — always available so bot can onboard users naturally
469+
// Credentials (10) — always available so bot can onboard users naturally
470470
'setup_polymarket_credentials',
471+
'setup_kalshi_credentials',
472+
'setup_manifold_credentials',
473+
'setup_binance_credentials',
474+
'setup_bybit_credentials',
475+
'setup_hyperliquid_credentials',
476+
'setup_mexc_credentials',
477+
'setup_betfair_credentials',
471478
'list_trading_credentials',
472479
'delete_trading_credentials',
473480

src/credentials/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ import {
1717
PolymarketCredentials,
1818
KalshiCredentials,
1919
ManifoldCredentials,
20+
BinanceCredentials,
21+
BybitCredentials,
22+
HyperliquidCredentials,
23+
MexcCredentials,
24+
BetfairCredentials,
2025
} from '../types.js';
2126
import { Database } from '../db/index.js';
2227
import { logger } from '../utils/logger.js';
@@ -103,7 +108,7 @@ export interface CredentialsManager {
103108
setCredentials: (
104109
userId: string,
105110
platform: Platform,
106-
credentials: PolymarketCredentials | KalshiCredentials | ManifoldCredentials
111+
credentials: PolymarketCredentials | KalshiCredentials | ManifoldCredentials | BinanceCredentials | BybitCredentials | HyperliquidCredentials | MexcCredentials | BetfairCredentials
107112
) => Promise<void>;
108113

109114
/**

src/types.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,42 @@ export interface ManifoldCredentials {
285285
apiKey: string;
286286
}
287287

288+
/**
289+
* Binance credentials (decrypted form)
290+
*/
291+
export interface BinanceCredentials {
292+
apiKey: string;
293+
apiSecret: string;
294+
testnet?: boolean;
295+
}
296+
297+
/**
298+
* Bybit credentials (decrypted form)
299+
*/
300+
export interface BybitCredentials {
301+
apiKey: string;
302+
apiSecret: string;
303+
testnet?: boolean;
304+
}
305+
306+
/**
307+
* Hyperliquid credentials (decrypted form)
308+
*/
309+
export interface HyperliquidCredentials {
310+
privateKey: string;
311+
walletAddress?: string;
312+
vaultAddress?: string;
313+
testnet?: boolean;
314+
}
315+
316+
/**
317+
* MEXC credentials (decrypted form)
318+
*/
319+
export interface MexcCredentials {
320+
apiKey: string;
321+
apiSecret: string;
322+
}
323+
288324
/**
289325
* Betfair credentials (decrypted form)
290326
*/
@@ -358,6 +394,10 @@ export type PlatformCredentials =
358394
| { platform: 'polymarket'; data: PolymarketCredentials }
359395
| { platform: 'kalshi'; data: KalshiCredentials }
360396
| { platform: 'manifold'; data: ManifoldCredentials }
397+
| { platform: 'binance'; data: BinanceCredentials }
398+
| { platform: 'bybit'; data: BybitCredentials }
399+
| { platform: 'hyperliquid'; data: HyperliquidCredentials }
400+
| { platform: 'mexc'; data: MexcCredentials }
361401
| { platform: 'betfair'; data: BetfairCredentials }
362402
| { platform: 'drift'; data: DriftCredentials }
363403
| { platform: 'smarkets'; data: SmarketsCredentials }
@@ -551,7 +591,7 @@ export interface CredentialsManager {
551591
setCredentials: (
552592
userId: string,
553593
platform: Platform,
554-
credentials: PolymarketCredentials | KalshiCredentials | ManifoldCredentials
594+
credentials: PolymarketCredentials | KalshiCredentials | ManifoldCredentials | BinanceCredentials | BybitCredentials | HyperliquidCredentials | MexcCredentials | BetfairCredentials
555595
) => Promise<void>;
556596
getCredentials: <T>(userId: string, platform: Platform) => Promise<T | null>;
557597
hasCredentials: (userId: string, platform: Platform) => Promise<boolean>;

0 commit comments

Comments
 (0)