Skip to content

Commit eec52a0

Browse files
author
Jayant Krishnamurthy
committed
add timestamp fields
1 parent f4c9781 commit eec52a0

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/index.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ export interface PriceData extends Base {
100100
validSlot: bigint
101101
emaPrice: Ema
102102
emaConfidence: Ema
103-
drv1Component: bigint
104-
drv1: number
103+
timestamp: bigint
105104
minPublishers: number
106105
drv2: number
107106
drv3: number
@@ -113,8 +112,7 @@ export interface PriceData extends Base {
113112
previousPrice: number
114113
previousConfidenceComponent: bigint
115114
previousConfidence: number
116-
drv5Component: bigint
117-
drv5: number
115+
previousTimestamp: bigint,
118116
priceComponents: PriceComponent[]
119117
aggregate: Price
120118
// The current price and confidence and status. The typical use of this interface is to consume these three fields.
@@ -276,9 +274,8 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
276274
const emaPrice = parseEma(data.slice(48, 72), exponent)
277275
// exponential moving average confidence interval
278276
const emaConfidence = parseEma(data.slice(72, 96), exponent)
279-
// space for future derived values
280-
const drv1Component = readBigInt64LE(data, 96)
281-
const drv1 = Number(drv1Component) * 10 ** exponent
277+
// timestamp of the current price
278+
const timestamp = readBigInt64LE(data, 96)
282279
// minimum number of publishers for status to be TRADING
283280
const minPublishers = data.readUInt8(104)
284281
// space for future derived values
@@ -300,8 +297,7 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
300297
const previousConfidenceComponent = readBigUInt64LE(data, 192)
301298
const previousConfidence = Number(previousConfidenceComponent) * 10 ** exponent
302299
// space for future derived values
303-
const drv5Component = readBigInt64LE(data, 200)
304-
const drv5 = Number(drv5Component) * 10 ** exponent
300+
const previousTimestamp = readBigInt64LE(data, 200)
305301
const aggregate = parsePriceInfo(data.slice(208, 240), exponent)
306302

307303
let status = aggregate.status
@@ -350,8 +346,7 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
350346
validSlot,
351347
emaPrice,
352348
emaConfidence,
353-
drv1Component,
354-
drv1,
349+
timestamp,
355350
minPublishers,
356351
drv2,
357352
drv3,
@@ -363,8 +358,7 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
363358
previousPrice,
364359
previousConfidenceComponent,
365360
previousConfidence,
366-
drv5Component,
367-
drv5,
361+
previousTimestamp,
368362
aggregate,
369363
priceComponents,
370364
price,

0 commit comments

Comments
 (0)