@blockworks-foundation/mango-feeds
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -18,2 +18,15 @@ import { ReconnectingWebsocketFeed } from './util'; | ||
} | ||
interface OrderbookL3Update { | ||
market: string; | ||
side: 'bid' | 'ask'; | ||
additions: Order[]; | ||
removals: Order[]; | ||
slot: number; | ||
writeVersion: number; | ||
} | ||
interface Order { | ||
price: number; | ||
quantity: number; | ||
ownerPubkey: string; | ||
} | ||
interface OrderbookL2Checkpoint { | ||
@@ -27,6 +40,16 @@ market: string; | ||
} | ||
interface OrderbookL3Checkpoint { | ||
market: string; | ||
side: 'bid' | 'ask'; | ||
bids: Order[]; | ||
asks: Order[]; | ||
slot: number; | ||
writeVersion: number; | ||
} | ||
export declare class OrderbookFeed extends ReconnectingWebsocketFeed { | ||
private _subscriptions?; | ||
private _onL2Update; | ||
private _onL3Update; | ||
private _onL2Checkpoint; | ||
private _onL3Checkpoint; | ||
constructor(url: string, options?: OrderbookFeedOptions); | ||
@@ -36,5 +59,7 @@ subscribe(subscriptions: OrderbookFeedSubscribeParams): void; | ||
onL2Update(callback: (update: OrderbookL2Update) => void): void; | ||
onL3Update(callback: (update: OrderbookL3Update) => void): void; | ||
onL2Checkpoint(callback: (checkpoint: OrderbookL2Checkpoint) => void): void; | ||
onL3Checkpoint(callback: (checkpoint: OrderbookL3Checkpoint) => void): void; | ||
} | ||
export {}; | ||
//# sourceMappingURL=orderbook.d.ts.map |
@@ -8,9 +8,28 @@ "use strict"; | ||
} | ||
function isOrderbookL3Update(obj) { | ||
return obj.additions !== undefined && obj.removals !== undefined; | ||
} | ||
function isOrderbookL2Checkpoint(obj) { | ||
return obj.bids !== undefined && obj.asks !== undefined; | ||
return (obj.bids !== undefined && | ||
obj.asks !== undefined && | ||
obj.bids.every((bid) => bid.length() == 2) && | ||
obj.asks.every((ask) => ask.length() == 2)); | ||
} | ||
function isOrderbookL3Checkpoint(obj) { | ||
return (obj.bids !== undefined && | ||
obj.asks !== undefined && | ||
obj.bids.every((order) => isOrder(order)) && | ||
obj.asks.every((order) => isOrder(order))); | ||
} | ||
function isOrder(obj) { | ||
return (obj.price !== undefined && | ||
obj.quantity !== undefined && | ||
obj.ownerPubkey !== undefined); | ||
} | ||
class OrderbookFeed extends util_1.ReconnectingWebsocketFeed { | ||
_subscriptions; | ||
_onL2Update = null; | ||
_onL3Update = null; | ||
_onL2Checkpoint = null; | ||
_onL3Checkpoint = null; | ||
constructor(url, options) { | ||
@@ -23,5 +42,11 @@ super(url, options?.reconnectionIntervalMs, options?.reconnectionMaxAttempts); | ||
} | ||
else if (isOrderbookL3Update(data) && this._onL3Update) { | ||
this._onL3Update(data); | ||
} | ||
else if (isOrderbookL2Checkpoint(data) && this._onL2Checkpoint) { | ||
this._onL2Checkpoint(data); | ||
} | ||
else if (isOrderbookL3Checkpoint(data) && this._onL3Checkpoint) { | ||
this._onL3Checkpoint(data); | ||
} | ||
}); | ||
@@ -57,6 +82,12 @@ if (this._subscriptions !== undefined) { | ||
} | ||
onL3Update(callback) { | ||
this._onL3Update = callback; | ||
} | ||
onL2Checkpoint(callback) { | ||
this._onL2Checkpoint = callback; | ||
} | ||
onL3Checkpoint(callback) { | ||
this._onL3Checkpoint = callback; | ||
} | ||
} | ||
exports.OrderbookFeed = OrderbookFeed; |
@@ -18,2 +18,15 @@ import { ReconnectingWebsocketFeed } from './util'; | ||
} | ||
interface OrderbookL3Update { | ||
market: string; | ||
side: 'bid' | 'ask'; | ||
additions: Order[]; | ||
removals: Order[]; | ||
slot: number; | ||
writeVersion: number; | ||
} | ||
interface Order { | ||
price: number; | ||
quantity: number; | ||
ownerPubkey: string; | ||
} | ||
interface OrderbookL2Checkpoint { | ||
@@ -27,6 +40,16 @@ market: string; | ||
} | ||
interface OrderbookL3Checkpoint { | ||
market: string; | ||
side: 'bid' | 'ask'; | ||
bids: Order[]; | ||
asks: Order[]; | ||
slot: number; | ||
writeVersion: number; | ||
} | ||
export declare class OrderbookFeed extends ReconnectingWebsocketFeed { | ||
private _subscriptions?; | ||
private _onL2Update; | ||
private _onL3Update; | ||
private _onL2Checkpoint; | ||
private _onL3Checkpoint; | ||
constructor(url: string, options?: OrderbookFeedOptions); | ||
@@ -36,5 +59,7 @@ subscribe(subscriptions: OrderbookFeedSubscribeParams): void; | ||
onL2Update(callback: (update: OrderbookL2Update) => void): void; | ||
onL3Update(callback: (update: OrderbookL3Update) => void): void; | ||
onL2Checkpoint(callback: (checkpoint: OrderbookL2Checkpoint) => void): void; | ||
onL3Checkpoint(callback: (checkpoint: OrderbookL3Checkpoint) => void): void; | ||
} | ||
export {}; | ||
//# sourceMappingURL=orderbook.d.ts.map |
@@ -5,9 +5,28 @@ import { ReconnectingWebsocketFeed } from './util'; | ||
} | ||
function isOrderbookL3Update(obj) { | ||
return obj.additions !== undefined && obj.removals !== undefined; | ||
} | ||
function isOrderbookL2Checkpoint(obj) { | ||
return obj.bids !== undefined && obj.asks !== undefined; | ||
return (obj.bids !== undefined && | ||
obj.asks !== undefined && | ||
obj.bids.every((bid) => bid.length() == 2) && | ||
obj.asks.every((ask) => ask.length() == 2)); | ||
} | ||
function isOrderbookL3Checkpoint(obj) { | ||
return (obj.bids !== undefined && | ||
obj.asks !== undefined && | ||
obj.bids.every((order) => isOrder(order)) && | ||
obj.asks.every((order) => isOrder(order))); | ||
} | ||
function isOrder(obj) { | ||
return (obj.price !== undefined && | ||
obj.quantity !== undefined && | ||
obj.ownerPubkey !== undefined); | ||
} | ||
export class OrderbookFeed extends ReconnectingWebsocketFeed { | ||
_subscriptions; | ||
_onL2Update = null; | ||
_onL3Update = null; | ||
_onL2Checkpoint = null; | ||
_onL3Checkpoint = null; | ||
constructor(url, options) { | ||
@@ -20,5 +39,11 @@ super(url, options?.reconnectionIntervalMs, options?.reconnectionMaxAttempts); | ||
} | ||
else if (isOrderbookL3Update(data) && this._onL3Update) { | ||
this._onL3Update(data); | ||
} | ||
else if (isOrderbookL2Checkpoint(data) && this._onL2Checkpoint) { | ||
this._onL2Checkpoint(data); | ||
} | ||
else if (isOrderbookL3Checkpoint(data) && this._onL3Checkpoint) { | ||
this._onL3Checkpoint(data); | ||
} | ||
}); | ||
@@ -54,5 +79,11 @@ if (this._subscriptions !== undefined) { | ||
} | ||
onL3Update(callback) { | ||
this._onL3Update = callback; | ||
} | ||
onL2Checkpoint(callback) { | ||
this._onL2Checkpoint = callback; | ||
} | ||
onL3Checkpoint(callback) { | ||
this._onL3Checkpoint = callback; | ||
} | ||
} |
@@ -18,2 +18,15 @@ import { ReconnectingWebsocketFeed } from './util'; | ||
} | ||
interface OrderbookL3Update { | ||
market: string; | ||
side: 'bid' | 'ask'; | ||
additions: Order[]; | ||
removals: Order[]; | ||
slot: number; | ||
writeVersion: number; | ||
} | ||
interface Order { | ||
price: number; | ||
quantity: number; | ||
ownerPubkey: string; | ||
} | ||
interface OrderbookL2Checkpoint { | ||
@@ -27,6 +40,16 @@ market: string; | ||
} | ||
interface OrderbookL3Checkpoint { | ||
market: string; | ||
side: 'bid' | 'ask'; | ||
bids: Order[]; | ||
asks: Order[]; | ||
slot: number; | ||
writeVersion: number; | ||
} | ||
export declare class OrderbookFeed extends ReconnectingWebsocketFeed { | ||
private _subscriptions?; | ||
private _onL2Update; | ||
private _onL3Update; | ||
private _onL2Checkpoint; | ||
private _onL3Checkpoint; | ||
constructor(url: string, options?: OrderbookFeedOptions); | ||
@@ -36,5 +59,7 @@ subscribe(subscriptions: OrderbookFeedSubscribeParams): void; | ||
onL2Update(callback: (update: OrderbookL2Update) => void): void; | ||
onL3Update(callback: (update: OrderbookL3Update) => void): void; | ||
onL2Checkpoint(callback: (checkpoint: OrderbookL2Checkpoint) => void): void; | ||
onL3Checkpoint(callback: (checkpoint: OrderbookL3Checkpoint) => void): void; | ||
} | ||
export {}; | ||
//# sourceMappingURL=orderbook.d.ts.map |
{ | ||
"name": "@blockworks-foundation/mango-feeds", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Typescript Client for mango-feeds.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/blockworks-foundation/mango-feeds", |
@@ -16,8 +16,8 @@ # mango-geyser-services | ||
- [`service-mango-pnl/`](service-mango-pnl/) | ||
- [`service-mango-pnl/`](service-mango-pnl/) | ||
A service providing pre-computed account lists ordered by unsettled PnL per market | ||
- [`service-mango-orderbook/`](service-mango-pnl/) | ||
- [`service-mango-orderbook/`](service-mango-pnl/) | ||
A service providing Orderbook L2 state and delta updates for Mango V4 Perp and Openbook Spot markets | ||
A service providing Orderbook L2/L3 state and delta updates for Mango V4 Perp and Openbook Spot markets |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
989
0
81143
41