diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a09721..dd9749c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2.20.0 + +- Add `messageSent` field to `PriceData` +- Add `maxLatency` field to `PriceData` + ## 2.19.0 - Upgrade `@coral-xyz/anchor` to `^0.28.1-beta.1` diff --git a/package-lock.json b/package-lock.json index 86f122e..6d20b44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pythnetwork/client", - "version": "2.19.0", + "version": "2.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@pythnetwork/client", - "version": "2.19.0", + "version": "2.20.0", "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.28.1-beta.1", diff --git a/package.json b/package.json index f23a0a9..8c9983d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/client", - "version": "2.19.0", + "version": "2.20.0", "description": "Client for consuming Pyth price data", "homepage": "https://pyth.network", "main": "lib/index.js", diff --git a/src/anchor/idl.json b/src/anchor/idl.json index eeeed91..927802f 100644 --- a/src/anchor/idl.json +++ b/src/anchor/idl.json @@ -598,6 +598,48 @@ "type": "publicKey" } ] + }, + { + "name": "setMaxLatency", + "discriminant": { "value": [2, 0, 0, 0, 18, 0, 0, 0] }, + "accounts": [ + { + "name": "fundingAccount", + "isMut": true, + "isSigner": true + }, + { + "name": "priceAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "permissionsAccount", + "isMut": false, + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "permissions" + } + ] + } + } + ], + "args": [ + { + "name": "maxLatency", + "type": "u8" + }, + { + "name": "unused", + "type": { + "array": ["u8", 3] + } + } + ] } ], "types": [ diff --git a/src/anchor/program.ts b/src/anchor/program.ts index fd8555c..a61705e 100644 --- a/src/anchor/program.ts +++ b/src/anchor/program.ts @@ -1,5 +1,5 @@ +import { AnchorProvider, Idl, Program } from '@coral-xyz/anchor' import { PublicKey } from '@solana/web3.js' -import { Program, AnchorProvider, Idl } from '@coral-xyz/anchor' import { PythOracleCoder } from './coder' import IDL from './idl.json' @@ -619,6 +619,48 @@ export type PythOracle = { }, ] }, + { + name: 'setMaxLatency' + discriminant: { value: [2, 0, 0, 0, 18, 0, 0, 0] } + accounts: [ + { + name: 'fundingAccount' + isMut: true + isSigner: true + }, + { + name: 'priceAccount' + isMut: true + isSigner: false + }, + { + name: 'permissionsAccount' + isMut: false + isSigner: false + pda: { + seeds: [ + { + kind: 'const' + type: 'string' + value: 'permissions' + }, + ] + } + }, + ] + args: [ + { + name: 'maxLatency' + type: 'u8' + }, + { + name: 'unused' + type: { + array: ['u8', 3] + } + }, + ] + }, ] types: [ { diff --git a/src/index.ts b/src/index.ts index 64bf9bd..5cef564 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 @@ -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) + // 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 @@ -350,7 +353,8 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData => emaConfidence, timestamp, minPublishers, - drv2, + messageSent, + maxLatency, drv3, drv4, productAccountKey, @@ -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'