HHelper
Inherits: Ownable
Title: Helper features and modifiers.
Author: Obiaraije Henry
Inherits OpenZeppelin {Ownable} so the launch owner is set at construction.
State Variables
owner2
Secondary owner who may run every admin action but cannot manage owners.
Set by owner1 via {Henriable.actionAdminSetOwner2}; address(0) means unset.
address internal owner2
ownerUsdToken
USDC token used for all investments, payouts and payments.
IERC20 internal ownerUsdToken
vehicleNft
Vehicle-title NFT collection used to hold and hand over asset titles.
Minted to this contract when an investment is fully funded and transferred to the rider once the hire purchase is paid in full.
HenriableVehicleNFT internal vehicleNft
ownerPayoutsList
All owner/contract payouts ever made.
HOwnerPayout[] internal ownerPayoutsList
ownerPayouts
Maps an investment id => 1-based position in {ownerPayoutsList} of the most recent owner payout for that investment.
Key: investment id (bytes32). Value: index + 1 into {ownerPayoutsList},
so 0 means no owner payout has been recorded for the investment yet.
mapping(bytes32 => uint256) internal ownerPayouts
ownerPayoutHistory
Maps an investment id => the aggregate owner payout history for it.
Key: investment id (bytes32). Value: {HOwnerPayoutsHistory} holding the running totals of every owner payout recorded on that investment.
mapping(bytes32 => HOwnerPayoutsHistory) internal ownerPayoutHistory
assetsList
All registered assets, in insertion order.
HAsset[] internal assetsList
assets
Maps an asset id => 1-based position in {assetsList}.
Key: asset id (bytes32). Value: index + 1 into {assetsList}, so 0 means
“not registered”; this single mapping provides an O(1) existence check
and lookup.
mapping(bytes32 => uint256) internal assets
assetInvestments
Maps an asset id => the investments created for that asset.
Key: asset id (bytes32). Value: array of 1-based positions into {investmentsList} (subtract 1 to index the array).
mapping(bytes32 => uint256[]) internal assetInvestments
investmentsList
All investment opportunities ever created.
HInvestment[] internal investmentsList
investments
Maps an investment id => 1-based position in {investmentsList}.
Key: investment id (bytes32). Value: index + 1 into {investmentsList},
so 0 means “not registered” for an O(1) existence check and lookup.
mapping(bytes32 => uint256) internal investments
investorsList
All registered investors.
HInvestor[] internal investorsList
completedRiderInvestmentList
Indices (into {investmentsList}) of investments whose rider has fully paid and that are complete.
uint256[] internal completedRiderInvestmentList
investmentsCompleted
Indices (into {investmentsList}) of completed rider investments. This list is append-only and is never cleared.
uint256[] internal investmentsCompleted
titleInvestmentId
Maps a minted title token id => the investment it was minted for.
The forward link lives on the investment ({HInvestment.nftTokenId}); this is the reverse, so a title can resolve its investment – and thus its asset and rider – without scanning the investment list. Set once when the title mints.
mapping(uint256 => bytes32) internal titleInvestmentId
investors
Maps an investor address => 1-based position in {investorsList}.
Key: investor address. Value: index + 1 into {investorsList}, so 0
means “not registered”.
mapping(address => uint256) internal investors
investorPayoutList
All investor payouts ever made.
HInvestorPayout[] internal investorPayoutList
investorPayouts
Maps an investor and investment id => the investor’s payout in {investorPayoutList}.
Key: investor address, then investment id (bytes32). Value: 1-based position in {investorPayoutList} of that investor’s most recent payout for the investment, or 0 if none has been recorded.
mapping(address => mapping(bytes32 => uint256)) internal investorPayouts
ridersList
All registered riders.
HRider[] internal ridersList
riders
Maps a rider address => 1-based position in {ridersList}.
Key: rider address. Value: index + 1 into {ridersList}, so 0 means
“not registered”.
mapping(address => uint256) internal riders
ridersHirePurchasesRequestsList
All rider hire-purchase requests ever made.
HRiderHirePurchaseRequest[] internal ridersHirePurchasesRequestsList
ridersHireRequestPurchasesByInvestment
Maps a rider id and investment id => the rider’s hire request in {ridersHirePurchasesRequestsList}.
Key: rider id (bytes32), then investment id (bytes32). Value: 1-based position in {ridersHirePurchasesRequestsList}, or 0 if the rider has not requested that investment.
mapping(bytes32 => mapping(bytes32 => uint256)) internal ridersHireRequestPurchasesByInvestment
rejectedRiders
Maps a rider id and investment id => a rejection marker.
Key: rider id (bytes32), then investment id (bytes32). Value: non-zero once the rider has been rejected for that investment, 0 otherwise.
mapping(bytes32 => mapping(bytes32 => uint256)) internal rejectedRiders
riderPayinsList
All rider periodic payments ever made.
HRiderPayin[] internal riderPayinsList
riderSavingsSlashesList
All rider savings slashes ever applied, in insertion order.
HRiderSavingsSlash[] internal riderSavingsSlashesList
riderSavingsSlashesByInvestment
Maps an investment id => 1-based position in {riderSavingsSlashesList} of the most recent slash for that investment.
Key: investment id (bytes32). Value: index + 1 into
{riderSavingsSlashesList}, so 0 means no slash has been recorded yet.
mapping(bytes32 => uint256) internal riderSavingsSlashesByInvestment
stats
Running platform totals exposed by {Henriable.getStats}.
Counters are maintained in O(1) at each write site; the totals that mirror list lengths are filled in by the getter at read time.
HStats internal stats
assetActiveInvestmentsCount
Maps an asset id => the number of its currently active investments.
Used to keep {HStats.assetsWithRunningInvestments} exact without looping: the global counter only moves when this per-asset count crosses 0.
mapping(bytes32 => uint256) internal assetActiveInvestmentsCount
assetHasCompletedInvestment
Maps an asset id => whether one of its investments has completed.
Completion is monotonic, so a boolean is enough to count {HStats.assetsWithCompletedInvestments} exactly once per asset.
mapping(bytes32 => bool) internal assetHasCompletedInvestment
Functions
constructor
Deploys the helper, setting the contract owner, the USDC token and the NFT.
constructor(address initialOwner, IERC20 ownerUsdToken_, HenriableVehicleNFT vehicleNft_) Ownable(initialOwner);
Parameters
| Name | Type | Description |
|---|---|---|
initialOwner | address | The address that will own the contract. |
ownerUsdToken_ | IERC20 | The USDC token used for investments, payouts and payments. |
vehicleNft_ | HenriableVehicleNFT | The vehicle-title NFT collection whose minter is this contract. |
onlyOwners
Restricts a function to owner1 or owner2.
Owner-managing functions keep OpenZeppelin’s {onlyOwner} (owner1 only), so owner2 can run admin actions but cannot set or clear owners. Reverts with OpenZeppelin’s {OwnableUnauthorizedAccount} when the caller is neither.
modifier onlyOwners() ;
isInvestmentStatus
Returns whether an investment is currently in any of the given statuses.
function isInvestmentStatus(bytes32 investmentId, HInvestmentStatus[] memory statuses)
internal
view
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
statuses | HInvestmentStatus[] | The statuses to test for. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the investment’s current status equals any entry in statuses. |
isAssetSettingsCorrect
Checks that an asset’s pricing settings can pay every investor and the owner.
The investor pools must cover the asset: every investor’s buying price times its slot count must be at least {HAsset.costPrice}, and the rider’s {HAsset.sellPrice} must cover that principal plus the profits promised to both pools plus {HAsset.ownerProfit}. The rider’s slashable savings ({HAsset.riderSlashableRepayableExtraCharge}) is charged on top of the sell price and refunded later, so it is deliberately excluded here.
function isAssetSettingsCorrect(HAsset memory asset) internal pure returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
asset | HAsset | The asset configuration to validate. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True when the pools cover the cost price and the sell price covers the investor principal, their profits and the owner’s profit. |
calcInvestmentOpportunityLevel1SettingsAccuracy
Checks that the level-1 settings of a new investment opportunity are consistent with its asset, so the rider’s payments can cover the profits promised to the senior and junior investor pools.
Placeholder: always returns true until the real accuracy math is implemented and reviewed. The investment parameter is intentionally unused.
function calcInvestmentOpportunityLevel1SettingsAccuracy(HInvestment storage) internal pure returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True when the level-1 settings are accurate. |
calcSeniorPoolPaidSoFar
Sums how much the senior investor pool has been paid so far on an investment.
An address may hold several senior seats, so a naive sum over the list would count that investor’s aggregate payout history once per seat. The mapping {HInvestment.seniorInvestors} points at the investor’s most recent seat, so only that seat’s entry counts, keeping each investor’s total counted once.
function calcSeniorPoolPaidSoFar(HInvestment storage investment) internal view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment (storage reference). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total amount paid to senior investors, in USDC base units (6 decimals). |
calcJuniorPoolPaidSoFar
Sums how much the junior investor pool has been paid so far on an investment.
An address may hold several junior seats, so a naive sum over the list would count that investor’s aggregate payout history once per seat. The mapping {HInvestment.juniorInvestors} points at the investor’s most recent seat, so only that seat’s entry counts, keeping each investor’s total counted once.
function calcJuniorPoolPaidSoFar(HInvestment storage investment) internal view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment (storage reference). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total amount paid to junior investors, in USDC base units (6 decimals). |
calcSharingFormula
Splits one rider payment across the owner and the two investor pools.
The rider’s refundable savings charge is collected on top of the payment and is not part of this split. The split is driven by what each pool is still owed, not by configurable percentages: the payment first fills the senior pool up to its remaining target (seats x (buying price + profit)), then the junior pool up to its target, and the owner receives whatever is left. Because the asset’s sell price covers the two pool targets plus {HAsset.ownerProfit}, this pays every investor their buying price plus profit in full and leaves the owner exactly its promised profit (plus any surplus when the sell price exceeds the targets). The owner absorbs integer-division dust.
function calcSharingFormula(HInvestment storage investment, HAsset storage asset, uint256 amount)
internal
view
returns (HSharingBreakdown memory);
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment being paid (storage reference). |
asset | HAsset | The asset backing the investment (storage reference). |
amount | uint256 | The rider payment to split, in USDC base units (6 decimals) (excludes the savings charge). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HSharingBreakdown | The per-bucket breakdown. |
calcRiderAmountToPayNow
Computes the payment a rider owes for the next instalment of an investment.
The rider owes {HAsset.sellPrice} in total and the outstanding balance is that minus what they have paid. The periodic minimum is capped by the outstanding balance on the final instalment, then the asset’s per-period savings charge is always added on top so the rider’s refundable savings keep accumulating.
function calcRiderAmountToPayNow(HInvestment storage investment, HAsset storage asset)
internal
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment being paid (storage reference). |
asset | HAsset | The asset backing the investment (storage reference). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount due for the next instalment, in USDC base units (6 decimals). |
maybeUpdateInvestmentStatus
Advances an investment’s lifecycle status when its current state and timing allow it.
State machine: every transition goes through setInvestmentStatus, which also keeps the stats counters in step.
- Pending -> AcceptingInvestments once the admin-set window opens
(
timeNextInvestmentStart <= now <= timeNextInvestmentEnd). - AcceptingInvestments -> InvestmentDone once the asset’s senior and junior pools are both filled, recording {HInvestment.investmentsDoneAt}.
- InvestmentDone -> AcceptingRiders once the admin-set hire window opens
(
timeNextRiderHireRequestStart <= now <= timeNextRiderHireRequestEnd). It runs lazily on first use (e.g. when an investor or rider calls in), so the status catches up. After each status update it returns.
function maybeUpdateInvestmentStatus(bytes32 investmentId) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment to update. |
actionMaybeUpdateStatus
Provided for frontend to call when they suspect a status should have changed but it did not. e.g. When start investment countdown has begone but investment is still pending. We can’t run a cron job so it has to be triggered somehow minimally.
function actionMaybeUpdateStatus(bytes32 _investmentId) external;
upsertInvestor
Creates an investor profile for an address, or updates it if it exists.
function upsertInvestor(address investorAddress, HInvestor memory investorProfile) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investorAddress | address | The investor’s address. |
investorProfile | HInvestor | The profile fields (name, country, age) to store. |
upsertRider
Creates a rider profile for an address, or updates it if it exists.
function upsertRider(address riderAddress, bytes32 riderName, bytes32 riderCountry, uint8 riderAge) internal;
Parameters
| Name | Type | Description |
|---|---|---|
riderAddress | address | The rider’s address. |
riderName | bytes32 | The rider’s name. |
riderCountry | bytes32 | The rider’s country. |
riderAge | uint8 | The rider’s age. |
recordDistribution
Records the accounting for one rider payment split across its beneficiaries.
Writes the payout state and moves no tokens, so the caller can keep the transfer step last (checks-effects-interactions). The owner and each investor in a tier share their pool equally; an empty tier or any division remainder stays in the contract. The rider’s savings charge is recorded separately by recordRiderSavings.
function recordDistribution(
HInvestment storage investment,
bytes32 investmentId,
HSharingBreakdown memory breakdown,
HPayoutType payoutType
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment the payment belongs to (storage reference). |
investmentId | bytes32 | The id of the investment. |
breakdown | HSharingBreakdown | The owner/investor split of the payment. |
payoutType | HPayoutType | What produced the payout ({HPayoutType.RiderPaying} or {HPayoutType.RiderSavingsSlash}); stored on every entry it creates. |
recordRiderSavings
Records the rider’s per-period savings charge for an investment.
The savings are held in the contract (not transferred): they are refunded when the rider completes and can be slashed if the rider defaults.
function recordRiderSavings(HInvestment storage investment, uint256 amount) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment the payment belongs to (storage reference). |
amount | uint256 | The savings charge to add, in USDC base units (6 decimals). |
recordRiderSavingsSlash
Records a slash of the rider’s savings for an investment.
Reduces the rider’s refundable savings, appends a global slash entry, links it to the investment, and updates the investment and platform slash totals. Writes state only: the caller splits and transfers the slashed amount separately, as those are part of the normal payout accounting.
function recordRiderSavingsSlash(HInvestment storage investment, bytes32 investmentId, uint256 amount) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment the slash belongs to (storage reference). |
investmentId | bytes32 | The id of the investment. |
amount | uint256 | The amount to slash, in USDC base units (6 decimals). |
applyRiderSavingsSlash
Validates and applies a slash of the rider’s savings for an investment.
Reverts when the slash exceeds the rider’s saved amount. Reduces the savings, records the slash, then splits the amount to the owner and investor pools as {HPayoutType.RiderSavingsSlash} payouts and transfers them.
function applyRiderSavingsSlash(HInvestment storage investment, bytes32 investmentId, uint256 amount) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment the slash belongs to (storage reference). |
investmentId | bytes32 | The id of the investment. |
amount | uint256 | The amount to slash, in USDC base units (6 decimals); must be non-zero. |
recordTierPayouts
Records an equal-share payout for every investor in a tier.
function recordTierPayouts(
HInvestment storage investment,
bytes32 investmentId,
address[] storage tierInvestors,
uint256 poolAmount,
HPayoutType payoutType
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment the payment belongs to (storage reference). |
investmentId | bytes32 | The id of the investment. |
tierInvestors | address[] | The tier’s investor list. |
poolAmount | uint256 | The total amount to split across the tier, in USDC base units (6 decimals). |
payoutType | HPayoutType | What produced the payout, stored on every entry it creates. |
transferDistribution
Transfers the owner and investor shares of a recorded distribution.
Call only after recordDistribution: this is the token-moving step.
function transferDistribution(HInvestment storage investment, HSharingBreakdown memory breakdown) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment the payment belongs to (storage reference). |
breakdown | HSharingBreakdown | The owner/investor/savings split of the payment. |
transferTierShares
Transfers an equal share of a tier’s pool to each of its investors.
function transferTierShares(address[] storage tierInvestors, uint256 poolAmount) internal;
Parameters
| Name | Type | Description |
|---|---|---|
tierInvestors | address[] | The tier’s investor list. |
poolAmount | uint256 | The total amount to split across the tier, in USDC base units (6 decimals). |
setAssetActive
Applies an asset’s active flag and keeps {HStats.activeAssets} in step.
The single write point for {HAsset.active} after creation, so the counter cannot drift.
function setAssetActive(HAsset storage asset, bool newActive) internal;
Parameters
| Name | Type | Description |
|---|---|---|
asset | HAsset | The asset to update (storage reference). |
newActive | bool | The requested active status. |
setInvestmentActive
Applies an investment’s active flag and keeps the running totals in step.
The single write point for {HInvestment.active} after creation. Updates {HStats.activeInvestments} and, via the asset’s active-investment count, {HStats.assetsWithRunningInvestments}.
function setInvestmentActive(HInvestment storage investment, bool newActive) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment to update (storage reference). |
newActive | bool | The requested active status. |
setInvestmentStatus
Applies an investment’s lifecycle status and keeps the running totals in step.
The single write point for {HInvestment.status} after creation, so the {HStats.investmentsInHire} and {HStats.investmentsPaidInFull} counters and the per-asset completion count cannot drift.
function setInvestmentStatus(HInvestment storage investment, HInvestmentStatus newStatus) internal;
Parameters
| Name | Type | Description |
|---|---|---|
investment | HInvestment | The investment to update (storage reference). |
newStatus | HInvestmentStatus | The requested lifecycle status. |
getOwnerUsdToken
Returns the USDC token used by the platform.
function getOwnerUsdToken() external view returns (IERC20);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IERC20 | The {IERC20} owner USDC token. |
getOwner2
Returns the secondary owner, who may run admin actions but not manage owners.
function getOwner2() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The owner2 address, or address(0) when unset. |
getVehicleNft
Returns the vehicle-title NFT collection used for asset titles.
Lets callers reach the collection (e.g. to read token metadata) through the platform address alone, without a separately configured NFT address.
function getVehicleNft() external view returns (HenriableVehicleNFT);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HenriableVehicleNFT | The {HenriableVehicleNFT} collection. |
getAssetsCount
Returns the total number of registered assets.
function getAssetsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {assetsList}. |
getAssetAt
Returns the asset registered at an index.
function getAssetAt(uint256 index) external view returns (HAsset memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {assetsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HAsset | The {HAsset} at the given index. |
getAsset
Returns an asset’s configuration by id.
function getAsset(bytes32 assetId) external view returns (HAsset memory);
Parameters
| Name | Type | Description |
|---|---|---|
assetId | bytes32 | The id of the asset. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HAsset | The {HAsset} for the given id (zero-filled if it does not exist). |
getAssetExists
Returns whether an asset id is registered.
function getAssetExists(bytes32 assetId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
assetId | bytes32 | The id of the asset. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the asset is registered. |
getAssetStorage
Returns a storage reference to a registered asset.
Hides the index + 1 bookkeeping so callers can read or write fields
directly, e.g. getAssetStorage(id).active = false;. Reverts if the
asset is not registered.
function getAssetStorage(bytes32 assetId) internal view returns (HAsset storage);
Parameters
| Name | Type | Description |
|---|---|---|
assetId | bytes32 | The id of the asset. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HAsset | A storage reference to the asset. |
getAssetInvestmentIds
Returns the ids of the investments created for an asset.
function getAssetInvestmentIds(bytes32 assetId) external view returns (bytes32[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
assetId | bytes32 | The id of the asset. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32[] | An array of investment ids. |
getAssetInvestmentStorage
Returns a storage reference to an investment created for an asset.
Hides the index + 1 bookkeeping used by {assetInvestments}.
function getAssetInvestmentStorage(bytes32 assetId, uint256 position) internal view returns (HInvestment storage);
Parameters
| Name | Type | Description |
|---|---|---|
assetId | bytes32 | The id of the asset. |
position | uint256 | The position in the asset’s investment list. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestment | A storage reference to the investment. |
getAssetInvestmentsCount
Returns the number of investments created for an asset.
function getAssetInvestmentsCount(bytes32 assetId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
assetId | bytes32 | The id of the asset. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The count of investments for the asset. |
getInvestmentsCount
Returns the total number of investment opportunities.
function getInvestmentsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {investmentsList}. |
getInvestmentIndex
Returns the 1-based index in {investmentsList} for an investment id.
Positions are 1-based (0 means “not registered”); to index the array directly, callers subtract 1.
function getInvestmentIndex(bytes32 investmentId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index, or 0 if the investment is not registered. |
getInvestmentStorage
Returns a storage reference to a registered investment.
Hides the index + 1 bookkeeping so callers can read or write fields
directly, e.g. getInvestmentStorage(id).active = false;. Reverts if
the investment is not registered.
function getInvestmentStorage(bytes32 investmentId) internal view returns (HInvestment storage);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestment | A storage reference to the investment. |
getInvestmentCore
Returns the core (half-investment) fields of an investment.
function getInvestmentCore(uint256 index)
external
view
returns (
bytes32 investmentId,
bool active,
bytes32 assetId,
uint256 investmentsDoneAt,
uint256 riderInitialBuyinUsd,
uint256 periodicRiderPayingInMinutes,
uint256 minimumRiderPeriodicPayingsUsd,
HInvestmentStatus status
);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | Unique investment id. |
active | bool | Whether the opportunity is active. |
assetId | bytes32 | Asset being invested in. |
investmentsDoneAt | uint256 | Time the funding target was reached. |
riderInitialBuyinUsd | uint256 | Initial rider buy-in, in USDC base units (6 decimals). |
periodicRiderPayingInMinutes | uint256 | Length of a rider period, in minutes. |
minimumRiderPeriodicPayingsUsd | uint256 | Minimum rider payment per period, in USDC base units (6 decimals). |
status | HInvestmentStatus | Current lifecycle status. |
getInvestmentSchedule
Returns the scheduling fields of an investment.
function getInvestmentSchedule(uint256 index)
external
view
returns (
uint256 timeNextInvestmentStart,
uint256 timeNextInvestmentEnd,
uint256 timeNextRiderHireRequestStart,
uint256 timeNextRiderHireRequestEnd
);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
timeNextInvestmentStart | uint256 | Start of the next investment round. |
timeNextInvestmentEnd | uint256 | End of the next investment round. |
timeNextRiderHireRequestStart | uint256 | Start of the next hire-request round. |
timeNextRiderHireRequestEnd | uint256 | End of the next hire-request round. |
getInvestmentRiderInfo
Returns the rider hire-purchase fields of an investment.
function getInvestmentRiderInfo(uint256 index)
external
view
returns (
address riderWhoHiredIt,
uint256 riderNextPayinDate,
uint256 nftTokenId,
uint256 timeRiderCompletedPayments,
uint256 timeNftTransferedToRider
);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
riderWhoHiredIt | address | Address of the rider who hired the asset. |
riderNextPayinDate | uint256 | Time the rider’s next payment is due. |
nftTokenId | uint256 | Token id of the NFT title for the asset. |
timeRiderCompletedPayments | uint256 | Time the rider completed all payments. |
timeNftTransferedToRider | uint256 | Time the NFT title was transferred to the rider. |
getTitleInfo
Returns what a title token needs for its metadata: the asset name and rider.
Read by {HenriableVehicleNFT.tokenURI} so the on-chain card can show the vehicle and the rider. Returns zero values for an unknown token, or before a rider is hired, which the metadata treats as “omit”.
function getTitleInfo(uint256 tokenId) external view returns (bytes32 assetName, address rider);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The title’s token id. |
Returns
| Name | Type | Description |
|---|---|---|
assetName | bytes32 | The bytes32 name of the asset the title represents. |
rider | address | The rider who hired the asset, or address(0) if none yet. |
getSeniorInvestorsList
Returns the list of senior investors for an investment.
function getSeniorInvestorsList(uint256 index) external view returns (address[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | The senior investor addresses. |
getJuniorInvestorsList
Returns the list of junior investors for an investment.
function getJuniorInvestorsList(uint256 index) external view returns (address[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | The junior investor addresses. |
getSeniorInvestorIndex
Returns a senior investor’s 1-based index within an investment’s senior list.
Positions are 1-based; 0 means the investor is not in the list. When an investor holds several seats, this is their most recently taken seat.
function getSeniorInvestorIndex(bytes32 investmentId, address investor) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
investor | address | The investor address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index, or 0 if not present. |
getJuniorInvestorIndex
Returns a junior investor’s 1-based index within an investment’s junior list.
Positions are 1-based; 0 means the investor is not in the list. When an investor holds several seats, this is their most recently taken seat.
function getJuniorInvestorIndex(bytes32 investmentId, address investor) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
investor | address | The investor address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index, or 0 if not present. |
getRidersHirePurchaseRequestsList
Returns the rider ids of the hire-purchase requests for an investment.
function getRidersHirePurchaseRequestsList(uint256 index) external view returns (bytes32[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32[] | An array of rider ids. |
getInvestmentHireRequestStorage
Returns a storage reference to a hire-purchase request of an investment.
Hides the index + 1 bookkeeping used by the investment’s request list.
function getInvestmentHireRequestStorage(bytes32 investmentId, uint256 position)
internal
view
returns (HRiderHirePurchaseRequest storage);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
position | uint256 | The position in the investment’s hire-request list. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderHirePurchaseRequest | A storage reference to the hire-purchase request. |
getRiderHirePurchaseRequestIndex
Returns a rider’s 1-based position in an investment’s hire-request list.
Positions are 1-based; 0 means the rider has no request for the investment.
function getRiderHirePurchaseRequestIndex(bytes32 investmentId, address rider) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
rider | address | The rider address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based position, or 0 if not present. |
getInvestmentRiderPayinsHistory
Returns the rider payment history of an investment.
function getInvestmentRiderPayinsHistory(uint256 index) external view returns (HPayingHistory memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HPayingHistory | The {HPayingHistory} for the investment’s rider. |
getInvestmentRiderSavings
Returns the rider savings record of an investment.
function getInvestmentRiderSavings(uint256 index) external view returns (HRiderSavingsHistory memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderSavingsHistory | The {HRiderSavingsHistory} for the investment’s rider. |
getInvestorPayoutHistory
Returns one investor’s payout history for an investment.
function getInvestorPayoutHistory(bytes32 investmentId, address investor)
external
view
returns (HInvestorPayoutsHistory memory);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
investor | address | The investor address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestorPayoutsHistory | The {HInvestorPayoutsHistory} for that investor. |
getInvestmentPayoutHistory
Returns the aggregate payout history of an investment.
function getInvestmentPayoutHistory(uint256 index) external view returns (HInvestmentPayoutsHistory memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestmentPayoutsHistory | The {HInvestmentPayoutsHistory} for the investment. |
getInvestmentContractPayoutHistory
Returns the contract/owner payout history recorded on an investment.
function getInvestmentContractPayoutHistory(uint256 index) external view returns (HOwnerPayoutsHistory memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HOwnerPayoutsHistory | The {HOwnerPayoutsHistory} for the investment. |
getInvestorsCount
Returns the total number of registered investors.
function getInvestorsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {investorsList}. |
getInvestorIndex
Returns an investor’s 1-based index in {investorsList}.
Positions are 1-based (0 means “not registered”); to index the array directly, callers subtract 1.
function getInvestorIndex(address investor) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investor | address | The investor address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index, or 0 if the investor is not registered. |
getInvestorStorage
Returns a storage reference to a registered investor.
Hides the index + 1 bookkeeping so callers can read or write fields
directly. Reverts if the investor is not registered.
function getInvestorStorage(address investor) internal view returns (HInvestor storage);
Parameters
| Name | Type | Description |
|---|---|---|
investor | address | The investor address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestor | A storage reference to the investor. |
getInvestorAt
Returns the investor registered at an index.
function getInvestorAt(uint256 index) external view returns (HInvestor memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investorsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestor | The {HInvestor} at the given index. |
getInvestor
Returns the investor profile for an address.
function getInvestor(address investor) external view returns (HInvestor memory);
Parameters
| Name | Type | Description |
|---|---|---|
investor | address | The investor address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestor | The {HInvestor} for the address (zero-filled if not registered). |
getRidersCount
Returns the total number of registered riders.
function getRidersCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {ridersList}. |
getRiderIndex
Returns a rider’s 1-based index in {ridersList}.
Positions are 1-based (0 means “not registered”); to index the array directly, callers subtract 1.
function getRiderIndex(address rider) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
rider | address | The rider address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index, or 0 if the rider is not registered. |
getRiderStorage
Returns a storage reference to a registered rider.
Hides the index + 1 bookkeeping so callers can read or write fields
directly. Reverts if the rider is not registered.
function getRiderStorage(address rider) internal view returns (HRider storage);
Parameters
| Name | Type | Description |
|---|---|---|
rider | address | The rider address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRider | A storage reference to the rider. |
getRiderAt
Returns the rider registered at an index.
function getRiderAt(uint256 index) external view returns (HRider memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {ridersList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRider | The {HRider} at the given index. |
getRider
Returns the rider profile for an address.
function getRider(address rider) external view returns (HRider memory);
Parameters
| Name | Type | Description |
|---|---|---|
rider | address | The rider address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRider | The {HRider} for the address (zero-filled if not registered). |
getHireRequestsCount
Returns the total number of rider hire-purchase requests.
function getHireRequestsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {ridersHirePurchasesRequestsList}. |
getHireRequestAt
Returns a rider hire-purchase request at an index.
function getHireRequestAt(uint256 index) external view returns (HRiderHirePurchaseRequest memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {ridersHirePurchasesRequestsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderHirePurchaseRequest | The {HRiderHirePurchaseRequest} at the given index. |
getRejectedRiderIndex
Returns whether/how a rider was rejected for an investment.
function getRejectedRiderIndex(bytes32 riderId, bytes32 investmentId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
riderId | bytes32 | The id of the rider. |
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | A non-zero marker if the rider was rejected, otherwise zero. |
getRiderPayinsCount
Returns the total number of rider payments.
function getRiderPayinsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {riderPayinsList}. |
getRiderPayinAt
Returns a rider payment at an index.
function getRiderPayinAt(uint256 index) external view returns (HRiderPayin memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {riderPayinsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderPayin | The {HRiderPayin} at the given index. |
getRiderPayinIndexes
Returns the payment indices recorded on an investment.
function getRiderPayinIndexes(bytes32 investmentId) external view returns (uint256[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256[] | The 1-based indices into the global rider payins list. |
getRiderAmountToPayNow
Returns how much the calling rider must pay for the next instalment of an investment, including the asset’s per-period savings charge.
Reads the investment’s rider payment history for the outstanding balance. Returns 0 when the caller is not the investment’s hired rider or the rider has already met the target total.
function getRiderAmountToPayNow(bytes32 investmentId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount the caller should pay now, in USDC base units (6 decimals). |
getRiderSavingsSlashesCount
Returns the total number of rider savings slashes.
function getRiderSavingsSlashesCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {riderSavingsSlashesList}. |
getRiderSavingsSlashAt
Returns a rider savings slash at an index.
function getRiderSavingsSlashAt(uint256 index) external view returns (HRiderSavingsSlash memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {riderSavingsSlashesList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderSavingsSlash | The {HRiderSavingsSlash} at the given index. |
getRiderSavingsSlashIndex
Returns the most recent savings slash index for an investment.
function getRiderSavingsSlashIndex(bytes32 investmentId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index into {riderSavingsSlashesList}, or 0 if none. |
getInvestmentRiderSavingsSlashes
Returns the savings slash indices recorded on an investment.
function getInvestmentRiderSavingsSlashes(bytes32 investmentId) external view returns (uint256[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256[] | The 1-based indices into the global rider savings slashes list. |
getInvestmentRiderSavingsSlashesHistory
Returns the aggregate savings slash history of an investment.
function getInvestmentRiderSavingsSlashesHistory(uint256 index)
external
view
returns (HRiderSavingsSlashesHistory memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderSavingsSlashesHistory | The {HRiderSavingsSlashesHistory} for the investment. |
getInvestorPayoutsCount
Returns the total number of investor payouts.
function getInvestorPayoutsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {investorPayoutList}. |
getInvestorPayoutAt
Returns an investor payout at an index.
function getInvestorPayoutAt(uint256 index) external view returns (HInvestorPayout memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investorPayoutList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestorPayout | The {HInvestorPayout} at the given index. |
getInvestorPayoutIndex
Returns an investor’s payout index for an investment.
function getInvestorPayoutIndex(address investor, bytes32 investmentId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investor | address | The investor address. |
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The index into {investorPayoutList}. |
getOwnerPayoutsCount
Returns the total number of owner payouts.
function getOwnerPayoutsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {ownerPayoutsList}. |
getOwnerPayoutAt
Returns an owner payout at an index.
function getOwnerPayoutAt(uint256 index) external view returns (HOwnerPayout memory);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {ownerPayoutsList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HOwnerPayout | The {HOwnerPayout} at the given index. |
getOwnerPayoutIndex
Returns the most recent owner payout index for an investment.
function getOwnerPayoutIndex(bytes32 investmentId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The index into {ownerPayoutsList}. |
getOwnerPayoutHistory
Returns the aggregate owner payout history for an investment.
function getOwnerPayoutHistory(bytes32 investmentId) external view returns (HOwnerPayoutsHistory memory);
Parameters
| Name | Type | Description |
|---|---|---|
investmentId | bytes32 | The id of the investment. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | HOwnerPayoutsHistory | The {HOwnerPayoutsHistory} for the investment. |
getCompletedRiderInvestmentsCount
Returns the number of completed rider investments.
function getCompletedRiderInvestmentsCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {completedRiderInvestmentList}. |
getCompletedRiderInvestmentAt
Returns a completed rider investment index.
function getCompletedRiderInvestmentAt(uint256 index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {completedRiderInvestmentList}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index into {investmentsList} (subtract 1 to index the array). |
getInvestmentsCompletedCount
Returns the number of investments marked complete.
function getInvestmentsCompletedCount() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The length of {investmentsCompleted}. |
getInvestmentsCompletedAt
Returns a completed investment index.
function getInvestmentsCompletedAt(uint256 index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index into {investmentsCompleted}. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The 1-based index into {investmentsList} (subtract 1 to index the array). |
getInvestors
Returns every registered investor profile.
Returns the whole list in one call; the paginated getInvestorsCount / getInvestorAt pair remains available for callers that page.
function getInvestors() external view returns (HInvestor[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestor[] | All entries of {investorsList}. |
getRiders
Returns every registered rider profile.
Returns the whole list in one call; the paginated getRidersCount / getRiderAt pair remains available for callers that page.
function getRiders() external view returns (HRider[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRider[] | All entries of {ridersList}. |
getHireRequests
Returns every rider hire-purchase request ever made.
Returns the whole list in one call; the paginated getHireRequestsCount / getHireRequestAt pair remains available for callers that page.
function getHireRequests() external view returns (HRiderHirePurchaseRequest[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderHirePurchaseRequest[] | All entries of {ridersHirePurchasesRequestsList}. |
getInvestorPayouts
Returns every investor payout ever made.
Returns the whole list in one call; the paginated getInvestorPayoutsCount / getInvestorPayoutAt pair remains available for callers that page.
function getInvestorPayouts() external view returns (HInvestorPayout[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HInvestorPayout[] | All entries of {investorPayoutList}. |
getRiderPayins
Returns every rider periodic payment ever made.
Returns the whole list in one call; the paginated getRiderPayinsCount / getRiderPayinAt pair remains available for callers that page.
function getRiderPayins() external view returns (HRiderPayin[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderPayin[] | All entries of {riderPayinsList}. |
getOwnerPayouts
Returns every owner/contract payout ever made.
Returns the whole list in one call; the paginated getOwnerPayoutsCount / getOwnerPayoutAt pair remains available for callers that page.
function getOwnerPayouts() external view returns (HOwnerPayout[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HOwnerPayout[] | All entries of {ownerPayoutsList}. |
getRiderSavingsSlashes
Returns every rider savings slash ever applied.
Returns the whole list in one call; the paginated getRiderSavingsSlashesCount / getRiderSavingsSlashAt pair remains available for callers that page.
function getRiderSavingsSlashes() external view returns (HRiderSavingsSlash[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | HRiderSavingsSlash[] | All entries of {riderSavingsSlashesList}. |