From f74eb064ceee81229685ab76eb51eaca412337cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rytis=20Grincevi=C4=8Dius?= Date: Tue, 12 Nov 2024 13:18:08 +0200 Subject: [PATCH] chore: show decimals --- src/controllers/sdex/volume.utils.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/controllers/sdex/volume.utils.ts b/src/controllers/sdex/volume.utils.ts index 77fabad..a6ac9b5 100644 --- a/src/controllers/sdex/volume.utils.ts +++ b/src/controllers/sdex/volume.utils.ts @@ -16,12 +16,17 @@ 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), }; } @@ -29,12 +34,17 @@ export async function prepareSdexVolume(chainId: number, days = 1) { 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), }; } });