Skip to content

Commit

Permalink
Merge pull request #86 from RealToken-Community/preprod
Browse files Browse the repository at this point in the history
Merge preprod to master
  • Loading branch information
AlexRLT authored Sep 1, 2024
2 parents ed61a4c + 80f8e5a commit 2f930b5
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "realtoken-dashboard-v2",
"version": "2.3.3",
"version": "2.4.0",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
2 changes: 1 addition & 1 deletion src/components/assetsView/filters/AssetsViewSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function useAssetsViewSort(filter: AssetsViewSortFilter) {
case AssetSortType.RENT:
return B.amount * B.netRentDayPerToken - A.amount * A.netRentDayPerToken
case AssetSortType.RENT_START:
return B.rentStartDate.date.localeCompare(A.rentStartDate.date)
return B.rentStartDate?.date.localeCompare(A.rentStartDate?.date)
case AssetSortType.NAME:
return A.shortName.localeCompare(b.shortName)
case AssetSortType.SUPPLY:
Expand Down
60 changes: 59 additions & 1 deletion src/components/assetsView/views/AssetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AssetTable: FC<{
{props.realtokens.map((item, index) => {
const isAProperty = item.hasOwnProperty('rentStatus')
if (!isAProperty) {
return <AssetTableRow key={'0'} value={item as UserRealtoken} />
return <RWATableRow key={'0'} value={item as RWARealtoken} />
}
return <AssetTableRow key={index} value={item as UserRealtoken} />
})}
Expand Down Expand Up @@ -159,4 +159,62 @@ const AssetTableRow: FC<{ value: UserRealtoken }> = (props) => {
</Table.Tr>
)
}

const RWATableRow: FC<{ value: RWARealtoken }> = (props) => {
const { t } = useTranslation('common', { keyPrefix: 'numbers' })
const transfersIsLoaded = useSelector(selectTransfersIsLoaded)

const { shortName, value, unitPriceCost, amount, totalInvestment } =
props.value

return (
<Table.Tr>
<Table.Td style={{ minWidth: '150px' }}>
<Anchor>{shortName}</Anchor>
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{useCurrencyValue(value)}
</Table.Td>
{transfersIsLoaded ? (
<>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
</>
) : null}

<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{useCurrencyValue(unitPriceCost)}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{t('decimal', { value: amount })}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{useCurrencyValue(totalInvestment)}
</Table.Td>
<Table.Td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{'-'}
</Table.Td>
</Table.Tr>
)
}

AssetTableRow.displayName = 'AssetTableRow'
7 changes: 7 additions & 0 deletions src/components/layouts/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export const Header: FC = () => {
label={t('YAM')}
leftSection={<IconExternalLink size={'1rem'} stroke={1.5} />}
/>
<NavLink
component={'a'}
href={'https://bridge.realtoken.network/'}
target={'_blank'}
label={t('Bridge')}
leftSection={<IconExternalLink size={'1rem'} stroke={1.5} />}
/>
</Drawer>
<div>
<Box className={styles.container}>
Expand Down
50 changes: 45 additions & 5 deletions src/hooks/useFullyRentedAPR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ import {
RentCalculationState,
} from 'src/types/RentCalculation'

const fullyRentedAPREstimation = (token: UserRealtoken) => {
const fullyRentedAPREstimation = (
token: UserRealtoken,
rentCalculation: RentCalculation,
) => {
// VEFA properties
if (isVEFA(token)) {
return getVEFAFullRentedAPR(token, rentCalculation)
}

// Case of fully rented property
if (token.rentedUnits === token.totalUnits) {
return token.annualPercentageYield
Expand Down Expand Up @@ -59,7 +67,7 @@ export const useFullyRentedAPR = (token: UserRealtoken) => {
const fullyRentedAPR = useMemo(() => {
const isDisabled = APRDisabled(rentCalculation, token)
if (isDisabled) return 0
return fullyRentedAPREstimation(token)
return fullyRentedAPREstimation(token, rentCalculation)
}, [token, rentCalculation])

return fullyRentedAPR
Expand All @@ -70,14 +78,16 @@ export const useGeneralFullyRentedAPR = (tokens: UserRealtoken[]) => {
// Fully rented APR average using valuation ponderation
const fullyRentedAPR = useMemo(() => {
const totalValue = tokens.reduce((acc, token) => {
const isDisabled = APRDisabled(rentCalculation, token)
const isDisabled = APRDisabled(rentCalculation, token) && !isVEFA(token)
if (isDisabled) return acc
return acc + token.value
}, 0)
const totalAPR = tokens.reduce((acc, token) => {
const isDisabled = APRDisabled(rentCalculation, token)
const isDisabled = APRDisabled(rentCalculation, token) && !isVEFA(token)
if (isDisabled) return acc
return acc + token.value * fullyRentedAPREstimation(token)
return (
acc + token.value * fullyRentedAPREstimation(token, rentCalculation)
)
}, 0)
return totalAPR / totalValue
}, [tokens, rentCalculation])
Expand All @@ -96,3 +106,33 @@ const APRDisabled = (
rentStartDate > realtimeDate.toDate()
return isDisabled
}

export const isVEFA = (token: UserRealtoken) => {
return (
token.shortName === 'Playa Caracol Cottage 10' ||
token.shortName === 'Playa Caracol 303300 E' ||
token.shortName === 'Playa Caracol 303200 E' ||
token.shortName === 'PH Pinoalto A002' ||
token.shortName === 'PH Pinoalto A003' ||
token.shortName === 'Vervana T1 '
)
}

const VEFAAPRs = {
'Playa Caracol Cottage 10': 10.77,
'Playa Caracol 303300 E': 10.69,
'Playa Caracol 303200 E': 10.8,
'PH Pinoalto A002': 10.11,
'PH Pinoalto A003': 10.11,
'Vervana T1 ': 11.33,
}

const getVEFAFullRentedAPR = (
token: UserRealtoken,
rentCalculation: RentCalculation,
) => {
if (rentCalculation.state === RentCalculationState.Realtime) {
return token.annualPercentageYield
}
return VEFAAPRs[token.shortName as keyof typeof VEFAAPRs]
}
3 changes: 2 additions & 1 deletion src/i18next/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"home": "Home",
"realt": "RealT",
"RMM": "RMM",
"YAM": "YAM"
"YAM": "YAM",
"Bridge": "Bridge"
},
"settings": {
"title": "Language",
Expand Down
5 changes: 3 additions & 2 deletions src/i18next/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"home": "Accueil",
"realt": "RealT",
"RMM": "RMM",
"YAM": "YAM"
"YAM": "YAM",
"Bridge": "Bridge"
},
"settings": {
"title": "Langue",
Expand Down Expand Up @@ -395,6 +396,6 @@
"description": "Récupération de vos transactions en cours. Ce chargement peut prendre un certain temps en fonction du nombre de transactions effecutées (10-20 secondes / 1000 transactions). Lors de vos prochaines visites, seul les nouvelles transactions seront récupérées."
},
"disclaimer":{
"fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ou RealT ne peut être tenu responsable en cas de décision prise à partir de données inexactites."
"fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ou RealT ne peut être tenue responsable en cas de décision prise à partir de données inexactes."
}
}
2 changes: 1 addition & 1 deletion src/pages/yamStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const YamStatisticsPage = () => {
<th>Token Price</th>
<th>Yam Price</th>
<th>Yam Difference (30 days)</th>
<th>Yam Volume</th>
<th>Yam Volume (30 days)</th>
</tr>
{paginationYamStatistics.map((statistics, index) => (
<YamStatisticsRow
Expand Down

0 comments on commit 2f930b5

Please sign in to comment.