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",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.29",
|
"version": "0.0.30",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@ -68,10 +68,10 @@ const PoolContainer = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onSwap = () => {
|
const onSwap = () => {
|
||||||
const oldAmountTop = amountTop;
|
// const oldAmountTop = amountTop;
|
||||||
const oldAmountBottom = amountBottom;
|
// const oldAmountBottom = amountBottom;
|
||||||
setAmountBottom(oldAmountTop);
|
// setAmountBottom(oldAmountTop);
|
||||||
setAmountTop(oldAmountBottom);
|
setAmountTop(amountBottom);
|
||||||
onCardsSwap();
|
onCardsSwap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,18 +138,23 @@ const PoolContainer = ({
|
|||||||
}, [pairReserves, amountTop, amountBottom, balanceTop, balanceBottom]);
|
}, [pairReserves, amountTop, amountBottom, balanceTop, balanceBottom]);
|
||||||
|
|
||||||
useEffect(() => {
|
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 value = new DecimalBigNumber(amountTop, balanceTop._decimals)
|
||||||
const amountToAdd = new DecimalBigNumber(value._value.toBigInt(), balanceTop._decimals);
|
const amountToAdd = new DecimalBigNumber(value._value.toBigInt(), balanceTop._decimals);
|
||||||
const amount = amountToAdd.mul(pairReserves.reserve0).div(pairReserves.reserve1);
|
const amount = amountToAdd.mul(pairReserves.reserve0).div(pairReserves.reserve1);
|
||||||
setAmountBottom(amount.toString());
|
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(() => {
|
}, [addressBottom, balanceTop, balanceBottom, amountTop, amountBottom, tokenAddresses, pairReserves])
|
||||||
setAmountTop("");
|
|
||||||
setAmountBottom("");
|
|
||||||
}, [tokenNameTop, tokenNameBottom])
|
|
||||||
|
|
||||||
const addLiquidityInner = async () => {
|
const addLiquidityInner = async () => {
|
||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user