Skip to content

change twap/twac to emap/emac #22

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

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all 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.6.1

### Changed
- Changed TWAP to EMAP and TWAC to EMAC

## 2.6.0

### Added
Expand Down
17 changes: 8 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export enum PriceType {

export enum DeriveType {
Unknown,
TWAP,
Volatility,
}

Expand Down Expand Up @@ -98,8 +97,8 @@ export interface PriceData extends Base {
numQuoters: number
lastSlot: bigint
validSlot: bigint
twap: Ema
twac: Ema
emaPrice: Ema
emaConfidence: Ema
drv1Component: bigint
drv1: number
minPublishers: number
Expand Down Expand Up @@ -271,10 +270,10 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
const lastSlot = readBigUInt64LE(data, 32)
// valid on-chain slot of aggregate price
const validSlot = readBigUInt64LE(data, 40)
// time-weighted average price
const twap = parseEma(data.slice(48, 72), exponent)
// time-weighted average confidence interval
const twac = parseEma(data.slice(72, 96), exponent)
// exponential moving average price
const emaPrice = parseEma(data.slice(48, 72), exponent)
// exponential moving average confidence interval
const emaConfidence = parseEma(data.slice(72, 96), exponent)
// space for future derived values
const drv1Component = readBigInt64LE(data, 96)
const drv1 = Number(drv1Component) * 10 ** exponent
Expand Down Expand Up @@ -347,8 +346,8 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
numQuoters,
lastSlot,
validSlot,
twap,
twac,
emaPrice,
emaConfidence,
drv1Component,
drv1,
minPublishers,
Expand Down