sellInFailMarket
Execute token sales in the fail market for specific proposals, enabling users to manage trades effectively within the Futarchy protocol on Solana. Input includes proposal ID, amount, and user public key.
Instructions
Sell tokens in the fail market for a proposal
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount to sell | |
| proposalId | Yes | The ID of the proposal to trade in | |
| user | Yes | User's public key |
Implementation Reference
- src/mcp/server/index.ts:474-509 (handler)The MCP tool handler function that invokes the apiClient.sellInFailMarket method, handles the response, and formats it for MCP.async ({ proposalId, amount, user }) => { try { const response = await apiClient.sellInFailMarket(proposalId, amount, user); if (!response.success) { return { content: [ { type: "text" as const, text: response.error || 'Unknown error', }, ], isError: true, }; } return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: "text" as const, text: `Error selling in fail market: ${error.message || 'Unknown error'}`, }, ], isError: true, }; } }
- src/mcp/server/index.ts:469-473 (schema)Zod input schema defining parameters: proposalId (string), amount (number), user (string).{ proposalId: z.string().describe("The ID of the proposal to trade in"), amount: z.number().describe("Amount to sell"), user: z.string().describe("User's public key"), },
- src/mcp/server/index.ts:466-510 (registration)Registers the sellInFailMarket tool with MCP server, including name, description, input schema, and handler.server.tool( "sellInFailMarket", "Sell tokens in the fail market for a proposal", { proposalId: z.string().describe("The ID of the proposal to trade in"), amount: z.number().describe("Amount to sell"), user: z.string().describe("User's public key"), }, async ({ proposalId, amount, user }) => { try { const response = await apiClient.sellInFailMarket(proposalId, amount, user); if (!response.success) { return { content: [ { type: "text" as const, text: response.error || 'Unknown error', }, ], isError: true, }; } return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: "text" as const, text: `Error selling in fail market: ${error.message || 'Unknown error'}`, }, ], isError: true, }; } } );
- src/mcp/common/api.ts:254-282 (helper)Helper method in FutarchyApiClient that performs HTTP POST request to the backend API endpoint /proposals/{proposalId}/sell-fail to execute the sell operation.async sellInFailMarket(proposalId: string, amount: number, userPublicKey: string): Promise<Response> { try { const response = await fetch(`${this.baseUrl}/proposals/${proposalId}/sell-fail`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ amount, user: userPublicKey }) }); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const data = await response.json(); return { success: true, data: data }; } catch (error: any) { return { success: false, error: error.message || 'Failed to sell in fail market' }; } }