Use Case
In the TV Show 'Succession', the media and entertainment conglomerate Waystar Royco (spoiler alert!) had a $2bn loan secured against the company's stock price. If their stock fell below $130USD a share they were effectively in breach of their debt covenant and their creditors were then able to legally pursue the repayment of the loan in full.
In the context of this example contract, the loan is secured against a BCH holding as collateral. The debt is tokenised via SLP tokens and held by one or more creditors (SLP token holders). If the BCH USD price fell below the agreed floor price then creditors can trustlessly initiate the repayment process without the need for an intermediary nor actions from the debtor.
Contract Features
- Calls a CashScript contract to validate the Debt ID used in the contract against the official ID stored onchain
- Uses Bitbox to retrieve and validate whether the BCH USD price has breached the convenant's floor price
- If 1 and 2 are true, it proceeds to loop through creditors holding the loan's tokenised debt (SLP token holders)
- It calculates repayment dividends based on token balances (i.e. share)
- It releases the BCH collateral by building a multi-output transaction and broadcasts to network
Future enhancements
- The CashScript contract is very minimalistic for now - will aim to move as much of the covenant logic into the CashScript contract where possible to ensure the calculations are performed on the network rather than client side. Will need CashScript to have arrays and limited looping functionalities at a minimum.
- Needs Mitra protocol upgrades (2-3 rounds away) for the repayments to be truely trustless.
- Develop a simple web front end for creditors to initiate a covenant audit, once CashScript browser support is available.
Getting Started
- Install Bitbox SDK
- Install SLP SDK
- Install Cashscript SDK 0.3.1 or above
- Install Memopress
- Create a few new addresses to represent creditors and send them shares of a SLP debt token (ideally with a circulating supply of 100)
- Fund a BCH collateral cashaddress and set the debt covenant parameters in Debt_Covenant.js
- Clone the repo and run the client logic in Debt_Covenant.js (you can perform contract registration steps manually as its easier for now)
git clone https://github.com/fifikobayashi/Debt-Covenant-Contract
cd Debt-Covenant-Contract
node Debt_Covenant.js