Submit Order
Submit a trade order using a quote obtained from the quote endpoint.
Request URL
POST https://ddp.definitive.fi/v2/portfolio/trade
Example
// First, get a quote
const quoteResponse = await AuthHelpers.signAndSend({
path: "/v2/portfolio/trade/quote",
method: "POST",
body: {
type: "market",
chain: "ethereum",
targetAsset: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
contraAsset: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
qty: "1000",
orderSide: "buy",
slippageTolerance: "0.01",
maxPriceImpact: "0.01"
},
apiKey: process.env.API_KEY,
apiSecret: process.env.API_SECRET,
});
// Then, submit the trade using the quote response
const tradeResponse = await AuthHelpers.signAndSend({
path: "/v2/portfolio/trade",
method: "POST",
body: quoteResponse, // The entire quote response is used as the request body
apiKey: process.env.API_KEY,
apiSecret: process.env.API_SECRET,
});
console.log('Trade Response:', tradeResponse);
Request Body
{
quote: {
type: string, // "market", "limit", "twap", or "stop"
chain: string,
targetAsset: string,
contraAsset: string,
qty: string,
orderSide: string,
quoteId: string,
quotedAmountOut: string,
quotedPriceImpact: string,
maxPriceImpact: string,
slippageTolerance: string,
// Additional fields based on order type
limitPrice?: string,
limitNotionalPrice?: string,
limitNotionalAsset?: string,
stopTrigger?: object,
orderTrigger?: object
},
metadata: {
toNotional: string,
fromNotional: string,
estimatedPriceImpact: string,
estimatedFee: string,
estimatedFeeNotional: string,
buyAmount: string
}
}
Response
{
orderId: string, // e.g. "00000000-0000-0000-0000-000000000001"
status: string, // e.g. "PENDING"
type: string, // e.g. "MARKET"
side: string, // e.g. "BUY"
baseAsset: {
id: string,
name: string,
ticker: string,
address: string,
chain: {
id: string,
name: string,
namespace: string
}
},
quoteAsset: {
id: string,
name: string,
ticker: string,
address: string,
chain: {
id: string,
name: string,
namespace: string
}
},
baseQuantity: number,
quoteQuantity: number,
price: number,
createdAt: string // ISO date string
}