FLUX白皮书

Flux 协议白皮书
Flux protocol White Paper

版本 2.0
Edition 2.0
2020年09月19日

作者
Author
彭翰 http://01.finance/
PengHan http://01.finance/

摘要
Abstract

本文介绍一种去中心化协议 Flux,该协议创建基于货币供求,通过算法设置利率的货币市场。允许用户零阻力、高速地交易资产的时间价值,增强市场流动性。并将该协议在高性能的去中心化区块链网络 Conflux 中实施。
This paper is aimed at introducing a decentralized protocol ——Flux. Flux creates a cryptocurrency market based on cryptocurrency supply and demand. Flux algorithmically set interest rates which allow users to trade at a high speed with zero obstructions, and thus enhances market liquidity. This protocol operates on the high-performance blockchain system Conflux Network.

1.介绍 Introduction
DeFi 是当下区块链行业最火热的概念之一,一般通俗理解为去中心化金融,即依托分布式网络搭建的金融体系。虽然 DeFi 作为加密货币市场的重要金融体系,对标金融体系有着安全性、稳定性、信任机制简单有效的优势,但是大部分 DeFi 产品面临着受限于公链交互困难、可抵押资产单一、产品操作繁琐等问题,目前 DeFi 只在少部分加密货币用户群体中流行,其发展任然困难重重。
DeFi, short for Decentralized Finance, is one of the most popular blockchain concepts. DeFi is a integral part of financial systems built on a blockchain protocol, and thus, has the same attributes of it: security, stability and increased trust-effectivenes. However, most DeFi products are limited by the low performance of the public blockchain they are developed on, only accept a limited amount of available collateralized assets, have below-average user experience, etc… Therefore, DeFi is currently only used by a small number of cryptocurrency owners, and is only in its early stages.

同时在经历了 2020 年 3 月 12 日加密数字世界黑天鹅事件,当日在短时间几乎所有数字货币出现了巨幅暴跌,直接导致多个 DeFi 产品以 MakerDao、Compound 为首的借贷平台出现了大量清算资产。而与此同时,以太坊网络出现了史无前例的堵塞情况,致使借款人无法缴纳保证金;清算人也无法通过以太坊网络转账方式获得数字资产去拍卖。大量被清算资产以极低甚至 0DAI 的价格被清算人、清算机器人拍走,造成了借款人、借贷平台的巨大损失。
Meanwhile, after experiencing the Black Swan incident on 2020.03.12, almost all cryptocurrencies experienced a huge plunge in a short period of time, which directly led to a large number of liquidated assets on many DeFi lending platforms, such a MakerDao or Compound. At the same time, there has been an unprecedented congestion in the Ethereum network, which prevents borrowers from paying deposits in time; and liquidators cannot obtain digital assets for auctions through transfers on the Ethereum network. A large number of liquidated assets were taken away by liquidators and liquidation robots at extremely low prices, down to even 0 DAI, instead of repaying the borrower’s collateral value and causing massive losses for borrowers and lending platforms.

作者完整经历了整次黑天鹅事件,目睹了借款人与平台的损失后决心研发一个新的借贷平台。这一想法得到了 conflux 技术社区的多数人的支持,我们都有一个共同的愿望就是为加密数字货币世界贡献自己的力量。既然以太坊的公链性能无法承载恶劣情况下 DeFi 产品的运作,那么我们采用性能数优于以太坊百倍的 conflux 公链作为底层,并且大量改进现有 DeFi 借贷产品的利率模型、抵押模型、清算逻辑等,去构建一个更加优秀能够抵御“十年洪水”级别的灾难的 DeFi 产品——Flux。
The author experienced the entire Black Swan incident, and after witnessing the losses of the borrower and the platform, the determination for develoinge a new lending platform was born. This idea has gained support in the technical community of Conflux Network since all have a common goal: contribute to the development of the blockchain and cryptocurrency ecosystem. Since the performance of Ethereum cannot support a seamless operation of DeFi products under severe conditions, Conflux Network is the logical choic, as its procotol’s performance is 100 times greater than of Ethereum. The increased perfermance of Conflux Network greatly improves the efficiency of the interest rate model, the collateralization model, the liquidation logic, etc., of current DeFi lending products. With the improvemtents just mentioned, we are determined to build a DeFi product that can withstand future market meldowns - Flux.

