Skip to content

Commit

Permalink
fix: withdrawal amount
Browse files Browse the repository at this point in the history
  • Loading branch information
anukulpandey committed Jul 22, 2024
1 parent 5873a6b commit 39fc605
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/PoolActions/Withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { faArrowUpFromBracket } from '@fortawesome/free-solid-svg-icons';
import BigNumber from 'bignumber.js';
import { RemoveLiquidityState } from '../../store';
import WithdrawPopup from './ConfirmPopups/Withdraw';
import { removeUserPoolSupply, calculatePoolShare } from '../../utils';
import { removeUserPoolSupply, calculatePoolShare, showRemovePoolTokenShare } from '../../utils';

interface WithdrawActions {
onRemoveLiquidity: () => Promise<void>;
Expand Down Expand Up @@ -33,9 +33,16 @@ export const Withdraw = ({
},
}: Withdraw): JSX.Element => {
const getTotalValue = useMemo((): number => {
const firstTokenValue = new BigNumber(token1.price).times(token1.amount).toNumber();
const secondTokenValue = new BigNumber(token2.price).times(token2.amount).toNumber();
const sum = firstTokenValue + secondTokenValue;
let amount1 = new BigNumber(showRemovePoolTokenShare(percentage, pool?.token1)).toNumber();
if (Number.isNaN(amount1)) amount1 = 0;
let amount2 = new BigNumber(showRemovePoolTokenShare(percentage, pool?.token2)).toNumber();
if (Number.isNaN(amount2)) amount2 = 0;

let value1 = Uik.utils.maxDecimals(new BigNumber(token1.price).times(amount1).toNumber(), 2);
if (Number.isNaN(value1)) value1 = 0;
let value2 = Uik.utils.maxDecimals(new BigNumber(token2.price).times(amount2).toNumber(), 2);
if (Number.isNaN(value2)) value2 = 0;
let sum = value1+value2;

Check failure on line 45 in src/components/PoolActions/Withdraw.tsx

View workflow job for this annotation

GitHub Actions / lint

'sum' is never reassigned. Use 'const' instead
return Uik.utils.maxDecimals(sum, 2);
}, [token1, token2]);

Expand Down

0 comments on commit 39fc605

Please sign in to comment.