Skip to main content
Glama

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
NameRequiredDescriptionDefault
amountYesDollar amount to repay, or "all"
dryRunNoPreview without signing (default: false)

Implementation Reference

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

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