MidnightBooks

Get quote

Returns a bundle-ready quote for the requested assets or units, plus expected best/worst average prices and maximum executable liquidity.

The endpoint optimizes for successful target-aware bundle execution under contention: takeable_offers are best-priced per-offer caps and their total can exceed the requested target, giving a bundle executor fallback liquidity when earlier offers are partially consumed or skipped.

To keep the returned set executable in a bounded number of takeable-offer executions, offers smaller than one thousandth of the requested size are omitted; requests below 1000 base units are exempt (the floor rounds down to zero). At most the 10,000 best-priced takeable offers are returned, which is far above any executable fill and only trims a flooded tail.

Use the returned takeable offers with a bundle abstraction that stops at your requested target and applies your max/min asset or unit protections. If you execute takeable offers independently with Midnight.take, do not submit every returned unit blindly: clamp each offer to your remaining target and current takeability, or you may execute more than intended.

If the requested size cannot be fully satisfied at quote time under the selected guard, the endpoint returns 422.

GET
/v0/midnight/books/{market-id}/{side}/quote

Path Parameters

side?string

Book side to quote (asks or bids).

Value in"asks" | "bids"
market-id?string

Market ID whose book to quote (market_id in responses).

Query Parameters

average_worst_price?string

Optional average weighted-price guard for the requested target. asks must execute at or below this value; bids must execute at or above it. The guard applies to the expected target fill, not to the sum of all returned takeable-offer caps. Mutually exclusive with slippage.

slippage?string

Optional slippage percentage used to derive average_worst_price from the quoted average_best_price for the requested target. Slippage constrains the expected target fill, not the sum of all returned takeable-offer caps. For asks, the guard increases by slippage; for bids, it decreases by slippage. Range: 0.1 to 100, with at most one decimal place. Mutually exclusive with average_worst_price.

units?string

Target unit amount. Provide exactly one of assets or units.

assets?string

Target assets amount. Provide exactly one of assets or units.

Response Body

application/json

application/json

application/json

application/json

curl -X GET "https://api.morpho.org/v0/midnight/books/0x1234567890123456789012345678901234567890123456789012345678901234/asks/quote?average_worst_price=1000000000000000000&slippage=0.5&units=1000000000000000000&assets=1000000000000000000"
{
  "data": {
    "available_assets": "1500000000000000000",
    "available_units": "1500000000000000000",
    "average_best_price": "1000000000000000000",
    "average_worst_price": "1000000000000000000",
    "takeable_offers": [
      {
        "market_id": "0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
        "offer": {
          "buy": false,
          "callback": "0x0000000000000000000000000000000000000000",
          "callback_data": "0x",
          "continuous_fee_cap": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
          "expiry": 1761922799,
          "group": "0x000000000000000000000000000000000000000000000000000000000008b8f4",
          "maker": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
          "market": {
            "chain_id": 8453,
            "collaterals": [
              {
                "liquidation_cursor": "250000000000000000",
                "lltv": "860000000000000000",
                "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
                "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751"
              }
            ],
            "enter_gate": "0x0000000000000000000000000000000000000000",
            "liquidator_gate": "0x0000000000000000000000000000000000000000",
            "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
            "maturity": 1761922799,
            "midnight": "0x2F7a3AA739ba5792Ce1b4eA046117f2C0095BCA6",
            "rcf_threshold": "0"
          },
          "max_assets": "0",
          "max_units": "369216000000000000000000",
          "ratifier": "0x0000000000000000000000000000000000000002",
          "receiver_if_maker_is_seller": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
          "reduce_only": false,
          "start": 1761922790,
          "tick": 495
        },
        "ratifier_data": "0x000000000000000000000000000000000000000000000000000000000000001b12121212121212121212121212121212121212121212121212121212121212123434343434343434343434343434343434343434343434343434343434343434",
        "units": "369216000000000000000000"
      }
    ]
  }
}
{
  "error": {
    "code": "VALIDATION_ERROR",
    "details": [
      {
        "field": "limit",
        "issue": "Limit must be greater than 0."
      }
    ],
    "message": "Limit must be greater than 0.",
    "request_id": "req-123"
  }
}
{
  "error": {
    "code": "VALIDATION_ERROR",
    "details": [
      {
        "field": "limit",
        "issue": "Limit must be greater than 0."
      }
    ],
    "message": "Limit must be greater than 0.",
    "request_id": "req-123"
  }
}
{
  "error": {
    "code": "VALIDATION_ERROR",
    "details": [
      {
        "field": "limit",
        "issue": "Limit must be greater than 0."
      }
    ],
    "message": "Limit must be greater than 0.",
    "request_id": "req-123"
  }
}