Skip to content

Commit

Permalink
chore: show decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
grinry committed Nov 12, 2024
1 parent 611c4b8 commit f74eb06
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/controllers/sdex/volume.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,35 @@ export async function prepareSdexVolume(chainId: number, days = 1) {
if (baseIndex < 0) {
result.push({
token: swap.base.address,
volume: swap.baseAmount,
volume: bignumber(swap.baseAmount)
.mul(10 ** swap.base.decimals)
.toFixed(0),
});
} else {
result[baseIndex] = {
token: swap.base.address,
volume: bignumber(swap.baseAmount).plus(result[baseIndex].volume).toString(),
volume: bignumber(swap.baseAmount)
.mul(10 ** swap.base.decimals)
.plus(result[baseIndex].volume)
.toFixed(0),
};
}

const quoteIndex = result.findIndex((s) => areAddressesEqual(s.token, swap.quote.address));
if (quoteIndex < 0) {
result.push({
token: swap.quote.address,
volume: bignumber(swap.quoteAmount).toString(),
volume: bignumber(swap.quoteAmount)
.mul(10 ** swap.quote.decimals)
.toFixed(0),
});
} else {
result[quoteIndex] = {
token: swap.quote.address,
volume: bignumber(swap.quoteAmount).plus(result[quoteIndex].volume).toString(),
volume: bignumber(swap.quoteAmount)
.mul(10 ** swap.quote.decimals)
.plus(result[quoteIndex].volume)
.toFixed(0),
};
}
});
Expand Down

0 comments on commit f74eb06

Please sign in to comment.