Balance not updating
vikas-viki opened this issue · 7 comments
Hey before this commit Allow SimpleAccount to transfer native token with executeBatch
everything was working fine but now when we deposit some eth the deposits is updating but not the balance
and when we send the eth using withdrawDepositTo
the balance of reciever is updating but not the deposits even if the balance is 1 eth it is saying balance amount is too large
What should be done ?
Previous version
Previously after calling withdrawDepositTo
the reciever deposits was updating, below image is senders contract after sending deposits
the below one is the reciever contract, where the balance is not updated but deposits successfully came to contract.
Is this the intended way or I'm missing something ?
Sorry, it is a bit confusing to read screen-shots. do you have commit ids or script that shows the problem ?
(or even account addresses and transaction-hashes, if it is on a public testnet)
We would like to help you with this issue, but we can't without further information.
So let me explain,
Before the commit Allow SimpleAccount to transfer native token with executeBatch
, what was happening is the Ethereum balance wasn't updating, like as you can see images in above previous version section, here is the flow
Previous
Initially when I create a smart wallet and send some funds to it from EOA, the ethers
balance wasn't updating, but the deposits
variable is updating, as you can see from function call getDeposit
. Here is pic
Current
Steps:
- Initially I created a wallet and sent some ethers (A wallet).
- Again I created another wallet (B wallet).
- I sent the funds from A to B.
Here the thing is in B wallet theethers
balance is updating but not thedeposits
variable. Here is the pic
Here the problem is, in the previous version, before the commit mentioned above the ethers balance is not updating but the deposits variable is updating and we are able to send deposits from one wallet to another.
But now the deposits variable is not updating but the ethers balance is updating and we are not able to withdraw the deposits even if the balance is there.
I hope you get this, sorry for replying late.
I don't think we've changed anything with the account regarding to deposit usage.
But I think you have some confusion about the deposit and its usage.
Some general notes about accounts:
- we're talking about account paying for itself, which means no paymaster is involved.
- An account can only pay from its "deposit" in the EntryPoint. the "getDeposit" method simply does
entryPoint.getDeposit(this)
- If the deposit is not high enough, then when the validateUserOp is called for this UserOp,the account is given the amount it needs to deposit for itself. it should send (at minimum) this amount back to the entrypoint, otherwise the UserOp would fail.
- the above required deposit is the "maximum cost", and after the execution of the UserOperation, the excess is returned into the deposit.
- The account may withdraw its deposit (using
entryPoint.withdrawTo()
whenever it likes.
Bottom line:
- in general case, you shouldn't do anything with the deposit. Your account manages just enough deposit before each TX.
- for any eth transfer, please use your balance.
Optimization:
if you make a lot of transactions, and want to reduce (slightly) your gas costs, then manually send some eth from your account to the entrypoint. This way, you're not required to refresh the deposit on each UserOp.
So the deposit meanse only the funds the wallet owner has deposited not the amount of ethers which it got from other person transferring to it then.
exactly. anything that was transfered to your account stays in your account, as your balance. you only move into a deposit what you want to be used to pay for gas.
Yup