Trustless Token Collateralized Bitcoin Cash Loans

@im_uname, 20191229, with inputs from @emergent_reasons and Jonathan Silverblood

Disclaimer: This writeup is a crude description of the idea, and should not be taken as a complete draft description nor a specification ready to be implemented.

The installment part of this writeup is heavily inspired by Karol Trzeszczkowski’s excellent Last Will and Mecenas contracts.

Motivation

Generally speaking, a collateralized loan involves a borrower putting up a valuable, less liquid, less fungible asset to borrow a more liquid, more fungible asset that is easier to use in commerce. In a fiat-denominated mortgage, for example, the borrower puts up a house, a highly valuable yet difficult to liquidate asset, in exchange for dollars. The lender gets interest, and the borrower gets additional utility from capital otherwise locked up in their house.

Failure to repay the loan results in the collateral being seized by the lender. Asset seizure is backed by law enforcement.

In Bitcoin Cash, it is possible to construct smart contract loans collateralized by SimpleLedger (SLP) tokens representing illiquid or less fungible assets, and borrow Bitcoin Cash, which is by far the most liquid and widely accepted asset on the BCH chain. These contracts will retain the basic characteristics of traditional loans, with some key differences. Such a contract can be constructed between any two party who agree without the need for notarization or enforcement by a third party. Enforcement of these contracts is via Bitcoin Script and can be executed by anyone, whether the participating parties or service provider, with no risk of theft.

Components

A basic contract can be constructed between just a borrower and a lender. The borrower should have a valuable asset, tokenized in SLP, that is relatively difficult to liquidate, or provide non-fungible value that is difficult to retain by exchanging into and out of more fungible assets. The lender should have liquid Bitcoin Cash that can be lent for duration of the contract. The amount of BCH lent should be less than the expected value of the collateral, with a difference sufficient to account for expected price volatility of both BCH and the collateral asset.

Contract Description

Two types of contracts are possible.

The simple case is a single-payment contract: The entirety of the loan is repaid and collateral redeemed at or before the end of the contract. Failure to pay in full before the end of the contract results in the tokenized asset becoming seizable by the lender. This is similar to a traditional pawn shop.

A more complex case is a contract that is paid in parts over the contract’s lifetime, with the the final transaction returning the tokenized asset to the borrower. Any overdue installments will result in the asset becoming seizable by the lender.

"Pawn shop" Single-payment Contract

The borrower and lender should fund the contract in one transaction to retain atomicity. In the transaction, the lender passes the agreed upon amount of BCH to the borrower. The borrower transfers their tokenized asset to a P2SH address in the same transaction.

Pseudocode of the P2SH script as follows:

contract singleloan()
{
    challenge repayment()
    {
        Verify that an op_return output is present and
        transfers asset to a predetermined borrower address.

        Verify that a repayment output is present and
        transfers sufficient BCH to a predetermined lender address.
    }

    challenge overdue()
    {
        Verify that the transaction has locktime beyond a
        predetermined blockheight or median time past.

        Verify that an op_return output is present and
        transfers asset to a predetermined lender address.
     }
}

"Mortgage" Installment Contract

Initial construction of the loan should be the same as the single-payment case. Rather than a single P2SH address, this uses a series of pre-calculated P2SH addresses, one for each payment. The series of addresses should be pre-constructed with each repayment amount pre-determined. Additionally, seizures due to overdue payments should require the lender to return some amount of equity accumulated thus far, with possible penalties agreed beforehand.

Pseudocode of installment scripts as follows:

contract installment()
{
    challenge repayment()
    {
        Verify that an op_return output is present and
        transfers asset to the predetermined next installment P2SH address.

        Verify that an installment output is present and
        transfers sufficient BCH to a predetermined lender address.
    }

    challenge overdue()
    {
        Verify that the transaction has locktime beyond a
        predetermined blockheight or median time past.

        Verify that an op_return output is present and
        transfers asset to a predetermined lender address.

        Verify that partial repayment output is present and
        transfers sufficient BCH to a predetermined borrower address.
     }
}

The final installment enforces return of the asset to the borrower.

Ecosystem Requirements

In order to have widespread impact, two things need to be present in significant amounts on the Bitcoin Cash chain:

  1. Bitcoin Cash itself needs to be sufficiently liquid, available, and widely adopted in order to serve as an attractive denomination for loans.

  2. Lower-liquidity or less fungible yet sufficiently valuable assets need to be present, tokenized via SLP, and have their value recognized by enough lenders for a viable market. The NFT1 standard is ideal for this purpose.

Ecosystem impact

Availability of a trustless loan market is expected to both increase demand and utility of Bitcoin Cash, as well as increase the attractiveness of tokenizing assets with SLP.

Edit: This writeup was also cross-posted to honestcash and readcash .