Skip to main content

compute_commission

Function compute_commission 

Source
pub fn compute_commission(
    fee_rate: Decimal,
    fee_exponent: Decimal,
    size: Decimal,
    price: Decimal,
    liquidity_side: LiquiditySide,
) -> Result<Decimal>
Expand 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.

§Errors

Returns an error for negative rates, exponents, or sizes, prices outside [0, 1], or a calculation that cannot be represented.

§References

https://docs.polymarket.com/trading/fees