EOSIO / eos

An open source smart contract platform
https://developers.eos.io/manuals/eos
MIT License
11.27k stars 3.6k forks source link

Current RAM price endpoint #4614

Closed vovapi closed 6 years ago

vovapi commented 6 years ago

It would be nice to have RAM price data accessible as API endpoint (or in get_info endpoint response for example). Now you know the ram price only after you have bought/sold RAM (or you can somehow calculate price based on bancor protocol or something). This is very unpleasant.

hama commented 6 years ago

bancor

vovapi commented 6 years ago

@hama, yes, you can calculate price manually using bancor protocol (I noted it above), but this is still frustrating. Why can't you know the price before you buy or sell? Why should you guess price every time you wanna buy it? Why no price tags?

taokayan commented 6 years ago

you can use the following method: run cleos get table eosio eosio rammarket you'll get something like:

  "rows": [{
      "supply": "10000000000.0000 RAMCORE",
      "base": {
        "balance": "14974544245 RAM",
        "weight": "0.50000000000000000"
      },
      "quote": {
        "balance": "4589161.3885 EOS",
        "weight": "0.50000000000000000"
      }
    }
  ]

then 4589161.3885 / 14974544245 x 1024 = 0.3138 is the RAM price per KB.

vovapi commented 6 years ago

This helped me, keeping in mind fee of buyram action (0.5%): https://github.com/EOSIO/eos/blob/369c7e31e17630e1327a48869b832635352a27f4/contracts/eosio.system/delegate_bandwidth.cpp#L111 With this in mind I get accurate results! Thanks a lot!

Still, do you plan to implement ram price endpoint?

taokayan commented 6 years ago

Yes, we'll implement it in the future.

slipo commented 6 years ago

For people implementing this in the future here's some roughed-out sample code: https://runkit.com/slipo/5b5a37b59fefb60012b18a90

Plus the related endpoint: https://runkit.io/slipo/5b5a37b59fefb60012b18a90/branches/master

vovapi commented 6 years ago

@taokayan why would you close this if it isn’t resolved? Maybe you should close this when you implement it?