Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: renterd allowance derived max pricing #647

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexfreska
Copy link
Member

@alexfreska alexfreska commented Jun 21, 2024

Status: Ready for review

The PR adds a default option to automatically calculate max gouging prices from the user configured usage estimates and allowance.

I don't think the previous simpler f(allowance, percents) => pricing version really captured the intended behaviour so I expanded the equation to incorporate the user estimates, while proportionally fixing the prices according to configurable weights, default: 10% upload, 50% download, 40% storage. Let me know if this solution makes sense.

The derivePricingFromAllowance method calculates the max price per TB for storage, download, and upload given a total spending allowance and estimated usage in TB for each type. The prices are kept proportional to each other using the weight factors provided as parameters. Storage and upload are also scaled by the redundancy multiplier.

The total cost equation is:

allowance * allowanceFactor = scaledAllowance =
  storageTBWithRedundancy * storageWeight * unitCost +
  downloadTBMonth * downloadWeight * unitCost +
  uploadTBMonthWithRedundancy * uploadWeight * unitCost

Once the unit cost is determined, the individual prices can be calculated:

maxUploadPriceTB = unitCost * uploadWeight
maxDownloadPriceTB = unitCost * downloadWeight
maxStoragePriceTBMonth = unitCost * storageWeight

The function also includes an allowance scaling factor to account for contract price variation. For example, if a user expects to pay $2 per TB, they should set the max value to $4 per TB because the optimal contracts may vary, eg: one contract at $1 and another at $3 which average to $2. The scaling factor helps avoid unnecessary churn.

Screenshot 2024-07-01 at 5 01 05 PM Screenshot 2024-07-01 at 5 00 32 PM

Copy link

changeset-bot bot commented Jun 21, 2024

🦋 Changeset detected

Latest commit: ae11f72

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
renterd Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member Author

alexfreska commented Jun 21, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @alexfreska and the rest of your teammates on Graphite Graphite

@alexfreska alexfreska force-pushed the refactor_renterd_allowance_auto_max branch 3 times, most recently from ec82738 to 4efd310 Compare June 27, 2024 13:35
@alexfreska alexfreska force-pushed the refactor_renterd_allowance_auto_max branch 2 times, most recently from f2ee837 to 5b333a7 Compare July 1, 2024 20:18
@alexfreska alexfreska force-pushed the refactor_renterd_allowance_auto_max branch from 5b333a7 to 1aaa3ca Compare July 1, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants