Skip to content

Commit 78651ac

Browse files
committed
rounding fix
1 parent 198cee0 commit 78651ac

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/components/transactions/Switch/BaseSwitchModalContent.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,10 @@ export const BaseSwitchModalContent = ({
674674
chainId={selectedChainId}
675675
destDecimals={selectedOutputToken.decimals}
676676
srcDecimals={selectedInputToken.decimals}
677-
outAmount={(
678-
Number(normalize(switchRates.destAmount, switchRates.destDecimals)) *
679-
(1 - safeSlippage)
680-
).toString()}
677+
outAmount={normalizeBN(switchRates.destAmount, switchRates.destDecimals)
678+
.multipliedBy(1 - safeSlippage)
679+
.decimalPlaces(switchRates.destDecimals, BigNumber.ROUND_UP)
680+
.toString()}
681681
/>
682682
);
683683
}

src/components/transactions/Switch/SwitchModalTxDetails.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Skeleton,
1010
Typography,
1111
} from '@mui/material';
12+
import { BigNumber } from 'bignumber.js';
1213
import { useState } from 'react';
1314
import { FormattedNumber } from 'src/components/primitives/FormattedNumber';
1415
import { Link } from 'src/components/primitives/Link';
@@ -178,6 +179,11 @@ const IntentTxDetails = ({
178179
</TextWithTooltip>
179180
);
180181

182+
const destAmountAfterSlippage = normalizeBN(switchRates.destAmount, switchRates.destDecimals)
183+
.multipliedBy(1 - safeSlippage)
184+
.decimalPlaces(switchRates.destDecimals, BigNumber.ROUND_UP)
185+
.toString();
186+
181187
return (
182188
<>
183189
<Accordion
@@ -309,10 +315,7 @@ const IntentTxDetails = ({
309315
sx={{ mr: 2, ml: 4, fontSize: '16px' }}
310316
/>
311317
<FormattedNumber
312-
value={
313-
Number(normalize(switchRates.destAmount, switchRates.destDecimals)) *
314-
(1 - safeSlippage)
315-
}
318+
value={destAmountAfterSlippage}
316319
variant="secondary14"
317320
compact
318321
roundDown={true}

0 commit comments

Comments
 (0)