Skip to content

Bugfix/withdrawal manager#219

Merged
gowthamsundaresan merged 1 commit into
feat/v2-corefrom
bugfix/withdrawal-manager
Aug 12, 2025
Merged

Bugfix/withdrawal manager#219
gowthamsundaresan merged 1 commit into
feat/v2-corefrom
bugfix/withdrawal-manager

Conversation

@parsaaba

@parsaaba parsaaba commented Aug 4, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/core/WithdrawalManagerv2.sol Outdated
EnumerableSet.Bytes32Set private activeWithdrawalRequests;
mapping(address => EnumerableSet.Bytes32Set) private userWithdrawalRequestsSet;

struct RebasingTokenConfig {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey since EL tracks rebasing already, can we use their functions underlyingToSharesView and sharesToUnderlyingView to do the rebasing calc?

With that method, we remove all the code overhead of rebasing including all the admin management. Also all if(rebasingToken) can be removed since we can just call the functions for any strategy and if it is not rebasing, it will simply return 1 * 10 ** decimals

@gowthamsundaresan gowthamsundaresan Aug 8, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We would then need to update queuedAssetBalances -> queuedAssetElShares
This actually also helps with accurate pricing of the LAT because in totalAssets calc, we can utilize the actual rebased value of the token

Comment thread src/core/WithdrawalManagerv2.sol Outdated
mapping(bytes32 => ILiquidTokenManager.Redemption) public redemptions;

uint256 public withdrawalDelay;
mapping(bytes32 => uint256[]) public withdrawalRequestShares;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm thinking do we need to keep this as a separate mapping? What if we update the Redemption struct to store requestedElShares & withdrawableElShares instead of requestedAmounts and withdrawableAmounts. Seems more gas efficient since we can work with all existing loops (and less code bloat)

Have you made this consideration already? If so, curious to know why separate mapping was preferred

Comment thread src/core/WithdrawalManagerv2.sol Outdated
uint256 requestedAmount = request.requestedAmounts[i];
uint256 maxSlippageAmount = (requestedAmount * config.maxSlippageBps) / BPS_DENOMINATOR;

if (rebasingAmount > requestedAmount + maxSlippageAmount) {

@gowthamsundaresan gowthamsundaresan Aug 8, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We would need to use withdrawableAmount here, the requestedAmount is never used other than in events. This is because requestedAmount is the pre-slashing amount of what the user wants, but it is never to be expected as the result

Comment thread src/core/WithdrawalManagerv2.sol Outdated

totalWithdrawalValue = totalWithdrawalValue > withdrawalValue ? totalWithdrawalValue - withdrawalValue : 0;

liquidToken.debitQueuedAssetBalances(assets, actualAmounts, sharesDeposited);

@gowthamsundaresan gowthamsundaresan Aug 8, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The issue here is the the total debited can be less than the total that was credited in settleUserWithdrawals

Regardless of rebasing and slashing loss, the total credit of queuedAssetBalance must equal the total debit after fulfilment so that it nets out to 0

Comment thread src/core/WithdrawalManagerv2.sol Outdated
}
}

function _calculateActualAmountsWithSlippageProtection(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we accept the suggestion of queuedAssetBalances -> queuedAssetElShares then we can minimize this function to solve only for the 1-2 wei transfer loss

@gowthamsundaresan gowthamsundaresan changed the base branch from dev to feat/v2-core August 12, 2025 09:29
@parsaaba parsaaba force-pushed the bugfix/withdrawal-manager branch from 4b1e082 to 943945e Compare August 12, 2025 16:49
@gowthamsundaresan gowthamsundaresan merged commit 0377510 into feat/v2-core Aug 12, 2025
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