Skip to content

Commit 9495efa

Browse files
committed
v2 account structure
1 parent 1f774e0 commit 9495efa

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/index.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,17 @@ export const parsePriceData = (data: Buffer) => {
127127
const currentSlot = readBigUInt64LE(data, 32)
128128
// valid on-chain slot of aggregate price
129129
const validSlot = readBigUInt64LE(data, 40)
130-
// calculated values derived from agg. price - up to 8
131-
const derived = []
132-
for (let d = 0; d < 8; d++) {
133-
derived.push(readBigInt64LE(data, 48 + d * 8))
134-
}
130+
// time-weighted average price
131+
const twap = readBigInt64LE(data, 48)
132+
// annualized price volatility
133+
const avol = readBigUInt64LE(data, 56)
134+
// space for future derived values
135+
const drv0 = readBigInt64LE(data, 64)
136+
const drv1 = readBigInt64LE(data, 72)
137+
const drv2 = readBigInt64LE(data, 80)
138+
const drv3 = readBigInt64LE(data, 88)
139+
const drv4 = readBigInt64LE(data, 96)
140+
const drv5 = readBigInt64LE(data, 104)
135141
// product id / reference account
136142
const productAccountKey = new PublicKey(data.slice(112, 144))
137143
// next price account in list
@@ -166,7 +172,14 @@ export const parsePriceData = (data: Buffer) => {
166172
numComponentPrices,
167173
currentSlot,
168174
validSlot,
169-
derived,
175+
twap,
176+
avol,
177+
drv0,
178+
drv1,
179+
drv2,
180+
drv3,
181+
drv4,
182+
drv5,
170183
productAccountKey,
171184
nextPriceAccountKey,
172185
aggregatePriceUpdaterAccountKey,

0 commit comments

Comments
 (0)