getBalance
Retrieve your futures account balance to monitor trading capital and manage cryptocurrency positions on the Aster Finance exchange.
Instructions
Get futures account balance.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:661-662 (handler)The handler logic for the 'getBalance' tool. It invokes the shared makeRequest helper to perform a signed GET request to the '/fapi/v2/balance' endpoint to retrieve the futures account balance.case 'getBalance': return makeRequest('GET', '/fapi/v2/balance', args, true);
- src/index.ts:396-396 (registration)Registration of the 'getBalance' tool in the MCP server's list of tools returned by ListToolsRequestSchema. Includes the tool's name, description, and input schema (no required parameters).{ name: 'getBalance', description: 'Get futures account balance.', inputSchema: { type: 'object', properties: {} } },
- src/index.ts:396-396 (schema)Input schema for 'getBalance' tool: an empty object (no parameters required).{ name: 'getBalance', description: 'Get futures account balance.', inputSchema: { type: 'object', properties: {} } },
- src/index.ts:542-579 (helper)Shared helper function 'makeRequest' used by the getBalance handler (and other signed tools) to make authenticated HTTP requests to the Aster Futures API, including HMAC-SHA256 signing using API_SECRET.const makeRequest = async (method: 'GET' | 'POST' | 'DELETE', path: string, params: any, isSigned = false) => { try { let config: any = { method, url: path, }; if (isSigned) { if (!API_KEY || !API_SECRET) { throw new McpError(ErrorCode.InvalidRequest, 'API_KEY and API_SECRET must be configured.'); } params.timestamp = Date.now(); const queryString = new URLSearchParams(params).toString(); const signature = crypto.createHmac('sha256', API_SECRET).update(queryString).digest('hex'); params.signature = signature; config.headers = { 'X-MBX-APIKEY': API_KEY }; } if (method === 'GET' || method === 'DELETE') { config.params = params; } else { // POST config.data = new URLSearchParams(params).toString(); config.headers = { ...config.headers, 'Content-Type': 'application/x-www-form-urlencoded' }; } const response = await this.axiosInstance.request(config); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] }; } catch (error) { if (axios.isAxiosError(error)) { throw new McpError( ErrorCode.InternalError, `Aster API error: ${error.response?.data?.msg || error.message}` ); } throw error; } };