penumbra-zone / web

Apache License 2.0
12 stars 15 forks source link

fix broken "max" button #1313

Closed TalDerei closed 2 months ago

TalDerei commented 3 months ago

References https://github.com/penumbra-zone/web/pull/1268#issuecomment-2164609477. Currently, the "max" functionality implemented in https://github.com/penumbra-zone/web/pull/1151 is broken in the context of non-zero gas fees. During transaction creation, the planner specifies outputs and fills in spends to balance the transaction, subtracting fees from the input. If the user attempts to spend their entire balance, they don't have any additional funds to pay for fees. Instead, we want to modify the planner request to spend all the available notes, and instead subtract fees from the output.

https://github.com/penumbra-zone/penumbra/pull/4615 was a necessary proto change towards that.

cc @grod220

grod220 commented 3 months ago

This is only an issue if the user is trying to spend their max amount of UM and they have no other token right?

TalDerei commented 3 months ago

Screenshot 2024-06-13 at 12 37 10 PM

Valentine1898 commented 3 months ago

This is only an issue if the user is trying to spend their max amount of UM

Not just UM, but other tokens as well if used as an alternative fee token

and they have no other token

It doesn't matter, if the user has UM, then the alternative fee token will not be used

hdevalence commented 3 months ago

We want to avoid a situation where a user has to manually decrease the amount slightly to leave a bit left over for gas, like on ethereum, we have the technology to deliver a better UX here so we should try to do so. It will require tracking some extra state in the send dialog (since we effectively want to secretly track an isSendingMax bool and branch on it).

conorsch commented 3 months ago

The related Planner changes in https://github.com/penumbra-zone/penumbra/pull/4615 shipped as part of v0.77.4, so this work should now be unblocked.

TalDerei commented 3 months ago

@hdevalence does https://github.com/penumbra-zone/web/pull/1151#issuecomment-2128525826 hold for other action types like swaps and delegations as well? it seems tricky