From ffd31688e816200a1eafa608e2b09e96a572fa0c Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 4 Nov 2021 14:58:33 +0000 Subject: [PATCH 1/4] restructure drv2 and add minPublishers field to PriceData --- src/index.ts | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 313500a..ce7bf14 100644 --- a/src/index.ts +++ b/src/index.ts @@ -78,8 +78,10 @@ export interface PriceData extends Base { twac: Ema drv1Component: bigint drv1: number - drv2Component: bigint + minPublishers: number drv2: number + drv3: number + drv4: number productAccountKey: PublicKey nextPriceAccountKey: PublicKey | null previousSlot: bigint @@ -87,8 +89,8 @@ export interface PriceData extends Base { previousPrice: number previousConfidenceComponent: bigint previousConfidence: number - drv3Component: bigint - drv3: number + drv5Component: bigint + drv5: number priceComponents: PriceComponent[] aggregate: Price, // The current price and confidence. The typical use of this interface is to consume these two fields. @@ -249,8 +251,14 @@ export const parsePriceData = (data: Buffer): PriceData => { // space for future derived values const drv1Component = readBigInt64LE(data, 96) const drv1 = Number(drv1Component) * 10 ** exponent - const drv2Component = readBigInt64LE(data, 104) - const drv2 = Number(drv2Component) * 10 ** exponent + // minimum number of publishers for status to be TRADING + const minPublishers = data.readUInt8(104) + // space for future derived values + const drv2 = data.readInt8(105) + // space for future derived values + const drv3 = data.readInt16LE(106) + // space for future derived values + const drv4 = data.readInt32LE(108) // product id / reference account const productAccountKey = new PublicKey(data.slice(112, 144)) // next price account in list @@ -264,8 +272,8 @@ export const parsePriceData = (data: Buffer): PriceData => { const previousConfidenceComponent = readBigUInt64LE(data, 192) const previousConfidence = Number(previousConfidenceComponent) * 10 ** exponent // space for future derived values - const drv3Component = readBigInt64LE(data, 200) - const drv3 = Number(drv3Component) * 10 ** exponent + const drv5Component = readBigInt64LE(data, 200) + const drv5 = Number(drv5Component) * 10 ** exponent const aggregate = parsePriceInfo(data.slice(208, 240), exponent) let price @@ -308,8 +316,10 @@ export const parsePriceData = (data: Buffer): PriceData => { twac, drv1Component, drv1, - drv2Component, + minPublishers, drv2, + drv3, + drv4, productAccountKey, nextPriceAccountKey, previousSlot, @@ -317,8 +327,8 @@ export const parsePriceData = (data: Buffer): PriceData => { previousPrice, previousConfidenceComponent, previousConfidence, - drv3Component, - drv3, + drv5Component, + drv5, aggregate, priceComponents, price, From d65ed46ae414b9723573c7b12660335882fdc051 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 4 Nov 2021 15:07:06 +0000 Subject: [PATCH 2/4] update version to 2.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0be9173..b277205 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/client", - "version": "2.4.0", + "version": "2.5.0", "description": "Client for consuming Pyth price data", "homepage": "https://pyth.network", "main": "lib/index.js", From dc742a746e9aa455e0beb716492504c3bf4d2d4d Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 4 Nov 2021 15:19:48 +0000 Subject: [PATCH 3/4] update CHANGELOG.md --- CHANGELOG.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ba9129..cb2ec17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,26 @@ # Changelog +### 2.5.0 + +### Changed + +Restructure `drv2` field in `PriceData` to `minPublishers` and other future drv values + +### 2.4.0 + +### Changed + +Product only define `price` and `confidence` fields if it currently has a valid price + +### Fixed + +Memory leak in an underlying library + ### 2.3.2 -Added PythConnection +### Added + +PythConnection ## 2.2.0 From 54f334a5fc67e087701cf82ffa913728f3f5d43e Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 4 Nov 2021 15:20:47 +0000 Subject: [PATCH 4/4] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9064e1b..8aa743f 100644 --- a/README.md +++ b/README.md @@ -54,4 +54,4 @@ use the methods in `index.ts` to parse the on-chain data structures into Javascr In order to release a new version of this library and publish it to npm, follow these steps: 1. Update `CHANGELOG.md` with a description of the changes in this version. 2. Run `npm version `. This command will update the version of the package, tag the branch in git, and push your changes to github. -3. Once your change is merged into `main`, a github action will automatically publish a new version of the package to npm. +3. Once your change is merged into `main`, create a release, and a github action will automatically publish a new version of the package to npm.