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

Compare staking amount + calculated fee against the available balance. #254

Open
vitsalis opened this issue Jun 17, 2024 · 2 comments
Open
Assignees
Labels

Comments

@vitsalis
Copy link
Member

Currently, we only compare the staker's selected stake amount against the balance and don't allow them to submit the form if they choose an amount they can't cover. However, this does not take into account the fees.

We recommend that we take the calculated fees (either based on the default fee rate or the user's selection of fee rate) into account and compare it against the balance before allowing the user to submit the staking form. An example of such a mechanism follows.

When the user loads up the form, they select a stake amount and we calculate the fee they would pay based on the default fee rate (currently mempool fastest). There are two cases:

  1. amount + defaultFeeRateCalculatedFee > balance. The "preview" button is disabled and the user has two choices
    a. Change the staking amount to something lower. In this case, no further action needs to be taken and the user can submit.
    b. Press the "use custom" button to change the fee to something lower. If they go into custom mode, they can lower the fee rate, and if they lower it enough so that amount + calculatedFee <= balance, we allow them to submit.
  2. amount + defaultFeeRateCalculatedFee <= balance. The "preview" button is enabled, and the user has two choices:
    a. Submit the transaction
    b. Press the "use custom" button to change the fee to something higher/lower. If they go to an amount that they can't cover, we don't allow them to submit.
@gbarkhatov
Copy link
Contributor

@vitsalis should we start discussing the design for this and overall logic implementation?

@vitsalis
Copy link
Member Author

We can. Unit tests take priority though.

@jrwbabylonlab jrwbabylonlab self-assigned this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants