-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated ipfs data structure checkpoint
- Loading branch information
1 parent
a76e5d1
commit ab46a12
Showing
38 changed files
with
422 additions
and
329 deletions.
There are no files selected for viewing
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
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
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,61 @@ | ||
import type { AssetId } from '@shapeshiftoss/caip' | ||
import { thorchainAssetId } from '@shapeshiftoss/caip' | ||
import { bn } from '@shapeshiftoss/chain-adapters' | ||
import { useMemo } from 'react' | ||
import { useTranslate } from 'react-polyglot' | ||
import { fromBaseUnit } from 'lib/math' | ||
import { getStakingContract } from 'pages/RFOX/helpers' | ||
import { useAffiliateRevenueQuery } from 'pages/RFOX/hooks/useAffiliateRevenueQuery' | ||
import { useCurrentEpochMetadataQuery } from 'pages/RFOX/hooks/useCurrentEpochMetadataQuery' | ||
import { selectAssetById, selectMarketDataByAssetIdUserCurrency } from 'state/slices/selectors' | ||
import { useAppSelector } from 'state/store' | ||
|
||
import { StatItem } from './StatItem' | ||
|
||
type EmissionsPoolProps = { | ||
stakingAssetId: AssetId | ||
} | ||
|
||
export const EmissionsPool: React.FC<EmissionsPoolProps> = ({ stakingAssetId }) => { | ||
const translate = useTranslate() | ||
|
||
const runeAsset = useAppSelector(state => selectAssetById(state, thorchainAssetId)) | ||
const runeAssetMarketData = useAppSelector(state => | ||
selectMarketDataByAssetIdUserCurrency(state, thorchainAssetId), | ||
) | ||
|
||
const stakingAsset = useAppSelector(state => selectAssetById(state, stakingAssetId)) | ||
|
||
const currentEpochMetadataResult = useCurrentEpochMetadataQuery() | ||
|
||
const affiliateRevenueResult = useAffiliateRevenueQuery<string>({ | ||
startTimestamp: currentEpochMetadataResult.data?.epochStartTimestamp, | ||
endTimestamp: currentEpochMetadataResult.data?.epochEndTimestamp, | ||
select: (totalRevenue: bigint) => { | ||
return bn(fromBaseUnit(totalRevenue.toString(), runeAsset?.precision ?? 0)) | ||
.times(runeAssetMarketData.price) | ||
.toFixed(2) | ||
}, | ||
}) | ||
|
||
const emissionsPoolUserCurrency = useMemo(() => { | ||
if (!affiliateRevenueResult.data) return | ||
if (!currentEpochMetadataResult.data) return | ||
|
||
const distributionRate = | ||
currentEpochMetadataResult.data.distributionRateByStakingContract[ | ||
getStakingContract(stakingAssetId) | ||
] | ||
|
||
return bn(affiliateRevenueResult.data).times(distributionRate).toFixed(2) | ||
}, [affiliateRevenueResult, currentEpochMetadataResult, stakingAssetId]) | ||
|
||
return ( | ||
<StatItem | ||
description={translate('RFOX.emissionsPool', { symbol: stakingAsset?.symbol })} | ||
helperDescription={translate('RFOX.emissionsPoolHelper', { symbol: stakingAsset?.symbol })} | ||
amountUserCurrency={emissionsPoolUserCurrency} | ||
isLoading={affiliateRevenueResult.isLoading || currentEpochMetadataResult.isLoading} | ||
/> | ||
) | ||
} |
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.