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
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount to swap (in source asset units) | |
| from | Yes | Source asset (e.g. USDC, SUI) | |
| to | Yes | Target asset (e.g. SUI, USDC) | |
| maxSlippage | No | Max slippage percentage (default: 3%) | |
| dryRun | No | Preview without signing (default: false) |
Implementation Reference
- packages/mcp/src/tools/write.ts:225-265 (handler)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); } }, );