@raintree-technology/perps 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,10 +65,9 @@ export class DecibelWsFeed extends EventEmitter {
65
65
  return;
66
66
  }
67
67
  log.info(`WebSocket connecting: ${this.wsUrl}`);
68
- const options = this.bearerToken
69
- ? { headers: { "Sec-WebSocket-Protocol": `decibel, ${this.bearerToken}` } }
70
- : undefined;
71
- this.ws = options ? new WebSocket(this.wsUrl, options) : new WebSocket(this.wsUrl);
68
+ this.ws = this.bearerToken
69
+ ? new WebSocket(this.wsUrl, ["decibel", this.bearerToken])
70
+ : new WebSocket(this.wsUrl);
72
71
  this.ws.on("open", () => {
73
72
  log.info("WebSocket connected");
74
73
  this.startPing();
@@ -157,18 +156,34 @@ export class DecibelWsFeed extends EventEmitter {
157
156
  this.emit("account_positions", { accountAddr: topic.split(":")[1], data: payload });
158
157
  return;
159
158
  }
159
+ if (topic.startsWith("user_positions:")) {
160
+ this.emit("account_positions", { accountAddr: topic.split(":")[1], data: payload });
161
+ return;
162
+ }
160
163
  if (topic.startsWith("account_open_orders:")) {
161
164
  this.emit("account_open_orders", { accountAddr: topic.split(":")[1], data: payload });
162
165
  return;
163
166
  }
167
+ if (topic.startsWith("user_open_orders:")) {
168
+ this.emit("account_open_orders", { accountAddr: topic.split(":")[1], data: payload });
169
+ return;
170
+ }
164
171
  if (topic.startsWith("order_updates:")) {
165
172
  this.emit("order_updates", { accountAddr: topic.split(":")[1], data: payload });
166
173
  return;
167
174
  }
175
+ if (topic.startsWith("user_order_history:")) {
176
+ this.emit("order_updates", { accountAddr: topic.split(":")[1], data: payload });
177
+ return;
178
+ }
168
179
  if (topic.startsWith("user_trades:")) {
169
180
  this.emit("user_trades", { accountAddr: topic.split(":")[1], data: payload });
170
181
  return;
171
182
  }
183
+ if (topic.startsWith("user_active_twaps:")) {
184
+ this.emit("user_active_twaps", { accountAddr: topic.split(":")[1], data: payload });
185
+ return;
186
+ }
172
187
  if (topic.startsWith("notifications:")) {
173
188
  this.emit("notifications", { accountAddr: topic.split(":")[1], data: payload });
174
189
  return;
@@ -2,7 +2,7 @@
2
2
  * Decibel Adapter
3
3
  * Implements PerpDEXAdapter interface for Decibel (Aptos)
4
4
  */
5
- import { type Balance, type CancelOrderParams, type ExchangeConfig, type ExchangeInfo, type FundingPayment, type FundingRate, type MarginType, type Market, type ModifyOrderParams, type Order, type OrderBook, type OrderParams, type PerpDEXAdapter, type Position, type PublicTrade, type SubscriptionCallbacks, type Ticker, type Trade, type Unsubscribe, type MMPConfig, type MMPStatus, type TWAPParams, type TWAPStatus } from "./interface.js";
5
+ import { type Balance, type CancelOrderParams, type ExchangeConfig, type ExchangeInfo, type FundingPayment, type FundingRate, type MarginType, type Market, type ModifyOrderParams, type Order, type OrderBook, type OrderParams, type PerpDEXAdapter, type Position, type PublicTrade, type SubscriptionCallbacks, type Ticker, type Trade, type Unsubscribe, type TWAPParams, type TWAPStatus } from "./interface.js";
6
6
  export declare class DecibelAdapter implements PerpDEXAdapter {
7
7
  readonly info: ExchangeInfo;
8
8
  private config;
@@ -19,6 +19,8 @@ export declare class DecibelAdapter implements PerpDEXAdapter {
19
19
  private readonly assetContextsByMarketAddr;
20
20
  private assetContextsTimestamp;
21
21
  private readonly trackedMarketAddrs;
22
+ private readonly depthAggregationSize;
23
+ private readonly twapStatusById;
22
24
  private readonly tickerSubscribers;
23
25
  private readonly orderBookSubscribers;
24
26
  private readonly globalSubscribers;
@@ -45,19 +47,15 @@ export declare class DecibelAdapter implements PerpDEXAdapter {
45
47
  cancelAllOrders(market?: string): Promise<number>;
46
48
  setLeverage(market: string, leverage: number): Promise<void>;
47
49
  setMarginType(market: string, type: MarginType): Promise<void>;
48
- modifyOrder(_params: ModifyOrderParams): Promise<Order>;
50
+ modifyOrder(params: ModifyOrderParams): Promise<Order>;
49
51
  batchPlaceOrders(paramsList: OrderParams[]): Promise<Order[]>;
50
52
  batchCancelOrders(paramsList: CancelOrderParams[]): Promise<boolean[]>;
51
- cancelAllAfter(_timeoutMs: number): Promise<void>;
52
53
  getOrderHistory(market?: string, limit?: number): Promise<Order[]>;
53
- getFundingHistory(_market?: string, _limit?: number): Promise<FundingPayment[]>;
54
+ getFundingHistory(market?: string, limit?: number): Promise<FundingPayment[]>;
54
55
  getPublicTrades(market: string, limit?: number): Promise<PublicTrade[]>;
55
- setMMP(_config: MMPConfig): Promise<void>;
56
- getMMP(_market: string): Promise<MMPStatus>;
57
- resetMMP(_market: string): Promise<void>;
58
- placeTWAP(_params: TWAPParams): Promise<TWAPStatus>;
59
- cancelTWAP(_twapId: string): Promise<boolean>;
60
- getTWAPStatus(_twapId: string): Promise<TWAPStatus | null>;
56
+ placeTWAP(params: TWAPParams): Promise<TWAPStatus>;
57
+ cancelTWAP(twapId: string): Promise<boolean>;
58
+ getTWAPStatus(twapId: string): Promise<TWAPStatus | null>;
61
59
  updateIsolatedMargin(_market: string, _amount: string): Promise<void>;
62
60
  subscribe(callbacks: SubscriptionCallbacks): Unsubscribe;
63
61
  subscribeOrderBook(market: string, callback: (book: OrderBook) => void): Unsubscribe;
@@ -70,6 +68,7 @@ export declare class DecibelAdapter implements PerpDEXAdapter {
70
68
  private handleWsAccountOpenOrders;
71
69
  private handleWsUserTrades;
72
70
  private handleWsOrderUpdate;
71
+ private handleWsActiveTwaps;
73
72
  private handleWsNotification;
74
73
  private resolveNetwork;
75
74
  private loadMarkets;
@@ -83,6 +82,12 @@ export declare class DecibelAdapter implements PerpDEXAdapter {
83
82
  private toPosition;
84
83
  private toOrder;
85
84
  private toTrade;
85
+ private toTwapStatus;
86
+ private mapTwapState;
87
+ private cacheTwapStatus;
88
+ private findAndCacheTwap;
89
+ private normalizeTwapLookupId;
90
+ private isMatchingTwapLookupId;
86
91
  private resolveMarketSymbol;
87
92
  private mapOrderStatus;
88
93
  private mapOrderType;