Docs

Publish Midnight credit-withdrawal offers

Builds and simulates the calls that publish a public set of reduce-only credit-withdrawal offers priced by offers.type.


POST
/v0/actions/midnight/offers/withdraw

Price offers require a nonzero tick; tick 0 returns 422 ACTION_UNSUPPORTED. Entries may target different markets on one chain when every market uses the same loan token; each offer must expire by its market maturity. Every offer carries the requested credit-unit cap, and fills across all offers in the group count toward one shared total, so the group as a whole fills at most that cap. The offers are reduce-only and cannot open debt. With p2p: true, the offer is intended for direct sharing with a taker and is not checked against public offer-book admission rules.

Authorization

ApiKeyAuth
x-api-key<token>

Send your Morpho-issued key on every action request. JWKS needs no key on every host; public documentation needs no key.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v0/actions/midnight/offers/withdraw" \  -H "Content-Type: application/json" \  -d '{    "account": "0x6aBB9Aeb93e9aF04c8D9FD2b84BF6ca8EDC3eAf2",    "chain_id": 8453,    "amount": {      "unit": "units",      "value": "1000000"    },    "offers": {      "type": "rate",      "entries": [        {          "market_id": "0xcdea4ca06837feca3026b23a95f0bd96c3eabdc77d1211472ce0346fcc200649",          "tick": "5000",          "starts_at": 0,          "expires_at": 1793000000,          "rate_wad": "1000000000"        }      ]    }  }'
{  "data": {    "action_id": "act_0123456789abcdef0123456789abcdef",    "status": "prepared",    "action": "midnight.make_withdraw",    "chain_id": 8453,    "account": "0x6aBB9Aeb93e9aF04c8D9FD2b84BF6ca8EDC3eAf2",    "expires_at": 1760001800,    "offer": {      "groups": [        "0xc85cc2662ff7d3e2fc1637e825c615ae660fdefe763062878c14272482ba4d07"      ],      "entry_count": 1    },    "calls": [      {        "id": "call_0",        "kind": "cancel_and_publish",        "to": "0x0bF30B530f816a619C3F28a3b9f44C441122555D",        "data": "0xb4691380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000003b2fba901c88f026bf50a12c8b28484cd81f95260ab1cbc7548804e8b2a9f3959022bc48913005e60d56c72d2af2e5b9cc0fc36000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000068e77f08000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018601000001811f8b08000000000000036360c00b14f04b3330129027a4df01bf344b0201eb1f10301f0564ed9ef57af2cbf52c276efed56ed99fb3e2ede1579f48d18f61de7d2602ee17ee381173284dfffbe5477fc4cc5fa81e135d97c67fef5f9941527b8f88ba4ad32e5f764aec67606041750f01ff59ebef9a20d3f1416d7fc0429d6e0d0f9f1bf253d50858803f7ef99d08f89f52a0c88acc5bfbf6c6eadc174665f96f3ffc3a32532fc6d76e6117b2bc13a6016cf8cdc7efbdac271b3ee092336fba756eee04fca65301302173b41e7f7c532f1f2074fed50689e83f558bcff3be51c2a5915736a0ce615f034e8359342f644acc4315db6011ba36ea6f76ef0e4ed9aba1326bfcae29de7c862cffab94f702e7bcb5db751d845cee159fabee7cfb931fa7fd33579c3bfe08b7c7b0d9bf403f6946e13ed36bb7f93b4eba9c9f1a1af2a6fd006e13880207b8369e3e1ed2c1f262d3cacf532728edf19868c0fa8c37ecb8aed6a7a73bcff01f2650be10040bf0495acf3a45a1f10c0c009b216e97a00500000000000000000000000000000000000000000000000000000000",        "value": "0"      }    ],    "simulation": {      "status": "success",      "block": {        "number": "21000000",        "timestamp": 1760000000      },      "wallet_changes": [],      "position_changes": {},      "effects": {        "groups": [          "0xc85cc2662ff7d3e2fc1637e825c615ae660fdefe763062878c14272482ba4d07"        ],        "entry_count": 1      }    }  }}
{  "error": {    "code": "REQUEST_ABORTED",    "message": "string",    "details": [      {        "code": "string",        "message": "string",        "path": [          "string"        ],        "rule": "string",        "details": {          "min_assets": "string",          "loan_token": "string"        }      }    ],    "request_id": "string"  }}
{  "error": {    "code": "MARKET_NOT_FOUND",    "message": "string",    "details": [      {        "code": "string",        "message": "string",        "path": [          "string"        ],        "rule": "string",        "details": {          "min_assets": "string",          "loan_token": "string"        }      }    ],    "request_id": "string"  }}
{  "error": {    "code": "PAYLOAD_TOO_LARGE",    "message": "string",    "details": [      {        "code": "string",        "message": "string",        "path": [          "string"        ],        "rule": "string",        "details": {          "min_assets": "string",          "loan_token": "string"        }      }    ],    "request_id": "string"  }}

{  "error": {    "code": "ACTION_UNSUPPORTED",    "message": "This action is not supported.",    "details": null,    "request_id": "req_0123456789abcdef0123456789abcdef"  }}

Empty
{  "error": {    "code": "INTERNAL_ERROR",    "message": "string",    "details": [      {        "code": "string",        "message": "string",        "path": [          "string"        ],        "rule": "string",        "details": {          "min_assets": "string",          "loan_token": "string"        }      }    ],    "request_id": "string"  }}
{  "error": {    "code": "CONTRACT_CODE_MISSING",    "message": "string",    "details": [      {        "code": "string",        "message": "string",        "path": [          "string"        ],        "rule": "string",        "details": {          "min_assets": "string",          "loan_token": "string"        }      }    ],    "request_id": "string"  }}