2.Flux协议 Flux Protooal
Flux 是一套完整的去中心化借贷协议,基于此协议,任何人都可以适配开发多样的借贷应用程序。
Flux is a compelte decentralized lending protocol, and anyone can adapt and develope a varitey of lending appications based on this protocol.

2.1资产与代币 Assets and Cryptocurrencies
Flux 协议所支持的资产除Conflux平台币 CFX外,其他资产必须符合 ERC777 标准。
Flux Protocol supports various digital assets. Besides supporting Conflux Network’s native token CFX, the protocol supports assets following the ERC-777 standard.

2.2供应资产 Supplying Assets
与Compound协议类似,Flux 协议是将每位用户供应的资产聚合在一起,形成一个聚合的货币市场。当一个用户供应资产时,它变成了可变现的资源。流动性提供者(存款人)可以随时提取资产,不需要等待特定的存款到期日。
Flux Protocol aggregates the assets of all users, forming an aggregated digital asset market -money market. Similar to the Compound protocol, once a user supplies the protocol with their assets, these assets become fungible. Liquidity providers (Lenders) can withdraw their supplied assets at any given time and do not need to wait for their specific loan matures.
货币市场中的余额根据该资产特有的供应利率计息,用户可以实时查看他们的余额(应计利息包括应收利息和应付利息);当用户进行更新他的余额的交易(供应、转移或提取代币)时,应计利息被转换成本金并支付给用户。
The asset balance ofmoney market accrues interest based on the specific supply rate of the asset. Users are free to view their balance at any time (accrued interest - interest receivable and interest payable); when users update their balances through a transaction (supply, transfer or withdrawl of assets) the accured interest is tranfered to the user.
长期持有CFX或其他资产的用户,可以将资产供应到Flux货币市场,以获得额外的投资回报。比如,拥有 CFX 的用户可以将他们的 CFX 资产供应给 Flux 货币市场,并赚取利息(以 CFX 计息)。而无需花费精力管理资产,无需承担投机风险。
Individual users that hold their assets as a long-term investment, such as CFX or other available digital assets, can supply these assets to themoney market as an additional source of return on their investment. For example, users owning CFX can supply their tokens to the money market, and earn interest (denominated in CFX) without having to manage their assets, fulfill loan requests or take speculative risks…

2.3借用资产 Borrowing Assets
Flux 允许用户通过信用质押轻松借走资产,用户对借出资产拥有完全所有权,可自由支配,可应用到任何其他可以到达的地方。用户无需设定还款日、借款利息等,只需指定需要借走何种资产,即可快速借走资产。如果是跨链资产,还可以一键从 Conflux 链中借出资产到指定的以太坊或者比特币地址中。
Flux allows users to borrow assets by depositing a trusted collateral. Users have all rights of the borrowed assets, and can freely use these assets anywhere they can be used. Users don’t need to negotiate maturity dates, interest rates, etc. User only need to specify the asset they want to borrow. In addition, if the assets are cross-chain assets, they can be cross-chained into other blockchain protocls, such as Ethereum or Bitcoin, through Conflux Network’s ShuttleFlow Protocol.
与供应资产类似,每个货币市场都有一个由市场资产利用率决定的浮动利率,该利率决定了借款成本(借款利息)。
Similar to the types of asset supply, everymoney markett has a floating interest rate, determined by the market forces, which set the borrowing cost for each asset (Borrowing Interest Rate).
为了控制风险,Flux根据风险设定每种资产的抵押因子(见表1),不可超额抵押,结合资产价格、余额、抵押因子可为每个账户动态计算借款额度;每个账户可以在借款额度内出用资产。
In order to mitigate market risks, Flux sets the collateral factor of various asset types according to their Asset Risk Level, as displayed in Table 1. Assets cannot be over-collateralized. By combining asset price, balance, and collateral factor, the borrowing capacity is dynamically calculated for each account; each account can only borrow assets within its borrowing capacity.
同时,每个账户未偿还的借款余额价值不得超过账户余额价值,我们称之为抵押率。用户可以不做任何动作(比如借款、还款、取款),使其值高于我们的清算抵押率;为了提高抵押率,用户以随时自由地偿还全部或部分借款资,、或供应更多资产。
即使用户的资产被用于质押,但依旧会获得存款利息。
At the same time, an account’s borrowing capacity cannot exceed the balance value of that specific account, which is called the collateral rate. An account cannot take any action (e.g. borrow, repay, or withdraw) that would increase the total value above their liquidation collateral rate; in order to increase the collateral rate, users can repay their borrowed assets partially or completely, and/or supply more assets into themoney market. Even if user assets are used as collateral, the interest will still be calculated normally…

