Feat/async hub#236
Open
lastperson wants to merge 40 commits into
Open
Conversation
…nter-stash-contracts into feat/upgradeable-pools
There was a problem hiding this comment.
Pull request overview
This PR updates LiquidityHub to support ERC-7540-style asynchronous redemptions, enabling users to request withdrawals when liquidity is insufficient and allowing an authorized operator (ops multisig) to later fulfill those pending redemptions once liquidity is available.
Changes:
- Add async redeem request tracking (
requestRedeem, operator approvals, andfulfilRedeem) and include pending requests in vault accounting. - Bound
maxRedeem/maxWithdrawby the liquidity pool’s current asset balance (so insufficient-liquidity withdrawals revert with ERC4626 max errors). - Add an extensive test suite covering the new async redeem flows and update the coverage baseline.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
contracts/LiquidityHub.sol |
Implements ERC-7540 async redeem requests, operator permissions, fulfill role, and liquidity-bounded max redeem/withdraw logic. |
contracts/interfaces/ILiquidityHub.sol |
Extends the public interface with async redeem and operator APIs. |
test/LiquidityHub.ts |
Adds tests for async redeem flows and updates insufficient-liquidity expectations. |
coverage-baseline.json |
Updates baseline coverage thresholds after adding tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+264
to
+269
| function claimableRedeemRequest(uint256 /* requestId */, address controller) public view returns (uint256) { | ||
| uint256 pending = _getStorage().redeemRequests[controller]; | ||
| if (pending == 0) return 0; | ||
| uint256 available = LIQUIDITY_POOL.balance(IERC20(asset())); | ||
| return Math.min(pending, previewWithdraw(available)); | ||
| } |
Comment on lines
+284
to
+288
| function maxRedeem(address owner) public view override returns (uint256) { | ||
| uint256 total = balanceOf(owner) + _getStorage().redeemRequests[owner]; | ||
| uint256 available = LIQUIDITY_POOL.balance(IERC20(asset())); | ||
| return Math.min(total, previewWithdraw(available)); | ||
| } |
Comment on lines
+61
to
64
| uint256 totalRedeemRequest; | ||
| mapping(address controller => uint256 shares) redeemRequests; | ||
| mapping(address controller => mapping(address operator => bool)) operators; | ||
| } |
| expect(await liquidityHub.totalRedeemRequest()).to.equal(4n * LP); | ||
| }); | ||
|
|
||
| it("claimableRedeemRequest returns min(pending, previewWithdraw(pool))", async function () { |
Use floor when calculating maxRedeem and claimableRedeemRequest
Collaborator
Author
|
@mpetrunic comments addressed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #193