Plans
Plan Swap and Supply
Create a plan to swap an asset and supply the result to a protocol
POST
Plan Swap and Supply
Plan Swap and Supply
Creates a plan that atomically swaps one asset for another and immediately supplies the result into a DeFi yield protocol. This is useful for one-step “zap” operations where you have one asset but want to earn on another. Returns a plan ID and an EIP-712 digest that must be signed to authorize execution.Request
Path parameters
| Parameter | Type | Description |
|---|---|---|
account_id | string | The sub-account ID |
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sell_asset | string | Yes | Asset to sell (e.g., "WETH") |
sell_amount | string | Yes | Amount to sell in the asset’s smallest unit |
buy_asset | string | Yes | Asset to buy and supply (e.g., "USDC") |
protocol | string | Yes | Protocol to supply into: "compound", "aave", or "morpho_vault" |
network | string | Yes | Target network (e.g., "base", "mainnet"). Funds on other chains are bridged automatically. |
market | string | No | Market reference (required for morpho_vault) |
Examples
Response (201 Created)
Response fields
| 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 |
Errors
| Status | Code | Description |
|---|---|---|
| 400 | invalid_params | Missing required parameters, unsupported protocol, or missing market for morpho_vault |
| 400 | plan_failed | Could not generate a valid plan (e.g., insufficient balance) |
| 400 | no_wallet | Account has no wallets |
| 408 | timeout | Folio computation timed out |
| 422 | swap_quote_failed | Could not fetch a swap quote from the DEX aggregator |
Notes
- Plans expire after 2 minutes. Sign and execute via Execute Plan before expiry.
- The swap and supply happen atomically in a single transaction.
- A 0.15% Legend fee is applied to the buy side of the swap quote.
- The full swapped amount (after fee) is deposited into the protocol.
- When using
morpho_vaultas the protocol, you must provide themarketparameter.
Plan Swap and Supply