paint-brush
How we built Constant: a secured P2P lending platform that puts customers in controlby@duyhtq
3,203 reads
3,203 reads

How we built Constant: a secured P2P lending platform that puts customers in control

by duyJuly 1st, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

“Banking is necessary, banks are not,” said Bill Gates in 1994.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How we built Constant: a secured P2P lending platform that puts customers in control
duy HackerNoon profile picture

“Banking is necessary, banks are not,” said Bill Gates in 1994.

In 2009, Bitcoin came along. Blockchain technology has opened up new possibilities to build better financial products that operate without the need for central authorities or banks.

I started Constant to build financial products based on P2P technologies. Our products belong to our users — they collectively operate, secure and enrich everything we build. Everything is open-source. Anyone can take part.

What follows describes our first product: decentralized, fully-secured P2P lending. Access to capital is key — to start or grow businesses, fund personal goals, support relationships, and pursue a higher quality of life. The more affordable capital we can provide, the more helpful we can be.

The evolution of lending

You are a lender whether you like it or not. Traditional lending happens once you deposit money into a bank. Your bank immediately loans it out to others via products like credit cards, charging predatory interest rates of up to 30% APR. The bank keeps most of these profits. You earn the national average of 0.8%. Subject to yearly inflation of around 2%, we’re effectively paying banks to store our money.

P2P lending platforms began with Zopa in the UK in 2005, and have since emerged as a popular alternative to traditional lending. However, they come with their own set of problems. Most offer risky, unsecured loans that have resulted in substantial losses for investors.

In China, for example, the once booming P2P lending industry has since fallen victim to scammers and rising defaults. Many platforms have either gone bankrupt or been unable to repay investors. In extreme cases, employees have simply run off with investor funds. Regulation has struggled to contain the problem, leaving many people out of pocket.

With the introduction of blockchain technologies, we now see a number of crypto P2P lending platforms — Dharma, Compound, and Constant — working on building better P2P lending platforms.

While our approaches differ, we all aim at building fully secured peer-to-peer lending platforms that replace reluctant trust with cryptographic proof, allowing any two anonymous parties from anywhere in the world to lend and borrow directly to and from each other, without the need for a trusted third party.

Loan management, collateralization and repayments are carried out collectively by the users of the network, protecting them from any single point of failure. This unique P2P property bypasses the need for a central party and allows for new, exciting use cases.

The traditional loan agreement has been replaced by an unstoppable Ethereum smart contract. It runs exactly as programmed — to return collateral to the borrower after repayment — without any possibility of downtime, fraud, or third-party interference. Once investors and borrowers commit to a loan, it is irreversible. Repayment is guaranteed.

All this happens without a central authority or a bank. If these platforms disappear, the smart contracts will continue to perform their function, collectively powered by all the nodes of the Ethereum blockchain.

Fully-secured, blockchain-enabled P2P lending is our contribution to a bankless banking system.

Of the three competing business models, which is the superior?

Shortcomings of current crypto P2P lending platforms

While there are a few crypto P2P lending platforms today, their products are designed for a small, niche audience: crypto savvy traders. Constant is built more broadly for the everyday user. We aim to reduce friction and ease transition into decentralized finance, by first building bridges between the existing financial system and its new alternatives.

As of May 15 2019, the combined loan volume of the two largest platforms, Dharma and Compound, is just shy of a modest $10 million. Global debt has just reached $215 trillion. The right product will migrate users and trigger mass adoption.

Let’s take a look at the shortcomings of current blockchain-based P2P lending solutions that stand in the way of mass adoption.

Lack of fiat support

Current solutions are exclusively crypto-to-crypto, as one might expect from P2P lending platforms built on blockchain technology. However, most of the current volume is generated by the crypto-trader community who long or short cryptocurrencies. Very rarely do these solutions impact other demographics.

Constant operates using USD stablecoins — cryptocurrency that is 1:1 pegged to USD. The platform hosts conversion of USD to stablecoins, as well as stablecoins to USD. As such, Constant makes crypto lending with USD stablecoins logistically identical to investing and borrowing USD. Loans can be easily put towards real-world use cases, such as buying a car, consolidating debt, or paying for a vacation. Investments appreciate steadily, without the typical volatility characteristic of the wider cryptocurrency market.

Lack of collateral choice

Current solutions offer a limited number of crypto assets as collateral (mostly BTC and ETH). We believe that more and more real-world assets will be tokenized. The more assets we support, the easier it will be for our users to get liquidity from their assets.

Constant’s engineers are working hard to add as many collateral types as possible. In addition to BTC and ETH, we are onboarding many additional ERC tokens. We’re also working with other blockchains to bring their tokens onto Constant, such as EOS, TRON, and TOMO.

