get-leverage-tiers
Retrieve futures leverage tiers for specific trading pairs on cryptocurrency exchanges. Define exchange, symbol, and market type to access precise leverage data for informed trading decisions.
Instructions
Get futures leverage tiers for trading pairs
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchange | Yes | Exchange ID (e.g., binance, bybit) | |
| marketType | No | Market type (default: future) | future |
| symbol | No | Trading pair symbol (optional, e.g., BTC/USDT) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"exchange": {
"description": "Exchange ID (e.g., binance, bybit)",
"type": "string"
},
"marketType": {
"default": "future",
"description": "Market type (default: future)",
"enum": [
"future",
"swap"
],
"type": "string"
},
"symbol": {
"description": "Trading pair symbol (optional, e.g., BTC/USDT)",
"type": "string"
}
},
"required": [
"exchange"
],
"type": "object"
}
Implementation Reference
- src/tools/public.ts:304-337 (handler)The handler function that implements the core logic of the 'get-leverage-tiers' tool. It fetches leverage tiers for futures/swap markets using the exchange API, with caching and rate limiting.}, async ({ exchange, symbol, marketType }) => { try { return await rateLimiter.execute(exchange, async () => { // Get futures exchange const ex = getExchangeWithMarketType(exchange, marketType); const cacheKey = `leverage_tiers:${exchange}:${marketType}:${symbol || 'all'}`; const tiers = await getCachedData(cacheKey, async () => { log(LogLevel.INFO, `Fetching leverage tiers for ${symbol || 'all symbols'} on ${exchange} (${marketType})`); if (symbol) { return await ex.fetchMarketLeverageTiers(symbol); } else { return await ex.fetchLeverageTiers(); } }, 3600000); // Cache for 1 hour return { content: [{ type: "text", text: JSON.stringify(tiers, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error fetching leverage tiers: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });
- src/tools/public.ts:301-303 (schema)Zod schema defining the input parameters for the 'get-leverage-tiers' tool: required exchange, optional symbol, and marketType.exchange: z.string().describe("Exchange ID (e.g., binance, bybit)"), symbol: z.string().optional().describe("Trading pair symbol (optional, e.g., BTC/USDT)"), marketType: z.enum(["future", "swap"]).default("future").describe("Market type (default: future)")
- src/tools/public.ts:300-337 (registration)Registration of the 'get-leverage-tiers' tool on the MCP server within the registerPublicTools function.server.tool("get-leverage-tiers", "Get futures leverage tiers for trading pairs", { exchange: z.string().describe("Exchange ID (e.g., binance, bybit)"), symbol: z.string().optional().describe("Trading pair symbol (optional, e.g., BTC/USDT)"), marketType: z.enum(["future", "swap"]).default("future").describe("Market type (default: future)") }, async ({ exchange, symbol, marketType }) => { try { return await rateLimiter.execute(exchange, async () => { // Get futures exchange const ex = getExchangeWithMarketType(exchange, marketType); const cacheKey = `leverage_tiers:${exchange}:${marketType}:${symbol || 'all'}`; const tiers = await getCachedData(cacheKey, async () => { log(LogLevel.INFO, `Fetching leverage tiers for ${symbol || 'all symbols'} on ${exchange} (${marketType})`); if (symbol) { return await ex.fetchMarketLeverageTiers(symbol); } else { return await ex.fetchLeverageTiers(); } }, 3600000); // Cache for 1 hour return { content: [{ type: "text", text: JSON.stringify(tiers, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error fetching leverage tiers: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });