You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements the module to manage separated lending order-book markets per maturity.
This contract also works as a factory contract that can deploy (start) a new lending market
for selected currency and maturity and has the calculation logic for the Genesis value in addition.
Deployed Lending Markets are rotated and reused as it reaches the maturity date. At the time of rotation,
a new maturity date is set and the compound factor is updated.
The users mainly call this contract to create orders to lend or borrow funds.
hasLendingMarket
modifier hasLendingMarket(bytes32_ccy)
Modifier to check if the currency has a lending market.
Gets the funds that are calculated from the user's lending and borrowing order list
for all currencies in ETH.
Name
Type
Description
_user
address
User's address
_depositCcy
bytes32
_depositAmount
uint256
isInitializedLendingMarket
function isInitializedLendingMarket(bytes32_ccy) publicviewreturns (bool)
Gets if the lending market is initialized.
Name
Type
Description
_ccy
bytes32
Currency name in bytes32
Name
Type
Description
[0]
bool
The boolean if the lending market is initialized or not
initializeLendingMarket
function initializeLendingMarket(bytes32_ccy, uint256_genesisDate, uint256_compoundFactor, uint256_orderFeeRate, uint256_autoRollFeeRate) external
Initialize the lending market to set a genesis date and compound factor
Name
Type
Description
_ccy
bytes32
Currency name in bytes32
_genesisDate
uint256
The genesis date when the initial market is opened
_compoundFactor
uint256
The initial compound factor when the initial market is opened
_orderFeeRate
uint256
The order fee rate received by protocol
_autoRollFeeRate
uint256
The auto roll fee rate received by protocol
createLendingMarket
function createLendingMarket(bytes32_ccy, uint256_openingDate) external
Deploys new Lending Market and save address at lendingMarkets mapping.
Reverts on deployment market with existing currency and term
Name
Type
Description
_ccy
bytes32
Main currency for new lending market
_openingDate
uint256
Timestamp when the lending market opens
createOrder
function createOrder(bytes32_ccy, uint256_maturity, enum ProtocolTypes.Side _side, uint256_amount, uint256_unitPrice) externalreturns (bool)
Creates an order. Takes orders if the orders are matched,
and places new order if not match it.
In addition, converts the future value to the genesis value if there is future value in past maturity
before the execution of order creation.
Name
Type
Description
_ccy
bytes32
Currency name in bytes32 of the selected market
_maturity
uint256
The maturity of the selected market
_side
enum ProtocolTypes.Side
Order position type, Borrow or Lend
_amount
uint256
Amount of funds the maker wants to borrow/lend
_unitPrice
uint256
Amount of unit price taker wish to borrow/lend
Name
Type
Description
[0]
bool
True if the execution of the operation succeeds
depositAndCreateOrder
function depositAndCreateOrder(bytes32_ccy, uint256_maturity, enum ProtocolTypes.Side _side, uint256_amount, uint256_unitPrice) externalpayablereturns (bool)
Deposits funds and creates an order at the same time.
Name
Type
Description
_ccy
bytes32
Currency name in bytes32 of the selected market
_maturity
uint256
The maturity of the selected market
_side
enum ProtocolTypes.Side
Order position type, Borrow or Lend
_amount
uint256
Amount of funds the maker wants to borrow/lend
_unitPrice
uint256
Amount of unit price taker wish to borrow/lend
Name
Type
Description
[0]
bool
True if the execution of the operation succeeds
createPreOrder
function createPreOrder(bytes32_ccy, uint256_maturity, enum ProtocolTypes.Side _side, uint256_amount, uint256_unitPrice) publicreturns (bool)
Creates a pre-order. A pre-order will only be accepted from 48 hours to 1 hour
before the market opens (Pre-order period). At the end of this period, Itayose will be executed.
Name
Type
Description
_ccy
bytes32
Currency name in bytes32 of the selected market
_maturity
uint256
The maturity of the selected market
_side
enum ProtocolTypes.Side
Order position type, Borrow or Lend
_amount
uint256
Amount of funds the maker wants to borrow/lend
_unitPrice
uint256
Amount of unit price taker wish to borrow/lend
Name
Type
Description
[0]
bool
True if the execution of the operation succeeds
depositAndCreatePreOrder
function depositAndCreatePreOrder(bytes32_ccy, uint256_maturity, enum ProtocolTypes.Side _side, uint256_amount, uint256_unitPrice) externalpayablereturns (bool)
Deposits funds and creates a pre-order at the same time.
Name
Type
Description
_ccy
bytes32
Currency name in bytes32 of the selected market
_maturity
uint256
The maturity of the selected market
_side
enum ProtocolTypes.Side
Order position type, Borrow or Lend
_amount
uint256
Amount of funds the maker wants to borrow/lend
_unitPrice
uint256
Amount of unit price taker wish to borrow/lend
Name
Type
Description
[0]
bool
True if the execution of the operation succeeds
unwindOrder
function unwindOrder(bytes32_ccy, uint256_maturity) externalreturns (bool)
Unwind all orders by creating an opposite position order.
Name
Type
Description
_ccy
bytes32
Currency name in bytes32 of the selected market
_maturity
uint256
The maturity of the selected market
executeItayoseCalls
function executeItayoseCalls(bytes32[] _currencies, uint256_maturity) externalreturns (bool)
cancelOrder
function cancelOrder(bytes32_ccy, uint256_maturity, uint48_orderId) externalreturns (bool)
Cancels the own order.
Name
Type
Description
_ccy
bytes32
Currency name in bytes32 of the selected market
_maturity
uint256
The maturity of the selected market
_orderId
uint48
Market order id
executeLiquidationCall
function executeLiquidationCall(bytes32_collateralCcy, bytes32_debtCcy, uint256_debtMaturity, address_user, uint24_poolFee) externalreturns (bool)
Liquidates a lending position if the user's coverage is less than 1.
A liquidation amount is calculated from the selected debt, but its maximum amount is the same as a collateral amount.
That amount needs to be set at liquidationAmountMax otherwise currency swapping using Uniswap will fail
if the collateral is insufficient.
Name
Type
Description
_collateralCcy
bytes32
Currency name to be used as collateral
_debtCcy
bytes32
Currency name to be used as debt
_debtMaturity
uint256
The market maturity of the debt
_user
address
User's address
_poolFee
uint24
Uniswap pool fee
Name
Type
Description
[0]
bool
True if the execution of the operation succeeds
registerLiquidator
function registerLiquidator(bool_isLiquidator) external
Registers a user as a liquidator.
Name
Type
Description
_isLiquidator
bool
The boolean if the user is a liquidator or not
rotateLendingMarkets
function rotateLendingMarkets(bytes32_ccy) external
Rotates the lending markets. In this rotation, the following actions are happened.
Updates the maturity at the beginning of the market array.
Moves the beginning of the market array to the end of it (Market rotation).
Update the compound factor in this contract using the next market unit price. (Auto-rolls)
Convert the future value held by reserve funds into the genesis value
Name
Type
Description
_ccy
bytes32
Currency name in bytes32 of the selected market
pauseLendingMarkets
function pauseLendingMarkets(bytes32_ccy) externalreturns (bool)
Pauses previously deployed lending market by currency
Name
Type
Description
_ccy
bytes32
Currency for pausing all lending markets
Name
Type
Description
[0]
bool
True if the execution of the operation succeeds
unpauseLendingMarkets
function unpauseLendingMarkets(bytes32_ccy) externalreturns (bool)
Unpauses previously deployed lending market by currency
Name
Type
Description
_ccy
bytes32
Currency name in bytes32
Name
Type
Description
[0]
bool
True if the execution of the operation succeeds
cleanUpAllFunds
function cleanUpAllFunds(address_user) external
Clean up all funds of the user
Name
Type
Description
_user
address
User's address
cleanUpFunds
function cleanUpFunds(bytes32_ccy, address_user) externalreturns (uint256totalActiveOrderCount)
Clean up user funds used for lazy evaluation by the following actions:
Removes order IDs that is already filled on the order book.
Convert Future values that have already been auto-rolled to Genesis values.