Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for maxLatency #76

Merged
merged 6 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.w0.0
cctdaniel marked this conversation as resolved.
Show resolved Hide resolved

- Add `messageSent` field to `PriceData`
- Add `maxLatency` field to `PriceData`

## 2.19.0

- Upgrade `@coral-xyz/anchor` to `^0.28.1-beta.1`
Expand Down
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.19.0",
"version": "2.20.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the lockfile as well.

"description": "Client for consuming Pyth price data",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down
18 changes: 11 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export interface PriceData extends Base {
emaConfidence: Ema
timestamp: bigint
minPublishers: number
drv2: number
messageSent: number
maxLatency: number
drv3: number
drv4: number
productAccountKey: PublicKey
Expand Down Expand Up @@ -285,10 +286,12 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
const timestamp = readBigInt64LE(data, 96)
// minimum number of publishers for status to be TRADING
const minPublishers = data.readUInt8(104)
// message sent flag
const messageSent = data.readUInt8(105)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by: previously added to the oracle program but js client wasn't updated

// configurable max latency in slots between send and receive
const maxLatency = data.readUInt8(106)
// space for future derived values
const drv2 = data.readInt8(105)
// space for future derived values
const drv3 = data.readInt16LE(106)
const drv3 = data.readInt8(107)
// space for future derived values
const drv4 = data.readInt32LE(108)
// product id / reference account
Expand Down Expand Up @@ -350,7 +353,8 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
emaConfidence,
timestamp,
minPublishers,
drv2,
messageSent,
maxLatency,
drv3,
drv4,
productAccountKey,
Expand Down Expand Up @@ -394,5 +398,5 @@ export const parsePermissionData = (data: Buffer): PermissionData => {

export { PythConnection } from './PythConnection'
export { PythHttpClient } from './PythHttpClient'
export { getPythProgramKeyForCluster, PythCluster, getPythClusterApiUrl } from './cluster'
export { pythOracleProgram, pythOracleCoder, pythIdl } from './anchor'
export { pythIdl, pythOracleCoder, pythOracleProgram } from './anchor'
export { PythCluster, getPythClusterApiUrl, getPythProgramKeyForCluster } from './cluster'
Comment on lines +401 to +402
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by: format

Loading