Commit c67000f
committed
fix: address Lista Fixed Term audit findings on LendingBroker
LendingBroker
- Add repayAll(onBehalf) for full position clearing, gated by whenNotPaused.
- Replace global checkPositionsMeetsMinLoan with per-position validators
(_validateDynamicPosition, _validateFixedPosition); remove the post-cascade
global check from onMoolahLiquidate so partial liquidations no longer revert
when a single position lands in the (0, minLoan) band.
- Reject non-divisible repaidShares in liquidate() to preserve the broker
market's totalBorrowAssets:totalBorrowShares = 1:VIRTUAL_SHARES invariant.
- Re-check amount == 0 after interest/principal clamping in
convertDynamicToFixed to prevent zero-principal fixed positions when the
user has no dynamic debt.
- Add docstring notes that fixed-repay amount and liquidate caller-whitelist
/ cascade ordering match the actual behavior.
Size optimization
- Move repay / repayAll bodies into LendingBrokerOperatorLib (DELEGATECALL'd).
- Move liquidation cascade orchestration to BrokerMath.executeLiquidationCascade.
- Move repayAll / convertDynamicToFixed pre-compute math to BrokerMath helpers.
- Consolidate duplicate errors and dead helpers.
LendingBroker shrinks from 27,358 -> 22,462 bytes (back under EIP-170).
Addresses audit findings: H1 (loan-token price drift stranding positions),
M (positions stranded by minLoanValue change), M (liquidation cascade dead
zone revert), M (non-divisible share liquidation drift), Info (zero-principal
fixed via convert), Low (_validatePositions stricter than Moolah post-liq
check), Info (fixed-repay natspec), Info (liquidate natspec outdated).
Generated with Claude Code1 parent c8081f9 commit c67000f
6 files changed
Lines changed: 1113 additions & 437 deletions
File tree
- src/broker
- interfaces
- libraries
- test/broker
0 commit comments