@cfxlabsinc/b2b-services
    Preparing search index...

    Implements read only methods for swap quotes

    The operations in this class assume that the Customer is already validated (both AuthN and AuthZ).

    Hierarchy (View Summary)

    Index
    db: B2bDatabase
    jupiterClient: JupiterSwapClient
    pricers: { cfx: VenuePricer; jupiter: VenuePricer } = ...

    One pricer per venue: adding a venue to SWAP_VENUES adds one here.

    productQuoteService: ProductQuoteService
    solanaTokenMintAddressService: SolanaTokenMintAddressService
    solanaTokenService: SolanaTokenQueryService
    instance: (...args: []) => SwapQuoteQueryService = ...

    The process service: the shared database, the quote engine, Jupiter and the token services.

    • The audit-free engine estimate() of the swap: the route, fees and amount math, with no product_quote row and no limit enforcement. Refuses SWAP_NOT_AVAILABLE, as create() does, when the engine will not price the swap.

      Parameters

      • __namedParameters: Omit<PriceArgs, "quote" | "targetToken"> & {
            customerId: string;
            entityId: string;
        }

      Returns Promise<{ ok: true; value: QuoteOutput } | { error: ServiceError; ok: false }>

    • Ephemeral (and entity-agnostic) quote of target amount and fees

      Parameters

      • __namedParameters: {
            customerId: string;
            entityId: string;
            sourceAmount: BigNumber;
            sourceCurrency: "MOVEUSD" | "USDC" | "SOL" | "WETH" | "WBTC";
            targetCurrency: "MOVEUSD" | "USDC" | "SOL" | "WETH" | "WBTC";
        }

      Returns Promise<
          | { ok: true; value: SwapEstimate }
          | {
              error:
                  | ServiceError<
                      "INVALID_INPUT"
                      | "INVALID_AMOUNT"
                      | "SWAP_NOT_AVAILABLE",
                  >
                  | PricingError;
              ok: false;
          },
      >

      invalidAmount

    • Parameters

      • __namedParameters: { customerId: string; entityId?: string; id: string }
        • customerId: string
        • OptionalentityId?: string

          The identity or organization that must own the quote.

        • id: string

      Returns Promise<{ ok: true; value: SwapQuote | null }>