Solana lending hooks · open source · Apache-2.0
Tie your loans.
Lien is a hook runtime for Marginfi v2, Kamino Lend, and Solend. Compose a knot of lifecycle handlers, install it on a pool, and let the on-chain executor enforce it on every deposit, borrow, repay, and liquidation.
- 6 / 6 hooks
- 47 / 47 tests
- Marginfi + Kamino + Solend
- Anchor 0.31
- Solana mainnet
Problem
Lending dApps already work. They just can't be told how to work.
Every operator wants their own rules. None of them want their own lending protocol. Today they have to pick one.
−18.4%
Avoidable liquidation
Marginfi, Kamino, and Solend treat LTV as static. When SOL whipsaws, healthy positions get reaped in the same block as broken ones. Operators have no way to tighten thresholds in real time.
$5.8M
MEV captured per quarter
Liquidation rewards on Solana are first-come-first-served. Searchers consistently frontrun the operator-aligned liquidators that fund recovery on bad debt.
0 / 3
Pools with KYC isolation
Institutional credit needs allowlisted borrowers. Today the only path is to fork the lending program — which forks the audit, the bug bounty, and the integrations too.
manual
Risk-off cycle response
Hedging a collateral basket against a drawdown means writing one-off bots. Each pool builds the same plumbing again from scratch.
Solution
One knot, many lifecycle points.
The hook runtime sits between the lending program and the user. It doesn't fork the protocol — it ties onto it.
- 01
Event
Marginfi, Kamino, or Solend CPI-calls the executor at any of eight lifecycle points.
- 02
Composition
The pool's installed knot — up to eight hooks in priority order — runs against the event.
- 03
Decision
Each hook returns Accept, Accept-with-side-effect, or Reject. Side-effects accumulate; a single Reject halts the lifecycle.
- 04
Apply
The adapter consumes the side-effects: override max LTV, override rate, delay liquidation, emit a Drift short, etc.
Library
Six standard knots. Eight slots per pool.
Every operator starts here. Publish your own to the marketplace, or stick with the canon — every standard hook is audited and Apache-2.0 licensed.
DynamicLTV
slipTightens max LTV as realised volatility climbs.
- base ltv75.00%
- vol floor1000 bps
- min ltv25.00%
fires on beforeBorrow · afterDeposit
TimeTriggerLiq
timer hitchBounds liquidations to operator windows; delays under stale oracle.
- window10:00–18:00 UTC
- max oracle age500 slots
- delay300 slots
fires on beforeLiquidate
WhitelistBorrow
lockRestricts new debt to a registered allowlist.
- gate typestatic pda
- rotationoff-chain signer
fires on beforeBorrow
AntiMEVLiq
double bowlineDelays liquidations and (optionally) reserves them for keepers.
- min delay3 slots
- keepersregistered set
fires on beforeLiquidate
AutoHedge
double helixOpens a Drift perp short when collateral crosses a trigger band.
- ratio50.00%
- trigger−12% from spot
- venuedrift-v2
fires on afterBorrow · afterDeposit
ReputationRate
rolling hitchDiscounts borrow rate against on-chain repayment reputation.
- base rate12.00%
- max discount6.00%
- lookback180 days
fires on beforeBorrow
Backtests
What the workshop produced last quarter.
Replays against archive node data, executed inside the Lien simulator with the same decision tree the on-chain executor would run.
SOL-USDC (Marginfi)
DynamicLTV + AntiMEVLiq
Mar 1 — Apr 1, 2026
- Liquidations vs baseline−31%
- MEV captured by ops keepers+$182k
- Max LTV at peak vol55%
JitoSOL-mSOL (Kamino)
DynamicLTV + AutoHedge
Feb 14 — Mar 14, 2026
- Realised drawdown−18%
- Hedge fills via Drift412
- Operator net rate APY9.8%
USDC institutional (Solend)
WhitelistBorrow + ReputationRate
Q1 2026
- Borrower default rate0.0%
- Average APR delta−2.4%
- Approved borrowers84
Token
$LIEN sits behind every knot.
The token bonds builders, operators, and keepers to the same workshop. Fees flow in. Stake flows out. Reputation accrues on-chain.
CA published at launch.
Execution fee · 50% buyback-burn
Every hook the executor runs charges a per-call fee. Half routes to a Jupiter buyback and burn of $LIEN.
Premium hook templates
Advanced AntiMEV, KYC, and AutoHedge templates are stakable — they unlock when an operator parks $LIEN against the pool.
Publisher revenue share
Hook publishers earn a share of subscription fees in $LIEN. Authors set their own terms in the marketplace listing.
Keeper rewards
Liquidation rewards routed through AntiMEVLiq compose with $LIEN emissions for registered keepers.
Start tying
Pick a knot. Install it on a pool. Watch the executor pull the rope.
The designer is browser-only. The executor is on Solana mainnet. The CLI and the VS Code extension are npm i -g lien-cli away.