-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from bleu/pedro/cow-425-uniswap-v2-withdraw-co…
…w-review-pt1 fix: elena comments pt1
- Loading branch information
Showing
14 changed files
with
257 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,10 @@ | ||
import { useCallback } from "react"; | ||
import useSWR from "swr"; | ||
import { isAddress } from "viem"; | ||
import { useFetchNewPoolCallback } from "./useFetchNewPoolCallback"; | ||
import { useMemo } from "react"; | ||
import { useUserPools } from "./useUserPools"; | ||
|
||
export function useSelectedPool(poolId: string) { | ||
const fetchNewPoolCallback = useFetchNewPoolCallback(); | ||
|
||
const getSelectedPoolCallback = useCallback( | ||
async (_poolId: string) => { | ||
if (!fetchNewPoolCallback) return; | ||
if (!isAddress(_poolId)) return; | ||
|
||
const fetchedNewPool = await fetchNewPoolCallback(_poolId); | ||
return fetchedNewPool; | ||
}, | ||
[fetchNewPoolCallback], | ||
); | ||
|
||
return useSWR(poolId, getSelectedPoolCallback); | ||
const { data: pools } = useUserPools(); | ||
return useMemo(() => { | ||
if (!pools) return; | ||
return pools.find((pool) => pool.id.toLowerCase() === poolId.toLowerCase()); | ||
}, [pools, poolId]); | ||
} |
Oops, something went wrong.