pub fn compute_commission(
fee_rate: Decimal,
fee_exponent: f64,
size: Decimal,
price: Decimal,
liquidity_side: LiquiditySide,
) -> DecimalExpand description
Computes a pUSD commission using Polymarket’s platform fee formula.
fee = C * feeRate * (p * (1 - p))^exponent, paid only by takers.
The fee is rounded to 5 decimal places.
The fee_rate here is the effective rate from feeSchedule.rate (e.g. 0.03 for
3%), not the fee_rate_bps field on a V2 trade response. The response field is
the post-trade rate that actually applied; under V2 the fee is no longer carried
in the signed order, so we compute commissions from the instrument’s fee schedule
rather than reading any cap off the order body.