Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

feat: add extra pool alerts #1122

Merged
merged 6 commits into from
Sep 26, 2024
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
6 changes: 6 additions & 0 deletions lib/modules/pool/alerts/usePoolAlerts.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ describe('Creates pool alerts for', () => {
"learnMoreLink": "https://forum.balancer.fi/t/vulnerability-found-in-some-pools/5102/1",
"status": "error",
},
{
"content": "This pool is in recovery mode",
"identifier": "poolIsInRecoveryMode",
"isSoftWarning": false,
"status": "warning",
},
]
`)
})
Expand Down
32 changes: 31 additions & 1 deletion lib/modules/pool/alerts/usePoolAlerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,42 @@ export function usePoolAlerts(pool: Pool) {
return alerts
}

const getPoolAlerts = (pool: Pool): PoolAlert[] => {
const alerts: PoolAlert[] = []

if (pool.dynamicData.isPaused && pool.dynamicData.isInRecoveryMode) {
alerts.push({
identifier: 'poolIsPausedAndInRecoveryMode',
content: 'This pool is paused and in recovery mode',
status: 'warning',
isSoftWarning: false,
})
} else if (pool.dynamicData.isPaused) {
alerts.push({
identifier: 'poolIsPaused',
content: 'This pool is paused',
status: 'warning',
isSoftWarning: false,
})
} else if (pool.dynamicData.isInRecoveryMode) {
alerts.push({
identifier: 'poolIsInRecoveryMode',
content: 'This pool is in recovery mode',
status: 'warning',
isSoftWarning: false,
})
}

return alerts
}

useEffect(() => {
const networkPoolAlerts = getNetworkPoolAlerts(pool)
const tokenPoolAlerts = getTokenPoolAlerts(pool)
const userAlerts = getUserAlerts(pool)
const poolAlerts = getPoolAlerts(pool)

setPoolAlerts([...networkPoolAlerts, ...tokenPoolAlerts, ...userAlerts])
setPoolAlerts([...networkPoolAlerts, ...tokenPoolAlerts, ...userAlerts, ...poolAlerts])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pool])

Expand Down
6 changes: 4 additions & 2 deletions lib/modules/pool/pool.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ export function hasReviewedRateProvider(token: GqlPoolTokenDetail): boolean {
export function shouldBlockAddLiquidity(pool: Pool) {
const poolTokens = pool.poolTokens as GqlPoolTokenDetail[]

// If pool is an LBP, we should block adding liquidity
if (isLBP(pool.type)) return true
// If pool is an LBP, paused or in recovery mode, we should block adding liquidity
if (isLBP(pool.type) || pool.dynamicData.isPaused || pool.dynamicData.isInRecoveryMode) {
return true
}

return poolTokens.some(token => {
// if token is not allowed - we should block adding liquidity
Expand Down
Loading