表1-资产质押因子


Table1- Collateral Factor of Asset Types

2.3.1风险与清算 Risk & Liquidation
为了降低 Flux 协议风险,保护流动性提供者,账户流动性为负的借款人将被协议的其他用户清算,以使其账户流动性恢复为正(即高于抵押物要求)。当清算发生时,账户的抵押品变成了可卖资产,价格为当前市场价格。任何人(清算人)可代表借款人偿还部分或全部未偿还借款。作为回报,清算人可获得借款人借款所持有的抵押品,这被定义为清算激励。
To reduce Flux Protocols’s risks and protect the liquidity suppliers (lenders), when liquidity value of an account becomes negative, it will be liquidated by other users of the protocol in order to maintain the protocols requirement of over-collateralizaion. When the liquidation process occures, the account’s collateral becomes an exchangable asset at the current market price. Anybody (liquidator) can repay the borrowing outstanding of the borrower account in exchange for the account’s collateral as liquidation reward.
抵押物要求,我们用清算抵押率表达,是一个固定值,当前设定为 110%。即,当账户的借款抵押率(账户余额价值除以未偿还的资产价值的值)低于清算抵押率时,表示该账户流动性为负。
Flux protocol expresses the collateral need as liquidation collateral rate, which is a fixed value and currently set at 110%. When an account’s borrow collateral rate is lower than the liquidation collateral rate, the liquidity value of an account becomes negative. In this case the value of an account’s borrowing outstanding exceeds their borrowing capacity.
任何Conflux 链上地址均可公平、零阻力参与清算,不依赖任何中心化系统。根据时间优先原则,清算人可将"清算账户"(即低于清算抵押率的账户)的任何未偿还借款的某一固定百分比结清。清算人替借款人偿还全部或部分借款后,依据风险级别从低到高依次获得借款人的部分或全部抵押品。但清算人每次只能选择偿还一种借款资产,与一个fToken合约进行互动。清算人获得的抵押物就像他们自己供给了资产一样。
Any Conflux Network address can equalliy participate in the liquidation process without any pressure and the reliance on a centralized system. On a first-in-time basis, the liquidator can invoke any portion of the outstanding borrowing. After the liquidator has repaid all or part of the account’s borrowing outstanding, it will obtain part or all of the borrower’s collateral according to the risk level from low to high (1USDT, ETH, FC). The liquidator can only choose to repay one type of borrowed asset at a time to inteact with one fToken smart contract. After the liquidator has received the collateral as a reward, the asset is owned by the liquidator.
为了避免剧烈价格波动引发的账户借款抵押率抖动来带的风险,当完成一次清算后,如果账户借款抵押率已回归到清算抵押率之上,则后续清算将被回撤,不可继续清算账户抵押资产。
To avoid liquidation due to severe fluctuation of asset prices putting an account’s borrow collateral rate at risk, everytime a liquidation settlement is processed, if an accounts’s borrow collateral rate returns to a value greater than the liquidation collateral rate, subsequent liquidation of this account’s collateral will be withdrawn, and thus, the account’s collateral cannot be liquidated anymore.
当账户借款抵押率远低于清算抵押率,跌破 102% 时,我们称之为穿(breakdown)仓。此时,Flux 协议指定的特定清算人将接管清算,该特定清算人将抵押资产在交易所卖出换购成借款资产,再偿还至Flux货币市场中。在换购中间的亏损部分,Flux 使用平台清算储备金补偿 20%,最多不超过50%的平台清算储备金。
When an account’s borrow collateral rate is far lower than the liquidation collateral rate, falling below 102%, forced liquidation takes place. When forced liquidation takes place, Flux Protocol’s designated liquidator will process the liquidation. The designated liquidator will use the collateral to purchase an asset on a cryptocurrency exchange that will be supplied back into themoney market… 20% of the losses from the redemption are compensated by the Flux Liquidation Reserve, not more than 50% of the total Flux Liquidation Reserve.

image

储备金 Reserves
如果清算人通过抢购得到借款人的部分或全部抵押品,那么清算人需支付 2%的抵押品作为手续费给Flux协议。手续费的一半存入平台储备金;另一半存入清算储备金。
If the liquidator has repaid all or part of an account’s borrowing outstanding, partially or fully, the liquidator must pay a 2% service fee to Flux Protocol; half of the service fee is deposited into the platform Flux Platform Reserve; the other half is deposited in the Flux Liquidation Reserve.

