Get position
Detail lookup for a single position by (market-id, user-address).
:market-id is the stable Midnight market id and is globally unique across supported chains. :user-address accepts any casing and is checksummed server-side.
Returns the position inside a data envelope. When the position is closed (no credit, no debt, no remaining collateral) or has never existed for a known market, the endpoint returns zero balances with type: null. Positions with credit == 0 && debt == 0 but non-empty collaterals are returned as type: "collateral_only".
For enterprise access, use https://private.api.morpho.org as the base URL and send your API key in the x-api-key header. Request an API key.
Path Parameters
Midnight market id.
User address for the requested position. Lowercase input is checksummed.
Response Body
application/json
application/json
const baseUrl = "https://api.morpho.org";const marketId = "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738";const userAddress = "0xd4F43105098845fFE89B16E7A3DCdd0A31898118";const url = new URL(`${baseUrl}/v0/midnight/markets/${marketId}/users/${userAddress}/position`);const response = await fetch(url, { headers: { accept: "application/json", },});if (!response.ok) throw new Error(await response.text());const body = await response.json();{
"data": {
"chain_id": 8453,
"market_id": "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738",
"user_address": "0xd4F43105098845fFE89B16E7A3DCdd0A31898118",
"loan_token": "0x4200000000000000000000000000000000000006",
"maturity": 1784300400,
"type": "borrow",
"credit": "0",
"pending_fee": "0",
"last_loss_factor": "0",
"loss_factor": "0",
"debt": "1046492040981691",
"collaterals": [
{
"token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "4000000"
}
],
"last_indexed_block": "48408699"
}
}{
"error": {
"code": "MARKET_NOT_FOUND",
"message": "Market 0x0000000000000000000000000000000000000000000000000000000000000000 not found",
"details": null,
"request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"
}
}