Skip to content

Commit 9f02611

Browse files
committed
feat: added withdraw and deposit more buttons for supported stablecoins
1 parent 312acab commit 9f02611

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

app/components/UI/AssetOverview/Balance/Balance.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import {
3333
getNonEvmNetworkImageSourceByChainId,
3434
} from '../../../../util/networks/customNetworks';
3535
import { RootState } from '../../../../reducers';
36+
import { isSupportedLendingTokenByChainId } from '../../Earn/utils';
37+
import EarnLendingBalance from '../../Earn/components/EarnLendingBalance';
38+
import { USER_HAS_LENDING_POSITIONS } from '../../Earn/constants/tempLendingConstants';
3639

3740
interface BalanceProps {
3841
asset: TokenI;
@@ -143,7 +146,11 @@ const Balance = ({ asset, mainBalance, secondaryBalance }: BalanceProps) => {
143146
{asset.name || asset.symbol}
144147
</Text>
145148
</AssetElement>
149+
{/* TODO: Abstract StakingBalance and EarnLendingBalance into single EarnBalance entrypoint */}
146150
{asset?.isETH && <StakingBalance asset={asset} />}
151+
{asset?.chainId &&
152+
isSupportedLendingTokenByChainId(asset.symbol, asset.chainId) &&
153+
USER_HAS_LENDING_POSITIONS && <EarnLendingBalance asset={asset} />}
147154
</View>
148155
);
149156
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { StyleSheet } from 'react-native';
2+
import { Theme } from '../../../../../util/theme/models';
3+
4+
const styleSheet = (params: { theme: Theme }) => {
5+
const { theme } = params;
6+
const { colors } = theme;
7+
8+
return StyleSheet.create({
9+
container: {
10+
flexDirection: 'row',
11+
justifyContent: 'space-between',
12+
paddingHorizontal: 16,
13+
paddingTop: 14,
14+
paddingBottom: 6,
15+
gap: 16,
16+
},
17+
button: {
18+
flex: 1,
19+
},
20+
});
21+
};
22+
23+
export default styleSheet;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React from 'react';
2+
import { View } from 'react-native';
3+
import Button, {
4+
ButtonSize,
5+
ButtonVariants,
6+
} from '../../../../../component-library/components/Buttons/Button';
7+
import { TokenI } from '../../../Tokens/types';
8+
import styleSheet from './EarnLendingBalance.styles';
9+
import { useStyles } from '../../../../hooks/useStyles';
10+
import { strings } from '../../../../../../locales/i18n';
11+
import { useNavigation } from '@react-navigation/native';
12+
import Routes from '../../../../../constants/navigation/Routes';
13+
import { useSelector } from 'react-redux';
14+
import { selectStablecoinLendingEnabledFlag } from '../../selectors/featureFlags';
15+
16+
export interface EarnLendingBalanceProps {
17+
asset: TokenI;
18+
}
19+
20+
const EarnLendingBalance = ({ asset }: EarnLendingBalanceProps) => {
21+
const { styles } = useStyles(styleSheet, {});
22+
23+
const isStablecoinLendingEnabled = useSelector(
24+
selectStablecoinLendingEnabledFlag,
25+
);
26+
27+
const navigation = useNavigation();
28+
29+
const handleNavigateToWithdrawalInputScreen = () => {
30+
navigation.navigate('StakeScreens', {
31+
screen: Routes.STAKING.UNSTAKE,
32+
params: {
33+
token: asset,
34+
},
35+
});
36+
};
37+
38+
const handleNavigateToDepositInputScreen = () => {
39+
navigation.navigate('StakeScreens', {
40+
screen: Routes.STAKING.STAKE,
41+
params: {
42+
token: asset,
43+
},
44+
});
45+
};
46+
47+
if (!isStablecoinLendingEnabled) return null;
48+
49+
return (
50+
<View style={styles.container}>
51+
<Button
52+
variant={ButtonVariants.Secondary}
53+
style={styles.button}
54+
size={ButtonSize.Lg}
55+
label={strings('earn.withdraw')}
56+
onPress={handleNavigateToWithdrawalInputScreen}
57+
/>
58+
<Button
59+
variant={ButtonVariants.Secondary}
60+
style={styles.button}
61+
size={ButtonSize.Lg}
62+
label={strings('earn.deposit_more')}
63+
onPress={handleNavigateToDepositInputScreen}
64+
/>
65+
</View>
66+
);
67+
};
68+
export default EarnLendingBalance;

0 commit comments

Comments
 (0)