stoodkev / SteemPlus

SteemPlus is a lightweight browser extension adding new features to your Steemit/Busy experience: - Voting slider for minnows - Possibility to filter (by tag/resteem/reputation) and sort ( by date/payout/votes) - Switch between Busy Steemit and Steemd by keyboard shortcuts - Delegation of Steem Power directly from the wallet
GNU General Public License v3.0
27 stars 32 forks source link

Maximum available SP for delegation is inaccurate in busy #124

Closed josephace135 closed 6 years ago

josephace135 commented 6 years ago

Expected behavior

When a delegator delegates parts of his SP to an account, the maximum available SP for delegation should be presented as the difference of his total SP minus his total delegated SP minus 5.000.

Actual behavior

When pressing the "Delegate" button in busy, the maximum available SP for delegation is incorrect wherein it is expressed in this formula: Max available SP = Total SP of the Delegator - Total delegated SP/Outgoing delegation of the account to be delegated - 5.000. With that formula, there are three possible scenarios that would occur which are as follows:

How to reproduce

Recording Of The Bug

In these three recordings, I am the delegator with a Total SP of 715.014 and my total delegated SP of 450.794 is not considered in the computation.

https://youtu.be/OHOAxnogT2A

https://youtu.be/Y5N4wiEb6vs

https://youtu.be/Cz44DxC6nCk

Environment

Issue

In delegate.js, the codes in 137-140, the formula for obtaining the maximum available SP that the user can delegate is shown.

      function getMaxSP(){
        var myVests = parseFloat(steem.formatter.vestToSteem(myAccountDelegation.vesting_shares.replace(' VESTS',''), globalP.totalVests, globalP.totalSteem) * 100) / 100;
        var maxSP = myVests - totalOutgoingDelegation - 5.000;

        return (maxSP > 0 ? maxSP.toFixed(3) : 0);
      }

With that, the amount for totalOutgoingDelegation is obtained from the account to be delegated instead of the delegator. Perhaps, the issue is found in the codes in line 88,

if(totalOutgoingDelegation===-1&&(regexWalletBusy.test(window.location.href)||regexWalletSteemit.test(window.location.href))&&retryCountDelegate<20)

steemplus commented 6 years ago

Fixed