Giter Site home page Giter Site logo

decentralized-mortgage-market's Introduction

Build Status

Decentralized Mortgage Market

This project implements a decentralized mortgage market where home buyers and banks can meet and negotiate mortgage agreements, and banks can sell pieces of these mortgages to investors. In turn, investors can also resell their investment to other investors. This market is completely decentralized, is blockchain-regulated and runs on Dispersy, a messaging platform.

Peer discovery

The decentralized mortgage market uses Dispersy for peer discovery (see ReadTheDocs). Upon finding a new peer, it exchanges its public key, its role in the network (i.e., home buyer, bank, investor), and information regarding its real world identity (e.g., name). For a few banks their public keys are hard-coded in the software. However, in future versions we plan to give the user the opportunity to provide their own public keys (which the user could find on a bank's website, for instance).

Contracts

Every agreement reached in the market, is recorded in a double-signed contract. We currently distinguish between three types of contracts:

  • Mortgage contracts represent the original agreement between the home buyer and the bank.
  • Investment contracts represent the part of the mortgage that is sold to an investor.
  • Promise-to-buy contracts record the promise between buyer and seller to transfer ownership of an investment in exchange for some monetary payment.
  • Payment confirmation contracts record the confirmation of payment, and must be linked to a promise-to-buy contract. Unlike other contracts, this contract does not record an agreement between two parties, but merely confirms an event.

Agreements

Before creating a contract, an agreement must be made about its contents. For instance, a mortgage contract would include the address of the underlying collateral.

Generally speaking, agreements are made using the following basic scheme:

Contract chain

Depending on the type of agreement peers A and B are:

Agreement type peer A peer B
Mortgage home buyer bank
Investment bank* investor
Promise-to-buy investor* investor

(* means the first message is broadcasted)

Signatures

Once an agreement is made either party creates a contract, signs it by appending an Ed25519 signature, and offers it to other party for signing.

Dependencies

With the exception of mortgage contracts, all contracts must have a single dependency. Investment contracts must depend on mortgage contracts, promise-to-buy contracts must depend on investment contracts, and payment confirmation contracts must depend on promise-to-buy contracts (see the figure below for an example).

Contract chain

Blockchain

Right after a contract has been signed, both parties multicast the contract to the banks. The banks, in turn, are tasked with storing these contracts on a the blockchain. To this end, banks keep a list of incoming contracts in memory. Periodically, banks will try to create a new block of contracts. Contracts are only selected to be in a block if all their dependencies have already been selected.

Block creation is only considered successful if it meets a certain target difficulty. Once a bank successfully generates such a block, it multicast the block to the other banks. For the next block, the difficulty will automatically re-target to achieve a predefined average block creation interval (currently set to 3 minutes).

Besides meeting the target difficulty, blocks have to satisfy several other requirements. For instance, banks are required to timestamp and sign their blocks. Additionally, they need to be in the possession of some kind of minimum value on the network (proof-of-stake), making Sybil attacks overly costly.

While extended branches should be rare, the market is able to cope with such issues by always choosing the longest chain of blocks as the winning chain.

The market does not offer any kind of monetary incentive for creating blocks, instead banks will have to create blocks simply because they cannot risk a potential malicious bank from putting incorrect contracts on the blockchain.

For sake of simplicity, the current maximum size of a block is only 1472 bytes, a limit chosen such that blocks can fit in a single UDP packet without risking IP fragmentation.

Usage

usage: main.py [--help] [--dispersy DISPERSY] [--api API] [--state STATE]
               [--keypair KEYPAIR] (--bank | --investor | --borrower)

Run the MarketCommunity

optional arguments:
  --help, -h           Show this help message and exit
  --dispersy DISPERSY  Dispersy port
  --api API            API port
  --state STATE        State directory
  --keypair KEYPAIR    Keypair filename
  --bank               Run as bank
  --investor           Run as investor
  --borrower           Run as borrower

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.