Docs

Get position

GET
/v0/midnight/markets/{market-id}/users/{user-address}/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".

Path Parameters

market-id*string

Midnight market id.

user-address*string

User address for the requested position. Lowercase input is checksummed.

Response Body

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/v0/midnight/markets/0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738/users/0xd4F43105098845fFE89B16E7A3DCdd0A31898118/position"
{  "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": "VALIDATION_FAILED",    "message": "Validation failed",    "details": [      {        "code": "invalid_string",        "message": "Invalid address",        "path": [          "user-address"        ]      }    ],    "request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"  }}
{  "error": {    "code": "MARKET_NOT_FOUND",    "message": "Market 0x0000000000000000000000000000000000000000000000000000000000000000 not found",    "details": null,    "request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"  }}
{  "error": {    "code": "INTERNAL_ERROR",    "message": "Internal server error",    "details": null,    "request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"  }}