# Mode analysis (with body)

Endpoint reference for the 1delta API. Index: https://docs.1delta.io/llms.txt · every endpoint: https://docs.1delta.io/llms-full.txt

---

### POST /v1/data/lending/mode/analysis

- operationId: `mode-analysis-with-body`
- docs: https://docs.1delta.io/1delta-api/mode-analysis-with-body/
- markdown: https://docs.1delta.io/1delta-api/mode-analysis-with-body.md
- tags: Lending (Data)

Mode analysis (with body)

Evaluate all mode-switching options for a user sub-account.

**Input:** POST a `UserDataForSubAccount` object (the same shape returned by `/user-positions` per sub-account).

**Output:** For each available mode on the specified lender/chain, returns:
- **healthFactor** — the hypothetical health factor if the user switches to that mode (`null` if no debt)
- **supportedAssets** — which marketUids are eligible as collateral or for borrowing in that mode
- **canSwitch** — whether the switch is safe (health factor > 1 and no incompatible debt)

Mode categories are cached server-side (1 hour TTL). Market configs are cached (3 minute TTL).

The "mode" terminology is the protocol-agnostic generalization of Aave V3's "e-mode" (efficiency mode); other lenders expose analogous category mechanisms.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `lender` | query | string | yes | Protocol identifier See the `LenderId` schema for the full set of accepted values. |
| `chain` | query | string | yes | Chain ID |

**Request body** (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `accountId` | string | no |  |
| `health` | number | no |  |
| `borrowCapacityUSD` | number | no |  |
| `balanceData` | object | yes | Balance data for the sub-account. `collateral` and `adjustedDebt` are required for health factor calculation. |
| `balanceData.collateral` | number | yes |  |
| `balanceData.adjustedDebt` | number | yes |  |
| `balanceData.deposits` | number | no |  |
| `balanceData.debt` | number | no |  |
| `balanceData.borrowDiscountedCollateral` | number | no |  |
| `balanceData.nav` | number | no |  |
| `aprData` | object | no |  |
| `positions` | object[] | yes |  |
| `positions[].marketUid` | string | no | Market identifier, formatted `lender:chainId:address`. |
| `positions[].depositsUSD` | number | no |  |
| `positions[].debtUSD` | number | no |  |
| `positions[].debtStableUSD` | number | no |  |
| `positions[].collateralEnabled` | boolean | no |  |
| `userConfig` | object | yes |  |
| `userConfig.selectedMode` | string | yes | Current mode/config key |
| `userConfig.id` | string | no |  |
| `userConfig.isWhitelisted` | boolean | no |  |

**Example request body**

```json
{
  "accountId": "string",
  "health": 1,
  "borrowCapacityUSD": 1,
  "balanceData": {
    "collateral": 1,
    "adjustedDebt": 1,
    "deposits": 1,
    "debt": 1,
    "borrowDiscountedCollateral": 1,
    "nav": 1
  },
  "aprData": {},
  "positions": [
    {
      "marketUid": "AAVE_V3:1:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "depositsUSD": 1,
      "debtUSD": 1,
      "debtStableUSD": 1,
      "collateralEnabled": true
    }
  ],
  "userConfig": {
    "selectedMode": "string",
    "id": "string",
    "isWhitelisted": true
  }
}
```

**Response `200`** — Mode analysis results

| Field | Type | Description |
| --- | --- | --- |
| `success` | true |  |
| `data` | object | Informational payload. `null` when the endpoint only builds calldata. |
| `actions` | null |  |

**Example response**

```json
{
  "success": true,
  "data": {}
}
```

**Response `400`** — Validation error

**Response `429`** — Rate limited. Unauthenticated callers share a per-IP budget; send an `x-api-key` header to lift it. Retry with exponential backoff.

**Response `500`** — Unexpected server error. Safe to retry with backoff.

**Response `502`** — An upstream data source or protocol origin failed (`error.code` is `ORIGIN_FAILED`). `error.details` carries the per-origin status. This is also what a missing or malformed required parameter currently returns, rather than a 400.
