Skip to content

Commit

Permalink
feat(idle): disable deposit on paused pools (#4141)
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre authored Mar 27, 2023
1 parent 8317a2f commit f2a4043
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
1 change: 0 additions & 1 deletion .env.base
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,17 @@ import {
selectAssetById,
selectAssets,
selectEarnUserStakingOpportunityByUserStakingId,
selectFeatureFlags,
selectFirstAccountIdByChainId,
selectHighestBalanceAccountIdByStakingId,
selectMarketDataById,
selectPortfolioCryptoBalanceByFilter,
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: <ArrowUpIcon />,
action: DefiAction.Deposit,
isDisabled: !IdleFinanceDeposits,
},
{
label: 'common.withdraw',
icon: <ArrowDownIcon />,
action: DefiAction.Withdraw,
},
]

const idleTagDescriptions: Record<IdleTag, TagDescription> = {
[IdleTag.BestYield]: {
title: 'idle.bestYield.title',
Expand Down Expand Up @@ -153,6 +136,23 @@ export const IdleOverview: React.FC<IdleOverviewProps> = ({
selectEarnUserStakingOpportunityByUserStakingId(state, opportunityDataFilter),
)

const defaultMenu: DefiButtonProps[] = useMemo(
() => [
{
label: 'common.deposit',
icon: <ArrowUpIcon />,
action: DefiAction.Deposit,
isDisabled: Boolean(!opportunityData?.active),
},
{
label: 'common.withdraw',
icon: <ArrowDownIcon />,
action: DefiAction.Withdraw,
},
],
[opportunityData?.active],
)

const underlyingAssetId = useMemo(
() => opportunityData?.underlyingAssetIds?.[0],
[opportunityData?.underlyingAssetIds],
Expand Down Expand Up @@ -217,7 +217,7 @@ export const IdleOverview: React.FC<IdleOverviewProps> = ({
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 => {
Expand Down
1 change: 1 addition & 0 deletions src/state/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export const migrations = {
11: clearIdleOpportunities,
12: clearOpportunities,
13: clearOpportunitiesAgain,
14: clearOpportunitiesAgain,
}
2 changes: 2 additions & 0 deletions src/state/slices/opportunitiesSlice/resolvers/idle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/state/slices/opportunitiesSlice/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type OpportunityMetadataBase = {
isClaimableRewards: boolean
// claimableRewards: boolean
expired?: boolean
active?: boolean
name: string
version?: string
tags?: string[]
Expand Down Expand Up @@ -164,6 +165,7 @@ type EarnOpportunityTypeBase = {
cryptoAmountPrecision: string
cryptoAmountBaseUnit: string
expired?: boolean
active?: boolean
chainId: ChainId
showAssetSymbol?: boolean
isLoaded: boolean
Expand Down
2 changes: 0 additions & 2 deletions src/state/slices/preferencesSlice/preferencesSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type FeatureFlags = {
BnbSmartChain: boolean
ThorSwap: boolean
IdleFinance: boolean
IdleFinanceDeposits: boolean
Axelar: boolean
Yat: boolean
WalletConnectToDapps: boolean
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/test/mocks/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const mockStore: ReduxState = {
ThorSwap: false,
Cowswap: false,
IdleFinance: false,
IdleFinanceDeposits: false,
Axelar: false,
Yat: false,
WalletConnectToDapps: false,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f2a4043

Please sign in to comment.