Loanable is a decentralized lending and borrowing system built on the Ethereum blockchain. It allows users to deposit, withdraw, and transfer tokens, as well as borrow tokens by providing collateral. The system supports multiple ERC20 tokens and includes features such as interest rate calculation, price updates, and loan management.
- Contains mathematical functions such as
nthRoot
andpower
for calculating roots and exponents. - Includes a
RandomWalk
contract for generating random numbers and simulating price movements.
- Manages token prices, interest rates, and deposit/loan calculations.
- Implements functions for updating token prices, calculating interest rates, and managing deposits and loans.
- Implements core banking functionalities such as depositing, withdrawing, and transferring tokens.
- Allows users to buy and sell tokens within the system.
- Extends the
Bank
contract to provide lending and borrowing functionalities. - Users can borrow tokens by providing collateral and repay loans to retrieve their collateral.
- An ERC20 token contract with additional features such as minting and claiming tokens.
- Inherits from OpenZeppelin's
ERC20
,ERC20Permit
, andOwnable
contracts.
- These are specific ERC20 token contracts that inherit from
MyToken
. - Each token has a unique name and can be used within the Loanable system.
To deploy the Loanable system, you need to compile and deploy the following contracts:
- TokenA.sol
- TokenB.sol
- TokenC.sol
- Loanable.sol
You can deploy these contracts using Remix IDE or any other Ethereum development environment.
-
Compile Contracts:
- Compile
TokenA.sol
,TokenB.sol
,TokenC.sol
, andLoanable.sol
in Remix IDE.
- Compile
-
Deploy Tokens:
- Deploy
TokenA
,TokenB
, andTokenC
contracts. These will be the ERC20 tokens used in the system.
- Deploy
-
Deploy Loanable:
- Deploy the
Loanable
contract, passing the addresses of the deployed tokens (TokenA
,TokenB
,TokenC
) as constructor arguments.
- Deploy the
-
Interact with the System:
- Once deployed, you can interact with the
Loanable
contract to deposit, withdraw, transfer, borrow, and repay tokens.
- Once deployed, you can interact with the
- Users can deposit and withdraw ETH or ERC20 tokens.
- The system tracks user balances and updates them accordingly.
- Users can transfer tokens to other users within the system.
- Users can borrow tokens by providing collateral in the form of other tokens.
- Loans accrue interest over time, and users must repay the loan to retrieve their collateral.
- The system periodically updates token prices based on a random walk algorithm.
- Interest rates are calculated based on the price changes.
- Interest rates are calculated using a custom algorithm that takes into account the time gap and price changes.
- Loans accrue interest over time, and users must repay the loan with interest.
- The system distributes dividends to users based on their deposit amounts when the total surplus exceeds a certain threshold.
The source code for this project is available on GitHub:
https://github.com/mianqiu00/Loanable
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
This project was developed by Yitian Wang.