Skip to content

Instantly share code, notes, and snippets.

@RubenSomsen
Last active May 2, 2022 13:10
Show Gist options
  • Save RubenSomsen/bf08664b3d174551ab7361ffb835fcef to your computer and use it in GitHub Desktop.
Save RubenSomsen/bf08664b3d174551ab7361ffb835fcef to your computer and use it in GitHub Desktop.
P2P Loans on Liquid

Liquid P2P Loans

This is a variation of the Hodl Hodl contract design for Liquid, but without an arbitrator (not counting Liquid itself). It's pretty simple and similar ideas exist, but it seemed interesting enough to write up and spur some conversation.

I'll begin by explaining the high level concept. For the full details, please examine the steps in the diagram below.

Concept

A contract where the Borrower puts up 1.5x collateral (e.g. 1.5 L-BTC) in order to borrow another asset (e.g. $10k USDT, if we assume that's the price of 1 L-BTC). The borrower can reclaim the collateral if they pay back the loan before expiry. If expiry is reached, the collateral goes to the Lender.

Use cases

  • Spending L-BTC without necessarily selling, which may trigger a taxable event in some regions
  • Leveraging your L-BTC position by buying more L-BTC with the USDT you borrowed

Risks

  • Borrower loses the collateral (likely to be overvalued) if they fail to repay the loan
  • Lender loses money if the collateral is no longer worth enough to cover the loan at expiry

The Lender's risk can be minimized by increasing the collateral. The Borrower's risk can be minimized by creating multiple "Repay Loan" transactions (see diagram) which pay back to a multisig with a potential buyer of the collateral. This way the Borrower can agree to give part of the collateral to the potential buyer, provided they pay back the loan in their stead. The same agreement could be made with the Lender, but they may not be willing to cooperate, as they'll receive the full collateral if the Borrower fails to pay.

Market Place

This concept still needs a market place where the Lender and Borrower can find each other. At a minimum, a contract can be achieved in 3 communication rounds:

  • Borrower makes an offer (e.g. revealing a 1.5 L-BTC UTXO for $10k USDT)
  • Lender takes it and signs "Initiate Loan" and "Repay Loan" (see diagram) (We forego the "Forfeit Collateral" tx in favor of having the "Initiate Loan" tx contain a timelocked script, saving a communication round)
  • Borrower signs "Initiate Loan" and sends it to the blockchain

-- Ruben Somsen

See also my other work.

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kukks
Copy link

Kukks commented Jun 1, 2021

Have you seen the research paper from Dmitry also on Liquid loans? https://ruggedbytes.com/articles/ll/

@RubenSomsen
Copy link
Author

@Kukks thanks for the link, yup, it's actually linked in this write-up in the top paragraph: "similar ideas exist"

His method is ultimately more powerful, because covenants can do more than these relatively straight-forward payment conditions, but this one's more simple to implement and results in smaller transactions.

@Kukks
Copy link

Kukks commented Jun 1, 2021

@Kukks thanks for the link, yup, it's actually linked in this write-up in the top paragraph: "similar ideas exist"

His method is ultimately more powerful, because covenants can do more than these relatively straight-forward payment conditions, but this one's more simple to implement and results in smaller transactions.

Doh, missed the link!
Let me try this again:
Have you seen this implementation:

Dmitry also has some additional sketches around the loans concept in his gist profile which are quite interesting:
https://gist.github.com/dgpv

@RubenSomsen
Copy link
Author

@Kukks I had seen a few of the sketches, but not the other links. Nice.

Generally speaking covenant stuff like this is quite interesting and powerful. Really cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment