Skip to main content
Glama

t2000_exchange

Swap assets on Cetus DEX to exchange tokens like USDC and SUI. Get quotes or execute trades with configurable slippage.

Instructions

Swap assets via Cetus DEX (e.g. USDC to SUI, SUI to USDC). Amount is in source asset units. Set dryRun: true to get a quote without executing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesAmount to swap (in source asset units)
fromYesSource asset (e.g. USDC, SUI)
toYesTarget asset (e.g. SUI, USDC)
maxSlippageNoMax slippage percentage (default: 3%)
dryRunNoPreview without signing (default: false)

Implementation Reference

  • The implementation of the 't2000_exchange' tool, which handles asset swaps via the Cetus DEX, including dry-run quoting and actual execution.
    server.tool(
      't2000_exchange',
      'Swap assets via Cetus DEX (e.g. USDC to SUI, SUI to USDC). Amount is in source asset units. Set dryRun: true to get a quote without executing.',
      {
        amount: z.number().describe('Amount to swap (in source asset units)'),
        from: z.string().describe('Source asset (e.g. USDC, SUI)'),
        to: z.string().describe('Target asset (e.g. SUI, USDC)'),
        maxSlippage: z.number().optional().describe('Max slippage percentage (default: 3%)'),
        dryRun: z.boolean().optional().describe('Preview without signing (default: false)'),
      },
      async ({ amount, from, to, maxSlippage, dryRun }) => {
        try {
          if (dryRun) {
            agent.enforcer.assertNotLocked();
            const quote = await agent.exchangeQuote({ from, to, amount });
    
            return {
              content: [{
                type: 'text',
                text: JSON.stringify({
                  preview: true,
                  from,
                  to,
                  amount,
                  expectedOutput: quote.expectedOutput,
                  priceImpact: quote.priceImpact,
                  fee: quote.fee.amount,
                }),
              }],
            };
          }
    
          const result = await mutex.run(() =>
            agent.exchange({ from, to, amount, maxSlippage }),
          );
          return { content: [{ type: 'text', text: JSON.stringify(result) }] };
        } catch (err) {
          return errorResult(err);
        }
      },
    );

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/mission69b/t2000'

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