From 1c9cb30b0bcd280476693a573ae6a04fd320e3db Mon Sep 17 00:00:00 2001
From: gomes <17035424+gomesalexandre@users.noreply.github.com>
Date: Mon, 27 Mar 2023 19:34:53 +0200
Subject: [PATCH 1/2] feat(idle): disable deposit on paused pools
---
.env.base | 1 -
src/config.ts | 1 -
.../IdleManager/Overview/IdleOverview.tsx | 38 +++++++++----------
src/state/migrations/index.ts | 1 +
.../resolvers/idle/index.ts | 2 +
src/state/slices/opportunitiesSlice/types.ts | 2 +
.../preferencesSlice/preferencesSlice.ts | 2 -
src/test/mocks/store.ts | 1 -
8 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/.env.base b/.env.base
index 85711f39a3e..162402f39fe 100644
--- a/.env.base
+++ b/.env.base
@@ -8,7 +8,6 @@ REACT_APP_FEATURE_COWSWAP=true
REACT_APP_FEATURE_DASHBOARD_TABS=true
REACT_APP_FEATURE_DEFI_DASHBOARD=true
REACT_APP_FEATURE_IDLE=true
-REACT_APP_FEATURE_IDLE_DEPOSITS=false
REACT_APP_FEATURE_LIFI_SWAP=false
REACT_APP_FEATURE_LIVESUPPORT=true
REACT_APP_FEATURE_MIXPANEL=true
diff --git a/src/config.ts b/src/config.ts
index 66bd83153a7..0aef27463d6 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -76,7 +76,6 @@ const validators = {
REACT_APP_FEATURE_ZRX_OPTIMISM: bool({ default: false }),
REACT_APP_FEATURE_THOR_SWAP: bool({ default: false }),
REACT_APP_FEATURE_IDLE: bool({ default: false }),
- REACT_APP_FEATURE_IDLE_DEPOSITS: bool({ default: false }),
REACT_APP_FEATURE_YAT: bool({ default: false }),
REACT_APP_FEATURE_AXELAR: bool({ default: false }),
REACT_APP_FEATURE_SAVERS_VAULTS: bool({ default: false }),
diff --git a/src/features/defi/providers/idle/components/IdleManager/Overview/IdleOverview.tsx b/src/features/defi/providers/idle/components/IdleManager/Overview/IdleOverview.tsx
index efd2e33e1c4..d16ef8f00fc 100644
--- a/src/features/defi/providers/idle/components/IdleManager/Overview/IdleOverview.tsx
+++ b/src/features/defi/providers/idle/components/IdleManager/Overview/IdleOverview.tsx
@@ -33,7 +33,6 @@ import {
selectAssetById,
selectAssets,
selectEarnUserStakingOpportunityByUserStakingId,
- selectFeatureFlags,
selectFirstAccountIdByChainId,
selectHighestBalanceAccountIdByStakingId,
selectMarketDataById,
@@ -41,26 +40,10 @@ import {
selectSelectedLocale,
selectUnderlyingStakingAssetsWithBalancesAndIcons,
} from 'state/slices/selectors'
-import { store, useAppSelector } from 'state/store'
+import { useAppSelector } from 'state/store'
import { IdleEmpty } from './IdleEmpty'
-const { IdleFinanceDeposits } = selectFeatureFlags(store.getState())
-
-const defaultMenu: DefiButtonProps[] = [
- {
- label: 'common.deposit',
- icon: ,
- action: DefiAction.Deposit,
- isDisabled: !IdleFinanceDeposits,
- },
- {
- label: 'common.withdraw',
- icon: ,
- action: DefiAction.Withdraw,
- },
-]
-
const idleTagDescriptions: Record = {
[IdleTag.BestYield]: {
title: 'idle.bestYield.title',
@@ -153,6 +136,23 @@ export const IdleOverview: React.FC = ({
selectEarnUserStakingOpportunityByUserStakingId(state, opportunityDataFilter),
)
+ const defaultMenu: DefiButtonProps[] = useMemo(
+ () => [
+ {
+ label: 'common.deposit',
+ icon: ,
+ action: DefiAction.Deposit,
+ isDisabled: Boolean(!opportunityData?.active),
+ },
+ {
+ label: 'common.withdraw',
+ icon: ,
+ action: DefiAction.Withdraw,
+ },
+ ],
+ [opportunityData?.active],
+ )
+
const underlyingAssetId = useMemo(
() => opportunityData?.underlyingAssetIds?.[0],
[opportunityData?.underlyingAssetIds],
@@ -217,7 +217,7 @@ export const IdleOverview: React.FC = ({
toolTip: translate('defi.modals.overview.noWithdrawals'),
},
]
- }, [contractAddress, idleInvestor, opportunityData, hasClaimBalance, translate])
+ }, [contractAddress, idleInvestor, opportunityData, defaultMenu, hasClaimBalance, translate])
const renderTags = useMemo(() => {
return opportunityData?.tags?.map(tag => {
diff --git a/src/state/migrations/index.ts b/src/state/migrations/index.ts
index 735982b37e5..a92a39b64e5 100644
--- a/src/state/migrations/index.ts
+++ b/src/state/migrations/index.ts
@@ -28,4 +28,5 @@ export const migrations = {
11: clearIdleOpportunities,
12: clearOpportunities,
13: clearOpportunitiesAgain,
+ 14: clearOpportunitiesAgain,
}
diff --git a/src/state/slices/opportunitiesSlice/resolvers/idle/index.ts b/src/state/slices/opportunitiesSlice/resolvers/idle/index.ts
index ad8435c3b6a..0fee84f9899 100644
--- a/src/state/slices/opportunitiesSlice/resolvers/idle/index.ts
+++ b/src/state/slices/opportunitiesSlice/resolvers/idle/index.ts
@@ -121,8 +121,10 @@ export const idleStakingOpportunitiesMetadataResolver = async ({
provider: DefiProvider.Idle,
type: DefiType.Staking,
tags: [opportunity.strategy],
+ active: opportunity.active,
}
: {
+ active: opportunity.active,
apy: opportunity.apy.toFixed(),
assetId,
cdoAddress: opportunity.metadata.cdoAddress,
diff --git a/src/state/slices/opportunitiesSlice/types.ts b/src/state/slices/opportunitiesSlice/types.ts
index d489c365c6f..cdfe8aeecfe 100644
--- a/src/state/slices/opportunitiesSlice/types.ts
+++ b/src/state/slices/opportunitiesSlice/types.ts
@@ -45,6 +45,7 @@ export type OpportunityMetadataBase = {
isClaimableRewards: boolean
// claimableRewards: boolean
expired?: boolean
+ active?: boolean
name: string
version?: string
tags?: string[]
@@ -164,6 +165,7 @@ type EarnOpportunityTypeBase = {
cryptoAmountPrecision: string
cryptoAmountBaseUnit: string
expired?: boolean
+ active?: boolean
chainId: ChainId
showAssetSymbol?: boolean
isLoaded: boolean
diff --git a/src/state/slices/preferencesSlice/preferencesSlice.ts b/src/state/slices/preferencesSlice/preferencesSlice.ts
index 2f2c4285a16..e45ea70c6cc 100644
--- a/src/state/slices/preferencesSlice/preferencesSlice.ts
+++ b/src/state/slices/preferencesSlice/preferencesSlice.ts
@@ -17,7 +17,6 @@ export type FeatureFlags = {
BnbSmartChain: boolean
ThorSwap: boolean
IdleFinance: boolean
- IdleFinanceDeposits: boolean
Axelar: boolean
Yat: boolean
WalletConnectToDapps: boolean
@@ -67,7 +66,6 @@ const initialState: Preferences = {
BnbSmartChain: getConfig().REACT_APP_FEATURE_BNBSMARTCHAIN,
ThorSwap: getConfig().REACT_APP_FEATURE_THOR_SWAP,
IdleFinance: getConfig().REACT_APP_FEATURE_IDLE,
- IdleFinanceDeposits: getConfig().REACT_APP_FEATURE_IDLE_DEPOSITS,
Axelar: getConfig().REACT_APP_FEATURE_AXELAR,
Yat: getConfig().REACT_APP_FEATURE_YAT,
WalletConnectToDapps: getConfig().REACT_APP_FEATURE_WALLET_CONNECT_TO_DAPPS,
diff --git a/src/test/mocks/store.ts b/src/test/mocks/store.ts
index 37322283861..3effddf317e 100644
--- a/src/test/mocks/store.ts
+++ b/src/test/mocks/store.ts
@@ -63,7 +63,6 @@ export const mockStore: ReduxState = {
ThorSwap: false,
Cowswap: false,
IdleFinance: false,
- IdleFinanceDeposits: false,
Axelar: false,
Yat: false,
WalletConnectToDapps: false,
From 0e512378590871c367f5ed184122701271165293 Mon Sep 17 00:00:00 2001
From: gomes <17035424+gomesalexandre@users.noreply.github.com>
Date: Mon, 27 Mar 2023 20:13:50 +0200
Subject: [PATCH 2/2] feat: bump @shapeshiftoss/investor-idle to latest
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index d31e6c701bd..6f31a169410 100644
--- a/package.json
+++ b/package.json
@@ -106,7 +106,7 @@
"@shapeshiftoss/hdwallet-walletconnect": "^1.46.0",
"@shapeshiftoss/hdwallet-xdefi": "^1.46.0",
"@shapeshiftoss/investor-foxy": "^8.0.1",
- "@shapeshiftoss/investor-idle": "^2.6.2",
+ "@shapeshiftoss/investor-idle": "^2.7.0",
"@shapeshiftoss/investor-yearn": "^6.4.4",
"@shapeshiftoss/logger": "^1.1.3",
"@shapeshiftoss/market-service": "^7.8.0",
diff --git a/yarn.lock b/yarn.lock
index aed2be7dd98..448f421ec65 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4331,10 +4331,10 @@
web3-core "1.7.4"
web3-utils "1.7.4"
-"@shapeshiftoss/investor-idle@^2.6.2":
- version "2.6.2"
- resolved "https://registry.yarnpkg.com/@shapeshiftoss/investor-idle/-/investor-idle-2.6.2.tgz#3a465cf457632bb6c3e504655ddd7df96ab2cede"
- integrity sha512-q6glEfBeE52AMG1MpEqflXuNp3tvlAKd0iHyxQhLEL6kT+6qNT3G5GL1ySAQuDD/fvwMHAZG9pR9LcChL1P00Q==
+"@shapeshiftoss/investor-idle@^2.7.0":
+ version "2.7.0"
+ resolved "https://registry.yarnpkg.com/@shapeshiftoss/investor-idle/-/investor-idle-2.7.0.tgz#37582f03192d80dbf52ce1ce2145efb623ca2254"
+ integrity sha512-k8lTfgIDjCkXe8ObhBu58xNRSnqsoF/wYcGRmtoZxTmdkUS0TbYhJfQ7KBjJ2DtryxoMCDnFnmQiQRYiF9qiEg==
dependencies:
"@ethersproject/providers" "^5.5.3"
bignumber.js "^9.1.1"