Skip to content

Commit

Permalink
Merge pull request #75 from RealToken-Community/fix-vefa-realtime-APR
Browse files Browse the repository at this point in the history
fix: VEFA Realtime  APR
  • Loading branch information
AlexRLT authored Aug 29, 2024
2 parents 00ab067 + b753a52 commit c0fe9df
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions src/hooks/useFullyRentedAPR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,9 @@ import {

const fullyRentedAPREstimation = (token: UserRealtoken) => {
// VEFA properties
if (token.shortName === 'Playa Caracol Cottage 10' && !token.hasTenants)
return 10.77
else if (token.shortName === 'Playa Caracol 303300' && !token.hasTenants)
return 10.69
else if (token.shortName === 'Playa Caracol 303200' && !token.hasTenants)
return 10.8
else if (token.shortName === 'PH Pinoalto A002' && !token.hasTenants)
return 10.11
else if (token.shortName === 'PH Pinoalto A003' && !token.hasTenants)
return 10.11
else if (token.shortName === 'Vervana T1 ' && !token.hasTenants) return 11.33
if (isVEFA(token)) {
return VEFAAPRs[token.shortName as keyof typeof VEFAAPRs]
}

if (token.rentedUnits === token.totalUnits) {
// Case of fully rented property
Expand Down Expand Up @@ -71,7 +63,7 @@ export const useFullyRentedAPR = (token: UserRealtoken) => {

const fullyRentedAPR = useMemo(() => {
const isDisabled = APRDisabled(rentCalculation, token)
if (isDisabled) return 0
if (isDisabled && !isVEFA(token)) return 0
return fullyRentedAPREstimation(token)
}, [token, rentCalculation])

Expand All @@ -83,12 +75,12 @@ 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)
}, 0)
Expand All @@ -109,3 +101,23 @@ const APRDisabled = (
rentStartDate > realtimeDate.toDate()
return isDisabled
}

export const isVEFA = (token: UserRealtoken) => {
return (
token.shortName === 'Playa Caracol Cottage 10' ||
token.shortName === 'Playa Caracol 303300' ||
token.shortName === 'Playa Caracol 303200' ||
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': 10.69,
'Playa Caracol 303200': 10.8,
'PH Pinoalto A002': 10.11,
'PH Pinoalto A003': 10.11,
'Vervana T1 ': 11.33,
}

0 comments on commit c0fe9df

Please sign in to comment.