@@ -171,6 +171,19 @@ export class MexTokenService {
171171
172172 private async getAllMexTokensRaw ( ) : Promise < MexToken [ ] > {
173173 const pairs = await this . mexPairService . getAllMexPairs ( ) ;
174+ const tokenVolumes : Record < string , number > = { } ;
175+
176+ for ( const pair of pairs ) {
177+ if ( ! tokenVolumes [ pair . baseId ] ) {
178+ tokenVolumes [ pair . baseId ] = 0 ;
179+ }
180+ tokenVolumes [ pair . baseId ] += Number ( pair . volume24h || 0 ) ;
181+
182+ if ( ! tokenVolumes [ pair . quoteId ] ) {
183+ tokenVolumes [ pair . quoteId ] = 0 ;
184+ }
185+ tokenVolumes [ pair . quoteId ] += Number ( pair . volume24h || 0 ) ;
186+ }
174187
175188 const mexTokens : MexToken [ ] = [ ] ;
176189 for ( const pair of pairs ) {
@@ -181,7 +194,7 @@ export class MexTokenService {
181194 wegldToken . name = pair . baseName ;
182195 wegldToken . price = pair . basePrice ;
183196 wegldToken . previous24hPrice = pair . basePrevious24hPrice ;
184- wegldToken . previous24hVolume = pair . volume24h ;
197+ wegldToken . previous24hVolume = tokenVolumes [ pair . baseId ] ;
185198 wegldToken . tradesCount = this . computeTradesCountForMexToken ( wegldToken , pairs ) ;
186199 mexTokens . push ( wegldToken ) ;
187200 }
@@ -191,6 +204,7 @@ export class MexTokenService {
191204 continue ;
192205 }
193206
207+ mexToken . previous24hVolume = tokenVolumes [ mexToken . id ] ;
194208 mexToken . tradesCount = this . computeTradesCountForMexToken ( mexToken , pairs ) ;
195209
196210 mexTokens . push ( mexToken ) ;
@@ -207,7 +221,7 @@ export class MexTokenService {
207221 name : pair . quoteName ,
208222 price : pair . quotePrice ,
209223 previous24hPrice : pair . quotePrevious24hPrice ,
210- previous24hVolume : pair . volume24h ,
224+ previous24hVolume : 0 ,
211225 tradesCount : 0 ,
212226 } ;
213227 }
@@ -219,7 +233,7 @@ export class MexTokenService {
219233 name : pair . baseName ,
220234 price : pair . basePrice ,
221235 previous24hPrice : pair . basePrevious24hPrice ,
222- previous24hVolume : pair . volume24h ,
236+ previous24hVolume : 0 ,
223237 tradesCount : 0 ,
224238 } ;
225239 }
@@ -231,7 +245,7 @@ export class MexTokenService {
231245 name : pair . quoteName ,
232246 price : pair . quotePrice ,
233247 previous24hPrice : pair . quotePrevious24hPrice ,
234- previous24hVolume : pair . volume24h ,
248+ previous24hVolume : 0 ,
235249 tradesCount : 0 ,
236250 } ;
237251 }
0 commit comments