-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: midas-allocator
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for acre-dapp-testnet canceled.
|
✅ Deploy Preview for acre-dapp canceled.
|
uint256 tbtcAmount = stbtc.convertToAssets(_shares); | ||
uint256 midasShares = vault.convertToShares(tbtcAmount); | ||
midasAllocator.withdraw(midasShares); | ||
stbtc.burn(_shares); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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:
requestRedeem(uint256 shares, address destination)
- it will be dedicated for EVM transfers.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 |
There was a problem hiding this comment.
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?
No description provided.