# Borrow

When you borrow USDC through Curvance, you're creating a debt position against your collateral. The system constantly evaluates your position to ensure it remains healthy (above the required collateralization ratio). The borrowing process is straightforward - you simply specify how much USDC you want to borrow, and the cUSDC contract handles the debt issuance. The borrowed USDC is sent directly to the `receiver` wallet.

{% hint style="success" %}
View functions inside [ProtocolReader](/app/developer-docs/protocol-reader.md) provide handy data needed to calculate borrow amounts.
{% endhint %}

To borrow, you may call the `borrow()` function in the respective cToken contract using these function arguments:

<table><thead><tr><th width="104">Type</th><th width="123">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of the underlying asset to borrow.</td></tr><tr><td>address</td><td>recipient</td><td>The address where the borrowed tokens will be sent.</td></tr></tbody></table>

Implementation snippet:

```javascript
async function borrowUSDC(amount) {
  // USDC has 6 decimal places
  const USDCDecimals = await USDC.decimals();
  const amountInUsdcUnits = ethers.utils.parseUnits(amount.toString(), USDCDecimals);
  
  // Borrow USDC
  const borrowTx = await cUSDC.borrow(amountInUsdcUnits);
  const receipt = await borrowTx.wait();
  
  console.log(`Successfully borrowed ${amount} USDC`);
  return receipt;
}
```

Your borrowing capacity depends on your collateral value, the collateralization ratio of your assets, and current market conditions. Curvance's risk model determines the maximum amount you can borrow against your collateral.

### Error Handling

When interacting with cUSDC contracts, you might encounter various errors. Curvance uses error selectors to provide specific information about what went wrong:

```javascript
async function safeBorrowUSDC(amount) {
  try {
    return await borrowUSDC(amount);
  } catch (error) {
    console.error('Borrowing failed:');
    
    if (error.data) {
      const errorSelector = error.data.slice(0, 10);
      if (errorSelector === 
        ethers.id('MarketManager__InsufficientCollateral()').slice(2, 10))) 
        console.error('Invalid parameter provided');
    } else {
      console.error('Error details:', error.message);
    }
    throw error;
  }
}
```

Common error scenarios include:

* Insufficient collateral for your requested borrow amount.
* Market paused for borrowing (temporary protocol safety measure).
* Trying to borrow less than the minimum loan size.
* Transaction would result in an unhealthy position.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.curvance.com/app/developer-docs/quick-start-guides/borrowing-and-repayment/borrow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
