How can I convert Vests to SP in Steemjs?
I'm using SteemJS and want to find the amount of SP a particular user has. I can easily calculate their total Vests by using the Vests a user has, adding the received vests and subtracting the delegated vests.
Once I have that number, I need to use this function to convert Vests to SP:
var steemPower = steem.formatter.vestToSteem(vestingShares, totalVestingShares, totalVestingFundSteem);
console.log(steemPower);
vestingShares is the amount of Vests that a user has, but what is totalVestingFundSteem and totalVestingFundSteem and how can I find them using SteemJS?
You could try this:
totalVestingShares = 0;
totalVestingFundSteem = 0;
steem.api.getDynamicGlobalProperties((err, result) => {
totalVestingShares = result.total_vesting_shares;
totalVestingFundSteem = result.total_vesting_fund_steem;
});
steem.api.getAccounts(['rishi556', 'clauxklein'], function(err, result) {
if (!err) {
for (let i = 0; i < result.length; ++ i) {
var steemPower = steem.formatter.vestToSteem(result[i].vesting_shares, totalVestingShares, totalVestingFundSteem);
log(result[i].name + "'s SteemPower is " + steemPower);
} else {
log("Steem API Error: ", err);
}
});
Thanks, this worked exactly like I needed it to.
I don't know much about this. However you can connect with the steemdevelopers in their discord server https://discord.gg/9QRB2H. They will be eager to help.