Code Monkey home page Code Monkey logo

blend's Introduction

blend

a p2p borrowing and lending protocol

motivation

there should be a transparent system for borrowers and lenders to find each other and make deals. the bitcoin ecosystem currently wants this because many skilled lightning node runners can earn good yield, but lack access to capital. but the protocol should extend to any type of bilateral borrowing/lending arrangement in any currency.

how it works: messages, trust, and reputation

messages are published using the nostr protocol. nostr relays gather the messages and present them to users. anybody can be a nostr relay and it is expected that several different websites emerge, each run by a different relay, each with a different style. for example some relays may be free and broadcast every request, whereas others may be more selective and only broadcast requests from borrowers who pay a fee.

each message should have one of the following types: 61 (OPEN_REQUEST), 62 (COMMENT) or CANCEL_REQUEST (kind 5 deletion event on the OPEN_REQUEST event) (more to be added!).

basic flow:

  • potential borrower publishes an OPEN_REQUEST stating their terms (this can be public or privately sent to select individuals)
  • other users can publish an COMMENT message rating the quality of other users or the quality of their particular debt offerings
  • potential lender contacts borrower (can be through nostr-native private encrypted messaging or email or telegram or anything)
  • potential borrower publishes a CANCEL_REQUEST to take down their listing
  • everything else is coordinated privately between lender and borrow, and they can publish public positive or negative COMMENT messages about the other one at any time. it is expected that standards will emerge where the borrower and lender request signatures from each other attesting to the terms of the deal.

OPEN_REQUEST

a potential borrower will submit a message of type OPEN_REQUEST that will look something like this:

{
    "kind": 61,
    "pubkey": "a10e7cb8f5aac7e6a50864af1b2c2cddcb3bbeb939b104d22b68f711c34f9f8f",
    "created_at": 1665704942,
    "tags": [],
    "content": "{\"comment\":\"Requesting 1 on-chain BTC, will pay back 1.004611 BTC in 3 weeks (5% APY)\"}",
    "signature": "d7e4ca6dd2903ff8f66ec533533258f54d350a0140468cae33fe6f48bca2b727..."
}

or this:

{
    "kind": 61,
    "pubkey": "4030592727c7b1806f40bdce9ddefe12741e7a3efb6c58f65707bee4bcc751c0",
    "created_at": 1665704952,
    "tags": [],
    "content": "{\"comment\":\"Requesting $100 paid via Cash App, will pay back $105 in 2 days.\",\"contact\":{\"telegram\":\"gambling_addict_69\"}}",
    "signature": "8ce21deff1554b86a901454286b1ec15c98785edbf99e817584abc30422d4293"
}

COMMENT

comments are the backbone of the trust model, as everything is based on reputations. it is expected that publicly known people and/or trusted companies will become credit rating agencies that rate the quality of borrowers.

a comment may look something like this:

{
    "type": 62,
    "pubkey": "48a0d69fbfeb990c3eba98dbd567203126850cda38a693c6ba5cf44fd971176c",
    "tags": [
        ["p", "a10e7cb8f5aac7e6a50864af1b2c2cddcb3bbeb939b104d22b68f711c34f9f8f"]
    ],
    "content": "{\"comment\":\"I had a good experience lending to this person. Their recent debt offering of 1 BTC for 5% APY in 3 weeks is very low risk\",\"rating\":1}",
    "created_at": 1665705232,
    "signature": "18f7218ca412493e4f78f9248e5467141ae243c327a900aeea615ee7b0acb748..."
}

or this:

{
    "type": 62,
    "pubkey": "48a0d69fbfeb990c3eba98dbd567203126850cda38a693c6ba5cf44fd971176c",
    "tags": [
        ["p", "4030592727c7b1806f40bdce9ddefe12741e7a3efb6c58f65707bee4bcc751c0"]
    ],
    "content": "{\"comment\":\"I've never seen this person before and it looks like they are a degenerate gambler. very high risk, do not recommend engaging with them.\",\"rating\":-1}",
    "created_at": 1665705272,
    "signature": "98ea8f65be00cab6d09274c22520b4496ef3a04ff98d52e130c9299af23981f9..."
}

CANCEL_REQUEST

A CANCEL_REQUEST is a kind 5 deletion event referencing a OPEN_REQUEST. This preserves the privacy of the borrower and the lender and signals this offer is no longer available. Only the borrower knows if the deal was accepted, and nobody knows who the lender is if there is one (unless they make a comment).

legal

this is very simply freedom of speech

TODO

hella fun stuff to do:

  • help poke holes in the protocol and make it better!
  • do we want some "blips" or something to make this into a real protocol (if that's even necessary)?
  • who wants to run the first relay?

blend's People

Contributors

dannydeezy avatar semisol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

22388o arealayer

blend's Issues

Some recommendations

  • If you want to be fully nostr compatible, you will need to do some changes
    • time should be replaced by created_at, and uses unix seconds instead of ms
    • public_key must be a 64 character public key according to BIP 340, and should be renamed to pubkey
    • signature must be a 128 character hex signature of the event, how it is generated is defined in NIP-01
    • message should be replaced by content
    • You cannot have properties like contact on the event itself, you can make content a stringified JSON object though.
    • You need to add a tags array, that may be empty or contain additional metadata. The current standard is one letter tags will get indexed, so you can look up any event with a specific tag value.
    • Kinds must be numbers, not strings.
  • Optional recommendations if you want to use nostr
    • CANCEL_REQUEST can be replaced by kind 5 events that will mark an event as "deleted" and may stop returning it in queries in some relays implementations, currently only nostr-rs-relay from my knowledge.

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.