Skip to content

feat: restrict active-loan withdrawals to cumulative lender allocations - #85

Open
microHoffman wants to merge 3 commits into
v1.5-deployment-changesfrom
v1.5-withdraw-restriction
Open

feat: restrict active-loan withdrawals to cumulative lender allocations#85
microHoffman wants to merge 3 commits into
v1.5-deployment-changesfrom
v1.5-withdraw-restriction

Conversation

@microHoffman

@microHoffman microHoffman commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

An active-loan lender can withdraw only cash allocated to their shares. The original per-call proportional cap could be bypassed: with 100 shares and 20 cash, a 25-share lender could withdraw 5, then immediately withdraw another ~3.158. The vault now records and consumes each owner's allocation, so the second withdrawal is unavailable until more cash is received or an unclaimed allocation is transferred to them.

  • Allocate unused capital, repayments, and direct donations proportionally to current shares when new cash is observed. Previously allocated cash is excluded from later distributions.
  • Debit the same owner allocation for withdrawals and redemptions, while retaining the cap imposed by the shares' asset value. Share transfers carry the proportional unclaimed allocation; delegated withdrawals charge the share owner.
  • Protect allocation updates with OpenZeppelin ReentrancyGuard and PWNLoan's settlement lock so callbacks cannot count principal before it leaves the vault or redeem before repayment arrives.
  • Preserve normal redemption of remaining cash and collateral after repayment or default. Fractional allocation dust remains in the vault and is included in ending-stage redemption.

Aave behavior matches v1.5-deployment-changes: deposits are supplied during pooling, all Aave assets are withdrawn at loan creation, and unused capital and repayments remain vault cash during the loan. The extra running/ending Aave supply and withdrawal logic and the unrelated stable-product fixture change have been removed from the PR diff.

Validation:

  • Full unit suite: 567 passed, including 81 vault tests.
  • Two real-token fuzz tests passed 256 runs each, covering repeated withdrawals/redemptions/transfers and repayment allocation.
  • Local vault fork suite: 21 passed using an alternate public Ethereum RPC with --threads 1 --compute-units-per-second 30. Includes Aave unavailable after funding, interest accrual, proportional withdrawal/redemption, and full repayment/default lifecycles.
  • GitHub CI: all 567 unit tests passed; five fork-suite setups failed because the configured PublicNode endpoint returned HTTP 403 requiring an archive token. CI run.
  • Second Standards and Spec/security review found no additional actionable issue after the fixes.

@microHoffman microHoffman self-assigned this Jan 28, 2026
@microHoffman
microHoffman changed the base branch from v1.5-updates to v1.5-deployment-changes February 9, 2026 13:26
@microHoffman microHoffman changed the title feat: add withdraw restriction max to proportional share of lender feat: add withdraw restriction max to proportional share of lender + supply repayment to aave if possible Feb 9, 2026
Restore the base Aave lifecycle: supply while pooling, withdraw all at loan
creation, and hold unused capital and repayments as cash during the loan.

Allocate newly received cash once per share and debit each owner's remaining
allowance on withdrawal or redemption. Move unclaimed allowances with share
transfers so burning or moving shares cannot refresh a spent allocation.
Guard allocation changes against token callbacks and locked loan settlement.

Add real-token regressions and fuzz coverage, and update fork scenarios for
the cumulative limits and Aave-independent repayment/collateral exits.
@microHoffman microHoffman changed the title feat: add withdraw restriction max to proportional share of lender + supply repayment to aave if possible feat: restrict active-loan withdrawals to cumulative lender allocations Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant