Skip to content

Commit

Permalink
feat: hide virtual pools in Thorchain LP "Available Pools" view (#6138)
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre authored Feb 7, 2024
1 parent 4f98bdf commit 862ec55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/pages/ThorChainLP/AvailablePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ const PoolButton = ({ pool }: PoolButtonProps) => {

export const AvailablePools = () => {
const headerComponent = useMemo(() => <PoolsHeader />, [])
const { data: parsedPools, isLoading } = usePools()
const { data: parsedPools, isLoading } = usePools(true)

const renderRows = useMemo(() => {
if (isLoading) return new Array(2).fill(null).map(() => <Skeleton height={16} />)
return parsedPools?.map(pool => <PoolButton key={pool.opportunityId} pool={pool} />)
Expand Down
27 changes: 16 additions & 11 deletions src/pages/ThorChainLP/queries/hooks/usePools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type ParsedPool = MidgardPoolResponse & {
opportunityId: string
}

export const usePools = () => {
export const usePools = (excludeVirtualPools?: boolean) => {
const assets = useAppSelector(selectAssets)
const selectPools = useCallback(
(pools: MidgardPoolResponse[]) => {
Expand All @@ -38,6 +38,20 @@ export const usePools = () => {
const asset = assets[assetId]
if (!asset) return acc

const symmetrical = {
...pool,
isAsymmetric: false,
asymSide: null,
assetId,
name: `${asset.symbol}/${runeAsset.symbol} LP`,
opportunityId: `${assetId}*sym`,
}

if (excludeVirtualPools) {
acc.push(symmetrical)
return acc
}

const runeSym = {
...pool,
isAsymmetric: true,
Expand All @@ -56,21 +70,12 @@ export const usePools = () => {
opportunityId: `${assetId}*${AsymSide.Asset}`,
}

const symmetrical = {
...pool,
isAsymmetric: false,
asymSide: null,
assetId,
name: `${asset.symbol}/${runeAsset.symbol} LP`,
opportunityId: `${assetId}*sym`,
}

acc.push(runeSym, assetSym, symmetrical)

return acc
}, [] as ParsedPool[])
},
[assets],
[assets, excludeVirtualPools],
)
const pools = useQuery({
...reactQueries.midgard.poolsData(),
Expand Down

0 comments on commit 862ec55

Please sign in to comment.