Skip to content

Commit

Permalink
Merge pull request #98 from skynetcap/feature/srm-124-fix-token-symbo…
Browse files Browse the repository at this point in the history
…l-permalinking

[SRM-124] Fix token symbol permalinking
  • Loading branch information
skynetcap authored Jul 31, 2022
2 parents 2f082e0 + 0277c02 commit 8cf3ee1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ public String market(Model model, @PathVariable String market) {
for (Token baseToken : possibleBaseTokens) {
// compile list of markets, return one with most fees accrued.
Optional<Market> optionalMarket = marketRankManager.getMostActiveMarket(baseToken.getPublicKey());
optionalMarket.ifPresent(activeMarkets::add);

if (optionalMarket.isPresent()) {
Market foundMarket = optionalMarket.get();
if (foundMarket.getBaseMint().equals(baseToken.getPublicKey())) {
activeMarkets.add(foundMarket);
}
}
}
activeMarkets.sort(Comparator.comparingLong(Market::getQuoteFeesAccrued).reversed());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ public List<Market> getMarketCache() {
return new ArrayList<>(marketCache.values());
}

public List<Market> getMarketsByBaseMint(PublicKey tokenMint) {
final Set<Market> result = new HashSet<>(marketMapCache.getOrDefault(tokenMint, new ArrayList<>()));
return new ArrayList<>(result);
}

public List<Market> getMarketsByTokenMint(PublicKey tokenMint) {
final Set<Market> result = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public String getImage(String tokenMint) {
}

public Optional<Market> getMostActiveMarket(PublicKey baseMint) {
List<Market> markets = marketManager.getMarketsByTokenMint(baseMint);
List<Market> markets = marketManager.getMarketsByBaseMint(baseMint);
if (markets.size() < 1) {
return Optional.empty();
}
Expand Down

0 comments on commit 8cf3ee1

Please sign in to comment.