KToken
contracts accept staking assets from users and mint transferrable kTokens from which users can redeem the staking assets. Controller
contract acts as the risk controller by allowing or rejecting user actions according to their collateral vs. liquidity states. KMCD
contracts keep records of Multi Collateral Debts (MCD) and work with Minter
contracts to control the supply of kUSD. Kaptain
contract along with KineOracle
contract keep updating asset and debt prices to feed Controller
and Minter
for their calculations.KToken
, Controller
and Minter
for majority of Kine Protocol functionalities.KToken
contracts implement the functionality of staking assets as collateral to users. By staking assets to KToken
contracts, stakers gain (mint) kTokens representing their staking balances and may use these balances as liquidity to increase their MCD Limit in order to mint kCurrency. The minted kTokens can be redeemed partially or in full to withdraw the assets, or be transferred to others following ERC20 protocol. Before kTokens being redeemed or transferred, Controller
contract will check if the owner's collateral is sufficient against its MCD to allow or reject transactions.KToken
contract. There are currently two kinds of kTokens, KEther
and KErc20
, which manage ether and ERC20 tokens respectively. KErc20
follows DelegateProxy pattern for upgradability, where KErc20Delegator
is the storage contract while KErc20Delegate
is the logic implementation contract.KErc20
contract or ether to KEther
contract as collateral and mint equivalent amount of kTokens to msg.sender
.KErc20
KEther
msg.sender
, and transfer equivalent amount of ERC20 tokens from KErc20
contract or ether from KEther
contract to msg.sender. Will check msg.sender
's liquidity first through Controller
contract and reject if liquidity is not sufficient after transfer.msg.sender
to another address. Will check msg.sender
's liquidity first through Controller
contract and reject if liquidity is not sufficient after transfer.KMCD
contracts. Each KMCD
contract can hold its own logic on debt creation and utilization.KMCD
contract in Kine Protocol, which incurs debt when user mint kUSD through KUSDMinter
contract. The minted kUSD shall be used to trade synthetic assets in Kine Exchange.KMCD
contract works as a debt ledger and cannot interact directly with external users. When users mint/burn kUSD on KUSDMinter
contract, the minter will call KMCD
contract to borrow/repay debt on their behalf.KUSDMinter
contract when user mint kUSD. Will create a kMCD borrow balance to the user. The amount borrowed must be less than the borrower's liquidity.KUSDMinter
contract when user burn kUSD. Will reduce the user's kMCD borrow balance.KUSDMinter
contract when a liquidator burns kUSD to liquidate another kMCD borrower. When a user becomes under-collateralized (has negative liquidity), a third party can liquidate its kMCD by repaying some or all (Close Factor
) of its borrowed kMCD and receive an amplified (Liquidation Incentive
) amount of collateral.KineUSD
(kUSD) and its minter KUSDMinter
.KineUSD
is an ERC20 which can be paused and prevent blacklist users to transfer. KUSDMinter
is the minter of KineUSD
and the interface to users to transit their debt to kUSD or vice versa.KUSDMinter
also distributes rewards periodically to stakers. The rewards are added periodically by reward distributor according to Kine Tokenomics and Kine Exchange trading fees. The accrued rewards can be claimed following a vesting algorithm.KineUSD
only allow the KUSDMinter
to mint/burn kUSD. KUSDMinter
call KMCD
to borrow/repay debt on behalf of users which actions will go through Controller
for risk control. KUSDMinter
also utilize accrued reward mechanism to calculate users' rewards status.KineUSD
KUSDMinter
, mint kUSD to account.KUSDMinter
, burn kUSD from account.KUSDMinter
msg.sender
. Borrowing kMCD will trigger Controller
to check user's liquidity to allow or reject the transaction. There is a start time only after which can users mint kUSD.msg.sender
and repay kMCD according to kMCD price on behalf of user. There is a start time only after which can users burn kUSD. There is a cool-down time before user can burn kUSD after last kUSD minting. This is to prevent bots from front running MCD price update by taking and repaying debt in short periods.msg.sender
's outstanding kMCD debt value. If kUSD balance is not sufficient, will burn all kUSD to repay debt. There is a start time only after when can users burn kUSD. There is a cool-down time before user can burn kUSD after last kUSD minting. This is to prevent bots from front running MCD price update by taking and repaying debt in short periods.msg.sender
's kUSD and call KMCD
liquidateBehalf
function (see KMCD
) on behalf of msg.sender
to liquidate staker's kMCD. If kUSD amount need to be burnt reached given maxBurnKUSDAmount
, will revert.msg.sender
and start a new release period for left and new accrued reward.Kaptain
), mint kUSD to Kine vault to keep kUSD total supply in line with the total debt value of the pool.Kaptain
), burn kUSD from Kine vault to keep kUSD total supply in line with the total debt value of the pool.KineUSD
KUSDMinter
KUSDMinter
will gradually mature in a release period. Every time user claim rewards, the release timer will be updated. The matured reward of total accrued rewards is calculated as :Liquidation Incentive
) amount of the staker's collateral. Calculation of account liquidity can be found in 3.5.4.KUSDMinter
stores a vault account address and only allows treasury to update vault's kUSD balance to keep debt pool value updated on chain. And the treasury is Kaptain
which drives the updates of vault kUSD balance change together with kMCD and Kine token prices, see 3.4 Price Feeds. Calculation of vault kUSD balance change happens in Kine Exchange and follows below algorithm:Kaptain
OpenOraclePriceData
contracts by Compound as price feeds for common assets. There is a customized view contract KineOracle
to store prices that are signed by reporters hosted by Kine.Kaptain
contract is responsible for updating kUSD balance in Kine vault via KUSDMinter
, calculating kMCD price and posting it along with other token prices to KineOracle
all in the same transaction.KineOracle
only accept prices posted from Kaptain
contract.Kaptain
contract only accept Kine Exchange poster call, and will validate if posted message is signed by Kine Reporter.KineOracle
OpenOraclePriceData
and saves them to KineOracle
. Prices are expected to be in USD with 6 decimals of precision.KineOracle
. Price is expected to be in USD with 6 decimals of precision.Kaptain
KUSDMinter
's treasuryMint
/treasuryBurn
to update Kine Exchange vault kUSD balance, calculate kMCD price and post prices to KineOracle
in the same transaction.KineOracle
Kaptain
Controller
implements the risk management functionality of the Kine Protocol. Controller
evaluates users' liquidity on their attempts to withdraw collaterals or take on more debts. It projects user-selected (by calling Enter Markets
and Exit Market
) staking assets in KToken
contracts by Collateral Factor
and asset prices (through KineOracle
) to user's liquidity, and control the amount of debt user can incur (borrow
) or reduce (repay
) in consequence. When a user becomes under-collateralized, Controller
calculates the proportion of its debt subject to liquidation by Close Factor
, and the amplified amount of collaterals by Liquidation Incentive
to be seized by liquidators.Controller
holds references of all supported KToken
/KMCD
instances, KineOracle
instance and provides functions to evaluate if transactions in KToken
, KMCD
are allowed or not. In certain conditions, admin
and pauseGuardian
can pause
and unpause
through Controller
contract.KToken
assets as account's liquidity providers.KToken
asset from sender's account liquidity calculation.Collateral Factor
that Controller
currently support.Controller
calculates the account's liquidity first to allow or reject the transaction. The calculation of account liquidity is as below:Controller
will iterate all kToken markets that user has entered in, sum all kToken balances multiplied by its asset price and Collateral Factor as total liquidity, sum all kMCD borrows multiplied by its debt price as total debt, count in additional liquidity or debt effect caused by user action, to conclude the final liquidity and shortfall (if liquidity is negative will present in shortfall as a positive number).