Centralized interest rates

Other solutions are decentralized to varying degrees, but interest rates are set by the company, just like banks do. In our view, interest rates are a critical component and must also be decentralized.

Constant peer-to-peer lending offers an order book solution. On Constant, the users, not the platform, set their own investment and loan rates. It’s 100% market driven.

High margins

Current solutions set fixed rates and earn the difference. For example, if the interest rate for investors is set at 4%, and 10% for borrowers, the platform absorbs the 6%. This is also how banks work. Banks set their own rates and earn the difference.

Constant doesn’t work this way. Constant simply matches investors and borrowers at the rate they agree on, and charges a minimal service fee.

Lack of cross-border use cases

Current solutions are somewhat insular, located mostly in the US.

Constant’s team is located in both the US and Asia. We believe that bridging developed economies and emerging markets is the way forward, essential to building a global P2P lending network.

Developed economies have plenty of low-cost capital but enjoy almost no returns on their savings. People in emerging markets suffer from high interest rates and lack the means to obtain traditional requirements for borrowers, such as credit scores and background checks.

Introducing Constant: a Crypto P2P Lending Platform

The Order Book

In a stock exchange, the tradable asset is a share, and traders trade on share unit prices (e.g. sell 100 shares of Apple at $200 each).

In a coin exchange, the tradable asset is a coin, and traders trade on coin unit prices (e.g. buy 2 Bitcoin at $7,000 each).

Similarly, in a fully secured peer-to-peer lending platform, the tradable asset is cryptocurrency, and traders trade on the interest rates of that cryptocurrency.

A P2P lending market trades on interest rates

Running on top of the Ethereum blockchain, Constant is a peer-to-peer lending platform that provides a simple way for anyone to:

  • Place an Invest Order or Borrow Order.
  • Be a Market Maker (set the interest rate) or a Market Taker (take the interest rate).
  • Borrow money instantly.
  • Secure collateral with a Smart Contract.

The Constant Pro web interface gives professional traders insight into the Constant P2P lending market

The Matching Engine

The Constant algorithm matches investors with borrowers glad to pay their rates. It then secures investor funds and borrower collateral in an unstoppable smart contract, and facilitates the entire transaction from beginning to end. Unlike P2P lending platforms like LendingClub, all loans on Constant are fully secured.

Constant’s lending mechanism is designed to bring people together to do business on their own terms

Automatic Liquidation

If the collateral value falls to 110% of the principal plus interest to date, Constant automatically sells it to pay back investors, and refunds the borrower the difference. In this scenario, investors get the principal back, plus their profit to date. They are able to then re-invest and find a new match.

Early repayment

Borrowers have the option to repay early before their collateral value hits the threshold for automatic liquidation. If less than 75% of the term has elapsed, they pay full interest for the time before repayment, and 50% of the interest due for the rest of the term. If more than 75% of the term has elapsed, they pay 100%.

In this case, investors also get their principal back, plus their profit to date. They then have the option to re-invest and find a new match.

Here’s an example:

Jon invests $10,000 at 12% APR for 6 months. Annie accepts his terms for her loan. Three months later, Annie decides she wants to repay early.

Annie repays the loan of $10,000, and the interest due — 12% APR for 3 months, and 6% APR for 3 months — bringing the total amount due to $10,450.

Jon has earned 12% APR for 3 months, and now has the option to withdraw $10,300, or re-invest and find a new borrower.

Noncustodial

Collateral is stored in a smart contract. All parties — the investor, borrower, or Constant — cannot move the collateral at any time, unless it meets the programmed conditions such as a repayment or default event.

Coins

On the investment side, Constant supports stablecoins, as well as fiat currencies which are converted automatically into stablecoins in the backend. Constant will add more stablecoins over time, but only those with liquidity. At the time of writing, Constant supports the following stablecoins:

  • USDC
  • TUSD
  • PAX
  • GUSD
  • USDS

Invest in fiat or stablecoins — the choice is yours

On the borrowing side, Constant supports multiple collateral types. Constant will add more coins over time, but only those with significant liquidity to ensure the smooth running of the platform. At this time, Constant accepts the following coins as collateral:

  • BTC
  • ETH
  • BNB
  • BAT
  • REP
  • OMG
  • HOT
  • ZRX
  • VET
  • TOMO
  • ENJ
  • ZIL
  • DGD
  • DGX
  • KCS
  • FTM
  • IOTX
  • LRC
  • NULS

Constant supports diverse coin portfolios

Multiple devices

Constant provides cross-platform web interfaces for:

  • Desktop
  • Mobile
  • iOS
  • Android

