diff --git a/package-lock.json b/package-lock.json index 947f4e6..1742925 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "realtoken-dashboard-v2", - "version": "2.3.3", + "version": "2.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "realtoken-dashboard-v2", - "version": "2.3.3", + "version": "2.4.0", "dependencies": { "@apollo/client": "^3.9.5", "@mantine/core": "^7.5.3", diff --git a/package.json b/package.json index 2ecc65b..f146668 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "realtoken-dashboard-v2", - "version": "2.3.3", + "version": "2.4.0", "scripts": { "dev": "next dev", "build": "next build", diff --git a/src/components/assetsView/filters/AssetsViewSort.tsx b/src/components/assetsView/filters/AssetsViewSort.tsx index 08f5a6c..fe73051 100644 --- a/src/components/assetsView/filters/AssetsViewSort.tsx +++ b/src/components/assetsView/filters/AssetsViewSort.tsx @@ -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: diff --git a/src/hooks/useFullyRentedAPR.ts b/src/hooks/useFullyRentedAPR.ts index 1100c13..b98c9ef 100644 --- a/src/hooks/useFullyRentedAPR.ts +++ b/src/hooks/useFullyRentedAPR.ts @@ -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 @@ -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 @@ -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]) @@ -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 ' @@ -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] +}