平台储备金用途如下:
(1)supplyintrestrate极端时注资进入存款市场;
(2)支付平台运用、市场费用等。
清算储备金用途如下:
(1)Flux官方清算机器人会尽量抢拍没有被清算人抢拍的清算资产;
(2)分摊部分穿仓费用,最高赔付50%清算储备金。

Flux Platform Reserves are used as follows:
(1 )Supply assets into themoney market when supplyintrestrate is under extreme situations;
(2) Cover for Flux Platform’s operation costs, etc.;
(1) Flux’ official liquidation robot will try to bid for liquidated assets that have not been bid on by liquidators;
(2) If the 50% of the Flux Liquidation Reserve cannot make up for the 20% of the total lisses, then the FPR will compensate for part of the forced liquidation loss, up to 50% of the Flux Liquidation Reserve.

2.4取款限制 Withdrawal Limitation
为防止借款人提取资产引发清算风险,Flux 协议强制要求借款人提取资产后抵押率不得低于120%,除非借款人还请所有借款。
To prevent liquidation risks that are casued ba borrowes withdraing their assetsl, Flux Protocol requires the collateral rate to beabove 120% after borrowes withdra thire assets, unless the borrowesr pas off the remaining loans.

2.5利率模型 Interest Rate Model
Flux 协议每个的货币市场,根据该市场中每个资产的供应关系(资金利用率来实现动态衡利率,无需借款人和存款人双方进行任何条款和利率谈判,依据市场利率完成资产流动。每个货币市场 a 有独立利率。每个货币市场a的利用率Ua将资产供应关系统一为一个变量:

Ua = Borrwsa/(Borrowsa+Casha)

In themoney market of each individual asset, Flux Protocol balances the interest rate automatically based on the assets supply relationship (funding utilization rate). The suppliers and borrowers do not need to negotiate terms and interest rates individually since the Flux Protocol has an interest rate model implemented. Eachmoney market has independent interest rates. The utilization rate U for eachmoney markett a unifies the asset supply and demand relationship into one variable:
Ua = Borrwsa/(Borrowsa+Casha)

其中Borrwsa表示货币市场a中未偿还的借款余额;Casha表示供应到货币市场的资产余额。遵循经济学原理,当借款需求低迷时,利率应是低的;相反,当借款需求旺盛时,利率应该是上升的。借款需求通过利用率函数表示,当前设定借款利率​(Borrow Interest Rate)是由利用率与一个基础利率(0.03)得到:

Borrowing Intrrest Ratea = (e20Ua-1)/(e20-1)*0.97+0.03
Borrwsa represents the outstanding loan balance in themoney markett a; Casha represents the balance of assets supplied to themoney markett a. Subjecting to economic principles, when borrowing demand is low, interest rates should be low; on the contrary, when borrowing demand ishighg, interest rates should rise. The borrowing demand is expressed by the utilization rate function. The current set borrowing interest rate (Borrow Interest Rate a) is obtained from the utilization rate and a base interest rate of 3% (0.03):

Borrowing Interest Ratea = (e20Ua-1)/(e20-1)*0.97+0.03

在同一个货币市场中恒定有:
Within onemoney markett a, there is the following interest rate equilibrium:

Borrwsa * Borrowing Interrest Ratea = Suppliesa * Supply Interest Ratea

我们可得到使用率变化时,利率变化曲线图。当资金使用率为0时,借款利率为0.03,存款利率为0。

The following chart sho the interest rate change influenced by the usage rate.:

image

In case the fund utilization rate is 0, the borrowing rate is 0.03 and the deposit rate is 0.

去中心化自治 Decentralized Autonmous Organizationy
Flux 协议要求对协议的任何修改都需要通过去中心化自治组织(简称DAO)投票通过后才能生效。这是 Flux 协议去中心化。在 Flux 协议的早期将由 Flux 开发团队内部管理 DAO,在 Flux 协议实现完,且稳定后 Flux 开发团队将对 Flux 的管理权限移交给社区DAO
The Flux protooal requires that any modification to theprotocol must be voted through the Decentralized Autonomous Organization (DAO) to take effect. This is to decentralize the Flux protocol. In the early stages of Flux Protocol, the Flux Development Team will manage the DAO internally. After the Flux Protocol is complete and stable, the Flux Development Team will transfer the management authority of Flux to the DAO community.

3.实施与架构
Flux 核心是使用Solidity编写,所有 Conflux 账户都可公开,零阻力使用 Flux。且提供各种接口给市场中的借款人、存款人、清算人等各类市场参与者。
Flux Protocol is written in Solidity, and all Conflux Network accounts can interact with the platform. Flux Protocol provides various interfaces to various market participants such as borrowers, depositors, and liquidators, etc…

Flux 协议在高效的去中心化区块链网络 Conflux 中实施,并使用跨链系统 ShuttleFlow 对接以太坊或比特币跨链资产。采用 Conflux 区块链的优势有:
The Flux protocol isbuild on Conflu Network and utilizesg the cross-chainmechanism ShuttleFlow tointeract with cross-chained Ethereum or Bitcoin assets. The advantages of using Conflux blockchain are::
1.Conflux 主网性能较之于 Ethereum 更高,Gas 费更低;
2.流动性更好,例如 wBTC、imBTC 等都以 fBTC 方式存储/抵押,共享流动性;
3.安全性更高,详细请见 2.3.3。
1.The performance of ConfluxNetworkt is higherand the transaction fees lower thann Ethereum.
2.Conflux has aimprovedr liquidit.,Ffor example, wBTC, imBTC and alik aresupplieddcollateralized via fBTC andenjoy sharde liquiditythrough this methody.
3.Conflux has a higher security, please refer to 2.3.3.

3.1货币市场money market
Flux 协议为每种资产开辟独立的货币市场 MoneyMarket,也称货币市场。我们把资产在 Flux 协议中映射成标准的ERC20 Token: fToken。借款人将资产转账至该合约,可以兑换成 fToken;随着时间的推移,借款人可以获得 fToken 利息回报。表2是Flux 上线的首批资产清单以及映射的 fToken 信息。
The Flux protocol opens up an independent money market for each asset, it is also known as the lending market. We define the assets in the Flux protocol as standard ERC20 Token: fToken. The borrowers transfer assets to the contract, and their assets can be converted into fToken; over time, the borrowers can gain fToken interest returns. Table 2 is a list of the first batch of assets launched by Flux and the corresponding fToken information.


表2-Flux首批借贷资产
table-2 fist Flux lending assets

3.2利率 Interest Rate
和 Compound 相同,Flux 货币市场是由一对现行利率(供给和借款利率)定义的,统一适用于所有用户,随着时间的推移,这对利率会随着供求关系的变化而调整。
Like Compound, the Flux money market is defined by a pair of current interest rates (supply and borrowing rates), which are applicable to all users. With passage of time, this pair of interest rates will be adjusted once changes in supply and demand take place.
对于每个货币市场来说,每次利率的变化都是通过利率指数(Interest Rate Index)来掌握的。每次利率的变化,都是由用户供给、取款、借款、偿还或清算资产所产生。用户余额包括应记利息,简单地说,就是当前利率指数除以用户余额最后一次更新时的利率指数之比。
For every monetary market, every change in interest rates is controlled by the Interest Rate Index. The change of the interest rate is a result of user actions like supply, withdrawal, borrowing, repayment or liquidation of assets. User balance includes interest payable, which is simply the ratio of the current interest rate index divided by the interest rate index when the user balance was last updated.
货币市场中每个账户地址的余额作为 account checkpoint 存储,account checkpoint 是一个 Solidity 元组 <uint256 borrows,uint256 interestIndex>,这个元组描述了账户最后一次更新借款时的利率指数和借款余额。货币市场的当前利率指数也会全局存储。
The balance of each account address in the money market is stored as an account checkpoint. The account checkpoint is a Solidity tuple <uint256 borrows, uint256 interestIndex>, which describes the interest rate index and the borrowing balance when the account was last updated. The current interest rate index of the money market is also stored globally.
每次交易发生时,该资产的供给利率和借款利率指数都会被更新为自上一期指数以来的复利,使用期内的利息,以 r∗t计价,按每期利率计算。
Each time a transaction is produced, the asset’s supply interest rate and borrowing interest rate index will be updated to the compound interest from the previous period of the index. The interest is priced at r∗t during the period of use,and calculated at the interest rate of each period.

Index(a,n) = Index(a,n-1)* (1+r*t)

3.3市场汇率 Market Exchange Rate
资产在货币市场 a 中流通,随着市场借贷供给关系和时间的推移, fToken 数量会不断增长,我们根据市场供求关系设定 fToken 的兑换汇率,也就是 fToken的市场汇率。
Assets circulate in the money market a, but the amount of fToken will continue to grow with market interest. We set the exchange rate of fToken according to market supply and demand, which is the market exchange rate of fToken as well.
Exchange Ratea = (Casha + Borrwsa )/Supplya
当存款不变,借款越多时,市场汇率越高。存款人的 fToken余额可兑换更多资产,多兑换的部分则为存款利息。
More borrowing brings a higher market exchange rate when the deposit remains unchanged. The depositor’s fToken balance can be exchanged for more assets, and the assets that are exchanged by the fToken balance are the deposit interest.
cTokensa = fTokensa / Exchange Ratea

3.4存款(铸币)Deposit(Mintage)
任何 Conflux 账户都可通过供给资产获得新铸造的 fToken;供给资产存入货币市场合约名下,其新铸造的 fToken 数量等于供给资产数量除以当前市场汇率。
Any Conflux account can obtain newly minted fTokens by offering assets, and the assets are deposited under the name of the money market contract, and the number of newly minted fTokens is equal to the number of the deposited assets divided by the current market exchange rate.
Flux 协议中有三大类资产,各类资产的供给途径有所差已:
There are three types of assets in the Fluxprotocol, and there are different ways of offering different assets::

1.Conflux 平台币 CFX 供给:通过 function mint() payable 函数供给。
1.Conflux token CFX: offering assetes through function mint() payable function
2.跨链资产cToken,有两种途径提供:
a)通过cToken.operatorSend(minter,market,amount,0x0,0x1) 转账至货币市场合约。
b)通过 ShuttleFlow 侧链系统将以太坊或者比特币链上资产转账至货币市场。ShuttleFlow将通过 cToken.mint(market,amount,minger,"") 铸造新的 cToken 到借贷合约。
2. Cross-chain assets cToken, two ways:
a)Transffering assets to the money market contract through cToken.operatorSend(minter,market,amount,0x0,0x1).
b)Transferring assets on the Ethereum or Bitcoin chain to the money market through the ShuttleFlow side chain system.ShuttleFlow will use cToken.mint(market,amount,minger,"") to mint new cTokens into the loan contract.