Seamlessly switch between all your devices

Multiple languages

The initial release will be in English and Vietnamese. More languages will be added over time, including Spanish, Chinese, Korean, and Japanese.

API

Constant will provide an open REST API for other platforms to integrate with ours. Here are some potential use cases:

  • Integrate with wallets, creating “Instant Borrow” and “Instant Invest” buttons
  • Integrate with PoS (Proof-of-Stake) chains to earn interest on staked collateral
  • Integrate with exchange reserves

Oracles

Oracles play an important role in the design of Constant. They feed diverse external data (such as the current BTC price) into Constant, removing single points of failure. They enable real-time percentage updates of the value of collateral used to secure the loan, and allow for liquidation to kick in accurately.

Multiple oracles ensure we have accurate data

Oracle Network

The Constant oracle network consists of a number of circles. Each circle contains a number of oracles. Oracles within a circle work together to report on a piece of data (i.e. the current price of Bitcoin or Ethereum). An oracle can join and leave a circle as it wishes.

Oracle circles

Each circle contains the following fields:

  • The sources of data
  • The size of the circle (i.e. number of oracles)
  • The reduction method: mean, median, or mode

Oracles combine to provide important data to the Constant platform

Reduction Method: Median

An oracle Oi has the following fields:

Vi is the value provided by Oi

Ti is the timestamp of the last update from oracle Oi

Wi is the number of times Oi submits wrong values

Q is the quorum (initially, 10 oracles)

T is the valid timestamp range (initially, 10 seconds)

W is the maximum number of times an oracle could be wrong (initially, 2)

e is the acceptable error margin, |Vi — Vj| < e then Vi = Vj

The value V is the median of the set S = { V1, V2, …, VN }, where

  • |S| > Q
  • now() — Ti < T
  • Wi < W

Let Scorrect be the set of values between the 25th and 75th percentile. An oracle Oi whose value is not in Scorrect is considered a wrongly submitted value (hence their wrong score Wi), and will have 1 added to it.

Add/Remove Oracle

Initially new oracles are added by the Constant core team. While this is somewhat centralized, it’s critical to keep the data feed accurate. Current solutions are simple and straightforward, designed to avoid Sybil attacks. In the future, we may replace this with a more decentralized solution.

An oracle Oi is immediately removed from the network if Wi > W, or if it is voted out by the board.

Incentive / Payout

The incentives are structured around base payouts and commissions:

B is base payout per update, set by the Constant team

C is commission payout per update, set by the Constant team

Pi is total payout Oi, paid per update

The payout for Oi ∈ Scorrect is:

Pi = B + C * | Δ — 2 * (Vi — V) | / Δ

Δ = | V25% — V75% |

Fees

Matching fees

Constant charges service fees for matching borrowers with investors. The current fees are 1% for borrowers, and 0% for investors.

Deposit & Withdrawal fees

Most deposits and withdrawals are free. We charge minimum fees for fiat deposits and withdrawals, to cover operational costs incurred by working with the banking industry.

Bank wire transfers continue to be the most expensive method of transferring money

Risks & outstanding issues

There are many risks involved in operating a decentralized finance product.

User fund security

Many financial products have failed due to poor security implementation, resulting in lost user funds. Our team mitigates the security risks in these ways:

  • Fiat currencies are held in FDIC-insured trust accounts insured up to $130M.
  • The collateral is held in Ethereum smart contracts that securely lock the assets.
  • Users have the option to store their collateral with our independent crypto custodian partner that offers up to $100M in insurance.

Dissolvement of Constant

Many financial platforms have failed and caused losses for their users. Constant protects users In the unlikely event that the team is dissolved; the technology it is built on ensures users’ funds remain protected and the loan contract runs as programmed.

No smart contract support for BTC

While most Constant loans are backed by smart contracts, BTC-collateralized loans are not, simply because Bitcoin doesn’t have a smart contract language. Our team mitigates the security risks in the following ways:

  • Use an independent party to manage the BTC collateral such as BitGo or PrimeTrust.
  • Implement a 2-out-of-3 multisig BTC address to manage the collateral (under active research and prototyping).

Constant is designed to protect both investors and borrowers.

For investors, if borrowers default, collateral is sold to refund the investor. If collateral falls in value, it is sold at a threshold. It’s all automated by an unstoppable smart contract — investors will always get their principal and their profit.

For borrowers, borrower collateral is stored safely in a smart contract escrow, powered by the Ethereum network. This runs exactly as programmed, independent from human intervention — no one can touch these assets. As long as borrowers repay, they will always get their collateral back.

We hope that Constant will be helpful to a lot of people.

<a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a>