Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blockworks-foundation/mango-feeds

Package Overview
Dependencies
Maintainers
7
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blockworks-foundation/mango-feeds - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

25

dist/cjs/src/orderbook.d.ts

@@ -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

33

dist/cjs/src/orderbook.js

@@ -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

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc