> ## 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.

# Set Max Fixed Rate

> Tighten the ceiling on any fixed rate the model owner can set

Builds the `setMaxFixedRate` transaction that lowers the ceiling on the fixed rate a market can stamp. It targets the market's interest model, and only the model owner can sign it, the same wallet that signs [Set Rate Mode](/endpoints/lending/set-rate-mode).

The ceiling moves down only. The lender of record can record it in its adoption terms, and from then on no owner can loosen what those terms bound. A market with no ceiling yet takes a first one here, and once recorded it can never be cleared.

The ceiling bounds the rates the owner can set, not the loans. Opening a loan never consults it, so loans already stamped keep their rate whatever the ceiling becomes.

## Path Parameters

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

## Body Parameters

<ParamField body="maxFixedRateBps" type="integer" required>
  The new ceiling in basis points. Integer, 1 to 50000. Refused when it exceeds the ceiling already recorded, and while the mode is `FIXED` when it falls below the rate new loans are being stamped with.
</ParamField>

<ParamField body="txHash" type="string">
  Hash of the transaction you broadcast for this operation. Send it to confirm the transaction and record the result. Omit it to receive the calldata. When `txHash` is present, every other field is ignored.
</ParamField>

## Tighten Below the Current Stamp

While the market runs `FIXED`, the ceiling cannot drop below the rate new loans are stamped with, because it would advertise a bound every new loan breaks. Lower the stamp first with [Set Rate Mode](/endpoints/lending/set-rate-mode), then tighten the ceiling to at most the new stamp.

## Confirm the Change

Send the mined hash back to this path as `{ "txHash": "0x..." }`. The API checks that the transaction called `setMaxFixedRate` on the market's interest model. It then reads the offering back from the chain and updates the market record.

## Response Fields

