-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from dappforce/creator-staking-fixes
Fix creator staking page
- Loading branch information
Showing
42 changed files
with
498 additions
and
265 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useMemo } from 'react' | ||
import { useGeneralEraInfo } from 'src/rtk/features/creatorStaking/generalEraInfo/generalEraInfoHooks' | ||
import BN from 'bignumber.js' | ||
import { convertToBalanceWithDecimal } from '@subsocial/utils' | ||
import { useGetDecimalsAndSymbolByNetwork } from 'src/components/utils/useGetDecimalsAndSymbolByNetwork' | ||
|
||
const blockReward = new BN(6) | ||
const eraReward = blockReward.multipliedBy(new BN(7200)) | ||
const annualReward = eraReward.multipliedBy(new BN(365)) | ||
const backerPercent = new BN(0.6) | ||
|
||
export const useCalculateApr = () => { | ||
const generalEraInfo = useGeneralEraInfo() | ||
const { decimal } = useGetDecimalsAndSymbolByNetwork('subsocial') | ||
|
||
const apr = useMemo(() => { | ||
if (!generalEraInfo) return | ||
|
||
const totalStakedWithDecimal = convertToBalanceWithDecimal( | ||
generalEraInfo.staked, | ||
decimal | ||
) | ||
|
||
return annualReward | ||
.dividedBy(totalStakedWithDecimal) | ||
.multipliedBy(backerPercent) | ||
.multipliedBy(100) | ||
}, [ !!generalEraInfo ]) | ||
|
||
return apr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.