Skip to content

Get Quote

Retrieves a quote for trading between two assets through the organization API. The request body varies based on the order type.

Request URL

POST https://ddp.definitive.fi/v2/organization/portfolios/{portfolioId}/trade/quote

Path Parameters

ParameterTypeRequiredDescription
portfolioIdstringYesUUID of the portfolio

Base Fields

All order types require these base fields:

FieldTypeRequiredDescription
typestringYes"market", "limit", "twap", "stop", "stop-loss", "take-profit"
chainstringYesChain identifier (e.g., "ethereum", "solana")
targetAssetstringYesAsset to buy or sell
contraAssetstringYesAsset to trade against
qtystringYesAmount to trade
orderSidestringYes"buy" or "sell"
slippageTolerancestringYesMax allowed slippage (e.g., "0.01" = 1%)
maxPriceImpactstringYesMax allowed price impact (e.g., "0.01")

Market Order

{
  type: "market",
  chain: "ethereum",
  targetAsset: "...",
  contraAsset: "...",
  qty: "1000",
  orderSide: "buy",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01"
}

Limit Order

Limit orders require a limit object:

FieldTypeRequiredDescription
limit.pricestringYesLimit price to trigger order
limit.isNotionalbooleanYesWhether price is a notional or exact amount
{
  type: "limit",
  chain: "solana",
  targetAsset: "...",
  contraAsset: "...",
  qty: "100.00",
  orderSide: "sell",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.05",
  limit: {
    price: "0.07",
    isNotional: false
  }
}

TWAP Order

FieldTypeRequiredDescription
durationSecondsnumberYesDuration in seconds
targetTWAPBucketsnumberNoOptional number of buckets
{
  type: "twap",
  chain: "ethereum",
  targetAsset: "...",
  contraAsset: "...",
  qty: "1000",
  orderSide: "buy",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01",
  durationSeconds: 3600,
  targetTWAPBuckets: 6
}

Stop-Loss Order

Stop-loss orders automatically trigger a market order when a price threshold is hit.

FieldTypeRequiredDescription
triggerobjectYesTrigger object with price and isNotional
limitobjectNoOptional fallback trigger
{
  type: "stop-loss",
  chain: "ethereum",
  targetAsset: "...",
  contraAsset: "...",
  qty: "1000",
  orderSide: "sell",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01",
  trigger: {
    price: "1600.00",
    isNotional: true
  },
  limit: {
    price: "1590.00",
    isNotional: true
  }
}

Take Profit Order

Take profit orders automatically sell when the price rises to a target level, allowing you to lock in gains.

FieldTypeRequiredDescription
orderSidestringYesMust be "sell" for take-profit orders
triggerobjectYesPrice trigger to activate the order
limitobjectNoOptional minimum execution price

Examples

Basic take profit (sell SOL when it hits $180):
{
  type: "take-profit",
  chain: "solana",
  targetAsset: "So11111111111111111111111111111111111111112", // SOL
  contraAsset: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
  qty: "0.5",
  orderSide: "sell",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01",
  trigger: {
    price: "180.00",
    isNotional: true // Price in USD
  }
}
Take profit with limit (trigger at $180, min execution price $178):
{
  type: "take-profit",
  chain: "solana",
  targetAsset: "So11111111111111111111111111111111111111112",
  contraAsset: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  qty: "0.5",
  orderSide: "sell",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01",
  trigger: {
    price: "180.00",
    isNotional: true
  },
  limit: {
    price: "178.00", // Minimum price to protect against slippage
    isNotional: true
  }
}
Cross-rate take profit (sell SOL when SOL/ETH ratio hits 0.055):
{
  type: "take-profit",
  chain: "solana",
  targetAsset: "So11111111111111111111111111111111111111112", // SOL
  contraAsset: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", // ETH
  qty: "0.5",
  orderSide: "sell",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01",
  trigger: {
    price: "0.055", // SOL/ETH cross rate
    isNotional: false // Cross-asset price, not USD
  }
}

Stop-Buy Order

Stop-buy orders are triggered when the price reaches a specific threshold, useful for buying breakouts or entering positions when momentum shifts.

FieldTypeRequiredDescription
orderSidestringYesMust be "buy" for stop-buy orders
triggerTypestringYes"upper" or "lower"
triggerobjectYesPrice trigger condition
limitobjectNoOptional limit price

Examples

Basic stop-buy (buy when SOL breaks above $158):
{
  type: "stop",
  chain: "solana",
  targetAsset: "So11111111111111111111111111111111111111112", // SOL
  contraAsset: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
  qty: "0.02",
  orderSide: "buy",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01",
  triggerType: "upper",
  trigger: {
    price: "158.00",
    isNotional: false
  }
}
Stop-buy with limit (triggered at $158, max price $160):
{
  type: "stop",
  chain: "solana",
  targetAsset: "So11111111111111111111111111111111111111112",
  contraAsset: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  qty: "0.02",
  orderSide: "buy",
  slippageTolerance: "0.01",
  maxPriceImpact: "0.01",
  triggerType: "upper",
  trigger: {
    price: "158.00",
    isNotional: false
  },
  limit: {
    price: "160.00",
    isNotional: false
  }
}

Trigger Types

  • "upper": Buy when price breaks above trigger price (breakout strategy)
  • "lower": Buy when price falls below trigger price (dip buying strategy)
 
---
 
## Response
 
```ts
{
  quote: {
    type: "limit",
    chain: "ethereum",
    targetAsset: "...",
    contraAsset: "...",
    qty: "1000",
    orderSide: "buy",
    quoteId: "00000000-0000-0000-0000-000000000004",
    quotedAmountOut: "0.555555",
    quotedPriceImpact: "0.0025",
    slippageTolerance: "0.01",
    maxPriceImpact: "0.01"
    // ...order-type-specific fields
  },
  metadata: {
    toNotional: "1000.00",
    fromNotional: "999.95",
    estimatedPriceImpact: "0.0025",
    estimatedFee: "1.50",
    estimatedFeeNotional: "1.50",
    buyAmount: "0.555555"
  }
}

Field Explanations

trigger vs limit

  • trigger: The price that activates the order. When this price is reached, the order becomes active.
  • limit: Optional constraint on execution price. Protects against slippage by setting a minimum (for sell orders) or maximum (for buy orders) execution price.

Example: Take profit with trigger at $180 and limit at $178:

  • Order activates when SOL hits $180
  • But will only execute if price is $178 or higher (protects against immediate price drop)

isNotional Flag

  • true: Price is in USD (notional value)
  • false: Price is the cross-rate between the two assets

Examples:

  • { price: "180.00", isNotional: true } = SOL at $180 USD
  • { price: "0.055", isNotional: false } = SOL/ETH ratio of 0.055

Order Execution

  • Stop-loss and take-profit without limit: Becomes a market order when triggered (executes immediately at best available price)
  • With limit: Becomes a limit order when triggered (waits for favorable price, may not fill immediately)

Notes

  • Always provide limit.isNotional for limit and stop-loss orders
  • Quotes are time-sensitive and should be submitted immediately
  • You must submit the quote to place the order
  • Order Status: You must poll Order Details to track order status - websocket subscriptions are not yet available