File tree 2 files changed +12
-28
lines changed
plugin-solana/src/providers
plugin-starknet/src/providers
2 files changed +12
-28
lines changed Original file line number Diff line number Diff line change @@ -604,21 +604,13 @@ export class TokenProvider {
604
604
}
605
605
606
606
// Sort pairs by both liquidity and market cap to get the highest one
607
- return dexData . pairs . reduce ( ( highestPair , currentPair ) => {
608
- const currentLiquidity = currentPair . liquidity . usd ;
609
- const currentMarketCap = currentPair . marketCap ;
610
- const highestLiquidity = highestPair . liquidity . usd ;
611
- const highestMarketCap = highestPair . marketCap ;
612
-
613
- if (
614
- currentLiquidity > highestLiquidity ||
615
- ( currentLiquidity === highestLiquidity &&
616
- currentMarketCap > highestMarketCap )
617
- ) {
618
- return currentPair ;
607
+ return dexData . pairs . sort ( ( a , b ) => {
608
+ const liquidityDiff = b . liquidity . usd - a . liquidity . usd ;
609
+ if ( liquidityDiff !== 0 ) {
610
+ return liquidityDiff ; // Higher liquidity comes first
619
611
}
620
- return highestPair ;
621
- } ) ;
612
+ return b . marketCap - a . marketCap ; // If liquidity is equal, higher market cap comes first
613
+ } ) [ 0 ] ;
622
614
}
623
615
624
616
async analyzeHolderDistribution (
Original file line number Diff line number Diff line change @@ -385,21 +385,13 @@ export class TokenProvider {
385
385
}
386
386
387
387
// Sort pairs by both liquidity and market cap to get the highest one
388
- return dexData . pairs . reduce ( ( highestPair , currentPair ) => {
389
- const currentLiquidity = currentPair . liquidity . usd ;
390
- const currentMarketCap = currentPair . marketCap ;
391
- const highestLiquidity = highestPair . liquidity . usd ;
392
- const highestMarketCap = highestPair . marketCap ;
393
-
394
- if (
395
- currentLiquidity > highestLiquidity ||
396
- ( currentLiquidity === highestLiquidity &&
397
- currentMarketCap > highestMarketCap )
398
- ) {
399
- return currentPair ;
388
+ return dexData . pairs . sort ( ( a , b ) => {
389
+ const liquidityDiff = b . liquidity . usd - a . liquidity . usd ;
390
+ if ( liquidityDiff !== 0 ) {
391
+ return liquidityDiff ; // Higher liquidity comes first
400
392
}
401
- return highestPair ;
402
- } ) ;
393
+ return b . marketCap - a . marketCap ; // If liquidity is equal, higher market cap comes first
394
+ } ) [ 0 ] ;
403
395
}
404
396
405
397
// TODO:
You can’t perform that action at this time.
0 commit comments