Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
public_keyNoFilter by sender public key (hex)
pairNoFilter by pair contract package hash
pageNo
page_sizeNo

Implementation Reference

  • 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) }] };
    },
  • 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) }] };
      },
    );
  • 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,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/make-software/cspr-trade-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server