Comment on page

# QSD Minting

The minting process of QSD will burn KUN, and the redemption process will mint KUN. The value of KUN will be directly related to the demands of QSD. The following equations describe the minting function of the QSD Protocol:
$Q = \overbrace{(Y_i*P_{i})}^{\text {collateral value}} + \overbrace{(K*P_K)}^{\text{KUN value}}$
$(1 − C_r​)({\sum_{i=0}^N{(Y_i*P_{i}}}))=C_r​(K ∗ P_K​)$
Where:
$Q$
is the units of newly minted QSD;
$C_r$
is the collateral ratio;
$Y_i$
is the units of collateral i to the system;
$P_{i}$
is the price in USD of collateral i;
$K$
is the units of KUN burned;
$P_K$
is the market price of the KUN token, provided by the weighted average prices of DEX pool.
Example A
On the Binance Smart Chain, minting QSD at a collateral ratio of 100% with 900 BUSD ($1/BUSD), 50 BNB ($40/BNB), and 2 BTCB ($37000/BTCB). Under this condition, the amount of KUN that needs to be burned is: $(1-1)×(900×1+50×40+2×37,000) = 1×(K×P_K)$ $0 = (K×P_K)$ We show that no KUN is needed to mint QSD when the protocol collateral ratio is 100% (fully collateralized). The number of QSD that can be minted at this time is: $Q = (900×1+50×40+2×37,000) + (0)$ $Q = 76,900$ 76,900 QSD are minted in this scenario. When the collateral ratio is 100%, the full value of QSD is calculated based on the collateral value. At this time, if users try to burn KUN to generate QSD, it will be returned because the result of $K×P_K$ on the right side of the equation is 0. Example B On the Binance Smart Chain, minting QSD at a collateral ratio of 70% with 900 BUSD ($1/BUSD), 50 BNB ($40/BNB), and 2 BTCB ($37000/BTCB), the price of KUN is \$0.5/KUN.
First, we need to calculate the demand for KUN:
$(1-70\%)×(900×1+50×40+2×37,000) = 70\%×(K×0.5)$
$K = 65,914.2857142857$
Therefore, when the collateral ratio is 70%, 900 BUSD, 50 BNB, and 2 BTCB are deposited to mint QSD, and 65,914.2857142857 KUN needs to be burned at the same time. At this time, the number of QSD that can be generated is:
$Q = (900×1+50×40+2×37,000) + (65,914.2857142857×0.5)$
$Q = 109,857.14285714285$
109,857.14285714285 QSD are minted in this scenario. 76,900 QSD are backed by the value of BUSD, BNB, and BTCB as collateral while the remaining 32,957.14285714285 QSD are not backed by anything. Instead, KUN is burned and removed from circulation proportional to the value of minted algorithmic QSD.
If not enough KUN put into the minting function alongside the collateral, the transaction will fail with a subtraction underflow error.
NOTE: At the initial stage of QIAN V2, only the single collateral function will be opened. After the system runs steadily, multiple collateral function will be opened at the same time to provide a complete minting function.