Skip to content

Commit

Permalink
Merge pull request #542 from beethovenxfi/fix-vebal-ranking
Browse files Browse the repository at this point in the history
fix vebal rank sorting
  • Loading branch information
franzns authored Dec 19, 2023
2 parents 5b932f6 + a74456f commit 526cfbc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/vebal/vebal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ export class VeBalService {
if (networkContext.data.veBal) {
const veBalUsers = await prisma.prismaVeBalUserBalance.findMany({
where: { chain: networkContext.chain },
orderBy: { balance: 'desc' },
});

for (const user of veBalUsers) {
const veBalUsersNum = veBalUsers.map(user => ({
...user,
balance: parseFloat(user.balance),
}));

veBalUsersNum.sort((a, b) => b.balance - a.balance);

for (const user of veBalUsersNum) {
if (user.userAddress === userAddress) {
balance = user.balance;
balance = user.balance.toString();
break;
}
rank++;
Expand Down

0 comments on commit 526cfbc

Please sign in to comment.