Skip to content

Commit

Permalink
feat(dapp): add support for Advanced Staking V3
Browse files Browse the repository at this point in the history
This commit extends the "Advanced Staking" program for two additional
months, accepting stakes until October 22, 2023, with an APR of 15% for
a locking period of 60 days.

Specifically, the following changes have been made:

-  `dapp/src/constants/stake-terms.ts`: Introduced the
   ADVANCED_3_TYPE_HEX constant, mapping it to 'advanced-v3' in
   HEX_STAKE_TYPE_TO_STAKE_TYPE.
-  `dapp/src/redux/slices/staking/stake-terms.ts`: Incorporated
   StakeType.AdvancedThree in the getStakeTerms function.
-  `dapp/src/services/rewards.ts`: Imported ADVANCED_3_TYPE_HEX and
   added a condition in the calculateRewardsForStake function to support
   the newly added staking type.
  • Loading branch information
pycckuu committed Aug 21, 2023
1 parent 08bdc81 commit 8aa6e28
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dapp/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SUBGRAPH_IDS_137=QmTi7Z7YoUpzYqwGytPuKYu2FuYPEhtPTsXti5dRxn8wHR,QmZPs5CFi5vpZW73
Z_ASSETS_REGISTRY_CONTRACT_137=0xb658B085144a0BEd098620BB829b676371B9B48c

ADVANCED_STAKING_APY=15
CURRENT_STAKING_TERM=advanced-v2
CURRENT_STAKING_TERM=advanced-v3
APY_PRP=10

# Faucet
Expand Down
2 changes: 2 additions & 0 deletions dapp/src/constants/stake-terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import {StakeTypes} from 'types/staking';
export const CLASSIC_TYPE_HEX = utils.id('classic').slice(0, 10);
export const ADVANCED_TYPE_HEX = utils.id('advanced').slice(0, 10);
export const ADVANCED_2_TYPE_HEX = utils.id('advanced-v2').slice(0, 10);
export const ADVANCED_3_TYPE_HEX = utils.id('advanced-v3').slice(0, 10);

export const HEX_STAKE_TYPE_TO_STAKE_TYPE = new Map<string, StakeTypes>([
[CLASSIC_TYPE_HEX, 'classic'],
[ADVANCED_TYPE_HEX, 'advanced'],
[ADVANCED_2_TYPE_HEX, 'advanced-v2'],
[ADVANCED_3_TYPE_HEX, 'advanced-v3'],
]);

export const STAKE_TYPE_TO_HEX_STAKE_TYPE = invertMap(
Expand Down
1 change: 1 addition & 0 deletions dapp/src/redux/slices/staking/stake-terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const getStakeTerms = createAsyncThunk(
StakeType.Advanced,
StakeType.Classic,
StakeType.AdvancedTwo,
StakeType.AdvancedThree,
]) {
const terms = await getStakingTermsFromContract(
library,
Expand Down
4 changes: 3 additions & 1 deletion dapp/src/services/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CLASSIC_TYPE_HEX,
ADVANCED_TYPE_HEX,
ADVANCED_2_TYPE_HEX,
ADVANCED_3_TYPE_HEX,
HEX_STAKE_TYPE_TO_STAKE_TYPE,
} from 'constants/stake-terms';
import {oneYearInMs} from 'constants/time';
Expand Down Expand Up @@ -166,7 +167,8 @@ export function calculateRewardsForStake(

if (
stake.stakeType === ADVANCED_TYPE_HEX ||
stake.stakeType === ADVANCED_2_TYPE_HEX
stake.stakeType === ADVANCED_2_TYPE_HEX ||
stake.stakeType === ADVANCED_3_TYPE_HEX
) {
return calculateRewardsForAdvancedStake(
stake,
Expand Down
3 changes: 2 additions & 1 deletion dapp/src/types/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {IStakingTypes} from 'contracts/Staking';
import {BigNumber} from 'ethers';
import {LoadingStatus} from 'loading';

export type StakeTypes = 'classic' | 'advanced' | 'advanced-v2';
export type StakeTypes = 'classic' | 'advanced' | 'advanced-v2' | 'advanced-v3';

export enum StakeType {
Classic = 'classic',
Advanced = 'advanced',
AdvancedTwo = 'advanced-v2',
AdvancedThree = 'advanced-v3',
}

export type StakeReward = {
Expand Down

0 comments on commit 8aa6e28

Please sign in to comment.