Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const isLpDepositEnabled = ({
}) => {
if (!assetId) return undefined

if (mimir.PAUSELP) return false

const pauseLpDepositMimirs = Object.fromEntries(
Object.entries(mimir).filter(([k]) => k.startsWith('PAUSELPDEPOSIT-')),
)
Expand All @@ -31,10 +33,32 @@ export const isLpDepositEnabled = ({
return !isDisabled
}

export const isLpWithdrawEnabled = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checks for global halt - not asset-specific, no such thing for withdraws

mimir,
assetId,
}: {
mimir: ThorchainMimir
assetId: AssetId | undefined
}) => {
if (!assetId) return undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here for conschischtenschy with deposit variant only


if (mimir.PAUSELP) return false

return true
}

export const useIsLpDepositEnabled = (assetId: AssetId | undefined) => {
return useThorchainMimir({
chainId: thorchainChainId,
enabled: Boolean(assetId),
select: mimir => isLpDepositEnabled({ mimir, assetId }),
})
}

export const useIsLpWithdrawEnabled = (assetId: AssetId | undefined) => {
return useThorchainMimir({
chainId: thorchainChainId,
enabled: Boolean(assetId),
select: mimir => isLpWithdrawEnabled({ mimir, assetId }),
})
}
11 changes: 8 additions & 3 deletions src/pages/ThorChainLP/AvailablePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const AvailablePools = () => {
const { data: pools } = usePools()
const translate = useTranslate()

const isThorchainLpDepositFlagEnabled = useFeatureFlag('ThorchainLpDeposit')
const isThorchainLpWithdrawFlagEnabled = useFeatureFlag('ThorchainLpWithdraw')

const headerComponent = useMemo(() => <PoolsHeader />, [])

// Partition pools by *akschually* available (not halted, staged, nor deposits disabled) and the rest
Expand Down Expand Up @@ -81,8 +84,10 @@ export const AvailablePools = () => {
Cell: ({ row, value }: { value: string; row: RowProps }) => {
const pool = row.original

const isThorchainLpDepositEnabled = useFeatureFlag('ThorchainLpDeposit')
const isThorchainLpWithdrawEnabled = useFeatureFlag('ThorchainLpWithdraw')
const isThorchainLpDepositEnabled =
isThorchainLpDepositFlagEnabled && pool.isLpDepositEnabled !== false
const isThorchainLpWithdrawEnabled =
isThorchainLpWithdrawFlagEnabled && pool.isLpWithdrawEnabled !== false
const isThorchainLpInteractionDisabled =
!isThorchainLpDepositEnabled && !isThorchainLpWithdrawEnabled

Expand Down Expand Up @@ -186,7 +191,7 @@ export const AvailablePools = () => {
},
},
],
[translate],
[translate, isThorchainLpDepositFlagEnabled, isThorchainLpWithdrawFlagEnabled],
)

const handlePoolClick = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,10 @@ export const AddLiquidityInput: React.FC<AddLiquidityInputProps> = ({
})
}, [poolAsset])

const isThorchainLpDepositFlagEnabled = useFeatureFlag('ThorchainLpDeposit')
const { data: isThorchainLpDepositEnabledForPool } = useIsLpDepositEnabled(poolAsset?.assetId)
const isThorchainLpDepositEnabled =
isThorchainLpDepositFlagEnabled && isThorchainLpDepositEnabledForPool !== false

