Repayment
The borrower must repay the loan before the Maturity Time to avoid liquidation by the DCA.
Recall that during Loan Assignment, BTC collateral for the loan was locked into the Collateral Vault. One of the spending conditions are a 2-of-2 multi-sig UTXO where one side is the DCA, and the other side is the Borrower, with an aggregatable adaptor signature scheme, allowing a signature from the Borrower to publicly reveal a repayment_secret
.
Assuming the loan is denominated in USDC, the borrower must submit a transaction to the Lending Contract on the Side Chain that includes:
A USDC transfer from the Borrower to the Lending Contract to repay the loan principal and interest.
A partially signed Bitcoin transaction to withdraw the BTC collateral
The repaid USDC funds are secured in a Repayment Escrow on the Side Chain, using a hash of a randomly generated repayment_secret
from the borrower. Anyone who provides the pre-image of this hash can transfer the funds from the Repayment Escrow back to the liquidity pool.
The USDC repayment is subject to a timelock (e.g., 24 hours). If the loan repayment is not completed before the timelock expires, the transaction will be automatically canceled, and the funds will be returned to the Borrower.
The Lending Contract verifies the repayment and produces a SignRequest. The DCA then fetches and partially signs the adaptor signature of the Bitcoin transaction and submits it to the Lending Contract. The contract aggregates these partial signatures from both the borrower and the DCA into an aggregated signature.
The borrower can adapt the withdrawal signature from the aggregated adaptor signature with their repayment_secret
and broadcast the withdrawal signature on the Bitcoin chain to reclaim their BTC collateral.
Once the signature is broadcast on Bitcoin, anyone can extract the repayment_secret
from the Bitcoin collateral withdrawal to move funds from the Repayment Escrow to the liquidity pool. This is then verified by the contract:
Last updated