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"
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
  }
}

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"
  }
}

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