Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0
Why this matters
In lending_pool/src/lib.rs, the MaxPoolSize cap in deposit is enforced against TotalDeposits, but redeem_shares decrements TotalDeposits by assets_to_return (principal + yield) using saturating_sub, so after withdrawals that include yield, TotalDeposits can saturate to 0 or understate principal, corrupting the cap. DepositorCount is incremented only when existing_shares == 0 but a partial withdrawal that leaves remaining > 0 keeps the depositor, while a full withdrawal decrements via saturating_sub(1); combined re-deposits/withdrawals can desync the count.
Acceptance criteria
Files to touch
Out of scope
- Per-depositor cost-basis tracking
- Cap policy redesign
Why this matters
In lending_pool/src/lib.rs, the MaxPoolSize cap in deposit is enforced against TotalDeposits, but redeem_shares decrements TotalDeposits by assets_to_return (principal + yield) using saturating_sub, so after withdrawals that include yield, TotalDeposits can saturate to 0 or understate principal, corrupting the cap. DepositorCount is incremented only when existing_shares == 0 but a partial withdrawal that leaves remaining > 0 keeps the depositor, while a full withdrawal decrements via saturating_sub(1); combined re-deposits/withdrawals can desync the count.
Acceptance criteria
Files to touch
Out of scope