diff --git a/package.json b/package.json
index f92ccfc..04a8dfa 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
- "version": "0.6.10",
+ "version": "0.6.11",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/src/containers/Dex/PoolContainer.jsx b/src/containers/Dex/PoolContainer.jsx
index acec9f3..6e3a2ac 100644
--- a/src/containers/Dex/PoolContainer.jsx
+++ b/src/containers/Dex/PoolContainer.jsx
@@ -139,7 +139,7 @@ const PoolContainer = ({
return { currentShares: lpTotalSupply, nextShares: lpTotalSupply };
}
const currentShares = lpBalance.div(lpTotalSupply).div(hundred);
- const nextShares = (lpBalance.add(estimatedAmountOut)).div(lpTotalSupply).div(hundred);
+ const nextShares = (lpBalance.add(estimatedAmountOut)).div(lpTotalSupply.add(estimatedAmountOut)).div(hundred);
return { currentShares, nextShares };
}, [lpBalance, lpTotalSupply, estimatedAmountOut]);
@@ -257,12 +257,12 @@ const PoolContainer = ({
style={{ fontSize: "12px", color: theme.colors.gray[40] }}
>
- Current:
- {!isSmallScreen ? `1 ${tokenNameTop} = ` : ""}{formatCurrency(poolPrices.priceIn, formatDecimals, tokenNameBottom)}
+ {`1 ${tokenNameTop}`}
+ {formatCurrency(poolPrices.priceIn, formatDecimals, tokenNameBottom)}
- Current:
- {!isSmallScreen ? `1 ${tokenNameBottom} = ` : ""}{formatCurrency(poolPrices.priceOut, formatDecimals, tokenNameTop)}
+ {`1 ${tokenNameBottom}`}
+ {formatCurrency(poolPrices.priceOut, formatDecimals, tokenNameTop)}
Current Pool Share:
diff --git a/src/containers/Dex/SwapContainer.jsx b/src/containers/Dex/SwapContainer.jsx
index b61ca96..cdb31e4 100644
--- a/src/containers/Dex/SwapContainer.jsx
+++ b/src/containers/Dex/SwapContainer.jsx
@@ -97,18 +97,18 @@ const SwapContainer = ({
const zero = new DecimalBigNumber(0n, 0);
const raw = new DecimalBigNumber(amountTop, balanceTop._decimals);
const amountInRaw = new DecimalBigNumber(raw._value.toBigInt(), balanceTop._decimals);
- const amountInWithFee = amountInRaw.mul(new DecimalBigNumber(997n, 3)); // TODO: filter
+ const amountInWithFee = amountInRaw.mul(new DecimalBigNumber(997n, 3));
const amountIn = addressTop.toUpperCase() === tokenAddresses.token0.toUpperCase() ? pairReserves.reserve0 : pairReserves.reserve1;
const amountOut = addressBottom.toUpperCase() === tokenAddresses.token1.toUpperCase() ? pairReserves.reserve1 : pairReserves.reserve0;
- if (amountIn.eq(zero)) {
+ if (amountOut.eq(zero)) {
setCurrentPrice("");
} else {
- setCurrentPrice(amountOut.div(amountIn).toString());
+ setCurrentPrice(amountIn.div(amountOut).toString());
}
- if (amountIn.eq(zero) || amountInWithFee.eq(zero)) {
+ if (amountOut.eq(zero) || amountInWithFee.eq(zero)) {
setAmountBottom("");
setNextPrice("");
} else {
@@ -116,14 +116,14 @@ const SwapContainer = ({
const denominator = amountIn.add(amountInWithFee);
const newAmountOut = nominator.div(denominator);
- const newReserve0 = amountIn.add(amountInWithFee);
- const newReserve1 = amountOut.sub(newAmountOut);
- const nextPrice = newReserve1.div(newReserve0);
+ const newReserveIn = amountIn.add(amountInWithFee);
+ const newReserveOut = amountOut.sub(newAmountOut);
+ const nextPrice = newReserveIn.div(newReserveOut);
setAmountBottom(newAmountOut.toString());
setNextPrice(nextPrice.toString());
}
- }, [addressBottom, amountTop, addressTop, isWrapping, isUnwrapping]);
+ }, [pairReserves, addressBottom, amountTop, addressTop, isWrapping, isUnwrapping]);
const minReceived = useMemo(() => {
const decimals = 7;
@@ -247,12 +247,12 @@ const SwapContainer = ({
style={{ fontSize: "12px", color: theme.colors.gray[40] }}
>
- Current:
- {!isSmallScreen ? `1 ${tokenNameTop} = ` : ""}{formatCurrency(currentPrice, formatDecimals, tokenNameBottom)}
+ {`1 ${tokenNameBottom} (Current)`}
+ {formatCurrency(currentPrice, formatDecimals, tokenNameTop)}
- Next:
- {!isSmallScreen ? `1 ${tokenNameTop} = ` : ""}{formatCurrency(nextPrice === "" ? currentPrice : nextPrice, formatDecimals, tokenNameBottom)}
+ {`1 ${tokenNameBottom} (Next)`}
+ {formatCurrency(nextPrice === "" ? currentPrice : nextPrice, formatDecimals, tokenNameTop)}
Min. Receive: