Docs

Build Morpho Blue refinance calls

Builds and simulates wallet calls for moving an account's complete live debt and collateral between distinct existing markets on the registered Morpho Blue deployment for the same chain.


POST
/v0/actions/blue/markets/{market-selector}/refinance

The position is always migrated in full. destination_borrow_assets equals the repaid source assets plus referral_fee_assets. The API uses only zero-penalty shared liquidity, so no withdrawal penalty is financed. Any signature_mode other than none requests Morpho authorization typed data instead of an authorization call when available.

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

Path Parameters

market-selector*string

Morpho Blue market selector formatted as <chain_id>:<market_id>. The chain ID is at most 9007199254740991.

Match^(?:[1-9][0-9]{0,14}|[1-8][0-9]{15}|900[0-6][0-9]{12}|90070[0-9]{11}|90071[0-8][0-9]{10}|900719[0-8][0-9]{9}|9007199[0-1][0-9]{8}|90071992[0-4][0-9]{7}|900719925[0-3][0-9]{6}|9007199254[0-6][0-9]{5}|90071992547[0-3][0-9]{4}|9007199254740[0-8][0-9]{2}|90071992547409[0-8][0-9]{1}|9007199254740990|9007199254740991):0x[0-9a-fA-F]{64}$

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/blue/markets/{market-selector}/refinance" \  -H "Content-Type: application/json" \  -d '{    "account": "0xfeed46c11F57B7126a773EeC6ae9cA7aE1C03C9a",    "destination_market": "8453:0x1c21c59df9db44bf6f645d854ee710a8ca17b479451447e9f56758aee10a2fad"  }'

{  "data": {    "action_id": "act_0123456789abcdef0123456789abcdef",    "status": "prepared",    "action": "blue.refinance",    "chain_id": 8453,    "account": "0xfeed46c11F57B7126a773EeC6ae9cA7aE1C03C9a",    "expires_at": 4000000000,    "source_market": {      "id": "0x0ca10126f6c94cbd9cf0a48cc9516ae5e3dec5aa68303e6d988ee37c5149bf0d",      "loan_asset": {        "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"      },      "collateral_asset": {        "address": "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22"      }    },    "destination_market": {      "id": "0x1c21c59df9db44bf6f645d854ee710a8ca17b479451447e9f56758aee10a2fad",      "loan_asset": {        "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"      },      "collateral_asset": {        "address": "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22"      }    },    "calls": [      {        "id": "call_0",        "kind": "authorization",        "to": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",        "data": "0xeecea0000000000000000000000000004d28d900e381ece4b351302f1abe588496793a2b0000000000000000000000000000000000000000000000000000000000000001",        "value": "0"      },      {        "id": "call_1",        "kind": "blue_refinance",        "to": "0x4D28D900e381eCE4B351302f1Abe588496793A2b",        "data": "0x9834e387000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec2200000000000000000000000097ff9cbd7e77348b2b8ffbb883bf29452ad1829500000000000000000000000046415998764c29ab2a25cbea6254146d50d226870000000000000000000000000000000000000000000000000aaf96eb9d0d0000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000b40d93f44411d8c09ad17d7f88195ef9b05ccd9600000000000000000000000046415998764c29ab2a25cbea6254146d50d226870000000000000000000000000000000000000000000000000bef55718ad600000000000000000000000000000000000000000000000000000bdd91f852f580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ee6b28000000000000000000000000000000000000000000000000000000000000000000ee6b280022221111",        "value": "0"      }    ],    "simulation": {      "status": "success",      "block": {        "number": "21000000",        "timestamp": 1760000000      },      "wallet_changes": [],      "position_changes": {        "source": {          "supply_shares": "0",          "borrow_shares": "-1000000000000",          "collateral_assets": "-1079092051947491"        },        "destination": {          "supply_shares": "0",          "borrow_shares": "931118670670",          "collateral_assets": "1079092051947491"        }      },      "effects": {        "collateral_assets": "1079092051947491",        "source_repaid_assets": "1042906",        "source_repaid_shares": "1000000000000",        "referral_fee_assets": "0",        "destination_borrow_assets": "1042906",        "destination_borrow_shares": "931118670670",        "ltv_bps": 2251,        "max_ltv_bps": 8550      }    }  }}

Include destination_market only once in the request body.

{  "error": {    "code": "VALIDATION_FAILED",    "message": "Validation failed",    "details": [      {        "code": "duplicate_key",        "message": "Duplicate JSON key",        "path": [          "destination_market"        ]      }    ],    "request_id": "req_0123456789abcdef"  }}

The selected Morpho Blue market was not found on this chain.

{  "error": {    "code": "MARKET_NOT_FOUND",    "message": "The Morpho Blue market does not exist on this chain.",    "details": null,    "request_id": "req_0123456789abcdef"  }}

Request bodies must not exceed 16384 bytes.

{  "error": {    "code": "PAYLOAD_TOO_LARGE",    "message": "Request body too large.",    "details": [      {        "code": "too_big",        "message": "Request body exceeds the 16384-byte limit",        "path": [          "body"        ]      }    ],    "request_id": "req_0123456789abcdef"  }}

Restart the same action without the continuation, sign the newly returned typed data, then finalize with the new continuation.

{  "error": {    "code": "SIGNATURE_REFRESH_REQUIRED",    "message": "The prepared signature nonce or deadline is no longer usable.",    "details": null,    "request_id": "req_0123456789abcdef"  }}

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"  }}

Chain state is temporarily unavailable; retry.

{  "error": {    "code": "STATE_UNAVAILABLE",    "message": "Chain state is temporarily unavailable.",    "details": null,    "request_id": "req_0123456789abcdef"  }}