Enable Stablecoin Loan Kit
Enable is a open source stablecoin loan kit that enables anyone to deploy a fullly functional peer-to-peer stablecoin loan with the following features:
- Immutable record of loan agreement and automatic tracking of repayments and defaults
- Out-of-the-box handling of crowdfunding and fractional ownership through loan shares
- Automatic routing of repayments to fractional owners
We built Enable with the vision to expand opportunity to emerging market borrowers through access to credit, to fund value-creating activities like education and starting a business.
The Enable stablecoin loan kit is standalone, and designed with minimum viable complexity in mind.
It is heavily inspired by the OpenZeppelin Crowdfund contracts and Dharma's loan contracts.
The Crowdloan functionality has been decomposed into the following categories:
Crowdloan: Track state of crowdfund, collect funds from lenders, and issue debt tokens. Once the funding is complete the borrower can withdraw funds. If the loan fails to get fully funded, lenders can withdraw their contribution.
RepaymentRouter: Handle repayments, and track withdrawal allowances for debt token holders.
TermsContract: Get information about the terms of the loan and it's current status.
We believe parts of this project could morph into generic standards useful to theEthereum community. We'll be expanding, modularizing, and genercizing as appropriate when the initial implementation is finished.
zos workflow for local development
npm installto install all zeppelinOS related dependencies
ganache-cli --deterministic) to run a local blockchain
- Create your own
.envfile based on
.env.sample. These are the
process.envvariables that will be used for deployment / application. As of Aug 2019 this is the Infura API key and mnemonic"
Deploy to ganache
For background: read Publishing an EVM package.
zos publish --network development. This publishes the project's app, package and provider. This updates the zos config file with "app.address" field that is needed for tests to run.
zos push --network development. This deploys the contracts in the project. This has the same effect as running
zos createon every contract. See Quickstart for context.
Deploy to ethereum and development networks mainnet, ropsten, kovan, ganche
npm run deploy:contracts -- --network kovanfrom bash; change the network to the desired network
npm run test. This also runs
zos push, which updates the contracts with the latest vrsions
For background: read Upgrading contracts
zos upgrade <contract name>or
zos upgrade --allbased on contract changed. This should upgrade the contracts.
We use ESLint and Prettier to format our code. Please make sure you have the following setting turned on in VSCode (or equivalent editor).
Test solidity coverage
We use Solidity Coverage.
Cannot read property
// Example > npm t TypeError: Cannot read property 'address' of undefined
This happens because zos needs contracts to be
published. To resolve, run:
zos publish zos publish --network development
"Appears to be git repo or submodule" during
This is usually because of the
websocket module which
web3 depends on. Remove all
.git submodules using the command below
# Finds all instances of .git folders in node_modules find ./node_modules -name ".git" # Deletes them find ./node_modules -name ".git" -delete
- Lender: lends to a loan
- Borrower: person who loan is disbursed to
- Loan Shares: fractional ownership in a loan
- Funding Goal: this is same as
principalRequestedfrom the borrower's point of view
- Total Crowdfunded: this is the amount raised in the crowdfund
- Principal Requested: the loan amount the borrower is requesting for
- Principal Disbursed: the amount
- Donations: "unauthorized" native ERC-20 transfers to smart contract
- Fund: lenders fund a loan
Stages and Outcomes
We need a set of (Mutually Exclusive, Collectively Exhaustive)[https://www.caseinterview.com/mece] stages and outcomes, that are used for our
Some possible scenarios we will need to 'describe':
Crowdfund has ended, but
borrower does not withdraw funds. If they do not
start loan within a certain period of time (e.g. 48 hours), lenders should be able to
no outcome yet ->
Crowdfund has ended, and
borrower decides they do not want the loan and wants to refund the money.
borrower decides to pause the crowdfund. The
fund should be suspended.
no outcome yet ->
These steps are sequential.
require statements can use
<= to test for stages
- crowdfund notStarted
- crowdfund started
- crowdfund ended (either early end by borrower, or hit goal)
- loan started and in repayment cycle (this can mean that it's in default)
- completed (i.e. either fully paid back or written off)
Crowdfund Outcomes (pertains to outcome of crowdfund)
- no outcome yet (in progress, or pending acceptance)
- crowdfund paused (not implemented)
- crowdfund ended
- crowdfund refunded (i.e. borrower rejects the crowdfund, returns money)
- crowdfund accepted (i.e. borrower starts the loan)
Loan Outcomes (pertains to outcome of loan)
- On time (not fully paid back yet)
- Late 30, 60, 90, 180 (number of days it's behind in loans)
- Fully paid back
- Written off (default)