Skip to content

Commit

Permalink
fix: Fix a caclulate amount
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Dec 9, 2023
1 parent fff3cc9 commit 2264f9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ const SelectPriceRangeCustom: React.FC<SelectPriceRangeCustomProps> = ({
if (!selectPool.currentPrice) {
return "-";
}
const currentPrice = toNumberFormat(selectPool.currentPrice, 4);
const currentPrice = toNumberFormat(1 / selectPool.currentPrice, 4);
return `${currentPrice} ${currentTokenA.symbol} per ${currentTokenB.symbol}`;
}, [currentTokenA.symbol, currentTokenB.symbol, selectPool.currentPrice]);

const startingPriceDescription = useMemo(() => {
if (startingPriceValue === "" || BigNumber(startingPriceValue).isNaN() || !currentTokenA || !currentTokenB) {
return "";
}
return `1 ${currentTokenB.symbol} = ${startingPriceValue} ${currentTokenA.symbol}`;
return `1 ${currentTokenA.symbol} = ${startingPriceValue} ${currentTokenB.symbol}`;
}, [currentTokenA, currentTokenB, startingPriceValue]);

const onClickTabItem = useCallback((symbol: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const EarnAddLiquidityContainer: React.FC = () => {
return;
}
const ordered = tokenA?.symbol === selectPool.compareToken?.symbol;
const currentPrice = ordered ? 1 / selectPool.currentPrice : selectPool.currentPrice;
const currentPrice = ordered ? selectPool.currentPrice : 1 / selectPool.currentPrice;
const depositRatioA = selectPool.depositRatio;
if (selectPool.minPrice === null || selectPool.maxPrice === null || depositRatioA === null) {
tokenBAmountInput.changeAmount(BigNumber(amount).multipliedBy(currentPrice).toFixed(0));
Expand All @@ -264,7 +264,7 @@ const EarnAddLiquidityContainer: React.FC = () => {
return;
}
const ordered = tokenB?.symbol === selectPool.compareToken?.symbol;
const currentPrice = ordered ? 1 / selectPool.currentPrice : selectPool.currentPrice;
const currentPrice = ordered ? selectPool.currentPrice : 1 / selectPool.currentPrice;
const depositRatioA = selectPool.depositRatio;
if (!selectPool.minPrice || !selectPool.maxPrice || depositRatioA === null) {
tokenAAmountInput.changeAmount(BigNumber(amount).multipliedBy(currentPrice).toFixed(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const EarnAddLiquidityContainer: React.FC = () => {
return;
}
const ordered = tokenA?.symbol === selectPool.compareToken?.symbol;
const currentPrice = ordered ? 1 / selectPool.currentPrice : selectPool.currentPrice;
const currentPrice = ordered ? selectPool.currentPrice : 1 / selectPool.currentPrice;
const depositRatioA = selectPool.depositRatio;
if (selectPool.minPrice === null || selectPool.maxPrice === null || depositRatioA === null) {
tokenBAmountInput.changeAmount(BigNumber(amount).multipliedBy(currentPrice).toFixed(0));
Expand All @@ -240,7 +240,7 @@ const EarnAddLiquidityContainer: React.FC = () => {
return;
}
const ordered = tokenB?.symbol === selectPool.compareToken?.symbol;
const currentPrice = ordered ? 1 / selectPool.currentPrice : selectPool.currentPrice;
const currentPrice = ordered ? selectPool.currentPrice : 1 / selectPool.currentPrice;
const depositRatioA = selectPool.depositRatio;
if (!selectPool.minPrice || !selectPool.maxPrice || depositRatioA === null) {
tokenAAmountInput.changeAmount(BigNumber(amount).multipliedBy(currentPrice).toFixed(0));
Expand Down

0 comments on commit 2264f9a

Please sign in to comment.