Skip to content

Commit

Permalink
fix vebal rank sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
mendesfabio committed Nov 29, 2023
1 parent e9c0cd0 commit a74456f
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 a74456f

Please sign in to comment.