Skip to content

Accounts

Accounts

RentalFeeSlippage

error RentalFeeSlippage()

Thrown when the estimated rental fee calculated upon renting is higher than maximal payment amount the renter is willing to pay.

InvalidWithdrawalAmount

error InvalidWithdrawalAmount(uint256 amount)

Thrown when the amount requested to be paid out is not valid.

InsufficientBalance

error InsufficientBalance(uint256 balance)

Thrown when the amount requested to be paid out is larger than available balance.

Balance

struct Balance {
  address token;
  uint256 amount;
}

Account

struct Account {
  struct EnumerableMapUpgradeable.AddressToUintMap tokenBalances;
}

withdraw

function withdraw(struct Accounts.Account self, address token, uint256 amount, address to) external

Transfers funds from the account balance to the specific address after validating balance sufficiency.

UserEarning

struct UserEarning {
  enum IPaymentManager.EarningType earningType;
  bool isLister;
  address account;
  uint256 value;
  address token;
}

UniverseEarning

struct UniverseEarning {
  enum IPaymentManager.EarningType earningType;
  uint256 universeId;
  uint256 value;
  address token;
}

ProtocolEarning

struct ProtocolEarning {
  enum IPaymentManager.EarningType earningType;
  uint256 value;
  address token;
}

RentalEarnings

struct RentalEarnings {
  struct Accounts.UserEarning[] userEarnings;
  struct Accounts.UniverseEarning universeEarning;
  struct Accounts.ProtocolEarning protocolEarning;
}

handleRentalPayment

function handleRentalPayment(struct Accounts.Registry self, struct Rentings.Params rentingParams, struct Rentings.RentalFees fees, address payer, uint256 maxPaymentAmount) external returns (struct Accounts.RentalEarnings earnings)

Redirects handle rental payment from RentingManager to Accounts.Registry

Name Type Description
self struct Accounts.Registry Instance of Accounts.Registry.
rentingParams struct Rentings.Params Renting params.
fees struct Rentings.RentalFees Rental fees.
payer address Address of the rent payer.
maxPaymentAmount uint256 Maximum payment amount.
Name Type Description
earnings struct Accounts.RentalEarnings Payment token earnings.

handleExternalERC20Reward

function handleExternalERC20Reward(struct Accounts.Registry self, struct Listings.Listing listing, struct Rentings.Agreement agreement, struct ERC20RewardDistributionHelper.RentalExternalERC20RewardFees rentalExternalERC20RewardFees, address rewardSource) external returns (struct Accounts.RentalEarnings earnings)

performPayouts

function performPayouts(struct Accounts.Registry self, struct Listings.Listing listing, struct Accounts.RentalEarnings rentalEarnings, address payer, address payoutToken) internal

_createListerEarning

function _createListerEarning(struct Listings.Listing listing, enum IPaymentManager.EarningType earningType, uint256 value, address token) internal pure returns (struct Accounts.UserEarning listerEarning)

_createNonListerEarning

function _createNonListerEarning(address user, enum IPaymentManager.EarningType earningType, uint256 value, address token) internal pure returns (struct Accounts.UserEarning nonListerEarning)

_createUniverseEarning

function _createUniverseEarning(enum IPaymentManager.EarningType earningType, uint256 universeId, uint256 value, address token) internal pure returns (struct Accounts.UniverseEarning universeEarning)

_createProtocolEarning

function _createProtocolEarning(enum IPaymentManager.EarningType earningType, uint256 value, address token) internal pure returns (struct Accounts.ProtocolEarning protocolEarning)

increaseBalance

function increaseBalance(struct Accounts.Account self, address token, uint256 amount) internal

Increments value of the particular account balance.

balance

function balance(struct Accounts.Account self, address token) internal view returns (uint256)

Returns account current balance. Does not revert if `token` is not in the map.

balances

function balances(struct Accounts.Account self) internal view returns (struct Accounts.Balance[])

Returns the list of account balances in various tokens.

Registry

struct Registry {
  struct Accounts.Account protocol;
  mapping(uint256 => struct Accounts.Account) universes;
  mapping(address => struct Accounts.Account) users;
}