To create a new market in the Bank contract, you need to call the createMarket function. This function requires specific parameters and a transaction fee. Follow these steps to create a market:
The createMarket function takes a single parameter of type MarketConfigs, which is a struct containing the following fields:
Field
Type
Description
loanToken
address
The address of the ERC20 token used for loans in this market
collateralToken
address
The address of the ERC20 token used as collateral in this market
oracle
address
The address of the price oracle contract for this market
irm
address
The address of the Interest Rate Model contract for this market
lltv
uint256
The Liquidation Loan-to-Value ratio for this market (in WAD, e.g., 0.8 * 1e18 for 80%)
Market Creation Fee
The createMarket function is payable, which means you need to send ETH along with the transaction. The required amount is stored in the marketCreationFee variable of the Bank contract. Make sure to include this fee when calling the function.
Steps to Create a Market
Prepare the MarketConfigs struct with the necessary parameters.
Determine the current marketCreationFee by calling the marketCreationFee() function on the Bank contract.
Call the createMarket function with the prepared MarketConfigs and include the marketCreationFee as the transaction value.
Example (using ethers.js)
Important Notes
Ensure that the oracle and IRM addresses are valid and compatible with the Bank contract.
The IRM (Interest Rate Model) must be registered with the Bank contract before creating a market. Use the registerIrm function to register a new IRM if needed.
The LLTV (Liquidation Loan-to-Value) ratio should be set carefully as it affects the risk parameters of the market.
Make sure you have sufficient ETH to cover the marketCreationFee.
After successfully creating a market, you can use the returned market ID for other operations such as supplying assets, borrowing, or managing collateral within that specific market.