Commit f1dabd5
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 ff8e907 commit f1dabd5
11 files changed
Lines changed: 7153 additions & 235 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 | | |
| |||
242 | 256 | | |
243 | 257 | | |
244 | 258 | | |
245 | | - | |
| 259 | + | |
| 260 | + | |
246 | 261 | | |
247 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
248 | 273 | | |
249 | 274 | | |
250 | 275 | | |
| |||
342 | 367 | | |
343 | 368 | | |
344 | 369 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | 370 | | |
352 | 371 | | |
353 | 372 | | |
| |||
386 | 405 | | |
387 | 406 | | |
388 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
389 | 417 | | |
390 | 418 | | |
391 | 419 | | |
| |||
734 | 762 | | |
735 | 763 | | |
736 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
737 | 783 | | |
738 | 784 | | |
739 | 785 | | |
740 | 786 | | |
741 | 787 | | |
742 | 788 | | |
743 | | - | |
| 789 | + | |
744 | 790 | | |
745 | 791 | | |
746 | 792 | | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
747 | 797 | | |
748 | 798 | | |
749 | 799 | | |
750 | 800 | | |
751 | 801 | | |
752 | | - | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
753 | 808 | | |
754 | 809 | | |
755 | 810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1707 | 1707 | | |
1708 | 1708 | | |
1709 | 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 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
0 commit comments