t2000_repay
Repay borrowed USDC debt in a bank account for AI agents. Specify dollar amount or "all" to clear entire debt, with optional preview mode.
Instructions
Repay borrowed USDC. Amount is in dollars. Use "all" to repay entire debt. Set dryRun: true to preview.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Dollar amount to repay, or "all" | |
| dryRun | No | Preview without signing (default: false) |
Implementation Reference
- packages/mcp/src/tools/write.ts:187-222 (handler)The 't2000_repay' tool registration and implementation, handling both dry run previews and the actual repayment logic via the agent.
server.tool( 't2000_repay', 'Repay borrowed USDC. Amount is in dollars. Use "all" to repay entire debt. Set dryRun: true to preview.', { amount: z.union([z.number(), z.literal('all')]).describe('Dollar amount to repay, or "all"'), dryRun: z.boolean().optional().describe('Preview without signing (default: false)'), }, async ({ amount, dryRun }) => { try { if (dryRun) { agent.enforcer.assertNotLocked(); const health = await agent.healthFactor(); const positions = await agent.positions(); const totalDebt = positions.positions .filter(p => p.type === 'borrow') .reduce((sum, p) => sum + p.amount, 0); return { content: [{ type: 'text', text: JSON.stringify({ preview: true, amount: amount === 'all' ? totalDebt : amount, currentDebt: totalDebt, currentHealthFactor: health.healthFactor, }), }], }; } const result = await mutex.run(() => agent.repay({ amount })); return { content: [{ type: 'text', text: JSON.stringify(result) }] }; } catch (err) { return errorResult(err); } },