3.非跨链ERC777资产:通过cToken.operatorSend(minter,market,amount,0x0,0x1) 转账至货币市场合约。
3. non-cross-chain ERC777 assets: transffering assets to the money market contract through cToken.operatorSend(minter,market,amount,0x0,0x1)

存款函数中处理的关键动作是:
1.铸造新 fToken 给minter;
2.更新minter余额;
3.更新利率模型。
注意,供给 ERC777 资产到货币市场的动作并不在存款函数中执行,而是由ERC777转账到货币时的 tokensReceived 回调来触发存款函数。
The key steps to process deposit function are:
1.Minting new fToke to minter;
2.Updating minter balance;
3.Updating interest rate model.
Please note: the process of supplying ERC777 assets to the money market is not executed via the repayment function, but when ERC777 assets are successfully deposited, the tokensReceived will trigger the deposit function.

3.5取款(赎回)Withdrawal(Redemption )
赎回相当于取款,一旦赎回资产将不再享有利息等权益。赎回函数负责将资产从货币市场转移至用户,以交换之前铸造的 fToken。资产赎回数量等于要赎回的fToken 数量乘以当前汇率得出。赎回数量必须小于用户账号的可用流动性以及市场的可用流动性。
Redemption is similar to withdrawal and once the redemption takes place, rights like interest income are no longer entitled to the withdrawer.The redemption function is responsible for transferring assets from the money market to users in exchange for the previously minted fToken. The amount of assets redeemed is equal to the amount of fToken to be redeemed multiplied by the current exchange rate. The redemption amount must be smaller than the available liquidity of the user account and the available liquidity of the market.

