DEV Community

hyunjun12312
hyunjun12312

Posted on

Why Steam Market fee calculators should use integer minor units

A fee calculator looks simple until the displayed total differs from the marketplace by one cent. The usual cause is not the percentage itself. It is the order of operations, minimum component fees, and rounding.

I built a small, dependency-free calculator to make those decisions visible and testable. The implementation works in integer minor units instead of floating-point currency values.

The problem with floating-point money

Code such as this is tempting:

const total = sellerAmount * 1.15;
Enter fullscreen mode Exit fullscreen mode

But binary floating-point values do not represent every decimal amount exactly. Formatting the final number can hide that problem without fixing the intermediate calculations.

The safer approach is to convert a displayed value into the currency's smallest configured unit and keep all fee calculations as integers:

const sellerReceives = 100; // cents
const steamRate = 0.05;
const publisherRate = 0.10;
Enter fullscreen mode Exit fullscreen mode

Each fee component is calculated separately because each component can have its own minimum and rounding rule.

Forward and reverse calculations are different

There are two useful questions:

  1. If the seller should receive a specific amount, what should the buyer pay?
  2. If the buyer pays a fixed displayed price, what can the seller receive?

The first direction can add calculated fee components to the seller amount. The reverse direction is less convenient because rounding makes a closed-form percentage division unreliable near boundaries.

The calculator solves the reverse direction with an integer binary search. It finds the greatest seller amount whose computed buyer price does not exceed the requested buyer price. This keeps the result deterministic and avoids loops over every possible cent.

Make assumptions configurable

The open-source implementation includes configurable:

  • marketplace fee rate;
  • publisher fee rate;
  • minimum fee for each component;
  • integer rounding behavior.

Its defaults model the common 5% marketplace fee plus 10% publisher fee example in USD cents. Those are defaults, not a promise that every game, currency, region, tax situation, or future Steam rule behaves identically.

You can inspect the code and tests in the Steam Market fee calculator repository. A browser version is also available as a localized Steam Market fee calculator.

Tests matter at the boundaries

Percentage examples in the middle of a price range rarely reveal mistakes. Better tests include:

  • the smallest permitted seller amount;
  • a price where a component minimum starts or stops applying;
  • a value immediately before and after a rounding boundary;
  • a game configured with no publisher fee;
  • invalid and negative input;
  • forward and reverse results for the same displayed total.

The project currently includes automated tests for the common fee example, reverse calculation, minimum component fees, invalid input, and a zero-publisher-fee configuration.

A practical limitation

This remains an estimate. Steam can change fee rules, publisher fees, minimums, currency increments, regional handling, and taxes. The amount shown by Steam immediately before a listing is submitted should remain the final source of truth.

The project is independent and is not affiliated with Valve or Steam. Its main purpose is to make the calculation logic auditable instead of hiding it behind a single percentage.

Related live service

SteamVaults is an independent third-party service currently focused only on buying and selling Mann Co. Supply Crate Keys with USDT. The live transaction service and this general-purpose fee calculator are separate.

Top comments (0)