Decimal issue fix
This commit is contained in:
parent
552444f773
commit
4f859f291b
|
@ -11,7 +11,7 @@ async function main() {
|
||||||
// const aggfeed2 = new AggregatedFeed(feeds, "eth:usd")
|
// const aggfeed2 = new AggregatedFeed(feeds, "eth:usd")
|
||||||
|
|
||||||
for (let pair of ["btc:usd", "eth:usd"]) {
|
for (let pair of ["btc:usd", "eth:usd"]) {
|
||||||
const aggfeed = new AggregatedFeed(feeds, pair)
|
const aggfeed = new AggregatedFeed(feeds, [], 2, pair)
|
||||||
|
|
||||||
setImmediate(async () => {
|
setImmediate(async () => {
|
||||||
for await (let _ of aggfeed.updates()) {
|
for await (let _ of aggfeed.updates()) {
|
||||||
|
|
|
@ -99,7 +99,7 @@ export class PriceFeeder {
|
||||||
}
|
}
|
||||||
|
|
||||||
const useFeeds = (priceFeedMapping[name]) ? priceFeedMapping[name].useFeeds.map(x => this.feeds[x]) : this.feeds;
|
const useFeeds = (priceFeedMapping[name]) ? priceFeedMapping[name].useFeeds.map(x => this.feeds[x]) : this.feeds;
|
||||||
const feed = new AggregatedFeed(useFeeds, priceFeedMapping[name].pairNames, name)
|
const feed = new AggregatedFeed(useFeeds, priceFeedMapping[name].pairNames, aggregatorInfo.config.decimals, name)
|
||||||
const priceFeed = feed.medians()
|
const priceFeed = feed.medians()
|
||||||
|
|
||||||
const minValueChangeForNewRound = priceFeedMapping[name].minValueChangeForNewRound || 100
|
const minValueChangeForNewRound = priceFeedMapping[name].minValueChangeForNewRound || 100
|
||||||
|
|
|
@ -366,13 +366,14 @@ export class AggregatedFeed {
|
||||||
public prices: IPrice[] = []
|
public prices: IPrice[] = []
|
||||||
|
|
||||||
// assume that the feeds are already connected
|
// assume that the feeds are already connected
|
||||||
constructor(public feeds: PriceFeed[], public pairMappings: string[], public pair: string) {
|
constructor(public feeds: PriceFeed[], public pairMappings: string[], public decimals: number, public pair: string) {
|
||||||
this.subscribe()
|
this.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
private subscribe() {
|
private subscribe() {
|
||||||
const pair = this.pair
|
const pair = this.pair
|
||||||
const pairMappings = this.pairMappings;
|
const pairMappings = this.pairMappings;
|
||||||
|
const decimals = this.decimals;
|
||||||
|
|
||||||
let j = 0
|
let j = 0
|
||||||
|
|
||||||
|
@ -387,6 +388,7 @@ export class AggregatedFeed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
price.timestamp = Date.now()
|
price.timestamp = Date.now()
|
||||||
|
price.decimals = decimals;
|
||||||
this.prices[index] = price
|
this.prices[index] = price
|
||||||
this.onPriceUpdate(price)
|
this.onPriceUpdate(price)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue