From 6cf2e9e211aa36a5c31ebb834e2ea1f57e2734ad Mon Sep 17 00:00:00 2001 From: groninge Date: Tue, 24 Sep 2024 12:59:06 +0200 Subject: [PATCH 1/6] update blocking add liquidity --- lib/modules/pool/pool.helpers.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/modules/pool/pool.helpers.ts b/lib/modules/pool/pool.helpers.ts index fee0098b8..d9fc1bb26 100644 --- a/lib/modules/pool/pool.helpers.ts +++ b/lib/modules/pool/pool.helpers.ts @@ -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 From cfa7a0067d66e1e2a294df1f0453247c4bca3e3d Mon Sep 17 00:00:00 2001 From: groninge Date: Tue, 24 Sep 2024 13:08:54 +0200 Subject: [PATCH 2/6] add alerts for paused and in recovery mode --- lib/modules/pool/alerts/usePoolAlerts.tsx | 49 +++++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/lib/modules/pool/alerts/usePoolAlerts.tsx b/lib/modules/pool/alerts/usePoolAlerts.tsx index 988f9aa0c..d4bfc96d6 100644 --- a/lib/modules/pool/alerts/usePoolAlerts.tsx +++ b/lib/modules/pool/alerts/usePoolAlerts.tsx @@ -54,16 +54,19 @@ export function usePoolAlerts(pool: Pool) { const getTokenPoolAlerts = (pool: Pool): PoolAlert[] => { const poolTokens = pool.poolTokens as GqlPoolTokenDetail[] - const alerts: PoolAlert[] = [] + const defaultAlertProps = { + status: 'error' as const, + isSoftWarning: false, + } + poolTokens?.forEach(token => { if (!token.isAllowed) { alerts.push({ identifier: `TokenNotAllowed-${token.symbol}`, content: `The token ${token.symbol} is currently not supported.`, - status: 'error', - isSoftWarning: false, + ...defaultAlertProps, }) } @@ -81,8 +84,7 @@ export function usePoolAlerts(pool: Pool) { identifier: `PriceProviderNotReviewed-${token.symbol}`, // eslint-disable-next-line max-len content: `The rate provider for ${token.symbol} has not been reviewed. For your safety, you can’t interact with this pool on this UI.`, - status: 'error', - isSoftWarning: true, + ...defaultAlertProps, }) } @@ -91,8 +93,7 @@ export function usePoolAlerts(pool: Pool) { identifier: `UnsafePriceProvider-${token.symbol}`, // eslint-disable-next-line max-len content: `The rate provider for ${token.symbol} has been reviewed as 'unsafe'. For your safety, you can't interact with this pool on this UI. `, - status: 'error', - isSoftWarning: true, + ...defaultAlertProps, }) } }) @@ -128,12 +129,44 @@ export function usePoolAlerts(pool: Pool) { return alerts } + const getPoolAlerts = (pool: Pool): PoolAlert[] => { + const alerts: PoolAlert[] = [] + + const defaultAlertProps = { + status: 'warning' as const, + isSoftWarning: false, + } + + if (pool.dynamicData.isPaused && pool.dynamicData.isInRecoveryMode) { + alerts.push({ + identifier: 'poolIsPausedAndInRecoveryMode', + content: 'This pool is paused and in recovery mode', + ...defaultAlertProps, + }) + } else if (pool.dynamicData.isPaused) { + alerts.push({ + identifier: 'poolIsPaused', + content: 'This pool is paused', + ...defaultAlertProps, + }) + } else if (pool.dynamicData.isInRecoveryMode) { + alerts.push({ + identifier: 'poolIsInRecoveryMode', + content: 'This pool is in recovery mode', + ...defaultAlertProps, + }) + } + + 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]) From 6d8921bd9babf2e091caebd84293914ffb65aa61 Mon Sep 17 00:00:00 2001 From: groninge Date: Tue, 24 Sep 2024 13:15:30 +0200 Subject: [PATCH 3/6] fix test --- lib/modules/pool/alerts/usePoolAlerts.spec.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/modules/pool/alerts/usePoolAlerts.spec.tsx b/lib/modules/pool/alerts/usePoolAlerts.spec.tsx index 282501924..2479ed3aa 100644 --- a/lib/modules/pool/alerts/usePoolAlerts.spec.tsx +++ b/lib/modules/pool/alerts/usePoolAlerts.spec.tsx @@ -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", + }, ] `) }) From 62a111270d5dc210faad04556aa41c657dec0670 Mon Sep 17 00:00:00 2001 From: groninge Date: Tue, 24 Sep 2024 13:18:45 +0200 Subject: [PATCH 4/6] fix formatting --- lib/modules/pool/alerts/usePoolAlerts.spec.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/modules/pool/alerts/usePoolAlerts.spec.tsx b/lib/modules/pool/alerts/usePoolAlerts.spec.tsx index 2479ed3aa..ba86bf2a1 100644 --- a/lib/modules/pool/alerts/usePoolAlerts.spec.tsx +++ b/lib/modules/pool/alerts/usePoolAlerts.spec.tsx @@ -51,10 +51,10 @@ describe('Creates pool alerts for', () => { "status": "error", }, { - content: 'This pool is in recovery mode', - identifier: 'poolIsInRecoveryMode', - isSoftWarning: false, - status: "warning", + "content": "This pool is in recovery mode", + "identifier": "poolIsInRecoveryMode", + "isSoftWarning": false, + "status": "warning", }, ] `) From b386c4886301133111fb77af15551da5f843dd4e Mon Sep 17 00:00:00 2001 From: groninge Date: Wed, 25 Sep 2024 11:44:26 +0200 Subject: [PATCH 5/6] reverted the extraction --- lib/modules/pool/alerts/usePoolAlerts.tsx | 28 ++++++++++------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/modules/pool/alerts/usePoolAlerts.tsx b/lib/modules/pool/alerts/usePoolAlerts.tsx index d4bfc96d6..c76c4746a 100644 --- a/lib/modules/pool/alerts/usePoolAlerts.tsx +++ b/lib/modules/pool/alerts/usePoolAlerts.tsx @@ -56,17 +56,13 @@ export function usePoolAlerts(pool: Pool) { const poolTokens = pool.poolTokens as GqlPoolTokenDetail[] const alerts: PoolAlert[] = [] - const defaultAlertProps = { - status: 'error' as const, - isSoftWarning: false, - } - poolTokens?.forEach(token => { if (!token.isAllowed) { alerts.push({ identifier: `TokenNotAllowed-${token.symbol}`, content: `The token ${token.symbol} is currently not supported.`, - ...defaultAlertProps, + status: 'error', + isSoftWarning: true, }) } @@ -84,7 +80,8 @@ export function usePoolAlerts(pool: Pool) { identifier: `PriceProviderNotReviewed-${token.symbol}`, // eslint-disable-next-line max-len content: `The rate provider for ${token.symbol} has not been reviewed. For your safety, you can’t interact with this pool on this UI.`, - ...defaultAlertProps, + status: 'error', + isSoftWarning: true, }) } @@ -93,7 +90,8 @@ export function usePoolAlerts(pool: Pool) { identifier: `UnsafePriceProvider-${token.symbol}`, // eslint-disable-next-line max-len content: `The rate provider for ${token.symbol} has been reviewed as 'unsafe'. For your safety, you can't interact with this pool on this UI. `, - ...defaultAlertProps, + status: 'error', + isSoftWarning: true, }) } }) @@ -132,28 +130,26 @@ export function usePoolAlerts(pool: Pool) { const getPoolAlerts = (pool: Pool): PoolAlert[] => { const alerts: PoolAlert[] = [] - const defaultAlertProps = { - status: 'warning' as const, - isSoftWarning: false, - } - if (pool.dynamicData.isPaused && pool.dynamicData.isInRecoveryMode) { alerts.push({ identifier: 'poolIsPausedAndInRecoveryMode', content: 'This pool is paused and in recovery mode', - ...defaultAlertProps, + status: 'warning', + isSoftWarning: false, }) } else if (pool.dynamicData.isPaused) { alerts.push({ identifier: 'poolIsPaused', content: 'This pool is paused', - ...defaultAlertProps, + status: 'warning', + isSoftWarning: false, }) } else if (pool.dynamicData.isInRecoveryMode) { alerts.push({ identifier: 'poolIsInRecoveryMode', content: 'This pool is in recovery mode', - ...defaultAlertProps, + status: 'warning', + isSoftWarning: false, }) } From 169fcc2c999efa939cd12b68d36af6799487543b Mon Sep 17 00:00:00 2001 From: groninge Date: Wed, 25 Sep 2024 11:47:25 +0200 Subject: [PATCH 6/6] correct revert --- lib/modules/pool/alerts/usePoolAlerts.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/modules/pool/alerts/usePoolAlerts.tsx b/lib/modules/pool/alerts/usePoolAlerts.tsx index c76c4746a..c0fb42ce6 100644 --- a/lib/modules/pool/alerts/usePoolAlerts.tsx +++ b/lib/modules/pool/alerts/usePoolAlerts.tsx @@ -54,6 +54,7 @@ export function usePoolAlerts(pool: Pool) { const getTokenPoolAlerts = (pool: Pool): PoolAlert[] => { const poolTokens = pool.poolTokens as GqlPoolTokenDetail[] + const alerts: PoolAlert[] = [] poolTokens?.forEach(token => { @@ -62,7 +63,7 @@ export function usePoolAlerts(pool: Pool) { identifier: `TokenNotAllowed-${token.symbol}`, content: `The token ${token.symbol} is currently not supported.`, status: 'error', - isSoftWarning: true, + isSoftWarning: false, }) }