align the information logic on the DEX
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
643211efc9
commit
55b047e02f
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.6.10",
|
"version": "0.6.11",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -139,7 +139,7 @@ const PoolContainer = ({
|
|||||||
return { currentShares: lpTotalSupply, nextShares: lpTotalSupply };
|
return { currentShares: lpTotalSupply, nextShares: lpTotalSupply };
|
||||||
}
|
}
|
||||||
const currentShares = lpBalance.div(lpTotalSupply).div(hundred);
|
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 };
|
return { currentShares, nextShares };
|
||||||
}, [lpBalance, lpTotalSupply, estimatedAmountOut]);
|
}, [lpBalance, lpTotalSupply, estimatedAmountOut]);
|
||||||
|
|
||||||
@ -257,12 +257,12 @@ const PoolContainer = ({
|
|||||||
style={{ fontSize: "12px", color: theme.colors.gray[40] }}
|
style={{ fontSize: "12px", color: theme.colors.gray[40] }}
|
||||||
>
|
>
|
||||||
<Box width="100%" display="flex" justifyContent="space-between">
|
<Box width="100%" display="flex" justifyContent="space-between">
|
||||||
<Typography fontSize="12px" lineHeight="15px">Current:</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{`1 ${tokenNameTop}`}</Typography>
|
||||||
<Typography fontSize="12px" lineHeight="15px">{!isSmallScreen ? `1 ${tokenNameTop} = ` : ""}{formatCurrency(poolPrices.priceIn, formatDecimals, tokenNameBottom)}</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{formatCurrency(poolPrices.priceIn, formatDecimals, tokenNameBottom)}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="100%" display="flex" justifyContent="space-between">
|
<Box width="100%" display="flex" justifyContent="space-between">
|
||||||
<Typography fontSize="12px" lineHeight="15px">Current:</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{`1 ${tokenNameBottom}`}</Typography>
|
||||||
<Typography fontSize="12px" lineHeight="15px">{!isSmallScreen ? `1 ${tokenNameBottom} = ` : ""}{formatCurrency(poolPrices.priceOut, formatDecimals, tokenNameTop)}</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{formatCurrency(poolPrices.priceOut, formatDecimals, tokenNameTop)}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="100%" display="flex" justifyContent="space-between">
|
<Box width="100%" display="flex" justifyContent="space-between">
|
||||||
<Typography fontSize="12px" lineHeight="15px">Current Pool Share:</Typography>
|
<Typography fontSize="12px" lineHeight="15px">Current Pool Share:</Typography>
|
||||||
|
|||||||
@ -97,18 +97,18 @@ const SwapContainer = ({
|
|||||||
const zero = new DecimalBigNumber(0n, 0);
|
const zero = new DecimalBigNumber(0n, 0);
|
||||||
const raw = new DecimalBigNumber(amountTop, balanceTop._decimals);
|
const raw = new DecimalBigNumber(amountTop, balanceTop._decimals);
|
||||||
const amountInRaw = new DecimalBigNumber(raw._value.toBigInt(), 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 amountIn = addressTop.toUpperCase() === tokenAddresses.token0.toUpperCase() ? pairReserves.reserve0 : pairReserves.reserve1;
|
||||||
const amountOut = addressBottom.toUpperCase() === tokenAddresses.token1.toUpperCase() ? pairReserves.reserve1 : pairReserves.reserve0;
|
const amountOut = addressBottom.toUpperCase() === tokenAddresses.token1.toUpperCase() ? pairReserves.reserve1 : pairReserves.reserve0;
|
||||||
|
|
||||||
if (amountIn.eq(zero)) {
|
if (amountOut.eq(zero)) {
|
||||||
setCurrentPrice("");
|
setCurrentPrice("");
|
||||||
} else {
|
} 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("");
|
setAmountBottom("");
|
||||||
setNextPrice("");
|
setNextPrice("");
|
||||||
} else {
|
} else {
|
||||||
@ -116,14 +116,14 @@ const SwapContainer = ({
|
|||||||
const denominator = amountIn.add(amountInWithFee);
|
const denominator = amountIn.add(amountInWithFee);
|
||||||
const newAmountOut = nominator.div(denominator);
|
const newAmountOut = nominator.div(denominator);
|
||||||
|
|
||||||
const newReserve0 = amountIn.add(amountInWithFee);
|
const newReserveIn = amountIn.add(amountInWithFee);
|
||||||
const newReserve1 = amountOut.sub(newAmountOut);
|
const newReserveOut = amountOut.sub(newAmountOut);
|
||||||
const nextPrice = newReserve1.div(newReserve0);
|
const nextPrice = newReserveIn.div(newReserveOut);
|
||||||
|
|
||||||
setAmountBottom(newAmountOut.toString());
|
setAmountBottom(newAmountOut.toString());
|
||||||
setNextPrice(nextPrice.toString());
|
setNextPrice(nextPrice.toString());
|
||||||
}
|
}
|
||||||
}, [addressBottom, amountTop, addressTop, isWrapping, isUnwrapping]);
|
}, [pairReserves, addressBottom, amountTop, addressTop, isWrapping, isUnwrapping]);
|
||||||
|
|
||||||
const minReceived = useMemo(() => {
|
const minReceived = useMemo(() => {
|
||||||
const decimals = 7;
|
const decimals = 7;
|
||||||
@ -247,12 +247,12 @@ const SwapContainer = ({
|
|||||||
style={{ fontSize: "12px", color: theme.colors.gray[40] }}
|
style={{ fontSize: "12px", color: theme.colors.gray[40] }}
|
||||||
>
|
>
|
||||||
<Box width="100%" display="flex" justifyContent="space-between">
|
<Box width="100%" display="flex" justifyContent="space-between">
|
||||||
<Typography fontSize="12px" lineHeight="15px">Current:</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{`1 ${tokenNameBottom} (Current)`}</Typography>
|
||||||
<Typography fontSize="12px" lineHeight="15px">{!isSmallScreen ? `1 ${tokenNameTop} = ` : ""}{formatCurrency(currentPrice, formatDecimals, tokenNameBottom)}</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{formatCurrency(currentPrice, formatDecimals, tokenNameTop)}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="100%" display="flex" justifyContent="space-between">
|
<Box width="100%" display="flex" justifyContent="space-between">
|
||||||
<Typography fontSize="12px" lineHeight="15px">Next:</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{`1 ${tokenNameBottom} (Next)`}</Typography>
|
||||||
<Typography fontSize="12px" lineHeight="15px">{!isSmallScreen ? `1 ${tokenNameTop} = ` : ""}{formatCurrency(nextPrice === "" ? currentPrice : nextPrice, formatDecimals, tokenNameBottom)}</Typography>
|
<Typography fontSize="12px" lineHeight="15px">{formatCurrency(nextPrice === "" ? currentPrice : nextPrice, formatDecimals, tokenNameTop)}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="100%" display="flex" justifyContent="space-between">
|
<Box width="100%" display="flex" justifyContent="space-between">
|
||||||
<Typography fontSize="12px" lineHeight="15px">Min. Receive:</Typography>
|
<Typography fontSize="12px" lineHeight="15px">Min. Receive:</Typography>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user