const feeEstimationMemo = useMemo(() => {
if (thorchainNotationPoolAssetId === undefined) return null
Expand Down Expand Up @@ -613,8 +616,6 @@ export const AddLiquidityInput: React.FC<AddLiquidityInputProps> = ({

const { isChainHalted, isFetching: isChainHaltedFetching } = useIsChainHalted(poolAsset?.chainId)

const isThorchainLpDepositFlagEnabled = useFeatureFlag('ThorchainLpDeposit')

const serializedApprovalTxIndex = useMemo(() => {
if (!(approvalTxId && poolAssetAccountAddress && poolAssetAccountId)) return ''
return serializeTxIndex(poolAssetAccountId, approvalTxId, poolAssetAccountAddress)
Expand Down Expand Up @@ -1044,7 +1045,6 @@ export const AddLiquidityInput: React.FC<AddLiquidityInputProps> = ({
actualRuneDepositAmountCryptoPrecision,
poolAsset,
runeMarketData,
isThorchainLpDepositFlagEnabled,
])

useEffect(() => {
Expand Down Expand Up @@ -1463,6 +1463,7 @@ export const AddLiquidityInput: React.FC<AddLiquidityInputProps> = ({
isConnected,
isSmartContractAccountAddress,
isThorchainLpDepositFlagEnabled,
isThorchainLpDepositEnabledForPool,
isTradingActive,
isChainHalted,
notEnoughFeeAssetError,
Expand All @@ -1474,7 +1475,6 @@ export const AddLiquidityInput: React.FC<AddLiquidityInputProps> = ({
runeAsset,
translate,
walletSupportsOpportunity,
isThorchainLpDepositEnabledForPool,
isStagedAsymDeposit,
])

Expand Down Expand Up @@ -1660,8 +1660,7 @@ export const AddLiquidityInput: React.FC<AddLiquidityInputProps> = ({
disabledSymDepositAfterRune ||
isTradingActive === false ||
isChainHalted ||
!isThorchainLpDepositFlagEnabled ||
isThorchainLpDepositEnabledForPool === false ||
!isThorchainLpDepositEnabled ||
!confirmedQuote ||
!hasEnoughAssetBalance ||
!hasEnoughRuneBalance ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { assertUnreachable } from '@/lib/utils'
import { fromThorBaseUnit, getThorchainFromAddress } from '@/lib/utils/thorchain'
import { THOR_PRECISION } from '@/lib/utils/thorchain/constants'
import { useIsChainHalted } from '@/lib/utils/thorchain/hooks/useIsChainHalted'
import { useIsLpWithdrawEnabled } from '@/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled'
import { useSendThorTx } from '@/lib/utils/thorchain/hooks/useSendThorTx'
import { estimateRemoveThorchainLiquidityPosition } from '@/lib/utils/thorchain/lp'
import type { LpConfirmedWithdrawalQuote, UserLpDataPosition } from '@/lib/utils/thorchain/lp/types'
Expand Down Expand Up @@ -190,7 +191,8 @@ export const RemoveLiquidityInput: React.FC<RemoveLiquidityInputProps> = ({
fromAssetId(assetId).chainId,
)

const isThorchainLpWithdrawEnabled = useFeatureFlag('ThorchainLpWithdraw')
const isThorchainLpWithdrawFlagEnabled = useFeatureFlag('ThorchainLpWithdraw')
const { data: isThorchainLpWithdrawEnabledForPool } = useIsLpWithdrawEnabled(poolAsset?.assetId)
Copy link
Contributor Author

@gomesalexandre gomesalexandre Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not exactly true re: "for pool", but keeps things consistent


const currentAccountIdByChainId = useMemo(() => {
if (!poolAsset) return {}
Expand Down Expand Up @@ -965,7 +967,8 @@ export const RemoveLiquidityInput: React.FC<RemoveLiquidityInputProps> = ({
if (isUnsupportedWithdraw) return translate('common.unsupportedNetwork')
if (isChainHalted) return translate('common.chainHalted')
if (isTradingActive === false) return translate('common.poolHalted')
if (!isThorchainLpWithdrawEnabled) return translate('common.poolDisabled')
if (!isThorchainLpWithdrawFlagEnabled) return translate('common.poolDisabled')
if (isThorchainLpWithdrawEnabledForPool === false) return translate('common.poolDisabled')
if (position?.remainingLockupTime)
return translate('defi.liquidityLocked', {
time: formatSecondsToDuration(position.remainingLockupTime),
Expand All @@ -983,7 +986,8 @@ export const RemoveLiquidityInput: React.FC<RemoveLiquidityInputProps> = ({
}, [
hasEnoughPoolAssetFeeAssetBalanceForTx,
hasEnoughRuneBalanceForTx,
isThorchainLpWithdrawEnabled,
isThorchainLpWithdrawFlagEnabled,
isThorchainLpWithdrawEnabledForPool,
isTradingActive,
isChainHalted,
isUnsupportedWithdraw,
Expand Down
1 change: 1 addition & 0 deletions src/pages/ThorChainLP/queries/hooks/usePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type Pool = MidgardPoolResponse & {
isTradingActive?: boolean
isTradingActiveLoading?: boolean
isLpDepositEnabled?: boolean
isLpWithdrawEnabled?: boolean
}

export type PoolStats = {
Expand Down
11 changes: 9 additions & 2 deletions src/pages/ThorChainLP/queries/hooks/usePools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import type { Pool, VolumeStats } from './usePool'
import { getPool, getVolumeStats, selectSwapsData } from './usePool'

import { bn } from '@/lib/bignumber/bignumber'
import { isLpDepositEnabled } from '@/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled'
import {
isLpDepositEnabled,
isLpWithdrawEnabled,
} from '@/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled'
import { useThorchainMimir } from '@/lib/utils/thorchain/hooks/useThorchainMimir'
import type { MidgardSwapHistoryResponse } from '@/lib/utils/thorchain/lp/types'
import { reactQueries } from '@/react-queries'
Expand Down Expand Up @@ -136,7 +139,11 @@ export const usePools = () => {
const assetId = thorPoolAssetIdToAssetId(pool.asset)
if (!assetId) return acc

acc.push({ ...pool, isLpDepositEnabled: isLpDepositEnabled({ mimir, assetId }) })
acc.push({
...pool,
isLpDepositEnabled: isLpDepositEnabled({ mimir, assetId }),
isLpWithdrawEnabled: isLpWithdrawEnabled({ mimir, assetId }),
})
return acc
}, [])

Expand Down