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

# Deploy Market

> Deploy a new lending market for a stock token

Deploys a complete lending market (oracle, interest model, insurance fund, and market contract) through the factory. Returns the unsigned factory call for you to sign, then register the deployed market with [Confirm Deploy](/endpoints/stock-lending/confirm-deploy).

<Warning>
  After deployment, the stock token issuer must authorize both the market and liquidation router on the stock token contract via `addAuthorizedContract`.
</Warning>

## Body Parameters

<ParamField body="stockTokenAddress" type="string" required>ERC-20 stock token address.</ParamField>
<ParamField body="issuerAddress" type="string" required>Issuer wallet (receives `ISSUER_ROLE`).</ParamField>
<ParamField body="adminAddress" type="string" required>Admin wallet (receives `DEFAULT_ADMIN_ROLE`).</ParamField>
<ParamField body="initialPrice" type="string" required>Initial oracle price in USD (e.g. `"50.00"`).</ParamField>
<ParamField body="borrowAssetAddress" type="string">ERC-20 the market lends. Defaults to the instance's USDC when omitted.</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="action" type="string">Always `SIGN_TRANSACTION`.</ResponseField>
    <ResponseField name="transaction" type="object">`to` (the factory) and `data`.</ResponseField>
    <ResponseField name="stockTokenAddress" type="string">Normalised collateral token address, echoed back.</ResponseField>
    <ResponseField name="confirmWith" type="object">The endpoint and field to send the hash to once the deployment is mined.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-stocks/api/markets/deploy" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "stockTokenAddress": "0xabc...def",
      "issuerAddress": "0x111...222",
      "adminAddress": "0x333...444",
      "initialPrice": "50.00"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "action": "SIGN_TRANSACTION",
      "transaction": { "to": "0xFeda...", "data": "0x..." },
      "stockTokenAddress": "0xabc...def",
      "confirmWith": {
        "endpoint": "POST /lending-stocks/api/markets/confirm-deploy",
        "field": "txHash"
      }
    }
  }
  ```

  ```json Error - Market Exists theme={null}
  {
    "success": false,
    "error": {
      "code": "MARKET_EXISTS",
      "message": "Market already exists for this token"
    }
  }
  ```
</ResponseExample>
