> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trusset.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Max Borrow

> Quote the maximum borrowable amount for a collateral size

Returns the largest amount the market will lend against a given quantity of collateral, computed by the contract at the current oracle price and collateral factor. Use it to drive a borrow slider before calling [Open Loan](/endpoints/external-securities-lending/open-loan).

The response also reports oracle freshness, because a quote against a stale price will not be honoured by the contract.

## Path Parameters

<ParamField path="marketId" type="string" required>Market ID.</ParamField>

## Query Parameters

<ParamField query="collateralAmount" type="string" required>
  Collateral quantity as a decimal string, for example `"1000"`. Parsed at the collateral token's decimals. Must be greater than zero.
</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="collateralAmount" type="string">The quantity you supplied, echoed back.</ResponseField>
    <ResponseField name="maxBorrow" type="string">Maximum borrowable amount, in borrow asset units.</ResponseField>
    <ResponseField name="isStale" type="boolean">Whether the oracle price is older than the market's `maxPriceAge`. `null` when the market has no oracle or the read failed.</ResponseField>
    <ResponseField name="priceAge" type="integer">Seconds since the last oracle update. `null` when unavailable.</ResponseField>
  </Expandable>
</ResponseField>

<Warning>
  When `isStale` is `true`, opening a loan against the stored price will revert. Either push a fresh NAV with [Sync Oracle Price](/endpoints/external-securities-lending/sync-oracle) or attach a `signedPrice` from [Sign Price](/endpoints/external-securities-lending/sign-price) to the borrow call.
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.trusset.org/lending-external-securities/api/markets/{marketId}/max-borrow?collateralAmount=1000" \
    -H "X-API-Key: trusset_your_key_here"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    `https://api.trusset.org/lending-external-securities/api/markets/${marketId}/max-borrow?collateralAmount=1000`,
    { headers: { 'X-API-Key': 'trusset_your_key_here' } }
  );
  const { data } = await res.json();
  if (data.isStale) {
    // refresh the NAV before quoting the borrower
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "collateralAmount": "1000",
      "maxBorrow": "78615.000000",
      "isStale": false,
      "priceAge": 1200
    }
  }
  ```

  ```json Error - Invalid Amount theme={null}
  {
    "success": false,
    "error": {
      "code": "INVALID_AMOUNT",
      "message": "collateralAmount query param required"
    }
  }
  ```
</ResponseExample>
