get_swap_history
Retrieve swap transaction history from the Casper Network DEX. Filter by sender public key or trading pair to analyze past exchange activity.
Instructions
Get swap transaction history
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| public_key | No | Filter by sender public key (hex) | |
| pair | No | Filter by pair contract package hash | |
| page | No | ||
| page_size | No |
Implementation Reference
- packages/mcp/src/tools/account.ts:41-49 (handler)MCP tool handler for 'get_swap_history' that calls the SDK client.
async (args) => { const result = await client.getSwapHistory({ publicKey: args.public_key, pairContractPackageHash: args.pair, page: args.page, pageSize: args.page_size, }); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] }; }, - packages/mcp/src/tools/account.ts:32-50 (registration)Registration of the 'get_swap_history' MCP tool.
server.tool( 'get_swap_history', 'Get swap transaction history', { public_key: z.string().optional().describe('Filter by sender public key (hex)'), pair: z.string().optional().describe('Filter by pair contract package hash'), page: z.number().optional(), page_size: z.number().optional(), }, async (args) => { const result = await client.getSwapHistory({ publicKey: args.public_key, pairContractPackageHash: args.pair, page: args.page, pageSize: args.page_size, }); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] }; }, ); - packages/sdk/src/client.ts:169-177 (handler)SDK client implementation of getSwapHistory.
async getSwapHistory(opts?: SwapHistoryQuery) { const accountHash = opts?.publicKey ? PublicKey.fromHex(opts.publicKey).accountHash().toHex() : undefined; return this.swapsApi.getSwaps({ senderAccountHash: accountHash, pairContractPackageHash: opts?.pairContractPackageHash, page: opts?.page, pageSize: opts?.pageSize,