Orchestration API
POST /quote
Returns one or more quotes for a given asset route and amount, including transaction payloads ready to sign.
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.
TypeScript Types: Generate types for this API with a single command. See
Type Generation.
API Reference: For detailed schema definitions and interactive testing,
see the API Reference.
Request
Endpoint
POST /quote
Headers
Content-Type: application/json
Body Parameters
Check the API reference for a detailed list of accepted parameters
Example Request
import type { components } from "./m0-swap"; // From type generation
type Quote = components["schemas"]["Quote"];
const response = await fetch("https://orchestration-api.m0.xyz/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",
quoteType: "fastest",
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"
}
}
]
}
]
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 };
}
Notes
- The
amountInparameter should be provided in the token's smallest unit (e.g., for a 6-decimal token,1000000represents 1 token) - 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