# Max debt swap range

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

---

### GET /v1/data/loop/range/debt-swap

- operationId: `max-debt-swap-range`
- docs: https://docs.1delta.io/1delta-api/max-debt-swap-range/
- markdown: https://docs.1delta.io/1delta-api/max-debt-swap-range.md
- tags: Loop (Data)

Max debt swap range

Compute the maximum amount for a debt swap.

The max swappable amount equals the user's total debt (variable + stable) in the source (input) asset.

Use `denomination=exactInput` (default) to base the range on the source debt, or `exactOutput` to base it on the target debt.

Requires `positions[]` in the POST body (or `account` for GET) to read the user's debt balances.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `marketUidIn` | query | string | no | Market identifier for the input (debt/short) side. |
| `marketUidOut` | query | string | no | Market identifier for the output (collateral/long) side. |
| `account` | query | string | no | Wallet address. Required for GET (on-chain balance fetch). |
| `accountId` | query | string | no | Sub-account ID (e.g. Euler V2, Init Capital). |
| `denomination` | query | "exactInput" \| "exactOutput" | no | Which side is the base denomination for the range. |

**Response `200`** — Max debt swap range

| Field | Type | Description |
| --- | --- | --- |
| `success` | true |  |
| `data` | object[] | Array of range results. |
| `data[].chainId` | string | EVM chain id, as a decimal string. See the `ChainId` schema. |
| `data[].lender` | string | Protocol identifier. See the `LenderId` schema. |
| `data[].marketLongUid` | string | Market UID of the collateral side |
| `data[].marketShortUid` | string | Market UID of the debt side |
| `data[].marketNameLong` | string | Display name of the collateral market/vault (e.g. the Euler eVault name). Disambiguates rows that share the collateral/debt token symbols and lender. |
| `data[].marketNameShort` | string | Display name of the debt market/vault. For Euler this is the controller (debt) eVault — the primary way to tell otherwise-identical WETH→USDC rows apart. |
| `data[].curatorNameLong` | string | Curator/brand of the collateral market (Euler: resolved from the vault governor). Null for lenders without a curator, or until the curator registry is seeded. Render as "curatorName + symbol", falling back to marketNameLong. |
| `data[].curatorNameShort` | string | Curator/brand of the debt (controller) market. Same semantics as curatorNameLong. |
| `data[].assetLong` | string | Collateral asset address |
| `data[].assetShort` | string | Debt asset address |
| `data[].assetGroupLong` | string |  |
| `data[].assetGroupShort` | string |  |
| `data[].symbolLong` | string | Collateral token symbol |
| `data[].nameLong` | string | Collateral token name |
| `data[].symbolShort` | string | Debt token symbol |
| `data[].nameShort` | string | Debt token name |
| `data[].collateralFactorLong` | number | Liquidation collateral factor for the long side |
| `data[].borrowCollateralFactorLong` | number | Borrow-adjusted collateral factor for the long side |
| `data[].borrowFactorLong` | number | Borrow factor for the long side |
| `data[].collateralDisabledLong` | boolean | Whether collateral is disabled for the long asset |
| `data[].debtDisabledLong` | boolean | Whether debt is disabled for the long asset |
| `data[].collateralFactorShort` | number | Liquidation collateral factor for the short side |
| `data[].borrowCollateralFactorShort` | number | Borrow-adjusted collateral factor for the short side |
| `data[].borrowFactorShort` | number | Borrow factor for the short side |
| `data[].collateralDisabledShort` | boolean | Whether collateral is disabled for the short asset |
| `data[].debtDisabledShort` | boolean | Whether debt is disabled for the short asset |
| `data[].eModeConfigId` | string | E-mode configuration ID |
| `data[].eMode` | string | E-mode category |
| `data[].aprBase` | number | Base APR (deposit - borrow + intrinsic, before rewards) |
| `data[].aprTotal` | number | Total APR (base + rewards) |
| `data[].maxLeverage` | number | Highest leverage multiple reachable in this market. |
| `data[].ltv` | number | Loan-to-value ratio (0-1) |
| `data[].depositRateLong` | number |  |
| `data[].variableBorrowRateShort` | number |  |
| `data[].intrinsicYieldLong` | number |  |
| `data[].intrinsicYieldShort` | number |  |
| `data[].variableBorrowDisabledShort` | boolean | True when the debt (short) market is a Lista DAO brokered market — it cannot be looped at a variable rate, only at one of the fixed terms in `termsShort`. `variableBorrowRateShort` is `0`/undefined for such pairs. |
| `data[].termsShort` | object[] | Fixed-term rate card for the debt (short) side when it is a Lista DAO brokered market. Each entry is one loop option — see the per-term net-APR recipe. `null`/empty for regular variable-rate pairs. For Term Finance an empty card means "not borrowable right now" rather than "no offers" — read `fixedTerm.auction` for why. |
| `data[].termsShort[].termId` | integer | Term identifier — MEANING IS LENDER-SPECIFIC. Exactly and TermMax: the pool/market unix MATURITY timestamp. Lista: the broker-defined product id. Teller: the duration in seconds (rolling term). Midnight and Term Finance: `0`, a placeholder (single maturity per market, so the id carries no information). Pass to `/v1/actions/lending/borrow?termId=…`. Numeric on-chain; some upstream feeds serialize it as a string — coerce with `Number()` when comparing. |
| `data[].termsShort[].depositApr` | number | Annualised fixed LEND rate at this maturity, in percent (Exactly only — its fixed pools quote both sides). |
| `data[].termsShort[].available` | number | Borrowable liquidity at this maturity in loan-token human units (Exactly only). |
| `data[].termsShort[].durationDays` | number | How long the position is locked at the fixed rate, in days (e.g. 7, 14, 30). |
| `data[].termsShort[].durationSecs` | number | Term duration in seconds (raw on-chain value). |
| `data[].termsShort[].apr` | number | Annualised borrow APR for this term, in **percent** (e.g. `3.85` = 3.85%). Same unit as `variableBorrowRate` / `stableBorrowRate`. For order-book markets (Midnight) this is the 0-notional top-of-book (cheapest) rate — see `aprAtAmount` for the size-weighted rate. |
| `data[].termsShort[].aprAtAmount` | number | Size-weighted (VWAP) borrow APR % at the supplied debt notional, for order-book fixed-term markets (Morpho Midnight): the borrow book filled cheapest-first, `(Σ filledᵢ·aprᵢ)/amount`. Present only when an amount is supplied AND the term carries an order-book `ladder`; broker rate cards (Lista, single flat rate) omit it and `apr` already applies at any size. |
| `data[].termsShort[].fillable` | number | Total loan-token depth in this term's order book — the maximum borrow openable at this maturity. Present only for order-book terms with an amount supplied. |
| `data[].termsShort[].capped` | boolean | True when the supplied debt notional exceeds `fillable` — the book can't fully fund the borrow at this maturity (`aprAtAmount` is then the drain-the-book VWAP). |
| `data[].termsShort[].ladder` | object[] | Order-book borrow ladder (best-borrow first) for order-book fixed-term markets (Midnight). Only serialized when `depth=true` (bulky). `aprAtAmount` is the pre-computed size-weighted rate; use this to re-derive it at any amount. |
| `data[].termsShort[].ladder[].apr` | number | Annualised borrow rate at this tier (%). |
| `data[].termsShort[].ladder[].units` | string | Credit/debt units at this tier (raw). |
| `data[].termsShort[].ladder[].assets` | number | Loan-token size available at this tier. |
| `data[].fixedTerm` | object | Fixed-term descriptor for this pair's lender, joined by lender key. Absent on variable-rate lenders. **For Term Finance (`model: "term"`), gate the borrow/loop CTA on `fixedTerm.auction.canBorrow`**: origination only happens inside scheduled sealed-bid auction rounds and most repos sit between rounds, so a pair can carry a maturity, an LTV and a rate and still be impossible to borrow. Note also that `aprBase`/`aprTotal` on such a pair are computed against a `variableBorrowRate` of 0 and therefore read as an enormous leveraged yield with a free debt leg — show them as indicative, not obtainable, whenever `canBorrow` is false. |
| `data[].fixedTerm.model` | "lista" \| "midnight" \| "term" \| "exactly" \| "teller" \| "termmax" | Underlying fixed-term protocol shape. |
| `data[].fixedTerm.maturity` | integer | Single fixed calendar maturity, unix seconds. Absent for rolling-duration menus (Lista) and multi-maturity markets (Exactly — the menu lives on `terms[]`). |
| `data[].fixedTerm.fees` | object | Market-level fees: `continuousFeeApr` (%/yr lender-side haircut, Midnight), `settlementFee` (fraction at the current TTM, Midnight), `latePenaltyApr` (%/yr on overdue debt, Exactly), `originationFeePercent` (upfront % of principal, Teller). Empty for lenders without them. |
| `data[].fixedTerm.earlyRepay` | object | Early-repayment policy: `{ kind: "none" \| "penalty" \| "discount" }`. `none` = exit any time at market price; `penalty` = per-loan penalty (amount is position-level); `discount` = repaying early costs LESS than face value (Exactly). |
| `data[].fixedTerm.provider` | object | Who fronts the term: `{ kind: "broker" \| "orderbook" \| "auction" \| "pool", address? }`. `auction` markets carry the `auction` window below and can only be borrowed inside a round. |
| `data[].fixedTerm.auction` | object | Origination window for a fixed-term market whose terms are only obtainable during a bounded round rather than continuously — Term Finance (`fixedTerm.provider.kind = "auction"`). Served on `fixedTerm.auction`; ABSENT on lenders whose terms are continuously available, and absent is NOT the same as `closed`. This is the difference between "the rate card is empty right now" and "this market cannot be borrowed at all": between rounds a Term repo still has a maturity, collateral params and a last-cleared rate, but nothing can be borrowed. Most repos are between rounds at any given time. |
| `data[].fixedTerm.auction.status` | "upcoming" \| "open" \| "revealing" \| "closed" | `upcoming` — a round is listed but not yet accepting submissions. `open` — accepting sealed bids/offers. `revealing` — bidding shut, sealed prices revealing and the round clearing. `closed` — no round is listed. Snapshot at fetch time; re-derive from the timestamps against the current clock when reading a cached response. |
| `data[].fixedTerm.auction.canBorrow` | boolean | Can a NEW borrow be opened right now? **Gate the borrow CTA on this**, not on `status` and not on the presence of a rate — it stays correct if more statuses are added. True only inside an open round: Term borrow origination is a sealed bid, so there is no other entry point. |
| `data[].fixedTerm.auction.canLend` | boolean | Can a NEW lend position be opened right now? Deliberately independent of `canBorrow` — the primary auction is only one of two lend surfaces, and buying repo tokens on the secondary market works between rounds. A closed round therefore leaves the market **lend-only**, not inert; greying out the whole market would be wrong. |
| `data[].fixedTerm.auction.secondsUntilClose` | integer | Seconds until submissions close (`revealTime − now`). Absent unless a round is open. A snapshot — for a live countdown derive from `revealTime`, since responses are cached. |
| `data[].fixedTerm.auction.implications` | string[] | Ready-to-display consequences of this market's origination model, most important first (same convention as `params.market.teller.implications`). Auction mechanics are unusual enough that showing only a rate misleads. |
| `data[].fixedTerm.auction.id` | string | Auction round id. Absent when `status: "closed"`. |
| `data[].fixedTerm.auction.startTime` | integer | Submissions open, unix seconds. Absent when closed. |
| `data[].fixedTerm.auction.revealTime` | integer | Submissions CLOSE and sealed prices begin revealing, unix seconds — **the deadline to act**. Absent when closed. |
| `data[].fixedTerm.auction.endTime` | integer | Round clears, unix seconds. Equal to `revealTime` on current deployments. Absent when closed. |
| `data[].fixedTerm.auction.minBorrowAmount` | string | Minimum bid (borrow) size for this round, loan-token BASE units. A real floor (e.g. `"1000000000"` = 1000 USDC) — a smaller amount cannot be submitted at all, so validate before building the action rather than surfacing a failed transaction. |
| `data[].fixedTerm.auction.minLendAmount` | string | Minimum offer (lend) size for this round, loan-token BASE units. |
| `data[].rewardAprLong` | number | Total reward APR on the collateral side |
| `data[].rewardAprShort` | number | Total reward APR on the debt side |
| `data[].rewardsLong` | object[] | Reward programs for the collateral side |
| `data[].rewardsShort` | object[] | Reward programs for the debt side |
| `data[].totalDepositsLong` | number | Total deposits in token units (long side) |
| `data[].totalDebtLong` | number | Total debt in token units (long side) |
| `data[].totalLiquidityLong` | number | Total liquidity in token units (long side) |
| `data[].totalDepositsShort` | number | Total deposits in token units (short side) |
| `data[].totalDebtShort` | number | Total debt in token units (short side) |
| `data[].totalLiquidityShort` | number | Total liquidity in token units (short side) |
| `data[].totalDepositsUsdLong` | number |  |
| `data[].totalDebtUsdLong` | number |  |
| `data[].totalLiquidityUsdLong` | number |  |
| `data[].totalDepositsUsdShort` | number |  |
| `data[].totalDebtUsdShort` | number |  |
| `data[].totalLiquidityUsdShort` | number |  |
| `data[].borrowLiquidityShort` | number | Available borrow liquidity (debt side) in token units |
| `data[].withdrawLiquidityLong` | number | Available withdraw liquidity (collateral side) in token units |
| `data[].depositableLong` | number | Remaining deposit capacity (collateral side) in token units |
| `data[].utilizationLong` | number |  |
| `data[].utilizationShort` | number |  |
| `data[].underlyingInfoLong` | object | Collateral asset metadata including token info, market prices, and oracle prices |
| `data[].underlyingInfoLong.asset` | object | Token metadata (address, symbol, name, decimals, logoURI, assetGroup) |
| `data[].underlyingInfoLong.prices` | object | Market prices (priceUsd, priceUsd24h, priceChange24h) |
| `data[].underlyingInfoLong.oraclePrice` | object | On-chain oracle prices (oraclePrice, oraclePriceUsd) |
| `data[].underlyingInfoShort` | object | Debt asset metadata including token info, market prices, and oracle prices |
| `data[].underlyingInfoShort.asset` | object | Token metadata (address, symbol, name, decimals, logoURI, assetGroup) |
| `data[].underlyingInfoShort.prices` | object | Market prices (priceUsd, priceUsd24h, priceChange24h) |
| `data[].underlyingInfoShort.oraclePrice` | object | On-chain oracle prices (oraclePrice, oraclePriceUsd) |
| `actions` | null |  |

