@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
    • Parameters

      • args: {
            db: B2bDatabase;
            jupiterClient: JupiterSwapClient;
            productQuoteService: ProductQuoteService;
            solanaTokenMintAddressService: SolanaTokenMintAddressService;
            solanaTokenService: SolanaTokenQueryService;
        }

      Returns SwapQuoteQueryService

    db: B2bDatabase
    jupiterClient: JupiterSwapClient
    productQuoteService: ProductQuoteService
    solanaTokenMintAddressService: SolanaTokenMintAddressService
    solanaTokenService: SolanaTokenQueryService
    • Build the SwapEstimate from an already-successful engine result's pricing block. Shared by the preview estimate() (fed by the engine's audit-free estimate()) and the authoritative create-time quote(), so both derive target amount + fees identically. The product_quote audit id is intentionally not threaded here — only create() produces one, and it pins that id onto the persisted swap_quote row directly.

      Parameters

      • __namedParameters: {
            quote: QuoteShape;
            sourceAmount: number;
            sourceCurrency: "MOVEUSD" | "USDC" | "SOL" | "WETH" | "WBTC";
            sourceToken: TokenData;
            targetCurrency: "MOVEUSD" | "USDC" | "SOL" | "WETH" | "WBTC";
            targetToken: TokenData;
        }

      Returns Promise<
          | { ok: true; value: SwapEstimate }
          | {
              error:
                  | ServiceError<"INVALID_INPUT" | "INVALID_AMOUNT">
                  | ServiceError<
                      "INVALID_AMOUNT_AFTER_FEES",
                      {
                          fees: Fees;
                          sourceAmount: number;
                          sourceAmountAfterFees: number;
                          sourceCurrency: "MOVEUSD"
                          | "USDC"
                          | "SOL"
                          | "WETH"
                          | "WBTC";
                          totalFees: BigNumber;
                      },
                  >;
              ok: false;
          },
      >

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

      Parameters

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

      Returns Promise<
          | { ok: true; value: SwapEstimate }
          | {
              error:
                  | ServiceError<"INVALID_INPUT" | "INVALID_AMOUNT">
                  | ServiceError<
                      "INVALID_AMOUNT_AFTER_FEES",
                      {
                          fees: Fees;
                          sourceAmount: number;
                          sourceAmountAfterFees: number;
                          sourceCurrency: "MOVEUSD"
                          | "USDC"
                          | "SOL"
                          | "WETH"
                          | "WBTC";
                          totalFees: BigNumber;
                      },
                  >;
              ok: false;
          },
      >

      invalidAmount