Every swap has two related numbers:
Implement trading_fee(x_in).
30 basis points.10_000 basis points = 100%.x_in = 1000, fee = 1000 * 30 / 10_000 = 3.A CPMM often needs to track the fee separately from the fee-adjusted input used in the quote formula.