freecoding.school100% FREE · NO SIGNUP
Yield OceanISSUE #11 of 34

interest rate models · utilization curves

Liquidity LuVSThe Sandwich Bot
Liquidity Lu saysLending rate models map utilization (borrowed / supplied) to APR — flat below a kink, steep above, pushing utilization back toward the target by repricing borrows.

Lending markets need rate dynamics that keep liquidity. A typical kinked interest rate model has two slopes: gentle below a target kink utilization (e.g., 80%), and steep above. At low utilization, rates are barely above base; above the kink they spike, pushing borrowers to repay and lenders to deposit, restoring liquidity.

The demo computes borrow APR at five utilization levels and shows the slope discontinuity at the kink.

Power-ups you unlock

The Sandwich Bot attacks — common mistakes

Boss battleCompute borrow APR at utilization 20%, 50%, 80%, 90%, and 95% with base=2%, slope1=4%, slope2=75%, kink=80%.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>
const BASE = 0.02, SLOPE1 = 0.04, SLOPE2 = 0.75, KINK = 0.80;
function borrowAPR(u){
  if(u <= KINK) return BASE + (u / KINK) * SLOPE1;
  return BASE + SLOPE1 + ((u - KINK) / (1 - KINK)) * SLOPE2;
}
const rows = [0.20, 0.50, 0.80, 0.90, 0.95].map(u =>
  '  U=' + String(Math.round(u*100)).padStart(3) + '%  → borrow APR ' + (borrowAPR(u)*100).toFixed(2) + '%'
);
document.getElementById('o').textContent = [
  'kinked interest model (base=2%, slope1=4%, slope2=75%, kink=80%):',
  '',
  ...rows,
  '',
  'gentle slope below 80% utilization, steep above to push U back down'
].join('\n');
</script></body></html>
▶ Open the interactive comic issue
‹ Liquidations · Health Factor · KeepersFlash Loans · Atomic Uncollateralized Credit ›