Flux 协议中有三大类资产,各类资产提供不同的接收资产方式:
1.Conflux 平台币 CFX:通过 function redeem(uint256 ftokens) 函数赎回资产到自己的 Conflux 地址。
2.跨链资产cToken:支持赎回到以太坊地址或比特币地址。
a)通过function redeem(uint256 ftokens) 函数,以赎回资产到自己的 Conflux 地址。
b)通过function redeem(uint256 ftokens, address receiver) 函数,receiver 输入以太坊或比特币地址,以赎回资产到以太坊或比特币钱包中。
3.非跨链ERC777资产:通过function redeem(uint256 ftokens) 函数,以赎回资产到自己的 Conflux 钱包。
There are three types of assets in the Flux protocol, and there are diferent ways to receive different assets:
1.Conflux token CFX: Redeem assets to your Conflux address through function redeem(uint256 ftokens) function.
2.Cross-chain cToken: Support redemption to Ethereum address or Bitcoin address
a.Redeem assets to your Conflux adress through function redeem(uint256 ftokens) function
b.Receiver shall enter their own ETH/BTC adress through function redeem(uint256 ftokens, address receiver) function to redeem thier asstes back to their ETH/BTC wallet.
3. Non-cross-chain ERC777 asstes: Redeem asstes back to your won Conflux wallet through function redeem(uint256 ftokens) function.

