Commit e6dd8b2
committed
address review: wire record_yield into repayment path; CEI + invariant guard
Once share value tracks TotalManagedAssets instead of the raw balance, loan
interest transferred into the pool no longer reaches LPs automatically. Wire it
up:
- lending_pool: add a per-token authorized yield reporter
(set_loan_manager/get_loan_manager, admin-gated, emits LoanManagerUpdated) and
gate record_yield to that reporter, falling back to admin when unset.
- loan_manager: report the interest + late-fee portion of a repayment and the
extension fee as yield via record_yield. Best-effort and non-fatal (only when
configured as the pool's reporter; pool-side errors are swallowed) so it can
never block a repayment. liquidate is intentionally left unwired and
documented, since recovered interest needs a paired principal write-off
(record_loss) to avoid inflating share value during a loss event.
Review nits:
- calc_shares_to_mint documents the managed-assets-positive invariant with a
debug_assert instead of silently minting 1:1 when total_assets_before == 0.
- redeem_shares now commits all accounting before the token transfer (CEI).
Adds pool tests for reporter gating and end-to-end loan_manager tests proving
repaid interest reaches LP share value and that repayment still succeeds when no
reporter is configured.1 parent 720bef2 commit e6dd8b2
9 files changed
Lines changed: 6241 additions & 9 deletions
File tree
- lending_pool
- src
- test_snapshots/test
- loan_manager
- src
- test_snapshots/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| |||
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
| |||
231 | 245 | | |
232 | 246 | | |
233 | 247 | | |
234 | | - | |
| 248 | + | |
| 249 | + | |
235 | 250 | | |
236 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
237 | 262 | | |
238 | 263 | | |
239 | 264 | | |
| |||
319 | 344 | | |
320 | 345 | | |
321 | 346 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | 347 | | |
329 | 348 | | |
330 | 349 | | |
| |||
363 | 382 | | |
364 | 383 | | |
365 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
366 | 394 | | |
367 | 395 | | |
368 | 396 | | |
| |||
702 | 730 | | |
703 | 731 | | |
704 | 732 | | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
705 | 751 | | |
706 | 752 | | |
707 | 753 | | |
708 | 754 | | |
709 | 755 | | |
710 | 756 | | |
711 | | - | |
| 757 | + | |
712 | 758 | | |
713 | 759 | | |
714 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
715 | 765 | | |
716 | 766 | | |
717 | 767 | | |
718 | 768 | | |
719 | 769 | | |
720 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
721 | 776 | | |
722 | 777 | | |
723 | 778 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1683 | 1683 | | |
1684 | 1684 | | |
1685 | 1685 | | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
0 commit comments