t2000_borrow
Borrow USDC using savings as collateral. Check health factor to avoid liquidation risks. Preview transactions before signing.
Instructions
Borrow USDC against savings collateral. Check health factor first — below 1.0 risks liquidation. Amount is in dollars. Set dryRun: true to preview.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Dollar amount to borrow | |
| dryRun | No | Preview without signing (default: false) |
Implementation Reference
- packages/mcp/src/tools/write.ts:151-185 (handler)Implementation of the 't2000_borrow' tool handler.
server.tool( 't2000_borrow', 'Borrow USDC against savings collateral. Check health factor first — below 1.0 risks liquidation. Amount is in dollars. Set dryRun: true to preview.', { amount: z.number().describe('Dollar amount to borrow'), 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 maxBorrow = await agent.maxBorrow(); return { content: [{ type: 'text', text: JSON.stringify({ preview: true, amount, maxBorrow: maxBorrow.maxAmount, currentHealthFactor: health.healthFactor, estimatedHealthFactorAfter: maxBorrow.healthFactorAfter, }), }], }; } const result = await mutex.run(() => agent.borrow({ amount })); return { content: [{ type: 'text', text: JSON.stringify(result) }] }; } catch (err) { return errorResult(err); } }, );