Withdraw a lend offer's supplied funding
Recovers the entire supply position held by the account's funding address in a variable-rate market.
First publish a lend offer funded from a variable-rate market through POST /v0/actions/midnight/offers/lend and retain its funding_address and funding_market; then execute POST /v0/actions/midnight/offers/cancel and confirm cancellation, or wait for the offers to expire; finally call this route using that funding_address and the id of that funding_market. This route does not cancel offers or check their cancellation/expiry. POSITION_EMPTY means there is nothing to withdraw. Returns exactly one call withdrawing all supply shares held by funding_address to account. No amount or signature continuation is accepted. expires_at is an offchain response-validity timestamp, not an onchain deadline. Simulation confirms the burned shares and loan assets received by the account; reverted or unverifiable simulations are rejected.
Authorization
ApiKeyAuth 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/funding/withdraw" \ -H "Content-Type: application/json" \ -d '{ "account": "0x6aBB9Aeb93e9aF04c8D9FD2b84BF6ca8EDC3eAf2", "chain_id": 8453, "funding_address": "0xEd9664ADD48a793A5c3f291FC77e1bF7beB4C4AC", "funding_market": "0x84662b4f95b85d6b082b68d32cf71bb565b3f22f216a65509cc2ede7dccdfe8c" }'{ "data": { "action_id": "act_0123456789abcdef0123456789abcdef", "status": "prepared", "action": "midnight.withdraw_funding", "chain_id": 8453, "account": "0x6aBB9Aeb93e9aF04c8D9FD2b84BF6ca8EDC3eAf2", "expires_at": 1760001800, "funding_address": "0xEd9664ADD48a793A5c3f291FC77e1bF7beB4C4AC", "market": { "id": "0x84662b4f95b85d6b082b68d32cf71bb565b3f22f216a65509cc2ede7dccdfe8c", "loan_asset": { "address": "0x4200000000000000000000000000000000000006" } }, "calls": [ { "id": "call_0", "kind": "withdraw_funding", "to": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb", "data": "0x5c2bea4900000000000000000000000042000000000000000000000000000000000000060000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000b03855ad5afd6b8db8091dd5551cac4ed621d9e600000000000000000000000046415998764c29ab2a25cbea6254146d50d226870000000000000000000000000000000000000000000000000d1d507e40be80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e8d4a51000000000000000000000000000ed9664add48a793a5c3f291fc77e1bf7beb4c4ac0000000000000000000000006abb9aeb93e9af04c8d9fd2b84bf6ca8edc3eaf2", "value": "0" } ], "simulation": { "status": "success", "block": { "number": "21000000", "timestamp": 1760000000 }, "wallet_changes": [ { "asset": { "type": "erc20", "address": "0x4200000000000000000000000000000000000006" }, "difference": "1000000" } ], "position_changes": { "supply_shares": "-1000000000000" }, "effects": { "shares": "1000000000000", "assets": "1000000" } } }}{ "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_CONTINUATION_INVALID", "message": "string", "details": [ { "code": "string", "message": "string", "path": [ "string" ], "rule": "string", "details": { "min_assets": "string", "loan_token": "string" } } ], "request_id": "string" }}{ "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" }}POSTCancel Midnight offer groups
Builds and simulates an unconditional, complete cancellation of one or more offer groups. group_id values come from the Morpho API…
POSTTake a Midnight offer group
Builds and simulates a take of one active Midnight offer group identified by <chain_id>:<group_id>. group_id values come from the Morpho API…