Skip to content

Commit 0ba9357

Browse files
authored
feat: add support for maxLatency (#76)
* add support for maxLatency * revert * revert * update readme * address comments * Update package version to 2.20.0
1 parent 8c24cfc commit 0ba9357

File tree

6 files changed

+104
-11
lines changed

6 files changed

+104
-11
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.20.0
4+
5+
- Add `messageSent` field to `PriceData`
6+
- Add `maxLatency` field to `PriceData`
7+
38
## 2.19.0
49

510
- Upgrade `@coral-xyz/anchor` to `^0.28.1-beta.1`

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/client",
3-
"version": "2.19.0",
3+
"version": "2.20.0",
44
"description": "Client for consuming Pyth price data",
55
"homepage": "https://pyth.network",
66
"main": "lib/index.js",

Diff for: src/anchor/idl.json

+42
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,48 @@
598598
"type": "publicKey"
599599
}
600600
]
601+
},
602+
{
603+
"name": "setMaxLatency",
604+
"discriminant": { "value": [2, 0, 0, 0, 18, 0, 0, 0] },
605+
"accounts": [
606+
{
607+
"name": "fundingAccount",
608+
"isMut": true,
609+
"isSigner": true
610+
},
611+
{
612+
"name": "priceAccount",
613+
"isMut": true,
614+
"isSigner": false
615+
},
616+
{
617+
"name": "permissionsAccount",
618+
"isMut": false,
619+
"isSigner": false,
620+
"pda": {
621+
"seeds": [
622+
{
623+
"kind": "const",
624+
"type": "string",
625+
"value": "permissions"
626+
}
627+
]
628+
}
629+
}
630+
],
631+
"args": [
632+
{
633+
"name": "maxLatency",
634+
"type": "u8"
635+
},
636+
{
637+
"name": "unused",
638+
"type": {
639+
"array": ["u8", 3]
640+
}
641+
}
642+
]
601643
}
602644
],
603645
"types": [

Diff for: src/anchor/program.ts

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { AnchorProvider, Idl, Program } from '@coral-xyz/anchor'
12
import { PublicKey } from '@solana/web3.js'
2-
import { Program, AnchorProvider, Idl } from '@coral-xyz/anchor'
33
import { PythOracleCoder } from './coder'
44
import IDL from './idl.json'
55

@@ -619,6 +619,48 @@ export type PythOracle = {
619619
},
620620
]
621621
},
622+
{
623+
name: 'setMaxLatency'
624+
discriminant: { value: [2, 0, 0, 0, 18, 0, 0, 0] }
625+
accounts: [
626+
{
627+
name: 'fundingAccount'
628+
isMut: true
629+
isSigner: true
630+
},
631+
{
632+
name: 'priceAccount'
633+
isMut: true
634+
isSigner: false
635+
},
636+
{
637+
name: 'permissionsAccount'
638+
isMut: false
639+
isSigner: false
640+
pda: {
641+
seeds: [
642+
{
643+
kind: 'const'
644+
type: 'string'
645+
value: 'permissions'
646+
},
647+
]
648+
}
649+
},
650+
]
651+
args: [
652+
{
653+
name: 'maxLatency'
654+
type: 'u8'
655+
},
656+
{
657+
name: 'unused'
658+
type: {
659+
array: ['u8', 3]
660+
}
661+
},
662+
]
663+
},
622664
]
623665
types: [
624666
{

Diff for: src/index.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export interface PriceData extends Base {
103103
emaConfidence: Ema
104104
timestamp: bigint
105105
minPublishers: number
106-
drv2: number
106+
messageSent: number
107+
maxLatency: number
107108
drv3: number
108109
drv4: number
109110
productAccountKey: PublicKey
@@ -285,10 +286,12 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
285286
const timestamp = readBigInt64LE(data, 96)
286287
// minimum number of publishers for status to be TRADING
287288
const minPublishers = data.readUInt8(104)
289+
// message sent flag
290+
const messageSent = data.readUInt8(105)
291+
// configurable max latency in slots between send and receive
292+
const maxLatency = data.readUInt8(106)
288293
// space for future derived values
289-
const drv2 = data.readInt8(105)
290-
// space for future derived values
291-
const drv3 = data.readInt16LE(106)
294+
const drv3 = data.readInt8(107)
292295
// space for future derived values
293296
const drv4 = data.readInt32LE(108)
294297
// product id / reference account
@@ -350,7 +353,8 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
350353
emaConfidence,
351354
timestamp,
352355
minPublishers,
353-
drv2,
356+
messageSent,
357+
maxLatency,
354358
drv3,
355359
drv4,
356360
productAccountKey,
@@ -394,5 +398,5 @@ export const parsePermissionData = (data: Buffer): PermissionData => {
394398

395399
export { PythConnection } from './PythConnection'
396400
export { PythHttpClient } from './PythHttpClient'
397-
export { getPythProgramKeyForCluster, PythCluster, getPythClusterApiUrl } from './cluster'
398-
export { pythOracleProgram, pythOracleCoder, pythIdl } from './anchor'
401+
export { pythIdl, pythOracleCoder, pythOracleProgram } from './anchor'
402+
export { PythCluster, getPythClusterApiUrl, getPythProgramKeyForCluster } from './cluster'

0 commit comments

Comments
 (0)