Create a plan to repay a borrow and reclaim collateral
| Parameter | Type | Description |
|---|---|---|
account_id | string | The sub-account ID |
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | string | Yes | Amount to repay in the asset’s smallest unit |
asset | string | Yes | Asset being repaid (e.g., "USDC") |
collateral_amount | string | Yes | Collateral to withdraw in its smallest unit |
collateral_asset | string | Yes | Collateral asset (e.g., "WETH") |
network | string | Yes | Target network (e.g., "base", "mainnet"). Funds on other chains are bridged automatically. |
protocol | string | Yes | Lending protocol: "compound" or "morpho" |
market | string | Morpho only | Morpho market ID (0x-prefixed 32-byte hex) |
| Field | Type | Description |
|---|---|---|
plan_id | string | Unique identifier for this plan (pln_ prefix) |
details | object | Transaction details including EIP-712 signing data |
details.eip712_data.digest | string | The hash to sign with the account’s signer key |
expires_at | string | ISO 8601 timestamp — plan must be executed before this time |
| Status | Code | Description |
|---|---|---|
| 400 | invalid_params | Missing required parameters, unsupported protocol, or invalid market ID |
| 400 | plan_failed | Could not generate a valid plan (e.g., no outstanding borrow) |
| 400 | no_wallet | Account has no wallets |
| 408 | timeout | Folio computation timed out |
market parameter is required for Morpho and must be a valid 32-byte market ID.action_type: "COMET_REPAY" (Compound) or "MORPHO_REPAY" (Morpho) in its metadata.