**Example response**

```json
{
  "success": true,
  "data": [
    {
      "chainId": "1",
      "lender": "AAVE_V3",
      "marketLongUid": "string",
      "marketShortUid": "string",
      "marketNameLong": "string",
      "marketNameShort": "string",
      "curatorNameLong": "string",
      "curatorNameShort": "string",
      "assetLong": "string",
      "assetShort": "string",
      "assetGroupLong": "string",
      "assetGroupShort": "string",
      "symbolLong": "string",
      "nameLong": "string",
      "symbolShort": "string",
      "nameShort": "string",
      "collateralFactorLong": 0.94,
      "borrowCollateralFactorLong": 0.92,
      "borrowFactorLong": 1,
      "collateralDisabledLong": true,
      "debtDisabledLong": true,
      "collateralFactorShort": 0.94,
      "borrowCollateralFactorShort": 0.92,
      "borrowFactorShort": 1,
      "collateralDisabledShort": true,
      "debtDisabledShort": true,
      "eModeConfigId": "string",
      "eMode": "string",
      "aprBase": 1,
      "aprTotal": 1,
      "maxLeverage": 1,
      "ltv": 1,
      "depositRateLong": 1,
      "variableBorrowRateShort": 1,
      "intrinsicYieldLong": 1,
      "intrinsicYieldShort": 1,
      "variableBorrowDisabledShort": true,
      "termsShort": [
        {
          "termId": 2,
          "depositApr": 1,
          "available": 1,
          "durationDays": 7,
          "durationSecs": 604800,
          "apr": 3.85,
          "aprAtAmount": 1,
          "fillable": 1,
          "capped": true,
          "ladder": [
            {
              "apr": 1,
              "units": "string",
              "assets": 1
            }
          ]
        }
      ],
      "fixedTerm": {
        "model": "term",
        "maturity": 1,
        "fees": {},
        "earlyRepay": {},
        "provider": {},
        "auction": {
          "status": "open",
          "canBorrow": true,
          "canLend": true,
          "secondsUntilClose": 263000,
          "implications": [
            "string"
          ],
          "id": "string",
          "startTime": 1,
          "revealTime": 1,
          "endTime": 1,
          "minBorrowAmount": "1000000000",
          "minLendAmount": "1000000000"
        }
      },
      "rewardAprLong": 1,
      "rewardAprShort": 1,
      "rewardsLong": [
        {}
      ],
      "rewardsShort": [
        {}
      ],
      "totalDepositsLong": 1,
      "totalDebtLong": 1,
      "totalLiquidityLong": 1,
      "totalDepositsShort": 1,
      "totalDebtShort": 1,
      "totalLiquidityShort": 1,
      "totalDepositsUsdLong": 1,
      "totalDebtUsdLong": 1,
      "totalLiquidityUsdLong": 1,
      "totalDepositsUsdShort": 1,
      "totalDebtUsdShort": 1,
      "totalLiquidityUsdShort": 1,
      "borrowLiquidityShort": 1,
      "withdrawLiquidityLong": 1,
      "depositableLong": 1,
      "utilizationLong": 1,
      "utilizationShort": 1,
      "underlyingInfoLong": {
        "asset": {},
        "prices": {},
        "oraclePrice": {}
      },
      "underlyingInfoShort": {
        "asset": {},
        "prices": {},
        "oraclePrice": {}
      }
    }
  ]
}
```

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