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

# Update Market Config

> Set the on-chain risk parameters for a market

Writes the market's full `config` struct. Every field is required on every call, so read the current values with [Get Market Config](/endpoints/external-securities-lending/get-config) first and send them back with your changes applied. Partial updates are not supported: an omitted field fails validation rather than retaining its current value.

Requires `ISSUER_ROLE` on the market contract.

<Warning>
  Changing `liquidationThreshold` moves the point at which existing loans become liquidatable. Raising it immediately puts loans at risk that were healthy a moment earlier. The contract caps each change at 10 percent per call.
</Warning>

## Path Parameters

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

## Body Parameters

<ParamField body="config" type="object" required>
  <Expandable>
    <ParamField body="collateralFactor" type="integer" required>Maximum loan to value in basis points. 1000 to 9500.</ParamField>
    <ParamField body="liquidationThreshold" type="integer" required>Liquidation trigger in basis points. 1000 to 9800. Must exceed `collateralFactor` to leave borrowers any buffer.</ParamField>
    <ParamField body="liquidationPenalty" type="integer" required>Penalty on liquidated debt in basis points. 0 to 5000.</ParamField>
    <ParamField body="protocolFeeRate" type="integer" required>Issuer share of accrued interest in basis points. 0 to 10000.</ParamField>
    <ParamField body="minBorrowAmount" type="string" required>Minimum borrow per loan, as a decimal string in borrow asset units.</ParamField>
    <ParamField body="maxPriceAge" type="integer" required>Seconds before the oracle price is treated as stale. 300 to 604800.</ParamField>
    <ParamField body="closeFactor" type="integer" required>Maximum fraction of a loan's debt repayable in one liquidation, in basis points. 1000 to 5000.</ParamField>
    <ParamField body="maxTotalCollateral" type="string" required>Global collateral cap as a decimal string in collateral token units. `"0"` means uncapped.</ParamField>
    <ParamField body="maxUserCollateral" type="string" required>Per-borrower collateral cap as a decimal string in collateral token units. `"0"` means uncapped.</ParamField>
    <ParamField body="useDutchAuction" type="boolean" required>Whether liquidations open a Dutch auction. Rejected on-chain when the market's `priceSource` is `MARKET`.</ParamField>
    <ParamField body="auctionDuration" type="integer" required>Auction length in seconds. 600 to 86400.</ParamField>
    <ParamField body="auctionStartPremium" type="integer" required>Opening price multiplier in basis points. 10000 to 20000, where 10000 is oracle price.</ParamField>
    <ParamField body="auctionMinPremium" type="integer" required>Floor price multiplier in basis points. 8000 to 10000. Floored at 9800 on-chain when `priceSource` is `MARKET`.</ParamField>
  </Expandable>
</ParamField>

<Note>
  `maxPriceAge` interacts directly with your NAV publication cadence. A fund that publishes NAV daily needs `maxPriceAge` above 86400 seconds, or every loan action will revert against a stale price between publications.
</Note>

<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.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-external-securities/api/markets/{marketId}/config" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "config": {
        "collateralFactor": 7000,
        "liquidationThreshold": 8000,
        "liquidationPenalty": 500,
        "protocolFeeRate": 2500,
        "minBorrowAmount": "1000",
        "maxPriceAge": 172800,
        "closeFactor": 5000,
        "maxTotalCollateral": "0",
        "maxUserCollateral": "0",
        "useDutchAuction": false,
        "auctionDuration": 3600,
        "auctionStartPremium": 13000,
        "auctionMinPremium": 9500
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Calldata Response theme={null}
  {
    "success": true,
    "data": {
      "action": "SIGN_TRANSACTION",
      "transaction": { "to": "0x70A0...", "data": "0x..." }
    }
  }
  ```

  ```json Confirmed Response theme={null}
  {
    "success": true,
    "data": { "txHash": "0xabc...def" }
  }
  ```

  ```json Error - Update Failed theme={null}
  {
    "success": false,
    "error": {
      "code": "CONFIG_UPDATE_FAILED",
      "message": "execution reverted: ThresholdChangeTooLarge"
    }
  }
  ```

  ```json Error - Validation theme={null}
  {
    "success": false,
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid request parameters",
      "details": [
        { "field": "config.collateralFactor", "message": "Number must be less than or equal to 9500" }
      ]
    }
  }
  ```
</ResponseExample>
