SteemVBS Update: Vests/Steem Conversion and Current Vote Worth

in utopian-io •  9 days ago

Introducing to SteemVBS

SteemVBS is the first Steem Library written in VBScript. Yes, it is VBScript. ;)

New Features

Adding the support for Vests/Steem Conversions and the functions to get the current vote worth. In particular, the following functions have been added to the library.

  1. Steem_Per_MVests
  2. Vests_To_Steem
  3. GetRewardFund
  4. GetRecentClaims
  5. GetAccountVests
  6. GetMedianPrice
  7. GetAccount_UpvoteValue

Examples

Vests and Steem:

Dim SteemIt
Set SteemIt = New Steem

WScript.Echo SteemIt.Steem_Per_MVests
WScript.Echo SteemIt.Vests_To_Steem(1)
WScript.Echo SteemIt.Steem_To_Vests(1)

Get Current Vote Worth:

' get account upvote value
Public Function GetAccount_UpvoteValue(id, vp, weight)
    Dim power
    power = (100 * vp * 100 * weight / 1e4 + 49) / 50
    Dim total_vests
    total_vests = GetAccountVests(id)
    Dim final_vests
    final_vests = total_vests * 1e6
    Dim rshares
    rshares = power * final_vests / 1e4
    Dim rewards
    rewards = GetRewardFund
    Dim sbd_median_price
    sbd_median_price = GetMedianPrice
    Dim estimate
    estimate = rshares / GetRecentClaims * rewards * sbd_median_price
    GetAccount_UpvoteValue = estimate
End Function

Fully Unit Tested:

Dim SteemIt
Set SteemIt = New Steem

Dim Util
Set Util = New Utility

Dim fund
fund = SteemIt.GetRewardFund
AssertTrue fund > 0, "Rewards Pool should be larger than zero"

Dim esp
esp = SteemIt.Vests_To_Steem(SteemIt.GetAccountVests("justyy"))
AssertTrue esp > 1000, "justyy's ESP should be at least 1000"

Dim price
price = SteemIt.GetMedianPrice
AssertTrue price > 0, "median price should be larger than 0"

Dim upvote_value
upvote_value = SteemIt.GetAccount_UpvoteValue("justyy", 100, 100)
AssertTrue upvote_value > 0.1, "full vote value should be at least $0.1"

Dim current_upvote_value
current_upvote_value = SteemIt.GetAccount_UpvoteValue("justyy", 50, 20)
AssertEqualFloat upvote_value * 0.5 * 0.2, current_upvote_value, 0.1, "current upvote value calculation error"

Set SteemIt = Nothing
Set Util = Nothing

image.png

Github

https://github.com/DoctorLai/steemvbs

Pull Requests

https://github.com/DoctorLai/steemvbs/pull/1

Support me and my work as a witness - witness thread by

  1. voting me here, or
  2. voting me as a witness proxy - let @justyy represent you.

Thank you! Some of My Contributions: SteemYY.com - SteemIt Tutorials, Robots, Tools and APIs and VPS Search Tool

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thanks for the contribution, @justyy! Sorry for the late review, it's probably because none of us use VBScript. It's cool to see you have added a couple of new functions. I was wondering if you use this library for something? Why should someone use this over e.g. one of Python/JavaScript's libraries?


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

·

Thank you for your review, @amosbastian! Keep up the good work!

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

Hi @justyy!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @justyy!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!