POST /quote
This endpoint returns one or more quotes for a given asset route and amount. Each quote includes the expected output amount, estimated fill time, and transaction payloads ready to be signed and submitted to the blockchain.
Request
Endpoint
POST /quote
Headers
Content-Type: application/json
x-api-key: YOUR_API_KEY
Body Parameters
| Field | Type | Required | Description |
|---|---|---|---|
route | Route | Yes | The source and destination assets, each a { chain, address } pair |
amountIn | string | Yes | Input amount in the token's smallest unit |
sender | string | Yes | The wallet address sending the input asset |
recipient | string | No | The address receiving the output asset (defaults to sender) |
maxNumQuotes | number | No | Maximum number of quotes to return (default 1) |
providers | ProvidersParams | No | include or exclude lists of providers to constrain routing (set at most one) |
Check the API reference for detailed schema definitions.
Example Request
import type { components } from "./m0-swap"; // From type generation
type Quote = components["schemas"]["Quote"];
const response = await fetch("https://gateway.m0.xyz/v1/orchestration/quote", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": "YOUR_API_KEY",
},
body: JSON.stringify({
route: {
source: {
chain: "Ethereum",
address: "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b", // M token
},
destination: {
chain: "Base",
address: "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b", // M token
},
},
amountIn: "1000000", // 1 M (6 decimals)
sender: "0xYourWalletAddress",
maxNumQuotes: 1,
}),
});
const quotes: Quote[] = await response.json();
Example Response
[
{
"route": {
"source": {
"chain": "Ethereum",
"address": "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b"
},
"destination": {
"chain": "Base",
"address": "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b"
}
},
"recipient": "0xYourWalletAddress",
"amountIn": "1000000",
"amountOut": "999500",
"estFillTime": 180,
"payloads": [
{
"provider": "m-wormhole-portal",
"annotation": "Bridge M from Ethereum to Base",
"data": {
"type": "evm",
"chain": "Ethereum",
"chainId": 1,
"to": "0x1234567890abcdef...",
"data": "0xabcdef...",
"value": "0"
}
}
]
}
]
Error Responses
All errors share the { code, message, requestId } body shape. Branch on code rather than on
the HTTP status.
| Status | Code | Description |
|---|---|---|
400 | BadQuoteRequest | Malformed or invalid body (missing fields, same source and destination, both include and exclude set, unsupported asset) |
404 | NoQuotesAvailable | The request was valid but no provider could produce a quote for this route and amount |
500 | QuoteError | Unexpected internal failure while computing quotes — retrying may succeed |
Executing Quote Payloads
Once you have a quote, you can execute its payloads using your preferred chain interface.
Here is an example executing a payload on Base using Viem.
EVM Payload Execution
import type { components } from "./m0-swap"; // From type generation
import { createPublicClient, http } from "viem";
import { base } from "viem/chains";
type EvmPayload = components["schemas"]["EvmPayload"];
async function executeEvmPayload(
payload: EvmPayload,
account: ReturnType<typeof privateKeyToAccount>,
) {
const client = createPublicClient({
chain: base,
transport: http(),
});
// Send the transaction
const hash = await client.sendTransaction({
to: payload.to as `0x${string}`,
data: payload.data as `0x${string}`,
value: BigInt(payload.value),
});
// Wait for confirmation
const receipt = await client.waitForTransactionReceipt({
hash,
confirmations: 1,
});
return { hash, receipt };
}
Filtering Providers
Use the optional providers field to control which liquidity providers are used when generating
quotes. You can either include only specific providers or exclude certain ones.
Check the API reference for all supported providers and their identifiers.
Include Only Specific Providers
const body = JSON.stringify({
route: {
/* ... */
},
amountIn: "1000000",
sender: "0xYourWalletAddress",
providers: {
include: ["m-wormhole-portal", "m-swap-facility"],
},
});
Exclude Specific Providers
const body = JSON.stringify({
route: {
/* ... */
},
amountIn: "1000000",
sender: "0xYourWalletAddress",
providers: {
exclude: ["wormhole-cctp"],
},
});
include and exclude are provided, include takes precedence — only the listed
providers will be used, and exclude is ignored.Notes
- The
amountInparameter should be provided in the token's smallest unit (e.g., for a 6-decimal token,1000000represents 1 token) - Results are ranked by best
amountOut, fastestestFillTime, and fewest payloads (in that order), and the response is capped atmaxNumQuotes(default1) - Payloads should be executed in order - wait for each transaction to confirm before sending the next
- Cross-chain quotes may include multiple payloads (e.g., approve + bridge)
- The
estFillTimeis an estimate in seconds for the entire route to complete