Get data
Fetch Midnight market, position, offer, and quote data through the API.
How to query Morpho Midnight data with the API?
For the Python examples, install Requests with pip install requests.
The executable examples below use full identifiers captured from live API responses. Replace the example wallet with the connected wallet. Market admission, offers and liquidity change over time; refresh market IDs from the listings and maker/group IDs from takeable offers when reusing these examples. Response samples are snapshots; the positions list sample shows its first item only.
Discovery & listing
List all markets
Public APIReturns all Midnight markets, optionally filtered by chain, loan token, or collateral. Supported chains: Ethereum (1), Base (8453), Arc (5042), Robinhood Chain (4663), Tempo (4217) and Arbitrum (42161).
All markets:
# All markets on Ethereum mainnet
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets?chain_ids=1"Filtered by token:
# USDC markets on Base with wETH as collateral
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets?chain_ids=8453&loan_assets=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&collateral_assets=0x4200000000000000000000000000000000000006"Get market detail
Public APIImmutable configuration for a single market: market family, loan token, maturity, collaterals (with LLTV, liquidation cursor, oracle), and gates. Does not include fees or total units (those live on the state endpoint).
A market ID stops resolving once its market matures and leaves the Router policy, so the IDs on this page are examples. Before calling a per-market route, take a live market_id from List policy-admitted books or List all markets.
GET /v0/midnight/markets/{market-id}
Each entry in the response's collaterals list carries exactly these fields:
token, lltv, liquidation_cursor, oracle
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33"// Response:
{
"data": {
"chain_id": 8453,
"market_id": "0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33",
"market_family_id": "0x56aa8ebe5a2c03d9c3e58f001e29517b60d09a86e0d44582e5a7375ac975429e",
"loan_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"collaterals": [
{
"token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"lltv": "980000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x4429112b3C00b40Cf295db81cfcdE39d7d5ADC1d"
},
{
"token": "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
"lltv": "625000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x96F1485DAf396c2ab7e53DC76d7B330143Cb2269"
}
],
"maturity": 1806073200,
"rcf_threshold": "900000000",
"enter_gate": "0x0000000000000000000000000000000000000000",
"liquidator_gate": "0x0000000000000000000000000000000000000000"
}
}Market state & metrics
Get market state
Public APILive market state: total units outstanding, fee configuration, and tick granularity. Separated from the market definition because these values change over time.
GET /v0/midnight/markets/{market-id}/state
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/state"// Response:
{
"data": {
"chain_id": 8453,
"market_id": "0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33",
"market_family_id": "0x56aa8ebe5a2c03d9c3e58f001e29517b60d09a86e0d44582e5a7375ac975429e",
"total_units": "972690079",
"tick_granularity": 4,
"settlement_fee_schedule": [
{
"time_to_maturity_days": 0,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 1,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 7,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 30,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 90,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 180,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 360,
"fee_cbp": "0"
}
],
"current_settlement_fee_wad": "0",
"current_settlement_fee_cbp": "0",
"continuous_fee_rate": "0",
"last_indexed_block": "59110752"
}
}Offers & rates
List policy-admitted books
Public APIThe endpoint returns only active maturities admitted by the current policy. Unlisted and past maturities stay excluded even when requested with ids; if a maturity leaves the policy, its books disappear immediately, including books with existing offers.
Each book includes the top 3 ask and bid levels. Sorting: Sort by comma-separated fields (`id`, `ask`, `bid`, `maturity`). Prefix a field with `-` for descending. Max 3 fields.
By maturity:
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books?chain_ids=8453&loan_tokens=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&sort=maturity"By best lend rate:
# Sort by best ask (lowest price = highest lend rate)
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books?chain_ids=8453&loan_tokens=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&sort=ask"Get full book for a market
Public APIEach level sums all offers at that tick. Levels returned per side: Maximum levels returned per side. Default: 100. Maximum: 6745 (ticks 0 through 6744, inclusive).
GET /v0/midnight/books/{market-id}
Each price level carries exactly these fields:
tick, price, units, assets, count
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33?depth=50"// Response:
{
"data": {
"market_id": "0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33",
"chain_id": 8453,
"midnight": "0xadedd8ab6de832766fedf0fac4992e5c4d3ea18a",
"loan_token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"collaterals": [
{
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"lltv": "980000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x4429112b3c00b40cf295db81cfcde39d7d5adc1d"
},
{
"token": "0x940181a94a35a4569e4529a3cdfb74e38fd98631",
"lltv": "625000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x96f1485daf396c2ab7e53dc76d7b330143cb2269"
}
],
"maturity": 1806073200,
"rcf_threshold": "900000000",
"enter_gate": "0x0000000000000000000000000000000000000000",
"liquidator_gate": "0x0000000000000000000000000000000000000000",
"asks": [
{
"tick": 4240,
"price": "986992700000000000",
"units": "616039688",
"assets": "608026675",
"count": 1
},
{
"tick": 4248,
"price": "987494700000000000",
"units": "356650391",
"assets": "352190371",
"count": 1
}
],
"bids": [
{
"tick": 4160,
"price": "980735600000000000",
"units": "53021426",
"assets": "52000000",
"count": 1
},
{
"tick": 4100,
"price": "974191500000000000",
"units": "103675715",
"assets": "101000000",
"count": 1
},
{
"tick": 4052,
"price": "967438700000000000",
"units": "104399380",
"assets": "101000000",
"count": 1
},
{
"tick": 4012,
"price": "960522100000000000",
"units": "105151147",
"assets": "101000000",
"count": 1
},
{
"tick": 3968,
"price": "951317000000000000",
"units": "106168607",
"assets": "101000000",
"count": 1
},
{
"tick": 3820,
"price": "903296200000000000",
"units": "553528290",
"assets": "500000000",
"count": 1
}
]
}
}Compute rates from prices (TTM = seconds to maturity):
// lend rate (from asks): (1 / (price / 1e18) - 1) × 365×86400 / TTM
// borrow rate (from bids): (1 / (price / 1e18) - 1) × 365×86400 / TTMGet one side of the book
Public API{side} is one of asks, bids.
GET /v0/midnight/books/{market-id}/{side}
# Just the asks (lender opportunities)
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/asks?depth=100"# Just the bids (borrower opportunities)
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/bids?depth=100"Quotes & execution
Get a quote (execution plan)
Public APIGiven a target amount (in assets or units) and a side, the Router returns execution-ready takeable offers sorted by best price with fallback excess.
The side names the offers you take: borrow from bids (offers to lend), or lend into asks (offers to borrow). Use the same public API host for both.
GET /v0/midnight/books/{market-id}/{side}/quote
limit: Maximum number of best-priced takeable offers the quote may walk and return. Returned prices and availability describe exactly this window, and a request that cannot fill within limit offers returns 422. Maximum: 10000. Default: 10000.
Each takeable offer's offer struct carries exactly these fields:
market, buy, maker, max_units, start, expiry, tick, group, callback, callback_data, receiver_if_maker_is_seller, ratifier, reduce_only, max_assets, continuous_fee_cap
Lend (take asks):
# "I want to lend 1 USDC" → take asks
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/asks/quote?assets=1000000&slippage=0.5&limit=10000"// Response:
{
"data": {
"average_best_price": "986993400962121168",
"average_worst_price": "987495346428179958",
"available_assets": "960217046",
"available_units": "972690079",
"takeable_offers": [
{
"units": "616039688",
"offer": {
"market": {
"chain_id": 8453,
"midnight": "0xadedd8ab6de832766fedf0fac4992e5c4d3ea18a",
"loan_token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"collaterals": [
{
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"lltv": "980000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x4429112b3c00b40cf295db81cfcde39d7d5adc1d"
},
{
"token": "0x940181a94a35a4569e4529a3cdfb74e38fd98631",
"lltv": "625000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x96f1485daf396c2ab7e53dc76d7b330143cb2269"
}
],
"maturity": 1806073200,
"rcf_threshold": "900000000",
"enter_gate": "0x0000000000000000000000000000000000000000",
"liquidator_gate": "0x0000000000000000000000000000000000000000"
},
"buy": false,
"maker": "0x7016ade82460af4a081d80eaef51d686f79dfce7",
"max_units": "616039688",
"max_assets": "0",
"start": 1795007873,
"expiry": 1795015132,
"tick": 4240,
"group": "0x2f193625055572eca8564c286fc7d1609ea40031e350764d48f524028f74632e",
"callback": "0x0000000000000000000000000000000000000000",
"callback_data": "0x",
"receiver_if_maker_is_seller": "0x7016ade82460af4a081d80eaef51d686f79dfce7",
"ratifier": "0xd6e70365c8e8dda9a4ca662c07bbe663b017755e",
"reduce_only": true,
"continuous_fee_cap": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
"ratifier_data": "0x000000000000000000000000000000000000000000000000000000000000001c251a955a5af12189e39d9c5ac5fab09e65a7eed241a7ab12c664eb169b20a9e150d80962366bff7f333cb72f255df79f853113cb0a093cb873ee1bb71e1e76c3522f05214a1c6e3428b9a925359a00cb0843306f8cb342b98a3a7d2a4193f60e000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000008171e6861962ba32a5f70db06251cdc1a2e9d4c347695b559ce5775296290e4d66d4e44e31edc5eb16c4ad450d2d430f28b654cdf3df9942c24c9923ee0a676631d3a6e603752e1b10536a74abac927a5ae179a8601e20df04be197d9f630c92d084b5cf173558dc43fadfff89fe4443725af550a2cd3373638c8c0d19832a7fc931be8b86edfc1905a3da64844a1cdb0bddb19b2096581397873873ba198ab6e9de03080a0c83f83ff549b893ff028f729883060a25812c596db7db34770c694f5bc14e42328204f85d6370ddef49253b30e0d1b33e5e84e3ffbbbc6873cc83e46b3bc10fae002c2880abd8b7aabcd169b35fd717f919baba200ecf203c2e9dd",
"valid_until": 1795015132,
"market_id": "0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33",
"warning": null
},
{
"units": "356650391",
"offer": {
"market": {
"chain_id": 8453,
"midnight": "0xadedd8ab6de832766fedf0fac4992e5c4d3ea18a",
"loan_token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"collaterals": [
{
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"lltv": "980000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x4429112b3c00b40cf295db81cfcde39d7d5adc1d"
},
{
"token": "0x940181a94a35a4569e4529a3cdfb74e38fd98631",
"lltv": "625000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0x96f1485daf396c2ab7e53dc76d7b330143cb2269"
}
],
"maturity": 1806073200,
"rcf_threshold": "900000000",
"enter_gate": "0x0000000000000000000000000000000000000000",
"liquidator_gate": "0x0000000000000000000000000000000000000000"
},
"buy": false,
"maker": "0x7016ade82460af4a081d80eaef51d686f79dfce7",
"max_units": "356650391",
"max_assets": "0",
"start": 1795007873,
"expiry": 1795015132,
"tick": 4248,
"group": "0x2539e474b54d6ab28d79fc0d5936c52074174a543a0914d4ac39f110c1b376bf",
"callback": "0x0000000000000000000000000000000000000000",
"callback_data": "0x",
"receiver_if_maker_is_seller": "0x7016ade82460af4a081d80eaef51d686f79dfce7",
"ratifier": "0xd6e70365c8e8dda9a4ca662c07bbe663b017755e",
"reduce_only": true,
"continuous_fee_cap": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
"ratifier_data": "0x000000000000000000000000000000000000000000000000000000000000001c251a955a5af12189e39d9c5ac5fab09e65a7eed241a7ab12c664eb169b20a9e150d80962366bff7f333cb72f255df79f853113cb0a093cb873ee1bb71e1e76c3522f05214a1c6e3428b9a925359a00cb0843306f8cb342b98a3a7d2a4193f60e000000000000000000000000000000000000000000000000000000000000006200000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000887c57f98579920b8c7b663efcded0b0ee1e27b5b35a3b36ff32f6a993f5c56016d4e44e31edc5eb16c4ad450d2d430f28b654cdf3df9942c24c9923ee0a676631d3a6e603752e1b10536a74abac927a5ae179a8601e20df04be197d9f630c92d084b5cf173558dc43fadfff89fe4443725af550a2cd3373638c8c0d19832a7fc931be8b86edfc1905a3da64844a1cdb0bddb19b2096581397873873ba198ab6e9de03080a0c83f83ff549b893ff028f729883060a25812c596db7db34770c694f5bc14e42328204f85d6370ddef49253b30e0d1b33e5e84e3ffbbbc6873cc83e46b3bc10fae002c2880abd8b7aabcd169b35fd717f919baba200ecf203c2e9dd",
"valid_until": 1795015132,
"market_id": "0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33",
"warning": null
}
]
}
}Borrow (take bids):
# "I want to borrow 1 USDC" → take bids
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/bids/quote?assets=1000000&slippage=0.5&limit=10000"# Same response shape - but offers have buy=true (lenders' buy-offers)By units:
# Quote by units instead of assets
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/asks/quote?units=1000000"If liquidity changes, HTTP 422 with INSUFFICIENT_LIQUIDITY is an expected outcome, handled as follows:
if (response.status === 422) {
const body = await response.json();
if (body.error?.code === "INSUFFICIENT_LIQUIDITY") {
return { quote: null, reason: "insufficient_liquidity" };
}
}See Get quote for parameters and response fields.
List takeable offers (raw)
Public APIIndividual executable offers with the full offer struct and ratifier data. Use when building custom routing or analysis.
By market side:
GET /v0/midnight/books/{market-id}/{side}/takeable-offers
Across markets, by maker:
GET /v0/midnight/takeable-offers
By market side:
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/books/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/asks/takeable-offers"By maker:
# All active offers from a specific maker
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/takeable-offers?maker=0x7016ade82460af4a081d80eaef51d686f79dfce7&limit=100"Takeability warnings
Public APIThe warning field explains why only part of an offer, or none of it, can be taken right now. Makers get it on their own offers from GET /v0/midnight/takeable-offers. A null value means the offer's complete remaining capacity is takeable. A non-null value gives the primary reason why more of the active offer is not currently takeable. On the book listing (GET /v0/midnight/books/{market-id}/{side}/takeable-offers) and quote (GET /v0/midnight/books/{market-id}/{side}/quote) endpoints, warning is deprecated: it will become null, then be removed. Use units there instead. On the book listing, it gives how much of each offer can be taken. On a quote, it's a per-offer cap, and the caps together can exceed the requested size. See Takeability warnings for how to read and surface them.
| Code | Meaning |
|---|---|
| Limit how much can be taken (possibly to zero) | |
MAKER_LIQUIDITY | Maker-controlled liquidity cannot back more units. |
MAKER_ALLOWANCE | The maker's loan-token approval cannot back more units. |
SOURCE_LIQUIDITY | The underlying protocol cannot currently release more liquidity. |
REDUCE_ONLY | More units would increase rather than reduce the maker's position. |
POSITION_CAPACITY | The maker's credit or debt position has no room for more units. |
AMOUNT_ROUNDING | Asset and unit rounding prevents another meaningful unit from executing. |
SINGLE_TAKE_LIMIT | The offer exceeds the maximum units allowed in one take. |
| None of it can be taken right now | |
CALLBACK_NOT_REGISTERED | The callback was not registered to the maker before the offer was submitted. |
RATIFIER_NOT_AUTHORIZED | The maker does not currently authorize the offer's ratifier. |
SIMULATION_FAILED | Router simulation failed for the offer's group and market. |
RESTRICTED_TAKER | The offer is reserved for a specific taker and cannot be taken publicly. Only the reserved taker can take it. |
ROOT_CANCELED | The offer's Ecrecover Merkle root was permanently canceled. |
ROOT_NOT_RATIFIED | The maker has not currently ratified the offer's Setter Merkle root. |
SIGNER_NOT_AUTHORIZED | The maker does not currently authorize the offer tree's signer. |
BELOW_MINIMUM_SIZE | The offer was removed after its supported size fell below policy minimum. |
For codes in the "Limit how much can be taken" group, the offer's units on GET /v0/midnight/takeable-offers shows how much can still be taken.
Some codes also return extra fields (limit_units, root, signer, observed_assets, minimum_assets). They're deprecated and not listed here, so rely on code alone.
Example:
// One takeable offer (excerpt; other fields omitted, values illustrative)
{
"market_id": "0xa249f0b3ffe8891c96ec93fd9c7d00e479da04e4ffe2f2502ea0e5db8eabc75d",
"units": "1000000",
// offer, ratifier_data, ...
"warning": {
"code": "MAKER_ALLOWANCE"
}
}Position tracking
List user positions
Public APIReturns all positions for a user across markets. Includes cost_basis, effective_apr and effective_rate_wad inline. To show a position's rate, use effective_apr: it is the APR the Morpho app displays. effective_rate_wad compounds, so it won't match. See Rate conventions. Position types: lend, borrow, collateral_only.
GET /v0/midnight/users/{user-address}/positions
All positions (first page):
This request fetches the first page of up to 100 positions. Pass the returned cursor as the
cursor query parameter on each subsequent request until the returned cursor is null.
Keep the same filters on each request.
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0x7016adE82460aF4a081d80EaEf51d686f79Dfce7/positions"// Response excerpt (first position only):
{
"cursor": null,
"data": [
{
"chain_id": 8453,
"market_id": "0x360146c649059bdbd396a2bffe4160c28de5a816873812df1867ece7d3a81476",
"user_address": "0x7016adE82460aF4a081d80EaEf51d686f79Dfce7",
"created_at": 1794576077,
"loan_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"maturity": 1795791600,
"type": "lend",
"credit": "25820024",
"pending_fee": "0",
"last_loss_factor": "0",
"loss_factor": "0",
"debt": "0",
"cost_basis": "25768989000000000000000000",
"effective_rate_wad": "52780652751216032",
"effective_apr": 0.05148582132374547,
"collaterals": []
}
]
}Lend only:
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0x7016adE82460aF4a081d80EaEf51d686f79Dfce7/positions?types=lend"Borrow only:
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0xA447e2B48AC061f3489443273e489731CccEeEaA/positions?types=borrow&collateral_assets=0x940181a94A35A4569E4529A3CDfB74e38FD98631"Get position detail
Public APIRaw position state in a specific market. Does not include cost_basis or effective_rate_wad (use the performance endpoint for those).
GET /v0/midnight/markets/{market-id}/users/{user-address}/position
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/users/0xA447e2B48AC061f3489443273e489731CccEeEaA/position"// Response:
{
"data": {
"chain_id": 8453,
"market_id": "0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33",
"user_address": "0xA447e2B48AC061f3489443273e489731CccEeEaA",
"loan_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"maturity": 1806073200,
"type": "borrow",
"credit": "0",
"pending_fee": "0",
"last_loss_factor": "0",
"loss_factor": "0",
"debt": "972690079",
"collaterals": [
{
"token": "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
"amount": "4416167930063692494204"
}
],
"last_indexed_block": "59110763"
}
}Get position performance
Public APICost basis and rates for P&L computation. Uses average cost accounting. To show the rate, use effective_apr, not the compounded effective_rate_wad; see Rate conventions.
GET /v0/midnight/markets/{market-id}/users/{user-address}/position/performance
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/users/0x7016adE82460aF4a081d80EaEf51d686f79Dfce7/position/performance"// Response:
{
"data": {
"chain_id": 8453,
"market_id": "0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33",
"user_address": "0x7016adE82460aF4a081d80EaEf51d686f79Dfce7",
"type": "lend",
"accounting_method": "average_cost",
"cost_basis": "950000000000000000000000000",
"effective_rate_wad": "59401172435254016",
"effective_apr": 0.05839646031731141,
"last_indexed_block": "59110752"
}
}List all positions in a market
Public APIFind all borrowers, cross-reference with oracle prices to find unhealthy positions.
This request fetches the first page of up to 100 positions. Pass the returned cursor as the
cursor query parameter on each subsequent request until the returned cursor is null.
Keep the same filters on each request.
GET /v0/midnight/markets/{market-id}/positions
# First page of borrowers in this market
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/positions?types=borrow"# Active positions only (market not yet matured)
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/positions?types=borrow&active_only=true"Transaction history
User transactions
Public APIAll onchain events for a user. Filter by event_types to focus on specific actions. Valid values:
borrow, lend, exit_lend_primary, exit_lend_secondary, exit_borrow_primary, exit_borrow_secondary, partial_liquidation, full_liquidation, withdraw_collateral, supply_collateral, roll
lend- entered a lending position (bought units)exit_lend_primary- redeemed credit (1:1 withdrawal)exit_lend_secondary- sold credit units earlyborrow- entered a borrowing position (sold units)exit_borrow_primary- repaid debtexit_borrow_secondary- bought units to close debt earlysupply_collateral- deposited collateralwithdraw_collateral- withdrew collateralpartial_liquidation/full_liquidation- liquidations; events include the borrower, collateral, seized assets, repaid units, post-maturity mode, bad debt, and latest loss factorroll- the borrower's Midnight debt and collateral were rolled into a Morpho Blue market under a rolling configuration the borrower authorized; events include the destination market, debt and collateral moved, and the incentive paid to the caller
GET /v0/midnight/users/{user-address}/transactions
Lending activity:
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0x7016adE82460aF4a081d80EaEf51d686f79Dfce7/transactions?event_types=lend,exit_lend_primary,exit_lend_secondary&maturities=1806073200"Borrowing activity:
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0xA447e2B48AC061f3489443273e489731CccEeEaA/transactions?event_types=borrow,exit_borrow_primary,exit_borrow_secondary,supply_collateral,withdraw_collateral"Market transactions
Public APIGET /v0/midnight/markets/{market-id}/transactions
# All activity in a market since a specific time
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets/0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33/transactions?created_at_gte=1719000000"Offer management
List offer groups
Public APITrack a maker's consumption groups and which offers belong to them. statuses selects one or
more lifecycle states (groups matching any of them are returned) and defaults to active.
Groups can also be narrowed to verified Blue callbacks with
callback_type=blue_buy, and to Midnight market families with market_family_ids.
This request fetches the first page of up to ten groups. Pass the returned cursor as the
cursor query parameter on each subsequent request until the returned cursor is null.
GET /v0/midnight/users/{user-address}/offer-groups
# First page of active offer groups for this maker (default lifecycle state)
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0x7016ade82460af4a081d80eaef51d686f79dfce7/offer-groups?limit=10"# Active offer groups filtered by market and group
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0x7016ade82460af4a081d80eaef51d686f79dfce7/offer-groups?statuses=active&market_ids=0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33&groups=0x5f23555fd8d51bedbf50d4979c1ccee98ce4fe6ffdb60f1c58724a5d96f487da&loan_assets=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&collateral_assets=0x940181a94A35A4569E4529A3CDfB74e38FD98631&maturities=1806073200"# Active offer group with verified Blue-buy callbacks
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/users/0x7016ade82460af4a081d80eaef51d686f79dfce7/offer-groups?statuses=active&callback_type=blue_buy&market_ids=0xad8c6d6df8c5a9a446127faec2622a3871b39fefa63a13eee62d8497086f2d33&groups=0x5f23555fd8d51bedbf50d4979c1ccee98ce4fe6ffdb60f1c58724a5d96f487da&limit=1"The statuses=expired filter is also accepted. The executable examples use active groups captured from live offers.
Mempool
Validate offers before publishing
Public APICheck whether the Router will index your offers. Payload is version byte + 4-byte big-endian gzip length + gzip(ABI-encoded (Offer, bytes ratifierData)[]). Optionally pass a timestamp to validate against a specific policy snapshot.
POST /v0/midnight/mempool/validate
Both requests deliberately validate a five-byte frame with no compressed content. HTTP 200 reports a payload_decompression issue; these offers would not be indexed. A payload that passes validation returns an empty issues list.
Current policy:
curl --silent --show-error --include --request POST "https://api.morpho.org/v0/midnight/mempool/validate" \
--header "Content-Type: application/json" \
--data-raw '{"chain_id": 8453, "payload": "0x0100000000"}'{
"data": {
"issues": [
{
"rule": "payload_decompression",
"details": null
}
]
}
}At a specific time:
# Validate against the policy snapshot active at a specific time
# Uses the latest 15:00 UTC boundary at or before the given timestamp
curl --silent --show-error --include --request POST "https://api.morpho.org/v0/midnight/mempool/validate?timestamp=2026-06-28T12:00:00Z" \
--header "Content-Type: application/json" \
--data-raw '{"chain_id": 8453, "payload": "0x0100000000"}'Pagination & filtering
Public APIList endpoints support cursor-based pagination. The response includes a cursor field - pass it as a query parameter to get the next page.
# First page
curl --silent --show-error --include "https://api.morpho.org/v0/midnight/markets?chain_ids=8453&limit=1"// Response:
{
"cursor": "eyJzIjoidG90YWxfdW5pdHMiLCJkIjoiZGVzYyIsInYiOiIxNDgxMDgzMDcxNjY4MjI3NDQzMDYiLCJ2TnVsbCI6ZmFsc2UsImkiOls4NDUzLCIweGJiOWVlMTNmZmU1MmY0ZDUyMzExNzc1YjFiZDRmYTMwOWU0MDJmZDAxZGRmYTE2NTAyM2M0MmRkNmU1YzA1MWQiXSwiZiI6IkZTbkVQbGxPNGFLd0ItM0tmcVo2UnQifQ",
"data": [
{
"chain_id": 8453,
"market_id": "0xbb9ee13ffe52f4d52311775b1bd4fa309e402fd01ddfa165023c42dd6e5c051d",
"market_family_id": "0x997f1f3780de5ff952ed877f3255a64cc6b142cccc84b1fc9f12a1b4fafcd4a8",
"loan_token": "0x4200000000000000000000000000000000000006",
"maturity": 1795791600,
"rcf_threshold": "4000000000000000000",
"enter_gate": "0x0000000000000000000000000000000000000000",
"liquidator_gate": "0x0000000000000000000000000000000000000000",
"total_units": "148108307166822744306",
"tick_granularity": 4,
"settlement_fee_schedule": [
{
"time_to_maturity_days": 0,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 1,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 7,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 30,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 90,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 180,
"fee_cbp": "0"
},
{
"time_to_maturity_days": 360,
"fee_cbp": "0"
}
],
"current_settlement_fee_wad": "0",
"current_settlement_fee_cbp": "0",
"continuous_fee_rate": "0",
"listed": false,
"lend_depth": null,
"borrow_depth": null,
"collaterals": [
{
"token": "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
"lltv": "945000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0xB03855Ad5AFD6B8db8091DD5551CAC4ed621d9E6"
},
{
"token": "0xFa750DD0099eAdB72d401244De73ce7B89edf90F",
"lltv": "980000000000000000",
"liquidation_cursor": "300000000000000000",
"oracle": "0xa02f629871be35d6db0F88C944cF955554Ec87c0"
}
]
}
]
}Set CURSOR to the cursor returned by your own first request (export CURSOR='...'), not the captured sample above. If it is null, there are no more pages.
# Next page - pass the cursor from your first response
curl --silent --show-error --include --get "https://api.morpho.org/v0/midnight/markets?chain_ids=8453&limit=1" \
--data-urlencode "cursor=${CURSOR:?Set CURSOR to the cursor returned by the first request}"// cursor is null when there are no more pagesThe markets list carries the richest filter set - other list endpoints follow the same conventions:
All these parameters are optional query parameters.
| Name | Type | Description |
|---|---|---|
chain_ids | array | Filter by chain ids. Supported chains: Ethereum (1), Base (8453), Arc (5042), Robinhood Chain (4663), Tempo (4217), and Arbitrum (42161). Required when any address filter is provided. |
market_ids | array | Filter by Midnight market ids. These ids are globally unique. |
market_family_ids | array | Filter by Midnight market family ids. A family contains markets whose immutable parameters differ only by maturity. |
loan_assets | array | Filter by loan token addresses. Combine with chain_ids; lowercase input is checksummed. |
collateral_assets | array | Filter by collateral token addresses. Combine with chain_ids; lowercase input is checksummed. |
oracle_addresses | array | Filter by collateral oracle addresses. Combine with chain_ids; lowercase input is checksummed. |
enter_gates | array | Filter by enter gate addresses. Combine with chain_ids; lowercase input is checksummed. |
liquidator_gates | array | Filter by liquidator gate addresses. Combine with chain_ids; lowercase input is checksummed. |
maturities | array | Filter by exact maturity timestamps, in unix seconds. |
active_only | string | When true, enforces maturity strictly after the current timestamp. |
maturity_gte | anyOf | Filter for maturities greater than or equal to this unix timestamp. |
maturity_lte | anyOf | Filter for maturities less than or equal to this unix timestamp. |
total_units_gte | string | Filter for total units greater than or equal to this value. |
total_units_lte | string | Filter for total units less than or equal to this value. |
lend_depth_gte | string | Filter for cached lend-side offer-book depth, in loan-token units, greater than or equal to this value. |
lend_depth_lte | string | Filter for cached lend-side offer-book depth, in loan-token units, less than or equal to this value. |
borrow_depth_gte | string | Filter for cached borrow-side offer-book depth, in loan-token units, greater than or equal to this value. |
borrow_depth_lte | string | Filter for cached borrow-side offer-book depth, in loan-token units, less than or equal to this value. |
listed | string | Filter by listing status. When true, returns only markets surfaced by the app trust layer; when false, only unlisted markets. Omit to return both. |
sort_by | string | Sort field for cursor pagination. |
sort_direction | string | Sort direction for cursor pagination. |
limit | integer | Maximum number of items to return. |
cursor | string | Opaque cursor from a previous page response. |