LarzLend — Overcollateralized Lending, Built in Larzscript
Borrow against collateral, and watch your health factor fall as interest accrues. Cross a threshold, and anyone — not just a registered lender — can step in and liquidate you.
What LarzLend actually does
A lender supplies real money into a shared pool. A borrower opens a loan against collateral at a minimum collateralization ratio, and interest accrues purely from elapsed wall-clock time. If the loan's health factor (collateral over what's owed) ever falls below the liquidation threshold, liquidate becomes callable — by anyone, not a pre-registered party to the loan. The caller pays off the debt and receives the collateral in return.
Every line below is the real output of sh examples/demo.sh against the actual interpreter — re-run fresh for this page, not copied from documentation. alice opens two loans at the same rate, one right at the minimum.
larzscript bin/larzlend.lz open-loan alice 150 100 --rate=0.1 larzscript bin/larzlend.lz open-loan alice 1000 100 --rate=0.1 larzscript bin/larzlend.lz health 2c1f72cd larzscript bin/larzlend.lz health 49feb11c
loan 2c1f72cd $100 borrowed by alice against $150 collateral loan 49feb11c $100 borrowed by alice against $1000 collateral loan 2c1f72cd: collateral $150, owed $170, health factor 0.88 (liquidatable) loan 49feb11c: collateral $1000, owed $160, health factor 6.25
Same rate, same elapsed time — the thin loan's health factor has already crossed below 1.0, the heavily collateralized one barely moved.
larzscript bin/larzlend.lz liquidate 49feb11c carol larzscript bin/larzlend.lz liquidate 2c1f72cd carol larzscript bin/larzlend.lz balance carol
error: loan is healthy - cannot liquidate (line 157) loan 2c1f72cd liquidated by carol - debt cleared, $150 collateral seized carol: $980
carol has never lent or borrowed a cent here — require health_factor(loan) < threshold is the entire access-control model for her, not a check on some pre-existing relationship. The healthy loan correctly refuses her; the thin one doesn't. Worth being honest about the numbers too: carol pays off $170 of debt and receives $150 of collateral — a real $20 loss in this run, because interest had already eaten past her margin by the time she acted. Liquidation here rewards speed, not patience, exactly the incentive that keeps real lending protocols from accumulating bad debt.
Why it matters
Every other flagship project's require gates a single transaction between known parties. LarzLend's gates an ongoing, time-driven condition against a total stranger — the third distinct shape require takes across this series, after LarzBank's overdraft check and LarzCrowd's escrow-drains-to-zero closure. Same keyword from the course's error-handling lesson, three very different jobs.