Skip to content

fix(accounts): buffer borrow and withdraw market capacity - #562

Merged
essserrr merged 1 commit into
masterfrom
codex/borrow-and-withdraw-capacity-buffer
Oct 29, 2026
Merged

essserrr merged 1 commit into
masterfrom
codex/borrow-and-withdraw-capacity-buffer

Conversation

@essserrr

Copy link
Copy Markdown
Collaborator

Borrow and withdraw Max can revert with BorrowingMoreThanU2ForbiddenException when borrowing capacity shrinks between calculation and execution. On the reported account, the unbuffered Max passed immediately but reverted after 15 seconds and one new block.

Reserve two basis points (0.02%) of market borrowing capacity before comparing it with collateral and per-account debt limits. Max remains unchanged when those other limits are lower than the buffered capacity.

Validation:

  • 21 focused calculator tests passed, including a decrease in market capacity between sizing and preparation.
  • SDK typecheck and Biome checks passed.
  • On the reported Mainnet fork, the buffered Max passed an eth_call after 15 seconds and two new blocks. No transaction was sent.
  • Local client build passed with the linked SDK.
  • Full SDK test suite is running; GitHub CI will also run the publication checks.

- Leave two basis points of available borrowing capacity for execution delays
- Verify Max remains valid after market capacity decreases by one basis point
@essserrr
essserrr merged commit 55c498f into master Oct 29, 2026
2 checks passed
@essserrr
essserrr deleted the codex/borrow-and-withdraw-capacity-buffer branch October 29, 2026 11:15
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