Skip to content

Metahub

Metahub

MetahubInitParams

struct MetahubInitParams {
  contract IACL acl;
  contract IERC20Upgradeable baseToken;
  address protocolExternalFeesCollector;
  contract IAssetClassRegistry assetClassRegistry;
}

onlyUniverseOwner

modifier onlyUniverseOwner(uint256 universeId)

Modifier to make a function callable only by the universe owner.

onlyExistingContract

modifier onlyExistingContract(bytes4 contractKey)

Modifier to make a function callable when contract with certain key exists.

onlyWarperManager

modifier onlyWarperManager()

Modifier to make a function callable only by the WarperManager contract.

onlyListingManager

modifier onlyListingManager()

Modifier to make a function callable only by the ListingManager contract.

onlyRentingManager

modifier onlyRentingManager()

Modifier to make a function callable only by the RentingManager contract.

onlyERC20RewardDistributor

modifier onlyERC20RewardDistributor()

Modifier to make a function callable only by the ERC20RewardDistributor contract.

constructor

constructor() public

initialize

function initialize(struct Metahub.MetahubInitParams params) external

Metahub initializer. ACL and AssetClassRegistry are self-registered from here and THEY DO NOT OWN a reference to Metahub!

Name Type Description
params struct Metahub.MetahubInitParams Initialization params.

registerContract

function registerContract(bytes4 contractKey, address contractAddress) external

Register new contract with a key.

Name Type Description
contractKey bytes4 Key of the contract.
contractAddress address Address of the contract.

registerAsset

function registerAsset(bytes4 assetClass, address original) external

Register a new asset.

Name Type Description
assetClass bytes4 Asset class identifier.
original address The original assets address.

depositAsset

function depositAsset(struct Assets.Asset asset, address from) external

Transfers an asset to the vault using associated controller.

Name Type Description
asset struct Assets.Asset Asset and its value.
from address The owner of the asset.

withdrawAsset

function withdrawAsset(struct Assets.Asset asset) external

Withdraw asset from the vault using associated controller to owner.

Name Type Description
asset struct Assets.Asset Asset and its value.

handleRentalPayment

function handleRentalPayment(struct Rentings.Params rentingParams, struct Rentings.RentalFees fees, address payer, uint256 maxPaymentAmount, bytes tokenQuote, bytes tokenQuoteSignature) external returns (struct Accounts.RentalEarnings rentalFixedEarnings, struct ITokenQuote.PaymentTokenData paymentTokenData)

Redirects handle rental payment from RentingManager to Accounts.Registry

Name Type Description
rentingParams struct Rentings.Params Renting params.
fees struct Rentings.RentalFees Rental fees.
payer address Address of the rent payer.
maxPaymentAmount uint256 Maximum payment amount.
tokenQuote bytes Encoded token quote data.
tokenQuoteSignature bytes Encoded ECDSA signature for checking token quote data for validity.
Name Type Description
rentalFixedEarnings struct Accounts.RentalEarnings
paymentTokenData struct ITokenQuote.PaymentTokenData Payment token data.

handleExternalERC20Reward

function handleExternalERC20Reward(struct Listings.Listing listing, struct Rentings.Agreement agreement, struct ERC20RewardDistributionHelper.RentalExternalERC20RewardFees rentalExternalERC20RewardFees) external returns (struct Accounts.RentalEarnings rentalExternalRewardEarnings)

Redirects handle external ERC20 reward payment from ERC20RewardDistributor to Accounts.Registry. Metahub must have enough funds to cover the distribution. ERC20RewardDistributor makes sure of that.

Name Type Description
listing struct Listings.Listing Represents, related to the distribution, listing.
agreement struct Rentings.Agreement Represents, related to the distribution, agreement.
rentalExternalERC20RewardFees struct ERC20RewardDistributionHelper.RentalExternalERC20RewardFees Represents calculated fees based on all terms applied to external reward.

withdrawProtocolFunds

function withdrawProtocolFunds(address token, uint256 amount, address to) external

Transfers the specific `amount` of `token` from a protocol balance to an arbitrary address.

Name Type Description
token address The token address.
amount uint256 The amount to be withdrawn.
to address The payee address.

withdrawUniverseFunds

function withdrawUniverseFunds(uint256 universeId, address token, uint256 amount, address to) external

Transfers the specific `amount` of `token` from a universe balance to an arbitrary address.

Name Type Description
universeId uint256 The universe ID.
token address The token address.
amount uint256 The amount to be withdrawn.
to address The payee address.

withdrawFunds

function withdrawFunds(address token, uint256 amount, address to) external

Transfers the specific `amount` of `token` from a user balance to an arbitrary address.

Name Type Description
token address The token address.
amount uint256 The amount to be withdrawn.
to address The payee address.

