Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
fix: makes the avg price into GB
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar committed Sep 7, 2020
1 parent 42ea215 commit 15c9e09
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/services/storage/handlers/offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function updatePrices (offer: Offer, period: BigNumber, price: BigNumber): Promi
}
}

export function weightedCumulativeAverage (newValue: number, currentCt: number, currentAvg): number {
export function weightedCumulativeAverage (newValue: number, currentCt: number, currentAvg: number): number {
if (!currentAvg) return newValue

const values = [currentAvg, newValue]
Expand Down Expand Up @@ -77,7 +77,7 @@ const handlers: { [key: string]: Function } = {
const plan = await updatePrices(offer, period, price)

const { plans, averagePrice } = offer
const planPrice = Math.round(plan.price.toNumber())
const planPrice = Math.round(plan.price.div(1024 ** 3).toNumber())

const newAvgPrice = plans && weightedCumulativeAverage(planPrice, plans.length, averagePrice)
offer.averagePrice = newAvgPrice || planPrice
Expand Down

0 comments on commit 15c9e09

Please sign in to comment.