The first Decentralized Lending Platform in Bitkub Chain powered by Finstable.
This repository contains the source code for YES token lending smart contract written in Solidity. The project is a fork of Compound Finance V2. We modified the contract to support credit scoring mechanism and Bitkub Next wallet integration. In this version, only YES token can be used as a collateral.
- Node JS version >=12
- NPM version >=6
Note: Please use NVM to downgrade Node and NPM version for convinient.
- Clone this repository
- Run
npm ito download dependencies
- Copy
.env.exampleand rename to.envand fill in your private keys.
- Unit testing:
npx hardhat test. - ABI and typechain generating:
npx hardhat compile. - Contract interaction:
npx hardhat run script scripts/<path-to-file> --network <network>. Replace with the folder and file name to run and replace with the network name (see the available networks inhardhat.config.tsfile). - Contract deployment:
npx hardhat run script deploy/<path-to-file> --network <network>. Replace and in the same way as the previous command.
- Check if BKC oracle subcription is not expired (https://www.bkcoracle.com/datafeed/view/1). Use wallet address YES Admin V1(0xfdC078e8d525c7bedb8705C7E940Ec11f1bAed78) to check. If the subscription is expired, get KDEV (https://console.bitkubchain.com/get-kdev) by paying some KUB with Bitkub Next wallet and transfer to a Metamask wallet. Finally, transfer to YES Admin V1 wallet to extend the subscription.
- Run
npx hardhat run scripts/oracle/testBKCOracle.ts --network <network>to make sure that the service is still up (we don't know when Bitkub put this service down). - Check if the oracle price index the price. Run
npx hardhat run scripts/oracle/testOracle.ts --network <network>. - If the price is not indexed, run
npx hardhat run scripts/interact/update-price.ts --network <network>to update the price. Wait for 10 minutes for the price to be updated. - Ensure that the price service is running to maintain the price in the long run.
This project contains with many pieces. Please find the source codes of those parts as follows:
- Frontend - The main user interface for interacting with lending contracts and campaigns by YES.
- API Server - Managing user accounts, credit scoring, campaigns, and token airdrops.
- Contract V2 - Token lending contract with any collateralized tokens.
- Wirtual NFT - The token locking and NFT minting contract used in Wirtual campaign.
- Price service - YES token price needs to be updated regularly. This API server submits a transaction to record price snapshot on-chain for every preconfigured interval. The updated price is very important to lending functionality. Failing to update price will halt the lending/borrowing functions of the system.
- V1 Liquidation service - An example source code for liquidation bot. This service is used to trigger liquidation in the system. The bot receives some rewards as an incentives. There is no restriction on running the bot. It can be run by anyone with any kind of implementation. Just need to trigger the right function under the right conditions specified in the lending contract.
- V2 Liquidation service - Same as the above code but is used for V2 contract.
