Skip to content

Proposal: Extend `siac renter` with optional currency conversion based on SIA_EXCHANGE_RATE env variable

Jan Vornberger requested to merge jav_/Sia:exchange-rate into master

MERGE REQUEST

MR Guidelines

Overview

This MR implements a proposal to extend the output of siac renter subcommands with optional, additional currency conversion. The idea would be, that the environment variable SIA_EXCHANGE_RATE can be set to something like "0.0038 USD" and then all amounts of the form "1 KS" will be displayed as "1 KS (~ 3.80 USD)". If SIA_EXCHANGE_RATE is not set, the output is unchanged.

The MR adds a new function currencyUnitsPlus() which works like the existing currencyUnits() but displays additional currency conversion if an exchange rate is available. I only made use of currencyUnitsPlus() for some of the renter subcommands. It could potentially also be used for host subcommands or other places in siac.

Example for Visual Changes

No changes when SIA_EXCHANGE_RATE is not set:

$ siac renter
Allowance:       4 KS
  Spent Funds:     560 SC
  Unspent Funds:   3.44 KS

Data Storage:
  Files:               6
  Total Stored:        12.664 GB
  Total Contract Data: 169.089 GB
  Min Redundancy:      2.40
  Active Contracts:    36
  Passive Contracts:   182
  Disabled Contracts:  45

With SIA_EXCHANGE_RATE set:

$ export SIA_EXCHANGE_RATE="0.0038 USD"
$ siac renter
Allowance:       4 KS (~ 15.20 USD)
  Spent Funds:     560 SC (~ 2.13 USD)
  Unspent Funds:   3.44 KS (~ 13.07 USD)

Data Storage:
  Files:               6
  Total Stored:        12.664 GB
  Total Contract Data: 169.089 GB
  Min Redundancy:      2.40
  Active Contracts:    36
  Passive Contracts:   182
  Disabled Contracts:  45

I also added this feature to the following subcommands:

$ siac renter -v
Allowance:       4 KS (~ 15.20 USD)
  Spent Funds:     560 SC (~ 2.13 USD)
  Unspent Funds:   3.44 KS (~ 13.07 USD)

Spending:
  Current Period Spending:
    Spent Funds:     560 SC (~ 2.13 USD)
      Storage:       73.95 SC (~ 0.28 USD)
      Upload:        2.912 SC (~ 0.01 USD)
      Download:      16.82 SC (~ 0.06 USD)
      Fees:          466.3 SC (~ 1.77 USD)
    Unspent Funds:   3.44 KS (~ 13.07 USD)
      Allocated:     2.305 KS (~ 8.76 USD)
      Unallocated:   1.135 KS (~ 4.31 USD)

Data Storage:
  Files:               6
  Total Stored:        12.664 GB
  Total Contract Data: 169.089 GB
  Min Redundancy:      2.40
  Active Contracts:    36
  Passive Contracts:   182
  Disabled Contracts:  45

Memory Status
  Available Memory  805.3 MB
  Starting Memory   805.3 MB
  Requested Memory  0 B

  Available Priority Memory  1.074 GB
  Starting Priority Memory   1.074 GB
  Requested Priority Memory  0 B

Rate limits: 
  Download Speed: no limit
  Upload Speed:   no limit
$ siac renter allowance
Allowance:
  Amount:               4 KS (~ 15.20 USD)
  Period:               4032 blocks
  Renew Window:         2016 blocks
  Hosts:                50

Skynet Portal Per-Contract Budget: 10 SC (~ 0.04 USD)

Expectations for period:
  Expected Storage:     1.0000 TB
  Expected Upload:      933.333 GB
  Expected Download:    933.333 GB
  Expected Redundancy:  3

Price Protections:
  MaxRPCPrice:               0 H per million requests
  MaxContractPrice:          0 H
  MaxDownloadBandwidthPrice: 0 H per TB
  MaxSectorAccessPrice:      0 H per million accesses
  MaxStoragePrice:           0 H per TB per Month
  MaxUploadBandwidthPrice:   0 H per TB

Spending:
  Current Period Spending:
    Spent Funds:     560 SC (~ 2.13 USD)
      Storage:       73.95 SC (~ 0.28 USD)
      Upload:        2.912 SC (~ 0.01 USD)
      Download:      16.82 SC (~ 0.06 USD)
      Fees:          466.3 SC (~ 1.77 USD)
    Unspent Funds:   3.44 KS (~ 13.07 USD)
      Allocated:     2.305 KS (~ 8.76 USD)
      Unallocated:   1.135 KS (~ 4.31 USD)

  Previous Spending: 1.61 KS (~ 6.12 USD)
    Withheld Funds:  0 H (0.00 USD)
    Release Block:   0
$ siac renter prices
Renter Prices (estimated):
  Fees for Creating a Set of Contracts:   328.9 SC (~ 1.25 USD)
  Download 1 TB:                          430.5 SC (~ 1.64 USD)
  Store 1 TB for 1 Month:                 2.288 KS (~ 8.70 USD)
  Store 1 TB for Allowance Period:        0 H (0.00 USD)
  Upload 1 TB:                            344 SC (~ 1.31 USD)

Allowance used for estimate:
  Funds:          4 KS (~ 15.20 USD)
  Period:         4032
  Hosts:          50
  Renew Window:   2016

Checklist

Review and complete the checklist to ensure that the MR is complete before assigned to an approver.

  • All new methods or updated methods have clear docstrings
  • Testing added or updated for new methods
  • Any new packages are added to Makefile and .gitlab-ci.yml
  • API documentation updated for API updates
  • Module README.md updated for changes to workflow
  • Issue added to Sia-UI repo for new supporting features
  • Changelog File Created

Issues Closed

Edited by Jan Vornberger

Merge request reports