Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

HInvestment

Git Source

Title: HInvestment

The full on-chain record of an investment opportunity.

Solidity structs cannot inherit, so the admin-supplied creation settings and the contract-filled fields are combined into this single struct and demarcated by the editor-folds below.

struct HInvestment {
//<editor-fold desc="Fields: Admin Supplied">

/// @notice Unique identifier of this investment slot.
bytes32 investmentId;

/// @notice Identifier of the {HAsset} this opportunity invests in.
bytes32 assetId;

/// @notice Initial buy-in a rider must pay to start the hire purchase, in USDC base units (6 decimals).
uint256 riderInitialBuyinUsd;

/// @notice Length of each rider payment period, in minutes.
uint256 periodicRiderPayingInMinutes;

/// @notice Minimum amount a rider must pay per period, in USDC base units (6 decimals).
uint256 minimumRiderPeriodicPayingsUsd;

//</editor-fold desc="Fields: Admin Supplied">

//<editor-fold desc="Fields: Contract Filled">

/// @notice Whether this opportunity is active.
/// @dev    May only be changed while no investor has invested in it. Forced
///         active when the opportunity is created.
bool active;

/// @notice Ordered list of senior investor addresses that have invested.
address[] seniorInvestorsList;

/// @notice Maps a senior investor address to its index in {seniorInvestorsList}.
mapping(address => uint256) seniorInvestors;

/// @notice Ordered list of junior investor addresses that have invested.
address[] juniorInvestorsList;

/// @notice Maps a junior investor address to its index in {juniorInvestorsList}.
mapping(address => uint256) juniorInvestors;

/// @notice Timestamp at which the investment finished raising its target.
uint256 investmentsDoneAt;

/// @notice Current lifecycle state of the investment.
HInvestmentStatus status;

//</editor-fold desc="Fields: Contract Filled">

//<editor-fold desc="Fields: Scheduling">

/// @notice Timestamp at which the next investment round is allowed to start.
uint256 timeNextInvestmentStart;

/// @notice Timestamp at which the next investment round ends.
uint256 timeNextInvestmentEnd;

/// @notice Timestamp at which the next rider hire-request round starts.
uint256 timeNextRiderHireRequestStart;

/// @notice Timestamp at which the next rider hire-request round ends.
uint256 timeNextRiderHireRequestEnd;

//</editor-fold desc="Fields: Scheduling">

//<editor-fold desc="Fields: Rider Hire Purchase">

/// @notice Indices (into the riders' request list) of hire requests for this investment.
uint256[] ridersHirePurchaseRequestsList;

/// @notice Maps a rider address to its index in {ridersHirePurchaseRequestsList}.
mapping(address => uint256) ridersHirePurchaseRequests;

/// @notice Address of the rider who has hired (or will hire) this asset.
address riderWhoHiredIt;

/// @notice Timestamp at which the rider's next periodic payment is due.
uint256 riderNextPayinDate;

/// @notice Aggregate record of the rider's payments toward this investment.
HPayingHistory riderPayinsHistory;

/// @notice Indices (into the global rider payins list) of this investment's payments,
///         stored as `index + 1`.
uint256[] riderPayinIndexes;

//</editor-fold desc="Fields: Rider Hire Purchase">

//<editor-fold desc="Fields: Rider Savings">

/// @notice Record of savings accumulated from the rider's payments (slashable).
HRiderSavingsHistory riderSavings;

/// @notice Indices (into the global rider savings slashes list) of the slashes applied to
///         this investment's rider savings, stored as `index + 1`.
uint256[] riderSavingsSlashes;

/// @notice Aggregate record of the savings slashed from this investment's rider.
HRiderSavingsSlashesHistory riderSavingsSlashesHistory;

//</editor-fold desc="Fields: Rider Savings">

//<editor-fold desc="Fields: Payouts">

/// @notice Per-investor payout history for this investment.
mapping(address => HInvestorPayoutsHistory) investorPayoutHistory;

/// @notice Aggregate payout history for this investment across all investors.
HInvestmentPayoutsHistory investmentPayoutHistory;

/// @notice Payout history for the contract/owner on this investment.
HOwnerPayoutsHistory contractPayoutHistory;

//</editor-fold desc="Fields: Payouts">

//<editor-fold desc="Fields: Completion">

/// @notice Token id of the NFT title minted for the asset in this investment.
uint256 nftTokenId;

/// @notice Timestamp at which the rider completed all payments.
uint256 timeRiderCompletedPayments;

/// @notice Timestamp at which the NFT title was transferred to the rider.
uint256 timeNftTransferedToRider;
//</editor-fold desc="Fields: Completion">
}