Skip to content
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

Allow to fetch "withdrawable balance" #539

Open
fleupold opened this issue Feb 12, 2020 · 0 comments
Open

Allow to fetch "withdrawable balance" #539

fleupold opened this issue Feb 12, 2020 · 0 comments
Labels
Version2 Proposals for the version 2 contract

Comments

@fleupold
Copy link
Contributor

At the moment we can query the withdrawal amount that has been requested. This value can be much larger than the available balance (it will be capped when we withdraw). However, there seems to be no way to read the amount of tokens which we will be able to withdraw successfully.

balanceStates is a private mapping (and cannot be made public due to ABI encoder issues). The only way to query balance information is via getBalances which will deduct any pending withdraw (capped at the current balance):

uint256 amount = Math.min(balanceStates[user][token].balance, balanceStates[user][token].pendingWithdraws.amount);

This is the amount which we will be able to withdraw, but there is no way to access it externally after a request has been made.
We would have to access balanceStates[user][token].balance directly. While this is possible from web3 via getStorageAt it does not seem possible from other smart contracts (cf. https://eips.ethereum.org/EIPS/eip-2330).
Thus external contracts such as the BatchExchangeViewer can give no accurate estimation of how much will end up in an account after a claimable withdraw is executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Version2 Proposals for the version 2 contract
Projects
None yet
Development

No branches or pull requests

2 participants