Class TradeAdapterWebsocket

Hierarchy

  • TradeAdapterWebsocket

Implements

Constructors

Properties

activeSubscriptions: Set<string> = ...
config: AdapterConfig = DEFAULT_CONFIG
connectionPromise: Promise<void>
listeners: WebsocketListener[] = []
localNonces: NonceMap = {}
network: "base" | "arbitrum" | "arbitrum-sepolia"
provider: Provider
resubscriptionResults: string[] = []
socket: w3cwebsocket
subscriptionRequests: SubscriptionRequest<any>[] = []

Methods

  • Parameters

    • signerAddress: string
    • accountId: number

    Returns Promise<Bytes>

  • Parameters

    • order: {
          accountId: number;
          accountUser: string;
          createdTimestampUnixMillis: number;
          expiryTimestampUnixMillis: number;
          id: string;
          kind: (({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; })) & (undefined | ({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; }));
          lpId: string;
          nonce: string;
          pair: Pair;
          signature: string;
          size: { amount: BigNumber; unit: "lpc" | "lot"; };
          status: (({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; })) & (undefined | ({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; }));
      }
      • accountId: number
      • accountUser: string
      • createdTimestampUnixMillis: number
      • expiryTimestampUnixMillis: number
      • id: string
      • kind: (({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; })) & (undefined | ({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; }))
      • lpId: string
      • nonce: string
      • pair: Pair
      • signature: string
      • size: { amount: BigNumber; unit: "lpc" | "lot"; }
      • status: (({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; })) & (undefined | ({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; }))

    Returns Promise<PlaceOrderResponse>

  • Parameters

    • cancelOrderId: string
    • cancelSignature: string
    • nonce: string
    • accountId: number
    • accountUser: string
    • newOrder: {
          accountId: number;
          accountUser: string;
          createdTimestampUnixMillis: number;
          expiryTimestampUnixMillis: number;
          id: string;
          kind: (({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; })) & (undefined | ({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; }));
          lpId: string;
          nonce: string;
          pair: Pair;
          signature: string;
          size: { amount: BigNumber; unit: "lpc" | "lot"; };
          status: (({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; })) & (undefined | ({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; }));
      }
      • accountId: number
      • accountUser: string
      • createdTimestampUnixMillis: number
      • expiryTimestampUnixMillis: number
      • id: string
      • kind: (({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; })) & (undefined | ({ kind: "market"; }) | ({ kind: "limit"; args: { limitPrice: BigNumber; }; }) | ({ kind: "stopMarket"; args: { triggerPrice: BigNumber; stopLoss?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: "stopLimit"; args: { triggerPrice: BigNumber; limitPrice: BigNumber; }; }) | ({ kind: "limitTrigger"; args: { triggerPrice: BigNumber; takeProfit?: { kind: "position"; } | { id: string; kind: "order"; } | null | undefined; }; }) | ({ kind: string; }))
      • lpId: string
      • nonce: string
      • pair: Pair
      • signature: string
      • size: { amount: BigNumber; unit: "lpc" | "lot"; }
      • status: (({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; })) & (undefined | ({ status: "open"; content: { status: "placed"; } | { status: "triggered"; content: { triggerPrice: BigNumber; timestampUnixMillis: number; }; }; }) | ({ status: "filled"; content: { price: BigNumber; timestampUnixMillis: number; settlementStatus: { status: "queued"; } | { status: "beforeTx"; } | { status: "indexing"; } | { status: "settled"; content: { ...; }; }; }; }) | ({ status: "cancelled"; content: { timestampUnixMillis: number; reason: string; userCancellation?: { address: string; nonce: string; signature: { v: number; r: string; s: string; }; } | null | undefined; }; }))

    Returns Promise<ReplaceOrderResponse>

  • Private

    Sets up a listener for the subscription. The listener will loop through sever updates for as long as the client keeps the subscription active. When called, this function should not be awaited as it is meant to be executed as a background task.

    Type Parameters

    • C

    Parameters

    Returns Promise<void>

  • Parameters

    • accountId: number
    • liquidityPoolId: string
    • size: {
          amount: BigNumber;
          unit: "lpc" | "lot";
      }
      • amount: BigNumber
      • unit: "lpc" | "lot"
    • pair: Pair
    • accountUser: string
    • signature: string

    Returns Promise<TradeResponse>

  • This function has no validation that the returned type is T

    Type Parameters

    • T

    Parameters

    • requestId: string
    • timeout: number = ...

    Returns {
        cancel: (() => void);
        result: Promise<T>;
    }

    • cancel: (() => void)
        • (): void
        • Returns void

    • result: Promise<T>

Generated using TypeDoc