Skip to content

Commit 9384f88

Browse files
authored
remove inconsistent fields from market stats (#1082)
* remove inconsistent fields from market stats * remove unused fields
1 parent ba55299 commit 9384f88

2 files changed

Lines changed: 0 additions & 21 deletions

File tree

app/lib/models/market_data.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
class TftMarketData {
22
final double lastPrice;
33
final double lastUsdPrice;
4-
final double change24h;
54
final double high24h;
65
final double low24h;
7-
final double volume24h;
86

97
TftMarketData({
108
required this.lastPrice,
119
required this.lastUsdPrice,
12-
required this.change24h,
1310
required this.high24h,
1411
required this.low24h,
15-
required this.volume24h,
1612
});
1713

1814
factory TftMarketData.fromTrades(List<dynamic> trades) {
@@ -25,41 +21,28 @@ class TftMarketData {
2521

2622
double high24h = lastUsdcPrice;
2723
double low24h = lastUsdcPrice;
28-
double volume24h = 0;
29-
30-
final oldestTrade = trades.last;
31-
final double oldestUsdcPrice = double.parse(oldestTrade['base_amount']) /
32-
double.parse(oldestTrade['counter_amount']);
3324

3425
for (var trade in trades) {
3526
double usdcPrice = double.parse(trade['base_amount']) /
3627
double.parse(trade['counter_amount']);
3728
high24h = usdcPrice > high24h ? usdcPrice : high24h;
3829
low24h = usdcPrice < low24h ? usdcPrice : low24h;
39-
volume24h += double.parse(trade['counter_amount']);
4030
}
4131

42-
final double change24h =
43-
((lastUsdcPrice - oldestUsdcPrice) / oldestUsdcPrice) * 100;
44-
4532
return TftMarketData(
4633
lastPrice: 1 / lastPrice,
4734
lastUsdPrice: lastUsdcPrice,
48-
change24h: change24h,
4935
high24h: high24h,
5036
low24h: low24h,
51-
volume24h: volume24h / 1000,
5237
);
5338
}
5439

5540
factory TftMarketData.empty() {
5641
return TftMarketData(
5742
lastPrice: 0,
5843
lastUsdPrice: 0,
59-
change24h: 0,
6044
high24h: 0,
6145
low24h: 0,
62-
volume24h: 0,
6346
);
6447
}
6548
}

app/lib/screens/market/overview.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,6 @@ class _OverviewWidgetState extends ConsumerState<OverviewWidget> {
440440
'${marketData!.lastPrice.toStringAsFixed(7)} USDC'),
441441
_buildMarketColumn('Last USD Price',
442442
'\$${marketData!.lastUsdPrice.toStringAsFixed(7)}'),
443-
_buildMarketColumn('24H Change',
444-
'${marketData!.change24h.toStringAsFixed(7)}%'),
445443
],
446444
),
447445
),
@@ -455,8 +453,6 @@ class _OverviewWidgetState extends ConsumerState<OverviewWidget> {
455453
'${marketData!.high24h.toStringAsFixed(7)} USDC'),
456454
_buildMarketColumn('24H Low',
457455
'${marketData!.low24h.toStringAsFixed(7)} USDC'),
458-
_buildMarketColumn('24H Volume',
459-
'${marketData!.volume24h.toStringAsFixed(7)}K USDC'),
460456
],
461457
),
462458
),

0 commit comments

Comments
 (0)