Skip to content

Commit

Permalink
chore: remove staking restrictions (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-orion authored Jan 24, 2024
1 parent a3b9bc2 commit f3d4f71
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 106 deletions.
5 changes: 3 additions & 2 deletions src/constants/staking.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: ice License 1.0

export const STAKING_YEARS_MIN = 1;
export const STAKING_YEARS_MIN = 0;

export const STAKING_YEARS_MAX = 5;

export const STAKING_YEARS_DEFAULT = 2;

export const STAKING_ALLOCATION_MIN = 1;
export const STAKING_ALLOCATION_MIN = 0;

export const STAKING_ALLOCATION_MAX = 100;

Expand All @@ -15,6 +15,7 @@ export const STAKING_ALLOCATION_DEFAULT = 75;
export const STAKING_RATE_PERCENTAGES_MAX = 250;

export const PRE_STAKING_BONUS_FOR_YEARS = {
0: 0,
1: 35,
2: 70,
3: 115,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export const useCalculatorSliderValues = () => {
const preStakingSummary = useSelector(preStakingSummarySelector, () => true);

return useMemo(() => {
const availableStakingYearsMin = Math.max(
STAKING_YEARS_MIN,
preStakingSummary?.years ?? 0,
);
const availableStakingYearsMin = STAKING_YEARS_MIN;
const availableStakingYearsMax = STAKING_YEARS_MAX;
const availableYearsPercentage =
100 -
Expand All @@ -30,10 +27,7 @@ export const useCalculatorSliderValues = () => {
const stakingYearsInitialValue =
preStakingSummary?.years ?? STAKING_YEARS_DEFAULT;

const availableAllocationMin = Math.max(
STAKING_ALLOCATION_MIN,
preStakingSummary?.allocation ?? 0,
);
const availableAllocationMin = STAKING_ALLOCATION_MIN;
const availableAllocationMax = STAKING_ALLOCATION_MAX;
const availableAllocationPercentage =
100 -
Expand Down
56 changes: 0 additions & 56 deletions src/screens/Staking/components/Footer/components/InfoRow/index.tsx

This file was deleted.

42 changes: 3 additions & 39 deletions src/screens/Staking/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,29 @@ import {CheckBox} from '@components/CheckBox';
import {IceLabel} from '@components/Labels/IceLabel';
import {COLORS} from '@constants/colors';
import {LINKS} from '@constants/links';
import {STAKING_ALLOCATION_MAX, STAKING_YEARS_MAX} from '@constants/staking';
import {SCREEN_SIDE_OFFSET} from '@constants/styles';
import {MainNavigationParams} from '@navigation/Main';
import {useNavigation} from '@react-navigation/native';
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
import {usePreStaking} from '@screens/Staking/hooks/usePreStaking';
import {balanceSummarySelector} from '@store/modules/Tokenomics/selectors';
import {CoinsStackIcon} from '@svg/CoinsStackIcon';
import {YearsOutlineIcon} from '@svg/YearsOutlineIcon';
import {isRTL, replaceString, t, tagRegex} from '@translations/i18n';
import {replaceString, t, tagRegex} from '@translations/i18n';
import {openLinkWithInAppBrowser} from '@utils/device';
import {formatNumberString} from '@utils/numbers';
import {font} from '@utils/styles';
import React, {memo, RefObject, useMemo, useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {useSelector} from 'react-redux';
import {isAndroid, rem} from 'rn-units';

import {InfoRow} from './components/InfoRow';

type Props = {
parameters: RefObject<{years: number; allocation: number} | null>;
};

export const Footer = memo(({parameters}: Props) => {
const navigation =
useNavigation<NativeStackNavigationProp<MainNavigationParams>>();
const {preStakingSummary, preStakingLoading, confirmPreStaking} =
usePreStaking();
const {preStakingLoading, confirmPreStaking} = usePreStaking();
const [termsAccepted, setTermsAccepted] = useState(false);
const maxValuesSet =
preStakingSummary?.years === STAKING_YEARS_MAX &&
preStakingSummary.allocation === STAKING_ALLOCATION_MAX;
const buttonDisabled = !termsAccepted || maxValuesSet;

const balanceSummary = useSelector(balanceSummarySelector);
const buttonDisabled = !termsAccepted;

const onStakePress = () => {
navigation.navigate({
Expand Down Expand Up @@ -90,29 +77,6 @@ export const Footer = memo(({parameters}: Props) => {
));
}, []);

if (maxValuesSet) {
return (
<>
<InfoRow
key={'staking.period'}
style={[styles.infoRowContainer, styles.infoRowContainerTop]}
Icon={YearsOutlineIcon}
label={t('staking.period_label')}
value={preStakingSummary?.years ?? '0'}
unit={t('global.years').toLowerCase()}
/>
<InfoRow
key={'staking.balance'}
style={styles.infoRowContainer}
Icon={CoinsStackIcon}
label={t('staking.balance_label')}
value={formatNumberString(balanceSummary?.preStaking ?? '0')}
unit={<IceLabel reversed={isRTL} color={COLORS.primaryLight} />}
/>
</>
);
}

return (
<View style={styles.container}>
<View style={styles.checkboxRow}>
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/Tokenomics/sagas/startPreStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function* startOrUpdatePreStakingSaga({
typeof Api.tokenomics.startOrUpdatePreStaking
> = yield call(Api.tokenomics.startOrUpdatePreStaking, {
userId,
years,
years: allocation !== 0 ? years : 0,
allocation,
});
yield put(
Expand Down

0 comments on commit f3d4f71

Please sign in to comment.