Skip to content

Rentings

Rentings

RentalAgreementConflict

error RentalAgreementConflict(uint256 conflictingRentalId)

Thrown when a rental agreement is being registered for a specific warper ID, while the previous rental agreement for this warper is still effective.

CannotDeleteEffectiveRentalAgreement

error CannotDeleteEffectiveRentalAgreement(uint256 rentalId)

Thrown when attempting to delete effective rental agreement data (before expiration).

RenterCannotBeZeroAddress

error RenterCannotBeZeroAddress()

Thrown when attempting to rent for Zero address.

RentalStatus

enum RentalStatus {
  NONE,
  AVAILABLE,
  RENTED
}

_GC_CYCLES

uint256 _GC_CYCLES

Defines the maximal allowed number of cycles when looking for expired rental agreements.

RentalFees

struct RentalFees {
  uint256 total;
  uint256 protocolFee;
  uint256 listerBaseFee;
  uint256 listerPremium;
  uint256 universeBaseFee;
  uint256 universePremium;
  struct IListingTermsRegistry.ListingTerms listingTerms;
  struct ITaxTermsRegistry.TaxTerms universeTaxTerms;
  struct ITaxTermsRegistry.TaxTerms protocolTaxTerms;
}

Params

struct Params {
  uint256 listingId;
  address warper;
  address renter;
  uint32 rentalPeriod;
  address paymentToken;
  uint256 listingTermsId;
  struct IListingTermsRegistry.ListingTerms selectedConfiguratorListingTerms;
}

Agreement

struct Agreement {
  struct Assets.Asset[] warpedAssets;
  uint256 universeId;
  bytes32 collectionId;
  uint256 listingId;
  address renter;
  uint32 startTime;
  uint32 endTime;
  struct Rentings.AgreementTerms agreementTerms;
}

AgreementTerms

struct AgreementTerms {
  struct IListingTermsRegistry.ListingTerms listingTerms;
  struct ITaxTermsRegistry.TaxTerms universeTaxTerms;
  struct ITaxTermsRegistry.TaxTerms protocolTaxTerms;
  struct ITokenQuote.PaymentTokenData paymentTokenData;
}

isEffective

function isEffective(struct Rentings.Agreement self) internal view returns (bool)

isRegistered

function isRegistered(struct Rentings.Agreement self) internal pure returns (bool)

RenterInfo

struct RenterInfo {
  struct EnumerableSetUpgradeable.UintSet rentalIndex;
  mapping(bytes32 => struct EnumerableSetUpgradeable.UintSet) collectionRentalIndex;
}

AssetInfo

struct AssetInfo {
  uint256 latestRentalId;
}

Registry

struct Registry {
  struct CountersUpgradeable.Counter idTracker;
  mapping(uint256 => struct Rentings.Agreement) agreements;
  mapping(uint256 => struct Rentings.Agreement) agreementsHistory;
  mapping(address => struct Rentings.RenterInfo) renters;
  mapping(bytes32 => struct Rentings.AssetInfo) assets;
}

userRentalCount

function userRentalCount(struct Rentings.Registry self, address renter) internal view returns (uint256)

Returns the number of currently registered rental agreements for particular renter account.

userRentalAgreements

function userRentalAgreements(struct Rentings.Registry self, address renter, uint256 offset, uint256 limit) external view returns (uint256[], struct Rentings.Agreement[])

Returns the paginated list of currently registered rental agreements for particular renter account.

deleteExpiredUserRentalAgreements

function deleteExpiredUserRentalAgreements(struct Rentings.Registry self, address renter, bytes32 collectionId, uint256 toBeRemoved) external

Finds expired user rental agreements associated with `collectionId` and deletes them. Deletes only first N entries defined by `toBeRemoved` param. The total number of cycles is capped by GC_CYCLES constant.

register

function register(struct Rentings.Registry self, struct Rentings.Agreement agreement) external returns (uint256 rentalId)

Performs new rental agreement registration.

updateAgreementConfig

function updateAgreementConfig(struct Rentings.Registry self, struct Rentings.Agreement inMemoryRentalAgreement, uint256 rentalId, struct Rentings.RentalFees rentalFees, struct Warpers.Warper warper, struct ITokenQuote.PaymentTokenData paymentTokenData) external returns (struct Rentings.Agreement)

Updates Agreement Record structure in storage and in memory.

removeExpiredRentalAgreement

function removeExpiredRentalAgreement(struct Rentings.Registry self, uint256 rentalId) external

Safely removes expired rental data from the registry.

_removeRentalAgreement

function _removeRentalAgreement(struct Rentings.Registry self, uint256 rentalId) private

Removes rental data from the registry.

collectionRentedValue

function collectionRentedValue(struct Rentings.Registry self, address renter, bytes32 collectionId) external view returns (uint256 value)

Finds all effective rental agreements from specific collection. Returns the total value rented by `renter`.

assetRentalStatus

function assetRentalStatus(struct Rentings.Registry self, struct Assets.AssetId assetId) external view returns (enum Rentings.RentalStatus)

Returns asset(s) rental status based on latest rental agreement.

validateRentingParams

function validateRentingParams(struct Rentings.Params params, contract IMetahub metahub) external view

Main renting request validation function.

calculateRentalFees

function calculateRentalFees(struct Rentings.Params rentingParams, struct Warpers.Warper warper, contract IMetahub metahub) external view returns (struct Rentings.RentalFees fees)

Performs rental fee calculation and returns the fee breakdown.