import { BigNumberJS } from '../../BigNumberJS' import { TokenState } from '../../ryze' import { Financials, IFinancialsConstructor } from './Financials' import { IGoogleLocation } from './IGoogleLocation' import { ITokenSpace } from './ITokenSpace' import { BaseToken } from '../BaseToken' import { TokenType } from '../TokenType' import { ERC20, IERC20Constructor } from '../ERC20' export interface IRealEstateConstructor { id: number apiId: number name: string symbol: string description: string images: string[] state: TokenState allocated: string maxSupply: string liquidToken: IERC20Constructor | null financials: IFinancialsConstructor location: IGoogleLocation spaces: ITokenSpace[] } export class RealEstate extends BaseToken { public readonly id: number public readonly apiId: number public readonly name: string public readonly symbol: string public readonly description: string public readonly image: string public readonly images: string[] public readonly liquidToken: ERC20 | null public readonly state: TokenState public readonly allocated: BigNumberJS public readonly maxSupply: BigNumberJS public readonly financials: Financials public readonly location: IGoogleLocation public readonly spaces: ITokenSpace[] public constructor({ id, apiId, name, symbol, description, images, state, liquidToken, allocated, maxSupply, financials, location, spaces, }: IRealEstateConstructor) { super(TokenType.REAL_ESTATE) this.id = id this.apiId = apiId this.name = name this.symbol = symbol this.description = description this.image = images[0] this.images = images this.state = state this.allocated = new BigNumberJS(allocated) this.maxSupply = new BigNumberJS(maxSupply) this.liquidToken = liquidToken ? new ERC20(liquidToken) : null this.financials = new Financials(financials) this.location = location this.spaces = spaces } public get displayState() { if (this.state === TokenState.PRE_SALE) return 'Pre-Sale' if (this.state === TokenState.PENDING) return 'Paperwork' if (this.state === TokenState.ENABLED) return 'Active' if (this.state === TokenState.DISABLED) return 'Disabled' throw new Error('Invalid state') } public get expectedReturns(): BigNumberJS { return this.financials.expectedRentIncome .plus(this.financials.expectedAppreciationPercentage) .plus(this.liquidToken?.pair?.apr || 0) } } export { Financials, IFinancialsConstructor, IGoogleLocation, ITokenSpace, }