From 5a80f102c03dfd736fe88c50aedf73ef6b683876 Mon Sep 17 00:00:00 2001 From: Adam <59410529+adam5909099@users.noreply.github.com> Date: Mon, 30 May 2022 00:50:14 -0400 Subject: [PATCH 1/2] Fix position flickering issue (#455) --- .../frontend/src/state/positions/atoms.ts | 1 - .../frontend/src/state/positions/hooks.ts | 19 +------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/packages/frontend/src/state/positions/atoms.ts b/packages/frontend/src/state/positions/atoms.ts index 3404e00ae..45fa131dd 100644 --- a/packages/frontend/src/state/positions/atoms.ts +++ b/packages/frontend/src/state/positions/atoms.ts @@ -65,7 +65,6 @@ export const managerAtom = atom((get) => { }) export const activePositionsAtom = atom([]) export const closedPositionsAtom = atom([]) -export const lpPositionsLoadingAtom = atom(false) export const squeethLiquidityAtom = atom(BIG_ZERO) export const wethLiquidityAtom = atom(BIG_ZERO) export const depositedSqueethAtom = atom(BIG_ZERO) diff --git a/packages/frontend/src/state/positions/hooks.ts b/packages/frontend/src/state/positions/hooks.ts index 33fad26ca..ff044ad73 100644 --- a/packages/frontend/src/state/positions/hooks.ts +++ b/packages/frontend/src/state/positions/hooks.ts @@ -19,7 +19,6 @@ import { managerAtom, activePositionsAtom, closedPositionsAtom, - lpPositionsLoadingAtom, squeethLiquidityAtom, wethLiquidityAtom, depositedSqueethAtom, @@ -207,7 +206,6 @@ export const useLpDebt = () => { export const useLPPositionsQuery = () => { const { squeethPool } = useAtomValue(addressesAtom) const address = useAtomValue(addressAtom) - const lpPositionsLoading = useAtomValue(lpPositionsLoadingAtom) const { data, refetch, loading, subscribeToMore } = useQuery(POSITIONS_QUERY, { variables: { poolAddress: squeethPool?.toLowerCase(), @@ -233,7 +231,7 @@ export const useLPPositionsQuery = () => { }) }, [address, squeethPool, subscribeToMore]) - return { data, refetch, loading: loading || lpPositionsLoading } + return { data, refetch, loading } } const MAX_UNIT = '0xffffffffffffffffffffffffffffffff' @@ -320,7 +318,6 @@ export const usePositionsAndFeesComputation = () => { const isWethToken0 = useAtomValue(isWethToken0Atom) const [activePositions, setActivePositions] = useAtom(activePositionsAtom) const setClosedPositions = useUpdateAtom(closedPositionsAtom) - const setLoading = useUpdateAtom(lpPositionsLoadingAtom) const setDepositedSqueeth = useUpdateAtom(depositedSqueethAtom) const setDepositedWeth = useUpdateAtom(depositedWethAtom) const setWithdrawnSqueeth = useUpdateAtom(withdrawnSqueethAtom) @@ -333,7 +330,6 @@ export const usePositionsAndFeesComputation = () => { useAppEffect(() => { if (positionAndFees && !gphLoading) { - setLoading(true) // Promise.all(positionAndFees).then((values: any[]) => { setActivePositions(positionAndFees.filter((p) => p.amount0.gt(0) || p.amount1.gt(0))) setClosedPositions(positionAndFees.filter((p) => p.amount0.isZero() && p.amount1.isZero())) @@ -367,18 +363,6 @@ export const usePositionsAndFeesComputation = () => { setWithdrawnWeth(withWeth) setSqueethLiquidity(sqthLiq) setWethLiquidity(wethLiq) - if ( - !( - depSqth.isEqualTo(0) && - depWeth.isEqualTo(0) && - withSqth.isEqualTo(0) && - sqthLiq.isEqualTo(0) && - wethLiq.isEqualTo(0) - ) || - activePositions.length === 0 - ) - setLoading(false) - // }) } }, [ gphLoading, @@ -389,7 +373,6 @@ export const usePositionsAndFeesComputation = () => { setClosedPositions, setDepositedSqueeth, setDepositedWeth, - setLoading, setSqueethLiquidity, setWethLiquidity, setWithdrawnSqueeth, From 8b24f82498e1c1a63ce6425c69213a0a9b7df604 Mon Sep 17 00:00:00 2001 From: Darya Kaviani Date: Tue, 31 May 2022 03:21:04 -0700 Subject: [PATCH 2/2] change getContractAt to getContract for controller and wsqueeth (#499) Co-authored-by: Haythem Sellami --- packages/hardhat/tasks/addSqueethLiquidity.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hardhat/tasks/addSqueethLiquidity.ts b/packages/hardhat/tasks/addSqueethLiquidity.ts index 6c54762aa..de1c3c4ed 100644 --- a/packages/hardhat/tasks/addSqueethLiquidity.ts +++ b/packages/hardhat/tasks/addSqueethLiquidity.ts @@ -30,8 +30,8 @@ task("addSqueethLiquidity", "Add liquidity to wsqueeth pool") const { deployer } = await getNamedAccounts(); const { positionManager, uniswapFactory } = await getUniswapDeployments(ethers, deployer, network.name) - const controller = await ethers.getContractAt("Controller", deployer); - const wsqueeth = await ethers.getContractAt("WPowerPerp", deployer); + const controller = await ethers.getContract("Controller", deployer); + const wsqueeth = await ethers.getContract("WPowerPerp", deployer); const weth = await getWETH(ethers, deployer, network.name) const isWethToken0 = parseInt(weth.address, 16) < parseInt(wsqueeth.address, 16)