Project and Justification
BlueStone is an on-chain lending platform, in which lenders deposit tokens in a small contract to earn interests and borrowers use their token assets as collateral and borrow from the contract. Borrow interest is a function of pool utilization and deposit interest is a function of borrow interest, liquidity utilization.
Team and Background
The Bluestone team has already developed a fixed-rate lending protocol on Ethereum. Lenders could deposit tokens into the protocol with fixed terms and earn interests after term matures. Borrowers, however, get fixed-rate term loans secured by collaterals. We have deployed an alpha version of the protocol to the Rinkeby test-net. Check out the alpha version and landing page.
We will be focus on building a money market protocol on Nervos as it’s more early stage. We understand the difference between the development on Nervos and Ethereum, but with the knowledge we learned about blockchain and the experience we gained building BlueStone, we have the expertise to build a lending platform on Nervos as well.
Technical Design
Smart Contract
DATA STRUCTURES
-
Liquidity Pools: a liquidity pool for each token, which contains
- total_supply_amount
- total_borrow_amount
- global_supply_cir: global supply cumulative interest rate (CIR)
- global_borrow_cir
- last_action_time: the time of last action that changes the supply/borrow amounts or CIRs
-
Accounts: an account for each user address, which contains
- info: store some information for each token, which contains
- supply_amount
- supply_cir: user deposit CIR
- borrow amount
- borrow_cir: user borrow CIR
- collateral_token
- collateral_amount
All data structures will be stored in a state cell.
- info: store some information for each token, which contains
CORE FUNCTIONS
-
AddCollateral()
-
Borrow()
-
LiquidateLoan()
-
Repay()
-
Supply()
-
Withdraw()
All the above functions may change the utilization of a token pool, so they will always update global_deposit_cir, global_borrow_cir and last_action_time and relative variables of the user account data structure.
OTHER ADMIN FUNCTIONS
Web Client
UI to interact with our contract. We can follow our current product design and use ckb-sdk-js to interact with CKB.
Price Oracle
We need token price in CKB/USD from external sources in order to calculate collateral ratio in smart contract.
Liquidating Bot
Liquidating bot helps liquidators to get loan records that can be liquidated, and liquidate the specified record according to the filter set by the users.
Monitoring
Monitor the status of the contract, price oracle and other components, and alert us on certain conditions, e.g. pool liquidity is not sufficient or pool utilization is too high.