changeProtocolExternalFeesCollector

function changeProtocolExternalFeesCollector(address newProtocolExternalFeesCollector) external

Changes the address of collector for Protocol's external fees. Also emits `ProtocolExternalFeesCollectorChanged`.

Name Type Description
newProtocolExternalFeesCollector address The new collector's address.

assetClassController

function assetClassController(bytes4 assetClass) external view returns (address)

Retrieve the asset class controller for a given assetClass.

Name Type Description
assetClass bytes4 Asset class identifier.
Name Type Description
[0] address The asset class controller.

supportedAssetCount

function supportedAssetCount() external view returns (uint256)

Returns the number of currently supported assets.

Name Type Description
[0] uint256 Asset count.

supportedAssets

function supportedAssets(uint256 offset, uint256 limit) external view returns (address[], struct Assets.AssetConfig[])

Returns the list of all supported asset addresses.

Name Type Description
offset uint256 Starting index.
limit uint256 Max number of items.
Name Type Description
[0] address[] List of original asset addresses.
[1] struct Assets.AssetConfig[] List of asset config structures.

baseToken

function baseToken() external view returns (address)

Returns the base token that's used for stable price denomination.

Name Type Description
[0] address The base token address.

baseTokenDecimals

function baseTokenDecimals() external view returns (uint8)

Returns the base token decimals.

Name Type Description
[0] uint8 The base token decimals.

protocolExternalFeesCollector

function protocolExternalFeesCollector() external view returns (address)

Returns address of Protocol's external fees collector.

Name Type Description
[0] address The address of Protocol's external fees collector.

protocolBalance

function protocolBalance(address token) external view returns (uint256)

Returns the amount of `token`, currently accumulated by the protocol.

Name Type Description
token address The token address.
Name Type Description
[0] uint256 Balance of `token`.

protocolBalances

function protocolBalances() external view returns (struct Accounts.Balance[])

Returns the list of protocol balances in various tokens.

Name Type Description
[0] struct Accounts.Balance[] List of balances.

universeBalance

function universeBalance(uint256 universeId, address token) external view returns (uint256)

Returns the amount of `token`, currently accumulated by the universe.

Name Type Description
universeId uint256 The universe ID.
token address The token address.
Name Type Description
[0] uint256 Balance of `token`.

universeBalances

function universeBalances(uint256 universeId) external view returns (struct Accounts.Balance[])

Returns the list of universe balances in various tokens.

Name Type Description
universeId uint256 The universe ID.
Name Type Description
[0] struct Accounts.Balance[] List of balances.

balance

function balance(address account, address token) external view returns (uint256)

Returns the amount of `token`, currently accumulated by the user.

Name Type Description
account address The account to query the balance for.
token address The token address.
Name Type Description
[0] uint256 Balance of `token`.

balances

function balances(address account) external view returns (struct Accounts.Balance[])

Returns the list of user balances in various tokens.

Name Type Description
account address The account to query the balance for.
Name Type Description
[0] struct Accounts.Balance[] List of balances.

getContract

function getContract(bytes4 contractKey) external view returns (address)

Get contract address with a key.

Name Type Description
contractKey bytes4 Key of the contract.
Name Type Description
[0] address Contract address.

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal

Checks whether the caller is authorized to upgrade the Metahub implementation.

_registerContract

function _registerContract(bytes4 contractKey, address contractAddress) internal

_emitRentalEarningsEvents

function _emitRentalEarningsEvents(struct Accounts.RentalEarnings rentalEarnings) internal

Emits necessary events about rental related earnings.

Name Type Description
rentalEarnings struct Accounts.RentalEarnings The rental earnings spread.

_checkContractExists

function _checkContractExists(bytes4 contractKey) internal view

Reverts if the contract with a key does not exists.

Name Type Description
contractKey bytes4 Key of the contract.

_checkValidContractEntity

function _checkValidContractEntity(bytes4 contractKey, address contractAddress) internal view

Reverts if provided address is not a valid contract entity.

Name Type Description
contractKey bytes4 Contract entity key.
contractAddress address Contract entity address.

_baseTokenDecimals

function _baseTokenDecimals() internal view returns (uint8)

Returns the base token decimals.

Name Type Description
[0] uint8 The base token decimals.

_getContract

function _getContract(bytes4 contractKey) internal view returns (address)

Get contract address with a key.

Name Type Description
contractKey bytes4 Key of the contract.
Name Type Description
[0] address Contract address.

_isExistingContract

function _isExistingContract(bytes4 contractKey) internal view returns (bool)

Checks if the contract with a key exists.

Name Type Description
contractKey bytes4 Key of the contract.
Name Type Description
[0] bool True if exists.

_acl

function _acl() internal view returns (contract IACL)

return the IACL address