a big thanks to Phroi
In this use case, a user has x
CKB (or iCKB) and would like to borrow against it.
With this protocol, a trustless secured loan is created between lender and borrower.
Terms of Loan
The interest rate and loan term t
are agreed to before the loan is originated and the borrower can pay back the loan at any time (and would only pay interest on the actual term of the loan)
The loan is issued 1:1 with collateral provided by borrower (and to keep the agreement trustless, they lock up the entirety of the interest for the loan)
Loan transaction
The following arrangement should be created through a partially signed transaction between lender and borrower.
-
Borrower funds cell_0 with capacity
x
CKB
----spending conditions
-----spend_path0: after timelockt
lender can spend (cell_1 must also be included in spend to enforce timelock)
-----spend_path1: (at any time) borrower can spend to create a locked cell adding an arbitrary amount of CKB (similar to 2 phase DAO withdrawal) -
cell_1 is timelocked to
t
, to enforce term of loan -
lender funds cell_2, which contains (
x
- total loan interest) CKB, spendable by borrower immediately
Closing the Loan
If the term of the loan expires without repayment, the lender claims the collateral backing the loan + interest payments.
If the borrower pays back the loan, they will claim their collateral less applicable interest payments (in the 2nd transaction of the withdrawal flow) and the remaining balance will be spendable by the lender.
In the case of iCKB, a ratio of CKB to iCKB would implicitly be agreed to by the amount of CKB provided by the lender against the borrowerâs iCKB collateral