getQuoteCustom

Installation

npm install @quickscope/sdk

Usage

Initialization

First, initialize the Quickscope class with your location ("frankfurt" or "nyc") and your API key:

import Quickscope from '@quickscope/sdk';
// OR
const Quickscope = require('@quickscope/sdk');

const quickscope = new Quickscope("frankfurt", "your-api-key");

Method: getQuoteCustom

Description

The getQuoteCustom method fetches a quote for a specific swap route defined by provider, program ID, or pool. This allows for fine-grained control over the swap path, enabling you to bypass routing logic and directly target a venue or route of your choice.

Use this method when you need to test specific liquidity sources, force use of a particular pool, or implement custom routing strategies.


Parameters

{
  from: string;
  to: string;
  amount: number;
  slippage: number;
  provider: string | null;
  programId: string | null;
  pool: string | null;
}
  • from: (string) – The mint address of the token being swapped from.
  • to: (string) – The mint address of the token being swapped to.
  • amount: (number) – The input amount in base units (e.g., lamports).
  • slippage: (number) – Acceptable slippage in basis points (e.g., 50 = 0.5%).
  • provider: (string | null) – The specific liquidity provider (e.g., "orca", "raydium"). Optional.
  • programId: (string | null) – The on-chain program ID to route through. Optional.
  • pool: (string | null) – The UUID of the specific pool to target. Optional.

Returns

Promise<quoteResponseMap>: A promise that resolves to an object containing an array of quote options and optional error fields.

quoteResponseMap Type

export type quoteResponseMap = {
    quote?: null | quoteResult,
    error?: null | string,
    error_code?: null | number | string,
}

quoteResult Type

export type quoteResult = {
    amountIn: number,
    amountOut: number,
    minAmountOut: number,
    prettyAmountOut: number,
    fromMint: SafeMint,
    toMint: SafeMint,
    slippage?: number,
    routes: Route[],
    routePath: string[],
}

SafeMint Type

export type SafeMint = {
    symbol: string;
    name: string;
    uuid: string;
    address: string;
    image: string;
    type: string;
    decimals: number;
}

Route Type

export type Route = {
    uuid: string,
    poolId: string,
    poolType: string,
    provider: string,
    program: string;
    amountIn: number,
    amountOut: number,
    minAmountOut?: number,
    fromMint: string,
    toMint: string,
    priceImpact: number,
    slippage?: number,
    error?: {
        code: string,
        message: string,
    },
}

Example

async function fetchCustomQuotes() {
    try {
        const result = await quickscope.v1.quote.getQuoteCustom({
            from: 'So11111111111111111111111111111111111111112', // SOL
            to: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',   // USDC
            amount: 1000000,
            slippage: 75,
            provider: 'orca',
            programId: null,
            pool: null
        });

        console.log('Best quote:', result.quotes[0]);

        // Example output:
        // {
        //   "quote": {
        //     "amountIn": 100000000,
        //     "amountOut": 15438989,
        //     "minAmountOut": 15130209,
        //     "prettyAmountOut": 15.438989,
        //     "slippage": 200,
        //     "fromMint": {},
        //     "toMint": {},
        //     "routePath": [
        //       "So11111111111111111111111111111111111111112",
        //       "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
        //     ],
        //     "routes": [
        //       {
        //         "uuid": "4279b7a7-76fc-4462-8de6-2c3059668802",
        //         "poolId": "5yuefgbJJpmFNK2iiYbLSpv1aZXq7F9AUKkZKErTYCvs",
        //         "poolType": "damm",
        //         "provider": "meteora",
        //         "program": "meteora_damm",
        //         "amountIn": 100000000,
        //         "amountOut": 15438989,
        //         "minAmountOut": 15130209,
        //         "fromMint": "So11111111111111111111111111111111111111112",
        //         "toMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        //         "priceImpact": 0.009
        //       }
        //     ]
        //   }
        // }
    } catch (error) {
        console.error('Error fetching best quote:', error);
    }
}

fetchCustomQuotes();

Error Handling

This method throws an error if:

  • No route matches the provided constraints
  • The pool or program ID is incorrect
  • The mint pair is unsupported
  • The API encounters an internal error

Use a try/catch block to gracefully handle and debug routing errors.