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

    Implements the creation of a Swap via a quote

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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    jupiterClient: JupiterSwapClient
    productQuoteService: ProductQuoteService
    solanaTokenMintAddressService: SolanaTokenMintAddressService
    solanaTokenService: SolanaTokenQueryService

    Methods

    • Parameters

      • __namedParameters: {
            customerId: string;
            entityId: string;
            id: string;
            originator?: string;
            transaction?:
                | Readonly<
                    { messageBytes: TransactionMessageBytes; signatures: SignaturesMap },
                >
                | null;
        }
        • customerId: string
        • entityId: string
        • id: string
        • Optionaloriginator?: string

          Workflow ID of the originator of this quote

          The originating workflows should expose a SWAP_COMPLETED signal that receives Swap (without quote) when the process is completed.

        • Optionaltransaction?:
              | Readonly<
                  { messageBytes: TransactionMessageBytes; signatures: SignaturesMap },
              >
              | null

      Returns Promise<
          | {
              ok: true;
              value: {
                  createdAt: Date;
                  id: string;
                  quote: SwapQuote;
                  receipt?: { id: string; type: "SOLANA_TRANSACTION_SIGNATURE" }[];
                  status: "CREATED" | "PENDING" | "FAILED" | "COMPLETED";
                  updatedAt: Date;
              };
          }
          | {
              error: | ServiceError<"INVALID_TRANSACTION">
              | ServiceError<"NOT_FOUND", { customerId?: string; entityId?: string }>
              | ServiceError<
                  "INSUFFICIENT_FUNDS",
                  { currency: string; walletAddress?: string },
              >
              | ServiceError<"LIMIT_REACHED", { violations: BigNumber }>;
              ok: false;
          },
      >

    • Quote with partially-signed transaction

      Parameters

      • __namedParameters: {
            customerId: string;
            depositId?: string;
            entityId: string;
            source: UnionOmit<SwapSide, "amountAfterFees">;
            target: UnionOmit<SwapSide, "amountAfterFees" | "amount">;
        }

      Returns Promise<
          | { ok: true; value: SwapQuote }
          | {
              error:
                  | ServiceError<
                      "NOT_FOUND",
                      { customerId?: string; entityId?: string },
                  >
                  | ServiceError<
                      "INSUFFICIENT_FUNDS",
                      { currency: string; walletAddress?: string },
                  >
                  | ServiceError<"LIMIT_REACHED", { violations: BigNumber }>
                  | ServiceError<
                      "NO_COUNTRY_FOR_IDENTITY"
                      | "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;
          },
      >

      insufficientFunds

    • 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