取款函数中处理的关键动作是:
1.划转 ERC777 资产给 msg.sender 或 receiver(由经跨链系统);
2.销毁 fToken;
3.更新 msg.sender 余额;
4.更新利率模型。
The key steps to process withdrawal functions are:
1.Transferring ERC777 assets to msg.sender or receiver (through cross-chain system);
2.Dispose fToken;
3.Updating msg.sender balance;
4.Updating interest rate model.

3.6借款 Borrowing
借款函数负责将资产从货币市场转移给用户,并创建一个借款余额,该余额根据资产的借款利率复利计息。借款数量必须少于用户的借款能力以及市场的可用流动性。用户必须维持抵押要求以避免清算。
The borrowing function is responsible for transferring the assets from the money market to the users, and creating a borrowing balance that is compounded based on the asset’s borrowing rate. The amount of borrowing must be smaller than the user’s borrowing capacity and the market’s available liquidity. The user must maintain the mortgage requirement in order to avoid liquidation.
请注意,借款人将收到一笔资产交易,对于 fETH 货币市场来说将是以太币。因此,借款人必须是可偿还的。
Please be noted that the borrower will receive an asset transaction, which will be Ether for the fETH money market. Therefore, the borrower must be repayable.
Flux 协议中有三大类资产,各类资产提供不同的接收资产方式:
1.Conflux 平台币 CFX:通过 function borrow(uint256 ctokens)函数借入资产到自己的 Conflux 地址。
2.跨链资产cToken:支持赎回到以太坊地址或比特币地址。
a.通过function borrow(uint256 ctokens)函数,借入资产到自己的 Conflux 地址。
b.通过function borrow(uint256 ctokens, address receiver) 函数,receiver 输入以太坊或比特币地址,以借入资产到以太坊或比特币钱包中。
3.非跨链ERC777资产:通过function borrow(uint256 ctokens)函数,借入资产到自己的 Conflux 地址。
There are three types of assets in the Fluxprotocol, and different assets has different ways get received::
1.Conflux token CFX: borrow assets to your Conflux address through function borrow(uint256 ctokens) function.
2…Cross-chain cToken: Support redemption to Ethereum address or Bitcoin address.
a.Borrow assets to your Conflux adress through function redeem(uint256 ftokens) function
b.To borrow assets to the Ethereum or Bitcoin wallet,the receiver need enter the Ethereum or Bitcoin address through function borrow(uint256 ctokens, address receiver) function,
3.Non-cross-chain ERC777 asstes: borrow asstes to your won Conflux wal let through function borrow(uint256 ctokens)function.

借款函数中处理的关键动作是:
1.划转 ERC777 资产给 msg.sender 或 receiver(由经跨链系统);
2.更新利率指数;
3.更新 msg.sender 借款余额;
4.更新利率模型。
The key steps to process borrwoing functions are:
1.Transferring ERC777 assets to msg.sender or receiver (through cross-chain system);
2.Updating interest rate index;
3.Updating msg.sender bowrrowing balance;
4.Updating interest rate model.

3.7偿还借款Debt Repayment
借款人通过还款函数负责将借入的资产转移到货币市场,以减少用户的借款余额。当借款人偿还的资产多余实际借款时,剩余部分将被作为存款记入账户名下。
The borrower transfers the borrowed assets to the money market through the repayment function,and in this way, the user’s loan balance can be reduced. When the borrower’s repayment of assets exceeds the actual assetes that has been borrowed, the excesses will be credited to the account as a deposit.

