frequency-chain / frequency

Frequency: A Polkadot Parachain
https://www.frequency.xyz
Apache License 2.0
48 stars 18 forks source link

[Feature]: Throw error when staking is greater than balance #1994

Open enddynayn opened 1 month ago

enddynayn commented 1 month ago

Description Currently, when a user attempts to stake an amount greater than their total account balance, the system stakes the entire balance minus a minimum amount required for unstaking. This behavior can confuse users who expect an error instead of staking the whole amount.

Acceptance Criteria

shannonwells commented 1 month ago

There was an alternative to the 2nd checkbox suggested by @harry-evans, which I also prefer: an RPC call for asking what your maximum allowable stake is (which is free), and then requiring you to submit a value that will work. To me the Issue as written is just slightly less of a surprise than before, and can still leave you with no token left for transaction fees.

Of course, one can check an account balance but IMO it would be more helpful to app developers to provide an endpoint that lets you ask what you can stake instead of having them query (or worse, store it and risk it going out of date) what the minimum stake is, get an estimate of transaction fee and then query their balance and do the math client side. Instead it's just two calls. It simplifies the stake extrinsic logic, nobody is surprised by the result, and nobody has to field support calls why it doesn't stake the amount they asked for.