Skip to main content

JUSD

What is JUSD

JUSD is a stablecoin developed by the JOJO system to facilitate multi-collateralization. This unique feature allows users to utilize non-stablecoin assets, such as BTC, ETH, etc., as a margin for trading. JUSD operates similarly to DAI, and users can mint JUSD using other ERC20 tokens as collateral. While JUSD can be traded freely, its price is not guaranteed equal to the Primary asset on the open market.

How to get JUSD

  1. Users can deposit registered collateral to borrow JUSD.
  2. Users can also use USDC to buy JUSD directly in the JOJO system.

JUSDBank

JUSDBank is a mortgage system that allows users to deposit ERC20 tokens and borrow JUSD. The borrowed JUSD will be automatically transferred to the trading system so that users can use JUSD as a margin to trade.

Deposit

Users can deposit collaterals by calling IJUSDBank#deposit(), the collateral must be already registered in the system.

/// @notice deposit function: users deposit their collateral
/// @param from: deposit from which account
/// @param collateral: deposit collateral type
/// @param amount: collateral amount
/// @param to: account that users want to deposit to
function deposit(address from, address collateral, uint256 amount, address to) external;

Borrow

The number of JUSD loans available is based on the number of users' deposited collaterals. The maximum number of user loans available is calculated using this formula.

maxBorrowAmount=sum(collateralAmountpriceinitialMortgageRate)maxBorrowAmount = sum(collateralAmount * price * initialMortgageRate)
/// @notice borrow function: get JUSD based on the amount of user's collaterals
/// @param amount: borrow JUSD amount
/// @param to: is the address receiving JUSD
/// @param isDepositToJOJO: whether deposit to JOJO account
function borrow(uint256 amount, address to, bool isDepositToJOJO) external;

Repay

The price of collateral will fluctuate with the market; to ensure that the collateral deposited will not be liquidated, users must return JUSD in time. There are two ways to return JUSD:

  • Transfer JUSD from JOJO Exchange to return it.
  • Buy JUSD directly in the market through USDC, then return it.
/// @notice repay function: repay the JUSD in order to avoid account liquidation by liquidators
/// @param amount: repay JUSD amount
/// @param to: repay to whom
function repay(uint256 amount, address to) external returns (uint256);

Withdraw

Once a withdrawal is made, JUSDBank conducts a safety assessment of the account. The transaction will be reversed if the evaluation reveals that the account has become unsafe. A standard formula is used to determine whether an account is secure. Users can withdraw collateral if the safety assessment confirms that the account is safe.

UserTotalBorrow<=sum(collateralAmountpriceinitialMortgageRate)UserTotalBorrow <= sum(collateralAmount * price * initialMortgageRate)
/// @notice withdraw function: users can withdraw their collateral
/// @param collateral: withdraw collateral type
/// @param amount: withdraw amount
/// @param to: is the address receiving asset
/// @param from: who want to withdraw asset
function withdraw(address collateral, uint256 amount, address to, address from) external;

Liquidate

When the value of borrowed JUSD > the value of deposited collaterals, then the trader will be liquidated. The start liquidation formula is

JUSDBorrow>sum(depositAmountpriceliquidationMortgageRate)JUSDBorrow > sum(depositAmount * price * liquidationMortgageRate)

During the liquidation process, the system attempts to sell collateral at a discounted price based on the mark price, and anyone interested in the collateral can participate in the liquidation. Liquidators can take all or part of the liquidated's collateral and help them repay JUSD.

The liquidation process can be divided into three parts. The first part involves calculating the amount of collateral to be liquidated, determining how much JUSD the liquidator needs to repay on behalf of the liquidated, how much USDC to collect as insurance fee, and if there is any remaining collateral for liquidation, how much to return to them. The second part involves the liquidator executing specific operations, such as repaying JUSD by calling the JOJOFlashLoan function. The third part requires price protection, ensuring the liquidator correctly repays JUSD and insurance.

Among these three operations, liquidators can implement the code for external calls related to JOJOFlashLoan. Currently, JOJO officially provides liquidation code examples, which can be found in FlashLoanLiquidate.sol. The primary implementation process involves selling the collateral obtained from liquidation and dividing the resulting USDC into three parts: one for repaying JUSD, another for paying insurance, and if the liquidated's collateral still has a remainder, transferring it to the liquidated in the form of USDC.

/// @notice liquidate function: The price of user mortgage assets fluctuates.
/// If the value of the mortgage collaterals cannot handle the value of JUSD borrowed, the collaterals may be liquidated
/// @param liquidatedTrader: is the trader to be liquidated
/// @param liquidationCollateral: is the liquidated collateral type
/// @param liquidationAmount: is the collateral amount liqidator want to take
/// @oaram param is the JOJOFlashloan's param
/// @param expectPrice: expect liquidate amount
function liquidate(
address liquidatedTrader,
address liquidationCollateral,
address liquidator,
uint256 liquidationAmount,
bytes memory param,
uint256 expectPrice
) external returns (DataTypes.LiquidateData memory liquidateData);