Skip to main content

Overview

The quote methods return swap quotes with pricing, presets, and auction parameters for cross-chain swaps. A quote must have enableEstimate: true to be used for creating orders.

getQuote

Get a quote for a cross-chain swap.

Parameters

params
QuoteParams
required
Quote request parameters

Response

quote
Quote
Quote object containing swap details

Example

import { SDK } from '@1inch/cross-chain-sdk'

const sdk = new SDK({
  url: 'https://api.1inch.dev/fusion-plus',
  authKey: 'your-api-key'
})

// Get a quote for swapping USDC from Ethereum to Polygon
const quote = await sdk.getQuote({
  srcChainId: 1, // Ethereum
  dstChainId: 137, // Polygon
  srcTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC on Ethereum
  dstTokenAddress: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', // USDC on Polygon
  amount: '1000000', // 1 USDC (6 decimals)
  walletAddress: '0x1234567890123456789012345678901234567890',
  enableEstimate: true // Required to create an order
})

console.log('Quote ID:', quote.quoteId)
console.log('Source amount:', quote.srcTokenAmount.toString())
console.log('Destination amount:', quote.dstTokenAmount.toString())
console.log('Recommended preset:', quote.recommendedPreset)

getQuoteWithCustomPreset

Get a quote with custom auction parameters instead of using the standard presets.

Parameters

params
QuoteParams
required
Quote request parameters (same as getQuote)
body
QuoteCustomPresetParams
required
Custom preset configuration

Response

quote
Quote
Quote object with custom preset applied. The presets.custom field will contain your custom preset.

Example

const quote = await sdk.getQuoteWithCustomPreset(
  {
    srcChainId: 1,
    dstChainId: 137,
    srcTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    dstTokenAddress: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
    amount: '1000000',
    walletAddress: '0x1234567890123456789012345678901234567890',
    enableEstimate: true
  },
  {
    customPreset: {
      auctionDuration: 180, // 3 minutes
      auctionStartAmount: '990000', // Start at 0.99 USDC
      auctionEndAmount: '980000', // End at 0.98 USDC
      points: [
        { toTokenAmount: '985000', delay: 90 }, // 0.985 USDC at 90 seconds
        { toTokenAmount: '982000', delay: 150 } // 0.982 USDC at 150 seconds
      ]
    }
  }
)

console.log('Custom preset:', quote.presets.custom)

Presets

Every quote includes preset configurations that define the auction parameters:

PresetEnum

Available preset types:
  • fast - Quick execution with lower potential returns
  • medium - Balanced speed and returns (usually recommended)
  • slow - Slower execution with potentially better returns
  • custom - Custom auction parameters (only when using getQuoteWithCustomPreset)

Preset Properties

Each preset contains:
auctionDuration
bigint
Duration of the Dutch auction in seconds
startAuctionIn
bigint
Delay before auction starts (in seconds)
initialRateBump
number
Initial rate bump percentage
auctionStartAmount
bigint
Destination token amount at auction start
startAmount
bigint
Destination token amount including gas bump
auctionEndAmount
bigint
Destination token amount at auction end
costInDstToken
bigint
Estimated cost in destination tokens
points
AuctionPoint[]
Points defining the auction curve
allowPartialFills
boolean
Whether partial fills are allowed
allowMultipleFills
boolean
Whether multiple fills are allowed
gasCostInfo
object
Gas cost estimates
exclusiveResolver
EvmAddress | undefined
Address of exclusive resolver (if any)
secretsCount
number
Number of secrets required for this preset

Example: Using Presets

const quote = await sdk.getQuote({
  srcChainId: 1,
  dstChainId: 137,
  srcTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
  dstTokenAddress: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
  amount: '1000000',
  walletAddress: '0x...',
  enableEstimate: true
})

// Access preset information
console.log('Recommended:', quote.recommendedPreset) // e.g., 'medium'

const fastPreset = quote.getPreset('fast')
console.log('Fast auction duration:', fastPreset.auctionDuration)
console.log('Fast allows partial fills:', fastPreset.allowPartialFills)

const mediumPreset = quote.getPreset('medium')
const slowPreset = quote.getPreset('slow')

// Use recommended preset
const recommendedPreset = quote.getPreset(quote.recommendedPreset)

Understanding the Quote Response

Token Amounts

All token amounts are returned as bigint in the token’s smallest unit:
const quote = await sdk.getQuote({ /* ... */ })

// For a token with 6 decimals (like USDC)
const srcAmount = quote.srcTokenAmount // 1000000n = 1 USDC
const dstAmount = quote.dstTokenAmount // 995000n = 0.995 USDC

// Convert to human-readable format
const srcUSDC = Number(srcAmount) / 1e6 // 1.0
const dstUSDC = Number(dstAmount) / 1e6 // 0.995

Auction Mechanics

Cross-chain swaps use a Dutch auction mechanism:
  1. Auction Start: The order becomes available to resolvers at auctionStartAmount
  2. Price Improvement: The price gradually improves (destination amount increases) following the points curve
  3. Auction End: After auctionDuration seconds, the price reaches auctionEndAmount
  4. Resolution: Resolvers compete to fill the order, typically resolving quickly for better margins

Time Locks

Time locks define safety windows for the atomic swap:
const timeLocks = quote.timeLocks

// Source chain time locks (in seconds)
console.log(timeLocks.srcWithdrawal)        // Time before maker can withdraw
console.log(timeLocks.srcPublicWithdrawal)  // Time before anyone can withdraw
console.log(timeLocks.srcCancellation)      // Time before order can be cancelled
console.log(timeLocks.srcPublicCancellation) // Time before public cancellation

// Destination chain time locks
console.log(timeLocks.dstWithdrawal)        // Time before withdrawal on dst
console.log(timeLocks.dstPublicWithdrawal)  // Time before public withdrawal
console.log(timeLocks.dstCancellation)      // Time before cancellation on dst

Safety Deposits

Safety deposits ensure both parties have skin in the game:
const quote = await sdk.getQuote({ /* ... */ })

console.log('Source deposit:', quote.srcSafetyDeposit)
console.log('Destination deposit:', quote.dstSafetyDeposit)
These deposits are refunded upon successful completion of the swap.

Build docs developers (and LLMs) love