Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <new version number>`. 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.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
30 changes: 20 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ 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
previousPriceComponent: bigint
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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -308,17 +316,19 @@ export const parsePriceData = (data: Buffer): PriceData => {
twac,
drv1Component,
drv1,
drv2Component,
minPublishers,
drv2,
drv3,
drv4,
productAccountKey,
nextPriceAccountKey,
previousSlot,
previousPriceComponent,
previousPrice,
previousConfidenceComponent,
previousConfidence,
drv3Component,
drv3,
drv5Component,
drv5,
aggregate,
priceComponents,
price,
Expand Down