Skip to content

Midas withdrawal queue #954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: midas-allocator
Choose a base branch
from
Draft

Conversation

aliberkhsl
Copy link

No description provided.

Copy link

netlify bot commented Jul 14, 2025

Deploy Preview for acre-dapp-testnet canceled.

Name Link
🔨 Latest commit 78820d0
🔍 Latest deploy log https://app.netlify.com/projects/acre-dapp-testnet/deploys/687f5ff45d893a0008f6117a

Copy link

netlify bot commented Jul 14, 2025

Deploy Preview for acre-dapp canceled.

Name Link
🔨 Latest commit 78820d0
🔍 Latest deploy log https://app.netlify.com/projects/acre-dapp/deploys/687f5ff4ad3d010008f76101

@nkuba nkuba changed the base branch from main to midas-allocator July 22, 2025 21:13
uint256 tbtcAmount = stbtc.convertToAssets(_shares);
uint256 midasShares = vault.convertToShares(tbtcAmount);
midasAllocator.withdraw(midasShares);
stbtc.burn(_shares);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we burn the shares we affect the ERC4626's (stBTC) conversion ratio calculation, by changing the totalSupply while totalAssets remain the same. Won't it have unexpected effects on the convertToAssets/convertToShares calculations?

If we want to burn the shares, we nee to adjust the totalAssets to reflect the expected amount that will be withdrawn.
Another solution would be to lock the stBTC shares in the WithdrawalQueue until the withdrawal request is finalized and burn them once the assets are leaving the vault.

/// @param _receiveOnEVM Whether to receive on EVM.
function createWithdrawalRequest(
uint256 _shares,
bytes20 _walletPubKeyHash,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have two variants of this function:

  1. requestRedeem(uint256 shares, address destination) - it will be dedicated for EVM transfers.
  2. requestRedeemAndBridge(uint256 shares, bytes20 walletPubKeyHash) - it will be dedicated for bridging back to Bitcoin.

WithdrawalRequest storage request = withdrawalRequests[_requestId];
request.completedAt = block.timestamp;
request.isCompleted = true;
tbtcAmount = request.tbtcAmount; // cache the tbtc amount
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a delay between the withdrawal request and finalization. We can't be sure the tbtcAmount released from the vault will match the amount we tracked with the request.
Have you had a chance to explore any solution to address it?

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.

2 participants