serum-vial
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -32,2 +32,6 @@ import { Market } from '@project-serum/serum'; | ||
private _l2LevelChanged; | ||
private _priceStringCache; | ||
private _sizeStringCache; | ||
private _getPriceAsString; | ||
private _getSizeAsString; | ||
private _mapToL2Level; | ||
@@ -34,0 +38,0 @@ private _putInEnvelope; |
@@ -512,5 +512,23 @@ "use strict"; | ||
} | ||
_priceStringCache = new Map(); | ||
_sizeStringCache = new Map(); | ||
_getPriceAsString(priceBN) { | ||
let priceString = this._priceStringCache.get(priceBN.toString()); | ||
if (priceString === undefined) { | ||
priceString = this._options.market.priceLotsToNumber(priceBN).toFixed(this._options.priceDecimalPlaces); | ||
this._priceStringCache.set(priceBN.toString(), priceString); | ||
} | ||
return priceString; | ||
} | ||
_getSizeAsString(sizeBN) { | ||
let sizeString = this._sizeStringCache.get(sizeBN.toString()); | ||
if (sizeString === undefined) { | ||
sizeString = this._options.market.baseSizeLotsToNumber(sizeBN).toFixed(this._options.sizeDecimalPlaces); | ||
this._sizeStringCache.set(sizeBN.toString(), sizeString); | ||
} | ||
return sizeString; | ||
} | ||
_mapToL2Level = (level) => { | ||
const price = this._options.market.priceLotsToNumber(level[0]).toFixed(this._options.priceDecimalPlaces); | ||
const size = this._options.market.baseSizeLotsToNumber(level[1]).toFixed(this._options.sizeDecimalPlaces); | ||
const price = this._getPriceAsString(level[0]); | ||
const size = this._getSizeAsString(level[1]); | ||
return [price, size]; | ||
@@ -671,3 +689,4 @@ }; | ||
_mapToOrderItem = ({ key, clientOrderId, feeTier, ownerSlot, owner, quantity }, isBids) => { | ||
const price = key.ushrn(64); | ||
const price = this._getPriceAsString(key.ushrn(64)); | ||
const size = this._getSizeAsString(quantity); | ||
const orderItem = { | ||
@@ -677,4 +696,4 @@ orderId: key.toString(), | ||
side: isBids ? 'buy' : 'sell', | ||
price: this._options.market.priceLotsToNumber(price).toFixed(this._options.priceDecimalPlaces), | ||
size: this._options.market.baseSizeLotsToNumber(quantity).toFixed(this._options.sizeDecimalPlaces), | ||
price, | ||
size, | ||
account: owner.toBase58(), | ||
@@ -681,0 +700,0 @@ accountSlot: ownerSlot, |
@@ -168,3 +168,4 @@ "use strict"; | ||
const ws = new ws_1.default(this._options.nodeWsEndpoint, { | ||
handshakeTimeout: 15 * 1000 | ||
handshakeTimeout: 15 * 1000, | ||
skipUTF8Validation: true | ||
}); | ||
@@ -171,0 +172,0 @@ ws.onopen = async () => { |
{ | ||
"name": "serum-vial", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"engines": { | ||
@@ -42,3 +42,3 @@ "node": ">=15" | ||
"@project-serum/serum": "^0.13.60", | ||
"@solana/web3.js": "^1.30.2", | ||
"@solana/web3.js": "^1.31.0", | ||
"@types/bintrees": "^1.0.3", | ||
@@ -54,15 +54,15 @@ "@types/bn.js": "^5.1.0", | ||
"winston": "^3.3.3", | ||
"ws": "^8.2.3", | ||
"yargs": "^17.2.1" | ||
"ws": "^8.3.0", | ||
"yargs": "^17.3.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^27.0.3", | ||
"@types/node": "^16.11.9", | ||
"@types/node": "^16.11.11", | ||
"@types/node-fetch": "^2.5.12", | ||
"@types/ws": "^8.2.0", | ||
"@types/ws": "^8.2.1", | ||
"cross-var": "^1.1.0", | ||
"husky": "^7.0.4", | ||
"jest": "^27.3.1", | ||
"lint-staged": "^11.2.6", | ||
"prettier": "^2.4.1", | ||
"jest": "^27.4.3", | ||
"lint-staged": "^12.1.2", | ||
"prettier": "^2.5.0", | ||
"ts-jest": "^27.0.7", | ||
@@ -69,0 +69,0 @@ "typescript": "^4.5.2" |
@@ -685,5 +685,32 @@ import { EVENT_QUEUE_LAYOUT, Market, Orderbook, getLayoutVersion } from '@project-serum/serum' | ||
private _priceStringCache: Map<string, string> = new Map() | ||
private _sizeStringCache: Map<string, string> = new Map() | ||
private _getPriceAsString(priceBN: BN) { | ||
let priceString = this._priceStringCache.get(priceBN.toString()) | ||
if (priceString === undefined) { | ||
priceString = this._options.market.priceLotsToNumber(priceBN).toFixed(this._options.priceDecimalPlaces) | ||
this._priceStringCache.set(priceBN.toString(), priceString) | ||
} | ||
return priceString | ||
} | ||
private _getSizeAsString(sizeBN: BN) { | ||
let sizeString = this._sizeStringCache.get(sizeBN.toString()) | ||
if (sizeString === undefined) { | ||
sizeString = this._options.market.baseSizeLotsToNumber(sizeBN).toFixed(this._options.sizeDecimalPlaces) | ||
this._sizeStringCache.set(sizeBN.toString(), sizeString) | ||
} | ||
return sizeString | ||
} | ||
private _mapToL2Level = (level: [BN, BN]): PriceLevel => { | ||
const price = this._options.market.priceLotsToNumber(level[0]).toFixed(this._options.priceDecimalPlaces) | ||
const size = this._options.market.baseSizeLotsToNumber(level[1]).toFixed(this._options.sizeDecimalPlaces) | ||
const price = this._getPriceAsString(level[0]) | ||
const size = this._getSizeAsString(level[1]) | ||
@@ -894,3 +921,4 @@ return [price, size] | ||
) => { | ||
const price = key.ushrn(64) | ||
const price = this._getPriceAsString(key.ushrn(64)) | ||
const size = this._getSizeAsString(quantity) | ||
@@ -901,4 +929,4 @@ const orderItem: OrderItem = { | ||
side: isBids ? 'buy' : 'sell', | ||
price: this._options.market.priceLotsToNumber(price).toFixed(this._options.priceDecimalPlaces), | ||
size: this._options.market.baseSizeLotsToNumber(quantity).toFixed(this._options.sizeDecimalPlaces), | ||
price, | ||
size, | ||
account: owner.toBase58(), | ||
@@ -905,0 +933,0 @@ accountSlot: ownerSlot, |
@@ -218,4 +218,5 @@ import { Market } from '@project-serum/serum' | ||
const ws = new WebSocket(this._options.nodeWsEndpoint, { | ||
handshakeTimeout: 15 * 1000 | ||
}) | ||
handshakeTimeout: 15 * 1000, | ||
skipUTF8Validation: true | ||
} as any) | ||
@@ -222,0 +223,0 @@ ws.onopen = async () => { |
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
300428
4414
Updated@solana/web3.js@^1.31.0
Updatedws@^8.3.0
Updatedyargs@^17.3.0