Skip to content

feat(core): add wallet-free storage cost estimators - #1031

Merged
SgtPooki merged 4 commits into
masterfrom
feat/estimate-storage-costs
Oct 22, 2026
Merged

SgtPooki merged 4 commits into
masterfrom
feat/estimate-storage-costs

Conversation

@SgtPooki

@SgtPooki SgtPooki commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Pricing pages and calculators (filecoin.cloud/ipfs2filecoin today, a general pricing calculator next) currently hardcode FWSS rates, and the ipfs2filecoin constants went stale with the v1.4.0 upgrade. This adds two pure functions to @filoz/synapse-core/warm-storage so those pages can read getPriceList() and stay in step with contract pricing, without a wallet or account state.

  • estimateOnboardingCost: what it costs to bring data on. Create-data-set and add-pieces fees for a piece count and batch size, plus the up-front deposit (30-day streaming lockup and lifecycle reserve), across copies.
  • estimateStorageCost: what it costs to keep data for a duration. Recurring rate and total across copies.

Why not reuse what's here:

  • calculateUploadFees and calculateLifecycleReserveFunding take one size per piece, which doesn't work for estimates like 10 TiB of 10 KiB files (about 1 billion pieces). They also price every piece as its own add-pieces call; that conservative default is kept here (piecesPerAddPiecesCall defaults to 1n), but callers can model batching.
  • getUploadCosts and calculateDepositNeeded need account state.

Storage is priced from sizeInBytes rather than PDP leaf counts, which can differ by up to 31 bytes per piece. The JSDoc points at calculateEffectiveRate for exact per-data-set math.

Against the live mainnet price list, 10 TiB in 1 GiB pieces, 100 per call, 2 copies:

USDFC
One-time fees 63.138
Up-front deposit 114.12
Per month 50.24
12 months 602.88

The deposit includes the lifecycle reserve and the replenishments the add-pieces fees trigger; the fees are paid out of it, not on top of it.

Tests: test/estimate-costs.test.ts uses the v1.4.0 mainnet price list.

estimateOnboardingCost prices bringing data onto FWSS: create-data-set and
add-pieces fees for a piece count and batch size, plus the deposit needed up
front (30-day streaming lockup and lifecycle reserve), per copy.

estimateStorageCost prices keeping data for a duration: recurring rate and
total across copies.

Both are pure functions over getPriceList output, so pricing pages and
calculators can stay in step with contract pricing without a wallet or
account state.
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Oct 20, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

filecoin-encryption-envelope

npm i https://pkg.pr.new/filecoin-encryption-envelope@1031

@filoz/keysmith

npm i https://pkg.pr.new/@filoz/keysmith@1031

@filoz/synapse-core

npm i https://pkg.pr.new/@filoz/synapse-core@1031

@filoz/synapse-react

npm i https://pkg.pr.new/@filoz/synapse-react@1031

@filoz/synapse-sdk

npm i https://pkg.pr.new/@filoz/synapse-sdk@1031

commit: 0286701

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
synapse-dev 0286701 Commit Preview URL

Branch Preview URL
Oct 22 2026, 02:15 PM

Reuse estimateStorageCost for the onboarding streaming lockup instead of
recomputing the rate. Replace the lower-bound and copies-ratio assertions
with exact values, add a lockup-period case so swapping defaultLockupPeriod
for EPOCHS_PER_MONTH fails, and cover each non-positive input guard.

@SgtPooki SgtPooki left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self review

@SgtPooki
SgtPooki marked this pull request as ready for review October 20, 2026 14:45
@FilOzzy FilOzzy moved this from 📌 Triage to 🔎 Awaiting review in FOC Oct 20, 2026
Comment thread packages/synapse-core/src/warm-storage/estimate-onboarding-cost.ts Outdated
@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ⌨️ In Progress in FOC Oct 21, 2026
@SgtPooki

Copy link
Copy Markdown
Contributor Author

first consumer: filecoin-project/filecoin-io-website#48, a calculator on filecoin.io/pricing.

@github-project-automation github-project-automation Bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FOC Oct 22, 2026
@SgtPooki
SgtPooki merged commit e7ccd77 into master Oct 22, 2026
18 checks passed
@SgtPooki
SgtPooki deleted the feat/estimate-storage-costs branch October 22, 2026 14:18
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

3 participants