mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
Make it dynamic
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user