Class 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

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

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

    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>