@waves.exchange/matcher-ws
Advanced tools
Comparing version 0.0.4 to 0.0.5
export * from './orderbook'; | ||
export * from './addressUpdates'; | ||
export * from './ratesUpdates'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,2 +5,4 @@ "use strict"; | ||
tslib_1.__exportStar(require("./orderbook"), exports); | ||
tslib_1.__exportStar(require("./addressUpdates"), exports); | ||
tslib_1.__exportStar(require("./ratesUpdates"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,2 @@ | ||
/// <reference types="zen-observable" /> | ||
import { Observable, WebSocketSubject } from '@waves.exchange/reactive'; | ||
@@ -11,2 +12,3 @@ import { BigNumber } from '@waves/bignumber'; | ||
S: string; | ||
U: number; | ||
b?: RawOrderbookOrder[]; | ||
@@ -13,0 +15,0 @@ a?: RawOrderbookOrder[]; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const bintrees_1 = require("bintrees"); | ||
const MatcherUpdateSequence_1 = require("./MatcherUpdateSequence"); | ||
class OrdersCache { | ||
@@ -56,2 +57,3 @@ constructor(type) { | ||
return new reactive_1.Observable((observer) => { | ||
const matcherUpdateSequence = new MatcherUpdateSequence_1.MatcherUpdateSequence(); | ||
const asks = new OrdersCache('asks'); | ||
@@ -65,16 +67,21 @@ const bids = new OrdersCache('bids'); | ||
const subscription = ws.multiplex(() => ({ T: 'obs', S: symbol, d: depth }), () => ({ T: 'u', S: symbol }), (data) => data.T === 'ob' && data.S === symbol).subscribe((ob) => { | ||
if (ob.a) { | ||
asks.patch(ob.a); | ||
if (matcherUpdateSequence.setAndValidate(ob.U)) { | ||
if (ob.a) { | ||
asks.patch(ob.a); | ||
} | ||
if (ob.b) { | ||
bids.patch(ob.b); | ||
} | ||
if (ob.t) { | ||
lastTrade = parseTrade(ob.t); | ||
} | ||
observer.next({ | ||
asks: asks.toArray(), | ||
bids: bids.toArray(), | ||
lastTrade: lastTrade, | ||
}); | ||
} | ||
if (ob.b) { | ||
bids.patch(ob.b); | ||
else { | ||
observer.error(new Error('Matcher update id is not consistent')); | ||
} | ||
if (ob.t) { | ||
lastTrade = parseTrade(ob.t); | ||
} | ||
observer.next({ | ||
asks: asks.toArray(), | ||
bids: bids.toArray(), | ||
lastTrade: lastTrade, | ||
}); | ||
}); | ||
@@ -81,0 +88,0 @@ return () => { |
{ | ||
"name": "@waves.exchange/matcher-ws", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
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
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
21957
25
286