Skip to content

Commit

Permalink
Merge pull request #81 from RealToken-Community/develop
Browse files Browse the repository at this point in the history
Bring develop last modification to pre-prod
  • Loading branch information
AlexRLT authored Sep 1, 2024
2 parents 3fca9df + 183bbcd commit 2d6bbf3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 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
31 changes: 23 additions & 8 deletions src/hooks/useFullyRentedAPR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import {
RentCalculationState,
} from 'src/types/RentCalculation'

const fullyRentedAPREstimation = (token: UserRealtoken) => {
const fullyRentedAPREstimation = (
token: UserRealtoken,
rentCalculation: RentCalculation,
) => {
// VEFA properties
if (isVEFA(token)) {
return VEFAAPRs[token.shortName as keyof typeof VEFAAPRs]
return getVEFAFullRentedAPR(token, rentCalculation)
}

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

return fullyRentedAPR
Expand All @@ -82,7 +85,9 @@ export const useGeneralFullyRentedAPR = (tokens: UserRealtoken[]) => {
const totalAPR = tokens.reduce((acc, 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 @@ -105,8 +110,8 @@ const APRDisabled = (
export const isVEFA = (token: UserRealtoken) => {
return (
token.shortName === 'Playa Caracol Cottage 10' ||
token.shortName === 'Playa Caracol 303300' ||
token.shortName === 'Playa Caracol 303200' ||
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 '
Expand All @@ -115,9 +120,19 @@ export const isVEFA = (token: UserRealtoken) => {

const VEFAAPRs = {
'Playa Caracol Cottage 10': 10.77,
'Playa Caracol 303300': 10.69,
'Playa Caracol 303200': 10.8,
'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]
}

0 comments on commit 2d6bbf3

Please sign in to comment.