Skip to content

Restrict Lending Pool Borrow/Repayment to Authorized Borrowing Contract - #123

Merged
Nabeelahh merged 1 commit into
Vaulty-X:mainfrom
ayshadogo:feat/lending-pool
Aug 22, 2026
Merged

Restrict Lending Pool Borrow/Repayment to Authorized Borrowing Contract#123
Nabeelahh merged 1 commit into
Vaulty-X:mainfrom
ayshadogo:feat/lending-pool

Conversation

@ayshadogo

Copy link
Copy Markdown
Contributor

Summary
Adds borrowing-contract authorization enforcement to the lending pool. borrow, repay, and update_debt are now gated so only a single, immutable borrowing-contract address per pool may invoke them. Direct user calls return Error::Unauthorized. All read-only accounting endpoints remain public.

Problem
Lending-pool borrow and repay operations could be called by any address, allowing direct callers to manipulate debt and liquidity accounting outside Vaulty's collateral checks in the borrowing contract.

Changes
New files:

  • Contract/lending/src/authorization.rs — require_borrowing_contract() helper that checks env.transacter().address() against the stored borrowing-contract address
  • Contract/lending/src/state.rs — Documents the storage layout, immutability guarantee, and initialization order
  • Contract/lending/tests/test_lending_borrow_authorization.rs — 14 dedicated authorization tests

Closes #117

@Nabeelahh
Nabeelahh merged commit 38d5d74 into Vaulty-X:main Aug 22, 2026
1 check failed
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.

Restrict Lending Pool Borrowing and Repayment to the Borrowing Contract

2 participants