Make it dynamic

This commit is contained in:
KoalaSat
2024-03-15 09:27:19 +01:00
parent eb37c03969
commit 10054407c6
2 changed files with 15 additions and 15 deletions

View File

@ -36,18 +36,20 @@ export const updateExchangeInfo = (federation: Federation): ExchangeInfo => {
'lifetime_volume',
];
Object.values(federation.coordinators).forEach((coordinator, index) => {
if (coordinator.info !== undefined) {
premiums[index] = coordinator.info.last_day_nonkyc_btc_premium;
volumes[index] = coordinator.info.last_day_volume;
highestVersion = getHigherVer(highestVersion, coordinator.info.version);
active_robots_today = Math.max(active_robots_today, coordinator.info.active_robots_today);
Object.values(federation.coordinators)
.filter((coor) => coor.isUpdated())
.forEach((coordinator, index) => {
if (coordinator.info !== undefined) {
premiums[index] = coordinator.info.last_day_nonkyc_btc_premium;
volumes[index] = coordinator.info.last_day_volume;
highestVersion = getHigherVer(highestVersion, coordinator.info.version);
active_robots_today = Math.max(active_robots_today, coordinator.info.active_robots_today);
aggregations.forEach((key: any) => {
info[key] = Number(info[key]) + Number(coordinator.info[key]);
});
}
});
aggregations.forEach((key: any) => {
info[key] = Number(info[key]) + Number(coordinator.info[key]);
});
}
});
info.last_day_nonkyc_btc_premium = weightedMean(premiums, volumes);
info.version = highestVersion;

View File

@ -65,10 +65,8 @@ export class Federation {
this.exchange.loadingCoordinators =
this.exchange.loadingCoordinators < 1 ? 0 : this.exchange.loadingCoordinators - 1;
this.loading = this.exchange.loadingCoordinators > 0;
if (Object.values(this.coordinators).every((coor) => coor.isUpdated())) {
this.updateExchange();
this.triggerHook('onFederationUpdate');
}
this.updateExchange();
this.triggerHook('onFederationUpdate');
};
// Setup