The calldata response carries the transaction twice. `transaction` holds `to` and `data`. The same `to` and `data` also sit directly on `data`, and that is where the `chainId` and `value` binding lands, so sign from those four fields.

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="action" type="string">`SIGN_TRANSACTION`. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="transaction" type="object">`{ to, data }` for the `setMaxFixedRate` call on the interest model. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="to" type="string">The interest model address. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="data" type="string">The encoded `setMaxFixedRate` call. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="value" type="string">Always `"0"`. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="chainId" type="integer">The chain your instance resolves to. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="functionName" type="string">`setMaxFixedRate`, or the verified function when confirming.</ResponseField>
    <ResponseField name="requiredRole" type="string">`INTEREST_MODEL_OWNER`. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="description" type="string">Plain-language summary of the change. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="requiredSigner" type="string">The model owner, the one wallet that can sign. `null` when the owner could not be read. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="heldByThisInstance" type="boolean">`true` when the owner is a verified wallet of your instance, `false` when it is not, `null` when the owner could not be read. The build is never refused on it. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="signerAddress" type="string">The owner, when your instance holds it. Otherwise `null`. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="note" type="string">Says the owner could not be read, or what to do when your instance cannot sign: hand the calldata to the owner, because any other wallet reverts `OwnableUnauthorizedAccount`. `null` when your instance holds the owner wallet. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="confirmWith" type="object">`{ endpoint, field }`: the call that confirms this transaction, and the body field that carries the hash. Returned when `txHash` is omitted.</ResponseField>
    <ResponseField name="txHash" type="string">Transaction hash. Returned when confirming.</ResponseField>
    <ResponseField name="signedBy" type="string">The wallet that sent the transaction. Returned when confirming.</ResponseField>
    <ResponseField name="blockNumber" type="integer">Block the transaction was mined in. Returned when confirming.</ResponseField>
    <ResponseField name="offering" type="object">The market's rate and term offering, read back from the chain after the transaction, with `maxFixedRate` among its fields. The same object [Set Rate Mode](/endpoints/lending/set-rate-mode) returns. Returned when confirming.</ResponseField>
    <ResponseField name="updatedColumns" type="array">Names of the stored market fields this confirmation changed. Returned when confirming.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/max-fixed-rate" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{ "maxFixedRateBps": 1200 }'
  ```

  ```typescript TypeScript theme={null}
  const url = `https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/max-fixed-rate`;
  const headers = { 'X-API-Key': 'trusset_your_key_here', 'Content-Type': 'application/json' };

  const build = await fetch(url, {
    method: 'POST',
    headers,
    body: JSON.stringify({ maxFixedRateBps: 1200 })
  });
  const { data: calldata } = await build.json();

  const tx = await ownerWallet.sendTransaction({
    to: calldata.to,
    data: calldata.data,
    value: calldata.value,
    chainId: calldata.chainId
  });
  await tx.wait();

  await fetch(url, { method: 'POST', headers, body: JSON.stringify({ txHash: tx.hash }) });
  ```
</RequestExample>

<ResponseExample>
  ```json Calldata Response theme={null}
  {
    "success": true,
    "data": {
      "action": "SIGN_TRANSACTION",
      "transaction": {
        "to": "0x3b25752c1459c5cf1b0bfcfdf0d56883c8047423",
        "data": "0x..."
      },
      "to": "0x3b25752c1459c5cf1b0bfcfdf0d56883c8047423",
      "data": "0x...",
      "functionName": "setMaxFixedRate",
      "requiredRole": "INTEREST_MODEL_OWNER",
      "description": "Tighten the fixed-rate ceiling to 1200 bps (requires interest model owner; downward only)",
      "requiredSigner": "0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
      "heldByThisInstance": false,
      "signerAddress": null,
      "note": "Only the interest model owner (0x5ad87a0621175206b72d10e4b8577b192e7f40ab) can sign this transaction, and no wallet registered on this instance is that owner: signed from any other wallet it reverts OwnableUnauthorizedAccount. Hand the calldata to the owner, or take the model over first.",
      "confirmWith": {
        "endpoint": "POST /lending-external-securities-v2/api/markets/clx_secmarket_001/max-fixed-rate",
        "field": "txHash"
      },
      "chainId": 11155111,
      "value": "0"
    }
  }
  ```

  ```json Error - Ceiling Only Decreases theme={null}
  {
    "success": false,
    "error": {
      "code": "MAX_FIXED_RATE_ONLY_DECREASES",
      "message": "The maxFixedRate ceiling moves downward only: it is 1500 bps now, recorded at adoption so no later operator can loosen what the terms bound."
    }
  }
  ```
</ResponseExample>

## Error Codes

| Code                            | HTTP  | Cause                                                                                                                                           |
| ------------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `MISSING_MARKET_ID`             | `400` | The `marketId` path segment is longer than 100 characters                                                                                       |
| `VALIDATION_ERROR`              | `400` | `maxFixedRateBps` is missing or outside 1 to 50000, or `txHash` is malformed                                                                    |
| `MAX_FIXED_RATE_ONLY_DECREASES` | `400` | `maxFixedRateBps` is above the ceiling already recorded                                                                                         |
| `INVALID_CONFIRMATION`          | `400` | The market has no on-chain address, so there is nothing to confirm against                                                                      |
| `MARKET_NOT_FOUND`              | `404` | No market with this ID on your instance                                                                                                         |
| `MAX_FIXED_RATE_BELOW_STAMP`    | `409` | The mode is `FIXED` and `maxFixedRateBps` is below the rate new loans are stamped with                                                          |
| `MARKET_PENDING_CURATOR`        | `409` | The market has no lender of record yet, so the market itself still owns the model and no wallet can sign. Skipped when confirming with `txHash` |
| `INTERNAL_ERROR`                | `500` | The chain could not be read while confirming. Retry shortly                                                                                     |
| `MODEL_UNRESOLVED`              | `503` | The market's interest model address could not be resolved. Retry shortly                                                                        |

Confirming with `txHash` can also return any [transaction verification error](/endpoints/introduction#confirm-a-transaction).
