fix for the issue on the DEX Pool page that was found during the community call
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
54641f2f77
commit
42ebad8697
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ghost-dao-interface",
|
||||
"private": true,
|
||||
"version": "0.0.29",
|
||||
"version": "0.0.30",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
@ -68,10 +68,10 @@ const PoolContainer = ({
|
||||
);
|
||||
|
||||
const onSwap = () => {
|
||||
const oldAmountTop = amountTop;
|
||||
const oldAmountBottom = amountBottom;
|
||||
setAmountBottom(oldAmountTop);
|
||||
setAmountTop(oldAmountBottom);
|
||||
// const oldAmountTop = amountTop;
|
||||
// const oldAmountBottom = amountBottom;
|
||||
// setAmountBottom(oldAmountTop);
|
||||
setAmountTop(amountBottom);
|
||||
onCardsSwap();
|
||||
}
|
||||
|
||||
@ -138,18 +138,23 @@ const PoolContainer = ({
|
||||
}, [pairReserves, amountTop, amountBottom, balanceTop, balanceBottom]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pairReserves && pairReserves.reserve1.gt(new DecimalBigNumber(0n, 0))) {
|
||||
if (addressTop.toUpperCase() === tokenAddresses.token1.toUpperCase()) {
|
||||
if (pairReserves?.reserve1.gt(new DecimalBigNumber(0n, 0))) {
|
||||
const value = new DecimalBigNumber(amountTop, balanceTop._decimals)
|
||||
const amountToAdd = new DecimalBigNumber(value._value.toBigInt(), balanceTop._decimals);
|
||||
const amount = amountToAdd.mul(pairReserves.reserve0).div(pairReserves.reserve1);
|
||||
setAmountBottom(amount.toString());
|
||||
}
|
||||
}, [amountTop, pairReserves])
|
||||
} else if (addressTop.toUpperCase() === tokenAddresses.token0.toUpperCase()) {
|
||||
if (pairReserves?.reserve0.gt(new DecimalBigNumber(0n, 0))) {
|
||||
const value = new DecimalBigNumber(amountTop, balanceBottom._decimals)
|
||||
const amountToAdd = new DecimalBigNumber(value._value.toBigInt(), balanceBottom._decimals);
|
||||
const amount = amountToAdd.mul(pairReserves.reserve1).div(pairReserves.reserve0);
|
||||
setAmountBottom(amount.toString());
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setAmountTop("");
|
||||
setAmountBottom("");
|
||||
}, [tokenNameTop, tokenNameBottom])
|
||||
}, [addressBottom, balanceTop, balanceBottom, amountTop, amountBottom, tokenAddresses, pairReserves])
|
||||
|
||||
const addLiquidityInner = async () => {
|
||||
setIsPending(true);
|
||||
@ -220,7 +225,7 @@ const PoolContainer = ({
|
||||
id="to"
|
||||
token={<TokenStack tokens={[tokenNameBottom]} sx={{ fontSize: "21px" }} />}
|
||||
tokenName={tokenNameBottom}
|
||||
value={amountBottom }
|
||||
value={amountBottom}
|
||||
onChange={event => emptyPool ? setAmountBottom(event.currentTarget.value) : {}}
|
||||
endString={emptyPool ? "Max" : undefined}
|
||||
endStringOnClick={emptyPool ? setMaxBottom : {}}
|
||||
|
Loading…
Reference in New Issue
Block a user