Skip to main content
POST
/
accounts
/
{account_id}
/
plan
/
add-backing
Plan Add Backing
curl --request POST \
  --url https://api.example.com/accounts/{account_id}/plan/add-backing

Plan Add Backing

Creates a plan to add backing (collateral) to an existing Morpho leveraged position. This improves the position’s health factor without changing leverage. Returns a plan ID and an EIP-712 digest that must be signed to authorize execution.

Request

POST /accounts/:account_id/plan/add-backing

Path parameters

ParameterTypeDescription
account_idstringThe sub-account ID

Body parameters

ParameterTypeRequiredDescription
exposure_assetstringYesThe position’s exposure asset (e.g., "WETH")
backing_assetstringYesThe backing/collateral asset (e.g., "USDC")
market_idstringYesMorpho market ID (0x-prefixed 32-byte hex)
amountstringYesAmount of backing asset to add in its smallest unit
is_shortbooleanYestrue if this is a short position, false for long
networkstringYesNetwork name (e.g., "base", "mainnet")

Examples

curl -X POST https://prime-api.legend.xyz/accounts/acc_2o0yiljtp378/plan/add-backing \
  -H "Authorization: Bearer $LEGEND_QUERY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "exposure_asset": "WETH",
    "backing_asset": "USDC",
    "market_id": "0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc",
    "amount": "1000000000",
    "is_short": false,
    "network": "base"
  }'
Response (201 Created)
{
  "plan_id": "pln_71mcui082png",
  "details": {
    "quark_operation_actions": [...],
    "eip712_data": {
      "digest": "0x8a3f...b7c2",
      "domain_separator": "0x...",
      "hash_struct": "0x..."
    }
  },
  "expires_at": "2025-06-15T10:32:00Z"
}

Response fields

FieldTypeDescription
plan_idstringUnique identifier for this plan (pln_ prefix)
detailsobjectTransaction details including EIP-712 signing data
details.eip712_data.digeststringThe hash to sign with the account’s signer key
expires_atstringISO 8601 timestamp — plan must be executed before this time

Errors

StatusCodeDescription
400invalid_paramsMissing required parameters or invalid market ID
400plan_failedCould not generate a valid plan
400no_walletAccount has no wallets
408timeoutFolio computation timed out

Notes

  • Plans expire after 2 minutes. Sign and execute via Execute Plan before expiry.
  • The market_id must match the Morpho market of the existing position.
  • Use Plan Withdraw Backing to remove collateral from a position.