Loans (MaxyLock) / Build with it
Wallets and lenders
For teams that run the loan themselves, without the SDK: a wallet taking a borrower through it, and a lender serving it.
Wallet integration
A wallet needs a host-chain RPC and a Bitcoin node or indexer that returns raw transactions, headers and Merkle branches.
- 01 Terms. Exchange keys and hashes, agree amounts, and build each tranche's script from its hash, lock time and both keys. The contract cannot check a script's branches, so both parties must.
- 02 Sign. EIP-712 over
LoanTerms. - 03 Fund. One transaction, one output per tranche, exact amounts.
- 04 Prove.
submitFundingProof, naming which output pays which tranche. - 05 Claim.
claimPayout. - 06 Repay.
repayTranche, then watch forSecretRevealed. - 07 Spend. Broadcast the hash-lock spend promptly, before the lender's lock opens.
If the reveal deadline passes with no secret, call triggerGhostLiquidation and watch the settler.
Run a watcher: many calls are open to anyone, and a party that is offline at the wrong moment loses by it.
Every field, signature, event and revert reason: MaxyLock documentation (PDF).
Lender operations
In Maxy's loans, Maxy does this. If you lend, you need three credentials on separate systems.
| Credential | Does | If lost or stolen |
|---|---|---|
| Host-chain key | Commits, reveals, claims | An attacker can claim the ledger balance |
| Bitcoin sweep key | Sweeps defaulted and interest tranches | An attacker can sweep tranches whose lock opened |
| Secret store | Holds each tranche's secret | Losing a secret costs as much as theft |
Your duties.
- Reveal at once on every
TrancheRepaid. This is the duty that costs you if missed. - Prove funding when it reaches its confirmations.
- Sweep defaulted and interest tranches after their locks.
- Finalize after
verificationDeadlineif a tranche is stillPending.
Use a fresh Bitcoin key and a fresh script for every loan. Never reuse a script hash.
Alert on.
- An
Escrowedtranche with noSecretRevealedsoon after repayment. - A confirmed funding transaction with no
TrancheVerified. - A tranche near its last safe repayment time.
- The verifier falling more than a few blocks behind Bitcoin.