Borrowing and Lending - AtomicLoans/atomicloans-rfc GitHub Wiki
Borrowing and Lending is done on Atomic Loans using the Funds.sol, Loans.sol and Sales.sol contracts.
- Bob starts lending by creating a Loan
Fundanddepositing stablecoins tokens - Alice requests a loan by providing proof of funds to the agent of Bob, as well as their secret hashes and Bitcoin public key
- Bob's agent requests a loan on behalf of the borrower by calling
Funds.request. This moves the stablecoin tokens to theLoanscontract, and creates a newLoan. - Alice locks her Bitcoin into the Bitcoin Collateral script
- Once the Bitcoin transaction has at least 1 confirmation, Bob calls
Loan.approveto approve the locking of the collateral - Alice calls
Loans.withdrawand revealsSecret Ato receive stablecoin tokens. - Alice maintains her collateralization ratio for the duration of the loan, ensuring that the loan doesn't get liquidated by calling
Loans.repayfor partial repayments when necessary - Before the end of the loan period, Alice calls
Loans.repayto repay the entire principal + interest owed in the loan. - Bob accepts the repayment by calling
Loans.acceptand revealingSecret B
If Bob fails to approve locking of the collateral
- Bob or Carol can cancel the loan by calling
Loans.cancelwhich will revealSecret BorSecret Cnecessary for unlocking the collateral
If Bob or Carol fails to accept the repayment of the loan
- Alice can call
Loans.refundto refund the repaid loan amount. Liquidation cannot occur, so instead Alice will simply receive the refundable collateral.
If Alice fails to maintain the minimum collateralization ratio
- Dave can call
Loans.liquidateto start the Liquidation process