Flux 协议中有三大类资产,各类资产的还款途径与供给资产类似:
There are three types of assets in the Fluxprotocol, and the way to repay the asstes is similar to the way of offerring assetes::

1.Conflux 平台币 CFX:通过 function repay() payable 函数还款。
1.Conflux token CFX: Repay the debt through function repay() payable function.
2.跨链资产cToken,有两种途径提供:
2.Cross-chain cToken, two ways:
a.通过 cToken.operatorSend(borrower,market,amount,0x0,0x0) 转账至货币市场合约,默认视为还款。
a.Transferring assetes to the money market contract through cToken.operatorSend(borrower,market,amount,0x0,0x0) are regarded as repayments by defualt.
b.通过 ShuttleFlow 侧链系统将以太坊或者比特币链上资产转账至货币市场。ShuttleFlow将通过 cToken.mint(market,amount,borrower,"") 铸造新的 cToken 到借贷合约,默认视为还款。
b.Transferring assets on the Ethereum or Bitcoin chain to the money market through the ShuttleFlow side-chain system. ShuttleFlow will use cToken.mint(market,amount,borrower,"") to mint a new cToken into the borrowing contract, which is regarded as a repayment by default.
3.非跨链ERC777资产:通过cToken.operatorSend(borrower,market,amount,0x0,0x0) 转账至货币市场合约。
3.Non-cross-chain ERC777 assets: transferring assetes to money market contracts through cToken.operatorSend(borrower,market,amount,0x0,0x0).
还款函数中处理的关键动作是:
1.更新利率指数;
2.更新 borower 或msg.sender 借款余额;
3.更新 borower 或msg.sender 账户余额(可能);
4.更新利率模型。
注意,偿还 ERC777 资产到货币市场的动作并不在还款函数中执行,而是由ERC777转账到货币市场地址时自动调用 tokensReceived 回调来触发的。

The key steps to process repayment functions are:
1.Updating interest rate index;
2.Updating borrower or msg.sender borrowing balance;
3.Updating borrower or msg.sender balance(possibly);
4.Updating interest rate model.
Please be noted the action of repaying ERC777 assets to the money market is not executed in therepayment function, but when ERC777 is transferred to the token, the tokensReceived will trigger the repayment function.

3.8清算借款 Borrowing Liquidation
清算人替借款人偿还全部或部分借款,使得借款人账户流动性回正。多个清算人参与清算时,将根据时间优先,依次清算。
The liquidator repays all or part of the borrowing for the borrower, so that the liquidity of the borrower’s account is restored. When multiple liquidators participate in the liquidation, they will be liquidated in order according to time priority.

Flux 协议中有三大类资产,各类资产的还款途径与供给资产类似:
There are three types of assets in the Fluxprotocol, and the repayment methods of each type of asset is similar to that of offering assets::

1.Conflux 平台币 CFX:
通过货币市场合约的 function liquidateBorrow(address borrower) payable 函数替 borrower 偿还部分或全部该单一市场基础资产。
1.Conflux token CFX:
Part or all of the underlying single market assets are repaid for borrowers through function liquidateBorrow(address borrower) payable function of the money market contract.

2.跨链资产cToken 和非跨链ERC777资产:
通过 cToken.operatorSend(sender,market,amount,borrower,0x2) 转账至货币市场合约完成清算,不支持通过跨链充值方式参与清算。
2. Cross-chain assets cToken and non-cross-chain ERC777 assets:
The settlement is completed through cToken.operatorSend(sender,market,amount,borrower,0x2) transfer to the money market contract, and the settlement through cross-chain recharge is not supported.

清算函数中处理的关键动作是:
1.更新 borrower借款余额;
2.更新 sender或msg.sender 账户余额;
3.sender 获得borrower 的抵押资产;
4.更新利率模型
注意,偿还 ERC777 资产到货币市场的动作并不在清算函数中执行,而是由ERC777转账到货币市场地址时自动调用的 tokensReceived 回调来触发的还款函数。
The key steps to process liquidation functions are:
1.Updating borrowing balance;
2.Updating sender or msg.sender balance;
3.sender obtains borrower’s mortgage assets;
4.Updating interest rate model.
Please be noted the action of repaying ERC777 assets to the money market is not executed in the clearing function, but when ERC777 is transferred to the token, the tokensReceived will trigger the clearing function.。